Skip to content

Commit

Permalink
Fix logic bug in world generation map code
Browse files Browse the repository at this point in the history
* Pulls in changes from PR#53
* All games except neworigins and standard had this bug - it had been
  previously fixed (partially) in those 2 codebases, but added parens
  to make sure comparison was correct.
  • Loading branch information
jt-traub committed May 8, 2024
1 parent 27235d9 commit d955009
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion basic/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,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
2 changes: 1 addition & 1 deletion fracas/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,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
2 changes: 1 addition & 1 deletion havilah/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,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
2 changes: 1 addition & 1 deletion kingdoms/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,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
2 changes: 1 addition & 1 deletion neworigins/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,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
2 changes: 1 addition & 1 deletion standard/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,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

0 comments on commit d955009

Please sign in to comment.