… | |
… | |
33 | 2 = door or wall to right, |
33 | 2 = door or wall to right, |
34 | 4 = door or wall above |
34 | 4 = door or wall above |
35 | 8 = door or wall below */ |
35 | 8 = door or wall below */ |
36 | int surround_index = 0; |
36 | int surround_index = 0; |
37 | |
37 | |
38 | if ((i > 0) && (layout[i - 1][j] == 'D' || layout[i - 1][j] == '#')) |
38 | if ((i > 0) && (layout[i - 1][j] == 'D' || layout[i - 1][j] == '#')) surround_index |= 1; |
39 | surround_index += 1; |
|
|
40 | if ((i < Xsize - 1) && (layout[i + 1][j] == 'D' || layout[i + 1][j] == '#')) |
39 | if ((i < Xsize - 1) && (layout[i + 1][j] == 'D' || layout[i + 1][j] == '#')) surround_index |= 2; |
41 | surround_index += 2; |
|
|
42 | if ((j > 0) && (layout[i][j - 1] == 'D' || layout[i][j - 1] == '#')) |
40 | if ((j > 0) && (layout[i][j - 1] == 'D' || layout[i][j - 1] == '#')) surround_index |= 4; |
43 | surround_index += 4; |
|
|
44 | if ((j < Ysize - 1) && (layout[i][j + 1] == 'D' && layout[i][j + 1] == '#')) |
41 | if ((j < Ysize - 1) && (layout[i][j + 1] == 'D' || layout[i][j + 1] == '#')) surround_index |= 8; |
45 | surround_index += 8; |
42 | |
46 | return surround_index; |
43 | return surround_index; |
47 | } |
44 | } |
48 | |
45 | |
49 | void |
46 | void |
50 | put_doors (maptile *the_map, char **maze, const char *doorstyle, random_map_params *RP) |
47 | put_doors (maptile *the_map, char **maze, const char *doorstyle, random_map_params *RP) |
… | |
… | |
79 | if (maze[i][j] == 'D') |
76 | if (maze[i][j] == 'D') |
80 | { |
77 | { |
81 | int sindex = surround_check2 (maze, i, j, RP->Xsize, RP->Ysize); |
78 | int sindex = surround_check2 (maze, i, j, RP->Xsize, RP->Ysize); |
82 | |
79 | |
83 | object *this_door = (sindex == 3 ? hdoors : vdoors) |
80 | object *this_door = (sindex == 3 ? hdoors : vdoors) |
84 | ->pick_random_object (); |
81 | ->pick_random_object (rmg_rndm); |
85 | |
82 | |
86 | if (!this_door)//TODO not necessary? |
83 | the_map->insert (this_door->clone (), i, j, 0, 0); |
87 | abort (); |
|
|
88 | |
|
|
89 | object *new_door = this_door->clone (); |
|
|
90 | new_door->x = i; |
|
|
91 | new_door->y = j; |
|
|
92 | insert_ob_in_map (new_door, the_map, NULL, 0); |
|
|
93 | } |
84 | } |
94 | } |
85 | } |
95 | } |
86 | } |
96 | |
87 | |