Re: VId: Changing of the VNums

From: Chris Jacobson (fear@technologist.com)
Date: 04/04/99


On 4/4/99 10:22 PM, Del Minturn (caminturn@earthlink.net) stated:

>The only problem I see with this, is you would have to add code to check
>all the zones for specific items/mobs/rooms instead of just one list.
>Not sure if I would like the idea of two or more items with the same
>number (granted it would have a different zone qualifier)
>Simplex 1
>Midgaard 1
>Thalos 1
>here is a problem, when you have two zones similar names
>what will separate them?
>oldthalos 1?
>
>The more I think about it.. the more I dislike the idea.
>Sorry.

Actually with my system (LexiMUD) I wouldn't have a problem - I use a
map<VNum, *> class (actually a custom written one) that stores everything
in an AVL tree (sorta like a Red/Black).  Thus:

class VId {
public:
     string    zone;
     UInt16    number;         //   Note: I use sign- and size-qualified
types

     bool operator <(const VId v);
     ...
};

bool VId::operator<(const VId v) {
     //   If VId::zone is a char *, use str_cmp
     if (zone < v.zone || (zone == v.zone && number < v.number))  return
true;
     //   zone == v.zone
     return false;  //   zone == v.zone && number >= v.number, or zone >
v.zone
}

Finally, if you want some speedup, instead of string zone, use an index
into the zone list.

- Chris Jacobson


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/15/00 PST