]> git.pond.sub.org Git - empserver/commitdiff
Prevent command from executing after game is down
authorRon Koenderink <rkoenderink@yahoo.ca>
Thu, 5 Feb 2009 02:53:26 +0000 (20:53 -0600)
committerRon Koenderink <rkoenderink@yahoo.ca>
Thu, 5 Feb 2009 02:53:26 +0000 (20:53 -0600)
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
src/lib/player/empdis.c
src/lib/player/player.c

index 5c58835a33a13c4eab27430b07421c201eddc9d7..67e4699f27b1126a2509d67b6a882c1f72ff56a2 100644 (file)
@@ -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);
index 2ab4fe78bce876af4396932b17abcaaf491765fb..2eb00d8809134202cd4aa4dc1532a6fa3cfaeabc 100644 (file)
@@ -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");
index e593c33e05e7e99020aa763b8b2f8bcbee4923ce..73e40c4ce4a9bbf53f503031be3aac4e2b0da76d 100644 (file)
@@ -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;
 }