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

Comparing deliantra/server/random_maps/door.C (file contents):
Revision 1.17 by root, Fri Apr 11 21:09:53 2008 UTC vs.
Revision 1.19 by root, Sun May 4 14:12:37 2008 UTC

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
49void 46void
50put_doors (maptile *the_map, char **maze, const char *doorstyle, random_map_params *RP) 47put_doors (maptile *the_map, char **maze, const char *doorstyle, random_map_params *RP)
76 for (i = 0; i < RP->Xsize; i++) 73 for (i = 0; i < RP->Xsize; i++)
77 for (j = 0; j < RP->Ysize; j++) 74 for (j = 0; j < RP->Ysize; j++)
78 { 75 {
79 if (maze[i][j] == 'D') 76 if (maze[i][j] == 'D')
80 { 77 {
81 int sindex; 78 int sindex = surround_check2 (maze, i, j, RP->Xsize, RP->Ysize);
82 object *this_door, *new_door;
83 79
84 sindex = surround_check2 (maze, i, j, RP->Xsize, RP->Ysize); 80 object *this_door = (sindex == 3 ? hdoors : vdoors)
85 if (sindex == 3) 81 ->pick_random_object (rmg_rndm);
86 this_door = hdoors->pick_random_object ();
87 else
88 this_door = vdoors->pick_random_object ();
89 82
90 if (!this_door) 83 the_map->insert (this_door->clone (), i, j, 0, 0);
91 abort ();
92
93 new_door = arch_to_object (this_door->arch);
94 this_door->copy_to (new_door);
95 new_door->x = i;
96 new_door->y = j;
97 insert_ob_in_map (new_door, the_map, NULL, 0);
98 } 84 }
99 } 85 }
100} 86}
101 87

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines