Fixed files
This commit is contained in:
parent
e706b772a0
commit
31faed3d95
15 changed files with 2543 additions and 4 deletions
106
linux_sdk/Makefile
Normal file
106
linux_sdk/Makefile
Normal file
|
|
@ -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 <proj name>_<build type><build target>)
|
||||||
|
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
|
||||||
|
|
||||||
20
linux_sdk/Makefile.mod
Normal file
20
linux_sdk/Makefile.mod
Normal file
|
|
@ -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)
|
||||||
54
linux_sdk/Makefile.plugin
Normal file
54
linux_sdk/Makefile.plugin
Normal file
|
|
@ -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)
|
||||||
60
linux_sdk/Makefile.vcpm
Normal file
60
linux_sdk/Makefile.vcpm
Normal file
|
|
@ -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
|
||||||
106
linux_sdk/Makefile~
Normal file
106
linux_sdk/Makefile~
Normal file
|
|
@ -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 <proj name>_<build type><build target>)
|
||||||
|
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
|
||||||
|
|
||||||
60
linux_sdk/makefile.vcpm~
Normal file
60
linux_sdk/makefile.vcpm~
Normal file
|
|
@ -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
|
||||||
106
linux_sdk/makefile~
Normal file
106
linux_sdk/makefile~
Normal file
|
|
@ -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 <proj name>_<build type><build target>)
|
||||||
|
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
|
||||||
|
|
||||||
BIN
linux_sdk/obj/vcpm/makefilecreator.o
Normal file
BIN
linux_sdk/obj/vcpm/makefilecreator.o
Normal file
Binary file not shown.
BIN
linux_sdk/obj/vcpm/vprojtomake.o
Normal file
BIN
linux_sdk/obj/vcpm/vprojtomake.o
Normal file
Binary file not shown.
690
public/filesystem.h~
Normal file
690
public/filesystem.h~
Normal file
|
|
@ -0,0 +1,690 @@
|
||||||
|
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//=============================================================================//
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
// need this for _alloca
|
// need this for _alloca
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <new.h>
|
#include <new>
|
||||||
|
|
||||||
// need this for memset
|
// need this for memset
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -246,7 +246,7 @@ typedef void * HINSTANCE;
|
||||||
#elif _LINUX
|
#elif _LINUX
|
||||||
#define ALIGN16 __attribute__((aligned(16)))
|
#define ALIGN16 __attribute__((aligned(16)))
|
||||||
#define ALIGN32 __attribute__((aligned(32)))
|
#define ALIGN32 __attribute__((aligned(32)))
|
||||||
#elif
|
#else
|
||||||
#define ALIGN16 /* */
|
#define ALIGN16 /* */
|
||||||
#define ALIGN32 /* */
|
#define ALIGN32 /* */
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
891
public/tier0/platform.h~
Normal file
891
public/tier0/platform.h~
Normal file
|
|
@ -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 <malloc.h>
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
// need this for memset
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#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 <limits.h>
|
||||||
|
#include <float.h>
|
||||||
|
|
||||||
|
// 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 <typename T>
|
||||||
|
inline T WordSwapC( T w )
|
||||||
|
{
|
||||||
|
uint16 temp;
|
||||||
|
|
||||||
|
temp = ((*((uint16 *)&w) & 0xff00) >> 8);
|
||||||
|
temp |= ((*((uint16 *)&w) & 0x00ff) << 8);
|
||||||
|
|
||||||
|
return *((T*)&temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
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 <typename T>
|
||||||
|
inline T WordSwapAsm( T w )
|
||||||
|
{
|
||||||
|
__asm
|
||||||
|
{
|
||||||
|
mov ax, w
|
||||||
|
xchg al, ah
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
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>( 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 <class T>
|
||||||
|
inline void Construct( T* pMemory )
|
||||||
|
{
|
||||||
|
::new( pMemory ) T;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
inline void CopyConstruct( T* pMemory, T const& src )
|
||||||
|
{
|
||||||
|
::new( pMemory ) T(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
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<int argument>
|
||||||
|
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<const int nArgument> \
|
||||||
|
struct __Function_##NAME \
|
||||||
|
{ \
|
||||||
|
static RETURN_TYPE FASTCALL Run ARGS; \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
template <const int i> \
|
||||||
|
struct __MetaLooper_##NAME : __MetaLooper_##NAME<i-1> \
|
||||||
|
{ \
|
||||||
|
__Type_##NAME func; \
|
||||||
|
inline __MetaLooper_##NAME() { func = __Function_##NAME<i>::Run; } \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
template<> \
|
||||||
|
struct __MetaLooper_##NAME<0> \
|
||||||
|
{ \
|
||||||
|
__Type_##NAME func; \
|
||||||
|
inline __MetaLooper_##NAME() { func = __Function_##NAME<0>::Run; } \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
class NAME \
|
||||||
|
{ \
|
||||||
|
private: \
|
||||||
|
static const __MetaLooper_##NAME<COUNT> m; \
|
||||||
|
public: \
|
||||||
|
enum { count = COUNT }; \
|
||||||
|
static const __Type_##NAME* functions; \
|
||||||
|
}; \
|
||||||
|
const __MetaLooper_##NAME<COUNT> NAME::m; \
|
||||||
|
const __Type_##NAME* NAME::functions = (__Type_##NAME*)&m; \
|
||||||
|
template<const int nArgument> \
|
||||||
|
RETURN_TYPE FASTCALL __Function_##NAME<nArgument>::Run ARGS
|
||||||
|
|
||||||
|
|
||||||
|
#define LOOP_INTERCHANGE(BOOLEAN, CODE)\
|
||||||
|
if( (BOOLEAN) )\
|
||||||
|
{\
|
||||||
|
CODE;\
|
||||||
|
} else\
|
||||||
|
{\
|
||||||
|
CODE;\
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "tier0/valve_on.h"
|
||||||
|
|
||||||
|
#endif /* PLATFORM_H */
|
||||||
313
public/tier1/keyvalues.h~
Normal file
313
public/tier1/keyvalues.h~
Normal file
|
|
@ -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 <vgui/VGUI.h>
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
@ -13,9 +13,9 @@
|
||||||
#endif
|
#endif
|
||||||
#include "vstdlib/strtools.h"
|
#include "vstdlib/strtools.h"
|
||||||
#include "tier0/dbg.h"
|
#include "tier0/dbg.h"
|
||||||
#include "KeyValues.h"
|
#include "keyvalues.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "vstdlib/ICommandLine.h"
|
#include "vstdlib/icommandline.h"
|
||||||
#include "vcprojconvert.h"
|
#include "vcprojconvert.h"
|
||||||
#include "makefilecreator.h"
|
#include "makefilecreator.h"
|
||||||
|
|
||||||
|
|
|
||||||
133
utils/vprojtomake/vprojtomake.cpp~
Normal file
133
utils/vprojtomake/vprojtomake.cpp~
Normal file
|
|
@ -0,0 +1,133 @@
|
||||||
|
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||||
|
//
|
||||||
|
// Purpose:
|
||||||
|
//
|
||||||
|
// $NoKeywords: $
|
||||||
|
//=============================================================================//
|
||||||
|
#include "stdafx.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
#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 <vcproj filename> \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;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue