ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/wall.C
(Generate patch)

Comparing deliantra/server/random_maps/wall.C (file contents):
Revision 1.42 by root, Fri Jul 2 17:41:24 2010 UTC vs.
Revision 1.49 by root, Mon Oct 29 23:55:54 2012 UTC

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 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 <random_map.h> 27#include <rmg.h>
27#include <rproto.h> 28#include <rproto.h>
28 29
29/* Put in the walls and autojoin them. */ 30/* Put in the walls and autojoin them. */
30 31
31/* 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
116/* 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,
117 and have everything nicely joined. It uses the maze. */ 118 and have everything nicely joined. It uses the maze. */
118static object * 119static object *
119pick_joined_wall (object *the_wall, const layout &maze, int i, int j, random_map_params *RP) 120pick_joined_wall (object *the_wall, const layout &maze, int i, int j, random_map_params *RP)
120{ 121{
121 /* 1 = wall to left,
122 2 = wall to right,
123 4 = wall above
124 8 = wall below */
125 int surround_index = 0;
126 int l; 122 int l;
127 char wall_name[1024]; 123 char wall_name[1024];
128 archetype *wall_arch = 0; 124 archetype *wall_arch = 0;
129 125
130 assign (wall_name, the_wall->arch->archname); 126 assign (wall_name, the_wall->arch->archname);
162 for (int dy = -1; dy <= 1; ++dy) 158 for (int dy = -1; dy <= 1; ++dy)
163 { 159 {
164 int x = i + dx; 160 int x = i + dx;
165 int y = j + dy; 161 int y = j + dy;
166 162
167 if (x >= 0 && x < maze.w 163 if (IN_RANGE_EXC (x, 0, maze.w)
168 && y >= 0 && y < maze.h 164 && IN_RANGE_EXC (y, 0, maze.h)
169 && maze [x][y] != '#') 165 && maze [x][y] != '#')
170 return true; 166 return true;
171 } 167 }
172 168
173 return false; 169 return false;
251 * global, previously-set variable, "wall_name" 247 * global, previously-set variable, "wall_name"
252 */ 248 */
253object * 249object *
254retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP) 250retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP)
255{ 251{
256 /* 1 = wall to left,
257 * 2 = wall to right,
258 * 4 = wall above
259 * 8 = wall below
260 */
261 int surround_index = 0;
262 int l; 252 int l;
263 object *the_wall = 0; 253 object *the_wall = 0;
264 object *new_wall = 0; 254 object *new_wall = 0;
265 archetype *wall_arch = 0; 255 archetype *wall_arch = 0;
266 256
303 { 293 {
304 new_wall = wall_arch->instance (); 294 new_wall = wall_arch->instance ();
305 new_wall->x = i; 295 new_wall->x = i;
306 new_wall->y = j; 296 new_wall->y = j;
307 297
308 if (the_wall && the_wall->map) 298 if (the_wall->map)
309 the_wall->destroy (); 299 the_wall->destroy ();
310 300
311 the_wall->move_block = MOVE_ALL; 301 the_wall->move_block = MOVE_ALL;
312 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);
313 } 303 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines