Skip to content

Commit

Permalink
Merge pull request Atlantis-PBEM#13 from ennorehling/static-analysis
Browse files Browse the repository at this point in the history
some small bugs in standard game
  • Loading branch information
Loriaki committed Nov 15, 2015
2 parents b8b9a6c + edb936e commit 9e90ec2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
20 changes: 8 additions & 12 deletions standard/extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,21 @@ int Game::SetupFaction( Faction *pFac )

Faction *Game::CheckVictory()
{
ARegion *reg;
forlist(&regions) {
ARegion *r = (ARegion *)elem;
forlist(&r->objects) {
Object *obj = (Object *)elem;
if (obj->type != O_BKEEP) continue;
if (obj->units.Num()) return NULL;
reg = r;
break;
}
}
{
// Now see find the first faction guarding the region
forlist(&reg->objects) {
Object *o = reg->GetDummy();
forlist(&o->units) {
Unit *u = (Unit *)elem;
if (u->guard == GUARD_GUARD) return u->faction;
// Now see find the first faction guarding the region
forlist(&reg->objects) {
Object *o = reg->GetDummy();
forlist(&o->units) {
Unit *u = (Unit *)elem;
if (u->guard == GUARD_GUARD) return u->faction;
}
}
break;
}
}
return NULL;
Expand Down
6 changes: 3 additions & 3 deletions standard/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ void ARegionList::MakeLand(ARegionArray *pRegs, int percentOcean,
}
for (int i=0; i<sz; i++) {
int dir = getrandom(NDIRS);
if ((reg->yloc < yoff*2) && ((dir < 2) || (dir = NDIRS-1))
if ((reg->yloc < yoff*2) && ((dir < 2) || (dir == NDIRS-1))
&& (getrandom(4) < 3)) continue;
if ((reg->yloc > (yband+yoff)*2) && ((dir < 5) && (dir > 1))
&& (getrandom(4) < 3)) continue;
Expand Down Expand Up @@ -837,7 +837,7 @@ void ARegionList::MakeUWMaze(ARegionArray *pArr)
ARegion *reg = pArr->GetRegion(x, y);
if (!reg) continue;

for (int i=D_NORTH; i<= NDIRS; i++) {
for (int i=D_NORTH; i< NDIRS; i++) {
int count = 0;
for (int j=D_NORTH; j< NDIRS; j++)
if (reg->neighbors[j]) count++;
Expand Down Expand Up @@ -1217,5 +1217,5 @@ void ARegionList::FinalSetupGates()
r->gatemonth = getrandom(12);;
}
}
delete used;
delete[] used;
}

0 comments on commit 9e90ec2

Please sign in to comment.