Remort code question

Posted by Meerclar on Sun 30 Jun 2002 03:25 PM — 5 posts, 22,304 views.

USA #0
This question is rather unusual in that it deals with moving eq across pfiles at remort. We at SB:R are interested in having any items flagged as quest objs "survive" the remort process as an inheritence of sorts and I personally am interested in avoiding a long and painful testing process to even find a way to accomplish this. The suggestion has been made that we could extract the items to a locker for the player but I personally feel it would be easier and safer to simply import them to the new pfile. What I'm looking for is suggestions on syntax for copying the objs from the old pfile and importing them to the new one. Any help would be massively appreciated.

Meerclar,
One of SB:R's overworked coders, but it's a labor of love so it's all good :)

Come visit us at
stormbringer.sytes.net:4500
United Kingdom #1
Look in remort.cpp around line 81 for the comment:
// swap over the connection to the new character

At this point oc represents the 'old character', and ch represents the character which is just about to go thru creation.

5 or so lines of the right code here will achieve what you want, it should selectively copy objects from oc's inventory to ch's inventory with some recursion over the object list carried by oc. Could even look at using obj_from_char() and obj_to_char(). I would suggest that the new character is not wearing any objects during their new creation.

- Kal
Developer of the Dawn of Time Codebase
http://www.dawnoftime.org/
USA #2
We intend to dump the objs into the new chars inventory due to the wildly varying levels of the objs in question. Most of them wouldnt even be particularly useful until much later in life but all are impossible, or nearly enough so, to replace. Many thanks for the advice Kal, figured this would be a good place to hit for suggestions since you make infrequent appearances when I'm able to catch you on SB:R for comment. Guess I'll get started on some design stuff now since we have a few ppl about ready to do the remort thing.

Thanks Kal.
USA #3
well, Ive done some work on this and its kickin my arse so Im gonna see if anyone else has any ideas. Heres what Im trying to add to the existing DoT begin_remort function before switching connection to the new char:

for (t_obj = ch->carrying; t_obj != NULL; t_obj = t_obj_next)
{
t_obj_next = t_obj->next_content;

// if this is a questitem, transfer to new char
if (IS_OBJ_STAT(t_obj,OBJEXTRA2_QUEST))
{
obj_from_char( obj );
obj_to_char( obj, ch );
return;
}
}

if (t_obj == NULL)
{
obj->next_content = ch->carrying;
ch->carrying = obj;
}
else
{
obj->next_content = t_obj->next_content;
t_obj->next_content = obj;
}

and OBJ_DATA *t_obj, *t_obj_next;
is added back up at the top of the file between
char_data *ch and
int stat

The errors at compile are:
remort.cpp:84: type `OBJ_DATA' is not a base type for type `char_data'
remort.cpp:85: type `OBJ_DATA' is not a base type for type `char_data'
remort.cpp: In function `void do_remort(char_data *, char *)':
remort.cpp:29: too few arguments to function `void begin_remort(char_data *, char_data *, OBJ_DATA *)'
remort.cpp:206: at this point in file
gmake: *** [remort.o] Error 1
United Kingdom #4
I didn't get exactly the same errors you had, but putting the source you provided into the dawn code... so I expect you have something else in your source which you aren't aware of.

If you take a clean remort.cpp, and put this in:

for (t_obj = ch->carrying; t_obj; t_obj = t_obj_next)
{
    t_obj_next = t_obj->next_content;   
    // if this is a questitem, transfer to new char
    if (IS_OBJ_STAT(t_obj,OBJEXTRA2_QUEST)) {
        obj_from_char( t_obj );
        obj_to_char( t_obj, ch );
        continue;
    }
}


Add the data types you had from above, that should transfer the the objects you want. There are a few things in the logic which will need testing... e.g. if you have a container with the OBJEXTRA2_QUEST flag set, will it transfer everything it holds (even if they don't have the flag).

Note that you had a return instead of a continue... also you were refering obj in place of t_obj ... e.g. obj_from_char( obj );... unless of course these is some code we didn't see.

Please note I aren't saying this code is perfect, nor comprehensive... I haven't even tested it, but it will get rid of your compile errors.

Good luck,

- Kal