subs: Split lnd_mar_put() off lnd_put() and specialize
lnd_put() serves two masters: march, which wants it to report
"stopped" and write back struct ulist member mobility to
unit.land.lnd_mobil, and ground combat, which doesn't.
lnd_put() assumes march when actor is non-zero. Correct (but see
commit 8c502d4
). Dates back to Empire 2.
Too ugly for my taste. Specialize for each master instead:
lnd_mar_put() for march, and lnd_put() for ground combat.
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
b5ffc1ca49
commit
18bf9e0b34
3 changed files with 26 additions and 12 deletions
|
@ -187,7 +187,8 @@ extern void lnd_takemob(struct emp_qelem *, double);
|
||||||
extern int lnd_spyval(struct lndstr *);
|
extern int lnd_spyval(struct lndstr *);
|
||||||
extern void intelligence_report(int, struct lndstr *, int, char *);
|
extern void intelligence_report(int, struct lndstr *, int, char *);
|
||||||
extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
|
extern void lnd_mar(struct emp_qelem *, double *, double *, int *, natid);
|
||||||
extern void lnd_put(struct emp_qelem *, natid);
|
extern void lnd_mar_put(struct emp_qelem *, natid);
|
||||||
|
extern void lnd_put(struct emp_qelem *);
|
||||||
extern int lnd_hardtarget(struct lndstr *);
|
extern int lnd_hardtarget(struct lndstr *);
|
||||||
extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
|
extern int lnd_mar_one_sector(struct emp_qelem *, int, natid, int);
|
||||||
extern int lnd_support(natid, natid, coord, coord, int);
|
extern int lnd_support(natid, natid, coord, coord, int);
|
||||||
|
|
|
@ -1959,7 +1959,7 @@ att_fight(int combat_mode, struct combat *off, struct emp_qelem *olist,
|
||||||
send_reacting_units_home(dlist);
|
send_reacting_units_home(dlist);
|
||||||
|
|
||||||
/* putland the defending land */
|
/* putland the defending land */
|
||||||
lnd_put(dlist, 0);
|
lnd_put(dlist);
|
||||||
|
|
||||||
/* putland the attacking land */
|
/* putland the attacking land */
|
||||||
put_oland(olist);
|
put_oland(olist);
|
||||||
|
@ -2340,7 +2340,7 @@ move_in_land(int combat_mode, struct combat *off, struct emp_qelem *olist,
|
||||||
}
|
}
|
||||||
if (QEMPTY(olist))
|
if (QEMPTY(olist))
|
||||||
return;
|
return;
|
||||||
lnd_put(olist, 0);
|
lnd_put(olist);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -532,7 +532,7 @@ lnd_mar(struct emp_qelem *list, double *minmobp, double *maxmobp,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
lnd_put(struct emp_qelem *list, natid actor)
|
lnd_mar_put(struct emp_qelem *list, natid actor)
|
||||||
{
|
{
|
||||||
struct emp_qelem *qp, *next;
|
struct emp_qelem *qp, *next;
|
||||||
struct ulist *llp;
|
struct ulist *llp;
|
||||||
|
@ -542,19 +542,32 @@ lnd_put(struct emp_qelem *list, natid actor)
|
||||||
next = qp->q_back;
|
next = qp->q_back;
|
||||||
llp = (struct ulist *)qp;
|
llp = (struct ulist *)qp;
|
||||||
lp = &llp->unit.land;
|
lp = &llp->unit.land;
|
||||||
if (actor) {
|
|
||||||
mpr(actor, "%s stopped at %s\n",
|
mpr(actor, "%s stopped at %s\n",
|
||||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, actor));
|
prland(lp), xyas(lp->lnd_x, lp->lnd_y, actor));
|
||||||
if (llp->mobil < -127)
|
if (llp->mobil < -127)
|
||||||
llp->mobil = -127;
|
llp->mobil = -127;
|
||||||
lp->lnd_mobil = llp->mobil;
|
lp->lnd_mobil = llp->mobil;
|
||||||
}
|
|
||||||
putland(lp->lnd_uid, lp);
|
putland(lp->lnd_uid, lp);
|
||||||
emp_remque(qp);
|
emp_remque(qp);
|
||||||
free(qp);
|
free(qp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
lnd_put(struct emp_qelem *list)
|
||||||
|
{
|
||||||
|
struct emp_qelem *qp, *next;
|
||||||
|
struct ulist *llp;
|
||||||
|
|
||||||
|
for (qp = list->q_back; qp != list; qp = next) {
|
||||||
|
next = qp->q_back;
|
||||||
|
llp = (struct ulist *)qp;
|
||||||
|
putland(llp->unit.land.lnd_uid, &llp->unit.land);
|
||||||
|
emp_remque(qp);
|
||||||
|
free(qp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sweep landmines with engineers in LAND_LIST for ACTOR.
|
* Sweep landmines with engineers in LAND_LIST for ACTOR.
|
||||||
* If EXPLICIT is non-zero, this is for an explicit sweep command from
|
* If EXPLICIT is non-zero, this is for an explicit sweep command from
|
||||||
|
@ -951,7 +964,7 @@ lnd_mar_one_sector(struct emp_qelem *list, int dir, natid actor,
|
||||||
int oldown;
|
int oldown;
|
||||||
|
|
||||||
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
|
if (dir <= DIR_STOP || dir >= DIR_VIEW) {
|
||||||
lnd_put(list, actor);
|
lnd_mar_put(list, actor);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
dx = diroff[dir][0];
|
dx = diroff[dir][0];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue