From b3e90417683b755e90ec450a8b811e5b77c631a1 Mon Sep 17 00:00:00 2001 From: def Date: Thu, 1 May 2014 03:03:31 +0200 Subject: [PATCH] Revert "Same hook strength for everyone (by cinaera)" This reverts commit 2b084645276baa37b7a31aafa3fab0e3a323201b. --- src/game/client/gameclient.cpp | 2 -- src/game/gamecore.cpp | 35 +++++++++++++------------- src/game/gamecore.h | 16 ++++-------- src/game/server/entities/character.cpp | 2 -- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 054e0f771..2950b58d3 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -518,7 +518,6 @@ static void Evolve(CNetObj_Character *pCharacter, int Tick) { pCharacter->m_Tick++; TempCore.Tick(false, true); - TempCore.PostTick(); TempCore.Move(); TempCore.Quantize(); } @@ -1198,7 +1197,6 @@ void CGameClient::OnPredict() if(!World.m_apCharacters[c]) continue; - World.m_apCharacters[c]->PostTick(); World.m_apCharacters[c]->Move(); World.m_apCharacters[c]->Quantize(); } diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 284913a46..2f4a17d31 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -89,7 +89,6 @@ void CCharacterCore::Reset() { m_Pos = vec2(0,0); m_Vel = vec2(0,0); - m_VelDiff = vec2(0,0); m_NewHook = false; m_HookPos = vec2(0,0); m_HookDir = vec2(0,0); @@ -226,9 +225,9 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) // add the speed modification according to players wanted direction if(m_Direction < 0) - m_Vel.x += SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, -Accel); + m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, -Accel); if(m_Direction > 0) - m_Vel.x += SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, Accel); + m_Vel.x = SaturatedAdd(-MaxSpeed, MaxSpeed, m_Vel.x, Accel); if(m_Direction == 0) m_Vel.x *= Friction; @@ -439,9 +438,9 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) float DragSpeed = m_pWorld->m_Tuning[g_Config.m_ClDummy].m_HookDragSpeed; // add force to the hooked player - vec2 Temp = pCharCore->m_VelDiff; - Temp.x += SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x + pCharCore->m_VelDiff.x, Accel*Dir.x*1.5f); - Temp.y += SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y + pCharCore->m_VelDiff.y, Accel*Dir.y*1.5f); + vec2 Temp = pCharCore->m_Vel; + Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.x, Accel*Dir.x*1.5f); + Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, pCharCore->m_Vel.y, Accel*Dir.y*1.5f); if(Temp.x > 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_270) || (pCharCore->m_TileIndexL == TILE_STOP && pCharCore->m_TileFlagsL == ROTATION_270) || (pCharCore->m_TileIndexL == TILE_STOPS && (pCharCore->m_TileFlagsL == ROTATION_90 || pCharCore->m_TileFlagsL ==ROTATION_270)) || (pCharCore->m_TileIndexL == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_270) || (pCharCore->m_TileFIndexL == TILE_STOP && pCharCore->m_TileFFlagsL == ROTATION_270) || (pCharCore->m_TileFIndexL == TILE_STOPS && (pCharCore->m_TileFFlagsL == ROTATION_90 || pCharCore->m_TileFFlagsL == ROTATION_270)) || (pCharCore->m_TileFIndexL == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_270) || (pCharCore->m_TileSIndexL == TILE_STOP && pCharCore->m_TileSFlagsL == ROTATION_270) || (pCharCore->m_TileSIndexL == TILE_STOPS && (pCharCore->m_TileSFlagsL == ROTATION_90 || pCharCore->m_TileSFlagsL == ROTATION_270)) || (pCharCore->m_TileSIndexL == TILE_STOPA))) Temp.x = 0; if(Temp.x < 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_90) || (pCharCore->m_TileIndexR == TILE_STOP && pCharCore->m_TileFlagsR == ROTATION_90) || (pCharCore->m_TileIndexR == TILE_STOPS && (pCharCore->m_TileFlagsR == ROTATION_90 || pCharCore->m_TileFlagsR == ROTATION_270)) || (pCharCore->m_TileIndexR == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_90) || (pCharCore->m_TileFIndexR == TILE_STOP && pCharCore->m_TileFFlagsR == ROTATION_90) || (pCharCore->m_TileFIndexR == TILE_STOPS && (pCharCore->m_TileFFlagsR == ROTATION_90 || pCharCore->m_TileFFlagsR == ROTATION_270)) || (pCharCore->m_TileFIndexR == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_90) || (pCharCore->m_TileSIndexR == TILE_STOP && pCharCore->m_TileSFlagsR == ROTATION_90) || (pCharCore->m_TileSIndexR == TILE_STOPS && (pCharCore->m_TileSFlagsR == ROTATION_90 || pCharCore->m_TileSFlagsR == ROTATION_270)) || (pCharCore->m_TileSIndexR == TILE_STOPA))) @@ -451,11 +450,19 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) if(Temp.y > 0 && ((pCharCore->m_TileIndex == TILE_STOP && pCharCore->m_TileFlags == ROTATION_0) || (pCharCore->m_TileIndexT == TILE_STOP && pCharCore->m_TileFlagsT == ROTATION_0) || (pCharCore->m_TileIndexT == TILE_STOPS && (pCharCore->m_TileFlagsT == ROTATION_0 || pCharCore->m_TileFlagsT == ROTATION_180)) || (pCharCore->m_TileIndexT == TILE_STOPA) || (pCharCore->m_TileFIndex == TILE_STOP && pCharCore->m_TileFFlags == ROTATION_0) || (pCharCore->m_TileFIndexT == TILE_STOP && pCharCore->m_TileFFlagsT == ROTATION_0) || (pCharCore->m_TileFIndexT == TILE_STOPS && (pCharCore->m_TileFFlagsT == ROTATION_0 || pCharCore->m_TileFFlagsT == ROTATION_180)) || (pCharCore->m_TileFIndexT == TILE_STOPA) || (pCharCore->m_TileSIndex == TILE_STOP && pCharCore->m_TileSFlags == ROTATION_0) || (pCharCore->m_TileSIndexT == TILE_STOP && pCharCore->m_TileSFlagsT == ROTATION_0) || (pCharCore->m_TileSIndexT == TILE_STOPS && (pCharCore->m_TileSFlagsT == ROTATION_0 || pCharCore->m_TileSFlagsT == ROTATION_180)) || (pCharCore->m_TileSIndexT == TILE_STOPA))) Temp.y = 0; - pCharCore->m_VelDiff = Temp; - // add a little bit force to the guy who has the grip - m_Vel.x += SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -Accel*Dir.x*0.25f); - m_Vel.y += SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -Accel*Dir.y*0.25f); + pCharCore->m_Vel = Temp; + Temp.x = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.x, -Accel*Dir.x*0.25f); + Temp.y = SaturatedAdd(-DragSpeed, DragSpeed, m_Vel.y, -Accel*Dir.y*0.25f); + if(Temp.x > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_270) || (m_TileIndexL == TILE_STOP && m_TileFlagsL == ROTATION_270) || (m_TileIndexL == TILE_STOPS && (m_TileFlagsL == ROTATION_90 || m_TileFlagsL ==ROTATION_270)) || (m_TileIndexL == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_270) || (m_TileFIndexL == TILE_STOP && m_TileFFlagsL == ROTATION_270) || (m_TileFIndexL == TILE_STOPS && (m_TileFFlagsL == ROTATION_90 || m_TileFFlagsL == ROTATION_270)) || (m_TileFIndexL == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_270) || (m_TileSIndexL == TILE_STOP && m_TileSFlagsL == ROTATION_270) || (m_TileSIndexL == TILE_STOPS && (m_TileSFlagsL == ROTATION_90 || m_TileSFlagsL == ROTATION_270)) || (m_TileSIndexL == TILE_STOPA))) + Temp.x = 0; + if(Temp.x < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_90) || (m_TileIndexR == TILE_STOP && m_TileFlagsR == ROTATION_90) || (m_TileIndexR == TILE_STOPS && (m_TileFlagsR == ROTATION_90 || m_TileFlagsR == ROTATION_270)) || (m_TileIndexR == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_90) || (m_TileFIndexR == TILE_STOP && m_TileFFlagsR == ROTATION_90) || (m_TileFIndexR == TILE_STOPS && (m_TileFFlagsR == ROTATION_90 || m_TileFFlagsR == ROTATION_270)) || (m_TileFIndexR == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_90) || (m_TileSIndexR == TILE_STOP && m_TileSFlagsR == ROTATION_90) || (m_TileSIndexR == TILE_STOPS && (m_TileSFlagsR == ROTATION_90 || m_TileSFlagsR == ROTATION_270)) || (m_TileSIndexR == TILE_STOPA))) + Temp.x = 0; + if(Temp.y < 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_180) || (m_TileIndexB == TILE_STOP && m_TileFlagsB == ROTATION_180) || (m_TileIndexB == TILE_STOPS && (m_TileFlagsB == ROTATION_0 || m_TileFlagsB == ROTATION_180)) || (m_TileIndexB == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_180) || (m_TileFIndexB == TILE_STOP && m_TileFFlagsB == ROTATION_180) || (m_TileFIndexB == TILE_STOPS && (m_TileFFlagsB == ROTATION_0 || m_TileFFlagsB == ROTATION_180)) || (m_TileFIndexB == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_180) || (m_TileSIndexB == TILE_STOP && m_TileSFlagsB == ROTATION_180) || (m_TileSIndexB == TILE_STOPS && (m_TileSFlagsB == ROTATION_0 || m_TileSFlagsB == ROTATION_180)) || (m_TileSIndexB == TILE_STOPA))) + Temp.y = 0; + if(Temp.y > 0 && ((m_TileIndex == TILE_STOP && m_TileFlags == ROTATION_0) || (m_TileIndexT == TILE_STOP && m_TileFlagsT == ROTATION_0) || (m_TileIndexT == TILE_STOPS && (m_TileFlagsT == ROTATION_0 || m_TileFlagsT == ROTATION_180)) || (m_TileIndexT == TILE_STOPA) || (m_TileFIndex == TILE_STOP && m_TileFFlags == ROTATION_0) || (m_TileFIndexT == TILE_STOP && m_TileFFlagsT == ROTATION_0) || (m_TileFIndexT == TILE_STOPS && (m_TileFFlagsT == ROTATION_0 || m_TileFFlagsT == ROTATION_180)) || (m_TileFIndexT == TILE_STOPA) || (m_TileSIndex == TILE_STOP && m_TileSFlags == ROTATION_0) || (m_TileSIndexT == TILE_STOP && m_TileSFlagsT == ROTATION_0) || (m_TileSIndexT == TILE_STOPS && (m_TileSFlagsT == ROTATION_0 || m_TileSFlagsT == ROTATION_180)) || (m_TileSIndexT == TILE_STOPA))) + Temp.y = 0; + m_Vel = Temp; } } } @@ -580,14 +587,6 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) m_Vel = normalize(m_Vel) * 6000; } -void CCharacterCore::PostTick() -{ - // apply velocity difference caused by external forces AFTER the tick - // to prevent errors in physics calculation (e.g different hook strengths) - m_Vel += m_VelDiff; - m_VelDiff = vec2(0,0); -} - void CCharacterCore::Move() { float RampValue = VelocityRamp(length(m_Vel)*50, m_pWorld->m_Tuning[g_Config.m_ClDummy].m_VelrampStart, m_pWorld->m_Tuning[g_Config.m_ClDummy].m_VelrampRange, m_pWorld->m_Tuning[g_Config.m_ClDummy].m_VelrampCurvature); diff --git a/src/game/gamecore.h b/src/game/gamecore.h index ba111786c..fb98c4c82 100644 --- a/src/game/gamecore.h +++ b/src/game/gamecore.h @@ -120,30 +120,27 @@ inline vec2 CalcPos(vec2 Pos, vec2 Velocity, float Curvature, float Speed, float return n; } -// Saturated adds Modifier on Current -// Returns the difference between new and old value + template inline T SaturatedAdd(T Min, T Max, T Current, T Modifier) { - T Old = Current; - if(Modifier < 0) { if(Current < Min) - return Current - Old; + return Current; Current += Modifier; if(Current < Min) Current = Min; - return Current - Old; + return Current; } else { if(Current > Max) - return Current - Old; + return Current; Current += Modifier; if(Current > Max) Current = Max; - return Current - Old; + return Current; } } @@ -191,7 +188,6 @@ class CCharacterCore public: vec2 m_Pos; vec2 m_Vel; - vec2 m_VelDiff; // caused by external forces, applied on posttick bool m_Hook; bool m_Collision; @@ -221,8 +217,6 @@ public: void Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore* pTeams, std::map > *pTeleOuts); void Reset(); void Tick(bool UseInput, bool IsClient); - void PostTick(); - void PostTick(bool IsClient); void Move(); void Read(const CNetObj_CharacterCore *pObjCore); diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 0481eda65..e4b09e7a7 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -756,13 +756,11 @@ void CCharacter::TickDefered() m_ReckoningCore.Init(&TempWorld, GameServer()->Collision(), &((CGameControllerDDRace*)GameServer()->m_pController)->m_Teams.m_Core, &((CGameControllerDDRace*)GameServer()->m_pController)->m_TeleOuts); m_ReckoningCore.m_Id = m_pPlayer->GetCID(); m_ReckoningCore.Tick(false, false); - m_ReckoningCore.PostTick(); m_ReckoningCore.Move(); m_ReckoningCore.Quantize(); } //lastsentcore - m_Core.PostTick(); vec2 StartPos = m_Core.m_Pos; vec2 StartVel = m_Core.m_Vel; bool StuckBefore = GameServer()->Collision()->TestBox(m_Core.m_Pos, vec2(28.0f, 28.0f));