Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shop listings



>  As the list of what is in the shop is built, it would seem to need
> to be attached to the player structure (if a static declaration inside
> the function was used, and someone somewhere else got a shop inventory,
> it would clobber the data.)  Does a variable in the player structure exit
> (exist) for this purpose, or do I need to add a new one (no big deal if
> I do)

No...and the player structure is already hopelessly messed up, another
variable won't make much difference... 8)

By the way, have a look at the recursive version (which is default now)
of the magic-mapping spell, which is able to confine its recursive
iterations within one room.

>  Second, it would seem best to copy the objects into the new list (and
> at the same time, merge objects, if possible).  It looks like there
> are some functions in object.c (libcross) that will do this, yet
> there are parts of them which are unclear (like what Enviroment is, and
> what it should be set to).  Does any good documentaion exist for
> libcross?  It would seem like the code I need to do will
> be something like:
> 
> 	copy_object(new_obj, shop_obj);
> 	if (!merge_ob(new_obj, list))
> 		insert_ob_in_ob(new_obj, list);
>  Where list is the list starting in the player structure.  Is
> this more or less correct?

Yes, but the result would be a lot of allocated objects...which wouldn't
be automatically freed in any way.

If list is the "menu" object, ie a sign within the shop, it can be used to
accumulate copies of all objects in the store when it is first applied,
at least temporarily.  If you don't free the objects, they will at least
be freed when the map is swapped out.  The syntax is will be something like:

  object *tmp = get_object();
  copy_object(shop_obj, tmp);
  insert_ob_in_ob(tmp, list);

Merging will be done automatically.

Hmm, you're defenitely right in that the library lacks documentation...

-Frank.