Sectors need space for items, deliveries and distribution thresholds.
To save space, the ancients invented `variables': a collection of key-value pairs, missing means zero value, space for `enough' keys. This complicates the code, as assigning to a `variable' can fail for lack of space. Over time, `enough' increased, and for quite some time now `variables' have been *wasting* space. This changeset replaces them, except in struct mchrstr, struct lchrstr and struct pchrstr, where they are read-only, and will be replaced later. It is only a first step; further cleanup is required. To simplify and minimize this necessarily huge changeset, the new item[] arrays have an unused slot 0, and the old variable types V_CIVIL, ... are still defined, but must have the same values as the item types I_CIVIL, ...
This commit is contained in:
parent
ba86513b01
commit
eccc5cb7d7
86 changed files with 853 additions and 1226 deletions
|
@ -34,6 +34,8 @@
|
|||
#ifndef _FILE_H_
|
||||
#define _FILE_H_
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct empfile {
|
||||
s_char *name; /* file name (e.g., "treaty") */
|
||||
s_char *file; /* file path */
|
||||
|
@ -43,8 +45,7 @@ struct empfile {
|
|||
void (*init) (int, s_char *); /* call this when object is created */
|
||||
int (*postread) (int, s_char *); /* specific massage routines for items */
|
||||
int (*prewrite) (int, s_char *);
|
||||
int varoffs[3]; /* struct offs for nv, vtype, vamt */
|
||||
int maxvars; /* max # vars for type */
|
||||
ptrdiff_t itemoffs; /* offset of item[] in struct */
|
||||
int fd; /* file descriptor */
|
||||
int baseid; /* starting item in cache */
|
||||
int cids; /* # ids in cache */
|
||||
|
@ -88,7 +89,6 @@ struct fileinit {
|
|||
struct castr *cadef;
|
||||
};
|
||||
|
||||
|
||||
extern struct castr *ef_cadef(int);
|
||||
extern int ef_read(int, int, caddr_t);
|
||||
extern s_char *ef_ptr(int, int);
|
||||
|
@ -104,8 +104,7 @@ extern int ef_ensure_space(int, int, int);
|
|||
extern void ef_zapcache(int);
|
||||
extern int ef_nelem(int);
|
||||
extern int ef_flags(int);
|
||||
extern int ef_vars(int, register s_char *, u_char **,
|
||||
u_char **, u_short **);
|
||||
extern u_short *ef_items(int, void *);
|
||||
extern int ef_byname(s_char *);
|
||||
|
||||
extern int ef_nbread(int type, int id, caddr_t ptr);
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#include "queue.h"
|
||||
#include "nsc.h"
|
||||
#include "retreat.h"
|
||||
#include "var.h"
|
||||
|
||||
#define LAND_MINEFF 10
|
||||
#define LAND_MINFIREEFF 40 /* arty must be this effic to fire */
|
||||
#define MAXLNDV 14
|
||||
#define LND_MINMOBCOST 0.200
|
||||
|
||||
struct lndstr {
|
||||
|
@ -71,9 +71,9 @@ struct lndstr {
|
|||
s_char lnd_rpath[RET_LEN]; /* retreat path */
|
||||
u_char lnd_rad_max; /* max radius for this unit */
|
||||
u_char lnd_scar; /* how experienced the unit is (not used) */
|
||||
s_char lnd_nv; /* current number of variables */
|
||||
u_char lnd_vtype[MAXLNDV];
|
||||
u_short lnd_vamt[MAXLNDV];
|
||||
u_short lnd_item[I_MAX+1]; /* amount of items on board */
|
||||
u_short lnd_pstage; /* plague stage */
|
||||
u_short lnd_ptime; /* how many etus remain in this stage */
|
||||
short lnd_land; /* pointer to transporting unit */
|
||||
u_char lnd_nland;
|
||||
time_t lnd_access; /* Last time mob was updated (MOB_ACCESS) */
|
||||
|
|
|
@ -101,6 +101,7 @@ extern void land_damage(struct lndstr *, int);
|
|||
extern void planedamage(struct plnstr *, int);
|
||||
extern int nukedamage(struct nchrstr *, int, int);
|
||||
extern int effdamage(register int, int);
|
||||
extern void item_damage(int, u_short *);
|
||||
extern int commdamage(register int, int, int);
|
||||
/* check.c */
|
||||
extern int check_sect_ok(struct sctstr *);
|
||||
|
@ -116,9 +117,7 @@ extern int blksize(int);
|
|||
extern time_t fdate(int);
|
||||
extern void filetruncate(s_char *);
|
||||
/* getvar.c */
|
||||
extern int getvar(int, s_char *, int);
|
||||
extern int getvec(int, int *, s_char *, int);
|
||||
extern int putvar(int, int, s_char *, int);
|
||||
extern int putvec(int, int *, s_char *, int);
|
||||
/* hap_fact.c */
|
||||
extern double hap_fact(struct natstr *, struct natstr *);
|
||||
|
@ -588,8 +587,7 @@ extern s_char *nxtitemp(struct nstr_item *, int);
|
|||
extern struct sctstr *nxtsctp(register struct nstr_sect *);
|
||||
/* plague.c */
|
||||
extern void do_plague(struct sctstr *, struct natstr *, int);
|
||||
extern int plague_people(struct natstr *, register int *, register int *,
|
||||
int);
|
||||
extern int plague_people(struct natstr *, int *, u_short *, u_short *, int);
|
||||
/* plane.c */
|
||||
extern int prod_plane(int, int, int *, int);
|
||||
/* populace.c */
|
||||
|
|
|
@ -34,19 +34,10 @@
|
|||
*/
|
||||
|
||||
|
||||
/*
|
||||
* each "point" of MAXSCTV costs 32k for 128x128.
|
||||
* MAXSCTV = 20 ==> 655k for the commodities alone!
|
||||
*
|
||||
* If you set this to I_MAX*3, you'll never run ou
|
||||
* of slots, which is nice. (You'll eat a lot of
|
||||
* space, tho)
|
||||
*/
|
||||
|
||||
#ifndef _SECT_H_
|
||||
#define _SECT_H_
|
||||
|
||||
#define MAXSCTV 42
|
||||
#include "var.h"
|
||||
|
||||
/* The order of the following elements is there to match up with genitem */
|
||||
|
||||
|
@ -80,9 +71,14 @@ struct sctstr {
|
|||
natid sct_oldown; /* old owner of sector (for liberation) */
|
||||
u_char sct_updated; /* Has this sect been updated? */
|
||||
u_char sct_off; /* Should this sector produce? */
|
||||
u_char sct_nv; /* current number of variables */
|
||||
u_char sct_vtype[MAXSCTV];
|
||||
u_short sct_vamt[MAXSCTV];
|
||||
u_short sct_item[I_MAX+1]; /* amount of items stored here */
|
||||
u_short sct_del[I_MAX+1]; /* delivieries */
|
||||
u_short sct_dist[I_MAX+1]; /* distribution thresholds */
|
||||
u_short sct_mines; /* number of mines */
|
||||
u_short sct_pstage; /* plague stage */
|
||||
u_short sct_ptime; /* how many etus remain in this stage */
|
||||
u_short sct_che; /* che combo */
|
||||
u_short sct_fallout;
|
||||
time_t sct_access; /* Last time mob was updated (MOB_ACCESS) */
|
||||
u_char sct_road; /* Road value of a sector */
|
||||
u_char sct_rail; /* Rail value of a sector */
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "queue.h"
|
||||
#include "misc.h"
|
||||
#include "retreat.h"
|
||||
#include "var.h"
|
||||
|
||||
#define SHIP_MINEFF 20
|
||||
|
||||
|
@ -61,8 +62,6 @@
|
|||
#define TMAX 6
|
||||
|
||||
|
||||
#define MAXSHPV 12
|
||||
|
||||
#define MAXSHPPATH 28
|
||||
#define MAXSHPNAMLEN 24
|
||||
|
||||
|
@ -94,9 +93,9 @@ struct shpstr {
|
|||
short shp_lstart[TMAX]; /* How much do we pick up at the start */
|
||||
short shp_lend[TMAX]; /* How much do we pick up at the end */
|
||||
u_char shp_autonav; /* autonavigation flags */
|
||||
s_char shp_nv; /* current number of variables */
|
||||
u_char shp_vtype[MAXSHPV];
|
||||
u_short shp_vamt[MAXSHPV];
|
||||
u_short shp_item[I_MAX+1]; /* amount of items on board */
|
||||
u_short shp_pstage; /* plague stage */
|
||||
u_short shp_ptime; /* how many etus remain in this stage */
|
||||
time_t shp_access; /* Last time mob was updated (MOB_ACCESS) */
|
||||
time_t shp_timestamp; /* Last time this ship was touched. */
|
||||
u_char shp_mobquota; /* mobility quota */
|
||||
|
|
|
@ -42,27 +42,13 @@
|
|||
#define PLG_INCUBATE 3
|
||||
#define PLG_EXPOSED 4
|
||||
|
||||
#define VT_ITEM (1<<5)
|
||||
#define VT_COND (2<<5)
|
||||
#define VT_DIST (3<<5)
|
||||
#define VT_DEL (4<<5)
|
||||
#define VT_SELL (5<<5)
|
||||
#define VT_SPARE1 (6<<5)
|
||||
#define VT_SPARE2 (7<<5)
|
||||
#define VT_ITEM 0
|
||||
#define VT_TYPE (7<<5)
|
||||
|
||||
#define isitem(x) (((x) & VT_TYPE) == VT_ITEM)
|
||||
#define iscond(x) (((x) & VT_TYPE) == VT_COND)
|
||||
#define isdist(x) (((x) & VT_TYPE) == VT_DIST)
|
||||
#define isdel(x) (((x) & VT_TYPE) == VT_DEL)
|
||||
#define issell(x) (((x) & VT_TYPE) == VT_SELL)
|
||||
#define unitem(x) ((x) & (VT_ITEM -1))
|
||||
|
||||
#define V_ITEM(x) ((x)|VT_ITEM) /* a moveable, sellable(?) commodity */
|
||||
#define V_COND(x) ((x)|VT_COND) /* condition (plg time, etc) */
|
||||
#define V_DIST(x) ((x)|VT_DIST) /* distribution command */
|
||||
#define V_DEL(x) ((x)|VT_DEL) /* delivery command */
|
||||
#define V_SELL(x) ((x)|VT_SELL) /* make a sale */
|
||||
|
||||
#define I_CIVIL 1
|
||||
#define I_MILIT 2
|
||||
|
@ -80,20 +66,6 @@
|
|||
#define I_RAD 14
|
||||
#define I_MAX 14
|
||||
|
||||
#define C_MINE 1
|
||||
#define C_PSTAGE 2
|
||||
#define C_PTIME 3
|
||||
#define C_REM 4
|
||||
#define C_CHE 5
|
||||
#define C_FALLOUT 6
|
||||
|
||||
#define V_MINE V_COND(C_MINE)
|
||||
#define V_PSTAGE V_COND(C_PSTAGE)
|
||||
#define V_PTIME V_COND(C_PTIME)
|
||||
#define V_REM V_COND(C_REM)
|
||||
#define V_CHE V_COND(C_CHE)
|
||||
#define V_FALLOUT V_COND(C_FALLOUT)
|
||||
|
||||
/* should this be here?? */
|
||||
#define CHE_MAX 255
|
||||
#define get_che_cnum(x) ((x) >> 8)
|
||||
|
@ -116,34 +88,4 @@
|
|||
#define V_UW V_ITEM(I_UW)
|
||||
#define V_RAD V_ITEM(I_RAD)
|
||||
|
||||
#define V_CDEL V_DEL(I_CIVIL)
|
||||
#define V_MDEL V_DEL(I_MILIT)
|
||||
#define V_SDEL V_DEL(I_SHELL)
|
||||
#define V_GDEL V_DEL(I_GUN)
|
||||
#define V_PDEL V_DEL(I_PETROL)
|
||||
#define V_IDEL V_DEL(I_IRON)
|
||||
#define V_DDEL V_DEL(I_DUST)
|
||||
#define V_BDEL V_DEL(I_BAR)
|
||||
#define V_FDEL V_DEL(I_FOOD)
|
||||
#define V_ODEL V_DEL(I_OIL)
|
||||
#define V_LDEL V_DEL(I_LCM)
|
||||
#define V_HDEL V_DEL(I_HCM)
|
||||
#define V_UDEL V_DEL(I_UW)
|
||||
#define V_RDEL V_DEL(I_RAD)
|
||||
|
||||
#define V_CDIST V_DIST(I_CIVIL)
|
||||
#define V_MDIST V_DIST(I_MILIT)
|
||||
#define V_SDIST V_DIST(I_SHELL)
|
||||
#define V_GDIST V_DIST(I_GUN)
|
||||
#define V_PDIST V_DIST(I_PETROL)
|
||||
#define V_IDIST V_DIST(I_IRON)
|
||||
#define V_DDIST V_DIST(I_DUST)
|
||||
#define V_BDIST V_DIST(I_BAR)
|
||||
#define V_FDIST V_DIST(I_FOOD)
|
||||
#define V_ODIST V_DIST(I_OIL)
|
||||
#define V_LDIST V_DIST(I_LCM)
|
||||
#define V_HDIST V_DIST(I_HCM)
|
||||
#define V_UDIST V_DIST(I_UW)
|
||||
#define V_RDIST V_DIST(I_RAD)
|
||||
|
||||
#endif /* _VAR_H_ */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "misc.h"
|
||||
#include "player.h"
|
||||
#include "var.h"
|
||||
|
@ -179,7 +180,14 @@ add(void)
|
|||
/* No dist path */
|
||||
sect.sct_dist_x = sect.sct_x;
|
||||
sect.sct_dist_y = sect.sct_y;
|
||||
sect.sct_nv = 0;
|
||||
memset(sect.sct_item, 0, sizeof(sect.sct_item));
|
||||
memset(sect.sct_del, 0, sizeof(sect.sct_del));
|
||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||
sect.sct_mines = 0;
|
||||
sect.sct_pstage = PLG_HEALTHY;
|
||||
sect.sct_ptime = 0;
|
||||
sect.sct_che = 0;
|
||||
sect.sct_fallout = 0;
|
||||
putsect(§);
|
||||
pr("wiped\n");
|
||||
} else {
|
||||
|
|
|
@ -57,7 +57,6 @@ anti(void)
|
|||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
int cond[I_MAX + 1];
|
||||
int mil, che, target;
|
||||
int avail_mil;
|
||||
int amil, ache;
|
||||
|
@ -77,10 +76,9 @@ anti(void)
|
|||
pr(" sect subversion activity report\n");
|
||||
pr(" ---- --------------------------\n");
|
||||
}
|
||||
getvec(VT_COND, cond, (char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (char *)§, EF_SECTOR);
|
||||
che = get_che_value(cond[C_CHE]);
|
||||
target = get_che_cnum(cond[C_CHE]);
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
che = get_che_value(sect.sct_che);
|
||||
target = get_che_cnum(sect.sct_che);
|
||||
avail_mil = sect.sct_mobil / 2;
|
||||
if (mil <= avail_mil)
|
||||
avail_mil = mil;
|
||||
|
@ -114,11 +112,10 @@ anti(void)
|
|||
}
|
||||
if (mil - milkilled > 0) {
|
||||
sect.sct_mobil = sect.sct_mobil - chekilled - milkilled;
|
||||
putvar(V_MILIT, mil - milkilled, (char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_MILIT] = mil - milkilled;
|
||||
if (ache == 0)
|
||||
cond[C_CHE] = 0;
|
||||
set_che_value(cond[C_CHE], ache);
|
||||
putvar(V_CHE, cond[C_CHE], (char *)§, EF_SECTOR);
|
||||
sect.sct_che = 0;
|
||||
set_che_value(sect.sct_che, ache);
|
||||
putsect(§);
|
||||
pr(" Body count: Military %d - Guerillas %d.\n",
|
||||
milkilled, chekilled);
|
||||
|
@ -141,11 +138,10 @@ anti(void)
|
|||
/* Ok, now leave anywhere from 16% to 25% of the che */
|
||||
n_cheleft = (ache / (n_cheleft + 3));
|
||||
ache -= n_cheleft;
|
||||
set_che_value(cond[C_CHE], n_cheleft);
|
||||
set_che_value(sect.sct_che, n_cheleft);
|
||||
} else
|
||||
cond[C_CHE] = 0;
|
||||
putvar(V_MILIT, ache, (char *)§, EF_SECTOR);
|
||||
putvar(V_CHE, cond[C_CHE], (char *)§, EF_SECTOR);
|
||||
sect.sct_che = 0;
|
||||
sect.sct_item[I_MILIT] = ache;
|
||||
if (sect.sct_own == sect.sct_oldown)
|
||||
sect.sct_oldown = 0;
|
||||
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x,
|
||||
|
|
|
@ -478,10 +478,8 @@ comm_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
return;
|
||||
getsect(target->sct_x, target->sct_y, §);
|
||||
target = §
|
||||
before = amt = getvar(ip->i_vtype, (s_char *)target, EF_SECTOR);
|
||||
putvar(ip->i_vtype, commdamage(amt, dam, ip->i_vtype),
|
||||
(s_char *)target, EF_SECTOR);
|
||||
amt = getvar(ip->i_vtype, (s_char *)target, EF_SECTOR);
|
||||
before = amt = target->sct_item[ip->i_vtype];
|
||||
target->sct_item[ip->i_vtype] = amt = commdamage(amt, dam, ip->i_vtype);
|
||||
if (before > 0.0)
|
||||
b = 100.0 * (1.0 - ((float)amt / (float)before));
|
||||
else
|
||||
|
@ -582,9 +580,9 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
continue;
|
||||
|
||||
shell = gun = 0;
|
||||
gun = min(getvar(V_GUN, (s_char *)&ship, EF_SHIP), ship.shp_glim);
|
||||
gun = min(ship.shp_item[I_GUN], ship.shp_glim);
|
||||
if (gun > 0) {
|
||||
shell = getvar(V_SHELL, (s_char *)&ship, EF_SHIP);
|
||||
shell = ship.shp_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell = supply_commod(ship.shp_own, ship.shp_x,
|
||||
ship.shp_y, I_SHELL, 1);
|
||||
|
@ -592,7 +590,7 @@ ship_bomb(struct emp_qelem *list, struct sctstr *target)
|
|||
mcp = &mchr[(int)ship.shp_type];
|
||||
if (gun > 0 && shell > 0 && !(mcp->m_flags & M_SUB)) {
|
||||
flak = (int)(techfact(ship.shp_tech, (double)gun) * 2.0);
|
||||
putvar(V_SHELL, shell, (s_char *)&ship, EF_SHIP);
|
||||
ship.shp_item[I_SHELL] = shell;
|
||||
putship(ship.shp_uid, &ship);
|
||||
sprintf(msg, "Flak! Firing %d guns from ship %s\n",
|
||||
flak, prship(&ship));
|
||||
|
|
|
@ -435,7 +435,9 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp,
|
|||
ship.shp_nxlight = 0;
|
||||
ship.shp_nchoppers = 0;
|
||||
ship.shp_fleet = ' ';
|
||||
ship.shp_nv = 0;
|
||||
memset(ship.shp_item, 0, sizeof(ship.shp_item));
|
||||
ship.shp_pstage = PLG_HEALTHY;
|
||||
ship.shp_ptime = 0;
|
||||
ship.shp_tech = tlev;
|
||||
|
||||
techdiff = (int)(tlev - mp->m_tech);
|
||||
|
@ -460,8 +462,8 @@ build_ship(register struct sctstr *sp, register struct mchrstr *mp,
|
|||
vec[I_LCM] -= lcm;
|
||||
vec[I_HCM] -= hcm;
|
||||
|
||||
if (getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR) == PLG_INFECT)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&ship, EF_SHIP);
|
||||
if (sp->sct_pstage == PLG_INFECT)
|
||||
ship.shp_pstage = PLG_EXPOSED;
|
||||
makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid, ship.shp_x,
|
||||
ship.shp_y);
|
||||
putship(ship.shp_uid, &ship);
|
||||
|
@ -585,7 +587,9 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp,
|
|||
land.lnd_rflags = 0;
|
||||
memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
|
||||
land.lnd_rad_max = 0;
|
||||
land.lnd_nv = 0;
|
||||
memset(land.lnd_item, 0, sizeof(land.lnd_item));
|
||||
land.lnd_pstage = PLG_HEALTHY;
|
||||
land.lnd_ptime = 0;
|
||||
land.lnd_att = (float)LND_ATTDEF(lp->l_att, tlev - lp->l_tech);
|
||||
land.lnd_def = (float)LND_ATTDEF(lp->l_def, tlev - lp->l_tech);
|
||||
land.lnd_vul = (int)LND_VUL(lp->l_vul, tlev - lp->l_tech);
|
||||
|
@ -627,8 +631,8 @@ build_land(register struct sctstr *sp, register struct lchrstr *lp,
|
|||
putvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND);
|
||||
*/
|
||||
|
||||
if (getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR) == PLG_INFECT)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&land, EF_LAND);
|
||||
if (sp->sct_pstage == PLG_INFECT)
|
||||
land.lnd_pstage = PLG_EXPOSED;
|
||||
putland(nstr.cur, &land);
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
|
||||
land.lnd_y);
|
||||
|
@ -778,7 +782,7 @@ build_bridge(register struct sctstr *sp, register int *vec)
|
|||
} else {
|
||||
sect.sct_mobil = 0;
|
||||
}
|
||||
putvar(V_MINE, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = 0;
|
||||
putsect(§);
|
||||
pr("Bridge span built over %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
@ -1102,7 +1106,7 @@ build_tower(register struct sctstr *sp, register int *vec)
|
|||
}
|
||||
if (!opt_DEFENSE_INFRA)
|
||||
sect.sct_defense = sect.sct_effic;
|
||||
putvar(V_MINE, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = 0;
|
||||
putsect(§);
|
||||
pr("Bridge tower built in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
|
|
@ -161,24 +161,13 @@ buy(void)
|
|||
return RET_FAIL;
|
||||
}
|
||||
ip = whichitem(comm.com_type);
|
||||
n = getvar(ip->i_vtype, (char *)§, EF_SECTOR);
|
||||
n = sect.sct_item[ip->i_vtype];
|
||||
qty = comm.com_amount;
|
||||
if (qty + n > 9990) {
|
||||
pr("That sector cannot hold %d more %s. It currently holds %d.\n",
|
||||
qty, ip->i_name, n);
|
||||
return RET_FAIL;
|
||||
}
|
||||
/* First we check for room, then we yank back. Probably not necessary. */
|
||||
if (putvar(ip->i_vtype, n + qty, (char *)§, EF_SECTOR) <= 0) {
|
||||
pr("No room to store %s in %s\n",
|
||||
ip->i_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (putvar(ip->i_vtype, n, (char *)§, EF_SECTOR) <= 0) {
|
||||
pr("Something weird just happened, tell the deity.\n");
|
||||
logerror("buy.c: putvar failed.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
if ((bid * comm.com_amount) > natp->nat_money) {
|
||||
pr("You don't have that much to spend!\n");
|
||||
return RET_FAIL;
|
||||
|
@ -250,7 +239,7 @@ check_market(void)
|
|||
continue;
|
||||
ip = whichitem(comm.com_type);
|
||||
sect = getsectp(comm.com_x, comm.com_y);
|
||||
m = getvar(ip->i_vtype, (char *)sect, EF_SECTOR);
|
||||
m = sect->sct_item[ip->i_vtype];
|
||||
|
||||
monleft = 0;
|
||||
|
||||
|
@ -344,14 +333,14 @@ check_market(void)
|
|||
wu(0, comm.com_owner,
|
||||
"Sale #%d fell through. Goods remain on the market.\n", n);
|
||||
comm.com_maxbidder = comm.com_owner;
|
||||
} else if (putvar(ip->i_vtype, m + comm.com_amount,
|
||||
(char *)sect, EF_SECTOR) <= 0) {
|
||||
} else if (m + comm.com_amount > 32767) {
|
||||
wu(0, comm.com_maxbidder,
|
||||
"Warehouse full, sale #%d fell though.\n", n);
|
||||
wu(0, comm.com_owner,
|
||||
"Sale #%d fell through. Goods remain on the market.\n", n);
|
||||
comm.com_maxbidder = comm.com_owner;
|
||||
} else {
|
||||
sect->sct_item[ip->i_vtype] = m + comm.com_amount;
|
||||
putsect(sect);
|
||||
nreport(comm.com_owner, N_MAKE_SALE, comm.com_maxbidder, 1);
|
||||
wu(0, comm.com_owner, "%s bought %d %c's from you for $%.2f\n",
|
||||
|
|
|
@ -205,12 +205,10 @@ grab_sect(register struct sctstr *sp, natid to)
|
|||
struct plnstr p;
|
||||
struct lndstr l;
|
||||
struct nukstr nuk;
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
/* Wipe all the distribution info */
|
||||
memset(vec, 0, sizeof(vec));
|
||||
putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR);
|
||||
putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR);
|
||||
memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
|
||||
memset(sp->sct_del, 0, sizeof(sp->sct_del));
|
||||
sp->sct_dist_x = sp->sct_x;
|
||||
sp->sct_dist_y = sp->sct_y;
|
||||
|
||||
|
@ -275,10 +273,10 @@ grab_sect(register struct sctstr *sp, natid to)
|
|||
sp->sct_avail = 0;
|
||||
|
||||
if (sp->sct_oldown == to) {
|
||||
oldche = get_che_value(getvar(V_CHE, (s_char *)sp, EF_SECTOR));
|
||||
oldche = get_che_value(sp->sct_che);
|
||||
set_che_value(oldche, 0);
|
||||
set_che_cnum(oldche, 0);
|
||||
(void)putvar(V_CHE, oldche, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = oldche;
|
||||
sp->sct_loyal = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,14 +85,12 @@ cens(void)
|
|||
pr(" ");
|
||||
pr("%4d", sect.sct_mobil);
|
||||
|
||||
getvec(VT_DEL, vec, (s_char *)§, EF_SECTOR);
|
||||
pr(" %c", dirstr[vec[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[vec[I_FOOD] & 0x7]);
|
||||
pr(" %c", dirstr[sect.sct_del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
|
||||
|
||||
getvec(VT_DIST, vec, (s_char *)§, EF_SECTOR);
|
||||
n = vec[I_UW] % 1000;
|
||||
n = sect.sct_dist[I_UW] % 1000;
|
||||
pr(" %c", n == 0 ? '.' : '0' + (n / 100));
|
||||
n = vec[I_FOOD] % 1000;
|
||||
n = sect.sct_dist[I_FOOD] % 1000;
|
||||
pr("%c ", n == 0 ? '.' : '0' + (n / 100));
|
||||
pr("%c", sect.sct_own != sect.sct_oldown ? '*' : ' ');
|
||||
|
||||
|
@ -110,8 +108,7 @@ cens(void)
|
|||
pr(" ");
|
||||
}
|
||||
if (opt_FALLOUT) {
|
||||
getvec(VT_COND, vec, (void *)§, EF_SECTOR);
|
||||
pr("%5d", vec[C_FALLOUT]);
|
||||
pr("%5d", sect.sct_fallout);
|
||||
}
|
||||
set_coastal(§);
|
||||
if (sect.sct_coastal)
|
||||
|
|
|
@ -65,7 +65,6 @@ coll(void)
|
|||
double owed;
|
||||
double pay;
|
||||
s_char buf[1024];
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
if (!opt_LOANS) {
|
||||
pr("Loans are not enabled.\n");
|
||||
|
@ -128,7 +127,7 @@ coll(void)
|
|||
for (i = 0; ichr[i].i_name; i++) {
|
||||
if (ichr[i].i_value == 0 || ichr[i].i_vtype == 0)
|
||||
continue;
|
||||
val = getvar(ichr[i].i_vtype, (s_char *)§, EF_SECTOR);
|
||||
val = sect.sct_item[ichr[i].i_vtype];
|
||||
pay += val * ichr[i].i_value;
|
||||
}
|
||||
pr("That sector (and its contents) is valued at $%.2f\n", pay);
|
||||
|
@ -138,7 +137,7 @@ coll(void)
|
|||
}
|
||||
if (sect.sct_type == SCT_CAPIT || sect.sct_type == SCT_MOUNT)
|
||||
caploss(§, sect.sct_own, "that was %s's capital!\n");
|
||||
putvar(V_MILIT, 1, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_MILIT] = 1; /* FIXME no where did this guy come from? */
|
||||
|
||||
/* Consider modifying takeover to take a "no che" argument and
|
||||
putting using it here again. */
|
||||
|
@ -147,9 +146,8 @@ coll(void)
|
|||
makenotlost(EF_SECTOR, player->cnum, 0, sect.sct_x, sect.sct_y);
|
||||
sect.sct_own = player->cnum;
|
||||
|
||||
memset(vec, 0, sizeof(vec));
|
||||
putvec(VT_DIST, vec, (s_char *)§, EF_SECTOR);
|
||||
putvec(VT_DEL, vec, (s_char *)§, EF_SECTOR);
|
||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||
memset(sect.sct_del, 0, sizeof(sect.sct_del));
|
||||
sect.sct_off = 1;
|
||||
sect.sct_dist_x = sect.sct_x;
|
||||
sect.sct_dist_y = sect.sct_y;
|
||||
|
|
|
@ -52,8 +52,6 @@ comm(void)
|
|||
int nsect;
|
||||
int n;
|
||||
struct nstr_sect nstr;
|
||||
int del[I_MAX + 1];
|
||||
int dist[I_MAX + 1];
|
||||
int item[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
|
@ -77,31 +75,29 @@ comm(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%3d", sect.sct_own);
|
||||
getvec(VT_DEL, del, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_DIST, dist, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_ITEM, item, (s_char *)§, EF_SECTOR);
|
||||
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c", dchr[sect.sct_type].d_mnem);
|
||||
pr(" %c", dirstr[del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_RAD] & 0x7]);
|
||||
prthresh(" %c", dist[I_SHELL]);
|
||||
prthresh("%c", dist[I_GUN]);
|
||||
prthresh("%c", dist[I_PETROL]);
|
||||
prthresh("%c", dist[I_IRON]);
|
||||
prthresh("%c", dist[I_DUST]);
|
||||
prthresh("%c", dist[I_BAR]);
|
||||
prthresh("%c", dist[I_OIL]);
|
||||
prthresh("%c", dist[I_LCM]);
|
||||
prthresh("%c", dist[I_HCM]);
|
||||
prthresh("%c", dist[I_RAD]);
|
||||
pr(" %c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
|
||||
prthresh(" %c", sect.sct_dist[I_SHELL]);
|
||||
prthresh("%c", sect.sct_dist[I_GUN]);
|
||||
prthresh("%c", sect.sct_dist[I_PETROL]);
|
||||
prthresh("%c", sect.sct_dist[I_IRON]);
|
||||
prthresh("%c", sect.sct_dist[I_DUST]);
|
||||
prthresh("%c", sect.sct_dist[I_BAR]);
|
||||
prthresh("%c", sect.sct_dist[I_OIL]);
|
||||
prthresh("%c", sect.sct_dist[I_LCM]);
|
||||
prthresh("%c", sect.sct_dist[I_HCM]);
|
||||
prthresh("%c", sect.sct_dist[I_RAD]);
|
||||
pr("%4d", item[I_SHELL]);
|
||||
pr("%4d", item[I_GUN]);
|
||||
pr("%5d", item[I_PETROL]);
|
||||
|
|
|
@ -87,10 +87,10 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
|
|||
continue;
|
||||
if (sect.sct_oldown == player->cnum)
|
||||
continue;
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (civ == 0)
|
||||
continue;
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
|
||||
/*
|
||||
* Military units count according to the number of
|
||||
|
@ -128,7 +128,7 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
|
|||
newuw = civ;
|
||||
if (newuw > uwtoconvert)
|
||||
newuw = uwtoconvert;
|
||||
uw = getvar(V_UW, (s_char *)§, EF_SECTOR);
|
||||
uw = sect.sct_item[I_UW];
|
||||
if (uw > 999)
|
||||
continue;
|
||||
if (newuw > 999 - uw)
|
||||
|
@ -157,13 +157,9 @@ do_conv(struct nstr_sect nstr, int uwtoconvert, int for_real)
|
|||
player->dolcost += newuw * 1.5;
|
||||
if (newuw < mob)
|
||||
mob = newuw;
|
||||
if (putvar(V_UW, newuw + uw, (s_char *)§, EF_SECTOR) == 0) {
|
||||
pr("No room for new uw in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
sect.sct_item[I_UW] = newuw + uw;
|
||||
civ -= newuw;
|
||||
putvar(V_CIVIL, civ, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_CIVIL] = civ;
|
||||
mob = roundavg(mob * 0.2);
|
||||
if (mob > sect.sct_mobil)
|
||||
mob = sect.sct_mobil;
|
||||
|
|
|
@ -50,7 +50,6 @@ cuto(void)
|
|||
int n;
|
||||
struct nstr_sect nstr;
|
||||
s_char dirstr[12];
|
||||
int del[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -71,37 +70,36 @@ cuto(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%3d", sect.sct_own);
|
||||
getvec(VT_DEL, del, (s_char *)§, EF_SECTOR);
|
||||
pr("%7s", xyas(nstr.x, nstr.y, player->cnum));
|
||||
pr(" %c ", dchr[sect.sct_type].d_mnem);
|
||||
pr("%c", dirstr[del[I_CIVIL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_MILIT] & 0x7]);
|
||||
pr("%c", dirstr[del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[del[I_FOOD] & 0x7]);
|
||||
pr("%c", dirstr[del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[del[I_RAD] & 0x7]);
|
||||
pr("%4d", del[I_CIVIL] & ~0x7);
|
||||
pr("%4d", del[I_MILIT] & ~0x7);
|
||||
pr("%4d", del[I_UW] & ~0x7);
|
||||
pr("%4d", del[I_FOOD] & ~0x7);
|
||||
pr("%4d", del[I_SHELL] & ~0x7);
|
||||
pr("%4d", del[I_GUN] & ~0x7);
|
||||
pr("%4d", del[I_PETROL] & ~0x7);
|
||||
pr("%4d", del[I_IRON] & ~0x7);
|
||||
pr("%4d", del[I_DUST] & ~0x7);
|
||||
pr("%4d", del[I_BAR] & ~0x7);
|
||||
pr("%4d", del[I_OIL] & ~0x7);
|
||||
pr("%4d", del[I_LCM] & ~0x7);
|
||||
pr("%4d", del[I_HCM] & ~0x7);
|
||||
pr("%4d", del[I_RAD] & ~0x7);
|
||||
pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
|
||||
pr("%4d", sect.sct_del[I_CIVIL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_MILIT] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_UW] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_FOOD] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_SHELL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_GUN] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_PETROL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_IRON] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_DUST] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_BAR] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_OIL] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_LCM] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_HCM] & ~0x7);
|
||||
pr("%4d", sect.sct_del[I_RAD] & ~0x7);
|
||||
pr("\n");
|
||||
}
|
||||
if (nsect == 0) {
|
||||
|
|
|
@ -50,9 +50,7 @@ deli(void)
|
|||
register int dir, del;
|
||||
register struct ichrstr *ich;
|
||||
register int thresh;
|
||||
int i_del;
|
||||
int sx, sy;
|
||||
int status;
|
||||
struct nstr_sect nstr;
|
||||
s_char buf[1024];
|
||||
s_char prompt[128];
|
||||
|
@ -68,13 +66,12 @@ deli(void)
|
|||
*/
|
||||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
i_del = V_DEL(ich - ichr);
|
||||
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
|
||||
del = getvar(i_del, (s_char *)§, EF_SECTOR);
|
||||
del = sect.sct_del[ich->i_vtype];
|
||||
thresh = del & ~0x7;
|
||||
dir = del & 0x7;
|
||||
|
||||
|
@ -105,16 +102,8 @@ deli(void)
|
|||
continue;
|
||||
|
||||
del = thresh + dir;
|
||||
status = putvar(i_del, del, (s_char *)§, EF_SECTOR);
|
||||
if (status < 0) {
|
||||
pr("No room for delivery path in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
} else if (!status) {
|
||||
/* Either nothing to set, or bogus amount. */
|
||||
continue;
|
||||
} else
|
||||
putsect(§);
|
||||
sect.sct_del[ich->i_vtype] = del;
|
||||
putsect(§);
|
||||
}
|
||||
|
||||
if (!del)
|
||||
|
|
|
@ -95,11 +95,11 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
|
|||
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);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (number < 0) {
|
||||
if ((deltamil = mil + number) <= 0)
|
||||
continue;
|
||||
|
@ -117,8 +117,8 @@ do_demo(struct natstr *natp, struct nstr_sect nstr, int number, s_char *p,
|
|||
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)
|
||||
|
|
|
@ -52,10 +52,7 @@ dump(void)
|
|||
int nsect;
|
||||
int n, i;
|
||||
struct nstr_sect nstr;
|
||||
int del[I_MAX + 1];
|
||||
int dist[I_MAX + 1];
|
||||
int item[I_MAX + 1];
|
||||
int cond[I_MAX + 1];
|
||||
int field[128];
|
||||
struct natstr *np;
|
||||
time_t now;
|
||||
|
@ -513,10 +510,7 @@ dump(void)
|
|||
/* census */
|
||||
if (player->god)
|
||||
pr("%d ", sect.sct_own);
|
||||
getvec(VT_DEL, del, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_DIST, dist, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_ITEM, item, (s_char *)§, EF_SECTOR);
|
||||
getvec(VT_COND, cond, (s_char *)§, EF_SECTOR);
|
||||
pr("%d %d", xrel(np, nstr.x), yrel(np, nstr.y));
|
||||
|
||||
set_coastal(§);
|
||||
|
@ -614,76 +608,76 @@ dump(void)
|
|||
break;
|
||||
/* cutoff */
|
||||
case 29:
|
||||
pr("%c", dirstr[del[I_UW] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_UW] & 0x7]);
|
||||
break;
|
||||
case 30:
|
||||
pr("%c", dirstr[del[I_FOOD] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_FOOD] & 0x7]);
|
||||
break;
|
||||
case 31:
|
||||
pr("%c", dirstr[del[I_SHELL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_SHELL] & 0x7]);
|
||||
break;
|
||||
case 32:
|
||||
pr("%c", dirstr[del[I_GUN] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_GUN] & 0x7]);
|
||||
break;
|
||||
case 33:
|
||||
pr("%c", dirstr[del[I_PETROL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_PETROL] & 0x7]);
|
||||
break;
|
||||
case 34:
|
||||
pr("%c", dirstr[del[I_IRON] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_IRON] & 0x7]);
|
||||
break;
|
||||
case 35:
|
||||
pr("%c", dirstr[del[I_DUST] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_DUST] & 0x7]);
|
||||
break;
|
||||
case 36:
|
||||
pr("%c", dirstr[del[I_BAR] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_BAR] & 0x7]);
|
||||
break;
|
||||
case 37:
|
||||
pr("%c", dirstr[del[I_OIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_OIL] & 0x7]);
|
||||
break;
|
||||
case 38:
|
||||
pr("%c", dirstr[del[I_LCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_LCM] & 0x7]);
|
||||
break;
|
||||
case 39:
|
||||
pr("%c", dirstr[del[I_HCM] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_HCM] & 0x7]);
|
||||
break;
|
||||
case 40:
|
||||
pr("%c", dirstr[del[I_RAD] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_RAD] & 0x7]);
|
||||
break;
|
||||
case 41:
|
||||
pr("%d", del[I_UW] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_UW] & ~0x7);
|
||||
break;
|
||||
case 42:
|
||||
pr("%d", del[I_FOOD] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_FOOD] & ~0x7);
|
||||
break;
|
||||
case 43:
|
||||
pr("%d", del[I_SHELL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_SHELL] & ~0x7);
|
||||
break;
|
||||
case 44:
|
||||
pr("%d", del[I_GUN] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_GUN] & ~0x7);
|
||||
break;
|
||||
case 45:
|
||||
pr("%d", del[I_PETROL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_PETROL] & ~0x7);
|
||||
break;
|
||||
case 46:
|
||||
pr("%d", del[I_IRON] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_IRON] & ~0x7);
|
||||
break;
|
||||
case 47:
|
||||
pr("%d", del[I_DUST] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_DUST] & ~0x7);
|
||||
break;
|
||||
case 48:
|
||||
pr("%d", del[I_BAR] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_BAR] & ~0x7);
|
||||
break;
|
||||
case 49:
|
||||
pr("%d", del[I_OIL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_OIL] & ~0x7);
|
||||
break;
|
||||
case 50:
|
||||
pr("%d", del[I_LCM] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_LCM] & ~0x7);
|
||||
break;
|
||||
case 51:
|
||||
pr("%d", del[I_HCM] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_HCM] & ~0x7);
|
||||
break;
|
||||
case 52:
|
||||
pr("%d", del[I_RAD] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_RAD] & ~0x7);
|
||||
break;
|
||||
/* level */
|
||||
case 53:
|
||||
|
@ -693,46 +687,46 @@ dump(void)
|
|||
pr("%d", yrel(getnatp(player->cnum), sect.sct_dist_y));
|
||||
break;
|
||||
case 55:
|
||||
pr("%d", dist[I_CIVIL]);
|
||||
pr("%d", sect.sct_dist[I_CIVIL]);
|
||||
break;
|
||||
case 56:
|
||||
pr("%d", dist[I_MILIT]);
|
||||
pr("%d", sect.sct_dist[I_MILIT]);
|
||||
break;
|
||||
case 57:
|
||||
pr("%d", dist[I_UW]);
|
||||
pr("%d", sect.sct_dist[I_UW]);
|
||||
break;
|
||||
case 58:
|
||||
pr("%d", dist[I_FOOD]);
|
||||
pr("%d", sect.sct_dist[I_FOOD]);
|
||||
break;
|
||||
case 59:
|
||||
pr("%d", dist[I_SHELL]);
|
||||
pr("%d", sect.sct_dist[I_SHELL]);
|
||||
break;
|
||||
case 60:
|
||||
pr("%d", dist[I_GUN]);
|
||||
pr("%d", sect.sct_dist[I_GUN]);
|
||||
break;
|
||||
case 61:
|
||||
pr("%d", dist[I_PETROL]);
|
||||
pr("%d", sect.sct_dist[I_PETROL]);
|
||||
break;
|
||||
case 62:
|
||||
pr("%d", dist[I_IRON]);
|
||||
pr("%d", sect.sct_dist[I_IRON]);
|
||||
break;
|
||||
case 63:
|
||||
pr("%d", dist[I_DUST]);
|
||||
pr("%d", sect.sct_dist[I_DUST]);
|
||||
break;
|
||||
case 64:
|
||||
pr("%d", dist[I_BAR]);
|
||||
pr("%d", sect.sct_dist[I_BAR]);
|
||||
break;
|
||||
case 65:
|
||||
pr("%d", dist[I_OIL]);
|
||||
pr("%d", sect.sct_dist[I_OIL]);
|
||||
break;
|
||||
case 66:
|
||||
pr("%d", dist[I_LCM]);
|
||||
pr("%d", sect.sct_dist[I_LCM]);
|
||||
break;
|
||||
case 67:
|
||||
pr("%d", dist[I_HCM]);
|
||||
pr("%d", sect.sct_dist[I_HCM]);
|
||||
break;
|
||||
case 68:
|
||||
pr("%d", dist[I_RAD]);
|
||||
pr("%d", sect.sct_dist[I_RAD]);
|
||||
break;
|
||||
case 69:
|
||||
pr("%d", sect.sct_road);
|
||||
|
@ -745,7 +739,7 @@ dump(void)
|
|||
break;
|
||||
case 72:
|
||||
if (opt_FALLOUT)
|
||||
pr("%d", cond[C_FALLOUT]);
|
||||
pr("%d", sect.sct_fallout);
|
||||
else
|
||||
pr("0");
|
||||
break;
|
||||
|
@ -753,16 +747,16 @@ dump(void)
|
|||
pr("%d", sect.sct_coastal);
|
||||
break;
|
||||
case 74:
|
||||
pr("%c", dirstr[del[I_CIVIL] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_CIVIL] & 0x7]);
|
||||
break;
|
||||
case 75:
|
||||
pr("%c", dirstr[del[I_MILIT] & 0x7]);
|
||||
pr("%c", dirstr[sect.sct_del[I_MILIT] & 0x7]);
|
||||
break;
|
||||
case 76:
|
||||
pr("%d", del[I_CIVIL] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_CIVIL] & ~0x7);
|
||||
break;
|
||||
case 77:
|
||||
pr("%d", del[I_MILIT] & ~0x7);
|
||||
pr("%d", sect.sct_del[I_MILIT] & ~0x7);
|
||||
break;
|
||||
case 78:
|
||||
pr("%d", sect.sct_terr1);
|
||||
|
|
|
@ -290,12 +290,10 @@ prsect(struct sctstr *sect)
|
|||
sect->sct_own, sect->sct_oldown, sect->sct_effic, sect->sct_mobil,
|
||||
sect->sct_min, sect->sct_gmin, sect->sct_fertil, sect->sct_oil,
|
||||
sect->sct_uran, sect->sct_work, sect->sct_loyal,
|
||||
getvar(V_CHE, (s_char *)sect, EF_SECTOR),
|
||||
getvar(V_PSTAGE, (s_char *)sect, EF_SECTOR),
|
||||
getvar(V_PTIME, (s_char *)sect, EF_SECTOR),
|
||||
getvar(V_FALLOUT, (s_char *)sect, EF_SECTOR), sect->sct_avail);
|
||||
sect->sct_che, sect->sct_pstage, sect->sct_ptime,
|
||||
sect->sct_fallout, sect->sct_avail);
|
||||
|
||||
pr("Mines <M>: %d\t", getvar(V_MINE, (s_char *)sect, EF_SECTOR));
|
||||
pr("Mines <M>: %d\t", sect->sct_mines);
|
||||
pr("Coastal <C>: %d\n", sect->sct_coastal);
|
||||
pr("Road %% <R>: %d\t", sect->sct_road);
|
||||
pr("Rail %% <r>: %d\t", sect->sct_rail);
|
||||
|
@ -434,9 +432,8 @@ pr_ship(struct shpstr *ship)
|
|||
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
|
||||
ship->shp_rpath, (int)ship->shp_rflags);
|
||||
getvec(VT_ITEM, vec, (s_char *)ship, EF_SHIP);
|
||||
pr("Plague Stage <a>: %d\n",
|
||||
getvar(V_PSTAGE, (s_char *)ship, EF_SHIP));
|
||||
pr("Plague Time <b>: %d\n", getvar(V_PTIME, (s_char *)ship, EF_SHIP));
|
||||
pr("Plague Stage <a>: %d\n", ship->shp_pstage);
|
||||
pr("Plague Time <b>: %d\n", ship->shp_ptime);
|
||||
pr("civ mil uw food shl gun pet irn dst oil lcm hcm rad\n");
|
||||
pr(" c m u f s g p i d o l h r\n");
|
||||
pr("%3d", vec[I_CIVIL]);
|
||||
|
@ -588,32 +585,32 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
|
|||
sect->sct_loyal = (u_char)new;
|
||||
break;
|
||||
case 'x':
|
||||
old = getvar(V_CHE, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_che;
|
||||
new = errcheck(arg, 0, 65536);
|
||||
pr("Guerillas in %s changed from %d to %d%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_CHE, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_che = new;
|
||||
break;
|
||||
case 'p':
|
||||
old = getvar(V_PSTAGE, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_pstage;
|
||||
new = errcheck(arg, 0, PLG_EXPOSED);
|
||||
pr("Plague stage of %s changed from %d to %d%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_PSTAGE, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_pstage = new;
|
||||
break;
|
||||
case 't':
|
||||
old = getvar(V_PTIME, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_ptime;
|
||||
new = errcheck(arg, 0, 255);
|
||||
pr("Plague time of %s changed from %d to %d%\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_PTIME, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_ptime = new;
|
||||
break;
|
||||
case 'F':
|
||||
old = getvar(V_FALLOUT, (s_char *)sect, EF_SECTOR);
|
||||
old = sect->sct_fallout;
|
||||
new = errcheck(arg, 0, 9999);
|
||||
pr("Fallout for sector %s changed from %d to %d\n",
|
||||
xyas(sect->sct_x, sect->sct_y, player->cnum), old, new);
|
||||
putvar(V_FALLOUT, new, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_fallout = new;
|
||||
break;
|
||||
case 'a':
|
||||
new = errcheck(arg, 0, 9999);
|
||||
|
@ -621,7 +618,7 @@ doland(s_char op, int arg, s_char *p, struct sctstr *sect)
|
|||
sect->sct_avail = new;
|
||||
break;
|
||||
case 'M':
|
||||
putvar(V_MINE, arg, (s_char *)sect, EF_SECTOR);
|
||||
sect->sct_mines = arg;
|
||||
pr("Mines changed to %d\n", arg);
|
||||
break;
|
||||
case 'L':
|
||||
|
@ -797,10 +794,10 @@ doship(s_char op, int arg, s_char *p, struct shpstr *ship)
|
|||
newx = newy = 0;
|
||||
switch (op) {
|
||||
case 'a':
|
||||
putvar(V_PSTAGE, arg, (s_char *)ship, EF_SHIP);
|
||||
ship->shp_pstage = arg;
|
||||
break;
|
||||
case 'b':
|
||||
putvar(V_PTIME, arg, (s_char *)ship, EF_SHIP);
|
||||
ship->shp_ptime = arg;
|
||||
break;
|
||||
case 'R':
|
||||
memcpy(ship->shp_rpath, p, sizeof(ship->shp_rpath));
|
||||
|
@ -877,82 +874,43 @@ doship(s_char op, int arg, s_char *p, struct shpstr *ship)
|
|||
ship->shp_nplane = errcheck(arg, 0, 100);
|
||||
break;
|
||||
case 'c':
|
||||
if (!putvar(V_CIVIL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_CIVIL] = arg;
|
||||
break;
|
||||
case 'm':
|
||||
if (!putvar(V_MILIT, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_MILIT] = arg;
|
||||
break;
|
||||
case 'u':
|
||||
if (!putvar(V_UW, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_UW] = arg;
|
||||
break;
|
||||
case 'f':
|
||||
if (!putvar(V_FOOD, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_FOOD] = arg;
|
||||
break;
|
||||
case 's':
|
||||
if (!putvar(V_SHELL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_SHELL] = arg;
|
||||
break;
|
||||
case 'g':
|
||||
if (!putvar(V_GUN, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_GUN] = arg;
|
||||
break;
|
||||
case 'p':
|
||||
if (!putvar(V_PETROL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_PETROL] = arg;
|
||||
break;
|
||||
case 'i':
|
||||
if (!putvar(V_IRON, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_IRON] = arg;
|
||||
break;
|
||||
case 'd':
|
||||
if (!putvar(V_DUST, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_DUST] = arg;
|
||||
break;
|
||||
case 'o':
|
||||
if (!putvar(V_OIL, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_OIL] = arg;
|
||||
break;
|
||||
case 'l':
|
||||
if (!putvar(V_LCM, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_LCM] = arg;
|
||||
break;
|
||||
case 'h':
|
||||
if (!putvar(V_HCM, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_HCM] = arg;
|
||||
break;
|
||||
case 'r':
|
||||
if (!putvar(V_RAD, arg, (s_char *)ship, EF_SHIP)) {
|
||||
pr("No room on ship!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
ship->shp_item[I_RAD] = arg;
|
||||
break;
|
||||
default:
|
||||
pr("huh? (%c)\n", op);
|
||||
|
@ -1050,82 +1008,43 @@ dounit(s_char op, int arg, s_char *p, struct lndstr *land)
|
|||
land->lnd_rflags = arg;
|
||||
break;
|
||||
case 'c':
|
||||
if (!putvar(V_CIVIL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land unit!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_CIVIL] = arg;
|
||||
break;
|
||||
case 'm':
|
||||
if (!putvar(V_MILIT, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_MILIT] = arg;
|
||||
break;
|
||||
case 'u':
|
||||
if (!putvar(V_UW, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_UW] = arg;
|
||||
break;
|
||||
case 'f':
|
||||
if (!putvar(V_FOOD, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_FOOD] = arg;
|
||||
break;
|
||||
case 's':
|
||||
if (!putvar(V_SHELL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_SHELL] = arg;
|
||||
break;
|
||||
case 'g':
|
||||
if (!putvar(V_GUN, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_GUN] = arg;
|
||||
break;
|
||||
case 'p':
|
||||
if (!putvar(V_PETROL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_PETROL] = arg;
|
||||
break;
|
||||
case 'i':
|
||||
if (!putvar(V_IRON, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_IRON] = arg;
|
||||
break;
|
||||
case 'd':
|
||||
if (!putvar(V_DUST, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_DUST] = arg;
|
||||
break;
|
||||
case 'o':
|
||||
if (!putvar(V_OIL, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_OIL] = arg;
|
||||
break;
|
||||
case 'l':
|
||||
if (!putvar(V_LCM, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_LCM] = arg;
|
||||
break;
|
||||
case 'h':
|
||||
if (!putvar(V_HCM, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_HCM] = arg;
|
||||
break;
|
||||
case 'r':
|
||||
if (!putvar(V_RAD, arg, (s_char *)land, EF_LAND)) {
|
||||
pr("No room on land!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
land->lnd_item[I_RAD] = arg;
|
||||
break;
|
||||
default:
|
||||
pr("huh? (%c)\n", op);
|
||||
|
|
|
@ -83,7 +83,7 @@ enli(void)
|
|||
continue;
|
||||
if (sect.sct_oldown != player->cnum)
|
||||
continue;
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (civ == 0)
|
||||
continue;
|
||||
if (sect.sct_loyal > 70) {
|
||||
|
@ -95,7 +95,7 @@ enli(void)
|
|||
pr("%s is out of mobility!\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
}
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
newmil = civ * 0.5;
|
||||
if (quota) {
|
||||
if (newmil > milwant - mil)
|
||||
|
@ -110,14 +110,10 @@ enli(void)
|
|||
continue;
|
||||
if (newmil > reserve)
|
||||
newmil = reserve;
|
||||
if (!putvar(V_MILIT, newmil + mil, (s_char *)§, EF_SECTOR)) {
|
||||
pr("No room for military in %s\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
sect.sct_item[I_MILIT] = newmil + mil;
|
||||
reserve -= newmil;
|
||||
totalmil += newmil;
|
||||
putvar(V_CIVIL, civ - newmil, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_CIVIL] = civ - newmil;
|
||||
pr("%3d enlisted in %s (%d)\n", newmil,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum), mil + newmil);
|
||||
if (sect.sct_mobil > 0) {
|
||||
|
|
|
@ -87,8 +87,8 @@ explore(void)
|
|||
pr("Not yours\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
infected = getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT;
|
||||
if ((amt_src = getvar(vtype, (s_char *)§, EF_SECTOR)) <= 0) {
|
||||
infected = sect.sct_pstage == PLG_INFECT;
|
||||
if ((amt_src = sect.sct_item[vtype]) <= 0) {
|
||||
pr("No %s in %s\n", ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_SYN;
|
||||
|
@ -136,14 +136,14 @@ explore(void)
|
|||
weight = amount * ip->i_lbs;
|
||||
/* remove commodities from source sector */
|
||||
getsect(x, y, &start);
|
||||
amt_src = getvar(vtype, (s_char *)&start, EF_SECTOR);
|
||||
amt_src = start.sct_item[vtype];
|
||||
amt_src -= amount;
|
||||
if (amt_src < 0) {
|
||||
pr("%s in %s are gone!\n", ip->i_name,
|
||||
xyas(start.sct_x, start.sct_y, player->cnum));
|
||||
return RET_OK;
|
||||
}
|
||||
putvar(vtype, amt_src, (s_char *)&start, EF_SECTOR);
|
||||
start.sct_item[vtype] = amt_src;
|
||||
start.sct_flags |= MOVE_IN_PROGRESS;
|
||||
putsect(&start);
|
||||
/*
|
||||
|
@ -235,18 +235,14 @@ explore(void)
|
|||
getsect(start.sct_x, start.sct_y, &start);
|
||||
start.sct_flags &= ~MOVE_IN_PROGRESS;
|
||||
putsect(&start);
|
||||
amt_dst = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
amt_dst = sect.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount) {
|
||||
amount = 32767 - amt_dst;
|
||||
pr("Only %d can be left there.\n", amount);
|
||||
if (amount <= 0)
|
||||
getsect(start.sct_x, start.sct_y, §);
|
||||
}
|
||||
if (putvar(vtype, amount + amt_dst, (s_char *)§, EF_SECTOR) < 0) {
|
||||
pr("No more room in %s.\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_OK;
|
||||
}
|
||||
sect.sct_item[vtype] = amount + amt_dst;
|
||||
/*
|
||||
* Now add commodities to destination sector,
|
||||
* along with plague that came along for the ride.
|
||||
|
@ -262,8 +258,8 @@ explore(void)
|
|||
sect.sct_mobil = 0;
|
||||
}
|
||||
}
|
||||
if (infected && getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == 0)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (infected && sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
if (vtype == V_CIVIL) {
|
||||
if (opt_NEW_WORK) {
|
||||
sect.sct_loyal = ((amt_dst * sect.sct_loyal) +
|
||||
|
|
|
@ -139,8 +139,8 @@ fuel(void)
|
|||
if (sect.sct_type == SCT_HARBR
|
||||
|| (opt_BIG_CITY && sect.sct_type == SCT_CAPIT)) {
|
||||
harbor = 1;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
if ((oil_amt + pet_amt) == 0)
|
||||
harbor = 0;
|
||||
|
||||
|
@ -161,8 +161,8 @@ fuel(void)
|
|||
|
||||
if (harbor) {
|
||||
ship_fuel = item.ship.shp_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
max_amt = mp->m_fuelc - ship_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -188,36 +188,28 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL] = max(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.ship,
|
||||
EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.ship,
|
||||
EF_SHIP);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& item.ship.shp_pstage == PLG_HEALTHY)
|
||||
item.ship.shp_pstage = PLG_EXPOSED;
|
||||
|
||||
putsect(§);
|
||||
putship(item.ship.shp_uid, &item.ship);
|
||||
|
@ -250,8 +242,8 @@ fuel(void)
|
|||
continue;
|
||||
}
|
||||
ship_fuel = item.ship.shp_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)&item2.ship, EF_SHIP);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)&item2.ship, EF_SHIP);
|
||||
oil_amt = item2.ship.shp_item[I_OIL];
|
||||
pet_amt = item2.ship.shp_item[I_PETROL];
|
||||
max_amt = mp->m_fuelc - ship_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -272,36 +264,29 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= max(oil_amt - (move_amt / 50), 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)&item2.ship, EF_SHIP);
|
||||
item2.ship.shp_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)&item2.ship, EF_SHIP) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.ship,
|
||||
EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.ship,
|
||||
EF_SHIP);
|
||||
if (item2.ship.shp_pstage == PLG_INFECT
|
||||
&& item.ship.shp_pstage == PLG_HEALTHY)
|
||||
item.ship.shp_pstage = PLG_EXPOSED;
|
||||
|
||||
putship(item.ship.shp_uid, &item.ship);
|
||||
/* quick hack -KHS */
|
||||
|
@ -323,8 +308,8 @@ fuel(void)
|
|||
lcp = &lchr[(int)item.land.lnd_type];
|
||||
|
||||
sector = 1;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
|
||||
if ((oil_amt + pet_amt) == 0)
|
||||
sector = 0;
|
||||
|
@ -337,8 +322,8 @@ fuel(void)
|
|||
|
||||
if (sector) {
|
||||
land_fuel = item.land.lnd_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)§, EF_SECTOR);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)§, EF_SECTOR);
|
||||
oil_amt = sect.sct_item[I_OIL];
|
||||
pet_amt = sect.sct_item[I_PETROL];
|
||||
max_amt = item.land.lnd_fuelc - land_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -364,36 +349,28 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL] = max(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.land,
|
||||
EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.land,
|
||||
EF_LAND);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& item.land.lnd_pstage == PLG_HEALTHY)
|
||||
item.land.lnd_pstage = PLG_EXPOSED;
|
||||
|
||||
putsect(§);
|
||||
putland(item.land.lnd_uid, &item.land);
|
||||
|
@ -427,8 +404,8 @@ fuel(void)
|
|||
continue;
|
||||
}
|
||||
land_fuel = item.land.lnd_fuel;
|
||||
oil_amt = getvar(V_OIL, (s_char *)&item2.land, EF_LAND);
|
||||
pet_amt = getvar(V_PETROL, (s_char *)&item2.land, EF_LAND);
|
||||
oil_amt = item2.land.lnd_item[I_OIL];
|
||||
pet_amt = item2.land.lnd_item[I_PETROL];
|
||||
max_amt = item.land.lnd_fuelc - land_fuel;
|
||||
|
||||
if (max_amt == 0) {
|
||||
|
@ -449,36 +426,29 @@ fuel(void)
|
|||
if ((pet_amt * 5) >= move_amt) {
|
||||
extra = ((float)move_amt / 5.0) - (move_amt / 5);
|
||||
if (extra > 0.0)
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)) - 1, 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5) - 1, 0);
|
||||
else
|
||||
putvar(V_PETROL,
|
||||
max((pet_amt - (move_amt / 5)), 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_PETROL]
|
||||
= max((pet_amt - move_amt / 5), 0);
|
||||
} else {
|
||||
putvar(V_PETROL, 0, (s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_PETROL] = 0;
|
||||
move_amt -= pet_amt * 5;
|
||||
extra = ((float)move_amt / 50.0) - (move_amt / 50);
|
||||
putvar(V_OIL, max(oil_amt - (move_amt / 50), 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= max(oil_amt - move_amt / 50, 0);
|
||||
if (extra > 0.0)
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)) - 1, 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50) - 1, 0);
|
||||
else
|
||||
putvar(V_OIL,
|
||||
max((oil_amt - (move_amt / 50)), 0),
|
||||
(s_char *)&item2.land, EF_LAND);
|
||||
item2.land.lnd_item[I_OIL]
|
||||
= max((oil_amt - move_amt / 50), 0);
|
||||
}
|
||||
|
||||
/* load plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)&item2.land, EF_LAND) ==
|
||||
PLG_INFECT && getvar(V_PSTAGE,
|
||||
(s_char *)&item.land,
|
||||
EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&item.land,
|
||||
EF_LAND);
|
||||
if (item2.land.lnd_pstage == PLG_INFECT
|
||||
&& item.land.lnd_pstage == PLG_HEALTHY)
|
||||
item.land.lnd_pstage = PLG_EXPOSED;
|
||||
|
||||
putland(item.land.lnd_uid, &item.land);
|
||||
/* quick hack -KHS */
|
||||
|
|
|
@ -69,18 +69,14 @@ give(void)
|
|||
return RET_SYN;
|
||||
if ((amt = atoi(p)) == 0)
|
||||
return RET_SYN;
|
||||
n = getvar(ip->i_vtype, (s_char *)§, EF_SECTOR);
|
||||
n = sect.sct_item[ip->i_vtype];
|
||||
if (amt < 0 && -amt > n) {
|
||||
m = 0;
|
||||
} else if (amt > 0 && amt + n > 9990) {
|
||||
m = 9990;
|
||||
} else
|
||||
m = n + amt;
|
||||
if (putvar(ip->i_vtype, m, (s_char *)§, EF_SECTOR) < 0) {
|
||||
pr("No room to store %s in %s\n", ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
return RET_FAIL;
|
||||
}
|
||||
sect.sct_item[ip->i_vtype] = m;
|
||||
putsect(§);
|
||||
if (sect.sct_own != 0 && m != n) {
|
||||
if (m > n) {
|
||||
|
|
|
@ -97,7 +97,7 @@ hard(void)
|
|||
prplane(&pln), xyas(pln.pln_x, pln.pln_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
hcm = getvar(V_HCM, (s_char *)§, EF_SECTOR);
|
||||
hcm = sect.sct_item[I_HCM];
|
||||
if (hcm == 0) {
|
||||
pr("No hcm in %s\n", xyas(pln.pln_x, pln.pln_y, player->cnum));
|
||||
continue;
|
||||
|
@ -112,7 +112,7 @@ hard(void)
|
|||
pln.pln_harden += n;
|
||||
player->dolcost += (5.0 * n);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
putvar(V_HCM, hcm - n, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_HCM] = hcm - n;
|
||||
putsect(§);
|
||||
pr("%s hardened to %d\n", prplane(&pln), pln.pln_harden);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ hidd(void)
|
|||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
int cond[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -68,14 +67,13 @@ hidd(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%3d ", sect.sct_own);
|
||||
getvec(VT_COND, cond, (s_char *)§, EF_SECTOR);
|
||||
prxy("%4d,%-4d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c %3d%% %3d %3d %3d %3d %3d %3d %3d",
|
||||
dchr[sect.sct_type].d_mnem, sect.sct_effic,
|
||||
sect.sct_oldown, sect.sct_loyal,
|
||||
get_che_cnum(cond[C_CHE]),
|
||||
get_che_value(cond[C_CHE]),
|
||||
cond[C_PSTAGE], cond[C_PTIME], cond[C_MINE]);
|
||||
get_che_cnum(sect.sct_che),
|
||||
get_che_value(sect.sct_che),
|
||||
sect.sct_pstage, sect.sct_ptime, sect.sct_mines);
|
||||
pr("\n");
|
||||
}
|
||||
if (nsect == 0) {
|
||||
|
|
|
@ -48,7 +48,6 @@ leve(void)
|
|||
struct sctstr sect;
|
||||
int nsect;
|
||||
struct nstr_sect nstr;
|
||||
int dist[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -65,24 +64,23 @@ leve(void)
|
|||
}
|
||||
if (player->god)
|
||||
pr("%2d ", sect.sct_own);
|
||||
getvec(VT_DIST, dist, (s_char *)§, EF_SECTOR);
|
||||
prxy("%3d,%-3d", nstr.x, nstr.y, player->cnum);
|
||||
pr(" %c ", dchr[sect.sct_type].d_mnem);
|
||||
prxy("%3d,%-3d", sect.sct_dist_x, sect.sct_dist_y, player->cnum);
|
||||
pr(" %4d", dist[I_CIVIL]);
|
||||
pr("%4d", dist[I_MILIT]);
|
||||
pr("%4d", dist[I_UW]);
|
||||
pr("%5d", dist[I_FOOD]);
|
||||
pr("%4d", dist[I_SHELL]);
|
||||
pr("%4d", dist[I_GUN]);
|
||||
pr("%4d", dist[I_PETROL]);
|
||||
pr("%5d", dist[I_IRON]);
|
||||
pr("%5d", dist[I_DUST]);
|
||||
pr("%4d", dist[I_BAR]);
|
||||
pr("%4d", dist[I_OIL]);
|
||||
pr("%4d", dist[I_LCM]);
|
||||
pr("%4d", dist[I_HCM]);
|
||||
pr("%4d", dist[I_RAD]);
|
||||
pr(" %4d", sect.sct_dist[I_CIVIL]);
|
||||
pr("%4d", sect.sct_dist[I_MILIT]);
|
||||
pr("%4d", sect.sct_dist[I_UW]);
|
||||
pr("%5d", sect.sct_dist[I_FOOD]);
|
||||
pr("%4d", sect.sct_dist[I_SHELL]);
|
||||
pr("%4d", sect.sct_dist[I_GUN]);
|
||||
pr("%4d", sect.sct_dist[I_PETROL]);
|
||||
pr("%5d", sect.sct_dist[I_IRON]);
|
||||
pr("%5d", sect.sct_dist[I_DUST]);
|
||||
pr("%4d", sect.sct_dist[I_BAR]);
|
||||
pr("%4d", sect.sct_dist[I_OIL]);
|
||||
pr("%4d", sect.sct_dist[I_LCM]);
|
||||
pr("%4d", sect.sct_dist[I_HCM]);
|
||||
pr("%4d", sect.sct_dist[I_RAD]);
|
||||
pr("\n");
|
||||
}
|
||||
if (nsect == 0) {
|
||||
|
|
|
@ -194,12 +194,12 @@ load(void)
|
|||
return retval;
|
||||
}
|
||||
/* load/unload plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&ship, EF_SHIP);
|
||||
if (getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& ship.shp_pstage == PLG_HEALTHY)
|
||||
ship.shp_pstage = PLG_EXPOSED;
|
||||
if (ship.shp_pstage == PLG_INFECT
|
||||
&& sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
putsect(§);
|
||||
putship(ship.shp_uid, &ship);
|
||||
}
|
||||
|
@ -302,12 +302,12 @@ lload(void)
|
|||
return retval;
|
||||
}
|
||||
/* load/unload plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&land, EF_LAND);
|
||||
if (getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_pstage == PLG_INFECT
|
||||
&& land.lnd_pstage == PLG_HEALTHY)
|
||||
land.lnd_pstage = PLG_EXPOSED;
|
||||
if (land.lnd_pstage == PLG_INFECT
|
||||
&& sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
|
||||
putsect(§);
|
||||
putland(land.lnd_uid, &land);
|
||||
|
@ -763,8 +763,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
|||
load_unload = LOAD;
|
||||
} else if (!amount)
|
||||
return 0;
|
||||
ship_amt = getvar(item, (s_char *)sp, EF_SHIP);
|
||||
sect_amt = getvar(item, (s_char *)sectp, EF_SECTOR);
|
||||
ship_amt = sp->shp_item[item];
|
||||
sect_amt = sectp->sct_item[item];
|
||||
if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
|
||||
pr("%s civilians refuse to %s at %s!\n",
|
||||
load_unload == UNLOAD ? "Your" : "Foreign",
|
||||
|
@ -799,8 +799,8 @@ load_comm_ship(struct sctstr *sectp, struct shpstr *sp,
|
|||
return RET_FAIL;
|
||||
if (!still_ok_ship(sectp, sp))
|
||||
return RET_SYN;
|
||||
putvar(item, sect_amt - move_amt, (s_char *)sectp, EF_SECTOR);
|
||||
putvar(item, ship_amt + move_amt, (s_char *)sp, EF_SHIP);
|
||||
sectp->sct_item[item] = sect_amt - move_amt;
|
||||
sp->shp_item[item] = ship_amt + move_amt;
|
||||
if (load_unload == LOAD) {
|
||||
pr("%d %s loaded onto %s at %s\n",
|
||||
move_amt,
|
||||
|
@ -989,8 +989,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
|||
return 0;
|
||||
}
|
||||
|
||||
land_amt = getvar(item, (s_char *)lp, EF_LAND);
|
||||
sect_amt = getvar(item, (s_char *)sectp, EF_SECTOR);
|
||||
land_amt = lp->lnd_item[item];
|
||||
sect_amt = sectp->sct_item[item];
|
||||
if (sectp->sct_oldown != player->cnum && item == V_CIVIL) {
|
||||
pr("%s civilians refuse to %s at %s!\n",
|
||||
load_unload == UNLOAD ? "Your" : "Foreign",
|
||||
|
@ -1020,8 +1020,8 @@ load_comm_land(struct sctstr *sectp, struct lndstr *lp,
|
|||
move_amt = load_unload * min(amount, max_amt);
|
||||
if (move_amt == 0)
|
||||
return 0;
|
||||
putvar(item, sect_amt - move_amt, (s_char *)sectp, EF_SECTOR);
|
||||
putvar(item, land_amt + move_amt, (s_char *)lp, EF_LAND);
|
||||
sectp->sct_item[item] = sect_amt - move_amt;
|
||||
lp->lnd_item[item] = land_amt + move_amt;
|
||||
|
||||
/* Did we put mils onto this unit? If so, reset the fortification */
|
||||
if (item == V_MILIT && move_amt > 0)
|
||||
|
|
|
@ -92,8 +92,8 @@ look(void)
|
|||
dchr[sect.sct_type].d_mnem, 0);
|
||||
pr(" %d%% efficient ", player->owner ? sect.sct_effic :
|
||||
roundintby((int)sect.sct_effic, 10));
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
if (civ)
|
||||
pr("with %s%d civ ", player->owner ? "" : "approx ",
|
||||
player->owner ? civ : roundintby(civ, 10));
|
||||
|
@ -226,8 +226,8 @@ llook(void)
|
|||
dchr[sect.sct_type].d_mnem, 0);
|
||||
pr(" %d%% efficient ", player->owner ? sect.sct_effic :
|
||||
roundintby((int)sect.sct_effic, 10));
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
if (civ)
|
||||
pr("with %s%d civ ", player->owner ? "" :
|
||||
"approx ", player->owner ? civ : roundintby(civ, 10));
|
||||
|
|
|
@ -88,7 +88,7 @@ ltend(void)
|
|||
return RET_FAIL;
|
||||
if ((amt = atoi(p)) == 0)
|
||||
break;
|
||||
ontender = getvar(ip->i_vtype, (s_char *)&tender, EF_SHIP);
|
||||
ontender = tender.shp_item[ip->i_vtype];
|
||||
if (ontender == 0 && amt > 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&tender));
|
||||
return RET_FAIL;
|
||||
|
@ -114,7 +114,7 @@ ltend(void)
|
|||
|
||||
if (target.lnd_ship != tender.shp_uid)
|
||||
continue;
|
||||
ontarget = getvar(ip->i_vtype, (s_char *)&target, EF_LAND);
|
||||
ontarget = target.lnd_item[ip->i_vtype];
|
||||
if (ontarget == 0 && amt < 0) {
|
||||
pr("No %s on %s\n",
|
||||
ip->i_name, prship((struct shpstr *)&target));
|
||||
|
@ -132,8 +132,7 @@ ltend(void)
|
|||
transfer = min(maxtender - ontender, transfer);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget - transfer,
|
||||
(s_char *)&target, EF_LAND);
|
||||
target.lnd_item[ip->i_vtype] = ontarget - transfer;
|
||||
ontender += transfer;
|
||||
total += transfer;
|
||||
} else {
|
||||
|
@ -142,8 +141,7 @@ ltend(void)
|
|||
transfer = min(transfer, maxtarget - ontarget);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget + transfer,
|
||||
(s_char *)&target, EF_LAND);
|
||||
target.lnd_item[ip->i_vtype] = ontarget + transfer;
|
||||
ontender -= transfer;
|
||||
total += transfer;
|
||||
}
|
||||
|
@ -157,7 +155,7 @@ ltend(void)
|
|||
pr("%d total %s transferred %s %s\n",
|
||||
total, ip->i_name, (amt > 0) ? "off of" : "to",
|
||||
prship(&tender));
|
||||
putvar(ip->i_vtype, ontender, (s_char *)&tender, EF_SHIP);
|
||||
tender.shp_item[ip->i_vtype] = ontender;
|
||||
tender.shp_mission = 0;
|
||||
putship(tender.shp_uid, &tender);
|
||||
}
|
||||
|
@ -167,10 +165,8 @@ ltend(void)
|
|||
static void
|
||||
expose_land(struct shpstr *s1, struct lndstr *l1)
|
||||
{
|
||||
if (getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)l1, EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)l1, EF_LAND);
|
||||
if (getvar(V_PSTAGE, (s_char *)l1, EF_LAND) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)s1, EF_SHIP);
|
||||
if (s1->shp_pstage == PLG_INFECT && l1->lnd_pstage == PLG_HEALTHY)
|
||||
l1->lnd_pstage = PLG_EXPOSED;
|
||||
if (l1->lnd_pstage == PLG_INFECT && s1->shp_pstage == PLG_HEALTHY)
|
||||
s1->shp_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ multifire(void)
|
|||
}
|
||||
resupply_commod(&fland, I_SHELL); /* Get more shells */
|
||||
putland(fland.lnd_uid, &fland);
|
||||
if (getvar(V_SHELL, (s_char *)&fland, EF_LAND) == 0) {
|
||||
if (fland.lnd_item[I_SHELL] == 0) {
|
||||
pr("%s -- not enough shells\n", prland(&fland));
|
||||
continue;
|
||||
}
|
||||
|
@ -207,11 +207,11 @@ multifire(void)
|
|||
continue;
|
||||
if (item.ship.shp_own != player->cnum)
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)&item.ship, EF_SHIP) < 1) {
|
||||
if (item.ship.shp_item[I_MILIT] < 1) {
|
||||
pr("Not enough mil on ship #%d\n", item.ship.shp_uid);
|
||||
continue;
|
||||
}
|
||||
gun = getvar(V_GUN, (s_char *)&item.ship, EF_SHIP);
|
||||
gun = item.ship.shp_item[I_GUN];
|
||||
gun = min(gun, item.ship.shp_glim);
|
||||
if (item.ship.shp_frnge == 0) {
|
||||
pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
|
||||
|
@ -221,7 +221,7 @@ multifire(void)
|
|||
pr("Not enough guns on ship #%d\n", item.ship.shp_uid);
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_SHELL, (s_char *)&item.ship, EF_SHIP) == 0) {
|
||||
if (item.ship.shp_item[I_SHELL] == 0) {
|
||||
pr("Not enough shells on ship #%d\n", item.ship.shp_uid);
|
||||
continue;
|
||||
}
|
||||
|
@ -241,17 +241,17 @@ multifire(void)
|
|||
pr("Fort not efficient enough to fire!\n");
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_GUN, (s_char *)&item.sect, EF_SECTOR) == 0) {
|
||||
if (item.sect.sct_item[I_GUN] == 0) {
|
||||
pr("Not enough guns in sector %s!\n",
|
||||
xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_SHELL, (s_char *)&item.sect, EF_SECTOR) == 0) {
|
||||
if (item.sect.sct_item[I_SHELL] == 0) {
|
||||
pr("Not enough shells in sector %s!\n",
|
||||
xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_MILIT, (s_char *)&item.sect, EF_SECTOR) < 5) {
|
||||
if (item.sect.sct_item[I_MILIT] < 5) {
|
||||
pr("Not enough military in sector %s!\n",
|
||||
xyas(item.sect.sct_x, item.sect.sct_y, player->cnum));
|
||||
continue;
|
||||
|
@ -327,17 +327,17 @@ multifire(void)
|
|||
}
|
||||
*/
|
||||
attacker = targ_ship;
|
||||
if ((mil = getvar(V_MILIT, (s_char *)&fship, EF_SHIP)) < 1) {
|
||||
if ((mil = fship.shp_item[I_MILIT]) < 1) {
|
||||
pr("Not enough military for firing crew.\n");
|
||||
continue;
|
||||
}
|
||||
gun = getvar(V_GUN, (s_char *)&fship, EF_SHIP);
|
||||
gun = fship.shp_item[I_GUN];
|
||||
gun = min(gun, fship.shp_glim);
|
||||
if (fship.shp_frnge == 0 || gun == 0) {
|
||||
pr("Insufficient arms.\n");
|
||||
continue;
|
||||
}
|
||||
shell = getvar(V_SHELL, (s_char *)&fship, EF_SHIP);
|
||||
shell = fship.shp_item[I_SHELL];
|
||||
if (shell < 2)
|
||||
shell += supply_commod(fship.shp_own, fship.shp_x,
|
||||
fship.shp_y, I_SHELL, 2 - shell);
|
||||
|
@ -377,7 +377,7 @@ multifire(void)
|
|||
guneff = seagun(fship.shp_effic, shots);
|
||||
dam = (int)guneff;
|
||||
shell -= ldround(((double)shots) / 2.0, 1);
|
||||
putvar(V_SHELL, shell, (s_char *)&fship, EF_SHIP);
|
||||
fship.shp_item[I_SHELL] = shell;
|
||||
putship(fship.shp_uid, &fship);
|
||||
if (opt_NOMOBCOST == 0)
|
||||
fship.shp_mobil = max(fship.shp_mobil - 15, -100);
|
||||
|
@ -402,12 +402,12 @@ multifire(void)
|
|||
pr("Unit %d cannot fire!\n", fland.lnd_uid);
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_SHELL, (s_char *)&fland, EF_LAND) == 0) {
|
||||
if (fland.lnd_item[I_SHELL] == 0) {
|
||||
pr("%s -- not enough shells\n", prland(&fland));
|
||||
continue;
|
||||
}
|
||||
|
||||
shell = getvar(V_SHELL, (s_char *)&fland, EF_LAND);
|
||||
shell = fland.lnd_item[I_SHELL];
|
||||
|
||||
range = techfact((int)fland.lnd_tech,
|
||||
(double)fland.lnd_frg / 2.0);
|
||||
|
@ -419,7 +419,7 @@ multifire(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
gun = getvar(V_GUN, (s_char *)&fland, EF_LAND);
|
||||
gun = fland.lnd_item[I_GUN];
|
||||
if (gun <= 0) {
|
||||
pr("%s -- not enough guns\n", prland(&fland));
|
||||
continue;
|
||||
|
@ -451,11 +451,11 @@ multifire(void)
|
|||
}
|
||||
}
|
||||
attacker = targ_land;
|
||||
if ((gun = getvar(V_GUN, (s_char *)&fsect, EF_SECTOR)) == 0) {
|
||||
if ((gun = fsect.sct_item[I_GUN]) == 0) {
|
||||
pr("Insufficient arms.\n");
|
||||
continue;
|
||||
}
|
||||
shell = getvar(V_SHELL, (s_char *)&fsect, EF_SECTOR);
|
||||
shell = fsect.sct_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell += supply_commod(fsect.sct_own, fsect.sct_x,
|
||||
fsect.sct_y, I_SHELL, 1);
|
||||
|
@ -463,7 +463,7 @@ multifire(void)
|
|||
pr("Klick! ...\n");
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_MILIT, (s_char *)&fsect, EF_SECTOR) < 5) {
|
||||
if (fsect.sct_item[I_MILIT] < 5) {
|
||||
pr("Not enough military for firing crew.\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -481,7 +481,7 @@ multifire(void)
|
|||
guneff = landgun((int)fsect.sct_effic, gun);
|
||||
dam = (int)guneff;
|
||||
shell--;
|
||||
putvar(V_SHELL, shell, (s_char *)&fsect, EF_SECTOR);
|
||||
fsect.sct_item[I_SHELL] = shell;
|
||||
putsect(&fsect);
|
||||
}
|
||||
trange = mapdist(x, y, fx, fy);
|
||||
|
@ -995,8 +995,8 @@ use_ammo(struct emp_qelem *list)
|
|||
struct shpstr ship;
|
||||
struct lndstr land;
|
||||
struct sctstr sect;
|
||||
int shell, type;
|
||||
s_char *ptr;
|
||||
int shell;
|
||||
u_short *item;
|
||||
double mobcost;
|
||||
struct mchrstr *mcp;
|
||||
|
||||
|
@ -1006,14 +1006,13 @@ use_ammo(struct emp_qelem *list)
|
|||
fp = (struct flist *)qp;
|
||||
if (fp->type == targ_ship) {
|
||||
getship(fp->uid, &ship);
|
||||
ptr = (s_char *)&ship;
|
||||
type = EF_SHIP;
|
||||
item = ship.shp_item;
|
||||
if (mchr[(int)ship.shp_type].m_flags & M_SUB) {
|
||||
shell = getvar(V_SHELL, ptr, type);
|
||||
shell = item[I_SHELL];
|
||||
shell--;
|
||||
if (shell < 0)
|
||||
shell = 0;
|
||||
putvar(V_SHELL, shell, ptr, type);
|
||||
item[I_SHELL] = shell;
|
||||
putship(ship.shp_uid, &ship);
|
||||
mcp = &mchr[(int)ship.shp_type];
|
||||
mobcost = ship.shp_effic * 0.01 * ship.shp_speed;
|
||||
|
@ -1025,18 +1024,16 @@ use_ammo(struct emp_qelem *list)
|
|||
}
|
||||
} else if (fp->type == targ_land) {
|
||||
getsect(fp->x, fp->y, §);
|
||||
ptr = (s_char *)§
|
||||
type = EF_SECTOR;
|
||||
item = sect.sct_item;
|
||||
} else {
|
||||
getland(fp->uid, &land);
|
||||
ptr = (s_char *)&land;
|
||||
type = EF_LAND;
|
||||
item = land.lnd_item;
|
||||
}
|
||||
shell = getvar(V_SHELL, ptr, type);
|
||||
shell = item[I_SHELL];
|
||||
shell--;
|
||||
if (shell < 0)
|
||||
shell = 0;
|
||||
putvar(V_SHELL, shell, ptr, type);
|
||||
item[I_SHELL] = shell;
|
||||
if (fp->type == targ_ship)
|
||||
putship(ship.shp_uid, &ship);
|
||||
else if (fp->type == targ_land)
|
||||
|
|
|
@ -56,7 +56,6 @@ mine(void)
|
|||
int mines;
|
||||
int shells;
|
||||
int mines_avail;
|
||||
int mines_there;
|
||||
|
||||
if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -70,7 +69,7 @@ mine(void)
|
|||
mp = &mchr[(int)ship.shp_type];
|
||||
if ((mp->m_flags & M_MINE) == 0)
|
||||
continue;
|
||||
if ((shells = getvar(V_SHELL, (s_char *)&ship, EF_SHIP)) == 0)
|
||||
if ((shells = ship.shp_item[I_SHELL]) == 0)
|
||||
continue;
|
||||
mines_avail = min(shells, mines);
|
||||
if (getsect(ship.shp_x, ship.shp_y, §) == 0 ||
|
||||
|
@ -78,10 +77,8 @@ mine(void)
|
|||
pr("You can't lay mines there!!\n");
|
||||
continue;
|
||||
}
|
||||
mines_there = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_SHELL, shells - mines_avail, (s_char *)&ship, EF_SHIP);
|
||||
putvar(V_MINE, mines_avail + mines_there, (s_char *)§,
|
||||
EF_SECTOR);
|
||||
sect.sct_mines += mines_avail;
|
||||
ship.shp_item[I_SHELL] = shells - mines_avail;
|
||||
putsect(§);
|
||||
ship.shp_mission = 0;
|
||||
putship(ship.shp_uid, &ship);
|
||||
|
@ -104,7 +101,6 @@ landmine(void)
|
|||
struct lchrstr *lp;
|
||||
struct nstr_item ni;
|
||||
int shells;
|
||||
int mines_there;
|
||||
int mines_wanted;
|
||||
int mines_laid;
|
||||
int total_mines_laid;
|
||||
|
@ -124,7 +120,7 @@ landmine(void)
|
|||
}
|
||||
resupply_commod(&land, I_SHELL);
|
||||
putland(land.lnd_uid, &land);
|
||||
if (!(shells = getvar(V_SHELL, (s_char *)&land, EF_LAND)))
|
||||
if (!(shells = land.lnd_item[I_SHELL]))
|
||||
continue;
|
||||
shells = min(shells, land.lnd_mobil);
|
||||
if (!getsect(land.lnd_x, land.lnd_y, §) ||
|
||||
|
@ -132,10 +128,9 @@ landmine(void)
|
|||
pr("You can't lay mines there!!\n");
|
||||
continue;
|
||||
}
|
||||
mines_there = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_own == sect.sct_oldown)
|
||||
pr("There are currently %d mines in %s\n",
|
||||
mines_there, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sect.sct_mines, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sprintf(prompt, "Drop how many mines from %s? ", prland(&land));
|
||||
mines_wanted = onearg(player->argp[2], prompt);
|
||||
if (!check_land_ok(&land))
|
||||
|
@ -146,18 +141,17 @@ landmine(void)
|
|||
total_mines_laid = 0;
|
||||
while (shells > 0 && total_mines_laid < mines_wanted) {
|
||||
mines_laid = min(shells, mines_wanted - total_mines_laid);
|
||||
putvar(V_SHELL, shells - mines_laid, (s_char *)&land, EF_LAND);
|
||||
land.lnd_item[I_SHELL] = shells - mines_laid;
|
||||
land.lnd_mobil -= mines_laid;
|
||||
putland(land.lnd_uid, &land);
|
||||
resupply_commod(&land, I_SHELL); /* Get more shells */
|
||||
putland(land.lnd_uid, &land);
|
||||
total_mines_laid += mines_laid;
|
||||
shells = getvar(V_SHELL, (s_char *)&land, EF_LAND);
|
||||
shells = land.lnd_item[I_SHELL];
|
||||
shells = min(shells, land.lnd_mobil);
|
||||
}
|
||||
getsect(sect.sct_x, sect.sct_y, §);
|
||||
putvar(V_MINE, total_mines_laid + mines_there, (s_char *)§,
|
||||
EF_SECTOR);
|
||||
sect.sct_mines += total_mines_laid;
|
||||
putsect(§);
|
||||
if (total_mines_laid == mines_wanted) {
|
||||
pr("%s laid a total of %d mines in %s",
|
||||
|
|
|
@ -103,16 +103,15 @@ move(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if ((getvar(V_MILIT, (s_char *)§, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)§, EF_SECTOR)) {
|
||||
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to move goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
stype = sect.sct_type;
|
||||
dp = &dchr[stype];
|
||||
infected = getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == PLG_INFECT;
|
||||
amt_src = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
infected = sect.sct_pstage == PLG_INFECT;
|
||||
amt_src = sect.sct_item[vtype];
|
||||
if (!istest && amt_src <= 0) {
|
||||
pr("No %s in %s\n", ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
@ -179,7 +178,7 @@ move(void)
|
|||
pr("Somebody has captured that sector!\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
amt_src = getvar(vtype, (s_char *)&start, EF_SECTOR);
|
||||
amt_src = start.sct_item[vtype];
|
||||
if (amt_src < amount) {
|
||||
pr("Only %d %s left in %s!\n", amt_src,
|
||||
ip->i_name, xyas(start.sct_x, start.sct_y, player->cnum));
|
||||
|
@ -188,7 +187,7 @@ move(void)
|
|||
} else
|
||||
amt_src -= amount;
|
||||
|
||||
putvar(vtype, amt_src, (s_char *)&start, EF_SECTOR);
|
||||
start.sct_item[vtype] = amt_src;
|
||||
start.sct_flags |= MOVE_IN_PROGRESS;
|
||||
putsect(&start);
|
||||
}
|
||||
|
@ -252,13 +251,13 @@ move(void)
|
|||
pr("Somebody has captured that sector!\n");
|
||||
getsect(x, y, §);
|
||||
}
|
||||
if (vtype == V_CIVIL && getvar(V_CIVIL, (s_char *)§, EF_SECTOR) &&
|
||||
sect.sct_oldown != player->cnum) {
|
||||
if (vtype == V_CIVIL && sect.sct_item[I_CIVIL]
|
||||
&& sect.sct_oldown != player->cnum) {
|
||||
pr("Your civilians don't want to stay!\n");
|
||||
getsect(x, y, §);
|
||||
}
|
||||
|
||||
amt_dst = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
amt_dst = sect.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount) {
|
||||
pr("Only enough room for %d in %s. The goods will be returned.\n",
|
||||
32767 - amt_dst, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
|
@ -281,7 +280,7 @@ move(void)
|
|||
getsect(x + diroff[n][0], y + diroff[n][1], &tsct);
|
||||
if (tsct.sct_own != player->cnum)
|
||||
continue;
|
||||
amt_dst = getvar(vtype, (s_char *)&tsct, EF_SECTOR);
|
||||
amt_dst = tsct.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount)
|
||||
continue;
|
||||
n = -1;
|
||||
|
@ -308,26 +307,21 @@ move(void)
|
|||
getsect(tsct.sct_x, tsct.sct_y, §);
|
||||
}
|
||||
|
||||
amt_dst = getvar(vtype, (s_char *)§, EF_SECTOR);
|
||||
amt_dst = sect.sct_item[vtype];
|
||||
if (32767 - amt_dst < amount) {
|
||||
amount = 32767 - amt_dst;
|
||||
pr("Only room for %d, the rest were lost.\n", amount);
|
||||
}
|
||||
if (istest)
|
||||
return RET_OK;
|
||||
if (putvar(vtype, amount + amt_dst, (s_char *)§, EF_SECTOR) < 0) {
|
||||
pr("No more room in %s. The goods were lost.\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
/* charge the player mobility anyway */
|
||||
amount = 0;
|
||||
}
|
||||
sect.sct_item[vtype] = amount + amt_dst;
|
||||
/*
|
||||
* Now add commodities to destination sector,
|
||||
* along with plague that came along for the ride.
|
||||
* Takeover unowned sectors if not deity.
|
||||
*/
|
||||
if (infected && getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) == 0)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (infected && sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
if (vtype == V_CIVIL) {
|
||||
if (opt_NEW_WORK) {
|
||||
sect.sct_loyal = ((amt_dst * sect.sct_loyal) +
|
||||
|
@ -398,8 +392,8 @@ would_abandon(struct sctstr *sp, int vtype, int amnt, struct lndstr *lp)
|
|||
if ((vtype != V_CIVIL) && (vtype != V_MILIT))
|
||||
return 0;
|
||||
|
||||
mil = getvar(V_MILIT, (s_char *)sp, EF_SECTOR);
|
||||
civs = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR);
|
||||
mil = sp->sct_item[I_MILIT];
|
||||
civs = sp->sct_item[I_CIVIL];
|
||||
|
||||
if (vtype == V_MILIT)
|
||||
mil -= amnt;
|
||||
|
|
|
@ -68,8 +68,8 @@ nati(void)
|
|||
pr("No capital. (was at %s)\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
else {
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
pr("%d%% eff %s at %s has %d civilian%s & %d military\n",
|
||||
sect.sct_effic,
|
||||
(sect.sct_type ==
|
||||
|
|
|
@ -160,13 +160,10 @@ new(void)
|
|||
sect.sct_min = 100;
|
||||
sect.sct_gmin = 100;
|
||||
}
|
||||
if (opt_RES_POP)
|
||||
putvar(V_CIVIL, 550, (s_char *)§, EF_SECTOR);
|
||||
else
|
||||
putvar(V_CIVIL, 999, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_MILIT, 55, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_FOOD, 1000, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_UW, 75, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_CIVIL] = opt_RES_POP ? 550 : 999;
|
||||
sect.sct_item[I_MILIT] = 55;
|
||||
sect.sct_item[I_FOOD] = 1000;
|
||||
sect.sct_item[I_UW] = 75;
|
||||
putsect(§);
|
||||
getsect(x + 2, y, §);
|
||||
sect.sct_own = num;
|
||||
|
@ -188,13 +185,10 @@ new(void)
|
|||
sect.sct_min = 100;
|
||||
sect.sct_gmin = 100;
|
||||
}
|
||||
if (opt_RES_POP)
|
||||
putvar(V_CIVIL, 550, (s_char *)§, EF_SECTOR);
|
||||
else
|
||||
putvar(V_CIVIL, 999, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_FOOD, 100, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_MILIT, 55, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_UW, 75, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_CIVIL] = opt_RES_POP ? 550 : 999;
|
||||
sect.sct_item[I_MILIT] = 55;
|
||||
sect.sct_item[I_FOOD] = 100;
|
||||
sect.sct_item[I_UW] = 75;
|
||||
putsect(§);
|
||||
natp->nat_btu = max_btus;
|
||||
natp->nat_stat &= ~STAT_NEW;
|
||||
|
@ -370,7 +364,6 @@ deity_build_land(int type, coord x, coord y, natid own, int tlev)
|
|||
land.lnd_maxlight = (int)LND_XPL(lp->l_nxlight, tlev - lp->l_tech);
|
||||
land.lnd_maxland = (int)LND_MXL(lp->l_mxland, tlev - lp->l_tech);
|
||||
|
||||
memset(lvec, 0, sizeof(lvec));
|
||||
getvec(VT_ITEM, lvec, (s_char *)&land, EF_LAND);
|
||||
lvec[I_FOOD] +=
|
||||
vl_find(V_FOOD, lp->l_vtype, lp->l_vamt, (int)lp->l_nv);
|
||||
|
|
|
@ -264,8 +264,7 @@ prod(void)
|
|||
if (*amount == 0)
|
||||
totcomp++;
|
||||
else {
|
||||
used = min(used, (int)(getvar((int)*comp, (s_char *)§,
|
||||
EF_SECTOR) / *amount));
|
||||
used = min(used, sect.sct_item[(int)*comp] / *amount);
|
||||
totcomp += *amount;
|
||||
}
|
||||
++comp;
|
||||
|
@ -293,8 +292,7 @@ prod(void)
|
|||
if (real < 0.0)
|
||||
real = 0.0;
|
||||
/* production backlog? */
|
||||
if ((there =
|
||||
getvar((int)vtype, (s_char *)§, EF_SECTOR)) >= 9999) {
|
||||
if ((there = sect.sct_item[vtype]) >= 9999) {
|
||||
there = 9999;
|
||||
}
|
||||
act = min(act, (9999 - there));
|
||||
|
|
|
@ -120,11 +120,11 @@ rese(void)
|
|||
ix = whichitem(comm.com_type);
|
||||
sect.sct_x = comm.sell_x;
|
||||
sect.sct_y = comm.sell_y;
|
||||
m = getvar(ix->i_vtype, (char *)§, EF_SECTOR);
|
||||
m = sect.sct_item[ix->i_vtype];
|
||||
m = m + comm.com_amount;
|
||||
if (m > 9999)
|
||||
m = 9999;
|
||||
putvar(ix->i_vtype, m, (char *)§, EF_SECTOR);
|
||||
sect.sct_item[ix->i_vtype] = m;
|
||||
putsect(§);
|
||||
comm.com_owner = 0;
|
||||
putcomm(number_set, &comm);
|
||||
|
|
|
@ -73,7 +73,7 @@ rout(void)
|
|||
|
||||
if ((ip = whatitem(player->argp[1], "What item? ")) == 0)
|
||||
return RET_SYN;
|
||||
i_del = V_DEL(ip - ichr);
|
||||
i_del = ip->i_vtype;;
|
||||
if (player->argp[2] == (s_char *)0) {
|
||||
if ((str = getstring("(sects)? ", buf1)) == 0)
|
||||
return RET_SYN;
|
||||
|
@ -122,7 +122,7 @@ rout(void)
|
|||
if (!player->owner)
|
||||
continue;
|
||||
p = &map[ns.dy][ns.dx * 2];
|
||||
if ((dir = getvar(i_del, (s_char *)§, EF_SECTOR) & 0x7) &&
|
||||
if ((dir = sect.sct_del[i_del] & 0x7) &&
|
||||
nstr_exec(cond, ncond, (s_char *)§, EF_SECTOR))
|
||||
memcpy(p, routech[dir][0], 3);
|
||||
p[1] = dchr[sect.sct_type].d_mnem;
|
||||
|
|
|
@ -31,18 +31,6 @@
|
|||
* John Yockey, 2001
|
||||
*/
|
||||
|
||||
/*
|
||||
#include <ctype.h>
|
||||
#include "player.h"
|
||||
#include "sect.h"
|
||||
#include "news.h"
|
||||
#include "xy.h"
|
||||
#include "nat.h"
|
||||
#include "path.h"
|
||||
#include "map.h"
|
||||
#include "commands.h"
|
||||
*/
|
||||
|
||||
#include "misc.h"
|
||||
#include "var.h"
|
||||
#include "land.h"
|
||||
|
@ -79,12 +67,11 @@ sabo(void)
|
|||
}
|
||||
if (!getsect(land.lnd_x, land.lnd_y, §))
|
||||
continue;
|
||||
getvec(VT_ITEM, vec, (s_char *)&land, EF_LAND);
|
||||
if (vec[I_SHELL] == 0) {
|
||||
if (land.lnd_item[I_SHELL] == 0) {
|
||||
pr("%s has no shells.\n", prland(&land));
|
||||
continue;
|
||||
}
|
||||
putvar(V_SHELL, vec[I_SHELL] - 1, (s_char *)&land, EF_LAND);
|
||||
--land.lnd_item[I_SHELL];
|
||||
|
||||
odds = LND_SPY_DETECT_CHANCE(land.lnd_effic);
|
||||
if (chance(odds)) {
|
||||
|
|
|
@ -145,13 +145,13 @@ sell(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if (((tot_mil + (getvar(V_MILIT, (char *)§, EF_SECTOR))) * 10)
|
||||
< getvar(V_CIVIL, (char *)§, EF_SECTOR)) {
|
||||
if (((tot_mil + sect.sct_item[I_MILIT]) * 10)
|
||||
< sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to sell goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
if (((amt = getvar(ip->i_vtype, (char *)§, EF_SECTOR))) == 0) {
|
||||
if ((amt = sect.sct_item[ip->i_vtype]) == 0) {
|
||||
pr("You don't have any %s to sell there.\n", ip->i_name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ sell(void)
|
|||
amt -= com;
|
||||
pr("Sold %d %s at %s (%d left)\n", com, ip->i_name,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum), amt);
|
||||
putvar(ip->i_vtype, amt, (char *)§, EF_SECTOR);
|
||||
sect.sct_item[ip->i_vtype] = amt;
|
||||
cc = ip->i_mnem;
|
||||
putsect(§);
|
||||
if (totalcom > 0) {
|
||||
|
|
|
@ -109,8 +109,8 @@ set(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if (tot_mil + (getvar(V_MILIT, (char *)§, EF_SECTOR)) * 10
|
||||
< getvar(V_CIVIL, (char *)§, EF_SECTOR)) {
|
||||
if (tot_mil + sect.sct_item[I_MILIT] * 10
|
||||
< sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to sell goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -214,20 +214,17 @@ setsector(void)
|
|||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
while (nxtsct(&nstr, §) > 0) {
|
||||
int mines;
|
||||
|
||||
if (!(p = getstarg(player->argp[3], "What value : ", buf))
|
||||
|| (*p == '\0'))
|
||||
return RET_SYN;
|
||||
amt = atoi(p);
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
current = mines;
|
||||
current = sect.sct_mines;
|
||||
current += amt;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
if (sect.sct_own != 0)
|
||||
resnoise(§, 1, "Mines", (int)mines, current);
|
||||
putvar(V_MINE, current, (s_char *)§, EF_SECTOR);
|
||||
resnoise(§, 1, "Mines", sect.sct_mines, current);
|
||||
sect.sct_mines = current;
|
||||
putsect(§);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -66,7 +66,7 @@ shoo(void)
|
|||
ip = whatitem(player->argp[1], "Shoot what <civ or uw> ");
|
||||
if (ip == 0 || (ip->i_vtype != V_CIVIL && ip->i_vtype != V_UW))
|
||||
return RET_SYN;
|
||||
item = ip - ichr;
|
||||
item = ip->i_vtype;
|
||||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
sprintf(prompt, "number of %s to shoot (max 999)? ", ip->i_name);
|
||||
|
@ -122,13 +122,13 @@ shoo(void)
|
|||
nshot, ip->i_name, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
if (chance(nshot / 100.0))
|
||||
nreport(player->cnum, N_SHOOT_CIV, sect.sct_oldown, 1);
|
||||
if (vec[item] <= 0 && ip->i_vtype == V_CIVIL &&
|
||||
(sect.sct_own != sect.sct_oldown)) {
|
||||
if (vec[item] <= 0 && item == V_CIVIL
|
||||
&& (sect.sct_own != sect.sct_oldown)) {
|
||||
sect.sct_oldown = sect.sct_own;
|
||||
pr(" %s is now completely yours\n",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
}
|
||||
putvar(ip->i_vtype, vec[item], (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[item] = vec[item];
|
||||
putsect(§);
|
||||
}
|
||||
return RET_OK;
|
||||
|
|
|
@ -70,7 +70,6 @@ sona(void)
|
|||
int dist;
|
||||
int x, y;
|
||||
int cx, cy;
|
||||
int mines;
|
||||
int changed = 0;
|
||||
int row;
|
||||
/* Where these are used are non-re-entrant, so we keep 'em around */
|
||||
|
@ -147,10 +146,10 @@ sona(void)
|
|||
continue;
|
||||
}
|
||||
if (ship.shp_tech >= 310 && sect.sct_type == SCT_WATER) {
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (mines) {
|
||||
if (sect.sct_mines) {
|
||||
pr("Sonar detects %d mines in %s!\n",
|
||||
mines, xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
sect.sct_mines,
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
rad[ns.dy][ns.dx] = 'X';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@ stre(void)
|
|||
double dtotal, r_total, eff;
|
||||
struct combat def[1];
|
||||
int dummy;
|
||||
int mines;
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
|
@ -96,12 +95,11 @@ stre(void)
|
|||
def->own = 0;
|
||||
eff = att_combat_eff(def);
|
||||
if (sect.sct_own == sect.sct_oldown) {
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (mines > 0)
|
||||
pr("%7d", mines);
|
||||
if (sect.sct_mines > 0)
|
||||
pr("%7d", sect.sct_mines);
|
||||
else
|
||||
pr("%7s", "");
|
||||
eff *= (1.0 + min(mines, 20) * 0.02);
|
||||
eff *= (1.0 + min(sect.sct_mines, 20) * 0.02);
|
||||
} else {
|
||||
pr("%7s", "?");
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ tend(void)
|
|||
pr("Amount must be non-zero!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
ontender = getvar(ip->i_vtype, (s_char *)&tender, EF_SHIP);
|
||||
ontender = tender.shp_item[ip->i_vtype];
|
||||
if (ontender == 0 && amt > 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&tender));
|
||||
return RET_FAIL;
|
||||
|
@ -144,7 +144,7 @@ tend(void)
|
|||
if (tender.shp_x != target.shp_x ||
|
||||
tender.shp_y != target.shp_y)
|
||||
continue;
|
||||
ontarget = getvar(ip->i_vtype, (s_char *)&target, EF_SHIP);
|
||||
ontarget = target.shp_item[ip->i_vtype];
|
||||
if (ontarget == 0 && amt < 0) {
|
||||
pr("No %s on %s\n", ip->i_name, prship(&target));
|
||||
continue;
|
||||
|
@ -161,8 +161,7 @@ tend(void)
|
|||
transfer = min(maxtender - ontender, transfer);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget - transfer,
|
||||
(s_char *)&target, EF_SHIP);
|
||||
target.shp_item[ip->i_vtype] = ontarget - transfer;
|
||||
ontender += transfer;
|
||||
total += transfer;
|
||||
} else {
|
||||
|
@ -171,8 +170,7 @@ tend(void)
|
|||
transfer = min(transfer, maxtarget - ontarget);
|
||||
if (transfer == 0)
|
||||
continue;
|
||||
putvar(ip->i_vtype, ontarget + transfer,
|
||||
(s_char *)&target, EF_SHIP);
|
||||
target.shp_item[ip->i_vtype] = ontarget + transfer;
|
||||
ontender -= transfer;
|
||||
total += transfer;
|
||||
}
|
||||
|
@ -186,7 +184,7 @@ tend(void)
|
|||
pr("%d total %s transferred %s %s\n",
|
||||
total, ip->i_name, (amt > 0) ? "off of" : "to",
|
||||
prship(&tender));
|
||||
putvar(ip->i_vtype, ontender, (s_char *)&tender, EF_SHIP);
|
||||
tender.shp_item[ip->i_vtype] = ontender;
|
||||
tender.shp_mission = 0;
|
||||
putship(tender.shp_uid, &tender);
|
||||
}
|
||||
|
@ -196,12 +194,10 @@ tend(void)
|
|||
static void
|
||||
expose_ship(struct shpstr *s1, struct shpstr *s2)
|
||||
{
|
||||
if (getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)s2, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)s2, EF_SHIP);
|
||||
if (getvar(V_PSTAGE, (s_char *)s2, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)s1, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)s1, EF_SHIP);
|
||||
if (s1->shp_pstage == PLG_INFECT && s2->shp_pstage == PLG_HEALTHY)
|
||||
s2->shp_pstage = PLG_EXPOSED;
|
||||
if (s2->shp_pstage == PLG_INFECT && s1->shp_pstage == PLG_HEALTHY)
|
||||
s1->shp_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -63,7 +63,7 @@ thre(void)
|
|||
return RET_SYN;
|
||||
if (!snxtsct(&nstr, player->argp[2]))
|
||||
return RET_SYN;
|
||||
type = V_DIST(ip->i_vtype & (~VT_TYPE));
|
||||
type = ip->i_vtype;
|
||||
if (player->argp[3] && *player->argp[3] &&
|
||||
(*player->argp[3] < '0' || *player->argp[3] > '9')) {
|
||||
pr("Threshold must be a number\n");
|
||||
|
@ -72,7 +72,7 @@ thre(void)
|
|||
while (!player->aborted && nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
val = getvar(type, (s_char *)§, EF_SECTOR);
|
||||
val = sect.sct_dist[type];
|
||||
if (val > 0)
|
||||
sprintf(prompt, "%s %s old threshold %d new? ",
|
||||
xyas(nstr.x, nstr.y, player->cnum),
|
||||
|
@ -98,9 +98,7 @@ thre(void)
|
|||
if (val > 0 && (player->argp[3] != 0 && *player->argp[3] != 0))
|
||||
pr("%s old threshold %d\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum), val);
|
||||
if (putvar(type, thresh, (s_char *)§, EF_SECTOR) < 0)
|
||||
pr("No room for threshold in %s\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
sect.sct_dist[type] = thresh;
|
||||
putsect(§);
|
||||
}
|
||||
return RET_OK;
|
||||
|
|
|
@ -87,14 +87,14 @@ torp(void)
|
|||
continue;
|
||||
if ((mchr[(int)sub.shp_type].m_flags & M_TORP) == 0)
|
||||
continue;
|
||||
shells = getvar(V_SHELL, (s_char *)&sub, EF_SHIP);
|
||||
shells = sub.shp_item[I_SHELL];
|
||||
if (shells < 3)
|
||||
shells +=
|
||||
supply_commod(sub.shp_own, sub.shp_x, sub.shp_y, I_SHELL,
|
||||
3 - shells);
|
||||
if (getvar(V_GUN, (s_char *)&sub, EF_SHIP) == 0 || shells < 3)
|
||||
if (sub.shp_item[I_GUN] == 0 || shells < 3)
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)&sub, EF_SHIP) < 1)
|
||||
if (sub.shp_item[I_MILIT] < 1)
|
||||
continue;
|
||||
if (sub.shp_effic < 60)
|
||||
continue;
|
||||
|
@ -115,16 +115,16 @@ torp(void)
|
|||
mchr[(int)sub.shp_type].m_name);
|
||||
continue;
|
||||
}
|
||||
shells = getvar(V_SHELL, (s_char *)&sub, EF_SHIP);
|
||||
shells = sub.shp_item[I_SHELL];
|
||||
if (shells < 3)
|
||||
shells +=
|
||||
supply_commod(sub.shp_own, sub.shp_x, sub.shp_y, I_SHELL,
|
||||
3 - shells);
|
||||
if (getvar(V_GUN, (s_char *)&sub, EF_SHIP) == 0 || shells < 3) {
|
||||
if (sub.shp_item[I_GUN] == 0 || shells < 3) {
|
||||
pr("Ship #%d has insufficient armament\n", sub.shp_uid);
|
||||
continue;
|
||||
}
|
||||
if (getvar(V_MILIT, (s_char *)&sub, EF_SHIP) < 1) {
|
||||
if (sub.shp_item[I_MILIT] < 1) {
|
||||
pr("Ship #%d has insufficient crew\n", sub.shp_uid);
|
||||
continue;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ torp(void)
|
|||
erange = (double)roundrange(erange);
|
||||
pr("Effective torpedo range is %.1f\n", erange);
|
||||
shells -= 3;
|
||||
putvar(V_SHELL, shells, (s_char *)&sub, EF_SHIP);
|
||||
sub.shp_item[I_SHELL] = shells;
|
||||
putship(sub.shp_uid, &sub);
|
||||
mcp = &mchr[(int)sub.shp_type];
|
||||
mobcost = sub.shp_effic * 0.01 * sub.shp_speed;
|
||||
|
@ -349,10 +349,10 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
|||
int gun;
|
||||
double guneff;
|
||||
|
||||
shells = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
gun = getvar(V_GUN, (s_char *)sp, EF_SHIP);
|
||||
shells = sp->shp_item[I_SHELL];
|
||||
gun = sp->shp_item[I_GUN];
|
||||
gun = min(gun, sp->shp_glim);
|
||||
gun = min(gun, getvar(V_MILIT, (s_char *)sp, EF_SHIP) / 2);
|
||||
gun = min(gun, sp->shp_item[I_MILIT] / 2);
|
||||
|
||||
shells +=
|
||||
supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, I_SHELL,
|
||||
|
@ -364,7 +364,7 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
|||
|
||||
/* ok, all set.. now, we shoot */
|
||||
shells -= ldround(((double)gun) / 2.0, 1);
|
||||
putvar(V_SHELL, shells, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[I_SHELL] = shells;
|
||||
putship(sp->shp_uid, sp);
|
||||
|
||||
guneff = seagun(sp->shp_effic, gun);
|
||||
|
@ -407,16 +407,16 @@ fire_torp(struct shpstr *sp, struct shpstr *targ, int range, int ntargets)
|
|||
double mobcost;
|
||||
struct mchrstr *mcp;
|
||||
|
||||
shells = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
shells = sp->shp_item[I_SHELL];
|
||||
|
||||
if (shells < 3)
|
||||
shells += supply_commod(sp->shp_own, sp->shp_x, sp->shp_y, I_SHELL,
|
||||
3 - shells);
|
||||
|
||||
if (getvar(V_GUN, (s_char *)sp, EF_SHIP) == 0 || shells < 3)
|
||||
if (sp->shp_item[I_GUN] == 0 || shells < 3)
|
||||
return 0;
|
||||
|
||||
if (getvar(V_MILIT, (s_char *)sp, EF_SHIP) < 1)
|
||||
if (sp->shp_item[I_MILIT] < 1)
|
||||
return 0;
|
||||
|
||||
if (sp->shp_effic < 60)
|
||||
|
@ -427,7 +427,7 @@ fire_torp(struct shpstr *sp, struct shpstr *targ, int range, int ntargets)
|
|||
|
||||
/* All set.. fire! */
|
||||
shells -= 3;
|
||||
putvar(V_SHELL, shells, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[I_SHELL] = shells;
|
||||
putship(sp->shp_uid, sp);
|
||||
|
||||
mcp = &mchr[(int)sp->shp_type];
|
||||
|
|
|
@ -166,8 +166,7 @@ tran_nuke(void)
|
|||
if (land.lnd_own == player->cnum)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if ((getvar(V_MILIT, (s_char *)§, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)§, EF_SECTOR)) {
|
||||
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to move goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
@ -282,8 +281,7 @@ tran_plane(void)
|
|||
snxtitem_xy(&ni, EF_LAND, sect.sct_x, sect.sct_y);
|
||||
while (nxtitem(&ni, (s_char *)&land))
|
||||
tot_mil += total_mil(&land);
|
||||
if ((getvar(V_MILIT, (s_char *)§, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)§, EF_SECTOR)) {
|
||||
if ((sect.sct_item[I_MILIT] + tot_mil) * 10 < sect.sct_item[I_CIVIL]) {
|
||||
pr("Military control required to move goods.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
|
|
|
@ -47,15 +47,13 @@ wipe(void)
|
|||
{
|
||||
struct sctstr sect;
|
||||
struct nstr_sect nstr;
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
if (!snxtsct(&nstr, player->argp[1]))
|
||||
return RET_SYN;
|
||||
memset(vec, 0, sizeof(vec));
|
||||
while (nxtsct(&nstr, §)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
putvec(VT_DIST, vec, (s_char *)§, EF_SECTOR);
|
||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||
pr("Distribution thresholds wiped from %s\n",
|
||||
xyas(nstr.x, nstr.y, player->cnum));
|
||||
putsect(§);
|
||||
|
|
|
@ -97,7 +97,6 @@ knockdown(struct sctstr *sp, struct emp_qelem *list)
|
|||
struct lndstr land;
|
||||
struct plnstr plane;
|
||||
struct nstr_item ni;
|
||||
int mines;
|
||||
struct natstr *np;
|
||||
|
||||
if (sp->sct_type == SCT_BTOWER)
|
||||
|
@ -161,12 +160,10 @@ knockdown(struct sctstr *sp, struct emp_qelem *list)
|
|||
plane.pln_effic = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
/*
|
||||
* save only the mines; zero the rest of the
|
||||
* commodities.
|
||||
*/
|
||||
mines = getvar(V_MINE, (caddr_t)sp, EF_SECTOR);
|
||||
sp->sct_nv = 0;
|
||||
if (mines > 0)
|
||||
(void)putvar(V_MINE, mines, (caddr_t)sp, EF_SECTOR);
|
||||
memset(sp->sct_item, 0, sizeof(sp->sct_item));
|
||||
memset(sp->sct_del, 0, sizeof(sp->sct_del));
|
||||
memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
|
||||
sp->sct_pstage = PLG_HEALTHY;
|
||||
sp->sct_ptime = 0;
|
||||
sp->sct_che = 0;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,24 @@
|
|||
#include "gen.h"
|
||||
#include "subs.h"
|
||||
|
||||
void
|
||||
item_damage(int pct, u_short *item)
|
||||
{
|
||||
int i, lose;
|
||||
|
||||
for (i = 1; i <= I_MAX; ++i) {
|
||||
if (opt_SUPER_BARS && i == I_BAR)
|
||||
continue;
|
||||
lose = roundavg((double)item[i] * pct * 0.01);
|
||||
if (i == I_CIVIL || i == I_MILIT || i == I_UW)
|
||||
lose = ldround(people_damage * lose, 1);
|
||||
item[i] = item[i] >= lose ? item[i] - lose : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ship_damage(struct shpstr *sp, int dam)
|
||||
{
|
||||
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
|
@ -65,8 +79,7 @@ ship_damage(struct shpstr *sp, int dam)
|
|||
sp->shp_mobil = damage((int)sp->shp_mobil, dam);
|
||||
if (opt_FUEL && sp->shp_fuel)
|
||||
sp->shp_fuel = damage((int)sp->shp_fuel, dam);
|
||||
sp->shp_nv = vl_damage(dam, sp->shp_vtype, sp->shp_vamt,
|
||||
(int)sp->shp_nv);
|
||||
item_damage(dam, sp->shp_item);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -93,8 +106,7 @@ land_damage(struct lndstr *lp, int dam)
|
|||
lp->lnd_mobil = damage((int)lp->lnd_mobil, dam);
|
||||
if (opt_FUEL && lp->lnd_fuel)
|
||||
lp->lnd_fuel = damage((int)lp->lnd_fuel, dam);
|
||||
lp->lnd_nv = vl_damage(dam, lp->lnd_vtype, lp->lnd_vamt,
|
||||
(int)lp->lnd_nv);
|
||||
item_damage(dam, lp->lnd_item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -423,9 +423,8 @@ ef_mtime(int type)
|
|||
return fdate(empfile[type].fd);
|
||||
}
|
||||
|
||||
int
|
||||
ef_vars(int type, register s_char *sp, u_char **nvp, u_char **vp,
|
||||
u_short **ap)
|
||||
u_short *
|
||||
ef_items(int type, void *sp)
|
||||
{
|
||||
register struct empfile *ef;
|
||||
|
||||
|
@ -433,11 +432,8 @@ ef_vars(int type, register s_char *sp, u_char **nvp, u_char **vp,
|
|||
return 0;
|
||||
ef = &empfile[type];
|
||||
if ((ef->flags & EFF_COM) == 0)
|
||||
return -1;
|
||||
*nvp = (u_char *)(sp + ef->varoffs[0]);
|
||||
*vp = (u_char *)(sp + ef->varoffs[1]);
|
||||
*ap = (u_short *)(sp + ef->varoffs[2]);
|
||||
return ef->maxvars;
|
||||
return 0;
|
||||
return (u_short *)((char *)sp + ef->itemoffs);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -36,81 +36,36 @@
|
|||
#include "file.h"
|
||||
#include "common.h"
|
||||
|
||||
int
|
||||
getvar(int vtype, s_char *sp, int ptype)
|
||||
{
|
||||
u_char *vtypep;
|
||||
u_short *vamtp;
|
||||
u_char *nvp;
|
||||
int amt;
|
||||
|
||||
if (ef_vars(ptype, sp, &nvp, &vtypep, &vamtp) < 0) {
|
||||
logerror("getvar: ptype %d has no vars", ptype);
|
||||
return 0;
|
||||
}
|
||||
amt = vl_find(vtype, vtypep, vamtp, (int)*nvp);
|
||||
if (amt < 0) {
|
||||
logerror("getvar: vl_find returns %d, vtype %d", amt, vtype);
|
||||
return 0;
|
||||
}
|
||||
return amt;
|
||||
}
|
||||
|
||||
int
|
||||
getvec(int class, int *vec, s_char *sp, int ptype)
|
||||
{
|
||||
u_char *vtypep;
|
||||
u_short *vamtp;
|
||||
u_char *nvp;
|
||||
int nv;
|
||||
u_short *src = ef_items(ptype, sp);
|
||||
int i;
|
||||
|
||||
if (ef_vars(ptype, sp, &nvp, &vtypep, &vamtp) < 0) {
|
||||
if (!src || class != VT_ITEM) {
|
||||
logerror("getvec: ptype %d has no vars", ptype);
|
||||
return 0;
|
||||
}
|
||||
nv = vl_getvec(vtypep, vamtp, (int)*nvp, class, vec);
|
||||
if (nv < 0) {
|
||||
logerror("vl_getvec: returns %d, ptype %d\n", nv, ptype);
|
||||
return 0;
|
||||
}
|
||||
return nv;
|
||||
}
|
||||
|
||||
int
|
||||
putvar(int vtype, int amt, s_char *sp, int ptype)
|
||||
{
|
||||
u_char *vtypep;
|
||||
u_short *vamtp;
|
||||
u_char *nvp;
|
||||
int maxv;
|
||||
for (i = 0; i <= I_MAX; ++i)
|
||||
vec[i] = src[i];
|
||||
|
||||
if (vtype < 0 || vtype > V_MAX) {
|
||||
logerror("putvar: bad vtype %d\n", vtype);
|
||||
return 0;
|
||||
}
|
||||
if ((maxv = ef_vars(ptype, sp, &nvp, &vtypep, &vamtp)) < 0) {
|
||||
logerror("putvar: ptype %d has no vars", ptype);
|
||||
return 0;
|
||||
}
|
||||
if (amt < 0)
|
||||
amt = 0;
|
||||
return vl_set(vtype, (u_int)amt, vtypep, vamtp, nvp, maxv);
|
||||
return I_MAX;
|
||||
}
|
||||
|
||||
int
|
||||
putvec(int class, int *vec, s_char *sp, int ptype)
|
||||
{
|
||||
u_char *vtypep;
|
||||
u_short *vamtp;
|
||||
u_char *nvp;
|
||||
int maxv, x;
|
||||
u_short *dst = ef_items(ptype, sp);
|
||||
int i;
|
||||
|
||||
if ((maxv = ef_vars(ptype, sp, &nvp, &vtypep, &vamtp)) < 0) {
|
||||
if (!dst || class != VT_ITEM) {
|
||||
logerror("putvec: ptype %d has no vars", ptype);
|
||||
return 0;
|
||||
}
|
||||
for (x = 0; x < I_MAX; x++)
|
||||
if (vec[x] < 0)
|
||||
vec[x] = 0;
|
||||
return vl_setvec(vtypep, vamtp, nvp, maxv, class, vec);
|
||||
|
||||
for (i = 0; i <= I_MAX; ++i)
|
||||
dst[i] = vec[i];
|
||||
|
||||
return I_MAX;
|
||||
}
|
||||
|
|
|
@ -72,8 +72,7 @@ sect_damage(struct sctstr *sp, int dam, struct emp_qelem *list)
|
|||
|
||||
if (sp->sct_mobil > 0)
|
||||
sp->sct_mobil = damage((int)sp->sct_mobil, dam);
|
||||
sp->sct_nv = vl_damage(dam,
|
||||
sp->sct_vtype, sp->sct_vamt, (int)sp->sct_nv);
|
||||
item_damage(dam, sp->sct_item);
|
||||
if (opt_EASY_BRIDGES == 0) {
|
||||
if (sp->sct_effic < 20 && sp->sct_type == SCT_BHEAD)
|
||||
bridgefall(sp, list);
|
||||
|
|
|
@ -41,7 +41,9 @@
|
|||
#include "common.h"
|
||||
#include "gen.h"
|
||||
|
||||
#if 0
|
||||
static int freeslot(u_char *vec, register u_char *end);
|
||||
#endif
|
||||
|
||||
int
|
||||
vl_find(register int vtype, u_char *typevec, u_short *amtvec, int nelem)
|
||||
|
@ -62,6 +64,7 @@ vl_find(register int vtype, u_char *typevec, u_short *amtvec, int nelem)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int
|
||||
vl_set(register int vtype, u_int amt, u_char *typevec, u_short *amtvec,
|
||||
u_char *nvp, int max)
|
||||
|
@ -283,3 +286,4 @@ freeslot(u_char *vec, register u_char *end)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#include <struct.h>
|
||||
#include <stddef.h>
|
||||
#include "misc.h"
|
||||
#include "var.h"
|
||||
#include "xy.h"
|
||||
|
@ -56,45 +56,48 @@
|
|||
|
||||
struct empfile empfile[] = {
|
||||
{"sect", EMPDIR "/data/sector", EFF_COM | EFF_XY | EFF_OWNER,
|
||||
0, sizeof(struct sctstr),
|
||||
0, 0, 0, {fldoff(sctstr, sct_nv), fldoff(sctstr, sct_vtype[0]),
|
||||
fldoff(sctstr, sct_vamt[0])}, MAXSCTV,
|
||||
0, sizeof(struct sctstr), 0, 0, 0, offsetof(struct sctstr, sct_item),
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"ship", EMPDIR "/data/ship", EFF_COM | EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct shpstr),
|
||||
0, 0, 0, {fldoff(shpstr, shp_nv), fldoff(shpstr, shp_vtype[0]),
|
||||
fldoff(shpstr, shp_vamt[0])}, MAXSHPV,
|
||||
0, sizeof(struct shpstr), 0, 0, 0, offsetof(struct shpstr, shp_item),
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"plane", EMPDIR "/data/plane", EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct plnstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"land", EMPDIR "/data/land", EFF_COM | EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct lndstr),
|
||||
0, 0, 0, {fldoff(lndstr, lnd_nv), fldoff(lndstr, lnd_vtype[0]),
|
||||
fldoff(lndstr, lnd_vamt[0])}, MAXLNDV,
|
||||
0, sizeof(struct plnstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"land", EMPDIR "/data/land", EFF_COM | EFF_XY | EFF_OWNER | EFF_GROUP,
|
||||
0, sizeof(struct lndstr), 0, 0, 0, offsetof(struct lndstr, lnd_item),
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nuke", EMPDIR "/data/nuke", EFF_XY | EFF_OWNER,
|
||||
0, sizeof(struct nukstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nuke", EMPDIR "/data/nuke", EFF_XY | EFF_OWNER, 0, sizeof(struct nukstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"news", EMPDIR "/data/news", 0,
|
||||
0, sizeof(struct nwsstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"treaty", EMPDIR "/data/treaty", 0, 0, sizeof(struct trtstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"trade", EMPDIR "/data/trade", 0, 0, sizeof(struct trdstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"pow", EMPDIR "/data/power", 0, 0, sizeof(struct powstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"nat", EMPDIR "/data/nation", 0, 0, sizeof(struct natstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
0, sizeof(struct nwsstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"treaty", EMPDIR "/data/treaty", 0,
|
||||
0, sizeof(struct trtstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"trade", EMPDIR "/data/trade", 0,
|
||||
0, sizeof(struct trdstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"pow", EMPDIR "/data/power", 0,
|
||||
0, sizeof(struct powstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"nat", EMPDIR "/data/nation", 0,
|
||||
0, sizeof(struct natstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"loan", EMPDIR "/data/loan", 0,
|
||||
0, sizeof(struct lonstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"map", EMPDIR "/data/map", 0, 0, DEF_WORLD_X * DEF_WORLD_Y / 2,
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"bmap", EMPDIR "/data/bmap", 0, 0, DEF_WORLD_X * DEF_WORLD_Y / 2,
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"commodity", EMPDIR "/data/commodity", 0, 0, sizeof(struct comstr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0},
|
||||
{"lost", EMPDIR "/data/lostitems", 0, 0, sizeof(struct loststr),
|
||||
0, 0, 0, {0, 0, 0}, 0, -1, -1, 0, 0, 0, 0, 0}
|
||||
0, sizeof(struct lonstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"map", EMPDIR "/data/map", 0,
|
||||
0, DEF_WORLD_X * DEF_WORLD_Y / 2, 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"bmap", EMPDIR "/data/bmap", 0,
|
||||
0, DEF_WORLD_X * DEF_WORLD_Y / 2, 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"commodity", EMPDIR "/data/commodity", 0,
|
||||
0, sizeof(struct comstr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0},
|
||||
{"lost", EMPDIR "/data/lostitems", 0, 0,
|
||||
sizeof(struct loststr), 0, 0, 0, 0,
|
||||
-1, -1, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
|
|
@ -59,3 +59,5 @@ struct ichrstr ichr[I_MAX + 2] = {
|
|||
{'r', V_RAD, 150, 1, 8, {1, 10, 1, 1}, "radioactive materials"},
|
||||
{0, 0, 0, 0, 0, {0, 0, 0, 0}, 0}
|
||||
};
|
||||
|
||||
int itm_maxno = (sizeof(ichr) / sizeof(struct ichrstr)) - 1;
|
||||
|
|
|
@ -52,11 +52,6 @@
|
|||
#include "lost.h"
|
||||
|
||||
struct castr var_ca[] = {
|
||||
{NSC_DEITY | NSC_VAR | V_PSTAGE, "pstage", 0},
|
||||
{NSC_DEITY | NSC_VAR | V_PTIME, "ptime", 0},
|
||||
{NSC_DEITY | NSC_VAR | V_CHE, "che", 0},
|
||||
{NSC_DEITY | NSC_VAR | V_MINE, "lmine", 0},
|
||||
{NSC_VAR | V_FALLOUT, "fallout", 0},
|
||||
{NSC_VAR | V_CIVIL, "civil", 0},
|
||||
{NSC_VAR | V_MILIT, "milit", 0},
|
||||
{NSC_VAR | V_SHELL, "shell", 0},
|
||||
|
@ -71,34 +66,6 @@ struct castr var_ca[] = {
|
|||
{NSC_VAR | V_HCM, "hcm", 0},
|
||||
{NSC_VAR | V_UW, "uw", 0},
|
||||
{NSC_VAR | V_RAD, "rad", 0},
|
||||
{NSC_VAR | V_CDIST, "c_dist", 0},
|
||||
{NSC_VAR | V_MDIST, "m_dist", 0},
|
||||
{NSC_VAR | V_UDIST, "u_dist", 0},
|
||||
{NSC_VAR | V_SDIST, "s_dist", 0},
|
||||
{NSC_VAR | V_GDIST, "g_dist", 0},
|
||||
{NSC_VAR | V_PDIST, "p_dist", 0},
|
||||
{NSC_VAR | V_IDIST, "i_dist", 0},
|
||||
{NSC_VAR | V_DDIST, "d_dist", 0},
|
||||
{NSC_VAR | V_BDIST, "b_dist", 0},
|
||||
{NSC_VAR | V_FDIST, "f_dist", 0},
|
||||
{NSC_VAR | V_ODIST, "o_dist", 0},
|
||||
{NSC_VAR | V_LDIST, "l_dist", 0},
|
||||
{NSC_VAR | V_HDIST, "h_dist", 0},
|
||||
{NSC_VAR | V_RDIST, "r_dist", 0},
|
||||
{NSC_VAR | V_CDEL, "c_del", 0},
|
||||
{NSC_VAR | V_MDEL, "m_del", 0},
|
||||
{NSC_VAR | V_UDEL, "u_del", 0},
|
||||
{NSC_VAR | V_SDEL, "s_del", 0},
|
||||
{NSC_VAR | V_GDEL, "g_del", 0},
|
||||
{NSC_VAR | V_PDEL, "p_del", 0},
|
||||
{NSC_VAR | V_IDEL, "i_del", 0},
|
||||
{NSC_VAR | V_DDEL, "d_del", 0},
|
||||
{NSC_VAR | V_BDEL, "b_del", 0},
|
||||
{NSC_VAR | V_FDEL, "f_del", 0},
|
||||
{NSC_VAR | V_ODEL, "o_del", 0},
|
||||
{NSC_VAR | V_LDEL, "l_del", 0},
|
||||
{NSC_VAR | V_HDEL, "h_del", 0},
|
||||
{NSC_VAR | V_RDEL, "r_del", 0},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -127,6 +94,43 @@ struct castr sect_ca[] = {
|
|||
{NSC_XCOORD | NSC_OFF | fldoff(sctstr, sct_dist_x), "xdist", 0},
|
||||
{NSC_YCOORD | NSC_OFF | fldoff(sctstr, sct_dist_y), "ydist", 0},
|
||||
{NSC_SHORT | NSC_OFF | fldoff(sctstr, sct_avail), "avail", 0},
|
||||
#define distoff(itype) (fldoff(sctstr, sct_dist) + (itype)*sizeof(u_short))
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_CIVIL), "c_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_MILIT), "m_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_UW), "u_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_SHELL), "s_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_GUN), "g_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_PETROL), "p_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_IRON), "i_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_DUST), "d_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_BAR), "b_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_FOOD), "f_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_OIL), "o_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_LCM), "l_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_HCM), "h_dist", 0},
|
||||
{NSC_USHORT | NSC_OFF | distoff(I_RAD), "r_dist", 0},
|
||||
#undef distoff
|
||||
#define deloff(itype) (fldoff(sctstr, sct_del) + (itype)*sizeof(u_short))
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_CIVIL), "c_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_MILIT), "m_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_UW), "u_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_SHELL), "s_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_GUN), "g_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_PETROL), "p_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_IRON), "i_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_DUST), "d_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_BAR), "b_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_FOOD), "f_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_OIL), "o_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_LCM), "l_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_HCM), "h_del", 0},
|
||||
{NSC_USHORT | NSC_OFF | deloff(I_RAD), "r_del", 0},
|
||||
#undef deloff
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_mines), "mines", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_pstage), "pstage", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_ptime), "ptime", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_che), "che", 0},
|
||||
{NSC_USHORT | NSC_OFF | fldoff(sctstr, sct_fallout), "fallout", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_road), "road", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_rail), "rail", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(sctstr, sct_defense), "dfense", 0},
|
||||
|
@ -162,6 +166,8 @@ struct castr ship_ca[] = {
|
|||
{NSC_UCHAR | NSC_OFF | fldoff(shpstr, shp_nxlight), "nxlight", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(shpstr, shp_nchoppers), "nchoppers", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(shpstr, shp_autonav), "autonav", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(shpstr, shp_pstage), "pstage", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(shpstr, shp_ptime), "ptime", 0},
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -189,6 +195,8 @@ struct castr land_ca[] = {
|
|||
{NSC_SHORT | NSC_OFF | fldoff(lndstr, lnd_retreat), "retreat", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(lndstr, lnd_fuel), "fuel", 0},
|
||||
{NSC_UCHAR | NSC_OFF | fldoff(lndstr, lnd_nxlight), "nxlight", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(lndstr, lnd_pstage), "pstage", 0},
|
||||
{NSC_DEITY | NSC_USHORT | NSC_OFF | fldoff(lndstr, lnd_ptime), "ptime", 0},
|
||||
{NSC_FLOAT | NSC_OFF | fldoff(lndstr, lnd_att), "att", 0},
|
||||
{NSC_FLOAT | NSC_OFF | fldoff(lndstr, lnd_def), "def", 0},
|
||||
{NSC_INT | NSC_OFF | fldoff(lndstr, lnd_vul), "vul", 0},
|
||||
|
|
|
@ -101,7 +101,7 @@ nat_cap(int btu)
|
|||
d = (double)(player->curup - np->nat_last_login) / s_p_etu;
|
||||
if (d > 336.0)
|
||||
d = 336.0;
|
||||
civ = getvar(V_CIVIL, (caddr_t)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
if (civ > 999)
|
||||
civ = 999;
|
||||
if ((sect.sct_effic) && (sect.sct_type != SCT_MOUNT))
|
||||
|
|
|
@ -182,8 +182,8 @@ ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
|||
PR(plane_owner, " %d%% efficient ",
|
||||
(sect.sct_own == plane_owner) ?
|
||||
sect.sct_effic : roundintby((int)sect.sct_effic, 25));
|
||||
civ = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
mil = getvar(V_MILIT, (s_char *)§, EF_SECTOR);
|
||||
civ = sect.sct_item[I_CIVIL];
|
||||
mil = sect.sct_item[I_MILIT];
|
||||
if (civ)
|
||||
PR(plane_owner, "with %s%d civ ",
|
||||
(sect.sct_own == plane_owner) ?
|
||||
|
@ -798,8 +798,8 @@ ac_doflak(struct emp_qelem *list, struct sctstr *from)
|
|||
plp = (struct plist *)list->q_forw;
|
||||
plane_owner = plp->plane.pln_own;
|
||||
|
||||
gun = getvar(V_GUN, (s_char *)from, EF_SECTOR);
|
||||
shell = getvar(V_SHELL, (s_char *)from, EF_SECTOR);
|
||||
gun = from->sct_item[I_GUN];
|
||||
shell = from->sct_item[I_SHELL];
|
||||
add = 0;
|
||||
if (shell < (gun / 2))
|
||||
add = supply_commod(from->sct_own, from->sct_x, from->sct_y,
|
||||
|
@ -813,7 +813,7 @@ ac_doflak(struct emp_qelem *list, struct sctstr *from)
|
|||
if (gun > 14)
|
||||
gun = 14;
|
||||
|
||||
putvar(V_SHELL, shell, (s_char *)from, EF_SECTOR);
|
||||
from->sct_item[I_SHELL] = shell;
|
||||
putsect(from);
|
||||
gun = 2.0 * tfact(from->sct_own, (double)gun);
|
||||
if (gun > 0) {
|
||||
|
@ -860,9 +860,9 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y)
|
|||
if (rel > HOSTILE)
|
||||
continue;
|
||||
shell = gun = 0;
|
||||
gun = min(getvar(V_GUN, (s_char *)&ship, EF_SHIP), ship.shp_glim);
|
||||
gun = min(ship.shp_item[I_GUN], ship.shp_glim);
|
||||
if (gun) {
|
||||
shell = getvar(V_SHELL, (s_char *)&ship, EF_SHIP);
|
||||
shell = ship.shp_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell = supply_commod(ship.shp_own, ship.shp_x,
|
||||
ship.shp_y, I_SHELL, 1);
|
||||
|
@ -882,7 +882,7 @@ ac_shipflak(struct emp_qelem *list, coord x, coord y)
|
|||
}
|
||||
PR(ship.shp_own, "firing %d flak guns from %s...\n",
|
||||
firing, prship(&ship));
|
||||
putvar(V_SHELL, shell, (s_char *)&ship, EF_SHIP);
|
||||
ship.shp_item[I_SHELL] = shell;
|
||||
putship(ship.shp_uid, &ship);
|
||||
from = ship.shp_own;
|
||||
}
|
||||
|
@ -1044,8 +1044,7 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a,
|
|||
struct lndstr land;
|
||||
struct sctstr sect;
|
||||
struct nstr_item ni;
|
||||
int type;
|
||||
s_char *ptr;
|
||||
u_short *item;
|
||||
struct plist *ip;
|
||||
|
||||
emp_initque(list);
|
||||
|
@ -1066,18 +1065,15 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a,
|
|||
if (!can_fly(plane.pln_uid))
|
||||
continue;
|
||||
getship(plane.pln_ship, &ship);
|
||||
ptr = (s_char *)&ship;
|
||||
type = EF_SHIP;
|
||||
item = ship.shp_item;
|
||||
} else if (plane.pln_land >= 0) {
|
||||
if (!can_fly(plane.pln_uid))
|
||||
continue;
|
||||
getland(plane.pln_land, &land);
|
||||
ptr = (s_char *)&land;
|
||||
type = EF_LAND;
|
||||
item = land.lnd_item;
|
||||
} else {
|
||||
getsect(plane.pln_x, plane.pln_y, §);
|
||||
ptr = (s_char *)§
|
||||
type = EF_SECTOR;
|
||||
item = sect.sct_item;
|
||||
#if 0
|
||||
if (sect.sct_effic < 60 && (pcp->pl_flags & P_V) == 0)
|
||||
continue;
|
||||
|
@ -1087,8 +1083,7 @@ getilist(struct emp_qelem *list, natid own, struct emp_qelem *a,
|
|||
continue;
|
||||
#endif
|
||||
}
|
||||
if (((float)getvar(V_PETROL, ptr, type)) <
|
||||
(((float)pcp->pl_fuel) / 2.0))
|
||||
if ((float)item[I_PETROL] < (float)pcp->pl_fuel / 2.0)
|
||||
continue;
|
||||
/* Finally, is it in the list of planes already in
|
||||
flight? */
|
||||
|
|
|
@ -203,7 +203,8 @@ att_get_combat(struct combat *com, int isdef)
|
|||
struct sctstr sect;
|
||||
struct shpstr ship;
|
||||
struct lndstr land;
|
||||
s_char *thing;
|
||||
u_short *item;
|
||||
int pstage;
|
||||
natid owner;
|
||||
int mil;
|
||||
int eff;
|
||||
|
@ -218,7 +219,8 @@ att_get_combat(struct combat *com, int isdef)
|
|||
}
|
||||
com->sct_type = sect.sct_type;
|
||||
com->sct_dcp = &dchr[sect.sct_type];
|
||||
thing = (s_char *)§
|
||||
item = sect.sct_item;
|
||||
pstage = sect.sct_pstage;
|
||||
owner = sect.sct_own;
|
||||
eff = sect.sct_effic;
|
||||
mob = sect.sct_mobil;
|
||||
|
@ -237,7 +239,8 @@ att_get_combat(struct combat *com, int isdef)
|
|||
return att_combat_init(com, EF_BAD);
|
||||
}
|
||||
com->lnd_lcp = &lchr[(int)land.lnd_type];
|
||||
thing = (s_char *)&land;
|
||||
item = land.lnd_item;
|
||||
pstage = land.lnd_pstage;
|
||||
owner = land.lnd_own;
|
||||
eff = land.lnd_effic;
|
||||
mob = land.lnd_mobil;
|
||||
|
@ -273,7 +276,8 @@ att_get_combat(struct combat *com, int isdef)
|
|||
pr("Ship #%d is not your ship!\n", com->shp_uid);
|
||||
return att_combat_init(com, EF_BAD);
|
||||
}
|
||||
thing = (s_char *)&ship;
|
||||
item = ship.shp_item;
|
||||
pstage = ship.shp_pstage;
|
||||
owner = ship.shp_own;
|
||||
eff = ship.shp_effic;
|
||||
mob = ship.shp_mobil;
|
||||
|
@ -288,7 +292,7 @@ att_get_combat(struct combat *com, int isdef)
|
|||
return att_combat_init(com, EF_BAD);
|
||||
}
|
||||
|
||||
mil = getvar(V_MILIT, thing, com->type);
|
||||
mil = item[I_MILIT];
|
||||
if (!com->set) { /* first time */
|
||||
if (isdef) { /* defender */
|
||||
com->troops = mil;
|
||||
|
@ -300,7 +304,7 @@ att_get_combat(struct combat *com, int isdef)
|
|||
/* don't abandon attacking sectors or ships */
|
||||
com->troops = max(0, mil - 1);
|
||||
}
|
||||
com->plague = (getvar(V_PSTAGE, thing, com->type)) == PLG_INFECT;
|
||||
com->plague = pstage == PLG_INFECT;
|
||||
} else { /* not first time */
|
||||
if (isdef) { /* defender */
|
||||
if (com->x != x || com->y != y) {
|
||||
|
@ -398,11 +402,10 @@ put_combat(struct combat *com)
|
|||
makenotlost(EF_SECTOR, com->own, 0, sect.sct_x, sect.sct_y);
|
||||
sect.sct_own = com->own;
|
||||
if (com->plague) {
|
||||
if (getvar(V_PSTAGE, (s_char *)§, EF_SECTOR) ==
|
||||
PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)§, EF_SECTOR);
|
||||
if (sect.sct_pstage == PLG_HEALTHY)
|
||||
sect.sct_pstage = PLG_EXPOSED;
|
||||
}
|
||||
putvar(V_MILIT, com->mil, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_item[I_MILIT] = com->mil;
|
||||
putsect(§);
|
||||
com->own = sect.sct_own; /* avoid WARNING if sector reverts */
|
||||
break;
|
||||
|
@ -421,11 +424,11 @@ put_combat(struct combat *com)
|
|||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid, land.lnd_x,
|
||||
land.lnd_y);
|
||||
if (com->plague) {
|
||||
if (getvar(V_PSTAGE, (s_char *)&land, EF_LAND) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&land, EF_LAND);
|
||||
if (land.lnd_pstage == PLG_HEALTHY)
|
||||
land.lnd_pstage = PLG_EXPOSED;
|
||||
}
|
||||
if (!(com->lnd_lcp->l_flags & L_SPY))
|
||||
putvar(V_MILIT, com->mil, (s_char *)&land, EF_LAND);
|
||||
land.lnd_item[I_MILIT] = com->mil;
|
||||
lnd_count_units(&land);
|
||||
if (com->own == player->cnum) {
|
||||
land.lnd_mission = 0;
|
||||
|
@ -449,10 +452,10 @@ put_combat(struct combat *com)
|
|||
makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid, ship.shp_x,
|
||||
ship.shp_y);
|
||||
if (com->plague) {
|
||||
if (getvar(V_PSTAGE, (s_char *)&ship, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&ship, EF_SHIP);
|
||||
if (ship.shp_pstage == PLG_HEALTHY)
|
||||
ship.shp_pstage = PLG_EXPOSED;
|
||||
}
|
||||
putvar(V_MILIT, com->mil, (s_char *)&ship, EF_SHIP);
|
||||
ship.shp_item[I_MILIT] = com->mil;
|
||||
count_units(&ship);
|
||||
if (com->own == player->cnum) {
|
||||
ship.shp_mission = 0;
|
||||
|
@ -1479,9 +1482,8 @@ att_infect_units(struct emp_qelem *list, int plague)
|
|||
for (qp = list->q_forw; qp != list; qp = next) {
|
||||
next = qp->q_forw;
|
||||
llp = (struct llist *)qp;
|
||||
if (getvar(V_PSTAGE, (s_char *)&(llp->land), EF_LAND) ==
|
||||
PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)&(llp->land), EF_LAND);
|
||||
if (llp->land.lnd_pstage == PLG_HEALTHY)
|
||||
llp->land.lnd_pstage = PLG_EXPOSED;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1742,8 +1744,7 @@ get_mine_dsupport(struct combat *def, int a_engineer)
|
|||
getsect(def->x, def->y, §);
|
||||
|
||||
if (sect.sct_oldown != player->cnum) {
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
mines = min(mines, 20);
|
||||
mines = min(sect.sct_mines, 20);
|
||||
if (a_engineer)
|
||||
mines = ldround(((double)mines / 2.0), 1);
|
||||
if (mines > 0) {
|
||||
|
|
|
@ -62,8 +62,7 @@ military_control(struct sctstr *sp)
|
|||
if (land.lnd_own == sp->sct_own)
|
||||
tot_mil += total_mil(&land);
|
||||
}
|
||||
if ((getvar(V_MILIT, (s_char *)sp, EF_SECTOR) + tot_mil) * 10
|
||||
< getvar(V_CIVIL, (s_char *)sp, EF_SECTOR))
|
||||
if ((sp->sct_item[I_MILIT] + tot_mil) * 10 < sp->sct_item[I_CIVIL])
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ detonate(struct plnstr *pp, int x, int y)
|
|||
continue;
|
||||
}
|
||||
if (opt_FALLOUT)
|
||||
fallout = getvar(V_FALLOUT, (s_char *)§, EF_SECTOR);
|
||||
fallout = sect.sct_fallout;
|
||||
sect_damage(§, damage, 0);
|
||||
if (sect.sct_x == x && sect.sct_y == y)
|
||||
retval = damage;
|
||||
|
@ -112,7 +112,7 @@ detonate(struct plnstr *pp, int x, int y)
|
|||
fallout += damage * 30;
|
||||
else
|
||||
fallout += damage * 3;
|
||||
putvar(V_FALLOUT, fallout, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_fallout = fallout;
|
||||
}
|
||||
if (damage > 100) {
|
||||
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
|
||||
|
|
|
@ -112,8 +112,7 @@ sd(natid att, natid own, coord x, coord y, int noisy, int defending,
|
|||
nshot = min(nshot, ship.shp_glim);
|
||||
if (nshot <= 0)
|
||||
continue;
|
||||
(void)putvar(V_SHELL, vec[I_SHELL] - nshot, (caddr_t)&ship,
|
||||
EF_SHIP);
|
||||
ship.shp_item[I_SHELL] = vec[I_SHELL] - nshot;
|
||||
putship(ship.shp_uid, &ship);
|
||||
if (defending)
|
||||
nreport(ship.shp_own, N_FIRE_BACK, att, 1);
|
||||
|
@ -254,16 +253,16 @@ sb(natid att, natid def, struct sctstr *sp, coord tx, coord ty, int noisy,
|
|||
range2 = mapdist((int)sp->sct_x, (int)sp->sct_y, tx, ty);
|
||||
if (range < range2)
|
||||
return 0;
|
||||
gun = getvar(V_GUN, (caddr_t)sp, EF_SECTOR);
|
||||
gun = sp->sct_item[I_GUN];
|
||||
if (gun == 0)
|
||||
return 0;
|
||||
shell = getvar(V_SHELL, (caddr_t)sp, EF_SECTOR);
|
||||
shell = sp->sct_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell += supply_commod(sp->sct_own, sp->sct_x, sp->sct_y, I_SHELL,
|
||||
1);
|
||||
if (shell <= 0)
|
||||
return 0;
|
||||
putvar(V_SHELL, shell - 1, (caddr_t)sp, EF_SECTOR);
|
||||
sp->sct_item[I_SHELL] = shell - 1;
|
||||
putsect(sp);
|
||||
damage = landgun((int)sp->sct_effic, gun);
|
||||
if (sp->sct_own != def)
|
||||
|
|
|
@ -256,7 +256,7 @@ lnd_take_casualty(int combat_mode, struct llist *llp, int cas)
|
|||
if (sect.sct_type == SCT_MOUNT)
|
||||
continue;
|
||||
++nowned;
|
||||
civs = getvar(V_CIVIL, (s_char *)§, EF_SECTOR);
|
||||
civs = sect.sct_item[I_CIVIL];
|
||||
if (civs > biggest) {
|
||||
biggest = civs;
|
||||
bx = sect.sct_x;
|
||||
|
@ -335,22 +335,14 @@ lnd_takemob(struct emp_qelem *list, double loss)
|
|||
int
|
||||
lnd_getmil(struct lndstr *lp)
|
||||
{
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
getvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
|
||||
return vec[I_MILIT];
|
||||
return lp->lnd_item[I_MILIT];
|
||||
}
|
||||
|
||||
void
|
||||
lnd_submil(struct lndstr *lp, int num)
|
||||
{
|
||||
int vec[I_MAX + 1];
|
||||
|
||||
getvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
|
||||
vec[I_MILIT] -= num;
|
||||
if (vec[I_MILIT] < 0)
|
||||
vec[I_MILIT] = 0;
|
||||
putvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
|
||||
int new = lp->lnd_item[I_MILIT] - num;
|
||||
lp->lnd_item[I_MILIT] = new < 0 ? 0 : new;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -711,12 +703,12 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
|
|||
llp->land.lnd_harden = 0;
|
||||
}
|
||||
putland(llp->land.lnd_uid, &llp->land);
|
||||
if (!(mines = getvar(V_MINE, (s_char *)§, EF_SECTOR)))
|
||||
if (!(mines = sect.sct_mines))
|
||||
continue;
|
||||
max = vl_find(V_SHELL, llp->lcp->l_vtype,
|
||||
llp->lcp->l_vamt, (int)llp->lcp->l_nv);
|
||||
lshells = getvar(V_SHELL, (s_char *)&llp->land, EF_LAND);
|
||||
sshells = getvar(V_SHELL, (s_char *)§, EF_SECTOR);
|
||||
lshells = llp->land.lnd_item[I_SHELL];
|
||||
sshells = sect.sct_item[I_SHELL];
|
||||
for (m = 0; mines > 0 && m < max * 2; m++) {
|
||||
if (chance(0.5 * llp->lcp->l_att)) {
|
||||
mpr(actor, "Sweep...\n");
|
||||
|
@ -727,9 +719,9 @@ lnd_sweep(struct emp_qelem *land_list, int verbose, int takemob,
|
|||
++sshells;
|
||||
}
|
||||
}
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_SHELL, lshells, (s_char *)&llp->land, EF_LAND);
|
||||
putvar(V_SHELL, sshells, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = mines;
|
||||
llp->land.lnd_item[I_SHELL] = lshells;
|
||||
sect.sct_item[I_SHELL] = sshells;
|
||||
putland(llp->land.lnd_uid, &llp->land);
|
||||
putsect(§);
|
||||
}
|
||||
|
@ -758,9 +750,8 @@ lnd_check_mines(struct emp_qelem *land_list)
|
|||
struct emp_qelem *next;
|
||||
struct llist *llp;
|
||||
struct sctstr sect;
|
||||
int mines;
|
||||
int stopping = 0;
|
||||
int has_engineers = contains_engineer(land_list);
|
||||
int with_eng = contains_engineer(land_list);
|
||||
|
||||
for (qp = land_list->q_back; qp != land_list; qp = next) {
|
||||
next = qp->q_back;
|
||||
|
@ -770,12 +761,11 @@ lnd_check_mines(struct emp_qelem *land_list)
|
|||
continue;
|
||||
if (sect.sct_type == SCT_BSPAN)
|
||||
continue;
|
||||
if (!(mines = getvar(V_MINE, (s_char *)§, EF_SECTOR)))
|
||||
if (!sect.sct_mines)
|
||||
continue;
|
||||
if (chance(DMINE_LHITCHANCE(mines) / (1 + 2 * has_engineers))) {
|
||||
if (chance(DMINE_LHITCHANCE(sect.sct_mines) / (1 + 2 * with_eng))) {
|
||||
lnd_hit_mine(&llp->land, llp->lcp);
|
||||
mines--;
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines--;
|
||||
putsect(§);
|
||||
putland(llp->land.lnd_uid, (s_char *)&llp->land);
|
||||
if (!llp->land.lnd_own) {
|
||||
|
@ -951,7 +941,7 @@ lnd_fort_interdiction(struct emp_qelem *list,
|
|||
continue;
|
||||
if (getrel(getnatp(fsect.sct_own), victim) >= NEUTRAL)
|
||||
continue;
|
||||
gun = getvar(V_GUN, (s_char *)&fsect, EF_SECTOR);
|
||||
gun = fsect.sct_item[I_GUN];
|
||||
if (gun < 1)
|
||||
continue;
|
||||
range = tfactfire(fsect.sct_own, (double)min(gun, 7));
|
||||
|
@ -961,16 +951,16 @@ lnd_fort_interdiction(struct emp_qelem *list,
|
|||
trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
|
||||
if (trange > range2)
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)&fsect, EF_SECTOR) < 5)
|
||||
if (fsect.sct_item[I_MILIT] < 5)
|
||||
continue;
|
||||
shell = getvar(V_SHELL, (s_char *)&fsect, EF_SECTOR);
|
||||
shell = fsect.sct_item[I_SHELL];
|
||||
if (shell < 1)
|
||||
shell += supply_commod(fsect.sct_own,
|
||||
fsect.sct_x, fsect.sct_y, I_SHELL, 1);
|
||||
if (shell < 1)
|
||||
continue;
|
||||
shell--;
|
||||
putvar(V_SHELL, shell, (s_char *)&fsect, EF_SECTOR);
|
||||
fsect.sct_item[I_SHELL] = shell;
|
||||
putsect(&fsect);
|
||||
if (gun > 7)
|
||||
gun = 7;
|
||||
|
@ -1252,7 +1242,7 @@ lnd_support(natid victim, natid attacker, coord x, coord y)
|
|||
if (land.lnd_effic < LAND_MINFIREEFF)
|
||||
continue;
|
||||
/* Do we have mil? */
|
||||
if (getvar(V_MILIT, (s_char *)&land, EF_LAND) <= 0)
|
||||
if (land.lnd_item[I_MILIT] <= 0)
|
||||
continue;
|
||||
rel = getrel(getnatp(land.lnd_own), attacker);
|
||||
rel2 = getrel(getnatp(land.lnd_own), victim);
|
||||
|
@ -1273,8 +1263,8 @@ lnd_support(natid victim, natid attacker, coord x, coord y)
|
|||
if (dist > range2)
|
||||
continue;
|
||||
|
||||
shell = getvar(V_SHELL, (s_char *)&land, EF_LAND);
|
||||
gun = getvar(V_GUN, (s_char *)&land, EF_LAND);
|
||||
shell = land.lnd_item[I_SHELL];
|
||||
gun = land.lnd_item[I_GUN];
|
||||
|
||||
if (shell == 0 || gun == 0)
|
||||
continue;
|
||||
|
|
|
@ -492,8 +492,8 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
if (md > range2)
|
||||
continue;
|
||||
|
||||
shell = getvar(V_SHELL, (s_char *)lp, EF_LAND);
|
||||
gun = getvar(V_GUN, (s_char *)lp, EF_LAND);
|
||||
shell = lp->lnd_item[I_SHELL];
|
||||
gun = lp->lnd_item[I_GUN];
|
||||
if (shell == 0 || gun == 0)
|
||||
continue;
|
||||
|
||||
|
@ -531,7 +531,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
(mission == MI_SINTERDICT)) &&
|
||||
(md > ship_max_interdiction_range))
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)sp, EF_SHIP) < 1)
|
||||
if (sp->shp_item[I_MILIT] < 1)
|
||||
continue;
|
||||
/*
|
||||
if ((mcp->m_flags & M_SUB) &&
|
||||
|
@ -558,10 +558,10 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
continue;
|
||||
if (sp->shp_mobil < (s_char)0)
|
||||
continue;
|
||||
gun = getvar(V_GUN, (s_char *)sp, EF_SHIP);
|
||||
gun = sp->shp_item[I_GUN];
|
||||
if (gun < 1)
|
||||
continue;
|
||||
shell = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
shell = sp->shp_item[I_SHELL];
|
||||
if (shell < 3)
|
||||
shell += supply_commod(sp->shp_own,
|
||||
sp->shp_x, sp->shp_y, I_SHELL,
|
||||
|
@ -579,7 +579,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
|
||||
if (!line_of_sight((s_char **)0, x, y, gp->x, gp->y))
|
||||
continue;
|
||||
putvar(V_SHELL, shell - 3, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[I_SHELL] = shell - 3;
|
||||
mobcost = sp->shp_effic * 0.01 * sp->shp_speed;
|
||||
mobcost = (480.0 / (mobcost +
|
||||
techfact(sp->shp_tech, mobcost)));
|
||||
|
@ -620,17 +620,15 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
range2 = (double)roundrange(range);
|
||||
if (md > range2)
|
||||
continue;
|
||||
gun = getvar(V_GUN, (s_char *)sp, EF_SHIP);
|
||||
gun = sp->shp_item[I_GUN];
|
||||
gun = min(gun, sp->shp_glim);
|
||||
shell = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
shell = sp->shp_item[I_SHELL];
|
||||
if (shell < gun)
|
||||
shell += supply_commod(sp->shp_own,
|
||||
sp->shp_x, sp->shp_y, I_SHELL,
|
||||
gun - shell);
|
||||
gun = min(gun, shell);
|
||||
gun = min(gun, (int)((float)getvar(V_MILIT,
|
||||
(s_char *)sp,
|
||||
EF_SHIP) / 2.0));
|
||||
gun = min(gun, sp->shp_item[I_MILIT] / 2.0);
|
||||
if (gun == 0)
|
||||
continue;
|
||||
gun = max(gun, 1);
|
||||
|
@ -654,7 +652,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
mpr(victim, "%s fires at you at %s\n",
|
||||
cname(sp->shp_own), prship(sp), xyas(x, y, victim));
|
||||
|
||||
putvar(V_SHELL, shell - gun, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[I_SHELL] = shell - gun;
|
||||
putship(sp->shp_uid, sp);
|
||||
}
|
||||
} else if (glp->type == EF_PLANE) {
|
||||
|
|
|
@ -169,7 +169,7 @@ move_ground(s_char *what, struct sctstr *start, struct sctstr *end,
|
|||
else if (dir == DIR_VIEW) {
|
||||
pr("%d%% %s with %d civilians.\n", sect.sct_effic,
|
||||
dchr[sect.sct_type].d_name,
|
||||
getvar(V_CIVIL, (s_char *)§, EF_SECTOR));
|
||||
sect.sct_item[I_CIVIL]);
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
|
@ -347,20 +347,17 @@ int
|
|||
check_lmines(coord x, coord y, double weight)
|
||||
{
|
||||
struct sctstr sect;
|
||||
int mines;
|
||||
int dam = 0;
|
||||
|
||||
getsect(x, y, §);
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
if (mines > 0 &&
|
||||
if (sect.sct_mines > 0 &&
|
||||
sect.sct_oldown != player->cnum &&
|
||||
chance(DMINE_LHITCHANCE(mines)) && chance(weight / 100.0)) {
|
||||
chance(DMINE_LHITCHANCE(sect.sct_mines)) && chance(weight / 100.0)) {
|
||||
pr_beep();
|
||||
pr("Blammo! Landmines detected! in %s ",
|
||||
xyas(sect.sct_x, sect.sct_y, player->cnum));
|
||||
dam = roll(20);
|
||||
--mines;
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
--sect.sct_mines;
|
||||
putsect(§);
|
||||
pr("%d damage sustained.\n", dam);
|
||||
}
|
||||
|
|
|
@ -218,7 +218,8 @@ decode(natid cnum, long int code, void *addr, int type)
|
|||
|
||||
nsc_code = code & NSC_CMASK;
|
||||
if (nsc_code == NSC_VAR) {
|
||||
val = getvar(val, addr, type);
|
||||
u_short *item = ef_items(type, addr);
|
||||
val = item ? item[val] : 0;
|
||||
} else if (nsc_code == NSC_OFF) {
|
||||
/*
|
||||
* add offset to value
|
||||
|
|
|
@ -217,7 +217,6 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
|||
int there;
|
||||
int max;
|
||||
struct mchrstr *mp;
|
||||
int mines_there;
|
||||
|
||||
if (ip == 0)
|
||||
return;
|
||||
|
@ -229,8 +228,7 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
|||
if (type == EF_SECTOR &&
|
||||
(((struct sctstr *)ptr)->sct_type == SCT_WATER) &&
|
||||
ip->i_vtype == V_SHELL) {
|
||||
mines_there = getvar(V_MINE, ptr, EF_SECTOR);
|
||||
putvar(V_MINE, amt + mines_there, ptr, EF_SECTOR);
|
||||
((struct sctstr *)ptr)->sct_mines += amt;
|
||||
pr("%d mines laid in %s.\n", amt,
|
||||
xyas(((struct sctstr *)ptr)->sct_x,
|
||||
((struct sctstr *)ptr)->sct_y, player->cnum));
|
||||
|
@ -240,23 +238,25 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
|||
writemap(player->cnum);
|
||||
putsect((struct sctstr *)ptr);
|
||||
} else {
|
||||
there = getvar(ip->i_vtype, ptr, type) + amt;
|
||||
max = 32767;
|
||||
if (type == EF_SHIP) {
|
||||
ship = (struct shpstr *)ptr;
|
||||
there = ship->shp_item[ip->i_vtype];
|
||||
mp = &mchr[(int)ship->shp_type];
|
||||
max = vl_find(ip->i_vtype, mp->m_vtype,
|
||||
mp->m_vamt, (int)mp->m_nv);
|
||||
} else {
|
||||
there = ((struct sctstr *)ptr)->sct_item[ip->i_vtype];
|
||||
max = 32767;
|
||||
}
|
||||
there += amt;
|
||||
if (there > max) {
|
||||
pr("%d excess %s discarded\n", max - there, ip->i_name);
|
||||
amt = max - there;
|
||||
there = max;
|
||||
}
|
||||
putvar(ip->i_vtype, there, ptr, type);
|
||||
pr("%d %s landed safely", amt, ip->i_name);
|
||||
if (type == EF_SECTOR) {
|
||||
struct sctstr *sectp = (struct sctstr *)ptr;
|
||||
sectp->sct_item[ip->i_vtype] = there;
|
||||
if (sectp->sct_own != player->cnum)
|
||||
wu(0, sectp->sct_own, "%s planes drop %d %s in %s\n",
|
||||
cname(player->cnum), amt, ip->i_name,
|
||||
|
@ -265,12 +265,14 @@ pln_dropoff(struct emp_qelem *list, struct ichrstr *ip, coord tx, coord ty,
|
|||
putsect((struct sctstr *)ptr);
|
||||
} else {
|
||||
struct shpstr *sp = (struct shpstr *)ptr;
|
||||
sp->shp_item[ip->i_vtype] = there;
|
||||
if (sp->shp_own != player->cnum)
|
||||
wu(0, sp->shp_own, "%s planes land %d %s on carrier %d\n",
|
||||
cname(player->cnum), amt, ip->i_name, sp->shp_uid);
|
||||
pr(" on carrier #%d\n", ship->shp_uid);
|
||||
putship(ship->shp_uid, ship);
|
||||
}
|
||||
pr("%d %s landed safely", amt, ip->i_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -906,7 +908,7 @@ plane_sweep(struct emp_qelem *plane_list, coord x, coord y)
|
|||
int found = 0;
|
||||
|
||||
getsect(x, y, §);
|
||||
mines_there = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
mines_there = sect.sct_mines;
|
||||
|
||||
if (mines_there == 0)
|
||||
return;
|
||||
|
@ -933,7 +935,7 @@ plane_sweep(struct emp_qelem *plane_list, coord x, coord y)
|
|||
|
||||
if (found && map_set(player->cnum, sect.sct_x, sect.sct_y, 'X', 0))
|
||||
writemap(player->cnum);
|
||||
putvar(V_MINE, mines_there, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = mines_there;
|
||||
putsect(§);
|
||||
}
|
||||
|
||||
|
|
|
@ -279,19 +279,19 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
|
|||
if (stopping)
|
||||
continue;
|
||||
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
mines = sect.sct_mines;
|
||||
if ((mcp->m_flags & M_SWEEP) && mines > 0 && !player->owner) {
|
||||
max = vl_find(V_SHELL, mcp->m_vtype,
|
||||
mcp->m_vamt, (int)mcp->m_nv);
|
||||
shells = getvar(V_SHELL, (s_char *)sp, EF_SHIP);
|
||||
shells = sp->shp_item[I_SHELL];
|
||||
for (m = 0; mines > 0 && m < 5; m++) {
|
||||
if (chance(0.66)) {
|
||||
mines--;
|
||||
shells = min(max, shells + 1);
|
||||
}
|
||||
}
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_SHELL, shells, (s_char *)sp, EF_SHIP);
|
||||
sect.sct_mines = mines;
|
||||
sect.sct_item[I_SHELL] = shells;
|
||||
putsect(§);
|
||||
}
|
||||
if (mines > 0 && !player->owner && chance(DMINE_HITCHANCE(mines))) {
|
||||
|
@ -303,7 +303,7 @@ retreat_ship1(struct shpstr *sp, s_char code, int orig)
|
|||
m = MINE_DAMAGE();
|
||||
shipdamage(sp, m);
|
||||
mines--;
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = mines;
|
||||
putsect(§);
|
||||
if (sp->shp_effic < SHIP_MINEFF)
|
||||
time_to_stop = 1;
|
||||
|
@ -519,20 +519,20 @@ retreat_land1(struct lndstr *lp, s_char code, int orig)
|
|||
if (stopping)
|
||||
continue;
|
||||
|
||||
mines = getvar(V_MINE, (s_char *)§, EF_SECTOR);
|
||||
mines = sect.sct_mines;
|
||||
if ((lcp->l_flags & L_ENGINEER) && mines > 0 &&
|
||||
(sect.sct_oldown != lp->lnd_own)) {
|
||||
max = vl_find(V_SHELL, lcp->l_vtype,
|
||||
lcp->l_vamt, (int)lcp->l_nv);
|
||||
shells = getvar(V_SHELL, (s_char *)lp, EF_LAND);
|
||||
shells = lp->lnd_item[I_SHELL];
|
||||
for (m = 0; mines > 0 && m < 5; m++) {
|
||||
if (chance(0.66)) {
|
||||
mines--;
|
||||
shells = min(max, shells + 1);
|
||||
}
|
||||
}
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_SHELL, shells, (s_char *)lp, EF_LAND);
|
||||
sect.sct_mines = mines;
|
||||
lp->lnd_item[I_SHELL] = shells;
|
||||
putsect(§);
|
||||
}
|
||||
if (mines > 0 && (sect.sct_oldown != lp->lnd_own) &&
|
||||
|
@ -546,7 +546,7 @@ retreat_land1(struct lndstr *lp, s_char code, int orig)
|
|||
m = MINE_LDAMAGE();
|
||||
landdamage(lp, m);
|
||||
mines--;
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
sect.sct_mines = mines;
|
||||
putsect(§);
|
||||
if (lp->lnd_effic < LAND_MINEFF)
|
||||
time_to_stop = 1;
|
||||
|
|
|
@ -84,8 +84,8 @@ checksect(struct sctstr *sp)
|
|||
if (sp->sct_mobil > 127)
|
||||
sp->sct_mobil = 0;
|
||||
|
||||
mil = getvar(V_MILIT, (s_char *)sp, EF_SECTOR);
|
||||
civs = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR);
|
||||
mil = sp->sct_item[I_MILIT];
|
||||
civs = sp->sct_item[I_CIVIL];
|
||||
if (sp->sct_own == sp->sct_oldown)
|
||||
loyalcivs = civs;
|
||||
else
|
||||
|
|
|
@ -249,11 +249,11 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, natid actor)
|
|||
mlp->mobil -= mobcost;
|
||||
mlp->ship.shp_mobil = (int)mlp->mobil;
|
||||
putship(mlp->ship.shp_uid, &mlp->ship);
|
||||
if (!(mines = getvar(V_MINE, (s_char *)§, EF_SECTOR)))
|
||||
if (!(mines = sect.sct_mines))
|
||||
continue;
|
||||
max = vl_find(V_SHELL, mlp->mcp->m_vtype,
|
||||
mlp->mcp->m_vamt, (int)mlp->mcp->m_nv);
|
||||
shells = getvar(V_SHELL, (s_char *)&mlp->ship, EF_SHIP);
|
||||
shells = mlp->ship.shp_item[I_SHELL];
|
||||
for (m = 0; mines > 0 && m < 5; m++) {
|
||||
if (chance(0.66)) {
|
||||
mpr(actor, "Sweep...\n");
|
||||
|
@ -262,8 +262,8 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, natid actor)
|
|||
changed |= map_set(actor, sect.sct_x, sect.sct_y, 'X', 0);
|
||||
}
|
||||
}
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
putvar(V_SHELL, shells, (s_char *)&mlp->ship, EF_SHIP);
|
||||
sect.sct_mines = mines;
|
||||
mlp->ship.shp_item[I_SHELL] = shells;
|
||||
if (shp_check_one_mines(mlp)) {
|
||||
stopping = 1;
|
||||
emp_remque(qp);
|
||||
|
@ -281,23 +281,21 @@ static int
|
|||
shp_check_one_mines(struct mlist *mlp)
|
||||
{
|
||||
struct sctstr sect;
|
||||
int mines;
|
||||
int changed = 0;
|
||||
int actor;
|
||||
|
||||
getsect(mlp->ship.shp_x, mlp->ship.shp_y, §);
|
||||
if (sect.sct_type != SCT_WATER)
|
||||
return 0;
|
||||
if (!(mines = getvar(V_MINE, (s_char *)§, EF_SECTOR)))
|
||||
if (!sect.sct_mines)
|
||||
return 0;
|
||||
if (chance(DMINE_HITCHANCE(mines))) {
|
||||
if (chance(DMINE_HITCHANCE(sect.sct_mines))) {
|
||||
actor = mlp->ship.shp_own;
|
||||
shp_hit_mine(&mlp->ship, mlp->mcp);
|
||||
mines--;
|
||||
sect.sct_mines--;
|
||||
changed |= map_set(actor, sect.sct_x, sect.sct_y, 'X', 0);
|
||||
if (changed)
|
||||
writemap(actor);
|
||||
putvar(V_MINE, mines, (s_char *)§, EF_SECTOR);
|
||||
putsect(§);
|
||||
putship(mlp->ship.shp_uid, (s_char *)&mlp->ship);
|
||||
if (!mlp->ship.shp_own)
|
||||
|
@ -669,7 +667,7 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy,
|
|||
continue;
|
||||
if (fsect.sct_type != SCT_FORTR)
|
||||
continue;
|
||||
gun = getvar(V_GUN, (s_char *)&fsect, EF_SECTOR);
|
||||
gun = fsect.sct_item[I_GUN];
|
||||
if (gun < 1)
|
||||
continue;
|
||||
range = tfactfire(fsect.sct_own, (double)min(gun, 7));
|
||||
|
@ -679,16 +677,16 @@ shp_fort_interdiction(struct emp_qelem *list, coord newx, coord newy,
|
|||
trange = mapdist(newx, newy, fsect.sct_x, fsect.sct_y);
|
||||
if (trange > range2)
|
||||
continue;
|
||||
if (getvar(V_MILIT, (s_char *)&fsect, EF_SECTOR) < 5)
|
||||
if (fsect.sct_item[I_MILIT] < 5)
|
||||
continue;
|
||||
shell = getvar(V_SHELL, (s_char *)&fsect, EF_SECTOR);
|
||||
shell = fsect.sct_item[I_SHELL];
|
||||
if (shell < 1)
|
||||
shell += supply_commod(fsect.sct_own,
|
||||
fsect.sct_x, fsect.sct_y, I_SHELL, 1);
|
||||
if (shell < 1)
|
||||
continue;
|
||||
shell--;
|
||||
putvar(V_SHELL, shell, (s_char *)&fsect, EF_SECTOR);
|
||||
fsect.sct_item[I_SHELL] = shell;
|
||||
putsect(&fsect);
|
||||
if (gun > 7)
|
||||
gun = 7;
|
||||
|
@ -983,7 +981,7 @@ shp_missile_defense(coord dx, coord dy, natid bombown, int hardtarget)
|
|||
ship.shp_uid);
|
||||
mpr(ship.shp_own, "%d%% hitchance...", hitchance);
|
||||
/* use ammo */
|
||||
putvar(V_SHELL, vec[I_SHELL] - 2, (caddr_t)&ship, EF_SHIP);
|
||||
ship.shp_item[I_SHELL] = vec[I_SHELL] - 2;
|
||||
putship(ship.shp_uid, &ship);
|
||||
|
||||
if (roll(100) <= hitchance) {
|
||||
|
|
|
@ -54,15 +54,14 @@ takeover(register struct sctstr *sp, natid newown)
|
|||
int che;
|
||||
int che_count;
|
||||
int oldche;
|
||||
int n, vec[I_MAX + 1];
|
||||
int n;
|
||||
struct nstr_item ni;
|
||||
struct plnstr p;
|
||||
struct lndstr land;
|
||||
|
||||
/* Wipe all the distribution info */
|
||||
memset(vec, 0, sizeof(vec));
|
||||
putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR);
|
||||
putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR);
|
||||
memset(sp->sct_dist, 0, sizeof(sp->sct_dist));
|
||||
memset(sp->sct_del, 0, sizeof(sp->sct_del));
|
||||
if (sp->sct_own == 0)
|
||||
sp->sct_off = 0;
|
||||
else
|
||||
|
@ -116,8 +115,8 @@ takeover(register struct sctstr *sp, natid newown)
|
|||
}
|
||||
|
||||
sp->sct_avail = 0;
|
||||
civ = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR);
|
||||
oldche = get_che_value(getvar(V_CHE, (s_char *)sp, EF_SECTOR));
|
||||
civ = sp->sct_item[I_CIVIL];
|
||||
oldche = get_che_value(sp->sct_che);
|
||||
/*
|
||||
* create guerrillas from civilians
|
||||
* how spunky are these guys?
|
||||
|
@ -143,8 +142,8 @@ takeover(register struct sctstr *sp, natid newown)
|
|||
set_che_value(che, che_count);
|
||||
if (newown != sp->sct_oldown)
|
||||
set_che_cnum(che, newown);
|
||||
(void)putvar(V_CHE, che, (s_char *)sp, EF_SECTOR);
|
||||
(void)putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = che;
|
||||
sp->sct_item[I_CIVIL] = civ;
|
||||
if (sp->sct_oldown == newown || civ == 0) {
|
||||
/*
|
||||
* taking over one of your old sectors
|
||||
|
|
|
@ -139,10 +139,9 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
|||
pr("(%3d) tech %d %d%% %s [",
|
||||
tp->trd_owner, sp->shp_tech, sp->shp_effic, prship(sp));
|
||||
|
||||
for (i = 0; i < sp->shp_nv; i++) {
|
||||
if (isitem(sp->shp_vtype[i]))
|
||||
pr("%c:%d ",
|
||||
ichr[unitem(sp->shp_vtype[i])].i_mnem, sp->shp_vamt[i]);
|
||||
for (i = 1; i <= I_MAX; ++i) {
|
||||
if (sp->shp_item[i])
|
||||
pr("%c:%d ", ichr[i].i_mnem, sp->shp_item[i]);
|
||||
}
|
||||
pr("] #%d", tp->trd_unitid);
|
||||
if (opt_SHOWPLANE) {
|
||||
|
@ -198,10 +197,9 @@ trade_desc(struct trdstr *tp, union trdgenstr *tgp)
|
|||
pr("(%3d) tech %d %d%% %s [",
|
||||
tp->trd_owner,
|
||||
lp->lnd_tech, lp->lnd_effic, lchr[(int)lp->lnd_type].l_name);
|
||||
for (i = 0; i < lp->lnd_nv; i++) {
|
||||
if (isitem(lp->lnd_vtype[i]))
|
||||
pr("%c:%d ",
|
||||
ichr[unitem(lp->lnd_vtype[i])].i_mnem, lp->lnd_vamt[i]);
|
||||
for (i = 1; i <= I_MAX; ++i) {
|
||||
if (lp->lnd_item[i])
|
||||
pr("%c:%d ", ichr[i].i_mnem, lp->lnd_item[i]);
|
||||
}
|
||||
pr("] #%d", tp->trd_unitid);
|
||||
if (opt_SHOWPLANE) {
|
||||
|
@ -262,7 +260,7 @@ get_couval(int cnum)
|
|||
for (k = 0; ichr[k].i_name; k++) {
|
||||
if (ichr[k].i_value == 0 || ichr[k].i_vtype == 0)
|
||||
continue;
|
||||
val = getvar(ichr[k].i_vtype, (s_char *)sp, EF_SECTOR);
|
||||
val = sp->sct_item[ichr[k].i_vtype];
|
||||
secttot += val * ichr[k].i_value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,22 +100,16 @@ deliver(register struct sctstr *from, struct ichrstr *ip, int dir,
|
|||
if (amt_moved <= 0)
|
||||
return 0;
|
||||
}
|
||||
amt_dst = getvar(vtype, (caddr_t)to, EF_SECTOR);
|
||||
amt_dst = to->sct_item[vtype];
|
||||
if (amt_moved + amt_dst > 9990) {
|
||||
/* delivery backlog */
|
||||
if ((amt_moved = 9990 - amt_dst) <= 0)
|
||||
return 0;
|
||||
}
|
||||
if (putvar(vtype, amt_moved + amt_dst, (s_char *)to, EF_SECTOR) < 0) {
|
||||
/* "No room to deliver commodities */
|
||||
wu(0, from->sct_own, "no room for %s in %s\n",
|
||||
ip->i_name, ownxy(to));
|
||||
return 0;
|
||||
}
|
||||
to->sct_item[vtype] = amt_moved + amt_dst;
|
||||
/* deliver the plague too! */
|
||||
if (plague == PLG_INFECT
|
||||
&& getvar(V_PSTAGE, (s_char *)to, EF_SECTOR) == 0)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)to, EF_SECTOR);
|
||||
if (plague == PLG_INFECT && to->sct_pstage == PLG_HEALTHY)
|
||||
to->sct_pstage = PLG_EXPOSED;
|
||||
n = from->sct_mobil - (int)(mcost * amt_moved);
|
||||
if (n < 0)
|
||||
n = 0;
|
||||
|
|
|
@ -64,7 +64,6 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
|||
int dist_packing;
|
||||
int diff;
|
||||
int item;
|
||||
int dists[I_MAX + 1];
|
||||
int remote[I_MAX + 1];
|
||||
int local[I_MAX + 1];
|
||||
int changed;
|
||||
|
@ -75,9 +74,6 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
|||
if ((sp->sct_dist_x == sp->sct_x) && (sp->sct_dist_y == sp->sct_y))
|
||||
return 0;
|
||||
|
||||
if (getvec(VT_DIST, dists, (s_char *)sp, EF_SECTOR) <= 0)
|
||||
return 0;
|
||||
|
||||
if (path == (s_char *)0) {
|
||||
if (sp->sct_own != 0) {
|
||||
if (imex == EXPORT) /* only want this once */
|
||||
|
@ -104,10 +100,10 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
|||
getvec(VT_ITEM, remote, (s_char *)dist, EF_SECTOR);
|
||||
lplague = rplague = changed = 0;
|
||||
for (item = 1; item < I_MAX + 1; item++) {
|
||||
if (dists[item] == 0)
|
||||
if (sp->sct_dist[item] == 0)
|
||||
continue;
|
||||
ip = &ichr[item];
|
||||
thresh = dists[item];
|
||||
thresh = sp->sct_dist[item];
|
||||
/*
|
||||
* calculate costs for importing and exporting.
|
||||
* the div 10.0 is because delivering straight through
|
||||
|
@ -204,19 +200,15 @@ dodistribute(struct sctstr *sp, int imex, s_char *path, double dist_i_cost,
|
|||
putvec(VT_ITEM, local, (s_char *)sp, EF_SECTOR);
|
||||
|
||||
if (lplague) {
|
||||
lplague = getvar(V_PSTAGE, (s_char *)dist, EF_SECTOR);
|
||||
if (lplague == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR) == PLG_HEALTHY) {
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)sp, EF_SECTOR);
|
||||
}
|
||||
lplague = dist->sct_pstage;
|
||||
if (lplague == PLG_INFECT && sp->sct_pstage == PLG_HEALTHY)
|
||||
sp->sct_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
||||
if (rplague) {
|
||||
rplague = getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR);
|
||||
if (rplague == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)dist, EF_SECTOR) == PLG_HEALTHY) {
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)dist, EF_SECTOR);
|
||||
}
|
||||
rplague = sp->sct_pstage;
|
||||
if (rplague == PLG_INFECT && dist->sct_pstage == PLG_HEALTHY)
|
||||
dist->sct_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
|
|
@ -116,8 +116,8 @@ upd_land(register struct lndstr *lp, register int etus,
|
|||
/* build = 1, maintain = 0 */
|
||||
{
|
||||
struct lchrstr *lcp;
|
||||
u_short pstage, ptime;
|
||||
int vec[I_MAX + 1];
|
||||
int cvec[I_MAX + 1];
|
||||
int n;
|
||||
int min = morale_base - (int)np->nat_level[NAT_HLEV];
|
||||
int mult;
|
||||
|
@ -186,9 +186,10 @@ upd_land(register struct lndstr *lp, register int etus,
|
|||
* do plague stuff. plague can't break out on land units,
|
||||
* but it can still kill people on them.
|
||||
*/
|
||||
getvec(VT_COND, cvec, (s_char *)lp, EF_LAND);
|
||||
if (cvec[C_PSTAGE] > 0) {
|
||||
n = plague_people(np, vec, cvec, etus);
|
||||
pstage = lp->lnd_pstage;
|
||||
ptime = lp->lnd_ptime;
|
||||
if (pstage != PLG_HEALTHY) {
|
||||
n = plague_people(np, vec, &pstage, &ptime, etus);
|
||||
switch (n) {
|
||||
case PLG_DYING:
|
||||
wu(0, lp->lnd_own,
|
||||
|
@ -200,9 +201,9 @@ upd_land(register struct lndstr *lp, register int etus,
|
|||
break;
|
||||
case PLG_INCUBATE:
|
||||
/* Are we still incubating? */
|
||||
if (n == cvec[C_PSTAGE]) {
|
||||
if (n == pstage) {
|
||||
/* Yes. Will it turn "infectious" next time? */
|
||||
if (cvec[C_PTIME] <= etus) {
|
||||
if (ptime <= etus) {
|
||||
/* Yes. Report an outbreak. */
|
||||
wu(0, lp->lnd_own,
|
||||
"Outbreak of PLAGUE on %s!\n", prland(lp));
|
||||
|
@ -216,9 +217,9 @@ upd_land(register struct lndstr *lp, register int etus,
|
|||
break;
|
||||
case PLG_EXPOSED:
|
||||
/* Has the plague moved to "incubation" yet? */
|
||||
if (n != cvec[C_PSTAGE]) {
|
||||
if (n != pstage) {
|
||||
/* Yes. Will it turn "infectious" next time? */
|
||||
if (cvec[C_PTIME] <= etus) {
|
||||
if (ptime <= etus) {
|
||||
/* Yes. Report an outbreak. */
|
||||
wu(0, lp->lnd_own,
|
||||
"Outbreak of PLAGUE on %s!\n", prland(lp));
|
||||
|
@ -229,7 +230,8 @@ upd_land(register struct lndstr *lp, register int etus,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
putvec(VT_COND, cvec, (s_char *)lp, EF_LAND);
|
||||
lp->lnd_pstage = pstage;
|
||||
lp->lnd_ptime = ptime;
|
||||
}
|
||||
putvec(VT_ITEM, vec, (s_char *)lp, EF_LAND);
|
||||
} /* end !player->simulation */
|
||||
|
|
|
@ -240,11 +240,11 @@ int
|
|||
nav_ship(register struct shpstr *sp)
|
||||
{
|
||||
struct sctstr *sectp;
|
||||
s_char *cp, item;
|
||||
s_char *cp;
|
||||
int stopping;
|
||||
int quit;
|
||||
int didsomething = 0;
|
||||
int max_amt, food_amt, comm;
|
||||
int max_amt, food_amt;
|
||||
s_char buf[1024];
|
||||
struct emp_qelem ship_list;
|
||||
struct emp_qelem *qp, *newqp;
|
||||
|
@ -332,11 +332,9 @@ nav_ship(register struct shpstr *sp)
|
|||
}
|
||||
/* special case for fishing boats */
|
||||
if ((mchr[(int)sp->shp_type].m_flags & M_FOOD) == 1) {
|
||||
item = (s_char)'f';
|
||||
comm = com_num(&item);
|
||||
food_amt = getvar(comm, (s_char *)sp, EF_SHIP);
|
||||
max_amt = (vl_find(comm, vship->m_vtype,
|
||||
vship->m_vamt, (int)vship->m_nv));
|
||||
food_amt = sp->shp_item[I_FOOD];
|
||||
max_amt = vl_find(V_FOOD, vship->m_vtype,
|
||||
vship->m_vamt, vship->m_nv);
|
||||
sectp = getsectp(sp->shp_x, sp->shp_y);
|
||||
|
||||
if (food_amt < max_amt && (sectp->sct_own == 0))
|
||||
|
|
|
@ -94,8 +94,8 @@ load_it(register struct shpstr *sp, register struct sctstr *psect, int i)
|
|||
item = sp->shp_tend[i]; /* commodity */
|
||||
comm = com_num(&item);
|
||||
|
||||
ship_amt = getvar(comm, (s_char *)sp, EF_SHIP);
|
||||
sect_amt = getvar(comm, (s_char *)psect, EF_SECTOR);
|
||||
ship_amt = sp->shp_item[comm];
|
||||
sect_amt = psect->sct_item[comm];
|
||||
|
||||
/* check for disloyal civilians */
|
||||
if (psect->sct_oldown != shipown && comm == V_CIVIL) {
|
||||
|
@ -133,18 +133,16 @@ load_it(register struct shpstr *sp, register struct sctstr *psect, int i)
|
|||
return 0; /* nothing to move */
|
||||
|
||||
|
||||
putvar(comm, ship_amt + transfer, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_item[comm] = ship_amt + transfer;
|
||||
if (comm == V_CIVIL || comm == V_MILIT)
|
||||
sect_amt++; /*adjustment */
|
||||
putvar(comm, sect_amt - transfer, (s_char *)psect, EF_SECTOR);
|
||||
psect->sct_item[comm] = sect_amt - transfer;
|
||||
|
||||
/* deal with the plague */
|
||||
if (getvar(V_PSTAGE, (s_char *)psect, EF_SECTOR) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)sp, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)sp, EF_SHIP);
|
||||
if (getvar(V_PSTAGE, (s_char *)sp, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)psect, EF_SECTOR) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)psect, EF_SECTOR);
|
||||
if (psect->sct_pstage == PLG_INFECT && sp->shp_pstage == PLG_HEALTHY)
|
||||
sp->shp_pstage = PLG_EXPOSED;
|
||||
if (sp->shp_pstage == PLG_INFECT && psect->sct_pstage == PLG_HEALTHY)
|
||||
psect->sct_pstage = PLG_EXPOSED;
|
||||
|
||||
return 1; /* we did someloading return 1 to keep */
|
||||
/* our loop happy in nav_ship() */
|
||||
|
@ -192,8 +190,8 @@ unload_it(register struct shpstr *sp)
|
|||
continue;
|
||||
|
||||
comm = com_num(&item);
|
||||
ship_amt = getvar(comm, (s_char *)sp, EF_SHIP);
|
||||
sect_amt = getvar(comm, (s_char *)sectp, EF_SECTOR);
|
||||
ship_amt = sp->shp_item[comm];
|
||||
sect_amt = sectp->sct_item[comm];
|
||||
|
||||
/* check for disloyal civilians */
|
||||
if (sectp->sct_oldown != shipown && comm == V_CIVIL) {
|
||||
|
@ -214,25 +212,20 @@ unload_it(register struct shpstr *sp)
|
|||
if (max_amt <= 0)
|
||||
continue;
|
||||
|
||||
putvar(comm, ship_amt - max_amt, (s_char *)sp, EF_SHIP);
|
||||
putvar(comm, sect_amt + max_amt, (s_char *)sectp, EF_SECTOR);
|
||||
|
||||
if (getvar(V_PSTAGE, (s_char *)sectp, EF_SECTOR) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)sp, EF_SHIP) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)sp, EF_SHIP);
|
||||
|
||||
if (getvar(V_PSTAGE, (s_char *)sp, EF_SHIP) == PLG_INFECT &&
|
||||
getvar(V_PSTAGE, (s_char *)sectp, EF_SECTOR) == PLG_HEALTHY)
|
||||
putvar(V_PSTAGE, PLG_EXPOSED, (s_char *)sectp, EF_SECTOR);
|
||||
sp->shp_item[comm] = ship_amt - max_amt;
|
||||
sectp->sct_item[comm] = sect_amt + max_amt;
|
||||
|
||||
if (sectp->sct_pstage == PLG_INFECT && sp->shp_pstage == PLG_HEALTHY)
|
||||
sp->shp_pstage = PLG_EXPOSED;
|
||||
if (sp->shp_pstage == PLG_INFECT && sectp->sct_pstage == PLG_HEALTHY)
|
||||
sectp->sct_pstage = PLG_EXPOSED;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* com_num
|
||||
* This small but useful bit of code runs through the list
|
||||
* of commodities and return the integer value of the
|
||||
* commodity it finds if possible. Very handy when using getvar().
|
||||
* commodity it finds if possible.
|
||||
* Basicly its a hacked version of whatitem.c found in the
|
||||
* /player directory.
|
||||
* new autonav code.
|
||||
|
|
|
@ -54,7 +54,7 @@ void
|
|||
do_plague(struct sctstr *sp, struct natstr *np, int etu)
|
||||
{
|
||||
int vec[I_MAX + 1];
|
||||
int cvec[I_MAX + 1];
|
||||
u_short pstage, ptime;
|
||||
int n;
|
||||
|
||||
if (opt_NO_PLAGUE) /* no plague nothing to do */
|
||||
|
@ -62,15 +62,14 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu)
|
|||
|
||||
if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
|
||||
return;
|
||||
if (getvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR) <= 0)
|
||||
memset(cvec, 0, sizeof(cvec));
|
||||
pstage = sp->sct_pstage;
|
||||
ptime = sp->sct_ptime;
|
||||
|
||||
if (cvec[C_PSTAGE] == 0) {
|
||||
cvec[C_PSTAGE] = infect_people(np, vec, sp->sct_effic,
|
||||
(int)sp->sct_mobil, sp);
|
||||
cvec[C_PTIME] = 0;
|
||||
if (pstage == PLG_HEALTHY) {
|
||||
pstage = infect_people(np, vec, sp->sct_effic, (int)sp->sct_mobil, sp);
|
||||
ptime = 0;
|
||||
} else {
|
||||
n = plague_people(np, vec, cvec, etu);
|
||||
n = plague_people(np, vec, &pstage, &ptime, etu);
|
||||
switch (n) {
|
||||
case PLG_DYING:
|
||||
wu(0, sp->sct_own, "PLAGUE deaths reported in %s.\n",
|
||||
|
@ -82,9 +81,9 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu)
|
|||
break;
|
||||
case PLG_INCUBATE:
|
||||
/* Are we still incubating? */
|
||||
if (n == cvec[C_PSTAGE]) {
|
||||
if (n == pstage) {
|
||||
/* Yes. Will it turn "infectious" next time? */
|
||||
if (cvec[C_PTIME] <= etu) {
|
||||
if (ptime <= etu) {
|
||||
/* Yes. Report an outbreak. */
|
||||
wu(0, sp->sct_own,
|
||||
"Outbreak of PLAGUE in %s!\n", ownxy(sp));
|
||||
|
@ -97,9 +96,9 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu)
|
|||
break;
|
||||
case PLG_EXPOSED:
|
||||
/* Has the plague moved to "incubation" yet? */
|
||||
if (n != cvec[C_PSTAGE]) {
|
||||
if (n != pstage) {
|
||||
/* Yes. Will it turn "infectious" next time? */
|
||||
if (cvec[C_PTIME] <= etu) {
|
||||
if (ptime <= etu) {
|
||||
/* Yes. Report an outbreak. */
|
||||
wu(0, sp->sct_own,
|
||||
"Outbreak of PLAGUE in %s!\n", ownxy(sp));
|
||||
|
@ -118,7 +117,8 @@ do_plague(struct sctstr *sp, struct natstr *np, int etu)
|
|||
sp->sct_oldown = 0;
|
||||
}
|
||||
putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
|
||||
putvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_pstage = pstage;
|
||||
sp->sct_ptime = ptime;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
@ -160,7 +160,8 @@ infect_people(struct natstr *np, register int *vec, u_int eff, int mobil,
|
|||
* stage. No reports generated here anymore.
|
||||
*/
|
||||
int
|
||||
plague_people(struct natstr *np, register int *vec, register int *cvec,
|
||||
plague_people(struct natstr *np, register int *vec,
|
||||
u_short *pstage, u_short *ptime,
|
||||
int etus)
|
||||
{
|
||||
int stage;
|
||||
|
@ -170,13 +171,13 @@ plague_people(struct natstr *np, register int *vec, register int *cvec,
|
|||
|
||||
if (opt_NO_PLAGUE) /* no plague nothing to do */
|
||||
return PLG_HEALTHY;
|
||||
cvec[C_PTIME] -= etus;
|
||||
stage = cvec[C_PSTAGE];
|
||||
*ptime -= etus;
|
||||
stage = *pstage;
|
||||
switch (stage) {
|
||||
case PLG_DYING:
|
||||
plg_num = 100.0 * etus;
|
||||
plg_denom = (np->nat_level[NAT_RLEV] + 100.0) *
|
||||
(vec[C_PTIME] + etus + 1.0);
|
||||
(*ptime + etus + 1.0);
|
||||
pct_left = 1.0 - (double)(plg_num / plg_denom);
|
||||
if (pct_left < 0.2)
|
||||
pct_left = 0.2;
|
||||
|
@ -188,18 +189,18 @@ plague_people(struct natstr *np, register int *vec, register int *cvec,
|
|||
case PLG_INCUBATE:
|
||||
break;
|
||||
case PLG_EXPOSED:
|
||||
cvec[C_PTIME] = 0;
|
||||
*ptime = 0;
|
||||
break;
|
||||
default:
|
||||
/* bad */
|
||||
logerror("plague_people: bad pstage %d", stage);
|
||||
cvec[C_PSTAGE] = PLG_HEALTHY;
|
||||
cvec[C_PTIME] = 0;
|
||||
*pstage = PLG_HEALTHY;
|
||||
*ptime = 0;
|
||||
return PLG_HEALTHY;
|
||||
}
|
||||
if (cvec[C_PTIME] <= 0) {
|
||||
cvec[C_PSTAGE]--;
|
||||
cvec[C_PTIME] = (etus / 2) + (random() % etus);
|
||||
if (*ptime <= 0) {
|
||||
*pstage -= 1;
|
||||
*ptime = (etus / 2) + (random() % etus);
|
||||
}
|
||||
return stage;
|
||||
}
|
||||
|
|
|
@ -65,12 +65,8 @@ prepare_sects(int etu, int *bp)
|
|||
if (opt_FALLOUT) {
|
||||
if (!player->simulation) {
|
||||
/* First, we determine which sectors to process fallout in */
|
||||
for (n = 0; NULL != (sp = getsectid(n)); n++) {
|
||||
if (getvar(V_FALLOUT, (s_char *)sp, EF_SECTOR))
|
||||
sp->sct_updated = 1;
|
||||
else
|
||||
sp->sct_updated = 0;
|
||||
}
|
||||
for (n = 0; NULL != (sp = getsectid(n)); n++)
|
||||
sp->sct_updated = sp->sct_fallout != 0;
|
||||
/* Next, we process the fallout there */
|
||||
for (n = 0; NULL != (sp = getsectid(n)); n++)
|
||||
if (sp->sct_updated)
|
||||
|
@ -81,7 +77,7 @@ prepare_sects(int etu, int *bp)
|
|||
spread_fallout(sp, etu);
|
||||
/* Next, we decay the fallout */
|
||||
for (n = 0; NULL != (sp = getsectid(n)); n++)
|
||||
if (getvar(V_FALLOUT, (s_char *)sp, EF_SECTOR))
|
||||
if (sp->sct_fallout)
|
||||
decay_fallout(sp, etu);
|
||||
}
|
||||
}
|
||||
|
@ -158,13 +154,13 @@ upd_slmilcosts(natid n, int etu)
|
|||
for (i = 0; NULL != (sp = getshipp(i)); i++) {
|
||||
if (!sp->shp_own || sp->shp_own != n)
|
||||
continue;
|
||||
if ((mil = getvar(V_MILIT, (s_char *)sp, EF_SHIP)) > 0)
|
||||
if ((mil = sp->shp_item[I_MILIT]) > 0)
|
||||
totalmil += mil;
|
||||
}
|
||||
for (i = 0; NULL != (lp = getlandp(i)); i++) {
|
||||
if (!lp->lnd_own || lp->lnd_own != n)
|
||||
continue;
|
||||
if ((mil = getvar(V_MILIT, (s_char *)lp, EF_LAND)) > 0)
|
||||
if ((mil = lp->lnd_item[I_MILIT]) > 0)
|
||||
totalmil += mil;
|
||||
}
|
||||
mil_pay = totalmil * etu * money_mil;
|
||||
|
|
|
@ -64,13 +64,13 @@ revolt(struct sctstr *sp)
|
|||
int n;
|
||||
int target;
|
||||
|
||||
che_combo = getvar(V_CHE, (s_char *)sp, EF_SECTOR);
|
||||
che_combo = sp->sct_che;
|
||||
che = get_che_value(che_combo);
|
||||
target = get_che_cnum(che_combo);
|
||||
if (che_combo != 0 && (target != sp->sct_own || che >= CHE_MAX))
|
||||
return;
|
||||
civ = getvar(V_CIVIL, (s_char *)sp, EF_SECTOR);
|
||||
uw = getvar(V_UW, (s_char *)sp, EF_SECTOR);
|
||||
civ = sp->sct_item[I_CIVIL];
|
||||
uw = sp->sct_item[I_UW];
|
||||
if (che > (civ + uw) * 3)
|
||||
return;
|
||||
che_uw = 0;
|
||||
|
@ -100,11 +100,11 @@ revolt(struct sctstr *sp)
|
|||
uw -= che_uw;
|
||||
set_che_cnum(che_combo, sp->sct_own);
|
||||
set_che_value(che_combo, che);
|
||||
putvar(V_CHE, (int)che_combo, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = che_combo;
|
||||
if (che_civ > 0)
|
||||
putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_CIVIL] = civ;
|
||||
if (che_uw > 0)
|
||||
putvar(V_UW, uw, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_UW] = uw;
|
||||
#ifdef DEBUG
|
||||
logerror("(#%d) %d che fired up in %s",
|
||||
sp->sct_own, che, ownxy(sp));
|
||||
|
@ -166,7 +166,7 @@ guerrilla(struct sctstr *sp)
|
|||
recruit = 0;
|
||||
convert = 0;
|
||||
move = 0;
|
||||
if ((n = getvar(V_CHE, (s_char *)sp, EF_SECTOR)) <= 0)
|
||||
if ((n = sp->sct_che) <= 0)
|
||||
return;
|
||||
che_combo = n;
|
||||
if (getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR) <= 0)
|
||||
|
@ -213,7 +213,7 @@ guerrilla(struct sctstr *sp)
|
|||
|
||||
/* Security forces killed all the che */
|
||||
if (che <= 0) {
|
||||
putvar(V_CHE, 0, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,8 +227,8 @@ guerrilla(struct sctstr *sp)
|
|||
/* target nation has dissolved: che's retire. */
|
||||
logerror("%d Che targeted at country %d retiring", che, target);
|
||||
civ += che;
|
||||
putvar(V_CHE, 0, (s_char *)sp, EF_SECTOR);
|
||||
putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = 0;
|
||||
sp->sct_item[I_CIVIL] = civ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -352,9 +352,9 @@ guerrilla(struct sctstr *sp)
|
|||
sp->sct_newtype = SCT_AGRI;
|
||||
n = civ / 20;
|
||||
civ -= n;
|
||||
putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
|
||||
putvar(V_UW, uw, (s_char *)sp, EF_SECTOR);
|
||||
putvar(V_MILIT, n, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_CIVIL] = civ;
|
||||
sp->sct_item[I_UW] = uw;
|
||||
sp->sct_item[I_MILIT] = n;
|
||||
move++;
|
||||
recruit = 0;
|
||||
if (sp->sct_own)
|
||||
|
@ -378,14 +378,14 @@ guerrilla(struct sctstr *sp)
|
|||
n = CHE_MAX - che;
|
||||
che += n;
|
||||
civ -= n;
|
||||
putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_CIVIL] = civ;
|
||||
}
|
||||
n = uw * (random() % 3) / 200;
|
||||
if (n + che > CHE_MAX)
|
||||
n = CHE_MAX - che;
|
||||
che += n;
|
||||
uw -= n;
|
||||
putvar(V_UW, uw, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_UW] = uw;
|
||||
}
|
||||
domove:
|
||||
if (move && che > 0) {
|
||||
|
@ -402,14 +402,14 @@ guerrilla(struct sctstr *sp)
|
|||
continue;
|
||||
if (nsp->sct_own != target)
|
||||
continue;
|
||||
if ((val = getvar(V_CHE, (s_char *)nsp, EF_SECTOR)) > 0) {
|
||||
if ((val = nsp->sct_che) > 0) {
|
||||
che_combo = val;
|
||||
if (get_che_cnum(che_combo) != target)
|
||||
continue;
|
||||
if (get_che_value(che_combo) + che > CHE_MAX)
|
||||
continue;
|
||||
}
|
||||
val = getvar(V_MILIT, (s_char *)nsp, EF_SECTOR);
|
||||
val = nsp->sct_item[I_MILIT];
|
||||
/* don't give che more precise info than spy */
|
||||
val = roundintby(val, 10);
|
||||
/* inject a modicum of indeterminism; also
|
||||
|
@ -422,20 +422,20 @@ guerrilla(struct sctstr *sp)
|
|||
}
|
||||
/* if we found a nice sector, go there */
|
||||
if (nicest_sp != 0) {
|
||||
che_combo = getvar(V_CHE, (s_char *)nicest_sp, EF_SECTOR);
|
||||
che_combo = nicest_sp->sct_che;
|
||||
che += get_che_value(che_combo);
|
||||
set_che_value(che_combo, che);
|
||||
set_che_cnum(che_combo, target);
|
||||
putvar(V_CHE, (int)che_combo, (s_char *)nicest_sp, EF_SECTOR);
|
||||
nicest_sp->sct_che = che_combo;
|
||||
che = 0;
|
||||
}
|
||||
}
|
||||
if (che > 0) {
|
||||
set_che_value(che_combo, che);
|
||||
set_che_cnum(che_combo, target);
|
||||
putvar(V_CHE, (int)che_combo, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = che_combo;
|
||||
} else
|
||||
putvar(V_CHE, 0, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_che = 0;
|
||||
if (mc > 0 || cc > 0) {
|
||||
/* don't tell who won just to be mean */
|
||||
wu(0, target,
|
||||
|
@ -456,13 +456,13 @@ take_casualties(struct sctstr *sp, int mc)
|
|||
struct nstr_item ni;
|
||||
|
||||
/* casualties come out of mil first */
|
||||
orig_mil = getvar(V_MILIT, (s_char *)sp, EF_SECTOR);
|
||||
orig_mil = sp->sct_item[I_MILIT];
|
||||
|
||||
if (mc <= orig_mil) {
|
||||
putvar(V_MILIT, (orig_mil - mc), (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_MILIT] = orig_mil - mc;
|
||||
return;
|
||||
}
|
||||
putvar(V_MILIT, 0, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_item[I_MILIT] = 0;
|
||||
|
||||
/* remaining casualites */
|
||||
mc -= orig_mil;
|
||||
|
|
|
@ -59,7 +59,6 @@ int
|
|||
dodeliver(struct sctstr *sp, int *vec)
|
||||
{
|
||||
register int i;
|
||||
int del[I_MAX + 1];
|
||||
int thresh;
|
||||
int dir;
|
||||
int plague;
|
||||
|
@ -68,15 +67,13 @@ dodeliver(struct sctstr *sp, int *vec)
|
|||
|
||||
if (sp->sct_mobil <= 0)
|
||||
return 0;
|
||||
if (getvec(VT_DEL, del, (s_char *)sp, EF_SECTOR) <= 0)
|
||||
return 0;
|
||||
changed = 0;
|
||||
plague = getvar(V_PSTAGE, (s_char *)sp, EF_SECTOR);
|
||||
plague = sp->sct_pstage;
|
||||
for (i = 1; i <= I_MAX; i++) {
|
||||
if (del[i] == 0)
|
||||
if (sp->sct_del[i] == 0)
|
||||
continue;
|
||||
thresh = del[i] & ~0x7;
|
||||
dir = del[i] & 0x7;
|
||||
thresh = sp->sct_del[i] & ~0x7;
|
||||
dir = sp->sct_del[i] & 0x7;
|
||||
n = deliver(sp, &ichr[i], dir, thresh, vec[i], plague);
|
||||
if (n > 0) {
|
||||
vec[i] -= n;
|
||||
|
@ -241,23 +238,21 @@ void
|
|||
do_fallout(register struct sctstr *sp, register int etus)
|
||||
{
|
||||
int vec[I_MAX + 1];
|
||||
int cvec[I_MAX + 1];
|
||||
int tvec[I_MAX + 1];
|
||||
struct shpstr *spp;
|
||||
struct lndstr *lp;
|
||||
int i;
|
||||
|
||||
getvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
|
||||
getvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR);
|
||||
/* This check shouldn't be needed, but just in case. :) */
|
||||
if (!cvec[C_FALLOUT] || !sp->sct_updated)
|
||||
if (!sp->sct_fallout || !sp->sct_updated)
|
||||
return;
|
||||
if (etus > 24)
|
||||
etus = 24;
|
||||
#if 0
|
||||
wu(0, 0, "Running fallout in %d,%d\n", sp->sct_x, sp->sct_y);
|
||||
#endif
|
||||
meltitems(etus, cvec[C_FALLOUT], sp->sct_own, vec, EF_SECTOR,
|
||||
meltitems(etus, sp->sct_fallout, sp->sct_own, vec, EF_SECTOR,
|
||||
sp->sct_x, sp->sct_y, 0);
|
||||
putvec(VT_ITEM, vec, (s_char *)sp, EF_SECTOR);
|
||||
for (i = 0; NULL != (lp = getlandp(i)); i++) {
|
||||
|
@ -266,7 +261,7 @@ do_fallout(register struct sctstr *sp, register int etus)
|
|||
if (lp->lnd_x != sp->sct_x || lp->lnd_y != sp->sct_y)
|
||||
continue;
|
||||
getvec(VT_ITEM, tvec, (s_char *)lp, EF_LAND);
|
||||
meltitems(etus, cvec[C_FALLOUT], lp->lnd_own, tvec, EF_LAND,
|
||||
meltitems(etus, sp->sct_fallout, lp->lnd_own, tvec, EF_LAND,
|
||||
lp->lnd_x, lp->lnd_y, lp->lnd_uid);
|
||||
putvec(VT_ITEM, tvec, (s_char *)lp, EF_LAND);
|
||||
}
|
||||
|
@ -278,12 +273,12 @@ do_fallout(register struct sctstr *sp, register int etus)
|
|||
if (mchr[(int)spp->shp_type].m_flags & M_SUB)
|
||||
continue;
|
||||
getvec(VT_ITEM, tvec, (s_char *)spp, EF_SHIP);
|
||||
meltitems(etus, cvec[C_FALLOUT], spp->shp_own, tvec, EF_SHIP,
|
||||
meltitems(etus, sp->sct_fallout, spp->shp_own, tvec, EF_SHIP,
|
||||
spp->shp_x, spp->shp_y, spp->shp_uid);
|
||||
putvec(VT_ITEM, tvec, (s_char *)spp, EF_SHIP);
|
||||
}
|
||||
#ifdef GODZILLA
|
||||
if ((cvec[C_FALLOUT] > 20) && chance(100))
|
||||
if ((sp->sct_fallout > 20) && chance(100))
|
||||
do_godzilla(sp);
|
||||
#endif /* GODZILLA */
|
||||
}
|
||||
|
@ -292,58 +287,48 @@ void
|
|||
spread_fallout(struct sctstr *sp, int etus)
|
||||
{
|
||||
struct sctstr *ap;
|
||||
int tvec[I_MAX + 1];
|
||||
int cvec[I_MAX + 1];
|
||||
int n;
|
||||
register int inc;
|
||||
|
||||
if (etus > 24)
|
||||
etus = 24;
|
||||
getvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR);
|
||||
for (n = DIR_FIRST; n <= DIR_LAST; n++) {
|
||||
ap = getsectp(sp->sct_x + diroff[n][0], sp->sct_y + diroff[n][1]);
|
||||
getvec(VT_COND, tvec, (char *)ap, EF_SECTOR);
|
||||
if (ap->sct_type == SCT_SANCT)
|
||||
continue;
|
||||
inc = roundavg(etus * fallout_spread * (cvec[C_FALLOUT])) - 1;
|
||||
inc = roundavg(etus * fallout_spread * (sp->sct_fallout)) - 1;
|
||||
#if 0
|
||||
if (cvec[C_FALLOUT]) {
|
||||
if (sp->sct_fallout) {
|
||||
wu(0, 0, "Fallout from sector %d,%d to %d,%d is %d=%d*%e*%d\n",
|
||||
sp->sct_x, sp->sct_y, sp->sct_x + diroff[n][0],
|
||||
sp->sct_y + diroff[n][1], inc, etus,
|
||||
fallout_spread, cvec[C_FALLOUT]);
|
||||
fallout_spread, sp->sct_fallout);
|
||||
}
|
||||
#endif
|
||||
if (inc < 0)
|
||||
inc = 0;
|
||||
tvec[C_FALLOUT] += inc;
|
||||
putvec(VT_COND, tvec, (char *)ap, EF_SECTOR);
|
||||
ap->sct_fallout += inc;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
decay_fallout(struct sctstr *sp, int etus)
|
||||
{
|
||||
int cvec[I_MAX + 1];
|
||||
int decay;
|
||||
|
||||
if (etus > 24)
|
||||
etus = 24;
|
||||
getvec(VT_COND, cvec, (char *)sp, EF_SECTOR);
|
||||
decay = roundavg(((decay_per_etu + 6.0) * fallout_spread) *
|
||||
(double)etus * (double)cvec[C_FALLOUT]);
|
||||
(double)etus * (double)sp->sct_fallout);
|
||||
|
||||
#if 0
|
||||
if (decay || cvec[C_FALLOUT])
|
||||
if (decay || sp->sct_fallout)
|
||||
wu(0, 0, "Fallout decay in %d,%d is %d from %d\n", sp->sct_x,
|
||||
sp->sct_y, decay, cvec[C_FALLOUT]);
|
||||
sp->sct_y, decay, sp->sct_fallout);
|
||||
#endif
|
||||
|
||||
cvec[C_FALLOUT] =
|
||||
(decay < cvec[C_FALLOUT]) ? (cvec[C_FALLOUT] - decay) : 0;
|
||||
if (cvec[C_FALLOUT] < 0)
|
||||
cvec[C_FALLOUT] = 0;
|
||||
putvec(VT_COND, cvec, (s_char *)sp, EF_SECTOR);
|
||||
sp->sct_fallout =
|
||||
(decay < sp->sct_fallout) ? (sp->sct_fallout - decay) : 0;
|
||||
}
|
||||
|
||||
#define SHOULD_PRODUCE(sp,t) (((sp->sct_type == t) || (t == -1)) ? 1 : 0)
|
||||
|
|
|
@ -117,7 +117,7 @@ upd_ship(register struct shpstr *sp, register int etus,
|
|||
struct sctstr *sectp;
|
||||
struct mchrstr *mp;
|
||||
int vec[I_MAX + 1];
|
||||
int cvec[I_MAX + 1];
|
||||
u_short pstage, ptime;
|
||||
int oil_gained;
|
||||
int max_oil;
|
||||
int max_food;
|
||||
|
@ -204,9 +204,10 @@ upd_ship(register struct shpstr *sp, register int etus,
|
|||
* do plague stuff. plague can't break out on ships,
|
||||
* but it can still kill people.
|
||||
*/
|
||||
getvec(VT_COND, cvec, (s_char *)sp, EF_SHIP);
|
||||
if (cvec[C_PSTAGE] > 0) {
|
||||
n = plague_people(np, vec, cvec, etus);
|
||||
pstage = sp->shp_pstage;
|
||||
ptime = sp->shp_ptime;
|
||||
if (pstage != PLG_HEALTHY) {
|
||||
n = plague_people(np, vec, &pstage, &ptime, etus);
|
||||
switch (n) {
|
||||
case PLG_DYING:
|
||||
wu(0, sp->shp_own,
|
||||
|
@ -218,9 +219,9 @@ upd_ship(register struct shpstr *sp, register int etus,
|
|||
break;
|
||||
case PLG_INCUBATE:
|
||||
/* Are we still incubating? */
|
||||
if (n == cvec[C_PSTAGE]) {
|
||||
if (n == pstage) {
|
||||
/* Yes. Will it turn "infectious" next time? */
|
||||
if (cvec[C_PTIME] <= etus) {
|
||||
if (ptime <= etus) {
|
||||
/* Yes. Report an outbreak. */
|
||||
wu(0, sp->shp_own,
|
||||
"Outbreak of PLAGUE on %s!\n", prship(sp));
|
||||
|
@ -234,9 +235,9 @@ upd_ship(register struct shpstr *sp, register int etus,
|
|||
break;
|
||||
case PLG_EXPOSED:
|
||||
/* Has the plague moved to "incubation" yet? */
|
||||
if (n != cvec[C_PSTAGE]) {
|
||||
if (n != pstage) {
|
||||
/* Yes. Will it turn "infectious" next time? */
|
||||
if (cvec[C_PTIME] <= etus) {
|
||||
if (ptime <= etus) {
|
||||
/* Yes. Report an outbreak. */
|
||||
wu(0, sp->shp_own,
|
||||
"Outbreak of PLAGUE on %s!\n", prship(sp));
|
||||
|
@ -248,7 +249,8 @@ upd_ship(register struct shpstr *sp, register int etus,
|
|||
break;
|
||||
}
|
||||
|
||||
putvec(VT_COND, cvec, (s_char *)sp, EF_SHIP);
|
||||
sp->shp_pstage = pstage;
|
||||
sp->shp_ptime = ptime;
|
||||
}
|
||||
putvec(VT_ITEM, vec, (s_char *)sp, EF_SHIP);
|
||||
pops[sp->shp_own] += vec[I_CIVIL];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue