1 | /* |
|
|
2 | * static char *rcsid_wall_c = |
|
|
3 | * "$Id: wall.C,v 1.1 2006/08/13 17:16:03 elmex Exp $"; |
|
|
4 | */ |
|
|
5 | |
|
|
6 | /* |
1 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
8 | |
3 | |
9 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
10 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
21 | |
16 | |
22 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
23 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
24 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
25 | |
20 | |
26 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
27 | */ |
22 | */ |
28 | |
23 | |
29 | #include <global.h> |
24 | #include <global.h> |
30 | #include <random_map.h> |
25 | #include <random_map.h> |
31 | #include <rproto.h> |
26 | #include <rproto.h> |
32 | |
27 | |
33 | /* Put in the walls and autojoin them. */ |
28 | /* Put in the walls and autojoin them. */ |
34 | |
29 | |
35 | |
30 | |
36 | /* 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 |
37 | are occupied. */ |
32 | are occupied. */ |
38 | |
33 | |
|
|
34 | int |
39 | int surround_flag(char **layout,int i,int j,RMParms *RP){ |
35 | surround_flag (char **layout, int i, int j, RMParms * RP) |
|
|
36 | { |
40 | /* 1 = wall to left, |
37 | /* 1 = wall to left, |
41 | 2 = wall to right, |
38 | 2 = wall to right, |
42 | 4 = wall above |
39 | 4 = wall above |
43 | 8 = wall below */ |
40 | 8 = wall below */ |
|
|
41 | int surround_index = 0; |
|
|
42 | |
|
|
43 | if ((i > 0) && layout[i - 1][j] != 0) |
44 | int surround_index = 0; |
44 | surround_index |= 1; |
45 | if((i > 0) && layout[i-1][j]!=0) surround_index |=1; |
|
|
46 | if((i < RP->Xsize-1) && layout[i+1][j]!=0) surround_index |=2; |
45 | if ((i < RP->Xsize - 1) && layout[i + 1][j] != 0) |
47 | if((j > 0) && layout[i][j-1]!=0) surround_index |=4; |
46 | surround_index |= 2; |
|
|
47 | if ((j > 0) && layout[i][j - 1] != 0) |
|
|
48 | surround_index |= 4; |
48 | if((j < RP->Ysize-1) && layout[i][j+1]!=0) surround_index |=8; |
49 | if ((j < RP->Ysize - 1) && layout[i][j + 1] != 0) |
|
|
50 | surround_index |= 8; |
49 | return surround_index; |
51 | return surround_index; |
50 | } |
52 | } |
51 | |
53 | |
52 | |
54 | |
53 | /* like surround_flag, but only walls count. |
55 | /* like surround_flag, but only walls count. |
54 | */ |
56 | */ |
55 | |
57 | |
|
|
58 | int |
56 | int surround_flag2(char **layout,int i,int j,RMParms *RP){ |
59 | surround_flag2 (char **layout, int i, int j, RMParms * RP) |
|
|
60 | { |
57 | /* 1 = wall to left, |
61 | /* 1 = wall to left, |
58 | 2 = wall to right, |
62 | 2 = wall to right, |
59 | 4 = wall above |
63 | 4 = wall above |
60 | 8 = wall below */ |
64 | 8 = wall below */ |
|
|
65 | int surround_index = 0; |
|
|
66 | |
|
|
67 | if ((i > 0) && layout[i - 1][j] == '#') |
61 | int surround_index = 0; |
68 | surround_index |= 1; |
62 | if((i > 0) && layout[i-1][j]=='#') surround_index |=1; |
|
|
63 | if((i < RP->Xsize-1) && layout[i+1][j]=='#') surround_index |=2; |
69 | if ((i < RP->Xsize - 1) && layout[i + 1][j] == '#') |
64 | if((j > 0) && layout[i][j-1]=='#') surround_index |=4; |
70 | surround_index |= 2; |
|
|
71 | if ((j > 0) && layout[i][j - 1] == '#') |
|
|
72 | surround_index |= 4; |
65 | if((j < RP->Ysize-1) && layout[i][j+1]=='#') surround_index |=8; |
73 | if ((j < RP->Ysize - 1) && layout[i][j + 1] == '#') |
|
|
74 | surround_index |= 8; |
66 | return surround_index; |
75 | return surround_index; |
67 | } |
76 | } |
68 | |
77 | |
69 | |
78 | |
70 | /* like surround_flag, except it checks a map, not a layout. |
79 | /* like surround_flag, except it checks a map, not a layout. |
71 | * Since this is part of the random map code, presumption |
80 | * Since this is part of the random map code, presumption |
72 | * is that this is not a tiled map. |
81 | * is that this is not a tiled map. |
73 | * What is considered blocking and not is somewhat hard coded. |
82 | * What is considered blocking and not is somewhat hard coded. |
74 | */ |
83 | */ |
|
|
84 | int |
75 | int surround_flag3(mapstruct *map,sint16 i,sint16 j,RMParms *RP){ |
85 | surround_flag3 (maptile *map, sint16 i, sint16 j, RMParms * RP) |
|
|
86 | { |
76 | /* |
87 | /* |
77 | * 1 = blocked to left, |
88 | * 1 = blocked to left, |
78 | * 2 = blocked to right, |
89 | * 2 = blocked to right, |
79 | * 4 = blocked above |
90 | * 4 = blocked above |
80 | * 8 = blocked below |
91 | * 8 = blocked below |
81 | */ |
92 | */ |
82 | |
93 | |
83 | int surround_index = 0; |
94 | int surround_index = 0; |
84 | |
95 | |
85 | if((i > 0) && (GET_MAP_MOVE_BLOCK(map, i-1,j) & ~MOVE_BLOCK_DEFAULT)) |
96 | if ((i > 0) && (GET_MAP_MOVE_BLOCK (map, i - 1, j) & ~MOVE_BLOCK_DEFAULT)) |
86 | surround_index |=1; |
97 | surround_index |= 1; |
87 | if((i < RP->Xsize-1) && (GET_MAP_MOVE_BLOCK(map, i+1,j) & ~MOVE_BLOCK_DEFAULT)) |
98 | if ((i < RP->Xsize - 1) && (GET_MAP_MOVE_BLOCK (map, i + 1, j) & ~MOVE_BLOCK_DEFAULT)) |
88 | surround_index |=2; |
99 | surround_index |= 2; |
89 | if((j > 0) && (GET_MAP_MOVE_BLOCK(map, i,j-1) & ~MOVE_BLOCK_DEFAULT)) |
100 | if ((j > 0) && (GET_MAP_MOVE_BLOCK (map, i, j - 1) & ~MOVE_BLOCK_DEFAULT)) |
90 | surround_index |=4; |
101 | surround_index |= 4; |
91 | if((j < RP->Ysize-1) && (GET_MAP_MOVE_BLOCK(map,i,j+1) & ~MOVE_BLOCK_DEFAULT)) |
102 | if ((j < RP->Ysize - 1) && (GET_MAP_MOVE_BLOCK (map, i, j + 1) & ~MOVE_BLOCK_DEFAULT)) |
92 | surround_index |=8; |
103 | surround_index |= 8; |
93 | |
104 | |
94 | return surround_index; |
105 | return surround_index; |
95 | } |
106 | } |
96 | |
107 | |
97 | /* like surround_flag2, except it checks a map, not a layout. */ |
108 | /* like surround_flag2, except it checks a map, not a layout. */ |
98 | |
109 | |
|
|
110 | int |
99 | int surround_flag4(mapstruct *map,int i,int j,RMParms *RP){ |
111 | surround_flag4 (maptile *map, int i, int j, RMParms * RP) |
|
|
112 | { |
100 | /* 1 = blocked to left, |
113 | /* 1 = blocked to left, |
101 | 2 = blocked to right, |
114 | 2 = blocked to right, |
102 | 4 = blocked above |
115 | 4 = blocked above |
103 | 8 = blocked below */ |
116 | 8 = blocked below */ |
|
|
117 | int surround_index = 0; |
|
|
118 | |
|
|
119 | if ((i > 0) && wall_blocked (map, i - 1, j)) |
104 | int surround_index = 0; |
120 | surround_index |= 1; |
105 | |
|
|
106 | if((i > 0) && wall_blocked(map,i-1,j)) surround_index |=1; |
|
|
107 | if((i < RP->Xsize-1) && wall_blocked(map,i+1,j)) surround_index |=2; |
121 | if ((i < RP->Xsize - 1) && wall_blocked (map, i + 1, j)) |
|
|
122 | surround_index |= 2; |
108 | if((j > 0) && wall_blocked(map,i,j-1)) surround_index |=4; |
123 | if ((j > 0) && wall_blocked (map, i, j - 1)) |
|
|
124 | surround_index |= 4; |
109 | if((j < RP->Ysize-1) && wall_blocked(map,i,j+1)) surround_index |=8; |
125 | if ((j < RP->Ysize - 1) && wall_blocked (map, i, j + 1)) |
|
|
126 | surround_index |= 8; |
110 | |
127 | |
111 | return surround_index; |
128 | return surround_index; |
112 | } |
129 | } |
113 | |
130 | |
114 | /* 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 |
115 | w_style) at '#' marks. */ |
132 | w_style) at '#' marks. */ |
116 | |
133 | |
|
|
134 | void |
117 | void make_map_walls(mapstruct *map,char **layout, char *w_style,RMParms *RP) { |
135 | make_map_walls (maptile *map, char **layout, char *w_style, RMParms * RP) |
|
|
136 | { |
118 | char styledirname[256]; |
137 | char styledirname[256]; |
119 | char stylefilepath[256]; |
138 | char stylefilepath[256]; |
120 | mapstruct *style_map=0; |
139 | maptile *style_map = 0; |
121 | object *the_wall; |
140 | object *the_wall; |
122 | |
141 | |
123 | /* get the style map */ |
142 | /* get the style map */ |
124 | if(!strcmp(w_style,"none")) return; |
143 | if (!strcmp (w_style, "none")) |
|
|
144 | return; |
125 | sprintf(styledirname,"%s","/styles/wallstyles"); |
145 | sprintf (styledirname, "%s", "/styles/wallstyles"); |
126 | sprintf(stylefilepath,"%s/%s",styledirname,w_style); |
146 | sprintf (stylefilepath, "%s/%s", styledirname, w_style); |
127 | style_map = find_style(styledirname,w_style,-1); |
147 | style_map = find_style (styledirname, w_style, -1); |
128 | if(style_map == 0) return; |
148 | if (style_map == 0) |
|
|
149 | return; |
129 | |
150 | |
130 | /* fill up the map with the given floor style */ |
151 | /* fill up the map with the given floor style */ |
131 | if((the_wall=pick_random_object(style_map))!=NULL) { |
152 | if ((the_wall = pick_random_object (style_map)) != NULL) |
132 | int i,j; |
153 | { |
133 | char *cp; |
154 | int i, j; |
|
|
155 | char *cp; |
134 | int joinedwalls=0; |
156 | int joinedwalls = 0; |
135 | object *thiswall; |
157 | object *thiswall; |
136 | |
158 | |
137 | sprintf(RP->wall_name,"%s",the_wall->arch->name); |
159 | sprintf (RP->wall_name, "%s", &the_wall->arch->name); |
138 | if ((cp=strchr(RP->wall_name,'_'))!=NULL) { |
160 | if ((cp = strchr (RP->wall_name, '_')) != NULL) |
139 | *cp=0; |
161 | { |
140 | joinedwalls=1; |
162 | *cp = 0; |
141 | } |
163 | joinedwalls = 1; |
|
|
164 | } |
142 | |
165 | |
143 | for(i=0;i<RP->Xsize;i++) |
166 | for (i = 0; i < RP->Xsize; i++) |
144 | for(j=0;j<RP->Ysize;j++) { |
167 | for (j = 0; j < RP->Ysize; j++) |
145 | if(layout[i][j]=='#') { |
168 | { |
146 | if(joinedwalls) |
169 | if (layout[i][j] == '#') |
|
|
170 | { |
|
|
171 | if (joinedwalls) |
147 | thiswall=pick_joined_wall(the_wall,layout,i,j,RP); |
172 | thiswall = pick_joined_wall (the_wall, layout, i, j, RP); |
148 | else |
173 | else |
149 | thiswall=arch_to_object(the_wall->arch); |
174 | thiswall = arch_to_object (the_wall->arch); |
150 | thiswall->x = i; |
175 | thiswall->x = i; |
151 | thiswall->y = j; |
176 | thiswall->y = j; |
152 | thiswall->move_block = MOVE_ALL; |
177 | thiswall->move_block = MOVE_ALL; |
153 | insert_ob_in_map(thiswall,map,thiswall,INS_NO_MERGE | INS_NO_WALK_ON); |
178 | insert_ob_in_map (thiswall, map, thiswall, INS_NO_MERGE | INS_NO_WALK_ON); |
154 | } |
179 | } |
155 | } |
180 | } |
156 | } |
181 | } |
157 | } |
182 | } |
158 | |
183 | |
159 | |
184 | |
160 | /* 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, |
161 | and have everything nicely joined. It uses the layout. */ |
186 | and have everything nicely joined. It uses the layout. */ |
162 | |
187 | |
|
|
188 | object * |
163 | object *pick_joined_wall(object *the_wall,char **layout,int i,int j,RMParms *RP) { |
189 | pick_joined_wall (object *the_wall, char **layout, int i, int j, RMParms * RP) |
|
|
190 | { |
164 | /* 1 = wall to left, |
191 | /* 1 = wall to left, |
165 | 2 = wall to right, |
192 | 2 = wall to right, |
166 | 4 = wall above |
193 | 4 = wall above |
167 | 8 = wall below */ |
194 | 8 = wall below */ |
168 | int surround_index=0; |
195 | int surround_index = 0; |
169 | int l; |
196 | int l; |
170 | char wall_name[64]; |
197 | char wall_name[64]; |
171 | archetype *wall_arch=0; |
198 | archetype *wall_arch = 0; |
172 | |
199 | |
173 | strcpy(wall_name,the_wall->arch->name); |
200 | strcpy (wall_name, the_wall->arch->name); |
174 | |
201 | |
175 | /* conventionally, walls are named like this: |
202 | /* conventionally, walls are named like this: |
176 | wallname_wallcode, where wallcode indicates |
203 | wallname_wallcode, where wallcode indicates |
177 | a joinedness, and wallname is the wall. |
204 | a joinedness, and wallname is the wall. |
178 | this code depends on the convention for |
205 | this code depends on the convention for |
179 | finding the right wall. */ |
206 | finding the right wall. */ |
180 | |
207 | |
181 | /* extract the wall name, which is the text up to the leading _ */ |
208 | /* extract the wall name, which is the text up to the leading _ */ |
182 | for(l=0;l<64;l++) { |
209 | for (l = 0; l < 64; l++) |
|
|
210 | { |
183 | if(wall_name[l]=='_') { |
211 | if (wall_name[l] == '_') |
184 | wall_name[l] = 0; |
212 | { |
185 | break; |
213 | wall_name[l] = 0; |
186 | } |
214 | break; |
|
|
215 | } |
187 | } |
216 | } |
188 | |
217 | |
189 | surround_index = surround_flag2(layout,i,j,RP); |
218 | surround_index = surround_flag2 (layout, i, j, RP); |
190 | |
219 | |
191 | switch(surround_index) { |
220 | switch (surround_index) |
|
|
221 | { |
192 | case 0: |
222 | case 0: |
193 | strcat(wall_name,"_0"); |
223 | strcat (wall_name, "_0"); |
194 | break; |
224 | break; |
195 | case 1: |
225 | case 1: |
196 | strcat(wall_name,"_1_3"); |
226 | strcat (wall_name, "_1_3"); |
197 | break; |
227 | break; |
198 | case 2: |
228 | case 2: |
199 | strcat(wall_name,"_1_4"); |
229 | strcat (wall_name, "_1_4"); |
200 | break; |
230 | break; |
201 | case 3: |
231 | case 3: |
202 | strcat(wall_name,"_2_1_2"); |
232 | strcat (wall_name, "_2_1_2"); |
203 | break; |
233 | break; |
204 | case 4: |
234 | case 4: |
205 | strcat(wall_name,"_1_2"); |
235 | strcat (wall_name, "_1_2"); |
206 | break; |
236 | break; |
207 | case 5: |
237 | case 5: |
208 | strcat(wall_name,"_2_2_4"); |
238 | strcat (wall_name, "_2_2_4"); |
209 | break; |
239 | break; |
210 | case 6: |
240 | case 6: |
211 | strcat(wall_name,"_2_2_1"); |
241 | strcat (wall_name, "_2_2_1"); |
212 | break; |
242 | break; |
213 | case 7: |
243 | case 7: |
214 | strcat(wall_name,"_3_1"); |
244 | strcat (wall_name, "_3_1"); |
215 | break; |
245 | break; |
216 | case 8: |
246 | case 8: |
217 | strcat(wall_name,"_1_1"); |
247 | strcat (wall_name, "_1_1"); |
218 | break; |
248 | break; |
219 | case 9: |
249 | case 9: |
220 | strcat(wall_name,"_2_2_3"); |
250 | strcat (wall_name, "_2_2_3"); |
221 | break; |
251 | break; |
222 | case 10: |
252 | case 10: |
223 | strcat(wall_name,"_2_2_2"); |
253 | strcat (wall_name, "_2_2_2"); |
224 | break; |
254 | break; |
225 | case 11: |
255 | case 11: |
226 | strcat(wall_name,"_3_3"); |
256 | strcat (wall_name, "_3_3"); |
227 | break; |
257 | break; |
228 | case 12: |
258 | case 12: |
229 | strcat(wall_name,"_2_1_1"); |
259 | strcat (wall_name, "_2_1_1"); |
230 | break; |
260 | break; |
231 | case 13: |
261 | case 13: |
232 | strcat(wall_name,"_3_4"); |
262 | strcat (wall_name, "_3_4"); |
233 | break; |
263 | break; |
234 | case 14: |
264 | case 14: |
235 | strcat(wall_name,"_3_2"); |
265 | strcat (wall_name, "_3_2"); |
236 | break; |
266 | break; |
237 | case 15: |
267 | case 15: |
238 | strcat(wall_name,"_4"); |
268 | strcat (wall_name, "_4"); |
239 | break; |
269 | break; |
240 | } |
270 | } |
241 | wall_arch = find_archetype(wall_name); |
271 | wall_arch = archetype::find (wall_name); |
|
|
272 | if (wall_arch) |
242 | if(wall_arch) return arch_to_object(wall_arch); |
273 | return arch_to_object (wall_arch); |
243 | else { |
274 | else |
|
|
275 | { |
244 | nroferrors--; |
276 | nroferrors--; |
245 | return arch_to_object(the_wall->arch); |
277 | return arch_to_object (the_wall->arch); |
246 | } |
278 | } |
247 | |
279 | |
248 | |
280 | |
249 | } |
281 | } |
250 | |
282 | |
251 | |
283 | |
252 | /* this takes a map, and changes an existing wall to match what's blocked |
284 | /* this takes a map, and changes an existing wall to match what's blocked |
253 | * around it, counting only doors and walls as blocked. If insert_flag is |
285 | * around it, counting only doors and walls as blocked. If insert_flag is |
254 | * 1, it will go ahead and insert the wall into the map. If not, it |
286 | * 1, it will go ahead and insert the wall into the map. If not, it |
255 | * will only return the wall which would belong there, and doesn't |
287 | * will only return the wall which would belong there, and doesn't |
256 | * remove anything. It depends on the |
288 | * remove anything. It depends on the |
257 | * global, previously-set variable, "wall_name" |
289 | * global, previously-set variable, "wall_name" |
258 | */ |
290 | */ |
259 | |
291 | |
|
|
292 | object * |
260 | object * retrofit_joined_wall(mapstruct *the_map,int i,int j,int insert_flag,RMParms *RP) { |
293 | retrofit_joined_wall (maptile *the_map, int i, int j, int insert_flag, RMParms * RP) |
|
|
294 | { |
261 | /* 1 = wall to left, |
295 | /* 1 = wall to left, |
262 | * 2 = wall to right, |
296 | * 2 = wall to right, |
263 | * 4 = wall above |
297 | * 4 = wall above |
264 | * 8 = wall below |
298 | * 8 = wall below |
265 | */ |
299 | */ |
266 | int surround_index=0; |
300 | int surround_index = 0; |
267 | int l; |
301 | int l; |
268 | object *the_wall=0; |
302 | object *the_wall = 0; |
269 | object *new_wall=0; |
303 | object *new_wall = 0; |
270 | archetype * wall_arch=0; |
304 | archetype *wall_arch = 0; |
271 | |
305 | |
272 | /* first find the wall */ |
306 | /* first find the wall */ |
273 | for(the_wall = get_map_ob(the_map,i,j);the_wall!=NULL;the_wall=the_wall->above) |
307 | for (the_wall = GET_MAP_OB (the_map, i, j); the_wall != NULL; the_wall = the_wall->above) |
274 | if ((the_wall->move_type & MOVE_WALK) && the_wall->type!=EXIT && the_wall->type!=TELEPORTER) |
308 | if ((the_wall->move_type & MOVE_WALK) && the_wall->type != EXIT && the_wall->type != TELEPORTER) |
275 | break; |
309 | break; |
276 | |
310 | |
277 | |
311 | |
278 | /* if what we found is a door, don't remove it, set the_wall to NULL to |
312 | /* if what we found is a door, don't remove it, set the_wall to NULL to |
279 | * signal that later. |
313 | * signal that later. |
280 | */ |
314 | */ |
281 | if(the_wall && (the_wall->type==DOOR || the_wall->type==LOCKED_DOOR) ) { |
315 | if (the_wall && (the_wall->type == DOOR || the_wall->type == LOCKED_DOOR)) |
|
|
316 | { |
282 | the_wall=NULL; |
317 | the_wall = NULL; |
283 | /* if we're not supposed to insert a new wall where there wasn't one, |
318 | /* if we're not supposed to insert a new wall where there wasn't one, |
284 | * we've gotta leave. |
319 | * we've gotta leave. |
285 | */ |
320 | */ |
286 | if(insert_flag==0) return 0; |
321 | if (insert_flag == 0) |
|
|
322 | return 0; |
287 | } |
323 | } |
288 | else if(the_wall==NULL) return NULL; |
324 | else if (the_wall == NULL) |
|
|
325 | return NULL; |
289 | |
326 | |
290 | /* canonicalize the wall name */ |
327 | /* canonicalize the wall name */ |
291 | for(l=0;l<64;l++) { |
328 | for (l = 0; l < 64; l++) |
|
|
329 | { |
292 | if(RP->wall_name[l]=='_') { |
330 | if (RP->wall_name[l] == '_') |
|
|
331 | { |
293 | RP->wall_name[l] = 0; |
332 | RP->wall_name[l] = 0; |
294 | break; |
333 | break; |
295 | } |
334 | } |
296 | } |
335 | } |
297 | |
336 | |
298 | surround_index = surround_flag4(the_map,i,j,RP); |
337 | surround_index = surround_flag4 (the_map, i, j, RP); |
299 | /* This would be a lot cleaner to just us a lookup table, |
338 | /* This would be a lot cleaner to just us a lookup table, |
300 | * eg, wall_suffix[surround_index] |
339 | * eg, wall_suffix[surround_index] |
301 | */ |
340 | */ |
302 | switch(surround_index) { |
341 | switch (surround_index) |
303 | case 0: |
342 | { |
|
|
343 | case 0: |
304 | strcat(RP->wall_name,"_0"); |
344 | strcat (RP->wall_name, "_0"); |
305 | break; |
345 | break; |
306 | case 1: |
346 | case 1: |
307 | strcat(RP->wall_name,"_1_3"); |
347 | strcat (RP->wall_name, "_1_3"); |
308 | break; |
348 | break; |
309 | case 2: |
349 | case 2: |
310 | strcat(RP->wall_name,"_1_4"); |
350 | strcat (RP->wall_name, "_1_4"); |
311 | break; |
351 | break; |
312 | case 3: |
352 | case 3: |
313 | strcat(RP->wall_name,"_2_1_2"); |
353 | strcat (RP->wall_name, "_2_1_2"); |
314 | break; |
354 | break; |
315 | case 4: |
355 | case 4: |
316 | strcat(RP->wall_name,"_1_2"); |
356 | strcat (RP->wall_name, "_1_2"); |
317 | break; |
357 | break; |
318 | case 5: |
358 | case 5: |
319 | strcat(RP->wall_name,"_2_2_4"); |
359 | strcat (RP->wall_name, "_2_2_4"); |
320 | break; |
360 | break; |
321 | case 6: |
361 | case 6: |
322 | strcat(RP->wall_name,"_2_2_1"); |
362 | strcat (RP->wall_name, "_2_2_1"); |
323 | break; |
363 | break; |
324 | case 7: |
364 | case 7: |
325 | strcat(RP->wall_name,"_3_1"); |
365 | strcat (RP->wall_name, "_3_1"); |
326 | break; |
366 | break; |
327 | case 8: |
367 | case 8: |
328 | strcat(RP->wall_name,"_1_1"); |
368 | strcat (RP->wall_name, "_1_1"); |
329 | break; |
369 | break; |
330 | case 9: |
370 | case 9: |
331 | strcat(RP->wall_name,"_2_2_3"); |
371 | strcat (RP->wall_name, "_2_2_3"); |
332 | break; |
372 | break; |
333 | case 10: |
373 | case 10: |
334 | strcat(RP->wall_name,"_2_2_2"); |
374 | strcat (RP->wall_name, "_2_2_2"); |
335 | break; |
375 | break; |
336 | case 11: |
376 | case 11: |
337 | strcat(RP->wall_name,"_3_3"); |
377 | strcat (RP->wall_name, "_3_3"); |
338 | break; |
378 | break; |
339 | case 12: |
379 | case 12: |
340 | strcat(RP->wall_name,"_2_1_1"); |
380 | strcat (RP->wall_name, "_2_1_1"); |
341 | break; |
381 | break; |
342 | case 13: |
382 | case 13: |
343 | strcat(RP->wall_name,"_3_4"); |
383 | strcat (RP->wall_name, "_3_4"); |
344 | break; |
384 | break; |
345 | case 14: |
385 | case 14: |
346 | strcat(RP->wall_name,"_3_2"); |
386 | strcat (RP->wall_name, "_3_2"); |
347 | break; |
387 | break; |
348 | case 15: |
388 | case 15: |
349 | strcat(RP->wall_name,"_4"); |
389 | strcat (RP->wall_name, "_4"); |
350 | break; |
390 | break; |
351 | } |
391 | } |
352 | wall_arch = find_archetype(RP->wall_name); |
392 | wall_arch = archetype::find (RP->wall_name); |
353 | if(wall_arch!=NULL) { |
393 | if (wall_arch != NULL) |
|
|
394 | { |
354 | new_wall=arch_to_object(wall_arch); |
395 | new_wall = arch_to_object (wall_arch); |
355 | new_wall->x = i; |
396 | new_wall->x = i; |
356 | new_wall->y = j; |
397 | new_wall->y = j; |
357 | if(the_wall && the_wall->map) { |
398 | if (the_wall && the_wall->map) |
358 | remove_ob(the_wall); |
399 | { |
359 | free_object(the_wall); |
400 | the_wall->remove (); |
360 | } |
401 | the_wall->destroy (); |
|
|
402 | } |
361 | the_wall->move_block = MOVE_ALL; |
403 | the_wall->move_block = MOVE_ALL; |
362 | insert_ob_in_map(new_wall,the_map,new_wall,INS_NO_MERGE | INS_NO_WALK_ON); |
404 | insert_ob_in_map (new_wall, the_map, new_wall, INS_NO_MERGE | INS_NO_WALK_ON); |
363 | } |
405 | } |
364 | else |
406 | else |
365 | nroferrors--; /* it's OK not to find an arch. */ |
407 | nroferrors--; /* it's OK not to find an arch. */ |
366 | return new_wall; |
408 | return new_wall; |
367 | } |
409 | } |
368 | |
|
|
369 | |
|
|