forked from github/server
extremely old bug in encounters()
This commit is contained in:
parent
080a85021f
commit
3a3628d3a9
1 changed files with 15 additions and 14 deletions
|
@ -377,28 +377,29 @@ encounter(region * r, unit * u)
|
||||||
void
|
void
|
||||||
encounters(void)
|
encounters(void)
|
||||||
{
|
{
|
||||||
region *r;
|
region *r;
|
||||||
|
|
||||||
for (r = regions; r; r = r->next) {
|
for (r = regions; r; r = r->next) {
|
||||||
if (!fval(r->terrain, SEA_REGION) && fval(r, RF_ENCOUNTER)) {
|
if (!fval(r->terrain, SEA_REGION) && fval(r, RF_ENCOUNTER)) {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
unit * u;
|
unit * u;
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
c += u->number;
|
c += u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c > 0) {
|
if (c > 0) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int n = rng_int() % c;
|
int n = rng_int() % c;
|
||||||
|
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
if (i+u->number>n) break;
|
if (i+u->number>n) break;
|
||||||
}
|
i+=u->number;
|
||||||
|
}
|
||||||
assert(u && u->number);
|
assert(u && u->number);
|
||||||
encounter(r, u);
|
encounter(r, u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const terrain_type *
|
static const terrain_type *
|
||||||
|
|
Loading…
Reference in a new issue