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.
This commit is contained in:
parent
48cec49fbf
commit
c7e2442d3a
3 changed files with 11 additions and 10 deletions
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue