Re: [LONG] saving object instances

From: Patrick Dughi (dughi@imaxx.net)
Date: 07/24/00


> Okay, Scenario 1: I load an object using load obj 300 lets say.  And it's a
> sword, great.  Now, I type in:
>
>  restring obj sword short a HUGE sword.
>
> Okay, I check my inventory and sure enough, instead of seeing "a sword"
> like I saw originally, I see "a HUGE sword."  Perfect eh? =(  Not so...
>
> Scenario 2: I create another sword after restringing the first.  Instead of
> the message "you create a sword" like I am expecting, I get "you create a
> HUGE sword."  Well, not good at all.  From this I deduce that perhaps the
> restring function is changing a template of the object instead of
> the "instance" of it?
>

        The problem is pretty simple actually.  Individual instantiations
of objects do not have unique strings.  Instead, they just have a pointer
pointing at the original string.  You seem to be freeing and reallocating
that correctly, but that's not what you want to do.  You want to simply
reallocate without freeing.

        You do run into a problem here though; if you restring a restrung
object, you _will_ want to free the string.  Just verify that the template
for the string you're checking is the same or not, and free based on that.

                                                PjD


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html  |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 04/10/01 PDT