From 13fae16817fc8728374b67ec2600c3acadd10ea4 Mon Sep 17 00:00:00 2001 From: Kyle Bradley Date: Thu, 8 Apr 2021 16:36:43 +0200 Subject: [PATCH 1/3] Reset hook of all players in a team whenever swap occurs. Standardized hook resets --- src/game/server/entities/character.cpp | 50 ++++++++++---------------- src/game/server/entities/character.h | 1 + src/game/server/teams.cpp | 22 ++++++++---- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 7c4bb1ec5..60449ddb1 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -737,10 +737,20 @@ void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput) mem_copy(&m_LatestPrevInput, &m_LatestInput, sizeof(m_LatestInput)); } +void CCharacter::ResetHook() +{ + m_Core.m_HookedPlayer = -1; + m_Core.m_HookState = HOOK_RETRACTED; + m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; + GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); + m_Core.m_HookPos = m_Core.m_Pos; +} + void CCharacter::ResetInput() { m_Input.m_Direction = 0; //m_Input.m_Hook = 0; + // simulate releasing the fire button if((m_Input.m_Fire & 1) != 0) m_Input.m_Fire++; @@ -1277,7 +1287,8 @@ void CCharacter::Snap(int SnappingClient) if(m_Core.m_ActiveWeapon == WEAPON_NINJA) pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_NINJA; - pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTime == 0 ? 0 : Server()->Tick() + m_FreezeTime; + pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTime == 0 ? 0 : + Server()->Tick() + m_FreezeTime; pDDNetCharacter->m_Jumps = m_Core.m_Jumps; pDDNetCharacter->m_TeleCheckpoint = m_TeleCheckpoint; pDDNetCharacter->m_StrongWeakID = m_StrongWeakID; @@ -1886,10 +1897,7 @@ void CCharacter::HandleTiles(int Index) m_Core.m_Pos = (*m_pTeleOuts)[z - 1][TeleOut]; if(!g_Config.m_SvTeleportHoldHook) { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - m_Core.m_HookPos = m_Core.m_Pos; + ResetHook(); } if(g_Config.m_SvTeleportLoseWeapons) ResetPickups(); @@ -1908,11 +1916,7 @@ void CCharacter::HandleTiles(int Index) if(!g_Config.m_SvTeleportHoldHook) { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_HookPos = m_Core.m_Pos; + ResetHook(); } if(g_Config.m_SvTeleportLoseWeapons) { @@ -1936,11 +1940,7 @@ void CCharacter::HandleTiles(int Index) if(!g_Config.m_SvTeleportHoldHook) { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_HookPos = m_Core.m_Pos; + ResetHook(); } return; @@ -1955,11 +1955,7 @@ void CCharacter::HandleTiles(int Index) if(!g_Config.m_SvTeleportHoldHook) { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - GameWorld()->ReleaseHooked(GetPlayer()->GetCID()); - m_Core.m_HookPos = m_Core.m_Pos; + ResetHook(); } } return; @@ -1978,10 +1974,7 @@ void CCharacter::HandleTiles(int Index) if(!g_Config.m_SvTeleportHoldHook) { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - m_Core.m_HookPos = m_Core.m_Pos; + ResetHook(); } return; @@ -1995,10 +1988,7 @@ void CCharacter::HandleTiles(int Index) if(!g_Config.m_SvTeleportHoldHook) { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; - m_Core.m_HookPos = m_Core.m_Pos; + ResetHook(); } } return; @@ -2275,9 +2265,7 @@ void CCharacter::Pause(bool Pause) if(m_Core.m_HookedPlayer != -1) // Keeping hook would allow cheats { - m_Core.m_HookedPlayer = -1; - m_Core.m_HookState = HOOK_RETRACTED; - m_Core.m_TriggeredEvents |= COREEVENT_HOOK_RETRACT; + ResetHook(); } } else diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index d092df96c..446a57b3a 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -54,6 +54,7 @@ public: void OnPredictedInput(CNetObj_PlayerInput *pNewInput); void OnDirectInput(CNetObj_PlayerInput *pNewInput); + void ResetHook(); void ResetInput(); void FireWeapon(); diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index e63dbb689..53c4abd90 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -726,6 +726,14 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in return; } + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) + { + GameServer()->m_apPlayers[i]->m_SwapTargetsClientID = -1; + } + } + int TimeoutAfterDelay = g_Config.m_SvSaveSwapGamesDelay + g_Config.m_SvSwapTimeout; if(Since >= TimeoutAfterDelay) { @@ -735,12 +743,17 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in GameServer()->SendChatTeam(Team, aBuf); - pPlayer->m_SwapTargetsClientID = -1; - pTargetPlayer->m_SwapTargetsClientID = -1; - return; } + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) + { + GameServer()->m_apPlayers[i]->GetCharacter()->ResetHook(); + } + } + CSaveTee PrimarySavedTee; PrimarySavedTee.Save(pPlayer->GetCharacter()); @@ -750,9 +763,6 @@ void CGameTeams::SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, in PrimarySavedTee.Load(pTargetPlayer->GetCharacter(), Team); SecondarySavedTee.Load(pPlayer->GetCharacter(), Team); - pPlayer->m_SwapTargetsClientID = -1; - pTargetPlayer->m_SwapTargetsClientID = -1; - str_format(aBuf, sizeof(aBuf), "%s has swapped with %s.", Server()->ClientName(pPlayer->GetCID()), Server()->ClientName(pTargetPlayer->GetCID())); From cad6b82cd9e5020bc81e34822c6140417f80efa3 Mon Sep 17 00:00:00 2001 From: Kyle Bradley Date: Thu, 8 Apr 2021 16:39:17 +0200 Subject: [PATCH 2/3] Removed unintended format changes --- src/game/server/entities/character.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 60449ddb1..52b1ddc89 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -750,7 +750,6 @@ void CCharacter::ResetInput() { m_Input.m_Direction = 0; //m_Input.m_Hook = 0; - // simulate releasing the fire button if((m_Input.m_Fire & 1) != 0) m_Input.m_Fire++; @@ -1287,8 +1286,7 @@ void CCharacter::Snap(int SnappingClient) if(m_Core.m_ActiveWeapon == WEAPON_NINJA) pDDNetCharacter->m_Flags |= CHARACTERFLAG_WEAPON_NINJA; - pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTime == 0 ? 0 : - Server()->Tick() + m_FreezeTime; + pDDNetCharacter->m_FreezeEnd = m_DeepFreeze ? -1 : m_FreezeTime == 0 ? 0 : Server()->Tick() + m_FreezeTime; pDDNetCharacter->m_Jumps = m_Core.m_Jumps; pDDNetCharacter->m_TeleCheckpoint = m_TeleCheckpoint; pDDNetCharacter->m_StrongWeakID = m_StrongWeakID; From 7c992e296a9c94fa1ce7c0c7e2d810f1aee7f711 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Fri, 9 Apr 2021 20:11:53 +0200 Subject: [PATCH 3/3] Center more tees --- src/game/client/components/hud.cpp | 32 ++++++++++++++------- src/game/client/components/killmessages.cpp | 25 ++++++++++++++-- src/game/client/components/menus_ingame.cpp | 28 +++++++++++++----- 3 files changed, 66 insertions(+), 19 deletions(-) diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index b092534e5..533ff7387 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -173,6 +173,8 @@ void CHud::RenderScoreHud() float Whole = 300 * Graphics()->ScreenAspect(); float StartY = 229.0f; + const float ScoreSingleBoxHeight = 18.0f; + bool ForceScoreInfoInit = !m_aScoreInfo[0].m_Initialized || !m_aScoreInfo[1].m_Initialized; m_aScoreInfo[0].m_Initialized = m_aScoreInfo[1].m_Initialized = true; @@ -215,7 +217,7 @@ void CHud::RenderScoreHud() Graphics()->SetColor(1.0f, 0.0f, 0.0f, 0.25f); else Graphics()->SetColor(0.0f, 0.0f, 1.0f, 0.25f); - m_aScoreInfo[t].m_RoundRectQuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(Whole - ScoreWidthMax - ImageSize - 2 * Split, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split, 18.0f, 5.0f, CUI::CORNER_L); + m_aScoreInfo[t].m_RoundRectQuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(Whole - ScoreWidthMax - ImageSize - 2 * Split, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split, ScoreSingleBoxHeight, 5.0f, CUI::CORNER_L); } Graphics()->TextureClear(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -282,10 +284,15 @@ void CHud::RenderScoreHud() } // draw tee of the flag holder - CTeeRenderInfo Info = m_pClient->m_aClients[ID].m_RenderInfo; - Info.m_Size = 18.0f; - RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1, 0), - vec2(Whole - ScoreWidthMax - Info.m_Size / 2 - Split, StartY + 1.0f + Info.m_Size / 2 + t * 20)); + CTeeRenderInfo TeeInfo = m_pClient->m_aClients[ID].m_RenderInfo; + TeeInfo.m_Size = ScoreSingleBoxHeight; + + CAnimState *pIdleState = CAnimState::GetIdle(); + vec2 OffsetToMid; + RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); + vec2 TeeRenderPos(Whole - ScoreWidthMax - TeeInfo.m_Size / 2 - Split, StartY + (t * 20) + ScoreSingleBoxHeight / 2.0f + OffsetToMid.y); + + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos); } } StartY += 8.0f; @@ -391,7 +398,7 @@ void CHud::RenderScoreHud() Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.25f); else Graphics()->SetColor(0.0f, 0.0f, 0.0f, 0.25f); - m_aScoreInfo[t].m_RoundRectQuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(Whole - ScoreWidthMax - ImageSize - 2 * Split - PosSize, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split + PosSize, 18.0f, 5.0f, CUI::CORNER_L); + m_aScoreInfo[t].m_RoundRectQuadContainerIndex = RenderTools()->CreateRoundRectQuadContainer(Whole - ScoreWidthMax - ImageSize - 2 * Split - PosSize, StartY + t * 20, ScoreWidthMax + ImageSize + 2 * Split + PosSize, ScoreSingleBoxHeight, 5.0f, CUI::CORNER_L); } Graphics()->TextureClear(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); @@ -446,10 +453,15 @@ void CHud::RenderScoreHud() } // draw tee - CTeeRenderInfo Info = m_pClient->m_aClients[ID].m_RenderInfo; - Info.m_Size = 18.0f; - RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1, 0), - vec2(Whole - ScoreWidthMax - Info.m_Size / 2 - Split, StartY + 1.0f + Info.m_Size / 2 + t * 20)); + CTeeRenderInfo TeeInfo = m_pClient->m_aClients[ID].m_RenderInfo; + TeeInfo.m_Size = ScoreSingleBoxHeight; + + CAnimState *pIdleState = CAnimState::GetIdle(); + vec2 OffsetToMid; + RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); + vec2 TeeRenderPos(Whole - ScoreWidthMax - TeeInfo.m_Size / 2 - Split, StartY + (t * 20) + ScoreSingleBoxHeight / 2.0f + OffsetToMid.y); + + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos); } } else diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index e05a35ba0..77a324032 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -221,7 +221,17 @@ void CKillMessages::OnRender() } if(m_aKillmsgs[r].m_VictimID >= 0) - RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_VictimRenderInfo, EMOTE_PAIN, vec2(-1, 0), vec2(x, y + 28)); + { + CTeeRenderInfo TeeInfo = m_aKillmsgs[r].m_VictimRenderInfo; + + CAnimState *pIdleState = CAnimState::GetIdle(); + vec2 OffsetToMid; + RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); + vec2 TeeRenderPos(x, y + 46.0f / 2.0f + OffsetToMid.y); + + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_PAIN, vec2(-1, 0), TeeRenderPos); + } + x -= 32.0f; // render weapon @@ -254,8 +264,19 @@ void CKillMessages::OnRender() // render killer tee x -= 24.0f; + if(m_aKillmsgs[r].m_KillerID >= 0) - RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_KillerRenderInfo, EMOTE_ANGRY, vec2(1, 0), vec2(x, y + 28)); + { + CTeeRenderInfo TeeInfo = m_aKillmsgs[r].m_KillerRenderInfo; + + CAnimState *pIdleState = CAnimState::GetIdle(); + vec2 OffsetToMid; + RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); + vec2 TeeRenderPos(x, y + 46.0f / 2.0f + OffsetToMid.y); + + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_ANGRY, vec2(1, 0), TeeRenderPos); + } + x -= 32.0f; // render killer name diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 6f0cf005b..d7caadf2d 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -293,9 +293,16 @@ void CMenus::RenderPlayers(CUIRect MainView) // player info Player.VSplitLeft(28.0f, &Button, &Player); - CTeeRenderInfo Info = m_pClient->m_aClients[Index].m_RenderInfo; - Info.m_Size = Button.h; - RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(Button.x + Button.h / 2, Button.y + Button.h / 2)); + + CTeeRenderInfo TeeInfo = m_pClient->m_aClients[Index].m_RenderInfo; + TeeInfo.m_Size = Button.h; + + CAnimState *pIdleState = CAnimState::GetIdle(); + vec2 OffsetToMid; + RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); + vec2 TeeRenderPos(Button.x + Button.h / 2, Button.y + Button.h / 2 + OffsetToMid.y); + + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos); Player.HSplitTop(1.5f, 0, &Player); Player.VSplitMid(&Player, &Button); @@ -589,10 +596,17 @@ bool CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) if(Item.m_Visible) { - CTeeRenderInfo Info = m_pClient->m_aClients[aPlayerIDs[i]].m_RenderInfo; - Info.m_Size = Item.m_Rect.h; - RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, EMOTE_NORMAL, vec2(1, 0), vec2(Item.m_Rect.x + Item.m_Rect.h / 2, Item.m_Rect.y + Item.m_Rect.h / 2)); - Item.m_Rect.x += Info.m_Size; + CTeeRenderInfo TeeInfo = m_pClient->m_aClients[aPlayerIDs[i]].m_RenderInfo; + TeeInfo.m_Size = Item.m_Rect.h; + + CAnimState *pIdleState = CAnimState::GetIdle(); + vec2 OffsetToMid; + RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); + vec2 TeeRenderPos(Item.m_Rect.x + Item.m_Rect.h / 2, Item.m_Rect.y + Item.m_Rect.h / 2 + OffsetToMid.y); + + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), TeeRenderPos); + + Item.m_Rect.x += TeeInfo.m_Size; UI()->DoLabelScaled(&Item.m_Rect, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, -1); } }