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.19 by root, Sat Feb 17 23:32:11 2007 UTC vs.
Revision 1.29 by root, Mon Oct 12 14:00:58 2009 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation; either version 2 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your 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 GNU General Public License 18 * You should have received a copy of the Affero GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * and the GNU General Public License along with this program. If not, see
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * <http://www.gnu.org/licenses/>.
21 * 21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 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 <random_map.h> 26#include <random_map.h>
27#include <rproto.h> 27#include <rproto.h>
28 28
29/* Put in the walls and autojoin them. */ 29/* Put in the walls and autojoin them. */
30 30
31
32/* given a layout and a coordinate, tell me which squares up/down/right/left 31/* given a layout and a coordinate, tell me which squares up/down/right/left
33 are occupied. */ 32 are occupied. */
34
35int 33int
36surround_flag (char **layout, int i, int j, random_map_params *RP) 34surround_flag (char **layout, int i, int j, random_map_params *RP)
37{ 35{
38 /* 1 = wall to left, 36 /* 1 = wall to left,
39 2 = wall to right, 37 2 = wall to right,
92 * 8 = blocked below 90 * 8 = blocked below
93 */ 91 */
94 92
95 int surround_index = 0; 93 int surround_index = 0;
96 94
95 // don't forget to update the mapspace!
96 if (i > 0) map->at (i - 1, j ).update ();
97 if (i < RP->Xsize - 1) map->at (i + 1, j ).update ();
98 if (j > 0) map->at (i , j - 1).update ();
99 if (j < RP->Ysize - 1) map->at (i , j + 1).update ();
100
97 if ((i > 0) && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & ~MOVE_BLOCK_DEFAULT)) 101 if ((i > 0) && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & MOVE_WALK))
98 surround_index |= 1; 102 surround_index |= 1;
99 if ((i < RP->Xsize - 1) && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & ~MOVE_BLOCK_DEFAULT)) 103 if ((i < RP->Xsize - 1) && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & MOVE_WALK))
100 surround_index |= 2; 104 surround_index |= 2;
101 if ((j > 0) && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & ~MOVE_BLOCK_DEFAULT)) 105 if ((j > 0) && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & MOVE_WALK))
102 surround_index |= 4; 106 surround_index |= 4;
103 if ((j < RP->Ysize - 1) && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & ~MOVE_BLOCK_DEFAULT)) 107 if ((j < RP->Ysize - 1) && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & MOVE_WALK))
104 surround_index |= 8; 108 surround_index |= 8;
105 109
106 return surround_index; 110 return surround_index;
107} 111}
108 112
148 style_map = find_style (styledirname, w_style, -1); 152 style_map = find_style (styledirname, w_style, -1);
149 if (!style_map) 153 if (!style_map)
150 return; 154 return;
151 155
152 /* fill up the map with the given floor style */ 156 /* fill up the map with the given floor style */
153 if ((the_wall = style_map->pick_random_object ())) 157 if ((the_wall = style_map->pick_random_object (rmg_rndm)))
154 { 158 {
155 int i, j; 159 int i, j;
156 char *cp; 160 char *cp;
157 int joinedwalls = 0; 161 int joinedwalls = 0;
158 object *thiswall; 162 object *thiswall;
159 163
160 sprintf (RP->wall_name, "%s", &the_wall->arch->name); 164 sprintf (RP->wall_name, "%s", &the_wall->arch->archname);
161 if ((cp = strchr (RP->wall_name, '_')) != NULL) 165 if ((cp = strchr (RP->wall_name, '_')) != NULL)
162 { 166 {
163 *cp = 0; 167 *cp = 0;
164 joinedwalls = 1; 168 joinedwalls = 1;
165 } 169 }
196 int surround_index = 0; 200 int surround_index = 0;
197 int l; 201 int l;
198 char wall_name[1024]; 202 char wall_name[1024];
199 archetype *wall_arch = 0; 203 archetype *wall_arch = 0;
200 204
201 assign (wall_name, the_wall->arch->name); 205 assign (wall_name, the_wall->arch->archname);
202 206
203 /* conventionally, walls are named like this: 207 /* conventionally, walls are named like this:
204 wallname_wallcode, where wallcode indicates 208 wallname_wallcode, where wallcode indicates
205 a joinedness, and wallname is the wall. 209 a joinedness, and wallname is the wall.
206 this code depends on the convention for 210 this code depends on the convention for
391 new_wall = arch_to_object (wall_arch); 395 new_wall = arch_to_object (wall_arch);
392 new_wall->x = i; 396 new_wall->x = i;
393 new_wall->y = j; 397 new_wall->y = j;
394 398
395 if (the_wall && the_wall->map) 399 if (the_wall && the_wall->map)
396 {
397 the_wall->remove ();
398 the_wall->destroy (); 400 the_wall->destroy ();
399 }
400 401
401 the_wall->move_block = MOVE_ALL; 402 the_wall->move_block = MOVE_ALL;
402 insert_ob_in_map (new_wall, the_map, new_wall, INS_NO_MERGE | INS_NO_WALK_ON); 403 insert_ob_in_map (new_wall, the_map, new_wall, INS_NO_MERGE | INS_NO_WALK_ON);
403 } 404 }
404 405

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines