update/revolt: Fix body count report
The body count reflects what take_casualties() should do, not what it actually does. It can be quite off, as the update test's changed output shows. Mostly because take_casualties() is utterly confused. That'll be fixed next. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
e55fb2227b
commit
f0a0de54b7
3 changed files with 29 additions and 28 deletions
|
@ -47,7 +47,7 @@
|
||||||
#include "sect.h"
|
#include "sect.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
static void take_casualties(struct sctstr *, int);
|
static int take_casualties(struct sctstr *, int);
|
||||||
static void lnd_dies_fighting_che(struct lndstr *);
|
static void lnd_dies_fighting_che(struct lndstr *);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -234,16 +234,13 @@ guerrilla(struct sctstr *sp)
|
||||||
* If loyalty bad enough, then take the sector over,
|
* If loyalty bad enough, then take the sector over,
|
||||||
* and enlist 5% of civ as military force.
|
* and enlist 5% of civ as military force.
|
||||||
*/
|
*/
|
||||||
while (che > 0 && mil > 0) {
|
while (che > cc && mil > mc) {
|
||||||
if (chance(odds)) {
|
if (chance(odds))
|
||||||
mc++;
|
mc++;
|
||||||
mil--;
|
else
|
||||||
} else {
|
|
||||||
cc++;
|
cc++;
|
||||||
che--;
|
|
||||||
}
|
}
|
||||||
}
|
if (mil > mc) {
|
||||||
if (mil > 0) {
|
|
||||||
/* military won. */
|
/* military won. */
|
||||||
n = sp->sct_loyal - roll0(15);
|
n = sp->sct_loyal - roll0(15);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
|
@ -253,7 +250,9 @@ guerrilla(struct sctstr *sp)
|
||||||
convert++;
|
convert++;
|
||||||
recruit++;
|
recruit++;
|
||||||
}
|
}
|
||||||
take_casualties(sp, mc);
|
mc = take_casualties(sp, mc);
|
||||||
|
che -= cc;
|
||||||
|
mil -= mc;
|
||||||
} else if (ratio < 5) {
|
} else if (ratio < 5) {
|
||||||
/*
|
/*
|
||||||
* guerrillas have to resort to blowing things up.
|
* guerrillas have to resort to blowing things up.
|
||||||
|
@ -285,16 +284,14 @@ guerrilla(struct sctstr *sp)
|
||||||
n = (mil / 5) + 1;
|
n = (mil / 5) + 1;
|
||||||
odds = (double)che / (n + security_bonus / 5 + che);
|
odds = (double)che / (n + security_bonus / 5 + che);
|
||||||
odds /= hap_fact(tnat, getnatp(sp->sct_oldown));
|
odds /= hap_fact(tnat, getnatp(sp->sct_oldown));
|
||||||
while (che > 0 && n > 0) {
|
while (che > cc && n > mc) {
|
||||||
if (chance(odds)) {
|
if (chance(odds))
|
||||||
mc++;
|
mc++;
|
||||||
n--;
|
else
|
||||||
} else {
|
|
||||||
cc++;
|
cc++;
|
||||||
che--;
|
|
||||||
}
|
}
|
||||||
}
|
mc = take_casualties(sp, mc);
|
||||||
take_casualties(sp, mc);
|
che -= cc;
|
||||||
mil -= mc;
|
mil -= mc;
|
||||||
recruit = 0;
|
recruit = 0;
|
||||||
}
|
}
|
||||||
|
@ -417,10 +414,10 @@ domove:
|
||||||
xyas(sp->sct_x, sp->sct_y, victim));
|
xyas(sp->sct_x, sp->sct_y, victim));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static int
|
||||||
take_casualties(struct sctstr *sp, int mc)
|
take_casualties(struct sctstr *sp, int mc)
|
||||||
{
|
{
|
||||||
int orig_mil;
|
int orig_mil, taken;
|
||||||
int cantake;
|
int cantake;
|
||||||
int nunits = 0, each, deq;
|
int nunits = 0, each, deq;
|
||||||
struct lndstr *lp;
|
struct lndstr *lp;
|
||||||
|
@ -431,12 +428,13 @@ take_casualties(struct sctstr *sp, int mc)
|
||||||
|
|
||||||
if (mc <= orig_mil) {
|
if (mc <= orig_mil) {
|
||||||
sp->sct_item[I_MILIT] = orig_mil - mc;
|
sp->sct_item[I_MILIT] = orig_mil - mc;
|
||||||
return;
|
return mc;
|
||||||
}
|
}
|
||||||
sp->sct_item[I_MILIT] = 0;
|
sp->sct_item[I_MILIT] = 0;
|
||||||
|
|
||||||
/* remaining casualites */
|
/* remaining casualites */
|
||||||
mc -= orig_mil;
|
mc -= orig_mil;
|
||||||
|
taken = orig_mil;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Need to take total_casualties and divide
|
* Need to take total_casualties and divide
|
||||||
|
@ -454,7 +452,7 @@ take_casualties(struct sctstr *sp, int mc)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nunits == 0)
|
if (nunits == 0)
|
||||||
return;
|
return taken;
|
||||||
|
|
||||||
each = (mc / nunits) + 2;
|
each = (mc / nunits) + 2;
|
||||||
|
|
||||||
|
@ -482,9 +480,10 @@ take_casualties(struct sctstr *sp, int mc)
|
||||||
lp->lnd_effic -= deq;
|
lp->lnd_effic -= deq;
|
||||||
lp->lnd_mobil -= deq / 2;
|
lp->lnd_mobil -= deq / 2;
|
||||||
deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
|
deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
|
||||||
|
taken += MIN(deq, lp->lnd_item[I_MILIT]);
|
||||||
lnd_submil(lp, deq);
|
lnd_submil(lp, deq);
|
||||||
if (mc <= 0)
|
if (mc <= 0)
|
||||||
return;
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kill some normal troops */
|
/* kill some normal troops */
|
||||||
|
@ -511,9 +510,10 @@ take_casualties(struct sctstr *sp, int mc)
|
||||||
lp->lnd_effic -= deq;
|
lp->lnd_effic -= deq;
|
||||||
lp->lnd_mobil -= deq / 2;
|
lp->lnd_mobil -= deq / 2;
|
||||||
deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
|
deq = lchr[(int)lp->lnd_type].l_item[I_MILIT] * (deq / 100.0);
|
||||||
|
taken += MIN(deq, lp->lnd_item[I_MILIT]);
|
||||||
lnd_submil(lp, deq);
|
lnd_submil(lp, deq);
|
||||||
if (mc <= 0)
|
if (mc <= 0)
|
||||||
return;
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hmm.. still some left.. kill off units now */
|
/* Hmm.. still some left.. kill off units now */
|
||||||
|
@ -528,9 +528,10 @@ take_casualties(struct sctstr *sp, int mc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
|
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
|
||||||
|
taken += lp->lnd_item[I_MILIT];
|
||||||
lnd_dies_fighting_che(lp);
|
lnd_dies_fighting_che(lp);
|
||||||
if (mc <= 0)
|
if (mc <= 0)
|
||||||
return;
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hmm.. still some left.. kill off units now */
|
/* Hmm.. still some left.. kill off units now */
|
||||||
|
@ -545,12 +546,14 @@ take_casualties(struct sctstr *sp, int mc)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
|
mc -= (lp->lnd_effic / 100.0) * lp->lnd_item[I_MILIT];
|
||||||
|
taken += lp->lnd_item[I_MILIT];
|
||||||
lnd_dies_fighting_che(lp);
|
lnd_dies_fighting_che(lp);
|
||||||
if (mc <= 0)
|
if (mc <= 0)
|
||||||
return;
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hmm.. everyone dead.. too bad */
|
/* Hmm.. everyone dead.. too bad */
|
||||||
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -182,10 +182,8 @@ land 0:31,-16:-1
|
||||||
| BUG: "Sector -12,-8 has been retaken!" instead of takeover
|
| BUG: "Sector -12,-8 has been retaken!" instead of takeover
|
||||||
| -10,-8 che win, don't take over
|
| -10,-8 che win, don't take over
|
||||||
| -8,-8 che lose
|
| -8,-8 che lose
|
||||||
| BUG: body count off, claims 7m, actually 11m
|
|
||||||
| BUG: che kill 4m more than they should
|
| BUG: che kill 4m more than they should
|
||||||
| -6,-8 che lose
|
| -6,-8 che lose
|
||||||
| BUG: body count off, claims 26m, actually 50m
|
|
||||||
| BUG: inf#29 shouldn't die
|
| BUG: inf#29 shouldn't die
|
||||||
| plague stage 4 (dying) -16:-1,-6 ship#10 land#10
|
| plague stage 4 (dying) -16:-1,-6 ship#10 land#10
|
||||||
| -16,-6 reverts to deity
|
| -16,-6 reverts to deity
|
||||||
|
|
|
@ -1374,10 +1374,10 @@
|
||||||
Play#0 output Play#0 1 Guerrilla warfare in -10,-8
|
Play#0 output Play#0 1 Guerrilla warfare in -10,-8
|
||||||
Play#0 output Play#0 1 body count: troops: 10, rebels: 5
|
Play#0 output Play#0 1 body count: troops: 10, rebels: 5
|
||||||
Play#0 output Play#0 1 Guerrilla warfare in -8,-8
|
Play#0 output Play#0 1 Guerrilla warfare in -8,-8
|
||||||
Play#0 output Play#0 1 body count: troops: 7, rebels: 22
|
Play#0 output Play#0 1 body count: troops: 11, rebels: 22
|
||||||
Play#0 output Play#0 1 inf infantry #29 dies fighting guerrillas in -6,-8
|
Play#0 output Play#0 1 inf infantry #29 dies fighting guerrillas in -6,-8
|
||||||
Play#0 output Play#0 1 Guerrilla warfare in -6,-8
|
Play#0 output Play#0 1 Guerrilla warfare in -6,-8
|
||||||
Play#0 output Play#0 1 body count: troops: 26, rebels: 52
|
Play#0 output Play#0 1 body count: troops: 50, rebels: 52
|
||||||
Play#0 output Play#0 1 Revolutionary subversion reported in -13,-7!
|
Play#0 output Play#0 1 Revolutionary subversion reported in -13,-7!
|
||||||
Play#0 output Play#0 1 PLAGUE deaths reported in -16,-6
|
Play#0 output Play#0 1 PLAGUE deaths reported in -16,-6
|
||||||
Play#0 output Play#0 1 PLAGUE deaths reported in -14,-6
|
Play#0 output Play#0 1 PLAGUE deaths reported in -14,-6
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue