FTE_TARGET=msvc now invokes some old version of msvc via wine, old FTE_TARGET=vc removed. Related code tweaks to make it a bit happier.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6001 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-08-04 21:17:31 +00:00
parent 1c5b264402
commit 221d4032af
36 changed files with 413 additions and 274 deletions

View File

@ -6,6 +6,8 @@
#only the following 3 are supported #only the following 3 are supported
#linux->win32 (FTE_TARGET=win32) RPM Package: "mingw32-gcc", DEB Package: "mingw32" #linux->win32 (FTE_TARGET=win32) RPM Package: "mingw32-gcc", DEB Package: "mingw32"
#linux->win64 (FTE_TARGET=win64) RPM Package: "mingw32-gcc", DEB Package: "mingw32" #linux->win64 (FTE_TARGET=win64) RPM Package: "mingw32-gcc", DEB Package: "mingw32"
#linux->win32 (FTE_TARGET=msvc32 MSVCPATH=? WINDOWSSDKDIR=?) invokes via wine.
#linux->win64 (FTE_TARGET=msvc64 MSVCPATH=? WINDOWSSDKDIR=?) invokes via wine.
#linux->linux 32 (FTE_TARGET=linux32) #linux->linux 32 (FTE_TARGET=linux32)
#linux->linux 64 (FTE_TARGET=linux64) #linux->linux 64 (FTE_TARGET=linux64)
#linux->linux x32 (FTE_TARGET=linux_x32) #linux->linux x32 (FTE_TARGET=linux_x32)
@ -36,6 +38,8 @@ COMPILE_SYS:=$(shell uname -o 2>&1)
#canonicalize the source path. except emscripten warns about that like crazy. *sigh* #canonicalize the source path. except emscripten warns about that like crazy. *sigh*
ifeq ($(FTE_TARGET),web) ifeq ($(FTE_TARGET),web)
BASE_DIR:=. BASE_DIR:=.
else ifeq ($(findstring msvc,$(FTE_TARGET)),msvc)
BASE_DIR:=.
else ifeq ($(FTE_TARGET),droid) else ifeq ($(FTE_TARGET),droid)
#android tools suck, but plugins need to find the engine directory. #android tools suck, but plugins need to find the engine directory.
BASE_DIR:=../engine BASE_DIR:=../engine
@ -110,7 +114,7 @@ ifneq (,$(BRANDING))
-include game_$(BRANDING).mak -include game_$(BRANDING).mak
endif endif
FTE_CONFIG?=fteqw FTE_CONFIG?=fteqw
ifneq ($(FTE_TARGET),vc) ifneq ($(findstring msvc,$(FTE_TARGET)),msvc)
ifeq (,$(FTE_CONFIG_EXTRA)) ifeq (,$(FTE_CONFIG_EXTRA))
export FTE_CONFIG_EXTRA := $(shell $(CC) -xc -E -P -DFTE_TARGET_$(FTE_TARGET) -DCOMPILE_OPTS common/config_$(FTE_CONFIG).h) export FTE_CONFIG_EXTRA := $(shell $(CC) -xc -E -P -DFTE_TARGET_$(FTE_TARGET) -DCOMPILE_OPTS common/config_$(FTE_CONFIG).h)
endif endif
@ -574,7 +578,7 @@ DO_ECHO=@
DO_CC=$(DO_ECHO) $(CC) $(LTO_CC) $(ALL_CFLAGS) -o $@ -c $< DO_CC=$(DO_ECHO) $(CC) $(LTO_CC) $(ALL_CFLAGS) -o $@ -c $<
DO_CXX=$(DO_ECHO) $(CXX) $(LTO_CC) $(ALL_CXXFLAGS) -o $@ -c $< DO_CXX=$(DO_ECHO) $(CXX) $(LTO_CC) $(ALL_CXXFLAGS) -o $@ -c $<
ifeq ($(FTE_TARGET),vc) ifeq ($(findstring msvc,$(FTE_TARGET)),msvc)
BASELDFLAGS= BASELDFLAGS=
endif endif
ifeq ($(FTE_TARGET),cyg) ifeq ($(FTE_TARGET),cyg)
@ -620,11 +624,11 @@ VISIBILITY_FLAGS?=
XLDFLAGS=-L$(ARCHLIBS) $(IMAGELDFLAGS) XLDFLAGS=-L$(ARCHLIBS) $(IMAGELDFLAGS)
#hack some other arguments based upon the toolchain #hack some other arguments based upon the toolchain
ifeq ($(FTE_TARGET),vc) ifeq ($(findstring msvc,$(FTE_TARGET)),msvc)
WARNINGFLAGS=-W3 -D_CRT_SECURE_NO_WARNINGS WARNINGFLAGS?=-W3 -D_CRT_SECURE_NO_WARNINGS
GNUC_FUNCS= GNUC_FUNCS=
else else
WARNINGFLAGS=-Wall -Wno-pointer-sign -Wno-unknown-pragmas -Wno-format-zero-length -Wno-strict-aliasing #-Wcast-align WARNINGFLAGS?=-Wall -Wno-pointer-sign -Wno-unknown-pragmas -Wno-format-zero-length -Wno-strict-aliasing #-Wcast-align
# GNUC_FUNCS= -Dstrnicmp=strncasecmp -Dstricmp=strcasecmp # GNUC_FUNCS= -Dstrnicmp=strncasecmp -Dstricmp=strcasecmp
endif endif
@ -643,9 +647,15 @@ RELEASE_CFLAGS?=$(CPUOPTIMIZATIONS)
#however, its use resulted in the player getting stuck etc, so be warned if you try re-enabling it. #however, its use resulted in the player getting stuck etc, so be warned if you try re-enabling it.
# #
ifeq ($(FTE_TARGET),vc) ifeq ($(findstring msvc,$(FTE_TARGET)),msvc)
#msvc doesn't do -dumpmachine. #msvc doesn't do -dumpmachine.
#we might as well get it to reuse the mingw libraries, if only because that makes those libraries easier to compile... #we might as well get it to reuse the mingw libraries, if only because that makes those libraries easier to compile...
ifeq ($(FTE_TARGET),msvc32)
BITS?=32
else ifeq ($(FTE_TARGET),msvc64)
BITS?=64
endif
BITS?=32
ifeq ($(BITS),64) ifeq ($(BITS),64)
ARCH?=x86_64-w64-mingw32 ARCH?=x86_64-w64-mingw32
else else
@ -1245,78 +1255,99 @@ ifeq (win_SDL,$(findstring win,$(FTE_TARGET))$(findstring _SDL,$(FTE_TARGET)))
endif endif
#FTE_TARGET=vc (Visual C) #FTE_TARGET=vc (Visual C)
ifeq ($(FTE_TARGET),vc) ifeq ($(findstring msvc,$(FTE_TARGET)),msvc)
DEBUG_CFLAGS= #assumptions...
MSVCDIR=Microsoft Visual Studio 10.0 ifneq ($(shell uname -o 2>&1 | grep Cygwin),)
#we're on cygwin
ifeq ($(WINRT),1) MSVCPATH?=C:/Program Files (x86)/Microsoft Visual Studio 8/VC/
WINDOWSSDKDIR=C:/Program Files (x86)/Windows Kits/8.1 WINDOWSSDKDIR?=C:/Program Files/Microsoft SDKs/Windows/v7.1/
FIXPATH=`cygpath -m "$(1)"`
ifeq ($(BITS),64) INVOKE="$(1)"
WINDRES=x86_64-w64-mingw32-windres
MSVCPATH=C:/Program Files (x86)/$(MSVCDIR)/VC/BIN/amd64/
else
WINDRES=i686-w64-mingw32-windres
MSVCPATH=C:/Program Files (x86)/$(MSVCDIR)/VC/BIN/
SDKINC=-I"$(WINDOWSSDKDIR)\Include\shared" -I"$(WINDOWSSDKDIR)\Include\um"
MSVCINC=-I"C:\Program Files (x86)\$(MSVCDIR)\VC\INCLUDE"
#-I"C:\Program Files (x86)\$(MSVCDIR)\VC\ATLMFC\INCLUDE"
# -I"C:\Program Files (x86)\$(MSVCDIR)\VC\PlatformSDK\include" -I"C:\Program Files (x86)\$(MSVCDIR)\SDK\v2.0\include"
MSVCLIB=/LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\VC\ATLMFC\LIB" /LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\VC\LIB" /LIBPATH:"$(WINDOWSSDKDIR)/lib/winv6.3/um/x86" /LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\SDK\v2.0\LIB"
JPEGLIB=libs/jpeg.lib
endif
else else
WINDOWSSDKDIR=C:/Program Files/Microsoft SDKs/Windows/v7.1 #we're PROBABLY on linux (invoke it via wine)
#MSVCPATH=/mnt/win/Program Files (x86)/Microsoft Visual Studio 10.0/VC/
ifeq ($(BITS),64) MSVCPATH?=/mnt/win/Program Files (x86)/Microsoft Visual Studio 8/VC/
WINDRES=x86_64-w64-mingw32-windres WINDOWSSDKDIR?=/mnt/win/Program Files/Microsoft SDKs/Windows/v7.1/
#functions to handle wine (or cygwin)
MSVCPATH=C:/Program Files (x86)/$(MSVCDIR)/VC/BIN/amd64/ FIXPATH=`winepath -w "$(1)"`
INVOKE=WINEDEBUG=-all WINEPATH="$(WINEPATH)" wine "$(1)"
MSVCINC=-I"C:\Program Files (x86)\$(MSVCDIR)\VC\ATLMFC\INCLUDE" -I"C:\Program Files (x86)\$(MSVCDIR)\VC\INCLUDE" -I"$(WINDOWSSDKDIR)/Include" -I"C:\Program Files (x86)\$(MSVCDIR)\VC\PlatformSDK\include" -I"C:\Program Files (x86)\$(MSVCDIR)\SDK\v2.0\include"
MSVCLIB=/LIBPATH:"C:\Program Files (x86)\$(MSVCPATH)\VC\ATLMFC\LIB\amd64" /LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\VC\LIB\amd64" /LIBPATH:"$(WINDOWSSDKDIR)\lib\amd64" /LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\SDK\v2.0\LIB\AMD64" /LIBPATH:"$(WINDOWSSDKDIR)\lib\x64"
JPEGLIB=libs/libjpeg$(BITS).lib
else
WINDRES=i686-w64-mingw32-windres
MSVCPATH=C:/Program Files (x86)/$(MSVCDIR)/VC/BIN/
MSVCINC=-I"C:\Program Files (x86)\$(MSVCDIR)\VC\ATLMFC\INCLUDE" -I"C:\Program Files (x86)\$(MSVCDIR)\VC\INCLUDE" -I"$(WINDOWSSDKDIR)/Include" -I"C:\Program Files (x86)\$(MSVCDIR)\VC\PlatformSDK\include" -I"C:\Program Files (x86)\$(MSVCDIR)\SDK\v2.0\include"
MSVCLIB=/LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\VC\ATLMFC\LIB" /LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\VC\LIB" /LIBPATH:"$(WINDOWSSDKDIR)\lib" /LIBPATH:"C:\Program Files (x86)\$(MSVCDIR)\SDK\v2.0\LIB"
JPEGLIB=libs/jpeg.lib
endif
endif endif
#our msvc library naming still assumes 32bit and thus no postfix for that target (microsoft usually reuse '32' for 64bit libraries too...).
ifeq ($(BITS),32)
LIBBITS=
else
LIBBITS=$(BITS)
endif
#evil lameness.
LIBS_DIR=./libs/
ifeq ($(BITS),64)
MSVC_ARCH=amd64/
WINSDK_ARCH=x64/
WINEPATH=
else
MSVC_ARCH=
WINSDK_ARCH=
WINEPATH=$(MSVCPATH)../Common7/IDE/
endif
LIBOPUS_STATIC=
#-I"$(MSVCPATH)/ATLMFC/INCLUDE"
MSVCINC+=-I"$(shell winepath -w "$(MSVCPATH)INCLUDE")"
MSVCINC+=-I"$(shell winepath -w "$(WINDOWSSDKDIR)/Include")"
#-I"$(MSVCPATH)PlatformSDK/include"
#-I"$(MSVCPATH)../SDK/v2.0/include"
MSVCLIB+=/libpath:"$(call FIXPATH,$(MSVCPATH)lib/$(MSVC_ARCH))"
MSVCLIB+=/libpath:"$(call FIXPATH,$(WINDOWSSDKDIR)Lib/$(WINSDK_ARCH))"
MSVCLIB+=/libpath:"$(call FIXPATH,$(LIBS_DIR))"
ARCHLIBS:=$(call FIXPATH,$(ARCHLIBS))
MSVCINC:=$(MSVCINC)
DO_WINDRES=$(DO_ECHO) $(WINDRES) /nologo $(BRANDFLAGS) $(MSVCINC) -I$(call FIXPATH,$(CLIENT_DIR)) -fo $(call FIXPATH,$@) $(call FIXPATH,$<)
WINDRES=$(call INVOKE,$(WINDOWSSDKDIR)Bin/$(WINSDK_ARCH)RC.exe)
LINK:=$(call INVOKE,$(MSVCPATH)/bin/$(MSVC_ARCH)link.exe)
CC:=$(call INVOKE,$(MSVCPATH)/bin/$(MSVC_ARCH)cl.exe) $(MSVCINC) -DMSVCLIBSPATH=libs/
CXX=$(CC)
#library stuff... we'll be breaking attempts to statically link because deps are too painful otherwise.
BASELDFLAGS=
CLIENTLIBFLAGS=
SERVERLIBFLAGS=
CLIENTLDDEPS=
SERVERLDDEPS=
#override various flags that expected gcc.
DEBUG_CFLAGS = -Od $(CPUOPTIMIZATIONS) /fp:fast
RELEASE_CFLAGS = -O2 -Gy -GS- $(CPUOPTIMIZATIONS) /fp:fast
RELEASE_LDFLAGS = /LTCG
#we need some command tweaks.
DO_CC=$(DO_ECHO) $(CC) /nologo $(ALL_CFLAGS) -Fo"$(call FIXPATH,$@)" -c "$(call FIXPATH,$<)"
DO_CXX=$(DO_ECHO) $(CXX) /nologo $(ALL_CFLAGS) -Fo"$(call FIXPATH,$@)" -c "$(call FIXPATH,$<)"
DO_LD=$(DO_ECHO) PATH="$(MSVCPATH)/Common7/IDE:$(PATH)" $(LINK) /nologo /out:"$(call FIXPATH,$@)" /nodefaultlib:libc.lib /LARGEADDRESSAWARE /nodefaultlib:MSVCRT $(MSVCLIB) $(SDKLIB) /manifest:no /OPT:REF wsock32.lib user32.lib kernel32.lib advapi32.lib winmm.lib libs/zlib$(LIBBITS).lib shell32.lib
STRIP=@echo SKIP: strip STRIP=@echo SKIP: strip
EXEPOSTFIX=.exe EXEPOSTFIX=.exe
CC=PATH="C:\Program Files (x86)\$(MSVCDIR)\Common7\IDE" "$(MSVCPATH)cl" $(SDKINC) $(MSVCINC) -D_CRT_SECURE_NO_WARNINGS #gotta work around a whole load of paths.
CXX=PATH="C:\Program Files (x86)\$(MSVCDIR)\Common7\IDE" "$(MSVCPATH)cl" $(SDKINC) $(MSVCINC) -D_CRT_SECURE_NO_WARNINGS BASE_CFLAGS:=$(WARNINGFLAGS) $(GNUC_FUNCS) -I$(call FIXPATH,$(CLIENT_DIR)) -I$(call FIXPATH,$(SERVER_DIR)) -I$(call FIXPATH,$(COMMON_DIR)) -I$(call FIXPATH,$(GL_DIR)) -I$(call FIXPATH,$(D3D_DIR)) -I$(call FIXPATH,$(PROGS_DIR)) -I. -I$(LIBS_DIR) -I$(LIBS_DIR)/dxsdk9/include -I$(LIBS_DIR)/dxsdk7/include $(SDL_INCLUDES) $(BOTLIB_CFLAGS) $(SVNREVISION)
DEBUG_CFLAGS ?= -Od $(CPUOPTIMIZATIONS) /fp:fast
PROFILE_CFLAGS = -O2 -Ot -Ox -GL $(CPUOPTIMISATIONS) /fp:fast
PROFILE_LDFLAGS = /LTCG:PGINSTRUMENT
RELEASE_CFLAGS = -O2 -Ot -Ox -GL -GS- -Gr $(CPUOPTIMIZATIONS) /fp:fast
RELEASE_LDFLAGS = /LTCG
# /LTCG:PGOPTIMIZE
DO_CC=$(DO_ECHO) $(CC) /nologo $(ALL_CFLAGS) -Fo$(shell cygpath -m $@) -c $(shell cygpath -m $<)
DO_CXX=$(DO_ECHO) $(CXX) /nologo $(ALL_CFLAGS) -Fo$(shell cygpath -m $@) -c $(shell cygpath -m $<) #this stuff isn't supported.
DO_LD=$(DO_ECHO) PATH="C:\Program Files (x86)\$(MSVCDIR)\Common7\IDE" "$(MSVCPATH)link" /nologo /out:"$(shell cygpath -m $@)" /nodefaultlib:libc.lib /LARGEADDRESSAWARE /nodefaultlib:MSVCRT $(MSVCLIB) $(SDKLIB) /manifest:no /OPT:REF wsock32.lib user32.lib kernel32.lib advapi32.lib winmm.lib libs/zlib$(BITS).lib shell32.lib PRECOMPHEADERS=
PRECOMPHEADERS =
DEPCC= DEPCC=
DEPCXX= DEPCXX=
LIBS_DIR=./libs/ #dedicated server stuff
BASE_CFLAGS:=$(WARNINGFLAGS) $(GNUC_FUNCS) -I$(shell cygpath -m $(CLIENT_DIR)) -I$(shell cygpath -m $(SERVER_DIR)) -I$(shell cygpath -m $(COMMON_DIR)) -I$(shell cygpath -m $(GL_DIR)) -I$(shell cygpath -m $(D3D_DIR)) -I$(shell cygpath -m $(PROGS_DIR)) -I. -I$(LIBS_DIR) -I$(LIBS_DIR)/dxsdk9/include -I$(LIBS_DIR)/dxsdk7/include $(SDL_INCLUDES) $(BOTLIB_CFLAGS) $(SVNREVISION)
SV_CFLAGS=$(SERVER_ONLY_CFLAGS) $(W32_CFLAGS) -DMULTITHREAD -DMSVCLIBPATH=libs/ SV_CFLAGS=$(SERVER_ONLY_CFLAGS) $(W32_CFLAGS) -DMULTITHREAD -DMSVCLIBPATH=libs/
SV_EXE_NAME=../$(EXE_NAME)-sv$(BITS)$(EXEPOSTFIX) SV_EXE_NAME=../$(EXE_NAME)-sv$(BITS)$(EXEPOSTFIX)
SV_DIR=sv_vc$(BITS) SV_DIR=sv_vc$(BITS)
SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(BOTLIB_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o resources.o SV_OBJS=$(COMMON_OBJS) $(SERVER_OBJS) $(BOTLIB_OBJS) $(PROGS_OBJS) $(WINDOWSSERVERONLY_OBJS) fs_win32.o resources.o
SV_LDFLAGS=/subsystem:console SV_LDFLAGS=ole32.lib /subsystem:console
GL_EXE_NAME=../$(EXE_NAME)-gl$(BITS)$(EXEPOSTFIX) GL_EXE_NAME=../$(EXE_NAME)-gl$(BITS)$(EXEPOSTFIX)
GLCL_EXE_NAME=../$(EXE_NAME)-mingl$(BITS) GLCL_EXE_NAME=../$(EXE_NAME)-mingl$(BITS)
@ -1330,6 +1361,14 @@ ifeq ($(FTE_TARGET),vc)
MINGL_DIR=mingl_vc$(BITS) MINGL_DIR=mingl_vc$(BITS)
MINGL_EXE_NAME=../$(EXE_NAME)-mingl$(BITS)$(EXEPOSTFIX) MINGL_EXE_NAME=../$(EXE_NAME)-mingl$(BITS)$(EXEPOSTFIX)
VKCL_OBJS=$(VKQUAKE_OBJS) $(D3DGL_OBJS) $(BOTLIB_OBJS) gl_bloom.o gl_vidnt.o $(WINDOWS_OBJS)
VK_EXE_NAME=../$(EXE_NAME)-vk$(BITS)$(EXEPOSTFIX)
VKCL_EXE_NAME=../$(EXE_NAME)-vkcl$(BITS)$(EXEPOSTFIX)
VK_CFLAGS=$(VKCFLAGS) $(CLIENTLIBFLAGS) $(DX7SDK) -DMULTITHREAD -DMSVCLIBPATH=libs/
VK_LDFLAGS=$(JPEGLIB) libs/libpng$(BITS).lib uuid.lib gdi32.lib ole32.lib /subsystem:windows
VKB_DIR=vk_vc$(BITS)
VKCL_DIR=vkcl_vc$(BITS)
D3DCL_OBJS=$(D3DQUAKE_OBJS) $(D3DGL_OBJS) $(BOTLIB_OBJS) $(WINDOWS_OBJS) D3DCL_OBJS=$(D3DQUAKE_OBJS) $(D3DGL_OBJS) $(BOTLIB_OBJS) $(WINDOWS_OBJS)
D3D_EXE_NAME=../$(EXE_NAME)-d3d$(BITS)$(EXEPOSTFIX) D3D_EXE_NAME=../$(EXE_NAME)-d3d$(BITS)$(EXEPOSTFIX)
D3DCL_EXE_NAME=../$(EXE_NAME)-d3dcl$(BITS)$(EXEPOSTFIX) D3DCL_EXE_NAME=../$(EXE_NAME)-d3dcl$(BITS)$(EXEPOSTFIX)
@ -1337,12 +1376,15 @@ ifeq ($(FTE_TARGET),vc)
D3D_CFLAGS=$(D3DCFLAGS) $(W32_CFLAGS) $(DX7SDK) -DMULTITHREAD -DMSVCLIBPATH=libs/ D3D_CFLAGS=$(D3DCFLAGS) $(W32_CFLAGS) $(DX7SDK) -DMULTITHREAD -DMSVCLIBPATH=libs/
D3DB_DIR=d3d_vc$(BITS) D3DB_DIR=d3d_vc$(BITS)
D3DCL_DIR=d3dcl_vc$(BITS) D3DCL_DIR=d3dcl_vc$(BITS)
#merged client stuff
MCL_OBJS=$(D3DGL_OBJS) $(GLQUAKE_OBJS) $(SOFTWARE_OBJS) $(D3DQUAKE_OBJS) $(BOTLIB_OBJS) gl_vidnt.o gl_videgl.o $(WINDOWS_OBJS)
M_EXE_NAME=../$(EXE_NAME)$(BITS)$(EXEPOSTFIX) M_EXE_NAME=../$(EXE_NAME)$(BITS)$(EXEPOSTFIX)
MCL_OBJS=$(GL_OBJS) $(D3DGL_OBJS) $(D3DQUAKE_OBJS) $(GLQUAKE_OBJS) gl_vidnt.o $(BOTLIB_OBJS) $(WINDOWS_OBJS) MCL_EXE_NAME=../$(EXE_NAME)cl$(BITS)$(EXEPOSTFIX)
M_CFLAGS=$(D3DCFLAGS) $(GLCFLAGS) $(W32_CFLAGS) $(D3DCFLAGS) -DMULTITHREAD -DMSVCLIBPATH=libs/ M_CFLAGS=$(GLCFLAGS) $(W32_CFLAGS) $(D3DCFLAGS) $(DX7SDK) $(VKCFLAGS) -DMULTITHREAD $(CLIENTLIBFLAGS)
MB_DIR=m_vc$(BITS) MB_DIR=m_vc$(BITS)
M_LDFLAGS=$(GLLDFLAGS) $(JPEGLIB) libs/libpng$(BITS).lib uuid.lib gdi32.lib ole32.lib /subsystem:windows MCL_DIR=mcl_vc$(BITS)
M_LDFLAGS=$(GLLDFLAGS) $(JPEGLIB) libs/libpng$(LIBBITS).lib uuid.lib gdi32.lib ole32.lib /subsystem:windows
endif endif
#FTE_TARGET=win32 | FTE_TARGET=win64 (MinGW32 | MinGW64) #FTE_TARGET=win32 | FTE_TARGET=win64 (MinGW32 | MinGW64)
@ -1787,7 +1829,11 @@ SV_DIR?=sv_sdl
DEPCC?=$(CC) DEPCC?=$(CC)
DEPCXX?=$(CXX) DEPCXX?=$(CXX)
ARCH:=$(ARCH) ARCH:=$(ARCH)
BASELDFLAGS:=-L$(ARCHLIBS) $(BASELDFLAGS) ifeq ($(findstring msvc,$(FTE_TARGET)),msvc)
BASELDFLAGS:=/libpath:"$(ARCHLIBS)" $(BASELDFLAGS)
else
BASELDFLAGS:=-L$(ARCHLIBS) $(BASELDFLAGS)
endif
default: help default: help
-include Makefile_private -include Makefile_private
@ -1829,14 +1875,16 @@ endif
VPATH = $(BASE_DIR) : $(CLIENT_DIR) : $(GL_DIR) : $(SW_DIR) : $(COMMON_DIR) : $(SERVER_DIR) : $(HTTP_DIR) : $(BASE_DIR)/irc : $(BASE_DIR)/email : $(QUX_DIR) : $(PROGS_DIR) : $(NACL_DIR) : $(D3D_DIR) : $(VK_DIR) : $(BOTLIB_DIR) : $(BASE_DIR)/web VPATH = $(BASE_DIR) : $(CLIENT_DIR) : $(GL_DIR) : $(SW_DIR) : $(COMMON_DIR) : $(SERVER_DIR) : $(HTTP_DIR) : $(BASE_DIR)/irc : $(BASE_DIR)/email : $(QUX_DIR) : $(PROGS_DIR) : $(NACL_DIR) : $(D3D_DIR) : $(VK_DIR) : $(BOTLIB_DIR) : $(BASE_DIR)/web
DO_WINDRES?=$(DO_ECHO) $(WINDRES) $(BRANDFLAGS) -I$(CLIENT_DIR) -O coff $< $@
# This is for linking the FTE icon to the MinGW target # This is for linking the FTE icon to the MinGW target
$(OUT_DIR)/resources.o : winquake.rc $(OUT_DIR)/resources.o : winquake.rc
@$(WINDRES) $(BRANDFLAGS) -I$(CLIENT_DIR) -O coff $< $@ $(DO_WINDRES)
$(OUT_DIR)/fteqcc.o : fteqcc.rc $(OUT_DIR)/fteqcc.o : fteqcc.rc
@$(WINDRES) $(BRANDFLAGS) -I$(PROGS_DIR) -O coff $< $@ $(DO_WINDRES)
#npAPI stuff requires some extra resources #npAPI stuff requires some extra resources
$(OUT_DIR)/npplug.o : ftequake/npplug.rc $(OUT_DIR)/npplug.o : ftequake/npplug.rc
@$(WINDRES) $(BRANDFLAGS) -I$(CLIENT_DIR) -O coff $< $@ $(DO_WINDRES)
#$(OUT_DIR)/%.d: %.c #$(OUT_DIR)/%.d: %.c
@ -2203,8 +2251,12 @@ nacl-dbg:
################################################# #################################################
#webgl helpers #webgl helpers
ifneq ($(shell which emcc 2> /dev/null),)
EMCC?=emcc
else
#EMCC?=/opt/emsdk_portable/emscripten/master/emcc #EMCC?=/opt/emsdk_portable/emscripten/master/emcc
EMCC?=emcc.bat --em-config $(shell cygpath -m $(USERPROFILE))/.emscripten EMCC?=emcc.bat --em-config $(shell cygpath -m $(USERPROFILE))/.emscripten
endif
ifeq ($(EMSDK),) ifeq ($(EMSDK),)
#just adds some extra paths (WINDOWS HOST ONLY) #just adds some extra paths (WINDOWS HOST ONLY)
#assumes you installed the emscripten 1.22.0 sdk to EMSCRIPTENROOT #assumes you installed the emscripten 1.22.0 sdk to EMSCRIPTENROOT
@ -2263,32 +2315,25 @@ else
endif endif
droid-rel: droid-rel:
$(MAKE) FTE_TARGET=droid droid/build.xml droid/ftekeystore @$(MAKE) FTE_TARGET=droid droid/build.xml droid/ftekeystore
$(foreach a, $(DROID_ARCH), $(MAKE) FTE_TARGET=droid m-rel plugins-rel DROID_ARCH=$a NATIVE_PLUGINS="$(NATIVE_PLUGINS)"; ) @$(foreach a, $(DROID_ARCH), $(MAKE) FTE_TARGET=droid m-rel plugins-rel DROID_ARCH=$a NATIVE_PLUGINS="$(NATIVE_PLUGINS)"; )
-rm -rf droid/libs @-rm -rf droid/libs
@$(foreach a, $(DROID_ARCH), mkdir -p droid/libs/$a; ) @$(foreach a, $(DROID_ARCH), mkdir -p droid/libs/$a; )
-@$(foreach a, $(DROID_ARCH), cp $(RELEASE_DIR)/m_droid-$a/*.so droid/libs/$a/; ) -@$(foreach a, $(DROID_ARCH), cp $(RELEASE_DIR)/m_droid-$a/*.so droid/libs/$a/; )
@cd droid && $(ANT) release @cd droid && $(ANT) -q release
ifneq ($(DROID_PACKSU),) ifneq ($(DROID_PACKSU),)
@echo
@echo Adding custom data files - non-compressed @echo Adding custom data files - non-compressed
@echo
zip droid/bin/FTEDroid-release-unsigned.apk -0 -j $(DROID_PACKSU) zip droid/bin/FTEDroid-release-unsigned.apk -0 -j $(DROID_PACKSU)
endif endif
ifneq ($(DROID_PACKSC),) ifneq ($(DROID_PACKSC),)
@echo
@echo Adding custom data files - compressed @echo Adding custom data files - compressed
@echo
zip droid/bin/FTEDroid-release-unsigned.apk -9 -j $(DROID_PACKSC) zip droid/bin/FTEDroid-release-unsigned.apk -9 -j $(DROID_PACKSC)
endif endif
@echo
@echo
@echo Signing package... I hope you remember your password. @echo Signing package... I hope you remember your password.
@echo
@$(JAVATOOL)jarsigner $(JARSIGNARGS) -digestalg SHA1 -sigalg MD5withRSA -keystore droid/ftekeystore droid/bin/FTEDroid-release-unsigned.apk autogen @$(JAVATOOL)jarsigner $(JARSIGNARGS) -digestalg SHA1 -sigalg MD5withRSA -keystore droid/ftekeystore droid/bin/FTEDroid-release-unsigned.apk autogen
-rm -f $(RELEASE_DIR)/FTEDroid.apk @-rm -f $(RELEASE_DIR)/FTEDroid.apk
$(ANDROID_ZIPALIGN) 4 droid/bin/FTEDroid-release-unsigned.apk $(NATIVE_RELEASE_DIR)/FTEDroid.apk @$(ANDROID_ZIPALIGN) 4 droid/bin/FTEDroid-release-unsigned.apk $(NATIVE_RELEASE_DIR)/FTEDroid.apk
droid-opt: droid-opt:
$(MAKE) FTE_TARGET=droid droid/build.xml droid/ftekeystore $(MAKE) FTE_TARGET=droid droid/build.xml droid/ftekeystore

View File

@ -1053,6 +1053,9 @@ int AAS_Reachability_EqualFloorHeight(int area1num, int area2num)
// Returns: - // Returns: -
// Changes Globals: - // Changes Globals: -
//=========================================================================== //===========================================================================
#ifdef _MSC_VER
#pragma optimize("", off) //work around msvc ICE
#endif
int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2num) int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2num)
{ {
int i, j, k, l, edge1num, edge2num, areas[10], numareas; int i, j, k, l, edge1num, edge2num, areas[10], numareas;
@ -1595,6 +1598,9 @@ int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2
} //end if } //end if
return qfalse; return qfalse;
} //end of the function AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge } //end of the function AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge
#ifdef _MSC_VER
#pragma optimize("", on) //work around msvc ICE
#endif
//=========================================================================== //===========================================================================
// returns the distance between the two vectors // returns the distance between the two vectors
// //

View File

@ -913,7 +913,6 @@ static qintptr_t UI_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con
{ {
static int overstrikemode; static int overstrikemode;
int ret=0; int ret=0;
char adrbuf[MAX_ADR_SIZE];
//Remember to range check pointers. //Remember to range check pointers.
//The QVM must not be allowed to write to anything outside it's memory. //The QVM must not be allowed to write to anything outside it's memory.
@ -1454,6 +1453,7 @@ static qintptr_t UI_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, con
{ {
char *buf = VM_POINTER(arg[2]); char *buf = VM_POINTER(arg[2]);
char *adr; char *adr;
char adrbuf[MAX_ADR_SIZE];
serverinfo_t *info = Master_InfoForNum(VM_LONG(arg[1])); serverinfo_t *info = Master_InfoForNum(VM_LONG(arg[1]));
if (info) if (info)
{ {

View File

@ -3143,7 +3143,7 @@ void Con_DrawConsole (int lines, qboolean noback)
for (i = 0; i < countof(buttons); i++) for (i = 0; i < countof(buttons); i++)
{ {
if (i == countof(buttons)-1) if (i == countof(buttons)-1)
tw = ~0u; tw = FLT_MAX;
else if (i == countof(buttons)-2) else if (i == countof(buttons)-2)
{ {
tw = 8+8; tw = 8+8;

View File

@ -1331,6 +1331,7 @@ qboolean WriteTGA(const char *filename, enum fs_relative fsroot, const qbyte *ft
#define png_const_bytep png_bytep #define png_const_bytep png_bytep
#define png_const_unknown_chunkp png_unknown_chunkp #define png_const_unknown_chunkp png_unknown_chunkp
#define png_const_textp png_textp #define png_const_textp png_textp
#define png_const_colorp png_colorp
#endif #endif
#if PNG_LIBPNG_VER < 10600 #if PNG_LIBPNG_VER < 10600
#define png_inforp png_infop #define png_inforp png_infop
@ -8838,9 +8839,11 @@ static void Image_Tr_PalettedtoRGBX8(struct pendingtextureinfo *mips, int alphap
} }
//may operate in place //may operate in place
static void Image_Tr_RGBX8toPaletted(struct pendingtextureinfo *mips, int dummy) static void Image_Tr_RGBX8toPaletted(struct pendingtextureinfo *mips, int args)
{ {
unsigned int mip; unsigned int mip;
int first=args&0xffff;
int stop=(args>>16)&0xffff;
for (mip = 0; mip < mips->mipcount; mip++) for (mip = 0; mip < mips->mipcount; mip++)
{ {
qbyte *in = mips->mip[mip].data; qbyte *in = mips->mip[mip].data;
@ -8855,7 +8858,7 @@ static void Image_Tr_RGBX8toPaletted(struct pendingtextureinfo *mips, int dummy)
mips->mip[mip].datasize = p*sizeof(*out); mips->mip[mip].datasize = p*sizeof(*out);
for(; p-->0; in += 4) for(; p-->0; in += 4)
*out++ = GetPaletteIndexNoFB(in[0], in[1], in[2]); *out++ = GetPaletteIndexRange(first, stop, in[0], in[1], in[2]);
} }
} }
@ -12221,7 +12224,9 @@ static struct
{PTI_RGBA32F, PTI_RGB32F, Image_Tr_DropBytes, (16<<16)|12, true}, {PTI_RGBA32F, PTI_RGB32F, Image_Tr_DropBytes, (16<<16)|12, true},
{PTI_RG8, PTI_RGBX8, Image_Tr_RG8ToRGXX8}, {PTI_RG8, PTI_RGBX8, Image_Tr_RG8ToRGXX8},
{PTI_RGBX8, PTI_P8, Image_Tr_RGBX8toPaletted}, {PTI_RGBX8, PTI_P8, Image_Tr_RGBX8toPaletted, 0},
{PTI_RGBX8, TF_H2_TRANS8_0, Image_Tr_RGBX8toPaletted, 1|(255<<16)},
{PTI_RGBX8, TF_TRANS8, Image_Tr_RGBX8toPaletted, 0|(254<<16)},
{PTI_P8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1}, {PTI_P8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1},
{TF_SOLID8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1}, {TF_SOLID8, PTI_RGBX8, Image_Tr_PalettedtoRGBX8, -1},
{TF_H2_TRANS8_0,PTI_RGBA8, Image_Tr_PalettedtoRGBX8, 0}, {TF_H2_TRANS8_0,PTI_RGBA8, Image_Tr_PalettedtoRGBX8, 0},
@ -12899,7 +12904,7 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
if (flags & IF_NOALPHA) if (flags & IF_NOALPHA)
{ {
switch(mips->encoding) safeswitch(mips->encoding)
{ {
case PTI_RGBA8: case PTI_RGBA8:
mips->encoding = PTI_RGBX8; mips->encoding = PTI_RGBX8;
@ -13063,7 +13068,9 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
case PTI_DEPTH24_8: case PTI_DEPTH24_8:
break; break;
case PTI_EMULATED: case PTI_EMULATED:
case PTI_MAX: break; //stfu case PTI_MAX:
safedefault:
break; //stfu
} }
//FIXME: fill alpha channel with 255? //FIXME: fill alpha channel with 255?
} }

View File

@ -261,23 +261,23 @@ extern "C" {
#if (_MSC_VER >= 1900) #if (_MSC_VER >= 1900)
// MSVC 14 has standardized snprintf functions, hurrah! // MSVC 14 has standardized snprintf functions, hurrah!
#elif (_MSC_VER >= 1400) #elif (_MSC_VER >= 1400)
//with MSVC 8, use MS extensions. return values are still wrong. //with MSVC 8, use microsoft's vsnprintf_s. return values are still wrong though.
#define snprintf linuxlike_snprintf_vc8 #define snprintf (void)linuxlike_snprintf_vc8
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3); int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d) #define vsnprintf(a, b, c, d) (void)(vsnprintf_s(a, b, _TRUNCATE, c, d))
#else #else
//msvc crap. return values are wrong but at least we can null terminate it safely. //msvc crap. return values are wrong but at least we can null terminate it safely.
#define snprintf linuxlike_snprintf #define snprintf (void)linuxlike_snprintf
int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3); int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf linuxlike_vsnprintf #define vsnprintf (void)linuxlike_vsnprintf
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr); int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
#endif #endif
#ifdef _MSC_VER #ifdef _MSC_VER
//these are provided so we don't use them //these are provided so we don't use them
//but mingw has some defines elsewhere and makes gcc moan //but mingw has some defines elsewhere and makes gcc moan
#define _vsnprintf unsafe_vsnprintf // #define _vsnprintf unsafe_vsnprintf
#define _snprintf unsafe_snprintf // #define _snprintf unsafe_snprintf
#ifndef strcasecmp #ifndef strcasecmp
#define strcasecmp _stricmp #define strcasecmp _stricmp

View File

@ -2900,7 +2900,7 @@ void Surf_GenBrushBatches(batch_t **batches, entity_t *ent)
if (!(cl_dlights[k].flags & LFLAG_LIGHTMAP)) if (!(cl_dlights[k].flags & LFLAG_LIGHTMAP))
continue; continue;
model->funcs.MarkLights (&cl_dlights[k], 1<<k, model->rootnode); model->funcs.MarkLights (&cl_dlights[k], (dlightbitmask_t)1<<k, model->rootnode);
} }
} }

View File

@ -1173,7 +1173,7 @@ static void BIH_RecursiveTest (struct bihtrace_s *fte_restrict tr, const struct
min = node->bihnode.cmin[1] - tr->expand[axis]; min = node->bihnode.cmin[1] - tr->expand[axis];
max = node->bihnode.cmax[1] + tr->expand[axis]; max = node->bihnode.cmax[1] + tr->expand[axis];
if (min <= tr->startpos[axis] && tr->startpos[axis] <= max) if (min <= tr->startpos[axis] && tr->startpos[axis] <= max)
return BIH_RecursiveTest(tr, node+node->bihnode.firstchild+1); BIH_RecursiveTest(tr, node+node->bihnode.firstchild+1);
} }
return; return;
#endif #endif
@ -1199,7 +1199,7 @@ static void BIH_RecursiveTest (struct bihtrace_s *fte_restrict tr, const struct
min = node->bvhnode.cmin - tr->expand[axis]; min = node->bvhnode.cmin - tr->expand[axis];
max = node->bvhnode.max[axis] + tr->expand[axis]; max = node->bvhnode.max[axis] + tr->expand[axis];
if (min <= tr->startpos[axis] && tr->startpos[axis] <= max) if (min <= tr->startpos[axis] && tr->startpos[axis] <= max)
return CM_RecursiveBIHTest(tr, node+node->bvhnode.firstchild+1); CM_RecursiveBIHTest(tr, node+node->bvhnode.firstchild+1);
} }
return; return;
#endif #endif
@ -1467,6 +1467,7 @@ restart:
#endif #endif
} }
FTE_UNREACHABLE; FTE_UNREACHABLE;
return 0;
} }
static unsigned int BIH_PointContents(struct model_s *mod, const vec3_t axis[3], const vec3_t p) static unsigned int BIH_PointContents(struct model_s *mod, const vec3_t axis[3], const vec3_t p)
{ {

View File

@ -181,30 +181,54 @@ void QDECL Q_strncpyz(char *d, const char *s, int n)
*d='\0'; *d='\0';
} }
//windows/linux have inconsistant snprintf //returns true on truncation
//this is an attempt to get them consistant and safe qboolean VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
//size is the total size of the buffer
void VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
{ {
#ifdef _DEBUG size_t ret;
if ((size_t)vsnprintf (dest, size, fmt, argptr) > size-1) #ifdef _WIN32
Sys_Error("Q_vsnprintfz: truncation"); //doesn't null terminate.
//returns -1 on truncation
ret = _vsnprintf (dest, size, fmt, argptr);
dest[size-1] = 0; //shitty paranoia
#else #else
vsnprintf (dest, size, fmt, argptr); //always null terminates.
//returns length regardless of truncation.
ret = vsnprintf (dest, size, fmt, argptr);
#endif #endif
dest[size-1] = 0; #ifdef _DEBUG
if (ret>=size)
Sys_Error("Q_vsnprintfz: Truncation\n");
#endif
//if ret is -1 (windows oversize, or general error) then it'll be treated as unsigned so really long. this makes the following check quite simple.
return ret>=size;
} }
//windows/linux have inconsistant snprintf //windows/linux have inconsistant snprintf
//this is an attempt to get them consistant and safe //this is an attempt to get them consistant and safe
//size is the total size of the buffer //size is the total size of the buffer
void VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...) qboolean VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
size_t ret;
va_start (argptr, fmt); va_start (argptr, fmt);
Q_vsnprintfz(dest, size, fmt, argptr); #ifdef _WIN32
//doesn't null terminate.
//returns -1 on truncation
ret = _vsnprintf (dest, size, fmt, argptr);
dest[size-1] = 0; //shitty paranoia
#else
//always null terminates.
//returns length regardless of truncation.
ret = vsnprintf (dest, size, fmt, argptr);
#endif
va_end (argptr); va_end (argptr);
#ifdef _DEBUG
if (ret>=size)
Sys_Error("Q_vsnprintfz: Truncation\n");
#endif
//if ret is -1 (windows oversize, or general error) then it'll be treated as unsigned so really long. this makes the following check quite simple.
return ret>=size;
} }
@ -420,16 +444,13 @@ char *Q_strcasestr(const char *haystack, const char *needle)
return NULL; //didn't find it return NULL; //didn't find it
} }
int VARGS Com_sprintf(char *buffer, int size, const char *format, ...) void VARGS Com_sprintf(char *buffer, int size, const char *format, ...)
{ {
int ret;
va_list argptr; va_list argptr;
va_start (argptr, format); va_start (argptr, format);
ret = vsnprintf (buffer, size, format, argptr); Q_vsnprintfz (buffer, size, format, argptr);
va_end (argptr); va_end (argptr);
return ret;
} }
void QDECL Com_Error( int level, const char *error, ... ) void QDECL Com_Error( int level, const char *error, ... )
{ {
@ -8054,7 +8075,7 @@ int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...)
va_list argptr; va_list argptr;
if (size <= 0) if (size <= 0)
return 0; return !buffer?-1:0;
size--; size--;
va_start (argptr, format); va_start (argptr, format);
@ -8067,12 +8088,12 @@ int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...)
} }
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr) int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr)
{ { //_vsnprintf truncates WITHOUT NULL, and returns -1
#undef _vsnprintf #undef _vsnprintf
int ret; int ret;
if (size <= 0) if (size <= 0)
return 0; return !buffer?-1:0;
size--; size--;
ret = _vsnprintf (buffer,size, format,argptr); ret = _vsnprintf (buffer,size, format,argptr);
@ -8083,7 +8104,7 @@ int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_lis
} }
#else #else
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...)
{ { //vsnprintf_s safely truncates with null, but returns -1 on truncation rather than untruncated full length
int ret; int ret;
va_list argptr; va_list argptr;

View File

@ -82,6 +82,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define quintptr_t unsigned qintptr_t #define quintptr_t unsigned qintptr_t
#define quint64_t unsigned qint64_t #define quint64_t unsigned qint64_t
#endif #endif
#ifndef uint32_t
#define int16_t qint16_t
#define uint16_t quint16_t
#define int32_t qint32_t
#define uint32_t quint32_t
#define int64_t qint64_t
#define uint64_t quint64_t
#define intptr_t qintptr_t
#define uintptr_t quintptr_t
#endif
#endif #endif
#ifndef FTE_WORDSIZE #ifndef FTE_WORDSIZE
@ -384,9 +395,9 @@ int wildcmp(const char *wild, const char *string); //1 if match
#define Q_strcmp(s1, s2) strcmp((s1), (s2)) #define Q_strcmp(s1, s2) strcmp((s1), (s2))
#define Q_strncmp(s1, s2, n) strncmp((s1), (s2), (n)) #define Q_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
void VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...) LIKEPRINTF(3); qboolean VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...) LIKEPRINTF(3); //true means truncated (will also warn in debug builds).
void VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list args); qboolean VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list args); //true means truncated (will also warn in debug builds).
int VARGS Com_sprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3); void VARGS Com_sprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define Q_strncpyS(d, s, n) do{const char *____in=(s);char *____out=(d);int ____i; for (____i=0;*(____in); ____i++){if (____i == (n))break;*____out++ = *____in++;}if (____i < (n))*____out='\0';}while(0) //only use this when it should be used. If undiciided, use N #define Q_strncpyS(d, s, n) do{const char *____in=(s);char *____out=(d);int ____i; for (____i=0;*(____in); ____i++){if (____i == (n))break;*____out++ = *____in++;}if (____i < (n))*____out='\0';}while(0) //only use this when it should be used. If undiciided, use N
#define Q_strncpyN(d, s, n) do{if (n < 0)Sys_Error("Bad length in strncpyz");Q_strncpyS((d), (s), (n));((char *)(d))[n] = '\0';}while(0) //this'll stop me doing buffer overflows. (guarenteed to overflow if you tried the wrong size.) #define Q_strncpyN(d, s, n) do{if (n < 0)Sys_Error("Bad length in strncpyz");Q_strncpyS((d), (s), (n));((char *)(d))[n] = '\0';}while(0) //this'll stop me doing buffer overflows. (guarenteed to overflow if you tried the wrong size.)

View File

@ -592,7 +592,7 @@ static void QDECL VFSW32_BuildHash(searchpathfuncs_t *handle, int hashdepth, voi
wp->hashdepth = hashdepth; wp->hashdepth = hashdepth;
Sys_EnumerateFiles(wp->rootpath, "*", VFSW32_RebuildFSHash, AddFileHash, handle); Sys_EnumerateFiles(wp->rootpath, "*", VFSW32_RebuildFSHash, AddFileHash, handle);
} }
static unsigned int QDECL VFSW32_CreateLoc(searchpathfuncs_t *handle, flocation_t *loc, const char *filename) static qboolean QDECL VFSW32_CreateLoc(searchpathfuncs_t *handle, flocation_t *loc, const char *filename)
{ {
vfsw32path_t *wp = (void*)handle; vfsw32path_t *wp = (void*)handle;
char *ofs; char *ofs;
@ -601,7 +601,7 @@ static unsigned int QDECL VFSW32_CreateLoc(searchpathfuncs_t *handle, flocation_
loc->offset = 0; loc->offset = 0;
loc->fhandle = handle; loc->fhandle = handle;
loc->rawname[sizeof(loc->rawname)-1] = 0; loc->rawname[sizeof(loc->rawname)-1] = 0;
if ((unsigned int)snprintf (loc->rawname, sizeof(loc->rawname), "%s/%s", wp->rootpath, filename) > sizeof(loc->rawname)-1) if (Q_snprintfz (loc->rawname, sizeof(loc->rawname), "%s/%s", wp->rootpath, filename))
return FF_NOTFOUND; return FF_NOTFOUND;
for (ofs = loc->rawname+1 ; *ofs ; ofs++) for (ofs = loc->rawname+1 ; *ofs ; ofs++)
{ {
@ -639,7 +639,7 @@ static unsigned int QDECL VFSW32_FLocate(searchpathfuncs_t *handle, flocation_t
*/ */
// check a file in the directory tree // check a file in the directory tree
if ((unsigned int)snprintf (netpath, sizeof(netpath), "%s/%s", wp->rootpath, filename) > sizeof(loc->rawname)-1) if (Q_snprintfz (netpath, sizeof(netpath), "%s/%s", wp->rootpath, filename))
return FF_NOTFOUND; return FF_NOTFOUND;
if (!WinNT) if (!WinNT)

View File

@ -969,7 +969,7 @@ void Log_MapNowCompleted(void)
m = Z_Malloc(sizeof(*m)+strlen(packagename)+strlen(sv.world.worldmodel->name)+2); m = Z_Malloc(sizeof(*m)+strlen(packagename)+strlen(sv.world.worldmodel->name)+2);
sprintf(m->name, "%s/%s", packagename, sv.world.worldmodel->name); sprintf(m->name, "%s/%s", packagename, sv.world.worldmodel->name);
m->fulltime = m->besttime = INFINITY; m->fulltime = m->besttime = FLT_MAX;
m->bestkills = m->bestsecrets = 0; m->bestkills = m->bestsecrets = 0;
m->next = maplog_enties; m->next = maplog_enties;
maplog_enties = m; maplog_enties = m;

View File

@ -922,7 +922,7 @@ msurface_t *Mod_GetSurfaceNearPoint(model_t *model, pvec3_t point)
int i; int i;
pvec3_t cpoint = {0,0,0}; pvec3_t cpoint = {0,0,0};
float bestdist = 0x7fffffff, dist; float bestdist = FLT_MAX, dist;
msurface_t *bestsurf = NULL; msurface_t *bestsurf = NULL;
if (model->fromgame == fg_quake || model->fromgame == fg_quake2) if (model->fromgame == fg_quake || model->fromgame == fg_quake2)
@ -1003,13 +1003,13 @@ void QCBUILTIN PF_getsurfaceclippedpoint(pubprogfuncs_t *prinst, struct globalva
{ {
//all polies, we can skip parts. special case. //all polies, we can skip parts. special case.
surf = model->surfaces + model->firstmodelsurface + surfnum; surf = model->surfaces + model->firstmodelsurface + surfnum;
getsurface_clippointpoly(model, surf, point, result, 0x7fffffff); getsurface_clippointpoly(model, surf, point, result, FLT_MAX);
} }
else else
{ {
//if performance is needed, I suppose we could try walking bsp nodes a bit //if performance is needed, I suppose we could try walking bsp nodes a bit
surf = model->surfaces + model->firstmodelsurface + surfnum; surf = model->surfaces + model->firstmodelsurface + surfnum;
getsurface_clippointtri(model, surf, point, result, 0x7fffffff); getsurface_clippointtri(model, surf, point, result, FLT_MAX);
} }
} }

View File

@ -2112,7 +2112,7 @@ static void Q1BSP_ClustersInSphere_Union(mleaf_t *firstleaf, const vec3_t center
continue; continue;
} }
} }
static qbyte *Q1BSP_ClustersInSphere(model_t *mod, const vec3_t center, float radius, pvsbuffer_t *fte_restrict pvsbuffer, const qbyte *unionwith) static qbyte *Q1BSP_ClustersInSphere(model_t *mod, const vec3_t center, float radius, pvsbuffer_t *fte_restrict pvsbuffer, const qbyte *fte_restrict unionwith)
{ {
if (!mod) if (!mod)
Sys_Error ("Mod_PointInLeaf: bad model"); Sys_Error ("Mod_PointInLeaf: bad model");

View File

@ -132,19 +132,19 @@ static void sha2trunc_init (void *context)
hd->count = 0; hd->count = 0;
} }
static inline u64 fte_inlinestatic u64
ROTR (u64 x, u64 n) ROTR (u64 x, u64 n)
{ {
return ((x >> n) | (x << (64 - n))); return ((x >> n) | (x << (64 - n)));
} }
static inline u64 fte_inlinestatic u64
Ch (u64 x, u64 y, u64 z) Ch (u64 x, u64 y, u64 z)
{ {
return ((x & y) ^ ( ~x & z)); return ((x & y) ^ ( ~x & z));
} }
static inline u64 fte_inlinestatic u64
Maj (u64 x, u64 y, u64 z) Maj (u64 x, u64 y, u64 z)
{ {
return ((x & y) ^ (x & z) ^ (y & z)); return ((x & y) ^ (x & z) ^ (y & z));
@ -156,13 +156,13 @@ Maj (u64 x, u64 y, u64 z)
#define S0(x) (ROTR((x),7) ^ ROTR((x),18) ^ ((x)>>3)) #define S0(x) (ROTR((x),7) ^ ROTR((x),18) ^ ((x)>>3))
#define S1(x) (ROTR((x),17) ^ ROTR((x),19) ^ ((x)>>10)) #define S1(x) (ROTR((x),17) ^ ROTR((x),19) ^ ((x)>>10))
static inline u64 fte_inlinestatic u64
Sum0 (u64 x) Sum0 (u64 x)
{ {
return (ROTR (x, 2) ^ ROTR (x, 13) ^ ROTR (x, 22)); return (ROTR (x, 2) ^ ROTR (x, 13) ^ ROTR (x, 22));
} }
static inline u64 fte_inlinestatic u64
Sum1 (u64 x) Sum1 (u64 x)
{ {
return (ROTR (x, 6) ^ ROTR (x, 11) ^ ROTR (x, 25)); return (ROTR (x, 6) ^ ROTR (x, 11) ^ ROTR (x, 25));
@ -171,13 +171,13 @@ Sum1 (u64 x)
#define S0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7)) #define S0(x) (ROTR((x),1) ^ ROTR((x),8) ^ ((x)>>7))
#define S1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6)) #define S1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))
static inline u64 fte_inlinestatic u64
Sum0 (u64 x) Sum0 (u64 x)
{ {
return (ROTR (x, 28) ^ ROTR (x, 34) ^ ROTR (x, 39)); return (ROTR (x, 28) ^ ROTR (x, 34) ^ ROTR (x, 39));
} }
static inline u64 fte_inlinestatic u64
Sum1 (u64 x) Sum1 (u64 x)
{ {
return (ROTR (x, 14) ^ ROTR (x, 18) ^ ROTR (x, 41)); return (ROTR (x, 14) ^ ROTR (x, 18) ^ ROTR (x, 41));

View File

@ -106,9 +106,9 @@ qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refres
#define FTE_Atomic32_Inc(ptr) __sync_add_and_fetch(ptr, 1) //returns the AFTER the operation. #define FTE_Atomic32_Inc(ptr) __sync_add_and_fetch(ptr, 1) //returns the AFTER the operation.
#define FTE_Atomic32_Dec(ptr) __sync_add_and_fetch(ptr, 1) //returns the AFTER the operation. #define FTE_Atomic32_Dec(ptr) __sync_add_and_fetch(ptr, 1) //returns the AFTER the operation.
#elif defined(_WIN32) #elif defined(_WIN32)
#define qatomic32_t LONG #define qatomic32_t long
#define FTE_Atomic32_Inc(ptr) InterlockedIncrement(ptr) #define FTE_Atomic32_Inc(ptr) _InterlockedIncrement(ptr)
#define FTE_Atomic32_Dec(ptr) InterlockedDecrement(ptr) #define FTE_Atomic32_Dec(ptr) _InterlockedDecrement(ptr)
#else #else
#define qatomic32_t qint32_t #define qatomic32_t qint32_t
#define FTE_Atomic32_Inc(ptr) FTE_Atomic32Mutex_Add(ptr, 1) #define FTE_Atomic32_Inc(ptr) FTE_Atomic32Mutex_Add(ptr, 1)

View File

@ -222,6 +222,23 @@ char *Z_StrDupf(const char *format, ...)
char *string; char *string;
int n; int n;
#if defined(_MSC_VER) || defined(_WIN32)
int try;
//msvc is shitty shit shit and doesn't even do c99. sadly mingw uses the same libraries.
try = 256;
for(;;)
{
string = Z_Malloc(try+1);
va_start (argptr, format);
n = _vsnprintf (string,try, format,argptr);
va_end (argptr);
if (n >= 0 && n < try)
break;
Z_Free(string);
try *= 2;
}
string[n] = 0;
#else
va_start (argptr, format); va_start (argptr, format);
n = vsnprintf (NULL,0, format,argptr); n = vsnprintf (NULL,0, format,argptr);
va_end (argptr); va_end (argptr);
@ -233,6 +250,7 @@ char *Z_StrDupf(const char *format, ...)
vsnprintf (string,n+1, format,argptr); vsnprintf (string,n+1, format,argptr);
va_end (argptr); va_end (argptr);
string[n] = 0; string[n] = 0;
#endif
return string; return string;
} }

View File

@ -2718,6 +2718,10 @@ qboolean Sh_GenerateShadowMap(dlight_t *l, int lighttype)
return true; return true;
} }
#ifdef _MSC_VER
#define round(a) floor((a)+0.5)
#endif
void Sh_OrthoAlignToFrustum(dlight_t *dl, int smsize) void Sh_OrthoAlignToFrustum(dlight_t *dl, int smsize)
{ {
vec3_t neworg; vec3_t neworg;

View File

@ -88,19 +88,34 @@ void Q_strncpyz(char *d, const char *s, int n)
*d='\0'; *d='\0';
} }
void VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...) qboolean VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
{ {
va_list args; size_t ret;
va_start (args, fmt);
#ifdef _WIN32 #ifdef _WIN32
#undef _vsnprintf //doesn't null terminate.
_vsnprintf (dest, size-1, fmt, args); //returns -1 on truncation
ret = _vsnprintf (dest, size, fmt, argptr);
dest[size-1] = 0; //shitty paranoia
#else #else
vsnprintf (dest, size-1, fmt, args); //always null terminates.
//returns length regardless of truncation.
ret = vsnprintf (dest, size, fmt, argptr);
#endif #endif
va_end (args); #ifdef _DEBUG
//make sure its terminated. if (ret>=size)
dest[size-1] = 0; Sys_Error("Q_vsnprintfz: Truncation\n");
#endif
//if ret is -1 (windows oversize, or general error) then it'll be treated as unsigned so really long. this makes the following check quite simple.
return ret>=size;
}
qboolean VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...)
{
va_list argptr;
qboolean ret;
va_start (argptr, fmt);
ret = Q_vsnprintfz(dest, size, fmt, argptr);
va_end (argptr);
return ret;
} }
/*char *va(char *format, ...) /*char *va(char *format, ...)

View File

@ -83,6 +83,7 @@ static void VARGS QC_snprintfz (char *dest, size_t size, const char *fmt, ...) L
//make sure its terminated. //make sure its terminated.
dest[size-1] = 0; dest[size-1] = 0;
} }
#define snprintf QC_snprintfz
#else #else
#define QC_vsnprintf vsnprintf #define QC_vsnprintf vsnprintf
#define QC_snprintfz snprintf #define QC_snprintfz snprintf

View File

@ -419,9 +419,9 @@ reeval:
break; break;
case OP_STOREP_I64: // 64bit case OP_STOREP_I64: // 64bit
i = OPB->_int + OPC->_int*sizeof(ptr->_int); i = OPB->_int + OPC->_int*sizeof(ptr->_int);
errorif (QCPOINTERWRITEFAIL(i, sizeof(ptr->_int64))) errorif (QCPOINTERWRITEFAIL(i, sizeof(ptr->i64)))
{ {
if (!(ptr=PR_GetWriteTempStringPtr(progfuncs, OPB->_int, OPC->_int*sizeof(ptr->_int), sizeof(ptr->_int64)))) if (!(ptr=PR_GetWriteTempStringPtr(progfuncs, OPB->_int, OPC->_int*sizeof(ptr->_int), sizeof(ptr->i64))))
{ {
if (i == -1) if (i == -1)
break; break;
@ -433,7 +433,7 @@ reeval:
} }
else else
ptr = QCPOINTERM(i); ptr = QCPOINTERM(i);
ptr->_int64 = OPA->_int64; ptr->i64 = OPA->i64;
break; break;
case OP_STOREP_V: case OP_STOREP_V:
i = OPB->_int + (OPC->_int*sizeof(ptr->_int)); i = OPB->_int + (OPC->_int*sizeof(ptr->_int));
@ -568,7 +568,7 @@ reeval:
} }
ptr = (eval_t *)(((int *)edvars(ed)) + i); ptr = (eval_t *)(((int *)edvars(ed)) + i);
ptr->_int64 = OPC->_int64; ptr->i64 = OPC->i64;
break; break;
case OP_STOREF_V: case OP_STOREF_V:
errorif ((unsigned)OPA->edict >= (unsigned)num_edicts) errorif ((unsigned)OPA->edict >= (unsigned)num_edicts)
@ -746,7 +746,7 @@ reeval:
break; break;
} }
ptr = (eval_t *)(((int *)edvars(ed)) + i); ptr = (eval_t *)(((int *)edvars(ed)) + i);
OPC->_int64 = ptr->_int64; OPC->i64 = ptr->i64;
} }
break; break;
case OP_LOAD_V: case OP_LOAD_V:
@ -1064,7 +1064,7 @@ reeval:
QCFAULT(&progfuncs->funcs, "bad array read in %s (index %i)", PR_StringToNative(&progfuncs->funcs, prinst.pr_xfunction->s_name), OPB->_int); QCFAULT(&progfuncs->funcs, "bad array read in %s (index %i)", PR_StringToNative(&progfuncs->funcs, prinst.pr_xfunction->s_name), OPB->_int);
} }
else else
OPC->_int64 = ((eval_t *)&glob[i])->_int64; OPC->i64 = ((eval_t *)&glob[i])->i64;
break; break;
case OP_LOADA_V: case OP_LOADA_V:
i = st->a + OPB->_int; i = st->a + OPB->_int;
@ -1156,7 +1156,7 @@ reeval:
{ {
if (i == -1) if (i == -1)
{ {
OPC->_int64 = 0; OPC->i64 = 0;
break; break;
} }
QCFAULT(&progfuncs->funcs, "bad pointer read in %s (from %#x)", PR_StringToNative(&progfuncs->funcs, prinst.pr_xfunction->s_name), i); QCFAULT(&progfuncs->funcs, "bad pointer read in %s (from %#x)", PR_StringToNative(&progfuncs->funcs, prinst.pr_xfunction->s_name), i);
@ -1164,7 +1164,7 @@ reeval:
} }
else else
ptr = QCPOINTERM(i); ptr = QCPOINTERM(i);
OPC->_int64 = ptr->_int64; OPC->i64 = ptr->i64;
break; break;
case OP_LOADP_V: case OP_LOADP_V:
@ -1625,33 +1625,33 @@ reeval:
//[u]int64+double opcodes //[u]int64+double opcodes
case OP_ADD_I64: OPC->_int64 = OPA->_int64 + OPB->_int64; break; case OP_ADD_I64: OPC->i64 = OPA->i64 + OPB->i64; break;
case OP_SUB_I64: OPC->_int64 = OPA->_int64 - OPB->_int64; break; case OP_SUB_I64: OPC->i64 = OPA->i64 - OPB->i64; break;
case OP_MUL_I64: OPC->_int64 = OPA->_int64 * OPB->_int64; break; case OP_MUL_I64: OPC->i64 = OPA->i64 * OPB->i64; break;
case OP_DIV_I64: OPC->_int64 = OPA->_int64 / OPB->_int64; break; case OP_DIV_I64: OPC->i64 = OPA->i64 / OPB->i64; break;
case OP_BITAND_I64: OPC->_int64 = OPA->_int64 & OPB->_int64; break; case OP_BITAND_I64: OPC->i64 = OPA->i64 & OPB->i64; break;
case OP_BITOR_I64: OPC->_int64 = OPA->_int64 | OPB->_int64; break; case OP_BITOR_I64: OPC->i64 = OPA->i64 | OPB->i64; break;
case OP_BITXOR_I64: OPC->_int64 = OPA->_int64 ^ OPB->_int64; break; case OP_BITXOR_I64: OPC->i64 = OPA->i64 ^ OPB->i64; break;
case OP_LSHIFT_I64I: OPC->_int64 = OPA->_int64 << OPB->_int; break; case OP_LSHIFT_I64I: OPC->i64 = OPA->i64 << OPB->_int; break;
case OP_RSHIFT_I64I: OPC->_int64 = OPA->_int64 >> OPB->_int; break; case OP_RSHIFT_I64I: OPC->i64 = OPA->i64 >> OPB->_int; break;
case OP_LT_I64: OPC->_int = OPA->_int64 < OPB->_int64; break; case OP_LT_I64: OPC->_int = OPA->i64 < OPB->i64; break;
case OP_LE_I64: OPC->_int = OPA->_int64 <= OPB->_int64; break; case OP_LE_I64: OPC->_int = OPA->i64 <= OPB->i64; break;
case OP_EQ_I64: OPC->_int = OPA->_int64 == OPB->_int64; break; case OP_EQ_I64: OPC->_int = OPA->i64 == OPB->i64; break;
case OP_NE_I64: OPC->_int = OPA->_int64 != OPB->_int64; break; case OP_NE_I64: OPC->_int = OPA->i64 != OPB->i64; break;
case OP_LT_U64: OPC->_int = OPA->_uint64 < OPB->_uint64; break; case OP_LT_U64: OPC->_int = OPA->u64 < OPB->u64; break;
case OP_LE_U64: OPC->_int = OPA->_uint64 <= OPB->_uint64; break; case OP_LE_U64: OPC->_int = OPA->u64 <= OPB->u64; break;
case OP_DIV_U64: OPC->_uint64 = OPA->_uint64 / OPB->_uint64; break; case OP_DIV_U64: OPC->u64 = OPA->u64 / OPB->u64; break;
case OP_RSHIFT_U64I: OPC->_uint64 = OPA->_uint64 >> OPB->_int; break; case OP_RSHIFT_U64I: OPC->u64 = OPA->u64 >> OPB->_int; break;
case OP_STORE_I64: OPB->_int64 = OPA->_int64; break; case OP_STORE_I64: OPB->i64 = OPA->i64; break;
case OP_CONV_UI64: OPC->_int64 = OPA->_uint; break; case OP_CONV_UI64: OPC->i64 = OPA->_uint; break;
case OP_CONV_II64: OPC->_int64 = OPA->_int; break; case OP_CONV_II64: OPC->i64 = OPA->_int; break;
case OP_CONV_I64I: OPC->_int = OPA->_int64; break; case OP_CONV_I64I: OPC->_int = OPA->i64; break;
case OP_CONV_FD: OPC->_double = OPA->_float; break; case OP_CONV_FD: OPC->_double = OPA->_float; break;
case OP_CONV_DF: OPC->_float = OPA->_double; break; case OP_CONV_DF: OPC->_float = OPA->_double; break;
case OP_CONV_I64F: OPC->_float = OPA->_int64; break; case OP_CONV_I64F: OPC->_float = OPA->i64; break;
case OP_CONV_FI64: OPC->_int64 = OPA->_float; break; case OP_CONV_FI64: OPC->i64 = OPA->_float; break;
case OP_CONV_I64D: OPC->_double = OPA->_int64; break; case OP_CONV_I64D: OPC->_double = OPA->i64; break;
case OP_CONV_DI64: OPC->_int64 = OPA->_double; break; case OP_CONV_DI64: OPC->i64 = OPA->_double; break;
case OP_ADD_D: OPC->_double = OPA->_double + OPB->_double; break; case OP_ADD_D: OPC->_double = OPA->_double + OPB->_double; break;
case OP_SUB_D: OPC->_double = OPA->_double - OPB->_double; break; case OP_SUB_D: OPC->_double = OPA->_double - OPB->_double; break;
case OP_MUL_D: OPC->_double = OPA->_double * OPB->_double; break; case OP_MUL_D: OPC->_double = OPA->_double * OPB->_double; break;
@ -1667,7 +1667,9 @@ reeval:
case OP_UNUSED: case OP_UNUSED:
case OP_POP: case OP_POP:
#ifdef __GNUC__
case OP_NUMREALOPS ... OP_NUMOPS: case OP_NUMREALOPS ... OP_NUMOPS:
#endif
safedefault: safedefault:
if (op & OP_BIT_BREAKPOINT) //break point! if (op & OP_BIT_BREAKPOINT) //break point!

View File

@ -611,10 +611,10 @@ char *PR_ValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val, pbool v
QC_snprintfz (line, sizeof(line), "%"pPRIu, val->_uint); QC_snprintfz (line, sizeof(line), "%"pPRIu, val->_uint);
break; break;
case ev_int64: case ev_int64:
QC_snprintfz (line, sizeof(line), "%"pPRIi64, val->_int64); QC_snprintfz (line, sizeof(line), "%"pPRIi64, val->i64);
break; break;
case ev_uint64: case ev_uint64:
QC_snprintfz (line, sizeof(line), "%"pPRIu64, val->_uint64); QC_snprintfz (line, sizeof(line), "%"pPRIu64, val->u64);
break; break;
case ev_vector: case ev_vector:
QC_snprintfz (line, sizeof(line), "'%g %g %g'", val->_vector[0], val->_vector[1], val->_vector[2]); QC_snprintfz (line, sizeof(line), "'%g %g %g'", val->_vector[0], val->_vector[1], val->_vector[2]);
@ -765,10 +765,10 @@ char *PDECL PR_UglyValueString (pubprogfuncs_t *ppf, etype_t type, eval_t *val)
sprintf (line, "%"pPRIu, val->_uint); sprintf (line, "%"pPRIu, val->_uint);
break; break;
case ev_int64: case ev_int64:
sprintf (line, "%"pPRIi64, val->_int64); sprintf (line, "%"pPRIi64, val->i64);
break; break;
case ev_uint64: case ev_uint64:
sprintf (line, "%"pPRIu64, val->_int64); sprintf (line, "%"pPRIu64, val->u64);
break; break;
case ev_vector: case ev_vector:
if (val->_vector[0] == (int)val->_vector[0] && val->_vector[1] == (int)val->_vector[1] && val->_vector[2] == (int)val->_vector[2]) if (val->_vector[0] == (int)val->_vector[0] && val->_vector[1] == (int)val->_vector[1] && val->_vector[2] == (int)val->_vector[2])
@ -846,10 +846,10 @@ char *PR_UglyOldValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val)
QC_snprintfz (line, sizeof(line), "%"pPRIu, val->_uint); QC_snprintfz (line, sizeof(line), "%"pPRIu, val->_uint);
break; break;
case ev_int64: case ev_int64:
QC_snprintfz (line, sizeof(line), "%"pPRIi64, val->_int64); QC_snprintfz (line, sizeof(line), "%"pPRIi64, val->i64);
break; break;
case ev_uint64: case ev_uint64:
QC_snprintfz (line, sizeof(line), "%"pPRIu64, val->_uint64); QC_snprintfz (line, sizeof(line), "%"pPRIu64, val->u64);
break; break;
case ev_vector: case ev_vector:
if (val->_vector[0] == (int)val->_vector[0] && val->_vector[1] == (int)val->_vector[1] && val->_vector[2] == (int)val->_vector[2]) if (val->_vector[0] == (int)val->_vector[0] && val->_vector[1] == (int)val->_vector[1] && val->_vector[2] == (int)val->_vector[2])
@ -1244,10 +1244,10 @@ pbool PDECL ED_ParseEval (pubprogfuncs_t *ppf, eval_t *eval, int type, const cha
eval->_uint = strtoul (s, NULL, 0); eval->_uint = strtoul (s, NULL, 0);
break; break;
case ev_int64: case ev_int64:
eval->_int64 = strtoll (s, NULL, 0); eval->i64 = strtoll (s, NULL, 0);
break; break;
case ev_uint64: case ev_uint64:
eval->_uint64 = strtoull (s, NULL, 0); eval->u64 = strtoull (s, NULL, 0);
break; break;
case ev_vector: case ev_vector:
@ -1382,7 +1382,7 @@ pbool ED_ParseEpair (progfuncs_t *progfuncs, size_t qcptr, unsigned int fldofs,
i = strtoll(s, &s, 0); i = strtoll(s, &s, 0);
while(*s == ' ' || *s == '\t') while(*s == ' ' || *s == '\t')
s++; s++;
eval->_int64 = i; eval->i64 = i;
if (*s) if (*s)
return false; //some kind of junk in there. return false; //some kind of junk in there.
break; break;
@ -1392,7 +1392,7 @@ pbool ED_ParseEpair (progfuncs_t *progfuncs, size_t qcptr, unsigned int fldofs,
u = strtoull(s, &s, 0); u = strtoull(s, &s, 0);
while(*s == ' ' || *s == '\t') while(*s == ' ' || *s == '\t')
s++; s++;
eval->_uint64 = u; eval->u64 = u;
if (*s) if (*s)
return false; //some kind of junk in there. return false; //some kind of junk in there.
break; break;

View File

@ -26,14 +26,14 @@
#if (_MSC_VER >= 1400) #if (_MSC_VER >= 1400)
//with MSVC 8, use MS extensions //with MSVC 8, use MS extensions
#define snprintf linuxlike_snprintf_vc8 #define snprintf linuxlike_snprintf_vc8
int VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3); void VARGS linuxlike_snprintf_vc8(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf(a, b, c, d) vsnprintf_s(a, b, _TRUNCATE, c, d) #define vsnprintf(a, b, c, d) (void)(vsnprintf_s(a, b, _TRUNCATE, c, d))
#else #else
//msvc crap //msvc crap
#define snprintf linuxlike_snprintf #define snprintf linuxlike_snprintf
int VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3); void VARGS linuxlike_snprintf(char *buffer, int size, const char *format, ...) LIKEPRINTF(3);
#define vsnprintf linuxlike_vsnprintf #define vsnprintf linuxlike_vsnprintf
int VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr); void VARGS linuxlike_vsnprintf(char *buffer, int size, const char *format, va_list argptr);
#endif #endif
#endif #endif

View File

@ -296,8 +296,8 @@ typedef union eval_s
func_t function; //module=0xff000000, func=0x00ffffff func_t function; //module=0xff000000, func=0x00ffffff
pint_t _int; pint_t _int;
puint_t _uint; puint_t _uint;
pint64_t _int64; pint64_t i64;
puint64_t _uint64; puint64_t u64;
pdouble_t _double; pdouble_t _double;
pint_t edict; pint_t edict;
pvec_t prog; //so it can easily be changed pvec_t prog; //so it can easily be changed

View File

@ -32,8 +32,8 @@ typedef float pvec_t;
typedef int pint_t; typedef int pint_t;
typedef unsigned int puint_t; typedef unsigned int puint_t;
#ifdef _MSC_VER #ifdef _MSC_VER
typedef __int64 pint64_t QC_ALIGN(4); typedef QC_ALIGN(4) __int64 pint64_t;
typedef unsigned __int64 puint64_t QC_ALIGN(4); typedef QC_ALIGN(4) unsigned __int64 puint64_t;
#define pPRId "d" #define pPRId "d"
#define pPRIi "i" #define pPRIi "i"
@ -58,7 +58,7 @@ typedef unsigned int puint_t;
#define QCVM_32 #define QCVM_32
#endif #endif
typedef double pdouble_t QC_ALIGN(4); //the qcvm uses vectors and stuff, so any 64bit types are only 4-byte aligned. we don't do atomics so this is fine so long as the compiler handles it for us. typedef QC_ALIGN(4) double pdouble_t; //the qcvm uses vectors and stuff, so any 64bit types are only 4-byte aligned. we don't do atomics so this is fine so long as the compiler handles it for us.
typedef unsigned int pbool; typedef unsigned int pbool;
typedef pvec_t pvec3_t[3]; typedef pvec_t pvec3_t[3];
typedef pint_t progsnum_t; typedef pint_t progsnum_t;

View File

@ -32,6 +32,7 @@
extern progfuncs_t *qccprogfuncs; extern progfuncs_t *qccprogfuncs;
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900
#define strtoll _strtoi64
#define strtoull _strtoui64 #define strtoull _strtoui64
#ifndef PRIxPTR #ifndef PRIxPTR
#define PRIxPTR "Ix" #define PRIxPTR "Ix"
@ -343,8 +344,8 @@ typedef union QCC_eval_s
func_t function; func_t function;
pint_t _int; pint_t _int;
puint_t _uint; puint_t _uint;
pint64_t _int64; pint64_t i64;
puint64_t _uint64; puint64_t u64;
// union QCC_eval_s *ptr; // union QCC_eval_s *ptr;
} QCC_eval_t; } QCC_eval_t;

View File

@ -1841,7 +1841,7 @@ static pbool QCC_Eval_Truth(const QCC_eval_t *eval, QCC_type_t *type, pbool assu
break; break;
case ev_int64: case ev_int64:
case ev_uint64: case ev_uint64:
istrue = (eval->_int64 != 0); istrue = (eval->i64 != 0);
break; break;
case ev_string: case ev_string:
if (flag_ifstring) if (flag_ifstring)
@ -2551,12 +2551,12 @@ const char *QCC_VarAtOffset(QCC_sref_t ref)
QC_snprintfz(message, sizeof(message), "%#"pPRIx"u", val->_uint); QC_snprintfz(message, sizeof(message), "%#"pPRIx"u", val->_uint);
return message; return message;
case ev_int64: case ev_int64:
//QC_snprintfz(message, sizeof(message), "%"pPRIu64"ill", val->_int64); //QC_snprintfz(message, sizeof(message), "%"pPRIu64"ill", val->i64);
QC_snprintfz(message, sizeof(message), "%#"pPRIx64"ill", val->_int64); QC_snprintfz(message, sizeof(message), "%#"pPRIx64"ill", val->i64);
return message; return message;
case ev_uint64: case ev_uint64:
//QC_snprintfz(message, sizeof(message), "%"pPRIu64"ull", val->_uint64); //QC_snprintfz(message, sizeof(message), "%"pPRIu64"ull", val->u64);
QC_snprintfz(message, sizeof(message), "%#"pPRIx64"ull", val->_uint64); QC_snprintfz(message, sizeof(message), "%#"pPRIx64"ull", val->u64);
return message; return message;
case ev_entity: case ev_entity:
QC_snprintfz(message, sizeof(message), "%"pPRIi"e", val->_int); QC_snprintfz(message, sizeof(message), "%"pPRIi"e", val->_int);
@ -3118,55 +3118,55 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
case OP_ADD_I64: case OP_ADD_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 + eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 + eval_b->i64);
case OP_SUB_I64: case OP_SUB_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 - eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 - eval_b->i64);
case OP_MUL_I64: case OP_MUL_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 * eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 * eval_b->i64);
case OP_DIV_I64: case OP_DIV_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 / eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 / eval_b->i64);
case OP_LSHIFT_I64I: case OP_LSHIFT_I64I:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 << eval_b->_int); return QCC_MakeInt64Const(eval_a->i64 << eval_b->_int);
case OP_RSHIFT_I64I: case OP_RSHIFT_I64I:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 >> eval_b->_int); return QCC_MakeInt64Const(eval_a->i64 >> eval_b->_int);
case OP_BITAND_I64: case OP_BITAND_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 & eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 & eval_b->i64);
case OP_BITOR_I64: case OP_BITOR_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 | eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 | eval_b->i64);
case OP_BITXOR_I64: case OP_BITXOR_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeInt64Const(eval_a->_int64 ^ eval_b->_int64); return QCC_MakeInt64Const(eval_a->i64 ^ eval_b->i64);
case OP_LE_I64: case OP_LE_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeIntConst(eval_a->_int64 <= eval_b->_int64); return QCC_MakeIntConst(eval_a->i64 <= eval_b->i64);
case OP_LT_I64: case OP_LT_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeIntConst(eval_a->_int64 < eval_b->_int64); return QCC_MakeIntConst(eval_a->i64 < eval_b->i64);
case OP_EQ_I64: case OP_EQ_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeIntConst(eval_a->_int64 == eval_b->_int64); return QCC_MakeIntConst(eval_a->i64 == eval_b->i64);
case OP_NE_I64: case OP_NE_I64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeIntConst(eval_a->_int64 != eval_b->_int64); return QCC_MakeIntConst(eval_a->i64 != eval_b->i64);
case OP_LT_U64: case OP_LT_U64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeIntConst(eval_a->_uint64 < eval_b->_uint64); return QCC_MakeIntConst(eval_a->u64 < eval_b->u64);
case OP_LE_U64: case OP_LE_U64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeIntConst(eval_a->_uint64 <= eval_b->_uint64); return QCC_MakeIntConst(eval_a->u64 <= eval_b->u64);
case OP_DIV_U64: case OP_DIV_U64:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeUInt64Const(eval_a->_uint64 / eval_b->_uint64); return QCC_MakeUInt64Const(eval_a->u64 / eval_b->u64);
case OP_RSHIFT_U64I: case OP_RSHIFT_U64I:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
return QCC_MakeUInt64Const(eval_a->_uint64 >> eval_b->_int); return QCC_MakeUInt64Const(eval_a->u64 >> eval_b->_int);
case OP_ADD_D: case OP_ADD_D:
QCC_FreeTemp(var_a); QCC_FreeTemp(var_b); QCC_FreeTemp(var_a); QCC_FreeTemp(var_b);
@ -3289,9 +3289,9 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
QCC_FreeTemp(var_a); QCC_FreeTemp(var_a);
optres_constantarithmatic++; optres_constantarithmatic++;
{ {
double d = eval_a->_int64; double d = eval_a->i64;
if ((pint64_t)d != eval_a->_int64) if ((pint64_t)d != eval_a->i64)
QCC_PR_ParseWarning(WARN_OVERFLOW, "Numerical truncation of %#"pPRIx64" to %#"pPRIx64".", eval_a->_int64, (pint64_t)d); QCC_PR_ParseWarning(WARN_OVERFLOW, "Numerical truncation of %#"pPRIx64" to %#"pPRIx64".", eval_a->i64, (pint64_t)d);
return QCC_MakeDoubleConst(d); return QCC_MakeDoubleConst(d);
} }
case OP_CONV_FI64: case OP_CONV_FI64:
@ -3304,9 +3304,9 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
QCC_FreeTemp(var_a); QCC_FreeTemp(var_a);
optres_constantarithmatic++; optres_constantarithmatic++;
{ {
float d = eval_a->_int64; float d = eval_a->i64;
if ((pint64_t)d != eval_a->_int64) if ((pint64_t)d != eval_a->i64)
QCC_PR_ParseWarning(WARN_OVERFLOW, "Numerical truncation of %#"pPRIx64" to %#"pPRIx64".", eval_a->_int64, (pint64_t)d); QCC_PR_ParseWarning(WARN_OVERFLOW, "Numerical truncation of %#"pPRIx64" to %#"pPRIx64".", eval_a->i64, (pint64_t)d);
return QCC_MakeFloatConst(d); return QCC_MakeFloatConst(d);
} }
case OP_CONV_II64: case OP_CONV_II64:
@ -3331,9 +3331,9 @@ QCC_sref_t QCC_PR_StatementFlags ( QCC_opcode_t *op, QCC_sref_t var_a, QCC_sref_
QCC_FreeTemp(var_a); QCC_FreeTemp(var_a);
optres_constantarithmatic++; optres_constantarithmatic++;
{ {
pint_t d = eval_a->_int64; pint_t d = eval_a->i64;
if ((pint64_t)d != eval_a->_int64) if ((pint64_t)d != eval_a->i64)
QCC_PR_ParseWarning(WARN_OVERFLOW, "Numerical truncation of %#"pPRIx64" to %#"pPRIx".", eval_a->_int64, (pint_t)d); QCC_PR_ParseWarning(WARN_OVERFLOW, "Numerical truncation of %#"pPRIx64" to %#"pPRIx".", eval_a->i64, (pint_t)d);
return QCC_MakeIntConst(d); return QCC_MakeIntConst(d);
} }
@ -5517,11 +5517,11 @@ static QCC_sref_t QCC_PR_ParseImmediate (void)
QCC_PR_Lex (); QCC_PR_Lex ();
return cn; return cn;
case ev_int64: case ev_int64:
cn = QCC_MakeInt64Const(pr_immediate._int64); cn = QCC_MakeInt64Const(pr_immediate.i64);
QCC_PR_Lex (); QCC_PR_Lex ();
return cn; return cn;
case ev_uint64: case ev_uint64:
cn = QCC_MakeUInt64Const(pr_immediate._uint64); cn = QCC_MakeUInt64Const(pr_immediate.u64);
QCC_PR_Lex (); QCC_PR_Lex ();
return cn; return cn;
@ -8130,7 +8130,7 @@ static QCC_sref_t QCC_Make64bitConst(QCC_type_t *type, puint64_t value) //all va
while (cn) while (cn)
{ {
if (cn->type->size == type->size) if (cn->type->size == type->size)
if (((QCC_eval_t*)cn->symboldata)->_uint64 == value) if (((QCC_eval_t*)cn->symboldata)->u64 == value)
return QCC_MakeSRefForce(cn, 0, type); return QCC_MakeSRefForce(cn, 0, type);
cn = Hash_GetNextKey(&floatconstdefstable, key, cn); cn = Hash_GetNextKey(&floatconstdefstable, key, cn);
} }
@ -8153,7 +8153,7 @@ static QCC_sref_t QCC_Make64bitConst(QCC_type_t *type, puint64_t value) //all va
cn->symbolsize = cn->type->size; cn->symbolsize = cn->type->size;
cn->symboldata = (QCC_eval_basic_t*)(cn+1); cn->symboldata = (QCC_eval_basic_t*)(cn+1);
((QCC_eval_t*)cn->symboldata)->_uint64 = value; ((QCC_eval_t*)cn->symboldata)->u64 = value;
Hash_AddKey(&floatconstdefstable, key, cn, qccHunkAlloc(sizeof(bucket_t))); Hash_AddKey(&floatconstdefstable, key, cn, qccHunkAlloc(sizeof(bucket_t)));
@ -8229,14 +8229,14 @@ QCC_sref_t QCC_MakeInt64Const(longlong llvalue)
{ {
pint64_t value = llvalue; pint64_t value = llvalue;
if (value != llvalue) if (value != llvalue)
QCC_PR_ParseWarning(WARN_OVERFLOW, "Constant int operand %llu will be truncated to %"PRIi64, llvalue, value); QCC_PR_ParseWarning(WARN_OVERFLOW, "Constant int operand %llu will be truncated to %"pPRIi64, llvalue, value);
return QCC_Make64bitConst(type_int64, value); return QCC_Make64bitConst(type_int64, value);
} }
QCC_sref_t QCC_MakeUInt64Const(unsigned longlong llvalue) QCC_sref_t QCC_MakeUInt64Const(unsigned longlong llvalue)
{ {
puint64_t value = llvalue; puint64_t value = llvalue;
if (value != llvalue) if (value != llvalue)
QCC_PR_ParseWarning(WARN_OVERFLOW, "Constant int operand %llu will be truncated to %"PRIu64, llvalue, value); QCC_PR_ParseWarning(WARN_OVERFLOW, "Constant int operand %llu will be truncated to %"pPRIu64, llvalue, value);
return QCC_Make64bitConst(type_uint64, value); return QCC_Make64bitConst(type_uint64, value);
} }
QCC_sref_t QCC_MakeDoubleConst(double value) QCC_sref_t QCC_MakeDoubleConst(double value)
@ -12654,9 +12654,9 @@ int QCC_PR_IntConstExpr(void)
case ev_uint: case ev_uint:
return ev->_uint; return ev->_uint;
case ev_int64: case ev_int64:
return ev->_int64; return ev->i64;
case ev_uint64: case ev_uint64:
return ev->_uint64; return ev->u64;
default: default:
QCC_PR_ParseError(ERR_NOTACONSTANT, "Value is not an integer constant"); QCC_PR_ParseError(ERR_NOTACONSTANT, "Value is not an integer constant");
} }
@ -17569,9 +17569,9 @@ QCC_type_t *QCC_PR_ParseEnum(pbool flags)
else if (sref.cast->type == ev_uint) else if (sref.cast->type == ev_uint)
next_f = next_i = eval->_uint; next_f = next_i = eval->_uint;
else if (sref.cast->type == ev_int64) else if (sref.cast->type == ev_int64)
next_f = (longlong)(next_i = eval->_int64); next_f = (longlong)(next_i = eval->i64);
else if (sref.cast->type == ev_uint64) else if (sref.cast->type == ev_uint64)
next_f = next_i = eval->_uint64; next_f = next_i = eval->u64;
} }
else if (sref.sym) else if (sref.sym)
QCC_PR_ParseError(ERR_NOTANUMBER, "enum - %s is not a compile-time constant", sref.sym->name); QCC_PR_ParseError(ERR_NOTANUMBER, "enum - %s is not a compile-time constant", sref.sym->name);

View File

@ -2157,7 +2157,7 @@ static void QCC_PR_LexNumber (void)
if (islong) if (islong)
{ {
pr_immediate_type = (isunsigned)?type_uint64:type_int64; pr_immediate_type = (isunsigned)?type_uint64:type_int64;
pr_immediate._int64 = num; pr_immediate.i64 = num;
} }
else else
{ {
@ -3985,8 +3985,8 @@ void QCC_PR_ParsePrintDef (int type, QCC_def_t *def)
case ev_double: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %g", ev->_double); break; case ev_double: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %g", ev->_double); break;
case ev_integer:QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %i", ev->_int); break; case ev_integer:QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %i", ev->_int); break;
case ev_uint: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %u", ev->_uint); break; case ev_uint: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %u", ev->_uint); break;
case ev_int64: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %i", (int)ev->_int64); break; case ev_int64: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %"pPRIi64, ev->i64); break;
case ev_uint64: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %u", (unsigned)ev->_uint64); break; case ev_uint64: QC_snprintfz(vlbuffer, sizeof(vlbuffer), " = %"pPRIu64, ev->u64); break;
default: *vlbuffer = 0; break; default: *vlbuffer = 0; break;
} }
} }

View File

@ -756,10 +756,10 @@ static void QCC_DumpAutoCvars (const char *outputname)
snprintf(line, sizeof(line), "set %s\t%"pPRIu"%s%s\n", n, val->_uint, desc?"\t//":"", desc?desc:""); snprintf(line, sizeof(line), "set %s\t%"pPRIu"%s%s\n", n, val->_uint, desc?"\t//":"", desc?desc:"");
break; break;
case ev_int64: case ev_int64:
snprintf(line, sizeof(line), "set %s\t%"pPRIi64"%s%s\n", n, val->_int64, desc?"\t//":"", desc?desc:""); snprintf(line, sizeof(line), "set %s\t%"pPRIi64"%s%s\n", n, val->i64, desc?"\t//":"", desc?desc:"");
break; break;
case ev_uint64: case ev_uint64:
snprintf(line, sizeof(line), "set %s\t%"pPRIu64"%s%s\n", n, val->_uint64, desc?"\t//":"", desc?desc:""); snprintf(line, sizeof(line), "set %s\t%"pPRIu64"%s%s\n", n, val->u64, desc?"\t//":"", desc?desc:"");
break; break;
case ev_string: case ev_string:
snprintf(line, sizeof(line), "set %s\t\"%s\"%s%s\n", n, strings + val->_int, desc?"\t//":"", desc?desc:""); snprintf(line, sizeof(line), "set %s\t\"%s\"%s%s\n", n, strings + val->_int, desc?"\t//":"", desc?desc:"");

View File

@ -1658,7 +1658,7 @@ static void PR_FallbackSpawn_Misc_Model(pubprogfuncs_t *progfuncs, edict_t *self
progfuncs->SetStringField(progfuncs, self, &self->v->model, "*null", true); progfuncs->SetStringField(progfuncs, self, &self->v->model, "*null", true);
if (self->v->angles[1] < 0) //mimic AD. shame there's no avelocity clientside. if (self->v->angles[1] < 0) //mimic AD. shame there's no avelocity clientside.
self->v->angles[1] = (rand()*(360.0f/RAND_MAX)); self->v->angles[1] = (rand()*(360.0/RAND_MAX));
//make sure the model is precached, to avoid errors. //make sure the model is precached, to avoid errors.
pr_globals = PR_globals(progfuncs, PR_CURRENT); pr_globals = PR_globals(progfuncs, PR_CURRENT);
@ -8755,7 +8755,7 @@ static void QCBUILTIN PF_h2starteffect(pubprogfuncs_t *prinst, struct globalvars
/*convert it to the requested chunk type*/ /*convert it to the requested chunk type*/
efnum = ce_chunk_1 + type - 1; efnum = ce_chunk_1 + type - 1;
if (efnum < ce_chunk_1 && efnum > ce_chunk_24) if (efnum < ce_chunk_1 || efnum > ce_chunk_24)
efnum = ce_chunk; efnum = ce_chunk;
if (h2customtents[efnum] != -1) if (h2customtents[efnum] != -1)

View File

@ -462,7 +462,7 @@ static void QDECL Q1QVMPF_ClearEdict(pubprogfuncs_t *pf, edict_t *e)
Q1QVMED_ClearEdict(e, true); Q1QVMED_ClearEdict(e, true);
} }
static void QDECL Q1QVMPF_EntRemove(pubprogfuncs_t *pf, edict_t *e, qboolean instant) static void QDECL Q1QVMPF_EntRemove(pubprogfuncs_t *pf, edict_t *e, pbool instant)
{ {
if (!ED_CanFree(e)) if (!ED_CanFree(e))
return; return;

View File

@ -1871,7 +1871,7 @@ void SV_MVD_SendInitialGamestate(mvddest_t *dest)
for (j = 0; j < MAX_CL_STATS; j++) for (j = 0; j < MAX_CL_STATS; j++)
{ {
demo.statsi[i][j] = 0x7fffffff; demo.statsi[i][j] = 0x7fffffff;
demo.statsf[i][j] = -0x7fffffff; demo.statsf[i][j] = -FLT_MAX;
} }
demo.playerreset[i] = true; demo.playerreset[i] = true;
} }

View File

@ -2226,8 +2226,8 @@ void SV_UpdateQCStats(edict_t *ent, int *statsi, char const** statss, float *sta
break; break;
case ev_int64: case ev_int64:
case ev_uint64: //split over 2 stats. case ev_uint64: //split over 2 stats.
statsi[qcstats[i].statnum] = eval->_uint64&0xffffffff; statsi[qcstats[i].statnum] = eval->u64&0xffffffff;
statsi[qcstats[i].statnum+1] = eval->_uint64>>32; statsi[qcstats[i].statnum+1] = eval->u64>>32;
break; break;
case ev_entity: case ev_entity:
statsi[qcstats[i].statnum] = NUM_FOR_EDICT(svprogfuncs, PROG_TO_EDICT(svprogfuncs, eval->edict)); statsi[qcstats[i].statnum] = NUM_FOR_EDICT(svprogfuncs, PROG_TO_EDICT(svprogfuncs, eval->edict));

View File

@ -57,7 +57,7 @@ static void R_DrawPortal(batch_t *batch, batch_t **blist, batch_t *depthmasklist
extern texid_t r_whiteimage, missing_texture_gloss, missing_texture_normal; extern texid_t r_whiteimage, missing_texture_gloss, missing_texture_normal;
extern texid_t r_blackimage, r_blackcubeimage, r_whitecubeimage; extern texid_t r_blackimage, r_blackcubeimage, r_whitecubeimage;
static void BE_RotateForEntity (const entity_t *e, const model_t *mod); static void BE_RotateForEntity (const entity_t *fte_restrict e, const model_t *fte_restrict mod);
void VKBE_SetupLightCBuffer(dlight_t *l, vec3_t colour); void VKBE_SetupLightCBuffer(dlight_t *l, vec3_t colour);
#ifdef VK_EXT_debug_utils #ifdef VK_EXT_debug_utils

View File

@ -341,29 +341,37 @@ void QDECL Q_strncpyz(char *d, const char *s, int n)
} }
*d='\0'; *d='\0';
} }
void VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
qboolean VARGS Q_vsnprintfz (char *dest, size_t size, const char *fmt, va_list argptr)
{ {
size_t ret;
#ifdef _WIN32 #ifdef _WIN32
#undef _vsnprintf //doesn't null terminate.
_vsnprintf (dest, size, fmt, argptr); //returns -1 on truncation
#define _vsnprintf unsafe_vsnprintf ret = _vsnprintf (dest, size, fmt, argptr);
dest[size-1] = 0; //shitty paranoia
#else #else
#ifdef _DEBUG //always null terminates.
if ((size_t)vsnprintf (dest, size, fmt, argptr) > size-1) //returns length regardless of truncation.
Sys_Error("Q_vsnprintfz: truncation"); ret = vsnprintf (dest, size, fmt, argptr);
#else
vsnprintf (dest, size, fmt, argptr);
#endif
#endif #endif
dest[size-1] = 0; #ifdef _DEBUG
if (ret>=size)
Sys_Error("Q_vsnprintfz: Truncation\n");
#endif
//if ret is -1 (windows oversize, or general error) then it'll be treated as unsigned so really long. this makes the following check quite simple.
return ret>=size;
} }
void VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...)
qboolean VARGS Q_snprintfz (char *dest, size_t size, const char *fmt, ...)
{ {
va_list argptr; va_list argptr;
qboolean ret;
va_start (argptr, fmt); va_start (argptr, fmt);
Q_vsnprintfz(dest, size, fmt, argptr); ret = Q_vsnprintfz(dest, size, fmt, argptr);
va_end (argptr); va_end (argptr);
return ret;
} }
//palette data is used in lmps, as well as written into pcxes or wads, probably some other things. //palette data is used in lmps, as well as written into pcxes or wads, probably some other things.

View File

@ -459,7 +459,6 @@ static qboolean JSON_Equals(json_t *t, const char *child, const char *expected)
return !strncmp(t->bodystart, expected, t->bodyend-t->bodystart); return !strncmp(t->bodystart, expected, t->bodyend-t->bodystart);
return false; return false;
} }
#include <inttypes.h>
static quintptr_t JSON_GetUInteger(json_t *t, const char *child, unsigned int fallback) static quintptr_t JSON_GetUInteger(json_t *t, const char *child, unsigned int fallback)
{ {
if (child) if (child)