[Code][Contrib] Quit / Room Saves

From: Lord Kyu (Sythrel@Adelphia.net)
Date: 10/15/00


   I have seen a ton of questions about how to get players to save where
they
had quit the game, and have read tons of solutions.  After some time
looking
at this and playing around with the code, I decided it might be
beneficial to
some implementors to make a quick little step by step guide to follow
showing
exactly how to get such a thing to work.  Note, none of the credit goes
to me
due to this being other coders work from the CircleMUD mailing list,
which I
grabbed code and ideas from, piecing them together.  This was tested on
patch
level 17, and everything seems fine.  If anyone sees any problems with
this,
please let me know.

   This code saves the room a character quit from, and will load them
back to
the room regardless if they quit to the menu and entered, or completely
quit,
unless that character has a pre assigned starting room (PLR_LOADROOM).

[Begin Instructions]

// in act.other.c (do_quit function)

      die(ch);
    } else {
      int loadroom = ch->in_room;
+     int value = world[IN_ROOM(ch)].number;
+     if (!PLR_FLAGGED(ch, PLR_LOADROOM)) {
+       GET_LOADROOM(ch) = value;
+     }

      /*
       * kill off all sockets connected to the same player as the one
who is

// in act.other.c (do_quit function)

      extract_char(ch);               /* Char is saved in extract char
*/

-     /* If someone is quitting in their house, let them load back here
*/
-     if (ROOM_FLAGGED(loadroom, ROOM_HOUSE))
+     /* If someone is quitting, let them load back here */
+     if (!PLR_FLAGGED(ch, PLR_LOADROOM))
        save_char(ch, loadroom);
    }

// in fight.c (death_cry function)

  void death_cry(struct char_data * ch)
  {
  int door;

+ if (!IS_NPC(ch) || !PLR_FLAGGED(ch, PLR_LOADROOM))
+   GET_LOADROOM(ch) = NOWHERE;

[End Instructions - Begin Kyu's Ending Statement]

   Simple enough, though you might wish to add some other checks in
later. I
have yet to need anything else, but then, my rent is disabled, and
saving the
characters room everytime they use save is a bit redundant to me. Also,
you
may wish to have it remove the loadroom if a player is purged.

[End Kyu's Ending Statement]

--

«¥» Lord Kyu «¥»


     +------------------------------------------------------------+
     | 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