Re: [Dev-C++] 'extern const' and std::vector
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-05-01 18:12:53
|
It still sounds like an object-oriented construct would work.
Make all data protected.
Add a lot of nice access functions.
Create one function that returns a const room entry. Any user of the room
may then only call const methods.
Give the administrators some way of retrieving a non-const room entry.
class Room;
class xx {
public:
const Room& GetRoom(RoomId& id);
Room& GetRoom(RoomId& id,const char *admin_password);
};
However, I still don't think that you need access to a room in constant
time. Logaritmic time would probably produce the reference to the room in
a fraction of the time that the work code need to perform actions on the
room - presenting contents of room, check for monsters or other players in
the room, ...
There are a number of disadvantages to using a vector, unless the data is
absolutely static. It takes a lot of time O(n) to insert a new entry in
the middle. If new entries are not inserted last, all existing indices -
and probably also pointers to them - will be invalidated.
/Per W
On Thu, 1 May 2003, David McKen wrote:
> Random access is essential!!!!
>
> We are storing them sequentially and the system for access
> uses the fact
> that room #3001 is located just after room #3000 (helps
> with speed).
> Concerning the comment that this is a bad design. This
> vector is what needs
> to be global. Only ceartain players (the admins) have the
> ability to
> directly edit this room data (this will also be
> controlled). No matter what
> part of the MMORPG is being used it will need access to
> this information
> (only some basic information commands don't).
>
> ----- Original Message -----
> From: "Ioannis Vranos" <iv...@at...>
> To: "Dev-C++ Mailing List"
> <dev...@li...>
> Sent: Thursday, May 01, 2003 1:27 PM
> Subject: RE: [Dev-C++] 'extern const' and std::vector
>
>
> > > -----Original Message-----
> > > From: Per Westermark [mailto:pw...@ia...]
> > > Sent: Thursday, May 01, 2003 8:23 PM
> > > To: Ioannis Vranos
> > > Cc: dev...@li...
> > > Subject: RE: [Dev-C++] 'extern const' and std::vector
> > >
> > >
> > > I assume MMORPG is Massive Multiplayer Online
> Role-Playing Game.
> > >
> > > If the game isn't too boring, I'm also assuming that
> you don't walk
> > > through the rooms in a sequential order.
> > >
> > > If you need random access, I would really go for a tree
> > > construct. Each
> > > node might point zero more alternative rooms, while you
> would still be
> > > able to locate a room in O(log n) time.
> > >
> > > If the tree for some reason gets too large to keep in
> memory, it might
> > > easily be placed partially on disk.
> >
> >
> >
> > I do not know much about trees but how can one have
> random access in a
> tree?
> > Trees involve sequential comparisons, don't they?
> >
> >
> >
> >
> > Ioannis Vranos
> >
> > * Programming pages: http://www.noicys.freeurl.com
> > * Alternative URL 1: http://run.to/noicys
> > * Alternative URL 2: http://www.noicys.cjb.net
> >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Search - Faster. Easier. Bingo.
> http://search.yahoo.com
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|