… | |
… | |
37 | 2 = wall to right, |
37 | 2 = wall to right, |
38 | 4 = wall above |
38 | 4 = wall above |
39 | 8 = wall below */ |
39 | 8 = wall below */ |
40 | int surround_index = 0; |
40 | int surround_index = 0; |
41 | |
41 | |
42 | if ((i > 0) && layout[i - 1][j] != 0) |
42 | if (i > 0 && layout[i - 1][j] != 0) surround_index |= 1; |
43 | surround_index |= 1; |
|
|
44 | if ((i < RP->Xsize - 1) && layout[i + 1][j] != 0) |
43 | if (i < RP->Xsize - 1 && layout[i + 1][j] != 0) surround_index |= 2; |
45 | surround_index |= 2; |
44 | if (j > 0 && layout[i][j - 1] != 0) surround_index |= 4; |
46 | if ((j > 0) && layout[i][j - 1] != 0) |
|
|
47 | surround_index |= 4; |
|
|
48 | if ((j < RP->Ysize - 1) && layout[i][j + 1] != 0) |
45 | if (j < RP->Ysize - 1 && layout[i][j + 1] != 0) surround_index |= 8; |
49 | surround_index |= 8; |
46 | |
50 | return surround_index; |
47 | return surround_index; |
51 | } |
48 | } |
52 | |
49 | |
53 | |
50 | |
54 | /* like surround_flag, but only walls count. |
51 | /* like surround_flag, but only walls count. |
… | |
… | |
61 | 2 = wall to right, |
58 | 2 = wall to right, |
62 | 4 = wall above |
59 | 4 = wall above |
63 | 8 = wall below */ |
60 | 8 = wall below */ |
64 | int surround_index = 0; |
61 | int surround_index = 0; |
65 | |
62 | |
66 | if ((i > 0) && layout[i - 1][j] == '#') |
63 | if (i > 0 && layout[i - 1][j] == '#') surround_index |= 1; |
67 | surround_index |= 1; |
|
|
68 | if ((i < RP->Xsize - 1) && layout[i + 1][j] == '#') |
64 | if (i < RP->Xsize - 1 && layout[i + 1][j] == '#') surround_index |= 2; |
69 | surround_index |= 2; |
65 | if (j > 0 && layout[i][j - 1] == '#') surround_index |= 4; |
70 | if ((j > 0) && layout[i][j - 1] == '#') |
|
|
71 | surround_index |= 4; |
|
|
72 | if ((j < RP->Ysize - 1) && layout[i][j + 1] == '#') |
66 | if (j < RP->Ysize - 1 && layout[i][j + 1] == '#') surround_index |= 8; |
73 | surround_index |= 8; |
67 | |
74 | return surround_index; |
68 | return surround_index; |
75 | } |
69 | } |
76 | |
70 | |
77 | |
71 | |
78 | /* like surround_flag, except it checks a map, not a layout. |
72 | /* like surround_flag, except it checks a map, not a layout. |
… | |
… | |
96 | if (i > 0) map->at (i - 1, j ).update (); |
90 | if (i > 0) map->at (i - 1, j ).update (); |
97 | if (i < RP->Xsize - 1) map->at (i + 1, j ).update (); |
91 | if (i < RP->Xsize - 1) map->at (i + 1, j ).update (); |
98 | if (j > 0) map->at (i , j - 1).update (); |
92 | if (j > 0) map->at (i , j - 1).update (); |
99 | if (j < RP->Ysize - 1) map->at (i , j + 1).update (); |
93 | if (j < RP->Ysize - 1) map->at (i , j + 1).update (); |
100 | |
94 | |
101 | if ((i > 0) && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & MOVE_WALK)) |
95 | if (i > 0 && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & MOVE_WALK)) surround_index |= 1; |
102 | surround_index |= 1; |
|
|
103 | if ((i < RP->Xsize - 1) && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & MOVE_WALK)) |
96 | if (i < RP->Xsize - 1 && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & MOVE_WALK)) surround_index |= 2; |
104 | surround_index |= 2; |
|
|
105 | if ((j > 0) && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & MOVE_WALK)) |
97 | if (j > 0 && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & MOVE_WALK)) surround_index |= 4; |
106 | surround_index |= 4; |
|
|
107 | if ((j < RP->Ysize - 1) && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & MOVE_WALK)) |
98 | if (j < RP->Ysize - 1 && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & MOVE_WALK)) surround_index |= 8; |
108 | surround_index |= 8; |
|
|
109 | |
99 | |
110 | return surround_index; |
100 | return surround_index; |
111 | } |
101 | } |
112 | |
102 | |
113 | /* like surround_flag2, except it checks a map, not a layout. */ |
103 | /* like surround_flag2, except it checks a map, not a layout. */ |
… | |
… | |
118 | 2 = blocked to right, |
108 | 2 = blocked to right, |
119 | 4 = blocked above |
109 | 4 = blocked above |
120 | 8 = blocked below */ |
110 | 8 = blocked below */ |
121 | int surround_index = 0; |
111 | int surround_index = 0; |
122 | |
112 | |
123 | if ((i > 0) && wall_blocked (map, i - 1, j)) |
113 | if (i > 0 && wall_blocked (map, i - 1, j)) surround_index |= 1; |
124 | surround_index |= 1; |
|
|
125 | if ((i < RP->Xsize - 1) && wall_blocked (map, i + 1, j)) |
114 | if (i < RP->Xsize - 1 && wall_blocked (map, i + 1, j)) surround_index |= 2; |
126 | surround_index |= 2; |
115 | if (j > 0 && wall_blocked (map, i, j - 1)) surround_index |= 4; |
127 | if ((j > 0) && wall_blocked (map, i, j - 1)) |
|
|
128 | surround_index |= 4; |
|
|
129 | if ((j < RP->Ysize - 1) && wall_blocked (map, i, j + 1)) |
116 | if (j < RP->Ysize - 1 && wall_blocked (map, i, j + 1)) surround_index |= 8; |
130 | surround_index |= 8; |
|
|
131 | |
117 | |
132 | return surround_index; |
118 | return surround_index; |
133 | } |
119 | } |
134 | |
120 | |
135 | /* picks the right wall type for this square, to make it look nice, |
121 | /* picks the right wall type for this square, to make it look nice, |
… | |
… | |
231 | |
217 | |
232 | /* get the style map */ |
218 | /* get the style map */ |
233 | if (!strcmp (w_style, "none")) |
219 | if (!strcmp (w_style, "none")) |
234 | return; |
220 | return; |
235 | |
221 | |
236 | maptile *style_map = find_style ("/styles/wallstyles", w_style, -1); |
222 | maptile *style_map = find_style ("/styles/wallstyles", w_style, RP->difficulty); |
237 | if (!style_map) |
223 | if (!style_map) |
238 | return; |
224 | return; |
239 | |
225 | |
240 | maptile *mining_map = m_style && *m_style |
226 | maptile *mining_map = m_style && *m_style |
241 | ? find_style ("/styles/miningstyles", m_style, -1) |
227 | ? find_style ("/styles/miningstyles", m_style, RP->difficulty) |
242 | : 0; |
228 | : 0; |
243 | |
229 | |
244 | if ((the_wall = style_map->pick_random_object (rmg_rndm))) |
230 | if ((the_wall = style_map->pick_random_object (rmg_rndm))) |
245 | { |
231 | { |
246 | int i, j; |
232 | int i, j; |