Skip to content

Commit 3300770

Browse files
committed
Fix Linux compile error and some warnings
1 parent 539bd29 commit 3300770

File tree

13 files changed

+47
-42
lines changed

13 files changed

+47
-42
lines changed

Client/core/CExceptionInformation_Impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool CExceptionInformation_Impl::GetModule(void* pQueryAddress, char* szOutputBu
149149
* See if we're able to use GetModuleHandleExA. According to Microsoft,
150150
* this API is only available on Windows XP and Vista.
151151
*/
152-
_pfnGetModuleHandleExA pfnGetModuleHandleExA = (_pfnGetModuleHandleExA)static_cast<void*>(GetProcAddress(hKern32, "GetModuleHandleExA"));
152+
auto pfnGetModuleHandleExA = reinterpret_cast<_pfnGetModuleHandleExA>(static_cast<void*>(GetProcAddress(hKern32, "GetModuleHandleExA")));
153153

154154
/*
155155
* TODO: Possibly use our own code to do this for other systems.

Client/core/CScreenShot.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void CScreenShot::CheckForScreenShot(bool bBeforeGUI)
128128
}
129129

130130
// Callback for threaded save
131-
DWORD CScreenShot::ThreadProc(LPVOID lpdwThreadParam)
131+
DWORD WINAPI CScreenShot::ThreadProc(LPVOID lpdwThreadParam)
132132
{
133133
uint uiLinePitch = ms_uiWidth * 4;
134134
void* pData = ms_ScreenShotBuffer.GetData();
@@ -194,7 +194,7 @@ DWORD CScreenShot::ThreadProc(LPVOID lpdwThreadParam)
194194

195195
void CScreenShot::StartSaveThread()
196196
{
197-
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)static_cast<void*>(ThreadProc), NULL, CREATE_SUSPENDED, NULL);
197+
HANDLE hThread = CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(ThreadProc), NULL, CREATE_SUSPENDED, NULL);
198198
if (!hThread)
199199
{
200200
CCore::GetSingleton().GetConsole()->Printf("Could not create screenshot thread.");

Client/core/CScreenShot.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class CScreenShot
2222
static void SetPhotoSavingInsideDocuments(bool bSavePhoto) noexcept;
2323

2424
protected:
25-
static void StartSaveThread();
26-
static void ClearBuffer();
27-
static SString GetScreenshotPath();
28-
static bool IsRateLimited(bool bIsCameraShot);
29-
static DWORD ThreadProc(LPVOID lpdwThreadParam);
25+
static void StartSaveThread();
26+
static void ClearBuffer();
27+
static SString GetScreenshotPath();
28+
static bool IsRateLimited(bool bIsCameraShot);
29+
static DWORD WINAPI ThreadProc(LPVOID lpdwThreadParam);
3030
};

Client/core/CrashHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ BOOL __stdcall SetCrashHandlerFilter(PFNCHFILTFN pFn)
8686
}
8787
else
8888
{
89-
if (TRUE == IsBadCodePtr((FARPROC)static_cast<void*>(pFn)))
89+
if (TRUE == IsBadCodePtr(reinterpret_cast<FARPROC>(static_cast<void*>(pFn))))
9090
{
9191
return (FALSE);
9292
}
@@ -157,7 +157,7 @@ LONG __stdcall CrashHandlerExceptionFilter(EXCEPTION_POINTERS* pExPtrs)
157157
// it got unloaded. If some other function loaded
158158
// back into the same address, however, there isn't much
159159
// I can do.
160-
if (FALSE == IsBadCodePtr((FARPROC)static_cast<void*>(g_pfnCallBack)))
160+
if (FALSE == IsBadCodePtr(reinterpret_cast<FARPROC>(static_cast<void*>(g_pfnCallBack))))
161161
{
162162
lRet = g_pfnCallBack(pExPtrs);
163163
}

Client/core/ServerBrowser/CServerCache.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class CServerCache : public CServerCacheInterface
6565
~CServerCache();
6666

6767
protected:
68-
bool LoadServerCache();
69-
static DWORD StaticThreadProc(LPVOID lpdwThreadParam);
70-
static void StaticSaveServerCache();
68+
bool LoadServerCache();
69+
static DWORD WINAPI StaticThreadProc(LPVOID lpdwThreadParam);
70+
static void StaticSaveServerCache();
7171

7272
bool m_bListChanged;
7373
std::map<CCachedKey, CCachedInfo> m_ServerCachedMap;
@@ -211,7 +211,7 @@ void CServerCache::SaveServerCache(bool bWaitUntilFinished)
211211
ms_ServerCachedMap = m_ServerCachedMap;
212212

213213
// Start save thread
214-
HANDLE hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)static_cast<void*>(CServerCache::StaticThreadProc), NULL, CREATE_SUSPENDED, NULL);
214+
HANDLE hThread = CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(CServerCache::StaticThreadProc), NULL, CREATE_SUSPENDED, NULL);
215215
if (!hThread)
216216
{
217217
CCore::GetSingleton().GetConsole()->Printf("Could not create server cache thread.");
@@ -238,7 +238,7 @@ void CServerCache::SaveServerCache(bool bWaitUntilFinished)
238238
// SaveServerCache thread
239239
//
240240
///////////////////////////////////////////////////////////////
241-
DWORD CServerCache::StaticThreadProc(LPVOID lpdwThreadParam)
241+
DWORD WINAPI CServerCache::StaticThreadProc(LPVOID lpdwThreadParam)
242242
{
243243
StaticSaveServerCache();
244244
ms_bIsSaving = false;

Client/mods/deathmatch/logic/CServerIdManager.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CServerIdManagerImpl : public CServerIdManager
6363
void SaveServerIdMap(bool bWait = false);
6464
const CServerIdInfo& GetServerIdInfo(const SString& strServerId);
6565
bool LoadServerIdMap();
66-
static DWORD StaticThreadProc(LPVOID lpdwThreadParam);
66+
static DWORD WINAPI StaticThreadProc(LPVOID lpdwThreadParam);
6767
static void StaticSaveServerIdMap();
6868

6969
bool m_bListChanged;
@@ -188,7 +188,7 @@ void CServerIdManagerImpl::SaveServerIdMap(bool bWait)
188188
ms_ServerIdMap = m_ServerIdMap;
189189

190190
// Start save thread
191-
HANDLE hThread = CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(static_cast<void*>(CServerIdManagerImpl::StaticThreadProc)),
191+
HANDLE hThread = CreateThread(NULL, 0, reinterpret_cast<LPTHREAD_START_ROUTINE>(CServerIdManagerImpl::StaticThreadProc),
192192
NULL, CREATE_SUSPENDED, NULL);
193193
if (!hThread)
194194
{
@@ -213,7 +213,7 @@ void CServerIdManagerImpl::SaveServerIdMap(bool bWait)
213213
// SaveServerIdMap thread
214214
//
215215
///////////////////////////////////////////////////////////////
216-
DWORD CServerIdManagerImpl::StaticThreadProc(LPVOID lpdwThreadParam)
216+
DWORD WINAPI CServerIdManagerImpl::StaticThreadProc(LPVOID lpdwThreadParam)
217217
{
218218
StaticSaveServerIdMap();
219219
ms_bIsSaving = false;

Server/core/CCrashHandlerAPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ BOOL __stdcall SetCrashHandlerFilter(PFNCHFILTFN pFn)
8989
}
9090
else
9191
{
92-
if (TRUE == IsBadCodePtr((FARPROC)static_cast<void*>(pFn)))
92+
if (TRUE == IsBadCodePtr(reinterpret_cast<FARPROC>(static_cast<void*>(pFn))))
9393
{
9494
return (FALSE);
9595
}
@@ -162,7 +162,7 @@ LONG __stdcall CrashHandlerExceptionFilter(EXCEPTION_POINTERS* pExPtrs)
162162
// it got unloaded. If some other function loaded
163163
// back into the same address, however, there isn't much
164164
// I can do.
165-
if (FALSE == IsBadCodePtr((FARPROC)static_cast<void*>(g_pfnCallBack)))
165+
if (FALSE == IsBadCodePtr(reinterpret_cast<FARPROC>(static_cast<void*>(g_pfnCallBack))))
166166
{
167167
lRet = g_pfnCallBack(pExPtrs);
168168
}

Server/core/CDynamicLibrary.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ FuncPtr_t CDynamicLibrary::GetProcedureAddress(const char* szProcName)
127127
if (m_hModule != 0)
128128
{
129129
#ifdef WIN32
130-
return (FuncPtr_t)static_cast<void*>(GetProcAddress(m_hModule, szProcName));
130+
return reinterpret_cast<FuncPtr_t>(static_cast<void*>(GetProcAddress(m_hModule, szProcName)));
131131
#else
132132
char* szError = NULL;
133133
dlerror();
134134

135-
FuncPtr_t pFunc = (FuncPtr_t)dlsym(m_hModule, szProcName);
135+
auto pFunc = reinterpret_cast<FuncPtr_t>(dlsym(m_hModule, szProcName));
136136
if ((szError = dlerror()) != NULL)
137137
{
138138
return NULL;

Server/core/CExceptionInformation_Impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ bool CExceptionInformation_Impl::GetModule(char* szOutputBuffer, int nOutputName
113113
* See if we're able to use GetModuleHandleExA. According to Microsoft,
114114
* this API is only available on Windows XP and Vista.
115115
*/
116-
_pfnGetModuleHandleExA pfnGetModuleHandleExA = (_pfnGetModuleHandleExA)static_cast<void*>(GetProcAddress(hKern32, "GetModuleHandleExA"));
116+
auto pfnGetModuleHandleExA = reinterpret_cast<_pfnGetModuleHandleExA>(static_cast<void*>(GetProcAddress(hKern32, "GetModuleHandleExA")));
117117

118118
/*
119119
* TODO: Possibly use our own code to do this for other systems.

Server/core/CModManagerImpl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ bool CModManagerImpl::Load(const char* szModName, int iArgumentCount, char* szAr
7474
}
7575

7676
// Grab the initialization procedure
77-
InitServer* pfnInitServer = (InitServer*)(static_cast<void*>(m_Library.GetProcedureAddress("InitServer")));
77+
#pragma warning(suppress: 4191)
78+
auto pfnInitServer = reinterpret_cast<InitServer*>(m_Library.GetProcedureAddress("InitServer"));
7879
if (!pfnInitServer)
7980
{
8081
// Unload the library

0 commit comments

Comments
 (0)