/*
* Empire - A multi-player, client/server Internet based war game.
- * Copyright (C) 1986-2000, 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
*
* ---
*
- * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
- * related information and legal notices. It is expected that any future
- * projects/authors will amend these files as needed.
+ * See files README, COPYING and CREDITS in the root of the source
+ * tree for related information and legal notices. It is expected
+ * that future projects/authors will amend these files as needed.
*
* ---
*
* Dave Pare, 1986
*/
-#include "misc.h"
-#include "player.h"
-#include "xy.h"
-#include "var.h"
-#include "sect.h"
-#include "nat.h"
-#include "nsc.h"
-#include "file.h"
+#include <config.h>
+
#include "commands.h"
/*
*/
static long do_demo(struct natstr *natp, struct nstr_sect nstr, int number,
- s_char *p, int for_real);
+ char *p, int for_real);
int
demo(void)
long cash;
long cost;
int number;
- s_char *p;
- s_char buf[1024];
+ char *p;
+ char buf[1024];
struct nstr_sect nstr;
natp = getnatp(player->cnum);
}
static long
-do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
+do_demo(struct natstr *natp, struct nstr_sect nstr, int number, char *p,
int for_real)
{
struct sctstr sect;
while (nxtsct(&nstr, §)) {
if (!player->owner || sect.sct_effic < 60)
continue;
- if ((mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR)) == 0)
+ if ((mil = sect.sct_item[I_MILIT]) == 0)
continue;
if (sect.sct_own != sect.sct_oldown)
continue;
- civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
- if (number < 0) {
- if ((deltamil = mil + number) <= 0)
- continue;
- } else if ((deltamil = min(mil, number)) <= 0)
+ civ = sect.sct_item[I_CIVIL];
+ deltamil = number < 0 ? mil + number : MIN(mil, number);
+ if (deltamil <= 0)
continue;
+ if (deltamil > ITEM_MAX - civ)
+ deltamil = ITEM_MAX - civ;
civ += deltamil;
mil -= deltamil;
mil_demob += deltamil;
deltamil, xyas(sect.sct_x, sect.sct_y, player->cnum), mil);
if (*p == 'y')
reserves += deltamil;
- putvar(V_MILIT, mil, (s_char *)§, EF_SECTOR);
- putvar(V_CIVIL, civ, (s_char *)§, EF_SECTOR);
+ sect.sct_item[I_MILIT] = mil;
+ sect.sct_item[I_CIVIL] = civ;
putsect(§);
}
if (!for_real)
}
pr("Total new civilians : %d\n", mil_demob);
if (*p == 'y')
- pr("Military reserve stands at %d (up %d)\n",
+ pr("Military reserve stands at %ld (up %d)\n",
natp->nat_reserve + reserves, reserves);
if (reserves > 0) {
natp->nat_reserve += reserves;