From 0d916e2ef6a18e76bca60cad27b23360ac4c1b6c Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Sun, 10 Jan 2021 17:23:00 +0100 Subject: [PATCH] Remove F-Client-specific messages The PLAYERFLAG_AIM can now be set directly on DDNet servers via the 0.7 bridge and will be sent to clients identifying themselves as DDNet clients. Add a new extended message that mirror the old `Sv_TeamsState`. --- datasrc/network.py | 12 +++--------- datasrc/seven/network.py | 2 +- src/engine/client/client.cpp | 5 +++++ src/engine/client/client.h | 1 + src/engine/server/server.cpp | 5 +---- src/engine/shared/protocol.h | 1 + src/engine/shared/protocol_ex.h | 3 ++- src/game/client/gameclient.cpp | 2 +- src/game/server/entities/character.cpp | 2 -- src/game/server/gamecontext.cpp | 14 -------------- src/game/server/player.cpp | 18 ++++++++---------- src/game/server/player.h | 1 - src/game/server/teams.cpp | 11 ++++++++++- 13 files changed, 33 insertions(+), 44 deletions(-) diff --git a/datasrc/network.py b/datasrc/network.py index 4db9e738e..2c7bbd8f5 100644 --- a/datasrc/network.py +++ b/datasrc/network.py @@ -23,7 +23,7 @@ GameInfoFlags = [ GameInfoFlags2 = [ "ALLOW_X_SKINS", "GAMETYPE_CITY", "GAMETYPE_FDDRACE", "ENTITIES_FDDRACE", ] -ExPlayerFlags = ["AFK", "PAUSED", "SPEC", "AIM"] +ExPlayerFlags = ["AFK", "PAUSED", "SPEC"] Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"] @@ -421,7 +421,7 @@ Messages = [ NetMessage("Unused", []), - NetMessage("Sv_TeamsState", []), + NetMessage("Sv_TeamsStateLegacy", []), # deprecated, use showothers@netmsg.ddnet.tw instead NetMessage("Cl_ShowOthersLegacy", [ @@ -442,11 +442,5 @@ Messages = [ NetIntRange("m_Show", 0, 2), ]), - NetMessageEx("Sv_TeamsStateEx", "teamsstate@netmsg.ddnet.tw", []), - - NetMessageEx("Cl_ExPlayerFlags", "explayerflags@netmsg.7.ddnet.tw", [ - NetIntAny("m_Flags"), - ]), - - NetMessageEx("Cl_IsDDrace", "isddrace@netmsg.7.ddnet.tw", []), + NetMessageEx("Sv_TeamsState", "teamsstate@netmsg.ddnet.tw", []), ] diff --git a/datasrc/seven/network.py b/datasrc/seven/network.py index 7ac60a865..d24ddb4e0 100644 --- a/datasrc/seven/network.py +++ b/datasrc/seven/network.py @@ -6,7 +6,7 @@ Emoticons = Enum("EMOTICON", ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", Votes = Enum("VOTE", ["UNKNOWN", "START_OP", "START_KICK", "START_SPEC", "END_ABORT", "END_PASS", "END_FAIL"]) # todo 0.8: add RUN_OP, RUN_KICK, RUN_SPEC; rem UNKNOWN ChatModes = Enum("CHAT", ["NONE", "ALL", "TEAM", "WHISPER"]) -PlayerFlags = Flags("PLAYERFLAG", ["ADMIN", "CHATTING", "SCOREBOARD", "READY", "DEAD", "WATCHING", "BOT"]) +PlayerFlags = Flags("PLAYERFLAG", ["ADMIN", "CHATTING", "SCOREBOARD", "READY", "DEAD", "WATCHING", "BOT", "AIM"]) GameFlags = Flags("GAMEFLAG", ["TEAMS", "FLAGS", "SURVIVAL", "RACE"]) GameStateFlags = Flags("GAMESTATEFLAG", ["WARMUP", "SUDDENDEATH", "ROUNDOVER", "GAMEOVER", "PAUSED", "STARTCOUNTDOWN"]) CoreEventFlags = Flags("COREEVENTFLAG", ["GROUND_JUMP", "AIR_JUMP", "HOOK_ATTACH_PLAYER", "HOOK_ATTACH_GROUND", "HOOK_HIT_NOHOOK"]) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index d70c16702..b2e002312 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1602,10 +1602,15 @@ static CServerCapabilities GetServerCapabilities(int Version, int Flags) DDNet = Flags & SERVERCAPFLAG_DDNET; } Result.m_ChatTimeoutCode = DDNet; + Result.m_AnyPlayerFlag = DDNet; if(Version >= 1) { Result.m_ChatTimeoutCode = Flags & SERVERCAPFLAG_CHATTIMEOUTCODE; } + if(Version >= 2) + { + Result.m_AnyPlayerFlag = Flags & SERVERCAPFLAG_ANYPLAYERFLAG; + } return Result; } diff --git a/src/engine/client/client.h b/src/engine/client/client.h index dae4c1131..565c0d44b 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -78,6 +78,7 @@ class CServerCapabilities { public: bool m_ChatTimeoutCode; + bool m_AnyPlayerFlag; }; class CClient : public IClient, public CDemoPlayer::IListener diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index e71995bd3..9fc24d32f 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -724,9 +724,6 @@ static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer, bool Sixup } else { - if(MsgId == NETMSGTYPE_SV_TEAMSSTATE) - MsgId = NETMSGTYPE_SV_TEAMSSTATEEX; - if(MsgId >= 0 && MsgId < OFFSET_UUID) MsgId = Msg_SixToSeven(MsgId); @@ -1151,7 +1148,7 @@ void CServer::SendCapabilities(int ClientID) { CMsgPacker Msg(NETMSG_CAPABILITIES, true); Msg.AddInt(SERVERCAP_CURVERSION); // version - Msg.AddInt(SERVERCAPFLAG_DDNET | SERVERCAPFLAG_CHATTIMEOUTCODE); // flags + Msg.AddInt(SERVERCAPFLAG_DDNET | SERVERCAPFLAG_CHATTIMEOUTCODE | SERVERCAPFLAG_ANYPLAYERFLAG); // flags SendMsg(&Msg, MSGFLAG_VITAL, ClientID); } diff --git a/src/engine/shared/protocol.h b/src/engine/shared/protocol.h index 8df95dfeb..56ff0248c 100644 --- a/src/engine/shared/protocol.h +++ b/src/engine/shared/protocol.h @@ -114,6 +114,7 @@ enum VERSION_DDNET_FIREDELAY_TUNE = 701, VERSION_DDNET_UPDATER_FIXED = 707, VERSION_DDNET_GAMETICK = 10042, + VERSION_DDNET_TEAMSSTATE_LEGACY = 15025, }; #endif diff --git a/src/engine/shared/protocol_ex.h b/src/engine/shared/protocol_ex.h index 25ce6643b..81d2b444d 100644 --- a/src/engine/shared/protocol_ex.h +++ b/src/engine/shared/protocol_ex.h @@ -20,9 +20,10 @@ enum UNPACKMESSAGE_OK, UNPACKMESSAGE_ANSWER, - SERVERCAP_CURVERSION = 1, + SERVERCAP_CURVERSION = 2, SERVERCAPFLAG_DDNET = 1 << 0, SERVERCAPFLAG_CHATTIMEOUTCODE = 1 << 1, + SERVERCAPFLAG_ANYPLAYERFLAG = 1 << 2, }; void RegisterUuids(class CUuidManager *pManager); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 7070dcb39..1ae92c039 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -854,7 +854,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_SoundID, 1.0f); } } - else if(MsgId == NETMSGTYPE_SV_TEAMSSTATE) + else if(MsgId == NETMSGTYPE_SV_TEAMSSTATE || MsgId == NETMSGTYPE_SV_TEAMSSTATELEGACY) { unsigned int i; diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 710840679..3e66e1bbc 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -1183,8 +1183,6 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID) pCharacter->m_Health = Health; pCharacter->m_Armor = Armor; pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags; - if(m_pPlayer->m_Aim) - pCharacter->m_PlayerFlags |= PLAYERFLAG_AIM; } else { diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 76a1a1d53..abfdf2d63 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -2139,20 +2139,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) Server()->SetClientDDNetVersion(ClientID, DDNetVersion); OnClientDDNetVersionKnown(ClientID); } - else if(MsgID == NETMSGTYPE_CL_ISDDRACE) - { - int Version = pUnpacker->GetInt(); - if(pUnpacker->Error()) - Version = -1; - - dbg_msg("ddrace", "%d using custom 0.7 client. ddrace version: %d", ClientID, Version); - ((CGameControllerDDRace *)m_pController)->m_Teams.SendTeamsState(ClientID); - } - else if(MsgID == NETMSGTYPE_CL_EXPLAYERFLAGS) - { - CNetMsg_Cl_ExPlayerFlags *pMsg = (CNetMsg_Cl_ExPlayerFlags *)pRawMsg; - pPlayer->m_Aim = pMsg->m_Flags & EXPLAYERFLAG_AIM; - } else if(MsgID == NETMSGTYPE_CL_SHOWOTHERSLEGACY) { if(g_Config.m_SvShowOthers && !g_Config.m_SvShowOthersDefault) diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 5d5401d8b..e2ec46821 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -139,8 +139,6 @@ void CPlayer::Reset() m_NotEligibleForFinish = false; m_EligibleForFinishCheck = 0; m_VotedForPractice = false; - - m_Aim = 0; } static int PlayerFlags_SevenToSix(int Flags) @@ -150,6 +148,8 @@ static int PlayerFlags_SevenToSix(int Flags) Six |= PLAYERFLAG_CHATTING; if(Flags & protocol7::PLAYERFLAG_SCOREBOARD) Six |= PLAYERFLAG_SCOREBOARD; + if(Flags & protocol7::PLAYERFLAG_AIM) + Six |= PLAYERFLAG_AIM; return Six; } @@ -325,7 +325,7 @@ void CPlayer::Snap(int SnappingClient) pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; - int ClientVersion = GetClientVersion(); + int SnappingClientVersion = SnappingClient >= 0 ? GameServer()->GetClientVersion(SnappingClient) : CLIENT_VERSIONNR; int Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID]; int Score = abs(m_Score) * -1; @@ -341,11 +341,11 @@ void CPlayer::Snap(int SnappingClient) pPlayerInfo->m_Latency = Latency; pPlayerInfo->m_Score = Score; - pPlayerInfo->m_Local = (int)(m_ClientID == SnappingClient && (m_Paused != PAUSE_PAUSED || ClientVersion >= VERSION_DDNET_OLD)); + pPlayerInfo->m_Local = (int)(m_ClientID == SnappingClient && (m_Paused != PAUSE_PAUSED || SnappingClient >= VERSION_DDNET_OLD)); pPlayerInfo->m_ClientID = id; - pPlayerInfo->m_Team = (ClientVersion < VERSION_DDNET_OLD || m_Paused != PAUSE_PAUSED || m_ClientID != SnappingClient) && m_Paused < PAUSE_SPEC ? m_Team : TEAM_SPECTATORS; + pPlayerInfo->m_Team = (SnappingClientVersion < VERSION_DDNET_OLD || m_Paused != PAUSE_PAUSED || m_ClientID != SnappingClient) && m_Paused < PAUSE_SPEC ? m_Team : TEAM_SPECTATORS; - if(m_ClientID == SnappingClient && m_Paused == PAUSE_PAUSED && ClientVersion < VERSION_DDNET_OLD) + if(m_ClientID == SnappingClient && m_Paused == PAUSE_PAUSED && SnappingClientVersion < VERSION_DDNET_OLD) pPlayerInfo->m_Team = TEAM_SPECTATORS; } else @@ -355,6 +355,8 @@ void CPlayer::Snap(int SnappingClient) return; pPlayerInfo->m_PlayerFlags = PlayerFlags_SixToSeven(m_PlayerFlags); + if(SnappingClientVersion >= VERSION_DDRACE && (m_PlayerFlags & PLAYERFLAG_AIM)) + pPlayerInfo->m_PlayerFlags |= protocol7::PLAYERFLAG_AIM; if(Server()->ClientAuthed(m_ClientID)) pPlayerInfo->m_PlayerFlags |= protocol7::PLAYERFLAG_ADMIN; @@ -400,8 +402,6 @@ void CPlayer::Snap(int SnappingClient) pDDNetPlayer->m_Flags |= EXPLAYERFLAG_SPEC; if(m_Paused == PAUSE_PAUSED) pDDNetPlayer->m_Flags |= EXPLAYERFLAG_PAUSED; - if(m_Aim) - pDDNetPlayer->m_Flags |= EXPLAYERFLAG_AIM; if(SnappingClient >= 0 && Server()->IsSixup(SnappingClient) && m_pCharacter && m_pCharacter->m_DDRaceState == DDRACE_STARTED && GameServer()->m_apPlayers[SnappingClient]->m_TimerType == TIMERTYPE_SIXUP) @@ -526,8 +526,6 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) { if(Server()->IsSixup(m_ClientID)) NewInput->m_PlayerFlags = PlayerFlags_SevenToSix(NewInput->m_PlayerFlags); - else - m_Aim = NewInput->m_PlayerFlags & PLAYERFLAG_AIM; if(NewInput->m_PlayerFlags) Server()->SetClientFlags(m_ClientID, NewInput->m_PlayerFlags); diff --git a/src/game/server/player.h b/src/game/server/player.h index 54e5dc2d1..afc26d68f 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -171,7 +171,6 @@ public: bool m_ShowAll; vec2 m_ShowDistance; bool m_SpecTeam; - bool m_Aim; bool m_NinjaJetpack; bool m_Afk; bool m_HasFinishScore; diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 600ea8302..8d7dfb454 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -426,15 +426,24 @@ void CGameTeams::SendTeamsState(int ClientID) if(g_Config.m_SvTeam == 3) return; - if(!m_pGameContext->m_apPlayers[ClientID] || (!Server()->IsSixup(ClientID) && m_pGameContext->m_apPlayers[ClientID]->GetClientVersion() <= VERSION_DDRACE)) + if(!m_pGameContext->m_apPlayers[ClientID]) return; CMsgPacker Msg(NETMSGTYPE_SV_TEAMSSTATE); + CMsgPacker MsgLegacy(NETMSGTYPE_SV_TEAMSSTATELEGACY); for(unsigned i = 0; i < MAX_CLIENTS; i++) + { Msg.AddInt(m_Core.Team(i)); + MsgLegacy.AddInt(m_Core.Team(i)); + } Server()->SendMsg(&Msg, MSGFLAG_VITAL, ClientID); + int ClientVersion = m_pGameContext->m_apPlayers[ClientID]->GetClientVersion(); + if(!Server()->IsSixup(ClientID) && VERSION_DDRACE < ClientVersion && ClientVersion <= VERSION_DDNET_TEAMSSTATE_LEGACY) + { + Server()->SendMsg(&MsgLegacy, MSGFLAG_VITAL, ClientID); + } } int CGameTeams::GetDDRaceState(CPlayer *Player)