/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2007, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ * Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
* Ken Stevens, Steve McClure
*
* This program is free software; you can redistribute it and/or modify
*/
#include <config.h>
-#if !defined(_WIN32)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <errno.h>
-#include <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
#include "com.h"
#include "empio.h"
#include "empthread.h"
#include "optlist.h"
#include "player.h"
#include "proto.h"
-#include "proto.h"
#include "prototypes.h"
-#include "sect.h"
#include "tel.h"
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 {
if (dispatch(player->combuf, redir) < 0)
status(void)
{
struct natstr *natp;
- int minute;
- struct sctstr sect;
+ int old_nstat, minute;
char buf[128];
if (player->state == PS_SHUTDOWN)
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);
- else if (player->dolcost < -100.0)
- pr("You just made $%.2f\n", -player->dolcost);
- if (natp->nat_money < player->dolcost && !player->broke) {
- player->broke = 1;
- player->nstat &= ~MONEY;
- pr("You are now broke; industries are on strike.\n");
- } else if (player->broke && natp->nat_money - player->dolcost > 0) {
- player->broke = 0;
- player->nstat |= MONEY;
- pr("You are no longer broke!\n");
- }
- natp->nat_money -= roundavg(player->dolcost);
- player->dolcost = 0.0;
- } else {
- if (natp->nat_money < 0.0 && !player->broke) {
- player->broke = 1;
- player->nstat &= ~MONEY;
- pr("You are now broke; industries are on strike.\n");
- }
- if (player->broke && natp->nat_money > 0) {
- player->broke = 0;
- player->nstat |= MONEY;
- pr("You are no longer broke!\n");
- }
- }
- getsect(natp->nat_xcap, natp->nat_ycap, §);
- if (influx(natp))
- player->nstat &= ~CAP;
- else
- player->nstat |= CAP;
- player->ncomstat = player->nstat;
- if (player->god)
- player->ncomstat |= CAP | MONEY;
+ if (player->dolcost > 100.0)
+ pr("That just cost you $%.2f\n", player->dolcost);
+ else if (player->dolcost < -100.0)
+ pr("You just made $%.2f\n", -player->dolcost);
+ natp->nat_money -= roundavg(player->dolcost);
+ player->dolcost = 0.0;
+
+ old_nstat = player->nstat;
+ player_set_nstat(player, natp);
+ if ((old_nstat & MONEY) && !(player->nstat & MONEY))
+ pr("You are now broke; industries are on strike.\n");
+ if (!(old_nstat & MONEY) && (player->nstat & MONEY))
+ pr("You are no longer broke!\n");
+
time(&player->curup);
minute = (player->curup - player->lasttime) / 60;
if (minute > 0) {
}
if (natp->nat_stat == STAT_ACTIVE && natp->nat_minused > m_m_p_d) {
pr("Max minutes per day limit exceeded.\n");
- player->ncomstat = VIS;
+ player->nstat = (player->nstat & ~NORM) | VIS;
}
if (player->btused) {
natp->nat_btu -= player->btused;
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) {
}
/*
- * actually a command; redirection and piping ignored.
* XXX This whole mess should be redone; execute block should
* start with "exec start", and should end with "exec end".
* We'll wait until 1.2 I guess.
char scanspace[1024];
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()) {
+ player->nstat &= ~EXEC;
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("\nExecute : %s\n", buf);
- if (dispatch(buf, redir) < 0)
+ pr("\nExecute : %s\n", buf);
+ if (redir) {
+ pr("Execute : redirection not supported\n");
+ failed = 1;
+ } else if (dispatch(buf, NULL) < 0)
failed = 1;
}
if (failed) {
while (recvclient(buf, sizeof(buf)) >= 0) ;
}
- if (redir == NULL)
- pr("Execute : %s\n", failed ? "aborted" : "terminated");
+
+ pr("Execute : %s\n", failed ? "aborted" : "terminated");
+ player->eof = 0;
return RET_OK;
}