Skip to content

Commit

Permalink
bugfix for vanilla (block connections in hell)
Browse files Browse the repository at this point in the history
- prevent connections drawn over rooms in hell
  • Loading branch information
pionere committed Aug 31, 2024
1 parent 959cf04 commit 17c6df9
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions Source/drlg_l4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1207,60 +1207,53 @@ static void L4ConnectBlock()
{
int j, i, rv;
BYTE hallok[std::max(L4BLOCKX, L4BLOCKY)];

memset(hallok, 0, sizeof(hallok));
for (j = L4BLOCKY - 2; j >= 0; j--) {
for (i = L4BLOCKX - 2; i >= 0; i--) {
// find the right side of the rooms
for (j = L4BLOCKY - 1; j >= 0; j--) {
for (i = L4BLOCKX - 1; i > 0; i--) {
if (drlg.dungBlock[i][j] == 1) {
assert(i + 1 < L4BLOCKX && j + 1 < L4BLOCKY);
if (drlg.dungBlock[i][j + 1] == 1 && drlg.dungBlock[i + 1][j + 1] == 0) {
hallok[j] = i;
}
i = 0;
break;
}
}
hallok[j] = i;
}

// connect to the right side of the dungeon
rv = RandRange(1, L4BLOCKY - 1);
while (true) {
if (hallok[rv] != 0) {
if (hallok[rv] != 0 && hallok[rv] == hallok[rv + 1]) {
for (i = L4BLOCKX - 1; i > hallok[rv]; i--) {
drlg.dungBlock[i][rv] = 1;
drlg.dungBlock[i][rv + 1] = 1;
}
break;
} else {
rv++;
if (rv == L4BLOCKY) {
if (rv == L4BLOCKY - 1) {
rv = 1;
}
}
}

memset(hallok, 0, sizeof(hallok));
for (i = L4BLOCKX - 2; i >= 0; i--) {
for (j = L4BLOCKY - 2; j >= 0; j--) {
// find the bottom side of the rooms
for (i = L4BLOCKX - 1; i >= 0; i--) {
for (j = L4BLOCKY - 1; j > 0; j--) {
if (drlg.dungBlock[i][j] == 1) {
assert(i + 1 < L4BLOCKX && j + 1 < L4BLOCKY);
if (drlg.dungBlock[i + 1][j] == 1 && drlg.dungBlock[i + 1][j + 1] == 0) {
hallok[i] = j;
}
j = 0;
break;
}
}
hallok[i] = j;
}

// connect to the bottom side of the dungeon
rv = RandRange(1, L4BLOCKX - 1);
while (true) {
if (hallok[rv] != 0) {
if (hallok[rv] != 0 && hallok[rv] == hallok[rv + 1]) {
for (j = L4BLOCKY - 1; j > hallok[rv]; j--) {
drlg.dungBlock[rv][j] = 1;
drlg.dungBlock[rv + 1][j] = 1;
}
break;
} else {
rv++;
if (rv == L4BLOCKX) {
if (rv == L4BLOCKX - 1) {
rv = 1;
}
}
Expand Down

0 comments on commit 17c6df9

Please sign in to comment.