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`.
This commit is contained in:
heinrich5991 2021-01-10 17:23:00 +01:00
parent 9940a806fa
commit 0d916e2ef6
13 changed files with 33 additions and 44 deletions

View file

@ -23,7 +23,7 @@ GameInfoFlags = [
GameInfoFlags2 = [ GameInfoFlags2 = [
"ALLOW_X_SKINS", "GAMETYPE_CITY", "GAMETYPE_FDDRACE", "ENTITIES_FDDRACE", "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"] 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("Unused", []),
NetMessage("Sv_TeamsState", []), NetMessage("Sv_TeamsStateLegacy", []),
# deprecated, use showothers@netmsg.ddnet.tw instead # deprecated, use showothers@netmsg.ddnet.tw instead
NetMessage("Cl_ShowOthersLegacy", [ NetMessage("Cl_ShowOthersLegacy", [
@ -442,11 +442,5 @@ Messages = [
NetIntRange("m_Show", 0, 2), NetIntRange("m_Show", 0, 2),
]), ]),
NetMessageEx("Sv_TeamsStateEx", "teamsstate@netmsg.ddnet.tw", []), NetMessageEx("Sv_TeamsState", "teamsstate@netmsg.ddnet.tw", []),
NetMessageEx("Cl_ExPlayerFlags", "explayerflags@netmsg.7.ddnet.tw", [
NetIntAny("m_Flags"),
]),
NetMessageEx("Cl_IsDDrace", "isddrace@netmsg.7.ddnet.tw", []),
] ]

View file

@ -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 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"]) 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"]) GameFlags = Flags("GAMEFLAG", ["TEAMS", "FLAGS", "SURVIVAL", "RACE"])
GameStateFlags = Flags("GAMESTATEFLAG", ["WARMUP", "SUDDENDEATH", "ROUNDOVER", "GAMEOVER", "PAUSED", "STARTCOUNTDOWN"]) 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"]) CoreEventFlags = Flags("COREEVENTFLAG", ["GROUND_JUMP", "AIR_JUMP", "HOOK_ATTACH_PLAYER", "HOOK_ATTACH_GROUND", "HOOK_HIT_NOHOOK"])

View file

@ -1602,10 +1602,15 @@ static CServerCapabilities GetServerCapabilities(int Version, int Flags)
DDNet = Flags & SERVERCAPFLAG_DDNET; DDNet = Flags & SERVERCAPFLAG_DDNET;
} }
Result.m_ChatTimeoutCode = DDNet; Result.m_ChatTimeoutCode = DDNet;
Result.m_AnyPlayerFlag = DDNet;
if(Version >= 1) if(Version >= 1)
{ {
Result.m_ChatTimeoutCode = Flags & SERVERCAPFLAG_CHATTIMEOUTCODE; Result.m_ChatTimeoutCode = Flags & SERVERCAPFLAG_CHATTIMEOUTCODE;
} }
if(Version >= 2)
{
Result.m_AnyPlayerFlag = Flags & SERVERCAPFLAG_ANYPLAYERFLAG;
}
return Result; return Result;
} }

View file

@ -78,6 +78,7 @@ class CServerCapabilities
{ {
public: public:
bool m_ChatTimeoutCode; bool m_ChatTimeoutCode;
bool m_AnyPlayerFlag;
}; };
class CClient : public IClient, public CDemoPlayer::IListener class CClient : public IClient, public CDemoPlayer::IListener

View file

@ -724,9 +724,6 @@ static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer, bool Sixup
} }
else else
{ {
if(MsgId == NETMSGTYPE_SV_TEAMSSTATE)
MsgId = NETMSGTYPE_SV_TEAMSSTATEEX;
if(MsgId >= 0 && MsgId < OFFSET_UUID) if(MsgId >= 0 && MsgId < OFFSET_UUID)
MsgId = Msg_SixToSeven(MsgId); MsgId = Msg_SixToSeven(MsgId);
@ -1151,7 +1148,7 @@ void CServer::SendCapabilities(int ClientID)
{ {
CMsgPacker Msg(NETMSG_CAPABILITIES, true); CMsgPacker Msg(NETMSG_CAPABILITIES, true);
Msg.AddInt(SERVERCAP_CURVERSION); // version 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); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }

View file

@ -114,6 +114,7 @@ enum
VERSION_DDNET_FIREDELAY_TUNE = 701, VERSION_DDNET_FIREDELAY_TUNE = 701,
VERSION_DDNET_UPDATER_FIXED = 707, VERSION_DDNET_UPDATER_FIXED = 707,
VERSION_DDNET_GAMETICK = 10042, VERSION_DDNET_GAMETICK = 10042,
VERSION_DDNET_TEAMSSTATE_LEGACY = 15025,
}; };
#endif #endif

View file

@ -20,9 +20,10 @@ enum
UNPACKMESSAGE_OK, UNPACKMESSAGE_OK,
UNPACKMESSAGE_ANSWER, UNPACKMESSAGE_ANSWER,
SERVERCAP_CURVERSION = 1, SERVERCAP_CURVERSION = 2,
SERVERCAPFLAG_DDNET = 1 << 0, SERVERCAPFLAG_DDNET = 1 << 0,
SERVERCAPFLAG_CHATTIMEOUTCODE = 1 << 1, SERVERCAPFLAG_CHATTIMEOUTCODE = 1 << 1,
SERVERCAPFLAG_ANYPLAYERFLAG = 1 << 2,
}; };
void RegisterUuids(class CUuidManager *pManager); void RegisterUuids(class CUuidManager *pManager);

View file

@ -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); 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; unsigned int i;

View file

@ -1183,8 +1183,6 @@ void CCharacter::SnapCharacter(int SnappingClient, int ID)
pCharacter->m_Health = Health; pCharacter->m_Health = Health;
pCharacter->m_Armor = Armor; pCharacter->m_Armor = Armor;
pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags; pCharacter->m_PlayerFlags = GetPlayer()->m_PlayerFlags;
if(m_pPlayer->m_Aim)
pCharacter->m_PlayerFlags |= PLAYERFLAG_AIM;
} }
else else
{ {

View file

@ -2139,20 +2139,6 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
Server()->SetClientDDNetVersion(ClientID, DDNetVersion); Server()->SetClientDDNetVersion(ClientID, DDNetVersion);
OnClientDDNetVersionKnown(ClientID); 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) else if(MsgID == NETMSGTYPE_CL_SHOWOTHERSLEGACY)
{ {
if(g_Config.m_SvShowOthers && !g_Config.m_SvShowOthersDefault) if(g_Config.m_SvShowOthers && !g_Config.m_SvShowOthersDefault)

View file

@ -139,8 +139,6 @@ void CPlayer::Reset()
m_NotEligibleForFinish = false; m_NotEligibleForFinish = false;
m_EligibleForFinishCheck = 0; m_EligibleForFinishCheck = 0;
m_VotedForPractice = false; m_VotedForPractice = false;
m_Aim = 0;
} }
static int PlayerFlags_SevenToSix(int Flags) static int PlayerFlags_SevenToSix(int Flags)
@ -150,6 +148,8 @@ static int PlayerFlags_SevenToSix(int Flags)
Six |= PLAYERFLAG_CHATTING; Six |= PLAYERFLAG_CHATTING;
if(Flags & protocol7::PLAYERFLAG_SCOREBOARD) if(Flags & protocol7::PLAYERFLAG_SCOREBOARD)
Six |= PLAYERFLAG_SCOREBOARD; Six |= PLAYERFLAG_SCOREBOARD;
if(Flags & protocol7::PLAYERFLAG_AIM)
Six |= PLAYERFLAG_AIM;
return Six; return Six;
} }
@ -325,7 +325,7 @@ void CPlayer::Snap(int SnappingClient)
pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody; pClientInfo->m_ColorBody = m_TeeInfos.m_ColorBody;
pClientInfo->m_ColorFeet = m_TeeInfos.m_ColorFeet; 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 Latency = SnappingClient == -1 ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aActLatency[m_ClientID];
int Score = abs(m_Score) * -1; int Score = abs(m_Score) * -1;
@ -341,11 +341,11 @@ void CPlayer::Snap(int SnappingClient)
pPlayerInfo->m_Latency = Latency; pPlayerInfo->m_Latency = Latency;
pPlayerInfo->m_Score = Score; 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_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; pPlayerInfo->m_Team = TEAM_SPECTATORS;
} }
else else
@ -355,6 +355,8 @@ void CPlayer::Snap(int SnappingClient)
return; return;
pPlayerInfo->m_PlayerFlags = PlayerFlags_SixToSeven(m_PlayerFlags); 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)) if(Server()->ClientAuthed(m_ClientID))
pPlayerInfo->m_PlayerFlags |= protocol7::PLAYERFLAG_ADMIN; pPlayerInfo->m_PlayerFlags |= protocol7::PLAYERFLAG_ADMIN;
@ -400,8 +402,6 @@ void CPlayer::Snap(int SnappingClient)
pDDNetPlayer->m_Flags |= EXPLAYERFLAG_SPEC; pDDNetPlayer->m_Flags |= EXPLAYERFLAG_SPEC;
if(m_Paused == PAUSE_PAUSED) if(m_Paused == PAUSE_PAUSED)
pDDNetPlayer->m_Flags |= EXPLAYERFLAG_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 && if(SnappingClient >= 0 && Server()->IsSixup(SnappingClient) && m_pCharacter && m_pCharacter->m_DDRaceState == DDRACE_STARTED &&
GameServer()->m_apPlayers[SnappingClient]->m_TimerType == TIMERTYPE_SIXUP) GameServer()->m_apPlayers[SnappingClient]->m_TimerType == TIMERTYPE_SIXUP)
@ -526,8 +526,6 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
{ {
if(Server()->IsSixup(m_ClientID)) if(Server()->IsSixup(m_ClientID))
NewInput->m_PlayerFlags = PlayerFlags_SevenToSix(NewInput->m_PlayerFlags); NewInput->m_PlayerFlags = PlayerFlags_SevenToSix(NewInput->m_PlayerFlags);
else
m_Aim = NewInput->m_PlayerFlags & PLAYERFLAG_AIM;
if(NewInput->m_PlayerFlags) if(NewInput->m_PlayerFlags)
Server()->SetClientFlags(m_ClientID, NewInput->m_PlayerFlags); Server()->SetClientFlags(m_ClientID, NewInput->m_PlayerFlags);

View file

@ -171,7 +171,6 @@ public:
bool m_ShowAll; bool m_ShowAll;
vec2 m_ShowDistance; vec2 m_ShowDistance;
bool m_SpecTeam; bool m_SpecTeam;
bool m_Aim;
bool m_NinjaJetpack; bool m_NinjaJetpack;
bool m_Afk; bool m_Afk;
bool m_HasFinishScore; bool m_HasFinishScore;

View file

@ -426,15 +426,24 @@ void CGameTeams::SendTeamsState(int ClientID)
if(g_Config.m_SvTeam == 3) if(g_Config.m_SvTeam == 3)
return; 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; return;
CMsgPacker Msg(NETMSGTYPE_SV_TEAMSSTATE); CMsgPacker Msg(NETMSGTYPE_SV_TEAMSSTATE);
CMsgPacker MsgLegacy(NETMSGTYPE_SV_TEAMSSTATELEGACY);
for(unsigned i = 0; i < MAX_CLIENTS; i++) for(unsigned i = 0; i < MAX_CLIENTS; i++)
{
Msg.AddInt(m_Core.Team(i)); Msg.AddInt(m_Core.Team(i));
MsgLegacy.AddInt(m_Core.Team(i));
}
Server()->SendMsg(&Msg, MSGFLAG_VITAL, ClientID); 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) int CGameTeams::GetDDRaceState(CPlayer *Player)