Devilution
Diablo devolved - magic behind the 1996 computer game
drlg_l1.cpp
Go to the documentation of this file.
1 
6 #include "all.h"
7 
9 
10 BYTE L5dungeon[80][80];
13 int HR1;
14 int HR2;
15 int HR3;
16 int VR1;
17 int VR2;
18 int VR3;
20 
21 const ShadowStruct SPATS[37] = {
22  // clang-format off
23  // strig, s1, s2, s3, nv1, nv2, nv3
24  { 7, 13, 0, 13, 144, 0, 142 },
25  { 16, 13, 0, 13, 144, 0, 142 },
26  { 15, 13, 0, 13, 145, 0, 142 },
27  { 5, 13, 13, 13, 152, 140, 139 },
28  { 5, 13, 1, 13, 143, 146, 139 },
29  { 5, 13, 13, 2, 143, 140, 148 },
30  { 5, 0, 1, 2, 0, 146, 148 },
31  { 5, 13, 11, 13, 143, 147, 139 },
32  { 5, 13, 13, 12, 143, 140, 149 },
33  { 5, 13, 11, 12, 150, 147, 149 },
34  { 5, 13, 1, 12, 143, 146, 149 },
35  { 5, 13, 11, 2, 143, 147, 148 },
36  { 9, 13, 13, 13, 144, 140, 142 },
37  { 9, 13, 1, 13, 144, 146, 142 },
38  { 9, 13, 11, 13, 151, 147, 142 },
39  { 8, 13, 0, 13, 144, 0, 139 },
40  { 8, 13, 0, 12, 143, 0, 149 },
41  { 8, 0, 0, 2, 0, 0, 148 },
42  { 11, 0, 0, 13, 0, 0, 139 },
43  { 11, 13, 0, 13, 139, 0, 139 },
44  { 11, 2, 0, 13, 148, 0, 139 },
45  { 11, 12, 0, 13, 149, 0, 139 },
46  { 11, 13, 11, 12, 139, 0, 149 },
47  { 14, 0, 0, 13, 0, 0, 139 },
48  { 14, 13, 0, 13, 139, 0, 139 },
49  { 14, 2, 0, 13, 148, 0, 139 },
50  { 14, 12, 0, 13, 149, 0, 139 },
51  { 14, 13, 11, 12, 139, 0, 149 },
52  { 10, 0, 13, 0, 0, 140, 0 },
53  { 10, 13, 13, 0, 140, 140, 0 },
54  { 10, 0, 1, 0, 0, 146, 0 },
55  { 10, 13, 11, 0, 140, 147, 0 },
56  { 12, 0, 13, 0, 0, 140, 0 },
57  { 12, 13, 13, 0, 140, 140, 0 },
58  { 12, 0, 1, 0, 0, 146, 0 },
59  { 12, 13, 11, 0, 140, 147, 0 },
60  { 3, 13, 11, 12, 150, 0, 0 }
61  // clang-format on
62 };
63 
64 // BUGFIX: This array should contain an additional 0 (207 elements).
65 const BYTE BSTYPES[] = {
66  0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
67  10, 11, 12, 13, 14, 15, 16, 17, 0, 0,
68  0, 0, 0, 0, 0, 1, 2, 10, 4, 5,
69  6, 7, 8, 9, 10, 11, 12, 14, 5, 14,
70  10, 4, 14, 4, 5, 0, 0, 0, 0, 0,
71  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
72  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
73  0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
74  2, 3, 4, 1, 6, 7, 16, 17, 2, 1,
75  1, 2, 2, 1, 1, 2, 2, 2, 2, 2,
76  1, 1, 11, 1, 13, 13, 13, 1, 2, 1,
77  2, 1, 2, 1, 2, 2, 2, 2, 12, 0,
78  0, 11, 1, 11, 1, 13, 0, 0, 0, 0,
79  0, 0, 0, 13, 13, 13, 13, 13, 13, 13,
80  13, 13, 13, 13, 13, 13, 1, 11, 2, 12,
81  13, 13, 13, 12, 2, 1, 2, 2, 4, 14,
82  4, 10, 13, 13, 4, 4, 1, 1, 4, 2,
83  2, 13, 13, 13, 13, 25, 26, 28, 30, 31,
84  41, 43, 40, 41, 42, 43, 25, 41, 43, 28,
85  28, 1, 2, 25, 26, 22, 22, 25, 26, 0,
86  0, 0, 0, 0, 0, 0, 0
87 };
88 
89 // BUGFIX: This array should contain an additional 0 (207 elements).
90 const BYTE L5BTYPES[] = {
91  0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
92  10, 11, 12, 13, 14, 15, 16, 17, 0, 0,
93  0, 0, 0, 0, 0, 25, 26, 0, 28, 0,
94  30, 31, 0, 0, 0, 0, 0, 0, 0, 0,
95  40, 41, 42, 43, 0, 0, 0, 0, 0, 0,
96  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98  0, 0, 0, 0, 0, 0, 0, 0, 0, 79,
99  80, 0, 82, 0, 0, 0, 0, 0, 0, 79,
100  0, 80, 0, 0, 79, 80, 0, 2, 2, 2,
101  1, 1, 11, 25, 13, 13, 13, 1, 2, 1,
102  2, 1, 2, 1, 2, 2, 2, 2, 12, 0,
103  0, 11, 1, 11, 1, 13, 0, 0, 0, 0,
104  0, 0, 0, 13, 13, 13, 13, 13, 13, 0,
105  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
106  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
107  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
108  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
109  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
110  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
111  0, 0, 0, 0, 0, 0, 0
112 };
113 const BYTE STAIRSUP[] = { 4, 4, 13, 13, 13, 13, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 6, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 };
114 const BYTE L5STAIRSUP[] = { 4, 4, 22, 22, 22, 22, 2, 2, 2, 2, 13, 13, 13, 13, 13, 13, 13, 13, 0, 66, 23, 0, 63, 64, 65, 0, 0, 67, 68, 0, 0, 0, 0, 0 };
115 const BYTE STAIRSDOWN[] = { 4, 3, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 62, 57, 58, 0, 61, 59, 60, 0, 0, 0, 0, 0 };
116 const BYTE LAMPS[] = { 2, 2, 13, 0, 13, 13, 129, 0, 130, 128 };
117 const BYTE PWATERIN[] = { 6, 6, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 0, 0, 0, 0, 0, 0, 0, 202, 200, 200, 84, 0, 0, 199, 203, 203, 83, 0, 0, 85, 206, 80, 81, 0, 0, 0, 134, 135, 0, 0, 0, 0, 0, 0, 0, 0 };
118 
119 /* data */
120 BYTE L5ConvTbl[16] = { 22, 13, 1, 13, 2, 13, 13, 13, 4, 13, 1, 13, 2, 13, 16, 13 };
121 
122 static void DRLG_PlaceDoor(int x, int y)
123 {
124  if ((L5dflags[x][y] & DLRG_PROTECTED) == 0) {
125  BYTE df = L5dflags[x][y] & 0x7F;
126  BYTE c = dungeon[x][y];
127 
128  if (df == 1) {
129  if (y != 1 && c == 2)
130  dungeon[x][y] = 26;
131  if (y != 1 && c == 7)
132  dungeon[x][y] = 31;
133  if (y != 1 && c == 14)
134  dungeon[x][y] = 42;
135  if (y != 1 && c == 4)
136  dungeon[x][y] = 43;
137  if (x != 1 && c == 1)
138  dungeon[x][y] = 25;
139  if (x != 1 && c == 10)
140  dungeon[x][y] = 40;
141  if (x != 1 && c == 6)
142  dungeon[x][y] = 30;
143  }
144  if (df == 2) {
145  if (x != 1 && c == 1)
146  dungeon[x][y] = 25;
147  if (x != 1 && c == 6)
148  dungeon[x][y] = 30;
149  if (x != 1 && c == 10)
150  dungeon[x][y] = 40;
151  if (x != 1 && c == 4)
152  dungeon[x][y] = 41;
153  if (y != 1 && c == 2)
154  dungeon[x][y] = 26;
155  if (y != 1 && c == 14)
156  dungeon[x][y] = 42;
157  if (y != 1 && c == 7)
158  dungeon[x][y] = 31;
159  }
160  if (df == 3) {
161  if (x != 1 && y != 1 && c == 4)
162  dungeon[x][y] = 28;
163  if (x != 1 && c == 10)
164  dungeon[x][y] = 40;
165  if (y != 1 && c == 14)
166  dungeon[x][y] = 42;
167  if (y != 1 && c == 2)
168  dungeon[x][y] = 26;
169  if (x != 1 && c == 1)
170  dungeon[x][y] = 25;
171  if (y != 1 && c == 7)
172  dungeon[x][y] = 31;
173  if (x != 1 && c == 6)
174  dungeon[x][y] = 30;
175  }
176  }
177 
178  L5dflags[x][y] = DLRG_PROTECTED;
179 }
180 
181 static void DRLG_L1Shadows()
182 {
183  int x, y, i;
184  BYTE sd[2][2];
185  BYTE tnv3;
186  BOOL patflag;
187 
188  for (y = 1; y < DMAXY; y++) {
189  for (x = 1; x < DMAXX; x++) {
190  sd[0][0] = BSTYPES[dungeon[x][y]];
191  sd[1][0] = BSTYPES[dungeon[x - 1][y]];
192  sd[0][1] = BSTYPES[dungeon[x][y - 1]];
193  sd[1][1] = BSTYPES[dungeon[x - 1][y - 1]];
194 
195  for (i = 0; i < 37; i++) {
196  if (SPATS[i].strig == sd[0][0]) {
197  patflag = TRUE;
198  if (SPATS[i].s1 && SPATS[i].s1 != sd[1][1])
199  patflag = FALSE;
200  if (SPATS[i].s2 && SPATS[i].s2 != sd[0][1])
201  patflag = FALSE;
202  if (SPATS[i].s3 && SPATS[i].s3 != sd[1][0])
203  patflag = FALSE;
204  if (patflag == TRUE) {
205  if (SPATS[i].nv1 && !L5dflags[x - 1][y - 1])
206  dungeon[x - 1][y - 1] = SPATS[i].nv1;
207  if (SPATS[i].nv2 && !L5dflags[x][y - 1])
208  dungeon[x][y - 1] = SPATS[i].nv2;
209  if (SPATS[i].nv3 && !L5dflags[x - 1][y])
210  dungeon[x - 1][y] = SPATS[i].nv3;
211  }
212  }
213  }
214  }
215  }
216 
217  for (y = 1; y < DMAXY; y++) {
218  for (x = 1; x < DMAXX; x++) {
219  if (dungeon[x - 1][y] == 139 && !L5dflags[x - 1][y]) {
220  tnv3 = 139;
221  if (dungeon[x][y] == 29)
222  tnv3 = 141;
223  if (dungeon[x][y] == 32)
224  tnv3 = 141;
225  if (dungeon[x][y] == 35)
226  tnv3 = 141;
227  if (dungeon[x][y] == 37)
228  tnv3 = 141;
229  if (dungeon[x][y] == 38)
230  tnv3 = 141;
231  if (dungeon[x][y] == 39)
232  tnv3 = 141;
233  dungeon[x - 1][y] = tnv3;
234  }
235  if (dungeon[x - 1][y] == 149 && !L5dflags[x - 1][y]) {
236  tnv3 = 149;
237  if (dungeon[x][y] == 29)
238  tnv3 = 153;
239  if (dungeon[x][y] == 32)
240  tnv3 = 153;
241  if (dungeon[x][y] == 35)
242  tnv3 = 153;
243  if (dungeon[x][y] == 37)
244  tnv3 = 153;
245  if (dungeon[x][y] == 38)
246  tnv3 = 153;
247  if (dungeon[x][y] == 39)
248  tnv3 = 153;
249  dungeon[x - 1][y] = tnv3;
250  }
251  if (dungeon[x - 1][y] == 148 && !L5dflags[x - 1][y]) {
252  tnv3 = 148;
253  if (dungeon[x][y] == 29)
254  tnv3 = 154;
255  if (dungeon[x][y] == 32)
256  tnv3 = 154;
257  if (dungeon[x][y] == 35)
258  tnv3 = 154;
259  if (dungeon[x][y] == 37)
260  tnv3 = 154;
261  if (dungeon[x][y] == 38)
262  tnv3 = 154;
263  if (dungeon[x][y] == 39)
264  tnv3 = 154;
265  dungeon[x - 1][y] = tnv3;
266  }
267  }
268  }
269 }
270 
271 static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int noquad, int ldir)
272 {
273  int sx, sy, sw, sh, xx, yy, i, ii, numt, found, t;
274  BOOL abort;
275 
276  sw = miniset[0];
277  sh = miniset[1];
278 
279  if (tmax - tmin == 0)
280  numt = 1;
281  else
282  numt = random_(0, tmax - tmin) + tmin;
283 
284  for (i = 0; i < numt; i++) {
285  sx = random_(0, DMAXX - sw);
286  sy = random_(0, DMAXY - sh);
287  abort = FALSE;
288  found = 0;
289 
290  while (abort == FALSE) {
291  abort = TRUE;
292  if (cx != -1 && sx >= cx - sw && sx <= cx + 12) {
293  sx++;
294  abort = FALSE;
295  }
296  if (cy != -1 && sy >= cy - sh && sy <= cy + 12) {
297  sy++;
298  abort = FALSE;
299  }
300 
301  switch (noquad) {
302  case 0:
303  if (sx < cx && sy < cy)
304  abort = FALSE;
305  break;
306  case 1:
307  if (sx > cx && sy < cy)
308  abort = FALSE;
309  break;
310  case 2:
311  if (sx < cx && sy > cy)
312  abort = FALSE;
313  break;
314  case 3:
315  if (sx > cx && sy > cy)
316  abort = FALSE;
317  break;
318  }
319 
320  ii = 2;
321 
322  for (yy = 0; yy < sh && abort == TRUE; yy++) {
323  for (xx = 0; xx < sw && abort == TRUE; xx++) {
324  if (miniset[ii] && dungeon[xx + sx][sy + yy] != miniset[ii])
325  abort = FALSE;
326  if (L5dflags[xx + sx][sy + yy])
327  abort = FALSE;
328  ii++;
329  }
330  }
331 
332  if (abort == FALSE) {
333  if (++sx == DMAXX - sw) {
334  sx = 0;
335  if (++sy == DMAXY - sh)
336  sy = 0;
337  }
338  if (++found > 4000)
339  return -1;
340  }
341  }
342 
343  ii = sw * sh + 2;
344 
345  for (yy = 0; yy < sh; yy++) {
346  for (xx = 0; xx < sw; xx++) {
347  if (miniset[ii])
348  dungeon[xx + sx][sy + yy] = miniset[ii];
349  ii++;
350  }
351  }
352  }
353 
354  if (miniset == PWATERIN) {
355  t = TransVal;
356  TransVal = 0;
357  DRLG_MRectTrans(sx, sy + 2, sx + 5, sy + 4);
358  TransVal = t;
359 
360  quests[Q_PWATER]._qtx = 2 * sx + 21;
361  quests[Q_PWATER]._qty = 2 * sy + 22;
362  }
363 
364  if (setview == TRUE) {
365  ViewX = 2 * sx + 19;
366  ViewY = 2 * sy + 20;
367  }
368 
369  if (ldir == 0) {
370  LvlViewX = 2 * sx + 19;
371  LvlViewY = 2 * sy + 20;
372  }
373 
374  if (sx < cx && sy < cy)
375  return 0;
376  if (sx > cx && sy < cy)
377  return 1;
378  if (sx < cx && sy > cy)
379  return 2;
380  else
381  return 3;
382 }
383 
384 static void DRLG_L1Floor()
385 {
386  int i, j;
387  LONG rv;
388 
389  for (j = 0; j < DMAXY; j++) {
390  for (i = 0; i < DMAXX; i++) {
391  if (L5dflags[i][j] == 0 && dungeon[i][j] == 13) {
392  rv = random_(0, 3);
393 
394  if (rv == 1)
395  dungeon[i][j] = 162;
396  if (rv == 2)
397  dungeon[i][j] = 163;
398  }
399  }
400  }
401 }
402 
403 static void DRLG_L1Pass3()
404 {
405  int i, j, xx, yy;
406  long v1, v2, v3, v4, lv;
407  WORD *MegaTiles;
408 
409  lv = 22 - 1;
410 
411  MegaTiles = (WORD *)&pMegaTiles[lv * 8];
412  v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
413  v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
414  v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
415  v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
416 
417  for (j = 0; j < MAXDUNY; j += 2)
418  {
419  for (i = 0; i < MAXDUNX; i += 2) {
420  dPiece[i][j] = v1;
421  dPiece[i + 1][j] = v2;
422  dPiece[i][j + 1] = v3;
423  dPiece[i + 1][j + 1] = v4;
424  }
425  }
426 
427  yy = 16;
428  for (j = 0; j < DMAXY; j++) {
429  xx = 16;
430  for (i = 0; i < DMAXX; i++) {
431  lv = dungeon[i][j] - 1;
433  MegaTiles = (WORD *)&pMegaTiles[lv * 8];
434  v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
435  v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
436  v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
437  v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
438  dPiece[xx][yy] = v1;
439  dPiece[xx + 1][yy] = v2;
440  dPiece[xx][yy + 1] = v3;
441  dPiece[xx + 1][yy + 1] = v4;
442  xx += 2;
443  }
444  yy += 2;
445  }
446 }
447 
448 static void DRLG_LoadL1SP()
449 {
450  L5setloadflag = FALSE;
451  if (QuestStatus(Q_BUTCHER)) {
452  L5pSetPiece = LoadFileInMem("Levels\\L1Data\\rnd6.DUN", NULL);
453  L5setloadflag = TRUE;
454  }
455  if (QuestStatus(Q_SKELKING) && gbMaxPlayers == 1) {
456  L5pSetPiece = LoadFileInMem("Levels\\L1Data\\SKngDO.DUN", NULL);
457  L5setloadflag = TRUE;
458  }
459  if (QuestStatus(Q_LTBANNER)) {
460  L5pSetPiece = LoadFileInMem("Levels\\L1Data\\Banner2.DUN", NULL);
461  L5setloadflag = TRUE;
462  }
463 }
464 
465 static void DRLG_FreeL1SP()
466 {
468 }
469 
471 {
472  char c;
473 
474  memset(dFlags, 0, sizeof(dFlags));
475  memset(dPlayer, 0, sizeof(dPlayer));
476  memset(dMonster, 0, sizeof(dMonster));
477  memset(dDead, 0, sizeof(dDead));
478  memset(dObject, 0, sizeof(dObject));
479  memset(dItem, 0, sizeof(dItem));
480  memset(dMissile, 0, sizeof(dMissile));
481  memset(dSpecial, 0, sizeof(dSpecial));
482  if (!lightflag) {
483  if (light4flag)
484  c = 3;
485  else
486  c = 15;
487  } else {
488  c = 0;
489  }
490  memset(dLight, c, sizeof(dLight));
491 }
492 
493 static void DRLG_InitL1Vals()
494 {
495  int i, j, pc;
496 
497  for (j = 0; j < MAXDUNY; j++) {
498  for (i = 0; i < MAXDUNX; i++) {
499  if (dPiece[i][j] == 12) {
500  pc = 1;
501  } else if (dPiece[i][j] == 11) {
502  pc = 2;
503  } else if (dPiece[i][j] == 71) {
504  pc = 1;
505  } else if (dPiece[i][j] == 259) {
506  pc = 5;
507  } else if (dPiece[i][j] == 249) {
508  pc = 2;
509  } else if (dPiece[i][j] == 325) {
510  pc = 2;
511  } else if (dPiece[i][j] == 321) {
512  pc = 1;
513  } else if (dPiece[i][j] == 255) {
514  pc = 4;
515  } else if (dPiece[i][j] == 211) {
516  pc = 1;
517  } else if (dPiece[i][j] == 344) {
518  pc = 2;
519  } else if (dPiece[i][j] == 341) {
520  pc = 1;
521  } else if (dPiece[i][j] == 331) {
522  pc = 2;
523  } else if (dPiece[i][j] == 418) {
524  pc = 1;
525  } else if (dPiece[i][j] == 421) {
526  pc = 2;
527  } else {
528  continue;
529  }
530  dSpecial[i][j] = pc;
531  }
532  }
533 }
534 
535 #ifndef SPAWN
536 void LoadL1Dungeon(char *sFileName, int vx, int vy)
537 {
538  int i, j, rw, rh;
539  BYTE *pLevelMap, *lm;
540 
541  dminx = 16;
542  dminy = 16;
543  dmaxx = 96;
544  dmaxy = 96;
545 
546  DRLG_InitTrans();
547  pLevelMap = LoadFileInMem(sFileName, NULL);
548 
549  for (j = 0; j < DMAXY; j++) {
550  for (i = 0; i < DMAXX; i++) {
551  dungeon[i][j] = 22;
552  L5dflags[i][j] = 0;
553  }
554  }
555 
556  lm = pLevelMap;
557  rw = *lm;
558  lm += 2;
559  rh = *lm;
560  lm += 2;
561 
562  for (j = 0; j < rh; j++) {
563  for (i = 0; i < rw; i++) {
564  if (*lm != 0) {
565  dungeon[i][j] = *lm;
566  L5dflags[i][j] |= DLRG_PROTECTED;
567  } else {
568  dungeon[i][j] = 13;
569  }
570  lm += 2;
571  }
572  }
573 
574  DRLG_L1Floor();
575  ViewX = vx;
576  ViewY = vy;
577  DRLG_L1Pass3();
579  DRLG_InitL1Vals();
580  SetMapMonsters(pLevelMap, 0, 0);
581  SetMapObjects(pLevelMap, 0, 0);
582  mem_free_dbg(pLevelMap);
583 }
584 
585 void LoadPreL1Dungeon(char *sFileName, int vx, int vy)
586 {
587  int i, j, rw, rh;
588  BYTE *pLevelMap, *lm;
589 
590  dminx = 16;
591  dminy = 16;
592  dmaxx = 96;
593  dmaxy = 96;
594 
595  pLevelMap = LoadFileInMem(sFileName, NULL);
596 
597  for (j = 0; j < DMAXY; j++) {
598  for (i = 0; i < DMAXX; i++) {
599  dungeon[i][j] = 22;
600  L5dflags[i][j] = 0;
601  }
602  }
603 
604  lm = pLevelMap;
605  rw = *lm;
606  lm += 2;
607  rh = *lm;
608  lm += 2;
609 
610  for (j = 0; j < rh; j++) {
611  for (i = 0; i < rw; i++) {
612  if (*lm != 0) {
613  dungeon[i][j] = *lm;
614  L5dflags[i][j] |= DLRG_PROTECTED;
615  } else {
616  dungeon[i][j] = 13;
617  }
618  lm += 2;
619  }
620  }
621 
622  DRLG_L1Floor();
623 
624  for (j = 0; j < DMAXY; j++) {
625  for (i = 0; i < DMAXX; i++) {
626  pdungeon[i][j] = dungeon[i][j];
627  }
628  }
629 
630  mem_free_dbg(pLevelMap);
631 }
632 #endif
633 
634 static void InitL5Dungeon()
635 {
636  int i, j;
637 
638  for (j = 0; j < DMAXY; j++) {
639  for (i = 0; i < DMAXX; i++) {
640  dungeon[i][j] = 0;
641  L5dflags[i][j] = 0;
642  }
643  }
644 }
645 
646 static void L5ClearFlags()
647 {
648  int i, j;
649 
650  for (j = 0; j < DMAXY; j++) {
651  for (i = 0; i < DMAXX; i++) {
652  L5dflags[i][j] &= 0xBF;
653  }
654  }
655 }
656 
657 static void L5drawRoom(int x, int y, int w, int h)
658 {
659  int i, j;
660 
661  for (j = 0; j < h; j++) {
662  for (i = 0; i < w; i++) {
663  dungeon[x + i][y + j] = 1;
664  }
665  }
666 }
667 
668 static BOOL L5checkRoom(int x, int y, int width, int height)
669 {
670  int i, j;
671 
672  for (j = 0; j < height; j++) {
673  for (i = 0; i < width; i++) {
674  if (i + x < 0 || i + x >= DMAXX || j + y < 0 || j + y >= DMAXY)
675  return FALSE;
676  if (dungeon[i + x][j + y])
677  return FALSE;
678  }
679  }
680 
681  return TRUE;
682 }
683 
684 static void L5roomGen(int x, int y, int w, int h, int dir)
685 {
686  int num, dirProb;
687  BOOL ran, ran2;
688  int width, height, rx, ry, ry2;
689  int cw, ch, cx1, cy1, cx2;
690 
691  dirProb = random_(0, 4);
692 
693  switch (dir == 1 ? dirProb != 0 : dirProb == 0) {
694  case FALSE:
695  num = 0;
696  do {
697  cw = (random_(0, 5) + 2) & 0xFFFFFFFE;
698  ch = (random_(0, 5) + 2) & 0xFFFFFFFE;
699  cy1 = h / 2 + y - ch / 2;
700  cx1 = x - cw;
701  ran = L5checkRoom(cx1 - 1, cy1 - 1, ch + 2, cw + 1);
702  num++;
703  } while (ran == FALSE && num < 20);
704 
705  if (ran == TRUE)
706  L5drawRoom(cx1, cy1, cw, ch);
707  cx2 = x + w;
708  ran2 = L5checkRoom(cx2, cy1 - 1, cw + 1, ch + 2);
709  if (ran2 == TRUE)
710  L5drawRoom(cx2, cy1, cw, ch);
711  if (ran == TRUE)
712  L5roomGen(cx1, cy1, cw, ch, 1);
713  if (ran2 == TRUE)
714  L5roomGen(cx2, cy1, cw, ch, 1);
715  break;
716  case TRUE:
717  num = 0;
718  do {
719  width = (random_(0, 5) + 2) & 0xFFFFFFFE;
720  height = (random_(0, 5) + 2) & 0xFFFFFFFE;
721  rx = w / 2 + x - width / 2;
722  ry = y - height;
723  ran = L5checkRoom(rx - 1, ry - 1, width + 2, height + 1);
724  num++;
725  } while (ran == FALSE && num < 20);
726 
727  if (ran == TRUE)
728  L5drawRoom(rx, ry, width, height);
729  ry2 = y + h;
730  ran2 = L5checkRoom(rx - 1, ry2, width + 2, height + 1);
731  if (ran2 == TRUE)
732  L5drawRoom(rx, ry2, width, height);
733  if (ran == TRUE)
734  L5roomGen(rx, ry, width, height, 0);
735  if (ran2 == TRUE)
736  L5roomGen(rx, ry2, width, height, 0);
737  break;
738  }
739 }
740 
741 static void L5firstRoom()
742 {
743  int ys, ye, y;
744  int xs, xe, x;
745 
746  if (random_(0, 2) == 0) {
747  ys = 1;
748  ye = DMAXY - 1;
749 
750  VR1 = random_(0, 2);
751  VR2 = random_(0, 2);
752  VR3 = random_(0, 2);
753 
754  if (VR1 + VR3 <= 1)
755  VR2 = 1;
756  if (VR1)
757  L5drawRoom(15, 1, 10, 10);
758  else
759  ys = 18;
760 
761  if (VR2)
762  L5drawRoom(15, 15, 10, 10);
763  if (VR3)
764  L5drawRoom(15, 29, 10, 10);
765  else
766  ye = 22;
767 
768  for (y = ys; y < ye; y++) {
769  dungeon[17][y] = 1;
770  dungeon[18][y] = 1;
771  dungeon[19][y] = 1;
772  dungeon[20][y] = 1;
773  dungeon[21][y] = 1;
774  dungeon[22][y] = 1;
775  }
776 
777  if (VR1)
778  L5roomGen(15, 1, 10, 10, 0);
779  if (VR2)
780  L5roomGen(15, 15, 10, 10, 0);
781  if (VR3)
782  L5roomGen(15, 29, 10, 10, 0);
783 
784  HR3 = 0;
785  HR2 = 0;
786  HR1 = 0;
787  } else {
788  xs = 1;
789  xe = DMAXX - 1;
790 
791  HR1 = random_(0, 2);
792  HR2 = random_(0, 2);
793  HR3 = random_(0, 2);
794 
795  if (HR1 + HR3 <= 1)
796  HR2 = 1;
797  if (HR1)
798  L5drawRoom(1, 15, 10, 10);
799  else
800  xs = 18;
801 
802  if (HR2)
803  L5drawRoom(15, 15, 10, 10);
804  if (HR3)
805  L5drawRoom(29, 15, 10, 10);
806  else
807  xe = 22;
808 
809  for (x = xs; x < xe; x++) {
810  dungeon[x][17] = 1;
811  dungeon[x][18] = 1;
812  dungeon[x][19] = 1;
813  dungeon[x][20] = 1;
814  dungeon[x][21] = 1;
815  dungeon[x][22] = 1;
816  }
817 
818  if (HR1)
819  L5roomGen(1, 15, 10, 10, 1);
820  if (HR2)
821  L5roomGen(15, 15, 10, 10, 1);
822  if (HR3)
823  L5roomGen(29, 15, 10, 10, 1);
824 
825  VR3 = 0;
826  VR2 = 0;
827  VR1 = 0;
828  }
829 }
830 
831 static int L5GetArea()
832 {
833  int i, j;
834  int rv;
835 
836  rv = 0;
837 
838  for (j = 0; j < DMAXY; j++) {
839  for (i = 0; i < DMAXX; i++) {
840  if (dungeon[i][j] == 1)
841  rv++;
842  }
843  }
844 
845  return rv;
846 }
847 
848 static void L5makeDungeon()
849 {
850  int i, j;
851  int i_2, j_2;
852 
853  for (j = 0; j < DMAXY; j++) {
854  for (i = 0; i < DMAXX; i++) {
855  j_2 = j << 1;
856  i_2 = i << 1;
857  L5dungeon[i_2][j_2] = dungeon[i][j];
858  L5dungeon[i_2][j_2 + 1] = dungeon[i][j];
859  L5dungeon[i_2 + 1][j_2] = dungeon[i][j];
860  L5dungeon[i_2 + 1][j_2 + 1] = dungeon[i][j];
861  }
862  }
863 }
864 
865 static void L5makeDmt()
866 {
867  int i, j, idx, val, dmtx, dmty;
868 
869  for (j = 0; j < DMAXY; j++) {
870  for (i = 0; i < DMAXX; i++) {
871  dungeon[i][j] = 22;
872  }
873  }
874 
875  for (j = 0, dmty = 1; dmty <= 77; j++, dmty += 2) {
876  for (i = 0, dmtx = 1; dmtx <= 77; i++, dmtx += 2) {
877  val = 8 * L5dungeon[dmtx + 1][dmty + 1]
878  + 4 * L5dungeon[dmtx][dmty + 1]
879  + 2 * L5dungeon[dmtx + 1][dmty]
880  + L5dungeon[dmtx][dmty];
881  idx = L5ConvTbl[val];
882  dungeon[i][j] = idx;
883  }
884  }
885 }
886 
887 static int L5HWallOk(int i, int j)
888 {
889  int x;
890  BOOL wallok;
891 
892  for (x = 1; dungeon[i + x][j] == 13; x++) {
893  if (dungeon[i + x][j - 1] != 13 || dungeon[i + x][j + 1] != 13 || L5dflags[i + x][j])
894  break;
895  }
896 
897  wallok = FALSE;
898  if (dungeon[i + x][j] >= 3 && dungeon[i + x][j] <= 7)
899  wallok = TRUE;
900  if (dungeon[i + x][j] >= 16 && dungeon[i + x][j] <= 24)
901  wallok = TRUE;
902  if (dungeon[i + x][j] == 22)
903  wallok = FALSE;
904  if (x == 1)
905  wallok = FALSE;
906 
907  if (wallok)
908  return x;
909  else
910  return -1;
911 }
912 
913 static int L5VWallOk(int i, int j)
914 {
915  int y;
916  BOOL wallok;
917 
918  for (y = 1; dungeon[i][j + y] == 13; y++) {
919  if (dungeon[i - 1][j + y] != 13 || dungeon[i + 1][j + y] != 13 || L5dflags[i][j + y])
920  break;
921  }
922 
923  wallok = FALSE;
924  if (dungeon[i][j + y] >= 3 && dungeon[i][j + y] <= 7)
925  wallok = TRUE;
926  if (dungeon[i][j + y] >= 16 && dungeon[i][j + y] <= 24)
927  wallok = TRUE;
928  if (dungeon[i][j + y] == 22)
929  wallok = FALSE;
930  if (y == 1)
931  wallok = FALSE;
932 
933  if (wallok)
934  return y;
935  else
936  return -1;
937 }
938 
939 static void L5HorizWall(int i, int j, char p, int dx)
940 {
941  int xx;
942  char wt, dt;
943 
944  switch (random_(0, 4)) {
945  case 0:
946  case 1:
947  dt = 2;
948  break;
949  case 2:
950  dt = 12;
951  if (p == 2)
952  p = 12;
953  if (p == 4)
954  p = 10;
955  break;
956  case 3:
957  dt = 36;
958  if (p == 2)
959  p = 36;
960  if (p == 4)
961  p = 27;
962  break;
963  }
964 
965  if (random_(0, 6) == 5)
966  wt = 12;
967  else
968  wt = 26;
969  if (dt == 12)
970  wt = 12;
971 
972  dungeon[i][j] = p;
973 
974  for (xx = 1; xx < dx; xx++) {
975  dungeon[i + xx][j] = dt;
976  }
977 
978  xx = random_(0, dx - 1) + 1;
979 
980  if (wt == 12) {
981  dungeon[i + xx][j] = wt;
982  } else {
983  dungeon[i + xx][j] = 2;
984  L5dflags[i + xx][j] |= DLRG_HDOOR;
985  }
986 }
987 
988 static void L5VertWall(int i, int j, char p, int dy)
989 {
990  int yy;
991  char wt, dt;
992 
993  switch (random_(0, 4)) {
994  case 0:
995  case 1:
996  dt = 1;
997  break;
998  case 2:
999  dt = 11;
1000  if (p == 1)
1001  p = 11;
1002  if (p == 4)
1003  p = 14;
1004  break;
1005  case 3:
1006  dt = 35;
1007  if (p == 1)
1008  p = 35;
1009  if (p == 4)
1010  p = 37;
1011  break;
1012  }
1013 
1014  if (random_(0, 6) == 5)
1015  wt = 11;
1016  else
1017  wt = 25;
1018  if (dt == 11)
1019  wt = 11;
1020 
1021  dungeon[i][j] = p;
1022 
1023  for (yy = 1; yy < dy; yy++) {
1024  dungeon[i][j + yy] = dt;
1025  }
1026 
1027  yy = random_(0, dy - 1) + 1;
1028 
1029  if (wt == 11) {
1030  dungeon[i][j + yy] = wt;
1031  } else {
1032  dungeon[i][j + yy] = 1;
1033  L5dflags[i][j + yy] |= DLRG_VDOOR;
1034  }
1035 }
1036 
1037 static void L5AddWall()
1038 {
1039  int i, j, x, y;
1040 
1041  for (j = 0; j < DMAXY; j++) {
1042  for (i = 0; i < DMAXX; i++) {
1043  if (!L5dflags[i][j]) {
1044  if (dungeon[i][j] == 3 && random_(0, 100) < 100) {
1045  x = L5HWallOk(i, j);
1046  if (x != -1)
1047  L5HorizWall(i, j, 2, x);
1048  }
1049  if (dungeon[i][j] == 3 && random_(0, 100) < 100) {
1050  y = L5VWallOk(i, j);
1051  if (y != -1)
1052  L5VertWall(i, j, 1, y);
1053  }
1054  if (dungeon[i][j] == 6 && random_(0, 100) < 100) {
1055  x = L5HWallOk(i, j);
1056  if (x != -1)
1057  L5HorizWall(i, j, 4, x);
1058  }
1059  if (dungeon[i][j] == 7 && random_(0, 100) < 100) {
1060  y = L5VWallOk(i, j);
1061  if (y != -1)
1062  L5VertWall(i, j, 4, y);
1063  }
1064  if (dungeon[i][j] == 2 && random_(0, 100) < 100) {
1065  x = L5HWallOk(i, j);
1066  if (x != -1)
1067  L5HorizWall(i, j, 2, x);
1068  }
1069  if (dungeon[i][j] == 1 && random_(0, 100) < 100) {
1070  y = L5VWallOk(i, j);
1071  if (y != -1)
1072  L5VertWall(i, j, 1, y);
1073  }
1074  }
1075  }
1076  }
1077 }
1078 
1079 static void DRLG_L5GChamber(int sx, int sy, BOOL topflag, BOOL bottomflag, BOOL leftflag, BOOL rightflag)
1080 {
1081  int i, j;
1082 
1083  if (topflag == TRUE) {
1084  dungeon[sx + 2][sy] = 12;
1085  dungeon[sx + 3][sy] = 12;
1086  dungeon[sx + 4][sy] = 3;
1087  dungeon[sx + 7][sy] = 9;
1088  dungeon[sx + 8][sy] = 12;
1089  dungeon[sx + 9][sy] = 2;
1090  }
1091  if (bottomflag == TRUE) {
1092  sy += 11;
1093  dungeon[sx + 2][sy] = 10;
1094  dungeon[sx + 3][sy] = 12;
1095  dungeon[sx + 4][sy] = 8;
1096  dungeon[sx + 7][sy] = 5;
1097  dungeon[sx + 8][sy] = 12;
1098  if (dungeon[sx + 9][sy] != 4) {
1099  dungeon[sx + 9][sy] = 21;
1100  }
1101  sy -= 11;
1102  }
1103  if (leftflag == TRUE) {
1104  dungeon[sx][sy + 2] = 11;
1105  dungeon[sx][sy + 3] = 11;
1106  dungeon[sx][sy + 4] = 3;
1107  dungeon[sx][sy + 7] = 8;
1108  dungeon[sx][sy + 8] = 11;
1109  dungeon[sx][sy + 9] = 1;
1110  }
1111  if (rightflag == TRUE) {
1112  sx += 11;
1113  dungeon[sx][sy + 2] = 14;
1114  dungeon[sx][sy + 3] = 11;
1115  dungeon[sx][sy + 4] = 9;
1116  dungeon[sx][sy + 7] = 5;
1117  dungeon[sx][sy + 8] = 11;
1118  if (dungeon[sx][sy + 9] != 4) {
1119  dungeon[sx][sy + 9] = 21;
1120  }
1121  sx -= 11;
1122  }
1123 
1124  for (j = 1; j < 11; j++) {
1125  for (i = 1; i < 11; i++) {
1126  dungeon[i + sx][j + sy] = 13;
1127  L5dflags[i + sx][j + sy] |= DLRG_CHAMBER;
1128  }
1129  }
1130 
1131  dungeon[sx + 4][sy + 4] = 15;
1132  dungeon[sx + 7][sy + 4] = 15;
1133  dungeon[sx + 4][sy + 7] = 15;
1134  dungeon[sx + 7][sy + 7] = 15;
1135 }
1136 
1137 static void DRLG_L5GHall(int x1, int y1, int x2, int y2)
1138 {
1139  int i;
1140 
1141  if (y1 == y2) {
1142  for (i = x1; i < x2; i++) {
1143  dungeon[i][y1] = 12;
1144  dungeon[i][y1 + 3] = 12;
1145  }
1146  } else {
1147  for (i = y1; i < y2; i++) {
1148  dungeon[x1][i] = 11;
1149  dungeon[x1 + 3][i] = 11;
1150  }
1151  }
1152 }
1153 
1154 static void L5tileFix()
1155 {
1156  int i, j;
1157 
1158  // BUGFIX: Bounds checks are required in all loop bodies.
1159  // See https://github.com/diasurgical/devilutionX/pull/401
1160 
1161  for (j = 0; j < DMAXY; j++) {
1162  for (i = 0; i < DMAXX; i++) {
1163  if (i + 1 < DMAXX) {
1164  if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 22)
1165  dungeon[i + 1][j] = 23;
1166  if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 22)
1167  dungeon[i + 1][j] = 18;
1168  if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 2)
1169  dungeon[i + 1][j] = 7;
1170  if (dungeon[i][j] == 6 && dungeon[i + 1][j] == 22)
1171  dungeon[i + 1][j] = 24;
1172  }
1173  if (j + 1 < DMAXY) {
1174  if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 22)
1175  dungeon[i][j + 1] = 24;
1176  if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 1)
1177  dungeon[i][j + 1] = 6;
1178  if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 22)
1179  dungeon[i][j + 1] = 19;
1180  }
1181  }
1182  }
1183 
1184  for (j = 0; j < DMAXY; j++) {
1185  for (i = 0; i < DMAXX; i++) {
1186  if (i + 1 < DMAXX) {
1187  if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 19)
1188  dungeon[i + 1][j] = 21;
1189  if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 22)
1190  dungeon[i + 1][j] = 20;
1191  if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 22)
1192  dungeon[i + 1][j] = 23;
1193  if (dungeon[i][j] == 13 && dungeon[i + 1][j] == 24)
1194  dungeon[i + 1][j] = 21;
1195  if (dungeon[i][j] == 19 && dungeon[i + 1][j] == 22)
1196  dungeon[i + 1][j] = 20;
1197  if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 19)
1198  dungeon[i + 1][j] = 21;
1199  if (dungeon[i][j] == 19 && dungeon[i + 1][j] == 1)
1200  dungeon[i + 1][j] = 6;
1201  if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 19)
1202  dungeon[i + 1][j] = 21;
1203  if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 1)
1204  dungeon[i + 1][j] = 6;
1205  if (dungeon[i][j] == 3 && dungeon[i + 1][j] == 22)
1206  dungeon[i + 1][j] = 24;
1207  if (dungeon[i][j] == 21 && dungeon[i + 1][j] == 1)
1208  dungeon[i + 1][j] = 6;
1209  if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 1)
1210  dungeon[i + 1][j] = 6;
1211  if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 24)
1212  dungeon[i + 1][j] = 21;
1213  if (dungeon[i][j] == 4 && dungeon[i + 1][j] == 16)
1214  dungeon[i + 1][j] = 17;
1215  if (dungeon[i][j] == 7 && dungeon[i + 1][j] == 13)
1216  dungeon[i + 1][j] = 17;
1217  if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 24)
1218  dungeon[i + 1][j] = 21;
1219  if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 13)
1220  dungeon[i + 1][j] = 17;
1221  }
1222  if (i > 0) {
1223  if (dungeon[i][j] == 23 && dungeon[i - 1][j] == 22)
1224  dungeon[i - 1][j] = 19;
1225  if (dungeon[i][j] == 19 && dungeon[i - 1][j] == 23)
1226  dungeon[i - 1][j] = 21;
1227  if (dungeon[i][j] == 6 && dungeon[i - 1][j] == 22)
1228  dungeon[i - 1][j] = 24;
1229  if (dungeon[i][j] == 6 && dungeon[i - 1][j] == 23)
1230  dungeon[i - 1][j] = 21;
1231  }
1232  if (j + 1 < DMAXY) {
1233  if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 2)
1234  dungeon[i][j + 1] = 7;
1235  if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 18)
1236  dungeon[i][j + 1] = 21;
1237  if (dungeon[i][j] == 18 && dungeon[i][j + 1] == 2)
1238  dungeon[i][j + 1] = 7;
1239  if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 2)
1240  dungeon[i][j + 1] = 7;
1241  if (dungeon[i][j] == 21 && dungeon[i][j + 1] == 2)
1242  dungeon[i][j + 1] = 7;
1243  if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 22)
1244  dungeon[i][j + 1] = 24;
1245  if (dungeon[i][j] == 6 && dungeon[i][j + 1] == 13)
1246  dungeon[i][j + 1] = 16;
1247  if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 13)
1248  dungeon[i][j + 1] = 16;
1249  if (dungeon[i][j] == 13 && dungeon[i][j + 1] == 16)
1250  dungeon[i][j + 1] = 17;
1251  }
1252  if (j > 0) {
1253  if (dungeon[i][j] == 6 && dungeon[i][j - 1] == 22)
1254  dungeon[i][j - 1] = 7;
1255  if (dungeon[i][j] == 6 && dungeon[i][j - 1] == 22)
1256  dungeon[i][j - 1] = 24;
1257  if (dungeon[i][j] == 7 && dungeon[i][j - 1] == 24)
1258  dungeon[i][j - 1] = 21;
1259  if (dungeon[i][j] == 18 && dungeon[i][j - 1] == 24)
1260  dungeon[i][j - 1] = 21;
1261  }
1262  }
1263  }
1264 
1265  for (j = 0; j < DMAXY; j++) {
1266  for (i = 0; i < DMAXX; i++) {
1267  if (j + 1 < DMAXY && dungeon[i][j] == 4 && dungeon[i][j + 1] == 2)
1268  dungeon[i][j + 1] = 7;
1269  if (i + 1 < DMAXX && dungeon[i][j] == 2 && dungeon[i + 1][j] == 19)
1270  dungeon[i + 1][j] = 21;
1271  if (j + 1 < DMAXY && dungeon[i][j] == 18 && dungeon[i][j + 1] == 22)
1272  dungeon[i][j + 1] = 20;
1273  }
1274  }
1275 }
1276 
1277 static void DRLG_L5Subs()
1278 {
1279  int x, y, rv, i;
1280 
1281  for (y = 0; y < DMAXY; y++) {
1282  for (x = 0; x < DMAXX; x++) {
1283  if (!random_(0, 4)) {
1284  BYTE c = L5BTYPES[dungeon[x][y]];
1285 
1286  if (c && !L5dflags[x][y]) {
1287  rv = random_(0, 16);
1288  i = -1;
1289 
1290  while (rv >= 0) {
1291  if (++i == sizeof(L5BTYPES))
1292  i = 0;
1293  if (c == L5BTYPES[i])
1294  rv--;
1295  }
1296 
1297  // BUGFIX: Add `&& y > 0` to the if statement. (fixed)
1298  if (i == 89 && y > 0) {
1299  if (L5BTYPES[dungeon[x][y - 1]] != 79 || L5dflags[x][y - 1])
1300  i = 79;
1301  else
1302  dungeon[x][y - 1] = 90;
1303  }
1304  // BUGFIX: Add `&& x + 1 < DMAXX` to the if statement. (fixed)
1305  if (i == 91 && x + 1 < DMAXX) {
1306  if (L5BTYPES[dungeon[x + 1][y]] != 80 || L5dflags[x + 1][y])
1307  i = 80;
1308  else
1309  dungeon[x + 1][y] = 92;
1310  }
1311  dungeon[x][y] = i;
1312  }
1313  }
1314  }
1315  }
1316 }
1317 
1318 static void DRLG_L5SetRoom(int rx1, int ry1)
1319 {
1320  int rw, rh, i, j;
1321  BYTE *sp;
1322 
1323  rw = *L5pSetPiece;
1324  rh = *(L5pSetPiece + 2);
1325 
1326  setpc_x = rx1;
1327  setpc_y = ry1;
1328  setpc_w = rw;
1329  setpc_h = rh;
1330 
1331  sp = L5pSetPiece + 4;
1332 
1333  for (j = 0; j < rh; j++) {
1334  for (i = 0; i < rw; i++) {
1335  if (*sp) {
1336  dungeon[rx1 + i][ry1 + j] = *sp;
1337  L5dflags[rx1 + i][ry1 + j] |= DLRG_PROTECTED;
1338  } else {
1339  dungeon[rx1 + i][ry1 + j] = 13;
1340  }
1341  sp += 2;
1342  }
1343  }
1344 }
1345 
1346 static void L5FillChambers()
1347 {
1348  int c;
1349 
1350  if (HR1)
1351  DRLG_L5GChamber(0, 14, 0, 0, 0, 1);
1352 
1353  if (HR2) {
1354  if (HR1 && !HR3)
1355  DRLG_L5GChamber(14, 14, 0, 0, 1, 0);
1356  if (!HR1 && HR3)
1357  DRLG_L5GChamber(14, 14, 0, 0, 0, 1);
1358  if (HR1 && HR3)
1359  DRLG_L5GChamber(14, 14, 0, 0, 1, 1);
1360  if (!HR1 && !HR3)
1361  DRLG_L5GChamber(14, 14, 0, 0, 0, 0);
1362  }
1363 
1364  if (HR3)
1365  DRLG_L5GChamber(28, 14, 0, 0, 1, 0);
1366  if (HR1 && HR2)
1367  DRLG_L5GHall(12, 18, 14, 18);
1368  if (HR2 && HR3)
1369  DRLG_L5GHall(26, 18, 28, 18);
1370  if (HR1 && !HR2 && HR3)
1371  DRLG_L5GHall(12, 18, 28, 18);
1372  if (VR1)
1373  DRLG_L5GChamber(14, 0, 0, 1, 0, 0);
1374 
1375  if (VR2) {
1376  if (VR1 && !VR3)
1377  DRLG_L5GChamber(14, 14, 1, 0, 0, 0);
1378  if (!VR1 && VR3)
1379  DRLG_L5GChamber(14, 14, 0, 1, 0, 0);
1380  if (VR1 && VR3)
1381  DRLG_L5GChamber(14, 14, 1, 1, 0, 0);
1382  if (!VR1 && !VR3)
1383  DRLG_L5GChamber(14, 14, 0, 0, 0, 0);
1384  }
1385 
1386  if (VR3)
1387  DRLG_L5GChamber(14, 28, 1, 0, 0, 0);
1388  if (VR1 && VR2)
1389  DRLG_L5GHall(18, 12, 18, 14);
1390  if (VR2 && VR3)
1391  DRLG_L5GHall(18, 26, 18, 28);
1392  if (VR1 && !VR2 && VR3)
1393  DRLG_L5GHall(18, 12, 18, 28);
1394 
1395  if (L5setloadflag) {
1396  if (VR1 || VR2 || VR3) {
1397  c = 1;
1398  if (!VR1 && VR2 && VR3 && random_(0, 2))
1399  c = 2;
1400  if (VR1 && VR2 && !VR3 && random_(0, 2))
1401  c = 0;
1402 
1403  if (VR1 && !VR2 && VR3) {
1404  if (random_(0, 2))
1405  c = 0;
1406  else
1407  c = 2;
1408  }
1409 
1410  if (VR1 && VR2 && VR3)
1411  c = random_(0, 3);
1412 
1413  switch (c) {
1414  case 0:
1415  DRLG_L5SetRoom(16, 2);
1416  break;
1417  case 1:
1418  DRLG_L5SetRoom(16, 16);
1419  break;
1420  case 2:
1421  DRLG_L5SetRoom(16, 30);
1422  break;
1423  }
1424  } else {
1425  c = 1;
1426  if (!HR1 && HR2 && HR3 && random_(0, 2))
1427  c = 2;
1428  if (HR1 && HR2 && !HR3 && random_(0, 2))
1429  c = 0;
1430 
1431  if (HR1 && !HR2 && HR3) {
1432  if (random_(0, 2))
1433  c = 0;
1434  else
1435  c = 2;
1436  }
1437 
1438  if (HR1 && HR2 && HR3)
1439  c = random_(0, 3);
1440 
1441  switch (c) {
1442  case 0:
1443  DRLG_L5SetRoom(2, 16);
1444  break;
1445  case 1:
1446  DRLG_L5SetRoom(16, 16);
1447  break;
1448  case 2:
1449  DRLG_L5SetRoom(30, 16);
1450  break;
1451  }
1452  }
1453  }
1454 }
1455 
1456 static void DRLG_L5FTVR(int i, int j, int x, int y, int d)
1457 {
1458  if (dTransVal[x][y] || dungeon[i][j] != 13) {
1459  if (d == 1) {
1460  dTransVal[x][y] = TransVal;
1461  dTransVal[x][y + 1] = TransVal;
1462  }
1463  if (d == 2) {
1464  dTransVal[x + 1][y] = TransVal;
1465  dTransVal[x + 1][y + 1] = TransVal;
1466  }
1467  if (d == 3) {
1468  dTransVal[x][y] = TransVal;
1469  dTransVal[x + 1][y] = TransVal;
1470  }
1471  if (d == 4) {
1472  dTransVal[x][y + 1] = TransVal;
1473  dTransVal[x + 1][y + 1] = TransVal;
1474  }
1475  if (d == 5)
1476  dTransVal[x + 1][y + 1] = TransVal;
1477  if (d == 6)
1478  dTransVal[x][y + 1] = TransVal;
1479  if (d == 7)
1480  dTransVal[x + 1][y] = TransVal;
1481  if (d == 8)
1482  dTransVal[x][y] = TransVal;
1483  } else {
1484  dTransVal[x][y] = TransVal;
1485  dTransVal[x + 1][y] = TransVal;
1486  dTransVal[x][y + 1] = TransVal;
1487  dTransVal[x + 1][y + 1] = TransVal;
1488  DRLG_L5FTVR(i + 1, j, x + 2, y, 1);
1489  DRLG_L5FTVR(i - 1, j, x - 2, y, 2);
1490  DRLG_L5FTVR(i, j + 1, x, y + 2, 3);
1491  DRLG_L5FTVR(i, j - 1, x, y - 2, 4);
1492  DRLG_L5FTVR(i - 1, j - 1, x - 2, y - 2, 5);
1493  DRLG_L5FTVR(i + 1, j - 1, x + 2, y - 2, 6);
1494  DRLG_L5FTVR(i - 1, j + 1, x - 2, y + 2, 7);
1495  DRLG_L5FTVR(i + 1, j + 1, x + 2, y + 2, 8);
1496  }
1497 }
1498 
1499 static void DRLG_L5FloodTVal()
1500 {
1501  int xx, yy, i, j;
1502 
1503  yy = 16;
1504 
1505  for (j = 0; j < DMAXY; j++) {
1506  xx = 16;
1507 
1508  for (i = 0; i < DMAXX; i++) {
1509  if (dungeon[i][j] == 13 && !dTransVal[xx][yy]) {
1510  DRLG_L5FTVR(i, j, xx, yy, 0);
1511  TransVal++;
1512  }
1513  xx += 2;
1514  }
1515  yy += 2;
1516  }
1517 }
1518 
1519 static void DRLG_L5TransFix()
1520 {
1521  int xx, yy, i, j;
1522 
1523  yy = 16;
1524 
1525  for (j = 0; j < DMAXY; j++) {
1526  xx = 16;
1527 
1528  for (i = 0; i < DMAXX; i++) {
1529  // BUGFIX: Should check for `j > 0` first. (fixed)
1530  if (dungeon[i][j] == 23 && j > 0 && dungeon[i][j - 1] == 18) {
1531  dTransVal[xx + 1][yy] = dTransVal[xx][yy];
1532  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1533  }
1534  // BUGFIX: Should check for `i + 1 < DMAXY` first. (fixed)
1535  if (dungeon[i][j] == 24 && i + 1 < DMAXY && dungeon[i + 1][j] == 19) {
1536  dTransVal[xx][yy + 1] = dTransVal[xx][yy];
1537  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1538  }
1539  if (dungeon[i][j] == 18) {
1540  dTransVal[xx + 1][yy] = dTransVal[xx][yy];
1541  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1542  }
1543  if (dungeon[i][j] == 19) {
1544  dTransVal[xx][yy + 1] = dTransVal[xx][yy];
1545  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1546  }
1547  if (dungeon[i][j] == 20) {
1548  dTransVal[xx + 1][yy] = dTransVal[xx][yy];
1549  dTransVal[xx][yy + 1] = dTransVal[xx][yy];
1550  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1551  }
1552  xx += 2;
1553  }
1554  yy += 2;
1555  }
1556 }
1557 
1558 static void DRLG_L5DirtFix()
1559 {
1560  int i, j;
1561 
1562  for (j = 0; j < DMAXY; j++) {
1563  for (i = 0; i < DMAXX; i++) {
1564  if (dungeon[i][j] == 21 && dungeon[i + 1][j] != 19)
1565  dungeon[i][j] = 202;
1566  if (dungeon[i][j] == 19 && dungeon[i + 1][j] != 19)
1567  dungeon[i][j] = 200;
1568  if (dungeon[i][j] == 24 && dungeon[i + 1][j] != 19)
1569  dungeon[i][j] = 205;
1570  if (dungeon[i][j] == 18 && dungeon[i][j + 1] != 18)
1571  dungeon[i][j] = 199;
1572  if (dungeon[i][j] == 21 && dungeon[i][j + 1] != 18)
1573  dungeon[i][j] = 202;
1574  if (dungeon[i][j] == 23 && dungeon[i][j + 1] != 18)
1575  dungeon[i][j] = 204;
1576  }
1577  }
1578 }
1579 
1580 static void DRLG_L5CornerFix()
1581 {
1582  int i, j;
1583 
1584  for (j = 1; j < DMAXY - 1; j++) {
1585  for (i = 1; i < DMAXX - 1; i++) {
1586  if (!(L5dflags[i][j] & DLRG_PROTECTED) && dungeon[i][j] == 17 && dungeon[i - 1][j] == 13 && dungeon[i][j - 1] == 1) {
1587  dungeon[i][j] = 16;
1588  L5dflags[i][j - 1] &= DLRG_PROTECTED;
1589  }
1590  if (dungeon[i][j] == 202 && dungeon[i + 1][j] == 13 && dungeon[i][j + 1] == 1) {
1591  dungeon[i][j] = 8;
1592  }
1593  }
1594  }
1595 }
1596 
1597 static void DRLG_L5(int entry)
1598 {
1599  int i, j;
1600  LONG minarea;
1601  BOOL doneflag;
1602 
1603  switch (currlevel) {
1604  case 1:
1605  minarea = 533;
1606  break;
1607  case 2:
1608  minarea = 693;
1609  break;
1610  case 3:
1611  case 4:
1612  minarea = 761;
1613  break;
1614  }
1615 
1616  do {
1617  DRLG_InitTrans();
1618 
1619  do {
1620  InitL5Dungeon();
1621  L5firstRoom();
1622  } while (L5GetArea() < minarea);
1623 
1624  L5makeDungeon();
1625  L5makeDmt();
1626  L5FillChambers();
1627  L5tileFix();
1628  L5AddWall();
1629  L5ClearFlags();
1630  DRLG_L5FloodTVal();
1631 
1632  doneflag = TRUE;
1633 
1634  if (QuestStatus(Q_PWATER)) {
1635  if (entry == 0) {
1636  if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 1, -1, 0) < 0)
1637  doneflag = FALSE;
1638  } else {
1639  if (DRLG_PlaceMiniSet(PWATERIN, 1, 1, 0, 0, 0, -1, 0) < 0)
1640  doneflag = FALSE;
1641  ViewY--;
1642  }
1643  }
1644  if (QuestStatus(Q_LTBANNER)) {
1645  if (entry == 0) {
1646  if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0)
1647  doneflag = FALSE;
1648  } else {
1649  if (DRLG_PlaceMiniSet(STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0)
1650  doneflag = FALSE;
1651  if (entry == 1) {
1652  ViewX = 2 * setpc_x + 20;
1653  ViewY = 2 * setpc_y + 28;
1654  } else {
1655  ViewY--;
1656  }
1657  }
1658  } else if (entry == 0) {
1659  if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 1, -1, 0) < 0)
1660  doneflag = FALSE;
1661  else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 0, -1, 1) < 0)
1662  doneflag = FALSE;
1663  } else {
1664  if (DRLG_PlaceMiniSet(L5STAIRSUP, 1, 1, 0, 0, 0, -1, 0) < 0)
1665  doneflag = FALSE;
1666  else if (DRLG_PlaceMiniSet(STAIRSDOWN, 1, 1, 0, 0, 1, -1, 1) < 0)
1667  doneflag = FALSE;
1668  ViewY--;
1669  }
1670  } while (doneflag == FALSE);
1671 
1672  for (j = 0; j < DMAXY; j++) {
1673  for (i = 0; i < DMAXX; i++) {
1674  if (dungeon[i][j] == 64) {
1675  int xx = 2 * i + 16; /* todo: fix loop */
1676  int yy = 2 * j + 16;
1677  DRLG_CopyTrans(xx, yy + 1, xx, yy);
1678  DRLG_CopyTrans(xx + 1, yy + 1, xx + 1, yy);
1679  }
1680  }
1681  }
1682 
1683  DRLG_L5TransFix();
1684  DRLG_L5DirtFix();
1685  DRLG_L5CornerFix();
1686 
1687  for (j = 0; j < DMAXY; j++) {
1688  for (i = 0; i < DMAXX; i++) {
1689  if (L5dflags[i][j] & 0x7F)
1690  DRLG_PlaceDoor(i, j);
1691  }
1692  }
1693 
1694  DRLG_L5Subs();
1695  DRLG_L1Shadows();
1696  DRLG_PlaceMiniSet(LAMPS, 5, 10, 0, 0, 0, -1, 4);
1697  DRLG_L1Floor();
1698 
1699  for (j = 0; j < DMAXY; j++) {
1700  for (i = 0; i < DMAXX; i++) {
1701  pdungeon[i][j] = dungeon[i][j];
1702  }
1703  }
1704 
1707 }
1708 
1709 void CreateL5Dungeon(DWORD rseed, int entry)
1710 {
1711  SetRndSeed(rseed);
1712 
1713  dminx = 16;
1714  dminy = 16;
1715  dmaxx = 96;
1716  dmaxy = 96;
1717 
1718  DRLG_InitTrans();
1719  DRLG_InitSetPC();
1720  DRLG_LoadL1SP();
1721  DRLG_L5(entry);
1722  DRLG_L1Pass3();
1723  DRLG_FreeL1SP();
1724  DRLG_InitL1Vals();
1725  DRLG_SetPC();
1726 }
1727 
LAMPS
const BYTE LAMPS[]
Definition: drlg_l1.cpp:116
QuestStruct::_qtx
int _qtx
Definition: structs.h:975
DRLG_InitTrans
void DRLG_InitTrans()
Definition: gendung.cpp:171
quests
QuestStruct quests[MAXQUESTS]
Definition: quests.cpp:8
CreateL5Dungeon
void CreateL5Dungeon(DWORD rseed, int entry)
Definition: drlg_l1.cpp:1709
setpc_w
int setpc_w
Definition: gendung.cpp:71
DRLG_LoadL1SP
static void DRLG_LoadL1SP()
Definition: drlg_l1.cpp:448
DRLG_L5FTVR
static void DRLG_L5FTVR(int i, int j, int x, int y, int d)
Definition: drlg_l1.cpp:1456
currlevel
BYTE currlevel
Definition: gendung.cpp:40
DLRG_CHAMBER
@ DLRG_CHAMBER
Definition: enums.h:2928
Q_BUTCHER
@ Q_BUTCHER
Definition: enums.h:2554
setpc_h
int setpc_h
Definition: gendung.cpp:70
L5dungeon
DEVILUTION_BEGIN_NAMESPACE BYTE L5dungeon[80][80]
Definition: drlg_l1.cpp:10
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
L5AddWall
static void L5AddWall()
Definition: drlg_l1.cpp:1037
SetRndSeed
void SetRndSeed(int s)
Set the RNG seed.
Definition: engine.cpp:728
DRLG_CopyTrans
void DRLG_CopyTrans(int sx, int sy, int dx, int dy)
Definition: gendung.cpp:208
VR2
int VR2
Definition: drlg_l1.cpp:17
InitL5Dungeon
static void InitL5Dungeon()
Definition: drlg_l1.cpp:634
dungeon
BYTE dungeon[DMAXX][DMAXY]
Definition: gendung.cpp:18
pdungeon
BYTE pdungeon[DMAXX][DMAXY]
Definition: gendung.cpp:20
dmaxx
int dmaxx
Definition: gendung.cpp:68
MAXDUNX
#define MAXDUNX
Definition: defs.h:25
DLRG_VDOOR
@ DLRG_VDOOR
Definition: enums.h:2927
pMegaTiles
BYTE * pMegaTiles
Definition: gendung.cpp:29
BSTYPES
const BYTE BSTYPES[]
Definition: drlg_l1.cpp:65
DRLG_L5CornerFix
static void DRLG_L5CornerFix()
Definition: drlg_l1.cpp:1580
ViewX
int ViewX
Definition: gendung.cpp:73
VR3
int VR3
Definition: drlg_l1.cpp:18
MemFreeDbg
#define MemFreeDbg(p)
Definition: defs.h:157
L5GetArea
static int L5GetArea()
Definition: drlg_l1.cpp:831
all.h
ViewY
int ViewY
Definition: gendung.cpp:74
DRLG_L5GChamber
static void DRLG_L5GChamber(int sx, int sy, BOOL topflag, BOOL bottomflag, BOOL leftflag, BOOL rightflag)
Definition: drlg_l1.cpp:1079
dObject
char dObject[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:19
HR3
int HR3
Definition: drlg_l1.cpp:15
PWATERIN
const BYTE PWATERIN[]
Definition: drlg_l1.cpp:117
DRLG_L5TransFix
static void DRLG_L5TransFix()
Definition: drlg_l1.cpp:1519
gbMaxPlayers
BYTE gbMaxPlayers
Specifies the maximum number of players in a game, where 1 represents a single player game and 4 repr...
Definition: multi.cpp:34
SPATS
const ShadowStruct SPATS[37]
Definition: drlg_l1.cpp:21
L5VWallOk
static int L5VWallOk(int i, int j)
Definition: drlg_l1.cpp:913
Q_PWATER
@ Q_PWATER
Definition: enums.h:2561
DRLG_L5GHall
static void DRLG_L5GHall(int x1, int y1, int x2, int y2)
Definition: drlg_l1.cpp:1137
MAXDUNY
#define MAXDUNY
Definition: defs.h:26
dLight
char dLight[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:27
DRLG_L5
static void DRLG_L5(int entry)
Definition: drlg_l1.cpp:1597
DRLG_L5Subs
static void DRLG_L5Subs()
Definition: drlg_l1.cpp:1277
dPiece
int dPiece[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:26
light4flag
BOOL light4flag
Definition: diablo.cpp:34
DRLG_L5DirtFix
static void DRLG_L5DirtFix()
Definition: drlg_l1.cpp:1558
DRLG_MRectTrans
void DRLG_MRectTrans(int x1, int y1, int x2, int y2)
Definition: gendung.cpp:178
L5ConvTbl
BYTE L5ConvTbl[16]
Definition: drlg_l1.cpp:120
DLRG_PROTECTED
@ DLRG_PROTECTED
Definition: enums.h:2929
TransVal
char TransVal
Definition: gendung.cpp:23
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
ShadowStruct::nv3
unsigned char nv3
Definition: structs.h:1136
ShadowStruct::nv2
unsigned char nv2
Definition: structs.h:1135
DRLG_L1Shadows
static void DRLG_L1Shadows()
Definition: drlg_l1.cpp:181
DRLG_L1Pass3
static void DRLG_L1Pass3()
Definition: drlg_l1.cpp:403
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
L5roomGen
static void L5roomGen(int x, int y, int w, int h, int dir)
Definition: drlg_l1.cpp:684
dMissile
char dMissile[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:76
L5tileFix
static void L5tileFix()
Definition: drlg_l1.cpp:1154
dItem
char dItem[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:57
DRLG_InitL1Vals
static void DRLG_InitL1Vals()
Definition: drlg_l1.cpp:493
LoadL1Dungeon
void LoadL1Dungeon(char *sFileName, int vx, int vy)
Definition: drlg_l1.cpp:536
L5BTYPES
const BYTE L5BTYPES[]
Definition: drlg_l1.cpp:90
dmaxy
int dmaxy
Definition: gendung.cpp:69
L5checkRoom
static BOOL L5checkRoom(int x, int y, int width, int height)
Definition: drlg_l1.cpp:668
lightflag
BOOL lightflag
Definition: lighting.cpp:22
L5makeDungeon
static void L5makeDungeon()
Definition: drlg_l1.cpp:848
Q_LTBANNER
@ Q_LTBANNER
Definition: enums.h:2555
L5dflags
BYTE L5dflags[DMAXX][DMAXY]
Definition: drlg_l1.cpp:11
DRLG_SetPC
void DRLG_SetPC()
Definition: gendung.cpp:253
DRLG_L5SetRoom
static void DRLG_L5SetRoom(int rx1, int ry1)
Definition: drlg_l1.cpp:1318
L5makeDmt
static void L5makeDmt()
Definition: drlg_l1.cpp:865
DMAXY
#define DMAXY
Definition: defs.h:8
DRLG_L1Floor
static void DRLG_L1Floor()
Definition: drlg_l1.cpp:384
DRLG_L5FloodTVal
static void DRLG_L5FloodTVal()
Definition: drlg_l1.cpp:1499
L5ClearFlags
static void L5ClearFlags()
Definition: drlg_l1.cpp:646
DRLG_PlaceMiniSet
static int DRLG_PlaceMiniSet(const BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int noquad, int ldir)
Definition: drlg_l1.cpp:271
LvlViewX
int LvlViewX
Definition: gendung.cpp:67
DRLG_CheckQuests
void DRLG_CheckQuests(int x, int y)
Definition: quests.cpp:516
LoadPreL1Dungeon
void LoadPreL1Dungeon(char *sFileName, int vx, int vy)
Definition: drlg_l1.cpp:585
dTransVal
char dTransVal[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:37
LvlViewY
int LvlViewY
Definition: gendung.cpp:66
SetMapMonsters
void SetMapMonsters(BYTE *pMap, int startx, int starty)
Definition: monster.cpp:1029
L5VertWall
static void L5VertWall(int i, int j, char p, int dy)
Definition: drlg_l1.cpp:988
VR1
int VR1
Definition: drlg_l1.cpp:16
L5firstRoom
static void L5firstRoom()
Definition: drlg_l1.cpp:741
L5STAIRSUP
const BYTE L5STAIRSUP[]
Definition: drlg_l1.cpp:114
STAIRSDOWN
const BYTE STAIRSDOWN[]
Definition: drlg_l1.cpp:115
QuestStruct::_qty
int _qty
Definition: structs.h:976
dSpecial
char dSpecial[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:50
random_
int random_(BYTE idx, int v)
Main RNG function.
Definition: engine.cpp:752
Q_SKELKING
@ Q_SKELKING
Definition: enums.h:2560
DRLG_PlaceDoor
static void DRLG_PlaceDoor(int x, int y)
Definition: drlg_l1.cpp:122
mem_free_dbg
void mem_free_dbg(void *p)
Multithreaded safe memfree.
Definition: engine.cpp:786
DLRG_HDOOR
@ DLRG_HDOOR
Definition: enums.h:2926
L5FillChambers
static void L5FillChambers()
Definition: drlg_l1.cpp:1346
HR2
int HR2
Definition: drlg_l1.cpp:14
dMonster
int dMonster[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:17
ShadowStruct
Definition: structs.h:1129
L5pSetPiece
BYTE * L5pSetPiece
Definition: drlg_l1.cpp:19
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
L5HWallOk
static int L5HWallOk(int i, int j)
Definition: drlg_l1.cpp:887
L5HorizWall
static void L5HorizWall(int i, int j, char p, int dx)
Definition: drlg_l1.cpp:939
dPlayer
char dPlayer[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:49
dFlags
char dFlags[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:56
L5drawRoom
static void L5drawRoom(int x, int y, int w, int h)
Definition: drlg_l1.cpp:657
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
setpc_y
int setpc_y
Definition: gendung.cpp:75
HR1
int HR1
Definition: drlg_l1.cpp:13
dDead
char dDead[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:21
DRLG_FreeL1SP
static void DRLG_FreeL1SP()
Definition: drlg_l1.cpp:465
L5setloadflag
BOOL L5setloadflag
Definition: drlg_l1.cpp:12
DMAXX
#define DMAXX
Definition: defs.h:7
ShadowStruct::nv1
unsigned char nv1
Definition: structs.h:1134
STAIRSUP
const BYTE STAIRSUP[]
Definition: drlg_l1.cpp:113