Greetings,
Brandon Lees wrote:
> I want 2 change do_look so that if there is more than one of an item
> it will be listed as <2x> a sword instead of being listed twice. Any
> suggestions on how to go about doing this?
>
I'd say there're about three possibilities:
a) treat items as a linked lists, and 'add' a new entry when objects
get into the same room/inventory/container/whatever. And then simply
add the name once, and count the members.
b) if you feel like pointer juggling: add a counter variable to your
objects and do some dynamic memory wizardry. (thats btw how the
RoM handles it. Now before I hear cries of 'memory fragmentation':
we will also (shortly) use a memory pool class for that matter
which will reduce that problem together with our overloaded
versions of operator new and operator delete ;) ). In short:
when an items gets into the same room/inv/cont, free it,
and increase the counter of the already existing one. This
method saves memory, BUT is cruel in memory fragmentation
(if you don't implement your own memory management that is...),
rather 'unsafe' (read: bugprone) and has some runtime overhead
(all the browsing through lists, etc.). However, we at the RoM
consider memory more valuable than runtime.
However: a *GOOD* understanding of ptrs is needed for this.
c) hmm...if you don't feel like being creative yourself: I believe
there's a code patch somewhere.
- Chris
--
/----------------------------------------------------------------------------\
| Christian Loth, chris@rom.mud.de | REALM OF MAGIC |
| http://rom.mud.de/~chris | telnet rom.mud.de 4000 |
| | http://rom.mud.de/ |
\----------------------------------------------------------------------------/
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/15/00 PST