Indented with src/scripts/indent-emp.

This commit is contained in:
Markus Armbruster 2003-09-02 20:48:48 +00:00
parent 5f263a7753
commit 9b7adfbecc
437 changed files with 52211 additions and 51052 deletions

View file

@ -47,7 +47,8 @@
#define CHE_MAX 255
void takeover_land(register struct lndstr *landp, natid newown, int hostile);
void takeover_land(register struct lndstr *landp, natid newown,
int hostile);
void takeover_plane(register struct plnstr *pp, natid newown);
void
@ -55,16 +56,16 @@ takeover(register struct sctstr *sp, natid newown)
{
struct plnstr *pp;
struct lndstr *lp;
int civ;
int che;
int che_count;
int oldche;
int n, vec[I_MAX+1];
int civ;
int che;
int che_count;
int oldche;
int n, vec[I_MAX + 1];
double odds;
struct nstr_item ni;
struct plnstr p;
struct lndstr land;
extern double hap_fact(struct natstr *, struct natstr *);
struct nstr_item ni;
struct plnstr p;
struct lndstr land;
extern double hap_fact(struct natstr *, struct natstr *);
extern int etu_per_update;
extern int sect_mob_neg_factor;
@ -73,21 +74,21 @@ takeover(register struct sctstr *sp, natid newown)
putvec(VT_DIST, vec, (s_char *)sp, EF_SECTOR);
putvec(VT_DEL, vec, (s_char *)sp, EF_SECTOR);
if (sp->sct_own == 0)
sp->sct_off = 0;
else
sp->sct_off = 1;
sp->sct_off = 0;
else
sp->sct_off = 1;
sp->sct_dist_x = sp->sct_x;
sp->sct_dist_y = sp->sct_y;
pp = &p;
/* Take over planes */
snxtitem_dist(&ni, EF_PLANE, sp->sct_x, sp->sct_y, 0);
while (nxtitem(&ni, (caddr_t)pp)) {
if (pp->pln_own != sp->sct_own)
continue;
continue;
takeover_plane(pp, newown);
}
/* Take over land units */
lp = &land;
snxtitem_dist(&ni, EF_LAND, sp->sct_x, sp->sct_y, 0);
@ -100,9 +101,9 @@ takeover(register struct sctstr *sp, natid newown)
continue;
/* Spies get a chance to hide */
if (lchr[(int)lp->lnd_type].l_flags & L_SPY) {
odds = (double)(100 - lp->lnd_effic) + 0.10;
if (!(chance(odds)))
continue;
odds = (double)(100 - lp->lnd_effic) + 0.10;
if (!(chance(odds)))
continue;
}
n = lp->lnd_effic - (30 + (random() % 100));
if (n < 0)
@ -110,7 +111,7 @@ takeover(register struct sctstr *sp, natid newown)
lp->lnd_effic = n;
if (lp->lnd_effic < LAND_MINEFF) {
lp->lnd_effic = 0;
mpr(newown,"%s blown up by the crew!\n", prland(lp));
mpr(newown, "%s blown up by the crew!\n", prland(lp));
wu(0, lp->lnd_own,
"%s blown up by the crew when %s took %s!\n",
prland(lp),
@ -124,7 +125,7 @@ takeover(register struct sctstr *sp, natid newown)
}
takeover_land(lp, newown, 1);
}
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));
@ -137,10 +138,10 @@ takeover(register struct sctstr *sp, natid newown)
che_count = 0;
che = 0;
if (n > 0 && sp->sct_own == sp->sct_oldown) {
che_count = (civ * n/3000) + 5;
che_count = (civ * n / 3000) + 5;
if (che_count * 2 > civ)
che_count = civ / 2;
che_count /= hap_fact(getnatp(newown),getnatp(sp->sct_own));
che_count /= hap_fact(getnatp(newown), getnatp(sp->sct_own));
if (che_count + oldche > CHE_MAX)
che_count = CHE_MAX - oldche;
if (che_count > 0) {
@ -153,8 +154,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);
(void)putvar(V_CHE, che, (s_char *)sp, EF_SECTOR);
(void)putvar(V_CIVIL, civ, (s_char *)sp, EF_SECTOR);
if (sp->sct_oldown == newown || civ == 0) {
/*
* taking over one of your old sectors
@ -184,36 +185,37 @@ takeover_plane(register struct plnstr *pp, natid newown)
int n;
if ((pp->pln_own == newown) || (pp->pln_own == 0))
return;
return;
if (pp->pln_flags & PLN_LAUNCHED)
return;
return;
if (pp->pln_ship >= 0 || pp->pln_land >= 0)
return;
return;
/*
* XXX If this was done right, planes could escape,
* flying to a nearby friendly airport.
*/
n = pp->pln_effic - (30 + (random() % 100));
if (n < 0) n = 0;
if (n < 0)
n = 0;
pp->pln_effic = n;
if (pp->pln_effic < PLANE_MINEFF || pp->pln_harden > (s_char)0) {
pp->pln_effic = 0;
mpr(newown,"%s blown up by the crew!\n", prplane(pp));
wu(0, pp->pln_own,
"%s blown up by the crew to avoid capture by %s at %s!\n",
prplane(pp),
cname(newown), xyas(pp->pln_x, pp->pln_y, pp->pln_own));
pp->pln_effic = 0;
mpr(newown, "%s blown up by the crew!\n", prplane(pp));
wu(0, pp->pln_own,
"%s blown up by the crew to avoid capture by %s at %s!\n",
prplane(pp),
cname(newown), xyas(pp->pln_x, pp->pln_y, pp->pln_own));
} else {
mpr(newown, "We have captured %s!\n", prplane(pp));
wu(0, pp->pln_own,
"%s captured by %s at %s!\n",
prplane(pp),
cname(newown), xyas(pp->pln_x, pp->pln_y, pp->pln_own));
mpr(newown, "We have captured %s!\n", prplane(pp));
wu(0, pp->pln_own,
"%s captured by %s at %s!\n",
prplane(pp),
cname(newown), xyas(pp->pln_x, pp->pln_y, pp->pln_own));
}
if (opt_MARKET)
trdswitchown(EF_PLANE, (int *)pp, newown);
trdswitchown(EF_PLANE, (int *)pp, newown);
if (pp->pln_mobil > (s_char)0)
pp->pln_mobil = 0;
pp->pln_mobil = 0;
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
pp->pln_own = newown;
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
@ -226,12 +228,12 @@ takeover_ship(register struct shpstr *sp, natid newown, int hostile)
{
register struct plnstr *pp;
register struct lndstr *lp;
struct nstr_item ni;
struct plnstr p;
struct lndstr llp;
struct nstr_item ni;
struct plnstr p;
struct lndstr llp;
if (opt_MARKET)
trdswitchown(EF_SHIP, (int *)sp, newown);
trdswitchown(EF_SHIP, (int *)sp, newown);
makelost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
sp->shp_own = newown;
makenotlost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
@ -240,7 +242,7 @@ takeover_ship(register struct shpstr *sp, natid newown, int hostile)
sp->shp_rflags = 0;
/* Keep track of when this was taken over */
time(&sp->shp_access);
bzero(sp->shp_rpath,RET_LEN);
bzero(sp->shp_rpath, RET_LEN);
pp = &p;
lp = &llp;
/* Take over planes */
@ -262,7 +264,8 @@ takeover_ship(register struct shpstr *sp, natid newown, int hostile)
pp->pln_mission = 0;
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
pp->pln_own = newown;
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x,
pp->pln_y);
putplane(pp->pln_uid, pp);
}
/* Take over land units */
@ -282,10 +285,10 @@ takeover_land(register struct lndstr *landp, natid newown, int hostile)
{
register struct plnstr *pp;
register struct lndstr *lp;
struct nstr_item ni;
struct plnstr p;
struct lndstr llp;
struct nstr_item ni;
struct plnstr p;
struct lndstr llp;
if (landp->lnd_effic < LAND_MINEFF) {
putland(landp->lnd_uid, landp);
return;
@ -298,9 +301,11 @@ takeover_land(register struct lndstr *landp, natid newown, int hostile)
if (opt_MARKET)
trdswitchown(EF_LAND, (int *)landp, newown);
landp->lnd_mission = 0;
makelost(EF_LAND, landp->lnd_own, landp->lnd_uid, landp->lnd_x, landp->lnd_y);
makelost(EF_LAND, landp->lnd_own, landp->lnd_uid, landp->lnd_x,
landp->lnd_y);
landp->lnd_own = newown;
makenotlost(EF_LAND, landp->lnd_own, landp->lnd_uid, landp->lnd_x, landp->lnd_y);
makenotlost(EF_LAND, landp->lnd_own, landp->lnd_uid, landp->lnd_x,
landp->lnd_y);
pp = &p;
lp = &llp;
/* Take over planes */
@ -322,7 +327,8 @@ takeover_land(register struct lndstr *landp, natid newown, int hostile)
pp->pln_mission = 0;
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
pp->pln_own = newown;
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x,
pp->pln_y);
putplane(pp->pln_uid, pp);
}
/* Take over land units */
@ -336,7 +342,3 @@ takeover_land(register struct lndstr *landp, natid newown, int hostile)
}
putland(landp->lnd_uid, landp);
}