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.29 by root, Mon Oct 12 14:00:58 2009 UTC vs.
Revision 1.31 by root, Fri Nov 6 13:03:34 2009 UTC

109 109
110 return surround_index; 110 return surround_index;
111} 111}
112 112
113/* like surround_flag2, except it checks a map, not a layout. */ 113/* like surround_flag2, except it checks a map, not a layout. */
114 114static int
115int
116surround_flag4 (maptile *map, int i, int j, random_map_params *RP) 115surround_flag4 (maptile *map, int i, int j, random_map_params *RP)
117{ 116{
118 /* 1 = blocked to left, 117 /* 1 = blocked to left,
119 2 = blocked to right, 118 2 = blocked to right,
120 4 = blocked above 119 4 = blocked above
131 surround_index |= 8; 130 surround_index |= 8;
132 131
133 return surround_index; 132 return surround_index;
134} 133}
135 134
135/* picks the right wall type for this square, to make it look nice,
136 and have everything nicely joined. It uses the layout. */
137static object *
138pick_joined_wall (object *the_wall, char **layout, int i, int j, random_map_params *RP)
139{
140 /* 1 = wall to left,
141 2 = wall to right,
142 4 = wall above
143 8 = wall below */
144 int surround_index = 0;
145 int l;
146 char wall_name[1024];
147 archetype *wall_arch = 0;
148
149 assign (wall_name, the_wall->arch->archname);
150
151 /* conventionally, walls are named like this:
152 wallname_wallcode, where wallcode indicates
153 a joinedness, and wallname is the wall.
154 this code depends on the convention for
155 finding the right wall. */
156
157 /* extract the wall name, which is the text up to the leading _ */
158 for (l = 0; l < 64; l++)
159 {
160 if (wall_name[l] == '_')
161 {
162 wall_name[l] = 0;
163 break;
164 }
165 }
166
167 surround_index = surround_flag2 (layout, i, j, RP);
168
169 switch (surround_index)
170 {
171 case 0:
172 strcat (wall_name, "_0");
173 break;
174 case 1:
175 strcat (wall_name, "_1_3");
176 break;
177 case 2:
178 strcat (wall_name, "_1_4");
179 break;
180 case 3:
181 strcat (wall_name, "_2_1_2");
182 break;
183 case 4:
184 strcat (wall_name, "_1_2");
185 break;
186 case 5:
187 strcat (wall_name, "_2_2_4");
188 break;
189 case 6:
190 strcat (wall_name, "_2_2_1");
191 break;
192 case 7:
193 strcat (wall_name, "_3_1");
194 break;
195 case 8:
196 strcat (wall_name, "_1_1");
197 break;
198 case 9:
199 strcat (wall_name, "_2_2_3");
200 break;
201 case 10:
202 strcat (wall_name, "_2_2_2");
203 break;
204 case 11:
205 strcat (wall_name, "_3_3");
206 break;
207 case 12:
208 strcat (wall_name, "_2_1_1");
209 break;
210 case 13:
211 strcat (wall_name, "_3_4");
212 break;
213 case 14:
214 strcat (wall_name, "_3_2");
215 break;
216 case 15:
217 strcat (wall_name, "_4");
218 break;
219 }
220 wall_arch = archetype::find (wall_name);
221
222 return wall_arch ? arch_to_object (wall_arch) : arch_to_object (the_wall->arch);
223}
224
136/* takes a map and a layout, and puts walls in the map (picked from 225/* takes a map and a layout, and puts walls in the map (picked from
137 w_style) at '#' marks. */ 226 w_style) at '#' marks. */
138
139void 227void
140make_map_walls (maptile *map, char **layout, char *w_style, random_map_params *RP) 228make_map_walls (maptile *map, char **layout, char *w_style, random_map_params *RP)
141{ 229{
142 char styledirname[1024]; 230 char styledirname[1024];
143 char stylefilepath[1024]; 231 char stylefilepath[1024];
175 { 263 {
176 if (joinedwalls) 264 if (joinedwalls)
177 thiswall = pick_joined_wall (the_wall, layout, i, j, RP); 265 thiswall = pick_joined_wall (the_wall, layout, i, j, RP);
178 else 266 else
179 thiswall = arch_to_object (the_wall->arch); 267 thiswall = arch_to_object (the_wall->arch);
268
180 thiswall->x = i; 269 thiswall->x = i;
181 thiswall->y = j; 270 thiswall->y = j;
182 thiswall->move_block = MOVE_ALL; 271 thiswall->move_block = MOVE_ALL;
183 insert_ob_in_map (thiswall, map, thiswall, INS_NO_MERGE | INS_NO_WALK_ON); 272 insert_ob_in_map (thiswall, map, thiswall, INS_NO_MERGE | INS_NO_WALK_ON);
184 } 273 }
185 } 274 }
186 } 275 }
187} 276}
188
189
190/* picks the right wall type for this square, to make it look nice,
191 and have everything nicely joined. It uses the layout. */
192
193object *
194pick_joined_wall (object *the_wall, char **layout, int i, int j, random_map_params *RP)
195{
196 /* 1 = wall to left,
197 2 = wall to right,
198 4 = wall above
199 8 = wall below */
200 int surround_index = 0;
201 int l;
202 char wall_name[1024];
203 archetype *wall_arch = 0;
204
205 assign (wall_name, the_wall->arch->archname);
206
207 /* conventionally, walls are named like this:
208 wallname_wallcode, where wallcode indicates
209 a joinedness, and wallname is the wall.
210 this code depends on the convention for
211 finding the right wall. */
212
213 /* extract the wall name, which is the text up to the leading _ */
214 for (l = 0; l < 64; l++)
215 {
216 if (wall_name[l] == '_')
217 {
218 wall_name[l] = 0;
219 break;
220 }
221 }
222
223 surround_index = surround_flag2 (layout, i, j, RP);
224
225 switch (surround_index)
226 {
227 case 0:
228 strcat (wall_name, "_0");
229 break;
230 case 1:
231 strcat (wall_name, "_1_3");
232 break;
233 case 2:
234 strcat (wall_name, "_1_4");
235 break;
236 case 3:
237 strcat (wall_name, "_2_1_2");
238 break;
239 case 4:
240 strcat (wall_name, "_1_2");
241 break;
242 case 5:
243 strcat (wall_name, "_2_2_4");
244 break;
245 case 6:
246 strcat (wall_name, "_2_2_1");
247 break;
248 case 7:
249 strcat (wall_name, "_3_1");
250 break;
251 case 8:
252 strcat (wall_name, "_1_1");
253 break;
254 case 9:
255 strcat (wall_name, "_2_2_3");
256 break;
257 case 10:
258 strcat (wall_name, "_2_2_2");
259 break;
260 case 11:
261 strcat (wall_name, "_3_3");
262 break;
263 case 12:
264 strcat (wall_name, "_2_1_1");
265 break;
266 case 13:
267 strcat (wall_name, "_3_4");
268 break;
269 case 14:
270 strcat (wall_name, "_3_2");
271 break;
272 case 15:
273 strcat (wall_name, "_4");
274 break;
275 }
276 wall_arch = archetype::find (wall_name);
277
278 return wall_arch ? arch_to_object (wall_arch) : arch_to_object (the_wall->arch);
279}
280
281 277
282/* this takes a map, and changes an existing wall to match what's blocked 278/* this takes a map, and changes an existing wall to match what's blocked
283 * around it, counting only doors and walls as blocked. If insert_flag is 279 * around it, counting only doors and walls as blocked. If insert_flag is
284 * 1, it will go ahead and insert the wall into the map. If not, it 280 * 1, it will go ahead and insert the wall into the map. If not, it
285 * will only return the wall which would belong there, and doesn't 281 * will only return the wall which would belong there, and doesn't
286 * remove anything. It depends on the 282 * remove anything. It depends on the
287 * global, previously-set variable, "wall_name" 283 * global, previously-set variable, "wall_name"
288 */ 284 */
289
290object * 285object *
291retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP) 286retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, random_map_params *RP)
292{ 287{
293 /* 1 = wall to left, 288 /* 1 = wall to left,
294 * 2 = wall to right, 289 * 2 = wall to right,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines