Browse Source

Bugfixes

pull/407/head
Xadhoom 7 years ago committed by Anders Jenbo
parent
commit
a1b7b8522a
  1. 10
      Source/drlg_l2.cpp
  2. 30
      Source/drlg_l3.cpp
  3. 10
      Source/drlg_l4.cpp
  4. 4
      Source/gendung.cpp
  5. 6
      Source/monster.cpp

10
Source/drlg_l2.cpp

@ -349,9 +349,9 @@ static void DRLG_L2PlaceRndSet(BYTE *miniset, int rndper)
}
kk = sw * sh + 2;
if (found == TRUE) {
for (yy = sy - sh; yy < sy + 2 * sh && found == TRUE; yy++) {
for (xx = sx - sw; xx < sx + 2 * sw; xx++) {
// BUGFIX: yy and xx can go out of bounds
for (yy = (sy - sh > 0 ? sy - sh : 0); yy < (sy + 2 * sh < DMAXY ? sy + 2 * sh : DMAXY) && found == TRUE; yy++) {
for (xx = (sx - sw > 0 ? sx - sw : 0); xx < (sx + 2 * sw < DMAXX ? sx + 2 * sw : DMAXX); xx++) {
// BUGFIX: yy and xx can go out of bounds (fixed)
if (dungeon[xx][yy] == miniset[kk]) {
found = FALSE;
}
@ -1411,8 +1411,8 @@ static BOOL CreateDungeon()
ConnectHall(nHx1, nHy1, nHx2, nHy2, nHd);
}
for (j = 0; j <= DMAXY; j++) { /// BUGFIX: change '<=' to '<'
for (i = 0; i <= DMAXX; i++) { /// BUGFIX: change '<=' to '<'
for (j = 0; j < DMAXY; j++) { /// BUGFIX: change '<=' to '<' (fixed)
for (i = 0; i < DMAXX; i++) { /// BUGFIX: change '<=' to '<' (fixed)
if (predungeon[i][j] == 67) {
predungeon[i][j] = 35;
}

30
Source/drlg_l3.cpp

@ -792,11 +792,11 @@ static void DRLG_L3Pool()
found = TRUE;
}
poolchance = random_(0, 100);
for (j = duny - totarea; j < duny + totarea; j++) {
for (i = dunx - totarea; i < dunx + totarea; i++) {
for (j = (duny - totarea > 0 ? duny - totarea : 0); j < (duny + totarea < DMAXY ? duny + totarea : DMAXY); j++) {
for (i = (dunx - totarea > 0 ? dunx - totarea : 0); i < (dunx + totarea < DMAXY ? dunx + totarea : DMAXY); i++) {
// BUGFIX: In the following swap the order to first do the
// index checks and only then access dungeon[i][j]
if (dungeon[i][j] & 0x80 && j >= 0 && j < DMAXY && i >= 0 && i < DMAXX) {
// index checks and only then access dungeon[i][j] (fixed)
if (dungeon[i][j] & 0x80) {
dungeon[i][j] &= ~0x80;
if (totarea > 4 && poolchance < 25 && !found) {
k = poolsub[dungeon[i][j]];
@ -816,8 +816,8 @@ static void DRLG_L3PoolFix()
{
int dunx, duny;
for (duny = 0; duny < DMAXY; duny++) { // BUGFIX: Change '0' to '1' and 'DMAXY' to 'DMAXY - 1'
for (dunx = 0; dunx < DMAXX; dunx++) { // BUGFIX: Change '0' to '1' and 'DMAXX' to 'DMAXX - 1'
for (duny = 1; duny < DMAXY - 1; duny++) { // BUGFIX: Change '0' to '1' and 'DMAXY' to 'DMAXY - 1' (fixed)
for (dunx = 1; dunx < DMAXX - 1; dunx++) { // BUGFIX: Change '0' to '1' and 'DMAXX' to 'DMAXX - 1' (fixed)
if (dungeon[dunx][duny] == 8) {
if (dungeon[dunx - 1][duny - 1] >= 25 && dungeon[dunx - 1][duny - 1] <= 41
&& dungeon[dunx - 1][duny] >= 25 && dungeon[dunx - 1][duny] <= 41
@ -940,18 +940,18 @@ static void DRLG_L3PlaceRndSet(const BYTE *miniset, int rndper)
}
kk = sw * sh + 2;
if (miniset[kk] >= 84 && miniset[kk] <= 100 && found == TRUE) {
// BUGFIX: accesses to dungeon can go out of bounds
// BUGFIX: accesses to dungeon can go out of bounds (fixed)
// BUGFIX: Comparisons vs 100 should use same tile as comparisons vs 84.
if (dungeon[sx - 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) {
if (sx - 1 >= 0 && dungeon[sx - 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) {
found = FALSE;
}
if (dungeon[sx + 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) {
if (sx + 1 < 40 && sx - 1 >= 0 && dungeon[sx + 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) {
found = FALSE;
}
if (dungeon[sx][sy + 1] >= 84 && dungeon[sx - 1][sy] <= 100) {
if (sy + 1 < 40 && sx - 1 >= 0 && dungeon[sx][sy + 1] >= 84 && dungeon[sx - 1][sy] <= 100) {
found = FALSE;
}
if (dungeon[sx][sy - 1] >= 84 && dungeon[sx - 1][sy] <= 100) {
if (sy - 1 >= 0 && sx - 1 >= 0 && dungeon[sx][sy - 1] >= 84 && dungeon[sx - 1][sy] <= 100) {
found = FALSE;
}
}
@ -1142,8 +1142,8 @@ static void DRLG_L3Wood()
int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2;
BOOL skip;
for (j = 0; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1'
for (i = 0; i < DMAXX - 1; i++) { // BUGFIX: Change '0' to '1'
for (j = 1; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' (fixed)
for (i = 1; i < DMAXX - 1; i++) { // BUGFIX: Change '0' to '1' (fixed)
if (dungeon[i][j] == 10 && random_(0, 2) != 0) {
x = i;
while (dungeon[x][j] == 10) {
@ -1212,8 +1212,8 @@ static void DRLG_L3Wood()
}
}
for (j = 0; j < DMAXY; j++) { // BUGFIX: Change '0' to '1'
for (i = 0; i < DMAXX; i++) { // BUGFIX: Change '0' to '1'
for (j = 1; j < DMAXY; j++) { // BUGFIX: Change '0' to '1' (fixed)
for (i = 1; i < DMAXX; i++) { // BUGFIX: Change '0' to '1' (fixed)
if (dungeon[i][j] == 7 && random_(0, 1) == 0 && SkipThemeRoom(i, j)) {
rt = random_(0, 2);
if (rt == 0) {

10
Source/drlg_l4.cpp

@ -1137,8 +1137,9 @@ static void uShape()
hallok[j] = FALSE;
}
if (dung[i][j] == 1) {
// BUGFIX: check that i + 1 < 20 and j + 1 < 20
if (dung[i][j + 1] == 1 && dung[i + 1][j + 1] == 0) {
// BUGFIX: check that i + 1 < 20 and j + 1 < 20 (fixed)
if (i + 1 < 20 && j + 1 < 20 &&
dung[i][j + 1] == 1 && dung[i + 1][j + 1] == 0) {
hallok[j] = TRUE;
} else {
hallok[j] = FALSE;
@ -1174,8 +1175,9 @@ static void uShape()
hallok[i] = FALSE;
}
if (dung[i][j] == 1) {
// BUGFIX: check that i + 1 < 20 and j + 1 < 20
if (dung[i + 1][j] == 1 && dung[i + 1][j + 1] == 0) {
// BUGFIX: check that i + 1 < 20 and j + 1 < 20 (fixed)
if (i + 1 < 20 && j + 1 < 20 &&
dung[i + 1][j] == 1 && dung[i + 1][j + 1] == 0) {
hallok[i] = TRUE;
} else {
hallok[i] = FALSE;

4
Source/gendung.cpp

@ -273,8 +273,8 @@ BOOL DRLG_WillThemeRoomFit(int floor, int x, int y, int minSize, int maxSize, in
xCount = 0;
yCount = 0;
// BUGFIX: change '&&' to '||'
if (x > DMAXX - maxSize && y > DMAXY - maxSize) {
// BUGFIX: change '&&' to '||' (fixed)
if (x > DMAXX - maxSize || y > DMAXY - maxSize) {
return FALSE;
}
if (!SkipThemeRoom(x, y)) {

6
Source/monster.cpp

@ -5195,7 +5195,7 @@ BOOL PosOkMonst(int i, int x, int y)
if (ret && dMissile[x][y] && i >= 0) {
mi = dMissile[x][y];
if (mi > 0) {
if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (done)
if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (fixed)
fire = TRUE;
} else {
for (j = 0; j < nummissiles; j++) {
@ -5227,7 +5227,7 @@ BOOL PosOkMonst2(int i, int x, int y)
if (ret && dMissile[x][y] && i >= 0) {
mi = dMissile[x][y];
if (mi > 0) {
if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (done)
if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (fixed)
fire = TRUE;
} else {
for (j = 0; j < nummissiles; j++) {
@ -5268,7 +5268,7 @@ BOOL PosOkMonst3(int i, int x, int y)
if (ret && dMissile[x][y] != 0 && i >= 0) {
mi = dMissile[x][y];
if (mi > 0) {
if (missile[mi]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1'
if (missile[mi - 1]._mitype == MIS_FIREWALL) { // BUGFIX: Change 'mi' to 'mi - 1' (fixed)
fire = TRUE;
} else {
for (j = 0; j < nummissiles; j++) {

Loading…
Cancel
Save