… | |
… | |
131 | surround_index |= 8; |
131 | surround_index |= 8; |
132 | |
132 | |
133 | return surround_index; |
133 | return surround_index; |
134 | } |
134 | } |
135 | |
135 | |
|
|
136 | /* picks the right wall type for this square, to make it look nice, |
|
|
137 | and have everything nicely joined. It uses the layout. */ |
|
|
138 | object * |
|
|
139 | pick_joined_wall (object *the_wall, char **layout, int i, int j, random_map_params *RP) |
|
|
140 | { |
|
|
141 | /* 1 = wall to left, |
|
|
142 | 2 = wall to right, |
|
|
143 | 4 = wall above |
|
|
144 | 8 = wall below */ |
|
|
145 | int surround_index = 0; |
|
|
146 | int l; |
|
|
147 | char wall_name[1024]; |
|
|
148 | archetype *wall_arch = 0; |
|
|
149 | |
|
|
150 | assign (wall_name, the_wall->arch->archname); |
|
|
151 | |
|
|
152 | /* conventionally, walls are named like this: |
|
|
153 | wallname_wallcode, where wallcode indicates |
|
|
154 | a joinedness, and wallname is the wall. |
|
|
155 | this code depends on the convention for |
|
|
156 | finding the right wall. */ |
|
|
157 | |
|
|
158 | /* extract the wall name, which is the text up to the leading _ */ |
|
|
159 | for (l = 0; l < 64; l++) |
|
|
160 | { |
|
|
161 | if (wall_name[l] == '_') |
|
|
162 | { |
|
|
163 | wall_name[l] = 0; |
|
|
164 | break; |
|
|
165 | } |
|
|
166 | } |
|
|
167 | |
|
|
168 | surround_index = surround_flag2 (layout, i, j, RP); |
|
|
169 | |
|
|
170 | switch (surround_index) |
|
|
171 | { |
|
|
172 | case 0: |
|
|
173 | strcat (wall_name, "_0"); |
|
|
174 | break; |
|
|
175 | case 1: |
|
|
176 | strcat (wall_name, "_1_3"); |
|
|
177 | break; |
|
|
178 | case 2: |
|
|
179 | strcat (wall_name, "_1_4"); |
|
|
180 | break; |
|
|
181 | case 3: |
|
|
182 | strcat (wall_name, "_2_1_2"); |
|
|
183 | break; |
|
|
184 | case 4: |
|
|
185 | strcat (wall_name, "_1_2"); |
|
|
186 | break; |
|
|
187 | case 5: |
|
|
188 | strcat (wall_name, "_2_2_4"); |
|
|
189 | break; |
|
|
190 | case 6: |
|
|
191 | strcat (wall_name, "_2_2_1"); |
|
|
192 | break; |
|
|
193 | case 7: |
|
|
194 | strcat (wall_name, "_3_1"); |
|
|
195 | break; |
|
|
196 | case 8: |
|
|
197 | strcat (wall_name, "_1_1"); |
|
|
198 | break; |
|
|
199 | case 9: |
|
|
200 | strcat (wall_name, "_2_2_3"); |
|
|
201 | break; |
|
|
202 | case 10: |
|
|
203 | strcat (wall_name, "_2_2_2"); |
|
|
204 | break; |
|
|
205 | case 11: |
|
|
206 | strcat (wall_name, "_3_3"); |
|
|
207 | break; |
|
|
208 | case 12: |
|
|
209 | strcat (wall_name, "_2_1_1"); |
|
|
210 | break; |
|
|
211 | case 13: |
|
|
212 | strcat (wall_name, "_3_4"); |
|
|
213 | break; |
|
|
214 | case 14: |
|
|
215 | strcat (wall_name, "_3_2"); |
|
|
216 | break; |
|
|
217 | case 15: |
|
|
218 | strcat (wall_name, "_4"); |
|
|
219 | break; |
|
|
220 | } |
|
|
221 | wall_arch = archetype::find (wall_name); |
|
|
222 | |
|
|
223 | return wall_arch ? arch_to_object (wall_arch) : arch_to_object (the_wall->arch); |
|
|
224 | } |
|
|
225 | |
136 | /* takes a map and a layout, and puts walls in the map (picked from |
226 | /* takes a map and a layout, and puts walls in the map (picked from |
137 | w_style) at '#' marks. */ |
227 | w_style) at '#' marks. */ |
138 | |
|
|
139 | void |
228 | void |
140 | make_map_walls (maptile *map, char **layout, char *w_style, random_map_params *RP) |
229 | make_map_walls (maptile *map, char **layout, char *w_style, random_map_params *RP) |
141 | { |
230 | { |
142 | char styledirname[1024]; |
231 | char styledirname[1024]; |
143 | char stylefilepath[1024]; |
232 | char stylefilepath[1024]; |
… | |
… | |
175 | { |
264 | { |
176 | if (joinedwalls) |
265 | if (joinedwalls) |
177 | thiswall = pick_joined_wall (the_wall, layout, i, j, RP); |
266 | thiswall = pick_joined_wall (the_wall, layout, i, j, RP); |
178 | else |
267 | else |
179 | thiswall = arch_to_object (the_wall->arch); |
268 | thiswall = arch_to_object (the_wall->arch); |
|
|
269 | |
180 | thiswall->x = i; |
270 | thiswall->x = i; |
181 | thiswall->y = j; |
271 | thiswall->y = j; |
182 | thiswall->move_block = MOVE_ALL; |
272 | thiswall->move_block = MOVE_ALL; |
183 | insert_ob_in_map (thiswall, map, thiswall, INS_NO_MERGE | INS_NO_WALK_ON); |
273 | insert_ob_in_map (thiswall, map, thiswall, INS_NO_MERGE | INS_NO_WALK_ON); |
184 | } |
274 | } |
185 | } |
275 | } |
186 | } |
276 | } |
187 | } |
277 | } |
188 | |
|
|
189 | |
|
|
190 | /* picks the right wall type for this square, to make it look nice, |
|
|
191 | and have everything nicely joined. It uses the layout. */ |
|
|
192 | |
|
|
193 | object * |
|
|
194 | pick_joined_wall (object *the_wall, char **layout, int i, int j, random_map_params *RP) |
|
|
195 | { |
|
|
196 | /* 1 = wall to left, |
|
|
197 | 2 = wall to right, |
|
|
198 | 4 = wall above |
|
|
199 | 8 = wall below */ |
|
|
200 | int surround_index = 0; |
|
|
201 | int l; |
|
|
202 | char wall_name[1024]; |
|
|
203 | archetype *wall_arch = 0; |
|
|
204 | |
|
|
205 | assign (wall_name, the_wall->arch->archname); |
|
|
206 | |
|
|
207 | /* conventionally, walls are named like this: |
|
|
208 | wallname_wallcode, where wallcode indicates |
|
|
209 | a joinedness, and wallname is the wall. |
|
|
210 | this code depends on the convention for |
|
|
211 | finding the right wall. */ |
|
|
212 | |
|
|
213 | /* extract the wall name, which is the text up to the leading _ */ |
|
|
214 | for (l = 0; l < 64; l++) |
|
|
215 | { |
|
|
216 | if (wall_name[l] == '_') |
|
|
217 | { |
|
|
218 | wall_name[l] = 0; |
|
|
219 | break; |
|
|
220 | } |
|
|
221 | } |
|
|
222 | |
|
|
223 | surround_index = surround_flag2 (layout, i, j, RP); |
|
|
224 | |
|
|
225 | switch (surround_index) |
|
|
226 | { |
|
|
227 | case 0: |
|
|
228 | strcat (wall_name, "_0"); |
|
|
229 | break; |
|
|
230 | case 1: |
|
|
231 | strcat (wall_name, "_1_3"); |
|
|
232 | break; |
|
|
233 | case 2: |
|
|
234 | strcat (wall_name, "_1_4"); |
|
|
235 | break; |
|
|
236 | case 3: |
|
|
237 | strcat (wall_name, "_2_1_2"); |
|
|
238 | break; |
|
|
239 | case 4: |
|
|
240 | strcat (wall_name, "_1_2"); |
|
|
241 | break; |
|
|
242 | case 5: |
|
|
243 | strcat (wall_name, "_2_2_4"); |
|
|
244 | break; |
|
|
245 | case 6: |
|
|
246 | strcat (wall_name, "_2_2_1"); |
|
|
247 | break; |
|
|
248 | case 7: |
|
|
249 | strcat (wall_name, "_3_1"); |
|
|
250 | break; |
|
|
251 | case 8: |
|
|
252 | strcat (wall_name, "_1_1"); |
|
|
253 | break; |
|
|
254 | case 9: |
|
|
255 | strcat (wall_name, "_2_2_3"); |
|
|
256 | break; |
|
|
257 | case 10: |
|
|
258 | strcat (wall_name, "_2_2_2"); |
|
|
259 | break; |
|
|
260 | case 11: |
|
|
261 | strcat (wall_name, "_3_3"); |
|
|
262 | break; |
|
|
263 | case 12: |
|
|
264 | strcat (wall_name, "_2_1_1"); |
|
|
265 | break; |
|
|
266 | case 13: |
|
|
267 | strcat (wall_name, "_3_4"); |
|
|
268 | break; |
|
|
269 | case 14: |
|
|
270 | strcat (wall_name, "_3_2"); |
|
|
271 | break; |
|
|
272 | case 15: |
|
|
273 | strcat (wall_name, "_4"); |
|
|
274 | break; |
|
|
275 | } |
|
|
276 | wall_arch = archetype::find (wall_name); |
|
|
277 | |
|
|
278 | return wall_arch ? arch_to_object (wall_arch) : arch_to_object (the_wall->arch); |
|
|
279 | } |
|
|
280 | |
|
|
281 | |
278 | |
282 | /* this takes a map, and changes an existing wall to match what's blocked |
279 | /* this takes a map, and changes an existing wall to match what's blocked |
283 | * around it, counting only doors and walls as blocked. If insert_flag is |
280 | * around it, counting only doors and walls as blocked. If insert_flag is |
284 | * 1, it will go ahead and insert the wall into the map. If not, it |
281 | * 1, it will go ahead and insert the wall into the map. If not, it |
285 | * will only return the wall which would belong there, and doesn't |
282 | * will only return the wall which would belong there, and doesn't |
286 | * remove anything. It depends on the |
283 | * remove anything. It depends on the |
287 | * global, previously-set variable, "wall_name" |
284 | * global, previously-set variable, "wall_name" |
288 | */ |
285 | */ |
289 | |
|
|
290 | object * |
286 | object * |
291 | retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP) |
287 | retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP) |
292 | { |
288 | { |
293 | /* 1 = wall to left, |
289 | /* 1 = wall to left, |
294 | * 2 = wall to right, |
290 | * 2 = wall to right, |