From 473810fc0cd59590c0cf3aa970166cff6b358e81 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 14 Jun 2018 20:32:31 +0300 Subject: [PATCH] MSVC & Win32 related fixes --- common/port.h | 1 + engine/common/lib_common.c | 2 +- engine/eiface.h | 1 + engine/platform/win32/win_lib.c | 2 +- game_launch/game.cpp | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/port.h b/common/port.h index 2be6a948..fc3b5b44 100644 --- a/common/port.h +++ b/common/port.h @@ -118,6 +118,7 @@ GNU General Public License for more details. #define strncasecmp _strnicmp #define open _open #define read _read + #define alloca _alloca // shut-up compiler warnings #pragma warning(disable : 4244) // MIPS diff --git a/engine/common/lib_common.c b/engine/common/lib_common.c index bf3e9412..cbf0048b 100644 --- a/engine/common/lib_common.c +++ b/engine/common/lib_common.c @@ -48,7 +48,7 @@ void *COM_FunctionFromName_SR( void *hInstance, const char *pName ) const char *COM_OffsetNameForFunction( void *function ) { static string sname; - Q_snprintf( sname, MAX_STRING, "ofs:%d", (int)(void*)(function - (void*)svgame.dllFuncs.pfnGameInit) ); + Q_snprintf( sname, MAX_STRING, "ofs:%d", (size_t)((byte*)function - (byte*)svgame.dllFuncs.pfnGameInit) ); MsgDev( D_NOTE, "COM_OffsetNameForFunction %s\n", sname ); return sname; } diff --git a/engine/eiface.h b/engine/eiface.h index 0fc110cb..2e456814 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -390,6 +390,7 @@ typedef struct short flags; } TYPEDESCRIPTION; +#undef ARRAYSIZE #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) typedef struct playermove_s playermove_t; diff --git a/engine/platform/win32/win_lib.c b/engine/platform/win32/win_lib.c index 426b4467..a130a687 100644 --- a/engine/platform/win32/win_lib.c +++ b/engine/platform/win32/win_lib.c @@ -950,7 +950,7 @@ const char *COM_NameForFunction( void *hInstance, void *function ) { index = hInst->ordinals[i]; - if(( function - hInst->funcBase ) == hInst->funcs[index] ) + if(( (char*)function - (char*)hInst->funcBase ) == hInst->funcs[index] ) return hInst->names[i]; } diff --git a/game_launch/game.cpp b/game_launch/game.cpp index 4715e8e5..2cc788a0 100644 --- a/game_launch/game.cpp +++ b/game_launch/game.cpp @@ -36,6 +36,7 @@ GNU General Public License for more details. #else #define XASHLIB "xash_dedicated.dll" #endif + #define dlerror() GetStringLastError() #include #endif