Re: [Newbie] [CODE] [LONG] Room Saves

From: Lord Kyu (shapeshifter@TKA.COM)
Date: 05/20/98

> I added this to do_quit, but it didn't work. The mortals started at the
> mortal_start_room and the immortals at the immortal_start_room. I then
> added the GET_LOADROOM(ch) function. Now, it looks like this:
> if (free_rent) {
>   Crash_rent(blah blah.....
>   save_char(ch, save_room);
>   GET_LOADROOM(ch) = save_room;
> }
> But it doesn't seem to work anyways. Should the save_char(ch, save_room)
> come on the very first line under if (free_rent) with Crash_rent under

        This is my do quit, it seems to work okay, though there is a small bug
with it. A player has to quit out complete for it to save the room. Meaning
if the person types "quit" then "1" they will start in the room they last
quit out in, and if there isn't one they load into the mortal start room
(if mortal) and into the immortal start room (if immortal).

  void die(struct char_data * ch);
  void Crash_rentsave(struct char_data * ch, int cost);
  extern int free_rent;
  sh_int save_room;
  struct descriptor_data *d, *next_d;

  if (IS_NPC(ch) || !ch->desc)

  if (subcmd != SCMD_QUIT && GET_LEVEL(ch) < LVL_IMMORT)
    send_to_char("You have to type quit--no less, to quit!\r\n", ch);
  else if (GET_POS(ch) == POS_SLEEPING)
    send_to_char("You can't quit while sleeping.\r\n", ch);
  else if (GET_POS(ch) == POS_FIGHTING)
    send_to_char("No way!  You're fighting for your life!\r\n", ch);
  else if (GET_POS(ch) < POS_STUNNED) {
    send_to_char("You die before your time...\r\n", ch);
  } else {
    if (!GET_INVIS_LEV(ch))
      act("$n has left the game.", TRUE, ch, 0, 0, TO_ROOM);
    sprintf(buf, "%s has quit the game.", GET_NAME(ch));
    mudlog(buf, NRM, MAX(LVL_IMMORT, GET_INVIS_LEV(ch)), TRUE);
    send_to_char("Goodbye, friend.. Come back soon!\r\n", ch);

     * kill off all sockets connected to the same player as the one who is
     * trying to quit.  Helps to maintain sanity as well as prevent duping.
    for (d = descriptor_list; d; d = next_d) {
      next_d = d->next;
      if (d == ch->desc)
      if (d->character && (GET_IDNUM(d->character) == GET_IDNUM(ch)))

   save_room = ch->in_room;
   if (free_rent)
      write_aliases(ch);     /* If your alias' dont save you will want to
remove this */
      Crash_rentsave(ch, 0);
      save_char(ch, save_room);
    extract_char(ch);           /* Char is saved in extract char */

    /* If someone is quitting in their house, let them load back here */
    if (ROOM_FLAGGED(save_room, ROOM_HOUSE))
      save_char(ch, save_room);

        And this is a small snip from my interpreter.c in case that is where your
problem lies. If anyone knows anything that is wrong with the way I have
done this please let me know. I am always looking to make improements.

      if ((load_room = GET_LOADROOM(d->character)) != NOWHERE)
        load_room = real_room(load_room);

      /* If char was saved with NOWHERE, or real_room above failed... */
      if (load_room == NOWHERE) {
        if (GET_LEVEL(d->character) >= LVL_IMMORT)
          load_room = r_immort_start_room;
          load_room = r_mortal_start_room;

      if (PLR_FLAGGED(d->character, PLR_FROZEN))
        load_room = r_frozen_start_room;

      char_to_room(d->character, load_room);
      if ((load_result = Crash_load(d->character)))
       if (GET_LEVEL(d->character) < LVL_IMMORT &&
           !PLR_FLAGGED(d->character, PLR_FROZEN)) {
         char_to_room(d->character, load_room);

- Lord Kyu -

     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | |

This archive was generated by hypermail 2b30 : 12/15/00 PST