From 5065bab8b5ae6620e4a818db698038db774ba935 Mon Sep 17 00:00:00 2001 From: c0d3d3v Date: Mon, 30 May 2022 19:33:42 +0200 Subject: [PATCH] fix swap does not swap no collision and no hook - remove duplicated variable for no collision and no hook --- .../client/prediction/entities/character.cpp | 24 +++++++++---------- src/game/gamecore.cpp | 15 ++++-------- src/game/gamecore.h | 2 -- src/game/server/entities/character.cpp | 16 +++++-------- src/game/server/save.cpp | 8 +++---- 5 files changed, 27 insertions(+), 38 deletions(-) diff --git a/src/game/client/prediction/entities/character.cpp b/src/game/client/prediction/entities/character.cpp index 53a13d7ae..81b55de1f 100644 --- a/src/game/client/prediction/entities/character.cpp +++ b/src/game/client/prediction/entities/character.cpp @@ -829,23 +829,23 @@ void CCharacter::HandleTiles(int Index) } // collide with others - if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && m_Core.m_Collision) + if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && !m_Core.m_NoCollision) { - m_Core.m_Collision = false; + m_Core.m_NoCollision = true; } - else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && !m_Core.m_Collision) + else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && m_Core.m_NoCollision) { - m_Core.m_Collision = true; + m_Core.m_NoCollision = false; } // hook others - if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && m_Core.m_Hook) + if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && !m_Core.m_NoHookHit) { - m_Core.m_Hook = false; + m_Core.m_NoHookHit = true; } - else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && !m_Core.m_Hook) + else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && m_Core.m_NoHookHit) { - m_Core.m_Hook = true; + m_Core.m_NoHookHit = false; } // unlimited air jumps @@ -1131,8 +1131,8 @@ void CCharacter::ResetPrediction() m_Jetpack = false; m_NinjaJetpack = false; m_Core.m_Jumps = 2; - m_Core.m_Hook = true; - m_Core.m_Collision = true; + m_Core.m_NoHookHit = false; + m_Core.m_NoCollision = false; m_NumInputs = 0; m_FreezeTime = 0; m_Core.m_FreezeTick = 0; @@ -1268,8 +1268,8 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende // set player collision SetSolo(!Tuning()->m_PlayerCollision && !Tuning()->m_PlayerHooking); - m_Core.m_Collision = Tuning()->m_PlayerCollision; - m_Core.m_Hook = Tuning()->m_PlayerHooking; + m_Core.m_NoCollision = !Tuning()->m_PlayerCollision; + m_Core.m_NoHookHit = !Tuning()->m_PlayerHooking; if(m_Core.m_HookTick != 0) m_EndlessHook = false; diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 0fc9d4112..2ebfcfe85 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -86,8 +86,6 @@ void CCharacterCore::Reset() m_JumpedTotal = 0; m_Jumps = 2; m_TriggeredEvents = 0; - m_Hook = true; - m_Collision = true; // DDNet Character m_Solo = false; @@ -275,7 +273,7 @@ void CCharacterCore::Tick(bool UseInput) } // Check against other players first - if(this->m_Hook && m_pWorld && m_Tuning.m_PlayerHooking) + if(!this->m_NoHookHit && m_pWorld && m_Tuning.m_PlayerHooking) { float Distance = 0.0f; for(int i = 0; i < MAX_CLIENTS; i++) @@ -409,7 +407,7 @@ void CCharacterCore::Tick(bool UseInput) { vec2 Dir = normalize(m_Pos - pCharCore->m_Pos); - bool CanCollide = (m_Super || pCharCore->m_Super) || (pCharCore->m_Collision && m_Collision && !m_NoCollision && !pCharCore->m_NoCollision && m_Tuning.m_PlayerCollision); + bool CanCollide = (m_Super || pCharCore->m_Super) || (!m_NoCollision && !pCharCore->m_NoCollision && m_Tuning.m_PlayerCollision); if(CanCollide && Distance < PhysicalSize() * 1.25f && Distance > 0.0f) { @@ -426,7 +424,7 @@ void CCharacterCore::Tick(bool UseInput) } // handle hook influence - if(m_Hook && m_HookedPlayer == i && m_Tuning.m_PlayerHooking) + if(!m_NoHookHit && m_HookedPlayer == i && m_Tuning.m_PlayerHooking) { if(Distance > PhysicalSize() * 1.50f) // TODO: fix tweakable variable { @@ -482,7 +480,7 @@ void CCharacterCore::Move() m_Vel.x = m_Vel.x * (1.0f / RampValue); - if(m_pWorld && (m_Super || (m_Tuning.m_PlayerCollision && m_Collision && !m_NoCollision && !m_Solo))) + if(m_pWorld && (m_Super || (m_Tuning.m_PlayerCollision && !m_NoCollision && !m_Solo))) { // check player collision float Distance = distance(m_Pos, NewPos); @@ -499,7 +497,7 @@ void CCharacterCore::Move() CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p]; if(!pCharCore || pCharCore == this) continue; - if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || !pCharCore->m_Collision || pCharCore->m_NoCollision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p))))) + if((!(pCharCore->m_Super || m_Super) && (m_Solo || pCharCore->m_Solo || pCharCore->m_NoCollision || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p))))) continue; float D = distance(Pos, pCharCore->m_Pos); if(D < PhysicalSize() && D >= 0.0f) @@ -574,9 +572,6 @@ void CCharacterCore::ReadDDNet(const CNetObj_DDNetCharacter *pObjDDNet) m_NoHookHit = pObjDDNet->m_Flags & CHARACTERFLAG_NO_HOOK; m_Super = pObjDDNet->m_Flags & CHARACTERFLAG_SUPER; - m_Hook = !m_NoHookHit; - m_Collision = !m_NoCollision; - // Endless m_EndlessHook = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_HOOK; m_EndlessJump = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_JUMP; diff --git a/src/game/gamecore.h b/src/game/gamecore.h index b790d18dd..fce0b5188 100644 --- a/src/game/gamecore.h +++ b/src/game/gamecore.h @@ -212,8 +212,6 @@ public: static constexpr vec2 PhysicalSizeVec2() { return vec2(28.0f, 28.0f); }; vec2 m_Pos; vec2 m_Vel; - bool m_Hook; - bool m_Collision; vec2 m_HookPos; vec2 m_HookDir; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 3c53f4202..771e808a2 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1231,9 +1231,9 @@ void CCharacter::Snap(int SnappingClient) pDDNetCharacter->m_Flags |= CHARACTERFLAG_SUPER; if(m_EndlessHook) pDDNetCharacter->m_Flags |= CHARACTERFLAG_ENDLESS_HOOK; - if(!m_Core.m_Collision || !GameServer()->Tuning()->m_PlayerCollision) + if(m_Core.m_NoCollision || !GameServer()->Tuning()->m_PlayerCollision) pDDNetCharacter->m_Flags |= CHARACTERFLAG_NO_COLLISION; - if(!m_Core.m_Hook || !GameServer()->Tuning()->m_PlayerHooking) + if(m_Core.m_NoHookHit || !GameServer()->Tuning()->m_PlayerHooking) pDDNetCharacter->m_Flags |= CHARACTERFLAG_NO_HOOK; if(m_SuperJump) pDDNetCharacter->m_Flags |= CHARACTERFLAG_ENDLESS_JUMP; @@ -1577,36 +1577,32 @@ void CCharacter::HandleTiles(int Index) } // collide with others - if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && m_Core.m_Collision) + if(((m_TileIndex == TILE_NPC_DISABLE) || (m_TileFIndex == TILE_NPC_DISABLE)) && !m_Core.m_NoCollision) { GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't collide with others"); - m_Core.m_Collision = false; m_Core.m_NoCollision = true; m_NeededFaketuning |= FAKETUNE_NOCOLL; GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings } - else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && !m_Core.m_Collision) + else if(((m_TileIndex == TILE_NPC_ENABLE) || (m_TileFIndex == TILE_NPC_ENABLE)) && m_Core.m_NoCollision) { GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can collide with others"); - m_Core.m_Collision = true; m_Core.m_NoCollision = false; m_NeededFaketuning &= ~FAKETUNE_NOCOLL; GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings } // hook others - if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && m_Core.m_Hook) + if(((m_TileIndex == TILE_NPH_DISABLE) || (m_TileFIndex == TILE_NPH_DISABLE)) && !m_Core.m_NoHookHit) { GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can't hook others"); - m_Core.m_Hook = false; m_Core.m_NoHookHit = true; m_NeededFaketuning |= FAKETUNE_NOHOOK; GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings } - else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && !m_Core.m_Hook) + else if(((m_TileIndex == TILE_NPH_ENABLE) || (m_TileFIndex == TILE_NPH_ENABLE)) && m_Core.m_NoHookHit) { GameServer()->SendChatTarget(GetPlayer()->GetCID(), "You can hook others"); - m_Core.m_Hook = true; m_Core.m_NoHookHit = false; m_NeededFaketuning &= ~FAKETUNE_NOHOOK; GameServer()->SendTuningParams(m_pPlayer->GetCID(), m_TuneZone); // update tunings diff --git a/src/game/server/save.cpp b/src/game/server/save.cpp index 0a11c208e..38e54b795 100644 --- a/src/game/server/save.cpp +++ b/src/game/server/save.cpp @@ -77,8 +77,8 @@ void CSaveTee::Save(CCharacter *pChr) // Core m_CorePos = pChr->m_Core.m_Pos; m_Vel = pChr->m_Core.m_Vel; - m_Hook = pChr->m_Core.m_Hook; - m_Collision = pChr->m_Core.m_Collision; + m_Hook = !pChr->m_Core.m_NoHookHit; + m_Collision = !pChr->m_Core.m_NoCollision; m_ActiveWeapon = pChr->m_Core.m_ActiveWeapon; m_Jumped = pChr->m_Core.m_Jumped; m_JumpedTotal = pChr->m_Core.m_JumpedTotal; @@ -170,8 +170,8 @@ void CSaveTee::Load(CCharacter *pChr, int Team, bool IsSwap) // Core pChr->m_Core.m_Pos = m_CorePos; pChr->m_Core.m_Vel = m_Vel; - pChr->m_Core.m_Hook = m_Hook; - pChr->m_Core.m_Collision = m_Collision; + pChr->m_Core.m_NoHookHit = !m_Hook; + pChr->m_Core.m_NoCollision = !m_Collision; pChr->m_Core.m_ActiveWeapon = m_ActiveWeapon; pChr->m_Core.m_Jumped = m_Jumped; pChr->m_Core.m_JumpedTotal = m_JumpedTotal;