[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Showing object's vNum

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Showing object's vNum
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Alkarindil   Brazil  (70 posts)  [Biography] bio
Date Tue 08 Apr 2008 10:09 PM (UTC)  quote  ]
Message
It's working!
Man, I would never think in made all this stuff...
Thanks a lot Nick!
Thanks David! U guys rox!
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 08 Apr 2008 09:50 PM (UTC)  quote  ]

Amended on Tue 08 Apr 2008 09:52 PM (UTC) by Nick Gammon

Message
Try making my suggested changes now.

By the way, I agree with the earlier posters that it is much more helpful to say in what way it doesn't work, rather than to say "I had no success".

There are a few major ways things "don't work":


  • It doesn't compile. In which case copy and paste the error message from the compiler.

  • It crashes when it runs. In which case copy and paste the error message from the crash, and describe what you did to cause it. Preferably use gdb to examine the crash, and do a "bt" (backtrace) to see exactly what happened leading up to the crash.

  • It seems to do nothing at all - that is, it runs but does the same thing as before. Perhaps you didn't reboot the server? Or you changed completely the wrong place?

  • It makes a difference, but the difference is wrong. In which case copy and paste the output you got, and explain in what way it is wrong. For example, it might show the incorrect vnum.



More detailed information saves a lot of time as we go to and fro trying to extract from you something which is in front of you on the screen. For example:

Quote:

Do nothing, it crashes.


That is not doing nothing, that is crashing. You need to be specific.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 08 Apr 2008 09:46 PM (UTC)  quote  ]
Message
Well, what I was trying to get at is that the obj pointer was probably null, and for you to find that information in the debugger because it will save you a very large amount of time in the future. But Nick provided the solution, so you can probably use that and make sure that it works for you. :-)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Alkarindil   Brazil  (70 posts)  [Biography] bio
Date Tue 08 Apr 2008 09:39 PM (UTC)  quote  ]
Message
Ow yes yes! My mistake, sorry!



Loaded 'ntdll.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winmm.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\secur32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wsock32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2_32.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\ws2help.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mswsock.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\dnsapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\winrnr.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wldap32.dll', no matching symbolic information found.
Loaded 'C:\Arquivos de programas\Bonjour\mdnsNSP.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\iphlpapi.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\hnetcfg.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\wshtcpip.dll', no matching symbolic information found.
First-chance exception in smaug.exe: 0xC0000005: Access Violation.
The program 'C:\Documents and Settings\alkarindil\Desktop\Smaug\smaug.exe' has exited with code 0 (0x0).



Is that info you need?
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 08 Apr 2008 09:34 PM (UTC)  quote  ]
Message
Example output:


You are carrying:
     a bone sword [9828]

...

A large marble fountain gushes forth here. [10401]

...

The corpse of the bone naga lies here. (2) [10]
A pool of spilled blood lies here. (4) [17]
The corpse of a carrion crawler lies here. (2) [10]
Still twitching as if to kick you, the leg of a carrion crawler lies here. [15]

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 08 Apr 2008 09:31 PM (UTC)  quote  ]

Amended on Tue 08 Apr 2008 09:53 PM (UTC) by Nick Gammon

Message
You need to look at the code to see what is happening.

You did this:


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


However the place you did it was at the end of the loop which looked at all objects, so obj will be null and it will crash with a null dereference.

If you examine the code you will see that s/he allocates some temporary variables (prgpstrShow, prgnShow, pitShow, pstrShow) which are used to hold the object's information (and group like objects). This is what is being displayed at display time. To display the vnum you need to allocate another item (I called it pvnumShow) and move the vnum into it. Here is the diff of my amendments:


*** act_info.c_orig	2008-04-09 07:14:44.000000000 +1000
--- act_info.c	2008-04-09 07:25:03.000000000 +1000
***************
*** 473,478 ****
--- 473,479 ----
     char **prgpstrShow;
     int *prgnShow;
     int *pitShow;
+    int *pvnumShow;
     char *pstrShow;
     OBJ_DATA *obj;
     int nShow;
***************
*** 537,542 ****
--- 538,544 ----
     CREATE( prgpstrShow, char *, count + ( ( offcount > 0 ) ? offcount : 0 ) );
     CREATE( prgnShow, int, count + ( ( offcount > 0 ) ? offcount : 0 ) );
     CREATE( pitShow, int, count + ( ( offcount > 0 ) ? offcount : 0 ) );
+    CREATE( pvnumShow, int, count + ( ( offcount > 0 ) ? offcount : 0 ) );
     nShow = 0;
     tmp = ( offcount > 0 ) ? offcount : 0;
     cnt = 0;
***************
*** 553,558 ****
--- 555,561 ----
           prgpstrShow[nShow] = str_dup( hallucinated_object( ms, fShort ) );
           prgnShow[nShow] = 1;
           pitShow[nShow] = number_range( ITEM_LIGHT, ITEM_BOOK );
+          pvnumShow[nShow] = number_range( 1, 500000 );
           nShow++;
           --tmp;
        }
***************
*** 560,565 ****
--- 563,569 ----
            && can_see_obj( ch, obj ) && ( obj->item_type != ITEM_TRAP || IS_AFFECTED( ch, AFF_DETECTTRAPS ) ) )
        {
           pstrShow = format_obj_to_char( obj, ch, fShort );
+          pvnumShow[nShow] = obj->pIndexData->vnum;
           fCombine = FALSE;
  
           if( IS_NPC( ch ) || xIS_SET( ch->act, PLR_COMBINE ) )
***************
*** 599,604 ****
--- 603,609 ----
           prgpstrShow[nShow] = str_dup( hallucinated_object( ms, fShort ) );
           prgnShow[nShow] = 1;
           pitShow[nShow] = number_range( ITEM_LIGHT, ITEM_BOOK );
+          pvnumShow[nShow] = number_range( 1, 500000 );
           nShow++;
        }
     }
***************
*** 646,651 ****
--- 651,657 ----
              ch_printf( ch, " (%d)", prgnShow[iShow] );
        }
  
+       ch_printf( ch, " [%d]", pvnumShow[iShow] );
        send_to_char( "\r\n", ch );
        DISPOSE( prgpstrShow[iShow] );
     }
***************
*** 664,669 ****
--- 670,676 ----
     DISPOSE( prgpstrShow );
     DISPOSE( prgnShow );
     DISPOSE( pitShow );
+    DISPOSE( pvnumShow );
     return;
  }


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 08 Apr 2008 09:24 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Zeno   USA  (2,867 posts)  [Biography] bio   Moderator
Date Tue 08 Apr 2008 09:23 PM (UTC)  quote  ]
Message
Use the debugger when it crashes.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Alkarindil   Brazil  (70 posts)  [Biography] bio
Date Tue 08 Apr 2008 09:06 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 08 Apr 2008 09:00 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Alkarindil   Brazil  (70 posts)  [Biography] bio
Date Tue 08 Apr 2008 08:52 PM (UTC)  quote  ]
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.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 08 Apr 2008 08:44 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Alkarindil   Brazil  (70 posts)  [Biography] bio
Date Tue 08 Apr 2008 08:43 PM (UTC)  quote  ]
Message
Do nothing, it crashes.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Tue 08 Apr 2008 08:33 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Alkarindil   Brazil  (70 posts)  [Biography] bio
Date Tue 08 Apr 2008 08:18 PM (UTC)  quote  ]

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...
[Go to top] 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.


4,933 views.

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

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]