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.10 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.12 by root, Sat Dec 30 18:45:28 2006 UTC

30 30
31/* 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
32 are occupied. */ 32 are occupied. */
33 33
34int 34int
35surround_flag (char **layout, int i, int j, RMParms * RP) 35surround_flag (char **layout, int i, int j, random_map_params * RP)
36{ 36{
37 /* 1 = wall to left, 37 /* 1 = wall to left,
38 2 = wall to right, 38 2 = wall to right,
39 4 = wall above 39 4 = wall above
40 8 = wall below */ 40 8 = wall below */
54 54
55/* like surround_flag, but only walls count. 55/* like surround_flag, but only walls count.
56 */ 56 */
57 57
58int 58int
59surround_flag2 (char **layout, int i, int j, RMParms * RP) 59surround_flag2 (char **layout, int i, int j, random_map_params * RP)
60{ 60{
61 /* 1 = wall to left, 61 /* 1 = wall to left,
62 2 = wall to right, 62 2 = wall to right,
63 4 = wall above 63 4 = wall above
64 8 = wall below */ 64 8 = wall below */
80 * Since this is part of the random map code, presumption 80 * Since this is part of the random map code, presumption
81 * is that this is not a tiled map. 81 * is that this is not a tiled map.
82 * What is considered blocking and not is somewhat hard coded. 82 * What is considered blocking and not is somewhat hard coded.
83 */ 83 */
84int 84int
85surround_flag3 (maptile *map, sint16 i, sint16 j, RMParms * RP) 85surround_flag3 (maptile *map, sint16 i, sint16 j, random_map_params * RP)
86{ 86{
87 /* 87 /*
88 * 1 = blocked to left, 88 * 1 = blocked to left,
89 * 2 = blocked to right, 89 * 2 = blocked to right,
90 * 4 = blocked above 90 * 4 = blocked above
106} 106}
107 107
108/* like surround_flag2, except it checks a map, not a layout. */ 108/* like surround_flag2, except it checks a map, not a layout. */
109 109
110int 110int
111surround_flag4 (maptile *map, int i, int j, RMParms * RP) 111surround_flag4 (maptile *map, int i, int j, random_map_params * RP)
112{ 112{
113 /* 1 = blocked to left, 113 /* 1 = blocked to left,
114 2 = blocked to right, 114 2 = blocked to right,
115 4 = blocked above 115 4 = blocked above
116 8 = blocked below */ 116 8 = blocked below */
130 130
131/* takes a map and a layout, and puts walls in the map (picked from 131/* takes a map and a layout, and puts walls in the map (picked from
132 w_style) at '#' marks. */ 132 w_style) at '#' marks. */
133 133
134void 134void
135make_map_walls (maptile *map, char **layout, char *w_style, RMParms * RP) 135make_map_walls (maptile *map, char **layout, char *w_style, random_map_params * RP)
136{ 136{
137 char styledirname[256]; 137 char styledirname[256];
138 char stylefilepath[256]; 138 char stylefilepath[256];
139 maptile *style_map = 0; 139 maptile *style_map = 0;
140 object *the_wall; 140 object *the_wall;
184 184
185/* picks the right wall type for this square, to make it look nice, 185/* picks the right wall type for this square, to make it look nice,
186 and have everything nicely joined. It uses the layout. */ 186 and have everything nicely joined. It uses the layout. */
187 187
188object * 188object *
189pick_joined_wall (object *the_wall, char **layout, int i, int j, RMParms * RP) 189pick_joined_wall (object *the_wall, char **layout, int i, int j, random_map_params * RP)
190{ 190{
191 /* 1 = wall to left, 191 /* 1 = wall to left,
192 2 = wall to right, 192 2 = wall to right,
193 4 = wall above 193 4 = wall above
194 8 = wall below */ 194 8 = wall below */
267 case 15: 267 case 15:
268 strcat (wall_name, "_4"); 268 strcat (wall_name, "_4");
269 break; 269 break;
270 } 270 }
271 wall_arch = archetype::find (wall_name); 271 wall_arch = archetype::find (wall_name);
272 if (wall_arch) 272
273 return wall_arch
273 return arch_to_object (wall_arch); 274 ? arch_to_object (wall_arch)
274 else
275 {
276 nroferrors--;
277 return arch_to_object (the_wall->arch); 275 : arch_to_object (the_wall->arch);
278 }
279
280
281} 276}
282 277
283 278
284/* this takes a map, and changes an existing wall to match what's blocked 279/* this takes a map, and changes an existing wall to match what's blocked
285 * around it, counting only doors and walls as blocked. If insert_flag is 280 * around it, counting only doors and walls as blocked. If insert_flag is
288 * remove anything. It depends on the 283 * remove anything. It depends on the
289 * global, previously-set variable, "wall_name" 284 * global, previously-set variable, "wall_name"
290 */ 285 */
291 286
292object * 287object *
293retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, RMParms * RP) 288retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params * RP)
294{ 289{
295 /* 1 = wall to left, 290 /* 1 = wall to left,
296 * 2 = wall to right, 291 * 2 = wall to right,
297 * 4 = wall above 292 * 4 = wall above
298 * 8 = wall below 293 * 8 = wall below
387 break; 382 break;
388 case 15: 383 case 15:
389 strcat (RP->wall_name, "_4"); 384 strcat (RP->wall_name, "_4");
390 break; 385 break;
391 } 386 }
387
392 wall_arch = archetype::find (RP->wall_name); 388 wall_arch = archetype::find (RP->wall_name);
389
393 if (wall_arch != NULL) 390 if (!wall_arch)
394 { 391 {
395 new_wall = arch_to_object (wall_arch); 392 new_wall = arch_to_object (wall_arch);
396 new_wall->x = i; 393 new_wall->x = i;
397 new_wall->y = j; 394 new_wall->y = j;
395
398 if (the_wall && the_wall->map) 396 if (the_wall && the_wall->map)
399 { 397 {
400 the_wall->remove (); 398 the_wall->remove ();
401 the_wall->destroy (); 399 the_wall->destroy ();
402 } 400 }
401
403 the_wall->move_block = MOVE_ALL; 402 the_wall->move_block = MOVE_ALL;
404 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);
405 } 404 }
406 else 405
407 nroferrors--; /* it's OK not to find an arch. */
408 return new_wall; 406 return new_wall;
409} 407}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines