Skip to content

Commit 64be017

Browse files
committed
Tweak log messages
1 parent 4e399fb commit 64be017

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

src/multiaddonmanager.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void Message(const char *msg, ...)
4141
char buf[1024] = {};
4242
V_vsnprintf(buf, sizeof(buf) - 1, msg, args);
4343

44-
ConColorMsg(Color(0, 255, 200), "[MultiAddonManager] %s", buf);
44+
LoggingSystem_Log(20, LS_MESSAGE, Color(0, 255, 200), "[MultiAddonManager] %s", buf);
4545

4646
va_end(args);
4747
}
@@ -54,7 +54,7 @@ void Panic(const char *msg, ...)
5454
char buf[1024] = {};
5555
V_vsnprintf(buf, sizeof(buf) - 1, msg, args);
5656

57-
Warning("[MultiAddonManager] %s", buf);
57+
LoggingSystem_Log(20, LS_WARNING, Color(255, 255, 0), "[MultiAddonManager] %s", buf);
5858

5959
va_end(args);
6060
}
@@ -124,7 +124,7 @@ bool MultiAddonManager::Load(PluginId id, ISmmAPI *ismm, char *error, size_t max
124124
}
125125
else if (sig_error == SIG_FOUND_MULTIPLE)
126126
{
127-
Warning("Signature for SendNetMessage occurs multiple times! Using first match but this might end up crashing!\n");
127+
Panic("Signature for SendNetMessage occurs multiple times! Using first match but this might end up crashing!\n");
128128
}
129129

130130
g_pfnHostStateRequest = (HostStateRequest_t)pEngineModule->FindSignature(HostStateRequest_Sig, sizeof(HostStateRequest_Sig) - 1, sig_error);
@@ -190,7 +190,7 @@ bool MultiAddonManager::Unload(char *error, size_t maxlen)
190190

191191
CUtlVector<std::string> g_vecMountedAddons;
192192

193-
void BuildAddonPath(const char *pszAddon, char *buf, size_t len)
193+
void MultiAddonManager::BuildAddonPath(const char *pszAddon, char *buf, size_t len)
194194
{
195195
// The workshop is stored relative to the working directory for whatever reason
196196
static CBufferStringGrowable<MAX_PATH> s_sWorkingDir;
@@ -199,7 +199,7 @@ void BuildAddonPath(const char *pszAddon, char *buf, size_t len)
199199
V_snprintf(buf, len, "%ssteamapps/workshop/content/730/%s/%s.vpk", s_sWorkingDir.Get(), pszAddon, pszAddon);
200200
}
201201

202-
bool MountAddon(const char *pszAddon, bool bAddToTail = false)
202+
bool MultiAddonManager::MountAddon(const char *pszAddon, bool bAddToTail = false)
203203
{
204204
if (!pszAddon || !*pszAddon)
205205
return false;
@@ -209,13 +209,13 @@ bool MountAddon(const char *pszAddon, bool bAddToTail = false)
209209

210210
if (!g_pFullFileSystem->FileExists(path))
211211
{
212-
Panic("Addon %s not found at %s\n", pszAddon, path);
212+
Panic(__FUNCTION__": Addon %s not found at %s\n", pszAddon, path);
213213
return false;
214214
}
215215

216216
if (g_vecMountedAddons.Find(pszAddon) != -1)
217217
{
218-
Panic("Addon %s is already mounted\n", pszAddon);
218+
Panic(__FUNCTION__": Addon %s is already mounted\n", pszAddon);
219219
return false;
220220
}
221221

@@ -227,7 +227,7 @@ bool MountAddon(const char *pszAddon, bool bAddToTail = false)
227227
return true;
228228
}
229229

230-
bool UnmountAddon(const char *pszAddon)
230+
bool MultiAddonManager::UnmountAddon(const char *pszAddon)
231231
{
232232
if (!pszAddon || !*pszAddon)
233233
return false;
@@ -245,19 +245,19 @@ bool UnmountAddon(const char *pszAddon)
245245
return true;
246246
}
247247

248-
void DownloadAddon(const char *pszAddon, bool bForce = false)
248+
void MultiAddonManager::DownloadAddon(const char *pszAddon, bool bForce = false)
249249
{
250250
if (!g_SteamAPI.SteamUGC())
251251
{
252-
Panic("Cannot download addons as the Steam API is not initialized\n");
252+
Panic(__FUNCTION__": Cannot download addons as the Steam API is not initialized\n");
253253
return;
254254
}
255255

256256
PublishedFileId_t addon = V_StringToUint64(pszAddon, 0);
257257

258258
if (addon == 0)
259259
{
260-
Panic("Invalid addon %s\n", pszAddon);
260+
Panic(__FUNCTION__": Invalid addon %s\n", pszAddon);
261261
return;
262262
}
263263

@@ -271,16 +271,16 @@ void DownloadAddon(const char *pszAddon, bool bForce = false)
271271

272272
if (!g_SteamAPI.SteamUGC()->DownloadItem(addon, true))
273273
{
274-
Panic("Addon download for %lli failed to start, addon ID is invalid or server is not logged on Steam\n", addon);
274+
Panic(__FUNCTION__": Addon download for %lli failed to start, addon ID is invalid or server is not logged on Steam\n", addon);
275275
return;
276276
}
277277

278278
Message("Addon download started for %lli\n", addon);
279279
}
280280

281-
void RefreshAddons()
281+
void MultiAddonManager::RefreshAddons()
282282
{
283-
Message("Refreshing addons\n");
283+
Message("Refreshing addons (%s)\n", g_sExtraAddons);
284284

285285
// Remove our paths first in case addons were switched
286286
FOR_EACH_VEC_BACK(g_vecMountedAddons, i)
@@ -311,7 +311,7 @@ void MultiAddonManager::OnAddonDownloaded(DownloadItemResult_t *pResult)
311311
{
312312
if (pResult->m_eResult != k_EResultOK)
313313
{
314-
Panic("Addon %lli download failed with status %i\n", pResult->m_nPublishedFileId, pResult->m_eResult);
314+
Panic(__FUNCTION__": Addon %lli download failed with status %i\n", pResult->m_nPublishedFileId, pResult->m_eResult);
315315
return;
316316
}
317317

@@ -340,7 +340,7 @@ CON_COMMAND_F(mm_extra_addons, "The workshop IDs of extra addons separated by co
340340
g_vecExtraAddons.PurgeAndDeleteElements();
341341
V_SplitString(g_sExtraAddons.c_str(), ",", g_vecExtraAddons);
342342

343-
RefreshAddons();
343+
g_MultiAddonManager.RefreshAddons();
344344
}
345345

346346
CON_COMMAND_F(mm_download_addon, "Download and mount an addon manually (server only)", FCVAR_GAMEDLL | FCVAR_RELEASE | FCVAR_SPONLY)
@@ -450,7 +450,7 @@ ClientJoinInfo_t *GetPendingClient(INetChannel *pNetChan)
450450

451451
void MultiAddonManager::Hook_StartupServer(const GameSessionConfiguration_t &config, ISource2WorldSession *, const char *)
452452
{
453-
Message("Hook_StartupServer: %s\n", g_pEngineServer->GetServerGlobals()->mapname);
453+
Message(__FUNCTION__ ": %s\n", g_pEngineServer->GetServerGlobals()->mapname);
454454

455455
g_pNetworkGameServer = g_pNetworkServerService->GetIGameServer();
456456
g_ClientsPendingAddon.RemoveAll();
@@ -477,7 +477,7 @@ void FASTCALL Hook_SendNetMessage(INetChannel *pNetChan, INetworkSerializable *p
477477

478478
if (pPendingClient)
479479
{
480-
Message("Detour_SendNetMessage: Sending addon %s to client %lli\n", g_vecExtraAddons[pPendingClient->addon], pPendingClient->steamid);
480+
Message(__FUNCTION__": Sending addon %s to client %lli\n", g_vecExtraAddons[pPendingClient->addon], pPendingClient->steamid);
481481

482482
CNETMsg_SignonState *pMsg = (CNETMsg_SignonState *)pData;
483483
pMsg->set_addons(g_vecExtraAddons[pPendingClient->addon]);
@@ -497,7 +497,7 @@ void* FASTCALL Hook_HostStateRequest(void *a1, void **pRequest)
497497
// This offset hasn't changed in 6 years so it should be safe
498498
CUtlString *sAddonString = (CUtlString *)(pRequest + 11);
499499

500-
Message("Hook_HostStateRequest: appending \"%s\" to addon string \"%s\"\n", g_sExtraAddons.c_str(), sAddonString->Get());
500+
Message(__FUNCTION__": appending \"%s\" to addon string \"%s\"\n", g_sExtraAddons.c_str(), sAddonString->Get());
501501

502502
// addons are simply comma-delimited, can have any number of them
503503
if (!sAddonString->IsEmpty())
@@ -517,7 +517,7 @@ bool MultiAddonManager::Hook_ClientConnect( CPlayerSlot slot, const char *pszNam
517517
if (g_vecExtraAddons.Count() == 0)
518518
RETURN_META_VALUE(MRES_IGNORED, true);
519519

520-
Message("Client %s (%lli) ", pszName, xuid);
520+
Message("Client %s (%lli) connected:\n", pszName, xuid);
521521

522522
// Store the client's ID temporarily as they will get reconnected once an extra addon is sent
523523
// This gets checked for in SendNetMessage so we don't repeatedly send the changelevel signon state for the same addon
@@ -529,7 +529,7 @@ bool MultiAddonManager::Hook_ClientConnect( CPlayerSlot slot, const char *pszNam
529529
if (!pPendingClient)
530530
{
531531
// Client joined for the first time or after a timeout
532-
ConColorMsg(Color(0, 255, 200), "connected for the first time, sending addon %s\n", g_vecExtraAddons[0]);
532+
Message("first connection, sending addon %s\n", g_vecExtraAddons[0]);
533533
AddPendingClient(xuid);
534534
}
535535
else if ((Plat_FloatTime() - pPendingClient->signon_timestamp) < g_flRejoinTimeout)
@@ -540,17 +540,17 @@ bool MultiAddonManager::Hook_ClientConnect( CPlayerSlot slot, const char *pszNam
540540

541541
if (pPendingClient->addon < g_vecExtraAddons.Count())
542542
{
543-
ConColorMsg(Color(0, 255, 200), "has reconnected within the interval, sending next addon %s\n", g_vecExtraAddons[pPendingClient->addon]);
543+
Message("reconnected within the interval, sending next addon %s\n", g_vecExtraAddons[pPendingClient->addon]);
544544
}
545545
else
546546
{
547-
ConColorMsg(Color(0, 255, 200), "has reconnected within the interval and has all addons, allowing\n");
547+
Message("reconnected within the interval and has all addons, allowing\n");
548548
g_ClientsPendingAddon.FastRemove(index);
549549
}
550550
}
551551
else
552552
{
553-
ConColorMsg(Color(0, 255, 200), "has reconnected after the timeout or did not receive the addon message, will resend addon %s\n", g_vecExtraAddons[pPendingClient->addon]);
553+
Message("reconnected after the timeout or did not receive the addon message, will resend addon %s\n", g_vecExtraAddons[pPendingClient->addon]);
554554
}
555555

556556
RETURN_META_VALUE(MRES_IGNORED, true);

src/multiaddonmanager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ class MultiAddonManager : public ISmmPlugin, public IMetamodListener
7474
void Hook_GameServerSteamAPIActivated();
7575
void Hook_StartupServer(const GameSessionConfiguration_t &config, ISource2WorldSession *, const char *);
7676
bool Hook_ClientConnect( CPlayerSlot slot, const char *pszName, uint64 xuid, const char *pszNetworkID, bool unk1, CBufferString *pRejectReason );
77+
78+
void BuildAddonPath(const char *pszAddon, char *buf, size_t len);
79+
bool MountAddon(const char *pszAddon, bool bAddToTail);
80+
bool UnmountAddon(const char *pszAddon);
81+
void DownloadAddon(const char *pszAddon, bool bForce);
82+
void RefreshAddons();
7783
public:
7884
const char *GetAuthor();
7985
const char *GetName();

0 commit comments

Comments
 (0)