From 467a3187dc4dfb5a14a62c53a78f8ed7fca5d0be Mon Sep 17 00:00:00 2001 From: Zwelf Date: Mon, 1 Apr 2024 12:58:41 +0200 Subject: [PATCH] Simplify and fix HookBase calculation Saw this while implementing TwGame. Increase teehistorian version_minor to make replaying teehistorian files easier. --- src/game/gamecore.cpp | 11 ++++++++--- src/game/server/teehistorian.cpp | 2 +- src/test/teehistorian.cpp | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 1d4e67add..fad18b7ac 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -308,11 +308,16 @@ void CCharacterCore::Tick(bool UseInput, bool DoDeferredTick) } else if(m_HookState == HOOK_FLYING) { + vec2 HookBase = m_Pos; + if(m_NewHook) + { + HookBase = m_HookTeleBase; + } vec2 NewPos = m_HookPos + m_HookDir * m_Tuning.m_HookFireSpeed; - if((!m_NewHook && distance(m_Pos, NewPos) > m_Tuning.m_HookLength) || (m_NewHook && distance(m_HookTeleBase, NewPos) > m_Tuning.m_HookLength)) + if(distance(HookBase, NewPos) > m_Tuning.m_HookLength) { m_HookState = HOOK_RETRACT_START; - NewPos = m_Pos + normalize(NewPos - m_Pos) * m_Tuning.m_HookLength; + NewPos = HookBase + normalize(NewPos - HookBase) * m_Tuning.m_HookLength; m_Reset = true; } @@ -337,7 +342,7 @@ void CCharacterCore::Tick(bool UseInput, bool DoDeferredTick) } // Check against other players first - if(!this->m_HookHitDisabled && m_pWorld && m_Tuning.m_PlayerHooking) + if(!this->m_HookHitDisabled && m_pWorld && m_Tuning.m_PlayerHooking && (m_HookState == HOOK_FLYING || !m_NewHook)) { float Distance = 0.0f; for(int i = 0; i < MAX_CLIENTS; i++) diff --git a/src/game/server/teehistorian.cpp b/src/game/server/teehistorian.cpp index f0a4f36b5..022c42819 100644 --- a/src/game/server/teehistorian.cpp +++ b/src/game/server/teehistorian.cpp @@ -10,7 +10,7 @@ static const char TEEHISTORIAN_NAME[] = "teehistorian@ddnet.tw"; static const CUuid TEEHISTORIAN_UUID = CalculateUuid(TEEHISTORIAN_NAME); static const char TEEHISTORIAN_VERSION[] = "2"; -static const char TEEHISTORIAN_VERSION_MINOR[] = "6"; +static const char TEEHISTORIAN_VERSION_MINOR[] = "7"; #define UUID(id, name) static const CUuid UUID_##id = CalculateUuid(name); #include diff --git a/src/test/teehistorian.cpp b/src/test/teehistorian.cpp index 7dceea260..60a912f92 100644 --- a/src/test/teehistorian.cpp +++ b/src/test/teehistorian.cpp @@ -105,7 +105,7 @@ protected: void Expect(const unsigned char *pOutput, size_t OutputSize) { static CUuid TEEHISTORIAN_UUID = CalculateUuid("teehistorian@ddnet.tw"); - static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"version_minor\":\"6\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\""; + static const char PREFIX1[] = "{\"comment\":\"teehistorian@ddnet.tw\",\"version\":\"2\",\"version_minor\":\"7\",\"game_uuid\":\"a1eb7182-796e-3b3e-941d-38ca71b2a4a8\",\"server_version\":\"DDNet test\",\"start_time\":\""; static const char PREFIX2[] = "\",\"server_name\":\"server name\",\"server_port\":\"8303\",\"game_type\":\"game type\",\"map_name\":\"Kobra 3 Solo\",\"map_size\":\"903514\",\"map_sha256\":\"0123456789012345678901234567890123456789012345678901234567890123\",\"map_crc\":\"eceaf25c\",\"prng_description\":\"test-prng:02468ace\",\"config\":{},\"tuning\":{},\"uuids\":["; static const char PREFIX3[] = "]}";