From 93d0f43a6a9b8f66dd50f24035e3ea0c9d520662 Mon Sep 17 00:00:00 2001 From: def Date: Tue, 25 Nov 2014 20:33:21 +0100 Subject: [PATCH] Broadcast about DDNet client delayed a bit (fixes #72) --- src/engine/shared/config_variables.h | 6 ++---- src/game/server/player.cpp | 27 ++++++++++++++------------- src/game/server/player.h | 1 + 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index 9495740ea..d146f9d9e 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -317,10 +317,8 @@ MACRO_CONFIG_INT(SvRankCheats, sv_rank_cheats, 0, 0, 1, CFGFLAG_SERVER, "Enable MACRO_CONFIG_INT(SvSpoofProtection, sv_spoof_protection, 0, 0, 1, CFGFLAG_SERVER, "Enable spoof protection") MACRO_CONFIG_INT(SvShutdownWhenEmpty, sv_shutdown_when_empty, 0, 0, 1, CFGFLAG_SERVER, "Shutdown server as soon as noone is on it anymore") MACRO_CONFIG_INT(SvKillProtection, sv_kill_protection, 20, 0, 9999, CFGFLAG_SERVER, "0 - Disable, 1-9999 minutes") -MACRO_CONFIG_INT(SvClientSuggestion, sv_client_suggestion, 1, 0, 1, CFGFLAG_SERVER, "Enable suggestion to use DDNet client when joining a server") - -MACRO_CONFIG_STR(SvClientSuggestionOther, sv_client_suggestion_other, 128, "Get the client from ddnet.tw to use all features on DDNet.", CFGFLAG_SERVER, "Broadcast to display to players without DDNet client") -MACRO_CONFIG_STR(SvClientSuggestionOld, sv_client_suggestion_old, 128, "Your client version is old. Update it on ddnet.tw for new features!", CFGFLAG_SERVER, "Broadcast to display to players with an old version of DDNet client") +MACRO_CONFIG_STR(SvClientSuggestion, sv_client_suggestion, 128, "Get the client from ddnet.tw to use all features on DDNet", CFGFLAG_SERVER, "Broadcast to display to players without DDNet client") +//MACRO_CONFIG_STR(SvClientSuggestionOld, sv_client_suggestion_old, 128, "Your client version is old. Update it on ddnet.tw for new features!", CFGFLAG_SERVER, "Broadcast to display to players with an old version of DDNet client") // netlimit MACRO_CONFIG_INT(SvNetlimit, sv_netlimit, 0, 0, 10000, CFGFLAG_SERVER, "Netlimit: Maximum amount of traffic a client is allowed to use (in kb/s)") diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index 4cac05550..4e1218e5c 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -25,6 +25,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team) m_ClientID = ClientID; m_Team = GameServer()->m_pController->ClampTeam(Team); m_pCharacter = 0; + m_NumInputs = 0; Reset(); } @@ -359,20 +360,20 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *NewInput) AfkVoteTimer(NewInput); - if(m_FirstPacket) - { - if(g_Config.m_SvClientSuggestion) - { - if(m_ClientVersion <= VERSION_DDNET_OLD) - GameServer()->SendBroadcast(g_Config.m_SvClientSuggestionOther, m_ClientID); - //if(m_ClientVersion < CLIENT_VERSIONNR) - // GameServer()->SendBroadcast(g_Config.m_SvClientSuggestionOld, m_ClientID); - m_FirstPacket = false; - } - } + m_NumInputs++; if(m_pCharacter && !m_Paused) m_pCharacter->OnPredictedInput(NewInput); + + // Magic number when we can hope that client has successfully identified itself + if(m_NumInputs == 10) + { + if(g_Config.m_SvClientSuggestion[0] != '\0' && m_ClientVersion <= VERSION_DDNET_OLD) + GameServer()->SendBroadcast(g_Config.m_SvClientSuggestion, m_ClientID); + + //if(g_Config.m_SvClientSuggestionOld[0] != '\0' && m_ClientVersion < CLIENT_VERSIONNR) + // GameServer()->SendBroadcast(g_Config.m_SvClientSuggestionOld, m_ClientID); + } } void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) @@ -391,8 +392,8 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) if(m_pCharacter) m_pCharacter->ResetInput(); - m_PlayerFlags = NewInput->m_PlayerFlags; - return; + m_PlayerFlags = NewInput->m_PlayerFlags; + return; } m_PlayerFlags = NewInput->m_PlayerFlags; diff --git a/src/game/server/player.h b/src/game/server/player.h index 5366ebc00..26a0b1ecc 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -112,6 +112,7 @@ public: private: CCharacter *m_pCharacter; + int m_NumInputs; CGameContext *m_pGameServer; CGameContext *GameServer() const { return m_pGameServer; }