From 5fa6e12d56acff11b454f9837a59bda51be432e4 Mon Sep 17 00:00:00 2001 From: Spoike Date: Wed, 4 Sep 2019 23:39:39 +0000 Subject: [PATCH] Compile fixes (mostly focused on windows) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5533 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- CMakeLists.txt | 14 +++++------ engine/client/m_mp3.c | 2 +- engine/common/bothdefs.h | 10 ++++++++ engine/d3d/d3d11_image.c | 42 ++++++++++++++++++++++----------- engine/d3d/vid_d3d.c | 45 ++++++++--------------------------- engine/d3d/vid_d3d11.c | 42 ++++++++------------------------- engine/d3d/vid_d3d8.c | 36 ++++++++++------------------ engine/gl/gl_screen.c | 2 -- engine/qclib/progsint.h | 12 ++++++++++ plugins/plugin.c | 51 ++++++++++++++++++++++++++++++++++++++++ plugins/plugin.h | 2 +- 11 files changed, 142 insertions(+), 116 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0fe5904..91c5b2381 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,7 +155,7 @@ IF(${ANDROID}) # INCLUDE_DIRECTORIES( ${FREETYPE_INCLUDE_DIRS} ) - SET(FTE_DEFINES ${FTE_DEFINES};ANDROID;VKQUAKE;DYNAMIC_LIBPNG;DYNAMIC_LIBJPEG;MULTITHREAD;stricmp=strcasecmp;strnicmp=strncasecmp) + SET(FTE_DEFINES ${FTE_DEFINES};ANDROID;VKQUAKE;DYNAMIC_LIBPNG;DYNAMIC_LIBJPEG;MULTITHREAD) SET(FTE_LIBS ${FTE_LIBS} android log EGL ${ZLIB_LIBRARIES} m ${CMAKE_DL_LIBS}) SET(FTE_ARCH_FILES engine/client/sys_droid.c @@ -236,7 +236,7 @@ ELSEIF(${UNIX}) #linux(ish) SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_X11) ENDIF() - SET(FTE_DEFINES ${FTE_DEFINES};DYNAMIC_LIBPNG;DYNAMIC_LIBJPEG;DYNAMIC_SDL;MULTITHREAD;stricmp=strcasecmp;strnicmp=strncasecmp) + SET(FTE_DEFINES ${FTE_DEFINES};DYNAMIC_LIBPNG;DYNAMIC_LIBJPEG;DYNAMIC_SDL;MULTITHREAD) SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES} m ${CMAKE_DL_LIBS} pthread ${SDL2_LIBRARIES}) SET(FTE_ARCH_FILES engine/client/sys_linux.c @@ -285,7 +285,7 @@ ELSEIF(${UNIX}) #linux(ish) ENDIF() ENDIF() - SET(FTESV_DEFINES MULTITHREAD;stricmp=strcasecmp;strnicmp=strncasecmp) + SET(FTESV_DEFINES MULTITHREAD) SET(FTESV_ARCH_FILES engine/server/sv_sys_unix.c engine/common/sys_linux_threads.c @@ -310,7 +310,7 @@ ELSEIF(1) #SDL INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}) #SDL2.0.7 supports vulkan, so lets use it. - SET(FTE_DEFINES ${FTE_DEFINES};FTE_SDL;DYNAMIC_LIBPNG;DYNAMIC_LIBJPEG;stricmp=strcasecmp;strnicmp=strncasecmp) + SET(FTE_DEFINES ${FTE_DEFINES};FTE_SDL;DYNAMIC_LIBPNG;DYNAMIC_LIBJPEG) SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES} m ${CMAKE_DL_LIBS} ${SDL2_LIBRARIES}) SET(FTE_ARCH_FILES engine/client/sys_sdl.c @@ -321,7 +321,7 @@ ELSEIF(1) #SDL engine/gl/gl_vidsdl.c ) - SET(FTESV_DEFINES FTE_SDL;stricmp=strcasecmp;strnicmp=strncasecmp) + SET(FTESV_DEFINES FTE_SDL) SET(FTESV_LIBS ${FTESV_LIBS} ${ZLIB_LIBRARIES} m ${CMAKE_DL_LIBS} ${SDL2_LIBRARIES}) IF(WIN32) @@ -774,7 +774,7 @@ ELSE() fteqtv/libqtvc/glibc_sucks.c engine/common/sha1.c ) - SET_TARGET_PROPERTIES(qtv PROPERTIES COMPILE_DEFINITIONS "${FTE_REVISON};stricmp=strcasecmp;strnicmp=strncasecmp") + SET_TARGET_PROPERTIES(qtv PROPERTIES COMPILE_DEFINITIONS "${FTE_REVISON}") IF(WIN32) TARGET_LINK_LIBRARIES(qtv ${ZLIB_LIBRARIES} ws2_32 winmm) ELSE() @@ -810,7 +810,7 @@ ELSE() engine/http/iwebiface.c engine/http/ftpserver.c ) - SET_TARGET_PROPERTIES(httpserver PROPERTIES COMPILE_DEFINITIONS "WEBSERVER;WEBSVONLY;${FTE_REVISON};stricmp=strcasecmp;strnicmp=strncasecmp") + SET_TARGET_PROPERTIES(httpserver PROPERTIES COMPILE_DEFINITIONS "WEBSERVER;WEBSVONLY;${FTE_REVISON}") IF(WIN32) TARGET_LINK_LIBRARIES(httpserver ${ZLIB_LIBRARIES} ws2_32) ENDIF() diff --git a/engine/client/m_mp3.c b/engine/client/m_mp3.c index ae52da0d9..ac5fc68cc 100644 --- a/engine/client/m_mp3.c +++ b/engine/client/m_mp3.c @@ -5158,7 +5158,7 @@ void Media_Init(void) Cvar_Register(&tts_mode, "Gimmicks"); #endif #ifdef AVAIL_MP3_ACM - S_RegisterSoundInputPlugin(S_LoadMP3Sound); + S_RegisterSoundInputPlugin(NULL, S_LoadMP3Sound); #endif diff --git a/engine/common/bothdefs.h b/engine/common/bothdefs.h index d0cdc3bd2..4d2b09fa0 100644 --- a/engine/common/bothdefs.h +++ b/engine/common/bothdefs.h @@ -783,6 +783,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define FTE_UNREACHABLE Sys_Error("Unreachable reached: %s %i\n", __FILE__, __LINE__) #endif +#ifdef _WIN32 + //Windows-specific... + #define stricmp _stricmp + #define strnicmp _strnicmp +#else + //Posix + #define stricmp strcasecmp + #define strnicmp strncasecmp +#endif + // !!! if this is changed, it must be changed in d_ifacea.h too !!! #define CACHE_SIZE 32 // used to align key data structures diff --git a/engine/d3d/d3d11_image.c b/engine/d3d/d3d11_image.c index 836bf8f54..ff59e3b9c 100644 --- a/engine/d3d/d3d11_image.c +++ b/engine/d3d/d3d11_image.c @@ -322,33 +322,47 @@ qboolean D3D11_LoadTextureMips(image_t *tex, const struct pendingtextureinfo *mi case PTI_EAC_R11_SNORM: case PTI_EAC_RG11: case PTI_EAC_RG11_SNORM: - case PTI_ASTC_4X4: //not invented here... + case PTI_ASTC_4X4_LDR: //not invented here... + case PTI_ASTC_5X4_LDR: + case PTI_ASTC_5X5_LDR: + case PTI_ASTC_6X5_LDR: + case PTI_ASTC_6X6_LDR: + case PTI_ASTC_8X5_LDR: + case PTI_ASTC_8X6_LDR: + case PTI_ASTC_10X5_LDR: + case PTI_ASTC_10X6_LDR: + case PTI_ASTC_8X8_LDR: + case PTI_ASTC_10X8_LDR: + case PTI_ASTC_10X10_LDR: + case PTI_ASTC_12X10_LDR: + case PTI_ASTC_12X12_LDR: + case PTI_ASTC_4X4_HDR: + case PTI_ASTC_5X4_HDR: + case PTI_ASTC_5X5_HDR: + case PTI_ASTC_6X5_HDR: + case PTI_ASTC_6X6_HDR: + case PTI_ASTC_8X5_HDR: + case PTI_ASTC_8X6_HDR: + case PTI_ASTC_10X5_HDR: + case PTI_ASTC_10X6_HDR: + case PTI_ASTC_8X8_HDR: + case PTI_ASTC_10X8_HDR: + case PTI_ASTC_10X10_HDR: + case PTI_ASTC_12X10_HDR: + case PTI_ASTC_12X12_HDR: case PTI_ASTC_4X4_SRGB: - case PTI_ASTC_5X4: case PTI_ASTC_5X4_SRGB: - case PTI_ASTC_5X5: case PTI_ASTC_5X5_SRGB: - case PTI_ASTC_6X5: case PTI_ASTC_6X5_SRGB: - case PTI_ASTC_6X6: case PTI_ASTC_6X6_SRGB: - case PTI_ASTC_8X5: case PTI_ASTC_8X5_SRGB: - case PTI_ASTC_8X6: case PTI_ASTC_8X6_SRGB: - case PTI_ASTC_10X5: case PTI_ASTC_10X5_SRGB: - case PTI_ASTC_10X6: case PTI_ASTC_10X6_SRGB: - case PTI_ASTC_8X8: case PTI_ASTC_8X8_SRGB: - case PTI_ASTC_10X8: case PTI_ASTC_10X8_SRGB: - case PTI_ASTC_10X10: case PTI_ASTC_10X10_SRGB: - case PTI_ASTC_12X10: case PTI_ASTC_12X10_SRGB: - case PTI_ASTC_12X12: case PTI_ASTC_12X12_SRGB: #ifdef FTE_TARGET_WEB case PTI_WHOLEFILE: //basically webgl only... diff --git a/engine/d3d/vid_d3d.c b/engine/d3d/vid_d3d.c index 44b47aa38..6ad46a2d8 100644 --- a/engine/d3d/vid_d3d.c +++ b/engine/d3d/vid_d3d.c @@ -970,7 +970,6 @@ static qboolean (D3D9_SCR_UpdateScreen) (void) { //extern int keydown[]; //extern cvar_t vid_conheight; - int uimenu; #ifdef TEXTEDITOR //extern qboolean editormodal; #endif @@ -1065,12 +1064,6 @@ static qboolean (D3D9_SCR_UpdateScreen) (void) Shader_DoReload(); -#ifdef VM_UI - uimenu = UI_MenuState(); -#else - uimenu = 0; -#endif - d3d9error(IDirect3DDevice9_BeginScene(pD3DDev9)); /* #ifdef TEXTEDITOR @@ -1093,19 +1086,6 @@ static qboolean (D3D9_SCR_UpdateScreen) (void) D3D9_Set2D(); - if (Media_ShowFilm()) - { - M_Draw(0); -// V_UpdatePalette (false); - Media_RecordFrame(); -// R2D_BrightenScreen(); - if (R2D_Flush) - R2D_Flush(); - IDirect3DDevice9_EndScene(pD3DDev9); - D3D9_VID_SwapBuffers(); - return true; - } - // // do 3D refresh drawing, and then update the screen // @@ -1114,25 +1094,20 @@ static qboolean (D3D9_SCR_UpdateScreen) (void) noworld = false; nohud = false; -#ifdef VM_CG - if (CG_Refresh()) + if (topmenu && topmenu->isopaque) + nohud = true; +#ifdef VM_CG + else if (CG_Refresh()) nohud = true; - else #endif #ifdef CSQC_DAT - if (CSQC_DrawView()) + else if (CSQC_DrawView()) nohud = true; - else #endif - if (uimenu != 1) - { - if (r_worldentity.model && cls.state == ca_active) - V_RenderView (nohud); - else - { - noworld = true; - } - } + else if (r_worldentity.model && cls.state == ca_active) + V_RenderView (nohud); + else + noworld = true; R2D_BrightenScreen(); @@ -1147,7 +1122,7 @@ static qboolean (D3D9_SCR_UpdateScreen) (void) nohud = true; } - SCR_DrawTwoDimensional(uimenu, nohud); + SCR_DrawTwoDimensional(nohud); V_UpdatePalette (false); Media_RecordFrame(); diff --git a/engine/d3d/vid_d3d11.c b/engine/d3d/vid_d3d11.c index 420ae5630..2d61ce18c 100644 --- a/engine/d3d/vid_d3d11.c +++ b/engine/d3d/vid_d3d11.c @@ -1316,7 +1316,6 @@ static qboolean (D3D11_SCR_UpdateScreen) (void) { //extern int keydown[]; //extern cvar_t vid_conheight; - int uimenu; #ifdef TEXTEDITOR //extern qboolean editormodal; #endif @@ -1369,12 +1368,6 @@ static qboolean (D3D11_SCR_UpdateScreen) (void) Shader_DoReload(); -#ifdef VM_UI - uimenu = UI_MenuState(); -#else - uimenu = 0; -#endif - // d3d11error(IDirect3DDevice9_BeginScene(pD3DDev9)); /* #ifdef TEXTEDITOR @@ -1394,16 +1387,6 @@ static qboolean (D3D11_SCR_UpdateScreen) (void) } #endif */ - if (Media_ShowFilm()) - { - M_Draw(0); -// V_UpdatePalette (false); - Media_RecordFrame(); -// R2D_BrightenScreen(); -// IDirect3DDevice9_EndScene(pD3DDev9); - D3D11_PresentOrCrash(); - return true; - } // // do 3D refresh drawing, and then update the screen @@ -1413,25 +1396,20 @@ static qboolean (D3D11_SCR_UpdateScreen) (void) noworld = false; nohud = false; -#ifdef VM_CG - if (CG_Refresh()) + if (topmenu && topmenu->isopaque) + nohud = true; +#ifdef VM_CG + else if (CG_Refresh()) nohud = true; - else #endif #ifdef CSQC_DAT - if (CSQC_DrawView()) + else if (CSQC_DrawView()) nohud = true; - else #endif - if (uimenu != 1) - { - if (r_worldentity.model && cls.state == ca_active) - V_RenderView (nohud); - else - { - noworld = true; - } - } + else if (r_worldentity.model && cls.state == ca_active) + V_RenderView (nohud); + else + noworld = true; D3D11_Set2D(); @@ -1454,7 +1432,7 @@ static qboolean (D3D11_SCR_UpdateScreen) (void) nohud = true; } - SCR_DrawTwoDimensional(uimenu, nohud); + SCR_DrawTwoDimensional(nohud); V_UpdatePalette (false); diff --git a/engine/d3d/vid_d3d8.c b/engine/d3d/vid_d3d8.c index d30da5e1d..1dffc4e85 100644 --- a/engine/d3d/vid_d3d8.c +++ b/engine/d3d/vid_d3d8.c @@ -1128,16 +1128,6 @@ static qboolean (D3D8_SCR_UpdateScreen) (void) } #endif */ - if (Media_ShowFilm()) - { - M_Draw(0); -// V_UpdatePalette (false); - Media_RecordFrame(); -// R2D_BrightenScreen(); - IDirect3DDevice8_EndScene(pD3DDev8); - IDirect3DDevice8_Present(pD3DDev8, NULL, NULL, NULL, NULL); - return true; - } // // do 3D refresh drawing, and then update the screen @@ -1149,25 +1139,23 @@ static qboolean (D3D8_SCR_UpdateScreen) (void) D3D8_Set2D(); -#ifdef VM_CG - if (CG_Refresh()) + if (topmenu && topmenu->isopaque) + nohud = true; +#ifdef VM_CG + else if (CG_Refresh()) nohud = true; - else #endif #ifdef CSQC_DAT - if (CSQC_DrawView()) + else if (CSQC_DrawView()) nohud = true; - else #endif - if (uimenu != 1) - { - if (r_worldentity.model && cls.state == ca_active) - V_RenderView (nohud); - else - { - noworld = true; - } - } + else if (uimenu != 1) + { + if (r_worldentity.model && cls.state == ca_active) + V_RenderView (nohud); + else + noworld = true; + } R2D_BrightenScreen(); diff --git a/engine/gl/gl_screen.c b/engine/gl/gl_screen.c index 89a23d870..c1d28bb01 100644 --- a/engine/gl/gl_screen.c +++ b/engine/gl/gl_screen.c @@ -175,9 +175,7 @@ qboolean GLSCR_UpdateScreen (void) if (r_worldentity.model && cls.state == ca_active) V_RenderView (nohud); else - { noworld = true; - } } GL_Set2D (false); diff --git a/engine/qclib/progsint.h b/engine/qclib/progsint.h index e15149d33..d768b3581 100644 --- a/engine/qclib/progsint.h +++ b/engine/qclib/progsint.h @@ -58,6 +58,18 @@ typedef unsigned char qbyte; #pragma warning(disable : 4267) #endif +#ifndef stricmp +#ifdef _WIN32 + //Windows-specific... + #define stricmp _stricmp + #define strnicmp _strnicmp +#else + //Posix + #define stricmp strcasecmp + #define strnicmp strncasecmp +#endif +#endif + //extern progfuncs_t *progfuncs; typedef struct sharedvar_s { diff --git a/plugins/plugin.c b/plugins/plugin.c index 0ce8a6015..c6fc6c302 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -138,6 +138,57 @@ char *va(const char *format, ...) //Identical in function to the one in Quake, t return string; } +#ifdef _WIN32 +// don't use these functions in MSVC8 +#if (_MSC_VER < 1400) +int QDECL linuxlike_snprintf(char *buffer, int size, const char *format, ...) +{ +#undef _vsnprintf + int ret; + va_list argptr; + + if (size <= 0) + return 0; + size--; + + va_start (argptr, format); + ret = _vsnprintf (buffer,size, format,argptr); + va_end (argptr); + + buffer[size] = '\0'; + + return ret; +} +int QDECL linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr) +{ +#undef _vsnprintf + int ret; + + if (size <= 0) + return 0; + size--; + + ret = _vsnprintf (buffer,size, format,argptr); + + buffer[size] = '\0'; + + return ret; +} +#else +int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) +{ + int ret; + va_list argptr; + + va_start (argptr, format); + ret = vsnprintf_s (buffer,size, _TRUNCATE, format,argptr); + va_end (argptr); + + return ret; +} +#endif +#endif + void Con_Printf(const char *format, ...) { va_list argptr; diff --git a/plugins/plugin.h b/plugins/plugin.h index e76a33eea..da9afc85e 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -176,7 +176,7 @@ typedef struct { struct wstats_s; -#define F(t, n, args) t (QDECL *n) args; +#define F(t, n, args) t (QDECL *n) args typedef struct //core stuff {