… | |
… | |
254 | underscore++; |
254 | underscore++; |
255 | *underscore = '\0'; |
255 | *underscore = '\0'; |
256 | |
256 | |
257 | int connect = 0; |
257 | int connect = 0; |
258 | |
258 | |
259 | if ((x > 0) && get_wall (map, x - 1, y)) |
259 | if (x > 0 && get_wall (map, x - 1, y)) connect |= 1; |
260 | connect |= 1; |
|
|
261 | if ((x < map->width - 1) && get_wall (map, x + 1, y)) |
260 | if (x < map->width - 1 && get_wall (map, x + 1, y)) connect |= 2; |
262 | connect |= 2; |
261 | if (y > 0 && get_wall (map, x, y - 1)) connect |= 4; |
263 | |
|
|
264 | if ((y > 0) && get_wall (map, x, y - 1)) |
|
|
265 | connect |= 4; |
|
|
266 | |
|
|
267 | if ((y < map->height - 1) && get_wall (map, x, y + 1)) |
262 | if (y < map->height - 1 && get_wall (map, x, y + 1)) connect |= 8; |
268 | connect |= 8; |
|
|
269 | |
263 | |
270 | switch (connect) |
264 | // one bit per dir, 1 left, 2 right, 4 up, 8 down |
271 | { |
265 | static const char *walltype[16] = { |
272 | case 0: |
266 | "0", |
273 | strcat (archetype, "0"); |
267 | "1_3", |
|
|
268 | "1_4", |
|
|
269 | "2_1_2", |
|
|
270 | "1_2", |
|
|
271 | "2_2_4", |
|
|
272 | "2_2_1", |
|
|
273 | "3_1", |
|
|
274 | "1_1", |
|
|
275 | "2_2_3", |
|
|
276 | "2_2_2", |
|
|
277 | "3_3", |
|
|
278 | "2_1_1", |
|
|
279 | "3_4", |
|
|
280 | "3_2", |
|
|
281 | "4" |
|
|
282 | }; |
274 | |
283 | |
275 | break; |
284 | strcat (archetype, walltype [connect]); |
276 | case 1: |
|
|
277 | strcat (archetype, "1_3"); |
|
|
278 | |
|
|
279 | break; |
|
|
280 | case 2: |
|
|
281 | strcat (archetype, "1_4"); |
|
|
282 | |
|
|
283 | break; |
|
|
284 | case 3: |
|
|
285 | strcat (archetype, "2_1_2"); |
|
|
286 | |
|
|
287 | break; |
|
|
288 | case 4: |
|
|
289 | strcat (archetype, "1_2"); |
|
|
290 | |
|
|
291 | break; |
|
|
292 | case 5: |
|
|
293 | strcat (archetype, "2_2_4"); |
|
|
294 | |
|
|
295 | break; |
|
|
296 | case 6: |
|
|
297 | strcat (archetype, "2_2_1"); |
|
|
298 | |
|
|
299 | break; |
|
|
300 | case 7: |
|
|
301 | strcat (archetype, "3_1"); |
|
|
302 | |
|
|
303 | break; |
|
|
304 | case 8: |
|
|
305 | strcat (archetype, "1_1"); |
|
|
306 | |
|
|
307 | break; |
|
|
308 | case 9: |
|
|
309 | strcat (archetype, "2_2_3"); |
|
|
310 | |
|
|
311 | break; |
|
|
312 | case 10: |
|
|
313 | strcat (archetype, "2_2_2"); |
|
|
314 | |
|
|
315 | break; |
|
|
316 | case 11: |
|
|
317 | strcat (archetype, "3_3"); |
|
|
318 | |
|
|
319 | break; |
|
|
320 | case 12: |
|
|
321 | strcat (archetype, "2_1_1"); |
|
|
322 | |
|
|
323 | break; |
|
|
324 | case 13: |
|
|
325 | strcat (archetype, "3_4"); |
|
|
326 | |
|
|
327 | break; |
|
|
328 | case 14: |
|
|
329 | strcat (archetype, "3_2"); |
|
|
330 | |
|
|
331 | break; |
|
|
332 | case 15: |
|
|
333 | strcat (archetype, "4"); |
|
|
334 | |
|
|
335 | break; |
|
|
336 | } |
|
|
337 | |
285 | |
338 | /* |
286 | /* |
339 | * Before anything, make sure the archetype does exist... |
287 | * Before anything, make sure the archetype does exist... |
340 | * If not, prolly an error... |
288 | * If not, prolly an error... |
341 | */ |
289 | */ |