/*
* 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.
*
* ---
*
* Steve McClure, 1996-2000
*/
-#ifdef Rel4
-#include <string.h>
-#endif /* Rel4 */
-#include "misc.h"
-#include "player.h"
-#include "var.h"
-#include "xy.h"
-#include "sect.h"
-#include "nsc.h"
-#include "nat.h"
-#include "deity.h"
-#include "path.h"
-#include "file.h"
-#include "optlist.h"
-#include "commands.h"
+#include <config.h>
-char *prompt[] = {
- "Improve what ('road' or 'rail')? ",
- "Improve what ('road', 'rail' or 'defense')? " };
+#include "commands.h"
+#include "optlist.h"
+#include "path.h"
int
improve(void)
{
- struct sctstr sect;
- int nsect;
- struct nstr_sect nstr;
- s_char *p;
- s_char buf[1024];
- s_char inbuf[128];
+ struct sctstr sect;
+ int nsect;
+ struct nstr_sect nstr;
+ char *p;
+ char buf[1024];
+ char prompt[128];
int type;
- int vec[I_MAX+1];
int value;
int ovalue;
int maxup;
int mneeded;
int dneeded;
int wanted;
-
- if (!(p = getstarg(player->argp[1],
- prompt[opt_DEFENSE_INFRA], buf)) ||
- !*p)
+
+ p = getstarg(player->argp[1],
+ "Improve what ('road', 'rail' or 'defense')? ",
+ buf);
+ if (!p || !*p)
return RET_SYN;
if (!strncmp(p, "ro", 2))
type = INT_ROAD;
else if (!strncmp(p, "ra", 2))
type = INT_RAIL;
- else if (!strncmp(p, "de", 2) && opt_DEFENSE_INFRA)
+ else if (!strncmp(p, "de", 2)) {
type = INT_DEF;
- else
+ } else
return RET_SYN;
+
+ if (!intrchr[type].in_enable) {
+ pr("%s improvement is disabled.\n", intrchr[type].in_name);
+ return RET_FAIL;
+ }
+
if (!snxtsct(&nstr, player->argp[2]))
return RET_SYN;
prdate();
value = sect.sct_road;
else if (type == INT_RAIL)
value = sect.sct_rail;
- else if (type == INT_DEF)
+ else /* type == INT_DEF */
value = sect.sct_defense;
- sprintf(inbuf, "Sector %s has a %s of %d%%. Improve how much? ",
+ sprintf(prompt, "Sector %s has a %s of %d%%. Improve how much? ",
xyas(sect.sct_x, sect.sct_y, player->cnum),
intrchr[type].in_name, value);
- if (!(p = getstarg(player->argp[3], inbuf, buf)) || !*p)
+ if (!(p = getstarg(player->argp[3], prompt, buf)) || !*p)
continue;
if (!check_sect_ok(§))
continue;
- getvec(VT_ITEM, vec, (s_char *)§, EF_SECTOR);
maxup = 100 - value;
wanted = atoi(p);
if (wanted < 0)
if (!maxup)
continue;
lneeded = intrchr[type].in_lcms * maxup;
- if (opt_NO_LCMS) lneeded = 0;
- if (vec[I_LCM] < lneeded) {
- lneeded = vec[I_LCM];
+ if (sect.sct_item[I_LCM] < lneeded) {
+ lneeded = sect.sct_item[I_LCM];
maxup = lneeded / intrchr[type].in_lcms;
if (maxup <= 0) {
pr("Not enough lcms in %s\n",
}
}
hneeded = intrchr[type].in_hcms * maxup;
- if (opt_NO_HCMS) hneeded = 0;
- if (vec[I_HCM] < hneeded) {
- hneeded = vec[I_HCM];
+ if (sect.sct_item[I_HCM] < hneeded) {
+ hneeded = sect.sct_item[I_HCM];
maxup = hneeded / intrchr[type].in_hcms;
if (maxup <= 0) {
pr("Not enough hcms in %s\n",
mneeded = intrchr[type].in_mcost * maxup;
dneeded = intrchr[type].in_dcost * maxup;
player->dolcost += dneeded;
- if (!opt_NO_LCMS) vec[I_LCM] -= lneeded;
- if (!opt_NO_HCMS) vec[I_HCM] -= hneeded;
+ sect.sct_item[I_LCM] -= lneeded;
+ sect.sct_item[I_HCM] -= hneeded;
sect.sct_mobil -= mneeded;
- putvec(VT_ITEM, vec, (s_char *)§, EF_SECTOR);
ovalue = value;
value += maxup;
- if (value > 100)
+ if (CANT_HAPPEN(value > 100))
value = 100;
pr("Sector %s %s increased from %d%% to %d%%\n",
xyas(sect.sct_x, sect.sct_y, player->cnum),
else
pr("%s: No sector(s)\n", "");
return RET_FAIL;
- }else
+ } else
pr("%d sector%s\n", nsect, splur(nsect));
return 0;
}
-
-