]> git.pond.sub.org Git - empserver/blobdiff - src/lib/player/player.c
Move show_first_tel() from player.c to rea.c
[empserver] / src / lib / player / player.c
index 73e40c4ce4a9bbf53f503031be3aac4e2b0da76d..4666d179ed7465ad20cc960623c775cb66471ac3 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2009, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
@@ -35,8 +35,6 @@
 
 #include <config.h>
 
-#include <errno.h>
-#include <stdio.h>
 #include "com.h"
 #include "empio.h"
 #include "empthread.h"
@@ -120,11 +118,14 @@ command(void)
 {
     char *redir;               /* UTF-8 */
     char scanspace[1024];
+    time_t now;
 
     if (getcommand(player->combuf) < 0)
        return 0;
 
-    if (!may_play_now(getnatp(player->cnum), time(NULL), 1))
+    now = time(NULL);
+    update_timeused(now);
+    if (!may_play_now(getnatp(player->cnum), now, 1))
        return 0;
 
     if (parse(player->combuf, scanspace, player->argp, player->comtail,
@@ -171,6 +172,7 @@ status(void)
        pr("You are no longer broke!\n");
 
     time(&player->curup);
+    update_timeused(player->curup);
     if (!may_play_now(natp, player->curup, 0))
        return 0;
     if (player->btused) {
@@ -253,37 +255,7 @@ execute(void)
 int
 show_motd(void)
 {
-    FILE *motd_fp;
-    struct telstr tgm;
-    char buf[MAXTELSIZE + 1];  /* UTF-8 */
-
-    if ((motd_fp = fopen(motdfil, "rb")) == NULL) {
-       if (errno == ENOENT)
-           return RET_OK;
-       else {
-           pr ("Could not open motd.\n");
-           logerror("Could not open motd (%s).\n", motdfil);
-           return RET_FAIL;
-       }
-    }
-    if (fread(&tgm, sizeof(tgm), 1, motd_fp) != 1) {
-       logerror("bad header on login message (motdfil)");
-       fclose(motd_fp);
-       return RET_FAIL;
-    }
-    if (tgm.tel_length >= (long)sizeof(buf)) {
-       logerror("text length (%ld) is too long for login message (motdfil)", tgm.tel_length);
-       fclose(motd_fp);
-       return RET_FAIL;
-    }
-    if (fread(buf, tgm.tel_length, 1, motd_fp) != 1) {
-       logerror("bad length %ld on login message", tgm.tel_length);
-       fclose(motd_fp);
-       return RET_FAIL;
-    }
-    buf[tgm.tel_length] = 0;
-    uprnf(buf);
-    fclose(motd_fp);
+    show_first_tel(motdfil);
     return RET_OK;
 }