Re: Poll for information

From: Mysidia (
Date: 08/21/01

On Mon, 20 Aug 2001, George Greer wrote:

IMO, look to the smaug codebase for guidance on this one.. group
objects that are exactly the same (except containers that have
stuff in them) into one structure and have a count item.
For one it saves memory and makes for nicer, readable output..
it's also nice for things such as 'show rent' -- people tend to
bag lots of small items like bread so they can have that midnight

I guess due to the way circle implements renting though, you have
to split them back off before saving to disk (or change the object
save method)

In the smaug codebase, obj_to_* functions automatically call a routine
called 'group object' and they return the pointer (the pointer given
to obj_to_* isn't necessarily valid after the call)

so instead of  obj_to_room(obj, room);
you have  obj = obj_to_room(obj, room);

obj_from_x or extract_obj take and/or destroy the entire object structure
with count unaffected, so to pull one object you separate it with
either  separate_obj(obj); or split_obj(obj, <number to remove>);
-- separating creates a 'clone' in the list with the count that
of the original less the number you're splitting off [separate
means 'split off just 1']

Obviously you have special casing for locating an object with
dot-notation, instead of simple comparison and single increment,
you have to compare with the 'count' range and increase by count

And when you make an edit to a single object you indeed you have to
split it off on what you describe as a copy-on-write-principle,
make the change, and then look for another object that might
be the same as it after the alteration

I've made these very alterations to a circle-based mud before, so
it is indeed possible.. the only thing that gave me problems
at first was a certain set of routines in shop.c...

in patricular, sort_keeper_objs  and slide_objs  had to be
uh... revamped, but then I was effecting other major changes to the linked
lists other than grouping.. like having a 'last_content'  pointer as well
as a 'first_content' pointer on object/room/mob lists, that way a
traversal could start at the end and step back easily

I say 'grouping', but really 'combined output', 'stacking', 'sorting',
it's all the same <chuckle>


   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/06/01 PST