Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
 parse description bug
Yesterday, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Yandex, Exalead, Google

Members: 0
Guests: 2
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Bugfix Lists » SmaugFUSS Bugfix List » [Bug] Hardcoded vnums using n...
Forum Rules | Mark all | Recent Posts

[Bug] Hardcoded vnums using numerical value
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Sep 3, 2006, 11:19 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
JoinedJan 1, 2002

Bug: Hardcoded vnums using numerical value
Danger: Low - Hardcoded vnums should use a definition name instead.
Found by: Kiasyn, Remcon, Conner
Fixed by: Kiasyn, Remcon, Conner

---

mud.h

Locate:
/*
 * Well known mob virtual numbers.
 * Defined in #MOBILES.
 */
#define MOB_VNUM_CITYGUARD	   3060
#define MOB_VNUM_VAMPIRE	   80
#define MOB_VNUM_ANIMATED_CORPSE   5
#define MOB_VNUM_DEITY		   17


Below that, add:
#define MOB_VNUM_SUPERMOB 3


mud_comm.c, do_mpbodybag

Locate:
   if( obj->in_room && !str_cmp( buf2, obj->short_descr ) && ( obj->pIndexData->vnum == 11 ) )


Change to:
   if( obj->in_room && obj->pIndexData->vnum == OBJ_VNUM_CORPSE_PC && !str_cmp( buf2, obj->short_descr ) )


mud_comm.c, do_mppurge

Locate:
   if( IS_NPC( victim ) && victim->pIndexData->vnum == 3 )
   {
      progbug( "Mppurge: trying to purge supermob", ch );
      return;
   }


Change to:
   if( IS_NPC( victim ) && victim->pIndexData->vnum == MOB_VNUM_SUPERMOB )
   {
      progbug( "Mppurge: trying to purge supermob", ch );
      return;
   }


mud_comm.c, do_mp_slay

Locate:
   if( IS_NPC( victim ) && victim->pIndexData->vnum == 3 )
   {
      send_to_char( "You cannot slay supermob!\r\n", ch );
      progbug( "Mpslay: trying to slay supermob", ch );
      return;
   }


Change to:
   if( IS_NPC( victim ) && victim->pIndexData->vnum == MOB_VNUM_SUPERMOB )
   {
      send_to_char( "You cannot slay supermob!\r\n", ch );
      progbug( "Mpslay: trying to slay supermob", ch );
      return;
   }


act_wiz.c, do_bodybag

Locate:
   if( obj->in_room && !str_cmp( buf2, obj->short_descr ) && ( obj->pIndexData->vnum == 11 ) )


Change to:
   if( obj->in_room && obj->pIndexData->vnum == OBJ_VNUM_CORPSE_PC && !str_cmp( buf2, obj->short_descr ) )


handler.c, can_see_obj

Locate:
   if( IS_NPC( ch ) && ch->pIndexData->vnum == 3 )
      return TRUE;


Change to:
   if( IS_NPC( ch ) && ch->pIndexData->vnum == MOB_VNUM_SUPERMOB )
      return TRUE;


handler.c, can_drop_obj

Locate:
   if( IS_NPC( ch ) && ch->pIndexData->vnum == 3 )
      return TRUE;


Change to:
   if( IS_NPC( ch ) && ch->pIndexData->vnum == MOB_VNUM_SUPERMOB )
      return TRUE;


mud_prog.c, init_supermob

Locate:
   supermob = create_mobile( get_mob_index( 3 ) );
   office = get_room_index( 3 );
   char_to_room( supermob, office );


Change to:
   supermob = create_mobile( get_mob_index( MOB_VNUM_SUPERMOB ) );
   office = get_room_index( ROOM_VNUM_POLY );
   char_to_room( supermob, office );


mud_prog.c, release_supermob

Replace the function with:
void release_supermob(  )
{
   char_from_room( supermob );
   char_to_room( supermob, get_room_index( ROOM_VNUM_POLY ) );
}


mud_prog.c, progbug

Locate:
   /*
    * Check if we're dealing with supermob, which means the bug occurred
    * in a room or obj prog.
    */
   if( vnum == 3 )


Change to:
   /*
    * Check if we're dealing with supermob, which means the bug occurred
    * in a room or obj prog.
    */
   if( vnum == MOB_VNUM_SUPERMOB )


mud_prog.c, set_supermob

Locate:
   if( !supermob )
      supermob = create_mobile( get_mob_index( 3 ) );


Change to:
   if( !supermob )
      supermob = create_mobile( get_mob_index( MOB_VNUM_SUPERMOB ) );


player.c, do_remains

Locate:
if( obj->in_room && !str_cmp( buf, obj->short_descr ) && ( obj->pIndexData->vnum == 11 ) )


Change to:
if( obj->in_room && !str_cmp( buf, obj->short_descr ) && ( obj->pIndexData->vnum == OBJ_VNUM_CORPSE_PC ) )


deity.c, do_supplicate

Locate:
if( obj->in_room && !str_cmp( buf2, obj->short_descr ) && ( obj->pIndexData->vnum == 11 ) )


Change to:
if( obj->in_room && !str_cmp( buf2, obj->short_descr ) && ( obj->pIndexData->vnum == OBJ_VNUM_CORPSE_PC ) )


Hard numerical vnums are not usuall a huge problem. But if someone removed the areas these vnums are in and the code can no longer find them, things usually go bad in a hurry. Changing them all to definition names allows them to be reset cleanly in mud.h so that one does not need to hunt down a bunch of hard references.
       
Pages:<< prev 1 next >>