Re: Objects in Objects

From: Gary Barnett (gbarnett@POLARNET.COM)
Date: 10/10/97


On Friday, October 10, 1997 12:48 AM, Soren P. Skou [SMTP:serces@MUD.DK]
wrote:
> Hi all..
>

<snip>

>
> I've tried tracking down the error. But it doesn't seem like there is
> anything wrong. 'Cept maybe, I took a good look at the Rentfiles, and
> what location the different EQ's was saved at. And as far as I can
> see, then Objects saved from Inventory has Location 0, regardless of
> if they are in another object or not. Dunno, maybe I'm reading the
> code wrong or something, but I've got the impression that EQ coming
> from a bag, will have a negative number, corresponding to the
> container they are in, or am I totally looney here????
>

Why not just write an ascii based object save/load routine?

Here's how I did it.

Objects in Inventory are at level 0

Objects in a bag are at successively increasing numbers based on how
many bags deep you are currently processing.

Use a routine to scan inventory, saving each obj. When a bag is encountered,
save it, then increment the count var and start looking in the bag. When you
are done with the bag's contents, decrement the counter var and continue
with the inventory scan. Repeat this process for worn equipment and put
a marker in the file so you know when inventory stops and eq begins.

If you save the object flags, the values, weight and text strings (if
different
from the prototype) you will have a pretty good system to handle your
rent files.

Loading is even easier. Just keep an array of object pointers to store the
bags at each level. WHen you increment the counter var you store a new
object in the array. When you decrement it, you take the new highest object
and start using it as the new 'container' for loaded objects.

It's also portable to just about any system. No binary files to worry about.

--Mallory

Example:

Inventory

 0 bread
 0 barrel
 0 bag
 1     wand
 1     staff
 1     bag
 2        cookie
 2        flask


I can picture in my mind a world without war, a world without hate.
And I can picture us attacking that world, because they'd never
expect it.     - Jack Handey


     +------------------------------------------------------------+
     | 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/08/00 PST