1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #include <util.h> |
26 | #include <util.h> |
27 | #include <random_map.h> |
27 | #include <rmg.h> |
28 | #include <rproto.h> |
28 | #include <rproto.h> |
29 | |
29 | |
30 | /* Put in the walls and autojoin them. */ |
30 | /* Put in the walls and autojoin them. */ |
31 | |
31 | |
32 | /* given a maze and a coordinate, tell me which squares up/down/right/left |
32 | /* given a maze and a coordinate, tell me which squares up/down/right/left |
… | |
… | |
76 | { |
76 | { |
77 | /* |
77 | /* |
78 | * 1 = blocked to left, |
78 | * 1 = blocked to left, |
79 | * 2 = blocked to right, |
79 | * 2 = blocked to right, |
80 | * 4 = blocked above |
80 | * 4 = blocked above |
81 | * 8 = blocked below |
81 | * 8 = blocked below |
82 | */ |
82 | */ |
83 | int surround_index = 0; |
83 | int surround_index = 0; |
84 | |
84 | |
85 | // don't forget to update the mapspace! |
85 | // don't forget to update the mapspace! |
86 | if (i > 0) map->at (i - 1, j ).update (); |
86 | if (i > 0) map->at (i - 1, j ).update (); |
… | |
… | |
117 | /* picks the right wall type for this square, to make it look nice, |
117 | /* picks the right wall type for this square, to make it look nice, |
118 | and have everything nicely joined. It uses the maze. */ |
118 | and have everything nicely joined. It uses the maze. */ |
119 | static object * |
119 | static object * |
120 | pick_joined_wall (object *the_wall, const layout &maze, int i, int j, random_map_params *RP) |
120 | pick_joined_wall (object *the_wall, const layout &maze, int i, int j, random_map_params *RP) |
121 | { |
121 | { |
122 | /* 1 = wall to left, |
|
|
123 | 2 = wall to right, |
|
|
124 | 4 = wall above |
|
|
125 | 8 = wall below */ |
|
|
126 | int surround_index = 0; |
|
|
127 | int l; |
122 | int l; |
128 | char wall_name[1024]; |
123 | char wall_name[1024]; |
129 | archetype *wall_arch = 0; |
124 | archetype *wall_arch = 0; |
130 | |
125 | |
131 | assign (wall_name, the_wall->arch->archname); |
126 | assign (wall_name, the_wall->arch->archname); |
… | |
… | |
247 | /* this takes a map, and changes an existing wall to match what's blocked |
242 | /* this takes a map, and changes an existing wall to match what's blocked |
248 | * around it, counting only doors and walls as blocked. If insert_flag is |
243 | * around it, counting only doors and walls as blocked. If insert_flag is |
249 | * 1, it will go ahead and insert the wall into the map. If not, it |
244 | * 1, it will go ahead and insert the wall into the map. If not, it |
250 | * will only return the wall which would belong there, and doesn't |
245 | * will only return the wall which would belong there, and doesn't |
251 | * remove anything. It depends on the |
246 | * remove anything. It depends on the |
252 | * global, previously-set variable, "wall_name" |
247 | * global, previously-set variable, "wall_name" |
253 | */ |
248 | */ |
254 | object * |
249 | object * |
255 | retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP) |
250 | retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP) |
256 | { |
251 | { |
257 | /* 1 = wall to left, |
|
|
258 | * 2 = wall to right, |
|
|
259 | * 4 = wall above |
|
|
260 | * 8 = wall below |
|
|
261 | */ |
|
|
262 | int surround_index = 0; |
|
|
263 | int l; |
252 | int l; |
264 | object *the_wall = 0; |
253 | object *the_wall = 0; |
265 | object *new_wall = 0; |
254 | object *new_wall = 0; |
266 | archetype *wall_arch = 0; |
255 | archetype *wall_arch = 0; |
267 | |
256 | |
… | |
… | |
269 | for (the_wall = GET_MAP_OB (the_map, i, j); the_wall; the_wall = the_wall->above) |
258 | for (the_wall = GET_MAP_OB (the_map, i, j); the_wall; the_wall = the_wall->above) |
270 | if ((the_wall->move_type & MOVE_WALK) && the_wall->type != EXIT && the_wall->type != TELEPORTER) |
259 | if ((the_wall->move_type & MOVE_WALK) && the_wall->type != EXIT && the_wall->type != TELEPORTER) |
271 | break; |
260 | break; |
272 | |
261 | |
273 | /* if what we found is a door, don't remove it, set the_wall to NULL to |
262 | /* if what we found is a door, don't remove it, set the_wall to NULL to |
274 | * signal that later. |
263 | * signal that later. |
275 | */ |
264 | */ |
276 | if (the_wall && (the_wall->type == DOOR || the_wall->type == LOCKED_DOOR)) |
265 | if (the_wall && (the_wall->type == DOOR || the_wall->type == LOCKED_DOOR)) |
277 | { |
266 | { |
278 | the_wall = NULL; |
267 | the_wall = NULL; |
279 | /* if we're not supposed to insert a new wall where there wasn't one, |
268 | /* if we're not supposed to insert a new wall where there wasn't one, |
280 | * we've gotta leave. |
269 | * we've gotta leave. |
281 | */ |
270 | */ |
282 | if (insert_flag == 0) |
271 | if (insert_flag == 0) |
283 | return 0; |
272 | return 0; |
284 | } |
273 | } |
285 | else if (the_wall == NULL) |
274 | else if (the_wall == NULL) |
… | |
… | |
304 | { |
293 | { |
305 | new_wall = wall_arch->instance (); |
294 | new_wall = wall_arch->instance (); |
306 | new_wall->x = i; |
295 | new_wall->x = i; |
307 | new_wall->y = j; |
296 | new_wall->y = j; |
308 | |
297 | |
309 | if (the_wall && the_wall->map) |
298 | if (the_wall->map) |
310 | the_wall->destroy (); |
299 | the_wall->destroy (); |
311 | |
300 | |
312 | the_wall->move_block = MOVE_ALL; |
301 | the_wall->move_block = MOVE_ALL; |
313 | insert_ob_in_map (new_wall, the_map, new_wall, INS_NO_MERGE | INS_NO_WALK_ON); |
302 | insert_ob_in_map (new_wall, the_map, new_wall, INS_NO_MERGE | INS_NO_WALK_ON); |
314 | } |
303 | } |