From 929675be684c2de630196022aa6365d414724bae Mon Sep 17 00:00:00 2001 From: VoxelDoesCode Date: Fri, 17 Mar 2023 17:53:10 -0400 Subject: [PATCH 1/4] Make team kills condensed in killfeed Clang + Formatting test before merge --- datasrc/network.py | 5 + src/game/client/components/killmessages.cpp | 113 ++++++++++++++------ src/game/client/components/killmessages.h | 20 ++-- src/game/server/entities/character.cpp | 21 +++- src/game/server/entities/character.h | 2 +- src/game/server/player.cpp | 4 +- src/game/server/player.h | 2 +- src/game/server/teams.cpp | 37 ++++++- src/game/server/teams.h | 2 + 9 files changed, 158 insertions(+), 48 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 66e064597..501736bcb 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -513,4 +513,9 @@ Messages = [ NetIntAny("m_ServerTimeBest"), NetIntAny("m_PlayerTimeBest"), ]), + + NetMessageEx("Sv_KillMsgPlus", "killmsgplus@netmsg.ddnet.tw", [ + NetBool("m_Sendable"), + NetIntRange("m_TeamSize", 0, 'MAX_CLIENTS'), + ]), ] diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index 317725c77..e64735c1e 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -23,6 +23,10 @@ void CKillMessages::OnWindowResize() void CKillMessages::OnReset() { m_KillmsgCurrent = 0; + m_VictimSkinCurrent = 0; + m_Sendable = true; + m_TeamSizeCarrier = 1; + for(auto &Killmsg : m_aKillmsgs) { Killmsg.m_Tick = -100000; @@ -103,6 +107,17 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) if(m_pClient->m_SuppressEvents) return; + if(MsgType == NETMSGTYPE_SV_KILLMSGPLUS) + { + CNetMsg_Sv_KillMsgPlus *pMsg = (CNetMsg_Sv_KillMsgPlus *)pRawMsg; + + m_Sendable = pMsg->m_Sendable; + m_TeamSizeCarrier = minimum(pMsg->m_TeamSize, 4); + + if(m_Sendable == true) + m_VictimSkinCurrent = 0; + } + if(MsgType == NETMSGTYPE_SV_KILLMSG) { CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg; @@ -112,13 +127,28 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) Kill.m_aVictimName[0] = '\0'; Kill.m_aKillerName[0] = '\0'; + Kill.m_TeamSize = m_TeamSizeCarrier; + Kill.m_VictimID = pMsg->m_Victim; if(Kill.m_VictimID >= 0 && Kill.m_VictimID < MAX_CLIENTS) { Kill.m_VictimTeam = m_pClient->m_aClients[Kill.m_VictimID].m_Team; Kill.m_VictimDDTeam = m_pClient->m_Teams.Team(Kill.m_VictimID); - str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_VictimID].m_aName); - Kill.m_VictimRenderInfo = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; + if(Kill.m_TeamSize != 1) + { + char aBuf[8]; + str_format(aBuf, sizeof(aBuf), "Team %d", Kill.m_VictimDDTeam); + str_copy(Kill.m_aVictimName, aBuf); + } + else + str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_VictimID].m_aName); + + if(!m_Sendable) + m_aVictimSkinBuffer[m_VictimSkinCurrent + 1] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; + else + m_aVictimSkinBuffer[0] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; + + m_VictimSkinCurrent = (m_VictimSkinCurrent + 1) % (MAX_KILLMSGTEAM - 1); } Kill.m_KillerID = pMsg->m_Killer; @@ -135,32 +165,44 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) Kill.m_FlagCarrierBlue = m_pClient->m_Snap.m_pGameDataObj ? m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue : -1; - Kill.m_VitctimTextWidth = Kill.m_KillerTextWidth = 0.f; - - float Width = 400 * 3.0f * Graphics()->ScreenAspect(); - float Height = 400 * 3.0f; - - float ScreenX0, ScreenY0, ScreenX1, ScreenY1; - Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); - Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f); - - CreateKillmessageNamesIfNotCreated(Kill); - - bool KillMsgValid = (Kill.m_VictimRenderInfo.m_CustomColoredSkin && Kill.m_VictimRenderInfo.m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_VictimRenderInfo.m_CustomColoredSkin && Kill.m_VictimRenderInfo.m_OriginalRenderSkin.m_Body.IsValid()); - // if killer != victim, killer must be valid too - KillMsgValid &= Kill.m_KillerID == Kill.m_VictimID || ((Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_OriginalRenderSkin.m_Body.IsValid())); - if(KillMsgValid) + if(m_Sendable) { - // add the message - m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS; + Kill.m_VitctimTextWidth = Kill.m_KillerTextWidth = 0.f; - TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex); - TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex); + float Width = 400 * 3.0f * Graphics()->ScreenAspect(); + float Height = 400 * 3.0f; - m_aKillmsgs[m_KillmsgCurrent] = Kill; + float ScreenX0, ScreenY0, ScreenX1, ScreenY1; + Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); + Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f); + + CreateKillmessageNamesIfNotCreated(Kill); + + int VictimSkinsValid = 0; + for(int i = 0; i < Kill.m_TeamSize; i++) + { + Kill.m_VictimRenderInfo[i] = m_aVictimSkinBuffer[i]; + if((Kill.m_VictimRenderInfo[i].m_CustomColoredSkin && Kill.m_VictimRenderInfo[i].m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_VictimRenderInfo[i].m_CustomColoredSkin && Kill.m_VictimRenderInfo[i].m_OriginalRenderSkin.m_Body.IsValid())) + VictimSkinsValid++; + dbg_msg("valid", "%d", VictimSkinsValid); + } + bool KillMsgValid = (VictimSkinsValid == Kill.m_TeamSize); + + // if killer != victim, killer must be valid too + KillMsgValid &= Kill.m_KillerID == Kill.m_VictimID || ((Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_OriginalRenderSkin.m_Body.IsValid())); + if(KillMsgValid) + { + // add the message + m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS; + + TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex); + TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex); + + m_aKillmsgs[m_KillmsgCurrent] = Kill; + } + + Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } - - Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } } @@ -224,20 +266,23 @@ void CKillMessages::OnRender() if(m_aKillmsgs[r].m_VictimID >= 0) { - CTeeRenderInfo TeeInfo = m_aKillmsgs[r].m_VictimRenderInfo; + for(int j = 0; j < m_aKillmsgs[r].m_TeamSize; j++) + { + CTeeRenderInfo TeeInfo = m_aKillmsgs[r].m_VictimRenderInfo[j]; - CAnimState *pIdleState = CAnimState::GetIdle(); - vec2 OffsetToMid; - RenderTools()->GetRenderTeeOffsetToRenderedTee(pIdleState, &TeeInfo, OffsetToMid); - vec2 TeeRenderPos(x, y + 46.0f / 2.0f + OffsetToMid.y); + 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); + RenderTools()->RenderTee(pIdleState, &TeeInfo, EMOTE_PAIN, vec2(-1, 0), TeeRenderPos); + + x -= 44.0f; + } } - x -= 32.0f; - // render weapon - x -= 44.0f; + x -= 32.0f; if(m_aKillmsgs[r].m_Weapon >= 0) { Graphics()->TextureSet(GameClient()->m_GameSkin.m_aSpriteWeapons[m_aKillmsgs[r].m_Weapon]); @@ -313,7 +358,7 @@ void CKillMessages::RefindSkins() { const CGameClient::CClientData &Client = GameClient()->m_aClients[m_aKillmsgs[r].m_VictimID]; if(Client.m_aSkinName[0] != '\0') - m_aKillmsgs[r].m_VictimRenderInfo = Client.m_RenderInfo; + m_aKillmsgs[r].m_VictimRenderInfo[0] = Client.m_RenderInfo; else m_aKillmsgs[r].m_VictimID = -1; } diff --git a/src/game/client/components/killmessages.h b/src/game/client/components/killmessages.h index 73668b1e4..809428492 100644 --- a/src/game/client/components/killmessages.h +++ b/src/game/client/components/killmessages.h @@ -6,6 +6,11 @@ #include +enum +{ + MAX_KILLMSGS = 5, + MAX_KILLMSGTEAM = 4, +}; class CKillMessages : public CComponent { int m_SpriteQuadContainerIndex; @@ -27,8 +32,7 @@ public: char m_aVictimName[64]; int m_VictimTextContainerIndex; float m_VitctimTextWidth; - CTeeRenderInfo m_VictimRenderInfo; - + CTeeRenderInfo m_VictimRenderInfo[MAX_KILLMSGTEAM]; int m_KillerID; int m_KillerTeam; char m_aKillerName[64]; @@ -39,11 +43,7 @@ public: int m_ModeSpecial; // for CTF, if the guy is carrying a flag for example int m_Tick; int m_FlagCarrierBlue; - }; - - enum - { - MAX_KILLMSGS = 5, + int m_TeamSize; }; private: @@ -53,6 +53,12 @@ public: CKillMsg m_aKillmsgs[MAX_KILLMSGS]; int m_KillmsgCurrent; + CTeeRenderInfo m_aVictimSkinBuffer[MAX_KILLMSGTEAM]; + int m_VictimSkinCurrent; + + bool m_Sendable; + int m_TeamSizeCarrier; + virtual int Sizeof() const override { return sizeof(*this); } virtual void OnWindowResize() override; virtual void OnReset() override; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 0adb70e66..3773e1af0 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -906,7 +906,7 @@ bool CCharacter::IncreaseArmor(int Amount) return true; } -void CCharacter::Die(int Killer, int Weapon) +void CCharacter::Die(int Killer, int Weapon, bool Single) { if(Server()->IsRecording(m_pPlayer->GetCID())) Server()->StopRecord(m_pPlayer->GetCID()); @@ -919,7 +919,24 @@ void CCharacter::Die(int Killer, int Weapon) m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); - // send the kill message + // send the kill messages + if(Single) + { + CNetMsg_Sv_KillMsgPlus MsgPlus; + + if(Team() != TEAM_FLOCK && Teams()->TeamSize(Team()) != 1 && Teams()->GetTeamState(Team()) != 1) + { + MsgPlus.m_Sendable = false; + MsgPlus.m_TeamSize = 0; + } + else + { + MsgPlus.m_Sendable = true; + MsgPlus.m_TeamSize = 1; + } + Server()->SendPackMsg(&MsgPlus, MSGFLAG_VITAL, -1); + } + CNetMsg_Sv_KillMsg Msg; Msg.m_Killer = Killer; Msg.m_Victim = m_pPlayer->GetCID(); diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 4309e54d1..95501fbbf 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -63,7 +63,7 @@ public: void ResetInput(); void FireWeapon(); - void Die(int Killer, int Weapon); + void Die(int Killer, int Weapon, bool Single = true); bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon); bool Spawn(class CPlayer *pPlayer, vec2 Pos); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index b48b2d763..029a31654 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -559,11 +559,11 @@ CCharacter *CPlayer::GetCharacter() return 0; } -void CPlayer::KillCharacter(int Weapon) +void CPlayer::KillCharacter(int Weapon, bool Single) { if(m_pCharacter) { - m_pCharacter->Die(m_ClientID, Weapon); + m_pCharacter->Die(m_ClientID, Weapon, Single); delete m_pCharacter; m_pCharacter = 0; diff --git a/src/game/server/player.h b/src/game/server/player.h index 61f31fe97..07f548351 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -59,7 +59,7 @@ public: void OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput); void OnDisconnect(); - void KillCharacter(int Weapon = WEAPON_GAME); + void KillCharacter(int Weapon = WEAPON_GAME, bool Single = true); CCharacter *GetCharacter(); void SpectatePlayerName(const char *pName); diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 06c1087ce..7fab22530 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -446,6 +446,12 @@ void CGameTeams::ChangeTeamState(int Team, int State) void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) { + int ShowcaseID = 0; + int First = 0; + + if(NewStrongID != -1) + ShowcaseID = NewStrongID; + for(int i = 0; i < MAX_CLIENTS; i++) { if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) @@ -453,7 +459,12 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) GameServer()->m_apPlayers[i]->m_VotedForPractice = false; if(i != ExceptID) { - GameServer()->m_apPlayers[i]->KillCharacter(WEAPON_SELF); + GameServer()->m_apPlayers[i]->KillCharacter(WEAPON_SELF, false); + + First++; + if(First == 1 && NewStrongID == -1) + ShowcaseID = i; + if(NewStrongID != -1 && i != NewStrongID) { GameServer()->m_apPlayers[i]->Respawn(true); // spawn the rest of team with weak hook on the killer @@ -461,6 +472,19 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) } } } + + CNetMsg_Sv_KillMsgPlus MsgPlus; + + MsgPlus.m_Sendable = true; + MsgPlus.m_TeamSize = TeamSize(Team); + Server()->SendPackMsg(&MsgPlus, MSGFLAG_VITAL, -1); + + CNetMsg_Sv_KillMsg Msg; + Msg.m_Killer = ShowcaseID; + Msg.m_Victim = ShowcaseID; + Msg.m_Weapon = WEAPON_SELF; + Msg.m_ModeSpecial = 0; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } bool CGameTeams::TeamFinished(int Team) @@ -1138,3 +1162,14 @@ int CGameTeams::GetFirstEmptyTeam() const return i; return -1; } + +int CGameTeams::TeamSize(int Team) +{ + int TeamSize = 0; + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) + TeamSize++; + } + return TeamSize; +} \ No newline at end of file diff --git a/src/game/server/teams.h b/src/game/server/teams.h index 25a758fed..5d0cf53d7 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -126,6 +126,8 @@ public: int GetFirstEmptyTeam() const; + int TeamSize(int Team); + bool TeeStarted(int ClientID) { return m_aTeeStarted[ClientID]; From 5b1a716aa2e2be9ab6884d1bea1b8a3c0a85a7c6 Mon Sep 17 00:00:00 2001 From: VoxelDoesCode Date: Sun, 26 Mar 2023 20:14:23 -0400 Subject: [PATCH 2/4] Simplify` KillMsgTeams` NetMsg, fixing bugs Clang format before squash Split apart OnMessage() before squash forgot something --- datasrc/network.py | 5 +- src/game/client/components/killmessages.cpp | 148 ++++++++++++-------- src/game/client/components/killmessages.h | 5 - src/game/server/entities/character.cpp | 27 ++-- src/game/server/teams.cpp | 33 +---- 5 files changed, 111 insertions(+), 107 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 501736bcb..5043ab188 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -515,7 +515,8 @@ Messages = [ ]), NetMessageEx("Sv_KillMsgPlus", "killmsgplus@netmsg.ddnet.tw", [ - NetBool("m_Sendable"), - NetIntRange("m_TeamSize", 0, 'MAX_CLIENTS'), + NetIntRange("m_Victim", 0, 'MAX_CLIENTS-1'), + NetIntRange("m_Weapon", -3, 'NUM_WEAPONS-1'), + NetIntRange("m_Size", 0, 'MAX_CLIENTS-1'), ]), ] diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index e64735c1e..09b7f26b1 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -24,8 +24,6 @@ void CKillMessages::OnReset() { m_KillmsgCurrent = 0; m_VictimSkinCurrent = 0; - m_Sendable = true; - m_TeamSizeCarrier = 1; for(auto &Killmsg : m_aKillmsgs) { @@ -111,11 +109,74 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) { CNetMsg_Sv_KillMsgPlus *pMsg = (CNetMsg_Sv_KillMsgPlus *)pRawMsg; - m_Sendable = pMsg->m_Sendable; - m_TeamSizeCarrier = minimum(pMsg->m_TeamSize, 4); + // unpack messages + CKillMsg Kill; + Kill.m_aVictimName[0] = '\0'; + Kill.m_aKillerName[0] = '\0'; + + Kill.m_TeamSize = pMsg->m_Size; + if(Kill.m_TeamSize > MAX_KILLMSGTEAM) + Kill.m_TeamSize = MAX_KILLMSGTEAM; + + Kill.m_VictimID = pMsg->m_Victim; + if(Kill.m_VictimID >= 0 && Kill.m_VictimID < MAX_CLIENTS) + { + Kill.m_VictimTeam = m_pClient->m_aClients[Kill.m_VictimID].m_Team; + Kill.m_VictimDDTeam = m_pClient->m_Teams.Team(Kill.m_VictimID); + Kill.m_VictimRenderInfo[0] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; - if(m_Sendable == true) m_VictimSkinCurrent = 0; + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_pClient->m_Teams.Team(i) == Kill.m_VictimDDTeam && i != Kill.m_VictimID) + { + Kill.m_VictimRenderInfo[m_VictimSkinCurrent + 1] = m_pClient->m_aClients[i].m_RenderInfo; + m_VictimSkinCurrent = (m_VictimSkinCurrent + 1) % (MAX_KILLMSGTEAM - 1); + } + } + + char aBuf[8]; + str_format(aBuf, sizeof(aBuf), "Team %d", Kill.m_VictimDDTeam); + str_copy(Kill.m_aVictimName, aBuf); + } + + Kill.m_KillerID = Kill.m_VictimID; + + Kill.m_Weapon = pMsg->m_Weapon; + Kill.m_ModeSpecial = 0; + Kill.m_Tick = Client()->GameTick(g_Config.m_ClDummy); + + Kill.m_VitctimTextWidth = Kill.m_KillerTextWidth = 0.f; + + float Width = 400 * 3.0f * Graphics()->ScreenAspect(); + float Height = 400 * 3.0f; + + float ScreenX0, ScreenY0, ScreenX1, ScreenY1; + Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); + Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f); + + CreateKillmessageNamesIfNotCreated(Kill); + + int VictimSkinsValid = 0; + for(int i = 0; i < Kill.m_TeamSize; i++) + { + if((Kill.m_VictimRenderInfo[i].m_CustomColoredSkin && Kill.m_VictimRenderInfo[i].m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_VictimRenderInfo[i].m_CustomColoredSkin && Kill.m_VictimRenderInfo[i].m_OriginalRenderSkin.m_Body.IsValid())) + VictimSkinsValid++; + } + bool KillMsgValid = VictimSkinsValid == Kill.m_TeamSize; + + if(KillMsgValid) + { + // add the message + m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS; + + TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex); + TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex); + + m_aKillmsgs[m_KillmsgCurrent] = Kill; + } + + Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } if(MsgType == NETMSGTYPE_SV_KILLMSG) @@ -127,28 +188,15 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) Kill.m_aVictimName[0] = '\0'; Kill.m_aKillerName[0] = '\0'; - Kill.m_TeamSize = m_TeamSizeCarrier; + Kill.m_TeamSize = 1; Kill.m_VictimID = pMsg->m_Victim; if(Kill.m_VictimID >= 0 && Kill.m_VictimID < MAX_CLIENTS) { Kill.m_VictimTeam = m_pClient->m_aClients[Kill.m_VictimID].m_Team; Kill.m_VictimDDTeam = m_pClient->m_Teams.Team(Kill.m_VictimID); - if(Kill.m_TeamSize != 1) - { - char aBuf[8]; - str_format(aBuf, sizeof(aBuf), "Team %d", Kill.m_VictimDDTeam); - str_copy(Kill.m_aVictimName, aBuf); - } - else - str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_VictimID].m_aName); - - if(!m_Sendable) - m_aVictimSkinBuffer[m_VictimSkinCurrent + 1] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; - else - m_aVictimSkinBuffer[0] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; - - m_VictimSkinCurrent = (m_VictimSkinCurrent + 1) % (MAX_KILLMSGTEAM - 1); + str_copy(Kill.m_aVictimName, m_pClient->m_aClients[Kill.m_VictimID].m_aName); + Kill.m_VictimRenderInfo[0] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; } Kill.m_KillerID = pMsg->m_Killer; @@ -165,44 +213,32 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) Kill.m_FlagCarrierBlue = m_pClient->m_Snap.m_pGameDataObj ? m_pClient->m_Snap.m_pGameDataObj->m_FlagCarrierBlue : -1; - if(m_Sendable) + Kill.m_VitctimTextWidth = Kill.m_KillerTextWidth = 0.f; + + float Width = 400 * 3.0f * Graphics()->ScreenAspect(); + float Height = 400 * 3.0f; + + float ScreenX0, ScreenY0, ScreenX1, ScreenY1; + Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); + Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f); + + CreateKillmessageNamesIfNotCreated(Kill); + + bool KillMsgValid = (Kill.m_VictimRenderInfo[0].m_CustomColoredSkin && Kill.m_VictimRenderInfo[0].m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_VictimRenderInfo[0].m_CustomColoredSkin && Kill.m_VictimRenderInfo[0].m_OriginalRenderSkin.m_Body.IsValid()); + // if killer != victim, killer must be valid too + KillMsgValid &= Kill.m_KillerID == Kill.m_VictimID || ((Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_OriginalRenderSkin.m_Body.IsValid())); + if(KillMsgValid) { - Kill.m_VitctimTextWidth = Kill.m_KillerTextWidth = 0.f; + // add the message + m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS; - float Width = 400 * 3.0f * Graphics()->ScreenAspect(); - float Height = 400 * 3.0f; + TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex); + TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex); - float ScreenX0, ScreenY0, ScreenX1, ScreenY1; - Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); - Graphics()->MapScreen(0, 0, Width * 1.5f, Height * 1.5f); - - CreateKillmessageNamesIfNotCreated(Kill); - - int VictimSkinsValid = 0; - for(int i = 0; i < Kill.m_TeamSize; i++) - { - Kill.m_VictimRenderInfo[i] = m_aVictimSkinBuffer[i]; - if((Kill.m_VictimRenderInfo[i].m_CustomColoredSkin && Kill.m_VictimRenderInfo[i].m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_VictimRenderInfo[i].m_CustomColoredSkin && Kill.m_VictimRenderInfo[i].m_OriginalRenderSkin.m_Body.IsValid())) - VictimSkinsValid++; - dbg_msg("valid", "%d", VictimSkinsValid); - } - bool KillMsgValid = (VictimSkinsValid == Kill.m_TeamSize); - - // if killer != victim, killer must be valid too - KillMsgValid &= Kill.m_KillerID == Kill.m_VictimID || ((Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_ColorableRenderSkin.m_Body.IsValid()) || (!Kill.m_KillerRenderInfo.m_CustomColoredSkin && Kill.m_KillerRenderInfo.m_OriginalRenderSkin.m_Body.IsValid())); - if(KillMsgValid) - { - // add the message - m_KillmsgCurrent = (m_KillmsgCurrent + 1) % MAX_KILLMSGS; - - TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_VictimTextContainerIndex); - TextRender()->DeleteTextContainer(m_aKillmsgs[m_KillmsgCurrent].m_KillerTextContainerIndex); - - m_aKillmsgs[m_KillmsgCurrent] = Kill; - } - - Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); + m_aKillmsgs[m_KillmsgCurrent] = Kill; } + + Graphics()->MapScreen(ScreenX0, ScreenY0, ScreenX1, ScreenY1); } } @@ -266,7 +302,7 @@ void CKillMessages::OnRender() if(m_aKillmsgs[r].m_VictimID >= 0) { - for(int j = 0; j < m_aKillmsgs[r].m_TeamSize; j++) + for(int j = (m_aKillmsgs[r].m_TeamSize - 1); j >= 0; j--) { CTeeRenderInfo TeeInfo = m_aKillmsgs[r].m_VictimRenderInfo[j]; diff --git a/src/game/client/components/killmessages.h b/src/game/client/components/killmessages.h index 809428492..bb5404ef0 100644 --- a/src/game/client/components/killmessages.h +++ b/src/game/client/components/killmessages.h @@ -52,13 +52,8 @@ private: public: CKillMsg m_aKillmsgs[MAX_KILLMSGS]; int m_KillmsgCurrent; - - CTeeRenderInfo m_aVictimSkinBuffer[MAX_KILLMSGTEAM]; int m_VictimSkinCurrent; - bool m_Sendable; - int m_TeamSizeCarrier; - virtual int Sizeof() const override { return sizeof(*this); } virtual void OnWindowResize() override; virtual void OnReset() override; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 3773e1af0..b46c9f05b 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -922,28 +922,25 @@ void CCharacter::Die(int Killer, int Weapon, bool Single) // send the kill messages if(Single) { - CNetMsg_Sv_KillMsgPlus MsgPlus; - - if(Team() != TEAM_FLOCK && Teams()->TeamSize(Team()) != 1 && Teams()->GetTeamState(Team()) != 1) + if(Team() != TEAM_FLOCK && Teams()->TeamSize(Team()) > 1 && Teams()->GetTeamState(Team()) != 1) { - MsgPlus.m_Sendable = false; - MsgPlus.m_TeamSize = 0; + CNetMsg_Sv_KillMsgPlus MsgPlus; + MsgPlus.m_Victim = m_pPlayer->GetCID(); + MsgPlus.m_Weapon = Weapon; + MsgPlus.m_Size = Teams()->TeamSize(Team()); + Server()->SendPackMsg(&MsgPlus, MSGFLAG_VITAL, -1); } else { - MsgPlus.m_Sendable = true; - MsgPlus.m_TeamSize = 1; + CNetMsg_Sv_KillMsg Msg; + Msg.m_Killer = Killer; + Msg.m_Victim = m_pPlayer->GetCID(); + Msg.m_Weapon = Weapon; + Msg.m_ModeSpecial = ModeSpecial; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } - Server()->SendPackMsg(&MsgPlus, MSGFLAG_VITAL, -1); } - CNetMsg_Sv_KillMsg Msg; - Msg.m_Killer = Killer; - Msg.m_Victim = m_pPlayer->GetCID(); - Msg.m_Weapon = Weapon; - Msg.m_ModeSpecial = ModeSpecial; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); - // a nice sound GameServer()->CreateSound(m_Pos, SOUND_PLAYER_DIE, TeamMask()); diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 7fab22530..4bd7f9a88 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -446,12 +446,6 @@ void CGameTeams::ChangeTeamState(int Team, int State) void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) { - int ShowcaseID = 0; - int First = 0; - - if(NewStrongID != -1) - ShowcaseID = NewStrongID; - for(int i = 0; i < MAX_CLIENTS; i++) { if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) @@ -461,10 +455,6 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) { GameServer()->m_apPlayers[i]->KillCharacter(WEAPON_SELF, false); - First++; - if(First == 1 && NewStrongID == -1) - ShowcaseID = i; - if(NewStrongID != -1 && i != NewStrongID) { GameServer()->m_apPlayers[i]->Respawn(true); // spawn the rest of team with weak hook on the killer @@ -472,19 +462,6 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) } } } - - CNetMsg_Sv_KillMsgPlus MsgPlus; - - MsgPlus.m_Sendable = true; - MsgPlus.m_TeamSize = TeamSize(Team); - Server()->SendPackMsg(&MsgPlus, MSGFLAG_VITAL, -1); - - CNetMsg_Sv_KillMsg Msg; - Msg.m_Killer = ShowcaseID; - Msg.m_Victim = ShowcaseID; - Msg.m_Weapon = WEAPON_SELF; - Msg.m_ModeSpecial = 0; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } bool CGameTeams::TeamFinished(int Team) @@ -1165,11 +1142,9 @@ int CGameTeams::GetFirstEmptyTeam() const int CGameTeams::TeamSize(int Team) { - int TeamSize = 0; + int NumberOfTees = 0; for(int i = 0; i < MAX_CLIENTS; i++) - { if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) - TeamSize++; - } - return TeamSize; -} \ No newline at end of file + NumberOfTees++; + return NumberOfTees; +} From 0dfced4ca48f8eb71b02662715c66e9b3f809ec9 Mon Sep 17 00:00:00 2001 From: VoxelDoesCode Date: Sun, 2 Apr 2023 21:06:32 -0400 Subject: [PATCH 3/4] Bring Team logic into teams.cpp MsgPlus -> Msg --- src/game/client/components/killmessages.cpp | 5 ++-- src/game/server/entities/character.cpp | 29 +++++++-------------- src/game/server/entities/character.h | 2 +- src/game/server/player.cpp | 4 +-- src/game/server/player.h | 2 +- src/game/server/teams.cpp | 28 +++++++++++++------- src/game/server/teams.h | 2 -- 7 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index 09b7f26b1..d2f00f146 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "killmessages.h" #include @@ -135,9 +136,7 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) } } - char aBuf[8]; - str_format(aBuf, sizeof(aBuf), "Team %d", Kill.m_VictimDDTeam); - str_copy(Kill.m_aVictimName, aBuf); + str_format(Kill.m_aVictimName, sizeof(Kill.m_aVictimName), Localize("Team %d"), Kill.m_VictimDDTeam); } Kill.m_KillerID = Kill.m_VictimID; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index b46c9f05b..c9b46f8ac 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -906,7 +906,7 @@ bool CCharacter::IncreaseArmor(int Amount) return true; } -void CCharacter::Die(int Killer, int Weapon, bool Single) +void CCharacter::Die(int Killer, int Weapon, bool SendKillMsg) { if(Server()->IsRecording(m_pPlayer->GetCID())) Server()->StopRecord(m_pPlayer->GetCID()); @@ -919,26 +919,15 @@ void CCharacter::Die(int Killer, int Weapon, bool Single) m_pPlayer->GetCID(), Server()->ClientName(m_pPlayer->GetCID()), Weapon, ModeSpecial); GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); - // send the kill messages - if(Single) + // send the kill message + if(SendKillMsg && (Team() == TEAM_FLOCK || Teams()->Count(Team()) == 1 || Teams()->GetTeamState(Team()) == CGameTeams::TEAMSTATE_OPEN)) { - if(Team() != TEAM_FLOCK && Teams()->TeamSize(Team()) > 1 && Teams()->GetTeamState(Team()) != 1) - { - CNetMsg_Sv_KillMsgPlus MsgPlus; - MsgPlus.m_Victim = m_pPlayer->GetCID(); - MsgPlus.m_Weapon = Weapon; - MsgPlus.m_Size = Teams()->TeamSize(Team()); - Server()->SendPackMsg(&MsgPlus, MSGFLAG_VITAL, -1); - } - else - { - CNetMsg_Sv_KillMsg Msg; - Msg.m_Killer = Killer; - Msg.m_Victim = m_pPlayer->GetCID(); - Msg.m_Weapon = Weapon; - Msg.m_ModeSpecial = ModeSpecial; - Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); - } + CNetMsg_Sv_KillMsg Msg; + Msg.m_Killer = Killer; + Msg.m_Victim = m_pPlayer->GetCID(); + Msg.m_Weapon = Weapon; + Msg.m_ModeSpecial = ModeSpecial; + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } // a nice sound diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index 95501fbbf..c0c5bfdea 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -63,7 +63,7 @@ public: void ResetInput(); void FireWeapon(); - void Die(int Killer, int Weapon, bool Single = true); + void Die(int Killer, int Weapon, bool SendKillMsg = true); bool TakeDamage(vec2 Force, int Dmg, int From, int Weapon); bool Spawn(class CPlayer *pPlayer, vec2 Pos); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 029a31654..2c27bc0a4 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -559,11 +559,11 @@ CCharacter *CPlayer::GetCharacter() return 0; } -void CPlayer::KillCharacter(int Weapon, bool Single) +void CPlayer::KillCharacter(int Weapon, bool SendKillMsg) { if(m_pCharacter) { - m_pCharacter->Die(m_ClientID, Weapon, Single); + m_pCharacter->Die(m_ClientID, Weapon, SendKillMsg); delete m_pCharacter; m_pCharacter = 0; diff --git a/src/game/server/player.h b/src/game/server/player.h index 07f548351..0934a938f 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -59,7 +59,7 @@ public: void OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput); void OnDisconnect(); - void KillCharacter(int Weapon = WEAPON_GAME, bool Single = true); + void KillCharacter(int Weapon = WEAPON_GAME, bool SendKillMsg = true); CCharacter *GetCharacter(); void SpectatePlayerName(const char *pName); diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 4bd7f9a88..c696e7797 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -446,6 +446,12 @@ void CGameTeams::ChangeTeamState(int Team, int State) void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) { + int ShowcaseID = 0; + int First = 0; + + if(NewStrongID != -1) + ShowcaseID = NewStrongID; + for(int i = 0; i < MAX_CLIENTS; i++) { if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) @@ -455,6 +461,10 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) { GameServer()->m_apPlayers[i]->KillCharacter(WEAPON_SELF, false); + First++; + if(First == 1 && NewStrongID == -1) + ShowcaseID = i; + if(NewStrongID != -1 && i != NewStrongID) { GameServer()->m_apPlayers[i]->Respawn(true); // spawn the rest of team with weak hook on the killer @@ -462,6 +472,13 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) } } } + + // send the team kill message + CNetMsg_Sv_KillMsgPlus Msg; + Msg.m_Victim = ShowcaseID; + Msg.m_Weapon = WEAPON_SELF; + Msg.m_Size = Count(Team); + Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } bool CGameTeams::TeamFinished(int Team) @@ -1138,13 +1155,4 @@ int CGameTeams::GetFirstEmptyTeam() const if(m_aTeamState[i] == TEAMSTATE_EMPTY) return i; return -1; -} - -int CGameTeams::TeamSize(int Team) -{ - int NumberOfTees = 0; - for(int i = 0; i < MAX_CLIENTS; i++) - if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) - NumberOfTees++; - return NumberOfTees; -} +} \ No newline at end of file diff --git a/src/game/server/teams.h b/src/game/server/teams.h index 5d0cf53d7..25a758fed 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -126,8 +126,6 @@ public: int GetFirstEmptyTeam() const; - int TeamSize(int Team); - bool TeeStarted(int ClientID) { return m_aTeeStarted[ClientID]; From 049d89ca41825f47cc79434854d612dc88d3fa82 Mon Sep 17 00:00:00 2001 From: VoxelDoesCode Date: Mon, 17 Apr 2023 17:33:30 -0400 Subject: [PATCH 4/4] Simplify NetMsg even more, with help from Fokko Quick changes Add m_First one more thing fokko pointed this out at 3 am Final push --- datasrc/network.py | 7 ++-- src/game/client/components/killmessages.cpp | 42 ++++++++++++--------- src/game/client/components/killmessages.h | 14 +++---- src/game/server/teams.cpp | 20 ++-------- 4 files changed, 37 insertions(+), 46 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 5043ab188..6da825613 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -514,9 +514,8 @@ Messages = [ NetIntAny("m_PlayerTimeBest"), ]), - NetMessageEx("Sv_KillMsgPlus", "killmsgplus@netmsg.ddnet.tw", [ - NetIntRange("m_Victim", 0, 'MAX_CLIENTS-1'), - NetIntRange("m_Weapon", -3, 'NUM_WEAPONS-1'), - NetIntRange("m_Size", 0, 'MAX_CLIENTS-1'), + NetMessageEx("Sv_KillMsgTeam", "killmsgteam@netmsg.ddnet.tw", [ + NetIntRange("m_Team", 0, 'MAX_CLIENTS-1'), + NetIntRange("m_First", -1, 'MAX_CLIENTS-1'), ]), ] diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index d2f00f146..2158f468b 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -11,6 +11,8 @@ #include "killmessages.h" #include #include +#include +#include void CKillMessages::OnWindowResize() { @@ -24,7 +26,6 @@ void CKillMessages::OnWindowResize() void CKillMessages::OnReset() { m_KillmsgCurrent = 0; - m_VictimSkinCurrent = 0; for(auto &Killmsg : m_aKillmsgs) { @@ -106,42 +107,47 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) if(m_pClient->m_SuppressEvents) return; - if(MsgType == NETMSGTYPE_SV_KILLMSGPLUS) + if(MsgType == NETMSGTYPE_SV_KILLMSGTEAM) { - CNetMsg_Sv_KillMsgPlus *pMsg = (CNetMsg_Sv_KillMsgPlus *)pRawMsg; + CNetMsg_Sv_KillMsgTeam *pMsg = (CNetMsg_Sv_KillMsgTeam *)pRawMsg; // unpack messages CKillMsg Kill; Kill.m_aVictimName[0] = '\0'; Kill.m_aKillerName[0] = '\0'; - Kill.m_TeamSize = pMsg->m_Size; - if(Kill.m_TeamSize > MAX_KILLMSGTEAM) - Kill.m_TeamSize = MAX_KILLMSGTEAM; + std::vector> vStrongWeakSorted; + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_pClient->m_Teams.Team(i) == pMsg->m_Team) + { + CCharacter *pChr = m_pClient->m_GameWorld.GetCharacterByID(i); + vStrongWeakSorted.emplace_back(i, pMsg->m_First == i ? MAX_CLIENTS : pChr ? pChr->GetStrongWeakID() : 0); + } + } - Kill.m_VictimID = pMsg->m_Victim; + std::stable_sort(vStrongWeakSorted.begin(), vStrongWeakSorted.end(), [](auto &Left, auto &Right) { return Left.second > Right.second; }); + + Kill.m_TeamSize = vStrongWeakSorted.size(); + if(Kill.m_TeamSize > MAX_KILLMSG_TEAM_MEMBERS) + Kill.m_TeamSize = MAX_KILLMSG_TEAM_MEMBERS; + + Kill.m_VictimID = vStrongWeakSorted[0].first; if(Kill.m_VictimID >= 0 && Kill.m_VictimID < MAX_CLIENTS) { Kill.m_VictimTeam = m_pClient->m_aClients[Kill.m_VictimID].m_Team; - Kill.m_VictimDDTeam = m_pClient->m_Teams.Team(Kill.m_VictimID); + Kill.m_VictimDDTeam = pMsg->m_Team; Kill.m_VictimRenderInfo[0] = m_pClient->m_aClients[Kill.m_VictimID].m_RenderInfo; - m_VictimSkinCurrent = 0; - for(int i = 0; i < MAX_CLIENTS; i++) - { - if(m_pClient->m_Teams.Team(i) == Kill.m_VictimDDTeam && i != Kill.m_VictimID) - { - Kill.m_VictimRenderInfo[m_VictimSkinCurrent + 1] = m_pClient->m_aClients[i].m_RenderInfo; - m_VictimSkinCurrent = (m_VictimSkinCurrent + 1) % (MAX_KILLMSGTEAM - 1); - } - } + for(int i = 1; i < Kill.m_TeamSize; i++) + Kill.m_VictimRenderInfo[i] = m_pClient->m_aClients[vStrongWeakSorted[i].first].m_RenderInfo; str_format(Kill.m_aVictimName, sizeof(Kill.m_aVictimName), Localize("Team %d"), Kill.m_VictimDDTeam); } Kill.m_KillerID = Kill.m_VictimID; - Kill.m_Weapon = pMsg->m_Weapon; + Kill.m_Weapon = -1; Kill.m_ModeSpecial = 0; Kill.m_Tick = Client()->GameTick(g_Config.m_ClDummy); diff --git a/src/game/client/components/killmessages.h b/src/game/client/components/killmessages.h index bb5404ef0..435a08d25 100644 --- a/src/game/client/components/killmessages.h +++ b/src/game/client/components/killmessages.h @@ -5,15 +5,14 @@ #include #include - -enum -{ - MAX_KILLMSGS = 5, - MAX_KILLMSGTEAM = 4, -}; class CKillMessages : public CComponent { int m_SpriteQuadContainerIndex; + enum + { + MAX_KILLMSGS = 5, + MAX_KILLMSG_TEAM_MEMBERS = 4, + }; public: // kill messages @@ -32,7 +31,7 @@ public: char m_aVictimName[64]; int m_VictimTextContainerIndex; float m_VitctimTextWidth; - CTeeRenderInfo m_VictimRenderInfo[MAX_KILLMSGTEAM]; + CTeeRenderInfo m_VictimRenderInfo[MAX_KILLMSG_TEAM_MEMBERS]; int m_KillerID; int m_KillerTeam; char m_aKillerName[64]; @@ -52,7 +51,6 @@ private: public: CKillMsg m_aKillmsgs[MAX_KILLMSGS]; int m_KillmsgCurrent; - int m_VictimSkinCurrent; virtual int Sizeof() const override { return sizeof(*this); } virtual void OnWindowResize() override; diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index c696e7797..0cb15f182 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -446,12 +446,6 @@ void CGameTeams::ChangeTeamState(int Team, int State) void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) { - int ShowcaseID = 0; - int First = 0; - - if(NewStrongID != -1) - ShowcaseID = NewStrongID; - for(int i = 0; i < MAX_CLIENTS; i++) { if(m_Core.Team(i) == Team && GameServer()->m_apPlayers[i]) @@ -460,11 +454,6 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) if(i != ExceptID) { GameServer()->m_apPlayers[i]->KillCharacter(WEAPON_SELF, false); - - First++; - if(First == 1 && NewStrongID == -1) - ShowcaseID = i; - if(NewStrongID != -1 && i != NewStrongID) { GameServer()->m_apPlayers[i]->Respawn(true); // spawn the rest of team with weak hook on the killer @@ -474,10 +463,9 @@ void CGameTeams::KillTeam(int Team, int NewStrongID, int ExceptID) } // send the team kill message - CNetMsg_Sv_KillMsgPlus Msg; - Msg.m_Victim = ShowcaseID; - Msg.m_Weapon = WEAPON_SELF; - Msg.m_Size = Count(Team); + CNetMsg_Sv_KillMsgTeam Msg; + Msg.m_Team = Team; + Msg.m_First = NewStrongID; Server()->SendPackMsg(&Msg, MSGFLAG_VITAL, -1); } @@ -1155,4 +1143,4 @@ int CGameTeams::GetFirstEmptyTeam() const if(m_aTeamState[i] == TEAMSTATE_EMPTY) return i; return -1; -} \ No newline at end of file +}