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

From: Christoffer Lundberg (avatar@ORION.BODEN.SE)
Date: 05/20/98


This is how my code looks, but it still don't seem to be working. I'm
still loaded to the mortal_/immortal_ start_room.

>Christoffer


On Wed, 20 May 1998, Lord Kyu wrote:

> ACMD(do_quit)
> {
>   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)
>     return;
>
>   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);
>     die(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)
>         continue;
>       if (d->character && (GET_IDNUM(d->character) == GET_IDNUM(ch)))
>         close_socket(d);
>     }
>
>    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))
>       write_aliases(ch);
>       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;
>         else
>           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_from_room(d->character);
>          char_to_room(d->character, load_room);
>        }
>
> - Lord Kyu -


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