subs: Factor common military counting out of shoo() and conv()
Put the new function security_strength() next to military_control(), because that one does a similar count. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
602f15f52d
commit
ffd6651f86
4 changed files with 33 additions and 39 deletions
|
@ -40,6 +40,33 @@
|
|||
#include "sect.h"
|
||||
#include "unit.h"
|
||||
|
||||
/*
|
||||
* Return strength of security detail in @sp.
|
||||
* Store number of land units with security capability in @nsecurity.
|
||||
*/
|
||||
int
|
||||
security_strength(struct sctstr *sp, int *nsecurity)
|
||||
{
|
||||
int strength;
|
||||
int nsec;
|
||||
struct nstr_item ni;
|
||||
struct lndstr land;
|
||||
|
||||
strength = sp->sct_item[I_MILIT];
|
||||
nsec = 0;
|
||||
snxtitem_xy(&ni, EF_LAND, sp->sct_x, sp->sct_y);
|
||||
while (nxtitem(&ni, &land)) {
|
||||
strength += land.lnd_item[I_MILIT];
|
||||
if (lchr[land.lnd_type].l_flags & L_SECURITY) {
|
||||
strength += land.lnd_item[I_MILIT];
|
||||
nsec++;
|
||||
}
|
||||
}
|
||||
|
||||
*nsecurity = nsec;
|
||||
return strength;
|
||||
}
|
||||
|
||||
/*
|
||||
* Does the player->owner have military control of this sector?
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue