From eab0815ddc68dfdcf1797fc39d0d35415fa63069 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Sun, 6 Oct 2019 13:51:16 +0200 Subject: [PATCH] Fix unintentional behavior change with blockers Could be seen on "Insane 3", on teleporter 37. Thanks to Zwelf for reporting. --- src/game/collision.cpp | 6 +++++- src/game/collision.h | 2 +- src/game/server/entities/character.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/collision.cpp b/src/game/collision.cpp index 6bd59a7c6..7e4372884 100644 --- a/src/game/collision.cpp +++ b/src/game/collision.cpp @@ -229,7 +229,7 @@ static int GetMoveRestrictions(int Direction, int Tile, int Flags) return Result&GetMoveRestrictionsMask(Direction); } -int CCollision::GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void *pUser, vec2 Pos, float Distance) +int CCollision::GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void *pUser, vec2 Pos, float Distance, int OverrideCenterTileIndex) { static const vec2 DIRECTIONS[NUM_MR_DIRS] = { @@ -245,6 +245,10 @@ int CCollision::GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void { vec2 ModPos = Pos + DIRECTIONS[d] * Distance; int ModMapIndex = GetPureMapIndex(ModPos); + if(d == MR_DIR_HERE && OverrideCenterTileIndex >= 0) + { + ModMapIndex = OverrideCenterTileIndex; + } for(int Front = 0; Front < 2; Front++) { int Tile; diff --git a/src/game/collision.h b/src/game/collision.h index 7c772ec7a..b3d1d64b1 100644 --- a/src/game/collision.h +++ b/src/game/collision.h @@ -60,7 +60,7 @@ public: int GetIndex(vec2 PrevPos, vec2 Pos); int GetFIndex(int x, int y); - int GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void *pUser, vec2 Pos, float Distance = 18.0f); + int GetMoveRestrictions(CALLBACK_SWITCHACTIVE pfnSwitchActive, void *pUser, vec2 Pos, float Distance = 18.0f, int OverrideCenterTileIndex = -1); int GetMoveRestrictions(vec2 Pos, float Distance = 18.0f) { return GetMoveRestrictions(0, 0, Pos, Distance); diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 510cc3313..3e1c38648 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1364,7 +1364,7 @@ void CCharacter::HandleTiles(int Index) //int PureMapIndex = GameServer()->Collision()->GetPureMapIndex(m_Pos); m_TileIndex = GameServer()->Collision()->GetTileIndex(MapIndex); m_TileFIndex = GameServer()->Collision()->GetFTileIndex(MapIndex); - m_MoveRestrictions = GameServer()->Collision()->GetMoveRestrictions(IsSwitchActiveCb, this, m_Pos); + m_MoveRestrictions = GameServer()->Collision()->GetMoveRestrictions(IsSwitchActiveCb, this, m_Pos, 18.0f, MapIndex); //Sensitivity int S1 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y - m_ProximityRadius / 3.f)); int S2 = GameServer()->Collision()->GetPureMapIndex(vec2(m_Pos.x + m_ProximityRadius / 3.f, m_Pos.y + m_ProximityRadius / 3.f));