]> git.pond.sub.org Git - empserver/blobdiff - src/lib/player/player.c
Update copyright notice
[empserver] / src / lib / player / player.c
index 6e568882f83073b5e59440ad217ca7bcb3729f2b..3f0009b79cd899949c15f7203a0afe184a286050 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2012, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
  *
  *  Known contributors to this file:
  *     Steve McClure, 2000
- *     Markus Armbruster, 2004-2011
+ *     Markus Armbruster, 2004-2012
  *     Ron Koenderink, 2004-2009
  */
 
 #include <config.h>
 
-#include "com.h"
 #include "empio.h"
 #include "empthread.h"
 #include "file.h"
-#include "journal.h"
 #include "misc.h"
 #include "nat.h"
 #include "optlist.h"
 #include "player.h"
-#include "proto.h"
 #include "prototypes.h"
-#include "tel.h"
 
 
 static int command(void);
@@ -59,7 +55,6 @@ player_main(struct player *p)
     struct natstr *natp;
     char buf[128];
 
-    p->state = PS_PLAYING;
     player = p;
     time(&player->curup);
     update_timeused_login(player->curup);
@@ -88,7 +83,6 @@ player_main(struct player *p)
     strcpy(natp->nat_hostaddr, player->hostaddr);
     natp->nat_last_login = player->curup;
     putnat(natp);
-    journal_login();
     if (natp->nat_flags & NF_INFORM && natp->nat_tgms > 0) {
        if (natp->nat_tgms == 1)
            pr("You have a new telegram waiting ...\n");
@@ -99,7 +93,9 @@ player_main(struct player *p)
     }
 
     while (status() && command()) {
-       player->aborted = player->eof;
+       if (player->got_ctld)
+           io_set_eof(player->iop);
+       player->aborted = 0;
        empth_yield();
     }
     /* #*# I put the following line in to prevent server crash -KHS */
@@ -109,7 +105,6 @@ player_main(struct player *p)
     update_timeused(natp->nat_last_logout);
     enforce_minimum_session_time();
     pr("Bye-bye\n");
-    journal_logout();
 }
 
 static int
@@ -171,7 +166,7 @@ status(void)
 
     time(&player->curup);
     update_timeused(player->curup);
-    if (player->eof || player->state == PS_SHUTDOWN
+    if (io_error(player->iop) || io_eof(player->iop)
        || !may_play_now(natp, player->curup))
        return 0;
 
@@ -243,7 +238,7 @@ execute(void)
        return RET_SYN;
     prexec(p);
 
-    while (!failed && status()) {
+    while (!failed && status() && !player->got_ctld) {
        player->nstat &= ~EXEC;
        if (getcommand(player->combuf) < 0)
            break;
@@ -253,13 +248,14 @@ execute(void)
            continue;
        }
        pr("\nExecute : ");
-       uprnf(buf);
+       uprnf(player->combuf);
        pr("\n");
        if (redir) {
            pr("Execute : redirection not supported\n");
            failed = 1;
-       } else if (dispatch(buf, NULL) < 0)
+       } else if (dispatch(player->combuf, NULL) < 0)
            failed = 1;
+       /* player->aborted not reset; makes next getcommand() fail */
        empth_yield();
     }
     if (failed) {
@@ -267,7 +263,7 @@ execute(void)
     }
 
     pr("Execute : %s\n", failed ? "aborted" : "terminated");
-    player->eof = 0;
+    player->got_ctld = 0;
     return RET_OK;
 }
 
@@ -281,7 +277,7 @@ show_motd(void)
 int
 quit(void)
 {
-    player->state = PS_SHUTDOWN;
+    io_set_eof(player->iop);
     return RET_OK;
 }