From c7e2442d3a8f63bdbcd9b3e1a72aa8db5ea470f9 Mon Sep 17 00:00:00 2001 From: Ron Koenderink Date: Wed, 4 Feb 2009 20:53:26 -0600 Subject: [PATCH] Prevent command from executing after game is down Move the gamedown() check from status to may_play_now() so it is checked upon login, before a command is executed and after command completion. This fixes the situation where a player to could execute one more command after the game was down. Report to the deities that the game is down. Remove to duplicate gamedown message. --- include/prototypes.h | 1 - src/lib/player/empdis.c | 16 +++++++++++----- src/lib/player/player.c | 4 ---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/include/prototypes.h b/include/prototypes.h index 5c58835a..67e4699f 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -365,7 +365,6 @@ extern int dispatch(char *, char *); extern int getcommand(char *); extern void init_player_commands(void); extern void log_last_commands(void); -extern int gamedown(void); extern void update_timeused_login(time_t now); extern void update_timeused(time_t now); extern void enforce_minimum_session_time(void); diff --git a/src/lib/player/empdis.c b/src/lib/player/empdis.c index 2ab4fe78..2eb00d88 100644 --- a/src/lib/player/empdis.c +++ b/src/lib/player/empdis.c @@ -180,15 +180,13 @@ disable_coms(void) /* * returns true if down */ -int -gamedown(void) +static int +gamedown(int suppress_deity_message) { FILE *down_fp; struct telstr tgm; char buf[MAXTELSIZE + 1]; /* UTF-8 */ - if (player->god) - return 0; if ((down_fp = fopen(downfil, "rb")) == NULL) return 0; if (fread(&tgm, sizeof(tgm), 1, down_fp) != 1) { @@ -207,9 +205,14 @@ gamedown(void) return 1; } buf[tgm.tel_length] = 0; + fclose(down_fp); + if (player->god) { + if (!suppress_deity_message) + pr("The game is down\n"); + return 0; + } uprnf(buf); pr("\nThe game is down\n"); - fclose(down_fp); return 1; } @@ -279,6 +282,9 @@ may_play_now(struct natstr *natp, time_t now, return 0; } + if (gamedown(suppress_deity_message)) + return 0; + if ((natp->nat_stat != STAT_GOD && natp->nat_stat != STAT_VIS) && natp->nat_timeused > m_m_p_d * 60) { pr("Max minutes per day limit exceeded.\n"); diff --git a/src/lib/player/player.c b/src/lib/player/player.c index e593c33e..73e40c4c 100644 --- a/src/lib/player/player.c +++ b/src/lib/player/player.c @@ -198,10 +198,6 @@ status(void) if (natp->nat_stat == STAT_ACTIVE && (player->nstat & CAP) == 0) pr("You lost your capital... better designate one (see info capital)\n"); putnat(natp); - if (gamedown() && !player->god) { - pr("gamedown\n"); - return 0; - } return 1; }