update: Factor out ship and land unit plague plague code
Factor plague_ship() out of upd_ship(), and plague_land() out of upd_land(). Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
1dfe91ca96
commit
7951e91e3f
2 changed files with 44 additions and 30 deletions
|
@ -49,6 +49,7 @@
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
static void upd_land(struct lndstr *, int, struct bp *, int);
|
static void upd_land(struct lndstr *, int, struct bp *, int);
|
||||||
|
static void plague_land(struct lndstr *, int);
|
||||||
static void landrepair(struct lndstr *, struct natstr *, struct bp *,
|
static void landrepair(struct lndstr *, struct natstr *, struct bp *,
|
||||||
int, struct budget *);
|
int, struct budget *);
|
||||||
static int feed_land(struct lndstr *, int);
|
static int feed_land(struct lndstr *, int);
|
||||||
|
@ -87,7 +88,6 @@ upd_land(struct lndstr *lp, int etus, struct bp *bp, int build)
|
||||||
struct budget *budget = &nat_budget[lp->lnd_own];
|
struct budget *budget = &nat_budget[lp->lnd_own];
|
||||||
struct lchrstr *lcp = &lchr[lp->lnd_type];
|
struct lchrstr *lcp = &lchr[lp->lnd_type];
|
||||||
struct natstr *np = getnatp(lp->lnd_own);
|
struct natstr *np = getnatp(lp->lnd_own);
|
||||||
int pstage, ptime;
|
|
||||||
int min = morale_base - (int)np->nat_level[NAT_HLEV];
|
int min = morale_base - (int)np->nat_level[NAT_HLEV];
|
||||||
int n, mult, eff_lost;
|
int n, mult, eff_lost;
|
||||||
double cost;
|
double cost;
|
||||||
|
@ -133,24 +133,31 @@ upd_land(struct lndstr *lp, int etus, struct bp *bp, int build)
|
||||||
if (n > 10)
|
if (n > 10)
|
||||||
nreport(lp->lnd_own, N_DIE_FAMINE, 0, 1);
|
nreport(lp->lnd_own, N_DIE_FAMINE, 0, 1);
|
||||||
}
|
}
|
||||||
/*
|
plague_land(lp, etus);
|
||||||
* do plague stuff. plague can't break out on land units,
|
|
||||||
* but it can still kill people on them.
|
|
||||||
*/
|
|
||||||
pstage = lp->lnd_pstage;
|
|
||||||
ptime = lp->lnd_ptime;
|
|
||||||
if (pstage != PLG_HEALTHY) {
|
|
||||||
n = plague_people(np, lp->lnd_item, &pstage, &ptime, etus);
|
|
||||||
if (n != PLG_HEALTHY)
|
|
||||||
plague_report(lp->lnd_own, n, pstage, ptime, etus,
|
|
||||||
"on", prland(lp));
|
|
||||||
lp->lnd_pstage = pstage;
|
|
||||||
lp->lnd_ptime = ptime;
|
|
||||||
}
|
|
||||||
} /* end !player->simulation */
|
} /* end !player->simulation */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
plague_land(struct lndstr *lp, int etus)
|
||||||
|
{
|
||||||
|
struct natstr *np = getnatp(lp->lnd_own);
|
||||||
|
int pstage, ptime;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Plague can't break out on land units, but it can still kill people */
|
||||||
|
pstage = lp->lnd_pstage;
|
||||||
|
ptime = lp->lnd_ptime;
|
||||||
|
if (pstage != PLG_HEALTHY) {
|
||||||
|
n = plague_people(np, lp->lnd_item, &pstage, &ptime, etus);
|
||||||
|
if (n != PLG_HEALTHY)
|
||||||
|
plague_report(lp->lnd_own, n, pstage, ptime, etus,
|
||||||
|
"on", prland(lp));
|
||||||
|
lp->lnd_pstage = pstage;
|
||||||
|
lp->lnd_ptime = ptime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus,
|
landrepair(struct lndstr *land, struct natstr *np, struct bp *bp, int etus,
|
||||||
struct budget *budget)
|
struct budget *budget)
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
static void upd_ship(struct shpstr *, int, struct bp *, int);
|
static void upd_ship(struct shpstr *, int, struct bp *, int);
|
||||||
|
static void plague_ship(struct shpstr *, int);
|
||||||
static void shiprepair(struct shpstr *, struct natstr *, struct bp *,
|
static void shiprepair(struct shpstr *, struct natstr *, struct bp *,
|
||||||
int, struct budget *);
|
int, struct budget *);
|
||||||
static void ship_produce(struct shpstr *, int, struct budget *);
|
static void ship_produce(struct shpstr *, int, struct budget *);
|
||||||
|
@ -86,7 +87,6 @@ upd_ship(struct shpstr *sp, int etus, struct bp *bp, int build)
|
||||||
struct budget *budget = &nat_budget[sp->shp_own];
|
struct budget *budget = &nat_budget[sp->shp_own];
|
||||||
struct mchrstr *mp = &mchr[sp->shp_type];
|
struct mchrstr *mp = &mchr[sp->shp_type];
|
||||||
struct natstr *np = getnatp(sp->shp_own);
|
struct natstr *np = getnatp(sp->shp_own);
|
||||||
int pstage, ptime;
|
|
||||||
int n, mult, eff_lost;
|
int n, mult, eff_lost;
|
||||||
double cost;
|
double cost;
|
||||||
|
|
||||||
|
@ -124,24 +124,31 @@ upd_ship(struct shpstr *sp, int etus, struct bp *bp, int build)
|
||||||
if (n > 10)
|
if (n > 10)
|
||||||
nreport(sp->shp_own, N_DIE_FAMINE, 0, 1);
|
nreport(sp->shp_own, N_DIE_FAMINE, 0, 1);
|
||||||
}
|
}
|
||||||
/*
|
plague_ship(sp, etus);
|
||||||
* do plague stuff. plague can't break out on ships,
|
|
||||||
* but it can still kill people.
|
|
||||||
*/
|
|
||||||
pstage = sp->shp_pstage;
|
|
||||||
ptime = sp->shp_ptime;
|
|
||||||
if (pstage != PLG_HEALTHY) {
|
|
||||||
n = plague_people(np, sp->shp_item, &pstage, &ptime, etus);
|
|
||||||
if (n != PLG_HEALTHY)
|
|
||||||
plague_report(sp->shp_own, n, pstage, ptime, etus,
|
|
||||||
"on", prship(sp));
|
|
||||||
sp->shp_pstage = pstage;
|
|
||||||
sp->shp_ptime = ptime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
plague_ship(struct shpstr *sp, int etus)
|
||||||
|
{
|
||||||
|
struct natstr *np = getnatp(sp->shp_own);
|
||||||
|
int pstage, ptime;
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* Plague can't break out on ships, but it can still kill people */
|
||||||
|
pstage = sp->shp_pstage;
|
||||||
|
ptime = sp->shp_ptime;
|
||||||
|
if (pstage != PLG_HEALTHY) {
|
||||||
|
n = plague_people(np, sp->shp_item, &pstage, &ptime, etus);
|
||||||
|
if (n != PLG_HEALTHY)
|
||||||
|
plague_report(sp->shp_own, n, pstage, ptime, etus,
|
||||||
|
"on", prship(sp));
|
||||||
|
sp->shp_pstage = pstage;
|
||||||
|
sp->shp_ptime = ptime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* idea is: a sector full of workers can fix up eight
|
* idea is: a sector full of workers can fix up eight
|
||||||
* battleships +8 % eff each etu. This will cost around
|
* battleships +8 % eff each etu. This will cost around
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue