From 31faed3d95420a3068e8f85fb66eb677f7a2faf7 Mon Sep 17 00:00:00 2001 From: dark-steveneq <83212176+dark-steveneq@users.noreply.github.com> Date: Wed, 4 May 2022 20:50:58 +0200 Subject: [PATCH] Fixed files --- linux_sdk/Makefile | 106 ++++ linux_sdk/Makefile.mod | 20 + linux_sdk/Makefile.plugin | 54 ++ linux_sdk/Makefile.vcpm | 60 ++ linux_sdk/Makefile~ | 106 ++++ linux_sdk/makefile.vcpm~ | 60 ++ linux_sdk/makefile~ | 106 ++++ linux_sdk/obj/vcpm/makefilecreator.o | Bin 0 -> 45628 bytes linux_sdk/obj/vcpm/vprojtomake.o | Bin 0 -> 10380 bytes public/filesystem.h~ | 690 +++++++++++++++++++++ public/tier0/platform.h | 4 +- public/tier0/platform.h~ | 891 +++++++++++++++++++++++++++ public/tier1/keyvalues.h~ | 313 ++++++++++ utils/vprojtomake/vprojtomake.cpp | 4 +- utils/vprojtomake/vprojtomake.cpp~ | 133 ++++ 15 files changed, 2543 insertions(+), 4 deletions(-) create mode 100644 linux_sdk/Makefile create mode 100644 linux_sdk/Makefile.mod create mode 100644 linux_sdk/Makefile.plugin create mode 100644 linux_sdk/Makefile.vcpm create mode 100644 linux_sdk/Makefile~ create mode 100644 linux_sdk/makefile.vcpm~ create mode 100644 linux_sdk/makefile~ create mode 100644 linux_sdk/obj/vcpm/makefilecreator.o create mode 100644 linux_sdk/obj/vcpm/vprojtomake.o create mode 100644 public/filesystem.h~ create mode 100644 public/tier0/platform.h~ create mode 100644 public/tier1/keyvalues.h~ create mode 100644 utils/vprojtomake/vprojtomake.cpp~ diff --git a/linux_sdk/Makefile b/linux_sdk/Makefile new file mode 100644 index 0000000..656e83b --- /dev/null +++ b/linux_sdk/Makefile @@ -0,0 +1,106 @@ +# +# SDK Makefile for x86 Linux +# +# + +############################################################################# +# Developer configurable items +############################################################################# + +# the name of the mod binary (_i486.so is appended to the end) +NAME=server + +# the location of the vcproj that builds the mod +MOD_PROJ=../dlls/server_scratch-2003.vcproj +# the name of the mod configuration (typically _) +MOD_CONFIG=server_sdk_ReleaseSDKWin32 + +# the directory the base binaries (tier0_i486.so, etc) are located +#GAME_DIR=../../ +#GAME_DIR=~/valve/hl2bin/ +GAME_DIR=~/valve/steam + +# compiler options (gcc 3.4.1 or above is required) +CC=/usr/local/bin/gcc +CPLUS=/usr/local/bin/g++ +CLINK=/usr/local/bin/gcc +CPP_LIB="/usr/local/lib/libstdc++.a /usr/local/lib/libgcc_eh.a" + +# put any compiler flags you want passed here +USER_CFLAGS= + +# link flags for your mod, make sure to include any special libraries here +LDFLAGS="-lm -ldl $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so mathlib_i486.a choreoobjects_i486.a tier1_i486.a" + +# XERCES 2.6.0 or above ( http://xml.apache.org/xerces-c/ ) is used by the vcproj to makefile converter +# it must be installed before being able to run this makefile +XERCES_INC_DIR=/home/dark/tmp/xerces-c-src_2_6_0/include +XERCES_LIB_DIR=/home/dark/tmp/xerces-c-src_2_6_0/lib +# if you have xerces installed already you should be able to use the two lines below +#XERCES_INC_DIR=/usr/include +#XERCES_LIB_DIR=/usr/lib + + +############################################################################# +# Things below here shouldn't need to be altered +############################################################################# +MAKE=make + +# the dir we want to put binaries we build into +BUILD_DIR=/home/dark/source2006/linux_sdk +# the place to put object files +BUILD_OBJ_DIR=$(BUILD_DIR)/obj + +# the location of the source code +SOURCE_DIR=.. + +# the CPU target for the build, must be i486 for now +ARCH=i486 +ARCH_CFLAGS=-mtune=i686 -march=pentium3 -mmmx -O3 + +# -fpermissive is so gcc 3.4.x doesn't complain about some template stuff +BASE_CFLAGS=-fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp +SHLIBEXT=so +SHLIBCFLAGS=-fPIC +SHLIBLDFLAGS=-shared -Wl,-Map,$@_map.txt -Wl + +#flags passed to the c compiler +CFLAGS="$(USER_CFLAGS) $(DEFINES) $(ARCH_CFLAGS) $(BASE_CFLAGS) -Usprintf=use_Q_snprintf_instead_of_sprintf -Ustrncpy=use_Q_strncpy_instead -UPROTECTED_THINGS_ENABLE" + +# define list passed to make for the sub makefile +BASE_DEFINES=CC=$(CC) CPLUS=$(CPLUS) CPP_LIB=$(CPP_LIB) \ + BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) \ + SOURCE_DIR=$(SOURCE_DIR) SHLIBLDFLAGS=$(SHLIBLDFLAGS) SHLIBEXT=$(SHLIBEXT) \ + CLINK=$(CLINK) CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) \ + ARCH=$(ARCH) GAME_DIR=$(GAME_DIR) MOD_CONFIG=$(MOD_CONFIG) NAME=$(NAME) \ + XERCES_INC_DIR=$(XERCES_INC_DIR) XERCES_LIB_DIR=$(XERCES_LIB_DIR) + +# Project Makefile +MAKE_MOD=/home/dark/source2006/linux_sdk/Makefile.mod +MAKE_VCPM=/home/dark/source2006/linux_sdk/Makefile.vcpm +MAKE_PLUGIN=/home/dark/source2006/linux_sdk/Makefile.plugin + +all: check vcpm mod + +check: + if [ -z "$(CC)" ]; then echo "Compiler not defined."; exit; fi + if [ ! -d $(BUILD_DIR) ];then mkdir $(BUILD_DIR);fi + cd $(BUILD_DIR) + +vcpm: + $(MAKE) -f $(MAKE_VCPM) $(BASE_DEFINES) + +mod: vcpm + if [ ! -f "tier0_i486.so" ]; then ln -s $(GAME_DIR)/bin/tier0_i486.so .; fi + if [ ! -f "vstdlib_i486.so" ]; then ln -s $(GAME_DIR)/bin/vstdlib_i486.so .; fi + ./vcpm $(MOD_PROJ) + $(MAKE) -f $(MAKE_MOD) $(BASE_DEFINES) + +plugin: + $(MAKE) -f $(MAKE_PLUGIN) $(BASE_DEFINES) + +clean: + $(MAKE) -f $(MAKE_VCPM) $(BASE_DEFINES) clean + $(MAKE) -f $(MAKE_PLUGIN) $(BASE_DEFINES) clean + $(MAKE) -f $(MAKE_MOD) $(BASE_DEFINES) clean + diff --git a/linux_sdk/Makefile.mod b/linux_sdk/Makefile.mod new file mode 100644 index 0000000..2e11591 --- /dev/null +++ b/linux_sdk/Makefile.mod @@ -0,0 +1,20 @@ +# +# wrapper Makefile for auto-generated make files +# +# + +############################################################################# +# PROJECT MAKEFILES +############################################################################# +MAKE_FILE=Makefile.$(MOD_CONFIG) +include $(MAKE_FILE) + +############################################################################# +# The compiler command lne for each src code file to compile +############################################################################# +DO_CC=$(CPLUS) -w $(INCLUDES) $(CFLAGS) -o $@ -c $< + + +clean: + rm -rf obj/$(NAME) + rm -f $(NAME)_$(ARCH).$(SHLIBEXT) diff --git a/linux_sdk/Makefile.plugin b/linux_sdk/Makefile.plugin new file mode 100644 index 0000000..0ef055b --- /dev/null +++ b/linux_sdk/Makefile.plugin @@ -0,0 +1,54 @@ +# +# Sample server plugin for SRC engine +# +# October 2004, alfred@valvesoftware.com +# + +PLUGIN_SRC_DIR=$(SOURCE_DIR)/utils/serverplugin_sample +PUBLIC_SRC_DIR=$(SOURCE_DIR)/public +TIER0_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier0 +TIER1_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier1 + +PLUGIN_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin +PUBLIC_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin/public +TIER0_OBJ_DIR=$(BUILD_OBJ_DIR)/plugin/tier0 + +CFLAGS=$(BASE_CFLAGS) $(ARCH_CFLAGS) +#DEBUG = -g -ggdb +#CFLAGS+= $(DEBUG) + +INCLUDEDIRS=-I$(PUBLIC_SRC_DIR) -I$(TIER1_PUBLIC_SRC_DIR) -Dstrcmpi=strcasecmp -D_alloca=alloca + +DO_CC=$(CPLUS) $(INCLUDEDIRS) -w $(CFLAGS) -DARCH=$(ARCH) -o $@ -c $< + +##################################################################### + +PLUGIN_OBJS = \ + $(PLUGIN_OBJ_DIR)/serverplugin_convar.o \ + $(PLUGIN_OBJ_DIR)/serverplugin_empty.o \ + $(PLUGIN_OBJ_DIR)/serverplugin_bot.o \ + +TIER0_OBJS = \ + $(TIER0_OBJ_DIR)/memoverride-vc7.o \ + +all: dirs serverplugin_empty_$(ARCH).$(SHLIBEXT) + +dirs: + -mkdir $(BUILD_OBJ_DIR) + -mkdir $(PLUGIN_OBJ_DIR) + -mkdir $(PUBLIC_OBJ_DIR) + -mkdir $(TIER0_OBJ_DIR) + $(CHECK_DSP) $(SOURCE_DSP) + +serverplugin_empty_$(ARCH).$(SHLIBEXT): $(PLUGIN_OBJS) $(TIER0_OBJS) + $(CLINK) $(DEBUG) -o $(BUILD_DIR)/$@ $(SHLIBLDFLAGS) $(PLUGIN_OBJS) $(TIER0_OBJS) $(PUBLIC_OBJS) $(CPP_LIB) $(LDFLAGS) $(CPP_LIB) + +$(PLUGIN_OBJ_DIR)/%.o: $(PLUGIN_SRC_DIR)/%.cpp + $(DO_CC) + +$(TIER0_OBJ_DIR)/%.o: $(TIER0_PUBLIC_SRC_DIR)/%.cpp + $(DO_CC) + +clean: + -rm -rf $(PLUGIN_OBJ_DIR) + -rm -f plugin_$(ARCH).$(SHLIBEXT) diff --git a/linux_sdk/Makefile.vcpm b/linux_sdk/Makefile.vcpm new file mode 100644 index 0000000..f3dbfbd --- /dev/null +++ b/linux_sdk/Makefile.vcpm @@ -0,0 +1,60 @@ +# +# VCProject file to Makefile converter +# +# November 2004, alfred@valvesoftware.com +# + +VCPM_SRC_DIR=$(SOURCE_DIR)/utils/vprojtomake +UTIL_COMMON_SRC_DIR=$(SOURCE_DIR)/utils/common +TIER1_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier1 +PUBLIC_SRC_DIR=$(SOURCE_DIR)/public +TIER1_SRC_DIR=$(SOURCE_DIR)/tier1 + +VCPM_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm +TIER1_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm/public + +#we use custome CFLAGS because the base ones interfere with XERCES +CFLAGS= -w -fpermissive -D_LINUX -DNDEBUG -D_alloca=alloca -D_snprintf=snprintf -D_vsnprintf=vsnprintf $(ARCH_CFLAGS) +#DEBUG = -g -ggdb +#CFLAGS+= $(DEBUG) + +INCLUDEDIRS=-I$(PUBLIC_SRC_DIR) -I$(XERCES_INC_DIR) -I$(UTIL_COMMON_SRC_DIR) -I$(TIER1_PUBLIC_SRC_DIR) +LDFLAGS_VC=-lm -ldl -L$(XERCES_LIB_DIR) -lxerces-c $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so + +DO_CC=$(CPLUS) $(INCLUDEDIRS) -w $(CFLAGS) -DARCH=$(ARCH) -o $@ -c $< + +##################################################################### + +VCPM_OBJS = \ + $(VCPM_OBJ_DIR)/makefilecreator.o \ + $(VCPM_OBJ_DIR)/vprojtomake.o \ + $(VCPM_OBJ_DIR)/vcprojconvert.o \ + +TIER1_OBJS = \ + $(TIER1_OBJ_DIR)/characterset.o \ + $(TIER1_OBJ_DIR)/interface.o \ + $(TIER1_OBJ_DIR)/generichash.o \ + $(TIER1_OBJ_DIR)/KeyValues.o \ + $(TIER1_OBJ_DIR)/stringpool.o \ + $(TIER1_OBJ_DIR)/utlbuffer.o \ + $(TIER1_OBJ_DIR)/utlsymbol.o \ + +all: dirs vcpm + +dirs: + -mkdir $(BUILD_OBJ_DIR) + -mkdir $(VCPM_OBJ_DIR) + -mkdir $(TIER1_OBJ_DIR) + +vcpm: $(VCPM_OBJS) $(TIER1_OBJS) + $(CLINK) $(DEBUG) -o $(BUILD_DIR)/$@ $(VCPM_OBJS) $(TIER1_OBJS) $(CPP_LIB) $(LDFLAGS_VC) + +$(VCPM_OBJ_DIR)/%.o: $(VCPM_SRC_DIR)/%.cpp + $(DO_CC) + +$(TIER1_OBJ_DIR)/%.o: $(TIER1_SRC_DIR)/%.cpp + $(DO_CC) -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp + +clean: + -rm -rf $(VCPM_OBJ_DIR) + -rm -f vcpm diff --git a/linux_sdk/Makefile~ b/linux_sdk/Makefile~ new file mode 100644 index 0000000..cfec036 --- /dev/null +++ b/linux_sdk/Makefile~ @@ -0,0 +1,106 @@ +# +# SDK Makefile for x86 Linux +# +# + +############################################################################# +# Developer configurable items +############################################################################# + +# the name of the mod binary (_i486.so is appended to the end) +NAME=server + +# the location of the vcproj that builds the mod +MOD_PROJ=../dlls/server_scratch-2003.vcproj +# the name of the mod configuration (typically _) +MOD_CONFIG=server_sdk_ReleaseSDKWin32 + +# the directory the base binaries (tier0_i486.so, etc) are located +#GAME_DIR=../../ +#GAME_DIR=~/valve/hl2bin/ +GAME_DIR=~/valve/steam + +# compiler options (gcc 3.4.1 or above is required) +CC=/usr/local/bin/gcc +CPLUS=/usr/local/bin/g++ +CLINK=/usr/local/bin/gcc +CPP_LIB="/usr/local/lib/libstdc++.a /usr/local/lib/libgcc_eh.a" + +# put any compiler flags you want passed here +USER_CFLAGS= + +# link flags for your mod, make sure to include any special libraries here +LDFLAGS="-lm -ldl $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so mathlib_i486.a choreoobjects_i486.a tier1_i486.a" + +# XERCES 2.6.0 or above ( http://xml.apache.org/xerces-c/ ) is used by the vcproj to makefile converter +# it must be installed before being able to run this makefile +XERCES_INC_DIR=/home/dark/tmp/xerces-c-src_2_6_0/include +XERCES_LIB_DIR=/home/dark/tmp/xerces-c-src_2_6_0/lib +# if you have xerces installed already you should be able to use the two lines below +XERCES_INC_DIR=/usr/include +XERCES_LIB_DIR=/usr/lib + + +############################################################################# +# Things below here shouldn't need to be altered +############################################################################# +MAKE=make + +# the dir we want to put binaries we build into +BUILD_DIR=/home/dark/source2006/linux_sdk +# the place to put object files +BUILD_OBJ_DIR=$(BUILD_DIR)/obj + +# the location of the source code +SOURCE_DIR=.. + +# the CPU target for the build, must be i486 for now +ARCH=i486 +ARCH_CFLAGS=-mtune=i686 -march=pentium3 -mmmx -O3 + +# -fpermissive is so gcc 3.4.x doesn't complain about some template stuff +BASE_CFLAGS=-fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp +SHLIBEXT=so +SHLIBCFLAGS=-fPIC +SHLIBLDFLAGS=-shared -Wl,-Map,$@_map.txt -Wl + +#flags passed to the c compiler +CFLAGS="$(USER_CFLAGS) $(DEFINES) $(ARCH_CFLAGS) $(BASE_CFLAGS) -Usprintf=use_Q_snprintf_instead_of_sprintf -Ustrncpy=use_Q_strncpy_instead -UPROTECTED_THINGS_ENABLE" + +# define list passed to make for the sub makefile +BASE_DEFINES=CC=$(CC) CPLUS=$(CPLUS) CPP_LIB=$(CPP_LIB) \ + BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) \ + SOURCE_DIR=$(SOURCE_DIR) SHLIBLDFLAGS=$(SHLIBLDFLAGS) SHLIBEXT=$(SHLIBEXT) \ + CLINK=$(CLINK) CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) \ + ARCH=$(ARCH) GAME_DIR=$(GAME_DIR) MOD_CONFIG=$(MOD_CONFIG) NAME=$(NAME) \ + XERCES_INC_DIR=$(XERCES_INC_DIR) XERCES_LIB_DIR=$(XERCES_LIB_DIR) + +# Project Makefile +MAKE_MOD=/home/dark/source2006/linux_sdk/Makefile.mod +MAKE_VCPM=/home/dark/source2006/linux_sdk/Makefile.vcpm +MAKE_PLUGIN=/home/dark/source2006/linux_sdk/Makefile.plugin + +all: check vcpm mod + +check: + if [ -z "$(CC)" ]; then echo "Compiler not defined."; exit; fi + if [ ! -d $(BUILD_DIR) ];then mkdir $(BUILD_DIR);fi + cd $(BUILD_DIR) + +vcpm: + $(MAKE) -f $(MAKE_VCPM) $(BASE_DEFINES) + +mod: vcpm + if [ ! -f "tier0_i486.so" ]; then ln -s $(GAME_DIR)/bin/tier0_i486.so .; fi + if [ ! -f "vstdlib_i486.so" ]; then ln -s $(GAME_DIR)/bin/vstdlib_i486.so .; fi + ./vcpm $(MOD_PROJ) + $(MAKE) -f $(MAKE_MOD) $(BASE_DEFINES) + +plugin: + $(MAKE) -f $(MAKE_PLUGIN) $(BASE_DEFINES) + +clean: + $(MAKE) -f $(MAKE_VCPM) $(BASE_DEFINES) clean + $(MAKE) -f $(MAKE_PLUGIN) $(BASE_DEFINES) clean + $(MAKE) -f $(MAKE_MOD) $(BASE_DEFINES) clean + diff --git a/linux_sdk/makefile.vcpm~ b/linux_sdk/makefile.vcpm~ new file mode 100644 index 0000000..f3dbfbd --- /dev/null +++ b/linux_sdk/makefile.vcpm~ @@ -0,0 +1,60 @@ +# +# VCProject file to Makefile converter +# +# November 2004, alfred@valvesoftware.com +# + +VCPM_SRC_DIR=$(SOURCE_DIR)/utils/vprojtomake +UTIL_COMMON_SRC_DIR=$(SOURCE_DIR)/utils/common +TIER1_PUBLIC_SRC_DIR=$(SOURCE_DIR)/public/tier1 +PUBLIC_SRC_DIR=$(SOURCE_DIR)/public +TIER1_SRC_DIR=$(SOURCE_DIR)/tier1 + +VCPM_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm +TIER1_OBJ_DIR=$(BUILD_OBJ_DIR)/vcpm/public + +#we use custome CFLAGS because the base ones interfere with XERCES +CFLAGS= -w -fpermissive -D_LINUX -DNDEBUG -D_alloca=alloca -D_snprintf=snprintf -D_vsnprintf=vsnprintf $(ARCH_CFLAGS) +#DEBUG = -g -ggdb +#CFLAGS+= $(DEBUG) + +INCLUDEDIRS=-I$(PUBLIC_SRC_DIR) -I$(XERCES_INC_DIR) -I$(UTIL_COMMON_SRC_DIR) -I$(TIER1_PUBLIC_SRC_DIR) +LDFLAGS_VC=-lm -ldl -L$(XERCES_LIB_DIR) -lxerces-c $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so + +DO_CC=$(CPLUS) $(INCLUDEDIRS) -w $(CFLAGS) -DARCH=$(ARCH) -o $@ -c $< + +##################################################################### + +VCPM_OBJS = \ + $(VCPM_OBJ_DIR)/makefilecreator.o \ + $(VCPM_OBJ_DIR)/vprojtomake.o \ + $(VCPM_OBJ_DIR)/vcprojconvert.o \ + +TIER1_OBJS = \ + $(TIER1_OBJ_DIR)/characterset.o \ + $(TIER1_OBJ_DIR)/interface.o \ + $(TIER1_OBJ_DIR)/generichash.o \ + $(TIER1_OBJ_DIR)/KeyValues.o \ + $(TIER1_OBJ_DIR)/stringpool.o \ + $(TIER1_OBJ_DIR)/utlbuffer.o \ + $(TIER1_OBJ_DIR)/utlsymbol.o \ + +all: dirs vcpm + +dirs: + -mkdir $(BUILD_OBJ_DIR) + -mkdir $(VCPM_OBJ_DIR) + -mkdir $(TIER1_OBJ_DIR) + +vcpm: $(VCPM_OBJS) $(TIER1_OBJS) + $(CLINK) $(DEBUG) -o $(BUILD_DIR)/$@ $(VCPM_OBJS) $(TIER1_OBJS) $(CPP_LIB) $(LDFLAGS_VC) + +$(VCPM_OBJ_DIR)/%.o: $(VCPM_SRC_DIR)/%.cpp + $(DO_CC) + +$(TIER1_OBJ_DIR)/%.o: $(TIER1_SRC_DIR)/%.cpp + $(DO_CC) -Dstricmp=strcasecmp -Dstrcmpi=strcasecmp + +clean: + -rm -rf $(VCPM_OBJ_DIR) + -rm -f vcpm diff --git a/linux_sdk/makefile~ b/linux_sdk/makefile~ new file mode 100644 index 0000000..b4e250c --- /dev/null +++ b/linux_sdk/makefile~ @@ -0,0 +1,106 @@ +# +# SDK Makefile for x86 Linux +# +# + +############################################################################# +# Developer configurable items +############################################################################# + +# the name of the mod binary (_i486.so is appended to the end) +NAME=server + +# the location of the vcproj that builds the mod +MOD_PROJ=../dlls/server_scratch-2003.vcproj +# the name of the mod configuration (typically _) +MOD_CONFIG=server_sdk_ReleaseSDKWin32 + +# the directory the base binaries (tier0_i486.so, etc) are located +#GAME_DIR=../../ +#GAME_DIR=~/valve/hl2bin/ +GAME_DIR=~/valve/steam + +# compiler options (gcc 3.4.1 or above is required) +CC=/usr/local/bin/gcc +CPLUS=/usr/local/bin/g++ +CLINK=/usr/local/bin/gcc +CPP_LIB="/usr/local/lib/libstdc++.a /usr/local/lib/libgcc_eh.a" + +# put any compiler flags you want passed here +USER_CFLAGS= + +# link flags for your mod, make sure to include any special libraries here +LDFLAGS="-lm -ldl $(GAME_DIR)/bin/tier0_i486.so $(GAME_DIR)/bin/vstdlib_i486.so mathlib_i486.a choreoobjects_i486.a tier1_i486.a" + +# XERCES 2.6.0 or above ( http://xml.apache.org/xerces-c/ ) is used by the vcproj to makefile converter +# it must be installed before being able to run this makefile +XERCES_INC_DIR=/home/dark/tmp/xerces-c-src_2_6_0/include +XERCES_LIB_DIR=/home/dark/tmp/xerces-c-src_2_6_0/lib +# if you have xerces installed already you should be able to use the two lines below +XERCES_INC_DIR=/usr/include +XERCES_LIB_DIR=/usr/lib + + +############################################################################# +# Things below here shouldn't need to be altered +############################################################################# +MAKE=make + +# the dir we want to put binaries we build into +BUILD_DIR=/home/dark/source2006/linux_sdk +# the place to put object files +BUILD_OBJ_DIR=$(BUILD_DIR)/obj + +# the location of the source code +SOURCE_DIR=.. + +# the CPU target for the build, must be i486 for now +ARCH=i486 +ARCH_CFLAGS=-mtune=i686 -march=pentium3 -mmmx -O3 + +# -fpermissive is so gcc 3.4.x doesn't complain about some template stuff +BASE_CFLAGS=-fpermissive -D_LINUX -DNDEBUG -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp +SHLIBEXT=so +SHLIBCFLAGS=-fPIC +SHLIBLDFLAGS=-shared -Wl,-Map,$@_map.txt -Wl + +#flags passed to the c compiler +CFLAGS="$(USER_CFLAGS) $(DEFINES) $(ARCH_CFLAGS) $(BASE_CFLAGS) -Usprintf=use_Q_snprintf_instead_of_sprintf -Ustrncpy=use_Q_strncpy_instead -UPROTECTED_THINGS_ENABLE" + +# define list passed to make for the sub makefile +BASE_DEFINES=CC=$(CC) CPLUS=$(CPLUS) CPP_LIB=$(CPP_LIB) \ + BUILD_DIR=$(BUILD_DIR) BUILD_OBJ_DIR=$(BUILD_OBJ_DIR) \ + SOURCE_DIR=$(SOURCE_DIR) SHLIBLDFLAGS=$(SHLIBLDFLAGS) SHLIBEXT=$(SHLIBEXT) \ + CLINK=$(CLINK) CFLAGS=$(CFLAGS) LDFLAGS=$(LDFLAGS) \ + ARCH=$(ARCH) GAME_DIR=$(GAME_DIR) MOD_CONFIG=$(MOD_CONFIG) NAME=$(NAME) \ + XERCES_INC_DIR=$(XERCES_INC_DIR) XERCES_LIB_DIR=$(XERCES_LIB_DIR) + +# Project Makefile +MAKE_MOD=Makefile.mod +MAKE_VCPM=Makefile.vcpm +MAKE_PLUGIN=Makefile.plugin + +all: check vcpm mod + +check: + if [ -z "$(CC)" ]; then echo "Compiler not defined."; exit; fi + if [ ! -d $(BUILD_DIR) ];then mkdir $(BUILD_DIR);fi + cd $(BUILD_DIR) + +vcpm: + $(MAKE) -f $(MAKE_VCPM) $(BASE_DEFINES) + +mod: vcpm + if [ ! -f "tier0_i486.so" ]; then ln -s $(GAME_DIR)/bin/tier0_i486.so .; fi + if [ ! -f "vstdlib_i486.so" ]; then ln -s $(GAME_DIR)/bin/vstdlib_i486.so .; fi + ./vcpm $(MOD_PROJ) + $(MAKE) -f $(MAKE_MOD) $(BASE_DEFINES) + +plugin: + $(MAKE) -f $(MAKE_PLUGIN) $(BASE_DEFINES) + +clean: + $(MAKE) -f $(MAKE_VCPM) $(BASE_DEFINES) clean + $(MAKE) -f $(MAKE_PLUGIN) $(BASE_DEFINES) clean + $(MAKE) -f $(MAKE_MOD) $(BASE_DEFINES) clean + diff --git a/linux_sdk/obj/vcpm/makefilecreator.o b/linux_sdk/obj/vcpm/makefilecreator.o new file mode 100644 index 0000000000000000000000000000000000000000..1d1834ae7c6f410131fde2319bca450b1fd4d2e1 GIT binary patch literal 45628 zcmeHw3wTu3_3xPn7$Ih&MvEFX;-CQ|CK!;HHZVy52{DooQIHTqMj|1^WClTyhncBN zhiS25>$76*!)moYxW-4VfdBz~6lrU1t^R4NEkmH9wcvSStLAF+@m8<+SL6h$+!7M?y z;CX`Cf+K)A@_eD-MS^*P7XwGj^BCY*c^)q~QSdUs0>R0Gg@VO`Qw1*)5TqpoU(cyf zE!#8a%&WS#J+e#-zUg~^?dmT_`ZsrOi98L(w8)G6e`Wc)L-{at?E@L0LIHOUh`hFN zz&#ZY;Vte0!oBW7K**^#AT-yV8ky_P?m*3y0dzWAEs=-OfCv#SD+SFS9|dQR_;H3-FB)nXI{Hv+ZgekC-%z;7rG0=bKO%RKNHU-dQ~ZS zEJTtn7HO(nu+85G&dR~|9 z$lA~5f-}RHvi7r!T)*!0r|m56s(PUcY|rz5Ft`Z!onSnN+SeC%t^I7I|6!<>ZdA`6 z3Vn&rxB%kf`bYGm3OfrOU79O+6Wu}ehE>Aa301y}3~|A>)yGG`y>@JsZzeR(L|fSA zf|l($?A$0_%DXYL(gx0bQeS8lbdc%{R8>N>|0hOD=PTZgJ2kCy(?&Q*`d8Zne3=Ddq{a``>KYK4eb2-Y&TRxDSUg62?o5i*n4Hg=bngydO7%h?ga@^3b4J#6efi~=M_)T<*RZwt z_zs4)ZjGk@eC=9Ia}{olTyA$2zNWQ>k8AmpWB3Pj*HDE!MRm+XcUPGcRZ$DW?*^^g zP7PsA-SMpB1LHUEBN@TD;d=Mj@LYF3^h-IJ+DvqZ>c#uQk&*mpsj}3BX7{RnVNZJAN9ebUHikXU?&TQdx|d5|wGWB;=;K@nAA2sCWS}cw zh-_goqd#Zm9lk2BOOHWw-ML|(u01)}kMLEc4Yg$WR5lXF2~RHx?p{4k{L@p=(qXe5 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zf%_rbZz6h%<;_IDV`&imndMHRw^_zf36eJMyq|iygzOO#4`IH6dp;**%!wgry+r)^ z)sw*eh|8lsezW3!Ucz?tGstp;i0^4E@sB(vQA+3sSSE?S!m^*}+blv@HB@W0MF>U&e@$5{gZ5li4bqMxTja{ta`xf@O-4e!*pOgrz>T1M!% z3O(n=Vvfnf{3`QH< zan0cI(XJx0Fok>o literal 0 HcmV?d00001 diff --git a/public/filesystem.h~ b/public/filesystem.h~ new file mode 100644 index 0000000..98d3e22 --- /dev/null +++ b/public/filesystem.h~ @@ -0,0 +1,690 @@ +//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#include + +#include "tier0/threadtools.h" +#include "tier0/memalloc.h" +#include "tier1/interface.h" +#include "tier1/utlsymbol.h" +#include "public/appframework/IAppSystem.h" + +#ifndef FILESYSTEM_H +#define FILESYSTEM_H + +#ifdef _WIN32 +#pragma once +#endif + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- + +class CUtlBuffer; +class KeyValues; + +typedef void * FileHandle_t; +typedef int FileFindHandle_t; +typedef void (*FileSystemLoggingFunc_t)( const char *fileName, const char *accessType ); +typedef int WaitForResourcesHandle_t; + + +#ifdef _XBOX +typedef void* HANDLE; +#endif +//----------------------------------------------------------------------------- +// Enums used by the interface +//----------------------------------------------------------------------------- + +#ifndef _XBOX +#define FILESYSTEM_MAX_SEARCH_PATHS 128 +#else +#define FILESYSTEM_MAX_SEARCH_PATHS 16 +#endif + +enum FileSystemSeek_t +{ + FILESYSTEM_SEEK_HEAD = SEEK_SET, + FILESYSTEM_SEEK_CURRENT = SEEK_CUR, + FILESYSTEM_SEEK_TAIL = SEEK_END, +}; + +enum +{ + FILESYSTEM_INVALID_FIND_HANDLE = -1 +}; + +enum FileWarningLevel_t +{ + // A problem! + FILESYSTEM_WARNING = -1, + + // Don't print anything + FILESYSTEM_WARNING_QUIET = 0, + + // On shutdown, report names of files left unclosed + FILESYSTEM_WARNING_REPORTUNCLOSED, + + // Report number of times a file was opened, closed + FILESYSTEM_WARNING_REPORTUSAGE, + + // Report all open/close events to console ( !slow! ) + FILESYSTEM_WARNING_REPORTALLACCESSES, + + // Report all open/close/read events to the console ( !slower! ) + FILESYSTEM_WARNING_REPORTALLACCESSES_READ, + + // Report all open/close/read/write events to the console ( !slower! ) + FILESYSTEM_WARNING_REPORTALLACCESSES_READWRITE, + + // Report all open/close/read/write events and all async I/O file events to the console ( !slower(est)! ) + FILESYSTEM_WARNING_REPORTALLACCESSES_ASYNC, + +}; + +// In non-retail builds, enable the file blocking access tracking stuff... +#if defined( TRACK_BLOCKING_IO ) +enum FileBlockingWarning_t +{ + // Report how long synchronous i/o took to complete + FILESYSTEM_BLOCKING_SYNCHRONOUS = 0, + // Report how long async i/o took to complete if AsyncFileFinished caused it to load via "blocking" i/o + FILESYSTEM_BLOCKING_ASYNCHRONOUS_BLOCK, + // Report how long async i/o took to complete + FILESYSTEM_BLOCKING_ASYNCHRONOUS, + // Report how long the async "callback" took + FILESYSTEM_BLOCKING_CALLBACKTIMING, + + FILESYSTEM_BLOCKING_NUMBINS, +}; + +#pragma pack(1) +class FileBlockingItem +{ +public: + enum + { + FB_ACCESS_OPEN = 1, + FB_ACCESS_CLOSE = 2, + FB_ACCESS_READ = 3, + FB_ACCESS_WRITE = 4, + FB_ACCESS_APPEND = 5, + FB_ACCESS_SIZE = 6 + }; + + FileBlockingItem() : + m_ItemType( (FileBlockingWarning_t)0 ), + m_flElapsed( 0.0f ), + m_nAccessType( 0 ) + { + SetFileName( NULL ); + } + + FileBlockingItem( int type, char const *filename, float elapsed, int accessType ) : + m_ItemType( (FileBlockingWarning_t)type ), + m_flElapsed( elapsed ), + m_nAccessType( accessType ) + { + SetFileName( filename ); + } + + void SetFileName( char const *filename ) + { + if ( !filename ) + { + m_szFilename[ 0 ] = 0; + return; + } + + int len = Q_strlen( filename ); + if ( len >= sizeof( m_szFilename ) ) + { + Q_strncpy( m_szFilename, &filename[ len - sizeof( m_szFilename ) + 1 ], sizeof( m_szFilename ) ); + } + else + { + Q_strncpy( m_szFilename, filename, sizeof( m_szFilename ) ); + } + } + + char const *GetFileName() const + { + return m_szFilename; + } + + FileBlockingWarning_t m_ItemType; + float m_flElapsed; + byte m_nAccessType; +private: + + char m_szFilename[ 32 ]; +}; +#pragma pack() + +class IBlockingFileItemList +{ +public: + + // You can't call any of the below calls without locking first + virtual void LockMutex() = 0; + virtual void UnlockMutex() = 0; + + virtual int First() const = 0; + virtual int Next( int i ) const = 0; + virtual int InvalidIndex() const = 0; + + virtual const FileBlockingItem& Get( int index ) const = 0; + + virtual void Reset() = 0; +}; + +#endif // TRACK_BLOCKING_IO + +enum FilesystemMountRetval_t +{ + FILESYSTEM_MOUNT_OK = 0, + FILESYSTEM_MOUNT_FAILED, +}; + +enum SearchPathAdd_t +{ + PATH_ADD_TO_HEAD, // First path searched + PATH_ADD_TO_TAIL, // Last path searched +}; + +enum FilesystemOpenExFlags_t +{ + FSOPEN_UNBUFFERED = ( 1 << 0 ), +}; + +#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0 + +//----------------------------------------------------------------------------- +// Structures used by the interface +//----------------------------------------------------------------------------- + +struct FileSystemStatistics +{ + CInterlockedUInt nReads, + nWrites, + nBytesRead, + nBytesWritten, + nSeeks; +}; + +//----------------------------------------------------------------------------- +// File system allocation functions. Client must free on failure +//----------------------------------------------------------------------------- +typedef void *(*FSAllocFunc_t)( const char *pszFilename, unsigned nBytes ); + +//----------------------------------------------------------------------------- +// Asynchronous support types +//----------------------------------------------------------------------------- + +DECLARE_POINTER_HANDLE(FSAsyncControl_t); +DECLARE_POINTER_HANDLE(FSAsyncFile_t); +const FSAsyncFile_t FS_INVALID_ASYNC_FILE = (FSAsyncFile_t)(0x0000ffff); + +//--------------------------------------------------------- +// Async file status +//--------------------------------------------------------- +enum FSAsyncStatus_t +{ + FSASYNC_ERR_ALIGNMENT = -6, // read parameters invalid for unbuffered IO + FSASYNC_ERR_FAILURE = -5, // hard subsystem failure + FSASYNC_ERR_READING = -4, // read error on file + FSASYNC_ERR_NOMEMORY = -3, // out of memory for file read + FSASYNC_ERR_UNKNOWNID = -2, // caller's provided id is not recognized + FSASYNC_ERR_FILEOPEN = -1, // filename could not be opened (bad path, not exist, etc) + FSASYNC_OK = 0, // operation is successful + FSASYNC_STATUS_PENDING, // file is properly queued, waiting for service + FSASYNC_STATUS_INPROGRESS, // file is being accessed + FSASYNC_STATUS_ABORTED, // file was aborted by caller + FSASYNC_STATUS_UNSERVICED, // file is not yet queued +}; + +//--------------------------------------------------------- +// Async request flags +//--------------------------------------------------------- +enum FSAsyncFlags_t +{ + FSASYNC_FLAGS_ALLOCNOFREE = ( 1 << 0 ), // do the allocation for dataPtr, but don't free + FSASYNC_FLAGS_NOSEARCHPATHS = ( 1 << 1 ), // filename is absolute + FSASYNC_FLAGS_FREEDATAPTR = ( 1 << 2 ), // free the memory for the dataPtr post callback + FSASYNC_FLAGS_RAWIO = ( 1 << 3 ), // request an unbuffered IO. On Win32 & XBox implies alignment restrictions. + FSASYNC_FLAGS_SYNC = ( 1 << 4 ), // Actually perform the operation synchronously. Used to simplify client code paths + FSASYNC_FLAGS_NULLTERMINATE = ( 1 << 5 ), // allocate an extra byte and null terminate the buffer read in +}; + +//--------------------------------------------------------- +// Optional completion callback for each async file serviced (or failed) +// call is not reentrant, async i/o guaranteed suspended until return +// Note: If you change the signature of the callback, you will have to account for it in FileSystemV12 (toml [4/18/2005] ) +//--------------------------------------------------------- +struct FileAsyncRequest_t; +typedef void (*FSAsyncCallbackFunc_t)(const FileAsyncRequest_t &request, int nBytesRead, FSAsyncStatus_t err); + +//--------------------------------------------------------- +// Description of an async request +//--------------------------------------------------------- +struct FileAsyncRequest_t +{ + FileAsyncRequest_t() { memset( this, 0, sizeof(*this) ); hSpecificAsyncFile = FS_INVALID_ASYNC_FILE; } + const char * pszFilename; // file system name + void * pData; // optional, system will alloc/free if NULL + int nOffset; // optional initial seek_set, 0=beginning + int nBytes; // optional read clamp, -1=exist test, 0=full read + FSAsyncCallbackFunc_t pfnCallback; // optional completion callback + void * pContext; // caller's unique file identifier + int priority; // inter list priority, 0=lowest + unsigned flags; // behavior modifier + const char * pszPathID; // path ID (NOTE: this field is here to remain binary compatible with release HL2 filesystem interface) + FSAsyncFile_t hSpecificAsyncFile; // Optional hint obtained using AsyncBeginRead() + FSAllocFunc_t pfnAlloc; // custom allocator. can be null. not compatible with FSASYNC_FLAGS_FREEDATAPTR +}; + + +//----------------------------------------------------------------------------- +// Base file system interface +//----------------------------------------------------------------------------- + +// This is the minimal interface that can be implemented to provide access to +// a named set of files. +#define BASEFILESYSTEM_INTERFACE_VERSION "VBaseFileSystem011" + +abstract_class IBaseFileSystem +{ +public: + virtual int Read( void* pOutput, int size, FileHandle_t file ) = 0; + virtual int Write( void const* pInput, int size, FileHandle_t file ) = 0; + + // if pathID is NULL, all paths will be searched for the file + virtual FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID = 0 ) = 0; + virtual void Close( FileHandle_t file ) = 0; + + + virtual void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) = 0; + virtual unsigned int Tell( FileHandle_t file ) = 0; + virtual unsigned int Size( FileHandle_t file ) = 0; + virtual unsigned int Size( const char *pFileName, const char *pPathID = 0 ) = 0; + + virtual void Flush( FileHandle_t file ) = 0; + virtual bool Precache( const char *pFileName, const char *pPathID = 0 ) = 0; + + virtual bool FileExists( const char *pFileName, const char *pPathID = 0 ) = 0; + virtual bool IsFileWritable( char const *pFileName, const char *pPathID = 0 ) = 0; + virtual bool SetFileWritable( char const *pFileName, bool writable, const char *pPathID = 0 ) = 0; + + virtual long GetFileTime( const char *pFileName, const char *pPathID = 0 ) = 0; + + //-------------------------------------------------------- + // Reads/writes files to utlbuffers. Use this for optimal read performance when doing open/read/close + //-------------------------------------------------------- + virtual bool ReadFile( const char *pFileName, const char *pPath, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) = 0; + virtual bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) = 0; + +#ifdef _XBOX + virtual bool IsFileOnLocalHDD( const char *pFileName, const char *pPath, int &pathID, unsigned int &offset, unsigned int &length ) = 0; + virtual bool GetSearchPathFromId( int pathID, char *pPath, int nPathLen, bool &bIsPackFile ) = 0; +#endif +}; + + +//----------------------------------------------------------------------------- +// Main file system interface +//----------------------------------------------------------------------------- + +#define FILESYSTEM_INTERFACE_VERSION "VFileSystem017" + +abstract_class IFileSystem : public IAppSystem, public IBaseFileSystem +{ +public: + //-------------------------------------------------------- + // Optional hooks to notify file system that application is initializing, + // needed if want to use convars in filesystem + //-------------------------------------------------------- + virtual bool ConnectApp( CreateInterfaceFn factory ) = 0; + virtual InitReturnVal_t InitApp() = 0; + virtual void ShutdownApp() = 0; + virtual void DisconnectApp() = 0; + + //-------------------------------------------------------- + // Steam operations + //-------------------------------------------------------- + + virtual bool IsSteam() const = 0; + + // Supplying an extra app id will mount this app in addition + // to the one specified in the environment variable "steamappid" + // + // If nExtraAppId is < -1, then it will mount that app ID only. + // (Was needed by the dedicated server b/c the "SteamAppId" env var only gets passed to steam.dll + // at load time, so the dedicated couldn't pass it in that way). + virtual FilesystemMountRetval_t MountSteamContent( int nExtraAppId = -1 ) = 0; + + //-------------------------------------------------------- + // Search path manipulation + //-------------------------------------------------------- + + // Add paths in priority order (mod dir, game dir, ....) + // If one or more .pak files are in the specified directory, then they are + // added after the file system path + // If the path is the relative path to a .bsp file, then any previous .bsp file + // override is cleared and the current .bsp is searched for an embedded PAK file + // and this file becomes the highest priority search path ( i.e., it's looked at first + // even before the mod's file system path ). + virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0; + virtual bool RemoveSearchPath( const char *pPath, const char *pathID = 0 ) = 0; + + // Remove all search paths (including write path?) + virtual void RemoveAllSearchPaths( void ) = 0; + + // Remove search paths associated with a given pathID + virtual void RemoveSearchPaths( const char *szPathID ) = 0; + + // This is for optimization. If you mark a path ID as "by request only", then files inside it + // will only be accessed if the path ID is specifically requested. Otherwise, it will be ignored. + // If there are currently no search paths with the specified path ID, then it will still + // remember it in case you add search paths with this path ID. + virtual void MarkPathIDByRequestOnly( const char *pPathID, bool bRequestOnly ) = 0; + + // converts a partial path into a full path + virtual const char *RelativePathToFullPath( const char *pFileName, const char *pPathID, char *pLocalPath, int localPathBufferSize ) = 0; + + // Returns the search path, each path is separated by ;s. Returns the length of the string returned + virtual int GetSearchPath( const char *pathID, bool bGetPackFiles, char *pPath, int nMaxLen ) = 0; + + // interface for custom pack files > 4Gb + virtual bool AddPackFile( const char *fullpath, const char *pathID ) = 0; + + //-------------------------------------------------------- + // File manipulation operations + //-------------------------------------------------------- + + // Deletes a file (on the WritePath) + virtual void RemoveFile( char const* pRelativePath, const char *pathID = 0 ) = 0; + + // Renames a file (on the WritePath) + virtual void RenameFile( char const *pOldPath, char const *pNewPath, const char *pathID = 0 ) = 0; + + // create a local directory structure + virtual void CreateDirHierarchy( const char *path, const char *pathID = 0 ) = 0; + + // File I/O and info + virtual bool IsDirectory( const char *pFileName, const char *pathID = 0 ) = 0; + + virtual void FileTimeToString( char* pStrip, int maxCharsIncludingTerminator, long fileTime ) = 0; + + //-------------------------------------------------------- + // Open file operations + //-------------------------------------------------------- + + virtual void SetBufferSize( FileHandle_t file, unsigned nBytes ) = 0; + + virtual bool IsOk( FileHandle_t file ) = 0; + + virtual bool EndOfFile( FileHandle_t file ) = 0; + + virtual char *ReadLine( char *pOutput, int maxChars, FileHandle_t file ) = 0; + virtual int FPrintf( FileHandle_t file, char *pFormat, ... ) = 0; + + //-------------------------------------------------------- + // Dynamic library operations + //-------------------------------------------------------- + + // load/unload modules + virtual CSysModule *LoadModule( const char *pFileName, const char *pPathID = 0, bool bValidatedDllOnly = true ) = 0; + virtual void UnloadModule( CSysModule *pModule ) = 0; + + //-------------------------------------------------------- + // File searching operations + //-------------------------------------------------------- + + // FindFirst/FindNext. Also see FindFirstEx. + virtual const char *FindFirst( const char *pWildCard, FileFindHandle_t *pHandle ) = 0; + virtual const char *FindNext( FileFindHandle_t handle ) = 0; + virtual bool FindIsDirectory( FileFindHandle_t handle ) = 0; + virtual void FindClose( FileFindHandle_t handle ) = 0; + + // Same as FindFirst, but you can filter by path ID, which can make it faster. + virtual const char *FindFirstEx( + const char *pWildCard, + const char *pPathID, + FileFindHandle_t *pHandle + ) = 0; + + //-------------------------------------------------------- + // File name and directory operations + //-------------------------------------------------------- + + // FIXME: This method is obsolete! Use RelativePathToFullPath instead! + // converts a partial path into a full path + virtual const char *GetLocalPath( const char *pFileName, char *pLocalPath, int localPathBufferSize ) = 0; + + // Returns true on success ( based on current list of search paths, otherwise false if + // it can't be resolved ) + virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative, int maxlen ) = 0; + + // Gets the current working directory + virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) = 0; + + //-------------------------------------------------------- + // Filename dictionary operations + //-------------------------------------------------------- + + virtual FileNameHandle_t FindOrAddFileName( char const *pFileName ) = 0; + virtual bool String( const FileNameHandle_t& handle, char *buf, int buflen ) = 0; + + //-------------------------------------------------------- + // Asynchronous file operations + //-------------------------------------------------------- + + //------------------------------------ + // Global operations + //------------------------------------ + FSAsyncStatus_t AsyncRead( const FileAsyncRequest_t &request, FSAsyncControl_t *phControl = NULL ) { return AsyncReadMultiple( &request, 1, phControl ); } + virtual FSAsyncStatus_t AsyncReadMultiple( const FileAsyncRequest_t *pRequests, int nRequests, FSAsyncControl_t *phControls = NULL ) = 0; + virtual FSAsyncStatus_t AsyncAppend(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, FSAsyncControl_t *pControl = NULL ) = 0; + virtual FSAsyncStatus_t AsyncAppendFile(const char *pAppendToFileName, const char *pAppendFromFileName, FSAsyncControl_t *pControl = NULL ) = 0; + virtual void AsyncFinishAll( int iToPriority = INT_MIN ) = 0; + virtual void AsyncFinishAllWrites() = 0; + virtual FSAsyncStatus_t AsyncFlush() = 0; + virtual bool AsyncSuspend() = 0; + virtual bool AsyncResume() = 0; + + //------------------------------------ + // Functions to hold a file open if planning on doing mutiple reads. Use is optional, + // and is taken only as a hint + //------------------------------------ + virtual FSAsyncStatus_t AsyncBeginRead( const char *pszFile, FSAsyncFile_t *phFile ) = 0; + virtual FSAsyncStatus_t AsyncEndRead( FSAsyncFile_t hFile ) = 0; + + //------------------------------------ + // Request management + //------------------------------------ + virtual FSAsyncStatus_t AsyncFinish( FSAsyncControl_t hControl, bool wait = true ) = 0; + virtual FSAsyncStatus_t AsyncGetResult( FSAsyncControl_t hControl, void **ppData, int *pSize ) = 0; + virtual FSAsyncStatus_t AsyncAbort( FSAsyncControl_t hControl ) = 0; + virtual FSAsyncStatus_t AsyncStatus( FSAsyncControl_t hControl ) = 0; + // set a new priority for a file already in the queue + virtual FSAsyncStatus_t AsyncSetPriority(FSAsyncControl_t hControl, int newPriority) = 0; + virtual void AsyncAddRef( FSAsyncControl_t hControl ) = 0; + virtual void AsyncRelease( FSAsyncControl_t hControl ) = 0; + + //-------------------------------------------------------- + // Remote resource management + //-------------------------------------------------------- + + // starts waiting for resources to be available + // returns FILESYSTEM_INVALID_HANDLE if there is nothing to wait on + virtual WaitForResourcesHandle_t WaitForResources( const char *resourcelist ) = 0; + // get progress on waiting for resources; progress is a float [0, 1], complete is true on the waiting being done + // returns false if no progress is available + // any calls after complete is true or on an invalid handle will return false, 0.0f, true + virtual bool GetWaitForResourcesProgress( WaitForResourcesHandle_t handle, float *progress /* out */ , bool *complete /* out */ ) = 0; + // cancels a progress call + virtual void CancelWaitForResources( WaitForResourcesHandle_t handle ) = 0; + + // hints that a set of files will be loaded in near future + // HintResourceNeed() is not to be confused with resource precaching. + virtual int HintResourceNeed( const char *hintlist, int forgetEverything ) = 0; + // returns true if a file is on disk + virtual bool IsFileImmediatelyAvailable(const char *pFileName) = 0; + + // copies file out of pak/bsp/steam cache onto disk (to be accessible by third-party code) + virtual void GetLocalCopy( const char *pFileName ) = 0; + + //-------------------------------------------------------- + // Debugging operations + //-------------------------------------------------------- + + // Dump to printf/OutputDebugString the list of files that have not been closed + virtual void PrintOpenedFiles( void ) = 0; + virtual void PrintSearchPaths( void ) = 0; + + // output + virtual void SetWarningFunc( void (*pfnWarning)( const char *fmt, ... ) ) = 0; + virtual void SetWarningLevel( FileWarningLevel_t level ) = 0; + virtual void AddLoggingFunc( void (*pfnLogFunc)( const char *fileName, const char *accessType ) ) = 0; + virtual void RemoveLoggingFunc( FileSystemLoggingFunc_t logFunc ) = 0; + + // Returns the file system statistics retreived by the implementation. Returns NULL if not supported. + virtual const FileSystemStatistics *GetFilesystemStatistics() = 0; + + //-------------------------------------------------------- + // Start of new functions after Lost Coast release (7/05) + //-------------------------------------------------------- + + virtual FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0, char **ppszResolvedFilename = NULL ) = 0; + + // Extended version of read provides more context to allow for more optimal reading + virtual int ReadEx( void* pOutput, int sizeDest, int size, FileHandle_t file ) = 0; + virtual int ReadFileEx( const char *pFileName, const char *pPath, void **ppBuf, bool bNullTerminate = false, bool bOptimalAlloc = false, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) = 0; + + virtual FileNameHandle_t FindFileName( char const *pFileName ) = 0; + +#if defined( TRACK_BLOCKING_IO ) + virtual void EnableBlockingFileAccessTracking( bool state ) = 0; + virtual bool IsBlockingFileAccessEnabled() const = 0; + + virtual IBlockingFileItemList *RetrieveBlockingFileAccessInfo() = 0; +#endif + + virtual void PurgePreloadedData() = 0; + virtual void PreloadData() = 0; + + // Fixme, we could do these via a string embedded into the compiled data, etc... + enum KeyValuesPreloadType_t + { + TYPE_VMT, + TYPE_SOUNDEMITTER, + TYPE_SOUNDSCAPE, + + NUM_PRELOAD_TYPES + }; + + virtual void LoadCompiledKeyValues( KeyValuesPreloadType_t type, char const *archiveFile ) = 0; + + // If the "PreloadedData" hasn't been purged, then this'll try and instance the KeyValues using the fast path of compiled keyvalues loaded during startup. + // Otherwise, it'll just fall through to the regular KeyValues loading routines + virtual KeyValues *LoadKeyValues( KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) = 0; + virtual bool LoadKeyValues( KeyValues& head, KeyValuesPreloadType_t type, char const *filename, char const *pPathID = 0 ) = 0; + virtual bool ExtractRootKeyName( KeyValuesPreloadType_t type, char *outbuf, size_t bufsize, char const *filename, char const *pPathID = 0 ) = 0; + + virtual FSAsyncStatus_t AsyncWrite(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend = false, FSAsyncControl_t *pControl = NULL ) = 0; + // Async read functions with memory blame + FSAsyncStatus_t AsyncReadCreditAlloc( const FileAsyncRequest_t &request, const char *pszFile, int line, FSAsyncControl_t *phControl = NULL ) { return AsyncReadMultipleCreditAlloc( &request, 1, pszFile, line, phControl ); } + virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc( const FileAsyncRequest_t *pRequests, int nRequests, const char *pszFile, int line, FSAsyncControl_t *phControls = NULL ) = 0; + + virtual bool GetFileTypeForFullPath( char const *pFullPath, wchar_t *buf, size_t bufSizeInBytes ) = 0; + + //-------------------------------------------------------- + //-------------------------------------------------------- + virtual bool ReadToBuffer( FileHandle_t hFile, CUtlBuffer &buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL ) = 0; + + //-------------------------------------------------------- + // Optimal IO operations + //-------------------------------------------------------- + virtual bool GetOptimalIOConstraints( FileHandle_t hFile, unsigned *pOffsetAlign, unsigned *pSizeAlign, unsigned *pBufferAlign ) = 0; + inline unsigned GetOptimalReadSize( FileHandle_t hFile, unsigned nLogicalSize ); + virtual void *AllocOptimalReadBuffer( FileHandle_t hFile, unsigned nSize = 0, unsigned nOffset = 0 ) = 0; + virtual void FreeOptimalReadBuffer( void * ) = 0; + + //-------------------------------------------------------- + // + //-------------------------------------------------------- + virtual void BeginMapAccess() = 0; + virtual void EndMapAccess() = 0; + + // Returns true on success, otherwise false if it can't be resolved + virtual bool FullPathToRelativePathEx( const char *pFullpath, const char *pPathId, char *pRelative, int maxlen ) = 0; + + virtual int GetPathIndex( const FileNameHandle_t &handle ) = 0; + virtual long GetPathTime( const char *pPath, const char *pPathID ) = 0; +}; + +//----------------------------------------------------------------------------- + +#if defined(_XBOX) && !defined(_RETAIL) +extern char g_szXBOXProfileLastFileOpened[1024]; +#define SetLastProfileFileRead( s ) Q_strcpy( g_szXBOXProfileLastFileOpened, pFileName ) +#define GetLastProfileFileRead() (&g_szXBOXProfileLastFileOpened[0]) +#else +#define SetLastProfileFileRead( s ) ((void)0) +#define GetLastProfileFileRead() NULL +#endif + +#if defined(_XBOX) && defined(_BASETSD_H_) +class CXboxDiskCacheSetter +{ +public: + CXboxDiskCacheSetter( SIZE_T newSize ) + { + m_oldSize = XGetFileCacheSize(); + XSetFileCacheSize( newSize ); + } + + ~CXboxDiskCacheSetter() + { + XSetFileCacheSize( m_oldSize ); + } +private: + SIZE_T m_oldSize; +}; +#define DISK_INTENSIVE() CXboxDiskCacheSetter cacheSetter( 1024*1024 ) +#else +#define DISK_INTENSIVE() ((void)0) +#endif + +//----------------------------------------------------------------------------- + +inline unsigned IFileSystem::GetOptimalReadSize( FileHandle_t hFile, unsigned nLogicalSize ) +{ + unsigned align; + if ( IsPC() && GetOptimalIOConstraints( hFile, &align, NULL, NULL ) ) + return AlignValue( nLogicalSize, align ); + else if ( IsXbox() ) + return AlignValue( nLogicalSize, 512 ); + else + return nLogicalSize; +} + +//----------------------------------------------------------------------------- + +// We include this here so it'll catch compile errors in VMPI early. +#include "filesystem_passthru.h" + +//----------------------------------------------------------------------------- +// Async memory tracking +//----------------------------------------------------------------------------- + +#if (defined(_DEBUG) || defined(USE_MEM_DEBUG)) +#define AsyncRead( a, b ) AsyncReadCreditAlloc( a, __FILE__, __LINE__, b ) +#define AsyncReadMutiple( a, b, c ) AsyncReadMultipleCreditAlloc( a, b, __FILE__, __LINE__, c ) +#endif + +#endif // FILESYSTEM_H diff --git a/public/tier0/platform.h b/public/tier0/platform.h index f06cc51..4928a43 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -22,7 +22,7 @@ // need this for _alloca #include -#include +#include // need this for memset #include @@ -246,7 +246,7 @@ typedef void * HINSTANCE; #elif _LINUX #define ALIGN16 __attribute__((aligned(16))) #define ALIGN32 __attribute__((aligned(32))) -#elif +#else #define ALIGN16 /* */ #define ALIGN32 /* */ #endif diff --git a/public/tier0/platform.h~ b/public/tier0/platform.h~ new file mode 100644 index 0000000..c63e953 --- /dev/null +++ b/public/tier0/platform.h~ @@ -0,0 +1,891 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// + +#ifndef PLATFORM_H +#define PLATFORM_H + +#include "wchartypes.h" +#include "basetypes.h" +#include "tier0/valve_off.h" + +#ifdef _WIN32 +#pragma once +#endif + +// feature enables +#define NEW_SOFTWARE_LIGHTING + +// need this for _alloca +#include +#include + +// need this for memset +#include + +#ifdef _RETAIL +#define IsRetail() true +#else +#define IsRetail() false +#endif + +#ifdef _DEBUG +#define IsRelease() false +#define IsDebug() true +#else +#define IsRelease() true +#define IsDebug() false +#endif + +#ifdef _WIN32 +#define IsLinux() false +#ifndef _XBOX +#define IsPC() true +#define IsConsole() false +#define IsXbox() false +#else +#ifndef _CONSOLE +#define _CONSOLE +#endif +#define IsPC() false +#define IsConsole() true +#define IsXbox() true +#endif +#elif defined(_LINUX) +#define IsPC() true +#define IsConsole() false +#define IsXbox() false +#define IsLinux() true +#else +#error +#endif + +typedef unsigned char uint8; + +#ifdef __x86_64__ +#define X64BITS +#endif + +#if defined( _WIN32 ) + +typedef __int16 int16; +typedef unsigned __int16 uint16; +typedef __int32 int32; +typedef unsigned __int32 uint32; +typedef __int64 int64; +typedef unsigned __int64 uint64; + +#ifdef X64BITS +typedef __int64 intp; // intp is an integer that can accomodate a pointer +typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *) +#else +typedef __int32 intp; +typedef unsigned __int32 uintp; +#endif + +#else // _WIN32 + +typedef short int16; +typedef unsigned short uint16; +typedef int int32; +typedef unsigned int uint32; +typedef long long int64; +typedef unsigned long long uint64; +#ifdef X64BITS +typedef long long intp; +typedef unsigned long long uintp; +#else +typedef int intp; +typedef unsigned int uintp; +#endif + +#endif // else _WIN32 + + +typedef float float32; +typedef double float64; + +// for when we don't care about how many bits we use +typedef unsigned int uint; + +#define XBOX_DVD_SECTORSIZE 2048 +#define XBOX_HDD_SECTORSIZE 512 + +// Custom windows messages for Xbox input +#define WM_XREMOTECOMMAND WM_USER + 100 +#define WM_XCONTROLLER_KEY WM_USER + 101 +#define WM_XCONTROLLER_UNPLUGGED WM_USER + 102 + +// This can be used to ensure the size of pointers to members when declaring +// a pointer type for a class that has only been forward declared +#ifdef _MSC_VER +#define SINGLE_INHERITANCE __single_inheritance +#define MULTIPLE_INHERITANCE __multiple_inheritance +#else +#define SINGLE_INHERITANCE +#define MULTIPLE_INHERITANCE +#endif + +#ifdef _MSC_VER +#define NO_VTABLE __declspec( novtable ) +#else +#define NO_VTABLE +#endif + +// This can be used to declare an abstract (interface only) class. +// Classes marked abstract should not be instantiated. If they are, and access violation will occur. +// +// Example of use: +// +// abstract_class CFoo +// { +// ... +// } +// +// MSDN __declspec(novtable) documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_langref_novtable.asp +// +// Note: NJS: This is not enabled for regular PC, due to not knowing the implications of exporting a class with no no vtable. +// It's probable that this shouldn't be an issue, but an experiment should be done to verify this. +// +#ifndef _XBOX +#define abstract_class class +#else +#define abstract_class class NO_VTABLE +#endif + +/* +FIXME: Enable this when we no longer fear change =) + +// need these for the limits +#include +#include + +// Maximum and minimum representable values +#define INT8_MAX SCHAR_MAX +#define INT16_MAX SHRT_MAX +#define INT32_MAX LONG_MAX +#define INT64_MAX (((int64)~0) >> 1) + +#define INT8_MIN SCHAR_MIN +#define INT16_MIN SHRT_MIN +#define INT32_MIN LONG_MIN +#define INT64_MIN (((int64)1) << 63) + +#define UINT8_MAX ((uint8)~0) +#define UINT16_MAX ((uint16)~0) +#define UINT32_MAX ((uint32)~0) +#define UINT64_MAX ((uint64)~0) + +#define UINT8_MIN 0 +#define UINT16_MIN 0 +#define UINT32_MIN 0 +#define UINT64_MIN 0 + +#ifndef UINT_MIN +#define UINT_MIN UINT32_MIN +#endif + +#define FLOAT32_MAX FLT_MAX +#define FLOAT64_MAX DBL_MAX + +#define FLOAT32_MIN FLT_MIN +#define FLOAT64_MIN DBL_MIN +*/ + +// portability / compiler settings +#if defined(_WIN32) && !defined(WINDED) + +#if defined(_M_IX86) +#define __i386__ 1 +#endif + +#elif _LINUX +typedef unsigned int DWORD; +typedef unsigned short WORD; +typedef void * HINSTANCE; +#define _MAX_PATH PATH_MAX +#endif // defined(_WIN32) && !defined(WINDED) + + +// Defines MAX_PATH +#ifndef MAX_PATH +#define MAX_PATH 260 +#endif + +// Used to step into the debugger +#ifdef _WIN32 +#define DebuggerBreak() __asm { int 3 } +#else +#define DebuggerBreak() {} +#endif +#define DebuggerBreakIfDebugging() if ( !Plat_IsInDebugSession() ) ; else DebuggerBreak() + +// C functions for external declarations that call the appropriate C++ methods +#ifndef EXPORT + #ifdef _WIN32 + #define EXPORT _declspec( dllexport ) + #else + #define EXPORT /* */ + #endif +#endif + +#if defined __i386__ && !defined __linux__ + #define id386 1 +#else + #define id386 0 +#endif // __i386__ + +// decls for aligning data +#ifdef _WIN32 + #define ALIGN16 __declspec(align(16)) + #define ALIGN32 __declspec(align(32)) +#elif _LINUX + #define ALIGN16 __attribute__((aligned(16))) + #define ALIGN32 __attribute__((aligned(32))) +#elif + #define ALIGN16 /* */ + #define ALIGN32 /* */ +#endif + +#ifdef _WIN32 + #define SELECTANY __declspec(selectany) +#elif _LINUX + #define SELECTANY __attribute__((weak)) +#else + #define SELECTANY static +#endif + +#if defined(_WIN32) && !defined(_XBOX) + +// Used for dll exporting and importing +#define DLL_EXPORT extern "C" __declspec( dllexport ) +#define DLL_IMPORT extern "C" __declspec( dllimport ) + +// Can't use extern "C" when DLL exporting a class +#define DLL_CLASS_EXPORT __declspec( dllexport ) +#define DLL_CLASS_IMPORT __declspec( dllimport ) + +// Can't use extern "C" when DLL exporting a global +#define DLL_GLOBAL_EXPORT extern __declspec( dllexport ) +#define DLL_GLOBAL_IMPORT extern __declspec( dllimport ) + +#elif defined _LINUX +// Used for dll exporting and importing +#define DLL_EXPORT extern "C" +#define DLL_IMPORT extern "C" + +// Can't use extern "C" when DLL exporting a class +#define DLL_CLASS_EXPORT +#define DLL_CLASS_IMPORT + +// Can't use extern "C" when DLL exporting a global +#define DLL_GLOBAL_EXPORT extern +#define DLL_GLOBAL_IMPORT extern + +#elif defined(_XBOX) + +#define DLL_EXPORT extern +#define DLL_IMPORT extern +#define DLL_CLASS_EXPORT +#define DLL_CLASS_IMPORT +#define DLL_GLOBAL_EXPORT +#define DLL_GLOBAL_IMPORT + +#else +#error "Unsupported Platform." +#endif + +// Used for standard calling conventions +#ifdef _WIN32 + #define STDCALL __stdcall + #define FASTCALL __fastcall + #define FORCEINLINE __forceinline + // GCC 3.4.1 has a bug in supporting forced inline of templated functions + // this macro lets us not force inlining in that case + #define FORCEINLINE_TEMPLATE __forceinline +#else + #define STDCALL + #define FASTCALL + #define FORCEINLINE __attribute__ ((always_inline)) + // GCC 3.4.1 has a bug in supporting forced inline of templated functions + // this macro lets us not force inlining in that case + #define FORCEINLINE_TEMPLATE + #define __stdcall __attribute__ ((__stdcall__)) +#endif + +// Force a function call site -not- to inlined. (useful for profiling) +#define DONT_INLINE(a) (((int)(a)+1)?(a):(a)) + +// Pass hints to the compiler to prevent it from generating unnessecary / stupid code +// in certain situations. Several compilers other than MSVC also have an equivilent +// construct. +// +// Essentially the 'Hint' is that the condition specified is assumed to be true at +// that point in the compilation. If '0' is passed, then the compiler assumes that +// any subsequent code in the same 'basic block' is unreachable, and thus usually +// removed. +#ifdef _MSC_VER + #define HINT(THE_HINT) __assume((THE_HINT)) +#else + #define HINT(THE_HINT) 0 +#endif + +// Marks the codepath from here until the next branch entry point as unreachable, +// and asserts if any attempt is made to execute it. +#define UNREACHABLE() { Assert(0); HINT(0); } + +// In cases where no default is present or appropriate, this causes MSVC to generate +// as little code as possible, and throw an assertion in debug. +#define NO_DEFAULT default: UNREACHABLE(); + +#ifdef _WIN32 +// Alloca defined for this platform +#define stackalloc( _size ) _alloca( _size ) +#define stackfree( _p ) 0 +#elif _LINUX +// Alloca defined for this platform +#define stackalloc( _size ) alloca( _size ) +#define stackfree( _p ) 0 +#endif + +#ifdef _WIN32 +// Remove warnings from warning level 4. +#pragma warning(disable : 4514) // warning C4514: 'acosl' : unreferenced inline function has been removed +#pragma warning(disable : 4100) // warning C4100: 'hwnd' : unreferenced formal parameter +#pragma warning(disable : 4127) // warning C4127: conditional expression is constant +#pragma warning(disable : 4512) // warning C4512: 'InFileRIFF' : assignment operator could not be generated +#pragma warning(disable : 4611) // warning C4611: interaction between '_setjmp' and C++ object destruction is non-portable +#pragma warning(disable : 4710) // warning C4710: function 'x' not inlined +#pragma warning(disable : 4702) // warning C4702: unreachable code +#pragma warning(disable : 4505) // unreferenced local function has been removed +#pragma warning(disable : 4239) // nonstandard extension used : 'argument' ( conversion from class Vector to class Vector& ) +#pragma warning(disable : 4097) // typedef-name 'BaseClass' used as synonym for class-name 'CFlexCycler::CBaseFlex' +#pragma warning(disable : 4324) // Padding was added at the end of a structure +#pragma warning(disable : 4244) // type conversion warning. +#pragma warning(disable : 4305) // truncation from 'const double ' to 'float ' +#pragma warning(disable : 4786) // Disable warnings about long symbol names +#pragma warning(disable : 4250) // 'X' : inherits 'Y::Z' via dominance + +#if _MSC_VER >= 1300 +#pragma warning(disable : 4511) // Disable warnings about private copy constructors +#pragma warning(disable : 4121) // warning C4121: 'symbol' : alignment of a member was sensitive to packing +#pragma warning(disable : 4530) // warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (disabled due to std headers having exception syntax) +#endif + +#if _MSC_VER >= 1400 +#pragma warning(disable : 4996) // functions declared deprecated +#endif + + +#endif + +// When we port to 64 bit, we'll have to resolve the int, ptr vs size_t 32/64 bit problems... +#if !defined( _WIN64 ) +#pragma warning( disable : 4267 ) // conversion from 'size_t' to 'int', possible loss of data +#pragma warning( disable : 4311 ) // pointer truncation from 'char *' to 'int' +#pragma warning( disable : 4312 ) // conversion from 'unsigned int' to 'memhandle_t' of greater size +#endif + +//----------------------------------------------------------------------------- +// FP exception handling +//----------------------------------------------------------------------------- +//#define CHECK_FLOAT_EXCEPTIONS 1 + +#ifdef _MSC_VER + +inline void SetupFPUControlWordForceExceptions() +{ + // use local to get and store control word + uint16 tmpCtrlW; + __asm + { + fnclex /* clear all current exceptions */ + fnstcw word ptr [tmpCtrlW] /* get current control word */ + and [tmpCtrlW], 0FCC0h /* Keep infinity control + rounding control */ + or [tmpCtrlW], 0230h /* set to 53-bit, mask only inexact, underflow */ + fldcw word ptr [tmpCtrlW] /* put new control word in FPU */ + } +} + +#ifdef CHECK_FLOAT_EXCEPTIONS + +inline void SetupFPUControlWord() +{ + SetupFPUControlWordForceExceptions(); +} + +#else + +inline void SetupFPUControlWord() +{ + // use local to get and store control word + uint16 tmpCtrlW; + __asm + { + fnstcw word ptr [tmpCtrlW] /* get current control word */ + and [tmpCtrlW], 0FCC0h /* Keep infinity control + rounding control */ + or [tmpCtrlW], 023Fh /* set to 53-bit, mask only inexact, underflow */ + fldcw word ptr [tmpCtrlW] /* put new control word in FPU */ + } +} + +#endif + +#else + +inline void SetupFPUControlWord() +{ +} + +#endif // _MSC_VER + + +//----------------------------------------------------------------------------- +// Purpose: Standard functions for handling endian-ness +//----------------------------------------------------------------------------- + +//------------------------------------- +// Basic swaps +//------------------------------------- + +template +inline T WordSwapC( T w ) +{ + uint16 temp; + + temp = ((*((uint16 *)&w) & 0xff00) >> 8); + temp |= ((*((uint16 *)&w) & 0x00ff) << 8); + + return *((T*)&temp); +} + +template +inline T DWordSwapC( T dw ) +{ + uint32 temp; + + temp = *((uint32 *)&dw) >> 24; + temp |= ((*((uint32 *)&dw) & 0x00FF0000) >> 8); + temp |= ((*((uint32 *)&dw) & 0x0000FF00) << 8); + temp |= ((*((uint32 *)&dw) & 0x000000FF) << 24); + + return *((T*)&temp); +} + +//------------------------------------- +// Fast swaps +//------------------------------------- + +#ifdef _MSC_VER + +#define WordSwap WordSwapAsm +#define DWordSwap DWordSwapAsm + +#pragma warning(push) +#pragma warning (disable:4035) // no return value + +template +inline T WordSwapAsm( T w ) +{ + __asm + { + mov ax, w + xchg al, ah + } +} + +template +inline T DWordSwapAsm( T dw ) +{ + __asm + { + mov eax, dw + bswap eax + } +} + +#pragma warning(pop) + +// The assembly implementation is not compatible with floats +template <> +inline float DWordSwapAsm( float f ) +{ + return DWordSwapC( f ); +} + +#else + +#define WordSwap WordSwapC +#define DWordSwap DWordSwapC + +#endif + +//------------------------------------- +// The typically used methods. +//------------------------------------- + +#if defined(__i386__) || defined(_XBOX) +#define LITTLE_ENDIAN 1 +#endif + +#ifdef _SGI_SOURCE +#define BIG_ENDIAN 1 +#endif + +#if defined(LITTLE_ENDIAN) + +#define BigShort( val ) WordSwap( val ) +#define BigWord( val ) WordSwap( val ) +#define BigLong( val ) DWordSwap( val ) +#define BigDWord( val ) DWordSwap( val ) +#define BigFloat( val ) DWordSwap( val ) +#define LittleShort( val ) ( val ) +#define LittleWord( val ) ( val ) +#define LittleLong( val ) ( val ) +#define LittleDWord( val ) ( val ) +#define LittleFloat( val ) ( val ) + +#elif defined(BIG_ENDIAN) + +#define BigShort( val ) ( val ) +#define BigWord( val ) ( val ) +#define BigLong( val ) ( val ) +#define BigDWord( val ) ( val ) +#define BigFloat( val ) ( val ) +#define LittleShort( val ) WordSwap( val ) +#define LittleWord( val ) WordSwap( val ) +#define LittleLong( val ) DWordSwap( val ) +#define LittleDWord( val ) DWordSwap( val ) +#define LittleFloat( val ) DWordSwap( val ) + +#else + +// @Note (toml 05-02-02): this technique expects the compiler to +// optimize the expression and eliminate the other path. On any new +// platform/compiler this should be tested. +inline short BigShort( short val ) { int test = 1; return ( *(char *)&test == 1 ) ? WordSwap( val ) : val; } +inline uint16 BigWord( uint16 val ) { int test = 1; return ( *(char *)&test == 1 ) ? WordSwap( val ) : val; } +inline long BigLong( long val ) { int test = 1; return ( *(char *)&test == 1 ) ? DWordSwap( val ) : val; } +inline uint32 BigDWord( uint32 val ) { int test = 1; return ( *(char *)&test == 1 ) ? DWordSwap( val ) : val; } +inline float BigFloat( float val ) { int test = 1; return ( *(char *)&test == 1 ) ? DWordSwap( val ) : val; } +inline short LittleShort( short val ) { int test = 1; return ( *(char *)&test == 1 ) ? val : WordSwap( val ); } +inline uint16 LittleWord( uint16 val ) { int test = 1; return ( *(char *)&test == 1 ) ? val : WordSwap( val ); } +inline long LittleLong( long val ) { int test = 1; return ( *(char *)&test == 1 ) ? val : DWordSwap( val ); } +inline uint32 LittleDWord( uint32 val ) { int test = 1; return ( *(char *)&test == 1 ) ? val : DWordSwap( val ); } +inline float LittleFloat( float val ) { int test = 1; return ( *(char *)&test == 1 ) ? val : DWordSwap( val ); } + +#endif + + +#ifndef STATIC_TIER0 + +#ifdef TIER0_DLL_EXPORT + #define PLATFORM_INTERFACE DLL_EXPORT + #define PLATFORM_OVERLOAD DLL_GLOBAL_EXPORT +#else + #define PLATFORM_INTERFACE DLL_IMPORT + #define PLATFORM_OVERLOAD DLL_GLOBAL_IMPORT +#endif + +#else // BUILD_AS_DLL + +#define PLATFORM_INTERFACE extern +#define PLATFORM_OVERLOAD + +#endif // BUILD_AS_DLL + + +PLATFORM_INTERFACE double Plat_FloatTime(); // Returns time in seconds since the module was loaded. +PLATFORM_INTERFACE unsigned long Plat_MSTime(); // Time in milliseconds. + +// b/w compatibility +#define Sys_FloatTime Plat_FloatTime + + +// Processor Information: +struct CPUInformation +{ + int m_Size; // Size of this structure, for forward compatability. + + bool m_bRDTSC : 1, // Is RDTSC supported? + m_bCMOV : 1, // Is CMOV supported? + m_bFCMOV : 1, // Is FCMOV supported? + m_bSSE : 1, // Is SSE supported? + m_bSSE2 : 1, // Is SSE2 Supported? + m_b3DNow : 1, // Is 3DNow! Supported? + m_bMMX : 1, // Is MMX supported? + m_bHT : 1; // Is HyperThreading supported? + + uint8 m_nLogicalProcessors, // Number op logical processors. + m_nPhysicalProcessors; // Number of physical processors + + int64 m_Speed; // In cycles per second. + + tchar* m_szProcessorID; // Processor vendor Identification. +}; + +PLATFORM_INTERFACE const CPUInformation& GetCPUInformation(); + +// ---------------------------------------------------------------------------------- // +// Performance Monitoring Events - L2 stats etc... +// ---------------------------------------------------------------------------------- // +PLATFORM_INTERFACE void InitPME(); +PLATFORM_INTERFACE void ShutdownPME(); +//PLATFORM_INTERFACE bool g_bPME; + + + +//----------------------------------------------------------------------------- +// Thread related functions +//----------------------------------------------------------------------------- +// Registers the current thread with Tier0's thread management system. +// This should be called on every thread created in the game. +PLATFORM_INTERFACE unsigned long Plat_RegisterThread( const tchar *pName = _T("Source Thread")); + +// Registers the current thread as the primary thread. +PLATFORM_INTERFACE unsigned long Plat_RegisterPrimaryThread(); + +// VC-specific. Sets the thread's name so it has a friendly name in the debugger. +// This should generally only be handled by Plat_RegisterThread and Plat_RegisterPrimaryThread +PLATFORM_INTERFACE void Plat_SetThreadName( unsigned long dwThreadID, const tchar *pName ); + +// These would be private if it were possible to export private variables from a .DLL. +// They need to be variables because they are checked by inline functions at performance +// critical places. +PLATFORM_INTERFACE unsigned long Plat_PrimaryThreadID; + +// Returns the ID of the currently executing thread. +PLATFORM_INTERFACE unsigned long Plat_GetCurrentThreadID(); + +// Returns the ID of the primary thread. +inline unsigned long Plat_GetPrimaryThreadID() +{ + return Plat_PrimaryThreadID; +} + +// Returns true if the current thread is the primary thread. +inline bool Plat_IsPrimaryThread() +{ + //return true; + return (Plat_GetPrimaryThreadID() == Plat_GetCurrentThreadID() ); +} + +//----------------------------------------------------------------------------- +// Process related functions +//----------------------------------------------------------------------------- +PLATFORM_INTERFACE const tchar *Plat_GetCommandLine(); +#ifndef _WIN32 +// helper function for OS's that don't have a ::GetCommandLine() call +PLATFORM_INTERFACE void Plat_SetCommandLine( const char *cmdLine ); +#endif + +//----------------------------------------------------------------------------- +// Security related functions +//----------------------------------------------------------------------------- +// Ensure that the hardware key's drivers have been installed. +PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyDriver(); + +// Ok, so this isn't a very secure way to verify the hardware key for now. It +// is primarially depending on the fact that all the binaries have been wrapped +// with the secure wrapper provided by the hardware keys vendor. +PLATFORM_INTERFACE bool Plat_VerifyHardwareKey(); + +// The same as above, but notifies user with a message box when the key isn't in +// and gives him an opportunity to correct the situation. +PLATFORM_INTERFACE bool Plat_VerifyHardwareKeyPrompt(); + +// Can be called in real time, doesn't perform the verify every frame. Mainly just +// here to allow the game to drop out quickly when the key is removed, rather than +// allowing the wrapper to pop up it's own blocking dialog, which the engine doesn't +// like much. +PLATFORM_INTERFACE bool Plat_FastVerifyHardwareKey(); + + + +//----------------------------------------------------------------------------- +// Include additional dependant header components. +//----------------------------------------------------------------------------- +#include "tier0/fasttimer.h" + + +//----------------------------------------------------------------------------- +// Just logs file and line to simple.log +//----------------------------------------------------------------------------- +PLATFORM_INTERFACE void* Plat_SimpleLog( const tchar* file, int line ); + +//#define Plat_dynamic_cast Plat_SimpleLog(__FILE__,__LINE__),dynamic_cast + +//----------------------------------------------------------------------------- +#if defined(_WIN32) +PLATFORM_INTERFACE bool Plat_IsInDebugSession(); +#else +#define Plat_IsInDebugSession() (false) +#endif + +//----------------------------------------------------------------------------- +// Methods to invoke the constructor, copy constructor, and destructor +//----------------------------------------------------------------------------- + +template +inline void Construct( T* pMemory ) +{ + ::new( pMemory ) T; +} + +template +inline void CopyConstruct( T* pMemory, T const& src ) +{ + ::new( pMemory ) T(src); +} + +template +inline void Destruct( T* pMemory ) +{ + pMemory->~T(); + +#ifdef _DEBUG + memset( pMemory, 0xDD, sizeof(T) ); +#endif +} + + +// +// GET_OUTER() +// +// A platform-independent way for a contained class to get a pointer to its +// owner. If you know a class is exclusively used in the context of some +// "outer" class, this is a much more space efficient way to get at the outer +// class than having the inner class store a pointer to it. +// +// class COuter +// { +// class CInner // Note: this does not need to be a nested class to work +// { +// void PrintAddressOfOuter() +// { +// printf( "Outer is at 0x%x\n", GET_OUTER( COuter, m_Inner ) ); +// } +// }; +// +// CInner m_Inner; +// friend class CInner; +// }; + +#define GET_OUTER( OuterType, OuterMember ) \ + ( ( OuterType * ) ( (uint8 *)this - offsetof( OuterType, OuterMember ) ) ) + + +/* TEMPLATE_FUNCTION_TABLE() + + (Note added to platform.h so platforms that correctly support templated + functions can handle portions as templated functions rather than wrapped + functions) + + Helps automate the process of creating an array of function + templates that are all specialized by a single integer. + This sort of thing is often useful in optimization work. + + For example, using TEMPLATE_FUNCTION_TABLE, this: + + TEMPLATE_FUNCTION_TABLE(int, Function, ( int blah, int blah ), 10) + { + return argument * argument; + } + + is equivilent to the following: + + (NOTE: the function has to be wrapped in a class due to code + generation bugs involved with directly specializing a function + based on a constant.) + + template + class FunctionWrapper + { + public: + int Function( int blah, int blah ) + { + return argument*argument; + } + } + + typedef int (*FunctionType)( int blah, int blah ); + + class FunctionName + { + public: + enum { count = 10 }; + FunctionType functions[10]; + }; + + FunctionType FunctionName::functions[] = + { + FunctionWrapper<0>::Function, + FunctionWrapper<1>::Function, + FunctionWrapper<2>::Function, + FunctionWrapper<3>::Function, + FunctionWrapper<4>::Function, + FunctionWrapper<5>::Function, + FunctionWrapper<6>::Function, + FunctionWrapper<7>::Function, + FunctionWrapper<8>::Function, + FunctionWrapper<9>::Function + }; +*/ + +PLATFORM_INTERFACE bool vtune( bool resume ); + + +#define TEMPLATE_FUNCTION_TABLE(RETURN_TYPE, NAME, ARGS, COUNT) \ + \ +typedef RETURN_TYPE (FASTCALL *__Type_##NAME) ARGS; \ + \ +template \ +struct __Function_##NAME \ +{ \ + static RETURN_TYPE FASTCALL Run ARGS; \ +}; \ + \ +template \ +struct __MetaLooper_##NAME : __MetaLooper_##NAME \ +{ \ + __Type_##NAME func; \ + inline __MetaLooper_##NAME() { func = __Function_##NAME::Run; } \ +}; \ + \ +template<> \ +struct __MetaLooper_##NAME<0> \ +{ \ + __Type_##NAME func; \ + inline __MetaLooper_##NAME() { func = __Function_##NAME<0>::Run; } \ +}; \ + \ +class NAME \ +{ \ +private: \ + static const __MetaLooper_##NAME m; \ +public: \ + enum { count = COUNT }; \ + static const __Type_##NAME* functions; \ +}; \ +const __MetaLooper_##NAME NAME::m; \ +const __Type_##NAME* NAME::functions = (__Type_##NAME*)&m; \ +template \ +RETURN_TYPE FASTCALL __Function_##NAME::Run ARGS + + +#define LOOP_INTERCHANGE(BOOLEAN, CODE)\ + if( (BOOLEAN) )\ + {\ + CODE;\ + } else\ + {\ + CODE;\ + } + +#include "tier0/valve_on.h" + +#endif /* PLATFORM_H */ diff --git a/public/tier1/keyvalues.h~ b/public/tier1/keyvalues.h~ new file mode 100644 index 0000000..9cff273 --- /dev/null +++ b/public/tier1/keyvalues.h~ @@ -0,0 +1,313 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef KEYVALUES_H +#define KEYVALUES_H + +#ifdef _WIN32 +#pragma once +#endif + +// #include + +#ifndef NULL +#ifdef __cplusplus +#define NULL 0 +#else +#define NULL ((void *)0) +#endif +#endif + +#include "utlvector.h" +#include "Color.h" + +class IBaseFileSystem; +class CUtlBuffer; +class Color; +typedef void * FileHandle_t; + +//----------------------------------------------------------------------------- +// Purpose: Simple recursive data access class +// Used in vgui for message parameters and resource files +// Destructor deletes all child KeyValues nodes +// Data is stored in key (string names) - (string/int/float)value pairs called nodes. +// +// About KeyValues Text File Format: + +// It has 3 control characters '{', '}' and '"'. Names and values may be quoted or +// not. The quote '"' charater must not be used within name or values, only for +// quoting whole tokens. You may use escape sequences wile parsing and add within a +// quoted token a \" to add quotes within your name or token. When using Escape +// Sequence the parser must now that by setting KeyValues::UsesEscapeSequences( true ), +// which it's off by default. Non-quoted tokens ends with a whitespace, '{', '}' and '"'. +// So you may use '{' and '}' within quoted tokens, but not for non-quoted tokens. +// An open bracket '{' after a key name indicates a list of subkeys which is finished +// with a closing bracket '}'. Subkeys use the same definitions recursively. +// Whitespaces are space, return, newline and tabulator. Allowed Escape sequences +// are \n, \t, \\, \n and \". The number character '#' is used for macro purposes +// (eg #include), don't use it as first charater in key names. +//----------------------------------------------------------------------------- +class KeyValues +{ +public: + KeyValues( const char *setName ); + + // Quick setup constructors + KeyValues( const char *setName, const char *firstKey, const char *firstValue ); + KeyValues( const char *setName, const char *firstKey, const wchar_t *firstValue ); + KeyValues( const char *setName, const char *firstKey, int firstValue ); + KeyValues( const char *setName, const char *firstKey, const char *firstValue, const char *secondKey, const char *secondValue ); + KeyValues( const char *setName, const char *firstKey, int firstValue, const char *secondKey, int secondValue ); + + // Section name + const char *GetName() const; + void SetName( const char *setName); + + // gets the name as a unique int + int GetNameSymbol() const; + + // File access. Set UsesEscapeSequences true, if resource file/buffer uses Escape Sequences (eg \n, \t) + void UsesEscapeSequences(bool state); // default false + bool LoadFromFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL ); + bool SaveToFile( IBaseFileSystem *filesystem, const char *resourceName, const char *pathID = NULL); + + // Read from a buffer... Note that the buffer must be null terminated + bool LoadFromBuffer( char const *resourceName, const char *pBuffer, IBaseFileSystem* pFileSystem = NULL, const char *pPathID = NULL ); + + // Read from a utlbuffer... + bool LoadFromBuffer( char const *resourceName, CUtlBuffer &buf, IBaseFileSystem* pFileSystem = NULL, const char *pPathID = NULL ); + + // Find a keyValue, create it if it is not found. + // Set bCreate to true to create the key if it doesn't already exist (which ensures a valid pointer will be returned) + KeyValues *FindKey(const char *keyName, bool bCreate = false); + KeyValues *FindKey(int keySymbol) const; + KeyValues *CreateNewKey(); // creates a new key, with an autogenerated name. name is guaranteed to be an integer, of value 1 higher than the highest other integer key name + void AddSubKey( KeyValues *pSubkey ); // Adds a subkey. Make sure the subkey isn't a child of some other keyvalues + void RemoveSubKey(KeyValues *subKey); // removes a subkey from the list, DOES NOT DELETE IT + + // Key iteration. + // + // NOTE: GetFirstSubKey/GetNextKey will iterate keys AND values. Use the functions + // below if you want to iterate over just the keys or just the values. + // + KeyValues *GetFirstSubKey(); // returns the first subkey in the list + KeyValues *GetNextKey(); // returns the next subkey + void SetNextKey( KeyValues * pDat); + + // + // These functions can be used to treat it like a true key/values tree instead of + // confusing values with keys. + // + // So if you wanted to iterate all subkeys, then all values, it would look like this: + // for ( KeyValues *pKey = pRoot->GetFirstTrueSubKey(); pKey; pKey = pKey->GetNextTrueSubKey() ) + // { + // Msg( "Key name: %s\n", pKey->GetName() ); + // } + // for ( KeyValues *pValue = pRoot->GetFirstValue(); pKey; pKey = pKey->GetNextValue() ) + // { + // Msg( "Int value: %d\n", pValue->GetInt() ); // Assuming pValue->GetDataType() == TYPE_INT... + // } + KeyValues* GetFirstTrueSubKey(); + KeyValues* GetNextTrueSubKey(); + + KeyValues* GetFirstValue(); // When you get a value back, you can use GetX and pass in NULL to get the value. + KeyValues* GetNextValue(); + + + // Data access + int GetInt( const char *keyName = NULL, int defaultValue = 0 ); + uint64 GetUint64( const char *keyName = NULL, uint64 defaultValue = 0 ); + float GetFloat( const char *keyName = NULL, float defaultValue = 0.0f ); + const char *GetString( const char *keyName = NULL, const char *defaultValue = "" ); + const wchar_t *GetWString( const char *keyName = NULL, const wchar_t *defaultValue = L"" ); + void *GetPtr( const char *keyName = NULL, void *defaultValue = (void*)0 ); + Color GetColor( const char *keyName = NULL /* default value is all black */); + bool IsEmpty(const char *keyName = NULL); + + // Data access + int GetInt( int keySymbol, int defaultValue = 0 ); + float GetFloat( int keySymbol, float defaultValue = 0.0f ); + const char *GetString( int keySymbol, const char *defaultValue = "" ); + const wchar_t *GetWString( int keySymbol, const wchar_t *defaultValue = L"" ); + void *GetPtr( int keySymbol, void *defaultValue = (void*)0 ); + Color GetColor( int keySymbol /* default value is all black */); + bool IsEmpty( int keySymbol ); + + // Key writing + void SetWString( const char *keyName, const wchar_t *value ); + void SetString( const char *keyName, const char *value ); + void SetInt( const char *keyName, int value ); + void SetUint64( const char *keyName, uint64 value ); + void SetFloat( const char *keyName, float value ); + void SetPtr( const char *keyName, void *value ); + void SetColor( const char *keyName, Color value); + + //Memory allocation (optimized) + void *operator new( unsigned int iAllocSize ); + void *operator new( unsigned int iAllocSize, int nBlockUse, const char *pFileName, int nLine ); + void operator delete( void *pMem ); + void operator delete( void *pMem, int nBlockUse, const char *pFileName, int nLine ); + + KeyValues& operator=( KeyValues& src ); + + // Adds a chain... if we don't find stuff in this keyvalue, we'll look + // in the one we're chained to. + void ChainKeyValue( KeyValues* pChain ); + + void RecursiveSaveToFile( CUtlBuffer& buf, int indentLevel ); + + bool WriteAsBinary( CUtlBuffer &buffer ); + bool ReadAsBinary( CUtlBuffer &buffer ); + + // Allocate & create a new copy of the keys + KeyValues *MakeCopy( void ) const; + + // Make a new copy of all subkeys, add them all to the passed-in keyvalues + void CopySubkeys( KeyValues *pParent ) const; + + // Clear out all subkeys, and the current value + void Clear( void ); + + // Data type + enum types_t + { + TYPE_NONE = 0, + TYPE_STRING, + TYPE_INT, + TYPE_FLOAT, + TYPE_PTR, + TYPE_WSTRING, + TYPE_COLOR, + TYPE_UINT64, + TYPE_NUMTYPES, + }; + types_t GetDataType(const char *keyName = NULL); + + // Virtual deletion function - ensures that KeyValues object is deleted from correct heap + void deleteThis(); + + void SetStringValue( char const *strValue ); + +private: + KeyValues( KeyValues& ); // prevent copy constructor being used + + // prevent delete being called except through deleteThis() + ~KeyValues(); + + KeyValues* CreateKey( const char *keyName ); + + void RecursiveCopyKeyValues( KeyValues& src ); + void RemoveEverything(); +// void RecursiveSaveToFile( IBaseFileSystem *filesystem, CUtlBuffer &buffer, int indentLevel ); +// void WriteConvertedString( CUtlBuffer &buffer, const char *pszString ); + + // NOTE: If both filesystem and pBuf are non-null, it'll save to both of them. + // If filesystem is null, it'll ignore f. + void RecursiveSaveToFile( IBaseFileSystem *filesystem, FileHandle_t f, CUtlBuffer *pBuf, int indentLevel ); + void WriteConvertedString( IBaseFileSystem *filesystem, FileHandle_t f, CUtlBuffer *pBuf, const char *pszString ); + + void RecursiveLoadFromBuffer( char const *resourceName, CUtlBuffer &buf ); + + // For handling #include "filename" + void AppendIncludedKeys( CUtlVector< KeyValues * >& includedKeys ); + void ParseIncludedKeys( char const *resourceName, const char *filetoinclude, + IBaseFileSystem* pFileSystem, const char *pPathID, CUtlVector< KeyValues * >& includedKeys ); + + // NOTE: If both filesystem and pBuf are non-null, it'll save to both of them. + // If filesystem is null, it'll ignore f. + void InternalWrite( IBaseFileSystem *filesystem, FileHandle_t f, CUtlBuffer *pBuf, const void *pData, int len ); + + void Init(); + const char * ReadToken( CUtlBuffer &buf, bool &wasQuoted ); + void WriteIndents( IBaseFileSystem *filesystem, FileHandle_t f, CUtlBuffer *pBuf, int indentLevel ); + + void FreeAllocatedValue(); + void AllocateValueBlock(int size); + + int m_iKeyName; // keyname is a symbol defined in KeyValuesSystem + + // These are needed out of the union because the API returns string pointers + char *m_sValue; + wchar_t *m_wsValue; + + // we don't delete these + union + { + int m_iValue; + float m_flValue; + void *m_pValue; + unsigned char m_Color[4]; + }; + +#ifdef _XBOX + char m_iDataType; + char m_bHasEscapeSequences; // true, if while parsing this KeyValue, Escape Sequences are used (default false) + char reserved[2]; + + KeyValues *m_pPeer; // pointer to next key in list + KeyValues *m_pSub; // pointer to Start of a new sub key list + KeyValues *m_pChain;// Search here if it's not in our list +#else + char m_iDataType; + char reserved[5]; + + KeyValues *m_pPeer; // pointer to next key in list + KeyValues *m_pSub; // pointer to Start of a new sub key list + KeyValues *m_pChain;// Search here if it's not in our list + char m_bHasEscapeSequences; // true, if while parsing this KeyValue, Escape Sequences are used (default false) +#endif +}; + + +//----------------------------------------------------------------------------- +// inline methods +//----------------------------------------------------------------------------- +inline int KeyValues::GetInt( int keySymbol, int defaultValue ) +{ + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->GetInt( (const char *)NULL, defaultValue ) : defaultValue; +} + +inline float KeyValues::GetFloat( int keySymbol, float defaultValue ) +{ + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->GetFloat( (const char *)NULL, defaultValue ) : defaultValue; +} + +inline const char *KeyValues::GetString( int keySymbol, const char *defaultValue ) +{ + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->GetString( (const char *)NULL, defaultValue ) : defaultValue; +} + +inline const wchar_t *KeyValues::GetWString( int keySymbol, const wchar_t *defaultValue ) +{ + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->GetWString( (const char *)NULL, defaultValue ) : defaultValue; +} + +inline void *KeyValues::GetPtr( int keySymbol, void *defaultValue ) +{ + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->GetPtr( (const char *)NULL, defaultValue ) : defaultValue; +} + +inline Color KeyValues::GetColor( int keySymbol ) +{ + Color defaultValue( 0, 0, 0, 0 ); + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->GetColor( ) : defaultValue; +} + +inline bool KeyValues::IsEmpty( int keySymbol ) +{ + KeyValues *dat = FindKey( keySymbol ); + return dat ? dat->IsEmpty( ) : true; +} + + +#endif // KEYVALUES_H diff --git a/utils/vprojtomake/vprojtomake.cpp b/utils/vprojtomake/vprojtomake.cpp index 284fb77..ecab487 100644 --- a/utils/vprojtomake/vprojtomake.cpp +++ b/utils/vprojtomake/vprojtomake.cpp @@ -13,9 +13,9 @@ #endif #include "vstdlib/strtools.h" #include "tier0/dbg.h" -#include "KeyValues.h" +#include "keyvalues.h" #include "cmdlib.h" -#include "vstdlib/ICommandLine.h" +#include "vstdlib/icommandline.h" #include "vcprojconvert.h" #include "makefilecreator.h" diff --git a/utils/vprojtomake/vprojtomake.cpp~ b/utils/vprojtomake/vprojtomake.cpp~ new file mode 100644 index 0000000..25ec2fd --- /dev/null +++ b/utils/vprojtomake/vprojtomake.cpp~ @@ -0,0 +1,133 @@ +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// +#include "stdafx.h" +#include +#ifdef _WIN32 +#include +#elif _LINUX +#define stricmp strcasecmp +#endif +#include "vstdlib/strtools.h" +#include "tier0/dbg.h" +#include "KeyValues.h" +#include "cmdlib.h" +#include "vstdlib/icommandline.h" +#include "vcprojconvert.h" +#include "makefilecreator.h" + +SpewRetval_t SpewFunc( SpewType_t type, char const *pMsg ) +{ + printf( "%s", pMsg ); +#ifdef _WIN32 + OutputDebugString( pMsg ); +#endif + + if ( type == SPEW_ERROR ) + { + printf( "\n" ); +#ifdef _WIN32 + OutputDebugString( "\n" ); +#endif + } + else if (type == SPEW_ASSERT) + { + return SPEW_DEBUGGER; + } + + return SPEW_CONTINUE; +} + +class MyFileSystem : public IBaseFileSystem +{ +public: + int Read( void* pOutput, int size, FileHandle_t file ) { return fread( pOutput, 1, size, (FILE *)file); } + int Write( void const* pInput, int size, FileHandle_t file ) { return fwrite( pInput, 1, size, (FILE *)file); } + FileHandle_t Open( const char *pFileName, const char *pOptions, const char *pathID = 0 ) { return (FileHandle_t)fopen( pFileName, pOptions); } + void Close( FileHandle_t file ) { fclose( (FILE *)file ); } + void Seek( FileHandle_t file, int pos, FileSystemSeek_t seekType ) {} + unsigned int Tell( FileHandle_t file ) { return 0;} + unsigned int Size( FileHandle_t file ) { return 0;} + unsigned int Size( const char *pFileName, const char *pPathID = 0 ) { return 0; } + void Flush( FileHandle_t file ) { fflush((FILE *)file); } + bool Precache( const char *pFileName, const char *pPathID = 0 ) {return false;} + bool FileExists( const char *pFileName, const char *pPathID = 0 ) {return false;} + bool IsFileWritable( char const *pFileName, const char *pPathID = 0 ) {return false;} + bool SetFileWritable( char const *pFileName, bool writable, const char *pPathID = 0 ) {return false;} + long GetFileTime( const char *pFileName, const char *pPathID = 0 ) { return 0; } + bool ReadFile( const char *pFileName, const char *pPath, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) {return false;} + bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) {return false;} +}; + +MyFileSystem g_MyFS; +IBaseFileSystem *g_pFileSystem = &g_MyFS; + +//----------------------------------------------------------------------------- +// Purpose: help text +//----------------------------------------------------------------------------- +void printusage( void ) +{ + Msg( "usage: vcprojtomake \n" ); +} + +//----------------------------------------------------------------------------- +// Purpose: debug helper, spits out a human readable keyvalues version of the various configs +//----------------------------------------------------------------------------- +void OutputKeyValuesVersion( CVCProjConvert & proj ) +{ + KeyValues *kv = new KeyValues( "project" ); + for ( int projIndex = 0; projIndex < proj.GetNumConfigurations(); projIndex++ ) + { + CVCProjConvert::CConfiguration & config = proj.GetConfiguration(projIndex); + KeyValues *configKv = kv->FindKey( config.GetName().String(), true ); + int fileCount = 0; + for( int fileIndex = 0; fileIndex < config.GetNumFileNames(); fileIndex++ ) + { + if ( config.GetFileType(fileIndex) == CVCProjConvert::CConfiguration::FILE_SOURCE ) + { + char num[20]; + Q_snprintf( num, sizeof(num), "%i", fileCount ); + fileCount++; + configKv->SetString( num, config.GetFileName(fileIndex) ); + } + } + } + kv->SaveToFile( g_pFileSystem, "files.vdf" ); + kv->deleteThis(); +} + +//----------------------------------------------------------------------------- +// Purpose: +// Input : argc - +// argv[] - +// Output : int +//----------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + SpewOutputFunc( SpewFunc ); + + Msg( "Valve Software - vcprojtomake.exe (%s)\n", __DATE__ ); + CommandLine()->CreateCmdLine( argc, argv ); + + if ( CommandLine()->ParmCount() < 2) + { + printusage(); + return 0; + } + + CVCProjConvert proj; + if ( !proj.LoadProject( CommandLine()->GetParm( 1 )) ) + { + Msg( "Failed to parse project\n" ); + return -1; + } + + OutputKeyValuesVersion(proj); + + CMakefileCreator makefile; + makefile.CreateMakefiles( proj ); + return 0; +}