Devilution
Diablo devolved - magic behind the 1996 computer game
drlg_l2.cpp
Go to the documentation of this file.
1 
6 #ifndef SPAWN
7 
8 #include <algorithm>
9 
10 #include "all.h"
11 
13 
14 int nSx1;
15 int nSx2;
16 int nSy1;
17 int nSy2;
22 
23 int Area_Min = 2;
24 int Room_Max = 10;
25 int Room_Min = 4;
26 int Dir_Xadd[5] = { 0, 0, 1, 0, -1 };
27 int Dir_Yadd[5] = { 0, -1, 0, 1, 0 };
28 ShadowStruct SPATSL2[2] = { { 6, 3, 0, 3, 48, 0, 50 }, { 9, 3, 0, 3, 48, 0, 50 } };
29 //short word_48489A = 0;
30 BYTE BTYPESL2[161] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 17, 18, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
31 BYTE BSTYPESL2[161] = { 0, 1, 2, 3, 0, 0, 6, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 6, 6, 6, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 6, 2, 2, 2, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 2, 2, 3, 3, 3, 3, 1, 1, 3, 3, 2, 2, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
32 BYTE VARCH1[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 7, 48, 0, 51, 39, 47, 44, 0, 0 };
33 BYTE VARCH2[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 8, 48, 0, 51, 39, 47, 44, 0, 0 };
34 BYTE VARCH3[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 6, 48, 0, 51, 39, 47, 44, 0, 0 };
35 BYTE VARCH4[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 9, 48, 0, 51, 39, 47, 44, 0, 0 };
36 BYTE VARCH5[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 14, 48, 0, 51, 39, 47, 44, 0, 0 };
37 BYTE VARCH6[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 13, 48, 0, 51, 39, 47, 44, 0, 0 };
38 BYTE VARCH7[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 16, 48, 0, 51, 39, 47, 44, 0, 0 };
39 BYTE VARCH8[] = { 2, 4, 3, 0, 3, 1, 3, 4, 0, 15, 48, 0, 51, 39, 47, 44, 0, 0 };
40 BYTE VARCH9[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 7, 48, 0, 51, 42, 47, 44, 0, 0 };
41 BYTE VARCH10[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 8, 48, 0, 51, 42, 47, 44, 0, 0 };
42 BYTE VARCH11[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 6, 48, 0, 51, 42, 47, 44, 0, 0 };
43 BYTE VARCH12[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 9, 48, 0, 51, 42, 47, 44, 0, 0 };
44 BYTE VARCH13[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 14, 48, 0, 51, 42, 47, 44, 0, 0 };
45 BYTE VARCH14[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 13, 48, 0, 51, 42, 47, 44, 0, 0 };
46 BYTE VARCH15[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 16, 48, 0, 51, 42, 47, 44, 0, 0 };
47 BYTE VARCH16[] = { 2, 4, 3, 0, 3, 8, 3, 4, 0, 15, 48, 0, 51, 42, 47, 44, 0, 0 };
48 BYTE VARCH17[] = { 2, 3, 2, 7, 3, 4, 0, 7, 141, 39, 47, 44, 0, 0 };
49 BYTE VARCH18[] = { 2, 3, 2, 7, 3, 4, 0, 8, 141, 39, 47, 44, 0, 0 };
50 BYTE VARCH19[] = { 2, 3, 2, 7, 3, 4, 0, 6, 141, 39, 47, 44, 0, 0 };
51 BYTE VARCH20[] = { 2, 3, 2, 7, 3, 4, 0, 9, 141, 39, 47, 44, 0, 0 };
52 BYTE VARCH21[] = { 2, 3, 2, 7, 3, 4, 0, 14, 141, 39, 47, 44, 0, 0 };
53 BYTE VARCH22[] = { 2, 3, 2, 7, 3, 4, 0, 13, 141, 39, 47, 44, 0, 0 };
54 BYTE VARCH23[] = { 2, 3, 2, 7, 3, 4, 0, 16, 141, 39, 47, 44, 0, 0 };
55 BYTE VARCH24[] = { 2, 3, 2, 7, 3, 4, 0, 15, 141, 39, 47, 44, 0, 0 };
56 BYTE VARCH25[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 7, 48, 0, 51, 39, 47, 44, 0, 0 };
57 BYTE VARCH26[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 8, 48, 0, 51, 39, 47, 44, 0, 0 };
58 BYTE VARCH27[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 6, 48, 0, 51, 39, 47, 44, 0, 0 };
59 BYTE VARCH28[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 9, 48, 0, 51, 39, 47, 44, 0, 0 };
60 BYTE VARCH29[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 14, 48, 0, 51, 39, 47, 44, 0, 0 };
61 BYTE VARCH30[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 13, 48, 0, 51, 39, 47, 44, 0, 0 };
62 BYTE VARCH31[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 16, 48, 0, 51, 39, 47, 44, 0, 0 };
63 BYTE VARCH32[] = { 2, 4, 3, 0, 3, 4, 3, 1, 0, 15, 48, 0, 51, 39, 47, 44, 0, 0 };
64 BYTE VARCH33[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 7, 142, 0, 51, 42, 47, 44, 0, 0 };
65 BYTE VARCH34[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 8, 142, 0, 51, 42, 47, 44, 0, 0 };
66 BYTE VARCH35[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 6, 142, 0, 51, 42, 47, 44, 0, 0 };
67 BYTE VARCH36[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 9, 142, 0, 51, 42, 47, 44, 0, 0 };
68 BYTE VARCH37[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 14, 142, 0, 51, 42, 47, 44, 0, 0 };
69 BYTE VARCH38[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 13, 142, 0, 51, 42, 47, 44, 0, 0 };
70 BYTE VARCH39[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 16, 142, 0, 51, 42, 47, 44, 0, 0 };
71 BYTE VARCH40[] = { 2, 4, 2, 0, 3, 8, 3, 4, 0, 15, 142, 0, 51, 42, 47, 44, 0, 0 };
72 BYTE HARCH1[] = { 3, 2, 3, 3, 0, 2, 5, 9, 49, 46, 0, 40, 45, 0 };
73 BYTE HARCH2[] = { 3, 2, 3, 3, 0, 2, 5, 6, 49, 46, 0, 40, 45, 0 };
74 BYTE HARCH3[] = { 3, 2, 3, 3, 0, 2, 5, 8, 49, 46, 0, 40, 45, 0 };
75 BYTE HARCH4[] = { 3, 2, 3, 3, 0, 2, 5, 7, 49, 46, 0, 40, 45, 0 };
76 BYTE HARCH5[] = { 3, 2, 3, 3, 0, 2, 5, 15, 49, 46, 0, 40, 45, 0 };
77 BYTE HARCH6[] = { 3, 2, 3, 3, 0, 2, 5, 16, 49, 46, 0, 40, 45, 0 };
78 BYTE HARCH7[] = { 3, 2, 3, 3, 0, 2, 5, 13, 49, 46, 0, 40, 45, 0 };
79 BYTE HARCH8[] = { 3, 2, 3, 3, 0, 2, 5, 14, 49, 46, 0, 40, 45, 0 };
80 BYTE HARCH9[] = { 3, 2, 3, 3, 0, 8, 5, 9, 49, 46, 0, 43, 45, 0 };
81 BYTE HARCH10[] = { 3, 2, 3, 3, 0, 8, 5, 6, 49, 46, 0, 43, 45, 0 };
82 BYTE HARCH11[] = { 3, 2, 3, 3, 0, 8, 5, 8, 49, 46, 0, 43, 45, 0 };
83 BYTE HARCH12[] = { 3, 2, 3, 3, 0, 8, 5, 7, 49, 46, 0, 43, 45, 0 };
84 BYTE HARCH13[] = { 3, 2, 3, 3, 0, 8, 5, 15, 49, 46, 0, 43, 45, 0 };
85 BYTE HARCH14[] = { 3, 2, 3, 3, 0, 8, 5, 16, 49, 46, 0, 43, 45, 0 };
86 BYTE HARCH15[] = { 3, 2, 3, 3, 0, 8, 5, 13, 49, 46, 0, 43, 45, 0 };
87 BYTE HARCH16[] = { 3, 2, 3, 3, 0, 8, 5, 14, 49, 46, 0, 43, 45, 0 };
88 BYTE HARCH17[] = { 3, 2, 1, 3, 0, 8, 5, 9, 140, 46, 0, 43, 45, 0 };
89 BYTE HARCH18[] = { 3, 2, 1, 3, 0, 8, 5, 6, 140, 46, 0, 43, 45, 0 };
90 BYTE HARCH19[] = { 3, 2, 1, 3, 0, 8, 5, 8, 140, 46, 0, 43, 45, 0 };
91 BYTE HARCH20[] = { 3, 2, 1, 3, 0, 8, 5, 7, 140, 46, 0, 43, 45, 0 };
92 BYTE HARCH21[] = { 3, 2, 1, 3, 0, 8, 5, 15, 140, 46, 0, 43, 45, 0 };
93 BYTE HARCH22[] = { 3, 2, 1, 3, 0, 8, 5, 16, 140, 46, 0, 43, 45, 0 };
94 BYTE HARCH23[] = { 3, 2, 1, 3, 0, 8, 5, 13, 140, 46, 0, 43, 45, 0 };
95 BYTE HARCH24[] = { 3, 2, 1, 3, 0, 8, 5, 14, 140, 46, 0, 43, 45, 0 };
96 BYTE HARCH25[] = { 3, 2, 3, 3, 0, 5, 2, 9, 49, 46, 0, 40, 45, 0 };
97 BYTE HARCH26[] = { 3, 2, 3, 3, 0, 5, 2, 6, 49, 46, 0, 40, 45, 0 };
98 BYTE HARCH27[] = { 3, 2, 3, 3, 0, 5, 2, 8, 49, 46, 0, 40, 45, 0 };
99 BYTE HARCH28[] = { 3, 2, 3, 3, 0, 5, 2, 7, 49, 46, 0, 40, 45, 0 };
100 BYTE HARCH29[] = { 3, 2, 3, 3, 0, 5, 2, 15, 49, 46, 0, 40, 45, 0 };
101 BYTE HARCH30[] = { 3, 2, 3, 3, 0, 5, 2, 16, 49, 46, 0, 40, 45, 0 };
102 BYTE HARCH31[] = { 3, 2, 3, 3, 0, 5, 2, 13, 49, 46, 0, 40, 45, 0 };
103 BYTE HARCH32[] = { 3, 2, 3, 3, 0, 5, 2, 14, 49, 46, 0, 40, 45, 0 };
104 BYTE HARCH33[] = { 3, 2, 1, 3, 0, 9, 5, 9, 140, 46, 0, 40, 45, 0 };
105 BYTE HARCH34[] = { 3, 2, 1, 3, 0, 9, 5, 6, 140, 46, 0, 40, 45, 0 };
106 BYTE HARCH35[] = { 3, 2, 1, 3, 0, 9, 5, 8, 140, 46, 0, 40, 45, 0 };
107 BYTE HARCH36[] = { 3, 2, 1, 3, 0, 9, 5, 7, 140, 46, 0, 40, 45, 0 };
108 BYTE HARCH37[] = { 3, 2, 1, 3, 0, 9, 5, 15, 140, 46, 0, 40, 45, 0 };
109 BYTE HARCH38[] = { 3, 2, 1, 3, 0, 9, 5, 16, 140, 46, 0, 40, 45, 0 };
110 BYTE HARCH39[] = { 3, 2, 1, 3, 0, 9, 5, 13, 140, 46, 0, 40, 45, 0 };
111 BYTE HARCH40[] = { 3, 2, 1, 3, 0, 9, 5, 14, 140, 46, 0, 40, 45, 0 };
112 BYTE USTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 72, 77, 0, 0, 76, 0, 0, 0, 0, 0, 0 };
113 BYTE DSTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 48, 71, 0, 0, 50, 78, 0, 0, 0, 0, 0 };
114 BYTE WARPSTAIRS[] = { 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 158, 160, 0, 0, 159, 0, 0, 0, 0, 0, 0 };
115 BYTE CRUSHCOL[] = { 3, 3, 3, 1, 3, 2, 6, 3, 3, 3, 3, 0, 0, 0, 0, 83, 0, 0, 0, 0 };
116 BYTE BIG1[] = { 2, 2, 3, 3, 3, 3, 113, 0, 112, 0 };
117 BYTE BIG2[] = { 2, 2, 3, 3, 3, 3, 114, 115, 0, 0 };
118 BYTE BIG3[] = { 1, 2, 1, 1, 117, 116 };
119 BYTE BIG4[] = { 2, 1, 2, 2, 118, 119 };
120 BYTE BIG5[] = { 2, 2, 3, 3, 3, 3, 120, 122, 121, 123 };
121 BYTE BIG6[] = { 1, 2, 1, 1, 125, 124 };
122 BYTE BIG7[] = { 2, 1, 2, 2, 126, 127 };
123 BYTE BIG8[] = { 2, 2, 3, 3, 3, 3, 128, 130, 129, 131 };
124 BYTE BIG9[] = { 2, 2, 1, 3, 1, 3, 133, 135, 132, 134 };
125 BYTE BIG10[] = { 2, 2, 2, 2, 3, 3, 136, 137, 3, 3 };
126 BYTE RUINS1[] = { 1, 1, 1, 80 };
127 BYTE RUINS2[] = { 1, 1, 1, 81 };
128 BYTE RUINS3[] = { 1, 1, 1, 82 };
129 BYTE RUINS4[] = { 1, 1, 2, 84 };
130 BYTE RUINS5[] = { 1, 1, 2, 85 };
131 BYTE RUINS6[] = { 1, 1, 2, 86 };
132 BYTE RUINS7[] = { 1, 1, 8, 87 };
133 BYTE PANCREAS1[] = { 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 108, 0, 0, 0, 0, 0, 0, 0 };
134 BYTE PANCREAS2[] = { 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 110, 0, 0, 0, 0, 0, 0, 0 };
135 BYTE CTRDOOR1[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 9, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
136 BYTE CTRDOOR2[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 8, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
137 BYTE CTRDOOR3[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 6, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
138 BYTE CTRDOOR4[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 7, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
139 BYTE CTRDOOR5[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 15, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
140 BYTE CTRDOOR6[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 13, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
141 BYTE CTRDOOR7[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 16, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
142 BYTE CTRDOOR8[] = { 3, 3, 3, 1, 3, 0, 4, 0, 0, 14, 0, 0, 4, 0, 0, 1, 0, 0, 0, 0 };
143 int Patterns[100][10] = {
144  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 3 },
145  { 0, 0, 0, 0, 2, 0, 0, 0, 0, 3 },
146  { 0, 7, 0, 0, 1, 0, 0, 5, 0, 2 },
147  { 0, 5, 0, 0, 1, 0, 0, 7, 0, 2 },
148  { 0, 0, 0, 7, 1, 5, 0, 0, 0, 1 },
149  { 0, 0, 0, 5, 1, 7, 0, 0, 0, 1 },
150  { 0, 1, 0, 0, 3, 0, 0, 1, 0, 4 },
151  { 0, 0, 0, 1, 3, 1, 0, 0, 0, 5 },
152  { 0, 6, 0, 6, 1, 0, 0, 0, 0, 6 },
153  { 0, 6, 0, 0, 1, 6, 0, 0, 0, 9 },
154  { 0, 0, 0, 6, 1, 0, 0, 6, 0, 7 },
155  { 0, 0, 0, 0, 1, 6, 0, 6, 0, 8 },
156  { 0, 6, 0, 6, 6, 0, 8, 6, 0, 7 },
157  { 0, 6, 8, 6, 6, 6, 0, 0, 0, 9 },
158  { 0, 6, 0, 0, 6, 6, 0, 6, 8, 8 },
159  { 6, 6, 6, 6, 6, 6, 0, 6, 0, 8 },
160  { 2, 6, 6, 6, 6, 6, 0, 6, 0, 8 },
161  { 7, 7, 7, 6, 6, 6, 0, 6, 0, 8 },
162  { 6, 6, 2, 6, 6, 6, 0, 6, 0, 8 },
163  { 6, 2, 6, 6, 6, 6, 0, 6, 0, 8 },
164  { 2, 6, 6, 6, 6, 6, 0, 6, 0, 8 },
165  { 6, 7, 7, 6, 6, 6, 0, 6, 0, 8 },
166  { 4, 4, 6, 6, 6, 6, 2, 6, 2, 8 },
167  { 2, 2, 2, 2, 6, 2, 2, 6, 2, 7 },
168  { 2, 2, 2, 2, 6, 2, 6, 6, 6, 7 },
169  { 2, 2, 6, 2, 6, 6, 2, 2, 6, 9 },
170  { 2, 6, 2, 2, 6, 2, 2, 2, 2, 6 },
171  { 2, 2, 2, 2, 6, 6, 2, 2, 2, 9 },
172  { 2, 2, 2, 6, 6, 2, 2, 2, 2, 6 },
173  { 2, 2, 0, 2, 6, 6, 2, 2, 0, 9 },
174  { 0, 0, 0, 0, 4, 0, 0, 0, 0, 12 },
175  { 0, 1, 0, 0, 1, 4, 0, 1, 0, 10 },
176  { 0, 0, 0, 1, 1, 1, 0, 4, 0, 11 },
177  { 0, 0, 0, 6, 1, 4, 0, 1, 0, 14 },
178  { 0, 6, 0, 1, 1, 0, 0, 4, 0, 16 },
179  { 0, 6, 0, 0, 1, 1, 0, 4, 0, 15 },
180  { 0, 0, 0, 0, 1, 1, 0, 1, 4, 13 },
181  { 8, 8, 8, 8, 1, 1, 0, 1, 1, 13 },
182  { 8, 8, 4, 8, 1, 1, 0, 1, 1, 10 },
183  { 0, 0, 0, 1, 1, 1, 1, 1, 1, 11 },
184  { 1, 1, 1, 1, 1, 1, 2, 2, 8, 2 },
185  { 0, 1, 0, 1, 1, 4, 1, 1, 0, 16 },
186  { 0, 0, 0, 1, 1, 1, 1, 1, 4, 11 },
187  { 1, 1, 4, 1, 1, 1, 0, 2, 2, 2 },
188  { 1, 1, 1, 1, 1, 1, 6, 2, 6, 2 },
189  { 4, 1, 1, 1, 1, 1, 6, 2, 6, 2 },
190  { 2, 2, 2, 1, 1, 1, 4, 1, 1, 11 },
191  { 4, 1, 1, 1, 1, 1, 2, 2, 2, 2 },
192  { 1, 1, 4, 1, 1, 1, 2, 2, 1, 2 },
193  { 4, 1, 1, 1, 1, 1, 1, 2, 2, 2 },
194  { 2, 2, 6, 1, 1, 1, 4, 1, 1, 11 },
195  { 4, 1, 1, 1, 1, 1, 2, 2, 6, 2 },
196  { 1, 2, 2, 1, 1, 1, 4, 1, 1, 11 },
197  { 0, 1, 1, 0, 1, 1, 0, 1, 1, 10 },
198  { 2, 1, 1, 3, 1, 1, 2, 1, 1, 14 },
199  { 1, 1, 0, 1, 1, 2, 1, 1, 0, 1 },
200  { 0, 4, 0, 1, 1, 1, 0, 1, 1, 14 },
201  { 4, 1, 0, 1, 1, 0, 1, 1, 0, 1 },
202  { 0, 1, 0, 4, 1, 1, 0, 1, 1, 15 },
203  { 1, 1, 1, 1, 1, 1, 0, 2, 2, 2 },
204  { 0, 1, 1, 2, 1, 1, 2, 1, 4, 10 },
205  { 2, 1, 1, 1, 1, 1, 0, 4, 0, 16 },
206  { 1, 1, 4, 1, 1, 2, 0, 1, 2, 1 },
207  { 2, 1, 1, 2, 1, 1, 1, 1, 4, 10 },
208  { 1, 1, 2, 1, 1, 2, 4, 1, 8, 1 },
209  { 2, 1, 4, 1, 1, 1, 4, 4, 1, 16 },
210  { 2, 1, 1, 1, 1, 1, 1, 1, 1, 16 },
211  { 1, 1, 2, 1, 1, 1, 1, 1, 1, 15 },
212  { 1, 1, 1, 1, 1, 1, 2, 1, 1, 14 },
213  { 4, 1, 1, 1, 1, 1, 2, 1, 1, 14 },
214  { 1, 1, 1, 1, 1, 1, 1, 1, 2, 8 },
215  { 0, 0, 0, 0, 255, 0, 0, 0, 0, 0 },
216  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
217  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
218  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
219  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
220  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
221  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
222  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
223  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
224  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
225  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
226  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
227  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
228  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
229  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
230  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
231  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
232  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
233  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
234  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
235  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
236  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
237  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
238  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
239  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
240  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
241  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
242  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
243  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
244 };
245 
246 static BOOL DRLG_L2PlaceMiniSet(BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir)
247 {
248  int sx, sy, sw, sh, xx, yy, i, ii, numt, bailcnt;
249  BOOL found;
250 
251  sw = miniset[0];
252  sh = miniset[1];
253 
254  if (tmax - tmin == 0) {
255  numt = 1;
256  } else {
257  numt = random_(0, tmax - tmin) + tmin;
258  }
259 
260  for (i = 0; i < numt; i++) {
261  sx = random_(0, DMAXX - sw);
262  sy = random_(0, DMAXY - sh);
263  found = FALSE;
264  for (bailcnt = 0; !found && bailcnt < 200; bailcnt++) {
265  found = TRUE;
266  if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) {
267  found = FALSE;
268  }
269  if (cx != -1 && sx >= cx - sw && sx <= cx + 12) {
270  sx = random_(0, DMAXX - sw);
271  sy = random_(0, DMAXY - sh);
272  found = FALSE;
273  }
274  if (cy != -1 && sy >= cy - sh && sy <= cy + 12) {
275  sx = random_(0, DMAXX - sw);
276  sy = random_(0, DMAXY - sh);
277  found = FALSE;
278  }
279  ii = 2;
280  for (yy = 0; yy < sh && found == TRUE; yy++) {
281  for (xx = 0; xx < sw && found == TRUE; xx++) {
282  if (miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) {
283  found = FALSE;
284  }
285  if (dflags[xx + sx][yy + sy] != 0) {
286  found = FALSE;
287  }
288  ii++;
289  }
290  }
291  if (!found) {
292  sx++;
293  if (sx == DMAXX - sw) {
294  sx = 0;
295  sy++;
296  if (sy == DMAXY - sh) {
297  sy = 0;
298  }
299  }
300  }
301  }
302  if (bailcnt >= 200) {
303  return FALSE;
304  }
305  ii = sw * sh + 2;
306  for (yy = 0; yy < sh; yy++) {
307  for (xx = 0; xx < sw; xx++) {
308  if (miniset[ii] != 0) {
309  dungeon[xx + sx][yy + sy] = miniset[ii];
310  }
311  ii++;
312  }
313  }
314  }
315 
316  if (setview == TRUE) {
317  ViewX = 2 * sx + 21;
318  ViewY = 2 * sy + 22;
319  }
320  if (ldir == 0) {
321  LvlViewX = 2 * sx + 21;
322  LvlViewY = 2 * sy + 22;
323  }
324  if (ldir == 6) {
325  LvlViewX = 2 * sx + 21;
326  LvlViewY = 2 * sy + 22;
327  }
328 
329  return TRUE;
330 }
331 
332 static void DRLG_L2PlaceRndSet(BYTE *miniset, int rndper)
333 {
334  int sx, sy, sw, sh, xx, yy, ii, kk;
335  BOOL found;
336 
337  sw = miniset[0];
338  sh = miniset[1];
339 
340  for (sy = 0; sy < DMAXY - sh; sy++) {
341  for (sx = 0; sx < DMAXX - sw; sx++) {
342  found = TRUE;
343  ii = 2;
344  if (sx >= nSx1 && sx <= nSx2 && sy >= nSy1 && sy <= nSy2) {
345  found = FALSE;
346  }
347  for (yy = 0; yy < sh && found == TRUE; yy++) {
348  for (xx = 0; xx < sw && found == TRUE; xx++) {
349  if (miniset[ii] != 0 && dungeon[xx + sx][yy + sy] != miniset[ii]) {
350  found = FALSE;
351  }
352  if (dflags[xx + sx][yy + sy] != 0) {
353  found = FALSE;
354  }
355  ii++;
356  }
357  }
358  kk = sw * sh + 2;
359  if (found == TRUE) {
360  for (yy = std::max(sy - sh, 0); yy < std::min(sy + 2 * sh, DMAXY) && found == TRUE; yy++) {
361  for (xx = std::max(sx - sw, 0); xx < std::min(sx + 2 * sw, DMAXX); xx++) {
362  // BUGFIX: yy and xx can go out of bounds (fixed)
363  if (dungeon[xx][yy] == miniset[kk]) {
364  found = FALSE;
365  }
366  }
367  }
368  }
369  if (found == TRUE && random_(0, 100) < rndper) {
370  for (yy = 0; yy < sh; yy++) {
371  for (xx = 0; xx < sw; xx++) {
372  if (miniset[kk] != 0) {
373  dungeon[xx + sx][yy + sy] = miniset[kk];
374  }
375  kk++;
376  }
377  }
378  }
379  }
380  }
381 }
382 
383 static void DRLG_L2Subs()
384 {
385  int x, y, i, j, k, rv;
386  BYTE c;
387 
388  for (y = 0; y < DMAXY; y++) {
389  for (x = 0; x < DMAXX; x++) {
390  if ((x < nSx1 || x > nSx2) && (y < nSy1 || y > nSy2) && random_(0, 4) == 0) {
391  c = BTYPESL2[dungeon[x][y]];
392  if (c != 0) {
393  rv = random_(0, 16);
394  k = -1;
395  while (rv >= 0) {
396  k++;
397  if (k == sizeof(BTYPESL2)) {
398  k = 0;
399  }
400  if (c == BTYPESL2[k]) {
401  rv--;
402  }
403  }
404  for (j = y - 2; j < y + 2; j++) {
405  for (i = x - 2; i < x + 2; i++) {
406  if (dungeon[i][j] == k) {
407  j = y + 3;
408  i = x + 2;
409  }
410  }
411  }
412  if (j < y + 3) {
413  dungeon[x][y] = k;
414  }
415  }
416  }
417  }
418  }
419 }
420 
421 static void DRLG_L2Shadows()
422 {
423  int x, y, i;
424  BOOL patflag;
425  BYTE sd[2][2];
426 
427  for (y = 1; y < DMAXY; y++) {
428  for (x = 1; x < DMAXX; x++) {
429  sd[0][0] = BSTYPESL2[dungeon[x][y]];
430  sd[1][0] = BSTYPESL2[dungeon[x - 1][y]];
431  sd[0][1] = BSTYPESL2[dungeon[x][y - 1]];
432  sd[1][1] = BSTYPESL2[dungeon[x - 1][y - 1]];
433  for (i = 0; i < 2; i++) {
434  if (SPATSL2[i].strig == sd[0][0]) {
435  patflag = TRUE;
436  if (SPATSL2[i].s1 != 0 && SPATSL2[i].s1 != sd[1][1]) {
437  patflag = FALSE;
438  }
439  if (SPATSL2[i].s2 != 0 && SPATSL2[i].s2 != sd[0][1]) {
440  patflag = FALSE;
441  }
442  if (SPATSL2[i].s3 != 0 && SPATSL2[i].s3 != sd[1][0]) {
443  patflag = FALSE;
444  }
445  if (patflag == TRUE) {
446  if (SPATSL2[i].nv1 != 0) {
447  dungeon[x - 1][y - 1] = SPATSL2[i].nv1;
448  }
449  if (SPATSL2[i].nv2 != 0) {
450  dungeon[x][y - 1] = SPATSL2[i].nv2;
451  }
452  if (SPATSL2[i].nv3 != 0) {
453  dungeon[x - 1][y] = SPATSL2[i].nv3;
454  }
455  }
456  }
457  }
458  }
459  }
460 }
461 
463 {
464  int i, j;
465 
466  for (j = 0; j < DMAXY; j++) {
467  for (i = 0; i < DMAXX; i++) {
468  predungeon[i][j] = 32;
469  dflags[i][j] = 0;
470  }
471  }
472 }
473 
474 static void DRLG_LoadL2SP()
475 {
476  setloadflag = FALSE;
477 
478  if (QuestStatus(Q_BLIND)) {
479  pSetPiece = LoadFileInMem("Levels\\L2Data\\Blind2.DUN", NULL);
480  setloadflag = TRUE;
481  } else if (QuestStatus(Q_BLOOD)) {
482  pSetPiece = LoadFileInMem("Levels\\L2Data\\Blood1.DUN", NULL);
483  setloadflag = TRUE;
484  } else if (QuestStatus(Q_SCHAMB)) {
485  pSetPiece = LoadFileInMem("Levels\\L2Data\\Bonestr2.DUN", NULL);
486  setloadflag = TRUE;
487  }
488 }
489 
490 static void DRLG_FreeL2SP()
491 {
493 }
494 
495 static void DRLG_L2SetRoom(int rx1, int ry1)
496 {
497  int rw, rh, i, j;
498  BYTE *sp;
499 
500  rw = pSetPiece[0];
501  rh = pSetPiece[2];
502 
503  setpc_x = rx1;
504  setpc_y = ry1;
505  setpc_w = rw;
506  setpc_h = rh;
507 
508  sp = &pSetPiece[4];
509 
510  for (j = 0; j < rh; j++) {
511  for (i = 0; i < rw; i++) {
512  if (*sp != 0) {
513  dungeon[i + rx1][j + ry1] = *sp;
514  dflags[i + rx1][j + ry1] |= DLRG_PROTECTED;
515  } else {
516  dungeon[i + rx1][j + ry1] = 3;
517  }
518  sp += 2;
519  }
520  }
521 }
522 
523 static void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW)
524 {
525  int i, j;
526 
527  predungeon[nX1][nY1] = 67;
528  predungeon[nX1][nY2] = 69;
529  predungeon[nX2][nY1] = 66;
530  predungeon[nX2][nY2] = 65;
531 
532  nRoomCnt++;
533  RoomList[nRoomCnt].nRoomx1 = nX1;
534  RoomList[nRoomCnt].nRoomx2 = nX2;
535  RoomList[nRoomCnt].nRoomy1 = nY1;
536  RoomList[nRoomCnt].nRoomy2 = nY2;
537 
538  if (ForceHW == TRUE) {
539  for (i = nX1; i < nX2; i++) {
541  while (i < nY2) {
542  dflags[i][nY1] |= DLRG_PROTECTED;
543  i++;
544  }
545  }
546  }
547  for (i = nX1 + 1; i <= nX2 - 1; i++) {
548  predungeon[i][nY1] = 35;
549  predungeon[i][nY2] = 35;
550  }
551  nY2--;
552  for (j = nY1 + 1; j <= nY2; j++) {
553  predungeon[nX1][j] = 35;
554  predungeon[nX2][j] = 35;
555  for (i = nX1 + 1; i < nX2; i++) {
556  predungeon[i][j] = 46;
557  }
558  }
559 }
560 
561 static void CreateDoorType(int nX, int nY)
562 {
563  BOOL fDoneflag;
564 
565  fDoneflag = FALSE;
566 
567  if (predungeon[nX - 1][nY] == 68) {
568  fDoneflag = TRUE;
569  }
570  if (predungeon[nX + 1][nY] == 68) {
571  fDoneflag = TRUE;
572  }
573  if (predungeon[nX][nY - 1] == 68) {
574  fDoneflag = TRUE;
575  }
576  if (predungeon[nX][nY + 1] == 68) {
577  fDoneflag = TRUE;
578  }
579  if (predungeon[nX][nY] == 66 || predungeon[nX][nY] == 67 || predungeon[nX][nY] == 65 || predungeon[nX][nY] == 69) {
580  fDoneflag = TRUE;
581  }
582 
583  if (!fDoneflag) {
584  predungeon[nX][nY] = 68;
585  }
586 }
587 
588 static void PlaceHallExt(int nX, int nY)
589 {
590  if (predungeon[nX][nY] == 32) {
591  predungeon[nX][nY] = 44;
592  }
593 }
594 
595 static void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd)
596 {
597  HALLNODE *p1, *p2;
598 
599  if (pHallList == NULL) {
601  pHallList->nHallx1 = nX1;
602  pHallList->nHally1 = nY1;
603  pHallList->nHallx2 = nX2;
604  pHallList->nHally2 = nY2;
605  pHallList->nHalldir = nHd;
606  pHallList->pNext = NULL;
607  } else {
608  p1 = (HALLNODE *)DiabloAllocPtr(sizeof(*pHallList));
609  p1->nHallx1 = nX1;
610  p1->nHally1 = nY1;
611  p1->nHallx2 = nX2;
612  p1->nHally2 = nY2;
613  p1->nHalldir = nHd;
614  p1->pNext = NULL;
615  p2 = pHallList;
616  while (p2->pNext != NULL) {
617  p2 = p2->pNext;
618  }
619  p2->pNext = p1;
620  }
621 }
622 
635 static void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL ForceHW, int nH, int nW)
636 {
637  int nAw, nAh, nRw, nRh, nRx1, nRy1, nRx2, nRy2, nHw, nHh, nHx1, nHy1, nHx2, nHy2, nRid;
638 
639  if (nRoomCnt >= 80) {
640  return;
641  }
642 
643  nAw = nX2 - nX1;
644  nAh = nY2 - nY1;
645  if (nAw < Area_Min || nAh < Area_Min) {
646  return;
647  }
648 
649  if (nAw > Room_Max) {
650  nRw = random_(0, Room_Max - Room_Min) + Room_Min;
651  } else if (nAw > Room_Min) {
652  nRw = random_(0, nAw - Room_Min) + Room_Min;
653  } else {
654  nRw = nAw;
655  }
656  if (nAh > Room_Max) {
657  nRh = random_(0, Room_Max - Room_Min) + Room_Min;
658  } else if (nAh > Room_Min) {
659  nRh = random_(0, nAh - Room_Min) + Room_Min;
660  } else {
661  nRh = nAh;
662  }
663 
664  if (ForceHW == TRUE) {
665  nRw = nW;
666  nRh = nH;
667  }
668 
669  nRx1 = random_(0, nX2 - nX1) + nX1;
670  nRy1 = random_(0, nY2 - nY1) + nY1;
671  nRx2 = nRw + nRx1;
672  nRy2 = nRh + nRy1;
673  if (nRx2 > nX2) {
674  nRx2 = nX2;
675  nRx1 = nX2 - nRw;
676  }
677  if (nRy2 > nY2) {
678  nRy2 = nY2;
679  nRy1 = nY2 - nRh;
680  }
681 
682  if (nRx1 >= 38) {
683  nRx1 = 38;
684  }
685  if (nRy1 >= 38) {
686  nRy1 = 38;
687  }
688  if (nRx1 <= 1) {
689  nRx1 = 1;
690  }
691  if (nRy1 <= 1) {
692  nRy1 = 1;
693  }
694  if (nRx2 >= 38) {
695  nRx2 = 38;
696  }
697  if (nRy2 >= 38) {
698  nRy2 = 38;
699  }
700  if (nRx2 <= 1) {
701  nRx2 = 1;
702  }
703  if (nRy2 <= 1) {
704  nRy2 = 1;
705  }
706  DefineRoom(nRx1, nRy1, nRx2, nRy2, ForceHW);
707 
708  if (ForceHW == TRUE) {
709  nSx1 = nRx1 + 2;
710  nSy1 = nRy1 + 2;
711  nSx2 = nRx2;
712  nSy2 = nRy2;
713  }
714 
715  nRid = nRoomCnt;
716  RoomList[nRid].nRoomDest = nRDest;
717 
718  if (nRDest != 0) {
719  if (nHDir == 1) {
720  nHx1 = random_(0, nRx2 - nRx1 - 2) + nRx1 + 1;
721  nHy1 = nRy1;
722  nHw = RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2;
723  nHx2 = random_(0, nHw) + RoomList[nRDest].nRoomx1 + 1;
724  nHy2 = RoomList[nRDest].nRoomy2;
725  }
726  if (nHDir == 3) {
727  nHx1 = random_(0, nRx2 - nRx1 - 2) + nRx1 + 1;
728  nHy1 = nRy2;
729  nHw = RoomList[nRDest].nRoomx2 - RoomList[nRDest].nRoomx1 - 2;
730  nHx2 = random_(0, nHw) + RoomList[nRDest].nRoomx1 + 1;
731  nHy2 = RoomList[nRDest].nRoomy1;
732  }
733  if (nHDir == 2) {
734  nHx1 = nRx2;
735  nHy1 = random_(0, nRy2 - nRy1 - 2) + nRy1 + 1;
736  nHx2 = RoomList[nRDest].nRoomx1;
737  nHh = RoomList[nRDest].nRoomy2 - RoomList[nRDest].nRoomy1 - 2;
738  nHy2 = random_(0, nHh) + RoomList[nRDest].nRoomy1 + 1;
739  }
740  if (nHDir == 4) {
741  nHx1 = nRx1;
742  nHy1 = random_(0, nRy2 - nRy1 - 2) + nRy1 + 1;
743  nHx2 = RoomList[nRDest].nRoomx2;
744  nHh = RoomList[nRDest].nRoomy2 - RoomList[nRDest].nRoomy1 - 2;
745  nHy2 = random_(0, nHh) + RoomList[nRDest].nRoomy1 + 1;
746  }
747  AddHall(nHx1, nHy1, nHx2, nHy2, nHDir);
748  }
749 
750  if (nRh > nRw) {
751  CreateRoom(nX1 + 2, nY1 + 2, nRx1 - 2, nRy2 - 2, nRid, 2, 0, 0, 0);
752  CreateRoom(nRx2 + 2, nRy1 + 2, nX2 - 2, nY2 - 2, nRid, 4, 0, 0, 0);
753  CreateRoom(nX1 + 2, nRy2 + 2, nRx2 - 2, nY2 - 2, nRid, 1, 0, 0, 0);
754  CreateRoom(nRx1 + 2, nY1 + 2, nX2 - 2, nRy1 - 2, nRid, 3, 0, 0, 0);
755  } else {
756  CreateRoom(nX1 + 2, nY1 + 2, nRx2 - 2, nRy1 - 2, nRid, 3, 0, 0, 0);
757  CreateRoom(nRx1 + 2, nRy2 + 2, nX2 - 2, nY2 - 2, nRid, 1, 0, 0, 0);
758  CreateRoom(nX1 + 2, nRy1 + 2, nRx1 - 2, nY2 - 2, nRid, 2, 0, 0, 0);
759  CreateRoom(nRx2 + 2, nY1 + 2, nX2 - 2, nRy2 - 2, nRid, 4, 0, 0, 0);
760  }
761 }
762 
763 static void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd)
764 {
765  HALLNODE *p1;
766 
767  p1 = pHallList->pNext;
768  *nX1 = pHallList->nHallx1;
769  *nY1 = pHallList->nHally1;
770  *nX2 = pHallList->nHallx2;
771  *nY2 = pHallList->nHally2;
772  *nHd = pHallList->nHalldir;
774  pHallList = p1;
775 }
776 
777 static void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd)
778 {
779  int nCurrd, nDx, nDy, nRp, nOrigX1, nOrigY1, fMinusFlag, fPlusFlag;
780  BOOL fDoneflag, fInroom;
781 
782  fDoneflag = FALSE;
783  fMinusFlag = random_(0, 100);
784  fPlusFlag = random_(0, 100);
785  nOrigX1 = nX1;
786  nOrigY1 = nY1;
787  CreateDoorType(nX1, nY1);
788  CreateDoorType(nX2, nY2);
789  nDx = abs(nX2 - nX1); /* unused */
790  nDy = abs(nY2 - nY1); /* unused */
791  nCurrd = nHd;
792  nX2 -= Dir_Xadd[nCurrd];
793  nY2 -= Dir_Yadd[nCurrd];
794  predungeon[nX2][nY2] = 44;
795  fInroom = FALSE;
796 
797  while (!fDoneflag) {
798  if (nX1 >= 38 && nCurrd == 2) {
799  nCurrd = 4;
800  }
801  if (nY1 >= 38 && nCurrd == 3) {
802  nCurrd = 1;
803  }
804  if (nX1 <= 1 && nCurrd == 4) {
805  nCurrd = 2;
806  }
807  if (nY1 <= 1 && nCurrd == 1) {
808  nCurrd = 3;
809  }
810  if (predungeon[nX1][nY1] == 67 && (nCurrd == 1 || nCurrd == 4)) {
811  nCurrd = 2;
812  }
813  if (predungeon[nX1][nY1] == 66 && (nCurrd == 1 || nCurrd == 2)) {
814  nCurrd = 3;
815  }
816  if (predungeon[nX1][nY1] == 69 && (nCurrd == 4 || nCurrd == 3)) {
817  nCurrd = 1;
818  }
819  if (predungeon[nX1][nY1] == 65 && (nCurrd == 2 || nCurrd == 3)) {
820  nCurrd = 4;
821  }
822  nX1 += Dir_Xadd[nCurrd];
823  nY1 += Dir_Yadd[nCurrd];
824  if (predungeon[nX1][nY1] == 32) {
825  if (fInroom) {
826  CreateDoorType(nX1 - Dir_Xadd[nCurrd], nY1 - Dir_Yadd[nCurrd]);
827  } else {
828  if (fMinusFlag < 50) {
829  if (nCurrd != 1 && nCurrd != 3) {
830  PlaceHallExt(nX1, nY1 - 1);
831  } else {
832  PlaceHallExt(nX1 - 1, nY1);
833  }
834  }
835  if (fPlusFlag < 50) {
836  if (nCurrd != 1 && nCurrd != 3) {
837  PlaceHallExt(nX1, nY1 + 1);
838  } else {
839  PlaceHallExt(nX1 + 1, nY1);
840  }
841  }
842  }
843  predungeon[nX1][nY1] = 44;
844  fInroom = FALSE;
845  } else {
846  if (!fInroom && predungeon[nX1][nY1] == 35) {
847  CreateDoorType(nX1, nY1);
848  }
849  if (predungeon[nX1][nY1] != 44) {
850  fInroom = TRUE;
851  }
852  }
853  nDx = abs(nX2 - nX1);
854  nDy = abs(nY2 - nY1);
855  if (nDx > nDy) {
856  nRp = 2 * nDx;
857  if (nRp > 30) {
858  nRp = 30;
859  }
860  if (random_(0, 100) < nRp) {
861  if (nX2 <= nX1 || nX1 >= DMAXX) {
862  nCurrd = 4;
863  } else {
864  nCurrd = 2;
865  }
866  }
867  } else {
868  nRp = 5 * nDy;
869  if (nRp > 80) {
870  nRp = 80;
871  }
872  if (random_(0, 100) < nRp) {
873  if (nY2 <= nY1 || nY1 >= DMAXY) {
874  nCurrd = 1;
875  } else {
876  nCurrd = 3;
877  }
878  }
879  }
880  if (nDy < 10 && nX1 == nX2 && (nCurrd == 2 || nCurrd == 4)) {
881  if (nY2 <= nY1 || nY1 >= DMAXY) {
882  nCurrd = 1;
883  } else {
884  nCurrd = 3;
885  }
886  }
887  if (nDx < 10 && nY1 == nY2 && (nCurrd == 1 || nCurrd == 3)) {
888  if (nX2 <= nX1 || nX1 >= DMAXX) {
889  nCurrd = 4;
890  } else {
891  nCurrd = 2;
892  }
893  }
894  if (nDy == 1 && nDx > 1 && (nCurrd == 1 || nCurrd == 3)) {
895  if (nX2 <= nX1 || nX1 >= DMAXX) {
896  nCurrd = 4;
897  } else {
898  nCurrd = 2;
899  }
900  }
901  if (nDx == 1 && nDy > 1 && (nCurrd == 2 || nCurrd == 4)) {
902  if (nY2 <= nY1 || nX1 >= DMAXX) {
903  nCurrd = 1;
904  } else {
905  nCurrd = 3;
906  }
907  }
908  if (nDx == 0 && predungeon[nX1][nY1] != 32 && (nCurrd == 2 || nCurrd == 4)) {
909  if (nX2 <= nOrigX1 || nX1 >= DMAXX) {
910  nCurrd = 1;
911  } else {
912  nCurrd = 3;
913  }
914  }
915  if (nDy == 0 && predungeon[nX1][nY1] != 32 && (nCurrd == 1 || nCurrd == 3)) {
916  if (nY2 <= nOrigY1 || nY1 >= DMAXY) {
917  nCurrd = 4;
918  } else {
919  nCurrd = 2;
920  }
921  }
922  if (nX1 == nX2 && nY1 == nY2) {
923  fDoneflag = TRUE;
924  }
925  }
926 }
927 
928 static void DoPatternCheck(int i, int j)
929 {
930  int k, l, x, y, nOk;
931 
932  for (k = 0; Patterns[k][4] != 255; k++) {
933  x = i - 1;
934  y = j - 1;
935  nOk = 254;
936  for (l = 0; l < 9 && nOk == 254; l++) {
937  nOk = 255;
938  if (l == 3 || l == 6) {
939  y++;
940  x = i - 1;
941  }
942  if (x >= 0 && x < DMAXX && y >= 0 && y < DMAXY) {
943  switch (Patterns[k][l]) {
944  case 0:
945  nOk = 254;
946  break;
947  case 1:
948  if (predungeon[x][y] == 35) {
949  nOk = 254;
950  }
951  break;
952  case 2:
953  if (predungeon[x][y] == 46) {
954  nOk = 254;
955  }
956  break;
957  case 4:
958  if (predungeon[x][y] == 32) {
959  nOk = 254;
960  }
961  break;
962  case 3:
963  if (predungeon[x][y] == 68) {
964  nOk = 254;
965  }
966  break;
967  case 5:
968  if (predungeon[x][y] == 68 || predungeon[x][y] == 46) {
969  nOk = 254;
970  }
971  break;
972  case 6:
973  if (predungeon[x][y] == 68 || predungeon[x][y] == 35) {
974  nOk = 254;
975  }
976  break;
977  case 7:
978  if (predungeon[x][y] == 32 || predungeon[x][y] == 46) {
979  nOk = 254;
980  }
981  break;
982  case 8:
983  if (predungeon[x][y] == 68 || predungeon[x][y] == 35 || predungeon[x][y] == 46) {
984  nOk = 254;
985  }
986  break;
987  }
988  } else {
989  nOk = 254;
990  }
991  x++;
992  }
993  if (nOk == 254) {
994  dungeon[i][j] = Patterns[k][9];
995  }
996  }
997 }
998 
999 static void L2TileFix()
1000 {
1001  int i, j;
1002 
1003  for (j = 0; j < DMAXY; j++) {
1004  for (i = 0; i < DMAXX; i++) {
1005  if (dungeon[i][j] == 1 && dungeon[i][j + 1] == 3) {
1006  dungeon[i][j + 1] = 1;
1007  }
1008  if (dungeon[i][j] == 3 && dungeon[i][j + 1] == 1) {
1009  dungeon[i][j + 1] = 3;
1010  }
1011  if (dungeon[i][j] == 3 && dungeon[i + 1][j] == 7) {
1012  dungeon[i + 1][j] = 3;
1013  }
1014  if (dungeon[i][j] == 2 && dungeon[i + 1][j] == 3) {
1015  dungeon[i + 1][j] = 2;
1016  }
1017  if (dungeon[i][j] == 11 && dungeon[i + 1][j] == 14) {
1018  dungeon[i + 1][j] = 16;
1019  }
1020  }
1021  }
1022 }
1023 
1024 static BOOL DL2_Cont(BOOL x1f, BOOL y1f, BOOL x2f, BOOL y2f)
1025 {
1026  if (x1f && x2f && y1f && y2f) {
1027  return FALSE;
1028  }
1029  if (x1f && x2f && (y1f || y2f)) {
1030  return TRUE;
1031  }
1032  if (y1f && y2f && (x1f || x2f)) {
1033  return TRUE;
1034  }
1035 
1036  return FALSE;
1037 }
1038 
1039 static int DL2_NumNoChar()
1040 {
1041  int t, ii, jj;
1042 
1043  t = 0;
1044  for (jj = 0; jj < DMAXY; jj++) {
1045  for (ii = 0; ii < DMAXX; ii++) {
1046  if (predungeon[ii][jj] == 32) {
1047  t++;
1048  }
1049  }
1050  }
1051 
1052  return t;
1053 }
1054 
1055 static void DL2_DrawRoom(int x1, int y1, int x2, int y2)
1056 {
1057  int ii, jj;
1058 
1059  for (jj = y1; jj <= y2; jj++) {
1060  for (ii = x1; ii <= x2; ii++) {
1061  predungeon[ii][jj] = 46;
1062  }
1063  }
1064  for (jj = y1; jj <= y2; jj++) {
1065  predungeon[x1][jj] = 35;
1066  predungeon[x2][jj] = 35;
1067  }
1068  for (ii = x1; ii <= x2; ii++) {
1069  predungeon[ii][y1] = 35;
1070  predungeon[ii][y2] = 35;
1071  }
1072 }
1073 
1074 static void DL2_KnockWalls(int x1, int y1, int x2, int y2)
1075 {
1076  int ii, jj;
1077 
1078  for (ii = x1 + 1; ii < x2; ii++) {
1079  if (predungeon[ii][y1 - 1] == 46 && predungeon[ii][y1 + 1] == 46) {
1080  predungeon[ii][y1] = 46;
1081  }
1082  if (predungeon[ii][y2 - 1] == 46 && predungeon[ii][y2 + 1] == 46) {
1083  predungeon[ii][y2] = 46;
1084  }
1085  if (predungeon[ii][y1 - 1] == 68) {
1086  predungeon[ii][y1 - 1] = 46;
1087  }
1088  if (predungeon[ii][y2 + 1] == 68) {
1089  predungeon[ii][y2 + 1] = 46;
1090  }
1091  }
1092  for (jj = y1 + 1; jj < y2; jj++) {
1093  if (predungeon[x1 - 1][jj] == 46 && predungeon[x1 + 1][jj] == 46) {
1094  predungeon[x1][jj] = 46;
1095  }
1096  if (predungeon[x2 - 1][jj] == 46 && predungeon[x2 + 1][jj] == 46) {
1097  predungeon[x2][jj] = 46;
1098  }
1099  if (predungeon[x1 - 1][jj] == 68) {
1100  predungeon[x1 - 1][jj] = 46;
1101  }
1102  if (predungeon[x2 + 1][jj] == 68) {
1103  predungeon[x2 + 1][jj] = 46;
1104  }
1105  }
1106 }
1107 
1108 static BOOL DL2_FillVoids()
1109 {
1110  int ii, jj, xx, yy, x1, x2, y1, y2;
1111  BOOL xf1, xf2, yf1, yf2;
1112  int to;
1113 
1114  to = 0;
1115  while (DL2_NumNoChar() > 700 && to < 100) {
1116  xx = random_(0, 38) + 1;
1117  yy = random_(0, 38) + 1;
1118  if (predungeon[xx][yy] != 35) {
1119  continue;
1120  }
1121  xf1 = xf2 = yf1 = yf2 = FALSE;
1122  if (predungeon[xx - 1][yy] == 32 && predungeon[xx + 1][yy] == 46) {
1123  if (predungeon[xx + 1][yy - 1] == 46
1124  && predungeon[xx + 1][yy + 1] == 46
1125  && predungeon[xx - 1][yy - 1] == 32
1126  && predungeon[xx - 1][yy + 1] == 32) {
1127  xf1 = yf1 = yf2 = TRUE;
1128  }
1129  } else if (predungeon[xx + 1][yy] == 32 && predungeon[xx - 1][yy] == 46) {
1130  if (predungeon[xx - 1][yy - 1] == 46
1131  && predungeon[xx - 1][yy + 1] == 46
1132  && predungeon[xx + 1][yy - 1] == 32
1133  && predungeon[xx + 1][yy + 1] == 32) {
1134  xf2 = yf1 = yf2 = TRUE;
1135  }
1136  } else if (predungeon[xx][yy - 1] == 32 && predungeon[xx][yy + 1] == 46) {
1137  if (predungeon[xx - 1][yy + 1] == 46
1138  && predungeon[xx + 1][yy + 1] == 46
1139  && predungeon[xx - 1][yy - 1] == 32
1140  && predungeon[xx + 1][yy - 1] == 32) {
1141  yf1 = xf1 = xf2 = TRUE;
1142  }
1143  } else if (predungeon[xx][yy + 1] == 32 && predungeon[xx][yy - 1] == 46) {
1144  if (predungeon[xx - 1][yy - 1] == 46
1145  && predungeon[xx + 1][yy - 1] == 46
1146  && predungeon[xx - 1][yy + 1] == 32
1147  && predungeon[xx + 1][yy + 1] == 32) {
1148  yf2 = xf1 = xf2 = TRUE;
1149  }
1150  }
1151  if (DL2_Cont(xf1, yf1, xf2, yf2)) {
1152  if (xf1) {
1153  x1 = xx - 1;
1154  } else {
1155  x1 = xx;
1156  }
1157  if (xf2) {
1158  x2 = xx + 1;
1159  } else {
1160  x2 = xx;
1161  }
1162  if (yf1) {
1163  y1 = yy - 1;
1164  } else {
1165  y1 = yy;
1166  }
1167  if (yf2) {
1168  y2 = yy + 1;
1169  } else {
1170  y2 = yy;
1171  }
1172  if (!xf1) {
1173  while (yf1 || yf2) {
1174  if (y1 == 0) {
1175  yf1 = FALSE;
1176  }
1177  if (y2 == DMAXY - 1) {
1178  yf2 = FALSE;
1179  }
1180  if (y2 - y1 >= 14) {
1181  yf1 = FALSE;
1182  yf2 = FALSE;
1183  }
1184  if (yf1) {
1185  y1--;
1186  }
1187  if (yf2) {
1188  y2++;
1189  }
1190  if (predungeon[x2][y1] != 32) {
1191  yf1 = FALSE;
1192  }
1193  if (predungeon[x2][y2] != 32) {
1194  yf2 = FALSE;
1195  }
1196  }
1197  y1 += 2;
1198  y2 -= 2;
1199  if (y2 - y1 > 5) {
1200  while (xf2) {
1201  if (x2 == 39) {
1202  xf2 = FALSE;
1203  }
1204  if (x2 - x1 >= 12) {
1205  xf2 = FALSE;
1206  }
1207  for (jj = y1; jj <= y2; jj++) {
1208  if (predungeon[x2][jj] != 32) {
1209  xf2 = FALSE;
1210  }
1211  }
1212  if (xf2) {
1213  x2++;
1214  }
1215  }
1216  x2 -= 2;
1217  if (x2 - x1 > 5) {
1218  DL2_DrawRoom(x1, y1, x2, y2);
1219  DL2_KnockWalls(x1, y1, x2, y2);
1220  }
1221  }
1222  } else if (!xf2) {
1223  while (yf1 || yf2) {
1224  if (y1 == 0) {
1225  yf1 = FALSE;
1226  }
1227  if (y2 == DMAXY - 1) {
1228  yf2 = FALSE;
1229  }
1230  if (y2 - y1 >= 14) {
1231  yf1 = FALSE;
1232  yf2 = FALSE;
1233  }
1234  if (yf1) {
1235  y1--;
1236  }
1237  if (yf2) {
1238  y2++;
1239  }
1240  if (predungeon[x1][y1] != 32) {
1241  yf1 = FALSE;
1242  }
1243  if (predungeon[x1][y2] != 32) {
1244  yf2 = FALSE;
1245  }
1246  }
1247  y1 += 2;
1248  y2 -= 2;
1249  if (y2 - y1 > 5) {
1250  while (xf1) {
1251  if (x1 == 0) {
1252  xf1 = FALSE;
1253  }
1254  if (x2 - x1 >= 12) {
1255  xf1 = FALSE;
1256  }
1257  for (jj = y1; jj <= y2; jj++) {
1258  if (predungeon[x1][jj] != 32) {
1259  xf1 = FALSE;
1260  }
1261  }
1262  if (xf1) {
1263  x1--;
1264  }
1265  }
1266  x1 += 2;
1267  if (x2 - x1 > 5) {
1268  DL2_DrawRoom(x1, y1, x2, y2);
1269  DL2_KnockWalls(x1, y1, x2, y2);
1270  }
1271  }
1272  } else if (!yf1) {
1273  while (xf1 || xf2) {
1274  if (x1 == 0) {
1275  xf1 = FALSE;
1276  }
1277  if (x2 == DMAXX - 1) {
1278  xf2 = FALSE;
1279  }
1280  if (x2 - x1 >= 14) {
1281  xf1 = FALSE;
1282  xf2 = FALSE;
1283  }
1284  if (xf1) {
1285  x1--;
1286  }
1287  if (xf2) {
1288  x2++;
1289  }
1290  if (predungeon[x1][y2] != 32) {
1291  xf1 = FALSE;
1292  }
1293  if (predungeon[x2][y2] != 32) {
1294  xf2 = FALSE;
1295  }
1296  }
1297  x1 += 2;
1298  x2 -= 2;
1299  if (x2 - x1 > 5) {
1300  while (yf2) {
1301  if (y2 == DMAXY - 1) {
1302  yf2 = FALSE;
1303  }
1304  if (y2 - y1 >= 12) {
1305  yf2 = FALSE;
1306  }
1307  for (ii = x1; ii <= x2; ii++) {
1308  if (predungeon[ii][y2] != 32) {
1309  yf2 = FALSE;
1310  }
1311  }
1312  if (yf2) {
1313  y2++;
1314  }
1315  }
1316  y2 -= 2;
1317  if (y2 - y1 > 5) {
1318  DL2_DrawRoom(x1, y1, x2, y2);
1319  DL2_KnockWalls(x1, y1, x2, y2);
1320  }
1321  }
1322  } else if (!yf2) {
1323  while (xf1 || xf2) {
1324  if (x1 == 0) {
1325  xf1 = FALSE;
1326  }
1327  if (x2 == DMAXX - 1) {
1328  xf2 = FALSE;
1329  }
1330  if (x2 - x1 >= 14) {
1331  xf1 = FALSE;
1332  xf2 = FALSE;
1333  }
1334  if (xf1) {
1335  x1--;
1336  }
1337  if (xf2) {
1338  x2++;
1339  }
1340  if (predungeon[x1][y1] != 32) {
1341  xf1 = FALSE;
1342  }
1343  if (predungeon[x2][y1] != 32) {
1344  xf2 = FALSE;
1345  }
1346  }
1347  x1 += 2;
1348  x2 -= 2;
1349  if (x2 - x1 > 5) {
1350  while (yf1) {
1351  if (y1 == 0) {
1352  yf1 = FALSE;
1353  }
1354  if (y2 - y1 >= 12) {
1355  yf1 = FALSE;
1356  }
1357  for (ii = x1; ii <= x2; ii++) {
1358  if (predungeon[ii][y1] != 32) {
1359  yf1 = FALSE;
1360  }
1361  }
1362  if (yf1) {
1363  y1--;
1364  }
1365  }
1366  y1 += 2;
1367  if (y2 - y1 > 5) {
1368  DL2_DrawRoom(x1, y1, x2, y2);
1369  DL2_KnockWalls(x1, y1, x2, y2);
1370  }
1371  }
1372  }
1373  }
1374  to++;
1375  }
1376 
1377  return DL2_NumNoChar() <= 700;
1378 }
1379 
1380 static BOOL CreateDungeon()
1381 {
1382  int i, j, nHx1, nHy1, nHx2, nHy2, nHd, ForceH, ForceW;
1383  BOOL ForceHW;
1384 
1385  ForceW = 0;
1386  ForceH = 0;
1387  ForceHW = FALSE;
1388 
1389  switch (currlevel) {
1390  case 5:
1391  if (quests[Q_BLOOD]._qactive) {
1392  ForceHW = TRUE;
1393  ForceH = 20;
1394  ForceW = 14;
1395  }
1396  break;
1397  case 6:
1398  if (quests[Q_SCHAMB]._qactive) {
1399  ForceHW = TRUE;
1400  ForceW = 10;
1401  ForceH = 10;
1402  }
1403  break;
1404  case 7:
1405  if (quests[Q_BLIND]._qactive) {
1406  ForceHW = TRUE;
1407  ForceW = 15;
1408  ForceH = 15;
1409  }
1410  break;
1411  case 8:
1412  break;
1413  }
1414 
1415  CreateRoom(2, 2, DMAXX - 1, DMAXY - 1, 0, 0, ForceHW, ForceH, ForceW);
1416 
1417  while (pHallList != NULL) {
1418  GetHall(&nHx1, &nHy1, &nHx2, &nHy2, &nHd);
1419  ConnectHall(nHx1, nHy1, nHx2, nHy2, nHd);
1420  }
1421 
1422  for (j = 0; j < DMAXY; j++) {
1423  for (i = 0; i < DMAXX; i++) {
1424  if (predungeon[i][j] == 67) {
1425  predungeon[i][j] = 35;
1426  }
1427  if (predungeon[i][j] == 66) {
1428  predungeon[i][j] = 35;
1429  }
1430  if (predungeon[i][j] == 69) {
1431  predungeon[i][j] = 35;
1432  }
1433  if (predungeon[i][j] == 65) {
1434  predungeon[i][j] = 35;
1435  }
1436  if (predungeon[i][j] == 44) {
1437  predungeon[i][j] = 46;
1438  if (predungeon[i - 1][j - 1] == 32) {
1439  predungeon[i - 1][j - 1] = 35;
1440  }
1441  if (predungeon[i - 1][j] == 32) {
1442  predungeon[i - 1][j] = 35;
1443  }
1444  if (predungeon[i - 1][1 + j] == 32) {
1445  predungeon[i - 1][1 + j] = 35;
1446  }
1447  if (predungeon[i + 1][j - 1] == 32) {
1448  predungeon[i + 1][j - 1] = 35;
1449  }
1450  if (predungeon[i + 1][j] == 32) {
1451  predungeon[i + 1][j] = 35;
1452  }
1453  if (predungeon[i + 1][1 + j] == 32) {
1454  predungeon[i + 1][1 + j] = 35;
1455  }
1456  if (predungeon[i][j - 1] == 32) {
1457  predungeon[i][j - 1] = 35;
1458  }
1459  if (predungeon[i][j + 1] == 32) {
1460  predungeon[i][j + 1] = 35;
1461  }
1462  }
1463  }
1464  }
1465 
1466  if (!DL2_FillVoids()) {
1467  return FALSE;
1468  }
1469 
1470  for (j = 0; j < DMAXY; j++) {
1471  for (i = 0; i < DMAXX; i++) {
1472  DoPatternCheck(i, j);
1473  }
1474  }
1475 
1476  return TRUE;
1477 }
1478 
1479 static void DRLG_L2Pass3()
1480 {
1481  int i, j, xx, yy;
1482  long v1, v2, v3, v4, lv;
1483  WORD *MegaTiles;
1484 
1485  lv = 12 - 1;
1486 
1487  MegaTiles = (WORD *)&pMegaTiles[lv * 8];
1488  v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
1489  v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
1490  v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
1491  v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
1492 
1493  for (j = 0; j < MAXDUNY; j += 2)
1494  {
1495  for (i = 0; i < MAXDUNX; i += 2) {
1496  dPiece[i][j] = v1;
1497  dPiece[i + 1][j] = v2;
1498  dPiece[i][j + 1] = v3;
1499  dPiece[i + 1][j + 1] = v4;
1500  }
1501  }
1502 
1503  yy = 16;
1504  for (j = 0; j < DMAXY; j++) {
1505  xx = 16;
1506  for (i = 0; i < DMAXX; i++) {
1507  lv = dungeon[i][j] - 1;
1508  MegaTiles = (WORD *)&pMegaTiles[lv * 8];
1509  v1 = SDL_SwapLE16(*(MegaTiles + 0)) + 1;
1510  v2 = SDL_SwapLE16(*(MegaTiles + 1)) + 1;
1511  v3 = SDL_SwapLE16(*(MegaTiles + 2)) + 1;
1512  v4 = SDL_SwapLE16(*(MegaTiles + 3)) + 1;
1513  dPiece[xx][yy] = v1;
1514  dPiece[xx + 1][yy] = v2;
1515  dPiece[xx][yy + 1] = v3;
1516  dPiece[xx + 1][yy + 1] = v4;
1517  xx += 2;
1518  }
1519  yy += 2;
1520  }
1521 }
1522 
1523 static void DRLG_L2FTVR(int i, int j, int x, int y, int d)
1524 {
1525  if (dTransVal[x][y] != 0 || dungeon[i][j] != 3) {
1526  if (d == 1) {
1527  dTransVal[x][y] = TransVal;
1528  dTransVal[x][y + 1] = TransVal;
1529  }
1530  if (d == 2) {
1531  dTransVal[x + 1][y] = TransVal;
1532  dTransVal[x + 1][y + 1] = TransVal;
1533  }
1534  if (d == 3) {
1535  dTransVal[x][y] = TransVal;
1536  dTransVal[x + 1][y] = TransVal;
1537  }
1538  if (d == 4) {
1539  dTransVal[x][y + 1] = TransVal;
1540  dTransVal[x + 1][y + 1] = TransVal;
1541  }
1542  if (d == 5) {
1543  dTransVal[x + 1][y + 1] = TransVal;
1544  }
1545  if (d == 6) {
1546  dTransVal[x][y + 1] = TransVal;
1547  }
1548  if (d == 7) {
1549  dTransVal[x + 1][y] = TransVal;
1550  }
1551  if (d == 8) {
1552  dTransVal[x][y] = TransVal;
1553  }
1554  } else {
1555  dTransVal[x][y] = TransVal;
1556  dTransVal[x + 1][y] = TransVal;
1557  dTransVal[x][y + 1] = TransVal;
1558  dTransVal[x + 1][y + 1] = TransVal;
1559  DRLG_L2FTVR(i + 1, j, x + 2, y, 1);
1560  DRLG_L2FTVR(i - 1, j, x - 2, y, 2);
1561  DRLG_L2FTVR(i, j + 1, x, y + 2, 3);
1562  DRLG_L2FTVR(i, j - 1, x, y - 2, 4);
1563  DRLG_L2FTVR(i - 1, j - 1, x - 2, y - 2, 5);
1564  DRLG_L2FTVR(i + 1, j - 1, x + 2, y - 2, 6);
1565  DRLG_L2FTVR(i - 1, j + 1, x - 2, y + 2, 7);
1566  DRLG_L2FTVR(i + 1, j + 1, x + 2, y + 2, 8);
1567  }
1568 }
1569 
1570 static void DRLG_L2FloodTVal()
1571 {
1572  int i, j, xx, yy;
1573 
1574  yy = 16;
1575  for (j = 0; j < DMAXY; j++) {
1576  xx = 16;
1577  for (i = 0; i < DMAXX; i++) {
1578  if (dungeon[i][j] == 3 && dTransVal[xx][yy] == 0) {
1579  DRLG_L2FTVR(i, j, xx, yy, 0);
1580  TransVal++;
1581  }
1582  xx += 2;
1583  }
1584  yy += 2;
1585  }
1586 }
1587 
1588 static void DRLG_L2TransFix()
1589 {
1590  int i, j, xx, yy;
1591 
1592  yy = 16;
1593  for (j = 0; j < DMAXY; j++) {
1594  xx = 16;
1595  for (i = 0; i < DMAXX; i++) {
1596  if (dungeon[i][j] == 14 && dungeon[i][j - 1] == 10) {
1597  dTransVal[xx + 1][yy] = dTransVal[xx][yy];
1598  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1599  }
1600  if (dungeon[i][j] == 15 && dungeon[i + 1][j] == 11) {
1601  dTransVal[xx][yy + 1] = dTransVal[xx][yy];
1602  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1603  }
1604  if (dungeon[i][j] == 10) {
1605  dTransVal[xx + 1][yy] = dTransVal[xx][yy];
1606  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1607  }
1608  if (dungeon[i][j] == 11) {
1609  dTransVal[xx][yy + 1] = dTransVal[xx][yy];
1610  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1611  }
1612  if (dungeon[i][j] == 16) {
1613  dTransVal[xx + 1][yy] = dTransVal[xx][yy];
1614  dTransVal[xx][yy + 1] = dTransVal[xx][yy];
1615  dTransVal[xx + 1][yy + 1] = dTransVal[xx][yy];
1616  }
1617  xx += 2;
1618  }
1619  yy += 2;
1620  }
1621 }
1622 
1623 static void L2DirtFix()
1624 {
1625  int i, j;
1626 
1627  for (j = 0; j < DMAXY; j++) {
1628  for (i = 0; i < DMAXX; i++) {
1629  if (dungeon[i][j] == 13 && dungeon[i + 1][j] != 11) {
1630  dungeon[i][j] = 146;
1631  }
1632  if (dungeon[i][j] == 11 && dungeon[i + 1][j] != 11) {
1633  dungeon[i][j] = 144;
1634  }
1635  if (dungeon[i][j] == 15 && dungeon[i + 1][j] != 11) {
1636  dungeon[i][j] = 148;
1637  }
1638  if (dungeon[i][j] == 10 && dungeon[i][j + 1] != 10) {
1639  dungeon[i][j] = 143;
1640  }
1641  if (dungeon[i][j] == 13 && dungeon[i][j + 1] != 10) {
1642  dungeon[i][j] = 146;
1643  }
1644  if (dungeon[i][j] == 14 && dungeon[i][j + 1] != 15) {
1645  dungeon[i][j] = 147;
1646  }
1647  }
1648  }
1649 }
1650 
1652 {
1653  int i, j;
1654  BOOL doorok;
1655 
1656  for (j = 0; j < DMAXY; j++) {
1657  for (i = 0; i < DMAXX; i++) {
1658  if (dungeon[i][j] == 4 && dungeon[i - 1][j] != 3) {
1659  dungeon[i][j] = 1;
1660  }
1661  if (dungeon[i][j] == 5 && dungeon[i][j - 1] != 3) {
1662  dungeon[i][j] = 2;
1663  }
1664  }
1665  }
1666  for (j = 1; j < DMAXY - 1; j++) {
1667  for (i = 1; i < DMAXX - 1; i++) {
1668  if (dflags[i][j] & DLRG_PROTECTED) {
1669  continue;
1670  }
1671  if ((dungeon[i][j] == 2 || dungeon[i][j] == 5) && dungeon[i][j - 1] == 3 && dungeon[i][j + 1] == 3) {
1672  doorok = FALSE;
1673  while (1) {
1674  if (dungeon[i][j] != 2 && dungeon[i][j] != 5) {
1675  break;
1676  }
1677  if (dungeon[i][j - 1] != 3 || dungeon[i][j + 1] != 3) {
1678  break;
1679  }
1680  if (dungeon[i][j] == 5) {
1681  doorok = TRUE;
1682  }
1683  i++;
1684  }
1685  if (!doorok && !(dflags[i - 1][j] & DLRG_PROTECTED)) {
1686  dungeon[i - 1][j] = 5;
1687  }
1688  }
1689  }
1690  }
1691  for (j = 1; j < DMAXX - 1; j++) { /* check: might be flipped */
1692  for (i = 1; i < DMAXY - 1; i++) {
1693  if (dflags[j][i] & DLRG_PROTECTED) {
1694  continue;
1695  }
1696  if ((dungeon[j][i] == 1 || dungeon[j][i] == 4) && dungeon[j - 1][i] == 3 && dungeon[j + 1][i] == 3) {
1697  doorok = FALSE;
1698  while (1) {
1699  if (dungeon[j][i] != 1 && dungeon[j][i] != 4) {
1700  break;
1701  }
1702  if (dungeon[j - 1][i] != 3 || dungeon[j + 1][i] != 3) {
1703  break;
1704  }
1705  if (dungeon[j][i] == 4) {
1706  doorok = TRUE;
1707  }
1708  i++;
1709  }
1710  if (!doorok && !(dflags[j][i - 1] & DLRG_PROTECTED)) {
1711  dungeon[j][i - 1] = 4;
1712  }
1713  }
1714  }
1715  }
1716 }
1717 
1719 {
1720  int i, j;
1721 
1722  for (j = 1; j < DMAXY; j++) {
1723  for (i = 1; i < DMAXX; i++) {
1724  if (dungeon[i][j] == 4 && dungeon[i][j - 1] == 3) {
1725  dungeon[i][j] = 7;
1726  }
1727  if (dungeon[i][j] == 5 && dungeon[i - 1][j] == 3) {
1728  dungeon[i][j] = 9;
1729  }
1730  }
1731  }
1732 }
1733 
1734 static void DRLG_L2(int entry)
1735 {
1736  int i, j;
1737  BOOL doneflag;
1738 
1739  doneflag = FALSE;
1740  while (!doneflag) {
1741  nRoomCnt = 0;
1742  InitDungeon();
1743  DRLG_InitTrans();
1744  if (!CreateDungeon()) {
1745  continue;
1746  }
1747  L2TileFix();
1748  if (setloadflag) {
1750  }
1751  DRLG_L2FloodTVal();
1752  DRLG_L2TransFix();
1753  if (entry == 0) {
1754  doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 1, 0);
1755  if (doneflag) {
1756  doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 0, 1);
1757  if (doneflag && currlevel == 5) {
1758  doneflag = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 0, 6);
1759  }
1760  }
1761  ViewY -= 2;
1762  } else if (entry == 1) {
1763  doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 0, 0);
1764  if (doneflag) {
1765  doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 1, 1);
1766  if (doneflag && currlevel == 5) {
1767  doneflag = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 0, 6);
1768  }
1769  }
1770  ViewX--;
1771  } else {
1772  doneflag = DRLG_L2PlaceMiniSet(USTAIRS, 1, 1, -1, -1, 0, 0);
1773  if (doneflag) {
1774  doneflag = DRLG_L2PlaceMiniSet(DSTAIRS, 1, 1, -1, -1, 0, 1);
1775  if (doneflag && currlevel == 5) {
1776  doneflag = DRLG_L2PlaceMiniSet(WARPSTAIRS, 1, 1, -1, -1, 1, 6);
1777  }
1778  }
1779  ViewY -= 2;
1780  }
1781  }
1782 
1783  L2LockoutFix();
1784  L2DoorFix();
1785  L2DirtFix();
1786 
1787  DRLG_PlaceThemeRooms(6, 10, 3, 0, 0);
1804  DRLG_L2PlaceRndSet(VARCH1, 100);
1805  DRLG_L2PlaceRndSet(VARCH2, 100);
1806  DRLG_L2PlaceRndSet(VARCH3, 100);
1807  DRLG_L2PlaceRndSet(VARCH4, 100);
1808  DRLG_L2PlaceRndSet(VARCH5, 100);
1809  DRLG_L2PlaceRndSet(VARCH6, 100);
1810  DRLG_L2PlaceRndSet(VARCH7, 100);
1811  DRLG_L2PlaceRndSet(VARCH8, 100);
1812  DRLG_L2PlaceRndSet(VARCH9, 100);
1836  DRLG_L2PlaceRndSet(HARCH1, 100);
1837  DRLG_L2PlaceRndSet(HARCH2, 100);
1838  DRLG_L2PlaceRndSet(HARCH3, 100);
1839  DRLG_L2PlaceRndSet(HARCH4, 100);
1840  DRLG_L2PlaceRndSet(HARCH5, 100);
1841  DRLG_L2PlaceRndSet(HARCH6, 100);
1842  DRLG_L2PlaceRndSet(HARCH7, 100);
1843  DRLG_L2PlaceRndSet(HARCH8, 100);
1844  DRLG_L2PlaceRndSet(HARCH9, 100);
1891  DRLG_L2PlaceRndSet(BIG6, 20);
1892  DRLG_L2PlaceRndSet(BIG7, 20);
1894  DRLG_L2PlaceRndSet(BIG9, 20);
1896  DRLG_L2Subs();
1897  DRLG_L2Shadows();
1898 
1899  for (j = 0; j < DMAXY; j++) {
1900  for (i = 0; i < DMAXX; i++) {
1901  pdungeon[i][j] = dungeon[i][j];
1902  }
1903  }
1904 
1907 }
1908 
1909 static void DRLG_InitL2Vals()
1910 {
1911  int i, j, pc;
1912 
1913  for (j = 0; j < MAXDUNY; j++) {
1914  for (i = 0; i < MAXDUNX; i++) {
1915  if (dPiece[i][j] == 541) {
1916  pc = 5;
1917  } else if (dPiece[i][j] == 178) {
1918  pc = 5;
1919  } else if (dPiece[i][j] == 551) {
1920  pc = 5;
1921  } else if (dPiece[i][j] == 542) {
1922  pc = 6;
1923  } else if (dPiece[i][j] == 553) {
1924  pc = 6;
1925  } else if (dPiece[i][j] == 13) {
1926  pc = 5;
1927  } else if (dPiece[i][j] == 17) {
1928  pc = 6;
1929  } else {
1930  continue;
1931  }
1932  dSpecial[i][j] = pc;
1933  }
1934  }
1935  for (j = 0; j < MAXDUNY; j++) {
1936  for (i = 0; i < MAXDUNX; i++) {
1937  if (dPiece[i][j] == 132) {
1938  dSpecial[i][j + 1] = 2;
1939  dSpecial[i][j + 2] = 1;
1940  } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) {
1941  dSpecial[i + 1][j] = 3;
1942  dSpecial[i + 2][j] = 4;
1943  }
1944  }
1945  }
1946 }
1947 
1948 void LoadL2Dungeon(char *sFileName, int vx, int vy)
1949 {
1950  int i, j, rw, rh, pc;
1951  BYTE *pLevelMap, *lm;
1952 
1953  InitDungeon();
1954  DRLG_InitTrans();
1955  pLevelMap = LoadFileInMem(sFileName, NULL);
1956 
1957  for (j = 0; j < DMAXY; j++) {
1958  for (i = 0; i < DMAXX; i++) {
1959  dungeon[i][j] = 12;
1960  dflags[i][j] = 0;
1961  }
1962  }
1963 
1964  lm = pLevelMap;
1965  rw = *lm;
1966  lm += 2;
1967  rh = *lm;
1968  lm += 2;
1969 
1970  for (j = 0; j < rh; j++) {
1971  for (i = 0; i < rw; i++) {
1972  if (*lm != 0) {
1973  dungeon[i][j] = *lm;
1974  dflags[i][j] |= DLRG_PROTECTED;
1975  } else {
1976  dungeon[i][j] = 3;
1977  }
1978  lm += 2;
1979  }
1980  }
1981  for (j = 0; j < DMAXY; j++) {
1982  for (i = 0; i < DMAXX; i++) {
1983  if (dungeon[i][j] == 0) {
1984  dungeon[i][j] = 12;
1985  }
1986  }
1987  }
1988 
1989  DRLG_L2Pass3();
1991 
1992  for (j = 0; j < MAXDUNY; j++) {
1993  for (i = 0; i < MAXDUNX; i++) {
1994  pc = 0;
1995  if (dPiece[i][j] == 541) {
1996  pc = 5;
1997  }
1998  if (dPiece[i][j] == 178) {
1999  pc = 5;
2000  }
2001  if (dPiece[i][j] == 551) {
2002  pc = 5;
2003  }
2004  if (dPiece[i][j] == 542) {
2005  pc = 6;
2006  }
2007  if (dPiece[i][j] == 553) {
2008  pc = 6;
2009  }
2010  if (dPiece[i][j] == 13) {
2011  pc = 5;
2012  }
2013  if (dPiece[i][j] == 17) {
2014  pc = 6;
2015  }
2016  dSpecial[i][j] = pc;
2017  }
2018  }
2019  for (j = 0; j < MAXDUNY; j++) {
2020  for (i = 0; i < MAXDUNX; i++) {
2021  if (dPiece[i][j] == 132) {
2022  dSpecial[i][j + 1] = 2;
2023  dSpecial[i][j + 2] = 1;
2024  } else if (dPiece[i][j] == 135 || dPiece[i][j] == 139) {
2025  dSpecial[i + 1][j] = 3;
2026  dSpecial[i + 2][j] = 4;
2027  }
2028  }
2029  }
2030 
2031  ViewX = vx;
2032  ViewY = vy;
2033  SetMapMonsters(pLevelMap, 0, 0);
2034  SetMapObjects(pLevelMap, 0, 0);
2035  mem_free_dbg(pLevelMap);
2036 }
2037 
2038 void LoadPreL2Dungeon(char *sFileName, int vx, int vy)
2039 {
2040  int i, j, rw, rh;
2041  BYTE *pLevelMap, *lm;
2042 
2043  InitDungeon();
2044  DRLG_InitTrans();
2045  pLevelMap = LoadFileInMem(sFileName, NULL);
2046 
2047  for (j = 0; j < DMAXY; j++) {
2048  for (i = 0; i < DMAXX; i++) {
2049  dungeon[i][j] = 12;
2050  dflags[i][j] = 0;
2051  }
2052  }
2053 
2054  lm = pLevelMap;
2055  rw = *lm;
2056  lm += 2;
2057  rh = *lm;
2058  lm += 2;
2059 
2060  for (j = 0; j < rh; j++) {
2061  for (i = 0; i < rw; i++) {
2062  if (*lm != 0) {
2063  dungeon[i][j] = *lm;
2064  dflags[i][j] |= DLRG_PROTECTED;
2065  } else {
2066  dungeon[i][j] = 3;
2067  }
2068  lm += 2;
2069  }
2070  }
2071  for (j = 0; j < DMAXY; j++) {
2072  for (i = 0; i < DMAXX; i++) {
2073  if (dungeon[i][j] == 0) {
2074  dungeon[i][j] = 12;
2075  }
2076  }
2077  }
2078  for (j = 0; j < DMAXY; j++) {
2079  for (i = 0; i < DMAXX; i++) {
2080  pdungeon[i][j] = dungeon[i][j];
2081  }
2082  }
2083 
2084  mem_free_dbg(pLevelMap);
2085 }
2086 
2087 void CreateL2Dungeon(DWORD rseed, int entry)
2088 {
2089  if (gbMaxPlayers == 1) {
2090  if (currlevel == 7 && !quests[Q_BLIND]._qactive) {
2091  currlevel = 6;
2092  CreateL2Dungeon(glSeedTbl[6], 4);
2093  currlevel = 7;
2094  }
2095  if (currlevel == 8) {
2096  if (!quests[Q_BLIND]._qactive) {
2097  currlevel = 6;
2098  CreateL2Dungeon(glSeedTbl[6], 4);
2099  currlevel = 8;
2100  } else {
2101  currlevel = 7;
2102  CreateL2Dungeon(glSeedTbl[7], 4);
2103  currlevel = 8;
2104  }
2105  }
2106  }
2107 
2108  SetRndSeed(rseed);
2109 
2110  dminx = 16;
2111  dminy = 16;
2112  dmaxx = 96;
2113  dmaxy = 96;
2114 
2115  DRLG_InitTrans();
2116  DRLG_InitSetPC();
2117  DRLG_LoadL2SP();
2118  DRLG_L2(entry);
2119  DRLG_L2Pass3();
2120  DRLG_FreeL2SP();
2121  DRLG_InitL2Vals();
2122  DRLG_SetPC();
2123 }
2124 
2126 #endif
BIG8
BYTE BIG8[]
Definition: drlg_l2.cpp:123
HARCH26
BYTE HARCH26[]
Definition: drlg_l2.cpp:97
VARCH24
BYTE VARCH24[]
Definition: drlg_l2.cpp:55
DRLG_InitTrans
void DRLG_InitTrans()
Definition: gendung.cpp:171
HARCH34
BYTE HARCH34[]
Definition: drlg_l2.cpp:105
pHallList
HALLNODE * pHallList
Definition: drlg_l2.cpp:21
VARCH22
BYTE VARCH22[]
Definition: drlg_l2.cpp:53
HARCH18
BYTE HARCH18[]
Definition: drlg_l2.cpp:89
quests
QuestStruct quests[MAXQUESTS]
Definition: quests.cpp:8
VARCH9
BYTE VARCH9[]
Definition: drlg_l2.cpp:40
Patterns
int Patterns[100][10]
Definition: drlg_l2.cpp:143
HARCH24
BYTE HARCH24[]
Definition: drlg_l2.cpp:95
RUINS7
BYTE RUINS7[]
Definition: drlg_l2.cpp:132
HALLNODE::nHally1
int nHally1
Definition: structs.h:1141
VARCH3
BYTE VARCH3[]
Definition: drlg_l2.cpp:34
setpc_w
int setpc_w
Definition: gendung.cpp:71
HARCH17
BYTE HARCH17[]
Definition: drlg_l2.cpp:88
HARCH7
BYTE HARCH7[]
Definition: drlg_l2.cpp:78
SPATSL2
ShadowStruct SPATSL2[2]
Definition: drlg_l2.cpp:28
currlevel
BYTE currlevel
Definition: gendung.cpp:40
PANCREAS2
BYTE PANCREAS2[]
Definition: drlg_l2.cpp:134
VARCH16
BYTE VARCH16[]
Definition: drlg_l2.cpp:47
DRLG_L2TransFix
static void DRLG_L2TransFix()
Definition: drlg_l2.cpp:1588
VARCH5
BYTE VARCH5[]
Definition: drlg_l2.cpp:36
HARCH32
BYTE HARCH32[]
Definition: drlg_l2.cpp:103
VARCH20
BYTE VARCH20[]
Definition: drlg_l2.cpp:51
setpc_h
int setpc_h
Definition: gendung.cpp:70
VARCH31
BYTE VARCH31[]
Definition: drlg_l2.cpp:62
dminx
int dminx
Definition: gendung.cpp:77
DL2_KnockWalls
static void DL2_KnockWalls(int x1, int y1, int x2, int y2)
Definition: drlg_l2.cpp:1074
QuestStatus
BOOL QuestStatus(int i)
Definition: quests.cpp:239
setpc_x
int setpc_x
Definition: gendung.cpp:72
RUINS2
BYTE RUINS2[]
Definition: drlg_l2.cpp:127
RUINS5
BYTE RUINS5[]
Definition: drlg_l2.cpp:130
GetHall
static void GetHall(int *nX1, int *nY1, int *nX2, int *nY2, int *nHd)
Definition: drlg_l2.cpp:763
SetRndSeed
void SetRndSeed(int s)
Set the RNG seed.
Definition: engine.cpp:728
HARCH38
BYTE HARCH38[]
Definition: drlg_l2.cpp:109
RUINS6
BYTE RUINS6[]
Definition: drlg_l2.cpp:131
dungeon
BYTE dungeon[DMAXX][DMAXY]
Definition: gendung.cpp:18
HARCH8
BYTE HARCH8[]
Definition: drlg_l2.cpp:79
pdungeon
BYTE pdungeon[DMAXX][DMAXY]
Definition: gendung.cpp:20
HALLNODE::nHalldir
int nHalldir
Definition: structs.h:1144
HARCH6
BYTE HARCH6[]
Definition: drlg_l2.cpp:77
USTAIRS
BYTE USTAIRS[]
Definition: drlg_l2.cpp:112
dmaxx
int dmaxx
Definition: gendung.cpp:68
MAXDUNX
#define MAXDUNX
Definition: defs.h:25
HARCH36
BYTE HARCH36[]
Definition: drlg_l2.cpp:107
Room_Max
int Room_Max
Definition: drlg_l2.cpp:24
HARCH22
BYTE HARCH22[]
Definition: drlg_l2.cpp:93
DRLG_L2PlaceRndSet
static void DRLG_L2PlaceRndSet(BYTE *miniset, int rndper)
Definition: drlg_l2.cpp:332
pMegaTiles
BYTE * pMegaTiles
Definition: gendung.cpp:29
VARCH40
BYTE VARCH40[]
Definition: drlg_l2.cpp:71
HARCH14
BYTE HARCH14[]
Definition: drlg_l2.cpp:85
ViewX
int ViewX
Definition: gendung.cpp:73
VARCH1
BYTE VARCH1[]
Definition: drlg_l2.cpp:32
L2DoorFix
void L2DoorFix()
Definition: drlg_l2.cpp:1718
DRLG_InitL2Vals
static void DRLG_InitL2Vals()
Definition: drlg_l2.cpp:1909
MemFreeDbg
#define MemFreeDbg(p)
Definition: defs.h:157
HARCH23
BYTE HARCH23[]
Definition: drlg_l2.cpp:94
VARCH28
BYTE VARCH28[]
Definition: drlg_l2.cpp:59
HARCH9
BYTE HARCH9[]
Definition: drlg_l2.cpp:80
HARCH5
BYTE HARCH5[]
Definition: drlg_l2.cpp:76
HARCH13
BYTE HARCH13[]
Definition: drlg_l2.cpp:84
BIG4
BYTE BIG4[]
Definition: drlg_l2.cpp:119
all.h
ViewY
int ViewY
Definition: gendung.cpp:74
HARCH3
BYTE HARCH3[]
Definition: drlg_l2.cpp:74
BSTYPESL2
BYTE BSTYPESL2[161]
Definition: drlg_l2.cpp:31
HARCH21
BYTE HARCH21[]
Definition: drlg_l2.cpp:92
DRLG_PlaceThemeRooms
void DRLG_PlaceThemeRooms(int minSize, int maxSize, int floor, int freq, int rndSize)
Definition: gendung.cpp:495
HARCH28
BYTE HARCH28[]
Definition: drlg_l2.cpp:99
DRLG_L2FTVR
static void DRLG_L2FTVR(int i, int j, int x, int y, int d)
Definition: drlg_l2.cpp:1523
VARCH38
BYTE VARCH38[]
Definition: drlg_l2.cpp:69
DRLG_LoadL2SP
static void DRLG_LoadL2SP()
Definition: drlg_l2.cpp:474
VARCH2
BYTE VARCH2[]
Definition: drlg_l2.cpp:33
HARCH35
BYTE HARCH35[]
Definition: drlg_l2.cpp:106
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
HALLNODE::nHally2
int nHally2
Definition: structs.h:1143
DRLG_L2Pass3
static void DRLG_L2Pass3()
Definition: drlg_l2.cpp:1479
pSetPiece
BYTE * pSetPiece
Definition: gendung.cpp:63
HARCH4
BYTE HARCH4[]
Definition: drlg_l2.cpp:75
VARCH29
BYTE VARCH29[]
Definition: drlg_l2.cpp:60
ROOMNODE::nRoomx2
int nRoomx2
Definition: structs.h:1151
MAXDUNY
#define MAXDUNY
Definition: defs.h:26
Area_Min
int Area_Min
Definition: drlg_l2.cpp:23
RUINS1
BYTE RUINS1[]
Definition: drlg_l2.cpp:126
InitDungeon
void InitDungeon()
Definition: drlg_l2.cpp:462
DefineRoom
static void DefineRoom(int nX1, int nY1, int nX2, int nY2, BOOL ForceHW)
Definition: drlg_l2.cpp:523
VARCH14
BYTE VARCH14[]
Definition: drlg_l2.cpp:45
dPiece
int dPiece[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:26
nSx1
DEVILUTION_BEGIN_NAMESPACE int nSx1
Definition: drlg_l2.cpp:14
VARCH36
BYTE VARCH36[]
Definition: drlg_l2.cpp:67
CreateDungeon
static BOOL CreateDungeon()
Definition: drlg_l2.cpp:1380
BIG2
BYTE BIG2[]
Definition: drlg_l2.cpp:117
DLRG_PROTECTED
@ DLRG_PROTECTED
Definition: enums.h:2929
HALLNODE::nHallx2
int nHallx2
Definition: structs.h:1142
VARCH25
BYTE VARCH25[]
Definition: drlg_l2.cpp:56
TransVal
char TransVal
Definition: gendung.cpp:23
VARCH18
BYTE VARCH18[]
Definition: drlg_l2.cpp:49
AddHall
static void AddHall(int nX1, int nY1, int nX2, int nY2, int nHd)
Definition: drlg_l2.cpp:595
DRLG_L2
static void DRLG_L2(int entry)
Definition: drlg_l2.cpp:1734
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
BIG7
BYTE BIG7[]
Definition: drlg_l2.cpp:122
ShadowStruct::nv3
unsigned char nv3
Definition: structs.h:1136
DL2_FillVoids
static BOOL DL2_FillVoids()
Definition: drlg_l2.cpp:1108
VARCH19
BYTE VARCH19[]
Definition: drlg_l2.cpp:50
VARCH32
BYTE VARCH32[]
Definition: drlg_l2.cpp:63
HALLNODE::nHallx1
int nHallx1
Definition: structs.h:1140
ShadowStruct::nv2
unsigned char nv2
Definition: structs.h:1135
BIG5
BYTE BIG5[]
Definition: drlg_l2.cpp:120
LoadL2Dungeon
void LoadL2Dungeon(char *sFileName, int vx, int vy)
Definition: drlg_l2.cpp:1948
CTRDOOR6
BYTE CTRDOOR6[]
Definition: drlg_l2.cpp:140
SetMapObjects
void SetMapObjects(BYTE *pMap, int startx, int starty)
Definition: objects.cpp:846
nSx2
int nSx2
Definition: drlg_l2.cpp:15
L2DirtFix
static void L2DirtFix()
Definition: drlg_l2.cpp:1623
HARCH20
BYTE HARCH20[]
Definition: drlg_l2.cpp:91
DRLG_L2PlaceMiniSet
static BOOL DRLG_L2PlaceMiniSet(BYTE *miniset, int tmin, int tmax, int cx, int cy, BOOL setview, int ldir)
Definition: drlg_l2.cpp:246
HARCH12
BYTE HARCH12[]
Definition: drlg_l2.cpp:83
DRLG_L2Subs
static void DRLG_L2Subs()
Definition: drlg_l2.cpp:383
VARCH13
BYTE VARCH13[]
Definition: drlg_l2.cpp:44
setloadflag
BOOL setloadflag
Definition: gendung.cpp:28
LoadFileInMem
BYTE * LoadFileInMem(char *pszName, DWORD *pdwFileLen)
Load a file in to a buffer.
Definition: engine.cpp:801
HARCH27
BYTE HARCH27[]
Definition: drlg_l2.cpp:98
HARCH16
BYTE HARCH16[]
Definition: drlg_l2.cpp:87
VARCH4
BYTE VARCH4[]
Definition: drlg_l2.cpp:35
RoomList
ROOMNODE RoomList[81]
Definition: drlg_l2.cpp:20
HALLNODE
Definition: structs.h:1139
VARCH35
BYTE VARCH35[]
Definition: drlg_l2.cpp:66
DL2_Cont
static BOOL DL2_Cont(BOOL x1f, BOOL y1f, BOOL x2f, BOOL y2f)
Definition: drlg_l2.cpp:1024
BIG1
BYTE BIG1[]
Definition: drlg_l2.cpp:116
VARCH26
BYTE VARCH26[]
Definition: drlg_l2.cpp:57
RUINS3
BYTE RUINS3[]
Definition: drlg_l2.cpp:128
BIG10
BYTE BIG10[]
Definition: drlg_l2.cpp:125
dmaxy
int dmaxy
Definition: gendung.cpp:69
HARCH39
BYTE HARCH39[]
Definition: drlg_l2.cpp:110
ConnectHall
static void ConnectHall(int nX1, int nY1, int nX2, int nY2, int nHd)
Definition: drlg_l2.cpp:777
VARCH7
BYTE VARCH7[]
Definition: drlg_l2.cpp:38
BIG6
BYTE BIG6[]
Definition: drlg_l2.cpp:121
VARCH30
BYTE VARCH30[]
Definition: drlg_l2.cpp:61
Q_SCHAMB
@ Q_SCHAMB
Definition: enums.h:2562
Q_BLIND
@ Q_BLIND
Definition: enums.h:2556
VARCH6
BYTE VARCH6[]
Definition: drlg_l2.cpp:37
VARCH39
BYTE VARCH39[]
Definition: drlg_l2.cpp:70
DSTAIRS
BYTE DSTAIRS[]
Definition: drlg_l2.cpp:113
CTRDOOR2
BYTE CTRDOOR2[]
Definition: drlg_l2.cpp:136
HARCH2
BYTE HARCH2[]
Definition: drlg_l2.cpp:73
DRLG_SetPC
void DRLG_SetPC()
Definition: gendung.cpp:253
HARCH29
BYTE HARCH29[]
Definition: drlg_l2.cpp:100
DRLG_L2SetRoom
static void DRLG_L2SetRoom(int rx1, int ry1)
Definition: drlg_l2.cpp:495
CTRDOOR7
BYTE CTRDOOR7[]
Definition: drlg_l2.cpp:141
DMAXY
#define DMAXY
Definition: defs.h:8
nRoomCnt
int nRoomCnt
Definition: drlg_l2.cpp:18
HARCH33
BYTE HARCH33[]
Definition: drlg_l2.cpp:104
DL2_NumNoChar
static int DL2_NumNoChar()
Definition: drlg_l2.cpp:1039
LvlViewX
int LvlViewX
Definition: gendung.cpp:67
RUINS4
BYTE RUINS4[]
Definition: drlg_l2.cpp:129
nSy2
int nSy2
Definition: drlg_l2.cpp:17
CTRDOOR4
BYTE CTRDOOR4[]
Definition: drlg_l2.cpp:138
DRLG_L2Shadows
static void DRLG_L2Shadows()
Definition: drlg_l2.cpp:421
HARCH25
BYTE HARCH25[]
Definition: drlg_l2.cpp:96
glSeedTbl
DWORD glSeedTbl[NUMLEVELS]
Definition: diablo.cpp:20
Room_Min
int Room_Min
Definition: drlg_l2.cpp:25
HARCH40
BYTE HARCH40[]
Definition: drlg_l2.cpp:111
CTRDOOR3
BYTE CTRDOOR3[]
Definition: drlg_l2.cpp:137
DRLG_CheckQuests
void DRLG_CheckQuests(int x, int y)
Definition: quests.cpp:516
DiabloAllocPtr
BYTE * DiabloAllocPtr(DWORD dwBytes)
Multithreaded safe malloc.
Definition: engine.cpp:765
dTransVal
char dTransVal[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:37
LvlViewY
int LvlViewY
Definition: gendung.cpp:66
VARCH27
BYTE VARCH27[]
Definition: drlg_l2.cpp:58
SetMapMonsters
void SetMapMonsters(BYTE *pMap, int startx, int starty)
Definition: monster.cpp:1029
CreateL2Dungeon
void CreateL2Dungeon(DWORD rseed, int entry)
Definition: drlg_l2.cpp:2087
HARCH30
BYTE HARCH30[]
Definition: drlg_l2.cpp:101
BIG9
BYTE BIG9[]
Definition: drlg_l2.cpp:124
HARCH15
BYTE HARCH15[]
Definition: drlg_l2.cpp:86
BTYPESL2
BYTE BTYPESL2[161]
Definition: drlg_l2.cpp:30
VARCH10
BYTE VARCH10[]
Definition: drlg_l2.cpp:41
HARCH31
BYTE HARCH31[]
Definition: drlg_l2.cpp:102
ROOMNODE::nRoomx1
int nRoomx1
Definition: structs.h:1149
CTRDOOR8
BYTE CTRDOOR8[]
Definition: drlg_l2.cpp:142
CreateDoorType
static void CreateDoorType(int nX, int nY)
Definition: drlg_l2.cpp:561
PlaceHallExt
static void PlaceHallExt(int nX, int nY)
Definition: drlg_l2.cpp:588
dflags
char dflags[DMAXX][DMAXY]
Definition: gendung.cpp:25
dSpecial
char dSpecial[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:50
VARCH33
BYTE VARCH33[]
Definition: drlg_l2.cpp:64
DoPatternCheck
static void DoPatternCheck(int i, int j)
Definition: drlg_l2.cpp:928
DL2_DrawRoom
static void DL2_DrawRoom(int x1, int y1, int x2, int y2)
Definition: drlg_l2.cpp:1055
random_
int random_(BYTE idx, int v)
Main RNG function.
Definition: engine.cpp:752
PANCREAS1
BYTE PANCREAS1[]
Definition: drlg_l2.cpp:133
ROOMNODE::nRoomy2
int nRoomy2
Definition: structs.h:1152
mem_free_dbg
void mem_free_dbg(void *p)
Multithreaded safe memfree.
Definition: engine.cpp:786
VARCH37
BYTE VARCH37[]
Definition: drlg_l2.cpp:68
L2LockoutFix
void L2LockoutFix()
Definition: drlg_l2.cpp:1651
Dir_Xadd
int Dir_Xadd[5]
Definition: drlg_l2.cpp:26
nSy1
int nSy1
Definition: drlg_l2.cpp:16
DRLG_FreeL2SP
static void DRLG_FreeL2SP()
Definition: drlg_l2.cpp:490
ShadowStruct
Definition: structs.h:1129
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
WARPSTAIRS
BYTE WARPSTAIRS[]
Definition: drlg_l2.cpp:114
HARCH10
BYTE HARCH10[]
Definition: drlg_l2.cpp:81
VARCH8
BYTE VARCH8[]
Definition: drlg_l2.cpp:39
VARCH15
BYTE VARCH15[]
Definition: drlg_l2.cpp:46
Dir_Yadd
int Dir_Yadd[5]
Definition: drlg_l2.cpp:27
HARCH1
BYTE HARCH1[]
Definition: drlg_l2.cpp:72
ROOMNODE::nRoomy1
int nRoomy1
Definition: structs.h:1150
ROOMNODE
Definition: structs.h:1148
CRUSHCOL
BYTE CRUSHCOL[]
Definition: drlg_l2.cpp:115
HARCH19
BYTE HARCH19[]
Definition: drlg_l2.cpp:90
VARCH11
BYTE VARCH11[]
Definition: drlg_l2.cpp:42
BIG3
BYTE BIG3[]
Definition: drlg_l2.cpp:118
CTRDOOR1
BYTE CTRDOOR1[]
Definition: drlg_l2.cpp:135
VARCH17
BYTE VARCH17[]
Definition: drlg_l2.cpp:48
DRLG_Init_Globals
void DRLG_Init_Globals()
Definition: drlg_l1.cpp:470
VARCH21
BYTE VARCH21[]
Definition: drlg_l2.cpp:52
CreateRoom
static void CreateRoom(int nX1, int nY1, int nX2, int nY2, int nRDest, int nHDir, BOOL ForceHW, int nH, int nW)
Draws a random room rectangle, and then subdivides the rest of the passed in rectangle into 4 and rec...
Definition: drlg_l2.cpp:635
dminy
int dminy
Definition: gendung.cpp:78
HALLNODE::pNext
struct HALLNODE * pNext
Definition: structs.h:1145
DRLG_InitSetPC
void DRLG_InitSetPC()
Definition: gendung.cpp:245
VARCH12
BYTE VARCH12[]
Definition: drlg_l2.cpp:43
setpc_y
int setpc_y
Definition: gendung.cpp:75
HARCH37
BYTE HARCH37[]
Definition: drlg_l2.cpp:108
CTRDOOR5
BYTE CTRDOOR5[]
Definition: drlg_l2.cpp:139
ROOMNODE::nRoomDest
int nRoomDest
Definition: structs.h:1153
predungeon
BYTE predungeon[DMAXX][DMAXY]
Definition: drlg_l2.cpp:19
LoadPreL2Dungeon
void LoadPreL2Dungeon(char *sFileName, int vx, int vy)
Definition: drlg_l2.cpp:2038
VARCH23
BYTE VARCH23[]
Definition: drlg_l2.cpp:54
VARCH34
BYTE VARCH34[]
Definition: drlg_l2.cpp:65
Q_BLOOD
@ Q_BLOOD
Definition: enums.h:2557
L2TileFix
static void L2TileFix()
Definition: drlg_l2.cpp:999
DRLG_L2FloodTVal
static void DRLG_L2FloodTVal()
Definition: drlg_l2.cpp:1570
DMAXX
#define DMAXX
Definition: defs.h:7
ShadowStruct::nv1
unsigned char nv1
Definition: structs.h:1134
HARCH11
BYTE HARCH11[]
Definition: drlg_l2.cpp:82