]> git.pond.sub.org Git - empserver/commitdiff
Log out player when time per day is exceeded
authorRon Koenderink <rkoenderink@yahoo.ca>
Sun, 16 Nov 2008 14:42:42 +0000 (08:42 -0600)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 16 Nov 2008 18:16:36 +0000 (13:16 -0500)
Commit 3da4030 already changed player_main() to log out the player
when m_m_p_d was exceeded in command().  This crept in accidentally.
Complete the job by changing status() to log out the player instead of
downgrading him to visitor status.

Also, change player_main(), command() and status() to apply the time
limit to countries in sanctuary in addition to active countries.
Leave visitors alone, because those are shared logins.  Make the
disconnect message to a player consistent for all situations.

Note that commit 875a80d1 already changed player_main() to apply the
time limit only to active countries instead of all, just like status()
does, but neglected to document that.

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

index 9912ba1d8093a35647b1a2c01ecd1d35b8f7b0d1..811e1d4ad6213a4a1bf04890451a00170c7cf1f5 100644 (file)
@@ -77,9 +77,9 @@ player_main(struct player *p)
        if (natp->nat_stat != STAT_GOD)
            return;
     }
-    if (natp->nat_stat == STAT_ACTIVE &&
-       natp->nat_timeused > m_m_p_d * 60) {
-       pr("Time exceeded today\n");
+    if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
+       && natp->nat_timeused > m_m_p_d * 60) {
+       pr("Max minutes per day limit exceeded.\n");
        return;
     }
     if (natp->nat_stat != STAT_VIS
@@ -137,8 +137,8 @@ command(void)
     now = time(NULL);
     update_timeused(now);
     natp = getnatp(player->cnum);
-    if (natp->nat_stat == STAT_ACTIVE &&
-       natp->nat_timeused > m_m_p_d * 60) {
+    if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
+       && natp->nat_timeused > m_m_p_d * 60) {
        pr("Max minutes per day limit exceeded.\n");
        return 0;
     }
@@ -188,10 +188,10 @@ status(void)
 
     time(&player->curup);
     update_timeused(player->curup);
-    if (natp->nat_stat == STAT_ACTIVE &&
-       natp->nat_timeused > m_m_p_d * 60) {
+    if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
+       && natp->nat_timeused > m_m_p_d * 60) {
        pr("Max minutes per day limit exceeded.\n");
-       player->nstat = (player->nstat & ~NORM) | VIS;
+       return 0;
     }
     if (player->btused) {
        natp->nat_btu -= player->btused;
index 5474d3dda0efdb7e63016e087c626fa30ff395da..c80f2ba0a42015ec16f31a8eb9ba276849ff5f5c 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 9912ba1..9dd8c5b 100644
+index 811e1d4..d08ac40 100644
 --- a/src/lib/player/player.c
 +++ b/src/lib/player/player.c
 @@ -40,6 +40,7 @@
@@ -817,7 +817,7 @@ index 9912ba1..9dd8c5b 100644
 +    now = empire_time(NULL);
      update_timeused(now);
      natp = getnatp(player->cnum);
-     if (natp->nat_stat == STAT_ACTIVE &&
+     if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
 @@ -186,7 +187,7 @@ status(void)
      if (!(old_nstat & MONEY) && (player->nstat & MONEY))
        pr("You are no longer broke!\n");
@@ -825,8 +825,8 @@ index 9912ba1..9dd8c5b 100644
 -    time(&player->curup);
 +    empire_time(&player->curup);
      update_timeused(player->curup);
-     if (natp->nat_stat == STAT_ACTIVE &&
-       natp->nat_timeused > m_m_p_d * 60) {
+     if ((natp->nat_stat == STAT_ACTIVE || natp->nat_stat == STAT_SANCT)
+       && natp->nat_timeused > m_m_p_d * 60) {
 diff --git a/src/lib/player/recvclient.c b/src/lib/player/recvclient.c
 index ab4ef69..8934189 100644
 --- a/src/lib/player/recvclient.c