|
|
1 | |
1 | /* |
2 | /* |
2 | * static char *rcsid_exit_c = |
3 | * static char *rcsid_exit_c = |
3 | * "$Id: exit.C,v 1.3 2006/09/03 00:18:41 root Exp $"; |
4 | * "$Id: exit.C,v 1.4 2006/09/10 16:06:37 root Exp $"; |
4 | */ |
5 | */ |
5 | |
6 | |
6 | /* |
7 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
8 | |
9 | |
… | |
… | |
32 | #include <rproto.h> |
33 | #include <rproto.h> |
33 | |
34 | |
34 | |
35 | |
35 | /* find a character in the layout. fx and fy are pointers to |
36 | /* find a character in the layout. fx and fy are pointers to |
36 | where to find the char. fx,fy = -1 if not found. */ |
37 | where to find the char. fx,fy = -1 if not found. */ |
|
|
38 | void |
37 | void find_in_layout(int mode, char target,int *fx,int *fy,char **layout,RMParms *RP) { |
39 | find_in_layout (int mode, char target, int *fx, int *fy, char **layout, RMParms * RP) |
|
|
40 | { |
38 | int M; |
41 | int M; |
39 | int i,j; |
42 | int i, j; |
|
|
43 | |
40 | *fx=-1; |
44 | *fx = -1; |
41 | *fy=-1; |
45 | *fy = -1; |
42 | |
46 | |
43 | /* if a starting point isn't given, pick one */ |
47 | /* if a starting point isn't given, pick one */ |
44 | if(mode < 1 || mode > 4) M=RANDOM() % 4 + 1 ; |
48 | if (mode < 1 || mode > 4) |
|
|
49 | M = RANDOM () % 4 + 1; |
|
|
50 | else |
45 | else M = mode; |
51 | M = mode; |
46 | |
52 | |
47 | /* four different search starting points and methods so that |
53 | /* four different search starting points and methods so that |
48 | we can do something different for symmetrical maps instead of |
54 | we can do something different for symmetrical maps instead of |
49 | the same damned thing every time. */ |
55 | the same damned thing every time. */ |
50 | switch(M) { |
56 | switch (M) |
51 | case 1: { /* search from top left down/right */ |
57 | { |
|
|
58 | case 1: |
|
|
59 | { /* search from top left down/right */ |
52 | for(i=1;i<RP->Xsize;i++) |
60 | for (i = 1; i < RP->Xsize; i++) |
53 | for(j=1;j<RP->Ysize;j++) { |
61 | for (j = 1; j < RP->Ysize; j++) |
|
|
62 | { |
54 | if(layout[i][j]==target) { |
63 | if (layout[i][j] == target) |
55 | *fx = i; *fy = j; |
64 | { |
56 | return; |
65 | *fx = i; |
|
|
66 | *fy = j; |
|
|
67 | return; |
|
|
68 | } |
|
|
69 | } |
|
|
70 | break; |
57 | } |
71 | } |
58 | } |
72 | case 2: |
59 | break; |
73 | { /* Search from top right down/left */ |
60 | } |
|
|
61 | case 2: { /* Search from top right down/left */ |
|
|
62 | for(i=RP->Xsize-2;i>0;i--) |
74 | for (i = RP->Xsize - 2; i > 0; i--) |
63 | for(j=1;j<RP->Ysize-1;j++) { |
75 | for (j = 1; j < RP->Ysize - 1; j++) |
|
|
76 | { |
64 | if(layout[i][j]==target) { |
77 | if (layout[i][j] == target) |
65 | *fx = i; *fy = j; |
78 | { |
66 | return; |
79 | *fx = i; |
|
|
80 | *fy = j; |
|
|
81 | return; |
|
|
82 | } |
|
|
83 | } |
|
|
84 | break; |
67 | } |
85 | } |
68 | } |
86 | case 3: |
69 | break; |
87 | { /* search from bottom-left up-right */ |
70 | } |
|
|
71 | case 3: { /* search from bottom-left up-right */ |
|
|
72 | for(i=1;i<RP->Xsize-1;i++) |
88 | for (i = 1; i < RP->Xsize - 1; i++) |
73 | for(j=RP->Ysize-2;j>0;j--) { |
89 | for (j = RP->Ysize - 2; j > 0; j--) |
|
|
90 | { |
74 | if(layout[i][j]==target) { |
91 | if (layout[i][j] == target) |
75 | *fx = i; *fy = j; |
92 | { |
76 | return; |
93 | *fx = i; |
|
|
94 | *fy = j; |
|
|
95 | return; |
|
|
96 | } |
|
|
97 | } |
|
|
98 | break; |
77 | } |
99 | } |
78 | } |
100 | case 4: |
79 | break; |
101 | { /* search from bottom-right up-left */ |
80 | } |
|
|
81 | case 4: { /* search from bottom-right up-left */ |
|
|
82 | for(i=RP->Xsize-2;i>0;i--) |
102 | for (i = RP->Xsize - 2; i > 0; i--) |
83 | for(j=RP->Ysize-2;j>0;j--) { |
103 | for (j = RP->Ysize - 2; j > 0; j--) |
|
|
104 | { |
84 | if(layout[i][j]==target) { |
105 | if (layout[i][j] == target) |
85 | *fx = i; *fy = j; |
106 | { |
86 | return; |
107 | *fx = i; |
|
|
108 | *fy = j; |
|
|
109 | return; |
|
|
110 | } |
|
|
111 | } |
|
|
112 | break; |
87 | } |
113 | } |
88 | } |
114 | } |
89 | break; |
|
|
90 | } |
|
|
91 | } |
|
|
92 | } |
115 | } |
93 | |
|
|
94 | |
|
|
95 | |
|
|
96 | |
116 | |
97 | |
117 | |
98 | |
118 | |
|
|
119 | |
|
|
120 | |
|
|
121 | |
99 | /* orientation: 0 means random, |
122 | /* orientation: 0 means random, |
100 | 1 means descending dungeon |
123 | 1 means descending dungeon |
101 | 2 means ascending dungeon |
124 | 2 means ascending dungeon |
102 | 3 means rightward |
125 | 3 means rightward |
103 | 4 means leftward |
126 | 4 means leftward |
104 | 5 means northward |
127 | 5 means northward |
105 | 6 means southward |
128 | 6 means southward |
106 | */ |
129 | */ |
107 | |
130 | |
|
|
131 | void |
108 | void place_exits(mapstruct *map, char **maze,char *exitstyle,int orientation,RMParms *RP) { |
132 | place_exits (mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms * RP) |
|
|
133 | { |
109 | char styledirname[256]; |
134 | char styledirname[256]; |
110 | mapstruct *style_map_down=0; /* harder maze */ |
135 | mapstruct *style_map_down = 0; /* harder maze */ |
111 | mapstruct *style_map_up=0; /* easier maze */ |
136 | mapstruct *style_map_up = 0; /* easier maze */ |
112 | object *the_exit_down; /* harder maze */ |
137 | object *the_exit_down; /* harder maze */ |
113 | object *the_exit_up; /* easier maze */ |
138 | object *the_exit_up; /* easier maze */ |
114 | object *random_sign; /* magic mouth saying this is a random map. */ |
139 | object *random_sign; /* magic mouth saying this is a random map. */ |
115 | char buf[512]; |
140 | char buf[512]; |
116 | int cx=-1,cy=-1; /* location of a map center */ |
141 | int cx = -1, cy = -1; /* location of a map center */ |
117 | int upx=-1,upy=-1; /* location of up exit */ |
142 | int upx = -1, upy = -1; /* location of up exit */ |
118 | int downx=-1,downy=-1; |
143 | int downx = -1, downy = -1; |
119 | int final_map_exit=1; |
144 | int final_map_exit = 1; |
120 | |
145 | |
121 | if(RP->exit_on_final_map){ |
146 | if (RP->exit_on_final_map) |
|
|
147 | { |
122 | if(strstr(RP->exit_on_final_map,"no")) final_map_exit=0; |
148 | if (strstr (RP->exit_on_final_map, "no")) |
|
|
149 | final_map_exit = 0; |
123 | } |
150 | } |
124 | |
151 | |
125 | if(orientation == 0) orientation = RANDOM() % 6 + 1; |
152 | if (orientation == 0) |
|
|
153 | orientation = RANDOM () % 6 + 1; |
126 | |
154 | |
127 | switch(orientation) { |
155 | switch (orientation) |
128 | case 1: |
|
|
129 | { |
156 | { |
|
|
157 | case 1: |
|
|
158 | { |
130 | sprintf(styledirname,"/styles/exitstyles/up"); |
159 | sprintf (styledirname, "/styles/exitstyles/up"); |
131 | style_map_up = find_style(styledirname,exitstyle,-1); |
160 | style_map_up = find_style (styledirname, exitstyle, -1); |
132 | sprintf(styledirname,"/styles/exitstyles/down"); |
161 | sprintf (styledirname, "/styles/exitstyles/down"); |
133 | style_map_down = find_style(styledirname,exitstyle,-1); |
162 | style_map_down = find_style (styledirname, exitstyle, -1); |
134 | break; |
163 | break; |
|
|
164 | } |
|
|
165 | case 2: |
|
|
166 | { |
|
|
167 | sprintf (styledirname, "/styles/exitstyles/down"); |
|
|
168 | style_map_up = find_style (styledirname, exitstyle, -1); |
|
|
169 | sprintf (styledirname, "/styles/exitstyles/up"); |
|
|
170 | style_map_down = find_style (styledirname, exitstyle, -1); |
|
|
171 | break; |
|
|
172 | } |
|
|
173 | default: |
|
|
174 | { |
|
|
175 | sprintf (styledirname, "/styles/exitstyles/generic"); |
|
|
176 | style_map_up = find_style (styledirname, exitstyle, -1); |
|
|
177 | style_map_down = style_map_up; |
|
|
178 | break; |
|
|
179 | } |
135 | } |
180 | } |
136 | case 2: |
181 | if (style_map_up == 0) |
|
|
182 | the_exit_up = arch_to_object (find_archetype ("exit")); |
|
|
183 | else |
137 | { |
184 | { |
138 | sprintf(styledirname,"/styles/exitstyles/down"); |
185 | object *tmp; |
139 | style_map_up = find_style(styledirname,exitstyle,-1); |
186 | |
140 | sprintf(styledirname,"/styles/exitstyles/up"); |
187 | tmp = pick_random_object (style_map_up); |
141 | style_map_down = find_style(styledirname,exitstyle,-1); |
188 | the_exit_up = arch_to_object (tmp->arch); |
142 | break; |
|
|
143 | } |
189 | } |
144 | default: |
|
|
145 | { |
|
|
146 | sprintf(styledirname,"/styles/exitstyles/generic"); |
|
|
147 | style_map_up = find_style(styledirname,exitstyle,-1); |
|
|
148 | style_map_down = style_map_up; |
|
|
149 | break; |
|
|
150 | } |
|
|
151 | } |
|
|
152 | if(style_map_up == 0) the_exit_up =arch_to_object(find_archetype("exit")); |
|
|
153 | else { |
|
|
154 | object *tmp; |
|
|
155 | tmp = pick_random_object(style_map_up); |
|
|
156 | the_exit_up = arch_to_object(tmp->arch); |
|
|
157 | } |
|
|
158 | |
190 | |
159 | /* we need a down exit only if we're recursing. */ |
191 | /* we need a down exit only if we're recursing. */ |
160 | if(RP->dungeon_level < RP->dungeon_depth || RP->final_map[0]!=0) |
192 | if (RP->dungeon_level < RP->dungeon_depth || RP->final_map[0] != 0) |
|
|
193 | if (style_map_down == 0) |
161 | if(style_map_down == 0) the_exit_down = arch_to_object(find_archetype("exit")); |
194 | the_exit_down = arch_to_object (find_archetype ("exit")); |
162 | else { |
195 | else |
|
|
196 | { |
163 | object *tmp; |
197 | object *tmp; |
|
|
198 | |
164 | tmp = pick_random_object(style_map_down); |
199 | tmp = pick_random_object (style_map_down); |
165 | the_exit_down = arch_to_object(tmp->arch); |
200 | the_exit_down = arch_to_object (tmp->arch); |
166 | } |
201 | } |
|
|
202 | else |
167 | else the_exit_down = 0; |
203 | the_exit_down = 0; |
168 | |
204 | |
169 | /* set up the up exit */ |
205 | /* set up the up exit */ |
170 | the_exit_up->stats.hp = RP->origin_x; |
206 | the_exit_up->stats.hp = RP->origin_x; |
171 | the_exit_up->stats.sp = RP->origin_y; |
207 | the_exit_up->stats.sp = RP->origin_y; |
172 | the_exit_up->slaying = RP->origin_map; |
208 | the_exit_up->slaying = RP->origin_map; |
173 | |
209 | |
174 | /* figure out where to put the entrance */ |
210 | /* figure out where to put the entrance */ |
175 | /* begin a logical block */ |
211 | /* begin a logical block */ |
176 | { |
212 | { |
177 | int i,j; |
213 | int i, j; |
|
|
214 | |
178 | /* First, look for a '<' char */ |
215 | /* First, look for a '<' char */ |
179 | find_in_layout(0,'<',&upx,&upy,maze,RP); |
216 | find_in_layout (0, '<', &upx, &upy, maze, RP); |
180 | |
217 | |
181 | /* next, look for a C, the map center. */ |
218 | /* next, look for a C, the map center. */ |
182 | find_in_layout(0,'C',&cx,&cy,maze,RP); |
219 | find_in_layout (0, 'C', &cx, &cy, maze, RP); |
183 | |
220 | |
184 | |
221 | |
185 | /* if we didn't find an up, find an empty place far from the center */ |
222 | /* if we didn't find an up, find an empty place far from the center */ |
186 | if(upx==-1 && cx!=-1) { |
223 | if (upx == -1 && cx != -1) |
|
|
224 | { |
187 | if(cx > RP->Xsize/2) upx = 1; |
225 | if (cx > RP->Xsize / 2) |
188 | else upx = RP->Xsize -2; |
226 | upx = 1; |
189 | if(cy > RP->Ysize/2) upy = 1; |
|
|
190 | else upy = RP->Ysize -2; |
|
|
191 | /* find an empty place far from the center */ |
|
|
192 | if(upx==1 && upy==1) find_in_layout(1,0,&upx,&upy,maze,RP); |
|
|
193 | else |
|
|
194 | if(upx==1 && upy>1) find_in_layout(3,0,&upx,&upy,maze,RP); |
|
|
195 | else |
227 | else |
196 | if(upx>1 && upy==1) find_in_layout(2,0,&upx,&upy,maze,RP); |
228 | upx = RP->Xsize - 2; |
|
|
229 | if (cy > RP->Ysize / 2) |
|
|
230 | upy = 1; |
197 | else |
231 | else |
|
|
232 | upy = RP->Ysize - 2; |
|
|
233 | /* find an empty place far from the center */ |
|
|
234 | if (upx == 1 && upy == 1) |
|
|
235 | find_in_layout (1, 0, &upx, &upy, maze, RP); |
|
|
236 | else if (upx == 1 && upy > 1) |
|
|
237 | find_in_layout (3, 0, &upx, &upy, maze, RP); |
|
|
238 | else if (upx > 1 && upy == 1) |
|
|
239 | find_in_layout (2, 0, &upx, &upy, maze, RP); |
|
|
240 | else if (upx > 1 && upy > 1) |
198 | if(upx>1 && upy>1) find_in_layout(4,0,&upx,&upy,maze,RP); |
241 | find_in_layout (4, 0, &upx, &upy, maze, RP); |
199 | } |
242 | } |
200 | |
243 | |
201 | /* no indication of where to place the exit, so just place it. */ |
244 | /* no indication of where to place the exit, so just place it. */ |
|
|
245 | if (upx == -1) |
202 | if(upx==-1) find_in_layout(0,0,&upx,&upy,maze,RP); |
246 | find_in_layout (0, 0, &upx, &upy, maze, RP); |
203 | |
247 | |
204 | the_exit_up->x = upx; |
248 | the_exit_up->x = upx; |
205 | the_exit_up->y = upy; |
249 | the_exit_up->y = upy; |
206 | |
250 | |
207 | /* surround the exits with notices that this is a random map. */ |
251 | /* surround the exits with notices that this is a random map. */ |
208 | for(j=1;j<9;j++) { |
252 | for (j = 1; j < 9; j++) |
|
|
253 | { |
209 | if(!wall_blocked(map,the_exit_up->x+freearr_x[j],the_exit_up->y+freearr_y[j])) { |
254 | if (!wall_blocked (map, the_exit_up->x + freearr_x[j], the_exit_up->y + freearr_y[j])) |
|
|
255 | { |
210 | random_sign = get_archetype("sign"); |
256 | random_sign = get_archetype ("sign"); |
211 | random_sign->x = the_exit_up->x+freearr_x[j]; |
257 | random_sign->x = the_exit_up->x + freearr_x[j]; |
212 | random_sign->y = the_exit_up->y+freearr_y[j]; |
258 | random_sign->y = the_exit_up->y + freearr_y[j]; |
213 | |
259 | |
214 | sprintf(buf,"This is a random map.\nLevel: %d\n", (RP->dungeon_level)-1); |
260 | sprintf (buf, "This is a random map.\nLevel: %d\n", (RP->dungeon_level) - 1); |
215 | |
261 | |
216 | random_sign->msg = buf; |
262 | random_sign->msg = buf; |
217 | insert_ob_in_map(random_sign,map,NULL,0); |
263 | insert_ob_in_map (random_sign, map, NULL, 0); |
|
|
264 | } |
218 | } |
265 | } |
219 | } |
|
|
220 | /* Block the exit so things don't get dumped on top of it. */ |
266 | /* Block the exit so things don't get dumped on top of it. */ |
221 | the_exit_up->move_block = MOVE_ALL; |
267 | the_exit_up->move_block = MOVE_ALL; |
222 | |
268 | |
223 | insert_ob_in_map(the_exit_up,map,NULL,0); |
269 | insert_ob_in_map (the_exit_up, map, NULL, 0); |
224 | maze[the_exit_up->x][the_exit_up->y]='<'; |
270 | maze[the_exit_up->x][the_exit_up->y] = '<'; |
225 | |
271 | |
226 | /* set the starting x,y for this map */ |
272 | /* set the starting x,y for this map */ |
227 | MAP_ENTER_X(map) = the_exit_up->x; |
273 | MAP_ENTER_X (map) = the_exit_up->x; |
228 | MAP_ENTER_Y(map) = the_exit_up->y; |
274 | MAP_ENTER_Y (map) = the_exit_up->y; |
229 | |
275 | |
230 | /* first, look for a '>' character */ |
276 | /* first, look for a '>' character */ |
231 | find_in_layout(0,'>',&downx,&downy,maze,RP); |
277 | find_in_layout (0, '>', &downx, &downy, maze, RP); |
232 | /* if no > is found use C */ |
278 | /* if no > is found use C */ |
233 | if(downx==-1) { downx = cx; downy=cy;}; |
279 | if (downx == -1) |
234 | |
280 | { |
|
|
281 | downx = cx; |
|
|
282 | downy = cy; |
|
|
283 | }; |
|
|
284 | |
235 | /* make the other exit far away from this one if |
285 | /* make the other exit far away from this one if |
236 | there's no center. */ |
286 | there's no center. */ |
237 | if(downx==-1) { |
287 | if (downx == -1) |
|
|
288 | { |
238 | if(upx > RP->Xsize/2) downx = 1; |
289 | if (upx > RP->Xsize / 2) |
239 | else downx = RP->Xsize -2; |
290 | downx = 1; |
240 | if(upy > RP->Ysize/2) downy = 1; |
|
|
241 | else downy = RP->Ysize -2; |
|
|
242 | /* find an empty place far from the entrance */ |
|
|
243 | if(downx==1 && downy==1) find_in_layout(1,0,&downx,&downy,maze,RP); |
|
|
244 | else |
|
|
245 | if(downx==1 && downy>1) find_in_layout(3,0,&downx,&downy,maze,RP); |
|
|
246 | else |
291 | else |
247 | if(downx>1 && downy==1) find_in_layout(2,0,&downx,&downy,maze,RP); |
292 | downx = RP->Xsize - 2; |
|
|
293 | if (upy > RP->Ysize / 2) |
|
|
294 | downy = 1; |
248 | else |
295 | else |
|
|
296 | downy = RP->Ysize - 2; |
|
|
297 | /* find an empty place far from the entrance */ |
|
|
298 | if (downx == 1 && downy == 1) |
|
|
299 | find_in_layout (1, 0, &downx, &downy, maze, RP); |
|
|
300 | else if (downx == 1 && downy > 1) |
|
|
301 | find_in_layout (3, 0, &downx, &downy, maze, RP); |
|
|
302 | else if (downx > 1 && downy == 1) |
|
|
303 | find_in_layout (2, 0, &downx, &downy, maze, RP); |
|
|
304 | else if (downx > 1 && downy > 1) |
249 | if(downx>1 && downy>1) find_in_layout(4,0,&downx,&downy,maze,RP); |
305 | find_in_layout (4, 0, &downx, &downy, maze, RP); |
|
|
306 | |
250 | |
307 | } |
251 | } |
|
|
252 | /* no indication of where to place the down exit, so just place it */ |
308 | /* no indication of where to place the down exit, so just place it */ |
|
|
309 | if (downx == -1) |
253 | if(downx==-1) find_in_layout(0,0,&downx,&downy,maze,RP); |
310 | find_in_layout (0, 0, &downx, &downy, maze, RP); |
254 | if(the_exit_down) { |
311 | if (the_exit_down) |
|
|
312 | { |
255 | char buf[2048]; |
313 | char buf[2048]; |
|
|
314 | |
256 | i = find_first_free_spot(the_exit_down, map, downx, downy); |
315 | i = find_first_free_spot (the_exit_down, map, downx, downy); |
257 | the_exit_down->x = downx + freearr_x[i]; |
316 | the_exit_down->x = downx + freearr_x[i]; |
258 | the_exit_down->y = downy + freearr_y[i]; |
317 | the_exit_down->y = downy + freearr_y[i]; |
259 | RP->origin_x = the_exit_down->x; |
318 | RP->origin_x = the_exit_down->x; |
260 | RP->origin_y = the_exit_down->y; |
319 | RP->origin_y = the_exit_down->y; |
261 | write_map_parameters_to_string(buf,RP); |
320 | write_map_parameters_to_string (buf, RP); |
262 | the_exit_down->msg = buf; |
321 | the_exit_down->msg = buf; |
263 | /* the identifier for making a random map. */ |
322 | /* the identifier for making a random map. */ |
264 | if(RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0]!=0) { |
323 | if (RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0] != 0) |
|
|
324 | { |
265 | mapstruct *new_map; |
325 | mapstruct *new_map; |
266 | object *the_exit_back = arch_to_object(the_exit_up->arch), *tmp; |
326 | object *the_exit_back = arch_to_object (the_exit_up->arch), *tmp; |
|
|
327 | |
267 | #if 0 |
328 | #if 0 |
268 | /* I'm not sure if there was any reason to change the path to the |
329 | /* I'm not sure if there was any reason to change the path to the |
269 | * map other than to maybe make it more descriptive in the 'maps' |
330 | * map other than to maybe make it more descriptive in the 'maps' |
270 | * command. But changing the map name makes life more complicated, |
331 | * command. But changing the map name makes life more complicated, |
271 | * (has_been_loaded needs to use the new name) |
332 | * (has_been_loaded needs to use the new name) |
272 | */ |
333 | */ |
273 | |
334 | |
274 | char new_map_name[MAX_BUF]; |
335 | char new_map_name[MAX_BUF]; |
|
|
336 | |
275 | /* give the final map a name */ |
337 | /* give the final map a name */ |
276 | sprintf(new_map_name,"%sfinal_map",RP->final_map); |
338 | sprintf (new_map_name, "%sfinal_map", RP->final_map); |
277 | /* set the exit down. */ |
339 | /* set the exit down. */ |
278 | #endif |
340 | #endif |
279 | /* load it */ |
341 | /* load it */ |
280 | if((new_map=ready_map_name(RP->final_map,0)) == NULL) |
342 | if ((new_map = ready_map_name (RP->final_map, 0)) == NULL) |
281 | return; |
343 | return; |
282 | |
344 | |
283 | the_exit_down->slaying = RP->final_map; |
345 | the_exit_down->slaying = RP->final_map; |
284 | strcpy(new_map->path,RP->final_map); |
346 | strcpy (new_map->path, RP->final_map); |
285 | |
347 | |
286 | for (tmp=GET_MAP_OB(new_map, MAP_ENTER_X(new_map), MAP_ENTER_Y(new_map)); tmp; tmp=tmp->above) |
348 | for (tmp = GET_MAP_OB (new_map, MAP_ENTER_X (new_map), MAP_ENTER_Y (new_map)); tmp; tmp = tmp->above) |
287 | /* Remove exit back to previous random map. There should only be one |
349 | /* Remove exit back to previous random map. There should only be one |
288 | * which is why we break out. To try to process more than one |
350 | * which is why we break out. To try to process more than one |
289 | * would require keeping a 'next' pointer, ad free_object kills tmp, which |
351 | * would require keeping a 'next' pointer, ad free_object kills tmp, which |
290 | * breaks the for loop. |
352 | * breaks the for loop. |
291 | */ |
353 | */ |
292 | if (tmp->type == EXIT && EXIT_PATH(tmp) && !strncmp(EXIT_PATH(tmp),"/random/", 8)) { |
354 | if (tmp->type == EXIT && EXIT_PATH (tmp) && !strncmp (EXIT_PATH (tmp), "/random/", 8)) |
|
|
355 | { |
293 | remove_ob(tmp); |
356 | remove_ob (tmp); |
294 | free_object(tmp); |
357 | free_object (tmp); |
295 | break; |
358 | break; |
296 | } |
359 | } |
297 | |
360 | |
298 | if (final_map_exit == 1) |
361 | if (final_map_exit == 1) |
299 | { |
362 | { |
300 | /* setup the exit back */ |
363 | /* setup the exit back */ |
301 | the_exit_back->slaying = map->path; |
364 | the_exit_back->slaying = map->path; |
302 | the_exit_back->stats.hp = the_exit_down->x; |
365 | the_exit_back->stats.hp = the_exit_down->x; |
303 | the_exit_back->stats.sp = the_exit_down->y; |
366 | the_exit_back->stats.sp = the_exit_down->y; |
304 | the_exit_back->x = MAP_ENTER_X(new_map); |
367 | the_exit_back->x = MAP_ENTER_X (new_map); |
305 | the_exit_back->y = MAP_ENTER_Y(new_map); |
368 | the_exit_back->y = MAP_ENTER_Y (new_map); |
306 | |
369 | |
307 | insert_ob_in_map(the_exit_back,new_map,NULL,0); |
370 | insert_ob_in_map (the_exit_back, new_map, NULL, 0); |
308 | } |
371 | } |
309 | |
372 | |
310 | set_map_timeout(new_map); /* So it gets swapped out */ |
373 | set_map_timeout (new_map); /* So it gets swapped out */ |
|
|
374 | } |
|
|
375 | else |
|
|
376 | the_exit_down->slaying = "/!"; |
|
|
377 | |
|
|
378 | /* Block the exit so things don't get dumped on top of it. */ |
|
|
379 | the_exit_down->move_block = MOVE_ALL; |
|
|
380 | insert_ob_in_map (the_exit_down, map, NULL, 0); |
|
|
381 | maze[the_exit_down->x][the_exit_down->y] = '>'; |
311 | } |
382 | } |
312 | else |
|
|
313 | the_exit_down->slaying = "/!"; |
|
|
314 | |
|
|
315 | /* Block the exit so things don't get dumped on top of it. */ |
|
|
316 | the_exit_down->move_block = MOVE_ALL; |
|
|
317 | insert_ob_in_map(the_exit_down,map,NULL,0); |
|
|
318 | maze[the_exit_down->x][the_exit_down->y]='>'; |
|
|
319 | } |
|
|
320 | } |
383 | } |
321 | |
384 | |
322 | } |
385 | } |
323 | |
386 | |
324 | |
387 | |
325 | |
388 | |
326 | /* this function unblocks the exits. We blocked them to |
389 | /* this function unblocks the exits. We blocked them to |
327 | keep things from being dumped on them during the other |
390 | keep things from being dumped on them during the other |
328 | phases of random map generation. */ |
391 | phases of random map generation. */ |
|
|
392 | void |
329 | void unblock_exits(mapstruct *map, char **maze, RMParms *RP) { |
393 | unblock_exits (mapstruct *map, char **maze, RMParms * RP) |
|
|
394 | { |
330 | int i=0,j=0; |
395 | int i = 0, j = 0; |
331 | object *walk; |
396 | object *walk; |
332 | |
397 | |
333 | for(i=0;i<RP->Xsize;i++) |
398 | for (i = 0; i < RP->Xsize; i++) |
334 | for(j=0;j<RP->Ysize;j++) |
399 | for (j = 0; j < RP->Ysize; j++) |
335 | if(maze[i][j]=='>' || maze[i][j]=='<') { |
400 | if (maze[i][j] == '>' || maze[i][j] == '<') |
|
|
401 | { |
336 | for(walk=get_map_ob(map,i,j);walk!=NULL;walk=walk->above) { |
402 | for (walk = get_map_ob (map, i, j); walk != NULL; walk = walk->above) |
|
|
403 | { |
337 | if(walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) { |
404 | if (walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) |
|
|
405 | { |
338 | walk->move_block = MOVE_BLOCK_DEFAULT; |
406 | walk->move_block = MOVE_BLOCK_DEFAULT; |
339 | update_object(walk,UP_OBJ_CHANGE); |
407 | update_object (walk, UP_OBJ_CHANGE); |
|
|
408 | } |
340 | } |
409 | } |
341 | } |
410 | } |
342 | } |
|
|
343 | } |
411 | } |