version 1.11 | | version 1.12 |
---|
| | |
/* | | /* |
* static char *rcsid_wall_c = | | * static char *rcsid_wall_c = |
* "$Id: wall.c,v 1.11 2004/08/07 23:24:13 temitchell Exp $"; | | * "$Id: wall.c,v 1.12 2005/11/16 08:16:08 mwedel Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
} | | } |
| | |
| | |
/* like surround_flag, except it checks a map, not a layout. */ | | /* like surround_flag, except it checks a map, not a layout. |
| | * Since this is part of the random map code, presumption |
| | * is that this is not a tiled map. |
| | * What is considered blocking and not is somewhat hard coded. |
| | */ |
int surround_flag3(mapstruct *map,sint16 i,sint16 j,RMParms *RP){ | | int surround_flag3(mapstruct *map,sint16 i,sint16 j,RMParms *RP){ |
/* 1 = blocked to left, | | /* |
2 = blocked to right, | | * 1 = blocked to left, |
4 = blocked above | | * 2 = blocked to right, |
8 = blocked below */ | | * 4 = blocked above |
| | * 8 = blocked below |
| | */ |
| | |
int surround_index = 0; | | int surround_index = 0; |
| | |
if((i > 0) && (get_map_flags(map,NULL, i-1,j, NULL, NULL) & P_BLOCKED)) | | if((i > 0) && (GET_MAP_MOVE_BLOCK(map, i-1,j) & ~MOVE_BLOCK_DEFAULT)) |
surround_index |=1; | | surround_index |=1; |
if((i < RP->Xsize-1) && (get_map_flags(map,NULL, i+1,j, NULL, NULL) & P_BLOCKED)) | | if((i < RP->Xsize-1) && (GET_MAP_MOVE_BLOCK(map, i+1,j) & ~MOVE_BLOCK_DEFAULT)) |
surround_index |=2; | | surround_index |=2; |
if((j > 0) && (get_map_flags(map, NULL, i,j-1, NULL, NULL) & P_BLOCKED)) | | if((j > 0) && (GET_MAP_MOVE_BLOCK(map, i,j-1) & ~MOVE_BLOCK_DEFAULT)) |
surround_index |=4; | | surround_index |=4; |
if((j < RP->Ysize-1) && (get_map_flags(map,NULL, i,j+1, NULL, NULL) & P_BLOCKED)) | | if((j < RP->Ysize-1) && (GET_MAP_MOVE_BLOCK(map,i,j+1) & ~MOVE_BLOCK_DEFAULT)) |
surround_index |=8; | | surround_index |=8; |
| | |
return surround_index; | | return surround_index; |
| | |
thiswall=arch_to_object(the_wall->arch); | | thiswall=arch_to_object(the_wall->arch); |
thiswall->x = i; | | thiswall->x = i; |
thiswall->y = j; | | thiswall->y = j; |
SET_FLAG(thiswall,FLAG_NO_PASS); /* make SURE it's a wall */ | | thiswall->move_block = MOVE_ALL; |
insert_ob_in_map(thiswall,map,thiswall,INS_NO_MERGE | INS_NO_WALK_ON); | | insert_ob_in_map(thiswall,map,thiswall,INS_NO_MERGE | INS_NO_WALK_ON); |
} | | } |
} | | } |
| | |
| | |
| | |
/* this takes a map, and changes an existing wall to match what's blocked | | /* this takes a map, and changes an existing wall to match what's blocked |
around it, counting only doors and walls as blocked. If insert_flag is | | * around it, counting only doors and walls as blocked. If insert_flag is |
1, it will go ahead and insert the wall into the map. If not, it | | * 1, it will go ahead and insert the wall into the map. If not, it |
will only return the wall which would belong there, and doesn't | | * will only return the wall which would belong there, and doesn't |
remove anything. It depends on the | | * remove anything. It depends on the |
global, previously-set variable, "wall_name" */ | | * global, previously-set variable, "wall_name" |
| | */ |
| | |
object * retrofit_joined_wall(mapstruct *the_map,int i,int j,int insert_flag,RMParms *RP) { | | object * retrofit_joined_wall(mapstruct *the_map,int i,int j,int insert_flag,RMParms *RP) { |
/* 1 = wall to left, | | /* 1 = wall to left, |
2 = wall to right, | | * 2 = wall to right, |
4 = wall above | | * 4 = wall above |
8 = wall below */ | | * 8 = wall below |
| | */ |
int surround_index=0; | | int surround_index=0; |
int l; | | int l; |
object *the_wall=0; | | object *the_wall=0; |
| | |
| | |
/* first find the wall */ | | /* first find the wall */ |
for(the_wall = get_map_ob(the_map,i,j);the_wall!=NULL;the_wall=the_wall->above) | | for(the_wall = get_map_ob(the_map,i,j);the_wall!=NULL;the_wall=the_wall->above) |
if(QUERY_FLAG(the_wall,FLAG_NO_PASS) && the_wall->type!=EXIT && the_wall->type!=TELEPORTER) break; | | if ((the_wall->move_type & MOVE_WALK) && the_wall->type!=EXIT && the_wall->type!=TELEPORTER) |
| | break; |
| | |
| | |
/* if what we found is a door, don't remove it, set the_wall to NULL to | | /* if what we found is a door, don't remove it, set the_wall to NULL to |
signal that later. */ | | * signal that later. |
| | */ |
if(the_wall && (the_wall->type==DOOR || the_wall->type==LOCKED_DOOR) ) { | | if(the_wall && (the_wall->type==DOOR || the_wall->type==LOCKED_DOOR) ) { |
the_wall=NULL; | | the_wall=NULL; |
/* if we're not supposed to insert a new wall where there wasn't one, | | /* if we're not supposed to insert a new wall where there wasn't one, |
we've gotta leave. */ | | * we've gotta leave. |
| | */ |
if(insert_flag==0) return 0; | | if(insert_flag==0) return 0; |
} | | } |
else if(the_wall==NULL) return NULL; | | else if(the_wall==NULL) return NULL; |
| | |
} | | } |
| | |
surround_index = surround_flag4(the_map,i,j,RP); | | surround_index = surround_flag4(the_map,i,j,RP); |
| | /* This would be a lot cleaner to just us a lookup table, |
| | * eg, wall_suffix[surround_index] |
| | */ |
switch(surround_index) { | | switch(surround_index) { |
case 0: | | case 0: |
strcat(RP->wall_name,"_0"); | | strcat(RP->wall_name,"_0"); |
| | |
remove_ob(the_wall); | | remove_ob(the_wall); |
free_object(the_wall); | | free_object(the_wall); |
} | | } |
SET_FLAG(new_wall,FLAG_NO_PASS); /* make SURE it's a wall */ | | the_wall->move_block = MOVE_ALL; |
insert_ob_in_map(new_wall,the_map,new_wall,INS_NO_MERGE | INS_NO_WALK_ON); | | insert_ob_in_map(new_wall,the_map,new_wall,INS_NO_MERGE | INS_NO_WALK_ON); |
} | | } |
else | | else |
nroferrors--; /* it's OK not to find an arch. */ | | nroferrors--; /* it's OK not to find an arch. */ |
return new_wall; | | return new_wall; |
| | |
} | | } |
| | |
| | |