Skip to content

Commit 797d905

Browse files
committed
Put some spammy log messages behind a cvar
1 parent 62aee6b commit 797d905

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/multiaddonmanager.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ CConVar<bool> mm_cache_clients_with_addons("mm_cache_clients_with_addons", FCVAR
4545
CConVar<float> mm_cache_clients_duration("mm_cache_clients_duration", FCVAR_NONE, "How long to cache clients' downloaded addons list in seconds, pass 0 for forever.", 0.0f);
4646
CConVar<float> mm_extra_addons_timeout("mm_extra_addons_timeout", FCVAR_NONE, "How long until clients are timed out in between connects for extra addons in seconds, requires mm_extra_addons to be used", 10.f);
4747

48+
CConVar<bool> mm_addon_debug("mm_addon_debug", FCVAR_NONE, "Whether to print some extra debug information", false);
49+
4850
void Message(const char *msg, ...)
4951
{
5052
va_list args;
@@ -566,7 +568,6 @@ void MultiAddonManager::Hook_GameServerSteamAPIActivated()
566568
g_SteamAPI.Init();
567569
m_CallbackDownloadItemResult.Register(this, &MultiAddonManager::OnAddonDownloaded);
568570

569-
Message("Refreshing addons to check for updates\n");
570571
RefreshAddons(true);
571572

572573
RETURN_META(MRES_IGNORED);
@@ -875,8 +876,6 @@ CON_COMMAND_F(mm_print_searchpaths_client, "Print search paths client-side, only
875876

876877
void MultiAddonManager::Hook_StartupServer(const GameSessionConfiguration_t &config, ISource2WorldSession *session, const char *mapname)
877878
{
878-
Message("Hook_StartupServer: %s\n", mapname);
879-
880879
gpGlobals = g_pEngineServer->GetServerGlobals();
881880
g_pNetworkGameServer = g_pNetworkServerService->GetIGameServer();
882881

@@ -941,8 +940,10 @@ bool FASTCALL Hook_SendNetMessage(CServerSideClient *pClient, CNetMessage *pData
941940
return g_pfnSendNetMessage(pClient, pData, bufType);
942941
}
943942

943+
if (mm_addon_debug.Get())
944+
Message("%s: Number of addons remaining to download for %lli: %d\n", __func__, steamID64, addons.Count());
945+
944946
// Otherwise, send the next addon to the client.
945-
Message("%s: Number of addons remaining to download for %lli: %d\n", __func__, steamID64, addons.Count());
946947
clientInfo.currentPendingAddon = addons.Head();
947948
pMsg->set_addons(addons.Head().c_str());
948949
pMsg->set_signon_state(SIGNONSTATE_CHANGELEVEL);
@@ -1016,11 +1017,14 @@ bool MultiAddonManager::Hook_ClientConnect( CPlayerSlot slot, const char *pszNam
10161017
{
10171018
if (Plat_FloatTime() - clientInfo.lastActiveTime > mm_extra_addons_timeout.Get())
10181019
{
1019-
Message("%s: Client %lli has reconnected after the timeout or did not receive the addon message, will not add addon %s to the downloaded list\n", __func__, steamID64, clientInfo.currentPendingAddon.c_str());
1020+
if (mm_addon_debug.Get())
1021+
Message("%s: Client %lli has reconnected after the timeout or did not receive the addon message, will not add addon %s to the downloaded list\n", __func__, steamID64, clientInfo.currentPendingAddon.c_str());
10201022
}
10211023
else
10221024
{
1023-
Message("%s: Client %lli has connected within the interval with the pending addon %s, will send next addon in SendNetMessage hook\n", __func__, steamID64, clientInfo.currentPendingAddon.c_str());
1025+
if (mm_addon_debug.Get())
1026+
Message("%s: Client %lli has connected within the interval with the pending addon %s, will send next addon in SendNetMessage hook\n", __func__, steamID64, clientInfo.currentPendingAddon.c_str());
1027+
10241028
clientInfo.downloadedAddons.AddToTail(clientInfo.currentPendingAddon);
10251029
}
10261030
// Reset the current pending addon anyway, SendNetMessage tells us which addon to download next.
@@ -1040,9 +1044,7 @@ void MultiAddonManager::Hook_ClientActive(CPlayerSlot slot, bool bLoadGame, cons
10401044
{
10411045
// When the client reaches this stage, they should already have all the necessary addons downloaded, so we can safely remove the downloaded addons list here.
10421046
if (!mm_cache_clients_with_addons.Get())
1043-
{
10441047
g_ClientAddons[steamID64].downloadedAddons.RemoveAll();
1045-
}
10461048
}
10471049

10481050
void MultiAddonManager::Hook_GameFrame(bool simulating, bool bFirstTick, bool bLastTick)
@@ -1097,7 +1099,9 @@ void FASTCALL Hook_ReplyConnection(INetworkGameServer *server, CServerSideClient
10971099
ClientAddonInfo_t &clientInfo = g_ClientAddons[steamID64];
10981100
if (mm_cache_clients_with_addons.Get() && mm_cache_clients_duration.Get() != 0 && Plat_FloatTime() - clientInfo.lastActiveTime > mm_cache_clients_duration.Get())
10991101
{
1100-
Message("%s: Client %lli has not connected for a while, clearing the cache\n", __func__, steamID64);
1102+
if (mm_addon_debug.Get())
1103+
Message("%s: Client %lli has not connected for a while, clearing the cache\n", __func__, steamID64);
1104+
11011105
clientInfo.currentPendingAddon.clear();
11021106
clientInfo.downloadedAddons.RemoveAll();
11031107
}
@@ -1124,7 +1128,9 @@ void FASTCALL Hook_ReplyConnection(INetworkGameServer *server, CServerSideClient
11241128

11251129
*addons = VectorToString(clientAddons).c_str();
11261130

1127-
Message("%s: Sending addons %s to steamID64 %lli\n", __func__, addons->Get(), steamID64);
1131+
if (mm_addon_debug.Get())
1132+
Message("%s: Sending addons %s to steamID64 %lli\n", __func__, addons->Get(), steamID64);
1133+
11281134
g_pfnReplyConnection(server, client);
11291135

11301136
*addons = originalAddons;

0 commit comments

Comments
 (0)