@ -1911,7 +1911,7 @@ geom2d::rect<int>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
bool hasTerrain = false ;
bool hasTerrain = false ;
for ( const LayerTag & layer : GetCurrentMap ( ) . LayerData ) { //Figure out if any tile at this position is terrain. If so, we have a collision box to check.
for ( const LayerTag & layer : GetCurrentMap ( ) . LayerData ) { //Figure out if any tile at this position is terrain. If so, we have a collision box to check.
int tileID = layer . tiles [ pos . y / 24 ] [ pos . x / 24 ] - 1 ;
int tileID = layer . tiles [ pos . y / GetCurrentMapData ( ) . tilewidth ] [ pos . x / GetCurrentMapData ( ) . tilewidth ] - 1 ;
if ( tileID = = - 1 ) continue ;
if ( tileID = = - 1 ) continue ;
const TilesheetData & data = GetTileSheet ( GetCurrentLevel ( ) , tileID ) ;
const TilesheetData & data = GetTileSheet ( GetCurrentLevel ( ) , tileID ) ;
if ( data . tileset - > isTerrain ) {
if ( data . tileset - > isTerrain ) {
@ -1919,7 +1919,7 @@ geom2d::rect<int>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
break ;
break ;
}
}
}
}
if ( ! hasTerrain ) return geom2d : : rect < int > ( { 0 , 0 } , { 24 , 24 } ) ; //We assume no terrain means we can't walk on this.
if ( ! hasTerrain ) return geom2d : : rect < int > ( { 0 , 0 } , { GetCurrentMapData ( ) . tilewidth , GetCurrentMapData ( ) . tilewidth } ) ; //We assume no terrain means we can't walk on this.
# pragma region Lower Bridge Collision Check
# pragma region Lower Bridge Collision Check
if ( ! upperLevel ) { //We are looking for lower bridge collisions.
if ( ! upperLevel ) { //We are looking for lower bridge collisions.
@ -1932,7 +1932,7 @@ geom2d::rect<int>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
# pragma endregion
# pragma endregion
//The logic here is, if there's a tile on the bridge, we respect that tile instead if we're on the upper level. So we don't check other layers when we are on the upper level and there is a tile below us.
//The logic here is, if there's a tile on the bridge, we respect that tile instead if we're on the upper level. So we don't check other layers when we are on the upper level and there is a tile below us.
if ( upperLevel & & bridgeLayerIndex ! = - 1 ) {
if ( upperLevel & & bridgeLayerIndex ! = - 1 ) {
int tileID = MAP_DATA [ map ] . LayerData [ bridgeLayerIndex ] . tiles [ int ( pos . y ) / game - > GetCurrentMapData ( ) . tilewidth ] [ int ( pos . x ) / game - > GetCurrentMapData ( ) . tilewidth ] - 1 ;
int tileID = MAP_DATA [ map ] . LayerData [ bridgeLayerIndex ] . tiles [ int ( pos . y ) / GetCurrentMapData ( ) . tilewidth ] [ int ( pos . x ) / GetCurrentMapData ( ) . tilewidth ] - 1 ;
if ( tileID ! = - 1 ) {
if ( tileID ! = - 1 ) {
if ( GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . find ( tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ) ! = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . end ( ) ) {
if ( GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . find ( tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ) ! = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . end ( ) ) {
return GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision [ tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ] . collision ;
return GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision [ tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ] . collision ;
@ -1944,7 +1944,7 @@ geom2d::rect<int>AiL::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
for ( int counter = 0 ; LayerTag & layer : MAP_DATA [ map ] . LayerData ) {
for ( int counter = 0 ; LayerTag & layer : MAP_DATA [ map ] . LayerData ) {
//auto HasNoClass=[&](){return layer.tag.data.find("class")==layer.tag.data.end();};
//auto HasNoClass=[&](){return layer.tag.data.find("class")==layer.tag.data.end();};
if ( counter ! = bridgeLayerIndex ) {
if ( counter ! = bridgeLayerIndex ) {
int tileID = layer . tiles [ int ( pos . y ) / game - > GetCurrentMapData ( ) . tilewidth ] [ int ( pos . x ) / game - > GetCurrentMapData ( ) . tilewidth ] - 1 ;
int tileID = layer . tiles [ int ( pos . y ) / GetCurrentMapData ( ) . tilewidth ] [ int ( pos . x ) / GetCurrentMapData ( ) . tilewidth ] - 1 ;
if ( tileID ! = - 1 & & GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . find ( tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ) ! = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . end ( ) ) {
if ( tileID ! = - 1 & & GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . find ( tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ) ! = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision . end ( ) ) {
geom2d : : rect < int > collisionRect = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision [ tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ] . collision ;
geom2d : : rect < int > collisionRect = GetTileSheet ( map , tileID % 1000000 ) . tileset - > collision [ tileID % 1000000 - GetTileSheet ( map , tileID % 1000000 ) . firstgid + 1 ] . collision ;
if ( foundRect . pos = = NO_COLLISION . pos & & foundRect . size = = NO_COLLISION . size ) {
if ( foundRect . pos = = NO_COLLISION . pos & & foundRect . size = = NO_COLLISION . size ) {