Re: [Code] save_char(ch, ch->in_room);

From: Patrick J. Dughi (dughi@IMAXX.NET)
Date: 04/20/98


> > changing the save_char(ch, NOWHERE) functions will allow characters to
> > "load up" in the room they quit in, but this doesn't stop a character from
> > quiting then entering the game right away to have the same effect as the
> > recall spell.  For the the save_char(ch, ch->in_room) to work the character
> > must quit the mud entirely. I've tried setting the setting the bit on the
> > Load_room and setting the load_room to that ch->in_room, but nothing has
> > seemed to work.
>
> that probably did it. As soon as someone camps or quits, they are saved
> in that room so even if they re-enter the game right away, they reload in
> the room that they camped in.

        Its a bit more complicated to changing just the save_char to that
bit. Realize that in many cases, when you'd like to save the status of a
character, they're in room 'nowhere', having been extracted already (after
being killed for example)...

        For example, when a character hits a DT, they are extracted - make
sure that you have the following code in place before they are:

      GET_LOADROOM(ch)=NOWHERE;
      save_char(ch,world[NOWHERE].number);

..
   in my do_quit function, I have something along this line..

     if(!IS_SET(PLR_FLAGS(ch),PLR_LOADROOM)) {
       GET_LOADROOM(ch)=world[ch->in_room].number;
       save_room=GET_LOADROOM(ch);
     } else {
       save_room=GET_LOADROOM(ch);
     }
     save_char(ch, save_room );
..
   right below the do_quit, we have do_save... ive got this in there..
  if(!IS_SET(PLR_FLAGS(player),PLR_LOADROOM)) {
    GET_LOADROOM(player)=world[player->in_room].number;
    save_char(player, world[player->in_room ].number );
  }
  else {
    save_char(player, world[ player->in_room ].number );
  }
..
  in handler.c under extract char, i just let the loadroom do its work:
    save_char(ch, world[ real_room(GET_LOADROOM(ch)) ].number );
..
  as a matter of fact, I use that same line each time I want to save the
status of a person in the multiple con_states within interpreter.c..about
five times by my count..
..
  then, in limits.c, where they idle out and are pulled into a void:
      save_char(ch, world[ GET_WAS_IN(ch) ].number );
..
  What happens then, is that each time the player quits, is disconnected,
etc, the player is saved in that room. no instant recalls nothing.. if the
loadroom flag is set, then the loadroom is never written over, but
otherwise, its updated when the character is saved or extracted.  Worse
case, you set loadroom to NOWHERE, and they'll load up in the start room,
but of course, that should only happen if you have a new character (init
it to NOWHERE), if you die or hit a dt, or some other unforseen oversight.


        This was _I_ think, more than adequately discussed on the previous
posts, and as long as you can use 'grep' or an advanced find function, you
shouldn't have any problem with it.

                                                PjD


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