Skip to content

Commit 39541f5

Browse files
committed
Add debug traces
1 parent 3c31161 commit 39541f5

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

sa-mp_masterlist_fix/Config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ bool Configuration::Load()
6262
// Populate any invalid setting with the equivalent from the default config
6363
if (!m_internetEndpoint.IsValid())
6464
{
65+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Invalid internet endpoint; falling back to the default");
6566
defaultConfig["endpoints"]["internet"].get_to(m_internetEndpoint);
6667
}
6768

6869
if (!m_hostedEndpoint.IsValid())
6970
{
71+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Invalid hosted endpoint; falling back to the default");
7072
defaultConfig["endpoints"]["hosted"].get_to(m_hostedEndpoint);
7173
}
7274

sa-mp_masterlist_fix/dllmain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ BOOL WINAPI DllMain(HINSTANCE, DWORD dwReason, LPVOID)
6262
{
6363
if (dwReason == DLL_PROCESS_ATTACH)
6464
{
65-
OutputDebugStringA("Loaded");
65+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Injected");
66+
6667
if (InitializeWrapper())
6768
{
6869
Fix::GetInstance().EarlyInitialize();

sa-mp_masterlist_fix/fix.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ int WINAPI Fix::connect(SOCKET s, const sockaddr* name, int namelen)
5454
{
5555
if (int newPort = self.GetEndpointForCurrentTab().m_port)
5656
{
57-
nameIpv4->sin_port = ::htons(static_cast<short>(newPort));
57+
if (self.m_socket != INVALID_SOCKET)
58+
{
59+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] New socket opened without closing the previous one (must never happen; report it on GitHub pls)");
60+
assert(false);
61+
}
5862

59-
assert(self.m_socket == INVALID_SOCKET && "New socket opened without closing the previous one");
63+
nameIpv4->sin_port = ::htons(static_cast<short>(newPort));
6064
self.m_socket = s;
6165
}
6266
}
@@ -108,6 +112,9 @@ MasterlistEndpoint Fix::GetEndpointForCurrentTab() const
108112
return m_config.GetHostedEndpoint();
109113
}
110114

115+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Invalid tab (should never happen; report it on GitHub pls)");
116+
assert(false);
117+
111118
return MasterlistEndpoint{};
112119
}
113120

@@ -163,6 +170,7 @@ void Fix::EarlyInitialize()
163170

164171
if (!m_config.Load())
165172
{
173+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Invalid configuration (must never happen; report it on GitHub pls)");
166174
assert(false && "Invalid configuration");
167175
return;
168176
}
@@ -184,9 +192,12 @@ bool Fix::Initialize()
184192
{
185193
// We're injected into a random process or in an unsupported SA-MP server browser version
186194
// Either way, we should not try to mess with the current process any longer
195+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Signature scanning failed");
187196
return false;
188197
}
189198

199+
::OutputDebugStringW(L"[SA-MP Masterlist Fix] Fully initialized");
200+
190201
m_fullyInit = true;
191202
return true;
192203
}

0 commit comments

Comments
 (0)