Devilution
Diablo devolved - magic behind the 1996 computer game
drlg_l3.cpp
Go to the documentation of this file.
1 
6 #ifndef SPAWN
7 
8 #include <algorithm>
9 
10 #include "all.h"
11 
13 
14 BOOLEAN lavapool;
15 int abyssx;
17 BOOLEAN lockout[DMAXX][DMAXY];
18 
19 const BYTE L3ConvTbl[16] = { 8, 11, 3, 10, 1, 9, 12, 12, 6, 13, 4, 13, 2, 14, 5, 7 };
20 const BYTE L3UP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 51, 50, 0, 48, 49, 0, 0, 0, 0 };
21 const BYTE L3DOWN[20] = { 3, 3, 8, 9, 7, 8, 9, 7, 0, 0, 0, 0, 47, 0, 0, 46, 0, 0, 0, 0 };
22 const BYTE L3HOLDWARP[20] = { 3, 3, 8, 8, 0, 10, 10, 0, 7, 7, 0, 125, 125, 0, 125, 125, 0, 0, 0, 0 };
23 const BYTE L3TITE1[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 57, 58, 0, 0, 56, 55, 0, 0, 0, 0, 0 };
24 const BYTE L3TITE2[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 61, 62, 0, 0, 60, 59, 0, 0, 0, 0, 0 };
25 const BYTE L3TITE3[34] = { 4, 4, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 65, 66, 0, 0, 64, 63, 0, 0, 0, 0, 0 };
26 const BYTE L3TITE6[42] = { 5, 4, 7, 7, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 77, 78, 0, 0, 0, 76, 74, 75, 0, 0, 0, 0, 0, 0 };
27 const BYTE L3TITE7[42] = { 4, 5, 7, 7, 7, 7, 7, 7, 0, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 83, 0, 0, 0, 82, 80, 0, 0, 81, 79, 0, 0, 0, 0, 0 };
28 const BYTE L3TITE8[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 52, 0, 0, 0, 0 };
29 const BYTE L3TITE9[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 53, 0, 0, 0, 0 };
30 const BYTE L3TITE10[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 54, 0, 0, 0, 0 };
31 const BYTE L3TITE11[20] = { 3, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 67, 0, 0, 0, 0 };
32 const BYTE L3TITE12[6] = { 2, 1, 9, 7, 68, 0 };
33 const BYTE L3TITE13[6] = { 1, 2, 10, 7, 69, 0 };
34 const BYTE L3CREV1[6] = { 2, 1, 8, 7, 84, 85 };
35 const BYTE L3CREV2[6] = { 2, 1, 8, 11, 86, 87 };
36 const BYTE L3CREV3[6] = { 1, 2, 8, 10, 89, 88 };
37 const BYTE L3CREV4[6] = { 2, 1, 8, 7, 90, 91 };
38 const BYTE L3CREV5[6] = { 1, 2, 8, 11, 92, 93 };
39 const BYTE L3CREV6[6] = { 1, 2, 8, 10, 95, 94 };
40 const BYTE L3CREV7[6] = { 2, 1, 8, 7, 96, 101 };
41 const BYTE L3CREV8[6] = { 1, 2, 2, 8, 102, 97 };
42 const BYTE L3CREV9[6] = { 2, 1, 3, 8, 103, 98 };
43 const BYTE L3CREV10[6] = { 2, 1, 4, 8, 104, 99 };
44 const BYTE L3CREV11[6] = { 1, 2, 6, 8, 105, 100 };
45 const BYTE L3ISLE1[14] = { 2, 3, 5, 14, 4, 9, 13, 12, 7, 7, 7, 7, 7, 7 };
46 const BYTE L3ISLE2[14] = { 3, 2, 5, 2, 14, 13, 10, 12, 7, 7, 7, 7, 7, 7 };
47 const BYTE L3ISLE3[14] = { 2, 3, 5, 14, 4, 9, 13, 12, 29, 30, 25, 28, 31, 32 };
48 const BYTE L3ISLE4[14] = { 3, 2, 5, 2, 14, 13, 10, 12, 29, 26, 30, 31, 27, 32 };
49 const BYTE L3ISLE5[10] = { 2, 2, 5, 14, 13, 12, 7, 7, 7, 7 };
50 const BYTE L3XTRA1[4] = { 1, 1, 7, 106 };
51 const BYTE L3XTRA2[4] = { 1, 1, 7, 107 };
52 const BYTE L3XTRA3[4] = { 1, 1, 7, 108 };
53 const BYTE L3XTRA4[4] = { 1, 1, 9, 109 };
54 const BYTE L3XTRA5[4] = { 1, 1, 10, 110 };
55 const BYTE L3ANVIL[244] = {
56  11, 11, 7, 7, 7, 7, 7, 7, 7, 7,
57  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
58  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
59  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
60  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
61  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
62  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
63  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
64  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
65  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
66  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
67  7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
68  7, 7, 7, 0, 0, 0, 0, 0, 0, 0,
69  0, 0, 0, 0, 0, 0, 29, 26, 26, 26,
70  26, 26, 30, 0, 0, 0, 29, 34, 33, 33,
71  37, 36, 33, 35, 30, 0, 0, 25, 33, 37,
72  27, 32, 31, 36, 33, 28, 0, 0, 25, 37,
73  32, 7, 7, 7, 31, 27, 32, 0, 0, 25,
74  28, 7, 7, 7, 7, 2, 2, 2, 0, 0,
75  25, 35, 30, 7, 7, 7, 29, 26, 30, 0,
76  0, 25, 33, 35, 26, 30, 29, 34, 33, 28,
77  0, 0, 31, 36, 33, 33, 35, 34, 33, 37,
78  32, 0, 0, 0, 31, 27, 27, 27, 27, 27,
79  32, 0, 0, 0, 0, 0, 0, 0, 0, 0,
80  0, 0, 0, 0
81 };
82 
83 static void InitL3Dungeon()
84 {
85  int i, j;
86 
87  memset(dungeon, 0, sizeof(dungeon));
88 
89  for (j = 0; j < DMAXY; j++) {
90  for (i = 0; i < DMAXX; i++) {
91  dungeon[i][j] = 0;
92  dflags[i][j] = 0;
93  }
94  }
95 }
96 
97 static BOOL DRLG_L3FillRoom(int x1, int y1, int x2, int y2)
98 {
99  int i, j, v;
100 
101  if (x1 <= 1 || x2 >= 34 || y1 <= 1 || y2 >= 38) {
102  return FALSE;
103  }
104 
105  v = 0;
106  for (j = y1; j <= y2; j++) {
107  for (i = x1; i <= x2; i++) {
108  v += dungeon[i][j];
109  }
110  }
111 
112  if (v != 0) {
113  return FALSE;
114  }
115 
116  for (j = y1 + 1; j < y2; j++) {
117  for (i = x1 + 1; i < x2; i++) {
118  dungeon[i][j] = 1;
119  }
120  }
121  for (j = y1; j <= y2; j++) {
122  if (random_(0, 2) != 0) {
123  dungeon[x1][j] = 1;
124  }
125  if (random_(0, 2) != 0) {
126  dungeon[x2][j] = 1;
127  }
128  }
129  for (i = x1; i <= x2; i++) {
130  if (random_(0, 2) != 0) {
131  dungeon[i][y1] = 1;
132  }
133  if (random_(0, 2) != 0) {
134  dungeon[i][y2] = 1;
135  }
136  }
137 
138  return TRUE;
139 }
140 
141 static void DRLG_L3CreateBlock(int x, int y, int obs, int dir)
142 {
143  int blksizex, blksizey, x1, y1, x2, y2;
144  BOOL contflag;
145 
146  blksizex = random_(0, 2) + 3;
147  blksizey = random_(0, 2) + 3;
148 
149  if (dir == 0) {
150  y2 = y - 1;
151  y1 = y2 - blksizey;
152  if (blksizex < obs) {
153  x1 = random_(0, blksizex) + x;
154  }
155  if (blksizex == obs) {
156  x1 = x;
157  }
158  if (blksizex > obs) {
159  x1 = x - random_(0, blksizex);
160  }
161  x2 = blksizex + x1;
162  }
163  if (dir == 3) {
164  x2 = x - 1;
165  x1 = x2 - blksizex;
166  if (blksizey < obs) {
167  y1 = random_(0, blksizey) + y;
168  }
169  if (blksizey == obs) {
170  y1 = y;
171  }
172  if (blksizey > obs) {
173  y1 = y - random_(0, blksizey);
174  }
175  y2 = y1 + blksizey;
176  }
177  if (dir == 2) {
178  y1 = y + 1;
179  y2 = y1 + blksizey;
180  if (blksizex < obs) {
181  x1 = random_(0, blksizex) + x;
182  }
183  if (blksizex == obs) {
184  x1 = x;
185  }
186  if (blksizex > obs) {
187  x1 = x - random_(0, blksizex);
188  }
189  x2 = blksizex + x1;
190  }
191  if (dir == 1) {
192  x1 = x + 1;
193  x2 = x1 + blksizex;
194  if (blksizey < obs) {
195  y1 = random_(0, blksizey) + y;
196  }
197  if (blksizey == obs) {
198  y1 = y;
199  }
200  if (blksizey > obs) {
201  y1 = y - random_(0, blksizey);
202  }
203  y2 = y1 + blksizey;
204  }
205 
206  if (DRLG_L3FillRoom(x1, y1, x2, y2) == TRUE) {
207  contflag = random_(0, 4);
208  if (contflag && dir != 2) {
209  DRLG_L3CreateBlock(x1, y1, blksizey, 0);
210  }
211  if (contflag && dir != 3) {
212  DRLG_L3CreateBlock(x2, y1, blksizex, 1);
213  }
214  if (contflag && dir != 0) {
215  DRLG_L3CreateBlock(x1, y2, blksizey, 2);
216  }
217  if (contflag && dir != 1) {
218  DRLG_L3CreateBlock(x1, y1, blksizex, 3);
219  }
220  }
221 }
222 
223 static void DRLG_L3FloorArea(int x1, int y1, int x2, int y2)
224 {
225  int i, j;
226 
227  for (j = y1; j <= y2; j++) {
228  for (i = x1; i <= x2; i++) {
229  dungeon[i][j] = 1;
230  }
231  }
232 }
233 
234 static void DRLG_L3FillDiags()
235 {
236  int i, j, v;
237 
238  for (j = 0; j < DMAXY - 1; j++) {
239  for (i = 0; i < DMAXX - 1; i++) {
240  v = dungeon[i + 1][j + 1] + 2 * dungeon[i][j + 1] + 4 * dungeon[i + 1][j] + 8 * dungeon[i][j];
241  if (v == 6) {
242  if (random_(0, 2) == 0) {
243  dungeon[i][j] = 1;
244  } else {
245  dungeon[i + 1][j + 1] = 1;
246  }
247  }
248  if (v == 9) {
249  if (random_(0, 2) == 0) {
250  dungeon[i + 1][j] = 1;
251  } else {
252  dungeon[i][j + 1] = 1;
253  }
254  }
255  }
256  }
257 }
258 
259 static void DRLG_L3FillSingles()
260 {
261  int i, j;
262 
263  for (j = 1; j < DMAXY - 1; j++) {
264  for (i = 1; i < DMAXX - 1; i++) {
265  if (dungeon[i][j] == 0
266  && dungeon[i][j - 1] + dungeon[i - 1][j - 1] + dungeon[i + 1][j - 1] == 3
267  && dungeon[i + 1][j] + dungeon[i - 1][j] == 2
268  && dungeon[i][j + 1] + dungeon[i - 1][j + 1] + dungeon[i + 1][j + 1] == 3) {
269  dungeon[i][j] = 1;
270  }
271  }
272  }
273 }
274 
275 static void DRLG_L3FillStraights()
276 {
277  int i, j, xc, xs, yc, ys, k, rv;
278 
279  for (j = 0; j < DMAXY - 1; j++) {
280  xs = 0;
281  for (i = 0; i < 37; i++) {
282  if (dungeon[i][j] == 0 && dungeon[i][j + 1] == 1) {
283  if (xs == 0) {
284  xc = i;
285  }
286  xs++;
287  } else {
288  if (xs > 3 && random_(0, 2) != 0) {
289  for (k = xc; k < i; k++) {
290  rv = random_(0, 2);
291  dungeon[k][j] = rv;
292  }
293  }
294  xs = 0;
295  }
296  }
297  }
298  for (j = 0; j < DMAXY - 1; j++) {
299  xs = 0;
300  for (i = 0; i < 37; i++) {
301  if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 0) {
302  if (xs == 0) {
303  xc = i;
304  }
305  xs++;
306  } else {
307  if (xs > 3 && random_(0, 2) != 0) {
308  for (k = xc; k < i; k++) {
309  rv = random_(0, 2);
310  dungeon[k][j + 1] = rv;
311  }
312  }
313  xs = 0;
314  }
315  }
316  }
317  for (i = 0; i < DMAXX - 1; i++) {
318  ys = 0;
319  for (j = 0; j < 37; j++) {
320  if (dungeon[i][j] == 0 && dungeon[i + 1][j] == 1) {
321  if (ys == 0) {
322  yc = j;
323  }
324  ys++;
325  } else {
326  if (ys > 3 && random_(0, 2) != 0) {
327  for (k = yc; k < j; k++) {
328  rv = random_(0, 2);
329  dungeon[i][k] = rv;
330  }
331  }
332  ys = 0;
333  }
334  }
335  }
336  for (i = 0; i < DMAXX - 1; i++) {
337  ys = 0;
338  for (j = 0; j < 37; j++) {
339  if (dungeon[i][j] == 1 && dungeon[i + 1][j] == 0) {
340  if (ys == 0) {
341  yc = j;
342  }
343  ys++;
344  } else {
345  if (ys > 3 && random_(0, 2) != 0) {
346  for (k = yc; k < j; k++) {
347  rv = random_(0, 2);
348  dungeon[i + 1][k] = rv;
349  }
350  }
351  ys = 0;
352  }
353  }
354  }
355 }
356 
357 static void DRLG_L3Edges()
358 {
359  int i, j;
360 
361  for (j = 0; j < DMAXY; j++) {
362  dungeon[DMAXX - 1][j] = 0;
363  }
364  for (i = 0; i < DMAXX; i++) {
365  dungeon[i][DMAXY - 1] = 0;
366  }
367 }
368 
370 {
371  int i, j, gfa;
372 
373  gfa = 0;
374 
375  for (j = 0; j < DMAXY; j++) {
376  for (i = 0; i < DMAXX; i++) {
377  gfa += dungeon[i][j];
378  }
379  }
380 
381  return gfa;
382 }
383 
384 static void DRLG_L3MakeMegas()
385 {
386  int i, j, v, rv;
387 
388  for (j = 0; j < DMAXY - 1; j++) {
389  for (i = 0; i < DMAXX - 1; i++) {
390  v = dungeon[i + 1][j + 1] + 2 * dungeon[i][j + 1] + 4 * dungeon[i + 1][j] + 8 * dungeon[i][j];
391  if (v == 6) {
392  rv = random_(0, 2);
393  if (rv == 0) {
394  v = 12;
395  } else {
396  v = 5;
397  }
398  }
399  if (v == 9) {
400  rv = random_(0, 2);
401  if (rv == 0) {
402  v = 13;
403  } else {
404  v = 14;
405  }
406  }
407  dungeon[i][j] = L3ConvTbl[v];
408  }
409  dungeon[DMAXX - 1][j] = 8;
410  }
411  for (i = 0; i < DMAXX; i++) {
412  dungeon[i][DMAXY - 1] = 8;
413  }
414 }
415 
416 static void DRLG_L3River()
417 {
418  int rx, ry, px, py, dir, pdir, nodir, nodir2, dircheck;
419  int river[3][100];
420  int rivercnt, riveramt;
421  int i, trys, found, bridge, lpcnt;
422  BOOL bail;
423 
424  rivercnt = 0;
425  bail = FALSE;
426  trys = 0;
428  pdir = -1;
429 
430  while (trys < 200 && rivercnt < 4) {
431  bail = FALSE;
432  while (!bail && trys < 200) {
433  trys++;
434  rx = 0;
435  ry = 0;
436  i = 0;
437  // BUGFIX: Replace with `(ry >= DMAXY || dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && i < 100` (fixed)
438  while ((ry >= DMAXY || dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28) && i < 100) {
439  rx = random_(0, DMAXX);
440  ry = random_(0, DMAXY);
441  i++;
442  // BUGFIX: Move `ry < DMAXY` check before dungeon checks (fixed)
443  while (ry < DMAXY && (dungeon[rx][ry] < 25 || dungeon[rx][ry] > 28)) {
444  rx++;
445  if (rx >= DMAXX) {
446  rx = 0;
447  ry++;
448  }
449  }
450  }
451  // BUGFIX: Continue if `ry >= DMAXY` (fixed)
452  if (ry >= DMAXY)
453  continue;
454  if (i >= 100) {
455  return;
456  }
457  switch (dungeon[rx][ry]) {
458  case 25:
459  dir = 3;
460  nodir = 2;
461  river[2][0] = 40;
462  break;
463  case 26:
464  dir = 0;
465  nodir = 1;
466  river[2][0] = 38;
467  break;
468  case 27:
469  dir = 1;
470  nodir = 0;
471  river[2][0] = 41;
472  break;
473  case 28:
474  dir = 2;
475  nodir = 3;
476  river[2][0] = 39;
477  break;
478  }
479  river[0][0] = rx;
480  river[1][0] = ry;
481  riveramt = 1;
482  nodir2 = 4;
483  dircheck = 0;
484  while (dircheck < 4 && riveramt < 100) {
485  px = rx;
486  py = ry;
487  if (dircheck == 0) {
488  dir = random_(0, 4);
489  } else {
490  dir = (dir + 1) & 3;
491  }
492  dircheck++;
493  while (dir == nodir || dir == nodir2) {
494  dir = (dir + 1) & 3;
495  dircheck++;
496  }
497  if (dir == 0 && ry > 0) {
498  ry--;
499  }
500  if (dir == 1 && ry < DMAXY) {
501  ry++;
502  }
503  if (dir == 2 && rx < DMAXX) {
504  rx++;
505  }
506  if (dir == 3 && rx > 0) {
507  rx--;
508  }
509  if (dungeon[rx][ry] == 7) {
510  dircheck = 0;
511  if (dir < 2) {
512  river[2][riveramt] = (BYTE)random_(0, 2) + 17;
513  }
514  if (dir > 1) {
515  river[2][riveramt] = (BYTE)random_(0, 2) + 15;
516  }
517  river[0][riveramt] = rx;
518  river[1][riveramt] = ry;
519  riveramt++;
520  if (dir == 0 && pdir == 2 || dir == 3 && pdir == 1) {
521  if (riveramt > 2) {
522  river[2][riveramt - 2] = 22;
523  }
524  if (dir == 0) {
525  nodir2 = 1;
526  } else {
527  nodir2 = 2;
528  }
529  }
530  if (dir == 0 && pdir == 3 || dir == 2 && pdir == 1) {
531  if (riveramt > 2) {
532  river[2][riveramt - 2] = 21;
533  }
534  if (dir == 0) {
535  nodir2 = 1;
536  } else {
537  nodir2 = 3;
538  }
539  }
540  if (dir == 1 && pdir == 2 || dir == 3 && pdir == 0) {
541  if (riveramt > 2) {
542  river[2][riveramt - 2] = 20;
543  }
544  if (dir == 1) {
545  nodir2 = 0;
546  } else {
547  nodir2 = 2;
548  }
549  }
550  if (dir == 1 && pdir == 3 || dir == 2 && pdir == 0) {
551  if (riveramt > 2) {
552  river[2][riveramt - 2] = 19;
553  }
554  if (dir == 1) {
555  nodir2 = 0;
556  } else {
557  nodir2 = 3;
558  }
559  }
560  pdir = dir;
561  } else {
562  rx = px;
563  ry = py;
564  }
565  }
566  // BUGFIX: Check `ry >= 2` (fixed)
567  if (dir == 0 && ry >= 2 && dungeon[rx][ry - 1] == 10 && dungeon[rx][ry - 2] == 8) {
568  river[0][riveramt] = rx;
569  river[1][riveramt] = ry - 1;
570  river[2][riveramt] = 24;
571  if (pdir == 2) {
572  river[2][riveramt - 1] = 22;
573  }
574  if (pdir == 3) {
575  river[2][riveramt - 1] = 21;
576  }
577  bail = TRUE;
578  }
579  // BUGFIX: Check `ry + 2 < DMAXY` (fixed)
580  if (dir == 1 && ry + 2 < DMAXY && dungeon[rx][ry + 1] == 2 && dungeon[rx][ry + 2] == 8) {
581  river[0][riveramt] = rx;
582  river[1][riveramt] = ry + 1;
583  river[2][riveramt] = 42;
584  if (pdir == 2) {
585  river[2][riveramt - 1] = 20;
586  }
587  if (pdir == 3) {
588  river[2][riveramt - 1] = 19;
589  }
590  bail = TRUE;
591  }
592  // BUGFIX: Check `rx + 2 < DMAXX` (fixed)
593  if (dir == 2 && rx + 2 < DMAXX && dungeon[rx + 1][ry] == 4 && dungeon[rx + 2][ry] == 8) {
594  river[0][riveramt] = rx + 1;
595  river[1][riveramt] = ry;
596  river[2][riveramt] = 43;
597  if (pdir == 0) {
598  river[2][riveramt - 1] = 19;
599  }
600  if (pdir == 1) {
601  river[2][riveramt - 1] = 21;
602  }
603  bail = TRUE;
604  }
605  // BUGFIX: Check `rx >= 2` (fixed)
606  if (dir == 3 && rx >= 2 && dungeon[rx - 1][ry] == 9 && dungeon[rx - 2][ry] == 8) {
607  river[0][riveramt] = rx - 1;
608  river[1][riveramt] = ry;
609  river[2][riveramt] = 23;
610  if (pdir == 0) {
611  river[2][riveramt - 1] = 20;
612  }
613  if (pdir == 1) {
614  river[2][riveramt - 1] = 22;
615  }
616  bail = TRUE;
617  }
618  }
619  if (bail == TRUE && riveramt < 7) {
620  bail = FALSE;
621  }
622  if (bail == TRUE) {
623  found = 0;
624  lpcnt = 0;
625  while (found == 0 && lpcnt < 30) {
626  lpcnt++;
627  bridge = random_(0, riveramt);
628  if ((river[2][bridge] == 15 || river[2][bridge] == 16)
629  && dungeon[river[0][bridge]][river[1][bridge] - 1] == 7
630  && dungeon[river[0][bridge]][river[1][bridge] + 1] == 7) {
631  found = 1;
632  }
633  if ((river[2][bridge] == 17 || river[2][bridge] == 18)
634  && dungeon[river[0][bridge] - 1][river[1][bridge]] == 7
635  && dungeon[river[0][bridge] + 1][river[1][bridge]] == 7) {
636  found = 2;
637  }
638  for (i = 0; i < riveramt && found != 0; i++) {
639  if (found == 1
640  && (river[1][bridge] - 1 == river[1][i] || river[1][bridge] + 1 == river[1][i])
641  && river[0][bridge] == river[0][i]) {
642  found = 0;
643  }
644  if (found == 2
645  && (river[0][bridge] - 1 == river[0][i] || river[0][bridge] + 1 == river[0][i])
646  && river[1][bridge] == river[1][i]) {
647  found = 0;
648  }
649  }
650  }
651  if (found != 0) {
652  if (found == 1) {
653  river[2][bridge] = 44;
654  } else {
655  river[2][bridge] = 45;
656  }
657  rivercnt++;
658  for (bridge = 0; bridge <= riveramt; bridge++) {
659  dungeon[river[0][bridge]][river[1][bridge]] = river[2][bridge];
660  }
661  } else {
662  bail = FALSE;
663  }
664  }
665  }
666 }
667 
668 static BOOL DRLG_L3Spawn(int x, int y, int *totarea);
669 
670 static BOOL DRLG_L3SpawnEdge(int x, int y, int *totarea)
671 {
672  BYTE i;
673  static BYTE spawntable[15] = { 0, 0x0A, 0x43, 0x05, 0x2C, 0x06, 0x09, 0, 0, 0x1C, 0x83, 0x06, 0x09, 0x0A, 0x05 };
674 
675  if (*totarea > 40) {
676  return TRUE;
677  }
678  if (x < 0 || y < 0 || x >= DMAXX || y >= DMAXY) {
679  return TRUE;
680  }
681  if (dungeon[x][y] & 0x80) {
682  return FALSE;
683  }
684  if (dungeon[x][y] > 15) {
685  return TRUE;
686  }
687 
688  i = dungeon[x][y];
689  dungeon[x][y] |= 0x80;
690  *totarea += 1;
691 
692  if (spawntable[i] & 8 && DRLG_L3SpawnEdge(x, y - 1, totarea) == TRUE) {
693  return TRUE;
694  }
695  if (spawntable[i] & 4 && DRLG_L3SpawnEdge(x, y + 1, totarea) == TRUE) {
696  return TRUE;
697  }
698  if (spawntable[i] & 2 && DRLG_L3SpawnEdge(x + 1, y, totarea) == TRUE) {
699  return TRUE;
700  }
701  if (spawntable[i] & 1 && DRLG_L3SpawnEdge(x - 1, y, totarea) == TRUE) {
702  return TRUE;
703  }
704  if (spawntable[i] & 0x80 && DRLG_L3Spawn(x, y - 1, totarea) == TRUE) {
705  return TRUE;
706  }
707  if (spawntable[i] & 0x40 && DRLG_L3Spawn(x, y + 1, totarea) == TRUE) {
708  return TRUE;
709  }
710  if (spawntable[i] & 0x20 && DRLG_L3Spawn(x + 1, y, totarea) == TRUE) {
711  return TRUE;
712  }
713  if (spawntable[i] & 0x10 && DRLG_L3Spawn(x - 1, y, totarea) == TRUE) {
714  return TRUE;
715  }
716 
717  return FALSE;
718 }
719 
720 static BOOL DRLG_L3Spawn(int x, int y, int *totarea)
721 {
722  BYTE i;
723  static BYTE spawntable[15] = { 0, 0x0A, 0x03, 0x05, 0x0C, 0x06, 0x09, 0, 0, 0x012, 0x03, 0x06, 0x09, 0x0A, 0x05 };
724 
725  if (*totarea > 40) {
726  return TRUE;
727  }
728  if (x < 0 || y < 0 || x >= DMAXX || y >= DMAXY) {
729  return TRUE;
730  }
731  if (dungeon[x][y] & 0x80) {
732  return FALSE;
733  }
734  if (dungeon[x][y] > 15) {
735  return TRUE;
736  }
737 
738  i = dungeon[x][y];
739  dungeon[x][y] |= 0x80;
740  *totarea += 1;
741 
742  if (i != 8) {
743  if (spawntable[i] & 8 && DRLG_L3SpawnEdge(x, y - 1, totarea) == TRUE) {
744  return TRUE;
745  }
746  if (spawntable[i] & 4 && DRLG_L3SpawnEdge(x, y + 1, totarea) == TRUE) {
747  return TRUE;
748  }
749  if (spawntable[i] & 2 && DRLG_L3SpawnEdge(x + 1, y, totarea) == TRUE) {
750  return TRUE;
751  }
752  if (spawntable[i] & 1 && DRLG_L3SpawnEdge(x - 1, y, totarea) == TRUE) {
753  return TRUE;
754  }
755  } else {
756  if (DRLG_L3Spawn(x + 1, y, totarea) == TRUE) {
757  return TRUE;
758  }
759  if (DRLG_L3Spawn(x - 1, y, totarea) == TRUE) {
760  return TRUE;
761  }
762  if (DRLG_L3Spawn(x, y + 1, totarea) == TRUE) {
763  return TRUE;
764  }
765  if (DRLG_L3Spawn(x, y - 1, totarea) == TRUE) {
766  return TRUE;
767  }
768  }
769 
770  return FALSE;
771 }
772 
778 static void DRLG_L3Pool()
779 {
780  int i, j, dunx, duny, totarea, poolchance;
781  BOOL found;
782  BYTE k;
783  static BYTE poolsub[15] = { 0, 35, 26, 36, 25, 29, 34, 7, 33, 28, 27, 37, 32, 31, 30 };
784 
785  for (duny = 0; duny < DMAXY; duny++) {
786  for (dunx = 0; dunx < DMAXY; dunx++) {
787  if (dungeon[dunx][duny] != 8) {
788  continue;
789  }
790  dungeon[dunx][duny] |= 0x80;
791  totarea = 1;
792  if (dunx + 1 < DMAXX) {
793  found = DRLG_L3Spawn(dunx + 1, duny, &totarea);
794  } else {
795  found = TRUE;
796  }
797  if (dunx - 1 > 0 && !found) {
798  found = DRLG_L3Spawn(dunx - 1, duny, &totarea);
799  } else {
800  found = TRUE;
801  }
802  if (duny + 1 < DMAXY && !found) {
803  found = DRLG_L3Spawn(dunx, duny + 1, &totarea);
804  } else {
805  found = TRUE;
806  }
807  if (duny - 1 > 0 && !found) {
808  found = DRLG_L3Spawn(dunx, duny - 1, &totarea);
809  } else {
810  found = TRUE;
811  }
812  poolchance = random_(0, 100);
813  for (j = std::max(duny - totarea, 0); j < std::min(duny + totarea, DMAXY); j++) {
814  for (i = std::max(dunx - totarea, 0); i < std::min(dunx + totarea, DMAXX); i++) {
815  // BUGFIX: In the following swap the order to first do the
816  // index checks and only then access dungeon[i][j] (fixed)
817  if (dungeon[i][j] & 0x80) {
818  dungeon[i][j] &= ~0x80;
819  if (totarea > 4 && poolchance < 25 && !found) {
820  k = poolsub[dungeon[i][j]];
821  if (k != 0 && k <= 37) {
822  dungeon[i][j] = k;
823  }
824  lavapool = TRUE;
825  }
826  }
827  }
828  }
829  }
830  }
831 }
832 
833 static void DRLG_L3PoolFix()
834 {
835  int dunx, duny;
836 
837  for (duny = 1; duny < DMAXY - 1; duny++) { // BUGFIX: Change '0' to '1' and 'DMAXY' to 'DMAXY - 1' (fixed)
838  for (dunx = 1; dunx < DMAXX - 1; dunx++) { // BUGFIX: Change '0' to '1' and 'DMAXX' to 'DMAXX - 1' (fixed)
839  if (dungeon[dunx][duny] == 8) {
840  if (dungeon[dunx - 1][duny - 1] >= 25 && dungeon[dunx - 1][duny - 1] <= 41
841  && dungeon[dunx - 1][duny] >= 25 && dungeon[dunx - 1][duny] <= 41
842  && dungeon[dunx - 1][duny + 1] >= 25 && dungeon[dunx - 1][duny + 1] <= 41
843  && dungeon[dunx][duny - 1] >= 25 && dungeon[dunx][duny - 1] <= 41
844  && dungeon[dunx][duny + 1] >= 25 && dungeon[dunx][duny + 1] <= 41
845  && dungeon[dunx + 1][duny - 1] >= 25 && dungeon[dunx + 1][duny - 1] <= 41
846  && dungeon[dunx + 1][duny] >= 25 && dungeon[dunx + 1][duny] <= 41
847  && dungeon[dunx + 1][duny + 1] >= 25 && dungeon[dunx + 1][duny + 1] <= 41) {
848  dungeon[dunx][duny] = 33;
849  }
850  }
851  }
852  }
853 }
854 
855 static BOOL DRLG_L3PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir)
856 {
857  int sx, sy, sw, sh, xx, yy, i, ii, numt, trys;
858  BOOL found;
859 
860  sw = miniset[0];
861  sh = miniset[1];
862 
863  if (tmax - tmin == 0) {
864  numt = 1;
865  } else {
866  numt = random_(0, tmax - tmin) + tmin;
867  }
868 
869  for (i = 0; i < numt; i++) {
870  sx = random_(0, DMAXX - sw);
871  sy = random_(0, DMAXY - sh);
872  found = FALSE;
873  trys = 0;
874  while (!found && trys < 200) {
875  trys++;
876  found = TRUE;
877  if (cx != -1 && sx >= cx - sw && sx <= cx + 12) {
878  sx = random_(0, DMAXX - sw);
879  sy = random_(0, DMAXY - sh);
880  found = FALSE;
881  }
882  if (cy != -1 && sy >= cy - sh && sy <= cy + 12) {
883  sx = random_(0, DMAXX - sw);
884  sy = random_(0, DMAXY - sh);
885  found = FALSE;
886  }
887  ii = 2;
888  for (yy = 0; yy < sh && found == TRUE; yy++) {
889  for (xx = 0; xx < sw && found == TRUE; xx++) {
890  if (miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) {
891  found = FALSE;
892  }
893  if (dflags[xx + sx][yy + sy] != 0) {
894  found = FALSE;
895  }
896  ii++;
897  }
898  }
899  if (!found) {
900  sx++;
901  if (sx == DMAXX - sw) {
902  sx = 0;
903  sy++;
904  if (sy == DMAXY - sh) {
905  sy = 0;
906  }
907  }
908  }
909  }
910  if (trys >= 200) {
911  return TRUE;
912  }
913  ii = sw * sh + 2;
914  for (yy = 0; yy < sh; yy++) {
915  for (xx = 0; xx < sw; xx++) {
916  if (miniset[ii] != 0) {
917  dungeon[xx + sx][yy + sy] = miniset[ii];
918  }
919  ii++;
920  }
921  }
922  }
923 
924  if (setview == TRUE) {
925  ViewX = 2 * sx + 17;
926  ViewY = 2 * sy + 19;
927  }
928  if (ldir == 0) {
929  LvlViewX = 2 * sx + 17;
930  LvlViewY = 2 * sy + 19;
931  }
932 
933  return FALSE;
934 }
935 
936 static void DRLG_L3PlaceRndSet(const BYTE *miniset, int rndper)
937 {
938  int sx, sy, sw, sh, xx, yy, ii, kk;
939  BOOL found;
940 
941  sw = miniset[0];
942  sh = miniset[1];
943 
944  for (sy = 0; sy < DMAXX - sh; sy++) {
945  for (sx = 0; sx < DMAXY - sw; sx++) {
946  found = TRUE;
947  ii = 2;
948  for (yy = 0; yy < sh && found == TRUE; yy++) {
949  for (xx = 0; xx < sw && found == TRUE; xx++) {
950  if (miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) {
951  found = FALSE;
952  }
953  if (dflags[xx + sx][yy + sy] != 0) {
954  found = FALSE;
955  }
956  ii++;
957  }
958  }
959  kk = sw * sh + 2;
960  if (miniset[kk] >= 84 && miniset[kk] <= 100 && found == TRUE) {
961  // BUGFIX: accesses to dungeon can go out of bounds (fixed)
962  // BUGFIX: Comparisons vs 100 should use same tile as comparisons vs 84.
963  if (sx - 1 >= 0 && dungeon[sx - 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) {
964  found = FALSE;
965  }
966  if (sx + 1 < 40 && sx - 1 >= 0 && dungeon[sx + 1][sy] >= 84 && dungeon[sx - 1][sy] <= 100) {
967  found = FALSE;
968  }
969  if (sy + 1 < 40 && sx - 1 >= 0 && dungeon[sx][sy + 1] >= 84 && dungeon[sx - 1][sy] <= 100) {
970  found = FALSE;
971  }
972  if (sy - 1 >= 0 && sx - 1 >= 0 && dungeon[sx][sy - 1] >= 84 && dungeon[sx - 1][sy] <= 100) {
973  found = FALSE;
974  }
975  }
976  if (found == TRUE && random_(0, 100) < rndper) {
977  for (yy = 0; yy < sh; yy++) {
978  for (xx = 0; xx < sw; xx++) {
979  if (miniset[kk] != 0) {
980  dungeon[xx + sx][yy + sy] = miniset[kk];
981  }
982  kk++;
983  }
984  }
985  }
986  }
987  }
988 }
989 
990 static BOOL WoodVertU(int i, int y)
991 {
992  if ((dungeon[i + 1][y] > 152 || dungeon[i + 1][y] < 130)
993  && (dungeon[i - 1][y] > 152 || dungeon[i - 1][y] < 130)) {
994  if (dungeon[i][y] == 7) {
995  return TRUE;
996  }
997  if (dungeon[i][y] == 10) {
998  return TRUE;
999  }
1000  if (dungeon[i][y] == 126) {
1001  return TRUE;
1002  }
1003  if (dungeon[i][y] == 129) {
1004  return TRUE;
1005  }
1006  if (dungeon[i][y] == 134) {
1007  return TRUE;
1008  }
1009  if (dungeon[i][y] == 136) {
1010  return TRUE;
1011  }
1012  }
1013 
1014  return FALSE;
1015 }
1016 
1017 static BOOL WoodVertD(int i, int y)
1018 {
1019  if ((dungeon[i + 1][y] > 152 || dungeon[i + 1][y] < 130)
1020  && (dungeon[i - 1][y] > 152 || dungeon[i - 1][y] < 130)) {
1021  if (dungeon[i][y] == 7) {
1022  return TRUE;
1023  }
1024  if (dungeon[i][y] == 2) {
1025  return TRUE;
1026  }
1027  if (dungeon[i][y] == 134) {
1028  return TRUE;
1029  }
1030  if (dungeon[i][y] == 136) {
1031  return TRUE;
1032  }
1033  }
1034 
1035  return FALSE;
1036 }
1037 
1038 static BOOL WoodHorizL(int x, int j)
1039 {
1040  if ((dungeon[x][j + 1] > 152 || dungeon[x][j + 1] < 130)
1041  && (dungeon[x][j - 1] > 152 || dungeon[x][j - 1] < 130)) {
1042  if (dungeon[x][j] == 7) {
1043  return TRUE;
1044  }
1045  if (dungeon[x][j] == 9) {
1046  return TRUE;
1047  }
1048  if (dungeon[x][j] == 121) {
1049  return TRUE;
1050  }
1051  if (dungeon[x][j] == 124) {
1052  return TRUE;
1053  }
1054  if (dungeon[x][j] == 135) {
1055  return TRUE;
1056  }
1057  if (dungeon[x][j] == 137) {
1058  return TRUE;
1059  }
1060  }
1061 
1062  return FALSE;
1063 }
1064 
1065 static BOOL WoodHorizR(int x, int j)
1066 {
1067  if ((dungeon[x][j + 1] > 152 || dungeon[x][j + 1] < 130)
1068  && (dungeon[x][j - 1] > 152 || dungeon[x][j - 1] < 130)) {
1069  if (dungeon[x][j] == 7) {
1070  return TRUE;
1071  }
1072  if (dungeon[x][j] == 4) {
1073  return TRUE;
1074  }
1075  if (dungeon[x][j] == 135) {
1076  return TRUE;
1077  }
1078  if (dungeon[x][j] == 137) {
1079  return TRUE;
1080  }
1081  }
1082 
1083  return FALSE;
1084 }
1085 
1087 {
1088  int i, j;
1089 
1090  for (j = 0; j < DMAXY; j++) {
1091  for (i = 0; i < DMAXX; i++) {
1092  if (dungeon[i][j] == 7) {
1093  if (dungeon[i - 1][j] <= 152 && dungeon[i - 1][j] >= 130
1094  && dungeon[i + 1][j] <= 152 && dungeon[i + 1][j] >= 130) {
1095  dungeon[i][j] = 146;
1096  continue;
1097  }
1098  }
1099  if (dungeon[i][j] == 7) {
1100  if (dungeon[i][j - 1] <= 152 && dungeon[i][j - 1] >= 130
1101  && dungeon[i][j + 1] <= 152 && dungeon[i][j + 1] >= 130) {
1102  dungeon[i][j] = 147;
1103  continue;
1104  }
1105  }
1106  }
1107  }
1108 }
1109 
1111 {
1112  int i, j;
1113 
1114  for (j = 0; j < DMAXY; j++) {
1115  for (i = 0; i < DMAXX; i++) {
1116  if (dungeon[i][j] == 146) {
1117  if (dungeon[i + 1][j] > 152 || dungeon[i + 1][j] < 130
1118  || dungeon[i - 1][j] > 152 || dungeon[i - 1][j] < 130) {
1119  dungeon[i][j] = 7;
1120  continue;
1121  }
1122  }
1123  if (dungeon[i][j] == 146) {
1124  if (dungeon[i + 1][j] != 130 && dungeon[i - 1][j] != 130
1125  && dungeon[i + 1][j] != 132 && dungeon[i - 1][j] != 132
1126  && dungeon[i + 1][j] != 133 && dungeon[i - 1][j] != 133
1127  && dungeon[i + 1][j] != 134 && dungeon[i - 1][j] != 134
1128  && dungeon[i + 1][j] != 136 && dungeon[i - 1][j] != 136
1129  && dungeon[i + 1][j] != 138 && dungeon[i - 1][j] != 138
1130  && dungeon[i + 1][j] != 140 && dungeon[i - 1][j] != 140) {
1131  dungeon[i][j] = 7;
1132  continue;
1133  }
1134  }
1135  if (dungeon[i][j] == 147) {
1136  if (dungeon[i][j + 1] > 152 || dungeon[i][j + 1] < 130
1137  || dungeon[i][j - 1] > 152 || dungeon[i][j - 1] < 130) {
1138  dungeon[i][j] = 7;
1139  continue;
1140  }
1141  }
1142  if (dungeon[i][j] == 147) {
1143  if (dungeon[i][j + 1] != 131 && dungeon[i][j - 1] != 131
1144  && dungeon[i][j + 1] != 132 && dungeon[i][j - 1] != 132
1145  && dungeon[i][j + 1] != 133 && dungeon[i][j - 1] != 133
1146  && dungeon[i][j + 1] != 135 && dungeon[i][j - 1] != 135
1147  && dungeon[i][j + 1] != 137 && dungeon[i][j - 1] != 137
1148  && dungeon[i][j + 1] != 138 && dungeon[i][j - 1] != 138
1149  && dungeon[i][j + 1] != 139 && dungeon[i][j - 1] != 139) {
1150  dungeon[i][j] = 7;
1151  continue;
1152  }
1153  }
1154  }
1155  }
1156 }
1157 
1158 static void DRLG_L3Wood()
1159 {
1160  int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2;
1161  BOOL skip;
1162 
1163  for (j = 1; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' (fixed)
1164  for (i = 1; i < DMAXX - 1; i++) { // BUGFIX: Change '0' to '1' (fixed)
1165  if (dungeon[i][j] == 10 && random_(0, 2) != 0) {
1166  x = i;
1167  while (dungeon[x][j] == 10) {
1168  x++;
1169  }
1170  x--;
1171  if (x - i > 0) {
1172  dungeon[i][j] = 127;
1173  for (xx = i + 1; xx < x; xx++) {
1174  if (random_(0, 2) != 0) {
1175  dungeon[xx][j] = 126;
1176  } else {
1177  dungeon[xx][j] = 129;
1178  }
1179  }
1180  dungeon[x][j] = 128;
1181  }
1182  }
1183  if (dungeon[i][j] == 9 && random_(0, 2) != 0) {
1184  y = j;
1185  while (dungeon[i][y] == 9) {
1186  y++;
1187  }
1188  y--;
1189  if (y - j > 0) {
1190  dungeon[i][j] = 123;
1191  for (yy = j + 1; yy < y; yy++) {
1192  if (random_(0, 2) != 0) {
1193  dungeon[i][yy] = 121;
1194  } else {
1195  dungeon[i][yy] = 124;
1196  }
1197  }
1198  dungeon[i][y] = 122;
1199  }
1200  }
1201  if (dungeon[i][j] == 11 && dungeon[i + 1][j] == 10 && dungeon[i][j + 1] == 9 && random_(0, 2) != 0) {
1202  dungeon[i][j] = 125;
1203  x = i + 1;
1204  while (dungeon[x][j] == 10) {
1205  x++;
1206  }
1207  x--;
1208  for (xx = i + 1; xx < x; xx++) {
1209  if (random_(0, 2) != 0) {
1210  dungeon[xx][j] = 126;
1211  } else {
1212  dungeon[xx][j] = 129;
1213  }
1214  }
1215  dungeon[x][j] = 128;
1216  y = j + 1;
1217  while (dungeon[i][y] == 9) {
1218  y++;
1219  }
1220  y--;
1221  for (yy = j + 1; yy < y; yy++) {
1222  if (random_(0, 2) != 0) {
1223  dungeon[i][yy] = 121;
1224  } else {
1225  dungeon[i][yy] = 124;
1226  }
1227  }
1228  dungeon[i][y] = 122;
1229  }
1230  }
1231  }
1232 
1233  for (j = 1; j < DMAXY; j++) { // BUGFIX: Change '0' to '1' (fixed)
1234  for (i = 1; i < DMAXX; i++) { // BUGFIX: Change '0' to '1' (fixed)
1235  if (dungeon[i][j] == 7 && random_(0, 1) == 0 && SkipThemeRoom(i, j)) {
1236  rt = random_(0, 2);
1237  if (rt == 0) {
1238  y1 = j;
1239  // BUGFIX: Check `y1 >= 0` first (fixed)
1240  while (y1 >= 0 && WoodVertU(i, y1)) {
1241  y1--;
1242  }
1243  y1++;
1244  y2 = j;
1245  // BUGFIX: Check `y2 < DMAXY` first (fixed)
1246  while (y2 < DMAXY && WoodVertD(i, y2)) {
1247  y2++;
1248  }
1249  y2--;
1250  skip = TRUE;
1251  if (dungeon[i][y1] == 7) {
1252  skip = FALSE;
1253  }
1254  if (dungeon[i][y2] == 7) {
1255  skip = FALSE;
1256  }
1257  if (y2 - y1 > 1 && skip) {
1258  rp = random_(0, y2 - y1 - 1) + y1 + 1;
1259  for (y = y1; y <= y2; y++) {
1260  if (y == rp) {
1261  continue;
1262  }
1263  if (dungeon[i][y] == 7) {
1264  if (random_(0, 2) != 0) {
1265  dungeon[i][y] = 135;
1266  } else {
1267  dungeon[i][y] = 137;
1268  }
1269  }
1270  if (dungeon[i][y] == 10) {
1271  dungeon[i][y] = 131;
1272  }
1273  if (dungeon[i][y] == 126) {
1274  dungeon[i][y] = 133;
1275  }
1276  if (dungeon[i][y] == 129) {
1277  dungeon[i][y] = 133;
1278  }
1279  if (dungeon[i][y] == 2) {
1280  dungeon[i][y] = 139;
1281  }
1282  if (dungeon[i][y] == 134) {
1283  dungeon[i][y] = 138;
1284  }
1285  if (dungeon[i][y] == 136) {
1286  dungeon[i][y] = 138;
1287  }
1288  }
1289  }
1290  }
1291  if (rt == 1) {
1292  x1 = i;
1293  // BUGFIX: Check `x1 >= 0` first (fixed)
1294  while (x1 >= 0 && WoodHorizL(x1, j)) {
1295  x1--;
1296  }
1297  x1++;
1298  x2 = i;
1299  // BUGFIX: Check `x2 < DMAXX` first (fixed)
1300  while (x2 < DMAXX && WoodHorizR(x2, j)) {
1301  x2++;
1302  }
1303  x2--;
1304  skip = TRUE;
1305  if (dungeon[x1][j] == 7) {
1306  skip = FALSE;
1307  }
1308  if (dungeon[x2][j] == 7) {
1309  skip = FALSE;
1310  }
1311  if (x2 - x1 > 1 && skip) {
1312  rp = random_(0, x2 - x1 - 1) + x1 + 1;
1313  for (x = x1; x <= x2; x++) {
1314  if (x == rp) {
1315  continue;
1316  }
1317  if (dungeon[x][j] == 7) {
1318  if (random_(0, 2) != 0) {
1319  dungeon[x][j] = 134;
1320  } else {
1321  dungeon[x][j] = 136;
1322  }
1323  }
1324  if (dungeon[x][j] == 9) {
1325  dungeon[x][j] = 130;
1326  }
1327  if (dungeon[x][j] == 121) {
1328  dungeon[x][j] = 132;
1329  }
1330  if (dungeon[x][j] == 124) {
1331  dungeon[x][j] = 132;
1332  }
1333  if (dungeon[x][j] == 4) {
1334  dungeon[x][j] = 140;
1335  }
1336  if (dungeon[x][j] == 135) {
1337  dungeon[x][j] = 138;
1338  }
1339  if (dungeon[x][j] == 137) {
1340  dungeon[x][j] = 138;
1341  }
1342  }
1343  }
1344  }
1345  }
1346  }
1347  }
1348 
1349  AddFenceDoors();
1350  FenceDoorFix();
1351 }
1352 
1354 {
1355  int sx, sy, sw, sh, xx, yy, ii, trys;
1356  BOOL found;
1357 
1358  sw = L3ANVIL[0];
1359  sh = L3ANVIL[1];
1360  sx = random_(0, DMAXX - sw);
1361  sy = random_(0, DMAXY - sh);
1362 
1363  found = FALSE;
1364  trys = 0;
1365  while (!found && trys < 200) {
1366  trys++;
1367  found = TRUE;
1368  ii = 2;
1369  for (yy = 0; yy < sh && found == TRUE; yy++) {
1370  for (xx = 0; xx < sw && found == TRUE; xx++) {
1371  if (L3ANVIL[ii] != 0 && dungeon[xx + sx][yy + sy] != L3ANVIL[ii]) {
1372  found = FALSE;
1373  }
1374  if (dflags[xx + sx][yy + sy] != 0) {
1375  found = FALSE;
1376  }
1377  ii++;
1378  }
1379  }
1380  if (!found) {
1381  sx++;
1382  if (sx == DMAXX - sw) {
1383  sx = 0;
1384  sy++;
1385  if (sy == DMAXY - sh) {
1386  sy = 0;
1387  }
1388  }
1389  }
1390  }
1391  if (trys >= 200) {
1392  return TRUE;
1393  }
1394 
1395  ii = sw * sh + 2;
1396  for (yy = 0; yy < sh; yy++) {
1397  for (xx = 0; xx < sw; xx++) {
1398  if (L3ANVIL[ii] != 0) {
1399  dungeon[xx + sx][yy + sy] = L3ANVIL[ii];
1400  }
1401  dflags[xx + sx][yy + sy] |= DLRG_PROTECTED;
1402  ii++;
1403  }
1404  }
1405 
1406  setpc_x = sx;
1407  setpc_y = sy;
1408  setpc_w = sw;
1409  setpc_h = sh;
1410 
1411  return FALSE;
1412 }
1413 
1415 {
1416  int i, j;
1417 
1418  for (j = 0; j < DMAXY; j++) {
1419  for (i = 0; i < DMAXX; i++) {
1420  if (dungeon[i][j] == 125 && dungeon[i + 1][j] == 125 && dungeon[i][j + 1] == 125 && dungeon[i + 1][j + 1] == 125) {
1421  dungeon[i][j] = 156;
1422  dungeon[i + 1][j] = 155;
1423  dungeon[i][j + 1] = 153;
1424  dungeon[i + 1][j + 1] = 154;
1425  return;
1426  }
1427  if (dungeon[i][j] == 5 && dungeon[i + 1][j + 1] == 7) {
1428  dungeon[i][j] = 7;
1429  }
1430  }
1431  }
1432 }
1433 
1435 {
1436  int i, j;
1437 
1438  for (j = 0; j < DMAXY; j++) {
1439  for (i = 0; i < DMAXX; i++) {
1440  if (dungeon[i][j] == 5 && dungeon[i + 1][j + 1] == 7) {
1441  dungeon[i][j] = 7;
1442  }
1443  }
1444  }
1445  for (j = 0; j < DMAXY; j++) {
1446  for (i = 0; i < DMAXX; i++) {
1447  if (dungeon[i][j] == 5 && dungeon[i + 1][j + 1] == 12 && dungeon[i + 1][j] == 7) {
1448  dungeon[i][j] = 7;
1449  dungeon[i][j + 1] = 7;
1450  dungeon[i + 1][j + 1] = 7;
1451  }
1452  if (dungeon[i][j] == 5 && dungeon[i + 1][j + 1] == 12 && dungeon[i][j + 1] == 7) {
1453  dungeon[i][j] = 7;
1454  dungeon[i + 1][j] = 7;
1455  dungeon[i + 1][j + 1] = 7;
1456  }
1457  }
1458  }
1459 }
1460 
1461 void DRLG_L3LockRec(int x, int y)
1462 {
1463  if (!lockout[x][y]) {
1464  return;
1465  }
1466 
1467  lockout[x][y] = FALSE;
1468  lockoutcnt++;
1469  DRLG_L3LockRec(x, y - 1);
1470  DRLG_L3LockRec(x, y + 1);
1471  DRLG_L3LockRec(x - 1, y);
1472  DRLG_L3LockRec(x + 1, y);
1473 }
1474 
1476 {
1477  int i, j, t, fx, fy;
1478 
1479  t = 0;
1480  for (j = 0; j < DMAXY; j++) {
1481  for (i = 0; i < DMAXX; i++) {
1482  if (dungeon[i][j] != 0) {
1483  lockout[i][j] = TRUE;
1484  fx = i;
1485  fy = j;
1486  t++;
1487  } else {
1488  lockout[i][j] = FALSE;
1489  }
1490  }
1491  }
1492 
1493  lockoutcnt = 0;
1494  DRLG_L3LockRec(fx, fy);
1495 
1496  return t == lockoutcnt;
1497 }
1498 
1499 static void DRLG_L3(int entry)
1500 {
1501  int x1, y1, x2, y2, i, j;
1502  BOOL found, genok;
1503 
1504  lavapool = FALSE;
1505 
1506  do {
1507  do {
1508  do {
1509  InitL3Dungeon();
1510  x1 = random_(0, 20) + 10;
1511  y1 = random_(0, 20) + 10;
1512  x2 = x1 + 2;
1513  y2 = y1 + 2;
1514  DRLG_L3FillRoom(x1, y1, x2, y2);
1515  DRLG_L3CreateBlock(x1, y1, 2, 0);
1516  DRLG_L3CreateBlock(x2, y1, 2, 1);
1517  DRLG_L3CreateBlock(x1, y2, 2, 2);
1518  DRLG_L3CreateBlock(x1, y1, 2, 3);
1519  if (QuestStatus(Q_ANVIL)) {
1520  x1 = random_(0, 10) + 10;
1521  y1 = random_(0, 10) + 10;
1522  x2 = x1 + 12;
1523  y2 = y1 + 12;
1524  DRLG_L3FloorArea(x1, y1, x2, y2);
1525  }
1526  DRLG_L3FillDiags();
1529  DRLG_L3FillDiags();
1530  DRLG_L3Edges();
1531  if (DRLG_L3GetFloorArea() >= 600) {
1532  found = DRLG_L3Lockout();
1533  } else {
1534  found = FALSE;
1535  }
1536  } while (!found);
1537  DRLG_L3MakeMegas();
1538  if (entry == 0) {
1539  genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 1, 0);
1540  if (!genok) {
1541  genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 0, 1);
1542  if (!genok && currlevel == 9) {
1543  genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, 0, 6);
1544  }
1545  }
1546  } else if (entry == 1) {
1547  genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 0, 0);
1548  if (!genok) {
1549  genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 1, 1);
1550  ViewX += 2;
1551  ViewY -= 2;
1552  if (!genok && currlevel == 9) {
1553  genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, 0, 6);
1554  }
1555  }
1556  } else {
1557  genok = DRLG_L3PlaceMiniSet(L3UP, 1, 1, -1, -1, 0, 0);
1558  if (!genok) {
1559  genok = DRLG_L3PlaceMiniSet(L3DOWN, 1, 1, -1, -1, 0, 1);
1560  if (!genok && currlevel == 9) {
1561  genok = DRLG_L3PlaceMiniSet(L3HOLDWARP, 1, 1, -1, -1, 1, 6);
1562  }
1563  }
1564  }
1565  if (!genok && QuestStatus(Q_ANVIL)) {
1566  genok = DRLG_L3Anvil();
1567  }
1568  } while (genok == TRUE);
1569  DRLG_L3Pool();
1570  } while (!lavapool);
1571 
1572  DRLG_L3PoolFix();
1573  FixL3Warp();
1582  DRLG_L3River();
1583 
1584  if (QuestStatus(Q_ANVIL)) {
1585  dungeon[setpc_x + 7][setpc_y + 5] = 7;
1586  dungeon[setpc_x + 8][setpc_y + 5] = 7;
1587  dungeon[setpc_x + 9][setpc_y + 5] = 7;
1588  if (dungeon[setpc_x + 10][setpc_y + 5] == 17 || dungeon[setpc_x + 10][setpc_y + 5] == 18) {
1589  dungeon[setpc_x + 10][setpc_y + 5] = 45;
1590  }
1591  }
1592 
1593  DRLG_PlaceThemeRooms(5, 10, 7, 0, 0);
1594  DRLG_L3Wood();
1622 
1623  for (j = 0; j < DMAXY; j++) {
1624  for (i = 0; i < DMAXX; i++) {
1625  pdungeon[i][j] = dungeon[i][j];
1626  }
1627  }
1628 
1630 }
1631 
1632 static void DRLG_L3Pass3()
1633 {
1634  int i, j, xx, yy;
1635  long v1, v2, v3, v4, lv;
1636  WORD *MegaTiles;
1637 
1638  lv = 8 - 1;
1639 
1640  MegaTiles = (WORD *)&pMegaTiles[lv * 8];
1641  v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
1642  v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
1643  v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
1644  v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
1645 
1646  for (j = 0; j < MAXDUNY; j += 2)
1647  {
1648  for (i = 0; i < MAXDUNX; i += 2) {
1649  dPiece[i][j] = v1;
1650  dPiece[i + 1][j] = v2;
1651  dPiece[i][j + 1] = v3;
1652  dPiece[i + 1][j + 1] = v4;
1653  }
1654  }
1655 
1656  yy = 16;
1657  for (j = 0; j < DMAXY; j++) {
1658  xx = 16;
1659  for (i = 0; i < DMAXX; i++) {
1660  lv = dungeon[i][j] - 1;
1661  if (lv >= 0) {
1662  MegaTiles = (WORD *)&pMegaTiles[lv * 8];
1663  v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
1664  v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
1665  v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
1666  v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
1667  } else {
1668  v1 = 0;
1669  v2 = 0;
1670  v3 = 0;
1671  v4 = 0;
1672  }
1673  dPiece[xx][yy] = v1;
1674  dPiece[xx + 1][yy] = v2;
1675  dPiece[xx][yy + 1] = v3;
1676  dPiece[xx + 1][yy + 1] = v4;
1677  xx += 2;
1678  }
1679  yy += 2;
1680  }
1681 }
1682 
1683 void CreateL3Dungeon(DWORD rseed, int entry)
1684 {
1685  int i, j;
1686 
1687  SetRndSeed(rseed);
1688  dminx = 16;
1689  dminy = 16;
1690  dmaxx = 96;
1691  dmaxy = 96;
1692  DRLG_InitTrans();
1693  DRLG_InitSetPC();
1694  DRLG_L3(entry);
1695  DRLG_L3Pass3();
1696 
1697  for (j = 0; j < MAXDUNY; j++) {
1698  for (i = 0; i < MAXDUNX; i++) {
1699  if (dPiece[i][j] >= 56 && dPiece[i][j] <= 147) {
1700  DoLighting(i, j, 7, -1);
1701  } else if (dPiece[i][j] >= 154 && dPiece[i][j] <= 161) {
1702  DoLighting(i, j, 7, -1);
1703  } else if (dPiece[i][j] == 150) {
1704  DoLighting(i, j, 7, -1);
1705  } else if (dPiece[i][j] == 152) {
1706  DoLighting(i, j, 7, -1);
1707  }
1708  }
1709  }
1710 
1711  DRLG_SetPC();
1712 }
1713 
1714 void LoadL3Dungeon(char *sFileName, int vx, int vy)
1715 {
1716  int i, j, rw, rh;
1717  BYTE *pLevelMap, *lm;
1718 
1719  InitL3Dungeon();
1720  dminx = 16;
1721  dminy = 16;
1722  dmaxx = 96;
1723  dmaxy = 96;
1724  DRLG_InitTrans();
1725  pLevelMap = LoadFileInMem(sFileName, NULL);
1726 
1727  lm = pLevelMap;
1728  rw = *lm;
1729  lm += 2;
1730  rh = *lm;
1731  lm += 2;
1732 
1733  for (j = 0; j < rh; j++) {
1734  for (i = 0; i < rw; i++) {
1735  if (*lm != 0) {
1736  dungeon[i][j] = *lm;
1737  } else {
1738  dungeon[i][j] = 7;
1739  }
1740  lm += 2;
1741  }
1742  }
1743  for (j = 0; j < DMAXY; j++) {
1744  for (i = 0; i < DMAXX; i++) {
1745  if (dungeon[i][j] == 0) {
1746  dungeon[i][j] = 8;
1747  }
1748  }
1749  }
1750 
1751  abyssx = MAXDUNX; // Unused
1752  DRLG_L3Pass3();
1754  ViewX = 31;
1755  ViewY = 83;
1756  SetMapMonsters(pLevelMap, 0, 0);
1757  SetMapObjects(pLevelMap, 0, 0);
1758 
1759  for (j = 0; j < MAXDUNY; j++) {
1760  for (i = 0; i < MAXDUNX; i++) {
1761  if (dPiece[i][j] >= 56 && dPiece[i][j] <= 147) {
1762  DoLighting(i, j, 7, -1);
1763  } else if (dPiece[i][j] >= 154 && dPiece[i][j] <= 161) {
1764  DoLighting(i, j, 7, -1);
1765  } else if (dPiece[i][j] == 150) {
1766  DoLighting(i, j, 7, -1);
1767  } else if (dPiece[i][j] == 152) {
1768  DoLighting(i, j, 7, -1);
1769  }
1770  }
1771  }
1772 
1773  mem_free_dbg(pLevelMap);
1774 }
1775 
1776 void LoadPreL3Dungeon(char *sFileName, int vx, int vy)
1777 {
1778  int i, j, rw, rh;
1779  BYTE *pLevelMap, *lm;
1780 
1781  InitL3Dungeon();
1782  DRLG_InitTrans();
1783  pLevelMap = LoadFileInMem(sFileName, NULL);
1784 
1785  lm = pLevelMap;
1786  rw = *lm;
1787  lm += 2;
1788  rh = *lm;
1789  lm += 2;
1790 
1791  for (j = 0; j < rh; j++) {
1792  for (i = 0; i < rw; i++) {
1793  if (*lm != 0) {
1794  dungeon[i][j] = *lm;
1795  } else {
1796  dungeon[i][j] = 7;
1797  }
1798  lm += 2;
1799  }
1800  }
1801  for (j = 0; j < DMAXY; j++) {
1802  for (i = 0; i < DMAXX; i++) {
1803  if (dungeon[i][j] == 0) {
1804  dungeon[i][j] = 8;
1805  }
1806  }
1807  }
1808 
1809  memcpy(pdungeon, dungeon, sizeof(pdungeon));
1810  mem_free_dbg(pLevelMap);
1811 }
1812 
1814 #endif
L3CREV6
const BYTE L3CREV6[6]
Definition: drlg_l3.cpp:39
DRLG_L3FillRoom
static BOOL DRLG_L3FillRoom(int x1, int y1, int x2, int y2)
Definition: drlg_l3.cpp:97
DRLG_L3River
static void DRLG_L3River()
Definition: drlg_l3.cpp:416
DRLG_InitTrans
void DRLG_InitTrans()
Definition: gendung.cpp:171
DRLG_L3PlaceRndSet
static void DRLG_L3PlaceRndSet(const BYTE *miniset, int rndper)
Definition: drlg_l3.cpp:936
Q_ANVIL
@ Q_ANVIL
Definition: enums.h:2558
setpc_w
int setpc_w
Definition: gendung.cpp:71
L3TITE2
const BYTE L3TITE2[34]
Definition: drlg_l3.cpp:24
L3UP
const BYTE L3UP[20]
Definition: drlg_l3.cpp:20
currlevel
BYTE currlevel
Definition: gendung.cpp:40
DRLG_L3Wood
static void DRLG_L3Wood()
Definition: drlg_l3.cpp:1158
setpc_h
int setpc_h
Definition: gendung.cpp:70
dminx
int dminx
Definition: gendung.cpp:77
QuestStatus
BOOL QuestStatus(int i)
Definition: quests.cpp:239
setpc_x
int setpc_x
Definition: gendung.cpp:72
SetRndSeed
void SetRndSeed(int s)
Set the RNG seed.
Definition: engine.cpp:728
L3CREV7
const BYTE L3CREV7[6]
Definition: drlg_l3.cpp:40
DoLighting
void DoLighting(int nXPos, int nYPos, int nRadius, int Lnum)
Definition: lighting.cpp:511
dungeon
BYTE dungeon[DMAXX][DMAXY]
Definition: gendung.cpp:18
L3TITE10
const BYTE L3TITE10[20]
Definition: drlg_l3.cpp:30
L3CREV9
const BYTE L3CREV9[6]
Definition: drlg_l3.cpp:42
DRLG_L3Pool
static void DRLG_L3Pool()
Flood fills dirt and wall tiles looking for an area of at most 40 tiles and disconnected from the map...
Definition: drlg_l3.cpp:778
pdungeon
BYTE pdungeon[DMAXX][DMAXY]
Definition: gendung.cpp:20
L3XTRA2
const BYTE L3XTRA2[4]
Definition: drlg_l3.cpp:51
dmaxx
int dmaxx
Definition: gendung.cpp:68
MAXDUNX
#define MAXDUNX
Definition: defs.h:25
WoodHorizL
static BOOL WoodHorizL(int x, int j)
Definition: drlg_l3.cpp:1038
DRLG_L3SpawnEdge
static BOOL DRLG_L3SpawnEdge(int x, int y, int *totarea)
Definition: drlg_l3.cpp:670
LoadPreL3Dungeon
void LoadPreL3Dungeon(char *sFileName, int vx, int vy)
Definition: drlg_l3.cpp:1776
pMegaTiles
BYTE * pMegaTiles
Definition: gendung.cpp:29
DRLG_L3Lockout
BOOL DRLG_L3Lockout()
Definition: drlg_l3.cpp:1475
ViewX
int ViewX
Definition: gendung.cpp:73
L3CREV5
const BYTE L3CREV5[6]
Definition: drlg_l3.cpp:38
DRLG_L3Spawn
static BOOL DRLG_L3Spawn(int x, int y, int *totarea)
Definition: drlg_l3.cpp:720
CreateL3Dungeon
void CreateL3Dungeon(DWORD rseed, int entry)
Definition: drlg_l3.cpp:1683
L3ISLE2
const BYTE L3ISLE2[14]
Definition: drlg_l3.cpp:46
L3ISLE3
const BYTE L3ISLE3[14]
Definition: drlg_l3.cpp:47
all.h
ViewY
int ViewY
Definition: gendung.cpp:74
L3CREV1
const BYTE L3CREV1[6]
Definition: drlg_l3.cpp:34
DRLG_PlaceThemeRooms
void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rndSize)
Definition: gendung.cpp:495
L3CREV11
const BYTE L3CREV11[6]
Definition: drlg_l3.cpp:44
DRLG_L3LockRec
void DRLG_L3LockRec(int x, int y)
Definition: drlg_l3.cpp:1461
L3TITE3
const BYTE L3TITE3[34]
Definition: drlg_l3.cpp:25
L3XTRA4
const BYTE L3XTRA4[4]
Definition: drlg_l3.cpp:53
L3ISLE1
const BYTE L3ISLE1[14]
Definition: drlg_l3.cpp:45
DRLG_L3PlaceMiniSet
static BOOL DRLG_L3PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir)
Definition: drlg_l3.cpp:855
lavapool
DEVILUTION_BEGIN_NAMESPACE BOOLEAN lavapool
Definition: drlg_l3.cpp:14
MAXDUNY
#define MAXDUNY
Definition: defs.h:26
L3TITE11
const BYTE L3TITE11[20]
Definition: drlg_l3.cpp:31
dPiece
int dPiece[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:26
DRLG_L3GetFloorArea
static int DRLG_L3GetFloorArea()
Definition: drlg_l3.cpp:369
DLRG_PROTECTED
@ DLRG_PROTECTED
Definition: enums.h:2929
L3XTRA1
const BYTE L3XTRA1[4]
Definition: drlg_l3.cpp:50
AddFenceDoors
void AddFenceDoors()
Definition: drlg_l3.cpp:1086
L3TITE7
const BYTE L3TITE7[42]
Definition: drlg_l3.cpp:27
WoodHorizR
static BOOL WoodHorizR(int x, int j)
Definition: drlg_l3.cpp:1065
WoodVertU
static BOOL WoodVertU(int i, int y)
Definition: drlg_l3.cpp:990
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
InitL3Dungeon
static void InitL3Dungeon()
Definition: drlg_l3.cpp:83
DRLG_L3FillStraights
static void DRLG_L3FillStraights()
Definition: drlg_l3.cpp:275
SetMapObjects
void SetMapObjects(BYTE *pMap, int startx, int starty)
Definition: objects.cpp:846
LoadFileInMem
BYTE * LoadFileInMem(char *pszName, DWORD *pdwFileLen)
Load a file in to a buffer.
Definition: engine.cpp:801
L3TITE6
const BYTE L3TITE6[42]
Definition: drlg_l3.cpp:26
SkipThemeRoom
BOOL SkipThemeRoom(int x, int y)
Definition: gendung.cpp:555
L3TITE1
const BYTE L3TITE1[34]
Definition: drlg_l3.cpp:23
L3ISLE5
const BYTE L3ISLE5[10]
Definition: drlg_l3.cpp:49
L3CREV3
const BYTE L3CREV3[6]
Definition: drlg_l3.cpp:36
L3TITE13
const BYTE L3TITE13[6]
Definition: drlg_l3.cpp:33
DRLG_L3MakeMegas
static void DRLG_L3MakeMegas()
Definition: drlg_l3.cpp:384
dmaxy
int dmaxy
Definition: gendung.cpp:69
DRLG_L3FillDiags
static void DRLG_L3FillDiags()
Definition: drlg_l3.cpp:234
DRLG_L3FloorArea
static void DRLG_L3FloorArea(int x1, int y1, int x2, int y2)
Definition: drlg_l3.cpp:223
FixL3Warp
void FixL3Warp()
Definition: drlg_l3.cpp:1414
L3TITE12
const BYTE L3TITE12[6]
Definition: drlg_l3.cpp:32
DRLG_L3Edges
static void DRLG_L3Edges()
Definition: drlg_l3.cpp:357
DRLG_SetPC
void DRLG_SetPC()
Definition: gendung.cpp:253
DMAXY
#define DMAXY
Definition: defs.h:8
LvlViewX
int LvlViewX
Definition: gendung.cpp:67
lockoutcnt
int lockoutcnt
Definition: drlg_l3.cpp:16
LvlViewY
int LvlViewY
Definition: gendung.cpp:66
SetMapMonsters
void SetMapMonsters(BYTE *pMap, int startx, int starty)
Definition: monster.cpp:1029
DRLG_L3CreateBlock
static void DRLG_L3CreateBlock(int x, int y, int obs, int dir)
Definition: drlg_l3.cpp:141
L3DOWN
const BYTE L3DOWN[20]
Definition: drlg_l3.cpp:21
L3ISLE4
const BYTE L3ISLE4[14]
Definition: drlg_l3.cpp:48
WoodVertD
static BOOL WoodVertD(int i, int y)
Definition: drlg_l3.cpp:1017
DRLG_L3Anvil
BOOL DRLG_L3Anvil()
Definition: drlg_l3.cpp:1353
DRLG_L3Pass3
static void DRLG_L3Pass3()
Definition: drlg_l3.cpp:1632
L3CREV8
const BYTE L3CREV8[6]
Definition: drlg_l3.cpp:41
dflags
char dflags[DMAXX][DMAXY]
Definition: gendung.cpp:25
FenceDoorFix
void FenceDoorFix()
Definition: drlg_l3.cpp:1110
random_
int random_(BYTE idx, int v)
Main RNG function.
Definition: engine.cpp:752
mem_free_dbg
void mem_free_dbg(void *p)
Multithreaded safe memfree.
Definition: engine.cpp:786
L3CREV10
const BYTE L3CREV10[6]
Definition: drlg_l3.cpp:43
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
L3CREV2
const BYTE L3CREV2[6]
Definition: drlg_l3.cpp:35
L3ANVIL
const BYTE L3ANVIL[244]
Definition: drlg_l3.cpp:55
L3TITE9
const BYTE L3TITE9[20]
Definition: drlg_l3.cpp:29
DRLG_L3FillSingles
static void DRLG_L3FillSingles()
Definition: drlg_l3.cpp:259
abyssx
int abyssx
Definition: drlg_l3.cpp:15
L3XTRA3
const BYTE L3XTRA3[4]
Definition: drlg_l3.cpp:52
DRLG_Init_Globals
void DRLG_Init_Globals()
Definition: drlg_l1.cpp:470
dminy
int dminy
Definition: gendung.cpp:78
DRLG_InitSetPC
void DRLG_InitSetPC()
Definition: gendung.cpp:245
LoadL3Dungeon
void LoadL3Dungeon(char *sFileName, int vx, int vy)
Definition: drlg_l3.cpp:1714
L3XTRA5
const BYTE L3XTRA5[4]
Definition: drlg_l3.cpp:54
FixL3HallofHeroes
void FixL3HallofHeroes()
Definition: drlg_l3.cpp:1434
L3HOLDWARP
const BYTE L3HOLDWARP[20]
Definition: drlg_l3.cpp:22
setpc_y
int setpc_y
Definition: gendung.cpp:75
lockout
BOOLEAN lockout[DMAXX][DMAXY]
Definition: drlg_l3.cpp:17
L3TITE8
const BYTE L3TITE8[20]
Definition: drlg_l3.cpp:28
L3CREV4
const BYTE L3CREV4[6]
Definition: drlg_l3.cpp:37
L3ConvTbl
const BYTE L3ConvTbl[16]
Definition: drlg_l3.cpp:19
DMAXX
#define DMAXX
Definition: defs.h:7
DRLG_L3
static void DRLG_L3(int entry)
Definition: drlg_l3.cpp:1499
DRLG_L3PoolFix
static void DRLG_L3PoolFix()
Definition: drlg_l3.cpp:833