/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*
* Known contributors to this file:
* Steve McClure, 2000
- *
*/
#include <config.h>
-#include "prototypes.h"
-#include <string.h>
+#include <errno.h>
+#include <stdio.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 "com.h"
-#include "nat.h"
+#include "prototypes.h"
#include "sect.h"
-#include "file.h"
-#include "proto.h"
-#include "empio.h"
-#include "empthread.h"
#include "tel.h"
-#include "gen.h"
-#include "subs.h"
-#include "common.h"
-#include "optlist.h"
-#if !defined(_WIN32)
-#include <unistd.h>
-#include <sys/time.h>
-#endif
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
+static int command(void);
static int status(void);
struct player *player;
time(&player->lasttime);
time(&player->curup);
show_motd();
- if (init_nats() < 0)
+ if (init_nats() < 0) {
+ pr("Server confused, try again later\n");
return;
+ }
natp = getnatp(player->cnum);
if (!gamehours(player->curup)) {
pr("Empire hours restriction in force\n");
time(&natp->nat_last_login);
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");
natp->nat_minused += 1;
putnat(natp);
pr("Bye-bye\n");
+ journal_logout();
}
-int
+static int
command(void)
{
- unsigned int x;
char *redir; /* UTF-8 */
char scanspace[1024];
if (getcommand(player->combuf) < 0)
return 0;
- if (parse(player->combuf, player->argp, &player->condarg,
- scanspace, &redir) < 0) {
+ if (parse(player->combuf, scanspace, player->argp, player->comtail,
+ &player->condarg, &redir) < 0) {
pr("See \"info Syntax\"?\n");
} else {
- /* XXX don't use alarm; use a scavenger thread */
- /* DONT USE IT!!!! alarm and sleep may and dont work
- together -- Sasha */
- /* alarm((unsigned int)60*60); 1 hour */
- if (player->condarg != NULL)
- for (x = 0; x < strlen(player->condarg); x++)
- if (isupper(*(player->condarg + x)))
- *(player->condarg + x) =
- tolower(*(player->condarg + x));
if (dispatch(player->combuf, redir) < 0)
pr("Try \"list of commands\" or \"info\"\n");
}
putnat(natp);
return 0;
}
- player->visitor = natp->nat_stat < STAT_SANCT;
if (player->dolcost != 0.0) {
if (player->dolcost > 100.0)
pr("That just cost you $%.2f\n", player->dolcost);
numstr(buf, natp->nat_ann));
natp->nat_ann = 0;
}
- if (!player->visitor && !player->god && (player->nstat & CAP) == 0)
+ if (natp->nat_stat == STAT_ACTIVE && (player->nstat & CAP) == 0)
pr("You lost your capital... better designate one\n");
putnat(natp);
if (gamedown() && !player->god) {
failed = 0;
redir = NULL;
- p = getstarg(player->argp[1], "File? ", buf);
-
+ if (player->comtail[1])
+ p = player->comtail[1];
+ else
+ p = getstring("File? ", buf);
if (p == NULL || *p == '\0')
return RET_SYN;
-
- /* FIXME should use raw argument here, to support UTF-8 file names */
- prexec(player->argp[1]);
+ prexec(p);
while (!failed && status()) {
if (recvclient(buf, sizeof(buf)) < 0)
break;
- if (parse(buf, player->argp, &player->condarg,
- scanspace, &redir) < 0) {
+ if (parse(buf, scanspace, player->argp, player->comtail,
+ &player->condarg, &redir) < 0) {
failed = 1;
continue;
}
}
if (redir == NULL)
pr("Execute : %s\n", failed ? "aborted" : "terminated");
+ player->eof = 0;
return RET_OK;
}