Skip to content

Commit 6c57cee

Browse files
committed
Refactor Debug::Log to call LogGame with formatted message
1 parent 46e5fed commit 6c57cee

File tree

11 files changed

+27
-18
lines changed

11 files changed

+27
-18
lines changed

src/CnCNetYR/Misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ DEFINE_JUMP(LJMP, 0x69A797, 0x69A937);
3232
void __fastcall IDTooLong(char* id)
3333
{
3434
if (strlen(id) > 24)
35-
Debug::Log("[Developer error] Tried to create a type with ID '%s' which is longer than the maximum length of 24.\n", id);
35+
Debug::LogGame("[Developer error] Tried to create a type with ID '%s' which is longer than the maximum length of 24.\n", id);
3636
}
3737

3838
DEFINE_NAKED_HOOK(0x41088D, AbstractTypeClass_CTOR_IDTooLong)

src/Misc/NoCD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ DEFINE_HOOK(0x6BD7CB, WinMain_NoCDPatches, 0x5)
9090
}
9191
else if (!GetCDClass::Instance.Count)
9292
{
93-
Debug::Log("[Spawner] No CD drives detected. Switching to NoCD mode.\n");
93+
Debug::Log("No CD drives detected. Switching to NoCD mode.\n");
9494
ApplyNoCDPatches();
9595
}
9696

src/Misc/SavedGamesInSubdir.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ namespace SavedGames
3030
{
3131
if (!std::filesystem::exists(Spawner::GetConfig()->SavedGameDir))
3232
{
33-
Debug::Log("\n[Spawner] Folder Saved Games does not exist, creating...\n");
33+
Debug::LogGame("\n");
34+
Debug::Log("Folder Saved Games does not exist, creating...\n");
3435
if (!std::filesystem::create_directories(Spawner::GetConfig()->SavedGameDir))
3536
{
36-
Debug::Log("\tCannot create folder Saved Games!\n");
37+
Debug::LogGame("\tCannot create folder Saved Games!\n");
3738
return false;
3839
}
39-
Debug::Log("\tDone.\n");
40+
Debug::LogGame("\tDone.\n");
4041
}
4142
return true;
4243
}

src/Spawner/ProtocolZero.Hook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ DEFINE_HOOK(0x647E6B, QueueAIMultiplayer__ProtocolZero_SetTiming, 0x5)
105105
GET(int, NewRetryDelta, EBP);
106106
GET(int, NewRetryTimeout, EAX);
107107

108-
Debug::Log("[Spawner] NewRetryDelta = %d, NewRetryTimeout = %d, FrameSendRate = %d, CurentLatencyLevel = %d\n"
108+
Debug::Log("NewRetryDelta = %d, NewRetryTimeout = %d, FrameSendRate = %d, CurentLatencyLevel = %d\n"
109109
, NewRetryDelta
110110
, NewRetryTimeout
111111
, (int)Game::Network::FrameSendRate

src/Spawner/ProtocolZero.LatencyLevel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void LatencyLevel::Apply(LatencyLevelEnum newLatencyLevel)
4040
if (newLatencyLevel <= CurentLatencyLevel)
4141
return;
4242

43-
Debug::Log("[Spawner] Player %ls, Loss mode (%d, %d) Frame = %d\n"
43+
Debug::Log("Player %ls, Loss mode (%d, %d) Frame = %d\n"
4444
, HouseClass::CurrentPlayer->UIName
4545
, newLatencyLevel
4646
, CurentLatencyLevel

src/Spawner/ProtocolZero.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void ProtocolZero::SendResponseTime2()
6262
if (event.AddEvent())
6363
{
6464
ProtocolZero::NextSendFrame = currentFrame + ProtocolZero::SendResponseTimeInterval;
65-
Debug::Log("[Spawner] Player %d sending response time of %d, LatencyMode = %d, Frame = %d\n"
65+
Debug::Log("Player %d sending response time of %d, LatencyMode = %d, Frame = %d\n"
6666
, event.HouseIndex
6767
, event.ResponseTime2.MaxAhead
6868
, event.ResponseTime2.LatencyLevel
@@ -82,7 +82,7 @@ void ProtocolZero::HandleResponseTime2(EventExt* event)
8282

8383
if (event->ResponseTime2.MaxAhead == 0)
8484
{
85-
Debug::Log("[Spawner] Returning because event->MaxAhead == 0\n");
85+
Debug::Log("Returning because event->MaxAhead == 0\n");
8686
return;
8787
}
8888

src/Spawner/Spawner.Hook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ DEFINE_HOOK(0x4FC551, HouseClass__MPlayerDefeated_NoEnemies, 0x5)
148148

149149
if ((pHouse->IsHumanPlayer || Spawner::GetConfig()->ContinueWithoutHumans) && pHouse->IsMutualAlly(MPlayerDefeated::pThis))
150150
{
151-
Debug::Log("[Spawner] MPlayer_Defeated() - Defeated player has a living ally");
151+
Debug::Log("MPlayer_Defeated() - Defeated player has a living ally");
152152
if (Spawner::GetConfig()->DefeatedBecomesObserver)
153153
MPlayerDefeated::pThis->MakeObserver();
154154

src/Spawner/Spawner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ bool Spawner::StartScenario(const char* pScenarioName)
176176
{
177177
if (pScenarioName[0] == 0 && !Config->LoadSaveGame)
178178
{
179-
Debug::Log("[Spawner] Failed Read Scenario [%s]\n", pScenarioName);
179+
Debug::Log("Failed Read Scenario [%s]\n", pScenarioName);
180180

181181
WWMessageBox::Instance.Process(
182182
StringTable::LoadString(GameStrings::TXT_UNABLE_READ_SCENARIO),
@@ -360,7 +360,7 @@ bool Spawner::LoadSavedGame(const char* saveGameName)
360360
{
361361
if (!saveGameName[0] || !LoadOptionsClass::LoadMission(saveGameName))
362362
{
363-
Debug::Log("[Spawner] Failed Load Game [%s]\n", saveGameName);
363+
Debug::Log("Failed Load Game [%s]\n", saveGameName);
364364

365365
WWMessageBox::Instance.Process(
366366
StringTable::LoadString(GameStrings::TXT_ERROR_LOADING_GAME),

src/Spawner/Statistics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ DEFINE_HOOK(0x647AE8, QueueAIMultiplayer_SendStatistics_1, 0x7)
221221

222222
DEFINE_HOOK(0x64823C, QueueAIMultiplayer_SendStatistics_2, 0x5)
223223
{
224-
Debug::Log(reinterpret_cast<char*>(0x8373BC) /* "Failure executing DoList\n" */);
224+
Debug::LogGame(reinterpret_cast<char*>(0x8373BC) /* "Failure executing DoList\n" */);
225225

226226
enum { Send = 0x648257, DontSend = 0x64825C };
227227

src/Utilities/Debug.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,17 @@
2525
#include <MessageListClass.h>
2626
#include <Utilities/Macro.h>
2727

28-
2928
char Debug::StringBuffer[0x1000];
3029

3130
void Debug::Log(const char* pFormat, ...)
31+
{
32+
va_list args;
33+
Debug::LogGame("[Spawner] ");
34+
Debug::LogGame(pFormat, args);
35+
va_end(args);
36+
}
37+
38+
void Debug::LogGame(const char* pFormat, ...)
3239
{
3340
JMP_STD(0x4068E0);
3441
}
@@ -38,7 +45,7 @@ void Debug::LogAndMessage(const char* pFormat, ...)
3845
va_list args;
3946
va_start(args, pFormat);
4047
vsprintf_s(StringBuffer, pFormat, args);
41-
Log("%s", StringBuffer);
48+
Debug::Log("%s", StringBuffer);
4249
va_end(args);
4350
wchar_t buffer[0x1000];
4451
CRT::mbstowcs(buffer, StringBuffer, 0x1000);
@@ -48,7 +55,7 @@ void Debug::LogAndMessage(const char* pFormat, ...)
4855
void Debug::LogWithVArgs(const char* pFormat, va_list args)
4956
{
5057
vsprintf_s(StringBuffer, pFormat, args);
51-
Log("%s", StringBuffer);
58+
Debug::Log("%s", StringBuffer);
5259
}
5360

5461
void Debug::INIParseFailed(const char* section, const char* flag, const char* value, const char* Message)
@@ -65,7 +72,7 @@ void Debug::FatalErrorAndExit(const char* pFormat, ...)
6572
{
6673
va_list args;
6774
va_start(args, pFormat);
68-
LogWithVArgs(pFormat, args);
75+
Debug::LogWithVArgs(pFormat, args);
6976
va_end(args);
7077
FatalExit(static_cast<int>(ExitCode::Undefined));
7178
}
@@ -74,7 +81,7 @@ void Debug::FatalErrorAndExit(ExitCode nExitCode, const char* pFormat, ...)
7481
{
7582
va_list args;
7683
va_start(args, pFormat);
77-
LogWithVArgs(pFormat, args);
84+
Debug::LogWithVArgs(pFormat, args);
7885
va_end(args);
7986
FatalExit(static_cast<int>(nExitCode));
8087
}

0 commit comments

Comments
 (0)