RE: [Dev-C++] 'extern const' and std::vector
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@at...> - 2003-05-02 03:32:52
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of David McKen > Sent: Thursday, May 01, 2003 10:09 PM > To: dev...@li... > Subject: Re: [Dev-C++] 'extern const' and std::vector >=20 >=20 > The rooms are not nesesarily accessed in sequential order. > One very used > command (at least by admins) is the goto command. Syntax: > goto <vnum or > player>. This can cause an admin in room #300 to need > access to room #50000. > Also ceartain other command allow ordinary players to make > different jumps > to rooms that are not in sequential order. >=20 > The assiging of rooms to the admins in charge of building > makes it very > likely that the rooms adjacent to the current room are > going to be within > that range (+ or -100) therefore with some exceptions > (which are not that > rare) moving from one room to another involves moving up or > down a few > vnums. As Per Westermark said a map seems to be more suitable than vector since = you are going to add things in the middle and you want random access. Or a multimap I would say if every room is beside in more than one rooms. >=20 > Hmm, I understand about the making the global variable a > class and actually > that was my other question. (I guarantee you if it dosen't > have to e global > I don't want it to be global, that only increases the > number of validity > checks I have to make, eww) >=20 > Each client is going to be in their own thread. For the > reading functions > this should prove no problem (two threads reading the same > variable doesn't > cause any problems? Right?) The writing functions (only > avalible to admins) > are what will require locking down (Mutex, Critical > Section, etc.). Yes you need a locking mechanism (although I do not know much about = threads yet). =20 > One of my original thoughts was to create a vector of > pointers to each room > structure. Thereby allowing random room access and also > allowing the > numbering system to remain intact. >=20 > if the vector currently only has rooms 1-100 filled in and > an admin request > to goto room #150 to start creating a new area then the > rooms in between 100 > and 150 will be NULL pointers that can be checked for, Or in the case of a map only the existing rooms will exist and when accessing a non-existent room, 0 is returned (if suitable for the type, which is suitable for pointers). > if > an admin request a > room the does not exist then a template room is created for > the admin to > edit to their liking. This has the obvious disadvantage in > that if an admin > request room #999999 and the vector only has the rooms up > to #1000 there > will be alot of NULL pointers wasting memory.=20 Yes, so map is perfect, it will not create 0-value pointers (NULL is = better for C, 0 is better for C++ regarding pointers). >Given the way > that these > numbers are assigned this should not be a problem (with the > exception of the > top admins who can load and save any area) most admins are > forced to remain > within their assigned range. >=20 > Any thoughts on this will be appreciated. As Per said: use map (or multimap if it fits you better). > BTW we have a project on sourceforge 'SinstradMUD'. > The current codebase is in the cvs repository in the /src > directory. > The (extremly alpha, still deciding what library to use) > code for the new > codebase is in the Sinstrad2 directory For what OS is it going to be? Ioannis Vranos =20 * Programming pages: http://www.noicys.freeurl.com * Alternative URL 1: http://run.to/noicys * Alternative URL 2: http://www.noicys.cjb.net |