]> git.pond.sub.org Git - empserver/blobdiff - src/lib/player/empdis.c
Add maximum logged in time check for nation state NEW
[empserver] / src / lib / player / empdis.c
index 14b32b96d4e7109f396e088dcc9aedf763c6ceb1..2ab4fe78bce876af4396932b17abcaaf491765fb 100644 (file)
@@ -229,7 +229,7 @@ void
 update_timeused_login(time_t now)
 {
     struct natstr *natp = getnatp(player->cnum);
-    time_t midnight_secs = seconds_since_midnight(player->lasttime);
+    time_t midnight_secs = seconds_since_midnight(now);
 
     if (now - natp->nat_last_logout > midnight_secs) {
        natp->nat_timeused = 0;
@@ -265,3 +265,24 @@ enforce_minimum_session_time(void)
        natp->nat_timeused += 15 - dt;
     putnat(natp);
 }
+
+int
+may_play_now(struct natstr *natp, time_t now,
+            int suppress_deity_message)
+{
+    update_timeused(now);
+
+    if (!gamehours(now)) {
+       if (natp->nat_stat != STAT_GOD || !suppress_deity_message)
+           pr("Empire hours restriction in force\n");
+       if (natp->nat_stat != STAT_GOD)
+           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");
+       return 0;
+    }
+    return 1;
+}