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.2 by root, Tue Aug 29 08:01:36 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.2 2006/08/29 08:01:36 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) {
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 = add_string(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;
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 = add_string(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 = add_string(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 = add_string("/!");
314 /* Block the exit so things don't get dumped on top of it. */ 314 /* Block the exit so things don't get dumped on top of it. */
315 the_exit_down->move_block = MOVE_ALL; 315 the_exit_down->move_block = MOVE_ALL;
332 for(i=0;i<RP->Xsize;i++) 332 for(i=0;i<RP->Xsize;i++)
333 for(j=0;j<RP->Ysize;j++) 333 for(j=0;j<RP->Ysize;j++)
334 if(maze[i][j]=='>' || maze[i][j]=='<') { 334 if(maze[i][j]=='>' || maze[i][j]=='<') {
335 for(walk=get_map_ob(map,i,j);walk!=NULL;walk=walk->above) { 335 for(walk=get_map_ob(map,i,j);walk!=NULL;walk=walk->above) {
336 if(walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) { 336 if(walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) {
337 walk->move_block = MOVE_BLOCK_DEFAULT; 337 walk->move_block = MOVE_BLOCK_DEFAULT;
338 update_object(walk,UP_OBJ_CHANGE); 338 update_object(walk,UP_OBJ_CHANGE);
339 } 339 }
340 } 340 }
341 } 341 }
342} 342}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines