From 0bb44d02b5ffbff28a807290cb30c868864bd727 Mon Sep 17 00:00:00 2001 From: kinther Date: Tue, 23 Dec 2025 09:46:56 -0800 Subject: [PATCH] Permanent PC death --- src/act.movement.c | 2 ++ src/fight.c | 1 + src/handler.c | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/act.movement.c b/src/act.movement.c index 08f8743..7f3eb59 100644 --- a/src/act.movement.c +++ b/src/act.movement.c @@ -467,6 +467,8 @@ int do_simple_move(struct char_data *ch, int dir, int need_specials_check) { mudlog(BRF, LVL_IMMORT, TRUE, "%s hit death trap #%d (%s)", GET_NAME(ch), GET_ROOM_VNUM(going_to), world[going_to].name); death_cry(ch); + if (!IS_NPC(ch)) + GET_POS(ch) = POS_DEAD; extract_char(ch); return (0); } diff --git a/src/fight.c b/src/fight.c index df31dd8..1660535 100644 --- a/src/fight.c +++ b/src/fight.c @@ -356,6 +356,7 @@ struct char_data *i; send_to_group(ch, GROUP(ch), "%s has died.\r\n", GET_NAME(ch)); update_pos(ch); + GET_POS(ch) = POS_DEAD; make_corpse(ch); extract_char(ch); diff --git a/src/handler.c b/src/handler.c index b6f72c0..52e4b2f 100644 --- a/src/handler.c +++ b/src/handler.c @@ -909,8 +909,12 @@ void extract_char_final(struct char_data *ch) if (d->character && GET_IDNUM(ch) == GET_IDNUM(d->character)) STATE(d) = CON_CLOSE; } - STATE(ch->desc) = CON_MENU; - write_to_output(ch->desc, "%s", CONFIG_MENU); + if (GET_POS(ch) == POS_DEAD) { + STATE(ch->desc) = CON_CLOSE; + } else { + STATE(ch->desc) = CON_MENU; + write_to_output(ch->desc, "%s", CONFIG_MENU); + } } } @@ -973,9 +977,30 @@ void extract_char_final(struct char_data *ch) if (SCRIPT_MEM(ch)) extract_script_mem(SCRIPT_MEM(ch)); } else { - save_char(ch); - Crash_delete_crashfile(ch); - REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_QUITING); + if (GET_POS(ch) == POS_DEAD) { + int pfilepos = GET_PFILEPOS(ch); + + if (pfilepos < 0) + pfilepos = get_ptable_by_name(GET_NAME(ch)); + + if (pfilepos >= 0) { + remove_player(pfilepos); + } else { + char filename[PATH_MAX]; + int i; + + log("SYSERR: Could not locate player index entry for %s on death cleanup.", + GET_NAME(ch)); + for (i = 0; i < MAX_FILES; i++) { + if (get_filename(filename, sizeof(filename), i, GET_NAME(ch))) + unlink(filename); + } + } + } else { + save_char(ch); + Crash_delete_crashfile(ch); + REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_QUITING); + } } /* If there's a descriptor, they're in the menu now. */