[CODE] Items disappearing bug & fix

From: Andrey Fidrya (andrey@alex-ua.com)
Date: 05/29/99


I've got a lot of complaints from players about items disappearing after
crashes. This was caused by two bugs, the one I described earlier
(about an month ago) and this one:

Here's how to reproduce it (I included a fix too):

===
[ Krys entering game with no equipment. ]

> goto krys
The Temple Of Midgaard
[...]
Krys the Apprentice of Magic is standing here.

> vnum obj bread
  1. [   10] a waybread
[...]

> load obj 3010
You create a bread.

>
Krys gets a bread.

> show rent krys
krys has no rent file.

> show rent krys
krys has no rent file.

> show rent krys
[ 3010] (   10au) a bread

> stat file krys
MALE PC 'Krys'  IDNum: [    2], In room [    0]
[...]
AFF: NOBITS

> show rent krys
krys has no rent file.

> say doh
You say, 'doh'

>
===

There are two ways to fix it, this one seems to be the most clear one:
*** Apply this only after applying my previous linkdead-death bugfix! ***

=== handler.c ===
-void extract_char(struct char_data *ch)
+void extract_char(struct char_data *ch, bool del_crashfile)
[...]
  if (!IS_NPC(ch)) {
    save_char(ch, NOWHERE);
+   if (del_crashfile)
    Crash_delete_crashfile(ch);

=== handler.h ===
-void    extract_char(struct char_data *ch);
+void extract_char(struct char_data *ch, bool del_crashfile);

=== act.movement.c ===
  if (ROOM_FLAGGED(ch->in_room, ROOM_DEATH) && GET_LEVEL(ch) < LVL_IMMORT) {
    log_death_trap(ch);
    death_cry(ch);
-   extract_char(ch);
+   extract_char(ch, TRUE); /* Wipe obj file too */

=== act.other.c ===
if (free_rent)
   Crash_rentsave(ch, 0);

-extract_char(ch);
+extract_char(ch, TRUE); /* Its safe to call del_crashfile here - if rent
was free, player's objfile will remain, otherwise it will be deleted */

=== act.wizard.c ===
ACMD(do_stat)
[...]
    else
      do_stat_character(ch, victim);
-   extract_char(victim);
+   extract_char(victim, FALSE); /* Don't touch obj files */
[...]
ACMD(do_vstat)
[...]
    do_stat_character(ch, mob);
-   extract_char(mob);
+   extract_char(mob, FALSE);
[...]
      if (!IS_NPC(vict)) {
        sprintf(buf, "(GC) %s has purged %s.", GET_NAME(ch),
GET_NAME(vict));
        mudlog(buf, BRF, LVL_GOD, TRUE);
      }
      /* Zmey: fixed do_purge+extract_char bug: */
      if (!IS_NPC(vict) && vict->desc) {
        STATE(vict->desc) = CON_CLOSE;
        vict->desc->character = NULL;
        vict->desc = NULL;
-       extract_char(vict);
+       extract_char(vict, TRUE); /* Extract items and wipe rent file */
        free_char(vict);
      } else
        extract_char(vict, FALSE); /* Doesn't matter for mobiles */
[...]
    for (vict = world[ch->in_room].people; vict; vict = next_v) {
      next_v = vict->next_in_room;
      if (IS_NPC(vict))
-   extract_char(vict);
+   extract_char(vict, FALSE);

=== fight.c ===
void raw_kill(struct char_data * ch)
[...]
  make_corpse(ch);
- extract_char(ch);
+ extract_char(ch, TRUE); /* Purge obj file if exists */

=== interpreter.c ===
    /* we've found a duplicate - blow him away, dumping his eq in limbo. */
    if (ch->in_room != NOWHERE)
      char_from_room(ch);
    char_to_room(ch, 1);
-   extract_char(ch);
+    extract_char(ch, TRUE); /* Shall it be FALSE? Imho not */

=== limits.c ===
      else
        Crash_idlesave(ch);
      sprintf(buf, "%s force-rented and extracted (idle).", GET_NAME(ch));
      mudlog(buf, CMP, LVL_GOD, TRUE);
-     extract_char(ch);
+     extract_char(ch, FALSE); /* Doesn't matter anyways */

=== objsave.c ===
    act("$n helps $N into $S private chamber.", FALSE, recep, 0, ch, TO_N
    save_room = ch->in_room;
-   extract_char(ch);
+   extract_char(ch, FALSE);

=== Thats all.
I copied both messages to bugs@circlemud.org.

Zmey // 3MoonsWorld (rmud.net.ru:4000)


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