diff --git a/.clang-format b/.clang-format index 253ff136..f405e7d7 100644 --- a/.clang-format +++ b/.clang-format @@ -1,36 +1,160 @@ --- +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignArrayOfStructures: Left +AlignConsecutiveMacros: true +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: InlineOnly +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: Empty +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: Yes +AttributeMacros: + - CONSTRUCT_EARLY + - DLL_CLASS_EXPORT + - DLL_CLASS_IMPORT + - DLL_EXPORT + - DLL_GLOBAL_EXPORT + - DLL_GLOBAL_IMPORT + - DLL_IMPORT + - EXPLICIT + - FASTCALL + - FMTFUNCTION + - FORCEINLINE + - FORCEINLINE_TEMPLATE + - MULTIPLE_INHERITANCE + - NOINLINE + - NO_VTABLE + - NULLTERMINATED + - PLATFORM_INTERFACE + - RESTRICT + - RESTRICT_FUNC + - SELECTANY + - SELECTOR + - SINGLE_INHERITANCE + - STDCALL + - TEMPLATE_SPEC_STATIC + - TEMPLATE_STATIC +BinPackArguments: true +BinPackParameters: true +BitFieldColonSpacing: Both +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Allman +BreakBeforeConceptDeclarations: Always +BreakBeforeTernaryOperators: false +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterComma +ColumnLimit: 0 +CompactNamespaces: false +ContinuationIndentWidth: 4 +ConstructorInitializerAllOnOneLineOrOnePerLine: false +Cpp11BracedListStyle: true +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false +EmptyLineBeforeAccessModifier: LogicalBlock +FixNamespaceComments: false +ForEachMacros: + - FOR_EACH_CURRENCY + - FOR_EACH_DICT + - FOR_EACH_DICT_FAST + - FOR_EACH_ENTLIST + - FOR_EACH_ENTLIST_HEAD + - FOR_EACH_HASHMAP + - FOR_EACH_HASHMAP_LRU + - FOR_EACH_HASHTABLE + - FOR_EACH_LL + - FOR_EACH_LL_BACK + - FOR_EACH_MAP + - FOR_EACH_MAP_BACK + - FOR_EACH_MAP_FAST + - FOR_EACH_OBJ + - FOR_EACH_PTR_ARRAY + - FOR_EACH_RBTREE_FAST + - FOR_EACH_SUBKEY + - FOR_EACH_TRUE_SUBKEY + - FOR_EACH_UTLRBTREE + - FOR_EACH_VALID_SPLITSCREEN_PLAYER + - FOR_EACH_VALUE + - FOR_EACH_VEC + - FOR_EACH_VEC_BACK +IncludeBlocks: Regroup +IncludeCategories: + - Regex: "cbase.h" + Priority: -1 + - Regex: "stdafx_client.h" + Priority: -1 + - Regex: "stdafx.h" + Priority: -1 + - Regex: "pch_tier0.h" + Priority: -1 + - Regex: "tier0/memdbgon.h" + Priority: 10000 + - Regex: ".*" + Priority: 1 +IndentCaseBlocks: true +IndentCaseLabels: false +IndentPPDirectives: None +IndentRequiresClause: true +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: Signature Language: Cpp -BasedOnStyle: Microsoft -Standard: Cpp11 - -AlignOperands: false - -IndentCaseLabels: 'true' -IndentPPDirectives: BeforeHash -IndentWidth: '4' - -FixNamespaceComments: 'true' +MacroBlockBegin: "^BEGIN_.*|IMPLEMENT_CLIENTCLASS_?.*_DT|IMPLEMENT_SERVERCLASS_.*$|^PRECACHE_REGISTER_BEGIN.*$" +MacroBlockEnd: "^END_.*$|^PRECACHE_REGISTER_END.*$" +MaxEmptyLinesToKeep: 1 NamespaceIndentation: All - -PointerAlignment: Right - -SortIncludes: 'false' - -TabWidth: '4' +PackConstructorInitializers: BinPack +PenaltyReturnTypeOnItsOwnLine: 1000000 +PointerAlignment: Right # todo: change to Left +PPIndentWidth: 1 +ReferenceAlignment: Right # todo: change to Left +ReflowComments: true +RequiresClausePosition: OwnLine +SeparateDefinitionBlocks: Always +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: true +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInConditionalStatement: true +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: true +SpacesInSquareBrackets: false +Standard: c++20 +StatementMacros: + - DECLARE_CLIENTCLASS + - DECLARE_CLIENTCLASS_NOBASE + - DECLARE_SERVERCLASS + - DECLARE_SERVERCLASS_NOBASE + - IMPLEMENT_CLIENTCLASS + - IMPLEMENT_SERVERCLASS + - NOTE_UNUSED +TabWidth: 4 UseTab: Always +UseCRLF: false +WhitespaceSensitiveMacros: + - MKSTRING -AccessModifierOffset: -4 - -SpacesInAngles: 'false' -SpacesInCStyleCastParentheses: 'false' -SpacesInConditionalStatement: 'true' -SpacesInContainerLiterals: 'false' -SpacesInParentheses: 'true' -SpacesInSquareBrackets: 'false' - -ReflowComments: 'false' - -PenaltyExcessCharacter: 0 --- Language: Proto DisableFormat: true \ No newline at end of file diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..aa480219 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ + +root = true + +[*] +insert_final_newline = true +indent_style = tab +indent_size = 4 +trim_trailing_whitespace = false +end_of_line = lf diff --git a/createallprojects b/createallprojects new file mode 100755 index 00000000..665824f1 --- /dev/null +++ b/createallprojects @@ -0,0 +1,2 @@ +#!/bin/sh +devtools/bin/vpc /vance +everything /mksln everything diff --git a/creategameprojects b/creategameprojects new file mode 100755 index 00000000..4928947e --- /dev/null +++ b/creategameprojects @@ -0,0 +1,2 @@ +#!/bin/sh +devtools/bin/vpc /vance +game +game_shader_dx9 /mksln games diff --git a/devtools/bin/linux/ccache b/devtools/bin/linux/ccache old mode 100644 new mode 100755 diff --git a/devtools/bin/vpc b/devtools/bin/vpc old mode 100644 new mode 100755 diff --git a/devtools/bin/vpc_linux b/devtools/bin/vpc_linux old mode 100644 new mode 100755 diff --git a/devtools/bin/vpc_osx b/devtools/bin/vpc_osx old mode 100644 new mode 100755 diff --git a/devtools/gendbg.sh b/devtools/gendbg.sh old mode 100644 new mode 100755 diff --git a/devtools/makefile_base_posix.mak b/devtools/makefile_base_posix.mak new file mode 100644 index 00000000..2eac4a2d --- /dev/null +++ b/devtools/makefile_base_posix.mak @@ -0,0 +1,453 @@ +# +# Base makefile for Linux. +# +# !!!!! Note to future editors !!!!! +# +# before you make changes, make sure you grok: +# 1. the difference between =, :=, +=, and ?= +# 2. how and when this base makefile gets included in the generated makefile(s) +# ( see http://www.gnu.org/software/make/manual/make.html#Flavors ) +# +# Command line prefixes: +# - errors are ignored +# @ command is not printed to stdout before being executed +# + command is executed even if Make is invoked in "do not exec" mode + +OS := $(shell uname) +HOSTNAME := $(shell hostname) + +-include $(SRCROOT)/devtools/steam_def.mak +-include $(SRCROOT)/devtools/sourcesdk_def.mak + +# To build with clang, set the following in your environment: +# CC = clang +# CXX = clang++ +ifneq (,$(findstring clang,$(CXX))) + CLANG_BUILD = 1 +endif + +ifeq ($(OS),Darwin) + $(error This file should never be used for Mac - use base.xconfig) +endif + +ifeq ($(CFG), release) + # With gcc 4.6.3, engine.so went from 7,383,765 to 8,429,109 when building with -O3. + # There also was no speed difference running at 1280x1024. May 2012, mikesart. + # tonyp: The size increase was likely caused by -finline-functions and -fipa-cp-clone getting switched on with -O3. + # -fno-omit-frame-pointer: need this for stack traces with perf. + OptimizerLevel_CompilerSpecific = -O2 -fno-strict-aliasing -ffast-math -fno-omit-frame-pointer -ftree-vectorize + ifeq ($(CLANG_BUILD),1) + # These aren't supported wit Clang 3.5. Need to remove when we update that. + OptimizerLevel_CompilerSpecific += -fpredictive-commoning -funswitch-loops + else + OptimizerLevel_CompilerSpecific += -fpredictive-commoning -funswitch-loops + endif +else + OptimizerLevel_CompilerSpecific = -O0 + #-O1 -finline-functions +endif + +# CPPFLAGS == "c/c++ *preprocessor* flags" - not "cee-plus-plus flags" +ARCH_FLAGS = +BUILDING_MULTI_ARCH = 0 +# Preserve cflags set in environment +ENV_CFLAGS := $(CFLAGS) +ENV_CXXFLAGS := $(CXXFLAGS) +CPPFLAGS = $(DEFINES) $(addprefix -I, $(abspath $(INCLUDEDIRS) )) +BASE_CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility) $(OptimizerLevel) -pipe $(GCC_ExtraCompilerFlags) -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE +CFLAGS = $(BASE_CFLAGS) $(ENV_CFLAGS) +# In -std=gnu++0x mode we get lots of errors about "error: narrowing conversion". -fpermissive +# turns these into warnings in gcc, and -Wno-c++11-narrowing suppresses them entirely in clang 3.1+. +ifeq ($(CLANG_BUILD),1) + CXXFLAGS = $(BASE_CFLAGS) -std=gnu++0x -Wno-c++11-narrowing -Wno-dangling-else $(ENV_CXXFLAGS) +else + # !!! ABI COMPAT: -fabi-compat-version=2 is needed to generate the proper symbols for linking + CXXFLAGS = $(BASE_CFLAGS) -std=gnu++0x -fpermissive -fabi-compat-version=2 $(ENV_CXXFLAGS) + # Diagnostics coloring + CXXFLAGS += -fdiagnostics-color=always +endif +DEFINES += -DVPROF_LEVEL=1 -DGNUC -DNO_HOOK_MALLOC -DNO_MALLOC_OVERRIDE + +## TODO: This cases build errors in cstrike/bin right now. Need to debug. +# This causes all filesystem interfaces to default to their 64bit versions on +# 32bit systems, which means we don't break on filesystems with inodes > 32bit. +# DEFINES += -D_FILE_OFFSET_BITS=64 + +LDFLAGS = $(CFLAGS) $(GCC_ExtraLinkerFlags) $(OptimizerLevel) +GENDEP_CXXFLAGS = -MMD -MP -MF $(@:.o=.P) +MAP_FLAGS = +Srv_GAMEOUTPUTFILE = +COPY_DLL_TO_SRV = 0 + +# We should always specify -Wl,--build-id, as documented at: +# http://linux.die.net/man/1/ld and http://fedoraproject.org/wiki/Releases/FeatureBuildId.http://fedoraproject.org/wiki/Releases/FeatureBuildId +LDFLAGS += -Wl,--build-id + +GCC_VER = +P4BIN = p4 +CRYPTOPPDIR=ubuntu12_32 + +ifeq ($(TARGET_PLATFORM),linux64) + MARCH_TARGET = core2 +else + MARCH_TARGET = pentium4 +endif + +ifeq ($(USE_VALVE_BINDIR),1) + # On dedicated servers, some plugins depend on global variable symbols in addition to functions. + # So symbols like _Z16ClearMultiDamagev should show up when you do "nm server_srv.so" in TF2. + STRIP_FLAGS = +else + # Linux desktop client (or client/dedicated server in chroot). + STRIP_FLAGS = -x +endif + +ifeq ($(CLANG_BUILD),1) + # Clang does not support -mfpmath=sse because it uses whatever + # instruction set extensions are available by default. + SSE_GEN_FLAGS = -msse2 +else + SSE_GEN_FLAGS = -msse2 -mfpmath=sse +endif + +CCACHE := $(SRCROOT)/devtools/bin/linux/ccache + +ifeq ($(origin AR), default) + AR = ar crs +endif +ifeq ($(origin CC), default) + CC = $(CCACHE) gcc$(GCC_VER) +endif +ifeq ($(origin CXX), default) + CXX = $(CCACHE) g++$(GCC_VER) +endif + +# Support ccache with clang. Add -Qunused-arguments to avoid excessive warnings due to +# a ccache quirk. Could also upgrade ccache. +# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html +ifeq ($(CLANG_BUILD),1) + CC := $(CCACHE) $(CC) -Qunused-arguments -fcolor-diagnostics + CXX := $(CCACHE) $(CXX) -Qunused-arguments -fcolor-diagnostics +endif +LINK ?= $(CC) + +ifeq ($(STEAM_BRANCH),1) + WARN_FLAGS = -Wall -Wextra -Wshadow -Wno-invalid-offsetof +else + WARN_FLAGS = -Wall -Wno-invalid-offsetof -Wno-multichar -Wno-overloaded-virtual + WARN_FLAGS += -Wno-write-strings + WARN_FLAGS += -Wno-unused-variable + WARN_FLAGS += -Wno-unused-but-set-variable + WARN_FLAGS += -Wno-unused-function +endif + +ifeq ($(CLANG_BUILD),1) + # Clang specific flags +else ifeq ($(GCC_VER),-4.8) + WARN_FLAGS += -Wno-unused-local-typedefs + WARN_FLAGS += -Wno-unused-result + WARN_FLAGS += -Wno-narrowing + # WARN_FLAGS += -Wno-unused-function +endif + +WARN_FLAGS += -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers +WARN_FLAGS += -Wno-sign-compare -Wno-reorder -Wno-invalid-offsetof -Wno-float-equal -Werror=return-type -Wno-narrowing +WARN_FLAGS += -fdiagnostics-show-option -Wformat -Wformat-security +WARN_FLAGS += -Wno-class-memaccess -Wno-unused-local-typedefs -Wno-ignored-attributes + +ifeq ($(TARGET_PLATFORM),linux64) + # nocona = pentium4 + 64bit + MMX, SSE, SSE2, SSE3 - no SSSE3 (that's three s's - added in core2) + ARCH_FLAGS += -march=$(MARCH_TARGET) -mtune=core2 + LD_SO = ld-linux-x86_64.so.2 + LIBSTDCXX := $(shell $(CXX) -print-file-name=libstdc++.a) + LIBSTDCXXPIC := $(shell $(CXX) -print-file-name=libstdc++-pic.a) +else + # pentium4 = MMX, SSE, SSE2 - no SSE3 (added in prescott) # -msse3 -mfpmath=sse + ARCH_FLAGS += -m32 -march=$(MARCH_TARGET) -mtune=core2 $(SSE_GEN_FLAGS) + LD_SO = ld-linux.so.2 + LIBSTDCXX := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so) + LIBSTDCXXPIC := $(shell $(CXX) $(ARCH_FLAGS) -print-file-name=libstdc++.so) + LDFLAGS += -m32 +endif + +GEN_SYM ?= $(SRCROOT)/devtools/gendbg.sh +ifeq ($(CFG),release) + STRIP ?= strip $(STRIP_FLAGS) -S +# CFLAGS += -ffunction-sections -fdata-sections +# LDFLAGS += -Wl,--gc-sections -Wl,--print-gc-sections +else + STRIP ?= true +endif +VSIGN ?= true + +ifeq ($(SOURCE_SDK), 1) + Srv_GAMEOUTPUTFILE := $(GAMEOUTPUTFILE:.so=_srv.so) + COPY_DLL_TO_SRV := 1 +endif + +LINK_MAP_FLAGS = -Wl,-Map,$(@:.so=).map + +SHLIBLDFLAGS = -shared $(LDFLAGS) -Wl,--no-undefined + +_WRAP := -Xlinker --wrap= +PATHWRAP = $(_WRAP)fopen $(_WRAP)freopen $(_WRAP)open $(_WRAP)creat $(_WRAP)access $(_WRAP)__xstat \ + $(_WRAP)stat $(_WRAP)lstat $(_WRAP)fopen64 $(_WRAP)open64 $(_WRAP)opendir $(_WRAP)__lxstat \ + $(_WRAP)chmod $(_WRAP)chown $(_WRAP)lchown $(_WRAP)symlink $(_WRAP)link $(_WRAP)__lxstat64 \ + $(_WRAP)mknod $(_WRAP)utimes $(_WRAP)unlink $(_WRAP)rename $(_WRAP)utime $(_WRAP)__xstat64 \ + $(_WRAP)mount $(_WRAP)mkfifo $(_WRAP)mkdir $(_WRAP)rmdir $(_WRAP)scandir $(_WRAP)realpath + +LIB_START_EXE = $(PATHWRAP) -static-libgcc -Wl,--start-group +LIB_END_EXE = -Wl,--end-group -lm -ldl $(LIBSTDCXX) -lpthread + +LIB_START_SHLIB = $(PATHWRAP) -static-libgcc -Wl,--start-group +LIB_END_SHLIB = -Wl,--end-group -lm -ldl $(LIBSTDCXXPIC) -lpthread -l:$(LD_SO) -Wl,--version-script=$(SRCROOT)/devtools/version_script.linux.txt + +# +# Profile-directed optimizations. +# Note: Last time these were tested 3/5/08, it actually slowed down the server benchmark by 5%! +# +# First, uncomment these, build, and test. It will generate .gcda and .gcno files where the .o files are. +# PROFILE_LINKER_FLAG=-fprofile-arcs +# PROFILE_COMPILER_FLAG=-fprofile-arcs +# +# Then, comment the above flags out again and rebuild with this flag uncommented: +# PROFILE_COMPILER_FLAG=-fprofile-use +# + +############################################################################# +# The compiler command lne for each src code file to compile +############################################################################# + +OBJ_DIR = ./obj_$(NAME)_$(TARGET_PLATFORM)$(TARGET_PLATFORM_EXT)/$(CFG) +CPP_TO_OBJ = $(CPPFILES:.cpp=.o) +CXX_TO_OBJ = $(CPP_TO_OBJ:.cxx=.o) +CC_TO_OBJ = $(CXX_TO_OBJ:.cc=.o) +MM_TO_OBJ = $(CC_TO_OBJ:.mm=.o) +C_TO_OBJ = $(MM_TO_OBJ:.c=.o) +OBJS = $(addprefix $(OBJ_DIR)/, $(notdir $(C_TO_OBJ))) + +ifeq ($(MAKE_VERBOSE),1) + QUIET_PREFIX = + QUIET_ECHO_POSTFIX = +else + QUIET_PREFIX = @ + QUIET_ECHO_POSTFIX = > /dev/null +endif + +ifeq ($(MAKE_CC_VERBOSE),1) +CC += -v +endif + +ifeq ($(CONFTYPE),lib) + LIB_File = $(OUTPUTFILE) +endif + +ifeq ($(CONFTYPE),dll) + SO_File = $(OUTPUTFILE) +endif + +ifeq ($(CONFTYPE),exe) + EXE_File = $(OUTPUTFILE) +endif + +# we generate dependencies as a side-effect of compilation now +GEN_DEP_FILE= + +PRE_COMPILE_FILE = + +POST_COMPILE_FILE = + +ifeq ($(BUILDING_MULTI_ARCH),1) + SINGLE_ARCH_CXXFLAGS=$(subst -arch x86_64,,$(CXXFLAGS)) + COMPILE_FILE = \ + $(QUIET_PREFIX) \ + echo "---- $(lastword $(subst /, ,$<)) as MULTIARCH----";\ + mkdir -p $(OBJ_DIR) && \ + $(CXX) $(SINGLE_ARCH_CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $< && \ + $(CXX) $(CXXFLAGS) -o $@ -c $< +else + COMPILE_FILE = \ + $(QUIET_PREFIX) \ + echo "---- $(lastword $(subst /, ,$<)) ----";\ + mkdir -p $(OBJ_DIR) && \ + $(CXX) $(CXXFLAGS) $(GENDEP_CXXFLAGS) -o $@ -c $< +endif + +ifneq "$(origin VALVE_NO_AUTO_P4)" "undefined" + P4_EDIT_START = chmod -R +w + P4_EDIT_END = || true + P4_REVERT_START = true + P4_REVERT_END = +else + ifndef P4_EDIT_CHANGELIST + # You can use an environment variable to specify what changelist to check the Linux Binaries out into. Normally the default + # setting is best, but here is an alternate example: + # export P4_EDIT_CHANGELIST_CMD="echo 1424335" + # ?= means that if P4_EDIT_CHANGELIST_CMD is already set it won't be changed. + P4_EDIT_CHANGELIST_CMD ?= $(P4BIN) changes -c `$(P4BIN) client -o | grep ^Client | cut -f 2` -s pending | fgrep 'POSIX Auto Checkout' | cut -d' ' -f 2 | tail -n 1 + P4_EDIT_CHANGELIST := $(shell $(P4_EDIT_CHANGELIST_CMD)) + endif + ifeq ($(P4_EDIT_CHANGELIST),) + # If we haven't found a changelist to check out to then create one. The name must match the one from a few + # lines above or else a new changelist will be created each time. + # Warning: the behavior of 'echo' is not consistent. In bash you need the "-e" option in order for \n to be + # interpreted as a line-feed, but in dash you do not, and if "-e" is passed along then it is printed, which + # confuses p4. So, if you run this command from the bash shell don't forget to add "-e" to the echo command. + P4_EDIT_CHANGELIST = $(shell echo -e "Change: new\nDescription: POSIX Auto Checkout" | $(P4BIN) change -i | cut -f 2 -d ' ') + endif + + P4_EDIT_START := for f in + P4_EDIT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | $(P4BIN) -x - edit -c $(P4_EDIT_CHANGELIST); else $(P4BIN) edit -c $(P4_EDIT_CHANGELIST) $$f; fi; fi; done $(QUIET_ECHO_POSTFIX) + P4_REVERT_START := for f in + P4_REVERT_END := ; do if [ -n $$f ]; then if [ -d $$f ]; then find $$f -type f -print | $(P4BIN) -x - revert; else $(P4BIN) revert $$f; fi; fi; done $(QUIET_ECHO_POSTFIX) +endif + +ifeq ($(CONFTYPE),dll) +all: $(OTHER_DEPENDENCIES) $(OBJS) $(GAMEOUTPUTFILE) + @echo $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX) +else +all: $(OTHER_DEPENDENCIES) $(OBJS) $(OUTPUTFILE) + @echo $(OUTPUTFILE) $(QUIET_ECHO_POSTFIX) +endif + +.PHONY: clean cleantargets cleanandremove rebuild relink RemoveOutputFile SingleFile + + +rebuild : + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) cleanandremove + $(MAKE) -f $(firstword $(MAKEFILE_LIST)) + + +# Use the relink target to force to relink the project. +relink: RemoveOutputFile all + +RemoveOutputFile: + rm -f $(OUTPUTFILE) + + +# This rule is so you can say "make SingleFile SingleFilename=/home/myname/valve_main/src/engine/language.cpp" and have it only build that file. +# It basically just translates the full filename to create a dependency on the appropriate .o file so it'll build that. +SingleFile : RemoveSingleFile $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o + @echo "" + +RemoveSingleFile: + $(QUIET_PREFIX) rm -f $(OBJ_DIR)/$(basename $(notdir $(SingleFilename))).o + +clean: +ifneq "$(OBJ_DIR)" "" + $(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)" + $(QUIET_PREFIX) rm -rf $(OBJ_DIR) +endif +ifneq "$(OUTPUTFILE)" "" + $(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \ + echo "$(P4BIN) revert $(OUTPUTFILE)"; \ + $(P4_REVERT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END); \ + fi; +endif +ifneq "$(OTHER_DEPENDENCIES)" "" + $(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)" + $(QUIET_PREFIX) rm -f $(OTHER_DEPENDENCIES) +endif +ifneq "$(GAMEOUTPUTFILE)" "" + $(QUIET_PREFIX) echo "$(P4BIN) revert $(GAMEOUTPUTFILE)" + $(QUIET_PREFIX) $(P4_REVERT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_REVERT_END) +endif + + +# Do the above cleaning, except with p4 edit and rm. Reason being ar crs adds and replaces obj files to the +# archive. However if you've renamed or deleted a source file, $(AR) won't remove it. This can leave +# us with archive files that have extra unused symbols, and also potentially cause compilation errors +# when you rename a file and have many duplicate symbols. +cleanandremove: +ifneq "$(OBJ_DIR)" "" + $(QUIET_PREFIX) echo "rm -rf $(OBJ_DIR)" + $(QUIET_PREFIX) -rm -rf $(OBJ_DIR) +endif +ifneq "$(OUTPUTFILE)" "" + $(QUIET_PREFIX) if [ -e $(OUTPUTFILE) ]; then \ + echo "$(P4BIN) edit and rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT)"; \ + $(P4_EDIT_START) $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); \ + fi; + $(QUIET_PREFIX) -rm -f $(OUTPUTFILE) $(OUTPUTFILE)$(SYM_EXT); +endif +ifneq "$(OTHER_DEPENDENCIES)" "" + $(QUIET_PREFIX) echo "rm -f $(OTHER_DEPENDENCIES)" + $(QUIET_PREFIX) -rm -f $(OTHER_DEPENDENCIES) +endif +ifneq "$(GAMEOUTPUTFILE)" "" + $(QUIET_PREFIX) echo "$(P4BIN) edit and rm -f $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT)" + $(QUIET_PREFIX) $(P4_EDIT_START) $(GAMEOUTPUTFILE) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END) + $(QUIET_PREFIX) -rm -f $(GAMEOUTPUTFILE) +endif + + +# This just deletes the final targets so it'll do a relink next time we build. +cleantargets: + $(QUIET_PREFIX) rm -f $(OUTPUTFILE) $(GAMEOUTPUTFILE) + + +$(LIB_File): $(OTHER_DEPENDENCIES) $(OBJS) + $(QUIET_PREFIX) -$(P4_EDIT_START) $(LIB_File) $(P4_EDIT_END); + $(QUIET_PREFIX) $(AR) $(LIB_File) $(OBJS) $(LIBFILES); + +SO_GameOutputFile = $(GAMEOUTPUTFILE) + +# Remove the target before installing a file over it; this prevents existing +# instances of the game from crashing due to the overwrite. +$(SO_GameOutputFile): $(SO_File) + $(QUIET_PREFIX) \ + $(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END) && \ + echo "----" $(QUIET_ECHO_POSTFIX);\ + echo "---- COPYING TO $@ [$(CFG)] ----";\ + echo "----" $(QUIET_ECHO_POSTFIX); + $(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE) $(P4_EDIT_END); + $(QUIET_PREFIX) -mkdir -p `dirname $(GAMEOUTPUTFILE)` > /dev/null; + $(QUIET_PREFIX) rm -f $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX); + $(QUIET_PREFIX) cp -v $(OUTPUTFILE) $(GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX); + $(QUIET_PREFIX) -$(P4_EDIT_START) $(GAMEOUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); + $(QUIET_PREFIX) $(GEN_SYM) $(GAMEOUTPUTFILE); + $(QUIET_PREFIX) -$(STRIP) $(GAMEOUTPUTFILE); + $(QUIET_PREFIX) $(VSIGN) -signvalve $(GAMEOUTPUTFILE); + $(QUIET_PREFIX) if [ "$(COPY_DLL_TO_SRV)" = "1" ]; then\ + echo "----" $(QUIET_ECHO_POSTFIX);\ + echo "---- COPYING TO $(Srv_GAMEOUTPUTFILE) ----";\ + echo "----" $(QUIET_ECHO_POSTFIX);\ + cp -v $(GAMEOUTPUTFILE) $(Srv_GAMEOUTPUTFILE) $(QUIET_ECHO_POSTFIX);\ + cp -v $(GAMEOUTPUTFILE)$(SYM_EXT) $(Srv_GAMEOUTPUTFILE)$(SYM_EXT) $(QUIET_ECHO_POSTFIX);\ + fi; + $(QUIET_PREFIX) if [ "$(IMPORTLIBRARY)" != "" ]; then\ + echo "----" $(QUIET_ECHO_POSTFIX);\ + echo "---- COPYING TO IMPORT LIBRARY $(IMPORTLIBRARY) ----";\ + echo "----" $(QUIET_ECHO_POSTFIX);\ + $(P4_EDIT_START) $(IMPORTLIBRARY) $(P4_EDIT_END) && \ + mkdir -p `dirname $(IMPORTLIBRARY)` > /dev/null && \ + cp -v $(OUTPUTFILE) $(IMPORTLIBRARY); \ + fi; + + +$(SO_File): $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES) + $(QUIET_PREFIX) \ + echo "----" $(QUIET_ECHO_POSTFIX);\ + echo "---- LINKING $@ [$(CFG)] ----";\ + echo "----" $(QUIET_ECHO_POSTFIX);\ + \ + $(LINK) $(LINK_MAP_FLAGS) $(SHLIBLDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_SHLIB) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_SHLIB); + $(VSIGN) -signvalve $(OUTPUTFILE); + + +$(EXE_File) : $(OTHER_DEPENDENCIES) $(OBJS) $(LIBFILENAMES) + $(QUIET_PREFIX) \ + echo "----" $(QUIET_ECHO_POSTFIX);\ + echo "---- LINKING EXE $@ [$(CFG)] ----";\ + echo "----" $(QUIET_ECHO_POSTFIX);\ + \ + $(P4_EDIT_START) $(OUTPUTFILE) $(P4_EDIT_END);\ + $(LINK) $(LINK_MAP_FLAGS) $(LDFLAGS) $(PROFILE_LINKER_FLAG) -o $(OUTPUTFILE) $(LIB_START_EXE) $(OBJS) $(LIBFILES) $(SystemLibraries) $(LIB_END_EXE); + $(QUIET_PREFIX) -$(P4_EDIT_START) $(OUTPUTFILE)$(SYM_EXT) $(P4_EDIT_END); + $(QUIET_PREFIX) $(GEN_SYM) $(OUTPUTFILE); + $(QUIET_PREFIX) -$(STRIP) $(OUTPUTFILE); + $(QUIET_PREFIX) $(VSIGN) -signvalve $(OUTPUTFILE); + + +tags: + etags -a -C -o $(SRCROOT)/TAGS *.cpp *.cxx *.h *.hxx \ No newline at end of file diff --git a/devtools/sourcesdk_def.mak b/devtools/sourcesdk_def.mak new file mode 100644 index 00000000..fc561ad7 --- /dev/null +++ b/devtools/sourcesdk_def.mak @@ -0,0 +1,3 @@ +#defines these macros so that we skip VSIGN and P4 steps in the SDK +SOURCE_SDK=1 +VALVE_NO_AUTO_P4=1 diff --git a/fgdlib/gamedata.cpp b/fgdlib/gamedata.cpp index f3689ee9..4bba8912 100644 --- a/fgdlib/gamedata.cpp +++ b/fgdlib/gamedata.cpp @@ -2,12 +2,16 @@ // //============================================================================= +#ifdef _WIN32 #include -#include #include -#include -#include "fgdlib/GameData.h" -#include "fgdlib/HelperInfo.h" +#endif + +#include + +#include +#include "fgdlib/gamedata.h" +#include "fgdlib/helperinfo.h" #include "KeyValues.h" #include "filesystem_tools.h" #include "tier1/strtools.h" @@ -280,8 +284,10 @@ BOOL GameData::Load(const char *pszFilename) { TokenReader tr; + #ifdef _WIN32 if(GetFileAttributes(pszFilename) == 0xffffffff) return FALSE; +#endif if(!tr.Open(pszFilename)) return FALSE; diff --git a/fgdlib/gdclass.cpp b/fgdlib/gdclass.cpp index 1de57b6a..779d0b64 100644 --- a/fgdlib/gdclass.cpp +++ b/fgdlib/gdclass.cpp @@ -4,8 +4,8 @@ // //============================================================================= -#include "fgdlib/GameData.h" // FGDLIB: eliminate dependency -#include "fgdlib/GDClass.h" +#include "fgdlib/gamedata.h" // FGDLIB: eliminate dependency +#include "fgdlib/gdclass.h" // memdbgon must be the last include file in a .cpp file!!! #include diff --git a/fgdlib/gdvar.cpp b/fgdlib/gdvar.cpp index fe8df025..a205f335 100644 --- a/fgdlib/gdvar.cpp +++ b/fgdlib/gdvar.cpp @@ -3,8 +3,8 @@ //============================================================================= #include "fgdlib/fgdlib.h" -#include "fgdlib/GameData.h" -#include "fgdlib/WCKeyValues.h" +#include "fgdlib/gamedata.h" +#include "fgdlib/wckeyvalues.h" #include "fgdlib/gdvar.h" // memdbgon must be the last include file in a .cpp file!!! @@ -669,7 +669,7 @@ void GDinputvariable::ToKeyValue(MDkeyvalue *pkv) } else if (eStoreAs == INTEGER) { - itoa(m_nValue, pkv->szValue, 10); + snprintf( pkv->szValue, 512, "%i", m_nValue ); } } diff --git a/fgdlib/inputoutput.cpp b/fgdlib/inputoutput.cpp index ee2b6033..d58b0547 100644 --- a/fgdlib/inputoutput.cpp +++ b/fgdlib/inputoutput.cpp @@ -6,7 +6,7 @@ #include -#include "fgdlib/InputOutput.h" +#include "fgdlib/inputoutput.h" // memdbgon must be the last include file in a .cpp file!!! #include diff --git a/fgdlib/wckeyvalues.cpp b/fgdlib/wckeyvalues.cpp index 83e52007..8a70ac0f 100644 --- a/fgdlib/wckeyvalues.cpp +++ b/fgdlib/wckeyvalues.cpp @@ -4,7 +4,7 @@ // //============================================================================= -#include "fgdlib/WCKeyValues.h" +"fgdlib/wckeyvalues.h" // memdbgon must be the last include file in a .cpp file!!! #include @@ -139,8 +139,8 @@ WCKeyValuesT::~WCKeyValuesT(void) template const char *WCKeyValuesT::GetValue(const char *pszKey, int *piIndex) const { - int i = FindByKeyName( pszKey ); - if ( i == GetInvalidIndex() ) + int i = WCKeyValuesT::FindByKeyName( pszKey ); + if ( i == WCKeyValuesT::GetInvalidIndex() ) { return NULL; } @@ -149,7 +149,7 @@ const char *WCKeyValuesT::GetValue(const char *pszKey, int *piIndex) const if(piIndex) piIndex[0] = i; - return m_KeyValues[i].szValue; + return WCKeyValuesT::m_KeyValues[i].szValue; } } @@ -169,7 +169,7 @@ template void WCKeyValuesT::SetValue(const char *pszKey, int iValue) { char szValue[100]; - itoa(iValue, szValue, 10); + snprintf( szValue, 100, "%i", iValue ); SetValue(pszKey, szValue); } @@ -233,8 +233,8 @@ void WCKeyValuesT::SetValue(const char *pszKey, const char *pszValue) StripEdgeWhiteSpace(szTmpKey); StripEdgeWhiteSpace(szTmpValue); - int i = FindByKeyName( szTmpKey ); - if ( i == GetInvalidIndex() ) + int i = WCKeyValuesT::FindByKeyName( szTmpKey ); + if ( i == WCKeyValuesT::GetInvalidIndex() ) { if ( pszValue ) { @@ -244,21 +244,21 @@ void WCKeyValuesT::SetValue(const char *pszKey, const char *pszValue) MDkeyvalue newkv; Q_strncpy( newkv.szKey, szTmpKey, sizeof( newkv.szKey ) ); Q_strncpy( newkv.szValue, szTmpValue, sizeof( newkv.szValue ) ); - InsertKeyValue( newkv ); + WCKeyValuesT::InsertKeyValue( newkv ); } } else { if (pszValue != NULL) { - V_strncpy(m_KeyValues[i].szValue, szTmpValue, sizeof(m_KeyValues[i].szValue)); + V_strncpy(WCKeyValuesT::m_KeyValues[i].szValue, szTmpValue, sizeof(WCKeyValuesT::m_KeyValues[i].szValue)); } // // If we are setting to a NULL value, delete the key. // else { - RemoveKeyAt( i ); + WCKeyValuesT::RemoveKeyAt( i ); } } } @@ -270,7 +270,7 @@ void WCKeyValuesT::SetValue(const char *pszKey, const char *pszValue) template void WCKeyValuesT::RemoveAll(void) { - m_KeyValues.RemoveAll(); + WCKeyValuesT::m_KeyValues.RemoveAll(); } diff --git a/game/client/cdll_client_int.cpp b/game/client/cdll_client_int.cpp index 6003d740..3a6c3e26 100644 --- a/game/client/cdll_client_int.cpp +++ b/game/client/cdll_client_int.cpp @@ -149,10 +149,12 @@ #endif -#ifdef VANCE +#if VANCE +#if _WIN32 // Discord RPC #include "discord_rpc.h" #include +#endif #include "IDeferredExt.h" //GAMEUI2 @@ -345,7 +347,7 @@ static ConVar s_CV_ShowParticleCounts("showparticlecounts", "0", 0, "Display num static ConVar s_cl_team("cl_team", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "Default team when joining a game"); static ConVar s_cl_class("cl_class", "default", FCVAR_USERINFO|FCVAR_ARCHIVE, "Default class when joining a game"); -#ifdef VANCE +#if VANCE && WIN32 // Discord RPC static ConVar cl_discord_appid("cl_discord_appid", "549012876413632533", FCVAR_DEVELOPMENTONLY | FCVAR_CHEAT); static int64_t startTimestamp = time(0); @@ -859,7 +861,7 @@ bool IsEngineThreaded() // Constructor //----------------------------------------------------------------------------- -#ifdef VANCE +#if VANCE && WIN32 //----------------------------------------------------------------------------- // Discord RPC //----------------------------------------------------------------------------- @@ -1146,7 +1148,7 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi HookHapticMessages(); // Always hook the messages #endif -#ifdef VANCE +#if VANCE && WIN32 // Discord RPC DiscordEventHandlers handlers; memset(&handlers, 0, sizeof(handlers)); @@ -1350,9 +1352,12 @@ void CHLClient::Shutdown( void ) DisconnectDataModel(); ShutdownFbx(); #endif + +#if VANCE && WIN32 // Discord RPC Discord_Shutdown(); - +#endif + // This call disconnects the VGui libraries which we rely on later in the shutdown path, so don't do it // DisconnectTier3Libraries( ); DisconnectTier2Libraries( ); @@ -1768,7 +1773,7 @@ void CHLClient::LevelInitPreEntity( char const* pMapName ) } #endif -#ifdef VANCE +#if VANCE && WIN32 // Discord RPC if (!g_bTextMode) { @@ -1884,7 +1889,7 @@ void CHLClient::LevelShutdown( void ) gHUD.LevelShutdown(); -#ifdef VANCE +#if VANCE && WIN32 // Discord RPC if (!g_bTextMode) { diff --git a/game/client/client_vance.vpc b/game/client/client_vance.vpc index 180e62b1..50266014 100644 --- a/game/client/client_vance.vpc +++ b/game/client/client_vance.vpc @@ -174,6 +174,6 @@ $Project "Client (Vance)" $Folder "Link Libraries" { - $Lib "$LIBCOMMON/discord-rpc" + $Lib "$LIBCOMMON/discord-rpc" [$WIN32] } } diff --git a/game/client/clientmode_shared.cpp b/game/client/clientmode_shared.cpp index 622208a4..3d0a25ca 100644 --- a/game/client/clientmode_shared.cpp +++ b/game/client/clientmode_shared.cpp @@ -1136,7 +1136,7 @@ void ClientModeShared::FireGameEvent( IGameEvent *event ) } } - if ( team == 0 && GetLocalTeam() > 0 ) + if ( team == 0 && GetLocalTeam() != 0 ) { bValidTeam = false; } diff --git a/game/client/clientshadowmgr.cpp b/game/client/clientshadowmgr.cpp index f9217315..5c1e12f2 100644 --- a/game/client/clientshadowmgr.cpp +++ b/game/client/clientshadowmgr.cpp @@ -1,6 +1,6 @@ //========= Copyright Valve Corporation, All rights reserved. ============// // -// Purpose: +// Purpose: // // $NoKeywords: $ // @@ -14,30 +14,30 @@ // // There are two important types of objects with respect to shadows: // the shadow receiver, and the shadow caster. How is the association made -// between casters + the receivers? Turns out it's done slightly differently +// between casters + the receivers? Turns out it's done slightly differently // depending on whether the receiver is the world, or if it's an entity. // -// In the case of the world, every time the engine's ProjectShadow() is called, +// In the case of the world, every time the engine's ProjectShadow() is called, // any previous receiver state stored (namely, which world surfaces are -// receiving shadows) are cleared. Then, when ProjectShadow is called, -// the engine iterates over all nodes + leaves within the shadow volume and -// marks front-facing surfaces in them as potentially being affected by the +// receiving shadows) are cleared. Then, when ProjectShadow is called, +// the engine iterates over all nodes + leaves within the shadow volume and +// marks front-facing surfaces in them as potentially being affected by the // shadow. Later on, if those surfaces are actually rendered, the surfaces // are clipped by the shadow volume + rendered. -// +// // In the case of entities, there are slightly different methods depending // on whether the receiver is a brush model or a studio model. However, there // are a couple central things that occur with both. // // Every time a shadow caster is moved, the ClientLeafSystem's ProjectShadow -// method is called to tell it to remove the shadow from all leaves + all +// method is called to tell it to remove the shadow from all leaves + all // renderables it's currently associated with. Then it marks each leaf in the // shadow volume as being affected by that shadow, and it marks every renderable // in that volume as being potentially affected by the shadow (the function // AddShadowToRenderable is called for each renderable in leaves affected // by the shadow volume). // -// Every time a shadow receiver is moved, the ClientLeafSystem first calls +// Every time a shadow receiver is moved, the ClientLeafSystem first calls // RemoveAllShadowsFromRenderable to have it clear out its state, and then // the ClientLeafSystem calls AddShadowToRenderable() for all shadows in all // leaves the renderable has moved into. @@ -673,7 +673,7 @@ void CTextureAllocator::GetTextureRect(TextureHandle_t handle, int& x, int& y, i //----------------------------------------------------------------------------- // Defines how big of a shadow texture we should be making per caster... //----------------------------------------------------------------------------- -#define TEXEL_SIZE_PER_CASTER_SIZE 2.0f +#define TEXEL_SIZE_PER_CASTER_SIZE 2.0f #define MAX_FALLOFF_AMOUNT 240 #define MAX_CLIP_PLANE_COUNT 4 #define SHADOW_CULL_TOLERANCE 0.5f @@ -684,7 +684,7 @@ static ConVar r_shadows_gamecontrol("r_shadows_gamecontrol", "-1", FCVAR_CHEAT); //----------------------------------------------------------------------------- // The class responsible for dealing with shadows on the client side -// Oh, and let's take a moment and notice how happy Robin and John must be +// Oh, and let's take a moment and notice how happy Robin and John must be // owing to the lack of space between this lovely comment and the class name =) //----------------------------------------------------------------------------- class CClientShadowMgr : public IClientShadowMgr @@ -1132,8 +1132,8 @@ void CVisibleShadowList::EnumShadow(unsigned short clientShadowHandle) info.m_hShadow = clientShadowHandle; m_ShadowsInView[i].m_flArea = ComputeScreenArea(vecAbsCenter, flRadius); - // Har, har. When water is rendering (or any multipass technique), - // we may well initially render from a viewpoint which doesn't include this shadow. + // Har, har. When water is rendering (or any multipass technique), + // we may well initially render from a viewpoint which doesn't include this shadow. // That doesn't mean we shouldn't check it again though. Sucks that we need to compute // the sphere + bbox multiply times though. shadow.m_nRenderFrame = gpGlobals->framecount; @@ -1766,7 +1766,7 @@ float CClientShadowMgr::GetBlobbyCutoffArea() const } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CClientShadowMgr::SetFalloffBias(ClientShadowHandle_t handle, unsigned char ucBias) { @@ -2396,7 +2396,7 @@ void CClientShadowMgr::BuildOrthoShadow(IClientRenderable* pRenderable, // Compute the falloff attenuation // Area computation isn't exact since xvec is not perp to yvec, but close enough -// float shadowArea = size.x * size.y; +// float shadowArea = size.x * size.y; // The entity may be overriding our shadow cast distance float flShadowCastDistance = GetShadowDistance(pRenderable); @@ -2414,7 +2414,7 @@ void CClientShadowMgr::BuildOrthoShadow(IClientRenderable* pRenderable, // FIXME!!!!!!!!!!!!!! Removing this for now since it seems to mess up the blobby shadows. // ComputeExtraClipPlanes( pEnt, handle, vec, mins, maxs, localShadowDir ); - // Add the shadow to the client leaf system so it correctly marks + // Add the shadow to the client leaf system so it correctly marks // leafs as being affected by a particular shadow ClientLeafSystem()->ProjectShadow(m_Shadows[handle].m_ClientLeafShadowHandle, nCount, pLeafList); } @@ -2576,7 +2576,7 @@ void CClientShadowMgr::BuildRenderToTextureShadow(IClientRenderable* pRenderable // Compute the falloff attenuation // Area computation isn't exact since xvec is not perp to yvec, but close enough // Extra factor of 4 in the maxHeight due to the size being half as big -// float shadowArea = size.x * size.y; +// float shadowArea = size.x * size.y; // The entity may be overriding our shadow cast distance float flShadowCastDistance = GetShadowDistance(pRenderable); @@ -2593,7 +2593,7 @@ void CClientShadowMgr::BuildRenderToTextureShadow(IClientRenderable* pRenderable // Compute extra clip planes to prevent poke-thru ComputeExtraClipPlanes(pRenderable, handle, vec, mins, maxs, localShadowDir); - // Add the shadow to the client leaf system so it correctly marks + // Add the shadow to the client leaf system so it correctly marks // leafs as being affected by a particular shadow ClientLeafSystem()->ProjectShadow(m_Shadows[handle].m_ClientLeafShadowHandle, nCount, pLeafList); } @@ -2700,7 +2700,7 @@ void CClientShadowMgr::BuildFlashlight(ClientShadowHandle_t handle) if (!bLightSpecificEntity) { - // Add the shadow to the client leaf system so it correctly marks + // Add the shadow to the client leaf system so it correctly marks // leafs as being affected by a particular shadow ClientLeafSystem()->ProjectFlashlight(shadow.m_ClientLeafShadowHandle, nCount, pLeafList); return; @@ -3409,14 +3409,14 @@ bool CClientShadowMgr::CullReceiver(ClientShadowHandle_t handle, IClientRenderab if (receiverDot <= sourceDot) { // Vector dest; - // VectorMA( pSourceRenderable->GetRenderOrigin(), 50, plane.normal, dest ); + // VectorMA( pSourceRenderable->GetRenderOrigin(), 50, plane.normal, dest ); // debugoverlay->AddLineOverlay( pSourceRenderable->GetRenderOrigin(), dest, 255, 255, 0, true, 1.0f ); return true; } else { // Vector dest; - // VectorMA( pSourceRenderable->GetRenderOrigin(), 50, plane.normal, dest ); + // VectorMA( pSourceRenderable->GetRenderOrigin(), 50, plane.normal, dest ); // debugoverlay->AddLineOverlay( pSourceRenderable->GetRenderOrigin(), dest, 255, 0, 0, true, 1.0f ); } } @@ -3425,14 +3425,14 @@ bool CClientShadowMgr::CullReceiver(ClientShadowHandle_t handle, IClientRenderab if (receiverDot >= sourceDot) { // Vector dest; - // VectorMA( pSourceRenderable->GetRenderOrigin(), -50, plane.normal, dest ); + // VectorMA( pSourceRenderable->GetRenderOrigin(), -50, plane.normal, dest ); // debugoverlay->AddLineOverlay( pSourceRenderable->GetRenderOrigin(), dest, 255, 255, 0, true, 1.0f ); return true; } else { // Vector dest; - // VectorMA( pSourceRenderable->GetRenderOrigin(), 50, plane.normal, dest ); + // VectorMA( pSourceRenderable->GetRenderOrigin(), 50, plane.normal, dest ); // debugoverlay->AddLineOverlay( pSourceRenderable->GetRenderOrigin(), dest, 255, 0, 0, true, 1.0f ); } } @@ -3872,7 +3872,7 @@ void CClientShadowMgr::DrawRenderToTextureShadowLOD(unsigned short clientShadowH //----------------------------------------------------------------------------- -// Advances to the next frame, +// Advances to the next frame, //----------------------------------------------------------------------------- void CClientShadowMgr::AdvanceFrame() { @@ -3880,7 +3880,7 @@ void CClientShadowMgr::AdvanceFrame() m_ShadowAllocator.AdvanceFrame(); } -int _cdecl CompareLights(const ClientShadowHandle_t *light_left, const ClientShadowHandle_t *light_right) +int CompareLights(const ClientShadowHandle_t *light_left, const ClientShadowHandle_t *light_right) { const FlashlightState_t& flashlightState1 = shadowmgr->GetFlashlightState(g_pClientShadowMgr->GetShadowHandle(*light_left)); const FlashlightState_t& flashlightState2 = shadowmgr->GetFlashlightState(g_pClientShadowMgr->GetShadowHandle(*light_right)); @@ -3927,7 +3927,7 @@ int CClientShadowMgr::BuildActiveShadowDepthList(const CViewSetup& viewSetup, in { continue; } - + vActiveShadows.AddToHead(i); } @@ -4451,4 +4451,4 @@ IMaterial* CShadowModelProxy::GetMaterial() return m_BaseTextureVar->GetOwningMaterial(); } -EXPOSE_INTERFACE(CShadowModelProxy, IMaterialProxy, "ShadowModel" IMATERIAL_PROXY_INTERFACE_VERSION); \ No newline at end of file +EXPOSE_INTERFACE(CShadowModelProxy, IMaterialProxy, "ShadowModel" IMATERIAL_PROXY_INTERFACE_VERSION); diff --git a/game/client/hud.cpp b/game/client/hud.cpp index af50b187..090cb607 100644 --- a/game/client/hud.cpp +++ b/game/client/hud.cpp @@ -134,10 +134,10 @@ void LoadHudTextures( CUtlDict< CHudTexture *, int >& list, const char *szFilena pTemp = pTemp->GetNextKey(); } } - } - // Failed for some reason. Delete the Key data and abort. - pKeyValuesData->deleteThis(); + // Failed for some reason. Delete the Key data and abort. + pKeyValuesData->deleteThis(); + } } //----------------------------------------------------------------------------- diff --git a/game/client/vance/c_env_skydome.cpp b/game/client/vance/c_env_skydome.cpp index 5058efb6..58c11a05 100644 --- a/game/client/vance/c_env_skydome.cpp +++ b/game/client/vance/c_env_skydome.cpp @@ -8,7 +8,7 @@ #include "rendertexture.h" #include "viewrender.h" #include "fmtstr.h" -#include "mathlib\mathlib.h" +#include "mathlib/mathlib.h" #include ConVarRef cl_sky_sunpos ("cl_sky_sunpos"); ConVarRef cl_sky_windspeed ("cl_sky_windspeed"); @@ -103,4 +103,4 @@ RecvPropVector(RECVINFO(m_vDesiredSunPos)), RecvPropVector(RECVINFO(m_vDesiredWindSpeed)), RecvPropFloat(RECVINFO(m_flDesiredThickness)), RecvPropFloat(RECVINFO(m_flDesiredCoverage)), -END_RECV_TABLE() \ No newline at end of file +END_RECV_TABLE() diff --git a/game/client/vance/c_light_manager.h b/game/client/vance/c_light_manager.h index 2b2e7af5..233645bf 100644 --- a/game/client/vance/c_light_manager.h +++ b/game/client/vance/c_light_manager.h @@ -2,8 +2,8 @@ #define C_LIGHT_MANAGER_H #include "igamesystem.h" -#include "UtlVector.h" -#include "../../public/mathlib/vector4d.h" +#include "tier1/utlvector.h" +#include "mathlib/vector4d.h" #define DEFLIGHT_SPOT_ZNEAR 8.0f #define DEFLIGHT_SPOT_RESOLUTION 1024 @@ -79,4 +79,4 @@ struct volume_light_t }; extern CLightingManager* GetLightingManager(); -#endif \ No newline at end of file +#endif diff --git a/game/client/vance/deferred_material_passthru.h b/game/client/vance/deferred_material_passthru.h index 136f625e..ce73f8d9 100644 --- a/game/client/vance/deferred_material_passthru.h +++ b/game/client/vance/deferred_material_passthru.h @@ -1,6 +1,6 @@ -//====== Copyright © Sandern Corporation, All rights reserved. ===========// +//====== Copyright � Sandern Corporation, All rights reserved. ===========// // -// Purpose: Implementation of IMaterialSystem interface which "passes tru" all +// Purpose: Implementation of IMaterialSystem interface which "passes tru" all // function calls to the real interface. Can be used to override // IMaterialSystem function calls (combined with engine->Mat_Stub). // @@ -180,7 +180,7 @@ class CPassThruMaterialSystem : public IMaterialSystem int w, int h, ImageFormat fmt, - int nFlags) + int nFlags) { return m_pBaseMaterialsPassThru->CreateProceduralTexture(pTextureName, pTextureGroupName, w, h, fmt, nFlags); } @@ -192,7 +192,7 @@ class CPassThruMaterialSystem : public IMaterialSystem int h, RenderTargetSizeMode_t sizeMode, // Controls how size is generated (and regenerated on video mode change). ImageFormat format, - MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED) + MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED) { return m_pBaseMaterialsPassThru->CreateRenderTargetTexture(w, h, sizeMode, format, depth); } @@ -204,7 +204,7 @@ class CPassThruMaterialSystem : public IMaterialSystem ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, - unsigned int renderTargetFlags = 0) + unsigned int renderTargetFlags = 0) { return m_pBaseMaterialsPassThru->CreateNamedRenderTargetTextureEx(pRTName, w, h, sizeMode, format, depth, textureFlags, renderTargetFlags); } @@ -216,7 +216,7 @@ class CPassThruMaterialSystem : public IMaterialSystem ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, bool bClampTexCoords = true, - bool bAutoMipMap = false) + bool bAutoMipMap = false) { return m_pBaseMaterialsPassThru->CreateNamedRenderTargetTexture(pRTName, w, h, sizeMode, format, depth, bClampTexCoords, bAutoMipMap); } @@ -228,7 +228,7 @@ class CPassThruMaterialSystem : public IMaterialSystem ImageFormat format, MaterialRenderTargetDepth_t depth = MATERIAL_RT_DEPTH_SHARED, unsigned int textureFlags = TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, - unsigned int renderTargetFlags = 0) + unsigned int renderTargetFlags = 0) { return m_pBaseMaterialsPassThru->CreateNamedRenderTargetTextureEx2(pRTName, w, h, sizeMode, format, depth, textureFlags, renderTargetFlags); } @@ -238,7 +238,7 @@ class CPassThruMaterialSystem : public IMaterialSystem virtual int AllocateLightmap(int width, int height, int offsetIntoLightmapPage[2], - IMaterial* pMaterial) + IMaterial* pMaterial) { return m_pBaseMaterialsPassThru->AllocateLightmap(width, height, offsetIntoLightmapPage, pMaterial); } @@ -247,7 +247,7 @@ class CPassThruMaterialSystem : public IMaterialSystem virtual void UpdateLightmap(int lightmapPageID, int lightmapSize[2], int offsetIntoLightmapPage[2], float* pFloatImage, float* pFloatImageBump1, - float* pFloatImageBump2, float* pFloatImageBump3) + float* pFloatImageBump2, float* pFloatImageBump3) { m_pBaseMaterialsPassThru->UpdateLightmap(lightmapPageID, lightmapSize, offsetIntoLightmapPage, pFloatImage, pFloatImageBump1, pFloatImageBump2, pFloatImageBump3); } @@ -322,6 +322,13 @@ class CPassThruMaterialSystem : public IMaterialSystem return m_pBaseMaterialsPassThru->FindMaterialEx(pMaterialName, pTextureGroupName, nContext, complain, pComplainPrefix); } +#ifdef DX_TO_GL_ABSTRACTION + virtual void DoStartupShaderPreloading() + { + m_pBaseMaterialsPassThru->DoStartupShaderPreloading(); + } +#endif + virtual void SetRenderTargetFrameBufferSizeOverrides(int nWidth, int nHeight) { m_pBaseMaterialsPassThru->SetRenderTargetFrameBufferSizeOverrides(nWidth, nHeight); } virtual void GetRenderTargetFrameBufferDimensions(int& nWidth, int& nHeight) { m_pBaseMaterialsPassThru->GetRenderTargetFrameBufferDimensions(nWidth, nHeight); } @@ -373,4 +380,4 @@ class CDeferredMaterialSystem : public CPassThruMaterialSystem }; -#endif // WARS_MATERIALSYSTEM_PASSTHRU_H \ No newline at end of file +#endif // WARS_MATERIALSYSTEM_PASSTHRU_H diff --git a/game/client/vance/deferred_screenspace_effects.cpp b/game/client/vance/deferred_screenspace_effects.cpp index 3d0b4f4f..c2005303 100644 --- a/game/client/vance/deferred_screenspace_effects.cpp +++ b/game/client/vance/deferred_screenspace_effects.cpp @@ -1,5 +1,5 @@ #include "cbase.h" -#include "screenspaceeffects.h" +#include "ScreenSpaceEffects.h" #include "rendertexture.h" #include "model_types.h" #include "materialsystem/imaterialsystemhardwareconfig.h" @@ -7,8 +7,8 @@ #include "materialsystem/imaterialvar.h" #include "cdll_client_int.h" #include "materialsystem/itexture.h" -#include "keyvalues.h" -#include "ClientEffectPrecacheSystem.h" +#include "KeyValues.h" +#include "clienteffectprecachesystem.h" #include "viewrender.h" #include "view_scene.h" #include "c_basehlplayer.h" @@ -566,4 +566,4 @@ void CSSR::Render(int x, int y, int w, int h) DrawScreenEffectMaterial(m_SSR_Add, x, y, w, h); pRenderContext.SafeRelease(); -} \ No newline at end of file +} diff --git a/game/client/vance/deferred_screenspace_effects_order.cpp b/game/client/vance/deferred_screenspace_effects_order.cpp index ad785407..1ee67deb 100644 --- a/game/client/vance/deferred_screenspace_effects_order.cpp +++ b/game/client/vance/deferred_screenspace_effects_order.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 2010, Gear Development, All rights reserved. ============// +//========= Copyright � 2010, Gear Development, All rights reserved. ============// // // Purpose: I imagine a few of you are going to wonder dearly what this is is why we're doing this. // Well, sit down. I'm going to tell you a story: @@ -14,7 +14,7 @@ #include "cbase.h" #include "ScreenSpaceEffects.h" #include "deferred_screenspace_effects.h" -#include "episodic\episodic_screenspaceeffects.h" +#include "episodic/episodic_screenspaceeffects.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" diff --git a/game/gameui2/button_panel.cpp b/game/gameui2/button_panel.cpp index 4fcb88f7..be5209f1 100644 --- a/game/gameui2/button_panel.cpp +++ b/game/gameui2/button_panel.cpp @@ -29,7 +29,7 @@ Button_Panel::Button_Panel(vgui::Panel* Parent, vgui::Panel* ActionSignalTarget, void Button_Panel::SetButtonText(const char* Text) { ButtonText = GetGameUI2().ConvertToLocalizedString(Text); - ButtonText = wcsupr(ButtonText); + ButtonText = V_wcsupr(ButtonText); } void Button_Panel::SetButtonDescription(const char* Description) @@ -280,4 +280,4 @@ void Button_Panel::OnMouseReleased(vgui::MouseCode MouseCode) GetParent()->OnCommand(CommandShared); } -} \ No newline at end of file +} diff --git a/game/gameui2/gameui2_interface.h b/game/gameui2/gameui2_interface.h index 5330292a..aec4a1dd 100644 --- a/game/gameui2/gameui2_interface.h +++ b/game/gameui2/gameui2_interface.h @@ -12,7 +12,7 @@ work. If not, see . #include "igameui2.h" #include "cdll_int.h" -#include "engine/ienginesound.h" +#include "engine/IEngineSound.h" #include "ienginevgui.h" #include "SoundEmitterSystem/isoundemittersystembase.h" #include "ivrenderview.h" @@ -88,4 +88,4 @@ class GameUI2 : public IGameUI2 IGameUI* GameUI; }; -extern GameUI2& GetGameUI2(); \ No newline at end of file +extern GameUI2& GetGameUI2(); diff --git a/game/gameui2/panel_options.cpp b/game/gameui2/panel_options.cpp index 8f33f8d8..be522e8a 100644 --- a/game/gameui2/panel_options.cpp +++ b/game/gameui2/panel_options.cpp @@ -41,7 +41,7 @@ Panel_Options::Panel_Options(vgui::VPANEL Parent, const char* PanelName) : BaseC Activate(); PanelTitle = GetGameUI2().ConvertToLocalizedString("#GameUI2_TitleOptions"); - PanelTitle = wcsupr(PanelTitle); + PanelTitle = V_wcsupr(PanelTitle); ButtonDone = new Button_Panel(this, this, ""); ButtonDone->SetButtonText("#GameUI2_Done"); @@ -210,4 +210,4 @@ void Panel_Options::OnCommand(char const* Command) CON_COMMAND(gameui2_openoptionsdialog, "") { new Panel_Options(GetGameUI2().GetVPanel(), ""); -} \ No newline at end of file +} diff --git a/game/gameui2/panel_quitgame.cpp b/game/gameui2/panel_quitgame.cpp index a128ce68..7dcc2f6c 100644 --- a/game/gameui2/panel_quitgame.cpp +++ b/game/gameui2/panel_quitgame.cpp @@ -15,9 +15,11 @@ work. If not, see . #include "vgui/ISurface.h" #include "vgui/IVGui.h" +#include "tier0/valve_minmax_off.h" // GCC 4.2.2 headers screw up our min/max defs. #include #include #include +#include "tier0/valve_minmax_on.h" // GCC 4.2.2 headers screw up our min/max defs. // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -64,4 +66,4 @@ void Panel_QuitGame::Paint() CON_COMMAND(gameui2_openquitgamedialog, "") { new Panel_QuitGame(GetGameUI2().GetVPanel(), ""); -} \ No newline at end of file +} diff --git a/game/server/vance/npc_assassin.cpp b/game/server/vance/npc_assassin.cpp index 4ff35d93..a1316bae 100644 --- a/game/server/vance/npc_assassin.cpp +++ b/game/server/vance/npc_assassin.cpp @@ -1,20 +1,20 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// // -// Purpose: +// Purpose: // // $NoKeywords: $ // //=============================================================================// #include "cbase.h" #include "ammodef.h" -#include "AI_Hint.h" -#include "AI_Navigator.h" +#include "ai_hint.h" +#include "ai_navigator.h" #include "npc_assassin.h" #include "game.h" #include "npcevent.h" #include "engine/IEngineSound.h" #include "ai_squad.h" -#include "AI_SquadSlot.h" +#include "ai_squadslot.h" #include "ai_moveprobe.h" #include "ai_scheduleobject.h" #include "ai_tacticalservices.h" @@ -117,7 +117,7 @@ Class_T CNPC_HAssassin::Classify(void) } //========================================================= -// CheckMeleeAttack1 - jump like crazy if the enemy gets too close. +// CheckMeleeAttack1 - jump like crazy if the enemy gets too close. //========================================================= int CNPC_HAssassin::MeleeAttack1Conditions(float flDot, float flDist) { @@ -179,7 +179,7 @@ int CNPC_HAssassin::RangeAttack1Conditions(float flDot, float flDist) } //========================================================= -// CheckRangeAttack2 - toss grenade is enemy gets in the way and is too close. +// CheckRangeAttack2 - toss grenade is enemy gets in the way and is too close. //========================================================= int CNPC_HAssassin::RangeAttack2Conditions(float flDot, float flDist) { @@ -245,7 +245,7 @@ void CNPC_HAssassin::StartTask(const Task_t* pTask) //========================================================= -// RunTask +// RunTask //========================================================= void CNPC_HAssassin::RunTask(const Task_t* pTask) { diff --git a/game/server/vance/npc_bullsquid.cpp b/game/server/vance/npc_bullsquid.cpp index 873791d2..884e496a 100644 --- a/game/server/vance/npc_bullsquid.cpp +++ b/game/server/vance/npc_bullsquid.cpp @@ -7,11 +7,11 @@ #include "cbase.h" #include "game.h" -#include "AI_Default.h" -#include "AI_Schedule.h" -#include "AI_Hull.h" -#include "AI_Navigator.h" -#include "AI_Motor.h" +#include "ai_default.h" +#include "ai_schedule.h" +#include "ai_hull.h" +#include "ai_navigator.h" +#include "ai_motor.h" #include "ai_squad.h" #include "npc_bullsquid.h" #include "npcevent.h" @@ -30,8 +30,8 @@ #include "engine/IEngineSound.h" #include "movevars_shared.h" -#include "AI_Hint.h" -#include "AI_Senses.h" +#include "ai_hint.h" +#include "ai_senses.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -57,7 +57,7 @@ enum //========================================================= // monster-specific tasks //========================================================= -enum +enum { TASK_SQUID_HOPTURN = LAST_SHARED_TASK + 1, TASK_SQUID_EAT, @@ -126,16 +126,16 @@ void CNPC_Bullsquid::Spawn() AddSolidFlags( FSOLID_NOT_STANDABLE ); SetMoveType( MOVETYPE_STEP ); m_bloodColor = BLOOD_COLOR_YELLOW; - + SetRenderColor( 255, 255, 255, 255 ); - + m_iHealth = sk_bullsquid_health.GetFloat(); m_flFieldOfView = 0.2;// indicates the width of this monster's forward view cone ( as a dotproduct result ) m_NPCState = NPC_STATE_NONE; - + CapabilitiesClear(); CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_INNATE_RANGE_ATTACK1 | bits_CAP_INNATE_MELEE_ATTACK1 | bits_CAP_INNATE_MELEE_ATTACK2 ); - + m_fCanThreatDisplay = TRUE; m_flNextSpitTime = gpGlobals->curtime; @@ -167,15 +167,15 @@ void CNPC_Bullsquid::Precache() //----------------------------------------------------------------------------- // Purpose: Indicates this monster's place in the relationship table. -// Output : +// Output : //----------------------------------------------------------------------------- Class_T CNPC_Bullsquid::Classify( void ) { - return CLASS_HOUNDEYE; + return CLASS_HOUNDEYE; } //========================================================= -// IdleSound +// IdleSound //========================================================= #define SQUID_ATTN_IDLE (float)1.5 void CNPC_Bullsquid::IdleSound( void ) @@ -184,7 +184,7 @@ void CNPC_Bullsquid::IdleSound( void ) } //========================================================= -// PainSound +// PainSound //========================================================= void CNPC_Bullsquid::PainSound( const CTakeDamageInfo &info ) { @@ -265,7 +265,7 @@ void CNPC_Bullsquid::HandleAnimEvent( animevent_t *pEvent ) Vector vSpitPos; GetAttachment( "Mouth", vSpitPos ); - + Vector vTarget = GetEnemy()->GetAbsOrigin(); Vector vToss; CBaseEntity* pBlocker; @@ -288,9 +288,9 @@ void CNPC_Bullsquid::HandleAnimEvent( animevent_t *pEvent ) random->RandomFloat( -100, -500 ) ) ); - + AttackSound(); - + CPVSFilter filter( vSpitPos ); te->SpriteSpray( filter, 0.0, &vSpitPos, &vToss, m_nSquidSpitSprite, 5, 10, 15 ); @@ -322,14 +322,14 @@ void CNPC_Bullsquid::HandleAnimEvent( animevent_t *pEvent ) case BSQUID_AE_TAILWHIP: { CBaseEntity *pHurt = CheckTraceHullAttack( 70, Vector(-16,-16,-16), Vector(16,16,16), sk_bullsquid_dmg_whip.GetFloat(), DMG_SLASH ); - if ( pHurt ) + if ( pHurt ) { Vector right, up; AngleVectors( GetAbsAngles(), NULL, &right, &up ); if ( pHurt->GetFlags() & ( FL_NPC | FL_CLIENT ) ) pHurt->ViewPunch( QAngle( 20, 0, -20 ) ); - + pHurt->ApplyAbsVelocityImpulse( 100 * (up+2*right) ); } } @@ -337,7 +337,7 @@ void CNPC_Bullsquid::HandleAnimEvent( animevent_t *pEvent ) */ case BSQUID_AE_BLINK: { - // close eye. + // close eye. m_nSkin = 1; } break; @@ -361,13 +361,13 @@ void CNPC_Bullsquid::HandleAnimEvent( animevent_t *pEvent ) case BSQUID_AE_THROW: { - // squid throws its prey IF the prey is a client. + // squid throws its prey IF the prey is a client. CBaseEntity *pHurt = CheckTraceHullAttack(70, Vector(-16, -16, -16), Vector(16, 16, 16), sk_bullsquid_dmg_whip.GetFloat(), DMG_SLASH ); if ( pHurt ) { pHurt->ViewPunch( QAngle(20,0,-20) ); - + // screeshake transforms the viewmodel as well as the viewangle. No problems with seeing the ends of the viewmodels. UTIL_ScreenShake( pHurt->GetAbsOrigin(), 25.0, 1.5, 0.7, 2, SHAKE_START ); @@ -447,7 +447,7 @@ int CNPC_Bullsquid::MeleeAttack1Conditions( float flDot, float flDist ) { return ( COND_CAN_MELEE_ATTACK1 ); } - + return( COND_NONE ); } @@ -459,9 +459,9 @@ int CNPC_Bullsquid::MeleeAttack1Conditions( float flDot, float flDist ) //========================================================= int CNPC_Bullsquid::MeleeAttack2Conditions( float flDot, float flDist ) { - if ( flDist <= 85 && flDot >= 0.7 && !HasCondition( COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes + if ( flDist <= 85 && flDot >= 0.7 && !HasCondition( COND_CAN_MELEE_ATTACK1 ) ) // The player & bullsquid can be as much as their bboxes return ( COND_CAN_MELEE_ATTACK2 ); - + return( COND_NONE ); } @@ -482,7 +482,7 @@ void CNPC_Bullsquid::RemoveIgnoredConditions( void ) if ( gpGlobals->curtime - m_flLastHurtTime <= 20 ) { - // haven't been hurt in 20 seconds, so let the squid care about stink. + // haven't been hurt in 20 seconds, so let the squid care about stink. ClearCondition( COND_SMELL ); } @@ -498,8 +498,8 @@ Disposition_t CNPC_Bullsquid::IRelationType( CBaseEntity *pTarget ) { if ( gpGlobals->curtime - m_flLastHurtTime < 5 && FClassnameIs( pTarget, "monster_headcrab" ) ) { - // if squid has been hurt in the last 5 seconds, and is getting relationship for a headcrab, - // tell squid to disregard crab. + // if squid has been hurt in the last 5 seconds, and is getting relationship for a headcrab, + // tell squid to disregard crab. return D_NU; } @@ -523,14 +523,14 @@ int CNPC_Bullsquid::OnTakeDamage_Alive( const CTakeDamageInfo &inputInfo ) if ( GetEnemy() != NULL && IsMoving() && pevAttacker == GetEnemy() && gpGlobals->curtime - m_flLastHurtTime > 3 ) { flDist = ( GetAbsOrigin() - GetEnemy()->GetAbsOrigin() ).Length2D(); - + if ( flDist > SQUID_SPRINT_DIST ) { AI_Waypoint_t* pRoute = GetNavigator()->GetPath()->Route(); if ( pRoute ) { - flDist = ( GetAbsOrigin() - pRoute[ pRoute->iNodeID ].vecLocation ).Length2D();// reusing flDist. + flDist = ( GetAbsOrigin() - pRoute[ pRoute->iNodeID ].vecLocation ).Length2D();// reusing flDist. if ( GetNavigator()->GetPath()->BuildTriangulationRoute( GetAbsOrigin(), pRoute[ pRoute->iNodeID ].vecLocation, flDist * 0.5, GetEnemy(), &vecApex, &vOffset, NAV_GROUND ) ) { @@ -572,23 +572,23 @@ int CNPC_Bullsquid::GetSoundInterests( void ) void CNPC_Bullsquid::OnListened( void ) { AISoundIter_t iter; - + CSound *pCurrentSound; - static int conditionsToClear[] = + static int conditionsToClear[] = { COND_SQUID_SMELL_FOOD, }; ClearConditions( conditionsToClear, ARRAYSIZE( conditionsToClear ) ); - + pCurrentSound = GetSenses()->GetFirstHeardSound( &iter ); - + while ( pCurrentSound ) { // the npc cares about this sound, and it's close enough to hear. int condition = COND_NONE; - + if ( !pCurrentSound->FIsSound() ) { // if not a sound, must be a smell - determine if it's just a scent, or if it's a food scent @@ -598,7 +598,7 @@ void CNPC_Bullsquid::OnListened( void ) condition = COND_SQUID_SMELL_FOOD; } } - + if ( condition != COND_NONE ) SetCondition( condition ); @@ -620,7 +620,7 @@ void CNPC_Bullsquid::RunAI( void ) if ( m_nSkin != 0 ) { // close eye if it was open. - m_nSkin = 0; + m_nSkin = 0; } if ( random->RandomInt( 0,39 ) == 0 ) @@ -640,7 +640,7 @@ void CNPC_Bullsquid::RunAI( void ) } //========================================================= -// GetSchedule +// GetSchedule //========================================================= int CNPC_Bullsquid::SelectSchedule( void ) { @@ -658,7 +658,7 @@ int CNPC_Bullsquid::SelectSchedule( void ) CSound *pSound; pSound = GetBestScent(); - + if ( pSound && (!FInViewCone( pSound->GetSoundOrigin() ) || !FVisible( pSound->GetSoundOrigin() )) ) { // scent is behind or occluded @@ -671,7 +671,7 @@ int CNPC_Bullsquid::SelectSchedule( void ) if ( HasCondition( COND_SMELL ) ) { - // there's something stinky. + // there's something stinky. CSound *pSound; pSound = GetBestScent(); @@ -709,7 +709,7 @@ int CNPC_Bullsquid::SelectSchedule( void ) CSound *pSound; pSound = GetBestScent(); - + if ( pSound && (!FInViewCone( pSound->GetSoundOrigin() ) || !FVisible( pSound->GetSoundOrigin() )) ) { // scent is behind or occluded @@ -734,7 +734,7 @@ int CNPC_Bullsquid::SelectSchedule( void ) { return SCHED_MELEE_ATTACK2; } - + return SCHED_CHASE_ENEMY; break; @@ -747,7 +747,7 @@ int CNPC_Bullsquid::SelectSchedule( void ) //========================================================= // FInViewCone - returns true is the passed vector is in // the caller's forward view cone. The dot product is performed -// in 2d, making the view cone infinitely tall. +// in 2d, making the view cone infinitely tall. //========================================================= bool CNPC_Bullsquid::FInViewCone( Vector pOrigin ) { @@ -793,7 +793,7 @@ void CNPC_Bullsquid::StartTask( const Task_t *pTask ) case TASK_SQUID_HOPTURN: { SetActivity( ACT_HOP ); - + if ( GetEnemy() ) { Vector vecFacing = ( GetEnemy()->GetAbsOrigin() - GetAbsOrigin() ); @@ -836,7 +836,7 @@ void CNPC_Bullsquid::RunTask( const Task_t *pTask ) if ( IsSequenceFinished() ) { - TaskComplete(); + TaskComplete(); } break; } @@ -850,8 +850,8 @@ void CNPC_Bullsquid::RunTask( const Task_t *pTask ) //========================================================= // GetIdealState - Overridden for Bullsquid to deal with -// the feature that makes it lose interest in headcrabs for -// a while if something injures it. +// the feature that makes it lose interest in headcrabs for +// a while if something injures it. //========================================================= NPC_STATE CNPC_Bullsquid::SelectIdealState( void ) { @@ -901,7 +901,7 @@ AI_BEGIN_CUSTOM_NPC( npc_bullsquid, CNPC_Bullsquid ) DEFINE_SCHEDULE ( SCHED_SQUID_HURTHOP, - + " Tasks" " TASK_STOP_MOVING 0" " TASK_SOUND_WAKE 0" @@ -910,14 +910,14 @@ AI_BEGIN_CUSTOM_NPC( npc_bullsquid, CNPC_Bullsquid ) " " " Interrupts" ) - + //========================================================= // > SCHED_SQUID_SEECRAB //========================================================= DEFINE_SCHEDULE ( SCHED_SQUID_SEECRAB, - + " Tasks" " TASK_STOP_MOVING 0" " TASK_SOUND_WAKE 0" @@ -928,14 +928,14 @@ AI_BEGIN_CUSTOM_NPC( npc_bullsquid, CNPC_Bullsquid ) " COND_LIGHT_DAMAGE" " COND_HEAVY_DAMAGE" ) - + //========================================================= // > SCHED_SQUID_EAT //========================================================= DEFINE_SCHEDULE ( SCHED_SQUID_EAT, - + " Tasks" " TASK_STOP_MOVING 0" " TASK_SQUID_EAT 10" @@ -958,14 +958,14 @@ AI_BEGIN_CUSTOM_NPC( npc_bullsquid, CNPC_Bullsquid ) " COND_NEW_ENEMY" " COND_SMELL" ) - + //========================================================= // > SCHED_SQUID_SNIFF_AND_EAT //========================================================= DEFINE_SCHEDULE ( SCHED_SQUID_SNIFF_AND_EAT, - + " Tasks" " TASK_STOP_MOVING 0" " TASK_SQUID_EAT 10" @@ -989,14 +989,14 @@ AI_BEGIN_CUSTOM_NPC( npc_bullsquid, CNPC_Bullsquid ) " COND_NEW_ENEMY" " COND_SMELL" ) - + //========================================================= // > SCHED_SQUID_WALLOW //========================================================= DEFINE_SCHEDULE ( SCHED_SQUID_WALLOW, - + " Tasks" " TASK_STOP_MOVING 0" " TASK_SQUID_EAT 10" @@ -1016,5 +1016,5 @@ AI_BEGIN_CUSTOM_NPC( npc_bullsquid, CNPC_Bullsquid ) " COND_HEAVY_DAMAGE" " COND_NEW_ENEMY" ) - + AI_END_CUSTOM_NPC() diff --git a/game/server/vance/npc_houndeye.cpp b/game/server/vance/npc_houndeye.cpp index 26013704..5bbc6af1 100644 --- a/game/server/vance/npc_houndeye.cpp +++ b/game/server/vance/npc_houndeye.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: Cute hound like Alien. // @@ -7,15 +7,15 @@ #include "cbase.h" #include "game.h" -#include "AI_Default.h" -#include "AI_Schedule.h" -#include "AI_Hull.h" -#include "AI_Navigator.h" -#include "AI_Route.h" -#include "AI_Squad.h" -#include "AI_SquadSlot.h" -#include "AI_Hint.h" -#include "NPCEvent.h" +#include "ai_default.h" +#include "ai_schedule.h" +#include "ai_hull.h" +#include "ai_navigator.h" +#include "ai_route.h" +#include "ai_squad.h" +#include "ai_squadslot.h" +#include "ai_hint.h" +#include "npcevent.h" #include "animation.h" #include "npc_houndeye.h" #include "gib.h" @@ -25,7 +25,7 @@ #include "engine/IEngineSound.h" #include "movevars_shared.h" -// houndeye does 20 points of damage spread over a sphere 384 units in diameter, and each additional +// houndeye does 20 points of damage spread over a sphere 384 units in diameter, and each additional // squad member increases the BASE damage by 110%, per the spec. #define HOUNDEYE_MAX_SQUAD_SIZE 4 #define HOUNDEYE_MAX_ATTACK_RADIUS 384 @@ -94,7 +94,7 @@ enum }; enum HoundEyeSquadSlots -{ +{ SQUAD_SLOTS_HOUND_ATTACK = LAST_SHARED_SQUADSLOT, }; @@ -105,14 +105,14 @@ enum HoundEyeSquadSlots void CNPC_Houndeye::Spawn() { Precache( ); - + SetRenderColor( 255, 255, 255, 255 ); SetModel( "models/houndeye.mdl" ); - + SetHullType(HULL_TINY); SetHullSizeNormal(); - + SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_STANDABLE ); SetMoveType( MOVETYPE_STEP ); @@ -123,7 +123,7 @@ void CNPC_Houndeye::Spawn() m_NPCState = NPC_STATE_NONE; m_fAsleep = FALSE; // everyone spawns awake m_fDontBlink = FALSE; - + CapabilitiesClear(); CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_INNATE_RANGE_ATTACK1 ); @@ -152,7 +152,7 @@ void CNPC_Houndeye::Precache() PrecacheScriptSound( "HoundEye.Sonic" ); BaseClass::Precache(); -} +} void CNPC_Houndeye::Event_Killed( const CTakeDamageInfo &info ) { @@ -163,10 +163,10 @@ void CNPC_Houndeye::Event_Killed( const CTakeDamageInfo &info ) int CNPC_Houndeye::RangeAttack1Conditions ( float flDot, float flDist ) { - // I'm not allowed to attack if standing in another hound eye + // I'm not allowed to attack if standing in another hound eye // (note houndeyes allowed to interpenetrate) trace_t tr; - UTIL_TraceHull( GetAbsOrigin(), GetAbsOrigin() + Vector(0,0,0.1), + UTIL_TraceHull( GetAbsOrigin(), GetAbsOrigin() + Vector(0,0,0.1), GetHullMins(), GetHullMaxs(), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr ); if (tr.startsolid) @@ -178,7 +178,7 @@ int CNPC_Houndeye::RangeAttack1Conditions ( float flDot, float flDist ) } } - // If I'm really close to my enemy allow me to attack if + // If I'm really close to my enemy allow me to attack if // I'm facing regardless of next attack time if (flDist < 100 && flDot >= 0.3) { @@ -205,7 +205,7 @@ int CNPC_Houndeye::RangeAttack1Conditions ( float flDot, float flDist ) void CNPC_Houndeye::IdleSound ( void ) { CPASAttenuationFilter filter( this ); - EmitSound( filter, entindex(), "HoundEye.Idle" ); + EmitSound( filter, entindex(), "HoundEye.Idle" ); } //========================================================= @@ -214,20 +214,20 @@ void CNPC_Houndeye::IdleSound ( void ) void CNPC_Houndeye::WarmUpSound ( void ) { CPASAttenuationFilter filter( this ); - EmitSound( filter, entindex(),"HoundEye.Warn" ); + EmitSound( filter, entindex(),"HoundEye.Warn" ); } //========================================================= -// WarnSound +// WarnSound //========================================================= void CNPC_Houndeye::WarnSound ( void ) { CPASAttenuationFilter filter( this ); - EmitSound( filter, entindex(), "HoundEye.Hunt" ); + EmitSound( filter, entindex(), "HoundEye.Hunt" ); } //========================================================= -// AlertSound +// AlertSound //========================================================= void CNPC_Houndeye::AlertSound ( void ) { @@ -240,21 +240,21 @@ void CNPC_Houndeye::AlertSound ( void ) } //========================================================= -// DeathSound +// DeathSound //========================================================= void CNPC_Houndeye::DeathSound( const CTakeDamageInfo &info ) { CPASAttenuationFilter filter( this ); - EmitSound( filter, entindex(), "HoundEye.Die" ); + EmitSound( filter, entindex(), "HoundEye.Die" ); } //========================================================= -// PainSound +// PainSound //========================================================= void CNPC_Houndeye::PainSound ( const CTakeDamageInfo &info ) { CPASAttenuationFilter filter( this ); - EmitSound( filter, entindex(), "HoundEye.Pain" ); + EmitSound( filter, entindex(), "HoundEye.Pain" ); } //========================================================= @@ -272,13 +272,13 @@ float CNPC_Houndeye::MaxYawSpeed ( void ) case ACT_CROUCHIDLE://sleeping! flYS = 0; break; - case ACT_IDLE: + case ACT_IDLE: flYS = 60; break; case ACT_WALK: flYS = 90; break; - case ACT_RUN: + case ACT_RUN: flYS = 90; break; case ACT_TURN_LEFT: @@ -291,7 +291,7 @@ float CNPC_Houndeye::MaxYawSpeed ( void ) } //========================================================= -// Classify - indicates this monster's place in the +// Classify - indicates this monster's place in the // relationship table. //========================================================= Class_T CNPC_Houndeye::Classify ( void ) @@ -339,14 +339,14 @@ void CNPC_Houndeye::HandleAnimEvent( animevent_t *pEvent ) case HOUND_AE_ANGERSOUND1: { CPASAttenuationFilter filter( this ); - EmitSound( filter, entindex(), "HoundEye.Anger1" ); + EmitSound( filter, entindex(), "HoundEye.Anger1" ); } break; case HOUND_AE_ANGERSOUND2: { CPASAttenuationFilter filter2( this ); - EmitSound( filter2, entindex(), "HoundEye.Anger2" ); + EmitSound( filter2, entindex(), "HoundEye.Anger2" ); } break; @@ -375,7 +375,7 @@ void CNPC_Houndeye::SonicAttack ( void ) EmitSound( filter, entindex(), "HoundEye.Sonic"); CBroadcastRecipientFilter filter2; - te->BeamRingPoint( filter2, 0.0, + te->BeamRingPoint( filter2, 0.0, GetAbsOrigin(), //origin 16, //start radius HOUNDEYE_MAX_ATTACK_RADIUS,//end radius @@ -395,7 +395,7 @@ void CNPC_Houndeye::SonicAttack ( void ) ); CBroadcastRecipientFilter filter3; - te->BeamRingPoint( filter3, 0.0, + te->BeamRingPoint( filter3, 0.0, GetAbsOrigin(), //origin 16, //start radius HOUNDEYE_MAX_ATTACK_RADIUS / 2, //end radius @@ -413,7 +413,7 @@ void CNPC_Houndeye::SonicAttack ( void ) 192, //a 0 //speed ); - + CBaseEntity *pEntity = NULL; // iterate on all entities in the vicinity. while ((pEntity = gEntList.FindEntityInSphere( pEntity, GetAbsOrigin(), HOUNDEYE_MAX_ATTACK_RADIUS )) != NULL) @@ -446,12 +446,12 @@ void CNPC_Houndeye::SonicAttack ( void ) { if ( pEntity->IsPlayer() ) { - // if this entity is a client, and is not in full view, inflict half damage. We do this so that players still + // if this entity is a client, and is not in full view, inflict half damage. We do this so that players still // take the residual damage if they don't totally leave the houndeye's effective radius. We restrict it to clients // so that monsters in other parts of the level don't take the damage and get pissed. flAdjustedDamage *= 0.5; } - else if ( !FClassnameIs( pEntity, "func_breakable" ) && !FClassnameIs( pEntity, "func_pushable" ) ) + else if ( !FClassnameIs( pEntity, "func_breakable" ) && !FClassnameIs( pEntity, "func_pushable" ) ) { // do not hurt nonclients through walls, but allow damage to be done to breakables flAdjustedDamage = 0; @@ -469,7 +469,7 @@ void CNPC_Houndeye::SonicAttack ( void ) if ( (pEntity->GetAbsOrigin() - GetAbsOrigin()).Length2D() <= HOUNDEYE_MAX_ATTACK_RADIUS ) { - if ( pEntity->GetMoveType() == MOVETYPE_VPHYSICS || (pEntity->VPhysicsGetObject() && !pEntity->IsPlayer()) ) + if ( pEntity->GetMoveType() == MOVETYPE_VPHYSICS || (pEntity->VPhysicsGetObject() && !pEntity->IsPlayer()) ) { IPhysicsObject *pPhysObject = pEntity->VPhysicsGetObject(); @@ -496,8 +496,8 @@ void CNPC_Houndeye::SonicAttack ( void ) } //========================================================= -// WriteBeamColor - writes a color vector to the network -// based on the size of the group. +// WriteBeamColor - writes a color vector to the network +// based on the size of the group. //========================================================= Vector CNPC_Houndeye::WriteBeamColor ( void ) { @@ -538,7 +538,7 @@ Vector CNPC_Houndeye::WriteBeamColor ( void ) bGreen = 220; bBlue = 255; } - + return Vector ( bRed, bGreen, bBlue ); } @@ -584,7 +584,7 @@ bool CNPC_Houndeye::FValidateHintType ( CAI_Hint *pHint ) } //========================================================= -// SetActivity +// SetActivity //========================================================= void CNPC_Houndeye::SetActivity ( Activity NewActivity ) { @@ -599,7 +599,7 @@ void CNPC_Houndeye::SetActivity ( Activity NewActivity ) iSequence = LookupSequence( "madidle" ); SetActivity( NewActivity ); // Go ahead and set this so it doesn't keep trying when the anim is not present - + // In case someone calls this with something other than the ideal activity SetIdealActivity( GetActivity() ); @@ -668,7 +668,7 @@ void CNPC_Houndeye::StartTask ( const Task_t *pTask ) SetIdealActivity( ACT_SPECIAL_ATTACK1 ); break; } - default: + default: { BaseClass::StartTask(pTask); break; @@ -677,7 +677,7 @@ void CNPC_Houndeye::StartTask ( const Task_t *pTask ) } //========================================================= -// RunTask +// RunTask //========================================================= void CNPC_Houndeye::RunTask ( const Task_t *pTask ) { @@ -696,7 +696,7 @@ void CNPC_Houndeye::RunTask ( const Task_t *pTask ) { TaskComplete(); } - + break; } case TASK_HOUND_CLOSE_EYE: @@ -720,7 +720,7 @@ void CNPC_Houndeye::RunTask ( const Task_t *pTask ) float idealYaw; idealYaw = UTIL_VecToYaw( GetNavigator()->GetGoalPos() ); GetMotor()->SetIdealYawAndUpdate( idealYaw ); - + float life; life = ((255 - GetCycle()) / ( m_flPlaybackRate * m_flPlaybackRate)); if (life < 0.1) @@ -737,10 +737,10 @@ void CNPC_Houndeye::RunTask ( const Task_t *pTask ) WRITE_BYTE( pev->frame / 25.0 ); // count WRITE_BYTE( life * 10 ); // life MessageEnd();*/ - + if ( IsSequenceFinished() ) { - SonicAttack(); + SonicAttack(); TaskComplete(); } @@ -760,7 +760,7 @@ void CNPC_Houndeye::RunTask ( const Task_t *pTask ) void CNPC_Houndeye::PrescheduleThink ( void ) { BaseClass::PrescheduleThink(); - + // if the hound is mad and is running, make hunt noises. if ( m_NPCState == NPC_STATE_COMBAT && GetActivity() == ACT_RUN && random->RandomFloat( 0, 1 ) < 0.2 ) { @@ -797,14 +797,14 @@ void CNPC_Houndeye::PrescheduleThink ( void ) } //========================================================= -// GetScheduleOfType +// GetScheduleOfType //========================================================= -int CNPC_Houndeye::TranslateSchedule( int scheduleType ) +int CNPC_Houndeye::TranslateSchedule( int scheduleType ) { if ( m_fAsleep ) { // if the hound is sleeping, must wake and stand! - if ( HasCondition( COND_HEAR_DANGER ) || HasCondition( COND_HEAR_THUMPER ) || HasCondition( COND_HEAR_COMBAT ) || + if ( HasCondition( COND_HEAR_DANGER ) || HasCondition( COND_HEAR_THUMPER ) || HasCondition( COND_HEAR_COMBAT ) || HasCondition( COND_HEAR_WORLD ) || HasCondition( COND_HEAR_PLAYER ) || HasCondition( COND_HEAR_BULLET_IMPACT ) ) { CSound *pWakeSound; @@ -867,7 +867,7 @@ int CNPC_Houndeye::TranslateSchedule( int scheduleType ) } else { - // client has taken off! + // client has taken off! return SCHED_HOUND_COMBAT_FAIL_NOPVS; } } @@ -904,7 +904,7 @@ int CNPC_Houndeye::SelectSchedule( void ) Vector v_forward; GetVectors( &v_forward, NULL, NULL ); UTIL_TraceEntity( this, GetAbsOrigin(), GetAbsOrigin() + v_forward * -128, MASK_SOLID, &trace ); - + if ( trace.fraction == 1.0 ) { // it's clear behind, so the hound will jump @@ -934,9 +934,9 @@ int CNPC_Houndeye::SelectSchedule( void ) //========================================================= // FLSoundVolume - subtracts the volume of the given sound -// from the distance the sound source is from the caller, -// and returns that value, which is considered to be the 'local' -// volume of the sound. +// from the distance the sound source is from the caller, +// and returns that value, which is considered to be the 'local' +// volume of the sound. //========================================================= float CNPC_Houndeye::FLSoundVolume( CSound *pSound ) { @@ -1161,7 +1161,7 @@ AI_END_CUSTOM_NPC() class CNPC_HoundeyeHD : public CNPC_Houndeye { DECLARE_CLASS( CNPC_HoundeyeHD, CNPC_Houndeye ); - + public: void Spawn( void ); void Precache( void ); @@ -1189,7 +1189,7 @@ void CNPC_HoundeyeHD::Precache() PrecacheScriptSound( "HoundEye.Sonic" ); CAI_BaseNPC::Precache(); -} +} //========================================================= // Spawn @@ -1197,14 +1197,14 @@ void CNPC_HoundeyeHD::Precache() void CNPC_HoundeyeHD::Spawn() { Precache( ); - + SetRenderColor( 255, 255, 255, 255 ); SetModel( "models/houndeye.mdl" ); - + SetHullType(HULL_TINY); SetHullSizeNormal(); - + SetSolid( SOLID_BBOX ); AddSolidFlags( FSOLID_NOT_STANDABLE ); SetMoveType( MOVETYPE_STEP ); @@ -1215,7 +1215,7 @@ void CNPC_HoundeyeHD::Spawn() m_NPCState = NPC_STATE_NONE; m_fAsleep = FALSE; // everyone spawns awake m_fDontBlink = FALSE; - + CapabilitiesClear(); CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_INNATE_RANGE_ATTACK1 ); diff --git a/game/server/vance/npc_roach.cpp b/game/server/vance/npc_roach.cpp index 77ea5c9d..54ec5913 100644 --- a/game/server/vance/npc_roach.cpp +++ b/game/server/vance/npc_roach.cpp @@ -1,26 +1,26 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// // -// Purpose: +// Purpose: // // $NoKeywords: $ // //=============================================================================// #include "cbase.h" #include "ai_basenpc.h" -#include "AI_Default.h" -#include "AI_Task.h" -#include "AI_Schedule.h" -#include "AI_Node.h" -#include "AI_Hull.h" -#include "AI_Hint.h" -#include "AI_Memory.h" -#include "AI_Route.h" -#include "AI_Motor.h" -#include "AI_Senses.h" +#include "ai_default.h" +#include "ai_task.h" +#include "ai_schedule.h" +#include "ai_node.h" +#include "ai_hull.h" +#include "ai_hint.h" +#include "ai_memory.h" +#include "ai_route.h" +#include "ai_motor.h" +#include "ai_senses.h" #include "soundent.h" #include "game.h" -#include "NPCEvent.h" -#include "EntityList.h" +#include "npcevent.h" +#include "entitylist.h" #include "activitylist.h" #include "animation.h" #include "basecombatweapon.h" @@ -28,8 +28,8 @@ #include "vstdlib/random.h" #include "engine/IEngineSound.h" #include "ammodef.h" -#include "AI_Behavior_Follow.h" -#include "AI_Navigator.h" +#include "ai_behavior_follow.h" +#include "ai_navigator.h" #include "decals.h" @@ -46,7 +46,7 @@ class CNPC_Roach : public CAI_BaseNPC { DECLARE_CLASS( CNPC_Roach, CAI_BaseNPC); - + public: void Spawn( void ); @@ -74,7 +74,7 @@ class CNPC_Roach : public CAI_BaseNPC float m_flLastLightLevel; float m_flNextSmellTime; - + // UNDONE: These don't necessarily need to be save/restored, but if we add more data, it may bool m_fLightHacked; int m_iMode; @@ -88,7 +88,7 @@ LINK_ENTITY_TO_CLASS( npc_cockroach, CNPC_Roach ); //BEGIN_DATADESC( CNPC_Roach ) // DEFINE_FUNCTION( RoachTouch ), - + //END_DATADESC() @@ -174,7 +174,7 @@ void CNPC_Roach::NPCThink( void ) if ( !m_fLightHacked ) { - // if light value hasn't been collection for the first time yet, + // if light value hasn't been collection for the first time yet, // suspend the creature for a second so the world finishes spawning, then we'll collect the light level. SetNextThink( gpGlobals->curtime + 1 ); m_fLightHacked = TRUE; @@ -213,12 +213,12 @@ void CNPC_Roach::NPCThink( void ) if ( m_iMode == ROACH_EAT ) { - // roach will ignore food for 30 to 45 seconds if it got bored while eating. + // roach will ignore food for 30 to 45 seconds if it got bored while eating. Eat( 30 + ( random->RandomInt(0,14) ) ); } } } - + // don't do this stuff if eating! if ( m_iMode == ROACH_IDLE ) { @@ -260,7 +260,7 @@ void CNPC_Roach::NPCThink( void ) break; } } - + if ( GetActivity() != ACT_IDLE ) { Move( flInterval ); @@ -289,10 +289,10 @@ void CNPC_Roach::PickNewDest ( int iCondition ) } } - do + do { // picks a random spot, requiring that it be at least 128 units away - // else, the roach will pick a spot too close to itself and run in + // else, the roach will pick a spot too close to itself and run in // circles. this is a hack but buys me time to work on the real monsters. vecNewDir.x = random->RandomInt( -1, 1 ); vecNewDir.y = random->RandomInt( -1, 1 ); @@ -306,7 +306,7 @@ void CNPC_Roach::PickNewDest ( int iCondition ) vecLocation.x = vecDest.x; vecLocation.y = vecDest.y; vecLocation.z = GetAbsOrigin().z; - + AI_NavGoal_t goal( GOALTYPE_LOCATION, vecLocation, ACT_WALK ); GetNavigator()->SetGoal( goal ); @@ -320,7 +320,7 @@ void CNPC_Roach::PickNewDest ( int iCondition ) } //========================================================= -// Look - overriden for the roach, which can virtually see +// Look - overriden for the roach, which can virtually see // 360 degrees. //========================================================= void CNPC_Roach::Look ( int iDistance ) @@ -336,7 +336,7 @@ void CNPC_Roach::Look ( int iDistance ) { return; } - + // Does sphere also limit itself to PVS? // Examine all entities within a reasonable radius // !!!PERFORMANCE - let's trivially reject the ent list before radius searching! @@ -352,7 +352,7 @@ void CNPC_Roach::Look ( int iDistance ) // we see monsters other than the Enemy. switch ( IRelationType ( pSightEnt ) ) { - case D_FR: + case D_FR: SetCondition( COND_SEE_FEAR ); break; case D_NU: @@ -369,14 +369,14 @@ void CNPC_Roach::Look ( int iDistance ) //========================================================= // roach's move function //========================================================= -void CNPC_Roach::Move ( float flInterval ) +void CNPC_Roach::Move ( float flInterval ) { float flWaypointDist; Vector vecApex; // local move to waypoint. flWaypointDist = ( GetNavigator()->GetGoalPos() - GetAbsOrigin() ).Length2D(); - + GetMotor()->SetIdealYawToTargetAndUpdate( GetNavigator()->GetGoalPos() ); float speed = 150 * flInterval; @@ -390,7 +390,7 @@ void CNPC_Roach::Move ( float flInterval ) // randomly change direction PickNewDest( m_iMode ); } - + if( !WalkMove( vMovePos, MASK_NPCSOLID ) ) { PickNewDest( m_iMode ); @@ -446,9 +446,9 @@ void CNPC_Roach::Touch ( CBaseEntity *pOther ) void CNPC_Roach::Event_Killed( const CTakeDamageInfo &info ) { RemoveSolidFlags( FSOLID_NOT_SOLID ); - + CPASAttenuationFilter filter( this ); - + //random sound if ( random->RandomInt( 0,4 ) == 1 ) { @@ -458,13 +458,13 @@ void CNPC_Roach::Event_Killed( const CTakeDamageInfo &info ) { EmitSound( filter, entindex(), "Roach.Smash" ); } - + CSoundEnt::InsertSound ( SOUND_WORLD, GetAbsOrigin(), 128, 1 ); UTIL_Remove( this ); } -int CNPC_Roach::GetSoundInterests ( void) +int CNPC_Roach::GetSoundInterests ( void) { return SOUND_CARCASS | SOUND_MEAT; diff --git a/game/server/vance/weapon_gauss.cpp b/game/server/vance/weapon_gauss.cpp index b6007b6c..faa8a56c 100644 --- a/game/server/vance/weapon_gauss.cpp +++ b/game/server/vance/weapon_gauss.cpp @@ -1,6 +1,6 @@ -//========= Copyright © 1996-2001, Valve LLC, All rights reserved. ============ +//========= Copyright � 1996-2001, Valve LLC, All rights reserved. ============ // -// Purpose: +// Purpose: // //============================================================================= @@ -10,7 +10,7 @@ #include "basehlcombatweapon.h" #include "decals.h" #include "beam_shared.h" -#include "AmmoDef.h" +#include "ammodef.h" #include "IEffects.h" #include "engine/IEngineSound.h" #include "in_buttons.h" @@ -21,9 +21,9 @@ #include "weapon_gauss.h" //----------------------------------------------------------------------------- -// Purpose: -// Input : &pos - -// &angles - +// Purpose: +// Input : &pos - +// &angles - //----------------------------------------------------------------------------- extern void TE_GaussExplosion(IRecipientFilter& filter, float delay, const Vector &pos, const Vector &dir, int type); @@ -38,7 +38,7 @@ END_SEND_TABLE() LINK_ENTITY_TO_CLASS( weapon_gauss, CWeaponGaussGun ); PRECACHE_WEAPON_REGISTER( weapon_gauss ); -acttable_t CWeaponGaussGun::m_acttable[] = +acttable_t CWeaponGaussGun::m_acttable[] = { { ACT_RANGE_ATTACK1, ACT_RANGE_ATTACK_AR2, true }, }; @@ -67,7 +67,7 @@ ConVar sk_plr_dmg_gauss( "sk_plr_dmg_gauss", "0" ); ConVar sk_plr_max_dmg_gauss( "sk_plr_dmg_gauss_max", "0" ); //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- CWeaponGaussGun::CWeaponGaussGun( void ) { @@ -80,7 +80,7 @@ CWeaponGaussGun::CWeaponGaussGun( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::Precache( void ) { @@ -90,7 +90,7 @@ void CWeaponGaussGun::Precache( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::Spawn( void ) { @@ -98,12 +98,12 @@ void CWeaponGaussGun::Spawn( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::Fire( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); - + if ( pOwner == NULL ) return; @@ -137,15 +137,15 @@ void CWeaponGaussGun::Fire( void ) aimDir = aimDir + x * GetBulletSpread().x * vecRight + y * GetBulletSpread().y * vecUp; Vector endPos = startPos + ( aimDir * MAX_TRACE_LENGTH ); - + //Shoot a shot straight out trace_t tr; UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); - + ClearMultiDamage(); CBaseEntity *pHit = tr.m_pEnt; - + CTakeDamageInfo dmgInfo( this, pOwner, sk_plr_dmg_gauss.GetFloat(), DMG_SHOCK ); if ( pHit != NULL ) @@ -153,7 +153,7 @@ void CWeaponGaussGun::Fire( void ) CalculateBulletDamageForce( &dmgInfo, m_iPrimaryAmmoType, aimDir, tr.endpos ); pHit->DispatchTraceAttack( dmgInfo, aimDir, &tr ); } - + if ( tr.DidHitWorld() ) { float hitAngle = -DotProduct( tr.plane.normal, aimDir ); @@ -161,12 +161,12 @@ void CWeaponGaussGun::Fire( void ) if ( hitAngle < 0.5f ) { Vector vReflection; - + vReflection = 2.0 * tr.plane.normal * hitAngle + aimDir; - + startPos = tr.endpos; endPos = startPos + ( vReflection * MAX_TRACE_LENGTH ); - + //Draw beam to reflection point DrawBeam( tr.startpos, tr.endpos, 1.6, true ); @@ -197,7 +197,7 @@ void CWeaponGaussGun::Fire( void ) { DrawBeam( tr.startpos, tr.endpos, 1.6, true ); } - + ApplyMultiDamage(); UTIL_ImpactTrace( &tr, GetAmmoDef()->DamageType(m_iPrimaryAmmoType), "ImpactGauss" ); @@ -214,12 +214,12 @@ void CWeaponGaussGun::Fire( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::ChargedFire( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); - + if ( pOwner == NULL ) return; @@ -242,10 +242,10 @@ void CWeaponGaussGun::ChargedFire( void ) Vector startPos= pOwner->Weapon_ShootPosition(); Vector aimDir = pOwner->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector endPos = startPos + ( aimDir * MAX_TRACE_LENGTH ); - + trace_t tr; UTIL_TraceLine( startPos, endPos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); - + ClearMultiDamage(); //Find how much damage to do @@ -269,11 +269,11 @@ void CWeaponGaussGun::ChargedFire( void ) CPVSFilter filter( tr.endpos ); te->GaussExplosion( filter, 0.0f, tr.endpos, tr.plane.normal, 0 ); - + Vector testPos = tr.endpos + ( aimDir * 48.0f ); UTIL_TraceLine( testPos, tr.endpos, MASK_SHOT, pOwner, COLLISION_GROUP_NONE, &tr ); - + if ( tr.allsolid == false ) { UTIL_DecalTrace( &tr, "RedGlowFade" ); @@ -322,12 +322,12 @@ void CWeaponGaussGun::ChargedFire( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, float width, bool useMuzzle ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); - + if ( pOwner == NULL ) return; @@ -344,7 +344,7 @@ void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, fl //Draw the main beam shaft CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, width ); - + if ( useMuzzle ) { pBeam->PointEntInit( endPos, m_hViewModel ); @@ -369,7 +369,7 @@ void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, fl for ( int i = 0; i < 3; i++ ) { pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, (width/2.0f) + i ); - + if ( useMuzzle ) { pBeam->PointEntInit( endPos, m_hViewModel ); @@ -380,7 +380,7 @@ void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, fl pBeam->SetStartPos( startPos ); pBeam->SetEndPos( endPos ); } - + pBeam->SetBrightness( random->RandomInt( 64, 255 ) ); pBeam->SetColor( 255, 255, 150+random->RandomInt( 0, 64 ) ); pBeam->RelinkBeam(); @@ -391,18 +391,18 @@ void CWeaponGaussGun::DrawBeam( const Vector &startPos, const Vector &endPos, fl } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::PrimaryAttack( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); - + if ( pOwner == NULL ) return; WeaponSound( SINGLE ); WeaponSound( SPECIAL2 ); - + SendWeaponAnim( ACT_VM_PRIMARYATTACK ); pOwner->DoMuzzleFlash(); @@ -418,7 +418,7 @@ void CWeaponGaussGun::PrimaryAttack( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::IncreaseCharge( void ) { @@ -426,7 +426,7 @@ void CWeaponGaussGun::IncreaseCharge( void ) return; CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); - + if ( pOwner == NULL ) return; @@ -444,10 +444,10 @@ void CWeaponGaussGun::IncreaseCharge( void ) { //Damage the player WeaponSound( SPECIAL2 ); - + // Add DMG_CRUSH because we don't want any physics force pOwner->TakeDamage( CTakeDamageInfo( this, this, 25, DMG_SHOCK | DMG_CRUSH ) ); - + color32 gaussDamage = {255,128,0,128}; UTIL_ScreenFade( pOwner, gaussDamage, 0.2f, 0.2f, FFADE_IN ); @@ -471,12 +471,12 @@ void CWeaponGaussGun::IncreaseCharge( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::SecondaryAttack( void ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); - + if ( pOwner == NULL ) return; @@ -487,7 +487,7 @@ void CWeaponGaussGun::SecondaryAttack( void ) { //Start looping animation SendWeaponAnim( ACT_VM_PULLBACK ); - + //Start looping sound if ( m_sndCharge == NULL ) { @@ -514,7 +514,7 @@ void CWeaponGaussGun::SecondaryAttack( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::AddViewKick( void ) { @@ -534,7 +534,7 @@ void CWeaponGaussGun::AddViewKick( void ) } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::ItemPostFrame( void ) { @@ -562,12 +562,12 @@ void CWeaponGaussGun::ItemPostFrame( void ) //Update spinning bits SetBoneController( 0, fanAngle ); SetBoneController( 1, m_flCoilAngle ); - + BaseClass::ItemPostFrame(); } //----------------------------------------------------------------------------- -// Purpose: +// Purpose: //----------------------------------------------------------------------------- void CWeaponGaussGun::StopChargeSound( void ) { @@ -578,8 +578,8 @@ void CWeaponGaussGun::StopChargeSound( void ) } //----------------------------------------------------------------------------- -// Purpose: -// Input : *pSwitchingTo - +// Purpose: +// Input : *pSwitchingTo - // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool CWeaponGaussGun::Holster( CBaseCombatWeapon *pSwitchingTo ) diff --git a/game/shared/vance/singleplayer_animstate.cpp b/game/shared/vance/singleplayer_animstate.cpp index 561e2d0d..c763b7b8 100644 --- a/game/shared/vance/singleplayer_animstate.cpp +++ b/game/shared/vance/singleplayer_animstate.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: Single Player animation state 'handler'. This utility is used // to evaluate the pose parameter value based on the direction @@ -14,7 +14,7 @@ #include "apparent_velocity_helper.h" #include "utldict.h" #include "filesystem.h" -#include "..\public\datacache\imdlcache.h" +#include "datacache/imdlcache.h" extern ConVar mp_facefronttime, mp_feetyawrate, mp_ik; @@ -501,4 +501,4 @@ void CSinglePlayerAnimState::GetOuterAbsVelocity(Vector& vel) #else vel = GetBasePlayer()->GetAbsVelocity(); #endif -} \ No newline at end of file +} diff --git a/materialsystem/stdshaders/VertexlitPBR_dx9.cpp b/materialsystem/stdshaders/VertexlitPBR_dx9.cpp index 9775552b..4e43ba53 100644 --- a/materialsystem/stdshaders/VertexlitPBR_dx9.cpp +++ b/materialsystem/stdshaders/VertexlitPBR_dx9.cpp @@ -6,7 +6,7 @@ #include "BaseVSShader.h" #include "convar.h" -#include "vertexlitpbr_dx9_helper.h" +#include "VertexlitPBR_dx9_helper.h" #include "lightpass_helper.h" #ifdef STDSHADER diff --git a/materialsystem/stdshaders/VertexlitPBR_dx9_helper.cpp b/materialsystem/stdshaders/VertexlitPBR_dx9_helper.cpp index 1bf8b338..eb9fa1d7 100644 --- a/materialsystem/stdshaders/VertexlitPBR_dx9_helper.cpp +++ b/materialsystem/stdshaders/VertexlitPBR_dx9_helper.cpp @@ -1,16 +1,16 @@ //========= Copyright Valve Corporation, All rights reserved. ============// // -// Purpose: +// Purpose: // // $NoKeywords: $ // //===========================================================================// #include "BaseVSShader.h" -#include "vertexlitPBR_dx9_helper.h" +#include "VertexlitPBR_dx9_helper.h" #include "convar.h" #include "cpp_shader_constant_register_map.h" #include "vertexlitPBR_vs30.inc" -#include "vertexlitPBR_ps30.inc" +#include "VertexlitPBR_ps30.inc" #include "commandbuilder.h" #include "IDeferredExt.h" @@ -29,10 +29,10 @@ extern ConVar r_csm_performance; // Initialize shader parameters //----------------------------------------------------------------------------- void InitParamsVertexLitPBR_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, VertexLitPBR_DX9_Vars_t &info ) -{ +{ // FLASHLIGHTFIXME: Do ShaderAPI::BindFlashlightTexture Assert( info.m_nFlashlightTexture >= 0 ); - + params[info.m_nBRDF]->SetStringValue("models/PBRTest/BRDF"); if ( g_pHardwareConfig->SupportsBorderColor() ) @@ -46,7 +46,7 @@ void InitParamsVertexLitPBR_DX9( CBaseVSShader *pShader, IMaterialVar** params, if (((info.m_nBumpmap != -1) && g_pConfig->UseBumpmapping() && params[info.m_nBumpmap]->IsDefined()) // we don't need a tangent space if we have envmap without bumpmap - // || ( info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsDefined() ) + // || ( info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsDefined() ) ) { SET_FLAGS2(MATERIAL_VAR2_NEEDS_TANGENT_SPACES); @@ -65,12 +65,12 @@ void InitVertexLitPBR_DX9( CBaseVSShader *pShader, IMaterialVar** params, Vertex { Assert( info.m_nFlashlightTexture >= 0 ); pShader->LoadTexture(info.m_nFlashlightTexture, TEXTUREFLAGS_SRGB); - + bool bIsBaseTextureTranslucent = false; if ( params[info.m_nBaseTexture]->IsDefined() ) { pShader->LoadTexture( info.m_nBaseTexture, TEXTUREFLAGS_SRGB ); - + if ( params[info.m_nBaseTexture]->GetTextureValue()->IsTranslucent() ) { bIsBaseTextureTranslucent = true; @@ -190,7 +190,7 @@ static void DrawVertexLitPBR_DX9_Internal( CBaseVSShader *pShader, IMaterialVar* if( bIsAlphaTested ) { - // disable alpha test and use the zfunc zequals since alpha isn't guaranteed to + // disable alpha test and use the zfunc zequals since alpha isn't guaranteed to // be the same on both the regular pass and the flashlight pass. pShaderShadow->EnableAlphaTest( false ); pShaderShadow->DepthFunc( SHADER_DEPTHFUNC_EQUAL ); @@ -210,7 +210,7 @@ static void DrawVertexLitPBR_DX9_Internal( CBaseVSShader *pShader, IMaterialVar* pShader->SetDefaultBlendingShadowState( info.m_nBaseTexture, true ); } } - + unsigned int flags = VERTEX_POSITION | VERTEX_NORMAL; int userDataSize = 0; @@ -258,7 +258,7 @@ static void DrawVertexLitPBR_DX9_Internal( CBaseVSShader *pShader, IMaterialVar* userDataSize = 4; // tangent S pShaderShadow->EnableTexture( SHADER_SAMPLER5, true ); // Normalizing cube map pShaderShadow->EnableSRGBWrite( true ); - + // texcoord0 : base texcoord int pTexCoordDim[3] = { 2, 2, 3 }; int nTexCoordCount = 1; @@ -352,7 +352,7 @@ static void DrawVertexLitPBR_DX9_Internal( CBaseVSShader *pShader, IMaterialVar* } pShader->BindTexture(SHADER_SAMPLER8, info.m_nBRDF); - + LightState_t lightState = { 0, false, false }; bool bFlashlightShadows = false; if( bHasFlashlight ) @@ -383,7 +383,7 @@ static void DrawVertexLitPBR_DX9_Internal( CBaseVSShader *pShader, IMaterialVar* bool bWriteDepthToAlpha = false; bool bWriteWaterFogToAlpha = false; - if( bFullyOpaque ) + if( bFullyOpaque ) { bWriteDepthToAlpha = pShaderAPI->ShouldWriteDepthToDestAlpha(); bWriteWaterFogToAlpha = (fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z); diff --git a/materialsystem/stdshaders/_shaderlist_dx9_20b.txt b/materialsystem/stdshaders/_shaderlist_dx9_20b.txt index 0d8b479a..09ed1bf9 100644 --- a/materialsystem/stdshaders/_shaderlist_dx9_20b.txt +++ b/materialsystem/stdshaders/_shaderlist_dx9_20b.txt @@ -18,9 +18,9 @@ //vertexlit_and_unlit_generic_ps2x.fxc //VertexLit_and_unlit_Generic_vs20.fxc //vertexlit_and_unlit_generic_bump_ps2x.fxc -//VertexLit_and_unlit_Generic_bump_vs20.fxc +//vertexLit_and_unlit_Generic_bump_vs20.fxc //SDK_screenspaceeffect_vs20.fxc depthwrite_ps2x.fxc -depthwrite_vs20.fxc \ No newline at end of file +depthwrite_vs20.fxc diff --git a/materialsystem/stdshaders/_shaderlist_dx9_30.txt b/materialsystem/stdshaders/_shaderlist_dx9_30.txt index b41e3cfb..4b1c41b1 100644 --- a/materialsystem/stdshaders/_shaderlist_dx9_30.txt +++ b/materialsystem/stdshaders/_shaderlist_dx9_30.txt @@ -62,7 +62,7 @@ vertexLit_and_unlit_Generic_vs30.fxc vertexlit_and_unlit_generic_bump_ps30.fxc VertexLit_and_unlit_Generic_bump_vs30.fxc -VertexlitPBR_ps30.fxc +vertexlitPBR_ps30.fxc vertexlitPBR_vs30.fxc lightmappedPBR_ps30.fxc @@ -103,4 +103,4 @@ depthwrite_ps2x.fxc passthru_vs20.fxc light_mesh_ps30.fxc -light_mesh_vs30.fxc \ No newline at end of file +light_mesh_vs30.fxc diff --git a/materialsystem/stdshaders/game_shader_dx9_vance.vpc b/materialsystem/stdshaders/game_shader_dx9_vance.vpc index f98cae65..4fda9ee2 100644 --- a/materialsystem/stdshaders/game_shader_dx9_vance.vpc +++ b/materialsystem/stdshaders/game_shader_dx9_vance.vpc @@ -5,7 +5,7 @@ //----------------------------------------------------------------------------- $Macro SRCDIR "..\.." -$Macro GAMENAME "VANCE" +$Macro GAMENAME "vance" $Include "$SRCDIR\materialsystem\stdshaders\game_shader_dx9_base.vpc" $Configuration @@ -73,4 +73,4 @@ $Project "Shaders (VANCE)" -$File "Bloom.cpp" } -} \ No newline at end of file +} diff --git a/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp b/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp index 7a683abd..84087571 100644 --- a/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp +++ b/materialsystem/stdshaders/lightmappedgeneric_dx9.cpp @@ -11,7 +11,7 @@ #include "lightmappedgeneric_dx9_helper.h" #ifdef VANCE #include "lightpass_helper.h" -#include "vertexlitpbr_dx9_helper.h" +#include "VertexlitPBR_dx9_helper.h" #endif // VANCE diff --git a/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp b/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp index 894f00ed..34d2c4ab 100644 --- a/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp +++ b/materialsystem/stdshaders/vertexlitgeneric_dx9.cpp @@ -14,7 +14,7 @@ #include "flesh_interior_blended_pass_helper.h" #include "weapon_sheen_pass_helper.h" #else -#include "vertexlitpbr_dx9_helper.h" +#include "VertexlitPBR_dx9_helper.h" #include "lightpass_helper.h" #endif // !VANCE diff --git a/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp b/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp index 6770542f..b9c3187a 100644 --- a/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp +++ b/materialsystem/stdshaders/vertexlitgeneric_dx9_helper.cpp @@ -1,6 +1,6 @@ //========= Copyright Valve Corporation, All rights reserved. ============// // -// Purpose: +// Purpose: // // $NoKeywords: $ // @@ -20,9 +20,9 @@ #endif // !VANCE #ifndef _X360 -#include "vertexlit_and_unlit_generic_vs30.inc" +#include "vertexLit_and_unlit_Generic_vs30.inc" #include "vertexlit_and_unlit_generic_ps30.inc" -#include "vertexlit_and_unlit_generic_bump_vs30.inc" +#include "VertexLit_and_unlit_Generic_bump_vs30.inc" #include "vertexlit_and_unlit_generic_bump_ps30.inc" #endif @@ -41,7 +41,7 @@ static inline bool WantsSkinShader( IMaterialVar** params, const VertexLitGeneri { if ( info.m_nPhong == -1) // Don't use skin without Phong return false; - + if ( params[info.m_nPhong]->GetIntValue() == 0 ) // Don't use skin without Phong turned on return false; @@ -66,7 +66,7 @@ int g_nSnapShots; // Initialize shader parameters //----------------------------------------------------------------------------- void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info ) -{ +{ InitIntParam( info.m_nPhong, params, 0 ); InitFloatParam( info.m_nAlphaTestReference, params, 0.0f ); @@ -117,7 +117,7 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para } } #endif // !VANCE - + // FLASHLIGHTFIXME: Do ShaderAPI::BindFlashlightTexture if ( info.m_nFlashlightTexture != -1 ) { @@ -130,7 +130,7 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para params[FLASHLIGHTTEXTURE]->SetStringValue( "effects/flashlight001" ); } } - + // Write over $basetexture with $info.m_nBumpmap if we are going to be using diffuse normal mapping. if ( info.m_nAlbedo != -1 && g_pConfig->UseBumpmapping() && info.m_nBumpmap != -1 && params[info.m_nBumpmap]->IsDefined() && params[info.m_nAlbedo]->IsDefined() && params[info.m_nBaseTexture]->IsDefined() ) @@ -174,9 +174,9 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para SET_FLAGS( MATERIAL_VAR_NO_DEBUG_OVERRIDE ); } - if( ( (info.m_nBumpmap != -1) && g_pConfig->UseBumpmapping() && params[info.m_nBumpmap]->IsDefined() ) + if( ( (info.m_nBumpmap != -1) && g_pConfig->UseBumpmapping() && params[info.m_nBumpmap]->IsDefined() ) // we don't need a tangent space if we have envmap without bumpmap - // || ( info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsDefined() ) + // || ( info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsDefined() ) ) { SET_FLAGS2( MATERIAL_VAR2_NEEDS_TANGENT_SPACES ); @@ -197,13 +197,13 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para CLEAR_FLAGS( MATERIAL_VAR_BASEALPHAENVMAPMASK ); } - if ( IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ) && info.m_nBumpmap != -1 && + if ( IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ) && info.m_nBumpmap != -1 && params[info.m_nBumpmap]->IsDefined() && !hasNormalMapAlphaEnvmapMask ) { Warning( "material %s has a normal map and $basealphaenvmapmask. Must use $normalmapalphaenvmapmask to get specular.\n\n", pMaterialName ); params[info.m_nEnvmap]->SetUndefined(); } - + if ( info.m_nEnvmapMask != -1 && params[info.m_nEnvmapMask]->IsDefined() && info.m_nBumpmap != -1 && params[info.m_nBumpmap]->IsDefined() ) { params[info.m_nEnvmapMask]->SetUndefined(); @@ -236,7 +236,7 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para void InitVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info ) { - + //bool bHasBump = ( info.m_nBumpmap != -1 ) && params[info.m_nBumpmap]->IsTexture(); //if ( bHasBump ) //{ @@ -246,9 +246,9 @@ void InitVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, bo #ifndef VANCE // both detailed and bumped = needs skin shader (for now) bool bNeedsSkinBecauseOfDetail = false; - if ( bNeedsSkinBecauseOfDetail || - ( info.m_nPhong != -1 && - params[info.m_nPhong]->GetIntValue() && + if ( bNeedsSkinBecauseOfDetail || + ( info.m_nPhong != -1 && + params[info.m_nPhong]->GetIntValue() && g_pHardwareConfig->SupportsPixelShaders_2_b() ) ) { InitSkin_DX9( pShader, params, info ); @@ -261,12 +261,12 @@ void InitVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, bo { pShader->LoadTexture( info.m_nFlashlightTexture, TEXTUREFLAGS_SRGB ); } - + bool bIsBaseTextureTranslucent = false; if ( info.m_nBaseTexture != -1 && params[info.m_nBaseTexture]->IsDefined() ) { pShader->LoadTexture( info.m_nBaseTexture, ( info.m_nGammaColorRead != -1 ) && ( params[info.m_nGammaColorRead]->GetIntValue() == 1 ) ? 0 : TEXTUREFLAGS_SRGB ); - + if ( params[info.m_nBaseTexture]->GetTextureValue()->IsTranslucent() ) { bIsBaseTextureTranslucent = true; @@ -316,7 +316,7 @@ void InitVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, bo { CLEAR_FLAGS( MATERIAL_VAR_ALPHATEST ); } - + if ( info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsDefined() ) { if ( !IS_FLAG_SET(MATERIAL_VAR_ENVMAPSPHERE) ) @@ -329,7 +329,7 @@ void InitVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, bo { pShader->LoadTexture( info.m_nEnvmap, g_pHardwareConfig->GetHDRType() == HDR_TYPE_NONE ? TEXTUREFLAGS_SRGB : 0 ); } - + if ( !g_pHardwareConfig->SupportsCubeMaps() ) { SET_FLAGS( MATERIAL_VAR_ENVMAPSPHERE ); @@ -365,10 +365,10 @@ class CVertexLitGeneric_DX9_Context : public CBasePerMaterialContextData static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShaderDynamicAPI *pShaderAPI, IShaderShadow* pShaderShadow, - bool bVertexLitGeneric, bool bHasFlashlight, + bool bVertexLitGeneric, bool bHasFlashlight, VertexLitGeneric_DX9_Vars_t &info, VertexCompressionType_t vertexCompression, - CBasePerMaterialContextData **pContextDataPtr ) + CBasePerMaterialContextData **pContextDataPtr ) { CVertexLitGeneric_DX9_Context *pContextData = reinterpret_cast< CVertexLitGeneric_DX9_Context *> ( *pContextDataPtr ); @@ -435,12 +435,12 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial bool bHasEnvmap = (!bHasFlashlight || IsX360() ) && info.m_nEnvmap != -1 && params[info.m_nEnvmap]->IsTexture(); - + bool bHasVertexColor = bVertexLitGeneric ? false : IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR ); bool bHasVertexAlpha = bVertexLitGeneric ? false : IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA ); /*^*/ // printf("\t\t[%d] bHasVertexColor\n",(int)bHasVertexColor); /*^*/ // printf("\t\t[%d] bHasVertexAlpha\n",(int)bHasVertexAlpha); - + if ( pShader->IsSnapshotting() || (! pContextData ) || ( pContextData->m_bMaterialVarsChanged ) ) { /*^*/ // printf("\t\t[1] snapshotting=%d pContextData=%08x pContextData->m_bMaterialVarsChanged=%d \n",(int)pShader->IsSnapshotting(), (int)pContextData, pContextData ? (int)pContextData->m_bMaterialVarsChanged : -1 ); @@ -462,8 +462,8 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial bool hasBaseAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_BASEALPHAENVMAPMASK ); bool hasNormalMapAlphaEnvmapMask = IS_FLAG_SET( MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK ); - - + + if ( info.m_nVertexAlphaTest != -1 && params[info.m_nVertexAlphaTest]->GetIntValue() > 0 ) { bHasVertexAlpha = true; @@ -516,7 +516,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial if ( bIsAlphaTested ) { - // disable alpha test and use the zfunc zequals since alpha isn't guaranteed to + // disable alpha test and use the zfunc zequals since alpha isn't guaranteed to // be the same on both the regular pass and the flashlight pass. pShaderShadow->EnableAlphaTest( false ); pShaderShadow->DepthFunc( SHADER_DEPTHFUNC_EQUAL ); @@ -537,7 +537,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial { pShader->SetBlendingShadowState( nBlendType ); } - + unsigned int flags = VERTEX_POSITION; if ( bHasNormal ) { @@ -622,7 +622,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial { if( bHasBump ) Warning( "DEPTHBLEND not supported by bump mapped variations of vertexlitgeneric to avoid shader bloat. Either remove the bump map or convince a graphics programmer that it's worth it.\n" ); - + pShaderShadow->EnableTexture( SHADER_SAMPLER10, true ); } @@ -643,11 +643,11 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial } pShaderShadow->EnableSRGBWrite( bSRGBWrite ); - + // texcoord0 : base texcoord int pTexCoordDim[3] = { 2, 2, 3 }; int nTexCoordCount = 1; - + if ( IsBoolSet( info.m_nSeparateDetailUVs, params ) ) { ++nTexCoordCount; @@ -658,7 +658,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial } #ifndef _X360 - // Special morphed decal information + // Special morphed decal information if ( bIsDecal && g_pHardwareConfig->HasFastVertexTextures() ) { nTexCoordCount = 3; @@ -1017,8 +1017,8 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial { pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_0, info.m_nBaseTextureTransform ); } - - + + if ( bHasDetailTexture ) { if ( IS_PARAM_DEFINED( info.m_nDetailTextureTransform ) ) @@ -1053,14 +1053,14 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial int nWidth, nHeight; pShaderAPI->GetBackBufferDimensions( nWidth, nHeight ); flResScale=max( 0.5, max( 1024.0/nWidth, 768/nHeight ) ); - + if ( bScaleEdges ) { float flMid = 0.5 * ( flSoftStart + flSoftEnd ); flSoftStart = clamp( flMid + flResScale * ( flSoftStart - flMid ), 0.05, 0.99 ); flSoftEnd = clamp( flMid + flResScale * ( flSoftEnd - flMid ), 0.05, 0.99 ); } - + if ( bScaleOutline ) { @@ -1070,7 +1070,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial float flMidE = 0.5 * ( flOutlineEnd1 + flOutlineEnd0 ); flOutlineEnd1 = clamp( flMidE + flResScale * ( flOutlineEnd1 - flMidE ), 0.05, 0.99 ); } - + } float flConsts[]={ @@ -1129,7 +1129,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial float vEnvMapSaturation_SelfIllumMask[4] = {1.0f, 1.0f, 1.0f, 0.0f}; if ( info.m_nEnvmapSaturation != -1 ) params[info.m_nEnvmapSaturation]->GetVecValue( vEnvMapSaturation_SelfIllumMask, 3 ); - + vEnvMapSaturation_SelfIllumMask[3] = bHasSelfIllumMask ? 1.0f : 0.0f; pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant( 3, vEnvMapSaturation_SelfIllumMask, 1 ); if ( bHasEnvmap ) @@ -1216,7 +1216,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial pContextData->m_SemiStaticCmdsOut.BindStandardTexture( SHADER_SAMPLER2, TEXTURE_GREY ); } } - + if ( bHasBump || bHasDiffuseWarp ) { pContextData->m_SemiStaticCmdsOut.BindStandardTexture( SHADER_SAMPLER5, TEXTURE_NORMALIZATION_CUBEMAP_SIGNED ); @@ -1271,7 +1271,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial { lightState.m_bStaticLightVertex = false; lightState.m_bStaticLightTexel = true; - + // Usual case, not debugging. if (!bHasMatLuxel) { @@ -1292,7 +1292,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial bool bWriteDepthToAlpha; bool bWriteWaterFogToAlpha; - if( bFullyOpaque ) + if( bFullyOpaque ) { bWriteDepthToAlpha = pShaderAPI->ShouldWriteDepthToDestAlpha(); bWriteWaterFogToAlpha = (fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z); @@ -1404,7 +1404,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( - LIGHTING_PREVIEW, + LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); SET_DYNAMIC_VERTEX_SHADER_COMBO( NUM_LIGHTS, bUseStaticControlFlow ? 0 : lightState.m_nNumLights ); @@ -1447,7 +1447,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial SET_DYNAMIC_VERTEX_SHADER_COMBO( STATIC_LIGHT_LIGHTMAP, lightState.m_bStaticLightTexel ? 1 : 0 ); SET_DYNAMIC_VERTEX_SHADER_COMBO( DOWATERFOG, fogIndex ); SET_DYNAMIC_VERTEX_SHADER_COMBO( SKINNING, numBones > 0 ); - SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, + SET_DYNAMIC_VERTEX_SHADER_COMBO( LIGHTING_PREVIEW, pShaderAPI->GetIntRenderingParameter(INT_RENDERPARM_ENABLE_FIXED_LIGHTING)!=0); SET_DYNAMIC_VERTEX_SHADER_COMBO( MORPHING, pShaderAPI->IsHWMorphingEnabled() ); SET_DYNAMIC_VERTEX_SHADER_COMBO( COMPRESSED_VERTS, (int)vertexCompression ); @@ -1480,7 +1480,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial float eyePos[4]; pShaderAPI->GetWorldSpaceCameraPosition( eyePos ); DynamicCmdsOut.SetPixelShaderConstant( 20, eyePos ); - + // Non-bump case does its own depth feathering work if ( !bHasBump && !bHasDiffuseWarp ) { diff --git a/public/chunkfile.cpp b/public/chunkfile.cpp index 81a77dd3..d06d5ace 100644 --- a/public/chunkfile.cpp +++ b/public/chunkfile.cpp @@ -151,7 +151,7 @@ ChunkHandler_t CChunkHandlerMap::GetHandler(const char *pszChunkName, void **ppD pNode = pNode->pNext; } - return(false); + return nullptr; } diff --git a/public/fgdlib/fgdlib.h b/public/fgdlib/fgdlib.h index 76051cfb..c7856f28 100644 --- a/public/fgdlib/fgdlib.h +++ b/public/fgdlib/fgdlib.h @@ -10,9 +10,9 @@ #pragma once #endif -#include "HelperInfo.h" -#include "GameData.h" -#include "GDClass.h" -#include "InputOutput.h" +#include "helperinfo.h" +#include "gamedata.h" +#include "gdclass.h" +#include "inputoutput.h" #endif // FGDLIB_H diff --git a/public/fgdlib/gamedata.h b/public/fgdlib/gamedata.h index cf8b5be1..59d47416 100644 --- a/public/fgdlib/gamedata.h +++ b/public/fgdlib/gamedata.h @@ -12,12 +12,15 @@ #pragma warning(push, 1) #pragma warning(disable:4701 4702 4530) +#undef min +#undef max #include #pragma warning(pop) -#include "TokenReader.h" -#include "GDClass.h" -#include "InputOutput.h" -#include "UtlString.h" + +#include "tokenreader.h" +#include "gdclass.h" +#include "inputoutput.h" +#include "utlstring.h" #include "utlvector.h" @@ -25,7 +28,7 @@ class MDkeyvalue; class GameData; class KeyValues; -enum TEXTUREFORMAT; +//enum TEXTUREFORMAT; typedef void (*GameDataMessageFunc_t)(int level, PRINTF_FORMAT_STRING const char *fmt, ...); diff --git a/public/fgdlib/gdclass.h b/public/fgdlib/gdclass.h index fe81bb37..8fa3d07c 100644 --- a/public/fgdlib/gdclass.h +++ b/public/fgdlib/gdclass.h @@ -17,10 +17,10 @@ #pragma once #endif -#include "HelperInfo.h" -#include "TokenReader.h" -#include "GDVar.h" -#include "InputOutput.h" +#include "helperinfo.h" +#include "tokenreader.h" +#include "gdvar.h" +#include "inputoutput.h" #include "mathlib/vector.h" class CHelperInfo; diff --git a/public/fgdlib/gdvar.h b/public/fgdlib/gdvar.h index 197ff30d..628eb526 100644 --- a/public/fgdlib/gdvar.h +++ b/public/fgdlib/gdvar.h @@ -10,7 +10,7 @@ #pragma once #include -#include // dvs: for MAX_STRING. Fix. +#include // dvs: for MAX_STRING. Fix. class MDkeyvalue; diff --git a/public/fgdlib/inputoutput.h b/public/fgdlib/inputoutput.h index 7438f08f..a491d553 100644 --- a/public/fgdlib/inputoutput.h +++ b/public/fgdlib/inputoutput.h @@ -10,7 +10,7 @@ #include -#include "fgdlib/EntityDefs.h" +#include "fgdlib/entitydefs.h" enum InputOutputType_t diff --git a/public/fgdlib/wckeyvalues.h b/public/fgdlib/wckeyvalues.h index 730d92d1..58036796 100644 --- a/public/fgdlib/wckeyvalues.h +++ b/public/fgdlib/wckeyvalues.h @@ -9,13 +9,16 @@ #pragma once -#include -#include -#include + #pragma warning(push, 1) #pragma warning(disable:4701 4702 4530) +#undef min +#undef max #include #pragma warning(pop) +#include +#include +#include #define KEYVALUE_MAX_KEY_LENGTH 80 @@ -188,7 +191,7 @@ typedef WCKeyValuesT WCKeyValuesVector; template inline const char *WCKeyValuesT::GetKey(int nIndex) const { - return(m_KeyValues.Element(nIndex).szKey); + return WCKeyValuesT::m_KeyValues.Element( nIndex ).szKey; } @@ -200,7 +203,7 @@ inline const char *WCKeyValuesT::GetKey(int nIndex) const template inline MDkeyvalue &WCKeyValuesT::GetKeyValue(int nIndex) { - return(m_KeyValues.Element(nIndex)); + return WCKeyValuesT::m_KeyValues.Element( nIndex ).szKey; } @@ -212,7 +215,7 @@ inline MDkeyvalue &WCKeyValuesT::GetKeyValue(int nIndex) template inline const MDkeyvalue& WCKeyValuesT::GetKeyValue(int nIndex) const { - return(m_KeyValues.Element(nIndex)); + return WCKeyValuesT::m_KeyValues.Element( nIndex ).szKey; } @@ -223,7 +226,7 @@ inline const MDkeyvalue& WCKeyValuesT::GetKeyValue(int nIndex) const template inline const char *WCKeyValuesT::GetValue(int nIndex) const { - return(m_KeyValues.Element(nIndex).szValue); + return WCKeyValuesT::m_KeyValues.Element( nIndex ).szKey; } diff --git a/public/loadcmdline.cpp b/public/loadcmdline.cpp index 30c616f3..fc809c3c 100644 --- a/public/loadcmdline.cpp +++ b/public/loadcmdline.cpp @@ -7,7 +7,7 @@ #include "KeyValues.h" #include "tier1/strtools.h" -#include "FileSystem_Tools.h" +#include "filesystem_tools.h" #include "tier1/utlstring.h" // So we know whether or not we own argv's memory diff --git a/public/scratchpad3d.cpp b/public/scratchpad3d.cpp index 96db2174..96029f5c 100644 --- a/public/scratchpad3d.cpp +++ b/public/scratchpad3d.cpp @@ -12,7 +12,7 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#ifndef POSIX + // NOTE - linux doesn't need any of this code! extern "C" @@ -631,5 +631,5 @@ IScratchPad3D* ScratchPad3D_Create( char const *pFilename ) CScratchPad3D *pRet = new CScratchPad3D( pFilename, pFileSystem, true ); return pRet; } -#endif // POSIX + diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h index b4a254ff..8d86c59e 100644 --- a/public/tier1/utlblockmemory.h +++ b/public/tier1/utlblockmemory.h @@ -135,10 +135,10 @@ CUtlBlockMemory::~CUtlBlockMemory() template< class T, class I > void CUtlBlockMemory::Swap( CUtlBlockMemory< T, I > &mem ) { - swap( m_pMemory, mem.m_pMemory ); - swap( m_nBlocks, mem.m_nBlocks ); - swap( m_nIndexMask, mem.m_nIndexMask ); - swap( m_nIndexShift, mem.m_nIndexShift ); + V_swap( m_pMemory, mem.m_pMemory ); + V_swap( m_nBlocks, mem.m_nBlocks ); + V_swap( m_nIndexMask, mem.m_nIndexMask ); + V_swap( m_nIndexShift, mem.m_nIndexShift ); } diff --git a/tier1/math_proxy.cpp b/tier1/math_proxy.cpp new file mode 100644 index 00000000..432705f9 --- /dev/null +++ b/tier1/math_proxy.cpp @@ -0,0 +1,50 @@ +/** + * + * math_proxy.cpp - Implements certain unresolved symbols and points them to their proper endpoints + * + */ +#include + +#if __GNUC__ > 5 + +extern "C" float __powf_finite(float x, float y) +{ + return powf(x, y); +} + +extern "C" double __atan2_finite(double y, double x) +{ + return atan2(y, x); +} + +extern "C" float __logf_finite(float f) +{ + return logf(f); +} + +extern "C" float __acosf_finite(float f) +{ + return acosf(f); +} + +extern "C" double __exp_finite(double f) +{ + return exp(f); +} + +extern "C" float __expf_finite(float f) +{ + return expf(f); +} + +extern "C" double __pow_finite(double x, double y) +{ + return pow(x, y); +} + +extern "C" double __log_finite(double f) +{ + return log(f); +} + +#endif diff --git a/tier1/strtools.cpp b/tier1/strtools.cpp index 2c5f72fa..97704f91 100644 --- a/tier1/strtools.cpp +++ b/tier1/strtools.cpp @@ -1411,7 +1411,7 @@ int _V_UCS2ToUnicode( const ucs2 *pUCS2, wchar_t *pUnicode, int cubDestSizeInByt size_t nMaxUTF8 = cubDestSizeInBytes; char *pIn = (char *)pUCS2; char *pOut = (char *)pUnicode; - if ( conv_t > 0 ) + if ( reinterpret_cast( conv_t ) > 0 ) { cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 ); iconv_close( conv_t ); @@ -1451,7 +1451,7 @@ int _V_UnicodeToUCS2( const wchar_t *pUnicode, int cubSrcInBytes, char *pUCS2, i size_t nMaxUCS2 = cubDestSizeInBytes; char *pIn = (char*)pUnicode; char *pOut = pUCS2; - if ( conv_t > 0 ) + if ( reinterpret_cast( conv_t ) > 0 ) { cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUCS2 ); iconv_close( conv_t ); @@ -1499,7 +1499,7 @@ int _V_UCS2ToUTF8( const ucs2 *pUCS2, char *pUTF8, int cubDestSizeInBytes ) size_t nMaxUTF8 = cubDestSizeInBytes - 1; char *pIn = (char *)pUCS2; char *pOut = (char *)pUTF8; - if ( conv_t > 0 ) + if ( reinterpret_cast( conv_t ) > 0 ) { const size_t nBytesToWrite = nMaxUTF8; cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 ); @@ -1544,7 +1544,7 @@ int _V_UTF8ToUCS2( const char *pUTF8, int cubSrcInBytes, ucs2 *pUCS2, int cubDes size_t nMaxUTF8 = cubDestSizeInBytes; char *pIn = (char *)pUTF8; char *pOut = (char *)pUCS2; - if ( conv_t > 0 ) + if ( reinterpret_cast( conv_t ) > 0 ) { cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 ); iconv_close( conv_t ); diff --git a/tier1/tier1.vpc b/tier1/tier1.vpc index 6f163a8b..52859ba1 100644 --- a/tier1/tier1.vpc +++ b/tier1/tier1.vpc @@ -5,7 +5,7 @@ //----------------------------------------------------------------------------- $macro SRCDIR ".." - + $include "$SRCDIR\vpc_scripts\source_lib_base.vpc" $Configuration @@ -47,6 +47,7 @@ $Project "tier1" $File "memstack.cpp" $File "NetAdr.cpp" $File "splitstring.cpp" + $File "math_proxy.cpp" [$POSIX] $File "processor_detect.cpp" [$WINDOWS||$X360] { $Configuration @@ -57,7 +58,7 @@ $Project "tier1" } } } - + $File "processor_detect_linux.cpp" [$POSIX] $File "qsort_s.cpp" [$LINUXALL||$PS3] $File "rangecheckedvar.cpp" diff --git a/utils/common/bsplib.cpp b/utils/common/bsplib.cpp index cadf7af5..4bf1c2c2 100644 --- a/utils/common/bsplib.cpp +++ b/utils/common/bsplib.cpp @@ -4564,8 +4564,14 @@ bool RepackBSPCallback_LZMA( CUtlBuffer &inputBuffer, CUtlBuffer &outputBuffer ) unsigned int originalSize = inputBuffer.TellPut() - inputBuffer.TellGet(); unsigned int compressedSize = 0; +#ifdef _WIN32 unsigned char *pCompressedOutput = LZMA_Compress( (unsigned char *)inputBuffer.Base() + inputBuffer.TellGet(), originalSize, &compressedSize ); + originalSize, &compressedSize ); +#else + Warning( "WARNING: Unsupported compression type used.\n" ); + unsigned char *pCompressedOutput = 0; +#endif if ( pCompressedOutput ) { outputBuffer.Put( pCompressedOutput, compressedSize ); diff --git a/utils/common/cmdlib.cpp b/utils/common/cmdlib.cpp index a5f9b747..19b320bc 100644 --- a/utils/common/cmdlib.cpp +++ b/utils/common/cmdlib.cpp @@ -25,6 +25,8 @@ #include "tier0/icommandline.h" #include "KeyValues.h" #include "filesystem_tools.h" +#include +#include "utlvector.h" #if defined( MPI ) @@ -59,7 +61,7 @@ CUtlLinkedList g_ExtraSpewHooks; bool g_bStopOnExit = false; void (*g_ExtraSpewHook)(const char*) = NULL; -#if defined( _WIN32 ) || defined( WIN32 ) +#if defined( _WIN32 ) || defined( WIN32 ) || defined( POSIX ) void CmdLib_FPrintf( FileHandle_t hFile, const char *pFormat, ... ) { @@ -126,7 +128,7 @@ char* CmdLib_FGets( char *pOut, int outSize, FileHandle_t hFile ) return pOut; } -#if !defined( _X360 ) +#ifdef _WIN32 #include #endif @@ -139,7 +141,7 @@ class CExitStopper if ( g_bStopOnExit ) { Warning( "\nPress any key to quit.\n" ); - getch(); + getchar(); } } } g_ExitStopper; @@ -151,7 +153,7 @@ static unsigned short g_BadColor = 0xFFFF; static WORD g_BackgroundFlags = 0xFFFF; static void GetInitialColors( ) { -#if !defined( _X360 ) + #ifdef _WIN32 // Get the old background attributes. CONSOLE_SCREEN_BUFFER_INFO oldInfo; GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &oldInfo ); @@ -173,7 +175,7 @@ static void GetInitialColors( ) WORD SetConsoleTextColor( int red, int green, int blue, int intensity ) { WORD ret = g_LastColor; -#if !defined( _X360 ) + #ifdef _WIN32 g_LastColor = 0; if( red ) g_LastColor |= FOREGROUND_RED; @@ -186,18 +188,31 @@ WORD SetConsoleTextColor( int red, int green, int blue, int intensity ) g_LastColor = g_InitialColor; SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), g_LastColor | g_BackgroundFlags ); + #else + if(red) red = 255; + if(green) green = 255; + if(blue) blue = 255; + printf("\x1B[38;2;%u;%u;%um", red, green, blue); #endif return ret; } void RestoreConsoleTextColor( WORD color ) { -#if !defined( _X360 ) +#ifdef _WIN32 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), color | g_BackgroundFlags ); g_LastColor = color; + #else + printf("\033[39m"); #endif } +#ifdef _POSIX +void OutputDebugString(const char* str) +{ + //printf("%s", str); +} +#endif #if defined( CMDLIB_NODBGLIB ) @@ -214,7 +229,7 @@ void Error( char const *pMsg, ... ) #else -CRITICAL_SECTION g_SpewCS; +CThreadMutex g_SpewMutex; bool g_bSpewCSInitted = false; bool g_bSuppressPrintfOutput = false; @@ -223,14 +238,13 @@ SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) // Hopefully two threads won't call this simultaneously right at the start! if ( !g_bSpewCSInitted ) { - InitializeCriticalSection( &g_SpewCS ); g_bSpewCSInitted = true; } WORD old; SpewRetval_t retVal; - EnterCriticalSection( &g_SpewCS ); + g_SpewMutex.Lock(); { if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG )) { @@ -256,30 +270,6 @@ SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_DEBUGGER; -#ifdef MPI - // VMPI workers don't want to bring up dialogs and suchlike. - // They need to have a special function installed to handle - // the exceptions and write the minidumps. - // Install the function after VMPI_Init with a call: - // SetupToolsMinidumpHandler( VMPI_ExceptionFilter ); - if ( g_bUseMPI && !g_bMPIMaster && !Plat_IsInDebugSession() ) - { - // Generating an exception and letting the - // installed handler handle it - ::RaiseException - ( - 0, // dwExceptionCode - EXCEPTION_NONCONTINUABLE, // dwExceptionFlags - 0, // nNumberOfArguments, - NULL // const ULONG_PTR* lpArguments - ); - - // Never get here (non-continuable exception) - - VMPI_HandleCrash( pMsg, NULL, true ); - exit( 0 ); - } -#endif } else if( type == SPEW_ERROR ) { @@ -315,7 +305,7 @@ SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) RestoreConsoleTextColor( old ); } - LeaveCriticalSection( &g_SpewCS ); + g_SpewMutex.Unlock(); if ( type == SPEW_ERROR ) { @@ -364,7 +354,7 @@ void InstallAllocationFunctions() void SetSpewFunctionLogFile( char const *pFilename ) { Assert( (!g_pLogFile) ); - g_pLogFile = g_pFileSystem->Open( pFilename, "a" ); + g_pLogFile = g_pFileSystem->Open( pFilename, "w" ); Assert( g_pLogFile ); if (!g_pLogFile) @@ -411,7 +401,11 @@ void CmdLib_Cleanup() void CmdLib_Exit( int exitCode ) { + #ifdef _WIN32 TerminateProcess( GetCurrentProcess(), 1 ); + #else + exit(exitCode); +#endif } @@ -1005,3 +999,159 @@ void QCopyFile (char *from, char *to) +CCommandLine::CCommandLine( int argc, char **argv ) +{ + m_argc = argc; + m_argv = argv; +} + +bool CCommandLine::FindInt( const char *_short, const char *_long, int &out ) +{ + size_t longlen = 0; + if ( _long ) + longlen = V_strlen( _long ); + for ( int i = 0; i < m_argc; i++ ) + { + const char *arg = m_argv[i]; + /* Check for short arg */ + if ( V_strcmp( _short, arg ) == 0 ) + { + if ( i == m_argc - 1 ) + return false; + out = V_atoi( m_argv[i + 1] ); + return true; + } + /* Check for long argument */ + if ( _long && V_strncmp( _long, arg, longlen ) == 0 ) + { + /* Use B as an offset to the part after the equals */ + int b = 0; + size_t sb = strlen( arg ); + for ( b = 0; arg[b] && arg[b] != '='; b++ ) + ; + if ( b == sb - 1 ) + return false; // Nothing after the = + out = V_atoi( &arg[b] ); + return true; + } + } + return false; +} + +bool CCommandLine::FindFloat( const char *_short, const char *_long, float &out ) +{ + size_t longlen = 0; + if ( _long ) + longlen = V_strlen( _long ); + for ( int i = 0; i < m_argc; i++ ) + { + const char *arg = m_argv[i]; + /* Check for short arg */ + if ( V_strcmp( _short, arg ) == 0 ) + { + if ( i == m_argc - 1 ) + return false; + out = V_atof( m_argv[i + 1] ); + return true; + } + /* Check for long argument */ + if ( _long && V_strncmp( _long, arg, longlen ) == 0 ) + { + /* Use B as an offset to the part after the equals */ + int b = 0; + size_t sb = strlen( arg ); + for ( b = 0; arg[b] && arg[b] != '='; b++ ) + ; + if ( b == sb - 1 ) + return false; // Nothing after the = + out = V_atof( &arg[b] ); + return true; + } + } + return false; +} + +bool CCommandLine::FindString( const char *_short, const char *_long, CUtlString &out ) +{ + size_t longlen = 0; + if ( _long ) + longlen = V_strlen( _long ); + for ( int i = 0; i < m_argc; i++ ) + { + const char *arg = m_argv[i]; + /* Check for short arg */ + if ( V_strcmp( _short, arg ) == 0 ) + { + if ( i == m_argc - 1 ) + return false; + out = (const char *)m_argv[i + 1]; + return true; + } + /* Check for long argument */ + if ( _long && V_strncmp( _long, arg, longlen ) == 0 ) + { + /* Use B as an offset to the part after the equals */ + int b = 0; + size_t sb = strlen( arg ); + for ( b = 0; arg[b] && arg[b] != '='; b++ ) + ; + if ( b == sb - 1 ) + return false; // Nothing after the = + out = (const char *)&arg[b]; + return true; + } + } + return false; +} + +bool CCommandLine::FindList( const char *_long, CUtlVector &outvec ) +{ + size_t longlen = 0; + if ( _long ) + longlen = V_strlen( _long ); + for ( int i = 0; i < m_argc; i++ ) + { + const char *arg = m_argv[i]; + /* Check for long argument */ + if ( _long && V_strncmp( _long, arg, longlen ) == 0 ) + { + /* Use B as an offset to the part after the equals */ + int b = 0; + size_t sb = strlen( arg ); + for ( b = 0; arg[b] && arg[b] != '='; b++ ) + ; + if ( b == sb - 1 ) + return false; // Nothing after the = + /* Split string based on , and add the the output vector */ + CSplitString split( &arg[b], "," ); + for ( auto s : split ) + { + outvec.AddToTail( s ); + } + return true; + } + } + return false; +} + +bool CCommandLine::HasParam( const char *_short, const char *_long ) +{ + size_t longlen = 0; + if ( _long ) + longlen = V_strlen( _long ); + for ( int i = 0; i < m_argc; i++ ) + { + const char *arg = m_argv[i]; + /* Check for short arg */ + if ( V_strcmp( _short, arg ) == 0 ) + { + return true; + } + /* Check for long argument */ + if ( _long && V_strncmp( _long, arg, longlen ) == 0 ) + { + return true; + } + } + return false; +} \ No newline at end of file diff --git a/utils/common/cmdlib.h b/utils/common/cmdlib.h index 5b5b2c7c..f896708e 100644 --- a/utils/common/cmdlib.h +++ b/utils/common/cmdlib.h @@ -174,5 +174,21 @@ typedef struct int count; } cblock_t; +/* Simple and relatively slow command line parsing class */ +class CCommandLine +{ +private: + int m_argc; + char **m_argv; + +public: + CCommandLine( int argc, char **argv ); + + bool FindInt( const char *_short, const char *_long, int &out ); + bool FindFloat( const char *_short, const char *_long, float &out ); + bool FindString( const char *_shoart, const char *_long, CUtlString &out ); + bool FindList( const char *_long, CUtlVector &outvec ); + bool HasParam( const char *_short, const char *_long ); +}; #endif // CMDLIB_H \ No newline at end of file diff --git a/utils/common/filesystem_tools.cpp b/utils/common/filesystem_tools.cpp index 9401c4ad..315d380a 100644 --- a/utils/common/filesystem_tools.cpp +++ b/utils/common/filesystem_tools.cpp @@ -62,7 +62,7 @@ void FileSystem_SetupStandardDirectories( const char *pFilename, const char *pGa Q_MakeAbsolutePath( qdir, sizeof( qdir ), pFilename, NULL ); Q_StripFilename( qdir ); - Q_strlower( qdir ); + //Q_strlower( qdir ); if ( qdir[0] != 0 ) { Q_AppendSlash( qdir, sizeof( qdir ) ); diff --git a/utils/common/map_shared.h b/utils/common/map_shared.h index 5f2b2b62..dd5f6d00 100644 --- a/utils/common/map_shared.h +++ b/utils/common/map_shared.h @@ -11,7 +11,7 @@ #endif -#include "ChunkFile.h" +#include "chunkfile.h" #include "bsplib.h" #include "cmdlib.h" diff --git a/utils/common/mstristrip.cpp b/utils/common/mstristrip.cpp index ad6ebdc8..813afef5 100644 --- a/utils/common/mstristrip.cpp +++ b/utils/common/mstristrip.cpp @@ -26,6 +26,8 @@ #include #include +#include +#include #ifdef _DEBUG #include #endif diff --git a/utils/common/physdll.cpp b/utils/common/physdll.cpp index 3df4b964..a3bd0c4d 100644 --- a/utils/common/physdll.cpp +++ b/utils/common/physdll.cpp @@ -14,7 +14,7 @@ CreateInterfaceFn GetPhysicsFactory( void ) { if ( !pPhysicsModule ) { - pPhysicsModule = g_pFullFileSystem->LoadModule( "VPHYSICS.DLL" ); + pPhysicsModule = g_pFullFileSystem->LoadModule( "vphysics" DLL_EXT_STRING ); if ( !pPhysicsModule ) return NULL; } diff --git a/utils/common/scriplib.cpp b/utils/common/scriplib.cpp index 1c8b47f8..b3b123a8 100644 --- a/utils/common/scriplib.cpp +++ b/utils/common/scriplib.cpp @@ -16,8 +16,8 @@ #include "xbox\xbox_win32stubs.h" #endif #if defined(POSIX) -#include "../../filesystem/linux_support.h" #include +#include #endif /* ============================================================================= @@ -1213,58 +1213,28 @@ int CScriptLib::GetFileList( const char* pDirPath, const char* pPattern, CUtlVec _findclose( h ); #elif defined(POSIX) - FIND_DATA findData; + /* Open the specified dir */ Q_FixSlashes( fullPath ); - void *h = FindFirstFile( fullPath, &findData ); - if ( (int)h == -1 ) - { - return 0; - } + DIR *dirent = opendir( fullPath ); + struct dirent *fileent; - do - { - // dos attribute complexities i.e. _A_NORMAL is 0 - if ( bFindDirs ) - { - // skip non dirs - if ( !( findData.dwFileAttributes & S_IFDIR ) ) - continue; - } - else - { - // skip dirs - if ( findData.dwFileAttributes & S_IFDIR ) - continue; - } + if(!dirent) return 0; - if ( !stricmp( findData.cFileName, "." ) ) + /* Loop thru the directory */ + while((fileent = readdir(dirent))) + { + struct stat statbuf; + if ( !stat( fileent->d_name, &statbuf ) ) continue; - - if ( !stricmp( findData.cFileName, ".." ) ) + if ( !S_ISREG( statbuf.st_mode ) ) continue; - char fileName[MAX_PATH]; - strcpy( fileName, sourcePath ); - strcat( fileName, findData.cFileName ); - - int j = fileList.AddToTail(); - fileList[j].fileName.Set( fileName ); - struct stat statbuf; - if ( stat( fileName, &statbuf ) ) -#ifdef OSX - fileList[j].timeWrite = statbuf.st_mtimespec.tv_sec; -#else - fileList[j].timeWrite = statbuf.st_mtime; -#endif - else - fileList[j].timeWrite = 0; +fileList_t flist; + flist.fileName.Set( fileent->d_name ); + flist.timeWrite = statbuf.st_mtime; + fileList.AddToTail( flist ); } - while ( !FindNextFile( h, &findData ) ); - - FindClose( h ); - -#else -#error + closedir( dirent ); #endif diff --git a/utils/common/threads.cpp b/utils/common/threads.cpp index 74e457a9..b2e864c7 100644 --- a/utils/common/threads.cpp +++ b/utils/common/threads.cpp @@ -13,12 +13,18 @@ #define USED -#include + #include "cmdlib.h" #define NO_THREAD_NAMES #include "threads.h" #include "pacifier.h" +#ifdef _WIN32 + #include +#else + #include +#endif + #define MAX_THREADS 16 @@ -107,16 +113,16 @@ WIN32 */ int numthreads = -1; -CRITICAL_SECTION crit; +CThreadMutex mutex; +//CRITICAL_SECTION crit; static int enter; - class CCritInit { public: CCritInit() { - InitializeCriticalSection (&crit); + //InitializeCriticalSection (&crit); } } g_CritInit; @@ -124,12 +130,16 @@ class CCritInit void SetLowPriority() { +#ifdef _WIN32 SetPriorityClass( GetCurrentProcess(), IDLE_PRIORITY_CLASS ); +#endif + /* NOT IMPLEMENTED FOR POSIX */ } void ThreadSetDefault (void) { +#ifdef _WIN32 SYSTEM_INFO info; if (numthreads == -1) // not set manually @@ -141,6 +151,9 @@ void ThreadSetDefault (void) } Msg ("%i threads\n", numthreads); +#else + numthreads = 8; /* Not porting the above shit yet, sorry */ +#endif } @@ -148,7 +161,7 @@ void ThreadLock (void) { if (!threaded) return; - EnterCriticalSection (&crit); + mutex.Lock(); if (enter) Error ("Recursive ThreadLock\n"); enter = 1; @@ -161,12 +174,16 @@ void ThreadUnlock (void) if (!enter) Error ("ThreadUnlock without lock\n"); enter = 0; - LeaveCriticalSection (&crit); + mutex.Unlock(); } // This runs in the thread and dispatches a RunThreadsFn call. +#ifdef _WIN32 DWORD WINAPI InternalRunThreadsFn( LPVOID pParameter ) +#else +void *InternalRunThreadsFn( void *pParameter ) +#endif { CRunThreadsData *pData = (CRunThreadsData*)pParameter; pData->m_Fn( pData->m_iThread, pData->m_pUserData ); @@ -174,6 +191,7 @@ DWORD WINAPI InternalRunThreadsFn( LPVOID pParameter ) } + void RunThreads_Start( RunThreadsFn fn, void *pUserData, ERunThreadsPriority ePriority ) { Assert( numthreads > 0 ); @@ -188,6 +206,7 @@ void RunThreads_Start( RunThreadsFn fn, void *pUserData, ERunThreadsPriority ePr g_RunThreadsData[i].m_pUserData = pUserData; g_RunThreadsData[i].m_Fn = fn; + #ifdef _WIN32 DWORD dwDummy; g_ThreadHandles[i] = CreateThread( NULL, // LPSECURITY_ATTRIBUTES lpsa, @@ -206,15 +225,29 @@ void RunThreads_Start( RunThreadsFn fn, void *pUserData, ERunThreadsPriority ePr { SetThreadPriority( g_ThreadHandles[i], THREAD_PRIORITY_IDLE ); } +#else + g_ThreadHandles[i] = malloc( sizeof( pthread_t ) ); + pthread_create( (pthread_t *)g_ThreadHandles[i], nullptr, InternalRunThreadsFn, &g_RunThreadsData[i] ); +#endif } } void RunThreads_End() { +#ifdef _WIN32 WaitForMultipleObjects( numthreads, g_ThreadHandles, TRUE, INFINITE ); +#endif for ( int i=0; i < numthreads; i++ ) + { +#ifdef _WIN32 CloseHandle( g_ThreadHandles[i] ); +#else + pthread_join( *(pthread_t *)g_ThreadHandles[i], NULL ); + //pthread_kill(*(pthread_t*)g_ThreadHandles[i], SIGTERM); + free( g_ThreadHandles[i] ); +#endif + } threaded = false; } diff --git a/utils/common/tools_minidump.cpp b/utils/common/tools_minidump.cpp index a7659200..7c27d168 100644 --- a/utils/common/tools_minidump.cpp +++ b/utils/common/tools_minidump.cpp @@ -5,8 +5,10 @@ // $NoKeywords: $ //=============================================================================// +#ifdef _WIN32 #include #include +#endif #include "tier0/minidump.h" #include "tools_minidump.h" @@ -18,8 +20,9 @@ static ToolsExceptionHandler g_pCustomExceptionHandler = NULL; // Internal helpers. // --------------------------------------------------------------------------------- // -static LONG __stdcall ToolsExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo ) +static long __stdcall ToolsExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo ) { +#ifdef _WIN32 // Non VMPI workers write a minidump and show a crash dialog like normal. int iType = MiniDumpNormal; if ( g_bToolsWriteFullMinidumps ) @@ -27,14 +30,21 @@ static LONG __stdcall ToolsExceptionFilter( struct _EXCEPTION_POINTERS *Exceptio WriteMiniDumpUsingExceptionInfo( ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo, (MINIDUMP_TYPE)iType ); return EXCEPTION_CONTINUE_SEARCH; +#else + return 0; +#endif } -static LONG __stdcall ToolsExceptionFilter_Custom( struct _EXCEPTION_POINTERS *ExceptionInfo ) +static long __stdcall ToolsExceptionFilter_Custom( struct _EXCEPTION_POINTERS *ExceptionInfo ) { +#ifdef _WIN32 // Run their custom handler. g_pCustomExceptionHandler( ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo ); return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway) +#else + return 0; +#endif } @@ -50,12 +60,16 @@ void EnableFullMinidumps( bool bFull ) void SetupDefaultToolsMinidumpHandler() { +#ifdef _WIN32 SetUnhandledExceptionFilter( ToolsExceptionFilter ); +#endif } void SetupToolsMinidumpHandler( ToolsExceptionHandler fn ) { g_pCustomExceptionHandler = fn; +#ifdef _WIN32 SetUnhandledExceptionFilter( ToolsExceptionFilter_Custom ); +#endif } diff --git a/utils/common/utilmatlib.cpp b/utils/common/utilmatlib.cpp index 7e62e000..08a2d682 100644 --- a/utils/common/utilmatlib.cpp +++ b/utils/common/utilmatlib.cpp @@ -15,18 +15,218 @@ #include #include "utilmatlib.h" #include "tier0/dbg.h" -#include +//#include #include "filesystem.h" #include "materialsystem/materialsystem_config.h" -#include "mathlib/Mathlib.h" +#include "mathlib/mathlib.h" + +#ifdef _POSIX + + #include + +static CreateInterfaceFn g_fileSystemFactory; + +class FakeLauncherMgr : public ILauncherMgr +{ +public: + virtual bool Connect( CreateInterfaceFn factory ) + { + return true; + } + + virtual void Disconnect() + { + } + + virtual void *QueryInterface( const char *pInterfaceName ) + { + return NULL; + } + + virtual InitReturnVal_t Init() + { + return (InitReturnVal_t)0; + } + + virtual void Shutdown() + { + } + + virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) + { + return true; + } + + virtual void IncWindowRefCount() + { + } + + virtual void DecWindowRefCount() + { + } + + virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) + { + return 0; + } + + #ifdef LINUX + virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) + { + return 0; + } + #endif + + virtual void SetCursorPosition( int x, int y ) + { + } + + virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) + { + } + + virtual bool IsWindowFullScreen() + { + return true; + } + + virtual void MoveWindow( int x, int y ) + { + } + + virtual void SizeWindow( int width, int tall ) + { + } + + virtual void PumpWindowsMessageLoop() + { + } + + virtual void DestroyGameWindow() + { + } + virtual void SetApplicationIcon( const char *pchAppIconFile ) + { + } + + virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) + { + } + + virtual void GetNativeDisplayInfo( int nDisplay, uint &nWidth, uint &nHeight, uint &nRefreshHz ) + { + } + + virtual void RenderedSize( uint &width, uint &height, bool set ) + { + } + + virtual void DisplayedSize( uint &width, uint &height ) + { + } + + #if defined( DX_TO_GL_ABSTRACTION ) + virtual PseudoGLContextPtr GetMainContext() + { + return NULL; + } + + virtual PseudoGLContextPtr GetGLContextForWindow( void *windowref ) + { + return NULL; + } + + virtual PseudoGLContextPtr CreateExtraContext() + { + return NULL; + } + + virtual void DeleteContext( PseudoGLContextPtr hContext ) + { + } + + virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) + { + return true; + } + + virtual GLMDisplayDB *GetDisplayDB( void ) + { + return NULL; + } + + virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) + { + } + + virtual void ShowPixels( CShowPixelsParams *params ) + { + } + #endif + + virtual void GetStackCrawl( CStackCrawlParams *params ) + { + } + + virtual void WaitUntilUserInput( int msSleepTime ) + { + } + + virtual void *GetWindowRef() + { + return NULL; + } + + virtual void SetMouseVisible( bool bState ) + { + } + + virtual void SetMouseCursor( SDL_Cursor *hCursor ) + { + } + + virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) + { + } + + virtual void OnFrameRendered() + { + } + + virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) + { + } + + virtual double GetPrevGLSwapWindowTime() + { + return 0.0; + } + +} g_FakeLauncherMgr; + +void *SDLMgrFactoryRedirector( const char *pName, int *pReturnCode ) +{ + return !strcmp( "SDLMgrInterface001", pName ) ? &g_FakeLauncherMgr : g_fileSystemFactory( pName, pReturnCode ); +} + +#endif void LoadMaterialSystemInterface( CreateInterfaceFn fileSystemFactory ) { if( g_pMaterialSystem ) return; + + #ifdef _POSIX + g_fileSystemFactory = fileSystemFactory; + fileSystemFactory = SDLMgrFactoryRedirector; +#endif // materialsystem.dll should be in the path, it's in bin along with vbsp. +#ifdef _WIN32 const char *pDllName = "materialsystem.dll"; +#else + const char *pDllName = "materialsystem.so"; +#endif CSysModule *materialSystemDLLHInst; materialSystemDLLHInst = g_pFullFileSystem->LoadModule( pDllName ); if( !materialSystemDLLHInst ) @@ -48,9 +248,15 @@ void LoadMaterialSystemInterface( CreateInterfaceFn fileSystemFactory ) Error( "Could not find factory interface in library MaterialSystem.dll" ); } - if (!g_pMaterialSystem->Init( "shaderapiempty.dll", 0, fileSystemFactory )) + #ifdef _WIN32 + const char *pShaderAPIEmptyName = "shaderapiempty.dll"; +#else + const char *pShaderAPIEmptyName = "shaderapiempty.so"; +#endif + + if ( !g_pMaterialSystem->Init( pShaderAPIEmptyName, nullptr, fileSystemFactory ) ) { - Error( "Could not start the empty shader (shaderapiempty.dll)!" ); + Error( "Could not start the empty shader (%s)!", pShaderAPIEmptyName ); } } diff --git a/utils/vbsp/boundbox.cpp b/utils/vbsp/boundbox.cpp index a62e9e2f..3bb5e2b7 100644 --- a/utils/vbsp/boundbox.cpp +++ b/utils/vbsp/boundbox.cpp @@ -6,7 +6,7 @@ //=============================================================================// #include "vbsp.h" -#include "BoundBox.h" +#include "boundbox.h" //#include "hammer_mathlib.h" //#include "MapDefs.h" diff --git a/utils/vbsp/cubemap.cpp b/utils/vbsp/cubemap.cpp index 3c2fe1ea..04b8a687 100644 --- a/utils/vbsp/cubemap.cpp +++ b/utils/vbsp/cubemap.cpp @@ -7,7 +7,7 @@ #include "vbsp.h" #include "bsplib.h" -#include "tier1/UtlBuffer.h" +#include "tier1/utlbuffer.h" #include "tier1/utlvector.h" #include "bitmap/imageformat.h" #include diff --git a/utils/vbsp/detailobjects.cpp b/utils/vbsp/detailobjects.cpp index e7475d94..0c5747f3 100644 --- a/utils/vbsp/detailobjects.cpp +++ b/utils/vbsp/detailobjects.cpp @@ -6,7 +6,11 @@ // $NoKeywords: $ //=============================================================================// +#ifdef _WIN32 #include +#include +#endif + #include "vbsp.h" #include "bsplib.h" #include "KeyValues.h" @@ -16,16 +20,16 @@ #include "bspfile.h" #include "utilmatlib.h" #include "gamebspfile.h" -#include "mathlib/VMatrix.h" +#include "mathlib/vmatrix.h" #include "materialpatch.h" #include "pacifier.h" #include "vstdlib/random.h" #include "builddisp.h" #include "disp_vbsp.h" -#include "UtlBuffer.h" -#include "CollisionUtils.h" +#include "utlbuffer.h" +#include "collisionutils.h" #include -#include "UtlLinkedList.h" +#include "utllinkedlist.h" #include "byteswap.h" #include "writebsp.h" diff --git a/utils/vbsp/disp_ivp.cpp b/utils/vbsp/disp_ivp.cpp index 1ed16518..54ecda66 100644 --- a/utils/vbsp/disp_ivp.cpp +++ b/utils/vbsp/disp_ivp.cpp @@ -240,7 +240,7 @@ void CDispMeshEvent::GetVirtualMesh( void *userData, virtualmeshlist_t *pList ) pList->surfacePropsIndex = 0; // doesn't matter here, reset at runtime pList->pHull = NULL; int indexMax = ARRAYSIZE(pList->indices); - int indexCount = min(m_indexCount, indexMax); + int indexCount = std::min( m_indexCount, indexMax ); Assert(m_indexCount < indexMax); Q_memcpy( pList->indices, m_pIndices, sizeof(*m_pIndices) * indexCount ); } @@ -260,7 +260,7 @@ void CDispMeshEvent::GetTrianglesInSphere( void *userData, const Vector ¢er, Assert(userData==((void *)this)); pList->triangleCount = m_indexCount/3; int indexMax = ARRAYSIZE(pList->triangleIndices); - int indexCount = min(m_indexCount, indexMax); + int indexCount = std::min( m_indexCount, indexMax ); Assert(m_indexCount < MAX_VIRTUAL_TRIANGLES*3); Q_memcpy( pList->triangleIndices, m_pIndices, sizeof(*m_pIndices) * indexCount ); } diff --git a/utils/vbsp/ivp.cpp b/utils/vbsp/ivp.cpp index 3c234c2f..2fab8396 100644 --- a/utils/vbsp/ivp.cpp +++ b/utils/vbsp/ivp.cpp @@ -16,7 +16,7 @@ #include "phyfile.h" #include #include "KeyValues.h" -#include "UtlBuffer.h" +#include "utlbuffer.h" #include "utlsymbol.h" #include "utlrbtree.h" #include "ivp.h" @@ -1054,7 +1054,7 @@ static void Flood_FindConnectedWaterVolumes_r( CUtlVector &list, node_ visited.Set( pLeaf->diskId ); list.AddToTail( pLeaf ); - baseleaf.minZ = min( pLeaf->mins.z, baseleaf.minZ ); + baseleaf.minZ = std::min( pLeaf->mins.z, baseleaf.minZ ); for (portal_t *p = pLeaf->portals ; p ; p = p->next[!oppositeNodeIndex]) { diff --git a/utils/vbsp/leakfile.cpp b/utils/vbsp/leakfile.cpp index d6038830..ed37d64b 100644 --- a/utils/vbsp/leakfile.cpp +++ b/utils/vbsp/leakfile.cpp @@ -7,7 +7,7 @@ //=============================================================================// #include "vbsp.h" -#include "color.h" +#include "Color.h" /* ============================================================================== diff --git a/utils/vbsp/manifest.cpp b/utils/vbsp/manifest.cpp index c72a9564..c46272a2 100644 --- a/utils/vbsp/manifest.cpp +++ b/utils/vbsp/manifest.cpp @@ -3,7 +3,9 @@ #include "map_shared.h" #include "fgdlib/fgdlib.h" #include "manifest.h" -#include "windows.h" +#ifdef _WIN32 + #include "windows.h" +#endif //----------------------------------------------------------------------------- // Purpose: default constructor @@ -359,10 +361,13 @@ bool CManifest::LoadVMFManifestUserPrefs( const char *pszFileName ) DWORD UserNameSize; UserNameSize = sizeof( UserName ); + // TODO: What does this do? +#ifdef _WIN32 if ( GetUserName( UserName, &UserNameSize ) == 0 ) { strcpy( UserPrefsFileName, "default" ); } +#endif sprintf( UserPrefsFileName, "\\%s.vmm_prefs", UserName ); V_StripExtension( pszFileName, FileName, sizeof( FileName ) ); diff --git a/utils/vbsp/map.cpp b/utils/vbsp/map.cpp index d80ab771..71e86fb1 100644 --- a/utils/vbsp/map.cpp +++ b/utils/vbsp/map.cpp @@ -15,6 +15,8 @@ #include "materialsub.h" #include "fgdlib/fgdlib.h" #include "manifest.h" +#include +#include #ifdef VSVMFIO #include "VmfImport.h" @@ -1271,7 +1273,7 @@ void ConvertSideList( entity_t *mapent, char *key ) } char szIndex[15]; - itoa( nIndex, szIndex, 10 ); + snprintf( szIndex, sizeof( szIndex ), "%i", szIndex ); strcat( szNewValue, szIndex ); } } diff --git a/utils/vbsp/materialpatch.cpp b/utils/vbsp/materialpatch.cpp index 96a30edb..146f3922 100644 --- a/utils/vbsp/materialpatch.cpp +++ b/utils/vbsp/materialpatch.cpp @@ -6,7 +6,7 @@ // //=============================================================================// #include "vbsp.h" -#include "UtlBuffer.h" +#include "utlbuffer.h" #include "utlsymbol.h" #include "utlrbtree.h" #include "KeyValues.h" diff --git a/utils/vbsp/staticprop.cpp b/utils/vbsp/staticprop.cpp index 48f6279e..c8e8016d 100644 --- a/utils/vbsp/staticprop.cpp +++ b/utils/vbsp/staticprop.cpp @@ -11,18 +11,23 @@ #include "utlvector.h" #include "bspfile.h" #include "gamebspfile.h" -#include "VPhysics_Interface.h" -#include "Studio.h" +#include "vphysics_interface.h" #include "byteswap.h" -#include "UtlBuffer.h" -#include "CollisionUtils.h" +#include "utlbuffer.h" +#include "collisionutils.h" #include -#include "CModel.h" -#include "PhysDll.h" +#include "cmodel.h" +#include "physdll.h" #include "utlsymbol.h" #include "tier1/strtools.h" #include "KeyValues.h" +/* This right here is a terrible fix, but it works. I don't want to nuke compat with Windurs */ +#undef MINMAX_H +#include + +#include "studio.h" + static void SetCurrentModel( studiohdr_t *pStudioHdr ); static void FreeCurrentModelVertexes(); @@ -247,7 +252,7 @@ static CPhysCollide* GetCollisionModel( char const* pModelName ) // Convert to a common string char* pTemp = (char*)_alloca(strlen(pModelName) + 1); strcpy( pTemp, pModelName ); - _strlwr( pTemp ); + strlwr( pTemp ); char* pSlash = strchr( pTemp, '\\' ); while( pSlash ) diff --git a/utils/vbsp/vbsp.cpp b/utils/vbsp/vbsp.cpp index 49408915..30557188 100644 --- a/utils/vbsp/vbsp.cpp +++ b/utils/vbsp/vbsp.cpp @@ -891,7 +891,8 @@ int RunVBSP( int argc, char **argv ) char path[1024]; CommandLine()->CreateCmdLine( argc, argv ); - MathLib_Init( 2.2f, 2.2f, 0.0f, OVERBRIGHT, false, false, false, false ); + MathLib_Init( 2.2f, 2.2f, 0.0f, OVERBRIGHT, false, true, true, false ); + FileSystem_Init( nullptr, 0, FSInitType_t::FS_INIT_COMPATIBILITY_MODE ); InstallSpewFunction(); SpewActivate( "developer", 1 ); diff --git a/utils/vbsp/vbsp.h b/utils/vbsp/vbsp.h index df3144ac..f71b084c 100644 --- a/utils/vbsp/vbsp.h +++ b/utils/vbsp/vbsp.h @@ -18,7 +18,7 @@ #include "bsplib.h" #include "qfiles.h" #include "utilmatlib.h" -#include "ChunkFile.h" +#include "chunkfile.h" #ifdef WIN32 #pragma warning( disable: 4706 ) diff --git a/utils/vbsp/vbsp.vpc b/utils/vbsp/vbsp.vpc index e55762f2..a2d18a46 100644 --- a/utils/vbsp/vbsp.vpc +++ b/utils/vbsp/vbsp.vpc @@ -15,11 +15,13 @@ $Configuration { $AdditionalIncludeDirectories "$BASE,..\common,..\vmpi" $PreprocessorDefinitions "$BASE;MACRO_MATHLIB;PROTECTED_THINGS_DISABLE" + $PreprocessorDefinitions "$BASE;USE_SDL" [$POSIX] } $Linker { - $AdditionalDependencies "$BASE ws2_32.lib odbc32.lib odbccp32.lib winmm.lib" + $AdditionalDependencies "$BASE ws2_32.lib odbc32.lib odbccp32.lib winmm.lib" [$WINDOWS] + $SystemLibraries "lzma" [$POSIX] } } @@ -178,7 +180,10 @@ $Project "Vbsp" $Lib mathlib $Lib tier2 $Lib vtf - $Lib "$LIBCOMMON/lzma" + $Lib tier1 + $ImpLib tier0 + $ImpLib vstdlib + $Lib "$LIBCOMMON/lzma" [$WINDOWS] } $File "notes.txt" diff --git a/utils/vbsp/worldvertextransitionfixup.cpp b/utils/vbsp/worldvertextransitionfixup.cpp index f97f3933..86d52871 100644 --- a/utils/vbsp/worldvertextransitionfixup.cpp +++ b/utils/vbsp/worldvertextransitionfixup.cpp @@ -6,7 +6,7 @@ #include "bsplib.h" #include "vbsp.h" -#include "tier1/UtlBuffer.h" +#include "tier1/utlbuffer.h" #include "tier1/utlvector.h" #include "KeyValues.h" #include "materialpatch.h" diff --git a/utils/vrad/disp_vrad.cpp b/utils/vrad/disp_vrad.cpp index b1d63b6e..5142f0f4 100644 --- a/utils/vrad/disp_vrad.cpp +++ b/utils/vrad/disp_vrad.cpp @@ -9,7 +9,7 @@ #include "utllinkedlist.h" #include "utlvector.h" #include "iscratchpad3d.h" -#include "scratchpadutils.h" +#include "ScratchPadUtils.h" //#define USE_SCRATCHPAD diff --git a/utils/vrad/incremental.cpp b/utils/vrad/incremental.cpp index ad46d04d..09cf0b7c 100644 --- a/utils/vrad/incremental.cpp +++ b/utils/vrad/incremental.cpp @@ -311,9 +311,9 @@ void CIncremental::AddLightToFace( { bool bNew; - EnterCriticalSection( &pLight->m_CS ); + pLight->m_Mutex.Lock(); pFace = pLight->FindOrCreateLightFace( iFace, lmSize, &bNew ); - LeaveCriticalSection( &pLight->m_CS ); + pLight->m_Mutex.Unlock(); pLight->m_pCachedFaces[iThread] = pFace; @@ -460,10 +460,10 @@ void CIncremental::FinishFace( if( pFace->m_CompressedData.TellPut() == 0 ) { // No contribution.. delete this face from the light. - EnterCriticalSection( &pLight->m_CS ); + pLight->m_Mutex.Lock(); pLight->m_LightFaces.Remove( pFace->m_LightFacesIndex ); delete pFace; - LeaveCriticalSection( &pLight->m_CS ); + pLight->m_Mutex.Unlock(); } else { @@ -719,14 +719,12 @@ void CIncremental::LinkLightsToFaces( CUtlVector &faceLights ) CIncLight::CIncLight() { memset( m_pCachedFaces, 0, sizeof(m_pCachedFaces) ); - InitializeCriticalSection( &m_CS ); } CIncLight::~CIncLight() { m_LightFaces.PurgeAndDeleteElements(); - DeleteCriticalSection( &m_CS ); } diff --git a/utils/vrad/incremental.h b/utils/vrad/incremental.h index 9e98054b..491d568d 100644 --- a/utils/vrad/incremental.h +++ b/utils/vrad/incremental.h @@ -59,7 +59,8 @@ class CIncLight public: - CRITICAL_SECTION m_CS; + //CRITICAL_SECTION m_CS; + CThreadMutex m_Mutex; // This is the light for which m_LightFaces was built. dworldlight_t m_Light; diff --git a/utils/vrad/leaf_ambient_lighting.cpp b/utils/vrad/leaf_ambient_lighting.cpp index 3836592e..204e3140 100644 --- a/utils/vrad/leaf_ambient_lighting.cpp +++ b/utils/vrad/leaf_ambient_lighting.cpp @@ -584,38 +584,6 @@ static void ThreadComputeLeafAmbient( int iThread, void *pUserData ) } } -void VMPI_ProcessLeafAmbient( int iThread, uint64 iLeaf, MessageBuffer *pBuf ) -{ - CUtlVector list; - ComputeAmbientForLeaf(iThread, (int)iLeaf, list); - - VMPI_SetCurrentStage( "EncodeLeafAmbientResults" ); - - // Encode the results. - int nSamples = list.Count(); - pBuf->write( &nSamples, sizeof( nSamples ) ); - if ( nSamples ) - { - pBuf->write( list.Base(), list.Count() * sizeof( ambientsample_t ) ); - } -} - -//----------------------------------------------------------------------------- -// Called on the master when a worker finishes processing a static prop. -//----------------------------------------------------------------------------- -void VMPI_ReceiveLeafAmbientResults( uint64 leafID, MessageBuffer *pBuf, int iWorker ) -{ - // Decode the results. - int nSamples; - pBuf->read( &nSamples, sizeof( nSamples ) ); - - g_LeafAmbientSamples[leafID].SetCount( nSamples ); - if ( nSamples ) - { - pBuf->read(g_LeafAmbientSamples[leafID].Base(), nSamples * sizeof(ambientsample_t) ); - } -} - void ComputePerLeafAmbientLighting() { @@ -642,17 +610,8 @@ void ComputePerLeafAmbientLighting() g_LeafAmbientSamples.SetCount(numleafs); - if ( g_bUseMPI ) - { - // Distribute the work among the workers. - VMPI_SetCurrentStage( "ComputeLeafAmbientLighting" ); - DistributeWork( numleafs, VMPI_DISTRIBUTEWORK_PACKETID, VMPI_ProcessLeafAmbient, VMPI_ReceiveLeafAmbientResults ); - } - else - { - RunThreadsOn(numleafs, true, ThreadComputeLeafAmbient); - } - + RunThreadsOn( numleafs, true, ThreadComputeLeafAmbient ); + // now write out the data Msg("Writing leaf ambient..."); g_pLeafAmbientIndex->RemoveAll(); diff --git a/utils/vrad/lightmap.cpp b/utils/vrad/lightmap.cpp index dfe1c180..d301b93c 100644 --- a/utils/vrad/lightmap.cpp +++ b/utils/vrad/lightmap.cpp @@ -2657,8 +2657,12 @@ static void GatherSampleLightAt4Points( SSE_SampleInfo_t& info, int sampleIdx, i { if (info.m_WarnFace != info.m_FaceNum) { + //Warning ("\nWARNING: Too many light styles on a face at (%f, %f, %f)\n", + // info.m_Points.x.m128_f32[0], info.m_Points.y.m128_f32[0], info.m_Points.z.m128_f32[0] ); Warning ("\nWARNING: Too many light styles on a face at (%f, %f, %f)\n", info.m_Points.x.m128_f32[0], info.m_Points.y.m128_f32[0], info.m_Points.z.m128_f32[0] ); + FLTX4_ELEMENT(info.m_Points.x, 0), FLTX4_ELEMENT(info.m_Points.y, 0), FLTX4_ELEMENT(info.m_Points.z, 0) ); + info.m_WarnFace = info.m_FaceNum; } continue; @@ -3413,13 +3417,7 @@ void BuildFacelights (int iThread, int facenum) return; } - if (!g_bUseMPI) - { - // - // This is done on the master node when MPI is used - // - BuildPatchLights( facenum ); - } + BuildPatchLights( facenum ); if( g_bDumpPatches ) { diff --git a/utils/vrad/mpivrad.cpp b/utils/vrad/mpivrad.cpp index 5b7bfc03..25e2e9ab 100644 --- a/utils/vrad/mpivrad.cpp +++ b/utils/vrad/mpivrad.cpp @@ -9,8 +9,11 @@ // mpivrad.cpp // +#ifdef _WIN32 #include #include +#endif + #include "vrad.h" #include "physdll.h" #include "lightmap.h" diff --git a/utils/vrad/radial.cpp b/utils/vrad/radial.cpp index 5dc99b50..c881e4b1 100644 --- a/utils/vrad/radial.cpp +++ b/utils/vrad/radial.cpp @@ -11,7 +11,7 @@ #include "radial.h" #include "mathlib/bumpvects.h" #include "utlrbtree.h" -#include "mathlib/VMatrix.h" +#include "mathlib/vmatrix.h" #include "macro_texture.h" diff --git a/utils/vrad/trace.cpp b/utils/vrad/trace.cpp index e0926e29..bc200dda 100644 --- a/utils/vrad/trace.cpp +++ b/utils/vrad/trace.cpp @@ -11,7 +11,7 @@ #include "vrad.h" #include "trace.h" -#include "Cmodel.h" +#include "cmodel.h" #include "mathlib/vmatrix.h" @@ -133,7 +133,8 @@ class CCoverageCountTexture : public CCoverageCount addedCoverage[s] = 0.0f; if ( ( sign >> s) & 0x1 ) { - addedCoverage[s] = ComputeCoverageFromTexture( b0->m128_f32[s], b1->m128_f32[s], b2->m128_f32[s], hitID ); + //addedCoverage[s] = ComputeCoverageFromTexture( b0->m128_f32[s], b1->m128_f32[s], b2->m128_f32[s], hitID ); // OLD + addedCoverage[s] = ComputeCoverageFromTexture( FLTX4_ELEMENT( *b0, s ), FLTX4_ELEMENT( *b1, s ), FLTX4_ELEMENT( *b2, s ), hitID ); } } m_coverage = AddSIMD( m_coverage, LoadUnalignedSIMD( addedCoverage ) ); @@ -169,7 +170,8 @@ void TestLine( const FourVectors& start, const FourVectors& stop, { visibility[i] = 1.0f; if ( ( rt_result.HitIds[i] != -1 ) && - ( rt_result.HitDistance.m128_f32[i] < len.m128_f32[i] ) ) + //( rt_result.HitDistance.m128_f32[i] < len.m128_f32[i] ) ) + (FLTX4_ELEMENT(rt_result.HitDistance, i) < FLTX4_ELEMENT(len, i))) { visibility[i] = 0.0f; } @@ -373,7 +375,8 @@ void TestLine_DoesHitSky( FourVectors const& start, FourVectors const& stop, { aOcclusion[i] = 0.0f; if ( ( rt_result.HitIds[i] != -1 ) && - ( rt_result.HitDistance.m128_f32[i] < len.m128_f32[i] ) ) + // ( rt_result.HitDistance.m128_f32[i] < len.m128_f32[i] ) ) + (FLTX4_ELEMENT(rt_result.HitDistance, i) < FLTX4_ELEMENT(len, i))) { int id = g_RtEnv.OptimizedTriangleList[rt_result.HitIds[i]].m_Data.m_IntersectData.m_nTriangleID; if ( !( id & TRACE_ID_SKY ) ) diff --git a/utils/vrad/vismat.cpp b/utils/vrad/vismat.cpp index ca9398ec..b630ce7a 100644 --- a/utils/vrad/vismat.cpp +++ b/utils/vrad/vismat.cpp @@ -467,14 +467,7 @@ BuildVisMatrix */ void BuildVisMatrix (void) { - if ( g_bUseMPI ) - { - RunMPIBuildVisLeafs(); - } - else - { - RunThreadsOn (dvis->numclusters, true, BuildVisLeafs); - } + RunThreadsOn (dvis->numclusters, true, BuildVisLeafs); } void FreeVisMatrix (void) diff --git a/utils/vrad/vrad.cpp b/utils/vrad/vrad.cpp index ef5a77fd..12ac16b9 100644 --- a/utils/vrad/vrad.cpp +++ b/utils/vrad/vrad.cpp @@ -2023,16 +2023,7 @@ bool RadWorld_Go() BuildFacesVisibleToLights( true ); } - // build initial facelights - if (g_bUseMPI) - { - // RunThreadsOnIndividual (numfaces, true, BuildFacelights); - RunMPIBuildFacelights(); - } - else - { - RunThreadsOnIndividual (numfaces, true, BuildFacelights); - } + RunThreadsOnIndividual (numfaces, true, BuildFacelights); // Was the process interrupted? if( g_pIncremental && (g_iCurFace != numfaces) ) @@ -2084,12 +2075,7 @@ bool RadWorld_Go() StaticDispMgr()->EndTimer(); // blend bounced light into direct light and save - VMPI_SetCurrentStage( "FinalLightFace" ); - if ( !g_bUseMPI || g_bMPIMaster ) - RunThreadsOnIndividual (numfaces, true, FinalLightFace); - - // Distribute the lighting data to workers. - VMPI_DistributeLightData(); + RunThreadsOnIndividual( numfaces, true, FinalLightFace ); Msg("FinalLightFace Done\n"); fflush(stdout); } @@ -2137,6 +2123,7 @@ void VRAD_LoadBSP( char const *pFilename ) SetLowPriority(); } + strcpy( source, pFilename ); strcpy( level_name, source ); // This must come after InitFileSystem because the file system pointer might change. @@ -2145,15 +2132,12 @@ void VRAD_LoadBSP( char const *pFilename ) // This part is just for VMPI. VMPI's file system needs the basedir in front of all filenames, // so we prepend qdir here. - strcpy( source, ExpandPath( source ) ); + //strcpy( source, ExpandPath( source ) ); - if ( !g_bUseMPI ) - { - // Setup the logfile. - char logFile[512]; - _snprintf( logFile, sizeof(logFile), "%s.log", source ); - SetSpewFunctionLogFile( logFile ); - } + // Setup the logfile. + char logFile[512]; + _snprintf( logFile, sizeof( logFile ), "%s.log", source ); + SetSpewFunctionLogFile( logFile ); LoadPhysicsDLL(); @@ -2164,8 +2148,13 @@ void VRAD_LoadBSP( char const *pFilename ) // Otherwise, try looking in the BIN directory from which we were run from Msg( "Could not find lights.rad in %s.\nTrying VRAD BIN directory instead...\n", global_lights ); +#ifdef _WIN32 GetModuleFileName( NULL, global_lights, sizeof( global_lights ) ); +#else + readlink( "/proc/self/exe", global_lights, sizeof( global_lights ) ); +#endif Q_ExtractFilePath( global_lights, global_lights, sizeof( global_lights ) ); + strcat( global_lights, "lights.rad" ); } @@ -2184,23 +2173,13 @@ void VRAD_LoadBSP( char const *pFilename ) Q_DefaultExtension(incrementfile, ".r0", sizeof(incrementfile)); Q_DefaultExtension(source, ".bsp", sizeof( source )); - Msg( "Loading %s\n", source ); - VMPI_SetCurrentStage( "LoadBSPFile" ); - LoadBSPFile (source); + //strcpy(source, ExpandPath(source)); + Msg( "Loading %s\n", pFilename ); + LoadBSPFile( pFilename ); - // Add this bsp to our search path so embedded resources can be found - if ( g_bUseMPI && g_bMPIMaster ) - { - // MPI Master, MPI workers don't need to do anything - g_pOriginalPassThruFileSystem->AddSearchPath(source, "GAME", PATH_ADD_TO_HEAD); - g_pOriginalPassThruFileSystem->AddSearchPath(source, "MOD", PATH_ADD_TO_HEAD); - } - else if ( !g_bUseMPI ) - { - // Non-MPI - g_pFullFileSystem->AddSearchPath(source, "GAME", PATH_ADD_TO_HEAD); - g_pFullFileSystem->AddSearchPath(source, "MOD", PATH_ADD_TO_HEAD); - } + // Non-MPI + g_pFullFileSystem->AddSearchPath( source, "GAME", PATH_ADD_TO_HEAD ); + g_pFullFileSystem->AddSearchPath( source, "MOD", PATH_ADD_TO_HEAD ); // now, set whether or not static prop lighting is present if (g_bStaticPropLighting) @@ -2327,7 +2306,6 @@ void VRAD_Finish() } Msg( "Writing %s\n", source ); - VMPI_SetCurrentStage( "WriteBSPFile" ); WriteBSPFile(source); if ( g_bDumpPatches ) @@ -2359,7 +2337,8 @@ void VRAD_Finish() // WorldCraft interface into vrad). void VRAD_Init() { - MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, false, false, false ); + FileSystem_Init( nullptr, 0, FSInitType_t::FS_INIT_COMPATIBILITY_MODE ); + MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f, false, true, true, false ); InstallAllocationFunctions(); InstallSpewFunction(); } @@ -2808,7 +2787,7 @@ int ParseCommandLine( int argc, char **argv, bool *onlydetail ) else if ( !Q_strncasecmp( argv[i], "-mpi", 4 ) || !Q_strncasecmp( argv[i-1], "-mpi", 4 ) ) { if ( stricmp( argv[i], "-mpi" ) == 0 ) - g_bUseMPI = true; + Error( "VMPI is not supported with this build\n" ); // Any other args that start with -mpi are ok too. if ( i == argc - 1 && V_stricmp( argv[i], "-mpi_ListParams" ) != 0 ) @@ -2973,7 +2952,6 @@ int RunVRAD( int argc, char **argv ) VRAD_Finish(); - VMPI_SetCurrentStage( "master done" ); DeleteCmdLine( argc, argv ); CmdLib_Cleanup(); @@ -2987,20 +2965,9 @@ int VRAD_Main(int argc, char **argv) VRAD_Init(); - // This must come first. - VRAD_SetupMPI( argc, argv ); + LoadCmdLineFromFile( argc, argv, source, "vrad" ); // Don't do this if we're a VMPI worker.. + SetupDefaultToolsMinidumpHandler(); -#if !defined( _DEBUG ) - if ( g_bUseMPI && !g_bMPIMaster ) - { - SetupToolsMinidumpHandler( VMPI_ExceptionFilter ); - } - else -#endif - { - LoadCmdLineFromFile( argc, argv, source, "vrad" ); // Don't do this if we're a VMPI worker.. - SetupDefaultToolsMinidumpHandler(); - } return RunVRAD( argc, argv ); } diff --git a/utils/vrad/vrad.h b/utils/vrad/vrad.h index 4ef9e488..af8bb659 100644 --- a/utils/vrad/vrad.h +++ b/utils/vrad/vrad.h @@ -24,9 +24,9 @@ #include "polylib.h" #include "threads.h" #include "builddisp.h" -#include "VRAD_DispColl.h" -#include "UtlMemory.h" -#include "UtlHash.h" +#include "vrad_dispcoll.h" +#include "utlmemory.h" +#include "utlhash.h" #include "utlvector.h" #include "iincremental.h" #include "raytrace.h" @@ -39,12 +39,14 @@ #include #include +#ifdef _WIN32 #pragma warning(disable: 4142 4028) #include #pragma warning(default: 4142 4028) +#include +#endif #include -#include #include @@ -616,4 +618,6 @@ IVradStaticPropMgr* StaticPropMgr(); extern float ComputeCoverageFromTexture( float b0, float b1, float b2, int32 hitID ); +#define FLTX4_ELEMENT( _flt, _index ) ( reinterpret_cast( &_flt )[_index] ) + #endif // VRAD_H diff --git a/utils/vrad/vrad_dispcoll.cpp b/utils/vrad/vrad_dispcoll.cpp index 2edd1ca9..38d7c1c0 100644 --- a/utils/vrad/vrad_dispcoll.cpp +++ b/utils/vrad/vrad_dispcoll.cpp @@ -6,11 +6,11 @@ //=============================================================================// #include "vrad.h" -#include "VRAD_DispColl.h" -#include "DispColl_Common.h" +#include "vrad_dispcoll.h" +#include "dispcoll_common.h" #include "radial.h" -#include "CollisionUtils.h" -#include "tier0\dbg.h" +#include "collisionutils.h" +#include "tier0/dbg.h" #define SAMPLE_BBOX_SLOP 5.0f #define TRIEDGE_EPSILON 0.001f diff --git a/utils/vrad/vrad_dispcoll.h b/utils/vrad/vrad_dispcoll.h index 787c3137..ecabac44 100644 --- a/utils/vrad/vrad_dispcoll.h +++ b/utils/vrad/vrad_dispcoll.h @@ -10,7 +10,7 @@ #pragma once #include -#include "DispColl_Common.h" +#include "dispcoll_common.h" //============================================================================= // diff --git a/utils/vrad/vrad_dll.vpc b/utils/vrad/vrad_dll.vpc index 7ebef01d..971c1385 100644 --- a/utils/vrad/vrad_dll.vpc +++ b/utils/vrad/vrad_dll.vpc @@ -14,12 +14,14 @@ $Configuration $Compiler { $AdditionalIncludeDirectories "$BASE,..\common,..\vmpi,..\vmpi\mysql\mysqlpp\include,..\vmpi\mysql\include" - $PreprocessorDefinitions "$BASE;MPI;PROTECTED_THINGS_DISABLE;VRAD" + $PreprocessorDefinitions "$BASE;PROTECTED_THINGS_DISABLE;VRAD" + $PreprocessorDefinitions "$BASE;MPI" [$WINDOWS] } $Linker { - $AdditionalDependencies "$BASE ws2_32.lib" + $AdditionalDependencies "$BASE ws2_32.lib" [$WINDOWS] + $SystemLibraries "lzma" [$POSIX] } } @@ -38,9 +40,9 @@ $Project "Vrad_dll" $File "$SRCDIR\public\loadcmdline.cpp" $File "$SRCDIR\public\lumpfiles.cpp" $File "macro_texture.cpp" - $File "..\common\mpi_stats.cpp" - $File "mpivrad.cpp" - $File "..\common\MySqlDatabase.cpp" + $File "..\common\mpi_stats.cpp" [$WINDOWS] + $File "mpivrad.cpp" [$WINDOWS] + $File "..\common\MySqlDatabase.cpp" [$WINDOWS] $File "..\common\pacifier.cpp" $File "..\common\physdll.cpp" $File "radial.cpp" @@ -48,7 +50,7 @@ $Project "Vrad_dll" $File "trace.cpp" $File "..\common\utilmatlib.cpp" $File "vismat.cpp" - $File "..\common\vmpi_tools_shared.cpp" + $File "..\common\vmpi_tools_shared.cpp" [$WINDOWS] $File "..\common\vmpi_tools_shared.h" $File "vrad.cpp" $File "VRAD_DispColl.cpp" @@ -71,6 +73,7 @@ $Project "Vrad_dll" $File "..\common\threads.cpp" $File "..\common\tools_minidump.cpp" $File "..\common\tools_minidump.h" + $File "..\common\filesystem_tools.cpp" [$POSIX] // Uncomment me if this breaks windows } $Folder "Public Files" @@ -79,6 +82,7 @@ $Project "Vrad_dll" $File "$SRCDIR\public\filesystem_helpers.cpp" $File "$SRCDIR\public\ScratchPad3D.cpp" $File "$SRCDIR\public\ScratchPadUtils.cpp" + $File "$SRCDIR\public\filesystem_init.cpp" [$POSIX] // Uncomment me if this breaks windows } } @@ -217,9 +221,9 @@ $Project "Vrad_dll" $Lib mathlib $Lib raytrace $Lib tier2 - $Lib vmpi + $Lib vmpi [$WINDOWS] $Lib vtf - $Lib "$LIBCOMMON/lzma" + $Lib "$LIBCOMMON/lzma" [$WINDOWS] } $File "notes.txt" diff --git a/utils/vrad/vraddetailprops.cpp b/utils/vrad/vraddetailprops.cpp index c782ca29..7c10866e 100644 --- a/utils/vrad/vraddetailprops.cpp +++ b/utils/vrad/vraddetailprops.cpp @@ -10,11 +10,11 @@ //=============================================================================// #include "vrad.h" -#include "Bsplib.h" -#include "GameBSPFile.h" -#include "UtlBuffer.h" +#include "bsplib.h" +#include "gamebspfile.h" +#include "utlbuffer.h" #include "utlvector.h" -#include "CModel.h" +#include "cmodel.h" #include "studio.h" #include "pacifier.h" #include "vraddetailprops.h" @@ -227,7 +227,9 @@ static void ComputeMaxDirectLighting( DetailObjectLump_t& prop, Vector* maxcolor normal4.DuplicateVector( normal ); GatherSampleLightSSE ( out, dl, -1, origin4, &normal4, 1, iThread ); - VectorMA( maxcolor[dl->light.style], out.m_flFalloff.m128_f32[0] * out.m_flDot[0].m128_f32[0], dl->light.intensity, maxcolor[dl->light.style] ); + //VectorMA( maxcolor[dl->light.style], out.m_flFalloff.m128_f32[0] * out.m_flDot[0].m128_f32[0], dl->light.intensity, maxcolor[dl->light.style] ); // OLD: for Windows + VectorMA( maxcolor[dl->light.style], FLTX4_ELEMENT(out.m_flFalloff, 0) * FLTX4_ELEMENT(out.m_flDot[0], 0), dl->light.intensity, maxcolor[dl->light.style] ); + } } @@ -960,47 +962,6 @@ void UnserializeDetailPropLighting( int lumpID, int lumpVersion, CUtlVector *pDetailPropLump = s_pDetailPropLightStyleLump; - - DetailObjectLump_t& prop = g_pMPIDetailProps[iWorkUnit]; - ComputeLighting( prop, iThread ); - - // Send the results back... - pBuf->write( &prop.m_Lighting, sizeof( prop.m_Lighting ) ); - pBuf->write( &prop.m_LightStyleCount, sizeof( prop.m_LightStyleCount ) ); - pBuf->write( &prop.m_LightStyles, sizeof( prop.m_LightStyles ) ); - - for ( int i=0; i < prop.m_LightStyleCount; i++ ) - { - DetailPropLightstylesLump_t *l = &pDetailPropLump->Element( i + prop.m_LightStyles ); - pBuf->write( &l->m_Lighting, sizeof( l->m_Lighting ) ); - pBuf->write( &l->m_Style, sizeof( l->m_Style ) ); - } -} - - -void VMPI_ReceiveDetailPropWU( int iWorkUnit, MessageBuffer *pBuf, int iWorker ) -{ - CUtlVector *pDetailPropLump = s_pDetailPropLightStyleLump; - - DetailObjectLump_t& prop = g_pMPIDetailProps[iWorkUnit]; - - pBuf->read( &prop.m_Lighting, sizeof( prop.m_Lighting ) ); - pBuf->read( &prop.m_LightStyleCount, sizeof( prop.m_LightStyleCount ) ); - pBuf->read( &prop.m_LightStyles, sizeof( prop.m_LightStyles ) ); - - pDetailPropLump->EnsureCount( prop.m_LightStyles + prop.m_LightStyleCount ); - - for ( int i=0; i < prop.m_LightStyleCount; i++ ) - { - DetailPropLightstylesLump_t *l = &pDetailPropLump->Element( i + prop.m_LightStyles ); - pBuf->read( &l->m_Lighting, sizeof( l->m_Lighting ) ); - pBuf->read( &l->m_Style, sizeof( l->m_Style ) ); - } -} //----------------------------------------------------------------------------- // Computes lighting for the detail props diff --git a/utils/vrad/vraddisps.cpp b/utils/vrad/vraddisps.cpp index d6bc6f7a..2dbfe228 100644 --- a/utils/vrad/vraddisps.cpp +++ b/utils/vrad/vraddisps.cpp @@ -8,12 +8,12 @@ #include "vrad.h" #include "utlvector.h" #include "cmodel.h" -#include "BSPTreeData.h" -#include "VRAD_DispColl.h" -#include "CollisionUtils.h" +#include "bsptreedata.h" +#include "vrad_dispcoll.h" +#include "collisionutils.h" #include "lightmap.h" -#include "Radial.h" -#include "CollisionUtils.h" +#include "radial.h" +#include "collisionutils.h" #include "mathlib/bumpvects.h" #include "utlrbtree.h" #include "tier0/fasttimer.h" diff --git a/utils/vrad/vraddll.cpp b/utils/vrad/vraddll.cpp index bc9f2f45..f7300642 100644 --- a/utils/vrad/vraddll.cpp +++ b/utils/vrad/vraddll.cpp @@ -170,8 +170,14 @@ void CVRadDLL::GetBSPInfo( CBSPInfo *pInfo ) bool CVRadDLL::DoIncrementalLight( char const *pVMFFile ) { char tempPath[MAX_PATH], tempFilename[MAX_PATH]; +#ifdef _WIN32 GetTempPath( sizeof( tempPath ), tempPath ); GetTempFileName( tempPath, "vmf_entities_", 0, tempFilename ); +#else + V_strcpy( tempPath, "/tmp/" ); + V_strcpy( tempFilename, "vradXXXXXXXX" ); + mkstemp( tempFilename ); +#endif FileHandle_t fp = g_pFileSystem->Open( tempFilename, "wb" ); if( !fp ) diff --git a/utils/vrad/vradstaticprops.cpp b/utils/vrad/vradstaticprops.cpp index 010a53b8..096b6923 100644 --- a/utils/vrad/vradstaticprops.cpp +++ b/utils/vrad/vradstaticprops.cpp @@ -11,16 +11,16 @@ #include "vrad.h" #include "mathlib/vector.h" -#include "UtlBuffer.h" +#include "utlbuffer.h" #include "utlvector.h" -#include "GameBSPFile.h" -#include "BSPTreeData.h" -#include "VPhysics_Interface.h" -#include "Studio.h" -#include "Optimize.h" -#include "Bsplib.h" -#include "CModel.h" -#include "PhysDll.h" +#include "gamebspfile.h" +#include "bsptreedata.h" +#include "vphysics_interface.h" +#include "studio.h" +#include "optimize.h" +#include "bsplib.h" +#include "cmodel.h" +#include "physdll.h" #include "phyfile.h" #include "collisionutils.h" #include "tier1/KeyValues.h" @@ -259,11 +259,6 @@ class CVradStaticPropMgr : public IVradStaticPropMgr void ComputeLighting( int iThread ); private: - // VMPI stuff. - static void VMPI_ProcessStaticProp_Static( int iThread, uint64 iStaticProp, MessageBuffer *pBuf ); - static void VMPI_ReceiveStaticPropResults_Static( uint64 iStaticProp, MessageBuffer *pBuf, int iWorker ); - void VMPI_ProcessStaticProp( int iThread, int iStaticProp, MessageBuffer *pBuf ); - void VMPI_ReceiveStaticPropResults( int iStaticProp, MessageBuffer *pBuf, int iWorker ); // local thread version static void ThreadComputeStaticPropLighting( int iThread, void *pUserData ); @@ -1204,7 +1199,8 @@ void ComputeDirectLightingAtPoint( Vector &position, Vector &normal, Vector &out GatherSampleLightSSE( sampleOutput, dl, -1, adjusted_pos4, &normal4, 1, iThread, nLFlags | GATHERLFLAGS_FORCE_FAST, static_prop_id_to_skip, flEpsilon ); - VectorMA( outColor, sampleOutput.m_flFalloff.m128_f32[0] * sampleOutput.m_flDot[0].m128_f32[0], dl->light.intensity, outColor ); + //VectorMA( outColor, sampleOutput.m_flFalloff.m128_f32[0] * sampleOutput.m_flDot[0].m128_f32[0], dl->light.intensity, outColor ); + VectorMA(outColor, FLTX4_ELEMENT(sampleOutput.m_flFalloff, 0) * FLTX4_ELEMENT(sampleOutput.m_flDot[0], 0), dl->light.intensity, outColor); } } @@ -1332,7 +1328,6 @@ void CVradStaticPropMgr::ComputeLighting( CStaticProp &prop, int iThread, int pr const int skip_prop = (g_bDisablePropSelfShadowing || (prop.m_Flags & STATIC_PROP_NO_SELF_SHADOWING)) ? prop_index : -1; const int nFlags = ( prop.m_Flags & STATIC_PROP_IGNORE_NORMALS ) ? GATHERLFLAGS_IGNORE_NORMALS : 0; - VMPI_SetCurrentStage( "ComputeLighting" ); matrix3x4_t matPos, matNormal; AngleMatrix(prop.m_Angles, prop.m_Origin, matPos); @@ -1658,91 +1653,6 @@ void CVradStaticPropMgr::SerializeLighting() } } -void CVradStaticPropMgr::VMPI_ProcessStaticProp_Static( int iThread, uint64 iStaticProp, MessageBuffer *pBuf ) -{ - g_StaticPropMgr.VMPI_ProcessStaticProp( iThread, iStaticProp, pBuf ); -} - -void CVradStaticPropMgr::VMPI_ReceiveStaticPropResults_Static( uint64 iStaticProp, MessageBuffer *pBuf, int iWorker ) -{ - g_StaticPropMgr.VMPI_ReceiveStaticPropResults( iStaticProp, pBuf, iWorker ); -} - -//----------------------------------------------------------------------------- -// Called on workers to do the computation for a static prop and send -// it to the master. -//----------------------------------------------------------------------------- -void CVradStaticPropMgr::VMPI_ProcessStaticProp( int iThread, int iStaticProp, MessageBuffer *pBuf ) -{ - // Compute the lighting. - CComputeStaticPropLightingResults results; - ComputeLighting( m_StaticProps[iStaticProp], iThread, iStaticProp, &results ); - - VMPI_SetCurrentStage( "EncodeLightingResults" ); - - // Encode the results. - int nLists = results.m_ColorVertsArrays.Count(); - pBuf->write( &nLists, sizeof( nLists ) ); - - for ( int i=0; i < nLists; i++ ) - { - CUtlVector &curList = *results.m_ColorVertsArrays[i]; - int count = curList.Count(); - pBuf->write( &count, sizeof( count ) ); - pBuf->write( curList.Base(), curList.Count() * sizeof( colorVertex_t ) ); - } - - nLists = results.m_ColorTexelsArrays.Count(); - pBuf->write(&nLists, sizeof(nLists)); - - for (int i = 0; i < nLists; i++) - { - CUtlVector &curList = *results.m_ColorTexelsArrays[i]; - int count = curList.Count(); - pBuf->write(&count, sizeof(count)); - pBuf->write(curList.Base(), curList.Count() * sizeof(colorTexel_t)); - } -} - -//----------------------------------------------------------------------------- -// Called on the master when a worker finishes processing a static prop. -//----------------------------------------------------------------------------- -void CVradStaticPropMgr::VMPI_ReceiveStaticPropResults( int iStaticProp, MessageBuffer *pBuf, int iWorker ) -{ - // Read in the results. - CComputeStaticPropLightingResults results; - - int nLists; - pBuf->read( &nLists, sizeof( nLists ) ); - - for ( int i=0; i < nLists; i++ ) - { - CUtlVector *pList = new CUtlVector; - results.m_ColorVertsArrays.AddToTail( pList ); - - int count; - pBuf->read( &count, sizeof( count ) ); - pList->SetSize( count ); - pBuf->read( pList->Base(), count * sizeof( colorVertex_t ) ); - } - - pBuf->read(&nLists, sizeof(nLists)); - - for (int i = 0; i < nLists; i++) - { - CUtlVector *pList = new CUtlVector; - results.m_ColorTexelsArrays.AddToTail(pList); - - int count; - pBuf->read(&count, sizeof(count)); - pList->SetSize(count); - pBuf->read(pList->Base(), count * sizeof(colorTexel_t)); - } - - // Apply the results. - ApplyLightingToStaticProp( iStaticProp, m_StaticProps[iStaticProp], &results ); -} - void CVradStaticPropMgr::ComputeLightingForProp( int iThread, int iStaticProp ) { @@ -1783,21 +1693,7 @@ void CVradStaticPropMgr::ComputeLighting( int iThread ) // ensure any traces against us are ignored because we have no inherit lighting contribution m_bIgnoreStaticPropTrace = true; - if ( g_bUseMPI ) - { - // Distribute the work among the workers. - VMPI_SetCurrentStage( "CVradStaticPropMgr::ComputeLighting" ); - - DistributeWork( - count, - VMPI_DISTRIBUTEWORK_PACKETID, - &CVradStaticPropMgr::VMPI_ProcessStaticProp_Static, - &CVradStaticPropMgr::VMPI_ReceiveStaticPropResults_Static ); - } - else - { - RunThreadsOn(count, true, ThreadComputeStaticPropLighting); - } + RunThreadsOn( count, true, ThreadComputeStaticPropLighting ); // restore default m_bIgnoreStaticPropTrace = false; diff --git a/utils/vrad_launcher/stdafx.h b/utils/vrad_launcher/stdafx.h index 36daff0a..8dc345b7 100644 --- a/utils/vrad_launcher/stdafx.h +++ b/utils/vrad_launcher/stdafx.h @@ -9,7 +9,6 @@ // or project specific include files that are used frequently, but // are changed infrequently // - #if !defined(AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_) #define AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_ diff --git a/utils/vrad_launcher/vrad_launcher.cpp b/utils/vrad_launcher/vrad_launcher.cpp index a4d31834..acdc5c75 100644 --- a/utils/vrad_launcher/vrad_launcher.cpp +++ b/utils/vrad_launcher/vrad_launcher.cpp @@ -8,14 +8,24 @@ // vrad_launcher.cpp : Defines the entry point for the console application. // +#ifdef _WIN32 #include "stdafx.h" #include +#else +#include +#include +#include +#endif + #include "tier1/strtools.h" #include "tier0/icommandline.h" +#include "appframework/AppFramework.h" +#include "ivraddll.h" char* GetLastErrorString() { +#ifdef _WIN32 static char err[2048]; LPVOID lpMsgBuf; @@ -37,6 +47,9 @@ char* GetLastErrorString() err[ sizeof( err ) - 1 ] = 0; return err; +#else + return 0; +#endif } @@ -61,6 +74,15 @@ int main(int argc, char* argv[]) CommandLine()->CreateCmdLine( argc, argv ); + /* JL: If we're on Linux, find our absolute directory path and use it to locate vrad.so */ +#ifdef LINUX + char dir[MAX_PATH]; + V_strcpy( dir, argv[0] ); + char *d = dirname( dir ); + char fullpath[PATH_MAX]; + realpath( d, fullpath ); +#endif + // check whether they used the -both switch. If this is specified, vrad will be run // twice, once with -hdr and once without int both_arg=0; @@ -107,7 +129,11 @@ int main(int argc, char* argv[]) // If it didn't load the module above, then use the if ( !pModule ) { +#ifdef _WIN32 strcpy( dllName, "vrad_dll.dll" ); +#else + V_snprintf( dllName, sizeof( dllName ), "%s/%s", fullpath, "vrad.so" ); +#endif pModule = Sys_LoadModule( dllName ); } diff --git a/utils/vrad_launcher/vrad_launcher.vpc b/utils/vrad_launcher/vrad_launcher.vpc index 6c1e7b2d..cb35c956 100644 --- a/utils/vrad_launcher/vrad_launcher.vpc +++ b/utils/vrad_launcher/vrad_launcher.vpc @@ -32,7 +32,7 @@ $Project "Vrad_launcher" $File "vrad_launcher.cpp" - $File "StdAfx.cpp" + $File "StdAfx.cpp" [$WINDOWS] { $Configuration { diff --git a/utils/vvis/flow.cpp b/utils/vvis/flow.cpp index 716fc1ae..7e12a008 100644 --- a/utils/vvis/flow.cpp +++ b/utils/vvis/flow.cpp @@ -485,11 +485,6 @@ void RecursiveLeafFlow (int leafnum, threaddata_t *thread, pstack_t *prevstack) long *test, *might, *vis, more; int pnum; - // Early-out if we're a VMPI worker that's told to exit. If we don't do this here, then the - // worker might spin its wheels for a while on an expensive work unit and not be available to the pool. - // This is pretty common in vis. - if ( g_bVMPIEarlyExit ) - return; if ( leafnum == g_TraceClusterStop ) { diff --git a/utils/vvis/vvis.cpp b/utils/vvis/vvis.cpp index 42edd0bf..f85b4853 100644 --- a/utils/vvis/vvis.cpp +++ b/utils/vvis/vvis.cpp @@ -7,7 +7,10 @@ //=============================================================================// // vis.c +#ifdef _WIN32 #include +#endif + #include "vis.h" #include "threads.h" #include "stdlib.h" @@ -302,15 +305,7 @@ void CalcPortalVis (void) } - if (g_bUseMPI) - { - RunMPIPortalFlow(); - } - else - { - RunThreadsOnIndividual (g_numportals*2, true, PortalFlow); - } -} + RunThreadsOnIndividual( g_numportals * 2, true, PortalFlow ); void CalcVisTrace (void) @@ -331,14 +326,7 @@ void CalcVis (void) { int i; - if (g_bUseMPI) - { - RunMPIBasePortalVis(); - } - else - { - RunThreadsOnIndividual (g_numportals*2, true, BasePortalVis); - } + RunThreadsOnIndividual( g_numportals * 2, true, BasePortalVis ); SortPortals (); @@ -413,44 +401,7 @@ void LoadPortals (char *name) FILE *f; - // Open the portal file. - if ( g_bUseMPI ) - { - // If we're using MPI, copy off the file to a temporary first. This will download the file - // from the MPI master, then we get to use nice functions like fscanf on it. - char tempPath[MAX_PATH], tempFile[MAX_PATH]; - if ( GetTempPath( sizeof( tempPath ), tempPath ) == 0 ) - { - Error( "LoadPortals: GetTempPath failed.\n" ); - } - - if ( GetTempFileName( tempPath, "vvis_portal_", 0, tempFile ) == 0 ) - { - Error( "LoadPortals: GetTempFileName failed.\n" ); - } - - // Read all the data from the network file into memory. - FileHandle_t hFile = g_pFileSystem->Open(name, "r"); - if ( hFile == FILESYSTEM_INVALID_HANDLE ) - Error( "LoadPortals( %s ): couldn't get file from master.\n", name ); - - CUtlVector data; - data.SetSize( g_pFileSystem->Size( hFile ) ); - g_pFileSystem->Read( data.Base(), data.Count(), hFile ); - g_pFileSystem->Close( hFile ); - - // Dump it into a temp file. - f = fopen( tempFile, "wt" ); - fwrite( data.Base(), 1, data.Count(), f ); - fclose( f ); - - // Open the temp file up. - f = fopen( tempFile, "rSTD" ); // read only, sequential, temporary, delete on close - } - else - { - f = fopen( name, "r" ); - } + f = fopen( name, "r" ); if ( !f ) Error ("LoadPortals: couldn't read %s\n",name); @@ -974,7 +925,7 @@ int ParseCommandLine( int argc, char **argv ) else if ( !Q_strncasecmp( argv[i], "-mpi", 4 ) || !Q_strncasecmp( argv[i-1], "-mpi", 4 ) ) { if ( stricmp( argv[i], "-mpi" ) == 0 ) - g_bUseMPI = true; + Error( "VMPI is not supported on this platform\n" ); // Any other args that start with -mpi are ok too. if ( i == argc - 1 ) @@ -1110,13 +1061,10 @@ int RunVVis( int argc, char **argv ) start = Plat_FloatTime(); - if (!g_bUseMPI) - { - // Setup the logfile. - char logFile[512]; - _snprintf( logFile, sizeof(logFile), "%s.log", source ); - SetSpewFunctionLogFile( logFile ); - } + // Setup the logfile. + char logFile[512]; + _snprintf( logFile, sizeof( logFile ), "%s.log", source ); + SetSpewFunctionLogFile( logFile ); // Run in the background? if( g_bLowPriority ) @@ -1187,10 +1135,7 @@ int RunVVis( int argc, char **argv ) { Error("Invalid cluster trace: %d to %d, valid range is 0 to %d\n", g_TraceClusterStart, g_TraceClusterStop, portalclusters-1 ); } - if ( g_bUseMPI ) - { - Warning("Can't compile trace in MPI mode\n"); - } + CalcVisTrace (); WritePortalTrace(source); } @@ -1217,17 +1162,12 @@ int main (int argc, char **argv) { CommandLine()->CreateCmdLine( argc, argv ); + FileSystem_Init( nullptr, 0, FSInitType_t::FS_INIT_COMPATIBILITY_MODE ); MathLib_Init( 2.2f, 2.2f, 0.0f, 1.0f, false, false, false, false ); InstallAllocationFunctions(); InstallSpewFunction(); - VVIS_SetupMPI( argc, argv ); - - // Install an exception handler. - if ( g_bUseMPI && !g_bMPIMaster ) - SetupToolsMinidumpHandler( VMPI_ExceptionFilter ); - else - SetupDefaultToolsMinidumpHandler(); + SetupDefaultToolsMinidumpHandler(); return RunVVis( argc, argv ); } diff --git a/utils/vvis/vvis_dll.vpc b/utils/vvis/vvis_dll.vpc index 211719ff..47c50225 100644 --- a/utils/vvis/vvis_dll.vpc +++ b/utils/vvis/vvis_dll.vpc @@ -14,12 +14,14 @@ $Configuration $Compiler { $AdditionalIncludeDirectories "$BASE,..\common,..\vmpi,..\vmpi\mysql\include" - $PreprocessorDefinitions "$BASE;MPI;PROTECTED_THINGS_DISABLE" + $PreprocessorDefinitions "$BASE;PROTECTED_THINGS_DISABLE" + $PreprocessorDefinitions "$BASE;MPI" [$WINDOWS] } $Linker { - $AdditionalDependencies "$BASE odbc32.lib odbccp32.lib ws2_32.lib" + $AdditionalDependencies "$BASE odbc32.lib odbccp32.lib ws2_32.lib" [$WINDOWS] + $SystemLibraries "lzma" [$POSIX] } } @@ -36,9 +38,9 @@ $Project "Vvis_dll" $File "flow.cpp" $File "$SRCDIR\public\loadcmdline.cpp" $File "$SRCDIR\public\lumpfiles.cpp" - $File "..\common\mpi_stats.cpp" - $File "mpivis.cpp" - $File "..\common\MySqlDatabase.cpp" + $File "..\common\mpi_stats.cpp" [$WINDOWS] + $File "mpivis.cpp" [$WINDOWS] + $File "..\common\MySqlDatabase.cpp" [$WINDOWS] $File "..\common\pacifier.cpp" $File "$SRCDIR\public\scratchpad3d.cpp" $File "..\common\scratchpad_helpers.cpp" @@ -46,10 +48,12 @@ $Project "Vvis_dll" $File "..\common\threads.cpp" $File "..\common\tools_minidump.cpp" $File "..\common\tools_minidump.h" - $File "..\common\vmpi_tools_shared.cpp" + $File "..\common\vmpi_tools_shared.cpp" [$WINDOWS] $File "vvis.cpp" $File "WaterDist.cpp" $File "$SRCDIR\public\zip_utils.cpp" + $File "$SRCDIR\public\filesystem_init.cpp" [$POSIX] + $File "..\common\filesystem_tools.cpp" [$POSIX] } $Folder "Header Files" @@ -96,7 +100,7 @@ $Project "Vvis_dll" { $Lib mathlib $Lib tier2 - $Lib vmpi - $Lib "$LIBCOMMON/lzma" + $Lib vmpi [$WINDOWS] + $Lib "$LIBCOMMON/lzma" [$WINDOWS] } } diff --git a/utils/vvis_launcher/vvis_launcher.cpp b/utils/vvis_launcher/vvis_launcher.cpp index edf03d25..3579dbec 100644 --- a/utils/vvis_launcher/vvis_launcher.cpp +++ b/utils/vvis_launcher/vvis_launcher.cpp @@ -8,16 +8,20 @@ // vvis_launcher.cpp : Defines the entry point for the console application. // -#include "stdafx.h" +#ifdef _WIN32 +#include "StdAfx.h" #include +#endif + #include "tier1/strtools.h" #include "tier0/icommandline.h" #include "ilaunchabledll.h" - +#include "interface.h" char* GetLastErrorString() { +#ifdef _WIN32 static char err[2048]; LPVOID lpMsgBuf; @@ -39,14 +43,21 @@ char* GetLastErrorString() err[ sizeof( err ) - 1 ] = 0; return err; +#else + return ""; +#endif } int main(int argc, char* argv[]) { CommandLine()->CreateCmdLine( argc, argv ); +#ifdef _WIN32 const char *pDLLName = "vvis_dll.dll"; - +#else + const char *pDLLName = "vvis.so"; +#endif + CSysModule *pModule = Sys_LoadModule( pDLLName ); if ( !pModule ) { diff --git a/utils/vvis_launcher/vvis_launcher.vpc b/utils/vvis_launcher/vvis_launcher.vpc index 71713400..9d5cbeeb 100644 --- a/utils/vvis_launcher/vvis_launcher.vpc +++ b/utils/vvis_launcher/vvis_launcher.vpc @@ -31,7 +31,7 @@ $Project "Vvis_launcher" { $File "vvis_launcher.cpp" - $File "StdAfx.cpp" + $File "StdAfx.cpp" [$WINDOWS] { $Configuration {