I don't know about you, but when I'm working on my mud I'm recompiling it
all the time!

But I've never had to recompile to add vnums.

#define MAX_ROOMS 1500000
See, my highest actual vnum is 1234531.  Not worried about it, at this time.


> 
> -----Original Message-----
> From: Chad Simmons [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 22, 2003 2:34 AM
> To: Jason Gauthier
> Cc: [email protected]
> 
> > It was a large task, but well worth it.
> > I created some globals:
> > 
> > extern ROOM_INDEX_DATA *pRoomArray[MAX_ROOMS]; ROOM_INDEX_DATA 
> > *pRoomArray[MAX_ROOMS];
> 
> 
> Erm, but then you'd have to recompile every time you needed 
> more VNUMS.
> 
> 
> > extern PROG_CODE *pRprogArray[MAX_MOB_PROGS]; PROG_CODE 
> > *pRprogArray[MAX_MOB_PROGS];
> > 
> > In all of the loading functions I've added code like this:
> > (in load_rooms)
> > pRoomArray[vnum]=pRoomIndex;
> > 
> > taking out this stuff:
> >         iHash                   = vnum % MAX_KEY_HASH;
> >         pRoomIndex->next        = room_index_hash[iHash];
> >         room_index_hash[iHash]  = pRoomIndex;
> > 
> > Then change get_room_index to something like this:
> > 
> > ROOM_INDEX_DATA *get_room_index( int vnum ) {
> >     return pRoomArray[vnum];
> > }
> 
> While it's true that the hash lookups add a bit of overhead 
> to the search by vnum operation over a standard array, it 
> does allow for gaps in the vnums without causing any memory loss.
> 
> My suggestion (rather than going to a straight array) would 
> have been to simply increase MAX_KEY_HASH. This would have 
> decreased the number of collisions without making it a static array. 
> 
> If you wanted to use an array (because you've researched it 
> and found that the memory lost to gaps in the vnums would be 
> negligable), you should at the very least use a dynamic 
> array. Read in the max vnum from a value in your area files, 
> then alloc_perm an array with that many elements. That will 
> save you from recompliling each time you need more vnums.
> 
> Just some suggestions,
> 
> ~Kender
> 
> =====
> -----BEGIN GEEK CODE BLOCK-----
> Version 3.1
> GCS/L/C/O d-(+) s++: a-- C+++$>++++ UBLS++++$ 
> P+++(--)$ L+++>++++ E--- W+>++$ N !o K? w(--) !O
> M- !V PS+ PE(++) Y+ PGP->+ t+ 5 X+() R(+) tv+@ 
> b++(+++) !DI+++ D G(-) e>+++$ h---() r+++ y+++
> ------END GEEK CODE BLOCK------
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design 
> software http://sitebuilder.yahoo.com
> 

Reply via email to