| 1030 | } |
| 1031 | |
| 1032 | bool Maps::canStepBetween(df::coord pos1, df::coord pos2) |
| 1033 | { |
| 1034 | color_ostream& out = Core::getInstance().getConsole(); |
| 1035 | int32_t dx = pos2.x-pos1.x; |
| 1036 | int32_t dy = pos2.y-pos1.y; |
| 1037 | int32_t dz = pos2.z-pos1.z; |
| 1038 | |
| 1039 | if ( dx*dx > 1 || dy*dy > 1 || dz*dz > 1 ) |
| 1040 | return false; |
| 1041 | |
| 1042 | if ( pos2.z < pos1.z ) { |
| 1043 | df::coord temp = pos1; |
| 1044 | pos1 = pos2; |
| 1045 | pos2 = temp; |
| 1046 | } |
| 1047 | |
| 1048 | df::map_block *block1 = getTileBlock(pos1); |
| 1049 | df::map_block *block2 = getTileBlock(pos2); |
| 1050 | |
| 1051 | if ( !block1 || !block2 ) |
| 1052 | return false; |
| 1053 | |
| 1054 | if ( !index_tile(block1->walkable,pos1) || !index_tile(block2->walkable,pos2) ) { |
| 1055 | return false; |
| 1056 | } |
| 1057 | |
| 1058 | if ( block1->designation[pos1.x&0xF][pos1.y&0xF].bits.flow_size >= 4 || |
| 1059 | block2->designation[pos2.x&0xF][pos2.y&0xF].bits.flow_size >= 4 ) |
| 1060 | return false; |
| 1061 | |
| 1062 | if ( dz == 0 ) |
| 1063 | return true; |
| 1064 | |
| 1065 | df::tiletype *type1 = Maps::getTileType(pos1); |
| 1066 | df::tiletype *type2 = Maps::getTileType(pos2); |
| 1067 | |
| 1068 | df::tiletype_shape shape1 = ENUM_ATTR(tiletype,shape,*type1); |
| 1069 | df::tiletype_shape shape2 = ENUM_ATTR(tiletype,shape,*type2); |
| 1070 | |
| 1071 | if ( dx == 0 && dy == 0 ) { |
| 1072 | //check for forbidden hatches and floors and such |
| 1073 | df::tile_building_occ upOcc = index_tile(block2->occupancy,pos2).bits.building; |
| 1074 | if ( upOcc == tile_building_occ::Impassable || upOcc == tile_building_occ::Obstacle || upOcc == tile_building_occ::Floored ) |
| 1075 | return false; |
| 1076 | |
| 1077 | if ( shape1 == tiletype_shape::STAIR_UPDOWN && shape2 == shape1 ) |
| 1078 | return true; |
| 1079 | if ( shape1 == tiletype_shape::STAIR_UPDOWN && shape2 == tiletype_shape::STAIR_DOWN ) |
| 1080 | return true; |
| 1081 | if ( shape1 == tiletype_shape::STAIR_UP && shape2 == tiletype_shape::STAIR_UPDOWN ) |
| 1082 | return true; |
| 1083 | if ( shape1 == tiletype_shape::STAIR_UP && shape2 == tiletype_shape::STAIR_DOWN ) |
| 1084 | return true; |
| 1085 | if ( shape1 == tiletype_shape::RAMP && shape2 == tiletype_shape::RAMP_TOP ) { |
| 1086 | //it depends |
| 1087 | //there has to be a wall next to the ramp |
| 1088 | bool foundWall = false; |
| 1089 | for ( int32_t x = -1; x <= 1; x++ ) { |
nothing calls this directly
no test coverage detected