Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Showing object's vNum

Showing object's vNum

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Tue 08 Apr 2008 05:28 PM (UTC)
Message
Hi! Some time ago I had changed my do_look code to display the vnum of the room to immortals with a very simple modification:

if( IS_IMMORTAL(ch))
pager_printf(ch, " (%d)",ch->in_room->vnum);

I am trying to do the same with the listed objects when using the look command, but with many trials, I have no success in this matter.

Is there any easy way to make this work?
Any suggestions?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Tue 08 Apr 2008 06:18 PM (UTC)
Message
Why doesn't basically the same thing work? What have you tried so far, and how has it failed?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #2 on Tue 08 Apr 2008 06:52 PM (UTC)
Message
I tryied to show vnum in the show_list_to_char() function.
But I am not understanding how the hell I can find the vnum.
I realise there is a for, and it prints the content of an array with the objects in the room. In the end we can find the breakline after the name of the object.
I also find out that the line that write the object's name is:

send_to_char( prgpstrShow[iShow], ch );

But is there any way of extract the vnum using this information?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Tue 08 Apr 2008 06:58 PM (UTC)
Message
The vnum is located in the object's prototype. So you want something like obj->prototype->vnum, although it might not actually be called "prototype".

If the function you're looking at is building things up one line at a time, putting them into an array, then you need to find where it prints out the name after which you want to put the vnum.

But no, you can't extract the vnum from the generated strings. You need to find the place where the object pointer is.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #4 on Tue 08 Apr 2008 08:05 PM (UTC)
Message
Ok, now I am trying something like

pager_printf(ch, " (%d)", obj->pIndexData->vnum);

Does not work.
What does pIndexData means?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #5 on Tue 08 Apr 2008 08:09 PM (UTC)
Message
Ah, yes, it's pIndexData, not prototype. That is indeed the prototype for the object. What do you mean by "does not work"? What is it doing, or not doing?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #6 on Tue 08 Apr 2008 08:18 PM (UTC)

Amended on Tue 08 Apr 2008 08:25 PM (UTC) by Alkarindil

Message
Okay, I downloaded the code from gammon's site, so this show_list_to_char() function in act_info.c is the same thing; I never touched it before.

in the end of this function are this lines:

send_to_char( prgpstrShow[iShow], ch );
//Print the object's name
pager_printf(ch, " (%d)", obj->pIndexData->vnum);
//My line
/*if ( IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE) ) */
	{
	    if ( prgnShow[iShow] != 1 )
		ch_printf( ch, " (%d)", prgnShow[iShow] );
	}
	send_to_char( "\n\r", ch );
	DISPOSE( prgpstrShow[iShow] );
    }

    if ( fShowNothing && nShow == 0 )
    {
	if ( IS_NPC(ch) || xIS_SET(ch->act, PLR_COMBINE) )
	    send_to_char( "     ", ch );
	set_char_color( AT_OBJECT, ch );
	send_to_char( "Nada.\n\r", ch );
    }

    /*
     * Clean up.
     */
    DISPOSE( prgpstrShow );
    DISPOSE( prgnShow	 );
    DISPOSE( pitShow	 );
    return;
}


Well, it must work for any player, but that's easy to change...
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Tue 08 Apr 2008 08:33 PM (UTC)
Message
Quote:
What do you mean by "does not work"? What is it doing, or not doing?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #8 on Tue 08 Apr 2008 08:43 PM (UTC)
Message
Do nothing, it crashes.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #9 on Tue 08 Apr 2008 08:44 PM (UTC)
Message
Could you give the output from gdb? Nick wrote an excellent guide here:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #10 on Tue 08 Apr 2008 08:52 PM (UTC)
Message
I am using Windows with Visual Studio: it's my computer at work.
I couldn't get this kind of debbuging to work here, I am just a "low-level" programmer.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #11 on Tue 08 Apr 2008 09:00 PM (UTC)
Message
If you have Visual Studio, you can use its debugger too. Just show the point at which the crash occurs; perhaps the 'obj' pointer is null?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #12 on Tue 08 Apr 2008 09:06 PM (UTC)
Message
This is the problem, there are no errors during the compilation! It crashes when I log in with any player and "see" the room.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #13 on Tue 08 Apr 2008 09:23 PM (UTC)
Message
Use the debugger when it crashes.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #14 on Tue 08 Apr 2008 09:24 PM (UTC)
Message
That's why I asked for the debugger output, not the compiler output. :-)

I'd suggest googling for Visual Studio Debugger tutorials. The only one I know of off-hand is:
http://www.stanford.edu/class/cs106b/handouts/HO07P.pdf
I don't know how helpful it will be, though.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


60,151 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.