From 6bfdad9771e9303696381bfd1587f9990f5d184f Mon Sep 17 00:00:00 2001 From: Ryozuki Date: Sun, 21 Apr 2019 14:57:45 +0200 Subject: [PATCH] fix super and solo --- src/game/client/components/players.cpp | 1 - src/game/gamecore.cpp | 30 ++++++++++++++++---------- src/game/server/ddracecommands.cpp | 2 ++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 51808d33a..23e0d877a 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -480,7 +480,6 @@ void CPlayers::RenderPlayer( { // apply predicted results m_pClient->m_aClients[ClientID].m_Predicted.Write(&Player); - m_pClient->m_aClients[ClientID].m_Predicted.m_Solo = m_pClient->m_aClients[ClientID].m_Solo; m_pClient->m_aClients[ClientID].m_PrevPredicted.Write(&Prev); IntraTick = Client()->PredIntraGameTick(); diff --git a/src/game/gamecore.cpp b/src/game/gamecore.cpp index 9fa9bd6be..89a35b14f 100644 --- a/src/game/gamecore.cpp +++ b/src/game/gamecore.cpp @@ -1,6 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include "gamecore.h" +#include #include @@ -312,7 +313,7 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) for(int i = 0; i < MAX_CLIENTS; i++) { CCharacterCore *pCharCore = m_pWorld->m_apCharacters[i]; - if(!pCharCore || pCharCore == this || (!m_Super && (!m_pTeams->CanCollide(i, m_Id) || pCharCore->m_Solo || pCharCore->m_NoHookHit))) + if(!pCharCore || pCharCore == this || (!(m_Super || pCharCore->m_Super) && (!m_pTeams->CanCollide(i, m_Id) || pCharCore->m_Solo || m_Solo))) continue; vec2 ClosestPoint = closest_point_on_line(m_HookPos, NewPos, pCharCore->m_Pos); @@ -426,15 +427,23 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) //player *p = (player*)ent; //if(pCharCore == this) // || !(p->flags&FLAG_ALIVE) - if(pCharCore == this || (m_Id != -1 && (!m_Super && !pCharCore->m_Super) && (!m_pTeams->CanCollide(m_Id, i) || pCharCore->m_Solo))) + if(pCharCore == this || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, i))) continue; // make sure that we don't nudge our self + if(!(m_Super || pCharCore->m_Super) && (m_Solo || pCharCore->m_Solo)) + continue; + // handle player <-> player collision float Distance = distance(m_Pos, pCharCore->m_Pos); vec2 Dir = normalize(m_Pos - pCharCore->m_Pos); - if(((m_Super || pCharCore->m_Super) || (pCharCore->m_Collision && this->m_Collision && !pCharCore->m_NoCollision && !this->m_NoCollision && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision)) - && Distance < PhysSize*1.25f - && Distance > 0.0f) + + bool CanCollide = (m_Super || pCharCore->m_Super) + || (pCharCore->m_Collision && m_Collision + && !m_NoCollision && !pCharCore->m_NoCollision + && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision + ); + + if(CanCollide && Distance < PhysSize*1.25f && Distance > 0.0f) { float a = (PhysSize*1.45f - Distance); float Velocity = 0.5f; @@ -449,7 +458,7 @@ void CCharacterCore::Tick(bool UseInput, bool IsClient) } // handle hook influence - if(m_Hook && !m_NoHookHit && m_HookedPlayer == i && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerHooking) + if(m_Hook && m_HookedPlayer == i && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerHooking) { if(Distance > PhysSize*1.50f) // TODO: fix tweakable variable { @@ -628,7 +637,7 @@ void CCharacterCore::Move() m_Vel.x = m_Vel.x*(1.0f/RampValue); - if(m_pWorld && m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision && this->m_Collision) + if(m_pWorld && (m_Super || (m_pWorld->m_Tuning[g_Config.m_ClDummy].m_PlayerCollision && m_Collision && !m_NoCollision && !m_Solo))) { // check player collision float Distance = distance(m_Pos, NewPos); @@ -641,10 +650,9 @@ void CCharacterCore::Move() for(int p = 0; p < MAX_CLIENTS; p++) { CCharacterCore *pCharCore = m_pWorld->m_apCharacters[p]; - if(!pCharCore || pCharCore == this - || !pCharCore->m_Collision - || (m_Id != -1 && !m_pTeams->CanCollide(m_Id, p)) - || pCharCore->m_Solo) + 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))))) continue; float D = distance(Pos, pCharCore->m_Pos); if(D < 28.0f && D > 0.0f) diff --git a/src/game/server/ddracecommands.cpp b/src/game/server/ddracecommands.cpp index 04705ed2f..06b5c1ff0 100644 --- a/src/game/server/ddracecommands.cpp +++ b/src/game/server/ddracecommands.cpp @@ -105,6 +105,7 @@ void CGameContext::ConSuper(IConsole::IResult *pResult, void *pUserData) if (pChr && !pChr->m_Super) { pChr->m_Super = true; + pSelf->m_World.m_Core.m_apCharacters[pResult->m_ClientID]->m_Super = true; pChr->UnFreeze(); pChr->m_TeamBeforeSuper = pChr->Team(); pChr->Teams()->SetCharacterTeam(pResult->m_ClientID, TEAM_SUPER); @@ -121,6 +122,7 @@ void CGameContext::ConUnSuper(IConsole::IResult *pResult, void *pUserData) if (pChr && pChr->m_Super) { pChr->m_Super = false; + pSelf->m_World.m_Core.m_apCharacters[pResult->m_ClientID]->m_Super = false; pChr->Teams()->SetForceCharacterTeam(pResult->m_ClientID, pChr->m_TeamBeforeSuper); }