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

Comparing deliantra/server/random_maps/exit.C (file contents):
Revision 1.1 by elmex, Sun Aug 13 17:16:03 2006 UTC vs.
Revision 1.3 by root, Sun Sep 3 00:18:41 2006 UTC

1/* 1/*
2 * static char *rcsid_exit_c = 2 * static char *rcsid_exit_c =
3 * "$Id: exit.C,v 1.1 2006/08/13 17:16:03 elmex Exp $"; 3 * "$Id: exit.C,v 1.3 2006/09/03 00:18:41 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
117 int upx=-1,upy=-1; /* location of up exit */ 117 int upx=-1,upy=-1; /* location of up exit */
118 int downx=-1,downy=-1; 118 int downx=-1,downy=-1;
119 int final_map_exit=1; 119 int final_map_exit=1;
120 120
121 if(RP->exit_on_final_map){ 121 if(RP->exit_on_final_map){
122 if(strstr(RP->exit_on_final_map,"no")) final_map_exit=0; 122 if(strstr(RP->exit_on_final_map,"no")) final_map_exit=0;
123 } 123 }
124 124
125 if(orientation == 0) orientation = RANDOM() % 6 + 1; 125 if(orientation == 0) orientation = RANDOM() % 6 + 1;
126 126
127 switch(orientation) { 127 switch(orientation) {
167 else the_exit_down = 0; 167 else the_exit_down = 0;
168 168
169 /* set up the up exit */ 169 /* set up the up exit */
170 the_exit_up->stats.hp = RP->origin_x; 170 the_exit_up->stats.hp = RP->origin_x;
171 the_exit_up->stats.sp = RP->origin_y; 171 the_exit_up->stats.sp = RP->origin_y;
172 the_exit_up->slaying = add_string(RP->origin_map); 172 the_exit_up->slaying = RP->origin_map;
173 173
174 /* figure out where to put the entrance */ 174 /* figure out where to put the entrance */
175 /* begin a logical block */ 175 /* begin a logical block */
176 { 176 {
177 int i,j; 177 int i,j;
208 for(j=1;j<9;j++) { 208 for(j=1;j<9;j++) {
209 if(!wall_blocked(map,the_exit_up->x+freearr_x[j],the_exit_up->y+freearr_y[j])) { 209 if(!wall_blocked(map,the_exit_up->x+freearr_x[j],the_exit_up->y+freearr_y[j])) {
210 random_sign = get_archetype("sign"); 210 random_sign = get_archetype("sign");
211 random_sign->x = the_exit_up->x+freearr_x[j]; 211 random_sign->x = the_exit_up->x+freearr_x[j];
212 random_sign->y = the_exit_up->y+freearr_y[j]; 212 random_sign->y = the_exit_up->y+freearr_y[j];
213 213
214 sprintf(buf,"This is a random map.\nLevel: %d\n", (RP->dungeon_level)-1); 214 sprintf(buf,"This is a random map.\nLevel: %d\n", (RP->dungeon_level)-1);
215 215
216 random_sign->msg = add_string(buf); 216 random_sign->msg = buf;
217 insert_ob_in_map(random_sign,map,NULL,0); 217 insert_ob_in_map(random_sign,map,NULL,0);
218 } 218 }
219 } 219 }
220 /* Block the exit so things don't get dumped on top of it. */ 220 /* Block the exit so things don't get dumped on top of it. */
221 the_exit_up->move_block = MOVE_ALL; 221 the_exit_up->move_block = MOVE_ALL;
257 the_exit_down->x = downx + freearr_x[i]; 257 the_exit_down->x = downx + freearr_x[i];
258 the_exit_down->y = downy + freearr_y[i]; 258 the_exit_down->y = downy + freearr_y[i];
259 RP->origin_x = the_exit_down->x; 259 RP->origin_x = the_exit_down->x;
260 RP->origin_y = the_exit_down->y; 260 RP->origin_y = the_exit_down->y;
261 write_map_parameters_to_string(buf,RP); 261 write_map_parameters_to_string(buf,RP);
262 the_exit_down->msg = add_string(buf); 262 the_exit_down->msg = buf;
263 /* the identifier for making a random map. */ 263 /* the identifier for making a random map. */
264 if(RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0]!=0) { 264 if(RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0]!=0) {
265 mapstruct *new_map; 265 mapstruct *new_map;
266 object *the_exit_back = arch_to_object(the_exit_up->arch), *tmp; 266 object *the_exit_back = arch_to_object(the_exit_up->arch), *tmp;
267#if 0 267#if 0
268 /* I'm not sure if there was any reason to change the path to the 268 /* 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' 269 * map other than to maybe make it more descriptive in the 'maps'
270 * command. But changing the map name makes life more complicated, 270 * command. But changing the map name makes life more complicated,
271 * (has_been_loaded needs to use the new name) 271 * (has_been_loaded needs to use the new name)
272 */ 272 */
273 273
274 char new_map_name[MAX_BUF]; 274 char new_map_name[MAX_BUF];
275 /* give the final map a name */ 275 /* give the final map a name */
276 sprintf(new_map_name,"%sfinal_map",RP->final_map); 276 sprintf(new_map_name,"%sfinal_map",RP->final_map);
277 /* set the exit down. */ 277 /* set the exit down. */
278#endif 278#endif
279 /* load it */ 279 /* load it */
280 if((new_map=ready_map_name(RP->final_map,0)) == NULL) 280 if((new_map=ready_map_name(RP->final_map,0)) == NULL)
281 return; 281 return;
282 282
283 the_exit_down->slaying = add_string(RP->final_map); 283 the_exit_down->slaying = RP->final_map;
284 strcpy(new_map->path,RP->final_map); 284 strcpy(new_map->path,RP->final_map);
285 285
286 for (tmp=GET_MAP_OB(new_map, MAP_ENTER_X(new_map), MAP_ENTER_Y(new_map)); tmp; tmp=tmp->above) 286 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 287 /* 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 288 * 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 289 * would require keeping a 'next' pointer, ad free_object kills tmp, which
290 * breaks the for loop. 290 * breaks the for loop.
291 */ 291 */
292 if (tmp->type == EXIT && EXIT_PATH(tmp) && !strncmp(EXIT_PATH(tmp),"/random/", 8)) { 292 if (tmp->type == EXIT && EXIT_PATH(tmp) && !strncmp(EXIT_PATH(tmp),"/random/", 8)) {
293 remove_ob(tmp); 293 remove_ob(tmp);
294 free_object(tmp); 294 free_object(tmp);
295 break; 295 break;
296 } 296 }
297 297
298 if (final_map_exit == 1) 298 if (final_map_exit == 1)
299 { 299 {
300 /* setup the exit back */ 300 /* setup the exit back */
301 the_exit_back->slaying = add_string(map->path); 301 the_exit_back->slaying = map->path;
302 the_exit_back->stats.hp = the_exit_down->x; 302 the_exit_back->stats.hp = the_exit_down->x;
303 the_exit_back->stats.sp = the_exit_down->y; 303 the_exit_back->stats.sp = the_exit_down->y;
304 the_exit_back->x = MAP_ENTER_X(new_map); 304 the_exit_back->x = MAP_ENTER_X(new_map);
305 the_exit_back->y = MAP_ENTER_Y(new_map); 305 the_exit_back->y = MAP_ENTER_Y(new_map);
306 306
307 insert_ob_in_map(the_exit_back,new_map,NULL,0); 307 insert_ob_in_map(the_exit_back,new_map,NULL,0);
308 } 308 }
309 309
310 set_map_timeout(new_map); /* So it gets swapped out */ 310 set_map_timeout(new_map); /* So it gets swapped out */
311 } 311 }
312 else 312 else
313 the_exit_down->slaying = add_string("/!"); 313 the_exit_down->slaying = "/!";
314
314 /* Block the exit so things don't get dumped on top of it. */ 315 /* Block the exit so things don't get dumped on top of it. */
315 the_exit_down->move_block = MOVE_ALL; 316 the_exit_down->move_block = MOVE_ALL;
316 insert_ob_in_map(the_exit_down,map,NULL,0); 317 insert_ob_in_map(the_exit_down,map,NULL,0);
317 maze[the_exit_down->x][the_exit_down->y]='>'; 318 maze[the_exit_down->x][the_exit_down->y]='>';
318 } 319 }
332 for(i=0;i<RP->Xsize;i++) 333 for(i=0;i<RP->Xsize;i++)
333 for(j=0;j<RP->Ysize;j++) 334 for(j=0;j<RP->Ysize;j++)
334 if(maze[i][j]=='>' || maze[i][j]=='<') { 335 if(maze[i][j]=='>' || maze[i][j]=='<') {
335 for(walk=get_map_ob(map,i,j);walk!=NULL;walk=walk->above) { 336 for(walk=get_map_ob(map,i,j);walk!=NULL;walk=walk->above) {
336 if(walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) { 337 if(walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) {
337 walk->move_block = MOVE_BLOCK_DEFAULT; 338 walk->move_block = MOVE_BLOCK_DEFAULT;
338 update_object(walk,UP_OBJ_CHANGE); 339 update_object(walk,UP_OBJ_CHANGE);
339 } 340 }
340 } 341 }
341 } 342 }
342} 343}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines