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 Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #15 on Tue 08 Apr 2008 09:31 PM (UTC)

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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #16 on Tue 08 Apr 2008 09:34 PM (UTC)
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
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #17 on Tue 08 Apr 2008 09:39 PM (UTC)
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?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #18 on Tue 08 Apr 2008 09:46 PM (UTC)
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
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #19 on Tue 08 Apr 2008 09:50 PM (UTC)

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
Top

Posted by Alkarindil   Brazil  (70 posts)  Bio
Date Reply #20 on Tue 08 Apr 2008 10:09 PM (UTC)
Message
It's working!
Man, I would never think in made all this stuff...
Thanks a lot Nick!
Thanks David! U guys rox!
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.


79,746 views.

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

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.