]> git.pond.sub.org Git - empserver/commitdiff
Prevent command from execute after game restrictions
authorRon Koenderink <rkoenderink@yahoo.ca>
Sat, 15 Nov 2008 22:50:44 +0000 (16:50 -0600)
committerRon Koenderink <rkoenderink@yahoo.ca>
Sat, 15 Nov 2008 22:51:02 +0000 (16:51 -0600)
If a player is at a prompt when either game hours
restrictions starts or logged in time limit is exceeded
the player is allow to enter one command.

src/lib/player/player.c
src/scripts/nightly/patches/All/emptime.c.patch

index 0e1c5e38520d5feafd3b2a50a95fb393429ee992..9912ba1d8093a35647b1a2c01ecd1d35b8f7b0d1 100644 (file)
@@ -109,8 +109,7 @@ player_main(struct player *p)
        natp->nat_tgms = 0;
     }
 
-    while (status()) {
-       command();
+    while (status() && command()) {
        player->aborted = player->eof;
        empth_yield();
     }
@@ -129,9 +128,21 @@ command(void)
 {
     char *redir;               /* UTF-8 */
     char scanspace[1024];
+    time_t now;
+    struct natstr *natp;
 
     if (getcommand(player->combuf) < 0)
        return 0;
+
+    now = time(NULL);
+    update_timeused(now);
+    natp = getnatp(player->cnum);
+    if (natp->nat_stat == STAT_ACTIVE &&
+       natp->nat_timeused > m_m_p_d * 60) {
+       pr("Max minutes per day limit exceeded.\n");
+       return 0;
+    }
+
     if (parse(player->combuf, scanspace, player->argp, player->comtail,
              &player->condarg, &redir) < 0) {
        pr("See \"info Syntax\"?\n");
index 8b74c4a4e604956a9928e852c9943e24cba15e43..5474d3dda0efdb7e63016e087c626fa30ff395da 100644 (file)
@@ -780,7 +780,7 @@ index 3106849..726b5fc 100644
      return lp;
  }
 diff --git a/src/lib/player/player.c b/src/lib/player/player.c
-index 0e1c5e3..9773db4 100644
+index 9912ba1..9dd8c5b 100644
 --- a/src/lib/player/player.c
 +++ b/src/lib/player/player.c
 @@ -40,6 +40,7 @@
@@ -800,7 +800,7 @@ index 0e1c5e3..9773db4 100644
      update_timeused_login(player->curup);
      show_motd();
      if (init_nats() < 0) {
-@@ -116,7 +117,7 @@ player_main(struct player *p)
+@@ -115,7 +116,7 @@ player_main(struct player *p)
      }
      /* #*# I put the following line in to prevent server crash -KHS */
      natp = getnatp(player->cnum);
@@ -809,7 +809,16 @@ index 0e1c5e3..9773db4 100644
      putnat(natp);
      update_timeused(natp->nat_last_logout);
      enforce_minimum_session_time();
-@@ -175,7 +176,7 @@ status(void)
+@@ -134,7 +135,7 @@ command(void)
+     if (getcommand(player->combuf) < 0)
+       return 0;
+-    now = time(NULL);
++    now = empire_time(NULL);
+     update_timeused(now);
+     natp = getnatp(player->cnum);
+     if (natp->nat_stat == STAT_ACTIVE &&
+@@ -186,7 +187,7 @@ status(void)
      if (!(old_nstat & MONEY) && (player->nstat & MONEY))
        pr("You are no longer broke!\n");