Simplify lnd_take_casualty()'s land unit retreat code
Bonus: avoids "may be used uninitialized" compiler warnings (the code was safe despite the warning).
This commit is contained in:
parent
3a7d7fa866
commit
d068259487
1 changed files with 1 additions and 4 deletions
|
@ -161,7 +161,6 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
|
||||||
int n;
|
int n;
|
||||||
int biggest;
|
int biggest;
|
||||||
int civs;
|
int civs;
|
||||||
int nowned;
|
|
||||||
coord ret_x, ret_y;
|
coord ret_x, ret_y;
|
||||||
coord bx, by;
|
coord bx, by;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -227,7 +226,6 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
|
||||||
* owner. Charge mob..
|
* owner. Charge mob..
|
||||||
*/
|
*/
|
||||||
biggest = -1;
|
biggest = -1;
|
||||||
nowned = 0;
|
|
||||||
for (n = 1; n <= 6; ++n) {
|
for (n = 1; n <= 6; ++n) {
|
||||||
ret_x = llp->unit.land.lnd_x + diroff[n][0];
|
ret_x = llp->unit.land.lnd_x + diroff[n][0];
|
||||||
ret_y = llp->unit.land.lnd_y + diroff[n][1];
|
ret_y = llp->unit.land.lnd_y + diroff[n][1];
|
||||||
|
@ -239,7 +237,6 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
|
||||||
mobcost = lnd_mobcost(&llp->unit.land, §);
|
mobcost = lnd_mobcost(&llp->unit.land, §);
|
||||||
if (mobcost < 0)
|
if (mobcost < 0)
|
||||||
continue;
|
continue;
|
||||||
++nowned;
|
|
||||||
civs = sect.sct_item[I_CIVIL];
|
civs = sect.sct_item[I_CIVIL];
|
||||||
if (civs > biggest) {
|
if (civs > biggest) {
|
||||||
biggest = civs;
|
biggest = civs;
|
||||||
|
@ -248,7 +245,7 @@ lnd_take_casualty(int combat_mode, struct ulist *llp, int cas)
|
||||||
bmcost = mobcost;
|
bmcost = mobcost;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!nowned)
|
if (biggest < 0)
|
||||||
nowhere_to_go = 1;
|
nowhere_to_go = 1;
|
||||||
else {
|
else {
|
||||||
/* retreat to bx,by */
|
/* retreat to bx,by */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue