| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| 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 |
|