aboutsummaryrefslogtreecommitdiff
path: root/mp/src
diff options
context:
space:
mode:
Diffstat (limited to 'mp/src')
-rw-r--r--mp/src/devtools/base.xcconfig46
-rw-r--r--mp/src/devtools/bin/osx32/xcode_ccache_wrapper3
-rw-r--r--mp/src/devtools/bin/vpc.exebin1129472 -> 1133568 bytes
-rwxr-xr-xmp/src/devtools/bin/vpc_linuxbin1184881 -> 1177324 bytes
-rwxr-xr-xmp/src/devtools/bin/vpc_osxbin1101980 -> 1098508 bytes
-rw-r--r--mp/src/devtools/debug.xcconfig4
-rw-r--r--mp/src/devtools/makefile_base_posix.mak2
-rw-r--r--mp/src/devtools/release.xcconfig4
-rw-r--r--mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dllbin90024 -> 90024 bytes
-rw-r--r--mp/src/dx9sdk/utilities/dx_proxy.dllbin678824 -> 678824 bytes
-rw-r--r--mp/src/fgdlib/fgdlib.vpc40
-rw-r--r--mp/src/fgdlib/gamedata.cpp886
-rw-r--r--mp/src/fgdlib/gdclass.cpp1041
-rw-r--r--mp/src/fgdlib/gdvar.cpp729
-rw-r--r--mp/src/fgdlib/inputoutput.cpp171
-rw-r--r--mp/src/fgdlib/wckeyvalues.cpp282
-rw-r--r--mp/src/game/client/c_baseentity.cpp113
-rw-r--r--mp/src/game/client/c_baseentity.h7
-rw-r--r--mp/src/game/client/c_baseplayer.cpp2
-rw-r--r--mp/src/game/client/cdll_client_int.cpp2
-rw-r--r--mp/src/game/client/client_base.vpc78
-rw-r--r--mp/src/game/client/client_hl2mp.vpc15
-rw-r--r--mp/src/game/client/death.cpp2
-rw-r--r--mp/src/game/protobuf_include.vpc17
-rw-r--r--mp/src/game/server/ai_behavior_lead.cpp3
-rw-r--r--mp/src/game/server/ai_networkmanager.cpp2
-rw-r--r--mp/src/game/server/ai_tacticalservices.cpp2
-rw-r--r--mp/src/game/server/baseentity.cpp31
-rw-r--r--mp/src/game/server/baseentity.h2
-rw-r--r--mp/src/game/server/client.cpp18
-rw-r--r--mp/src/game/server/doors.cpp14
-rw-r--r--mp/src/game/server/doors.h1
-rw-r--r--mp/src/game/server/episodic/npc_hunter.cpp6
-rw-r--r--mp/src/game/server/hl2/npc_barnacle.cpp5
-rw-r--r--mp/src/game/server/hl2/npc_zombine.cpp2
-rw-r--r--mp/src/game/server/player.h40
-rw-r--r--mp/src/game/server/props.cpp12
-rw-r--r--mp/src/game/server/server_base.vpc42
-rw-r--r--mp/src/game/server/testfunctions.cpp26
-rw-r--r--mp/src/game/server/util.cpp3
-rw-r--r--mp/src/game/shared/GameStats.cpp2
-rw-r--r--mp/src/game/shared/playernet_vars.h4
-rw-r--r--mp/src/game/shared/shareddefs.h11
-rw-r--r--mp/src/lib/common/libcurl.libbin0 -> 5617846 bytes
-rw-r--r--mp/src/lib/common/linux32/libcrypto.a (renamed from mp/src/lib/linux32/release/libcrypto.a)bin2788376 -> 2788376 bytes
-rw-r--r--mp/src/lib/common/linux32/libcurl.a (renamed from mp/src/lib/linux32/libcurl.a)bin376238 -> 376238 bytes
-rw-r--r--mp/src/lib/common/linux32/libcurlssl.a (renamed from mp/src/lib/linux32/libcurlssl.a)bin474906 -> 474906 bytes
-rw-r--r--mp/src/lib/common/linux32/libssl.a (renamed from mp/src/lib/linux32/libssl.a)bin487180 -> 487180 bytes
-rw-r--r--mp/src/lib/osx32/bitmap.abin3542712 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/choreoobjects.abin5118704 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/dmxloader.abin4176952 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/libcurl.dylibbin98548 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/libtier0.dylibbin168128 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/libvstdlib.dylibbin188076 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/particles.abin7630344 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/shaderlib.abin2982016 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/tier2.abin3700040 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/tier3.abin3354672 -> 0 bytes
-rw-r--r--mp/src/lib/osx32/vtf.abin3108872 -> 0 bytes
-rw-r--r--mp/src/lib/public/appframework.libbin1610376 -> 1610618 bytes
-rw-r--r--mp/src/lib/public/bitmap.libbin3929388 -> 3933330 bytes
-rw-r--r--mp/src/lib/public/choreoobjects.libbin3290672 -> 3291150 bytes
-rw-r--r--mp/src/lib/public/dmxloader.libbin2797158 -> 2797384 bytes
-rw-r--r--mp/src/lib/public/fgdlib.libbin2461660 -> 2462284 bytes
-rw-r--r--mp/src/lib/public/libprotobuf.lib (renamed from mp/src/lib/win32/release/vs2010/libprotobuf.lib)bin27790670 -> 27790670 bytes
-rw-r--r--mp/src/lib/public/libz.libbin0 -> 236866 bytes
-rw-r--r--mp/src/lib/public/linux32/bitmap.abin1168636 -> 1168636 bytes
-rw-r--r--mp/src/lib/public/linux32/choreoobjects.abin2148256 -> 2148256 bytes
-rw-r--r--mp/src/lib/public/linux32/dmxloader.abin1750688 -> 1750688 bytes
-rw-r--r--mp/src/lib/public/linux32/libprotobuf.a (renamed from mp/src/lib/linux32/release/libprotobuf.a)bin7850752 -> 7850752 bytes
-rw-r--r--mp/src/lib/public/linux32/libsteam_api.so (renamed from mp/src/lib/linux32/libsteam_api.so)bin79027 -> 79027 bytes
-rw-r--r--mp/src/lib/public/linux32/libtier0.sobin759225 -> 759505 bytes
-rw-r--r--mp/src/lib/public/linux32/libvstdlib.sobin1171959 -> 1172163 bytes
-rw-r--r--mp/src/lib/public/linux32/libz.abin0 -> 110018 bytes
-rw-r--r--mp/src/lib/public/linux32/matsys_controls.abin7177880 -> 7177932 bytes
-rw-r--r--mp/src/lib/public/linux32/particles.abin7346764 -> 7346764 bytes
-rw-r--r--mp/src/lib/public/linux32/shaderlib.abin301020 -> 301020 bytes
-rw-r--r--mp/src/lib/public/linux32/tier2.abin1497768 -> 1497768 bytes
-rw-r--r--mp/src/lib/public/linux32/tier3.abin1036384 -> 1036384 bytes
-rw-r--r--mp/src/lib/public/linux32/vtf.abin498418 -> 498418 bytes
-rw-r--r--mp/src/lib/public/mathlib.libbin2290772 -> 2311446 bytes
-rw-r--r--mp/src/lib/public/matsys_controls.libbin18140064 -> 18149570 bytes
-rw-r--r--mp/src/lib/public/nvtristrip.libbin1068866 -> 1068906 bytes
-rw-r--r--mp/src/lib/public/osx32/bitmap.abin0 -> 861816 bytes
-rw-r--r--mp/src/lib/public/osx32/choreoobjects.abin0 -> 2424152 bytes
-rw-r--r--mp/src/lib/public/osx32/dmxloader.abin0 -> 1498400 bytes
-rw-r--r--mp/src/lib/public/osx32/libprotobuf.a (renamed from mp/src/lib/osx32/release/libprotobuf.a)bin1637400 -> 1637400 bytes
-rw-r--r--mp/src/lib/public/osx32/libsteam_api.dylib (renamed from mp/src/lib/osx32/libsteam_api.dylib)bin129580 -> 129580 bytes
-rw-r--r--mp/src/lib/public/osx32/libtier0.dylibbin0 -> 164388 bytes
-rw-r--r--mp/src/lib/public/osx32/libvstdlib.dylibbin0 -> 183432 bytes
-rw-r--r--mp/src/lib/public/osx32/mathlib.abin0 -> 1062016 bytes
-rw-r--r--mp/src/lib/public/osx32/matsys_controls.a (renamed from mp/src/lib/osx32/matsys_controls.a)bin12356096 -> 9671600 bytes
-rw-r--r--mp/src/lib/public/osx32/particles.abin0 -> 4946856 bytes
-rw-r--r--mp/src/lib/public/osx32/raytrace.abin0 -> 409464 bytes
-rw-r--r--mp/src/lib/public/osx32/shaderlib.abin0 -> 302616 bytes
-rw-r--r--mp/src/lib/public/osx32/tier1.abin0 -> 2656344 bytes
-rw-r--r--mp/src/lib/public/osx32/tier2.abin0 -> 1018528 bytes
-rw-r--r--mp/src/lib/public/osx32/tier3.abin0 -> 675344 bytes
-rw-r--r--mp/src/lib/public/osx32/vgui_controls.a (renamed from mp/src/lib/win32/debug/vs2010/libprotobuf.lib)bin29211874 -> 35457064 bytes
-rw-r--r--mp/src/lib/public/osx32/vtf.abin0 -> 429512 bytes
-rw-r--r--mp/src/lib/public/particles.libbin9151936 -> 9154414 bytes
-rw-r--r--mp/src/lib/public/raytrace.libbin782746 -> 781454 bytes
-rw-r--r--mp/src/lib/public/shaderlib.libbin797592 -> 797764 bytes
-rw-r--r--mp/src/lib/public/tier0.libbin102394 -> 102394 bytes
-rw-r--r--mp/src/lib/public/tier1.libbin6676292 -> 6689054 bytes
-rw-r--r--mp/src/lib/public/tier2.libbin3280830 -> 3282482 bytes
-rw-r--r--mp/src/lib/public/tier3.libbin2366404 -> 2366646 bytes
-rw-r--r--mp/src/lib/public/vgui_controls.libbin49914672 -> 49942122 bytes
-rw-r--r--mp/src/lib/public/vmpi.libbin6411898 -> 6413930 bytes
-rw-r--r--mp/src/lib/public/vstdlib.libbin13050 -> 13050 bytes
-rw-r--r--mp/src/lib/public/vtf.libbin1056646 -> 1058036 bytes
-rw-r--r--mp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc16
-rw-r--r--mp/src/mathlib/mathlib.vpc2
-rw-r--r--mp/src/public/XUnzip.cpp8
-rw-r--r--mp/src/public/bone_setup.cpp2
-rw-r--r--mp/src/public/cdll_int.h2
-rw-r--r--mp/src/public/engine/IStaticPropMgr.h3
-rw-r--r--mp/src/public/engine/ivmodelrender.h2
-rw-r--r--mp/src/public/game/server/pluginvariant.h2
-rw-r--r--mp/src/public/inputsystem/iinputsystem.h7
-rw-r--r--mp/src/public/tier0/dbg.h4
-rw-r--r--mp/src/public/tier0/platform.h4
-rw-r--r--mp/src/public/tier1/fmtstr.h11
-rw-r--r--mp/src/public/tier1/utlstring.h3
-rw-r--r--mp/src/public/vgui_controls/Panel.h8
-rw-r--r--mp/src/raytrace/raytrace.cpp901
-rw-r--r--mp/src/raytrace/raytrace.vpc26
-rw-r--r--mp/src/raytrace/trace2.cpp376
-rw-r--r--mp/src/raytrace/trace3.cpp127
-rw-r--r--mp/src/tier0/tier0_exclude.vpc5
-rw-r--r--mp/src/tier1/bitbuf.cpp10
-rw-r--r--mp/src/tier1/strtools.cpp24
-rw-r--r--mp/src/tier1/tier1.vpc3
-rw-r--r--mp/src/utils/captioncompiler/captioncompiler.vpc10
-rw-r--r--mp/src/utils/glview/glview.vpc6
-rw-r--r--mp/src/utils/height2normal/height2normal.vpc8
-rw-r--r--mp/src/utils/motionmapper/motionmapper.vpc8
-rw-r--r--mp/src/utils/phonemeextractor/phonemeextractor.vpc4
-rw-r--r--mp/src/utils/phonemeextractor/phonemeextractor_ims.vpc4
-rw-r--r--mp/src/utils/qc_eyes/qc_eyes.vpc2
-rw-r--r--mp/src/utils/serverplugin_sample/serverplugin_empty.vpc8
-rw-r--r--mp/src/utils/tgadiff/tgadiff.vpc8
-rw-r--r--mp/src/utils/vbsp/vbsp.vpc12
-rw-r--r--mp/src/utils/vice/vice.vpc6
-rw-r--r--mp/src/utils/vrad/vrad_dll.vpc14
-rw-r--r--mp/src/utils/vrad_launcher/vrad_launcher.vpc2
-rw-r--r--mp/src/utils/vtf2tga/vtf2tga.vpc10
-rw-r--r--mp/src/utils/vtfdiff/vtfdiff.vpc10
-rw-r--r--mp/src/utils/vvis/vvis_dll.vpc8
-rw-r--r--mp/src/utils/vvis_launcher/vvis_launcher.vpc2
-rw-r--r--mp/src/vgui2/vgui_controls/TextEntry.cpp2
-rw-r--r--mp/src/vgui2/vgui_controls/vgui_controls.vpc1
-rw-r--r--mp/src/vpc_scripts/definitions/win32_2010.def7
-rw-r--r--mp/src/vpc_scripts/groups.vgc3
-rw-r--r--mp/src/vpc_scripts/platform_dirs.vpc5
-rw-r--r--mp/src/vpc_scripts/projects.vgc10
-rw-r--r--mp/src/vpc_scripts/protobuf_builder.vpc2
-rw-r--r--mp/src/vpc_scripts/source_base.vpc29
-rw-r--r--mp/src/vpc_scripts/source_dll_base.vpc37
-rw-r--r--mp/src/vpc_scripts/source_dll_linux_base.vpc27
-rw-r--r--mp/src/vpc_scripts/source_dll_posix_base.vpc9
-rw-r--r--mp/src/vpc_scripts/source_dll_qt_base.vpc44
-rw-r--r--mp/src/vpc_scripts/source_dll_win32_base.vpc122
-rw-r--r--mp/src/vpc_scripts/source_dll_win32_debug.vpc52
-rw-r--r--mp/src/vpc_scripts/source_dll_win32_release.vpc74
-rw-r--r--mp/src/vpc_scripts/source_exe_base.vpc27
-rw-r--r--mp/src/vpc_scripts/source_exe_con_base.vpc18
-rw-r--r--mp/src/vpc_scripts/source_exe_con_win32_base.vpc2
-rw-r--r--mp/src/vpc_scripts/source_exe_posix_base.vpc29
-rw-r--r--mp/src/vpc_scripts/source_exe_qt_base.vpc5
-rw-r--r--mp/src/vpc_scripts/source_exe_qt_con_base.vpc16
-rw-r--r--mp/src/vpc_scripts/source_exe_qt_win32_base.vpc48
-rw-r--r--mp/src/vpc_scripts/source_exe_win_win32_base.vpc108
-rw-r--r--mp/src/vpc_scripts/source_exe_win_win32_debug.vpc43
-rw-r--r--mp/src/vpc_scripts/source_exe_win_win32_release.vpc69
-rw-r--r--mp/src/vpc_scripts/source_lib_base.vpc34
-rw-r--r--mp/src/vpc_scripts/source_lib_posix_base.vpc17
-rw-r--r--mp/src/vpc_scripts/source_lib_qt_base.vpc2
-rw-r--r--mp/src/vpc_scripts/source_lib_qt_win32_base.vpc22
-rw-r--r--mp/src/vpc_scripts/source_lib_win32_base.vpc39
-rw-r--r--mp/src/vpc_scripts/source_lib_win32_debug.vpc28
-rw-r--r--mp/src/vpc_scripts/source_lib_win32_release.vpc44
-rw-r--r--mp/src/vpc_scripts/source_linux_base_project.vpc37
-rw-r--r--mp/src/vpc_scripts/source_mll_qt_base.vpc35
-rw-r--r--mp/src/vpc_scripts/source_posix_base.vpc55
-rw-r--r--mp/src/vpc_scripts/source_video_base.vpc46
-rw-r--r--mp/src/vpc_scripts/source_win32_base.vpc45
-rw-r--r--mp/src/vpc_scripts/version.vpc2
-rw-r--r--mp/src/vstdlib/vstdlib_exclude.vpc3
189 files changed, 5804 insertions, 732 deletions
diff --git a/mp/src/devtools/base.xcconfig b/mp/src/devtools/base.xcconfig
new file mode 100644
index 00000000..d5ba4a16
--- /dev/null
+++ b/mp/src/devtools/base.xcconfig
@@ -0,0 +1,46 @@
+ALWAYS_SEARCH_USER_PATHS = YES
+HEADER_SEARCH_PATHS = $(HEADER_SEARCH_PATHS) $(SDKROOT)/usr/include/malloc
+
+ARCHS = i386
+ONLY_ACTIVE_ARCH = NO
+COPY_PHASE_STRIP = NO
+DEBUG_INFORMATION_FORMAT = dwarf-with-dsym
+
+DEAD_CODE_STRIPPING = YES
+PRESERVE_DEAD_CODE_INITS_AND_TERMS = YES
+
+GCC_C_LANGUAGE_STANDARD = gnu99
+GCC_ENABLE_OBJC_EXCEPTIONS = YES
+GCC_SYMBOLS_PRIVATE_EXTERN = YES
+GCC_INLINES_ARE_PRIVATE_EXTERN = YES
+GCC_REUSE_STRINGS = YES
+
+// CPP11_NO_LIBCXX is used to gate some C++11 features that require that we
+// switch to libc++. We haven't switched to libc++11 because we have been unable
+// to find a clean way to build libcef_dll_wrapper with libc++.
+// We currently build libcef for Steam which needs to run on 10.5, and Xcode
+// does not support linking with libc++ and targeting 10.5.
+// Once libcef_dll_wrapper has been built with libc++, and you rebuild protobuf
+// with libc++ (which is trivial), you can remove CPP11_NO_LIBCXX and add the
+// following line to the xcconfig:
+// CLANG_CXX_LIBRARY = libc++
+GCC_PREPROCESSOR_DEFINITIONS = _DLL_EXT=.dylib NO_MALLOC_OVERRIDE=1 VPROF_LEVEL=1 NO_HOOK_MALLOC=1 PNG_NO_PEDANTIC_WARNINGS CPP11_NO_LIBCXX
+BASE_CFLAGS= -Usprintf -Ustrncpy -UPROTECTED_THINGS_ENABLE
+
+GCC_WARN_ABOUT_INVALID_OFFSETOF_MACRO = NO
+WARNING_CFLAGS = -Wno-deprecated-writable-strings -Wno-switch-enum -Wno-switch -Wno-unused-value -Wno-parentheses -Wno-logical-op-parentheses -Wno-c++11-narrowing
+
+// CLANG - and use the ccache wrapper
+GCC_VERSION = com.apple.compilers.llvm.clang.1_0
+CC = $(SOURCE_ROOT)/devtools/bin/osx32/xcode_ccache_wrapper
+LDPLUSPLUS = $(DT_TOOLCHAIN_DIR)/usr/bin/clang++
+CLANG_WARN_CXX0X_EXTENSIONS = NO
+CLANG_CXX_LANGUAGE_STANDARD = gnu++11
+
+// include <memory.h> gets confused, 'cause ivp has one, and the system has one, and only one
+// gets into the header map, so sacrifice speed for corectness.
+USE_HEADERMAP = NO
+
+SDKROOT = macosx10.7
+MACOSX_DEPLOYMENT_TARGET = 10.5
+GCC_FAST_MATH = YES
diff --git a/mp/src/devtools/bin/osx32/xcode_ccache_wrapper b/mp/src/devtools/bin/osx32/xcode_ccache_wrapper
new file mode 100644
index 00000000..4f038475
--- /dev/null
+++ b/mp/src/devtools/bin/osx32/xcode_ccache_wrapper
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec $(dirname $0)/ccache "${DT_TOOLCHAIN_DIR}"/usr/bin/clang -Qunused-arguments "$@"
diff --git a/mp/src/devtools/bin/vpc.exe b/mp/src/devtools/bin/vpc.exe
index ddc1328c..2394de95 100644
--- a/mp/src/devtools/bin/vpc.exe
+++ b/mp/src/devtools/bin/vpc.exe
Binary files differ
diff --git a/mp/src/devtools/bin/vpc_linux b/mp/src/devtools/bin/vpc_linux
index d6534046..c69b62f5 100755
--- a/mp/src/devtools/bin/vpc_linux
+++ b/mp/src/devtools/bin/vpc_linux
Binary files differ
diff --git a/mp/src/devtools/bin/vpc_osx b/mp/src/devtools/bin/vpc_osx
index 0f9ef14b..701d780e 100755
--- a/mp/src/devtools/bin/vpc_osx
+++ b/mp/src/devtools/bin/vpc_osx
Binary files differ
diff --git a/mp/src/devtools/debug.xcconfig b/mp/src/devtools/debug.xcconfig
new file mode 100644
index 00000000..668a3cf1
--- /dev/null
+++ b/mp/src/devtools/debug.xcconfig
@@ -0,0 +1,4 @@
+#include "base.xcconfig"
+GCC_OPTIMIZATION_LEVEL = 0
+OTHER_CFLAGS = $(derived) $(BASE_CFLAGS)
+
diff --git a/mp/src/devtools/makefile_base_posix.mak b/mp/src/devtools/makefile_base_posix.mak
index 7ad95035..8b32dec5 100644
--- a/mp/src/devtools/makefile_base_posix.mak
+++ b/mp/src/devtools/makefile_base_posix.mak
@@ -42,7 +42,7 @@ CFLAGS = $(ARCH_FLAGS) $(CPPFLAGS) $(WARN_FLAGS) -fvisibility=$(SymbolVisibility
# 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 ($(CXX),clang++)
- CXXFLAGS = $(CFLAGS) -Wno-c++11-narrowing -Wno-dangling-else
+ CXXFLAGS = $(CFLAGS) -Wno-c++11-narrowing
else
CXXFLAGS = $(CFLAGS) -fpermissive
endif
diff --git a/mp/src/devtools/release.xcconfig b/mp/src/devtools/release.xcconfig
new file mode 100644
index 00000000..5e1a475f
--- /dev/null
+++ b/mp/src/devtools/release.xcconfig
@@ -0,0 +1,4 @@
+#include "base.xcconfig"
+
+GCC_OPTIMIZATION_LEVEL = 2
+OTHER_CFLAGS = $(derived) $(BASE_CFLAGS) -ftree-vectorize -fpredictive-commoning -funswitch-loops
diff --git a/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll b/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll
index d76adbc0..e1989363 100644
--- a/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll
+++ b/mp/src/dx10sdk/Utilities/dx9_30/dx_proxy.dll
Binary files differ
diff --git a/mp/src/dx9sdk/utilities/dx_proxy.dll b/mp/src/dx9sdk/utilities/dx_proxy.dll
index 676a897d..56453730 100644
--- a/mp/src/dx9sdk/utilities/dx_proxy.dll
+++ b/mp/src/dx9sdk/utilities/dx_proxy.dll
Binary files differ
diff --git a/mp/src/fgdlib/fgdlib.vpc b/mp/src/fgdlib/fgdlib.vpc
new file mode 100644
index 00000000..6ff37694
--- /dev/null
+++ b/mp/src/fgdlib/fgdlib.vpc
@@ -0,0 +1,40 @@
+//-----------------------------------------------------------------------------
+// FGDLIB.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR ".."
+$Include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE,$SRCDIR\utils\common"
+ }
+}
+
+$Project "Fgdlib"
+{
+ $Folder "Source Files"
+ {
+ $File "gamedata.cpp"
+ $File "gdclass.cpp"
+ $File "gdvar.cpp"
+ $File "inputoutput.cpp"
+ $File "wckeyvalues.cpp"
+ }
+
+ $Folder "Header Files"
+ {
+ $File "$SRCDIR\public\fgdlib\fgdlib.h"
+ $File "$SRCDIR\public\fgdlib\gamedata.h"
+ $File "$SRCDIR\public\fgdlib\gdclass.h"
+ $File "$SRCDIR\public\fgdlib\gdvar.h"
+ $File "$SRCDIR\public\fgdlib\helperinfo.h"
+ $File "$SRCDIR\public\fgdlib\ieditortexture.h"
+ $File "$SRCDIR\public\fgdlib\inputoutput.h"
+ $File "$SRCDIR\public\fgdlib\wckeyvalues.h"
+ }
+}
diff --git a/mp/src/fgdlib/gamedata.cpp b/mp/src/fgdlib/gamedata.cpp
new file mode 100644
index 00000000..cd94b23d
--- /dev/null
+++ b/mp/src/fgdlib/gamedata.cpp
@@ -0,0 +1,886 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+#include <windows.h>
+#include <tier0/dbg.h>
+#include <io.h>
+#include <WorldSize.h>
+#include "fgdlib/GameData.h"
+#include "fgdlib/HelperInfo.h"
+#include "KeyValues.h"
+#include "filesystem_tools.h"
+#include "tier1/strtools.h"
+#include "utlmap.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgon.h"
+
+#pragma warning(disable:4244)
+
+
+const int MAX_ERRORS = 5;
+
+
+static GameDataMessageFunc_t g_pMsgFunc = NULL;
+
+
+//-----------------------------------------------------------------------------
+// Sets the function used for emitting error messages while loading gamedata files.
+//-----------------------------------------------------------------------------
+void GDSetMessageFunc(GameDataMessageFunc_t pFunc)
+{
+ g_pMsgFunc = pFunc;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Fetches the next token from the file.
+// Input : tr -
+// ppszStore - Destination buffer, one of the following:
+// pointer to NULL - token will be placed in an allocated buffer
+// pointer to non-NULL buffer - token will be placed in buffer
+// ttexpecting -
+// pszExpecting -
+// Output :
+//-----------------------------------------------------------------------------
+static bool DoGetToken(TokenReader &tr, char **ppszStore, int nSize, trtoken_t ttexpecting, const char *pszExpecting)
+{
+ trtoken_t ttype;
+
+ if (*ppszStore != NULL)
+ {
+ // Reads the token into the given buffer.
+ ttype = tr.NextToken(*ppszStore, nSize);
+ }
+ else
+ {
+ // Allocates a buffer to hold the token.
+ ttype = tr.NextTokenDynamic(ppszStore);
+ }
+
+ if (ttype == TOKENSTRINGTOOLONG)
+ {
+ GDError(tr, "unterminated string or string too long");
+ return false;
+ }
+
+ //
+ // Check for a bad token type.
+ //
+ char *pszStore = *ppszStore;
+ bool bBadTokenType = false;
+ if ((ttype != ttexpecting) && (ttexpecting != TOKENNONE))
+ {
+ //
+ // If we were expecting a string and got an integer, don't worry about it.
+ // We can translate from integer to string.
+ //
+ if (!((ttexpecting == STRING) && (ttype == INTEGER)))
+ {
+ bBadTokenType = true;
+ }
+ }
+
+ if (bBadTokenType && (pszExpecting == NULL))
+ {
+ //
+ // We didn't get the expected token type but no expected
+ // string was specified.
+ //
+ char *pszTokenName;
+ switch (ttexpecting)
+ {
+ case IDENT:
+ {
+ pszTokenName = "identifier";
+ break;
+ }
+
+ case INTEGER:
+ {
+ pszTokenName = "integer";
+ break;
+ }
+
+ case STRING:
+ {
+ pszTokenName = "string";
+ break;
+ }
+
+ case OPERATOR:
+ default:
+ {
+ pszTokenName = "symbol";
+ break;
+ }
+ }
+
+ GDError(tr, "expecting %s", pszTokenName);
+ return false;
+ }
+ else if (bBadTokenType || ((pszExpecting != NULL) && !IsToken(pszStore, pszExpecting)))
+ {
+ //
+ // An expected string was specified, and we got either the wrong type or
+ // the right type but the wrong string,
+ //
+ GDError(tr, "expecting '%s', but found '%s'", pszExpecting, pszStore);
+ return false;
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : tr -
+// error -
+// Output :
+//-----------------------------------------------------------------------------
+bool GDError(TokenReader &tr, const char *error, ...)
+{
+ char szBuf[128];
+ va_list vl;
+ va_start(vl, error);
+ vsprintf(szBuf, error, vl);
+ va_end(vl);
+
+ if (g_pMsgFunc)
+ {
+ // HACK: should use an enumeration for error level
+ g_pMsgFunc(1, tr.Error(szBuf));
+ }
+
+ if (tr.GetErrorCount() >= MAX_ERRORS)
+ {
+ if (g_pMsgFunc)
+ {
+ // HACK: should use an enumeration for error level
+ g_pMsgFunc(1, " - too many errors; aborting.");
+ }
+
+ return false;
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Fetches the next token from the file.
+// Input : tr - The token reader object with which to fetch the token.
+// pszStore - Buffer in which to place the token, NULL to discard the token.
+// ttexpecting - The token type that we are expecting. If this is not TOKENNONE
+// and token type read is different, the operation will fail.
+// pszExpecting - The token string that we are expecting. If this string
+// is not NULL and the token string read is different, the operation will fail.
+// Output : Returns TRUE if the operation succeeded, FALSE if there was an error.
+// If there was an error, the error will be reported in the message window.
+//-----------------------------------------------------------------------------
+bool GDGetToken(TokenReader &tr, char *pszStore, int nSize, trtoken_t ttexpecting, const char *pszExpecting)
+{
+ Assert(pszStore != NULL);
+ if (pszStore != NULL)
+ {
+ return DoGetToken(tr, &pszStore, nSize, ttexpecting, pszExpecting);
+ }
+
+ return false;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Fetches the next token from the file.
+// Input : tr - The token reader object with which to fetch the token.
+// pszStore - Buffer in which to place the token, NULL to discard the token.
+// ttexpecting - The token type that we are expecting. If this is not TOKENNONE
+// and token type read is different, the operation will fail.
+// pszExpecting - The token string that we are expecting. If this string
+// is not NULL and the token string read is different, the operation will fail.
+// Output : Returns TRUE if the operation succeeded, FALSE if there was an error.
+// If there was an error, the error will be reported in the message window.
+//-----------------------------------------------------------------------------
+bool GDSkipToken(TokenReader &tr, trtoken_t ttexpecting, const char *pszExpecting)
+{
+ //
+ // Read the next token into a buffer and discard it.
+ //
+ char szDiscardBuf[MAX_TOKEN];
+ char *pszDiscardBuf = szDiscardBuf;
+ return DoGetToken(tr, &pszDiscardBuf, sizeof(szDiscardBuf), ttexpecting, pszExpecting);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Fetches the next token from the file, allocating a buffer exactly
+// large enough to hold the token.
+// Input : tr -
+// ppszStore -
+// ttexpecting -
+// pszExpecting -
+// Output :
+//-----------------------------------------------------------------------------
+bool GDGetTokenDynamic(TokenReader &tr, char **ppszStore, trtoken_t ttexpecting, const char *pszExpecting)
+{
+ if (ppszStore == NULL)
+ {
+ return false;
+ }
+
+ *ppszStore = NULL;
+ return DoGetToken(tr, ppszStore, -1, ttexpecting, pszExpecting);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor.
+//-----------------------------------------------------------------------------
+GameData::GameData(void)
+{
+ m_nMaxMapCoord = 8192;
+ m_nMinMapCoord = -8192;
+ m_InstanceClass = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor.
+//-----------------------------------------------------------------------------
+GameData::~GameData(void)
+{
+ ClearData();
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void GameData::ClearData(void)
+{
+ // delete classes.
+ int nCount = m_Classes.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ GDclass *pm = m_Classes.Element(i);
+ delete pm;
+ }
+ m_Classes.RemoveAll();
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Loads a gamedata (FGD) file into this object.
+// Input : pszFilename -
+// Output : Returns TRUE on success, FALSE on failure.
+//-----------------------------------------------------------------------------
+BOOL GameData::Load(const char *pszFilename)
+{
+ TokenReader tr;
+
+ if(GetFileAttributes(pszFilename) == 0xffffffff)
+ return FALSE;
+
+ if(!tr.Open(pszFilename))
+ return FALSE;
+
+ trtoken_t ttype;
+ char szToken[128];
+
+ while (1)
+ {
+ if (tr.GetErrorCount() >= MAX_ERRORS)
+ {
+ break;
+ }
+
+ ttype = tr.NextToken(szToken, sizeof(szToken));
+
+ if(ttype == TOKENEOF)
+ break;
+
+ if(ttype != OPERATOR || !IsToken(szToken, "@"))
+ {
+ if(!GDError(tr, "expected @"))
+ return FALSE;
+ }
+
+ // check what kind it is, and parse a new object
+ if (tr.NextToken(szToken, sizeof(szToken)) != IDENT)
+ {
+ if(!GDError(tr, "expected identifier after @"))
+ return FALSE;
+ }
+
+ if (IsToken(szToken, "baseclass") || IsToken(szToken, "pointclass") || IsToken(szToken, "solidclass") || IsToken(szToken, "keyframeclass") ||
+ IsToken(szToken, "moveclass") || IsToken(szToken, "npcclass") || IsToken(szToken, "filterclass"))
+ {
+ //
+ // New class.
+ //
+ GDclass *pNewClass = new GDclass;
+ if (!pNewClass->InitFromTokens(tr, this))
+ {
+ tr.IgnoreTill(OPERATOR, "@"); // go to next section
+ delete pNewClass;
+ }
+ else
+ {
+ if (IsToken(szToken, "baseclass")) // Not directly available to user.
+ {
+ pNewClass->SetBaseClass(true);
+ }
+ else if (IsToken(szToken, "pointclass")) // Generic point class.
+ {
+ pNewClass->SetPointClass(true);
+ }
+ else if (IsToken(szToken, "solidclass")) // Tied to solids.
+ {
+ pNewClass->SetSolidClass(true);
+ }
+ else if (IsToken(szToken, "npcclass")) // NPC class - can be spawned by npc_maker.
+ {
+ pNewClass->SetPointClass(true);
+ pNewClass->SetNPCClass(true);
+ }
+ else if (IsToken(szToken, "filterclass")) // Filter class - can be used as a filter
+ {
+ pNewClass->SetPointClass(true);
+ pNewClass->SetFilterClass(true);
+ }
+ else if (IsToken(szToken, "moveclass")) // Animating
+ {
+ pNewClass->SetMoveClass(true);
+ pNewClass->SetPointClass(true);
+ }
+ else if (IsToken(szToken, "keyframeclass")) // Animation keyframes
+ {
+ pNewClass->SetKeyFrameClass(true);
+ pNewClass->SetPointClass(true);
+ }
+
+ // Check and see if this new class matches an existing one. If so we will override the previous definition.
+ int nExistingClassIndex = 0;
+ GDclass *pExistingClass = ClassForName(pNewClass->GetName(), &nExistingClassIndex);
+ if (NULL != pExistingClass)
+ {
+ m_Classes.InsertAfter(nExistingClassIndex, pNewClass);
+ m_Classes.Remove(nExistingClassIndex);
+ }
+ else
+ {
+ m_Classes.AddToTail(pNewClass);
+ }
+ }
+ }
+ else if (IsToken(szToken, "include"))
+ {
+ if (GDGetToken(tr, szToken, sizeof(szToken), STRING))
+ {
+ // Let's assume it's in the same directory.
+ char justPath[MAX_PATH], loadFilename[MAX_PATH];
+ if ( Q_ExtractFilePath( pszFilename, justPath, sizeof( justPath ) ) )
+ {
+ Q_snprintf( loadFilename, sizeof( loadFilename ), "%s%s", justPath, szToken );
+ }
+ else
+ {
+ Q_strncpy( loadFilename, szToken, sizeof( loadFilename ) );
+ }
+
+ // First try our fully specified directory
+ if (!Load(loadFilename))
+ {
+ // Failing that, try our start directory
+ if (!Load(szToken))
+ {
+ GDError(tr, "error including file: %s", szToken);
+ }
+ }
+ }
+ }
+ else if (IsToken(szToken, "mapsize"))
+ {
+ if (!ParseMapSize(tr))
+ {
+ // Error in map size specifier, skip to next @ sign.
+ tr.IgnoreTill(OPERATOR, "@");
+ }
+ }
+ else if ( IsToken( szToken, "materialexclusion" ) )
+ {
+ if ( !LoadFGDMaterialExclusions( tr ) )
+ {
+ // FGD exclusions not defined; skip to next @ sign.
+ tr.IgnoreTill(OPERATOR, "@");
+ }
+ }
+ else if ( IsToken( szToken, "autovisgroup" ) )
+ {
+ if ( !LoadFGDAutoVisGroups( tr ) )
+ {
+ // FGD AutoVisGroups not defined; skip to next @ sign.
+ tr.IgnoreTill(OPERATOR, "@");
+ }
+ }
+ else
+ {
+ GDError(tr, "unrecognized section name %s", szToken);
+ tr.IgnoreTill(OPERATOR, "@");
+ }
+ }
+
+ if (tr.GetErrorCount() > 0)
+ {
+ return FALSE;
+ }
+
+ tr.Close();
+
+ return TRUE;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Parses the "mapsize" specifier, which should be of the form:
+//
+// mapsize(min, max)
+//
+// ex: mapsize(-8192, 8192)
+//
+// Input : tr -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GameData::ParseMapSize(TokenReader &tr)
+{
+ if (!GDSkipToken(tr, OPERATOR, "("))
+ {
+ return false;
+ }
+
+ char szToken[128];
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return false;
+ }
+ int nMin = atoi(szToken);
+
+ if (!GDSkipToken(tr, OPERATOR, ","))
+ {
+ return false;
+ }
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return false;
+ }
+ int nMax = atoi(szToken);
+
+ if (nMin != nMax)
+ {
+ m_nMinMapCoord = min(nMin, nMax);
+ m_nMaxMapCoord = max(nMin, nMax);
+ }
+
+ if (!GDSkipToken(tr, OPERATOR, ")"))
+ {
+ return false;
+ }
+
+ return true;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : pszName -
+// piIndex -
+// Output :
+//-----------------------------------------------------------------------------
+GDclass *GameData::ClassForName(const char *pszName, int *piIndex)
+{
+ int nCount = m_Classes.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ GDclass *mp = m_Classes.Element(i);
+ if(!strcmp(mp->GetName(), pszName))
+ {
+ if(piIndex)
+ piIndex[0] = i;
+ return mp;
+ }
+ }
+
+ return NULL;
+}
+
+
+// These are 'standard' keys that every entity uses, but they aren't specified that way in the .fgd
+static const char *RequiredKeys[] =
+{
+ "Origin",
+ "Angles",
+ NULL
+};
+
+//-----------------------------------------------------------------------------
+// Purpose: this function will set up the initial class about to be instanced
+// Input : pszClassName - the class name of the entity to be instanced
+// pszInstancePrefix - the prefix to be used for all name fields
+// Origin - the origin offset of the instance
+// Angles - the angle rotation of the instance
+// Output : if successful, will return the game data class of the class name
+//-----------------------------------------------------------------------------
+GDclass *GameData::BeginInstanceRemap( const char *pszClassName, const char *pszInstancePrefix, Vector &Origin, QAngle &Angle )
+{
+ m_InstanceOrigin = Origin;
+ m_InstanceAngle = Angle;
+ AngleMatrix( m_InstanceAngle, m_InstanceOrigin, m_InstanceMat );
+
+ strcpy( m_InstancePrefix, pszInstancePrefix );
+
+ if ( m_InstanceClass )
+ {
+ delete m_InstanceClass;
+ m_InstanceClass = NULL;
+ }
+
+ if ( strcmpi( pszClassName, "info_overlay_accessor" ) == 0 )
+ { // yucky hack for a made up entity in the bsp process
+ pszClassName = "info_overlay";
+ }
+
+ GDclass *BaseClass = ClassForName( pszClassName );
+ if ( BaseClass )
+ {
+ m_InstanceClass = new GDclass();
+ m_InstanceClass->Parent = this;
+ m_InstanceClass->AddBase( BaseClass );
+
+ for( int i = 0; RequiredKeys[ i ]; i++ )
+ {
+ if ( m_InstanceClass->VarForName( RequiredKeys[ i ] ) == NULL )
+ {
+ BaseClass = ClassForName( RequiredKeys[ i ] );
+ if ( BaseClass )
+ {
+ m_InstanceClass->AddBase( BaseClass );
+ }
+ }
+ }
+ }
+ else
+ {
+ m_InstanceClass = NULL;
+ }
+
+ return m_InstanceClass;
+}
+
+
+enum tRemapOperation
+{
+ REMAP_NAME = 0,
+ REMAP_POSITION,
+ REMAP_ANGLE,
+ REMAP_ANGLE_NEGATIVE_PITCH,
+};
+
+
+static CUtlMap< GDIV_TYPE, tRemapOperation > RemapOperation;
+
+
+//-----------------------------------------------------------------------------
+// Purpose: function to sort the class type for the RemapOperations map
+// Input : type1 - the first type to compare against
+// type2 - the second type to compare against
+// Output : returns true if the first type is less than the second one
+//-----------------------------------------------------------------------------
+static bool CUtlType_LessThan( const GDIV_TYPE &type1, const GDIV_TYPE &type2 )
+{
+ return ( type1 < type2 );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: this function will attempt to remap a key's value
+// Input : pszKey - the name of the key
+// pszInvalue - the original value
+// AllowNameRemapping - only do name remapping if this parameter is true.
+// this is generally only false on the instance level.
+// Output : returns true if the value changed
+// pszOutValue - the new value if changed
+//-----------------------------------------------------------------------------
+bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *pszOutValue, TNameFixup NameFixup )
+{
+ if ( RemapOperation.Count() == 0 )
+ {
+ RemapOperation.SetLessFunc( &CUtlType_LessThan );
+ RemapOperation.Insert( ivAngle, REMAP_ANGLE );
+ RemapOperation.Insert( ivTargetDest, REMAP_NAME );
+ RemapOperation.Insert( ivTargetSrc, REMAP_NAME );
+ RemapOperation.Insert( ivOrigin, REMAP_POSITION );
+ RemapOperation.Insert( ivAxis, REMAP_ANGLE );
+ RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
+ }
+
+ if ( !m_InstanceClass )
+ {
+ return false;
+ }
+
+ GDinputvariable *KVVar = m_InstanceClass->VarForName( pszKey );
+ if ( !KVVar )
+ {
+ return false;
+ }
+
+ GDIV_TYPE KVType = KVVar->GetType();
+ int KVRemapIndex = RemapOperation.Find( KVType );
+ if ( KVRemapIndex == RemapOperation.InvalidIndex() )
+ {
+ return false;
+ }
+
+ strcpy( pszOutValue, pszInValue );
+
+ switch( RemapOperation[ KVRemapIndex ] )
+ {
+ case REMAP_NAME:
+ if ( KVType != ivInstanceVariable )
+ {
+ RemapNameField( pszInValue, pszOutValue, NameFixup );
+ }
+ break;
+
+ case REMAP_POSITION:
+ {
+ Vector inPoint( 0.0f, 0.0f, 0.0f ), outPoint;
+
+ sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z );
+ VectorTransform( inPoint, m_InstanceMat, outPoint );
+ sprintf( pszOutValue, "%g %g %g", outPoint.x, outPoint.y, outPoint.z );
+ }
+ break;
+
+ case REMAP_ANGLE:
+ if ( m_InstanceAngle.x != 0.0f || m_InstanceAngle.y != 0.0f || m_InstanceAngle.z != 0.0f )
+ {
+ QAngle inAngles( 0.0f, 0.0f, 0.0f ), outAngles;
+ matrix3x4_t angToWorld, localMatrix;
+
+ sscanf ( pszInValue, "%f %f %f", &inAngles.x, &inAngles.y, &inAngles.z );
+
+ AngleMatrix( inAngles, angToWorld );
+ MatrixMultiply( m_InstanceMat, angToWorld, localMatrix );
+ MatrixAngles( localMatrix, outAngles );
+
+ sprintf( pszOutValue, "%g %g %g", outAngles.x, outAngles.y, outAngles.z );
+ }
+ break;
+
+ case REMAP_ANGLE_NEGATIVE_PITCH:
+ if ( m_InstanceAngle.x != 0.0f || m_InstanceAngle.y != 0.0f || m_InstanceAngle.z != 0.0f )
+ {
+ QAngle inAngles( 0.0f, 0.0f, 0.0f ), outAngles;
+ matrix3x4_t angToWorld, localMatrix;
+
+ sscanf ( pszInValue, "%f", &inAngles.x ); // just the pitch
+ inAngles.x = -inAngles.x;
+
+ AngleMatrix( inAngles, angToWorld );
+ MatrixMultiply( m_InstanceMat, angToWorld, localMatrix );
+ MatrixAngles( localMatrix, outAngles );
+
+ sprintf( pszOutValue, "%g", -outAngles.x ); // just the pitch
+ }
+ break;
+ }
+
+ return ( strcmpi( pszInValue, pszOutValue ) != 0 );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: this function will attempt to remap a name field.
+// Input : pszInvalue - the original value
+// AllowNameRemapping - only do name remapping if this parameter is true.
+// this is generally only false on the instance level.
+// Output : returns true if the value changed
+// pszOutValue - the new value if changed
+//-----------------------------------------------------------------------------
+bool GameData::RemapNameField( const char *pszInValue, char *pszOutValue, TNameFixup NameFixup )
+{
+ strcpy( pszOutValue, pszInValue );
+
+ if ( pszInValue[ 0 ] && pszInValue[ 0 ] != '@' )
+ { // ! at the start of a value means it is global and should not be remaped
+ switch( NameFixup )
+ {
+ case NAME_FIXUP_PREFIX:
+ sprintf( pszOutValue, "%s-%s", m_InstancePrefix, pszInValue );
+ break;
+
+ case NAME_FIXUP_POSTFIX:
+ sprintf( pszOutValue, "%s-%s", pszInValue, m_InstancePrefix );
+ break;
+ }
+ }
+
+ return ( strcmpi( pszInValue, pszOutValue ) != 0 );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Gathers any FGD-defined material directory exclusions
+// Input :
+// Output :
+//-----------------------------------------------------------------------------
+bool GameData::LoadFGDMaterialExclusions( TokenReader &tr )
+{
+ if ( !GDSkipToken( tr, OPERATOR, "[" ) )
+ {
+ return false;
+ }
+ while ( 1 )
+ {
+ char szToken[128];
+ bool bMatchFound = false;
+
+ if ( tr.PeekTokenType( szToken, sizeof( szToken ) ) == OPERATOR )
+ {
+ break;
+ }
+ else if ( GDGetToken( tr, szToken, sizeof( szToken ), STRING ) )
+ {
+ // Make sure we haven't loaded this from another FGD
+ for ( int i = 0; i < m_FGDMaterialExclusions.Count(); i++ )
+ {
+ if ( !stricmp( szToken, m_FGDMaterialExclusions[i].szDirectory ) )
+ {
+ bMatchFound = true;
+ break;
+ }
+ }
+
+ // Parse the string
+ if ( bMatchFound == false )
+ {
+ int index = m_FGDMaterialExclusions.AddToTail();
+ Q_strncpy( m_FGDMaterialExclusions[index].szDirectory, szToken, sizeof( m_FGDMaterialExclusions[index].szDirectory ) );
+ m_FGDMaterialExclusions[index].bUserGenerated = false;
+ }
+ }
+ }
+
+ //
+ // Closing square brace.
+ //
+ if ( !GDSkipToken( tr, OPERATOR, "]" ) )
+ {
+ return( FALSE );
+ }
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Gathers any FGD-defined Auto VisGroups
+// Input :
+// Output :
+//-----------------------------------------------------------------------------
+bool GameData::LoadFGDAutoVisGroups( TokenReader &tr )
+{
+ int gindex = 0; // Index of AutoVisGroups
+ int cindex = 0; // Index of Classes
+
+ char szToken[128];
+
+ // Handle the Parent -- World Geometry, Entities, World Detail
+ if ( GDSkipToken( tr, OPERATOR, "=" ) )
+ {
+ // We expect a name
+ if ( !GDGetToken( tr, szToken, sizeof( szToken ), STRING ) )
+ {
+ return( FALSE );
+ }
+
+ gindex = m_FGDAutoVisGroups.AddToTail();
+ Q_strncpy( m_FGDAutoVisGroups[gindex].szParent, szToken, sizeof( m_FGDAutoVisGroups[gindex].szParent ) );
+
+ // We expect a Class
+ if ( !GDSkipToken( tr, OPERATOR, "[" ) )
+ {
+ return( FALSE );
+ }
+ }
+
+ // Handle the Class(es) -- Brush Entities, Occluders, Lights
+ while ( 1 )
+ {
+ if ( GDGetToken( tr, szToken, sizeof( szToken ), STRING ) )
+ {
+ cindex = m_FGDAutoVisGroups[gindex].m_Classes.AddToTail();
+ Q_strncpy( m_FGDAutoVisGroups[gindex].m_Classes[cindex].szClass, szToken, sizeof( m_FGDAutoVisGroups[gindex].m_Classes[cindex].szClass ) );
+
+ if ( !GDSkipToken( tr, OPERATOR, "[" ) )
+ {
+ return( FALSE );
+ }
+
+ // Parse objects/entities -- func_detail, point_template, light_spot
+ while ( 1 )
+ {
+ if ( tr.PeekTokenType( szToken, sizeof( szToken ) ) == OPERATOR )
+ {
+ break;
+ }
+
+ if ( !GDGetToken( tr, szToken, sizeof( szToken ), STRING ) )
+ {
+ return( FALSE );
+ }
+
+ m_FGDAutoVisGroups[gindex].m_Classes[cindex].szEntities.CopyAndAddToTail( szToken );
+
+ }
+
+ if ( !GDSkipToken( tr, OPERATOR, "]" ) )
+ {
+ return( FALSE );
+ }
+
+ // See if we have another Class coming up
+ if ( tr.PeekTokenType( szToken, sizeof( szToken ) ) == STRING )
+ {
+ continue;
+ }
+
+ // If no more Classes, we now expect a terminating ']'
+ if ( !GDSkipToken( tr, OPERATOR, "]" ) )
+ {
+ return( FALSE );
+ }
+
+ // We're done
+ return true;
+ }
+ // We don't have another Class; look for a terminating brace
+ else
+ {
+ if ( !GDSkipToken( tr, OPERATOR, "]" ) )
+ {
+ return( FALSE );
+ }
+ }
+ }
+
+ // Safety net
+ GDError( tr, "Malformed AutoVisGroup -- Last processed: %s", szToken );
+ return( FALSE );
+}
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include "tier0/memdbgoff.h"
diff --git a/mp/src/fgdlib/gdclass.cpp b/mp/src/fgdlib/gdclass.cpp
new file mode 100644
index 00000000..be07610e
--- /dev/null
+++ b/mp/src/fgdlib/gdclass.cpp
@@ -0,0 +1,1041 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#include "fgdlib/GameData.h" // FGDLIB: eliminate dependency
+#include "fgdlib/GDClass.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor.
+//-----------------------------------------------------------------------------
+GDclass::GDclass(void)
+{
+ m_nVariables = 0;
+ m_bBase = false;
+ m_bSolid = false;
+ m_bBase = false;
+ m_bSolid = false;
+ m_bModel = false;
+ m_bMove = false;
+ m_bKeyFrame = false;
+ m_bPoint = false;
+ m_bNPC = false;
+ m_bFilter = false;
+
+ m_bHalfGridSnap = false;
+
+ m_bGotSize = false;
+ m_bGotColor = false;
+
+ m_rgbColor.r = 220;
+ m_rgbColor.g = 30;
+ m_rgbColor.b = 220;
+ m_rgbColor.a = 0;
+
+ m_pszDescription = NULL;
+
+ for (int i = 0; i < 3; i++)
+ {
+ m_bmins[i] = -8;
+ m_bmaxs[i] = 8;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor. Frees variable and helper lists.
+//-----------------------------------------------------------------------------
+GDclass::~GDclass(void)
+{
+ //
+ // Free variables.
+ //
+ int nCount = m_Variables.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ GDinputvariable *pvi = m_Variables.Element(i);
+ delete pvi;
+ }
+ m_Variables.RemoveAll();
+
+ //
+ // Free helpers.
+ //
+ nCount = m_Helpers.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ CHelperInfo *pHelper = m_Helpers.Element(i);
+ delete pHelper;
+ }
+ m_Helpers.RemoveAll();
+
+ //
+ // Free inputs.
+ //
+ nCount = m_Inputs.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ CClassInput *pInput = m_Inputs.Element(i);
+ delete pInput;
+ }
+ m_Inputs.RemoveAll();
+
+ //
+ // Free outputs.
+ //
+ nCount = m_Outputs.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ CClassOutput *pOutput = m_Outputs.Element(i);
+ delete pOutput;
+ }
+ m_Outputs.RemoveAll();
+
+ delete m_pszDescription;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Adds the base class's variables to our variable list. Acquires the
+// base class's bounding box and color, if any.
+// Input : pszBase - Name of base class to add.
+//-----------------------------------------------------------------------------
+void GDclass::AddBase(GDclass *pBase)
+{
+ int iBaseIndex;
+ Parent->ClassForName(pBase->GetName(), &iBaseIndex);
+
+ //
+ // Add variables from base - update variable table
+ //
+ for (int i = 0; i < pBase->GetVariableCount(); i++)
+ {
+ GDinputvariable *pVar = pBase->GetVariableAt(i);
+ AddVariable(pVar, pBase, iBaseIndex, i);
+ }
+
+ //
+ // Add inputs from the base.
+ // UNDONE: need to use references to inputs & outputs to conserve memory
+ //
+ int nCount = pBase->GetInputCount();
+ for (int i = 0; i < nCount; i++)
+ {
+ CClassInput *pInput = pBase->GetInput(i);
+
+ CClassInput *pNew = new CClassInput;
+ *pNew = *pInput;
+ AddInput(pNew);
+ }
+
+ //
+ // Add outputs from the base.
+ //
+ nCount = pBase->GetOutputCount();
+ for (int i = 0; i < nCount; i++)
+ {
+ CClassOutput *pOutput = pBase->GetOutput(i);
+
+ CClassOutput *pNew = new CClassOutput;
+ *pNew = *pOutput;
+ AddOutput(pNew);
+ }
+
+ //
+ // If we don't have a bounding box, try to get the base's box.
+ //
+ if (!m_bGotSize)
+ {
+ if (pBase->GetBoundBox(m_bmins, m_bmaxs))
+ {
+ m_bGotSize = true;
+ }
+ }
+
+ //
+ // If we don't have a color, use the base's color.
+ //
+ if (!m_bGotColor)
+ {
+ m_rgbColor = pBase->GetColor();
+ m_bGotColor = true;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Adds the given GDInputVariable to this GDClass's list of variables.
+// Input : pVar -
+// pBase -
+// iBaseIndex -
+// iVarIndex -
+// Output : Returns TRUE if the pVar pointer was copied directly into this GDClass,
+// FALSE if not. If this function returns TRUE, pVar should not be
+// deleted by the caller.
+//-----------------------------------------------------------------------------
+BOOL GDclass::AddVariable(GDinputvariable *pVar, GDclass *pBase, int iBaseIndex, int iVarIndex)
+{
+ int iThisIndex;
+ GDinputvariable *pThisVar = VarForName(pVar->GetName(), &iThisIndex);
+
+ //
+ // Check to see if we are overriding an existing variable definition.
+ //
+ if (pThisVar != NULL)
+ {
+ //
+ // Same name, different type. Flag this as an error.
+ //
+ if (pThisVar->GetType() != pVar->GetType())
+ {
+ return(false);
+ }
+
+ GDinputvariable *pAddVar;
+ bool bReturn;
+
+ //
+ // Check to see if we need to combine a choices/flags array.
+ //
+ if (pVar->GetType() == ivFlags || pVar->GetType() == ivChoices)
+ {
+ //
+ // Combine two variables' flags into a new variable. Add the new
+ // variable to the local variable list and modify the old variable's
+ // position in our variable map to reflect the new local variable.
+ // This way, we can have multiple inheritance.
+ //
+ GDinputvariable *pNewVar = new GDinputvariable;
+
+ *pNewVar = *pVar;
+ pNewVar->Merge(*pThisVar);
+
+ pAddVar = pNewVar;
+ bReturn = false;
+ }
+ else
+ {
+ pAddVar = pVar;
+ bReturn = true;
+ }
+
+ if (m_VariableMap[iThisIndex][0] == -1)
+ {
+ //
+ // "pThisVar" is a leaf variable - we can remove since it is overridden.
+ //
+ int nIndex = m_Variables.Find(pThisVar);
+ Assert(nIndex != -1);
+ delete pThisVar;
+
+ m_Variables.Element(nIndex) = pAddVar;
+
+ //
+ // No need to modify variable map - we just replaced
+ // the pointer in the local variable list.
+ //
+ }
+ else
+ {
+ //
+ // "pThisVar" was declared in a base class - we can replace the reference in
+ // our variable map with the new variable.
+ //
+ m_VariableMap[iThisIndex][0] = iBaseIndex;
+
+ if (iBaseIndex == -1)
+ {
+ m_Variables.AddToTail(pAddVar);
+ m_VariableMap[iThisIndex][1] = m_Variables.Count() - 1;
+ }
+ else
+ {
+ m_VariableMap[iThisIndex][1] = iVarIndex;
+ }
+ }
+
+ return(bReturn);
+ }
+
+ //
+ // New variable.
+ //
+ if (iBaseIndex == -1)
+ {
+ //
+ // Variable declared in the leaf class definition - add it to the list.
+ //
+ m_Variables.AddToTail(pVar);
+ }
+
+ //
+ // Too many variables already declared in this class definition - abort.
+ //
+ if (m_nVariables == GD_MAX_VARIABLES)
+ {
+ //CUtlString str;
+ //str.Format("Too many gamedata variables for class \"%s\"", m_szName);
+ //AfxMessageBox(str);
+
+ return(false);
+ }
+
+ //
+ // Add the variable to our list.
+ //
+ m_VariableMap[m_nVariables][0] = iBaseIndex;
+ m_VariableMap[m_nVariables][1] = iVarIndex;
+ ++m_nVariables;
+
+ //
+ // We added the pointer to our list of items (see Variables.AddToTail, above) so
+ // we must return true here.
+ //
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Finds an input by name.
+//-----------------------------------------------------------------------------
+CClassInput *GDclass::FindInput(const char *szName)
+{
+ int nCount = GetInputCount();
+ for (int i = 0; i < nCount; i++)
+ {
+ CClassInput *pInput = GetInput(i);
+ if (!stricmp(pInput->GetName(), szName))
+ {
+ return(pInput);
+ }
+ }
+
+ return(NULL);
+}
+
+
+//-----------------------------------------------------------------------------
+// Finds an output by name.
+//-----------------------------------------------------------------------------
+CClassOutput *GDclass::FindOutput(const char *szName)
+{
+ int nCount = GetOutputCount();
+ for (int i = 0; i < nCount; i++)
+ {
+ CClassOutput *pOutput = GetOutput(i);
+ if (!stricmp(pOutput->GetName(), szName))
+ {
+ return(pOutput);
+ }
+ }
+
+ return(NULL);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Gets the mins and maxs of the class's bounding box as read from the
+// FGD file. This controls the onscreen representation of any entities
+// derived from this class.
+// Input : pfMins - Receives minimum X, Y, and Z coordinates for the class.
+// pfMaxs - Receives maximum X, Y, and Z coordinates for the class.
+// Output : Returns TRUE if this class has a specified bounding box, FALSE if not.
+//-----------------------------------------------------------------------------
+BOOL GDclass::GetBoundBox(Vector& pfMins, Vector& pfMaxs)
+{
+ if (m_bGotSize)
+ {
+ pfMins[0] = m_bmins[0];
+ pfMins[1] = m_bmins[1];
+ pfMins[2] = m_bmins[2];
+
+ pfMaxs[0] = m_bmaxs[0];
+ pfMaxs[1] = m_bmaxs[1];
+ pfMaxs[2] = m_bmaxs[2];
+ }
+
+ return(m_bGotSize);
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+CHelperInfo *GDclass::GetHelper(int nIndex)
+{
+ return m_Helpers.Element(nIndex);
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+CClassInput *GDclass::GetInput(int nIndex)
+{
+ return m_Inputs.Element(nIndex);
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+CClassOutput *GDclass::GetOutput(int nIndex)
+{
+ return m_Outputs.Element(nIndex);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : tr -
+// pGD -
+// Output : Returns TRUE if worth continuing, FALSE otherwise.
+//-----------------------------------------------------------------------------
+BOOL GDclass::InitFromTokens(TokenReader& tr, GameData *pGD)
+{
+ Parent = pGD;
+
+ //
+ // Initialize VariableMap
+ //
+ for (int i = 0; i < GD_MAX_VARIABLES; i++)
+ {
+ m_VariableMap[i][0] = -1;
+ m_VariableMap[i][1] = -1;
+ }
+
+ //
+ // Parse all specifiers (base, size, color, etc.)
+ //
+ if (!ParseSpecifiers(tr))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Specifiers should be followed by an "="
+ //
+ if (!GDSkipToken(tr, OPERATOR, "="))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Parse the class name.
+ //
+ if (!GDGetToken(tr, m_szName, sizeof(m_szName), IDENT))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Check next operator - if ":", we have a description - if "[",
+ // we have no description.
+ //
+ char szToken[MAX_TOKEN];
+ if ((tr.PeekTokenType(szToken,sizeof(szToken)) == OPERATOR) && IsToken(szToken, ":"))
+ {
+ // Skip ":"
+ tr.NextToken(szToken, sizeof(szToken));
+
+ //
+ // Free any existing description and set the pointer to NULL so that GDGetToken
+ // allocates memory for us.
+ //
+ delete m_pszDescription;
+ m_pszDescription = NULL;
+
+ // Load description
+ if (!GDGetTokenDynamic(tr, &m_pszDescription, STRING))
+ {
+ return(FALSE);
+ }
+ }
+
+ //
+ // Opening square brace.
+ //
+ if (!GDSkipToken(tr, OPERATOR, "["))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Get class variables.
+ //
+ if (!ParseVariables(tr))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Closing square brace.
+ //
+ if (!GDSkipToken(tr, OPERATOR, "]"))
+ {
+ return(FALSE);
+ }
+
+ return(TRUE);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : &tr -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseBase(TokenReader &tr)
+{
+ char szToken[MAX_TOKEN];
+
+ while (1)
+ {
+ if (!GDGetToken(tr, szToken, sizeof(szToken), IDENT))
+ {
+ return(false);
+ }
+
+ //
+ // Find base class in list of classes.
+ //
+ GDclass *pBase = Parent->ClassForName(szToken);
+ if (pBase == NULL)
+ {
+ GDError(tr, "undefined base class '%s", szToken);
+ return(false);
+ }
+
+ AddBase(pBase);
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), OPERATOR))
+ {
+ return(false);
+ }
+
+ if (IsToken(szToken, ")"))
+ {
+ break;
+ }
+ else if (!IsToken(szToken, ","))
+ {
+ GDError(tr, "expecting ',' or ')', but found %s", szToken);
+ return(false);
+ }
+ }
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : &tr -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseColor(TokenReader &tr)
+{
+ char szToken[MAX_TOKEN];
+
+ //
+ // Red.
+ //
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return(false);
+ }
+ BYTE r = atoi(szToken);
+
+ //
+ // Green.
+ //
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return(false);
+ }
+ BYTE g = atoi(szToken);
+
+ //
+ // Blue.
+ //
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return(false);
+ }
+ BYTE b = atoi(szToken);
+
+ m_rgbColor.r = r;
+ m_rgbColor.g = g;
+ m_rgbColor.b = b;
+ m_rgbColor.a = 0;
+
+ m_bGotColor = true;
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), OPERATOR, ")"))
+ {
+ return(false);
+ }
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Parses a helper from the FGD file. Helpers are of the following format:
+//
+// <helpername>(<parameter 0> <parameter 1> ... <parameter n>)
+//
+// When this function is called, the helper name has already been parsed.
+// Input : tr - Tokenreader to use for parsing.
+// pszHelperName - Name of the helper being declared.
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseHelper(TokenReader &tr, char *pszHelperName)
+{
+ char szToken[MAX_TOKEN];
+
+ CHelperInfo *pHelper = new CHelperInfo;
+ pHelper->SetName(pszHelperName);
+
+ bool bCloseParen = false;
+ while (!bCloseParen)
+ {
+ trtoken_t eType = tr.PeekTokenType(szToken,sizeof(szToken));
+
+ if (eType == OPERATOR)
+ {
+ if (!GDGetToken(tr, szToken, sizeof(szToken), OPERATOR))
+ {
+ delete pHelper;
+ return(false);
+ }
+
+ if (IsToken(szToken, ")"))
+ {
+ bCloseParen = true;
+ }
+ else if (IsToken(szToken, "="))
+ {
+ delete pHelper;
+ return(false);
+ }
+ }
+ else
+ {
+ if (!GDGetToken(tr, szToken, sizeof(szToken), eType))
+ {
+ delete pHelper;
+ return(false);
+ }
+ else
+ {
+ pHelper->AddParameter(szToken);
+ }
+ }
+ }
+
+ m_Helpers.AddToTail(pHelper);
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : &tr -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseSize(TokenReader &tr)
+{
+ char szToken[MAX_TOKEN];
+
+ //
+ // Mins.
+ //
+ for (int i = 0; i < 3; i++)
+ {
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return(false);
+ }
+
+ m_bmins[i] = (float)atof(szToken);
+ }
+
+ if (tr.PeekTokenType(szToken,sizeof(szToken)) == OPERATOR && IsToken(szToken, ","))
+ {
+ //
+ // Skip ","
+ //
+ tr.NextToken(szToken, sizeof(szToken));
+
+ //
+ // Get maxes.
+ //
+ for (int i = 0; i < 3; i++)
+ {
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return(false);
+ }
+ m_bmaxs[i] = (float)atof(szToken);
+ }
+ }
+ else
+ {
+ //
+ // Split mins across origin.
+ //
+ for (int i = 0; i < 3; i++)
+ {
+ float div2 = m_bmins[i] / 2;
+ m_bmaxs[i] = div2;
+ m_bmins[i] = -div2;
+ }
+ }
+
+ m_bGotSize = true;
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), OPERATOR, ")"))
+ {
+ return(false);
+ }
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : &tr -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseSpecifiers(TokenReader &tr)
+{
+ char szToken[MAX_TOKEN];
+
+ while (tr.PeekTokenType() == IDENT)
+ {
+ tr.NextToken(szToken, sizeof(szToken));
+
+ //
+ // Handle specifiers that don't have any parens after them.
+ //
+ if (IsToken(szToken, "halfgridsnap"))
+ {
+ m_bHalfGridSnap = true;
+ }
+ else
+ {
+ //
+ // Handle specifiers require parens after them.
+ //
+ if (!GDSkipToken(tr, OPERATOR, "("))
+ {
+ return(false);
+ }
+
+ if (IsToken(szToken, "base"))
+ {
+ if (!ParseBase(tr))
+ {
+ return(false);
+ }
+ }
+ else if (IsToken(szToken, "size"))
+ {
+ if (!ParseSize(tr))
+ {
+ return(false);
+ }
+ }
+ else if (IsToken(szToken, "color"))
+ {
+ if (!ParseColor(tr))
+ {
+ return(false);
+ }
+ }
+ else if (!ParseHelper(tr, szToken))
+ {
+ return(false);
+ }
+ }
+ }
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Reads an input using a given token reader. If the input is
+// read successfully, the input is added to this class. If not, a
+// parsing failure is returned.
+// Input : tr - Token reader to use for parsing.
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseInput(TokenReader &tr)
+{
+ char szToken[MAX_TOKEN];
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), IDENT, "input"))
+ {
+ return(false);
+ }
+
+ CClassInput *pInput = new CClassInput;
+
+ bool bReturn = ParseInputOutput(tr, pInput);
+ if (bReturn)
+ {
+ AddInput(pInput);
+ }
+ else
+ {
+ delete pInput;
+ }
+
+ return(bReturn);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Reads an input or output using a given token reader.
+// Input : tr - Token reader to use for parsing.
+// pInputOutput - Input or output to fill out.
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseInputOutput(TokenReader &tr, CClassInputOutputBase *pInputOutput)
+{
+ char szToken[MAX_TOKEN];
+
+ //
+ // Read the name.
+ //
+ if (!GDGetToken(tr, szToken, sizeof(szToken), IDENT))
+ {
+ return(false);
+ }
+
+ pInputOutput->SetName(szToken);
+
+ //
+ // Read the type.
+ //
+ if (!GDGetToken(tr, szToken, sizeof(szToken), OPERATOR, "("))
+ {
+ return(false);
+ }
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), IDENT))
+ {
+ return(false);
+ }
+
+ InputOutputType_t eType = pInputOutput->SetType(szToken);
+ if (eType == iotInvalid)
+ {
+ GDError(tr, "bad input/output type '%s'", szToken);
+ return(false);
+ }
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), OPERATOR, ")"))
+ {
+ return(false);
+ }
+
+ //
+ // Check the next operator - if ':', we have a description.
+ //
+ if ((tr.PeekTokenType(szToken,sizeof(szToken)) == OPERATOR) && (IsToken(szToken, ":")))
+ {
+ //
+ // Skip the ":".
+ //
+ tr.NextToken(szToken, sizeof(szToken));
+
+ //
+ // Read the description.
+ //
+ char *pszDescription;
+ if (!GDGetTokenDynamic(tr, &pszDescription, STRING))
+ {
+ return(false);
+ }
+
+ pInputOutput->SetDescription(pszDescription);
+ }
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Reads an output using a given token reader. If the output is
+// read successfully, the output is added to this class. If not, a
+// parsing failure is returned.
+// Input : tr - Token reader to use for parsing.
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseOutput(TokenReader &tr)
+{
+ char szToken[MAX_TOKEN];
+
+ if (!GDGetToken(tr, szToken, sizeof(szToken), IDENT, "output"))
+ {
+ return(false);
+ }
+
+ CClassOutput *pOutput = new CClassOutput;
+
+ bool bReturn = ParseInputOutput(tr, pOutput);
+ if (bReturn)
+ {
+ AddOutput(pOutput);
+ }
+ else
+ {
+ delete pOutput;
+ }
+
+ return(bReturn);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : &tr -
+// Output : Returns true on success, false on failure.
+//-----------------------------------------------------------------------------
+bool GDclass::ParseVariables(TokenReader &tr)
+{
+ while (1)
+ {
+ char szToken[MAX_TOKEN];
+
+ if (tr.PeekTokenType(szToken,sizeof(szToken)) == OPERATOR)
+ {
+ break;
+ }
+
+ if (!stricmp(szToken, "input"))
+ {
+ if (!ParseInput(tr))
+ {
+ return(false);
+ }
+
+ continue;
+ }
+
+ if (!stricmp(szToken, "output"))
+ {
+ if (!ParseOutput(tr))
+ {
+ return(false);
+ }
+
+ continue;
+ }
+
+ if (!stricmp(szToken, "key"))
+ {
+ GDGetToken(tr, szToken, sizeof(szToken));
+ }
+
+ GDinputvariable * var = new GDinputvariable;
+ if (!var->InitFromTokens(tr))
+ {
+ delete var;
+ return(false);
+ }
+
+ int nDupIndex;
+ GDinputvariable *pDupVar = VarForName(var->GetName(), &nDupIndex);
+
+ // check for duplicate variable definitions
+ if (pDupVar)
+ {
+ // Same name, different type.
+ if (pDupVar->GetType() != var->GetType())
+ {
+ char szError[_MAX_PATH];
+
+ sprintf(szError, "%s: Variable '%s' is multiply defined with different types.", GetName(), var->GetName());
+ GDError(tr, szError);
+ }
+ }
+
+ if (!AddVariable(var, this, -1, m_Variables.Count()))
+ {
+ delete var;
+ }
+ }
+
+ return(true);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : iIndex -
+// Output : GDinputvariable *
+//-----------------------------------------------------------------------------
+GDinputvariable *GDclass::GetVariableAt(int iIndex)
+{
+ if ( iIndex < 0 || iIndex >= m_nVariables )
+ return NULL;
+
+ if (m_VariableMap[iIndex][0] == -1)
+ {
+ return m_Variables.Element(m_VariableMap[iIndex][1]);
+ }
+
+ // find var's owner
+ GDclass *pVarClass = Parent->GetClass(m_VariableMap[iIndex][0]);
+
+ // find var in pVarClass
+ return pVarClass->GetVariableAt(m_VariableMap[iIndex][1]);
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+GDinputvariable *GDclass::VarForName(const char *pszName, int *piIndex)
+{
+ for(int i = 0; i < GetVariableCount(); i++)
+ {
+ GDinputvariable *pVar = GetVariableAt(i);
+ if(!strcmpi(pVar->GetName(), pszName))
+ {
+ if(piIndex)
+ piIndex[0] = i;
+ return pVar;
+ }
+ }
+
+ return NULL;
+}
+
+void GDclass::GetHelperForGDVar( GDinputvariable *pVar, CUtlVector<const char *> *pszHelperName )
+{
+ const char *pszName = pVar->GetName();
+ for( int i = 0; i < GetHelperCount(); i++ )
+ {
+ CHelperInfo *pHelper = GetHelper( i );
+ int nParamCount = pHelper->GetParameterCount();
+ for ( int j = 0; j < nParamCount; j++ )
+ {
+ if ( !strcmpi( pszName, pHelper->GetParameter( j ) ) )
+ {
+ pszHelperName->AddToTail(pHelper->GetName());
+ }
+ }
+ }
+}
+
+
+
diff --git a/mp/src/fgdlib/gdvar.cpp b/mp/src/fgdlib/gdvar.cpp
new file mode 100644
index 00000000..5b9a21be
--- /dev/null
+++ b/mp/src/fgdlib/gdvar.cpp
@@ -0,0 +1,729 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+//=============================================================================
+
+#include "fgdlib/fgdlib.h"
+#include "fgdlib/GameData.h"
+#include "fgdlib/WCKeyValues.h"
+#include "fgdlib/gdvar.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+
+typedef struct
+{
+ GDIV_TYPE eType; // The enumeration of this type.
+ char *pszName; // The name of this type.
+ trtoken_t eStoreAs; // How this type is stored (STRING, INTEGER, etc).
+} TypeMap_t;
+
+
+//-----------------------------------------------------------------------------
+// Maps type names to type enums and parsing logic for values.
+//-----------------------------------------------------------------------------
+static TypeMap_t TypeMap[] =
+{
+ { ivAngle, "angle", STRING },
+ { ivChoices, "choices", STRING },
+ { ivColor1, "color1", STRING },
+ { ivColor255, "color255", STRING },
+ { ivDecal, "decal", STRING },
+ { ivFlags, "flags", INTEGER },
+ { ivInteger, "integer", INTEGER },
+ { ivSound, "sound", STRING },
+ { ivSprite, "sprite", STRING },
+ { ivString, "string", STRING },
+ { ivStudioModel, "studio", STRING },
+ { ivTargetDest, "target_destination", STRING },
+ { ivTargetSrc, "target_source", STRING },
+ { ivTargetNameOrClass, "target_name_or_class", STRING }, // Another version of target_destination that accepts class names
+ { ivVector, "vector", STRING },
+ { ivNPCClass, "npcclass", STRING },
+ { ivFilterClass, "filterclass", STRING },
+ { ivFloat, "float", STRING },
+ { ivMaterial, "material", STRING },
+ { ivScene, "scene", STRING },
+ { ivSide, "side", STRING },
+ { ivSideList, "sidelist", STRING },
+ { ivOrigin, "origin", STRING },
+ { ivAxis, "axis", STRING },
+ { ivVecLine, "vecline", STRING },
+ { ivPointEntityClass, "pointentityclass", STRING },
+ { ivNodeDest, "node_dest", INTEGER },
+ { ivInstanceFile, "instance_file", STRING },
+ { ivAngleNegativePitch, "angle_negative_pitch", STRING },
+ { ivInstanceVariable, "instance_variable", STRING },
+ { ivInstanceParm, "instance_parm", STRING },
+};
+
+
+char *GDinputvariable::m_pszEmpty = "";
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+GDinputvariable::GDinputvariable(void)
+{
+ m_szDefault[0] = 0;
+ m_nDefault = 0;
+ m_szValue[0] = 0;
+ m_bReportable = FALSE;
+ m_bReadOnly = false;
+ m_pszDescription = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: construct generally used for creating a temp instance parm type
+// Input : szType - the textual type of this variable
+// szName - the name description of this variable
+//-----------------------------------------------------------------------------
+GDinputvariable::GDinputvariable( const char *szType, const char *szName )
+{
+ m_szDefault[0] = 0;
+ m_nDefault = 0;
+ m_szValue[0] = 0;
+ m_bReportable = FALSE;
+ m_bReadOnly = false;
+ m_pszDescription = NULL;
+
+ m_eType = GetTypeFromToken( szType );
+ strcpy( m_szName, szName );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor.
+//-----------------------------------------------------------------------------
+GDinputvariable::~GDinputvariable(void)
+{
+ delete [] m_pszDescription;
+ m_Items.RemoveAll();
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Implements the copy operator.
+//-----------------------------------------------------------------------------
+GDinputvariable &GDinputvariable::operator =(GDinputvariable &Other)
+{
+ m_eType = Other.GetType();
+ strcpy(m_szName, Other.m_szName);
+ strcpy(m_szLongName, Other.m_szLongName);
+ strcpy(m_szDefault, Other.m_szDefault);
+
+ //
+ // Copy the description.
+ //
+ delete [] m_pszDescription;
+ if (Other.m_pszDescription != NULL)
+ {
+ m_pszDescription = new char[strlen(Other.m_pszDescription) + 1];
+ strcpy(m_pszDescription, Other.m_pszDescription);
+ }
+ else
+ {
+ m_pszDescription = NULL;
+ }
+
+ m_nDefault = Other.m_nDefault;
+ m_bReportable = Other.m_bReportable;
+ m_bReadOnly = Other.m_bReadOnly;
+
+ m_Items.RemoveAll();
+
+ int nCount = Other.m_Items.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ m_Items.AddToTail(Other.m_Items.Element(i));
+ }
+
+ return(*this);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the storage format of a given variable type.
+// Input : pszToken - Sting containing the token.
+// Output : GDIV_TYPE corresponding to the token in the string, ivBadType if the
+// string does not correspond to a valid type.
+//-----------------------------------------------------------------------------
+trtoken_t GDinputvariable::GetStoreAsFromType(GDIV_TYPE eType)
+{
+ for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++)
+ {
+ if (TypeMap[i].eType == eType)
+ {
+ return(TypeMap[i].eStoreAs);
+ }
+ }
+
+ Assert(FALSE);
+ return(STRING);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the enumerated type of a string token.
+// Input : pszToken - Sting containing the token.
+// Output : GDIV_TYPE corresponding to the token in the string, ivBadType if the
+// string does not correspond to a valid type.
+//-----------------------------------------------------------------------------
+GDIV_TYPE GDinputvariable::GetTypeFromToken(const char *pszToken)
+{
+ for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++)
+ {
+ if (IsToken(pszToken, TypeMap[i].pszName))
+ {
+ return(TypeMap[i].eType);
+ }
+ }
+
+ return(ivBadType);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns a string representing the type of this variable, eg. "integer".
+//-----------------------------------------------------------------------------
+const char *GDinputvariable::GetTypeText(void)
+{
+ for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++)
+ {
+ if (TypeMap[i].eType == m_eType)
+ {
+ return(TypeMap[i].pszName);
+ }
+ }
+
+ return("unknown");
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : tr -
+// Output : Returns TRUE on success, FALSE on failure.
+//-----------------------------------------------------------------------------
+BOOL GDinputvariable::InitFromTokens(TokenReader& tr)
+{
+ char szToken[128];
+
+ if (!GDGetToken(tr, m_szName, sizeof(m_szName), IDENT))
+ {
+ return FALSE;
+ }
+
+ if (!GDSkipToken(tr, OPERATOR, "("))
+ {
+ return FALSE;
+ }
+
+ // check for "reportable" marker
+ trtoken_t ttype = tr.NextToken(szToken, sizeof(szToken));
+ if (ttype == OPERATOR)
+ {
+ if (!strcmp(szToken, "*"))
+ {
+ m_bReportable = true;
+ }
+ }
+ else
+ {
+ tr.Stuff(ttype, szToken);
+ }
+
+ // get type
+ if (!GDGetToken(tr, szToken, sizeof(szToken), IDENT))
+ {
+ return FALSE;
+ }
+
+ if (!GDSkipToken(tr, OPERATOR, ")"))
+ {
+ return FALSE;
+ }
+
+ //
+ // Check for known variable types.
+ //
+ m_eType = GetTypeFromToken(szToken);
+ if (m_eType == ivBadType)
+ {
+ GDError(tr, "'%s' is not a valid variable type", szToken);
+ return FALSE;
+ }
+
+ //
+ // Look ahead at the next token.
+ //
+ ttype = tr.PeekTokenType(szToken,sizeof(szToken));
+
+ //
+ // Check for the "readonly" specifier.
+ //
+ if ((ttype == IDENT) && IsToken(szToken, "readonly"))
+ {
+ tr.NextToken(szToken, sizeof(szToken));
+ m_bReadOnly = true;
+
+ //
+ // Look ahead at the next token.
+ //
+ ttype = tr.PeekTokenType(szToken,sizeof(szToken));
+ }
+
+ //
+ // Check for the ':' indicating a long name.
+ //
+ if (ttype == OPERATOR && IsToken(szToken, ":"))
+ {
+ //
+ // Eat the ':'.
+ //
+ tr.NextToken(szToken, sizeof(szToken));
+
+ if (m_eType == ivFlags)
+ {
+ GDError(tr, "flag sets do not have long names");
+ return FALSE;
+ }
+
+ //
+ // Get the long name.
+ //
+ if (!GDGetToken(tr, m_szLongName, sizeof(m_szLongName), STRING))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Look ahead at the next token.
+ //
+ ttype = tr.PeekTokenType(szToken,sizeof(szToken));
+
+ //
+ // Check for the ':' indicating a default value.
+ //
+ if (ttype == OPERATOR && IsToken(szToken, ":"))
+ {
+ //
+ // Eat the ':'.
+ //
+ tr.NextToken(szToken, sizeof(szToken));
+
+ //
+ // Look ahead at the next token.
+ //
+ ttype = tr.PeekTokenType(szToken,sizeof(szToken));
+ if (ttype == OPERATOR && IsToken(szToken, ":"))
+ {
+ //
+ // No default value provided, skip to the description.
+ //
+ }
+ else
+ {
+ //
+ // Determine how to parse the default value. If this is a choices field, the
+ // default could either be a string or an integer, so we must look ahead and
+ // use whichever is there.
+ //
+ trtoken_t eStoreAs = GetStoreAsFromType(m_eType);
+
+ if (eStoreAs == STRING)
+ {
+ if (!GDGetToken(tr, m_szDefault, sizeof(m_szDefault), STRING))
+ {
+ return(FALSE);
+ }
+ }
+ else if (eStoreAs == INTEGER)
+ {
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return(FALSE);
+ }
+
+ m_nDefault = atoi(szToken);
+ }
+
+ //
+ // Look ahead at the next token.
+ //
+ ttype = tr.PeekTokenType(szToken,sizeof(szToken));
+ }
+ }
+
+ //
+ // Check for the ':' indicating a description.
+ //
+ if (ttype == OPERATOR && IsToken(szToken, ":"))
+ {
+ //
+ // Eat the ':'.
+ //
+ tr.NextToken(szToken, sizeof(szToken));
+
+ //
+ // Read the description.
+ //
+
+ // If we've already read a description then free it to avoid memory leaks.
+ if ( m_pszDescription )
+ {
+ delete [] m_pszDescription;
+ m_pszDescription = NULL;
+ }
+ if (!GDGetTokenDynamic(tr, &m_pszDescription, STRING))
+ {
+ return(FALSE);
+ }
+
+ //
+ // Look ahead at the next token.
+ //
+ ttype = tr.PeekTokenType(szToken,sizeof(szToken));
+ }
+ }
+ else
+ {
+ //
+ // Default long name is short name.
+ //
+ strcpy(m_szLongName, m_szName);
+ }
+
+ //
+ // Check for the ']' indicating the end of the class definition.
+ //
+ if ((ttype == OPERATOR && IsToken(szToken, "]")) || ttype != OPERATOR)
+ {
+ if (m_eType == ivFlags || m_eType == ivChoices)
+ {
+ //
+ // Can't define a flags or choices variable without providing any flags or choices.
+ //
+ GDError(tr, "no %s specified", m_eType == ivFlags ? "flags" : "choices");
+ return(FALSE);
+ }
+ return(TRUE);
+ }
+
+ if (!GDSkipToken(tr, OPERATOR, "="))
+ {
+ return(FALSE);
+ }
+
+ if (m_eType != ivFlags && m_eType != ivChoices)
+ {
+ GDError(tr, "didn't expect '=' here");
+ return(FALSE);
+ }
+
+ // should be '[' to start flags/choices
+ if (!GDSkipToken(tr, OPERATOR, "["))
+ {
+ return(FALSE);
+ }
+
+ // get flags?
+ if (m_eType == ivFlags)
+ {
+ GDIVITEM ivi;
+
+ while (1)
+ {
+ ttype = tr.PeekTokenType();
+ if (ttype != INTEGER)
+ {
+ break;
+ }
+
+ // store bitflag value
+ GDGetToken(tr, szToken, sizeof(szToken), INTEGER);
+ sscanf( szToken, "%lu", &ivi.iValue );
+
+ // colon..
+ if (!GDSkipToken(tr, OPERATOR, ":"))
+ {
+ return FALSE;
+ }
+
+ // get description
+ if (!GDGetToken(tr, szToken, sizeof(szToken), STRING))
+ {
+ return FALSE;
+ }
+ strcpy(ivi.szCaption, szToken);
+
+ // colon..
+ if (!GDSkipToken(tr, OPERATOR, ":"))
+ {
+ return FALSE;
+ }
+
+ // get default setting
+ if (!GDGetToken(tr, szToken, sizeof(szToken), INTEGER))
+ {
+ return FALSE;
+ }
+ ivi.bDefault = atoi(szToken) ? TRUE : FALSE;
+
+ // add item to array of items
+ m_Items.AddToTail(ivi);
+ }
+
+ // Set the default value.
+ unsigned long nDefault = 0;
+ for (int i = 0; i < m_Items.Count(); i++)
+ {
+ if (m_Items[i].bDefault)
+ nDefault |= m_Items[i].iValue;
+ }
+ m_nDefault = (int)nDefault;
+ Q_snprintf( m_szDefault, sizeof( m_szDefault ), "%d", m_nDefault );
+ }
+ else if (m_eType == ivChoices)
+ {
+ GDIVITEM ivi;
+
+ while (1)
+ {
+ ttype = tr.PeekTokenType();
+ if ((ttype != INTEGER) && (ttype != STRING))
+ {
+ break;
+ }
+
+ // store choice value
+ GDGetToken(tr, szToken, sizeof(szToken), ttype);
+ ivi.iValue = 0;
+ strcpy(ivi.szValue, szToken);
+
+ // colon
+ if (!GDSkipToken(tr, OPERATOR, ":"))
+ {
+ return FALSE;
+ }
+
+ // get description
+ if (!GDGetToken(tr, szToken, sizeof(szToken), STRING))
+ {
+ return FALSE;
+ }
+
+ strcpy(ivi.szCaption, szToken);
+
+ m_Items.AddToTail(ivi);
+ }
+ }
+
+ if (!GDSkipToken(tr, OPERATOR, "]"))
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Decodes a key value from a string.
+// Input : pkv - Pointer to the key value object containing string encoded value.
+//-----------------------------------------------------------------------------
+void GDinputvariable::FromKeyValue(MDkeyvalue *pkv)
+{
+ trtoken_t eStoreAs = GetStoreAsFromType(m_eType);
+
+ if (eStoreAs == STRING)
+ {
+ strcpy(m_szValue, pkv->szValue);
+ }
+ else if (eStoreAs == INTEGER)
+ {
+ m_nValue = atoi(pkv->szValue);
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Determines whether the given flag is set (assuming this is an ivFlags).
+// Input : uCheck - Flag to check.
+// Output : Returns TRUE if flag is set, FALSE if not.
+//-----------------------------------------------------------------------------
+BOOL GDinputvariable::IsFlagSet(unsigned int uCheck)
+{
+ Assert(m_eType == ivFlags);
+ return (((unsigned int)m_nValue & uCheck) == uCheck) ? TRUE : FALSE;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Combines the flags or choices items from another variable into our
+// list of flags or choices. Ours take priority if collisions occur.
+// Input : Other - The variable whose items are being merged with ours.
+//-----------------------------------------------------------------------------
+void GDinputvariable::Merge(GDinputvariable &Other)
+{
+ //
+ // Only valid if we are of the same type.
+ //
+ if (Other.GetType() != GetType())
+ {
+ return;
+ }
+
+ //
+ // Add Other's items to this ONLY if there is no same-value entry
+ // for a specific item.
+ //
+ bool bFound = false;
+ int nOurItems = m_Items.Count();
+ for (int i = 0; i < Other.m_Items.Count(); i++)
+ {
+ GDIVITEM &TheirItem = Other.m_Items[i];
+ for (int j = 0; j < nOurItems; j++)
+ {
+ GDIVITEM &OurItem = m_Items[j];
+ if (TheirItem.iValue == OurItem.iValue)
+ {
+ bFound = true;
+ break;
+ }
+ }
+
+ if (!bFound)
+ {
+ //
+ // Not found in our list - add their item to our list.
+ //
+ m_Items.AddToTail(TheirItem);
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Determines whether the given flag is set (assuming this is an ivFlags).
+// Input : uFlags - Flags to set.
+// bSet - TRUE to set the flags, FALSE to clear them.
+//-----------------------------------------------------------------------------
+void GDinputvariable::SetFlag(unsigned int uFlags, BOOL bSet)
+{
+ Assert(m_eType == ivFlags);
+ if (bSet)
+ {
+ m_nValue |= uFlags;
+ }
+ else
+ {
+ m_nValue &= ~uFlags;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Sets this keyvalue to its default value.
+//-----------------------------------------------------------------------------
+void GDinputvariable::ResetDefaults(void)
+{
+ if (m_eType == ivFlags)
+ {
+ m_nValue = 0;
+
+ //
+ // Run thru flags and set any default flags.
+ //
+ int nCount = m_Items.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ if (m_Items[i].bDefault)
+ {
+ m_nValue |= GetFlagMask(i);
+ }
+ }
+ }
+ else
+ {
+ m_nValue = m_nDefault;
+ strcpy(m_szValue, m_szDefault);
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Encodes a key value as a string.
+// Input : pkv - Pointer to the key value object to receive the encoded string.
+//-----------------------------------------------------------------------------
+void GDinputvariable::ToKeyValue(MDkeyvalue *pkv)
+{
+ strcpy(pkv->szKey, m_szName);
+
+ trtoken_t eStoreAs = GetStoreAsFromType(m_eType);
+
+ if (eStoreAs == STRING)
+ {
+ strcpy(pkv->szValue, m_szValue);
+ }
+ else if (eStoreAs == INTEGER)
+ {
+ itoa(m_nValue, pkv->szValue, 10);
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the description string that corresponds to a value string
+// for a choices list.
+// Input : pszString - The choices value string.
+// Output : Returns the description string.
+//-----------------------------------------------------------------------------
+const char *GDinputvariable::ItemStringForValue(const char *szValue)
+{
+ int nCount = m_Items.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ if (!stricmp(m_Items[i].szValue, szValue))
+ {
+ return(m_Items[i].szCaption);
+ }
+ }
+
+ return(NULL);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns the value string that corresponds to a description string
+// for a choices list.
+// Input : pszString - The choices description string.
+// Output : Returns the value string.
+//-----------------------------------------------------------------------------
+const char *GDinputvariable::ItemValueForString(const char *szString)
+{
+ int nCount = m_Items.Count();
+ for (int i = 0; i < nCount; i++)
+ {
+ if (!strcmpi(m_Items[i].szCaption, szString))
+ {
+ return(m_Items[i].szValue);
+ }
+ }
+
+ return(NULL);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: this function will let you iterate through the text names of the variable types
+// Input : eType - the type to get the text of
+// Output : returns the textual name
+//-----------------------------------------------------------------------------
+const char *GDinputvariable::GetVarTypeName( GDIV_TYPE eType )
+{
+ return TypeMap[ eType ].pszName;
+}
+
+
diff --git a/mp/src/fgdlib/inputoutput.cpp b/mp/src/fgdlib/inputoutput.cpp
new file mode 100644
index 00000000..11c97df0
--- /dev/null
+++ b/mp/src/fgdlib/inputoutput.cpp
@@ -0,0 +1,171 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+
+#include <tier0/dbg.h>
+#include "fgdlib/InputOutput.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+
+typedef struct
+{
+ InputOutputType_t eType; // The enumeration of this type.
+ char *pszName; // The name of this type.
+} TypeMap_t;
+
+
+char *CClassInputOutputBase::g_pszEmpty = "";
+
+
+//-----------------------------------------------------------------------------
+// Maps type names to type enums for inputs and outputs.
+//-----------------------------------------------------------------------------
+static TypeMap_t TypeMap[] =
+{
+ { iotVoid, "void" },
+ { iotInt, "integer" },
+ { iotBool, "bool" },
+ { iotString, "string" },
+ { iotFloat, "float" },
+ { iotVector, "vector" },
+ { iotEHandle, "target_destination" },
+ { iotColor, "color255" },
+ { iotEHandle, "ehandle" }, // for backwards compatibility
+};
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+CClassInputOutputBase::CClassInputOutputBase(void)
+{
+ m_eType = iotInvalid;
+ m_pszDescription = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : pszName -
+// eType -
+//-----------------------------------------------------------------------------
+CClassInputOutputBase::CClassInputOutputBase(const char *pszName, InputOutputType_t eType)
+{
+ m_pszDescription = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor.
+//-----------------------------------------------------------------------------
+CClassInputOutputBase::~CClassInputOutputBase(void)
+{
+ delete m_pszDescription;
+ m_pszDescription = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Returns a string representing the type of this I/O, eg. "integer".
+//-----------------------------------------------------------------------------
+const char *CClassInputOutputBase::GetTypeText(void)
+{
+ for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++)
+ {
+ if (TypeMap[i].eType == m_eType)
+ {
+ return(TypeMap[i].pszName);
+ }
+ }
+
+ return("unknown");
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : szType -
+// Output : InputOutputType_t
+//-----------------------------------------------------------------------------
+InputOutputType_t CClassInputOutputBase::SetType(const char *szType)
+{
+ for (int i = 0; i < sizeof(TypeMap) / sizeof(TypeMap[0]); i++)
+ {
+ if (!stricmp(TypeMap[i].pszName, szType))
+ {
+ m_eType = TypeMap[i].eType;
+ return(m_eType);
+ }
+ }
+
+ return(iotInvalid);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Assignment operator.
+//-----------------------------------------------------------------------------
+CClassInputOutputBase &CClassInputOutputBase::operator =(CClassInputOutputBase &Other)
+{
+ strcpy(m_szName, Other.m_szName);
+ m_eType = Other.m_eType;
+
+ //
+ // Copy the description.
+ //
+ delete m_pszDescription;
+ if (Other.m_pszDescription != NULL)
+ {
+ m_pszDescription = new char[strlen(Other.m_pszDescription) + 1];
+ strcpy(m_pszDescription, Other.m_pszDescription);
+ }
+ else
+ {
+ m_pszDescription = NULL;
+ }
+
+ return(*this);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+CClassInput::CClassInput(void)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : pszName -
+// eType -
+//-----------------------------------------------------------------------------
+CClassInput::CClassInput(const char *pszName, InputOutputType_t eType)
+ : CClassInputOutputBase(pszName, eType)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+CClassOutput::CClassOutput(void)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : pszName -
+// eType -
+//-----------------------------------------------------------------------------
+CClassOutput::CClassOutput(const char *pszName, InputOutputType_t eType)
+ : CClassInputOutputBase(pszName, eType)
+{
+}
diff --git a/mp/src/fgdlib/wckeyvalues.cpp b/mp/src/fgdlib/wckeyvalues.cpp
new file mode 100644
index 00000000..d802eb42
--- /dev/null
+++ b/mp/src/fgdlib/wckeyvalues.cpp
@@ -0,0 +1,282 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================
+
+#include "fgdlib/WCKeyValues.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor.
+//-----------------------------------------------------------------------------
+MDkeyvalue::~MDkeyvalue(void)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Assignment operator.
+//-----------------------------------------------------------------------------
+MDkeyvalue &MDkeyvalue::operator =(const MDkeyvalue &other)
+{
+ V_strcpy_safe(szKey, other.szKey);
+ V_strcpy_safe(szValue, other.szValue);
+
+ return(*this);
+}
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void WCKVBase_Vector::RemoveKeyAt(int nIndex)
+{
+ Assert(nIndex >= 0);
+ Assert(nIndex < (int)m_KeyValues.Count());
+
+ if ((nIndex >= 0) && (nIndex < (int)m_KeyValues.Count()))
+ {
+ m_KeyValues.Remove(nIndex);
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Adds the key to the keyvalue array. Allows duplicate keys.
+//
+// NOTE: This should only be used for keyvalue lists that do not require
+// unique key names! If you use this function then you should use GetCount
+// and GetKey/Value by index rather than GetValue by key name.
+//-----------------------------------------------------------------------------
+void WCKVBase_Vector::AddKeyValue(const char *pszKey, const char *pszValue)
+{
+ if (!pszKey || !pszValue)
+ {
+ return;
+ }
+
+ char szTmpKey[KEYVALUE_MAX_KEY_LENGTH];
+ char szTmpValue[KEYVALUE_MAX_VALUE_LENGTH];
+
+ V_strcpy_safe(szTmpKey, pszKey);
+ V_strcpy_safe(szTmpValue, pszValue);
+
+ StripEdgeWhiteSpace(szTmpKey);
+ StripEdgeWhiteSpace(szTmpValue);
+
+ //
+ // Add the keyvalue to our list.
+ //
+ MDkeyvalue newkv;
+ V_strcpy_safe(newkv.szKey, szTmpKey);
+ V_strcpy_safe(newkv.szValue, szTmpValue);
+ m_KeyValues.AddToTail(newkv);
+}
+
+int WCKVBase_Vector::FindByKeyName( const char *pKeyName ) const
+{
+ for ( int i=0; i < m_KeyValues.Count(); i++ )
+ {
+ if ( V_stricmp( m_KeyValues[i].szKey, pKeyName ) == 0 )
+ return i;
+ }
+ return GetInvalidIndex();
+}
+
+void WCKVBase_Vector::InsertKeyValue( const MDkeyvalue &kv )
+{
+ m_KeyValues.AddToTail( kv );
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void WCKVBase_Dict::RemoveKeyAt(int nIndex)
+{
+ m_KeyValues.RemoveAt(nIndex);
+}
+
+
+int WCKVBase_Dict::FindByKeyName( const char *pKeyName ) const
+{
+ return m_KeyValues.Find( pKeyName );
+}
+
+void WCKVBase_Dict::InsertKeyValue( const MDkeyvalue &kv )
+{
+ m_KeyValues.Insert( kv.szKey, kv );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor. Sets the initial size of the keyvalue array.
+//-----------------------------------------------------------------------------
+template<class Base>
+WCKeyValuesT<Base>::WCKeyValuesT(void)
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Destructor. Deletes the contents of this keyvalue array.
+//-----------------------------------------------------------------------------
+template<class Base>
+WCKeyValuesT<Base>::~WCKeyValuesT(void)
+{
+ //int i = 0;
+ //while (i < m_KeyValues.GetSize())
+ //{
+ // delete m_KeyValues.GetAt(i++);
+ //}
+
+ RemoveAll();
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+template<class Base>
+const char *WCKeyValuesT<Base>::GetValue(const char *pszKey, int *piIndex) const
+{
+ int i = FindByKeyName( pszKey );
+ if ( i == GetInvalidIndex() )
+ {
+ return NULL;
+ }
+ else
+ {
+ if(piIndex)
+ piIndex[0] = i;
+
+ return m_KeyValues[i].szValue;
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+template<class Base>
+void WCKeyValuesT<Base>::RemoveKey(const char *pszKey)
+{
+ SetValue(pszKey, (const char *)NULL);
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+template<class Base>
+void WCKeyValuesT<Base>::SetValue(const char *pszKey, int iValue)
+{
+ char szValue[100];
+ itoa(iValue, szValue, 10);
+
+ SetValue(pszKey, szValue);
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Strips leading and trailing whitespace from the string.
+// Input : psz -
+//-----------------------------------------------------------------------------
+void StripEdgeWhiteSpace(char *psz)
+{
+ if (!psz || !*psz)
+ return;
+
+ char *pszBase = psz;
+
+ while (V_isspace(*psz))
+ {
+ psz++;
+ }
+
+ int iLen = strlen(psz) - 1;
+
+ if ( iLen >= 0 )
+ {
+ while (V_isspace(psz[iLen]))
+ {
+ psz[iLen--] = 0;
+ }
+ }
+
+ if (psz != pszBase)
+ {
+ memmove(pszBase, psz, iLen + 2);
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+// Input : pszKey -
+// pszValue -
+//-----------------------------------------------------------------------------
+template<class Base>
+void WCKeyValuesT<Base>::SetValue(const char *pszKey, const char *pszValue)
+{
+ char szTmpKey[KEYVALUE_MAX_KEY_LENGTH];
+ char szTmpValue[KEYVALUE_MAX_VALUE_LENGTH];
+
+ V_strcpy_safe(szTmpKey, pszKey);
+
+ if (pszValue != NULL)
+ {
+ V_strcpy_safe(szTmpValue, pszValue);
+ }
+ else
+ {
+ szTmpValue[0] = 0;
+ }
+
+ StripEdgeWhiteSpace(szTmpKey);
+ StripEdgeWhiteSpace(szTmpValue);
+
+ int i = FindByKeyName( szTmpKey );
+ if ( i == GetInvalidIndex() )
+ {
+ if ( pszValue )
+ {
+ //
+ // Add the keyvalue to our list.
+ //
+ MDkeyvalue newkv;
+ Q_strncpy( newkv.szKey, szTmpKey, sizeof( newkv.szKey ) );
+ Q_strncpy( newkv.szValue, szTmpValue, sizeof( newkv.szValue ) );
+ InsertKeyValue( newkv );
+ }
+ }
+ else
+ {
+ if (pszValue != NULL)
+ {
+ V_strncpy(m_KeyValues[i].szValue, szTmpValue, sizeof(m_KeyValues[i].szValue));
+ }
+ //
+ // If we are setting to a NULL value, delete the key.
+ //
+ else
+ {
+ RemoveKeyAt( i );
+ }
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+template<class Base>
+void WCKeyValuesT<Base>::RemoveAll(void)
+{
+ m_KeyValues.RemoveAll();
+}
+
+
+// Explicit instantiations.
+template class WCKeyValuesT<WCKVBase_Dict>;
+template class WCKeyValuesT<WCKVBase_Vector>;
+
+
+
diff --git a/mp/src/game/client/c_baseentity.cpp b/mp/src/game/client/c_baseentity.cpp
index 8e2e752d..89b503d4 100644
--- a/mp/src/game/client/c_baseentity.cpp
+++ b/mp/src/game/client/c_baseentity.cpp
@@ -2462,27 +2462,36 @@ void C_BaseEntity::UnlinkFromHierarchy()
void C_BaseEntity::ValidateModelIndex( void )
{
#ifdef TF_CLIENT_DLL
- if ( m_nModelIndexOverrides[MODEL_INDEX_OVERRIDE_DEFAULT] > 0 )
+ if ( m_nModelIndexOverrides[VISION_MODE_NONE] > 0 )
{
if ( IsLocalPlayerUsingVisionFilterFlags( TF_VISION_FILTER_HALLOWEEN ) )
{
- if ( m_nModelIndexOverrides[MODEL_INDEX_OVERRIDE_HALLOWEEN] > 0 )
+ if ( m_nModelIndexOverrides[VISION_MODE_HALLOWEEN] > 0 )
{
- SetModelByIndex( m_nModelIndexOverrides[MODEL_INDEX_OVERRIDE_HALLOWEEN] );
+ SetModelByIndex( m_nModelIndexOverrides[VISION_MODE_HALLOWEEN] );
return;
}
}
if ( IsLocalPlayerUsingVisionFilterFlags( TF_VISION_FILTER_PYRO ) )
{
- if ( m_nModelIndexOverrides[MODEL_INDEX_OVERRIDE_PYRO] > 0 )
+ if ( m_nModelIndexOverrides[VISION_MODE_PYRO] > 0 )
{
- SetModelByIndex( m_nModelIndexOverrides[MODEL_INDEX_OVERRIDE_PYRO] );
+ SetModelByIndex( m_nModelIndexOverrides[VISION_MODE_PYRO] );
return;
}
}
- SetModelByIndex( m_nModelIndexOverrides[MODEL_INDEX_OVERRIDE_DEFAULT] );
+ if ( IsLocalPlayerUsingVisionFilterFlags( TF_VISION_FILTER_ROME ) )
+ {
+ if ( m_nModelIndexOverrides[VISION_MODE_ROME] > 0 )
+ {
+ SetModelByIndex( m_nModelIndexOverrides[VISION_MODE_ROME] );
+ return;
+ }
+ }
+
+ SetModelByIndex( m_nModelIndexOverrides[VISION_MODE_NONE] );
return;
}
@@ -3597,6 +3606,48 @@ void C_BaseEntity::AddStudioDecal( const Ray_t& ray, int hitbox, int decalIndex,
}
}
+//-----------------------------------------------------------------------------
+void C_BaseEntity::AddColoredStudioDecal( const Ray_t& ray, int hitbox, int decalIndex,
+ bool doTrace, trace_t& tr, Color cColor, int maxLODToDecal )
+{
+ if (doTrace)
+ {
+ enginetrace->ClipRayToEntity( ray, MASK_SHOT, this, &tr );
+
+ // Trace the ray against the entity
+ if (tr.fraction == 1.0f)
+ return;
+
+ // Set the trace index appropriately...
+ tr.m_pEnt = this;
+ }
+
+ // Exit out after doing the trace so any other effects that want to happen can happen.
+ if ( !r_drawmodeldecals.GetBool() )
+ return;
+
+ // Found the point, now lets apply the decals
+ CreateModelInstance();
+
+ // FIXME: Pass in decal up?
+ Vector up(0, 0, 1);
+
+ if (doTrace && (GetSolid() == SOLID_VPHYSICS) && !tr.startsolid && !tr.allsolid)
+ {
+ // Choose a more accurate normal direction
+ // Also, since we have more accurate info, we can avoid pokethru
+ Vector temp;
+ VectorSubtract( tr.endpos, tr.plane.normal, temp );
+ Ray_t betterRay;
+ betterRay.Init( tr.endpos, temp );
+ modelrender->AddColoredDecal( m_ModelInstance, betterRay, up, decalIndex, GetStudioBody(), cColor, true, maxLODToDecal );
+ }
+ else
+ {
+ modelrender->AddColoredDecal( m_ModelInstance, ray, up, decalIndex, GetStudioBody(), cColor, false, maxLODToDecal );
+ }
+}
+
//-----------------------------------------------------------------------------
// This method works when we've got a brush model
@@ -3648,6 +3699,56 @@ void C_BaseEntity::AddDecal( const Vector& rayStart, const Vector& rayEnd,
}
//-----------------------------------------------------------------------------
+void C_BaseEntity::AddColoredDecal( const Vector& rayStart, const Vector& rayEnd,
+ const Vector& decalCenter, int hitbox, int decalIndex, bool doTrace, trace_t& tr, Color cColor, int maxLODToDecal )
+{
+ Ray_t ray;
+ ray.Init( rayStart, rayEnd );
+
+ // FIXME: Better bloat?
+ // Bloat a little bit so we get the intersection
+ ray.m_Delta *= 1.1f;
+
+ int modelType = modelinfo->GetModelType( model );
+ if ( doTrace )
+ {
+ enginetrace->ClipRayToEntity( ray, MASK_SHOT, this, &tr );
+ switch ( modelType )
+ {
+ case mod_studio:
+ tr.m_pEnt = this;
+ break;
+ case mod_brush:
+ if ( tr.fraction == 1.0f )
+ return; // Explicitly end
+ default:
+ // By default, no collision
+ tr.fraction = 1.0f;
+ break;
+ }
+ }
+
+ switch ( modelType )
+ {
+ case mod_studio:
+ AddColoredStudioDecal( ray, hitbox, decalIndex, doTrace, tr, cColor, maxLODToDecal );
+ break;
+
+ case mod_brush:
+ {
+ color32 cColor32 = { cColor.r(), cColor.g(), cColor.b(), cColor.a() };
+ effects->DecalColorShoot( decalIndex, index, model, GetAbsOrigin(), GetAbsAngles(), decalCenter, 0, 0, cColor32 );
+ }
+ break;
+
+ default:
+ // By default, no collision
+ tr.fraction = 1.0f;
+ break;
+ }
+}
+
+//-----------------------------------------------------------------------------
// A method to remove all decals from an entity
//-----------------------------------------------------------------------------
void C_BaseEntity::RemoveAllDecals( void )
diff --git a/mp/src/game/client/c_baseentity.h b/mp/src/game/client/c_baseentity.h
index 3ea4b7fd..e00513df 100644
--- a/mp/src/game/client/c_baseentity.h
+++ b/mp/src/game/client/c_baseentity.h
@@ -770,6 +770,10 @@ public:
// A method to apply a decal to an entity
virtual void AddDecal( const Vector& rayStart, const Vector& rayEnd,
const Vector& decalCenter, int hitbox, int decalIndex, bool doTrace, trace_t& tr, int maxLODToDecal = ADDDECAL_TO_ALL_LODS );
+
+ virtual void AddColoredDecal( const Vector& rayStart, const Vector& rayEnd,
+ const Vector& decalCenter, int hitbox, int decalIndex, bool doTrace, trace_t& tr, Color cColor, int maxLODToDecal = ADDDECAL_TO_ALL_LODS );
+
// A method to remove all decals from an entity
void RemoveAllDecals( void );
@@ -1317,7 +1321,7 @@ public:
short m_nModelIndex;
#ifdef TF_CLIENT_DLL
- int m_nModelIndexOverrides[MAX_MODEL_INDEX_OVERRIDES];
+ int m_nModelIndexOverrides[MAX_VISION_MODES];
#endif
char m_takedamage;
@@ -1464,6 +1468,7 @@ private:
// methods related to decal adding
void AddStudioDecal( const Ray_t& ray, int hitbox, int decalIndex, bool doTrace, trace_t& tr, int maxLODToDecal = ADDDECAL_TO_ALL_LODS );
+ void AddColoredStudioDecal( const Ray_t& ray, int hitbox, int decalIndex, bool doTrace, trace_t& tr, Color cColor, int maxLODToDecal );
void AddBrushModelDecal( const Ray_t& ray, const Vector& decalCenter, int decalIndex, bool doTrace, trace_t& tr );
void ComputePackedOffsets( void );
diff --git a/mp/src/game/client/c_baseplayer.cpp b/mp/src/game/client/c_baseplayer.cpp
index 8e4ff89f..74c12bbc 100644
--- a/mp/src/game/client/c_baseplayer.cpp
+++ b/mp/src/game/client/c_baseplayer.cpp
@@ -2178,7 +2178,7 @@ void C_BasePlayer::PlayPlayerJingle()
if ( !filesystem->FileExists( fullsoundname ) )
{
char custname[ 512 ];
- Q_snprintf( custname, sizeof( custname ), "downloads/%s.dat", soundhex );
+ Q_snprintf( custname, sizeof( custname ), "download/user_custom/%c%c/%s.dat", soundhex[0], soundhex[1], soundhex );
// it may have been downloaded but not copied under materials folder
if ( !filesystem->FileExists( custname ) )
return; // not downloaded yet
diff --git a/mp/src/game/client/cdll_client_int.cpp b/mp/src/game/client/cdll_client_int.cpp
index c8f7f40b..4e856c95 100644
--- a/mp/src/game/client/cdll_client_int.cpp
+++ b/mp/src/game/client/cdll_client_int.cpp
@@ -116,6 +116,7 @@
#include "rtime.h"
#include "tf_hud_disconnect_prompt.h"
#include "../engine/audio/public/sound.h"
+#include "tf_shared_content_manager.h"
#endif
#include "clientsteamcontext.h"
#include "renamed_recvtable_compat.h"
@@ -1018,6 +1019,7 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
#if defined( TF_CLIENT_DLL )
IGameSystem::Add( CustomTextureToolCacheGameSystem() );
+ IGameSystem::Add( TFSharedContentManager() );
#endif
#if defined( TF_CLIENT_DLL )
diff --git a/mp/src/game/client/client_base.vpc b/mp/src/game/client/client_base.vpc
index 8acae4f7..757a4cce 100644
--- a/mp/src/game/client/client_base.vpc
+++ b/mp/src/game/client/client_base.vpc
@@ -44,14 +44,18 @@ $Configuration "Release"
$Configuration
{
+ $General
+ {
+ $OutputDirectory ".\$GAMENAME" [$OSXALL]
+ }
+
$Compiler
{
$AdditionalIncludeDirectories ".\;$BASE;$SRCDIR\vgui2\include;$SRCDIR\vgui2\controls;$SRCDIR\game\shared;.\game_controls;$SRCDIR\thirdparty\sixensesdk\include"
$PreprocessorDefinitions "$BASE;NO_STRING_T;CLIENT_DLL;VECTOR;VERSION_SAFE_STEAM_API_INTERFACES;PROTECTED_THINGS_ENABLE;strncpy=use_Q_strncpy_instead;_snprintf=use_Q_snprintf_instead"
$PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;fopen=dont_use_fopen" [$WIN32]
$PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;" [$OSXALL]
- $PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;" [$LINUX]
- $PreprocessorDefinitions "$BASE;USE_WEBM_FOR_REPLAY" [$LINUX]
+ $PreprocessorDefinitions "$BASE;ENABLE_CHROMEHTMLWINDOW;USE_WEBM_FOR_REPLAY;" [$LINUXALL]
$PreprocessorDefinitions "$BASE;CURL_STATICLIB" [$WIN32 && $BUILD_REPLAY]
$Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"
$Create/UsePCHThroughFile "cbase.h"
@@ -1232,55 +1236,7 @@ $Project
$File "game_controls\IconPanel.h"
}
- $Folder "Link Libraries" [$WIN32]
- {
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\choreoobjects.lib"
- $DynamicFile "$SRCDIR\lib\public\dmxloader.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\matsys_controls.lib"
- $DynamicFile "$SRCDIR\lib\public\particles.lib"
- $DynamicFile "$SRCDIR\lib\public\tier1.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\tier3.lib"
- $DynamicFile "$SRCDIR\lib\public\vgui_controls.lib"
- $DynamicFile "$SRCDIR\lib\public\steam_api.lib"
- $DynamicFile "$SRCDIR\lib\public\vtf.lib"
- $DynamicFile "$SRCDIR\lib\win32\release\libcurl.lib" [$BUILD_REPLAY]
- }
-
- $Folder "Link Libraries" [$X360]
- {
- $DynamicFile "$SRCDIR\lib\public\bitmap_360.lib"
- $DynamicFile "$SRCDIR\lib\public\choreoobjects_360.lib"
- $DynamicFile "$SRCDIR\lib\public\dmxloader_360.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib_360.lib"
- $DynamicFile "$SRCDIR\lib\public\matsys_controls_360.lib"
- $DynamicFile "$SRCDIR\lib\public\particles_360.lib"
- $DynamicFile "$SRCDIR\lib\public\tier1_360.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2_360.lib"
- $DynamicFile "$SRCDIR\lib\public\tier3_360.lib"
- $DynamicFile "$SRCDIR\lib\public\vgui_controls_360.lib"
- }
-
- $Folder "Link Libraries" [$POSIX && !$LINUX]
- {
- $DynamicFile "$SRCDIR\lib\$PLATFORM\libcurl$_IMPLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\bitmap$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\choreoobjects$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\dmxloader$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\mathlib$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\matsys_controls$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\particles$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier1$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier2$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier3$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\vgui_controls$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXsteam_api$_IMPLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\vtf$_STATICLIB_EXT"
- }
-
- $Folder "Link Libraries" [$LINUX]
+ $Folder "Link Libraries"
{
$Lib bitmap
$Lib choreoobjects
@@ -1292,12 +1248,20 @@ $Project
$Lib tier2
$Lib tier3
$Lib vgui_controls
- $Lib vtf
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXsteam_api$_IMPLIB_EXT"
- $DynamicFile "$SRCDIR/lib/linux32/libcurl$_STATICLIB_EXT" [$DEDICATED]
- $DynamicFile "$SRCDIR/lib/linux32/libcurlssl$_STATICLIB_EXT" [!$DEDICATED]
- $DynamicFile "$SRCDIR/lib/linux32/libssl$_STATICLIB_EXT" [!$DEDICATED]
- $DynamicFile "$SRCDIR/lib/linux32/release/libcrypto$_STATICLIB_EXT" [!$DEDICATED]
+ $Lib vtf
+ $ImpLib steam_api
+
+ $Lib $LIBCOMMON/libcrypto [$POSIX]
+
+ $ImpLib "$LIBCOMMON\curl" [$OSXALL]
+
+ $Lib "$LIBCOMMON\libcurl" [$WIN32]
+ $Lib "libz" [$WIN32]
+
+ $Libexternal libz [$LINUXALL]
+ $Libexternal "$LIBCOMMON/libcurl" [$LINUXALL]
+ $Libexternal "$LIBCOMMON/libcurlssl" [$LINUXALL]
+ $Libexternal "$LIBCOMMON/libssl" [$LINUXALL]
}
}
diff --git a/mp/src/game/client/client_hl2mp.vpc b/mp/src/game/client/client_hl2mp.vpc
index 9e50fefd..597b39d9 100644
--- a/mp/src/game/client/client_hl2mp.vpc
+++ b/mp/src/game/client/client_hl2mp.vpc
@@ -10,9 +10,6 @@ $Macro GAMENAME "mod_hl2mp" [$SOURCESDK]
$Include "$SRCDIR\game\client\client_base.vpc"
-$macro VSLIBDIR "." [!$VS2010]
-$macro VSLIBDIR "VS2010" [$VS2010]
-
$Configuration
{
$Compiler
@@ -174,16 +171,4 @@ $Project "Client (HL2MP)"
}
}
}
- $Folder "Libraries"
- {
- $File "$SRCDIR\lib\$PLATFORM\release\$VSLIBDIR\libprotobuf.lib" [$WINDOWS]
- {
- $Configuration "Debug" { $ExcludedFromBuild "Yes" }
- }
- $File "$SRCDIR\lib\$PLATFORM\debug\$VSLIBDIR\libprotobuf.lib" [$WINDOWS]
- {
- $Configuration "Release" { $ExcludedFromBuild "Yes" }
- }
- $File "$SRCDIR\lib\$PLATFORM\release\libprotobuf.a" [$POSIX]
- }
}
diff --git a/mp/src/game/client/death.cpp b/mp/src/game/client/death.cpp
index fa63ede8..50463d57 100644
--- a/mp/src/game/client/death.cpp
+++ b/mp/src/game/client/death.cpp
@@ -289,7 +289,7 @@ void CHudDeathNotice::FireGameEvent( KeyValues * event)
if ( !strcmp( killedwith+2, "gauss" ) )
Q_strncpy( killedwith, "d_tau cannon", sizeof( killedwith ) );
- Msg( killedwith+2 ); // skip over the "d_" part
+ Msg( "%s", killedwith+2 ); // skip over the "d_" part
}
Msg( "\n" );
diff --git a/mp/src/game/protobuf_include.vpc b/mp/src/game/protobuf_include.vpc
index 6b21fb6a..75392eda 100644
--- a/mp/src/game/protobuf_include.vpc
+++ b/mp/src/game/protobuf_include.vpc
@@ -6,25 +6,10 @@
$MacroRequired "PLATFORM"
-$macro VSLIBDIR "." [!$VS2010]
-$macro VSLIBDIR "VS2010" [$VS2010]
-
$Project
{
$Folder "Libraries"
{
- // Always use the release version of libprotobuf.lib because the debug
- // version uses iterator debugging, which is incompatible with the rest of
- // the Valve world.
- $File "$SRCDIR\lib\$PLATFORM\release\$VSLIBDIR\libprotobuf.lib" [$WINDOWS && $VS2010]
- $File "$SRCDIR\lib\$PLATFORM\release\$VSLIBDIR\libprotobuf.lib" [$WINDOWS && !$VS2010]
- {
- $Configuration "Debug" { $ExcludedFromBuild "Yes" }
- }
- $File "$SRCDIR\lib\$PLATFORM\debug\$VSLIBDIR\libprotobuf.lib" [$WINDOWS && !$VS2010]
- {
- $Configuration "Release" { $ExcludedFromBuild "Yes" }
- }
- $File "$SRCDIR\lib\$PLATFORM\release\libprotobuf.a" [$POSIX]
+ $Libexternal libprotobuf
}
}
diff --git a/mp/src/game/server/ai_behavior_lead.cpp b/mp/src/game/server/ai_behavior_lead.cpp
index 10462e08..cc4e0aed 100644
--- a/mp/src/game/server/ai_behavior_lead.cpp
+++ b/mp/src/game/server/ai_behavior_lead.cpp
@@ -3,7 +3,8 @@
// Purpose:
//
//=============================================================================//
-
+#undef strncpy // we use std::string below that needs a good strncpy define
+#undef sprintf // "
#include "cbase.h"
#include "ai_behavior_lead.h"
diff --git a/mp/src/game/server/ai_networkmanager.cpp b/mp/src/game/server/ai_networkmanager.cpp
index 00826e02..69d6319e 100644
--- a/mp/src/game/server/ai_networkmanager.cpp
+++ b/mp/src/game/server/ai_networkmanager.cpp
@@ -48,7 +48,7 @@ inline void DebugConnectMsg( int node1, int node2, const char *pszFormat, ... )
Q_vsnprintf( string, sizeof(string), pszFormat, argptr );
va_end( argptr );
- DevMsg( string );
+ DevMsg( "%s", string );
}
}
diff --git a/mp/src/game/server/ai_tacticalservices.cpp b/mp/src/game/server/ai_tacticalservices.cpp
index 08d32699..70fc643c 100644
--- a/mp/src/game/server/ai_tacticalservices.cpp
+++ b/mp/src/game/server/ai_tacticalservices.cpp
@@ -347,7 +347,7 @@ int CAI_TacticalServices::FindCoverNode(const Vector &vNearPos, const Vector &vT
MARK_TASK_EXPENSIVE();
- DebugFindCover( g_AIDebugFindCoverNode, GetOuter()->EyePosition(), vThreatEyePos, 0, 255, 255 );
+ DebugFindCover( NO_NODE, GetOuter()->EyePosition(), vThreatEyePos, 0, 255, 255 );
int iMyNode = GetPathfinder()->NearestNodeToPoint( vNearPos );
diff --git a/mp/src/game/server/baseentity.cpp b/mp/src/game/server/baseentity.cpp
index 689aa020..48f1a4a7 100644
--- a/mp/src/game/server/baseentity.cpp
+++ b/mp/src/game/server/baseentity.cpp
@@ -653,7 +653,7 @@ void CBaseEntity::SetModelIndex( int index )
void CBaseEntity::ClearModelIndexOverrides( void )
{
#ifdef TF_DLL
- for ( int index = 0 ; index < MAX_MODEL_INDEX_OVERRIDES ; index++ )
+ for ( int index = 0 ; index < MAX_VISION_MODES ; index++ )
{
m_nModelIndexOverrides.Set( index, 0 );
}
@@ -663,7 +663,7 @@ void CBaseEntity::ClearModelIndexOverrides( void )
void CBaseEntity::SetModelIndexOverride( int index, int nValue )
{
#ifdef TF_DLL
- if ( ( index >= MODEL_INDEX_OVERRIDE_DEFAULT ) && ( index < MAX_MODEL_INDEX_OVERRIDES ) )
+ if ( ( index >= VISION_MODE_NONE ) && ( index < MAX_VISION_MODES ) )
{
if ( nValue != m_nModelIndexOverrides[index] )
{
@@ -1950,7 +1950,7 @@ BEGIN_DATADESC_NO_BASE( CBaseEntity )
// DEFINE_FIELD( m_fDataObjectTypes, FIELD_INTEGER ),
#ifdef TF_DLL
- DEFINE_ARRAY( m_nModelIndexOverrides, FIELD_INTEGER, MAX_MODEL_INDEX_OVERRIDES ),
+ DEFINE_ARRAY( m_nModelIndexOverrides, FIELD_INTEGER, MAX_VISION_MODES ),
#endif
END_DATADESC()
@@ -7302,6 +7302,30 @@ void CC_Ent_Create( const CCommand& args )
{
MDLCACHE_CRITICAL_SECTION();
+ CBasePlayer *pPlayer = UTIL_GetCommandClient();
+ if (!pPlayer)
+ {
+ return;
+ }
+
+ // Don't allow regular users to create point_servercommand entities for the same reason as blocking ent_fire
+ if ( !Q_stricmp( args[1], "point_servercommand" ) )
+ {
+ if ( engine->IsDedicatedServer() )
+ {
+ // We allow people with disabled autokick to do it, because they already have rcon.
+ if ( pPlayer->IsAutoKickDisabled() == false )
+ return;
+ }
+ else if ( gpGlobals->maxClients > 1 )
+ {
+ // On listen servers with more than 1 player, only allow the host to create point_servercommand.
+ CBasePlayer *pHostPlayer = UTIL_GetListenServerHost();
+ if ( pPlayer != pHostPlayer )
+ return;
+ }
+ }
+
bool allowPrecache = CBaseEntity::IsPrecacheAllowed();
CBaseEntity::SetAllowPrecache( true );
@@ -7322,7 +7346,6 @@ void CC_Ent_Create( const CCommand& args )
DispatchSpawn(entity);
// Now attempt to drop into the world
- CBasePlayer* pPlayer = UTIL_GetCommandClient();
trace_t tr;
Vector forward;
pPlayer->EyeVectors( &forward );
diff --git a/mp/src/game/server/baseentity.h b/mp/src/game/server/baseentity.h
index 016915ca..7bcc3c2e 100644
--- a/mp/src/game/server/baseentity.h
+++ b/mp/src/game/server/baseentity.h
@@ -792,7 +792,7 @@ public:
CNetworkVar( short, m_nModelIndex );
#ifdef TF_DLL
- CNetworkArray( int, m_nModelIndexOverrides, MAX_MODEL_INDEX_OVERRIDES ); // used to override the base model index on the client if necessary
+ CNetworkArray( int, m_nModelIndexOverrides, MAX_VISION_MODES ); // used to override the base model index on the client if necessary
#endif
// was pev->rendercolor
diff --git a/mp/src/game/server/client.cpp b/mp/src/game/server/client.cpp
index 2fd87cfe..39905046 100644
--- a/mp/src/game/server/client.cpp
+++ b/mp/src/game/server/client.cpp
@@ -798,6 +798,24 @@ CON_COMMAND( give, "Give item to player.\n\tArguments: <item_name>" )
Q_strncpy( item_to_give, args[1], sizeof( item_to_give ) );
Q_strlower( item_to_give );
+ // Don't allow regular users to create point_servercommand entities for the same reason as blocking ent_fire
+ if ( !Q_stricmp( item_to_give, "point_servercommand" ) )
+ {
+ if ( engine->IsDedicatedServer() )
+ {
+ // We allow people with disabled autokick to do it, because they already have rcon.
+ if ( pPlayer->IsAutoKickDisabled() == false )
+ return;
+ }
+ else if ( gpGlobals->maxClients > 1 )
+ {
+ // On listen servers with more than 1 player, only allow the host to create point_servercommand.
+ CBasePlayer *pHostPlayer = UTIL_GetListenServerHost();
+ if ( pPlayer != pHostPlayer )
+ return;
+ }
+ }
+
// Dirty hack to avoid suit playing it's pickup sound
if ( !Q_stricmp( item_to_give, "item_suit" ) )
{
diff --git a/mp/src/game/server/doors.cpp b/mp/src/game/server/doors.cpp
index 53abb829..d8f06c49 100644
--- a/mp/src/game/server/doors.cpp
+++ b/mp/src/game/server/doors.cpp
@@ -340,12 +340,11 @@ void CBaseDoor::Spawn()
#ifdef TF_DLL
if ( TFGameRules() && TFGameRules()->IsMultiplayer() )
{
- if ( !m_flBlockDamage )
- {
- // Never block doors in TF2 - to prevent various exploits.
- m_flBlockDamage = 10.f;
- }
+ // Never block doors in TF2 - to prevent various exploits.
+ m_bIgnoreNonPlayerEntsOnBlock = true;
}
+#else
+ m_bIgnoreNonPlayerEntsOnBlock = false;
#endif // TF_DLL
}
@@ -1207,6 +1206,11 @@ void CBaseDoor::Blocked( CBaseEntity *pOther )
pOther->TakeDamage( CTakeDamageInfo( this, this, m_flBlockDamage, DMG_CRUSH ) );
}
}
+ // If set, ignore non-player ents that block us. Mainly of use in multiplayer to prevent exploits.
+ else if ( pOther && !pOther->IsPlayer() && m_bIgnoreNonPlayerEntsOnBlock )
+ {
+ return;
+ }
// If we're set to force ourselves closed, keep going
if ( m_bForceClosed )
diff --git a/mp/src/game/server/doors.h b/mp/src/game/server/doors.h
index 0de009dc..0a545ecf 100644
--- a/mp/src/game/server/doors.h
+++ b/mp/src/game/server/doors.h
@@ -114,6 +114,7 @@ public:
bool m_bDoorGroup;
bool m_bLocked; // Whether the door is locked
bool m_bIgnoreDebris;
+ bool m_bIgnoreNonPlayerEntsOnBlock; // Non-player entities should never block. This variable needs more letters.
FuncDoorSpawnPos_t m_eSpawnPosition;
diff --git a/mp/src/game/server/episodic/npc_hunter.cpp b/mp/src/game/server/episodic/npc_hunter.cpp
index fa9daff8..9d7dfd3e 100644
--- a/mp/src/game/server/episodic/npc_hunter.cpp
+++ b/mp/src/game/server/episodic/npc_hunter.cpp
@@ -2199,7 +2199,7 @@ void CNPC_Hunter::PrescheduleThink()
if ( m_flPupilDilateTime < gpGlobals->curtime )
{
CBasePlayer *pPlayer = UTIL_PlayerByIndex( 1 );
- if ( pPlayer && !pPlayer->IsIlluminatedByFlashlight( this, NULL ) || !PlayerFlashlightOnMyEyes( pPlayer ) )
+ if ( ( pPlayer && !pPlayer->IsIlluminatedByFlashlight( this, NULL ) ) || !PlayerFlashlightOnMyEyes( pPlayer ) )
{
//Msg( "NOT SHINING FLASHLIGHT ON ME\n" );
@@ -6347,13 +6347,13 @@ void CNPC_Hunter::FootFX( const Vector &origin )
CBaseEntity *CNPC_Hunter::GetEnemyVehicle()
{
if ( GetEnemy() == NULL )
- return false;
+ return NULL;
CBaseCombatCharacter *pCCEnemy = GetEnemy()->MyCombatCharacterPointer();
if ( pCCEnemy != NULL )
return pCCEnemy->GetVehicleEntity();
- return false;
+ return NULL;
}
diff --git a/mp/src/game/server/hl2/npc_barnacle.cpp b/mp/src/game/server/hl2/npc_barnacle.cpp
index 92201730..012d371d 100644
--- a/mp/src/game/server/hl2/npc_barnacle.cpp
+++ b/mp/src/game/server/hl2/npc_barnacle.cpp
@@ -1810,7 +1810,10 @@ void CNPC_Barnacle::SwallowPrey( void )
#if HL2_EPISODIC
// digest poisonous things for just a moment before being killed by them (it looks wierd if it's instant)
- m_flDigestFinish = gpGlobals->curtime + m_bSwallowingPoison ? 0.48f : 10.0f;
+ // Parentheses were probably intended around the ?: part of the expression, but putting them there now
+ // would change the behavior which is undesirable, so parentheses were placed around the '+' to suppress
+ // compiler warnings.
+ m_flDigestFinish = ( gpGlobals->curtime + m_bSwallowingPoison ) ? 0.48f : 10.0f;
#else
m_flDigestFinish = gpGlobals->curtime + 10.0;
#endif
diff --git a/mp/src/game/server/hl2/npc_zombine.cpp b/mp/src/game/server/hl2/npc_zombine.cpp
index 5c74e1a9..611dc682 100644
--- a/mp/src/game/server/hl2/npc_zombine.cpp
+++ b/mp/src/game/server/hl2/npc_zombine.cpp
@@ -571,7 +571,7 @@ void CNPC_Zombine::HandleAnimEvent( animevent_t *pEvent )
{
pNPC = ppAIs[i];
- if( pNPC->Classify() == CLASS_PLAYER_ALLY || pNPC->Classify() == CLASS_PLAYER_ALLY_VITAL && pNPC->FVisible(this) )
+ if( pNPC->Classify() == CLASS_PLAYER_ALLY || ( pNPC->Classify() == CLASS_PLAYER_ALLY_VITAL && pNPC->FVisible(this) ) )
{
int priority;
Disposition_t disposition;
diff --git a/mp/src/game/server/player.h b/mp/src/game/server/player.h
index c17ff974..c1fa4f69 100644
--- a/mp/src/game/server/player.h
+++ b/mp/src/game/server/player.h
@@ -358,7 +358,7 @@ public:
bool IsHLTV( void ) const { return pl.hltv; }
bool IsReplay( void ) const { return pl.replay; }
- virtual bool IsPlayer( void ) const { return true; } // Spectators return TRUE for this, use IsObserver to seperate cases
+ virtual bool IsPlayer( void ) const { return true; } // Spectators return TRUE for this, use IsObserver to separate cases
virtual bool IsNetClient( void ) const { return true; } // Bots should return FALSE for this, they can't receive NET messages
// Spectators should return TRUE for this
@@ -1500,6 +1500,44 @@ int CollectPlayers( CUtlVector< T * > *playerVector, int team = TEAM_ANY, bool i
return playerVector->Count();
}
+template < typename T >
+int CollectHumanPlayers( CUtlVector< T * > *playerVector, int team = TEAM_ANY, bool isAlive = false, bool shouldAppend = false )
+{
+ if ( !shouldAppend )
+ {
+ playerVector->RemoveAll();
+ }
+
+ for( int i=1; i<=gpGlobals->maxClients; ++i )
+ {
+ CBasePlayer *player = UTIL_PlayerByIndex( i );
+
+ if ( player == NULL )
+ continue;
+
+ if ( FNullEnt( player->edict() ) )
+ continue;
+
+ if ( !player->IsPlayer() )
+ continue;
+
+ if ( player->IsBot() )
+ continue;
+
+ if ( !player->IsConnected() )
+ continue;
+
+ if ( team != TEAM_ANY && player->GetTeamNumber() != team )
+ continue;
+
+ if ( isAlive && !player->IsAlive() )
+ continue;
+
+ playerVector->AddToTail( assert_cast< T * >( player ) );
+ }
+
+ return playerVector->Count();
+}
enum
{
diff --git a/mp/src/game/server/props.cpp b/mp/src/game/server/props.cpp
index eefa467b..d20756f3 100644
--- a/mp/src/game/server/props.cpp
+++ b/mp/src/game/server/props.cpp
@@ -1937,6 +1937,18 @@ void CDynamicProp::Spawn( )
}
//m_debugOverlays |= OVERLAY_ABSBOX_BIT;
+
+#ifdef TF_DLL
+ const char *pszModelName = modelinfo->GetModelName( GetModel() );
+ if ( pszModelName && pszModelName[0] )
+ {
+ if ( FStrEq( pszModelName, "models/bots/boss_bot/carrier_parts.mdl" ) )
+ {
+ SetModelIndexOverride( VISION_MODE_NONE, modelinfo->GetModelIndex( pszModelName ) );
+ SetModelIndexOverride( VISION_MODE_ROME, modelinfo->GetModelIndex( "models/bots/tw2/boss_bot/twcarrier_addon.mdl" ) );
+ }
+ }
+#endif
}
//-----------------------------------------------------------------------------
diff --git a/mp/src/game/server/server_base.vpc b/mp/src/game/server/server_base.vpc
index 8b24610b..94dfd0f9 100644
--- a/mp/src/game/server/server_base.vpc
+++ b/mp/src/game/server/server_base.vpc
@@ -44,6 +44,11 @@ $Configuration "Release"
$Configuration
{
+ $General
+ {
+ $OutputDirectory ".\$GAMENAME" [$OSXALL]
+ }
+
$Compiler
{
$AdditionalIncludeDirectories "$BASE;.\;$SRCDIR\game\shared;$SRCDIR\utils\common;$SRCDIR\game\shared\econ;$SRCDIR\game\server\NextBot"
@@ -998,40 +1003,7 @@ $Project
$File "toolframework_server.h"
}
-
- $Folder "Link Libraries" [$WIN32]
- {
- $DynamicFile "$SRCDIR\lib\public\choreoobjects.lib"
- $DynamicFile "$SRCDIR\lib\public\dmxloader.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\particles.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\tier3.lib"
- $DynamicFile "$SRCDIR\lib\public\steam_api.lib"
- }
-
- $Folder "Link Libraries" [$X360]
- {
- $DynamicFile "$SRCDIR\lib\public\choreoobjects_360.lib"
- $DynamicFile "$SRCDIR\lib\public\dmxloader_360.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib_360.lib"
- $DynamicFile "$SRCDIR\lib\public\particles_360.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2_360.lib"
- $DynamicFile "$SRCDIR\lib\public\tier3_360.lib"
- }
-
- $Folder "Link Libraries" [$POSIX && !$LINUX]
- {
- $DynamicFile "$SRCDIR\lib\$PLATFORM\choreoobjects$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\dmxloader$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\mathlib$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\particles$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier2$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier3$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXsteam_api$_IMPLIB_EXT"
- }
-
- $Folder "Link Libraries" [$LINUX]
+ $Folder "Link Libraries"
{
$Lib choreoobjects
$Lib dmxloader
@@ -1039,6 +1011,6 @@ $Project
$Lib particles
$Lib tier2
$Lib tier3
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXsteam_api$_EXTERNAL_IMPLIB_EXT"
+ $ImpLibexternal steam_api
}
}
diff --git a/mp/src/game/server/testfunctions.cpp b/mp/src/game/server/testfunctions.cpp
index c949a1da..c6f452b2 100644
--- a/mp/src/game/server/testfunctions.cpp
+++ b/mp/src/game/server/testfunctions.cpp
@@ -16,6 +16,14 @@
void Test_CreateEntity( const CCommand &args )
{
+ CBasePlayer *pPlayer = UTIL_GetCommandClient();
+
+ // Require a player entity or that the command was entered from the dedicated server console
+ if ( !pPlayer && UTIL_GetCommandClientIndex() > 0 )
+ {
+ return;
+ }
+
if ( args.ArgC() < 2 )
{
Error( "Test_CreateEntity: requires entity classname argument." );
@@ -23,6 +31,24 @@ void Test_CreateEntity( const CCommand &args )
const char *pClassName = args[ 1 ];
+ // Don't allow regular users to create point_servercommand entities for the same reason as blocking ent_fire
+ if ( pPlayer && !Q_stricmp( pClassName, "point_servercommand" ) )
+ {
+ if ( engine->IsDedicatedServer() )
+ {
+ // We allow people with disabled autokick to do it, because they already have rcon.
+ if ( pPlayer->IsAutoKickDisabled() == false )
+ return;
+ }
+ else if ( gpGlobals->maxClients > 1 )
+ {
+ // On listen servers with more than 1 player, only allow the host to create point_servercommand.
+ CBasePlayer *pHostPlayer = UTIL_GetListenServerHost();
+ if ( pPlayer != pHostPlayer )
+ return;
+ }
+ }
+
if ( !CreateEntityByName( pClassName ) )
{
Error( "Test_CreateEntity( %s ) failed.", pClassName );
diff --git a/mp/src/game/server/util.cpp b/mp/src/game/server/util.cpp
index 8b2365f7..431c8561 100644
--- a/mp/src/game/server/util.cpp
+++ b/mp/src/game/server/util.cpp
@@ -1892,7 +1892,8 @@ int DispatchSpawn( CBaseEntity *pEntity )
// Don't allow the PVS check to skip animation setup during spawning
pAnimating->SetBoneCacheFlags( BCF_IS_IN_SPAWN );
pEntity->Spawn();
- pAnimating->ClearBoneCacheFlags( BCF_IS_IN_SPAWN );
+ if ( pEntSafe != NULL )
+ pAnimating->ClearBoneCacheFlags( BCF_IS_IN_SPAWN );
}
mdlcache->SetAsyncLoad( MDLCACHE_ANIMBLOCK, bAsyncAnims );
diff --git a/mp/src/game/shared/GameStats.cpp b/mp/src/game/shared/GameStats.cpp
index 3571827d..e81eaed6 100644
--- a/mp/src/game/shared/GameStats.cpp
+++ b/mp/src/game/shared/GameStats.cpp
@@ -3,10 +3,8 @@
// Purpose:
//
//=============================================================================
-
#include "cbase.h"
-
#include "igamesystem.h"
#include "gamestats.h"
#include "tier1/utlstring.h"
diff --git a/mp/src/game/shared/playernet_vars.h b/mp/src/game/shared/playernet_vars.h
index 9fdeec0f..abb49765 100644
--- a/mp/src/game/shared/playernet_vars.h
+++ b/mp/src/game/shared/playernet_vars.h
@@ -77,10 +77,10 @@ struct fogplayerparams_t
{
m_hCtrl.Set( NULL );
m_flTransitionTime = -1.0f;
- m_OldColor.r = m_OldColor.g = m_OldColor.g = m_OldColor.a = 0.0f;
+ m_OldColor.r = m_OldColor.g = m_OldColor.b = m_OldColor.a = 0;
m_flOldStart = 0.0f;
m_flOldEnd = 0.0f;
- m_NewColor.r = m_NewColor.g = m_NewColor.g = m_NewColor.a = 0.0f;
+ m_NewColor.r = m_NewColor.g = m_NewColor.b = m_NewColor.a = 0;
m_flNewStart = 0.0f;
m_flNewEnd = 0.0f;
}
diff --git a/mp/src/game/shared/shareddefs.h b/mp/src/game/shared/shareddefs.h
index 4dbab433..868ae046 100644
--- a/mp/src/game/shared/shareddefs.h
+++ b/mp/src/game/shared/shareddefs.h
@@ -919,14 +919,17 @@ enum
#define TF_VISION_FILTER_NONE 0
#define TF_VISION_FILTER_PYRO (1<<0) // 1
#define TF_VISION_FILTER_HALLOWEEN (1<<1) // 2
+#define TF_VISION_FILTER_ROME (1<<2) // 4
+// THIS ENUM SHOULD MATCH THE ORDER OF THE FLAGS ABOVE
enum
{
- MODEL_INDEX_OVERRIDE_DEFAULT = 0,
- MODEL_INDEX_OVERRIDE_PYRO,
- MODEL_INDEX_OVERRIDE_HALLOWEEN,
+ VISION_MODE_NONE = 0,
+ VISION_MODE_PYRO,
+ VISION_MODE_HALLOWEEN,
+ VISION_MODE_ROME,
- MAX_MODEL_INDEX_OVERRIDES
+ MAX_VISION_MODES
};
#endif // TF_DLL || TF_CLIENT_DLL
diff --git a/mp/src/lib/common/libcurl.lib b/mp/src/lib/common/libcurl.lib
new file mode 100644
index 00000000..9b6fc8fb
--- /dev/null
+++ b/mp/src/lib/common/libcurl.lib
Binary files differ
diff --git a/mp/src/lib/linux32/release/libcrypto.a b/mp/src/lib/common/linux32/libcrypto.a
index 274849e0..274849e0 100644
--- a/mp/src/lib/linux32/release/libcrypto.a
+++ b/mp/src/lib/common/linux32/libcrypto.a
Binary files differ
diff --git a/mp/src/lib/linux32/libcurl.a b/mp/src/lib/common/linux32/libcurl.a
index be6615d9..be6615d9 100644
--- a/mp/src/lib/linux32/libcurl.a
+++ b/mp/src/lib/common/linux32/libcurl.a
Binary files differ
diff --git a/mp/src/lib/linux32/libcurlssl.a b/mp/src/lib/common/linux32/libcurlssl.a
index ea01c02c..ea01c02c 100644
--- a/mp/src/lib/linux32/libcurlssl.a
+++ b/mp/src/lib/common/linux32/libcurlssl.a
Binary files differ
diff --git a/mp/src/lib/linux32/libssl.a b/mp/src/lib/common/linux32/libssl.a
index a96bdc0a..a96bdc0a 100644
--- a/mp/src/lib/linux32/libssl.a
+++ b/mp/src/lib/common/linux32/libssl.a
Binary files differ
diff --git a/mp/src/lib/osx32/bitmap.a b/mp/src/lib/osx32/bitmap.a
deleted file mode 100644
index cfdb3754..00000000
--- a/mp/src/lib/osx32/bitmap.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/choreoobjects.a b/mp/src/lib/osx32/choreoobjects.a
deleted file mode 100644
index 47431a06..00000000
--- a/mp/src/lib/osx32/choreoobjects.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/dmxloader.a b/mp/src/lib/osx32/dmxloader.a
deleted file mode 100644
index bdbf0211..00000000
--- a/mp/src/lib/osx32/dmxloader.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/libcurl.dylib b/mp/src/lib/osx32/libcurl.dylib
deleted file mode 100644
index 3056d8b3..00000000
--- a/mp/src/lib/osx32/libcurl.dylib
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/libtier0.dylib b/mp/src/lib/osx32/libtier0.dylib
deleted file mode 100644
index af6b5c58..00000000
--- a/mp/src/lib/osx32/libtier0.dylib
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/libvstdlib.dylib b/mp/src/lib/osx32/libvstdlib.dylib
deleted file mode 100644
index 4a7a32a6..00000000
--- a/mp/src/lib/osx32/libvstdlib.dylib
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/particles.a b/mp/src/lib/osx32/particles.a
deleted file mode 100644
index 7808c3f8..00000000
--- a/mp/src/lib/osx32/particles.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/shaderlib.a b/mp/src/lib/osx32/shaderlib.a
deleted file mode 100644
index db25a2bc..00000000
--- a/mp/src/lib/osx32/shaderlib.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/tier2.a b/mp/src/lib/osx32/tier2.a
deleted file mode 100644
index 5b374e52..00000000
--- a/mp/src/lib/osx32/tier2.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/tier3.a b/mp/src/lib/osx32/tier3.a
deleted file mode 100644
index 2bc80e46..00000000
--- a/mp/src/lib/osx32/tier3.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/osx32/vtf.a b/mp/src/lib/osx32/vtf.a
deleted file mode 100644
index c0ef3476..00000000
--- a/mp/src/lib/osx32/vtf.a
+++ /dev/null
Binary files differ
diff --git a/mp/src/lib/public/appframework.lib b/mp/src/lib/public/appframework.lib
index c69838ca..73b8e36b 100644
--- a/mp/src/lib/public/appframework.lib
+++ b/mp/src/lib/public/appframework.lib
Binary files differ
diff --git a/mp/src/lib/public/bitmap.lib b/mp/src/lib/public/bitmap.lib
index cf3530fc..6c9482e6 100644
--- a/mp/src/lib/public/bitmap.lib
+++ b/mp/src/lib/public/bitmap.lib
Binary files differ
diff --git a/mp/src/lib/public/choreoobjects.lib b/mp/src/lib/public/choreoobjects.lib
index eb31ddd4..b1baadfb 100644
--- a/mp/src/lib/public/choreoobjects.lib
+++ b/mp/src/lib/public/choreoobjects.lib
Binary files differ
diff --git a/mp/src/lib/public/dmxloader.lib b/mp/src/lib/public/dmxloader.lib
index 18edcba5..d1cd4019 100644
--- a/mp/src/lib/public/dmxloader.lib
+++ b/mp/src/lib/public/dmxloader.lib
Binary files differ
diff --git a/mp/src/lib/public/fgdlib.lib b/mp/src/lib/public/fgdlib.lib
index fb1aafd9..b17ea30b 100644
--- a/mp/src/lib/public/fgdlib.lib
+++ b/mp/src/lib/public/fgdlib.lib
Binary files differ
diff --git a/mp/src/lib/win32/release/vs2010/libprotobuf.lib b/mp/src/lib/public/libprotobuf.lib
index e25942c5..e25942c5 100644
--- a/mp/src/lib/win32/release/vs2010/libprotobuf.lib
+++ b/mp/src/lib/public/libprotobuf.lib
Binary files differ
diff --git a/mp/src/lib/public/libz.lib b/mp/src/lib/public/libz.lib
new file mode 100644
index 00000000..692f43dd
--- /dev/null
+++ b/mp/src/lib/public/libz.lib
Binary files differ
diff --git a/mp/src/lib/public/linux32/bitmap.a b/mp/src/lib/public/linux32/bitmap.a
index bbd65285..9e9b1385 100644
--- a/mp/src/lib/public/linux32/bitmap.a
+++ b/mp/src/lib/public/linux32/bitmap.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/choreoobjects.a b/mp/src/lib/public/linux32/choreoobjects.a
index bbeb2ef3..a24bab3c 100644
--- a/mp/src/lib/public/linux32/choreoobjects.a
+++ b/mp/src/lib/public/linux32/choreoobjects.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/dmxloader.a b/mp/src/lib/public/linux32/dmxloader.a
index 71d39e95..35530866 100644
--- a/mp/src/lib/public/linux32/dmxloader.a
+++ b/mp/src/lib/public/linux32/dmxloader.a
Binary files differ
diff --git a/mp/src/lib/linux32/release/libprotobuf.a b/mp/src/lib/public/linux32/libprotobuf.a
index 2fd92725..2fd92725 100644
--- a/mp/src/lib/linux32/release/libprotobuf.a
+++ b/mp/src/lib/public/linux32/libprotobuf.a
Binary files differ
diff --git a/mp/src/lib/linux32/libsteam_api.so b/mp/src/lib/public/linux32/libsteam_api.so
index 6238c83e..6238c83e 100644
--- a/mp/src/lib/linux32/libsteam_api.so
+++ b/mp/src/lib/public/linux32/libsteam_api.so
Binary files differ
diff --git a/mp/src/lib/public/linux32/libtier0.so b/mp/src/lib/public/linux32/libtier0.so
index cd02bc3b..1b821914 100644
--- a/mp/src/lib/public/linux32/libtier0.so
+++ b/mp/src/lib/public/linux32/libtier0.so
Binary files differ
diff --git a/mp/src/lib/public/linux32/libvstdlib.so b/mp/src/lib/public/linux32/libvstdlib.so
index f6aea107..729c1dd0 100644
--- a/mp/src/lib/public/linux32/libvstdlib.so
+++ b/mp/src/lib/public/linux32/libvstdlib.so
Binary files differ
diff --git a/mp/src/lib/public/linux32/libz.a b/mp/src/lib/public/linux32/libz.a
new file mode 100644
index 00000000..0e5f958b
--- /dev/null
+++ b/mp/src/lib/public/linux32/libz.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/matsys_controls.a b/mp/src/lib/public/linux32/matsys_controls.a
index 1a284e03..70222e64 100644
--- a/mp/src/lib/public/linux32/matsys_controls.a
+++ b/mp/src/lib/public/linux32/matsys_controls.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/particles.a b/mp/src/lib/public/linux32/particles.a
index 626fecaf..2de80570 100644
--- a/mp/src/lib/public/linux32/particles.a
+++ b/mp/src/lib/public/linux32/particles.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/shaderlib.a b/mp/src/lib/public/linux32/shaderlib.a
index 502a3193..9fa52e09 100644
--- a/mp/src/lib/public/linux32/shaderlib.a
+++ b/mp/src/lib/public/linux32/shaderlib.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/tier2.a b/mp/src/lib/public/linux32/tier2.a
index a440a0b7..f3cbd890 100644
--- a/mp/src/lib/public/linux32/tier2.a
+++ b/mp/src/lib/public/linux32/tier2.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/tier3.a b/mp/src/lib/public/linux32/tier3.a
index 77f98b2b..0ceee4b2 100644
--- a/mp/src/lib/public/linux32/tier3.a
+++ b/mp/src/lib/public/linux32/tier3.a
Binary files differ
diff --git a/mp/src/lib/public/linux32/vtf.a b/mp/src/lib/public/linux32/vtf.a
index 4d7f1f26..a5f39932 100644
--- a/mp/src/lib/public/linux32/vtf.a
+++ b/mp/src/lib/public/linux32/vtf.a
Binary files differ
diff --git a/mp/src/lib/public/mathlib.lib b/mp/src/lib/public/mathlib.lib
index d581b673..d7e6eef8 100644
--- a/mp/src/lib/public/mathlib.lib
+++ b/mp/src/lib/public/mathlib.lib
Binary files differ
diff --git a/mp/src/lib/public/matsys_controls.lib b/mp/src/lib/public/matsys_controls.lib
index bf1da093..2fb462ea 100644
--- a/mp/src/lib/public/matsys_controls.lib
+++ b/mp/src/lib/public/matsys_controls.lib
Binary files differ
diff --git a/mp/src/lib/public/nvtristrip.lib b/mp/src/lib/public/nvtristrip.lib
index 21185355..afea63d1 100644
--- a/mp/src/lib/public/nvtristrip.lib
+++ b/mp/src/lib/public/nvtristrip.lib
Binary files differ
diff --git a/mp/src/lib/public/osx32/bitmap.a b/mp/src/lib/public/osx32/bitmap.a
new file mode 100644
index 00000000..13f58a27
--- /dev/null
+++ b/mp/src/lib/public/osx32/bitmap.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/choreoobjects.a b/mp/src/lib/public/osx32/choreoobjects.a
new file mode 100644
index 00000000..2fb14bb8
--- /dev/null
+++ b/mp/src/lib/public/osx32/choreoobjects.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/dmxloader.a b/mp/src/lib/public/osx32/dmxloader.a
new file mode 100644
index 00000000..db336f43
--- /dev/null
+++ b/mp/src/lib/public/osx32/dmxloader.a
Binary files differ
diff --git a/mp/src/lib/osx32/release/libprotobuf.a b/mp/src/lib/public/osx32/libprotobuf.a
index 2327c2cc..2327c2cc 100644
--- a/mp/src/lib/osx32/release/libprotobuf.a
+++ b/mp/src/lib/public/osx32/libprotobuf.a
Binary files differ
diff --git a/mp/src/lib/osx32/libsteam_api.dylib b/mp/src/lib/public/osx32/libsteam_api.dylib
index 3eed40fe..3eed40fe 100644
--- a/mp/src/lib/osx32/libsteam_api.dylib
+++ b/mp/src/lib/public/osx32/libsteam_api.dylib
Binary files differ
diff --git a/mp/src/lib/public/osx32/libtier0.dylib b/mp/src/lib/public/osx32/libtier0.dylib
new file mode 100644
index 00000000..84180383
--- /dev/null
+++ b/mp/src/lib/public/osx32/libtier0.dylib
Binary files differ
diff --git a/mp/src/lib/public/osx32/libvstdlib.dylib b/mp/src/lib/public/osx32/libvstdlib.dylib
new file mode 100644
index 00000000..a54a8a7b
--- /dev/null
+++ b/mp/src/lib/public/osx32/libvstdlib.dylib
Binary files differ
diff --git a/mp/src/lib/public/osx32/mathlib.a b/mp/src/lib/public/osx32/mathlib.a
new file mode 100644
index 00000000..48fa10e0
--- /dev/null
+++ b/mp/src/lib/public/osx32/mathlib.a
Binary files differ
diff --git a/mp/src/lib/osx32/matsys_controls.a b/mp/src/lib/public/osx32/matsys_controls.a
index 75d6fc9e..0a8de4ed 100644
--- a/mp/src/lib/osx32/matsys_controls.a
+++ b/mp/src/lib/public/osx32/matsys_controls.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/particles.a b/mp/src/lib/public/osx32/particles.a
new file mode 100644
index 00000000..f3332c0d
--- /dev/null
+++ b/mp/src/lib/public/osx32/particles.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/raytrace.a b/mp/src/lib/public/osx32/raytrace.a
new file mode 100644
index 00000000..475c9a03
--- /dev/null
+++ b/mp/src/lib/public/osx32/raytrace.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/shaderlib.a b/mp/src/lib/public/osx32/shaderlib.a
new file mode 100644
index 00000000..dcc79c72
--- /dev/null
+++ b/mp/src/lib/public/osx32/shaderlib.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/tier1.a b/mp/src/lib/public/osx32/tier1.a
new file mode 100644
index 00000000..81093003
--- /dev/null
+++ b/mp/src/lib/public/osx32/tier1.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/tier2.a b/mp/src/lib/public/osx32/tier2.a
new file mode 100644
index 00000000..c5f77742
--- /dev/null
+++ b/mp/src/lib/public/osx32/tier2.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/tier3.a b/mp/src/lib/public/osx32/tier3.a
new file mode 100644
index 00000000..521e0491
--- /dev/null
+++ b/mp/src/lib/public/osx32/tier3.a
Binary files differ
diff --git a/mp/src/lib/win32/debug/vs2010/libprotobuf.lib b/mp/src/lib/public/osx32/vgui_controls.a
index 73515f85..c4797048 100644
--- a/mp/src/lib/win32/debug/vs2010/libprotobuf.lib
+++ b/mp/src/lib/public/osx32/vgui_controls.a
Binary files differ
diff --git a/mp/src/lib/public/osx32/vtf.a b/mp/src/lib/public/osx32/vtf.a
new file mode 100644
index 00000000..08054ef6
--- /dev/null
+++ b/mp/src/lib/public/osx32/vtf.a
Binary files differ
diff --git a/mp/src/lib/public/particles.lib b/mp/src/lib/public/particles.lib
index 4f78b611..df995060 100644
--- a/mp/src/lib/public/particles.lib
+++ b/mp/src/lib/public/particles.lib
Binary files differ
diff --git a/mp/src/lib/public/raytrace.lib b/mp/src/lib/public/raytrace.lib
index 2b9ad265..8f4fce6d 100644
--- a/mp/src/lib/public/raytrace.lib
+++ b/mp/src/lib/public/raytrace.lib
Binary files differ
diff --git a/mp/src/lib/public/shaderlib.lib b/mp/src/lib/public/shaderlib.lib
index 53a7744d..2047f41a 100644
--- a/mp/src/lib/public/shaderlib.lib
+++ b/mp/src/lib/public/shaderlib.lib
Binary files differ
diff --git a/mp/src/lib/public/tier0.lib b/mp/src/lib/public/tier0.lib
index da3ed75c..6098e682 100644
--- a/mp/src/lib/public/tier0.lib
+++ b/mp/src/lib/public/tier0.lib
Binary files differ
diff --git a/mp/src/lib/public/tier1.lib b/mp/src/lib/public/tier1.lib
index d9293e4a..7f0985e1 100644
--- a/mp/src/lib/public/tier1.lib
+++ b/mp/src/lib/public/tier1.lib
Binary files differ
diff --git a/mp/src/lib/public/tier2.lib b/mp/src/lib/public/tier2.lib
index 6600cb7f..9d058f9d 100644
--- a/mp/src/lib/public/tier2.lib
+++ b/mp/src/lib/public/tier2.lib
Binary files differ
diff --git a/mp/src/lib/public/tier3.lib b/mp/src/lib/public/tier3.lib
index a549f07e..634832e9 100644
--- a/mp/src/lib/public/tier3.lib
+++ b/mp/src/lib/public/tier3.lib
Binary files differ
diff --git a/mp/src/lib/public/vgui_controls.lib b/mp/src/lib/public/vgui_controls.lib
index d05d0bcb..ae56ebcd 100644
--- a/mp/src/lib/public/vgui_controls.lib
+++ b/mp/src/lib/public/vgui_controls.lib
Binary files differ
diff --git a/mp/src/lib/public/vmpi.lib b/mp/src/lib/public/vmpi.lib
index b16b57ae..323dd59e 100644
--- a/mp/src/lib/public/vmpi.lib
+++ b/mp/src/lib/public/vmpi.lib
Binary files differ
diff --git a/mp/src/lib/public/vstdlib.lib b/mp/src/lib/public/vstdlib.lib
index 80035b6a..ffb8d830 100644
--- a/mp/src/lib/public/vstdlib.lib
+++ b/mp/src/lib/public/vstdlib.lib
Binary files differ
diff --git a/mp/src/lib/public/vtf.lib b/mp/src/lib/public/vtf.lib
index 32a90207..88a718bc 100644
--- a/mp/src/lib/public/vtf.lib
+++ b/mp/src/lib/public/vtf.lib
Binary files differ
diff --git a/mp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc b/mp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc
index c2fe0d49..8ba932d3 100644
--- a/mp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc
+++ b/mp/src/materialsystem/stdshaders/game_shader_dx9_base.vpc
@@ -74,23 +74,9 @@ $Project
$Folder "Link Libraries" [$WIN32]
{
// $File "$SRCDIR\dx9sdk\lib\d3dx9.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\shaderlib.lib"
}
- $Folder "Link Libraries" [$X360]
- {
- $DynamicFile "$SRCDIR\lib\public\mathlib_360.lib"
- $DynamicFile "$SRCDIR\lib\public\shaderlib_360.lib"
- }
-
- $Folder "Link Libraries" [$POSIX&&!$LINUX]
- {
- $DynamicFile "$SRCDIR\lib\$PLATFORM\mathlib$_STATICLIB_EXT"
- $DynamicFile "$SRCDIR\lib\$PLATFORM\shaderlib$_STATICLIB_EXT"
- }
-
- $Folder "Link Libraries" [$LINUX]
+ $Folder "Link Libraries"
{
$Lib mathlib
$Lib shaderlib
diff --git a/mp/src/mathlib/mathlib.vpc b/mp/src/mathlib/mathlib.vpc
index 59a0c95f..cff0f986 100644
--- a/mp/src/mathlib/mathlib.vpc
+++ b/mp/src/mathlib/mathlib.vpc
@@ -5,8 +5,6 @@
//-----------------------------------------------------------------------------
$macro SRCDIR ".."
-$Macro OUTLIBDIR "$SRCDIR\lib\public" [!$LINUX]
-
$include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
$Configuration
diff --git a/mp/src/public/XUnzip.cpp b/mp/src/public/XUnzip.cpp
index 22c7d62c..72fc7805 100644
--- a/mp/src/public/XUnzip.cpp
+++ b/mp/src/public/XUnzip.cpp
@@ -3232,10 +3232,12 @@ int unzlocal_GetCurrentFileInfoInternal (unzFile file, unz_file_info *pfile_info
// we check the magic
if (err==UNZ_OK)
+ {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x02014b50)
err=UNZ_BADZIPFILE;
+ }
if (unzlocal_getShort(s->file,&file_info.version) != UNZ_OK)
err=UNZ_ERRNO;
@@ -3312,10 +3314,12 @@ int unzlocal_GetCurrentFileInfoInternal (unzFile file, unz_file_info *pfile_info
uSizeRead = extraFieldBufferSize;
if (lSeek!=0)
+ {
if (lufseek(s->file,lSeek,SEEK_CUR)==0)
lSeek=0;
else
err=UNZ_ERRNO;
+ }
if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0))
if (lufread(extraField,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
@@ -3337,10 +3341,12 @@ int unzlocal_GetCurrentFileInfoInternal (unzFile file, unz_file_info *pfile_info
uSizeRead = commentBufferSize;
if (lSeek!=0)
+ {
if (lufseek(s->file,lSeek,SEEK_CUR)==0)
{} // unused lSeek=0;
else
err=UNZ_ERRNO;
+ }
if ((file_info.size_file_comment>0) && (commentBufferSize>0))
if (lufread(szComment,(uInt)uSizeRead,1,s->file)!=1)
err=UNZ_ERRNO;
@@ -3490,10 +3496,12 @@ int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s,uInt *piSizeVar,
if (err==UNZ_OK)
+ {
if (unzlocal_getLong(s->file,&uMagic) != UNZ_OK)
err=UNZ_ERRNO;
else if (uMagic!=0x04034b50)
err=UNZ_BADZIPFILE;
+ }
if (unzlocal_getShort(s->file,&uData) != UNZ_OK)
err=UNZ_ERRNO;
diff --git a/mp/src/public/bone_setup.cpp b/mp/src/public/bone_setup.cpp
index b8033c49..31fb4965 100644
--- a/mp/src/public/bone_setup.cpp
+++ b/mp/src/public/bone_setup.cpp
@@ -57,7 +57,9 @@ public:
{
p = new T[MAXSTUDIOBONES];
if ( ((size_t)p) % TSLIST_NODE_ALIGNMENT != 0 )
+ {
DebuggerBreak();
+ }
}
return p;
diff --git a/mp/src/public/cdll_int.h b/mp/src/public/cdll_int.h
index 1801c383..56598198 100644
--- a/mp/src/public/cdll_int.h
+++ b/mp/src/public/cdll_int.h
@@ -566,6 +566,8 @@ public:
virtual bool IsActiveApp() = 0;
virtual void DisconnectInternal() = 0;
+
+ virtual int GetInstancesRunningCount( ) = 0;
};
diff --git a/mp/src/public/engine/IStaticPropMgr.h b/mp/src/public/engine/IStaticPropMgr.h
index 428d0133..ca06f8ff 100644
--- a/mp/src/public/engine/IStaticPropMgr.h
+++ b/mp/src/public/engine/IStaticPropMgr.h
@@ -63,7 +63,8 @@ public:
// Adds decals to static props, returns point of decal in trace_t
virtual void AddDecalToStaticProp( const Vector& rayStart, const Vector& rayEnd,
int staticPropIndex, int decalIndex, bool doTrace, trace_t& tr ) = 0;
-
+ virtual void AddColorDecalToStaticProp( Vector const& rayStart, Vector const& rayEnd,
+ int staticPropIndex, int decalIndex, bool doTrace, trace_t& tr, bool bUseColor, Color cColor ) = 0;
// Adds/removes shadows from static props
virtual void AddShadowToStaticProp( unsigned short shadowHandle, IClientRenderable* pRenderable ) = 0;
virtual void RemoveAllShadowsFromStaticProp( IClientRenderable* pRenderable ) = 0;
diff --git a/mp/src/public/engine/ivmodelrender.h b/mp/src/public/engine/ivmodelrender.h
index 0b28aba1..5b60d893 100644
--- a/mp/src/public/engine/ivmodelrender.h
+++ b/mp/src/public/engine/ivmodelrender.h
@@ -138,6 +138,8 @@ public:
// radius of the decal to create.
virtual void AddDecal( ModelInstanceHandle_t handle, Ray_t const& ray,
Vector const& decalUp, int decalIndex, int body, bool noPokeThru = false, int maxLODToDecal = ADDDECAL_TO_ALL_LODS ) = 0;
+ virtual void AddColoredDecal( ModelInstanceHandle_t handle, Ray_t const& ray,
+ Vector const& decalUp, int decalIndex, int body, Color cColor, bool noPokeThru = false, int maxLODToDecal = ADDDECAL_TO_ALL_LODS ) = 0;
// Removes all the decals on a model instance
virtual void RemoveAllDecals( ModelInstanceHandle_t handle ) = 0;
diff --git a/mp/src/public/game/server/pluginvariant.h b/mp/src/public/game/server/pluginvariant.h
index 1f0d5f32..5eb67a5e 100644
--- a/mp/src/public/game/server/pluginvariant.h
+++ b/mp/src/public/game/server/pluginvariant.h
@@ -56,7 +56,7 @@ public:
fieldtype_t FieldType( void ) { return fieldType; }
void SetBool( bool b ) { bVal = b; fieldType = FIELD_BOOLEAN; }
- void SetString( char *str ) { Q_snprintf(iszVal, 1024, str); fieldType = FIELD_STRING; }
+ void SetString( char *str ) { Q_snprintf(iszVal, 1024, "%s", str); fieldType = FIELD_STRING; }
void SetInt( int val ) { iVal = val, fieldType = FIELD_INTEGER; }
void SetFloat( float val ) { flVal = val, fieldType = FIELD_FLOAT; }
void SetEdict( edict_t *val ) { eVal = val; fieldType = FIELD_EHANDLE; }
diff --git a/mp/src/public/inputsystem/iinputsystem.h b/mp/src/public/inputsystem/iinputsystem.h
index f2453067..55dd0559 100644
--- a/mp/src/public/inputsystem/iinputsystem.h
+++ b/mp/src/public/inputsystem/iinputsystem.h
@@ -117,6 +117,13 @@ public:
// read and clear accumulated raw input values
virtual bool GetRawMouseAccumulators( int& accumX, int& accumY ) = 0;
+
+ // tell the input system that we're not a game, we're console text mode.
+ // this is used for dedicated servers to not initialize joystick system.
+ // this needs to be called before CInputSystem::Init (e.g. in PreInit of
+ // some system) if you want ot prevent the joystick system from ever
+ // being initialized.
+ virtual void SetConsoleTextMode( bool bConsoleTextMode ) = 0;
};
diff --git a/mp/src/public/tier0/dbg.h b/mp/src/public/tier0/dbg.h
index c1f8794e..2faa26a5 100644
--- a/mp/src/public/tier0/dbg.h
+++ b/mp/src/public/tier0/dbg.h
@@ -253,9 +253,13 @@ DBG_INTERFACE struct SDL_Window * GetAssertDialogParent();
if ( ret == SPEW_DEBUGGER) \
{ \
if ( !ShouldUseNewAssertDialog() || DoNewAssertDialog( __TFILE__, __LINE__, _msg ) ) \
+ { \
DebuggerBreak(); \
+ } \
if ( _bFatal ) \
+ { \
_ExitOnFatalAssert( __TFILE__, __LINE__ ); \
+ } \
} \
} \
} while (0)
diff --git a/mp/src/public/tier0/platform.h b/mp/src/public/tier0/platform.h
index 38e6b563..1ff753f5 100644
--- a/mp/src/public/tier0/platform.h
+++ b/mp/src/public/tier0/platform.h
@@ -150,7 +150,6 @@ typedef signed char int8;
#if defined(__x86_64__) || defined(_WIN64)
#define X64BITS
- #define PLATFORM_64BITS
#endif // __x86_64__
#if defined( _WIN32 )
@@ -391,7 +390,7 @@ typedef void * HINSTANCE;
// On OSX, SIGTRAP doesn't really stop the thread cold when debugging.
// So if being debugged, use INT3 which is precise.
#ifdef OSX
-#define DebuggerBreak() if ( Plat_IsInDebugSession() ) __asm ( "int $3" ); else { raise(SIGTRAP); }
+#define DebuggerBreak() if ( Plat_IsInDebugSession() ) { __asm ( "int $3" ); } else { raise(SIGTRAP); }
#else
#define DebuggerBreak() raise(SIGTRAP)
#endif
@@ -662,6 +661,7 @@ typedef void * HINSTANCE;
#pragma GCC diagnostic ignored "-Wconversion-null" // passing NULL to non-pointer argument 1
#pragma GCC diagnostic ignored "-Wnull-arithmetic" // NULL used in arithmetic. Ie, vpanel == NULL where VPANEL is uint.
#pragma GCC diagnostic ignored "-Wswitch-enum" // enumeration values not handled in switch
+#pragma GCC diagnostic ignored "-Wswitch" // enumeration values not handled in switch
#endif
diff --git a/mp/src/public/tier1/fmtstr.h b/mp/src/public/tier1/fmtstr.h
index d9d5fef2..64d44add 100644
--- a/mp/src/public/tier1/fmtstr.h
+++ b/mp/src/public/tier1/fmtstr.h
@@ -18,6 +18,9 @@
#if defined( _WIN32 )
#pragma once
#endif
+#if defined(POSIX)
+#pragma GCC visibility push(hidden)
+#endif
//=============================================================================
@@ -28,7 +31,7 @@
int result; \
va_list arg_ptr; \
bool bTruncated = false; \
- static int scAsserted = 0; \
+ static unsigned int scAsserted = 0; \
\
va_start(arg_ptr, lastArg); \
result = Q_vsnprintfRet( (szBuf), nBufSize, (*(ppszFormat)), arg_ptr, &bTruncated ); \
@@ -115,7 +118,7 @@ public:
m_nLength = 0;
}
- void AppendFormat( PRINTF_FORMAT_STRING const char *pchFormat, ... )
+ void AppendFormat(PRINTF_FORMAT_STRING const char *pchFormat, ... ) FMTFUNCTION( 2, 3 )
{
char *pchEnd = m_szBuf + m_nLength;
FmtStrVSNPrintf( pchEnd, SIZE_BUF - m_nLength, m_bQuietTruncation, &pchFormat, m_nLength, pchFormat );
@@ -174,6 +177,10 @@ void CFmtStrN<SIZE_BUF>::AppendFormatV( const char *pchFormat, va_list args )
}
+#if defined(POSIX)
+#pragma GCC visibility pop
+#endif
+
//-----------------------------------------------------------------------------
//
// Purpose: Default-sized string formatter
diff --git a/mp/src/public/tier1/utlstring.h b/mp/src/public/tier1/utlstring.h
index eec22dfa..26d98338 100644
--- a/mp/src/public/tier1/utlstring.h
+++ b/mp/src/public/tier1/utlstring.h
@@ -16,7 +16,8 @@
#include "limits.h"
#if defined( OSX )
-inline wchar_t *wcsdup(const wchar_t *pString)
+#define wcsdup wcsdup_osx
+inline wchar_t *wcsdup_osx(const wchar_t *pString)
{
wchar_t *pMemory;
diff --git a/mp/src/public/vgui_controls/Panel.h b/mp/src/public/vgui_controls/Panel.h
index afbfd177..23af650c 100644
--- a/mp/src/public/vgui_controls/Panel.h
+++ b/mp/src/public/vgui_controls/Panel.h
@@ -519,10 +519,10 @@ public:
// [tj] Simple getters and setters to decide which corners to draw rounded
unsigned char GetRoundedCorners() { return m_roundedCorners; }
void SetRoundedCorners (unsigned char cornerFlags) { m_roundedCorners = cornerFlags; }
- bool ShouldDrawTopLeftCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_TOP_LEFT; }
- bool ShouldDrawTopRightCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_TOP_RIGHT; }
- bool ShouldDrawBottomLeftCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_LEFT; }
- bool ShouldDrawBottomRightCornerRounded() { return m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_RIGHT; }
+ bool ShouldDrawTopLeftCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_TOP_LEFT ) != 0; }
+ bool ShouldDrawTopRightCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_TOP_RIGHT ) != 0; }
+ bool ShouldDrawBottomLeftCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_LEFT ) != 0; }
+ bool ShouldDrawBottomRightCornerRounded() { return ( m_roundedCorners & PANEL_ROUND_CORNER_BOTTOM_RIGHT ) != 0; }
//=============================================================================
// HPE_END
diff --git a/mp/src/raytrace/raytrace.cpp b/mp/src/raytrace/raytrace.cpp
new file mode 100644
index 00000000..142220e2
--- /dev/null
+++ b/mp/src/raytrace/raytrace.cpp
@@ -0,0 +1,901 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+// $Id$
+
+#include "raytrace.h"
+#include <filesystem_tools.h>
+#include <cmdlib.h>
+#include <stdio.h>
+
+static bool SameSign(float a, float b)
+{
+ int32 aa=*((int *) &a);
+ int32 bb=*((int *) &b);
+ return ((aa^bb)&0x80000000)==0;
+}
+
+int FourRays::CalculateDirectionSignMask(void) const
+{
+ // this code treats the floats as integers since all it cares about is the sign bit and
+ // floating point compares suck.
+
+ int ret;
+ int ormask;
+ int andmask;
+ int32 const *treat_as_int=((int32 const *) (&direction));
+
+ ormask=andmask=*(treat_as_int++);
+ ormask|=*treat_as_int;
+ andmask&=*(treat_as_int++);
+ ormask|=*(treat_as_int);
+ andmask&=*(treat_as_int++);
+ ormask|=*(treat_as_int);
+ andmask&=*(treat_as_int++);
+ if (ormask>=0)
+ ret=0;
+ else
+ {
+ if (andmask<0)
+ ret=1;
+ else return -1;
+ }
+ ormask=andmask=*(treat_as_int++);
+ ormask|=*treat_as_int;
+ andmask&=*(treat_as_int++);
+ ormask|=*(treat_as_int);
+ andmask&=*(treat_as_int++);
+ ormask|=*(treat_as_int);
+ andmask&=*(treat_as_int++);
+ if (ormask<0)
+ {
+ if (andmask<0)
+ ret|=2;
+ else return -1;
+ }
+ ormask=andmask=*(treat_as_int++);
+ ormask|=*treat_as_int;
+ andmask&=*(treat_as_int++);
+ ormask|=*(treat_as_int);
+ andmask&=*(treat_as_int++);
+ ormask|=*(treat_as_int);
+ andmask&=*(treat_as_int++);
+ if (ormask<0)
+ {
+ if (andmask<0)
+ ret|=4;
+ else return -1;
+ }
+ return ret;
+}
+
+
+
+
+void RayTracingEnvironment::MakeRoomForTriangles( int ntris )
+{
+ //OptimizedTriangleList.EnsureCapacity( ntris );
+ if (! (Flags & RTE_FLAGS_DONT_STORE_TRIANGLE_COLORS))
+ TriangleColors.EnsureCapacity( ntris );
+}
+
+
+void RayTracingEnvironment::AddTriangle(int32 id, const Vector &v1,
+ const Vector &v2, const Vector &v3,
+ const Vector &color)
+{
+ AddTriangle( id, v1, v2, v3, color, 0, 0 );
+}
+
+void RayTracingEnvironment::AddTriangle(int32 id, const Vector &v1,
+ const Vector &v2, const Vector &v3,
+ const Vector &color, uint16 flags, int32 materialIndex)
+{
+ CacheOptimizedTriangle tmptri;
+ tmptri.m_Data.m_GeometryData.m_nTriangleID = id;
+ tmptri.Vertex( 0 ) = v1;
+ tmptri.Vertex( 1 ) = v2;
+ tmptri.Vertex( 2 ) = v3;
+ tmptri.m_Data.m_GeometryData.m_nFlags = flags;
+ OptimizedTriangleList.AddToTail(tmptri);
+ if (! ( Flags & RTE_FLAGS_DONT_STORE_TRIANGLE_COLORS) )
+ TriangleColors.AddToTail(color);
+ if ( !( Flags & RTE_FLAGS_DONT_STORE_TRIANGLE_MATERIALS) )
+ TriangleMaterials.AddToTail(materialIndex);
+// printf("add triange from (%f %f %f),(%f %f %f),(%f %f %f) id %d\n",
+// XYZ(v1),XYZ(v2),XYZ(v3),id);
+}
+
+void RayTracingEnvironment::AddQuad(
+ int32 id, const Vector &v1, const Vector &v2, const Vector &v3,
+ const Vector &v4, // specify vertices in cw or ccw order
+ const Vector &color)
+{
+ AddTriangle(id,v1,v2,v3,color);
+ AddTriangle(id+1,v1,v3,v4,color);
+}
+
+
+void RayTracingEnvironment::AddAxisAlignedRectangularSolid(int id,Vector minc, Vector maxc,
+ const Vector &color)
+{
+
+ // "far" face
+ AddQuad(id,
+ Vector(minc.x,maxc.y,maxc.z),
+ Vector(maxc.x,maxc.y,maxc.z),Vector(maxc.x,minc.y,maxc.z),
+ Vector(minc.x,minc.y,maxc.z),color);
+ // "near" face
+ AddQuad(id,
+ Vector(minc.x,maxc.y,minc.z),
+ Vector(maxc.x,maxc.y,minc.z),Vector(maxc.x,minc.y,minc.z),
+ Vector(minc.x,minc.y,minc.z),color);
+
+ // "left" face
+ AddQuad(id,
+ Vector(minc.x,maxc.y,maxc.z),
+ Vector(minc.x,maxc.y,minc.z),
+ Vector(minc.x,minc.y,minc.z),
+ Vector(minc.x,minc.y,maxc.z),color);
+ // "right" face
+ AddQuad(id,
+ Vector(maxc.x,maxc.y,maxc.z),
+ Vector(maxc.x,maxc.y,minc.z),
+ Vector(maxc.x,minc.y,minc.z),
+ Vector(maxc.x,minc.y,maxc.z),color);
+
+ // "top" face
+ AddQuad(id,
+ Vector(minc.x,maxc.y,maxc.z),
+ Vector(maxc.x,maxc.y,maxc.z),
+ Vector(maxc.x,maxc.y,minc.z),
+ Vector(minc.x,maxc.y,minc.z),color);
+ // "bot" face
+ AddQuad(id,
+ Vector(minc.x,minc.y,maxc.z),
+ Vector(maxc.x,minc.y,maxc.z),
+ Vector(maxc.x,minc.y,minc.z),
+ Vector(minc.x,minc.y,minc.z),color);
+}
+
+
+
+static Vector GetEdgeEquation(Vector p1, Vector p2, int c1, int c2, Vector InsidePoint)
+{
+ float nx=p1[c2]-p2[c2];
+ float ny=p2[c1]-p1[c1];
+ float d=-(nx*p1[c1]+ny*p1[c2]);
+// assert(fabs(nx*p1[c1]+ny*p1[c2]+d)<0.01);
+// assert(fabs(nx*p2[c1]+ny*p2[c2]+d)<0.01);
+
+ // use the convention that negative is "outside"
+ float trial_dist=InsidePoint[c1]*nx+InsidePoint[c2]*ny+d;
+ if (trial_dist<0)
+ {
+ nx = -nx;
+ ny = -ny;
+ d = -d;
+ trial_dist = -trial_dist;
+ }
+ nx /= trial_dist; // scale so that it will be =1.0 at the oppositve vertex
+ ny /= trial_dist;
+ d /= trial_dist;
+
+ return Vector(nx,ny,d);
+}
+
+void CacheOptimizedTriangle::ChangeIntoIntersectionFormat(void)
+{
+ // lose the vertices and use edge equations instead
+
+ // grab the whole original triangle to we don't overwrite it
+ TriGeometryData_t srcTri = m_Data.m_GeometryData;
+
+ m_Data.m_IntersectData.m_nFlags = srcTri.m_nFlags;
+ m_Data.m_IntersectData.m_nTriangleID = srcTri.m_nTriangleID;
+
+ Vector p1 = srcTri.Vertex( 0 );
+ Vector p2 = srcTri.Vertex( 1 );
+ Vector p3 = srcTri.Vertex( 2 );
+
+ Vector e1 = p2 - p1;
+ Vector e2 = p3 - p1;
+
+ Vector N = e1.Cross( e2 );
+ N.NormalizeInPlace();
+ // now, determine which axis to drop
+ int drop_axis = 0;
+ for(int c=1 ; c<3 ; c++)
+ if ( fabs(N[c]) > fabs( N[drop_axis] ) )
+ drop_axis = c;
+
+ m_Data.m_IntersectData.m_flD = N.Dot( p1 );
+ m_Data.m_IntersectData.m_flNx = N.x;
+ m_Data.m_IntersectData.m_flNy = N.y;
+ m_Data.m_IntersectData.m_flNz = N.z;
+
+ // decide which axes to keep
+ int nCoordSelect0 = ( drop_axis + 1 ) % 3;
+ int nCoordSelect1 = ( drop_axis + 2 ) % 3;
+
+ m_Data.m_IntersectData.m_nCoordSelect0 = nCoordSelect0;
+ m_Data.m_IntersectData.m_nCoordSelect1 = nCoordSelect1;
+
+
+ Vector edge1 = GetEdgeEquation( p1, p2, nCoordSelect0, nCoordSelect1, p3 );
+ m_Data.m_IntersectData.m_ProjectedEdgeEquations[0] = edge1.x;
+ m_Data.m_IntersectData.m_ProjectedEdgeEquations[1] = edge1.y;
+ m_Data.m_IntersectData.m_ProjectedEdgeEquations[2] = edge1.z;
+
+ Vector edge2 = GetEdgeEquation( p2, p3, nCoordSelect0, nCoordSelect1, p1 );
+ m_Data.m_IntersectData.m_ProjectedEdgeEquations[3] = edge2.x;
+ m_Data.m_IntersectData.m_ProjectedEdgeEquations[4] = edge2.y;
+ m_Data.m_IntersectData.m_ProjectedEdgeEquations[5] = edge2.z;
+
+
+}
+
+int n_intersection_calculations=0;
+
+int CacheOptimizedTriangle::ClassifyAgainstAxisSplit(int split_plane, float split_value)
+{
+ // classify a triangle against an axis-aligned plane
+ float minc=Vertex(0)[split_plane];
+ float maxc=minc;
+ for(int v=1;v<3;v++)
+ {
+ minc=min(minc,Vertex(v)[split_plane]);
+ maxc=max(maxc,Vertex(v)[split_plane]);
+ }
+
+ if (minc>=split_value)
+ return PLANECHECK_POSITIVE;
+ if (maxc<=split_value)
+ return PLANECHECK_NEGATIVE;
+ if (minc==maxc)
+ return PLANECHECK_POSITIVE;
+ return PLANECHECK_STRADDLING;
+}
+
+#define MAILBOX_HASH_SIZE 256
+#define MAX_TREE_DEPTH 21
+#define MAX_NODE_STACK_LEN (40*MAX_TREE_DEPTH)
+
+struct NodeToVisit {
+ CacheOptimizedKDNode const *node;
+ fltx4 TMin;
+ fltx4 TMax;
+};
+
+
+static fltx4 FourEpsilons={1.0e-10,1.0e-10,1.0e-10,1.0e-10};
+static fltx4 FourZeros={1.0e-10,1.0e-10,1.0e-10,1.0e-10};
+static fltx4 FourNegativeEpsilons={-1.0e-10,-1.0e-10,-1.0e-10,-1.0e-10};
+
+static float BoxSurfaceArea(Vector const &boxmin, Vector const &boxmax)
+{
+ Vector boxdim=boxmax-boxmin;
+ return 2.0*((boxdim[0]*boxdim[2])+(boxdim[0]*boxdim[1])+(boxdim[1]*boxdim[2]));
+}
+
+void RayTracingEnvironment::Trace4Rays(const FourRays &rays, fltx4 TMin, fltx4 TMax,
+ RayTracingResult *rslt_out,
+ int32 skip_id, ITransparentTriangleCallback *pCallback)
+{
+ int msk=rays.CalculateDirectionSignMask();
+ if (msk!=-1)
+ Trace4Rays(rays,TMin,TMax,msk,rslt_out,skip_id, pCallback);
+ else
+ {
+ // sucky case - can't trace 4 rays at once. in the worst case, need to trace all 4
+ // separately, but usually we will still get 2x, Since our tracer only does 4 at a
+ // time, we will have to cover up the undesired rays with the desired ray
+
+ //!! speed!! there is room for some sse-ization here
+ FourRays tmprays;
+ tmprays.origin=rays.origin;
+
+ uint8 need_trace[4]={1,1,1,1};
+ for(int try_trace=0;try_trace<4;try_trace++)
+ {
+ if (need_trace[try_trace])
+ {
+ need_trace[try_trace]=2; // going to trace it
+ // replicate the ray being traced into all 4 rays
+ tmprays.direction.x=ReplicateX4(rays.direction.X(try_trace));
+ tmprays.direction.y=ReplicateX4(rays.direction.Y(try_trace));
+ tmprays.direction.z=ReplicateX4(rays.direction.Z(try_trace));
+ // now, see if any of the other remaining rays can be handled at the same time.
+ for(int try2=try_trace+1;try2<4;try2++)
+ if (need_trace[try2])
+ {
+ if (
+ SameSign(rays.direction.X(try2),
+ rays.direction.X(try_trace)) &&
+ SameSign(rays.direction.Y(try2),
+ rays.direction.Y(try_trace)) &&
+ SameSign(rays.direction.Z(try2),
+ rays.direction.Z(try_trace)))
+ {
+ need_trace[try2]=2;
+ tmprays.direction.X(try2) = rays.direction.X(try2);
+ tmprays.direction.Y(try2) = rays.direction.Y(try2);
+ tmprays.direction.Z(try2) = rays.direction.Z(try2);
+ }
+ }
+ // ok, now trace between 1 and 3 rays, and output the results
+ RayTracingResult tmpresults;
+ msk=tmprays.CalculateDirectionSignMask();
+ assert(msk!=-1);
+ Trace4Rays(tmprays,TMin,TMax,msk,&tmpresults,skip_id, pCallback);
+ // now, move results to proper place
+ for(int i=0;i<4;i++)
+ if (need_trace[i]==2)
+ {
+ need_trace[i]=0;
+ rslt_out->HitIds[i]=tmpresults.HitIds[i];
+ SubFloat(rslt_out->HitDistance, i) = SubFloat(tmpresults.HitDistance, i);
+ rslt_out->surface_normal.X(i) = tmpresults.surface_normal.X(i);
+ rslt_out->surface_normal.Y(i) = tmpresults.surface_normal.Y(i);
+ rslt_out->surface_normal.Z(i) = tmpresults.surface_normal.Z(i);
+ }
+
+ }
+ }
+ }
+}
+
+
+void RayTracingEnvironment::Trace4Rays(const FourRays &rays, fltx4 TMin, fltx4 TMax,
+ int DirectionSignMask, RayTracingResult *rslt_out,
+ int32 skip_id, ITransparentTriangleCallback *pCallback)
+{
+ rays.Check();
+
+ memset(rslt_out->HitIds,0xff,sizeof(rslt_out->HitIds));
+
+ rslt_out->HitDistance=ReplicateX4(1.0e23);
+
+ rslt_out->surface_normal.DuplicateVector(Vector(0.,0.,0.));
+ FourVectors OneOverRayDir=rays.direction;
+ OneOverRayDir.MakeReciprocalSaturate();
+
+ // now, clip rays against bounding box
+ for(int c=0;c<3;c++)
+ {
+ fltx4 isect_min_t=
+ MulSIMD(SubSIMD(ReplicateX4(m_MinBound[c]),rays.origin[c]),OneOverRayDir[c]);
+ fltx4 isect_max_t=
+ MulSIMD(SubSIMD(ReplicateX4(m_MaxBound[c]),rays.origin[c]),OneOverRayDir[c]);
+ TMin=MaxSIMD(TMin,MinSIMD(isect_min_t,isect_max_t));
+ TMax=MinSIMD(TMax,MaxSIMD(isect_min_t,isect_max_t));
+ }
+ fltx4 active=CmpLeSIMD(TMin,TMax); // mask of which rays are active
+ if (! IsAnyNegative(active) )
+ return; // missed bounding box
+
+ int32 mailboxids[MAILBOX_HASH_SIZE]; // used to avoid redundant triangle tests
+ memset(mailboxids,0xff,sizeof(mailboxids)); // !!speed!! keep around?
+
+ int front_idx[3],back_idx[3]; // based on ray direction, whether to
+ // visit left or right node first
+
+ if (DirectionSignMask & 1)
+ {
+ back_idx[0]=0;
+ front_idx[0]=1;
+ }
+ else
+ {
+ back_idx[0]=1;
+ front_idx[0]=0;
+ }
+ if (DirectionSignMask & 2)
+ {
+ back_idx[1]=0;
+ front_idx[1]=1;
+ }
+ else
+ {
+ back_idx[1]=1;
+ front_idx[1]=0;
+ }
+ if (DirectionSignMask & 4)
+ {
+ back_idx[2]=0;
+ front_idx[2]=1;
+ }
+ else
+ {
+ back_idx[2]=1;
+ front_idx[2]=0;
+ }
+
+ NodeToVisit NodeQueue[MAX_NODE_STACK_LEN];
+ CacheOptimizedKDNode const *CurNode=&(OptimizedKDTree[0]);
+ NodeToVisit *stack_ptr=&NodeQueue[MAX_NODE_STACK_LEN];
+ while(1)
+ {
+ while (CurNode->NodeType() != KDNODE_STATE_LEAF) // traverse until next leaf
+ {
+ int split_plane_number=CurNode->NodeType();
+ CacheOptimizedKDNode const *FrontChild=&(OptimizedKDTree[CurNode->LeftChild()]);
+
+ fltx4 dist_to_sep_plane= // dist=(split-org)/dir
+ MulSIMD(
+ SubSIMD(ReplicateX4(CurNode->SplittingPlaneValue),
+ rays.origin[split_plane_number]),OneOverRayDir[split_plane_number]);
+ fltx4 active=CmpLeSIMD(TMin,TMax); // mask of which rays are active
+
+ // now, decide how to traverse children. can either do front,back, or do front and push
+ // back.
+ fltx4 hits_front=AndSIMD(active,CmpGeSIMD(dist_to_sep_plane,TMin));
+ if (! IsAnyNegative(hits_front))
+ {
+ // missed the front. only traverse back
+ //printf("only visit back %d\n",CurNode->LeftChild()+back_idx[split_plane_number]);
+ CurNode=FrontChild+back_idx[split_plane_number];
+ TMin=MaxSIMD(TMin, dist_to_sep_plane);
+
+ }
+ else
+ {
+ fltx4 hits_back=AndSIMD(active,CmpLeSIMD(dist_to_sep_plane,TMax));
+ if (! IsAnyNegative(hits_back) )
+ {
+ // missed the back - only need to traverse front node
+ //printf("only visit front %d\n",CurNode->LeftChild()+front_idx[split_plane_number]);
+ CurNode=FrontChild+front_idx[split_plane_number];
+ TMax=MinSIMD(TMax, dist_to_sep_plane);
+ }
+ else
+ {
+ // at least some rays hit both nodes.
+ // must push far, traverse near
+ //printf("visit %d,%d\n",CurNode->LeftChild()+front_idx[split_plane_number],
+ // CurNode->LeftChild()+back_idx[split_plane_number]);
+ assert(stack_ptr>NodeQueue);
+ --stack_ptr;
+ stack_ptr->node=FrontChild+back_idx[split_plane_number];
+ stack_ptr->TMin=MaxSIMD(TMin,dist_to_sep_plane);
+ stack_ptr->TMax=TMax;
+ CurNode=FrontChild+front_idx[split_plane_number];
+ TMax=MinSIMD(TMax,dist_to_sep_plane);
+ }
+ }
+ }
+ // hit a leaf! must do intersection check
+ int ntris=CurNode->NumberOfTrianglesInLeaf();
+ if (ntris)
+ {
+ int32 const *tlist=&(TriangleIndexList[CurNode->TriangleIndexStart()]);
+ do
+ {
+ int tnum=*(tlist++);
+ //printf("try tri %d\n",tnum);
+ // check mailbox
+ int mbox_slot=tnum & (MAILBOX_HASH_SIZE-1);
+ TriIntersectData_t const *tri = &( OptimizedTriangleList[tnum].m_Data.m_IntersectData );
+ if ( ( mailboxids[mbox_slot] != tnum ) && ( tri->m_nTriangleID != skip_id ) )
+ {
+ n_intersection_calculations++;
+ mailboxids[mbox_slot] = tnum;
+ // compute plane intersection
+
+
+ FourVectors N;
+ N.x = ReplicateX4( tri->m_flNx );
+ N.y = ReplicateX4( tri->m_flNy );
+ N.z = ReplicateX4( tri->m_flNz );
+
+ fltx4 DDotN = rays.direction * N;
+ // mask off zero or near zero (ray parallel to surface)
+ fltx4 did_hit = OrSIMD( CmpGtSIMD( DDotN,FourEpsilons ),
+ CmpLtSIMD( DDotN, FourNegativeEpsilons ) );
+
+ fltx4 numerator=SubSIMD( ReplicateX4( tri->m_flD ), rays.origin * N );
+
+ fltx4 isect_t=DivSIMD( numerator,DDotN );
+ // now, we have the distance to the plane. lets update our mask
+ did_hit = AndSIMD( did_hit, CmpGtSIMD( isect_t, FourZeros ) );
+ //did_hit=AndSIMD(did_hit,CmpLtSIMD(isect_t,TMax));
+ did_hit = AndSIMD( did_hit, CmpLtSIMD( isect_t, rslt_out->HitDistance ) );
+
+ if ( ! IsAnyNegative( did_hit ) )
+ continue;
+
+ // now, check 3 edges
+ fltx4 hitc1 = AddSIMD( rays.origin[tri->m_nCoordSelect0],
+ MulSIMD( isect_t, rays.direction[ tri->m_nCoordSelect0] ) );
+ fltx4 hitc2 = AddSIMD( rays.origin[tri->m_nCoordSelect1],
+ MulSIMD( isect_t, rays.direction[tri->m_nCoordSelect1] ) );
+
+ // do barycentric coordinate check
+ fltx4 B0 = MulSIMD( ReplicateX4( tri->m_ProjectedEdgeEquations[0] ), hitc1 );
+
+ B0 = AddSIMD(
+ B0,
+ MulSIMD( ReplicateX4( tri->m_ProjectedEdgeEquations[1] ), hitc2 ) );
+ B0 = AddSIMD(
+ B0, ReplicateX4( tri->m_ProjectedEdgeEquations[2] ) );
+
+ did_hit = AndSIMD( did_hit, CmpGeSIMD( B0, FourZeros ) );
+
+ fltx4 B1 = MulSIMD( ReplicateX4( tri->m_ProjectedEdgeEquations[3] ), hitc1 );
+ B1 = AddSIMD(
+ B1,
+ MulSIMD( ReplicateX4( tri->m_ProjectedEdgeEquations[4]), hitc2 ) );
+
+ B1 = AddSIMD(
+ B1, ReplicateX4( tri->m_ProjectedEdgeEquations[5] ) );
+
+ did_hit = AndSIMD( did_hit, CmpGeSIMD( B1, FourZeros ) );
+
+ fltx4 B2 = AddSIMD( B1, B0 );
+ did_hit = AndSIMD( did_hit, CmpLeSIMD( B2, Four_Ones ) );
+
+ if ( ! IsAnyNegative( did_hit ) )
+ continue;
+
+ // if the triangle is transparent
+ if ( tri->m_nFlags & FCACHETRI_TRANSPARENT )
+ {
+ if ( pCallback )
+ {
+ // assuming a triangle indexed as v0, v1, v2
+ // the projected edge equations are set up such that the vert opposite the first
+ // equation is v2, and the vert opposite the second equation is v0
+ // Therefore we pass them back in 1, 2, 0 order
+ // Also B2 is currently B1 + B0 and needs to be 1 - (B1+B0) in order to be a real
+ // barycentric coordinate. Compute that now and pass it to the callback
+ fltx4 b2 = SubSIMD( Four_Ones, B2 );
+ if ( pCallback->VisitTriangle_ShouldContinue( *tri, rays, &did_hit, &B1, &b2, &B0, tnum ) )
+ {
+ did_hit = Four_Zeros;
+ }
+ }
+ }
+ // now, set the hit_id and closest_hit fields for any enabled rays
+ fltx4 replicated_n = ReplicateIX4(tnum);
+ StoreAlignedSIMD((float *) rslt_out->HitIds,
+ OrSIMD(AndSIMD(replicated_n,did_hit),
+ AndNotSIMD(did_hit,LoadAlignedSIMD(
+ (float *) rslt_out->HitIds))));
+ rslt_out->HitDistance=OrSIMD(AndSIMD(isect_t,did_hit),
+ AndNotSIMD(did_hit,rslt_out->HitDistance));
+
+ rslt_out->surface_normal.x=OrSIMD(
+ AndSIMD(N.x,did_hit),
+ AndNotSIMD(did_hit,rslt_out->surface_normal.x));
+ rslt_out->surface_normal.y=OrSIMD(
+ AndSIMD(N.y,did_hit),
+ AndNotSIMD(did_hit,rslt_out->surface_normal.y));
+ rslt_out->surface_normal.z=OrSIMD(
+ AndSIMD(N.z,did_hit),
+ AndNotSIMD(did_hit,rslt_out->surface_normal.z));
+
+ }
+ } while (--ntris);
+ // now, check if all rays have terminated
+ fltx4 raydone=CmpLeSIMD(TMax,rslt_out->HitDistance);
+ if (! IsAnyNegative(raydone))
+ {
+ return;
+ }
+ }
+
+ if (stack_ptr==&NodeQueue[MAX_NODE_STACK_LEN])
+ {
+ return;
+ }
+ // pop stack!
+ CurNode=stack_ptr->node;
+ TMin=stack_ptr->TMin;
+ TMax=stack_ptr->TMax;
+ stack_ptr++;
+ }
+}
+
+
+int RayTracingEnvironment::MakeLeafNode(int first_tri, int last_tri)
+{
+ CacheOptimizedKDNode ret;
+ ret.Children=KDNODE_STATE_LEAF+(TriangleIndexList.Count()<<2);
+ ret.SetNumberOfTrianglesInLeafNode(1+(last_tri-first_tri));
+ for(int tnum=first_tri;tnum<=last_tri;tnum++)
+ TriangleIndexList.AddToTail(tnum);
+ OptimizedKDTree.AddToTail(ret);
+ return OptimizedKDTree.Count()-1;
+}
+
+
+void RayTracingEnvironment::CalculateTriangleListBounds(int32 const *tris,int ntris,
+ Vector &minout, Vector &maxout)
+{
+ minout = Vector( 1.0e23, 1.0e23, 1.0e23);
+ maxout = Vector( -1.0e23, -1.0e23, -1.0e23);
+ for(int i=0; i<ntris; i++)
+ {
+ CacheOptimizedTriangle const &tri=OptimizedTriangleList[tris[i]];
+ for(int v=0; v<3; v++)
+ for(int c=0; c<3; c++)
+ {
+ minout[c]=min(minout[c],tri.Vertex(v)[c]);
+ maxout[c]=max(maxout[c],tri.Vertex(v)[c]);
+ }
+ }
+}
+
+
+// Both the "quick" and regular kd tree building algorithms here use the "surface area heuristic":
+// the relative probability of hitting the "left" subvolume (Vl) from a split is equal to that
+// subvolume's surface area divided by its parent's surface area (Vp) : P(Vl | V)=SA(Vl)/SA(Vp).
+// The same holds for the right subvolume, Vp. Nl is the number of triangles in the left volume,
+// and Nr in the right volume. if Ct is the cost of traversing one tree node, and Ci is the cost of
+// intersection with the primitive, than the cost of splitting is estimated as:
+//
+// Ct+Ci*((SA(Vl)/SA(V))*Nl+(SA(Vr)/SA(V)*Nr)).
+// and the cost of not splitting is
+// Ci*N
+//
+// This both provides a metric to minimize when computing how and where to split, and also a
+// termination criterion.
+//
+// the "quick" method just splits down the middle, while the slow method splits at the best
+// discontinuity of the cost formula. The quick method splits along the longest axis ; the
+// regular algorithm tries all 3 to find which one results in the minimum cost
+//
+// both methods use the additional optimization of "growing" empty nodes - if the split results in
+// one side being devoid of triangles, the empty side is "grown" as much as possible.
+//
+
+#define COST_OF_TRAVERSAL 75 // approximate #operations
+#define COST_OF_INTERSECTION 167 // approximate #operations
+
+
+float RayTracingEnvironment::CalculateCostsOfSplit(
+ int split_plane,int32 const *tri_list,int ntris,
+ Vector MinBound,Vector MaxBound, float &split_value,
+ int &nleft, int &nright, int &nboth)
+{
+ // determine the costs of splitting on a given axis, and label triangles with respect to
+ // that axis by storing the value in coordselect0. It will also return the number of
+ // tris in the left, right, and nboth groups, in order to facilitate memory
+ nleft=nboth=nright=0;
+
+ // now, label each triangle. Since we have not converted the triangles into
+ // intersection fromat yet, we can use the CoordSelect0 field of each as a temp.
+ nleft=0;
+ nright=0;
+ nboth=0;
+ float min_coord=1.0e23,max_coord=-1.0e23;
+
+ for(int t=0;t<ntris;t++)
+ {
+ CacheOptimizedTriangle &tri=OptimizedTriangleList[tri_list[t]];
+ // determine max and min coordinate values for later optimization
+ for(int v=0;v<3;v++)
+ {
+ min_coord = min( min_coord, tri.Vertex(v)[split_plane] );
+ max_coord = max( max_coord, tri.Vertex(v)[split_plane] );
+ }
+ switch(tri.ClassifyAgainstAxisSplit(split_plane,split_value))
+ {
+ case PLANECHECK_NEGATIVE:
+ nleft++;
+ tri.m_Data.m_GeometryData.m_nTmpData0 = PLANECHECK_NEGATIVE;
+ break;
+
+ case PLANECHECK_POSITIVE:
+ nright++;
+ tri.m_Data.m_GeometryData.m_nTmpData0 = PLANECHECK_POSITIVE;
+ break;
+
+ case PLANECHECK_STRADDLING:
+ nboth++;
+ tri.m_Data.m_GeometryData.m_nTmpData0 = PLANECHECK_STRADDLING;
+ break;
+ }
+ }
+ // now, if the split resulted in one half being empty, "grow" the empty half
+ if (nleft && (nboth==0) && (nright==0))
+ split_value=max_coord;
+ if (nright && (nboth==0) && (nleft==0))
+ split_value=min_coord;
+
+ // now, perform surface area/cost check to determine whether this split was worth it
+ Vector LeftMins=MinBound;
+ Vector LeftMaxes=MaxBound;
+ Vector RightMins=MinBound;
+ Vector RightMaxes=MaxBound;
+ LeftMaxes[split_plane]=split_value;
+ RightMins[split_plane]=split_value;
+ float SA_L=BoxSurfaceArea(LeftMins,LeftMaxes);
+ float SA_R=BoxSurfaceArea(RightMins,RightMaxes);
+ float ISA=1.0/BoxSurfaceArea(MinBound,MaxBound);
+ float cost_of_split=COST_OF_TRAVERSAL+COST_OF_INTERSECTION*(nboth+
+ (SA_L*ISA*(nleft))+(SA_R*ISA*(nright)));
+ return cost_of_split;
+}
+
+
+#define NEVER_SPLIT 0
+
+void RayTracingEnvironment::RefineNode(int node_number,int32 const *tri_list,int ntris,
+ Vector MinBound,Vector MaxBound, int depth)
+{
+ if (ntris<3) // never split empty lists
+ {
+ // no point in continuing
+ OptimizedKDTree[node_number].Children=KDNODE_STATE_LEAF+(TriangleIndexList.Count()<<2);
+ OptimizedKDTree[node_number].SetNumberOfTrianglesInLeafNode(ntris);
+
+#ifdef DEBUG_RAYTRACE
+ OptimizedKDTree[node_number].vecMins = MinBound;
+ OptimizedKDTree[node_number].vecMaxs = MaxBound;
+#endif
+
+ for(int t=0;t<ntris;t++)
+ TriangleIndexList.AddToTail(tri_list[t]);
+ return;
+ }
+
+ float best_cost=1.0e23;
+ int best_nleft=0,best_nright=0,best_nboth=0;
+ float best_splitvalue=0;
+ int split_plane=0;
+
+ int tri_skip=1+(ntris/10); // don't try all trinagles as split
+ // points when there are a lot of them
+ for(int axis=0;axis<3;axis++)
+ {
+ for(int ts=-1;ts<ntris;ts+=tri_skip)
+ {
+ for(int tv=0;tv<3;tv++)
+ {
+ int trial_nleft,trial_nright,trial_nboth;
+ float trial_splitvalue;
+ if (ts==-1)
+ trial_splitvalue=0.5*(MinBound[axis]+MaxBound[axis]);
+ else
+ {
+ // else, split at the triangle vertex if possible
+ CacheOptimizedTriangle &tri=OptimizedTriangleList[tri_list[ts]];
+ trial_splitvalue = tri.Vertex(tv)[axis];
+ if ((trial_splitvalue>MaxBound[axis]) || (trial_splitvalue<MinBound[axis]))
+ continue; // don't try this vertex - not inside
+
+ }
+// printf("ts=%d tv=%d tp=%f\n",ts,tv,trial_splitvalue);
+ float trial_cost=
+ CalculateCostsOfSplit(axis,tri_list,ntris,MinBound,MaxBound,trial_splitvalue,
+ trial_nleft,trial_nright, trial_nboth);
+// printf("try %d cost=%f nl=%d nr=%d nb=%d sp=%f\n",axis,trial_cost,trial_nleft,trial_nright, trial_nboth,
+// trial_splitvalue);
+ if (trial_cost<best_cost)
+ {
+ split_plane=axis;
+ best_cost=trial_cost;
+ best_nleft=trial_nleft;
+ best_nright=trial_nright;
+ best_nboth=trial_nboth;
+ best_splitvalue=trial_splitvalue;
+ // save away the axis classification of each triangle
+ for(int t=0 ; t < ntris; t++)
+ {
+ CacheOptimizedTriangle &tri=OptimizedTriangleList[tri_list[t]];
+ tri.m_Data.m_GeometryData.m_nTmpData1 = tri.m_Data.m_GeometryData.m_nTmpData0;
+ }
+ }
+ if (ts==-1)
+ break;
+ }
+ }
+
+ }
+ float cost_of_no_split=COST_OF_INTERSECTION*ntris;
+ if ( (cost_of_no_split<=best_cost) || NEVER_SPLIT || (depth>MAX_TREE_DEPTH))
+ {
+ // no benefit to splitting. just make this a leaf node
+ OptimizedKDTree[node_number].Children=KDNODE_STATE_LEAF+(TriangleIndexList.Count()<<2);
+ OptimizedKDTree[node_number].SetNumberOfTrianglesInLeafNode(ntris);
+#ifdef DEBUG_RAYTRACE
+ OptimizedKDTree[node_number].vecMins = MinBound;
+ OptimizedKDTree[node_number].vecMaxs = MaxBound;
+#endif
+ for(int t=0;t<ntris;t++)
+ TriangleIndexList.AddToTail(tri_list[t]);
+ }
+ else
+ {
+// printf("best split was %d at %f (mid=%f,n=%d, sk=%d)\n",split_plane,best_splitvalue,
+// 0.5*(MinBound[split_plane]+MaxBound[split_plane]),ntris,tri_skip);
+ // its worth splitting!
+ // we will achieve the splitting without sorting by using a selection algorithm.
+ int32 *new_triangle_list;
+ new_triangle_list=new int32[ntris];
+
+ // now, perform surface area/cost check to determine whether this split was worth it
+ Vector LeftMins=MinBound;
+ Vector LeftMaxes=MaxBound;
+ Vector RightMins=MinBound;
+ Vector RightMaxes=MaxBound;
+ LeftMaxes[split_plane]=best_splitvalue;
+ RightMins[split_plane]=best_splitvalue;
+
+ int n_left_output=0;
+ int n_both_output=0;
+ int n_right_output=0;
+ for(int t=0;t<ntris;t++)
+ {
+ CacheOptimizedTriangle &tri=OptimizedTriangleList[tri_list[t]];
+ switch( tri.m_Data.m_GeometryData.m_nTmpData1 )
+ {
+ case PLANECHECK_NEGATIVE:
+// printf("%d goes left\n",t);
+ new_triangle_list[n_left_output++]=tri_list[t];
+ break;
+ case PLANECHECK_POSITIVE:
+ n_right_output++;
+// printf("%d goes right\n",t);
+ new_triangle_list[ntris-n_right_output]=tri_list[t];
+ break;
+ case PLANECHECK_STRADDLING:
+// printf("%d goes both\n",t);
+ new_triangle_list[best_nleft+n_both_output]=tri_list[t];
+ n_both_output++;
+ break;
+
+
+ }
+ }
+ int left_child=OptimizedKDTree.Count();
+ int right_child=left_child+1;
+// printf("node %d split on axis %d at %f, nl=%d nr=%d nb=%d lc=%d rc=%d\n",node_number,
+// split_plane,best_splitvalue,best_nleft,best_nright,best_nboth,
+// left_child,right_child);
+ OptimizedKDTree[node_number].Children=split_plane+(left_child<<2);
+ OptimizedKDTree[node_number].SplittingPlaneValue=best_splitvalue;
+#ifdef DEBUG_RAYTRACE
+ OptimizedKDTree[node_number].vecMins = MinBound;
+ OptimizedKDTree[node_number].vecMaxs = MaxBound;
+#endif
+ CacheOptimizedKDNode newnode;
+ OptimizedKDTree.AddToTail(newnode);
+ OptimizedKDTree.AddToTail(newnode);
+ // now, recurse!
+ if ( (ntris<20) && ((best_nleft==0) || (best_nright==0)) )
+ depth+=100;
+ RefineNode(left_child,new_triangle_list,best_nleft+best_nboth,LeftMins,LeftMaxes,depth+1);
+ RefineNode(right_child,new_triangle_list+best_nleft,best_nright+best_nboth,
+ RightMins,RightMaxes,depth+1);
+ delete[] new_triangle_list;
+ }
+}
+
+
+void RayTracingEnvironment::SetupAccelerationStructure(void)
+{
+ CacheOptimizedKDNode root;
+ OptimizedKDTree.AddToTail(root);
+ int32 *root_triangle_list=new int32[OptimizedTriangleList.Count()];
+ for(int t=0;t<OptimizedTriangleList.Count();t++)
+ root_triangle_list[t]=t;
+ CalculateTriangleListBounds(root_triangle_list,OptimizedTriangleList.Count(),m_MinBound,
+ m_MaxBound);
+ RefineNode(0,root_triangle_list,OptimizedTriangleList.Count(),m_MinBound,m_MaxBound,0);
+ delete[] root_triangle_list;
+
+ // now, convert all triangles to "intersection format"
+ for(int i=0;i<OptimizedTriangleList.Count();i++)
+ OptimizedTriangleList[i].ChangeIntoIntersectionFormat();
+}
+
+
+
+void RayTracingEnvironment::AddInfinitePointLight(Vector position, Vector intensity)
+{
+ LightDesc_t mylight(position,intensity);
+ LightList.AddToTail(mylight);
+
+}
+
+
diff --git a/mp/src/raytrace/raytrace.vpc b/mp/src/raytrace/raytrace.vpc
new file mode 100644
index 00000000..d8504ec4
--- /dev/null
+++ b/mp/src/raytrace/raytrace.vpc
@@ -0,0 +1,26 @@
+//-----------------------------------------------------------------------------
+// RAYTRACE.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR ".."
+$Include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE,$SRCDIR\utils\common"
+ }
+}
+
+$Project "Raytrace"
+{
+ $Folder "Source Files"
+ {
+ $File "raytrace.cpp"
+ $File "trace2.cpp"
+ $File "trace3.cpp"
+ }
+}
diff --git a/mp/src/raytrace/trace2.cpp b/mp/src/raytrace/trace2.cpp
new file mode 100644
index 00000000..f7f4ed7e
--- /dev/null
+++ b/mp/src/raytrace/trace2.cpp
@@ -0,0 +1,376 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+// $Id$
+#include "raytrace.h"
+#include <mathlib/halton.h>
+
+static uint32 MapDistanceToPixel(float t)
+{
+ if (t<0) return 0xffff0000;
+ if (t>100) return 0xff000000;
+ int a=t*1000; a&=0xff;
+ int b=t*10; b &=0xff;
+ int c=t*.01; c &=0xff;
+ return 0xff000000+(a<<16)+(b<<8)+c;
+}
+
+#define IGAMMA (1.0/2.2)
+
+#define MAGIC_NUMBER (1<<23)
+
+static fltx4 Four_MagicNumbers={ MAGIC_NUMBER, MAGIC_NUMBER, MAGIC_NUMBER, MAGIC_NUMBER };
+static ALIGN16 int32 Four_255s[4]= {0xff,0xff,0xff,0xff};
+#define PIXMASK ( * ( reinterpret_cast< fltx4 *>( &Four_255s ) ) )
+
+void MapLinearIntensities(FourVectors const &intens,uint32 *p1, uint32 *p2, uint32 *p3, uint32 *p4)
+{
+ // convert four pixels worth of sse-style rgb into argb lwords
+ // NOTE the _mm_empty macro is voodoo. do not mess with this routine casually - simply throwing
+ // anything that ends up generating a fpu stack references in here would be bad news.
+ static fltx4 pixscale={255.0,255.0,255.0,255.0};
+ fltx4 r,g,b;
+ r=MinSIMD(pixscale,MulSIMD(pixscale,PowSIMD(intens.x,IGAMMA)));
+ g=MinSIMD(pixscale,MulSIMD(pixscale,PowSIMD(intens.y,IGAMMA)));
+ b=MinSIMD(pixscale,MulSIMD(pixscale,PowSIMD(intens.z,IGAMMA)));
+ // now, convert to integer
+ r=AndSIMD( AddSIMD( r, Four_MagicNumbers ), PIXMASK );
+ g=AndSIMD( AddSIMD( g, Four_MagicNumbers ), PIXMASK );
+ b=AndSIMD( AddSIMD( b, Four_MagicNumbers ), PIXMASK );
+
+ *(p1)=(SubInt(r, 0))|(SubInt(g, 0)<<8)|(SubInt(b, 0)<<16);
+ *(p2)=(SubInt(r, 1))|(SubInt(g, 1)<<8)|(SubInt(b, 1)<<16);
+ *(p3)=(SubInt(r, 2))|(SubInt(g, 2)<<8)|(SubInt(b, 2)<<16);
+ *(p4)=(SubInt(r, 3))|(SubInt(g, 3)<<8)|(SubInt(b, 3)<<16);
+}
+
+static ALIGN16 int32 signmask[4]={0x80000000,0x80000000,0x80000000,0x80000000};
+static ALIGN16 int32 all_ones[4]={-1,-1,-1,-1};
+static fltx4 all_zeros={0,0,0,0};
+static fltx4 TraceLimit={1.0e20,1.0e20,1.0e20,1.0e20};
+
+void RayTracingEnvironment::RenderScene(
+ int width, int height, // width and height of desired rendering
+ int stride, // actual width in pixels of target buffer
+ uint32 *output_buffer, // pointer to destination
+ Vector CameraOrigin, // eye position
+ Vector ULCorner, // word space coordinates of upper left
+ // monitor corner
+ Vector URCorner, // top right corner
+ Vector LLCorner, // lower left
+ Vector LRCorner, // lower right
+ RayTraceLightingMode_t lmode)
+{
+ // first, compute deltas
+ Vector dxvector=URCorner;
+ dxvector-=ULCorner;
+ dxvector*=(1.0/width);
+ Vector dxvectortimes2=dxvector;
+ dxvectortimes2+=dxvector;
+
+ Vector dyvector=LLCorner;
+ dyvector-=ULCorner;
+ dyvector*=(1.0/height);
+
+
+ // block_offsets-relative offsets for eahc of the 4 pixels in the block, in sse format
+ FourVectors block_offsets;
+ block_offsets.LoadAndSwizzle(Vector(0,0,0),dxvector,dyvector,dxvector+dyvector);
+
+ FourRays myrays;
+ myrays.origin.DuplicateVector(CameraOrigin);
+
+ // tmprays is used fo rthe case when we cannot trace 4 rays at once.
+ FourRays tmprays;
+ tmprays.origin.DuplicateVector(CameraOrigin);
+
+ // now, we will ray trace pixels. we will do the rays in a 2x2 pattern
+ for(int y=0;y<height;y+=2)
+ {
+ Vector SLoc=dyvector;
+ SLoc*=((float) y);
+ SLoc+=ULCorner;
+ uint32 *dest=output_buffer+y*stride;
+ for(int x=0;x<width;x+=2)
+ {
+ myrays.direction.DuplicateVector(SLoc);
+ myrays.direction+=block_offsets;
+ myrays.direction.VectorNormalize();
+
+ RayTracingResult rslt;
+ Trace4Rays(myrays,all_zeros,TraceLimit, &rslt);
+ if ((rslt.HitIds[0]==-1) && (rslt.HitIds[1]==-1) &&
+ (rslt.HitIds[2]==-1) && (rslt.HitIds[3]==-1))
+ MapLinearIntensities(BackgroundColor,dest,dest+1,dest+stride,dest+stride+1);
+ else
+ {
+ // make sure normal points back towards ray origin
+ fltx4 ndoti=rslt.surface_normal*myrays.direction;
+ fltx4 bad_dirs=AndSIMD(CmpGtSIMD(ndoti,Four_Zeros),
+ LoadAlignedSIMD((float *) signmask));
+
+ // flip signs of all "wrong" normals
+ rslt.surface_normal.x=XorSIMD(bad_dirs,rslt.surface_normal.x);
+ rslt.surface_normal.y=XorSIMD(bad_dirs,rslt.surface_normal.y);
+ rslt.surface_normal.z=XorSIMD(bad_dirs,rslt.surface_normal.z);
+
+ FourVectors intens;
+ intens.DuplicateVector(Vector(0,0,0));
+ // set up colors
+ FourVectors surf_colors;
+ surf_colors.DuplicateVector(Vector(0,0,0));
+ for(int i=0;i<4;i++)
+ {
+ if (rslt.HitIds[i]>=0)
+ {
+ surf_colors.X(i)=TriangleColors[rslt.HitIds[i]].x;
+ surf_colors.Y(i)=TriangleColors[rslt.HitIds[i]].y;
+ surf_colors.Z(i)=TriangleColors[rslt.HitIds[i]].z;
+ }
+
+ }
+ FourVectors surface_pos=myrays.direction;
+ surface_pos*=rslt.HitDistance;
+ surface_pos+=myrays.origin;
+
+ switch(lmode)
+ {
+ case DIRECT_LIGHTING:
+ {
+ // light all points
+ for(int l=0;l<LightList.Count();l++)
+ {
+ LightList[l].ComputeLightAtPoints(surface_pos,rslt.surface_normal,
+ intens);
+ }
+ }
+ break;
+
+ case DIRECT_LIGHTING_WITH_SHADOWS:
+ {
+ // light all points
+ for(int l=0;l<LightList.Count();l++)
+ {
+ FourVectors ldir;
+ ldir.DuplicateVector(LightList[l].m_Position);
+ ldir-=surface_pos;
+ fltx4 MaxT=ldir.length();
+ ldir.VectorNormalizeFast();
+ // now, compute shadow flag
+ FourRays myrays;
+ myrays.origin=surface_pos;
+ FourVectors epsilon=ldir;
+ epsilon*=0.01;
+ myrays.origin+=epsilon;
+ myrays.direction=ldir;
+ RayTracingResult shadowtest;
+ Trace4Rays(myrays,Four_Zeros,MaxT, &shadowtest);
+ fltx4 unshadowed=CmpGtSIMD(shadowtest.HitDistance,MaxT);
+ if (! (IsAllZeros(unshadowed)))
+ {
+ FourVectors tmp;
+ tmp.DuplicateVector(Vector(0,0,0));
+ LightList[l].ComputeLightAtPoints(surface_pos,rslt.surface_normal,
+ tmp);
+ intens.x=AddSIMD(intens.x,AndSIMD(tmp.x,unshadowed));
+ intens.y=AddSIMD(intens.y,AndSIMD(tmp.y,unshadowed));
+ intens.z=AddSIMD(intens.z,AndSIMD(tmp.z,unshadowed));
+ }
+ }
+ }
+ break;
+ }
+ // now, mask off non-hitting pixels
+ intens.VProduct(surf_colors);
+ fltx4 no_hit_mask=CmpGtSIMD(rslt.HitDistance,TraceLimit);
+
+ intens.x=OrSIMD(AndSIMD(BackgroundColor.x,no_hit_mask),
+ AndNotSIMD(no_hit_mask,intens.x));
+ intens.y=OrSIMD(AndSIMD(BackgroundColor.y,no_hit_mask),
+ AndNotSIMD(no_hit_mask,intens.y));
+ intens.z=OrSIMD(AndSIMD(BackgroundColor.y,no_hit_mask),
+ AndNotSIMD(no_hit_mask,intens.z));
+
+ MapLinearIntensities(intens,dest,dest+1,dest+stride,dest+stride+1);
+ }
+ dest+=2;
+ SLoc+=dxvectortimes2;
+ }
+ }
+}
+
+
+
+
+#define SQ(x) ((x)*(x))
+
+void RayTracingEnvironment::ComputeVirtualLightSources(void)
+{
+ int start_pos=0;
+ for(int b=0;b<3;b++)
+ {
+ int nl=LightList.Count();
+ int where_to_start=start_pos;
+ start_pos=nl;
+ for(int l=where_to_start;l<nl;l++)
+ {
+ DirectionalSampler_t sample_generator;
+ int n_desired=1*LightList[l].m_Color.Length();
+ if (LightList[l].m_Type==MATERIAL_LIGHT_SPOT)
+ n_desired*=LightList[l].m_Phi/2;
+ for(int try1=0;try1<n_desired;try1++)
+ {
+ LightDesc_t const &li=LightList[l];
+ FourRays myrays;
+ myrays.origin.DuplicateVector(li.m_Position);
+ RayTracingResult rslt;
+ Vector trial_dir=sample_generator.NextValue();
+ if (li.IsDirectionWithinLightCone(trial_dir))
+ {
+ myrays.direction.DuplicateVector(trial_dir);
+ Trace4Rays(myrays,all_zeros,ReplicateX4(1000.0), &rslt);
+ if ((rslt.HitIds[0]!=-1))
+ {
+ // make sure normal points back towards ray origin
+ fltx4 ndoti=rslt.surface_normal*myrays.direction;
+ fltx4 bad_dirs=AndSIMD(CmpGtSIMD(ndoti,Four_Zeros),
+ LoadAlignedSIMD((float *) signmask));
+
+ // flip signs of all "wrong" normals
+ rslt.surface_normal.x=XorSIMD(bad_dirs,rslt.surface_normal.x);
+ rslt.surface_normal.y=XorSIMD(bad_dirs,rslt.surface_normal.y);
+ rslt.surface_normal.z=XorSIMD(bad_dirs,rslt.surface_normal.z);
+
+ // a hit! let's make a virtual light source
+
+ // treat the virtual light as a disk with its center at the hit position
+ // and its radius scaled by the amount of the solid angle this probe
+ // represents.
+ float area_of_virtual_light=
+ 4.0*M_PI*SQ( SubFloat( rslt.HitDistance, 0 ) )*(1.0/n_desired);
+
+ FourVectors intens;
+ intens.DuplicateVector(Vector(0,0,0));
+
+ FourVectors surface_pos=myrays.direction;
+ surface_pos*=rslt.HitDistance;
+ surface_pos+=myrays.origin;
+ FourVectors delta=rslt.surface_normal;
+ delta*=0.1;
+ surface_pos+=delta;
+ LightList[l].ComputeLightAtPoints(surface_pos,rslt.surface_normal,
+ intens);
+ FourVectors surf_colors;
+ surf_colors.DuplicateVector(TriangleColors[rslt.HitIds[0]]);
+ intens*=surf_colors;
+ // see if significant
+ LightDesc_t l1;
+ l1.m_Type=MATERIAL_LIGHT_SPOT;
+ l1.m_Position=Vector(surface_pos.X(0),surface_pos.Y(0),surface_pos.Z(0));
+ l1.m_Direction=Vector(rslt.surface_normal.X(0),rslt.surface_normal.Y(0),
+ rslt.surface_normal.Z(0));
+ l1.m_Color=Vector(intens.X(0),intens.Y(0),intens.Z(0));
+ if (l1.m_Color.Length()>0)
+ {
+ l1.m_Color*=area_of_virtual_light/M_PI;
+ l1.m_Range=0.0;
+ l1.m_Falloff=1.0;
+ l1.m_Attenuation0=1.0;
+ l1.m_Attenuation1=0.0;
+ l1.m_Attenuation2=1.0; // intens falls off as 1/r^2
+ l1.m_Theta=0;
+ l1.m_Phi=M_PI;
+ l1.RecalculateDerivedValues();
+ LightList.AddToTail(l1);
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
+
+static unsigned int GetSignMask(Vector const &v)
+{
+ unsigned int ret=0;
+ if (v.x<0.0)
+ ret++;
+ if (v.y<0)
+ ret+=2;
+ if (v.z<0)
+ ret+=4;
+ return ret;
+}
+
+
+inline void RayTracingEnvironment::FlushStreamEntry(RayStream &s,int msk)
+{
+ assert(msk>=0);
+ assert(msk<8);
+ fltx4 tmax=s.PendingRays[msk].direction.length();
+ fltx4 scl=ReciprocalSaturateSIMD(tmax);
+ s.PendingRays[msk].direction*=scl; // normalize
+ RayTracingResult tmpresult;
+ Trace4Rays(s.PendingRays[msk],Four_Zeros,tmax,msk,&tmpresult);
+ // now, write out results
+ for(int r=0;r<4;r++)
+ {
+ RayTracingSingleResult *out=s.PendingStreamOutputs[msk][r];
+ out->ray_length=SubFloat( tmax, r );
+ out->surface_normal.x=tmpresult.surface_normal.X(r);
+ out->surface_normal.y=tmpresult.surface_normal.Y(r);
+ out->surface_normal.z=tmpresult.surface_normal.Z(r);
+ out->HitID=tmpresult.HitIds[r];
+ out->HitDistance=SubFloat( tmpresult.HitDistance, r );
+ }
+ s.n_in_stream[msk]=0;
+}
+
+void RayTracingEnvironment::AddToRayStream(RayStream &s,
+ Vector const &start,Vector const &end,
+ RayTracingSingleResult *rslt_out)
+{
+ Vector delta=end;
+ delta-=start;
+ int msk=GetSignMask(delta);
+ assert(msk>=0);
+ assert(msk<8);
+ int pos=s.n_in_stream[msk];
+ assert(pos<4);
+ s.PendingRays[msk].origin.X(pos)=start.x;
+ s.PendingRays[msk].origin.Y(pos)=start.y;
+ s.PendingRays[msk].origin.Z(pos)=start.z;
+ s.PendingRays[msk].direction.X(pos)=delta.x;
+ s.PendingRays[msk].direction.Y(pos)=delta.y;
+ s.PendingRays[msk].direction.Z(pos)=delta.z;
+ s.PendingStreamOutputs[msk][pos]=rslt_out;
+ if (pos==3)
+ {
+ FlushStreamEntry(s,msk);
+ }
+ else
+ s.n_in_stream[msk]++;
+}
+
+void RayTracingEnvironment::FinishRayStream(RayStream &s)
+{
+ for(int msk=0;msk<8;msk++)
+ {
+ int cnt=s.n_in_stream[msk];
+ if (cnt)
+ {
+ // fill in unfilled entries with dups of first
+ for(int c=cnt;c<4;c++)
+ {
+ s.PendingRays[msk].origin.X(c) = s.PendingRays[msk].origin.X(0);
+ s.PendingRays[msk].origin.Y(c) = s.PendingRays[msk].origin.Y(0);
+ s.PendingRays[msk].origin.Z(c) = s.PendingRays[msk].origin.Z(0);
+ s.PendingRays[msk].direction.X(c) = s.PendingRays[msk].direction.X(0);
+ s.PendingRays[msk].direction.Y(c) = s.PendingRays[msk].direction.Y(0);
+ s.PendingRays[msk].direction.Z(c) = s.PendingRays[msk].direction.Z(0);
+ s.PendingStreamOutputs[msk][c]=s.PendingStreamOutputs[msk][0];
+ }
+ FlushStreamEntry(s,msk);
+ }
+ }
+}
diff --git a/mp/src/raytrace/trace3.cpp b/mp/src/raytrace/trace3.cpp
new file mode 100644
index 00000000..d8000c3d
--- /dev/null
+++ b/mp/src/raytrace/trace3.cpp
@@ -0,0 +1,127 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+
+#include "raytrace.h"
+#include <bspfile.h>
+#include "bsplib.h"
+
+static Vector VertCoord(dface_t const &f, int vnum)
+{
+ int eIndex = dsurfedges[f.firstedge+vnum];
+ int point;
+ if( eIndex < 0 )
+ {
+ point = dedges[-eIndex].v[1];
+ }
+ else
+ {
+ point = dedges[eIndex].v[0];
+ }
+ dvertex_t *v=dvertexes+point;
+ return Vector(v->point[0],v->point[1],v->point[2]);
+
+}
+
+Vector colors[]={
+ Vector(0.5,0.5,1),
+ Vector(0.5,1,0.5),
+ Vector(0.5,1,1),
+ Vector(1,0.5,0.5),
+ Vector(1,0.5,1),
+ Vector(1,1,1)};
+
+void RayTracingEnvironment::AddBSPFace(int id,dface_t const &face)
+{
+ if (face.dispinfo!=-1) // displacements must be dealt with elsewhere
+ return;
+ texinfo_t *tx =(face.texinfo>=0)?&(texinfo[face.texinfo]):0;
+// if (tx && (tx->flags & (SURF_SKY|SURF_NODRAW)))
+// return;
+ if (tx)
+ {
+ printf("id %d flags=%x\n",id,tx->flags);
+ }
+ printf("side: ");
+ for(int v=0;v<face.numedges;v++)
+ {
+ printf("(%f %f %f) ",XYZ(VertCoord(face,v)));
+ }
+ printf("\n");
+ int ntris=face.numedges-2;
+ for(int tri=0;tri<ntris;tri++)
+ {
+
+ AddTriangle(id,VertCoord(face,0),VertCoord(face,(tri+1)%face.numedges),
+ VertCoord(face,(tri+2)%face.numedges),Vector(1,1,1)); //colors[id % NELEMS(colors)]);
+ }
+}
+
+void RayTracingEnvironment::InitializeFromLoadedBSP(void)
+{
+// CUtlVector<uint8> PlanesToSkip;
+// SidesToSkip.EnsureCapacity(numplanes);
+// for(int s=0;s<numplanes;s++)
+// SidesToSkip.AddToTail(0);
+// for(int b=0;b<numbrushes;b++)
+// if ((dbrushes[b].contents & MASK_OPAQUE)==0)
+// {
+// // transparent brush - mark all its sides as "do not process"
+// for(int s=0;s<dbrushes[b].numsides;s++)
+// {
+// PlanesToSkip[s+dbrushes[b].firstside]=1;
+// }
+
+// }
+// // now, add all origfaces, omitting those whose sides are the ones we marked previously
+// for(int c=0;c<numorigfaces;c++)
+// {
+// dface_t const &f=dorigfaces[c];
+// if (SidesToSkip[f.AddBSPFace(c,dorigfaces[c]);
+// }
+
+
+
+// // ugly - I want to traverse all the faces. but there is no way to get from a face back to it's
+// // original brush, and I need to get back to the face to the contents field of the brush. So I
+// // will create a temporary mapping from a "side" to its brush. I can get from the face to it
+// // side, which can get me back to its brush.
+
+// CUtlVector<uint8> OrigFaceVisited;
+// OrigFaceVisited.EnsureCapacity(numorigfaces);
+// int n_added=0;
+
+// for(int i=0;i<numorigfaces;i++)
+// OrigFaceVisited.AddToTail(0);
+
+// for(int l=0;l<numleafs;l++)
+// {
+// dleaf_t const &lf=dleafs[l];
+// // if (lf.contents & MASK_OPAQUE)
+// {
+// for(int f=0;f<lf.numleaffaces;f++);
+// {
+// dface_t const &face=dfaces[f+lf.firstleafface];
+// if (OrigFaceVisited[face.origFace]==0)
+// {
+// dface_t const &oface=dorigfaces[face.origFace];
+// OrigFaceVisited[face.origFace]=1;
+// n_added++;
+// AddBSPFace(face.origFace,oface);
+// }
+// }
+// }
+// }
+// printf("added %d of %d\n",n_added,numorigfaces);
+// for(int c=0;c<numorigfaces;c++)
+// {
+// dface_t const &f=dorigfaces[c];
+// AddBSPFace(c,dorigfaces[c]);
+// }
+ for(int c=0;c<numfaces;c++)
+ {
+// dface_t const &f=dfaces[c];
+ AddBSPFace(c,dorigfaces[c]);
+ }
+
+// AddTriangle(1234,Vector(51,145,-700),Vector(71,165,-700),Vector(51,165,-700),colors[5]);
+}
+
diff --git a/mp/src/tier0/tier0_exclude.vpc b/mp/src/tier0/tier0_exclude.vpc
index 70d2d165..fa713717 100644
--- a/mp/src/tier0/tier0_exclude.vpc
+++ b/mp/src/tier0/tier0_exclude.vpc
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
-// tier0_s_exclude.vpc
+// tier0_exclude.vpc
//
// Project Script
//-----------------------------------------------------------------------------
@@ -8,8 +8,7 @@ $Project
{
$Folder "Link Libraries"
{
- -$File "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXtier0$_IMPLIB_EXT" [!$WINDOWS]
- -$File "$SRCDIR\lib\public\$_IMPLIB_PREFIXtier0$_IMPLIB_EXT" [$WINDOWS]
+ -$Lib "$LIBPUBLIC\tier0"
}
$Folder "Source Files"
{
diff --git a/mp/src/tier1/bitbuf.cpp b/mp/src/tier1/bitbuf.cpp
index 8294c93c..4c457aa4 100644
--- a/mp/src/tier1/bitbuf.cpp
+++ b/mp/src/tier1/bitbuf.cpp
@@ -877,7 +877,7 @@ unsigned int bf_read::CheckReadUBitLong(int numbits)
void bf_read::ReadBits(void *pOutData, int nBits)
{
#if defined( BB_PROFILING )
- VPROF( "bf_write::ReadBits" );
+ VPROF( "bf_read::ReadBits" );
#endif
unsigned char *pOut = (unsigned char*)pOutData;
@@ -1083,7 +1083,7 @@ unsigned int bf_read::ReadBitLong(int numbits, bool bSigned)
float bf_read::ReadBitCoord (void)
{
#if defined( BB_PROFILING )
- VPROF( "bf_write::ReadBitCoord" );
+ VPROF( "bf_read::ReadBitCoord" );
#endif
int intval=0,fractval=0,signbit=0;
float value = 0.0;
@@ -1126,7 +1126,7 @@ float bf_read::ReadBitCoord (void)
float bf_read::ReadBitCoordMP( bool bIntegral, bool bLowPrecision )
{
#if defined( BB_PROFILING )
- VPROF( "bf_write::ReadBitCoordMP" );
+ VPROF( "bf_read::ReadBitCoordMP" );
#endif
// BitCoordMP float encoding: inbounds bit, integer bit, sign bit, optional int bits, float bits
// BitCoordMP integer encoding: inbounds bit, integer bit, optional sign bit, optional int bits.
@@ -1212,7 +1212,7 @@ float bf_read::ReadBitCoordMP( bool bIntegral, bool bLowPrecision )
unsigned int bf_read::ReadBitCoordBits (void)
{
#if defined( BB_PROFILING )
- VPROF( "bf_write::ReadBitCoordBits" );
+ VPROF( "bf_read::ReadBitCoordBits" );
#endif
unsigned int flags = ReadUBitLong(2);
@@ -1231,7 +1231,7 @@ unsigned int bf_read::ReadBitCoordBits (void)
unsigned int bf_read::ReadBitCoordMPBits( bool bIntegral, bool bLowPrecision )
{
#if defined( BB_PROFILING )
- VPROF( "bf_write::ReadBitCoordMPBits" );
+ VPROF( "bf_read::ReadBitCoordMPBits" );
#endif
unsigned int flags = ReadUBitLong(2);
diff --git a/mp/src/tier1/strtools.cpp b/mp/src/tier1/strtools.cpp
index 6e0ba9f5..5e7fd002 100644
--- a/mp/src/tier1/strtools.cpp
+++ b/mp/src/tier1/strtools.cpp
@@ -1491,14 +1491,34 @@ int V_UCS2ToUTF8( const ucs2 *pUCS2, char *pUTF8, int cubDestSizeInBytes )
#elif defined(POSIX)
iconv_t conv_t = iconv_open( "UTF-8", "UCS-2LE" );
size_t cchResult = -1;
- size_t nLenUnicde = cubDestSizeInBytes;
- size_t nMaxUTF8 = cubDestSizeInBytes;
+
+ // pUCS2 will be null-terminated so use that to work out the input
+ // buffer size. Note that we shouldn't assume iconv will stop when it
+ // finds a zero, and nLenUnicde should be given in bytes, so we multiply
+ // it by sizeof( ucs2 ) at the end.
+ size_t nLenUnicde = 0;
+ while ( pUCS2[nLenUnicde] )
+ {
+ ++nLenUnicde;
+ }
+ nLenUnicde *= sizeof( ucs2 );
+
+ // Calculate number of bytes we want iconv to write, leaving space
+ // for the null-terminator
+ size_t nMaxUTF8 = cubDestSizeInBytes - 1;
char *pIn = (char *)pUCS2;
char *pOut = (char *)pUTF8;
if ( conv_t > 0 )
{
cchResult = 0;
+ const size_t nBytesToWrite = nMaxUTF8;
cchResult = iconv( conv_t, &pIn, &nLenUnicde, &pOut, &nMaxUTF8 );
+
+ // Calculate how many bytes were actually written and use that to
+ // null-terminate our output string.
+ const size_t nBytesWritten = nBytesToWrite - nMaxUTF8;
+ pUTF8[nBytesWritten] = 0;
+
iconv_close( conv_t );
if ( (int)cchResult < 0 )
cchResult = 0;
diff --git a/mp/src/tier1/tier1.vpc b/mp/src/tier1/tier1.vpc
index eac035ce..9ff36c83 100644
--- a/mp/src/tier1/tier1.vpc
+++ b/mp/src/tier1/tier1.vpc
@@ -5,11 +5,8 @@
//-----------------------------------------------------------------------------
$macro SRCDIR ".."
-
-$macro OUTLIBDIR "$SRCDIR\lib\public" [!$LINUX && !$OSXALL]
$include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
-$include "$SRCDIR\vstdlib\vstdlib_exclude.vpc" [$OSXALL]
$Configuration
{
diff --git a/mp/src/utils/captioncompiler/captioncompiler.vpc b/mp/src/utils/captioncompiler/captioncompiler.vpc
index 6d60fabe..a6af7a7b 100644
--- a/mp/src/utils/captioncompiler/captioncompiler.vpc
+++ b/mp/src/utils/captioncompiler/captioncompiler.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
@@ -52,9 +52,9 @@ $Project "Captioncompiler"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\appframework.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\tier3.lib"
+ $Lib appframework
+ $Lib mathlib
+ $Lib tier2
+ $Lib tier3
}
}
diff --git a/mp/src/utils/glview/glview.vpc b/mp/src/utils/glview/glview.vpc
index b645cfde..3045d128 100644
--- a/mp/src/utils/glview/glview.vpc
+++ b/mp/src/utils/glview/glview.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
$Configuration
{
@@ -49,7 +49,7 @@ $Project "Glview"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $Lib mathlib
+ $Lib tier2
}
}
diff --git a/mp/src/utils/height2normal/height2normal.vpc b/mp/src/utils/height2normal/height2normal.vpc
index d6379a6d..dc1cb73b 100644
--- a/mp/src/utils/height2normal/height2normal.vpc
+++ b/mp/src/utils/height2normal/height2normal.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
@@ -34,8 +34,8 @@ $Project "Height2normal"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $Lib bitmap
+ $Lib mathlib
+ $Lib tier2
}
}
diff --git a/mp/src/utils/motionmapper/motionmapper.vpc b/mp/src/utils/motionmapper/motionmapper.vpc
index 0a59a92d..1272c040 100644
--- a/mp/src/utils/motionmapper/motionmapper.vpc
+++ b/mp/src/utils/motionmapper/motionmapper.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
@@ -81,8 +81,8 @@ $Project "Motionmapper"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\nvtristrip.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $Lib mathlib
+ $Lib nvtristrip
+ $Lib tier2
}
}
diff --git a/mp/src/utils/phonemeextractor/phonemeextractor.vpc b/mp/src/utils/phonemeextractor/phonemeextractor.vpc
index 160fe8d8..f6e82e4d 100644
--- a/mp/src/utils/phonemeextractor/phonemeextractor.vpc
+++ b/mp/src/utils/phonemeextractor/phonemeextractor.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin\phonemeextractors"
-$Include "$SRCDIR\vpc_scripts\source_dll_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration
{
@@ -77,7 +77,7 @@ $Project "Phonemeextractor"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
+ $Lib mathlib
$DynamicFile "..\sapi51\lib\i386\sapi.lib"
}
}
diff --git a/mp/src/utils/phonemeextractor/phonemeextractor_ims.vpc b/mp/src/utils/phonemeextractor/phonemeextractor_ims.vpc
index 135ac216..e3df0327 100644
--- a/mp/src/utils/phonemeextractor/phonemeextractor_ims.vpc
+++ b/mp/src/utils/phonemeextractor/phonemeextractor_ims.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin\phonemeextractors"
-$Include "$SRCDIR\vpc_scripts\source_dll_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration
{
@@ -92,7 +92,7 @@ $Project "Phonemeextractor_ims"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
+ $Lib mathlib
$File "..\sapi51\lib\i386\sapi.lib"
}
}
diff --git a/mp/src/utils/qc_eyes/qc_eyes.vpc b/mp/src/utils/qc_eyes/qc_eyes.vpc
index 3873b59a..54b35528 100644
--- a/mp/src/utils/qc_eyes/qc_eyes.vpc
+++ b/mp/src/utils/qc_eyes/qc_eyes.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
$Configuration
{
diff --git a/mp/src/utils/serverplugin_sample/serverplugin_empty.vpc b/mp/src/utils/serverplugin_sample/serverplugin_empty.vpc
index 66bdd80f..a4bc5380 100644
--- a/mp/src/utils/serverplugin_sample/serverplugin_empty.vpc
+++ b/mp/src/utils/serverplugin_sample/serverplugin_empty.vpc
@@ -56,11 +56,7 @@ $Project "Serverplugin_empty"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib" [$WIN32]
- $DynamicFile "$SRCDIR\lib\public\tier2.lib" [$WIN32]
- $DynamicFile "$SRCDIR\lib\public\$PLATFORM\mathlib$_STATICLIB_EXT" [$LINUX]
- $DynamicFile "$SRCDIR\lib\public\$PLATFORM\tier2$_STATICLIB_EXT" [$LINUX]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\mathlib$_STATICLIB_EXT" [$OSXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier2$_STATICLIB_EXT" [$OSXALL]
+ $Lib mathlib
+ $Lib tier2
}
}
diff --git a/mp/src/utils/tgadiff/tgadiff.vpc b/mp/src/utils/tgadiff/tgadiff.vpc
index 6338b77f..1bfc6b1f 100644
--- a/mp/src/utils/tgadiff/tgadiff.vpc
+++ b/mp/src/utils/tgadiff/tgadiff.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Project "Tgadiff"
{
@@ -18,8 +18,8 @@ $Project "Tgadiff"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $Lib bitmap
+ $Lib mathlib
+ $Lib tier2
}
}
diff --git a/mp/src/utils/vbsp/vbsp.vpc b/mp/src/utils/vbsp/vbsp.vpc
index 10fc9db1..4c6d1862 100644
--- a/mp/src/utils/vbsp/vbsp.vpc
+++ b/mp/src/utils/vbsp/vbsp.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
@@ -173,11 +173,11 @@ $Project "Vbsp"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\fgdlib.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\vtf.lib"
+ $Lib bitmap
+ $Lib fgdlib
+ $Lib mathlib
+ $Lib tier2
+ $Lib vtf
}
$File "notes.txt"
diff --git a/mp/src/utils/vice/vice.vpc b/mp/src/utils/vice/vice.vpc
index 31e51b23..8a87d0bb 100644
--- a/mp/src/utils/vice/vice.vpc
+++ b/mp/src/utils/vice/vice.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
@@ -35,7 +35,7 @@ $Project "Vice"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
+ $Lib tier2
+ $Lib mathlib
}
}
diff --git a/mp/src/utils/vrad/vrad_dll.vpc b/mp/src/utils/vrad/vrad_dll.vpc
index 1b0c1c1f..02fb290a 100644
--- a/mp/src/utils/vrad/vrad_dll.vpc
+++ b/mp/src/utils/vrad/vrad_dll.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_dll_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration
{
@@ -213,12 +213,12 @@ $Project "Vrad_dll"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\raytrace.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\vmpi.lib"
- $DynamicFile "$SRCDIR\lib\public\vtf.lib"
+ $Lib bitmap
+ $Lib mathlib
+ $Lib raytrace
+ $Lib tier2
+ $Lib vmpi
+ $Lib vtf
}
$File "notes.txt"
diff --git a/mp/src/utils/vrad_launcher/vrad_launcher.vpc b/mp/src/utils/vrad_launcher/vrad_launcher.vpc
index 08914048..c9868357 100644
--- a/mp/src/utils/vrad_launcher/vrad_launcher.vpc
+++ b/mp/src/utils/vrad_launcher/vrad_launcher.vpc
@@ -8,7 +8,7 @@ $Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
$Macro OUTBINNAME "vrad"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
diff --git a/mp/src/utils/vtf2tga/vtf2tga.vpc b/mp/src/utils/vtf2tga/vtf2tga.vpc
index dd02ec09..b51ed3e1 100644
--- a/mp/src/utils/vtf2tga/vtf2tga.vpc
+++ b/mp/src/utils/vtf2tga/vtf2tga.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Project "Vtf2tga"
{
@@ -39,9 +39,9 @@ $Project "Vtf2tga"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\vtf.lib"
+ $Lib bitmap
+ $Lib mathlib
+ $Lib tier2
+ $Lib vtf
}
}
diff --git a/mp/src/utils/vtfdiff/vtfdiff.vpc b/mp/src/utils/vtfdiff/vtfdiff.vpc
index f67bd123..7ed8be34 100644
--- a/mp/src/utils/vtfdiff/vtfdiff.vpc
+++ b/mp/src/utils/vtfdiff/vtfdiff.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Project "Vtfdiff"
{
@@ -18,9 +18,9 @@ $Project "Vtfdiff"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\bitmap.lib"
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\vtf.lib"
+ $Lib bitmap
+ $Lib mathlib
+ $Lib tier2
+ $Lib vtf
}
}
diff --git a/mp/src/utils/vvis/vvis_dll.vpc b/mp/src/utils/vvis/vvis_dll.vpc
index c7d0d457..34ac8fcb 100644
--- a/mp/src/utils/vvis/vvis_dll.vpc
+++ b/mp/src/utils/vvis/vvis_dll.vpc
@@ -7,7 +7,7 @@
$Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Include "$SRCDIR\vpc_scripts\source_dll_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
$Configuration
{
@@ -94,8 +94,8 @@ $Project "Vvis_dll"
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\mathlib.lib"
- $DynamicFile "$SRCDIR\lib\public\tier2.lib"
- $DynamicFile "$SRCDIR\lib\public\vmpi.lib"
+ $Lib mathlib
+ $Lib tier2
+ $Lib vmpi
}
}
diff --git a/mp/src/utils/vvis_launcher/vvis_launcher.vpc b/mp/src/utils/vvis_launcher/vvis_launcher.vpc
index 88d6e9a1..5cf8eb99 100644
--- a/mp/src/utils/vvis_launcher/vvis_launcher.vpc
+++ b/mp/src/utils/vvis_launcher/vvis_launcher.vpc
@@ -8,7 +8,7 @@ $Macro SRCDIR "..\.."
$Macro OUTBINDIR "$SRCDIR\..\game\bin"
$Macro OUTBINNAME "vvis"
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc"
$Configuration
{
diff --git a/mp/src/vgui2/vgui_controls/TextEntry.cpp b/mp/src/vgui2/vgui_controls/TextEntry.cpp
index 3b0c189f..cecf3e04 100644
--- a/mp/src/vgui2/vgui_controls/TextEntry.cpp
+++ b/mp/src/vgui2/vgui_controls/TextEntry.cpp
@@ -3355,7 +3355,7 @@ void TextEntry::CopySelected()
buf.AddToTail(m_TextStream[i]);
}
buf.AddToTail('\0');
- system()->SetClipboardText(buf.Base(), x1 - x0);
+ system()->SetClipboardText(buf.Base(), buf.Count());
}
// have to request focus if we used the menu
diff --git a/mp/src/vgui2/vgui_controls/vgui_controls.vpc b/mp/src/vgui2/vgui_controls/vgui_controls.vpc
index f3b1d116..2b90d073 100644
--- a/mp/src/vgui2/vgui_controls/vgui_controls.vpc
+++ b/mp/src/vgui2/vgui_controls/vgui_controls.vpc
@@ -7,7 +7,6 @@
$macro SRCDIR "..\.."
$Macro GENERATED_PROTO_DIR "generated_proto"
$macro PROTOBUF_LITE 0
-$Macro OUTLIBDIR "$SRCDIR\lib\public" [!$LINUX]
$include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
$include "$SRCDIR\vpc_scripts\protobuf_builder.vpc"
diff --git a/mp/src/vpc_scripts/definitions/win32_2010.def b/mp/src/vpc_scripts/definitions/win32_2010.def
index 6d28d562..96d78d22 100644
--- a/mp/src/vpc_scripts/definitions/win32_2010.def
+++ b/mp/src/vpc_scripts/definitions/win32_2010.def
@@ -232,7 +232,12 @@
{
"type" "ignore"
}
-
+
+ "$AdditionalLibraryDirectories"
+ {
+ "type" "ignore"
+ }
+
// General
"$AdditionalIncludeDirectories"
{
diff --git a/mp/src/vpc_scripts/groups.vgc b/mp/src/vpc_scripts/groups.vgc
index c4786f55..9bbb0e1c 100644
--- a/mp/src/vpc_scripts/groups.vgc
+++ b/mp/src/vpc_scripts/groups.vgc
@@ -18,6 +18,7 @@ $Group "game"
{
"client"
"mathlib"
+ "raytrace"
"server"
"tier1"
"vgui_controls"
@@ -32,12 +33,14 @@ $Group "everything"
{
"captioncompiler"
"client"
+ "fgdlib"
"game_shader_dx9"
"glview"
"height2normal"
"mathlib"
"motionmapper"
"phonemeextractor"
+ "raytrace"
"qc_eyes"
"server"
"serverplugin_empty"
diff --git a/mp/src/vpc_scripts/platform_dirs.vpc b/mp/src/vpc_scripts/platform_dirs.vpc
new file mode 100644
index 00000000..f19b8a20
--- /dev/null
+++ b/mp/src/vpc_scripts/platform_dirs.vpc
@@ -0,0 +1,5 @@
+$Macro PLATSUBDIR "\." [$WIN32]
+$Macro PLATSUBDIR "\x64" [$WIN64]
+$Macro PLATSUBDIR "\." [$X360]
+$Macro PLATSUBDIR "\linux32" [$LINUX32]
+$Macro PLATSUBDIR "\osx32" [$OSX32]
diff --git a/mp/src/vpc_scripts/projects.vgc b/mp/src/vpc_scripts/projects.vgc
index 9ce86546..5b448e59 100644
--- a/mp/src/vpc_scripts/projects.vgc
+++ b/mp/src/vpc_scripts/projects.vgc
@@ -19,6 +19,11 @@ $Project "client"
"game\client\client_hl2mp.vpc" [($WIN32||$POSIX) && $HL2MP]
}
+$Project "fgdlib"
+{
+ "fgdlib\fgdlib.vpc" [$WIN32]
+}
+
$Project "game_shader_dx9"
{
"materialsystem\stdshaders\game_shader_dx9_hl2mp.vpc" [$HL2MP]
@@ -54,6 +59,11 @@ $Project "phonemeextractor"
"utils\phonemeextractor\phonemeextractor.vpc" [$WIN32]
}
+$Project "raytrace"
+{
+ "raytrace\raytrace.vpc" [$WIN32||$X360||$POSIX]
+}
+
$Project "qc_eyes"
{
"utils\qc_eyes\qc_eyes.vpc" [$WIN32]
diff --git a/mp/src/vpc_scripts/protobuf_builder.vpc b/mp/src/vpc_scripts/protobuf_builder.vpc
index 518aeafb..a0fd8667 100644
--- a/mp/src/vpc_scripts/protobuf_builder.vpc
+++ b/mp/src/vpc_scripts/protobuf_builder.vpc
@@ -9,7 +9,7 @@ $CustomBuildStep "proto"
$CommandLine "mkdir $GENERATED_PROTO_DIR 2> /dev/null;" \
"$SRCDIR/devtools/bin/osx32/protoc --proto_path=$SRCDIR\thirdparty\protobuf-2.3.0\src --proto_path=$(InputDir) --proto_path=$SRCDIR\gcsdk --cpp_out=$GENERATED_PROTO_DIR $(InputPath)" [$OSXALL]
$CommandLine "mkdir $GENERATED_PROTO_DIR 2> /dev/null;" \
- "$SRCDIR/gcsdk/bin/linux/protoc --proto_path=$SRCDIR\thirdparty\protobuf-2.3.0\src --proto_path=$(InputDir) --proto_path=$SRCDIR\gcsdk --cpp_out=$GENERATED_PROTO_DIR $(InputPath)" [$LINUX]
+ "$SRCDIR/gcsdk/bin/linux/protoc --proto_path=$SRCDIR\thirdparty\protobuf-2.3.0\src --proto_path=$(InputDir) --proto_path=$SRCDIR\gcsdk --cpp_out=$GENERATED_PROTO_DIR $(InputPath)" [$LINUXALL]
$Outputs "$GENERATED_PROTO_DIR\$(InputName).pb.cc;$GENERATED_PROTO_DIR\$(InputName).pb.h"
}
diff --git a/mp/src/vpc_scripts/source_base.vpc b/mp/src/vpc_scripts/source_base.vpc
index fc70c2e5..86722a3a 100644
--- a/mp/src/vpc_scripts/source_base.vpc
+++ b/mp/src/vpc_scripts/source_base.vpc
@@ -15,3 +15,32 @@
// rel/tf_beta branch:
//$Conditional TF_BETA "1"
+$Configuration "Debug"
+{
+ $Compiler
+ {
+ // Pass on appropriate branch define to preprocessor
+ $PreprocessorDefinitions "VPC"
+ $PreprocessorDefinitions "$BASE;STAGING_ONLY" [$STAGING_ONLY]
+ $PreprocessorDefinitions "$BASE;TF_BETA" [$TF_BETA]
+ $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+// Need to revisit the code to make things run with the _RETAIL preprocessor definition
+// This line was added in the previous check-in, but had previously not been defined in this branch
+// $PreprocessorDefinitions "$BASE;_RETAIL" [$RETAIL]
+ }
+}
+
+$Configuration "Release"
+{
+ $Compiler
+ {
+ // Pass on appropriate branch define to preprocessor
+ $PreprocessorDefinitions "VPC"
+ $PreprocessorDefinitions "$BASE;STAGING_ONLY" [$STAGING_ONLY]
+ $PreprocessorDefinitions "$BASE;TF_BETA" [$TF_BETA]
+ $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+// Need to revisit the code to make things run with the _RETAIL preprocessor definition
+// This line was added in the previous check-in, but had previously not been defined in this branch
+// $PreprocessorDefinitions "$BASE;_RETAIL" [$RETAIL]
+ }
+}
diff --git a/mp/src/vpc_scripts/source_dll_base.vpc b/mp/src/vpc_scripts/source_dll_base.vpc
index b2c07984..c4b73b97 100644
--- a/mp/src/vpc_scripts/source_dll_base.vpc
+++ b/mp/src/vpc_scripts/source_dll_base.vpc
@@ -1,20 +1,25 @@
-//-----------------------------------------------------------------------------
-// source_dll_base.VPC
-//
-// Project Script
-//-----------------------------------------------------------------------------
-
+$MacroRequired "OUTDLLEXT" "$_DLL_EXT"
+$Include "$SRCDIR\vpc_scripts\platform_dirs.vpc"
$include "$SRCDIR\vpc_scripts\source_base.vpc"
-$Macro PLATSUBDIR "\linux32" [$LINUX32]
-$Macro PLATSUBDIR "\osx32" [$OSX32]
-$Macro OUTBINDIR "$OUTBINDIR" [$LINUX32]
-$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR" [$LINUX32]
-$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR" [$LINUX32]
-
-$include "$SRCDIR\vpc_scripts\source_dll_win32_base.vpc" [$WINDOWS]
-$include "$SRCDIR\vpc_scripts\source_dll_x360_base.vpc" [$X360]
-$include "$SRCDIR\vpc_scripts\source_dll_posix_base.vpc" [$OSXALL]
-$Include "$SRCDIR\vpc_scripts\source_dll_linux_base.vpc" [$LINUX]
+$include "$SRCDIR\vpc_scripts\source_dll_posix_base.vpc" [$POSIX]
+$Include "$SRCDIR\vpc_scripts\source_dll_win32_base.vpc" [( $WIN32 || $WIN64 ) && !$POSIX]
+$Include "$SRCDIR\vpc_scripts\source_dll_x360_base.vpc" [$X360]
+$Include "$SRCDIR\vpc_scripts\source_ppu_prx_ps3_base.vpc" [$PS3]
$Include "$SRCDIR\vpc_scripts\source_video_base.vpc"
+$Configuration
+{
+ $General [$VS2010]
+ {
+ $TargetExtension "$OUTDLLEXT"
+ }
+
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;DEV_BUILD" [!$PUBLISH]
+ $PreprocessorDefinitions "$BASE;_PROFILE" [$PROFILE && !$RETAIL]
+ $PreprocessorDefinitions "$BASE;RETAIL_ASSERTS" [$RETAIL && $RETAILASSERTS]
+ $PreprocessorDefinitions "$BASE;FRAME_POINTER_OMISSION_DISABLED" [$NOFPO || $VS2010]
+ }
+}
diff --git a/mp/src/vpc_scripts/source_dll_linux_base.vpc b/mp/src/vpc_scripts/source_dll_linux_base.vpc
index 18fb1f55..f82cb3e9 100644
--- a/mp/src/vpc_scripts/source_dll_linux_base.vpc
+++ b/mp/src/vpc_scripts/source_dll_linux_base.vpc
@@ -2,9 +2,8 @@
$Include "$SRCDIR\vpc_scripts\version.vpc"
$Include "$SRCDIR\vpc_scripts\source_linux_base_project.vpc"
-
$MacroRequired "OUTBINNAME" "$PROJECTNAME"
-
+$MacroRequired "OUTBINDIR" "$SRCDIR\..\game\bin"
// General configuration info.
$Configuration
@@ -12,7 +11,7 @@ $Configuration
$General
{
$ConfigurationType "Dynamic Library (.dll)"
- $OutputFile "$(OBJ_DIR)/$OUTBINNAME$_DLL_EXT"
+ $OutputFile "$(OBJ_DIR)/$OUTBINNAME$_DLL_EXT"
$GameOutputFile "$OUTBINDIR/$OUTBINNAME$_DLL_EXT"
}
@@ -22,3 +21,25 @@ $Configuration
}
}
+// Skeleton Project - All derived projects get this as a starting base
+$Project
+{
+ $Folder "Source Files"
+ {
+ $File "$SRCDIR\public\tier0\memoverride.cpp"
+ {
+ $Configuration
+ {
+ $Compiler
+ {
+ $Create/UsePrecompiledHeader "Not Using Precompiled Headers"
+ }
+ }
+ }
+ }
+
+ $Folder "Resources"
+ {
+ $File "$ROOTSCRIPT"
+ }
+}
diff --git a/mp/src/vpc_scripts/source_dll_posix_base.vpc b/mp/src/vpc_scripts/source_dll_posix_base.vpc
index c7fc3e10..67040686 100644
--- a/mp/src/vpc_scripts/source_dll_posix_base.vpc
+++ b/mp/src/vpc_scripts/source_dll_posix_base.vpc
@@ -13,12 +13,17 @@ $Configuration
$General
{
$ConfigurationType "Dynamic Library (.dll)"
- $GameOutputFile "$OUTBINDIR/$OUTBINNAME$_DLL_EXT"
+ $GameOutputFile "$OUTBINDIR/$OUTBINNAME$OUTDLLEXT"
+ }
+
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;DLLNAME=$OUTBINNAME"
}
$Linker
{
- $OutputFile "$(OBJ_DIR)/$OUTBINNAME$_DLL_EXT"
+ $OutputFile "$(OBJ_DIR)/$OUTBINNAME$OUTDLLEXT"
}
}
diff --git a/mp/src/vpc_scripts/source_dll_qt_base.vpc b/mp/src/vpc_scripts/source_dll_qt_base.vpc
new file mode 100644
index 00000000..cd2b994b
--- /dev/null
+++ b/mp/src/vpc_scripts/source_dll_qt_base.vpc
@@ -0,0 +1,44 @@
+//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
+//
+//==================================================================================================
+
+$Macro QT_ROOT "$SRCDIR\thirdparty\lgpl\qt"
+
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
+$Include "$SRCDIR\vpc_scripts\qt_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE;.\;$SRCDIR\game\shared;$QT_ROOT\include;.\$QT_TARGET_SUBDIR"
+ $PreprocessorDefinitions "$BASE;QT_LARGEFILE_SUPPORT;QT_DLL;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
+ $DisableSpecificWarnings "4127;4512;$BASE"
+
+ // Causes a bunch of bogus compiler warnings for now; let's disable it
+ $Detect64bitPortabilityIssues "No"
+ }
+}
+
+$Configuration "Release"
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;QT_NO_DEBUG"
+ }
+}
+
+$Project
+{
+ $Folder "Link Libraries" [$QTDEBUG]
+ {
+ $Lib "$QT_ROOT\lib\qtcored4"
+ $Lib "$QT_ROOT\lib\qtguid4"
+ }
+
+ $Folder "Link Libraries" [!$QTDEBUG]
+ {
+ $Lib "$QT_ROOT\lib\qtcore4"
+ $Lib "$QT_ROOT\lib\qtgui4"
+ }
+}
diff --git a/mp/src/vpc_scripts/source_dll_win32_base.vpc b/mp/src/vpc_scripts/source_dll_win32_base.vpc
index 4382efaa..cbd0a49a 100644
--- a/mp/src/vpc_scripts/source_dll_win32_base.vpc
+++ b/mp/src/vpc_scripts/source_dll_win32_base.vpc
@@ -6,26 +6,13 @@
$Include "$SRCDIR\vpc_scripts\version.vpc"
-$Macro NOAPPENDPLATSUBDIR "1" [!$WIN64]
-
-$MacroRequired "PLATSUBDIR"
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME" "$PROJECTNAME"
$MacroRequired "OUTBINDIR"
-
-// These are convenient for adjusting directory paths based on platform
-// but they must be used without absolute consistency to avoid dependency
-// problems. It appears that if VPC compares $LIBPUBLIC to $SRCDIR\lib\public
-// it will decide that they are not equal, even if the *value* of $LIBPUBLIC
-// is $SRCDIR\lib\public. These macros can safely be used in copy commands
-// and other areas that VPC doesn't use for dependency tracking.
-$Macro LIBPUBLIC "$SRCDIR\lib\public"
-$Macro LIBCOMMON "$SRCDIR\lib\common"
-
-// Fix up directories for targets like win64
-$Macro OUTBINDIR "$OUTBINDIR$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR && !$NOMODIFYOUTBINDIR]
-$Macro LIBPUBLIC "$LIBPUBLIC$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR]
-$Macro LIBCOMMON "$LIBCOMMON$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR]
+
+$Macro OUTBINDIR "$OUTBINDIR$PLATSUBDIR"
+$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR"
+$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR"
$Include "$SRCDIR\vpc_scripts\loadaddress.vpc"
$Include "$SRCDIR\vpc_scripts\source_dll_win32_debug.vpc"
@@ -34,75 +21,71 @@ $Include "$SRCDIR\vpc_scripts\source_win32_base.vpc"
$IgnoreRedundancyWarning "ON"
-$Linux
-{
- -$File "$SRCDIR\lib\public\tier0.lib"
- $file "$SRCDIR\linux\tier0_i686.so"
-
- -$File "$SRCDIR\lib\public\vstdlib.lib" [!$WIN64]
- -$File "$SRCDIR\lib\public\$PLATFORM\vstdlib.lib" [$WIN64]
- $file "$SRCDIR\linux\vstdlib_i686.so"
-}
-
// Common Configuration
$Configuration
{
- $General [$VS2010]
+ $General [$VS2010]
+ {
+ $TargetName "$OUTBINNAME"
+ }
+
+ $Compiler
{
- $TargetName "$OUTBINNAME"
+ $PreprocessorDefinitions "$BASE;PLATFORM_64BITS;WIN64;_WIN64;COMPILER_MSVC64" [$WIN64]
+ $PreprocessorDefinitions "$BASE;COMPILER_MSVC32" [$WIN32]
+ $PreprocessorDefinitions "$BASE;COMPILER_MSVC;_DLL_EXT=$_DLL_EXT"
+ $PreprocessorDefinitions "$BASE;DLLNAME=$OUTBINNAME"
}
+ $Compiler [$WIN32]
+ {
+ $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)"
+ }
+
+ $Linker
+ {
+ $AdditionalDependencies "$BASE shell32.lib user32.lib advapi32.lib gdi32.lib comdlg32.lib ole32.lib" [$WIN32||$WIN64]
+ $TargetMachine "MachineX86 (/MACHINE:X86)" [$WIN32]
+ $TargetMachine "MachineX64 (/MACHINE:X64)" [$WIN64]
+ // Suppress this pointless warning using the undocumented /ignore linker switch
+ // schemalib.lib(schemaclassinfo.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
+ $AdditionalOptions "$BASE /ignore:4221"
+ }
+
$PreBuildEvent
{
$CommandLine "if EXIST $OUTBINDIR\$(TargetFileName) for /f $QUOTEdelims=$QUOTE %%A in ('attrib $QUOTE$OUTBINDIR\$(TargetFileName)$QUOTE') do set valveTmpIsReadOnly=$QUOTE%%A$QUOTE" "\n" \
"set valveTmpIsReadOnlyLetter=%valveTmpIsReadOnly:~6,1%" "\n" \
"if $QUOTE%valveTmpIsReadOnlyLetter%$QUOTE==$QUOTER$QUOTE del /q $QUOTE$(TargetDir)$QUOTE$(TargetFileName)" "\n" \
- "$CRCCHECK" [!$SOURCESDK]
+ "$CRCCHECK" "\n"
}
$PostBuildEvent [!$ANALYZE]
{
$CommandLine "if not exist $QUOTE$OUTBINDIR$QUOTE mkdir $QUOTE$OUTBINDIR$QUOTE" "\n"
$CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $QUOTE$OUTBINDIR\$(TargetFileName)$QUOTE $SRCDIR" "\n" [!$SOURCESDK]
- $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetFileName) $QUOTE$OUTBINDIR\$(TargetFileName)$QUOTE" "\n" \
+ $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$(TargetFileName)$QUOTE $QUOTE$OUTBINDIR\$(TargetFileName)$QUOTE" "\n" \
"if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
- "if exist $QUOTE$(TargetDir)$QUOTE$(TargetName).map copy $QUOTE$(TargetDir)$QUOTE$(TargetName).map $OUTBINDIR\$(TargetName).map" "\n"
- $CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetName).pdb $SRCDIR" "\n" [!$SOURCESDK]
- $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetName).pdb $OUTBINDIR\$(TargetName).pdb" "\n" \
+ "if exist $QUOTE$(TargetDir)$(TargetName).map$QUOTE copy $QUOTE$(TargetDir)$(TargetName).map$QUOTE $OUTBINDIR\$(TargetName).map" "\n"
+ $CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $QUOTE$OUTBINDIR\$(TargetName).pdb$QUOTE $SRCDIR" "\n" [!$SOURCESDK]
+ $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$(TargetName).pdb$QUOTE $OUTBINDIR\$(TargetName).pdb" "\n" \
"if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
"goto BuildEventOK" "\n" \
":BuildEventFailed" "\n" \
"echo *** ERROR! PostBuildStep FAILED for $(ProjectName)! EXE or DLL is probably running. ***" "\n" \
- "del /q $QUOTE$(TargetDir)$QUOTE$(TargetFileName)" "\n" \
+ "del /q $QUOTE$(TargetDir)$(TargetFileName)$QUOTE" "\n" \
"exit 1" "\n" \
- ":BuildEventOK" "\n"
+ ":BuildEventOK" "\n"
$CommandLine "$BASE" "\n" \
- "call $SRCDIR\devtools\bin\vsign.bat -sign $OUTBINDIR\$(TargetFileName)" "\n" [$RETAIL && !$SOURCESDK]
+ "call $SRCDIR\devtools\bin\vsign.bat -sign $OUTBINDIR\$(TargetFileName)" "\n" [$RETAIL && $PUBLISH]
$CommandLine "$BASE" "\n" \
- "call $SRCDIR\devtools\bin\vsign.bat -signvalve $OUTBINDIR\$(TargetFileName)" "\n" [!$RETAIL && !$SOURCESDK]
+ "call $SRCDIR\devtools\bin\vsign.bat -signvalve $OUTBINDIR\$(TargetFileName)" "\n" [!$RETAIL && !$PUBLISH && !$SOURCESDK]
$Description "Publishing to $OUTBINDIR"
$ExcludedFromBuild "No"
}
-
- $Linker
- {
- // Suppress this warning using the undocumented /ignore linker switch
- // schemalib.lib(schemaclassinfo.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
- $AdditionalOptions "$BASE /ignore:4221"
- $AdditionalDependencies "%(AdditionalDependencies)" [$VS2010]
- $TargetMachine "MachineX86 (/MACHINE:X86)" [$WIN32]
- $TargetMachine "MachineX64 (/MACHINE:X64)" [$WIN64]
-
- // This option is from the devil. Basically, it causes the link inputs
- // to vary depending on what is in the solution. This is anathema
- // to the way that we use projects and solutions here at Valve.
- // It also exposes a bug in VS2005 causing files to be recompiled/linked
- // even if nothing changed.
- $LinkLibraryDependencies "false"
- }
}
// Skeleton Project - All derived projects get this as a starting base
@@ -120,23 +103,6 @@ $Project
}
}
}
-
- // Implement __imp__EncodePointer and __imp__DecodePointer so that we can run on XP SP1
- // when building with VS 2010.
- $File "$SRCDIR\public\tier0\pointeroverride.asm" [$WIN32 && $VS2010]
- {
- $Configuration
- {
- $CustomBuildStep
- {
- // General
- $CommandLine "$QUOTE$(VCInstallDir)bin\ml.exe$QUOTE /safeseh /c /Cp /Zi /Fo$QUOTE$(IntDir)\$(InputName).obj$QUOTE $QUOTE$(InputPath)$QUOTE"
- $Description "Compiling pointeroverride.asm"
- $Outputs "$(IntDir)\$(InputName).obj"
- }
- }
- }
-
$File "$SRCDIR\common\debug_dll_check.cpp" [!$SOURCESDK]
{
$Configuration
@@ -146,18 +112,14 @@ $Project
$Create/UsePrecompiledHeader "Not Using Precompiled Headers"
}
}
- }
+ }
}
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\tier0.lib" [!$WIN64]
- $DynamicFile "$SRCDIR\lib\public\tier1.lib" [!$WIN64]
- $DynamicFile "$SRCDIR\lib\public\vstdlib.lib" [!$WIN64]
-
- $DynamicFile "$SRCDIR\lib\public\$PLATFORM\tier0.lib" [$WIN64]
- $DynamicFile "$SRCDIR\lib\public\$PLATFORM\tier1.lib" [$WIN64]
- $DynamicFile "$SRCDIR\lib\public\$PLATFORM\vstdlib.lib" [$WIN64]
+ $Implib "$LIBPUBLIC\tier0"
+ $Lib "$LIBPUBLIC\tier1"
+ $Implib "$LIBPUBLIC\vstdlib"
}
}
diff --git a/mp/src/vpc_scripts/source_dll_win32_debug.vpc b/mp/src/vpc_scripts/source_dll_win32_debug.vpc
index 5867cc9c..8d53aaf6 100644
--- a/mp/src/vpc_scripts/source_dll_win32_debug.vpc
+++ b/mp/src/vpc_scripts/source_dll_win32_debug.vpc
@@ -6,18 +6,26 @@
$IgnoreRedundancyWarning "ON"
-$MacroRequired "PLATSUBDIR"
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME"
$MacroRequired "OUTBINDIR"
+$MacroRequired "LIBPUBLIC"
+$MacroRequired "LIBCOMMON"
+$MacroRequired "PLATSUBDIR"
+$MacroRequired "OUTDLLEXT"
+$MacroRequiredAllowEmpty "GAMENAME"
+$MacroRequiredAllowEmpty "INTERMEDIATESUBDIR"
+$MacroRequiredAllowEmpty "_UNITYSUBDIR"
+$Macro "_SUBDIRSUFFIX" "$INTERMEDIATESUBDIR$GAMENAME$PLATSUBDIR$_UNITYSUBDIR"
$Configuration "Debug"
{
$General
{
// General
- $OutputDirectory ".\Debug$PLATSUBDIR"
- $IntermediateDirectory ".\Debug$PLATSUBDIR"
+ $OutputDirectory ".\Debug$_SUBDIRSUFFIX"
+ $IntermediateDirectory ".\Debug$_SUBDIRSUFFIX"
+
$ExtensionsToDeleteOnClean
$BuildLogFile
$InheritedProjectPropertySheets
@@ -49,11 +57,10 @@ $Configuration "Debug"
// General
$AdditionalIncludeDirectories "$SRCDIR\common;$SRCDIR\public;$SRCDIR\public\tier0;$SRCDIR\public\tier1"
$Resolve#UsingReferences
- $DebugInformationFormat "Program Database for Edit & Continue (/ZI)" [!$EANDCDISABLED && !$WIN64]
- $DebugInformationFormat "Program Database (/Zi)" [$EANDCDISABLED || $WIN64]
+ $DebugInformationFormat "Program Database for Edit & Continue (/ZI)" [$WIN32]
+ $DebugInformationFormat "Program Database (/Zi)" [$WIN64]
$SuppressStartupBanner
$WarningLevel "Level 4 (/W4)"
- $Detect64bitPortabilityIssues "Yes (/Wp64)"
$TreatWarningsAsErrors
$UseUNICODEResponseFiles
@@ -67,19 +74,14 @@ $Configuration "Debug"
$WholeProgramOptimization
// Preprocessor
- $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;DLLNAME=$OUTBINNAME"
- $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+ $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
$IgnoreStandardIncludePath
$GeneratePreprocessedFile
$KeepComments
// Code Generation
$EnableStringPooling "Yes (/GF)"
- // EnableMinimalRebuild is incompatible with /MP (multi-processor builds)
- // and it also makes it hard to iterate on warnings because the compiler
- // detects that there is no reason to recompile when you request it.
- // It should always be off? It should definitely be off for /analyze builds.
- //$EnableMinimalRebuild "Yes (/Gm)" [!$ANALYZE]
+ $EnableMinimalRebuild
$EnableC++Exceptions "No"
$SmallerTypeCheck
$BasicRuntimeChecks "Default"
@@ -88,7 +90,6 @@ $Configuration "Debug"
$BufferSecurityCheck "Yes"
$EnableFunctionLevelLinking
$EnableEnhancedInstructionSet
- $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" [$WIN32]
$FloatingPointModel "Fast (/fp:fast)"
$EnableFloatingPointExceptions
@@ -127,18 +128,18 @@ $Configuration "Debug"
$ShowIncludes
$UndefinePreprocessorDefinitions
$UndefineAllPreprocessorDefinitions
- $UseFullPaths
+ $UseFullPaths "Yes (/FC)"
$OmitDefaultLibraryNames
$ErrorReporting "Prompt Immediately (/errorReport:prompt)"
- // Command Line
- $AdditionalOptions "$BASE /MP"
+ // Command Line (L4D adding /MP)
+ $AdditionalOptions "/MP /Zm200"
}
$Linker
{
// General
- $OutputFile "$(OutDir)/$OUTBINNAME.dll"
+ $OutputFile "$(OutDir)/$OUTBINNAME$OUTDLLEXT"
$ShowProgress "Not Set"
$Version
$EnableIncrementalLinking "Yes (/INCREMENTAL)"
@@ -166,13 +167,12 @@ $Configuration "Debug"
$ManifestFile
$AdditionalManifestDependencies
$AllowIsolation
+ //$UACExecutionLevel [$VS2010]
// Debugging
$GenerateDebugInfo "Yes (/DEBUG)"
$GenerateProgramDatabaseFile "$(IntDir)/$(TargetName).pdb"
$StripPrivateSymbols
- $GenerateMapFile "No"
- $MapFileName "$(IntDir)/$(TargetName).map"
$MapExports
$DebuggableAssembly
@@ -188,6 +188,9 @@ $Configuration "Debug"
$SwapRunFromNetwork
$Driver
+ // DYNAMICBASE/ASLR in debug builds is annoying and not helpful.
+ $RandomizedBaseAddress "false"
+
// Optimization
$References
$EnableCOMDATFolding
@@ -213,6 +216,7 @@ $Configuration "Debug"
$DelayLoadedDLL
$ImportLibrary
$MergeSections
+ $TargetMachine
$Profile
$CLRThreadAttribute
$CLRImageType
@@ -226,12 +230,6 @@ $Configuration "Debug"
$AdditionalOptions
}
- $Linker [$VS2010]
- {
- // SAFE_SEH should always be disabled on debug builds.
- $ImageHasSafeExceptionHandlers "false"
- }
-
$ManifestTool
{
// General
@@ -285,7 +283,7 @@ $Configuration "Debug"
$Resources
{
// General
- $PreprocessorDefinitions "_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ $PreprocessorDefinitions "$BASE;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
$Culture "English (United States) (0x409)"
$AdditionalIncludeDirectories
$IgnoreStandardIncludePath
diff --git a/mp/src/vpc_scripts/source_dll_win32_release.vpc b/mp/src/vpc_scripts/source_dll_win32_release.vpc
index 997d5809..58eea752 100644
--- a/mp/src/vpc_scripts/source_dll_win32_release.vpc
+++ b/mp/src/vpc_scripts/source_dll_win32_release.vpc
@@ -6,18 +6,34 @@
$IgnoreRedundancyWarning "ON"
-$MacroRequired "PLATSUBDIR"
+// Disable frame pointer omission to allow fast stack walking, necessary for
+// good ETW profiling.
+$Macro NOFPO "1"
+
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME"
$MacroRequired "OUTBINDIR"
+$MacroRequired "LIBPUBLIC"
+$MacroRequired "LIBCOMMON"
+$MacroRequired "PLATSUBDIR"
+$MacroRequired "OUTDLLEXT"
+$MacroRequiredAllowEmpty "GAMENAME"
+$MacroRequiredAllowEmpty "INTERMEDIATESUBDIR"
+$MacroRequiredAllowEmpty "_UNITYSUBDIR"
+$Macro "_SUBDIRSUFFIX" "$INTERMEDIATESUBDIR$GAMENAME$PLATSUBDIR$_UNITYSUBDIR"
$Configuration "Release"
{
$General
{
// General
- $OutputDirectory ".\Release$PLATSUBDIR"
- $IntermediateDirectory ".\Release$PLATSUBDIR"
+ $OutputDirectory ".\Release$_SUBDIRSUFFIX" [!$RETAIL && !$PROFILE]
+ $IntermediateDirectory ".\Release$_SUBDIRSUFFIX" [!$RETAIL && !$PROFILE]
+ $OutputDirectory ".\Retail$_SUBDIRSUFFIX" [$RETAIL]
+ $IntermediateDirectory ".\Retail$_SUBDIRSUFFIX" [$RETAIL]
+ $OutputDirectory ".\Profile$_SUBDIRSUFFIX" [!$RETAIL && $PROFILE]
+ $IntermediateDirectory ".\Profile$_SUBDIRSUFFIX" [!$RETAIL && $PROFILE]
+
$ExtensionsToDeleteOnClean
$BuildLogFile
$InheritedProjectPropertySheets
@@ -29,7 +45,7 @@ $Configuration "Release"
$MinimizeCRTUseInATL
$CharacterSet "Use Multi-Byte Character Set"
$CommonLanguageRuntimeSupport
- $WholeProgramOptimization
+ $WholeProgramOptimization "Use Link Time Code Generation" [$LTCG]
}
$Debugging
@@ -52,7 +68,6 @@ $Configuration "Release"
$DebugInformationFormat "Program Database (/Zi)"
$SuppressStartupBanner
$WarningLevel "Level 4 (/W4)"
- $Detect64bitPortabilityIssues "Yes (/Wp64)"
$TreatWarningsAsErrors
$UseUNICODEResponseFiles
@@ -66,10 +81,8 @@ $Configuration "Release"
$WholeProgramOptimization
// Preprocessor
- $PreprocessorDefinitions "WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;DLLNAME=$OUTBINNAME"
- // Enable asserts in release builds if /define:releaseasserts is specified on the VPC command line.
- $PreprocessorDefinitions "$BASE;RELEASEASSERTS" [$RELEASEASSERTS]
- $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+ $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS]
$IgnoreStandardIncludePath
$GeneratePreprocessedFile
$KeepComments
@@ -82,11 +95,10 @@ $Configuration "Release"
$BasicRuntimeChecks
$RuntimeLibrary "Multi-threaded (/MT)"
$StructMemberAlignment
- $BufferSecurityCheck "Yes" [$STAGING_ONLY]
- $BufferSecurityCheck "No" [!$STAGING_ONLY]
+ $BufferSecurityCheck "No" [$RETAIL]
+ $BufferSecurityCheck "Yes" [!$RETAIL]
$EnableFunctionLevelLinking "Yes (/Gy)"
$EnableEnhancedInstructionSet
- $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" [$WIN32]
$FloatingPointModel "Fast (/fp:fast)"
$EnableFloatingPointExceptions
@@ -125,20 +137,21 @@ $Configuration "Release"
$ShowIncludes
$UndefinePreprocessorDefinitions
$UndefineAllPreprocessorDefinitions
- $UseFullPaths
+ $UseFullPaths "Yes (/FC)"
$OmitDefaultLibraryNames
$ErrorReporting "Prompt Immediately (/errorReport:prompt)"
- // Command Line
- $AdditionalOptions "$BASE /MP"
+ // Command Line (L4D adding /MP)
+ $AdditionalOptions "/MP /Zm200"
// Enable extra debugging information.
- $AdditionalOptions "$BASE /d2Zi+"
+ $AdditionalOptions "$BASE /d2Zi+" [$VS2010]
+ $AdditionalOptions "$BASE /Oy-" [$NOFPO]
}
$Linker
{
// General
- $OutputFile "$(OutDir)/$OUTBINNAME.dll"
+ $OutputFile "$(OutDir)/$OUTBINNAME$OUTDLLEXT"
$ShowProgress "Not Set"
$Version
$EnableIncrementalLinking "No (/INCREMENTAL:NO)"
@@ -166,13 +179,12 @@ $Configuration "Release"
$ManifestFile
$AdditionalManifestDependencies
$AllowIsolation
+ //$UACExecutionLevel
// Debugging
$GenerateDebugInfo "Yes (/DEBUG)"
$GenerateProgramDatabaseFile "$(IntDir)/$(TargetName).pdb"
$StripPrivateSymbols
- $GenerateMapFile "No"
- $MapFileName "$(IntDir)/$(TargetName).map"
$MapExports
$DebuggableAssembly
@@ -188,9 +200,22 @@ $Configuration "Release"
$SwapRunFromNetwork
$Driver
+ // RandomizeBaseAddress (/DYNAMICBASE, /ASLR) is a hugely important security setting.
+ // However it can cause confusion during development and can make tracking down certain
+ // bugs tricky by making code/stack/heap addresses change between runs. Enable for retail,
+ // but disable for development builds.
+ $RandomizedBaseAddress "true" [$RETAIL]
+ $RandomizedBaseAddress "false" [!$RETAIL]
+
// Optimization
$References "Eliminate Unreferenced Data (/OPT:REF)"
- $EnableCOMDATFolding "Remove Redundant COMDATs (/OPT:ICF)"
+ // COMDAT folding can be very confusing when debugging and profiling because it can
+ // cause execution to go through nonsensical functions (that happen to be binary
+ // equivalent to the logical function). The performance benefit is small enough that
+ // it is not worth enabling in the development builds. It should be enabled on retail
+ // builds.
+ $EnableCOMDATFolding "Remove Redundant COMDATs (/OPT:ICF)" [$RETAIL]
+ $EnableCOMDATFolding "No (/OPT:NOICF)" [!$RETAIL]
$OptimizeForWindows98
$FunctionOrder
$ProfileGuidedDatabase
@@ -208,12 +233,13 @@ $Configuration "Release"
$NoEntryPoint
$SetChecksum
$BaseAddress "$LOADADDRESS_DEVELOPMENT"
- $BaseAddress "$LOADADDRESS_RETAIL" [$RETAIL]
+ //$BaseAddress "$LOADADDRESS_RETAIL" [$RETAIL]
$FixedBaseAddress
$TurnOffAssemblyGeneration
$DelayLoadedDLL
$ImportLibrary
$MergeSections
+ $TargetMachine
$Profile
$CLRThreadAttribute
$CLRImageType
@@ -224,7 +250,7 @@ $Configuration "Release"
$CLRUnmanagedCodeCheck
// Command Line
- $AdditionalOptions "$BASE /DYNAMICBASE"
+ $AdditionalOptions
}
$ManifestTool
@@ -280,7 +306,7 @@ $Configuration "Release"
$Resources
{
// General
- $PreprocessorDefinitions "NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ $PreprocessorDefinitions "$BASE;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
$Culture "English (United States) (0x409)"
$AdditionalIncludeDirectories
$IgnoreStandardIncludePath
@@ -320,4 +346,4 @@ $Configuration "Release"
$Outputs
$AdditionalDependencies
}
-} \ No newline at end of file
+}
diff --git a/mp/src/vpc_scripts/source_exe_base.vpc b/mp/src/vpc_scripts/source_exe_base.vpc
index 7fc9096d..24b94cb2 100644
--- a/mp/src/vpc_scripts/source_exe_base.vpc
+++ b/mp/src/vpc_scripts/source_exe_base.vpc
@@ -1,13 +1,20 @@
-//-----------------------------------------------------------------------------
-// source_exe_base.VPC
-//
-// Project Script
-//-----------------------------------------------------------------------------
-
+$Include "$SRCDIR\vpc_scripts\platform_dirs.vpc"
$include "$SRCDIR\vpc_scripts\source_base.vpc"
-$include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc" [$WINDOWS]
-$Include "$SRCDIR\vpc_scripts\source_exe_linux_base.vpc" [$LINUX]
-$include "$SRCDIR\vpc_scripts\source_exe_posix_base.vpc" [$POSIX && !$LINUX]
-$include "$SRCDIR\vpc_scripts\source_xex_x360_base.vpc" [$X360]
+$Include "$SRCDIR\vpc_scripts\source_exe_posix_base.vpc" [$POSIX]
+$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc" [$WIN32 || $WIN64]
+$Include "$SRCDIR\vpc_scripts\source_xex_x360_base.vpc" [$X360]
+$Include "$SRCDIR\vpc_scripts\source_ppu_elf_ps3_base.vpc" [$PS3]
+
$Include "$SRCDIR\vpc_scripts\source_video_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;DEV_BUILD" [!$PUBLISH]
+ $PreprocessorDefinitions "$BASE;_PROFILE" [$PROFILE && !$RETAIL]
+ $PreprocessorDefinitions "$BASE;RETAIL_ASSERTS" [$RETAIL && $RETAILASSERTS]
+ $PreprocessorDefinitions "$BASE;FRAME_POINTER_OMISSION_DISABLED" [$NOFPO || $VS2010]
+ }
+} \ No newline at end of file
diff --git a/mp/src/vpc_scripts/source_exe_con_base.vpc b/mp/src/vpc_scripts/source_exe_con_base.vpc
new file mode 100644
index 00000000..8edc0449
--- /dev/null
+++ b/mp/src/vpc_scripts/source_exe_con_base.vpc
@@ -0,0 +1,18 @@
+$Include "$SRCDIR\vpc_scripts\platform_dirs.vpc"
+$include "$SRCDIR\vpc_scripts\source_base.vpc"
+
+
+$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc" [$WINDOWS]
+$Include "$SRCDIR\vpc_scripts\source_exe_posix_base.vpc" [$POSIX]
+$Include "$SRCDIR\vpc_scripts\source_xex_x360_base.vpc" [$X360]
+
+$Configuration
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;DEV_BUILD" [!$PUBLISH]
+ $PreprocessorDefinitions "$BASE;_PROFILE" [$PROFILE && !$RETAIL]
+ $PreprocessorDefinitions "$BASE;RETAIL_ASSERTS" [$RETAIL && $RETAILASSERTS]
+ $PreprocessorDefinitions "$BASE;FRAME_POINTER_OMISSION_DISABLED" [$NOFPO || $VS2010]
+ }
+}
diff --git a/mp/src/vpc_scripts/source_exe_con_win32_base.vpc b/mp/src/vpc_scripts/source_exe_con_win32_base.vpc
index 0b83dfa9..e410cdf0 100644
--- a/mp/src/vpc_scripts/source_exe_con_win32_base.vpc
+++ b/mp/src/vpc_scripts/source_exe_con_win32_base.vpc
@@ -7,6 +7,8 @@
$IgnoreRedundancyWarning "ON"
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINDIR"
+$MacroRequired "PLATSUBDIR"
+
$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
diff --git a/mp/src/vpc_scripts/source_exe_posix_base.vpc b/mp/src/vpc_scripts/source_exe_posix_base.vpc
index d864cc0e..33e7b2a6 100644
--- a/mp/src/vpc_scripts/source_exe_posix_base.vpc
+++ b/mp/src/vpc_scripts/source_exe_posix_base.vpc
@@ -5,10 +5,11 @@
//-----------------------------------------------------------------------------
$Include "$SRCDIR\vpc_scripts\version.vpc"
-$Include "$SRCDIR\vpc_scripts\source_posix_base.vpc"
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME" "$PROJECTNAME"
+$Macro IS_LIB_PROJECT "1"
+$Include "$SRCDIR\vpc_scripts\source_posix_base.vpc"
$Include "$SRCDIR\vpc_scripts\loadaddress.vpc"
@@ -22,9 +23,21 @@ $Configuration
$ConfigurationType "Application (.exe)"
}
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;EXENAME=$OUTBINNAME"
+ }
+
$Linker
{
- $OutputFile "$SRCDIR/../game/$OUTBINNAME"
+ $OutputFile "$SRCDIR/../game/$OUTBINNAME"
+
+ // In order to get the Valve standard allocator memory alignment (16-byte
+ // alignment for objects that are a multiple of 16 bytes) we use tcmalloc.
+ // Using -l will ask the linker to use it, but if there are no references
+ // to malloc/free then it may not actually use it. Wrapping the flag in the
+ // as-needed controls forces it to be pulled in (from libtcmalloc_minimal.so).
+ $GCC_ExtraLinkerFlags "-Wl,--no-as-needed -ltcmalloc_minimal -Wl,--as-needed" [$LINUXALL&&!$DEDICATED]
}
}
@@ -49,16 +62,10 @@ $Project
{
$File "$ROOTSCRIPT"
}
-
-
- $Folder "Link Libraries"
+
+ $Folder "Link Libraries" [$LINUXALL&&!$DEDICATED]
{
- $ImpLib tier0 [$LINUXALL]
- $Lib tier1 [$LINUXALL]
- $ImpLib vstdlib [$LINUXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXtier0$_IMPLIB_EXT" [!$LINUXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier1$_STATICLIB_EXT" [!$LINUXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXvstdlib$_IMPLIB_EXT" [!$LINUXALL]
+ $File "$SRCDIR/thirdparty/gperftools-2.0/.libs/libtcmalloc_minimal.so"
}
}
diff --git a/mp/src/vpc_scripts/source_exe_qt_base.vpc b/mp/src/vpc_scripts/source_exe_qt_base.vpc
new file mode 100644
index 00000000..c327c7b4
--- /dev/null
+++ b/mp/src/vpc_scripts/source_exe_qt_base.vpc
@@ -0,0 +1,5 @@
+// call up either the posix or win32 vpc file based upon target platform
+
+//$Include "$SRCDIR\vpc_scripts\source_exe_qt_linux_base.vpc" [$POSIX]
+$Include "$SRCDIR\vpc_scripts\source_exe_qt_win32_base.vpc" [$WIN32 || $WIN64]
+ \ No newline at end of file
diff --git a/mp/src/vpc_scripts/source_exe_qt_con_base.vpc b/mp/src/vpc_scripts/source_exe_qt_con_base.vpc
new file mode 100644
index 00000000..4620e908
--- /dev/null
+++ b/mp/src/vpc_scripts/source_exe_qt_con_base.vpc
@@ -0,0 +1,16 @@
+// base file for a console app with qt. win32 only for now. CG: I'm not 100% sure this is the right definition,
+// but I'm moving the logic here so it doesn't end up pasted into every such app.
+
+$Include "$SRCDIR\vpc_scripts\source_exe_qt_win32_base.vpc"
+
+$Configuration
+{
+ $Linker
+ {
+ $SubSystem "Console (/SUBSYSTEM:CONSOLE)"
+ }
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE,..\common"
+ }
+}
diff --git a/mp/src/vpc_scripts/source_exe_qt_win32_base.vpc b/mp/src/vpc_scripts/source_exe_qt_win32_base.vpc
new file mode 100644
index 00000000..bb186df3
--- /dev/null
+++ b/mp/src/vpc_scripts/source_exe_qt_win32_base.vpc
@@ -0,0 +1,48 @@
+//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
+//
+//==================================================================================================
+
+$Macro QT_ROOT "$SRCDIR\thirdparty\lgpl\qt"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_base.vpc"
+$Include "$SRCDIR\vpc_scripts\qt_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE;.\;$SRCDIR\game\shared;$QT_ROOT\include;.\$QT_TARGET_SUBDIR"
+ $PreprocessorDefinitions "$BASE;UNICODE;QT_LARGEFILE_SUPPORT;QT_DLL;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
+ $PreprocessorDefinitions "$BASE;QT_NO_DEBUG" [!$QTDEBUG]
+ $DisableSpecificWarnings "4127;4512;$BASE"
+ }
+}
+
+$Configuration
+{
+ $Linker
+ {
+ // Link tier0 first because Qt needs our allocators during static object initization!
+ $AdditionalDependencies "$BASE $LIBPUBLIC\tier0.lib"
+ $GenerateManifest "Yes"
+ $AdditionalOptions "$BASE $QUOTE/MANIFESTDEPENDENCY:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' publicKeyToken='6595b64144ccf1df' language='*' processorArchitecture='*'$QUOTE"
+ }
+}
+
+$Project
+{
+ $Folder "Link Libraries" [$QTDEBUG]
+ {
+ $Lib "$QT_ROOT\lib\qtmaind"
+ $Lib "$QT_ROOT\lib\qtcored4"
+ $Lib "$QT_ROOT\lib\qtguid4"
+ }
+
+ $Folder "Link Libraries" [!$QTDEBUG]
+ {
+ $Lib "$QT_ROOT\lib\qtmain"
+ $Lib "$QT_ROOT\lib\qtcore4"
+ $Lib "$QT_ROOT\lib\qtgui4"
+ }
+}
+
diff --git a/mp/src/vpc_scripts/source_exe_win_win32_base.vpc b/mp/src/vpc_scripts/source_exe_win_win32_base.vpc
index ff784642..bda4bc3c 100644
--- a/mp/src/vpc_scripts/source_exe_win_win32_base.vpc
+++ b/mp/src/vpc_scripts/source_exe_win_win32_base.vpc
@@ -6,59 +6,71 @@
$Include "$SRCDIR\vpc_scripts\version.vpc"
-$Macro NOAPPENDPLATSUBDIR "1" [!$WIN64]
-
-$MacroRequired "PLATSUBDIR"
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME" "$PROJECTNAME"
$MacroRequired "OUTBINDIR"
-// These are convenient for adjusting directory paths based on platform
-// but they must be used without absolute consistency to avoid dependency
-// problems. It appears that if VPC compares $LIBPUBLIC to $SRCDIR\lib\public
-// it will decide that they are not equal, even if the *value* of $LIBPUBLIC
-// is $SRCDIR\lib\public. These macros can safely be used in copy commands
-// and other areas that VPC doesn't use for dependency tracking.
-$Macro LIBPUBLIC "$SRCDIR\lib\public"
-$Macro LIBCOMMON "$SRCDIR\lib\common"
+$Macro OUTBINDIR "$OUTBINDIR$PLATSUBDIR"
+$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR"
+$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR"
$Include "$SRCDIR\vpc_scripts\loadaddress.vpc"
$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_debug.vpc"
$Include "$SRCDIR\vpc_scripts\source_exe_win_win32_release.vpc"
$Include "$SRCDIR\vpc_scripts\source_win32_base.vpc"
-// Fix up directories for targets like win64
-$Macro OUTBINDIR "$OUTBINDIR$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR]
-$Macro LIBPUBLIC "$LIBPUBLIC$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR]
-$Macro LIBCOMMON "$LIBCOMMON$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR]
-
$IgnoreRedundancyWarning "ON"
// Common Configuration
$Configuration
{
- $General [$VS2010]
+ $General [$VS2010]
+ {
+ $TargetName "$OUTBINNAME"
+ }
+
+
+ $Compiler
{
- $TargetName "$OUTBINNAME"
+ $PreprocessorDefinitions "$BASE;PLATFORM_64BITS;WIN64;_WIN64;COMPILER_MSVC64" [$WIN64]
+ $PreprocessorDefinitions "$BASE;COMPILER_MSVC32" [$WIN32]
+ $PreprocessorDefinitions "$BASE;COMPILER_MSVC;EXENAME=$OUTBINNAME;_DLL_EXT=$_DLL_EXT"
}
+ $Compiler [$WIN32]
+ {
+ $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)"
+ }
+
+ $Linker
+ {
+ $AdditionalDependencies "$BASE shell32.lib user32.lib advapi32.lib gdi32.lib comdlg32.lib ole32.lib" [$WIN32]
+ $TargetMachine "MachineX86 (/MACHINE:X86)" [$WIN32]
+ $TargetMachine "MachineX64 (/MACHINE:X64)" [$WIN64]
+ // NXCOMPAT (also known as DEP or Data Access Protection) should be enabled for all
+ // executables for security and debugging reasons.
+ $AdditionalOptions "/NXCOMPAT"
+ // Suppress this pointless warning using the undocumented /ignore linker switch
+ // schemalib.lib(schemaclassinfo.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
+ $AdditionalOptions "$BASE /ignore:4221"
+ }
+
$PreBuildEvent
{
$CommandLine "if EXIST $OUTBINDIR\$(TargetFileName) for /f $QUOTEdelims=$QUOTE %%A in ('attrib $QUOTE$OUTBINDIR\$(TargetFileName)$QUOTE') do set valveTmpIsReadOnly=$QUOTE%%A$QUOTE" "\n" \
"set valveTmpIsReadOnlyLetter=%valveTmpIsReadOnly:~6,1%" "\n" \
"if $QUOTE%valveTmpIsReadOnlyLetter%$QUOTE==$QUOTER$QUOTE del /q $QUOTE$(TargetDir)$QUOTE$(TargetFileName)" "\n" \
- "$CRCCHECK"
+ "$CRCCHECK" "\n"
}
$PostBuildEvent [!$ANALYZE]
{
- $CommandLine "if not exist $QUOTE$OUTBINDIR$QUOTE mkdir $QUOTE$OUTBINDIR$QUOTE" "\n"
- $CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetFileName) $SRCDIR" "\n" [! $SOURCESDK ]
- $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetFileName) $OUTBINDIR\$(TargetFileName)" "\n" \
+ $CommandLine "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetFileName) $SRCDIR" "\n" [!$SOURCESDK]
+ $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetFileName) $OUTBINDIR\$(TargetFileName) >nul" "\n" \
"if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
- "if exist $QUOTE$(TargetDir)$QUOTE$(TargetName).map copy $QUOTE$(TargetDir)$QUOTE$(TargetName).map $OUTBINDIR\$(TargetName).map" "\n"
- $CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetName).pdb $SRCDIR" "\n" [ !$SOURCESDK ]
- $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetName).pdb $OUTBINDIR\$(TargetName).pdb" "\n" \
+ "if exist $QUOTE$(TargetDir)$QUOTE$(TargetName).map copy $QUOTE$(TargetDir)$QUOTE$(TargetName).map $OUTBINDIR\$(TargetName).map >nul" "\n"
+ $CommandLine "$BASE" "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTBINDIR\$(TargetName).pdb $SRCDIR" "\n" [!$SOURCESDK]
+ $CommandLine "$BASE" "copy $QUOTE$(TargetDir)$QUOTE$(TargetName).pdb $OUTBINDIR\$(TargetName).pdb >nul" "\n" \
"if ERRORLEVEL 1 goto BuildEventFailed" "\n" \
"goto BuildEventOK" "\n" \
":BuildEventFailed" "\n" \
@@ -66,29 +78,9 @@ $Configuration
"del /q $QUOTE$(TargetDir)$QUOTE$(TargetFileName)" "\n" \
"exit 1" "\n" \
":BuildEventOK" "\n"
-
- $CommandLine "$BASE" "\n" \
- "call $SRCDIR\devtools\bin\vsign.bat -sign $OUTBINDIR\$(TargetFileName)" "\n" [$RETAIL && !$SOURCESDK ]
-
- $CommandLine "$BASE" "\n" \
- "call $SRCDIR\devtools\bin\vsign.bat -signvalve $OUTBINDIR\$(TargetFileName)" "\n" [!$RETAIL && !$SOURCESDK ]
-
$Description "Publishing to $OUTBINDIR"
$ExcludedFromBuild "No"
}
-
- $Linker
- {
- // NXCOMPAT (also known as DEP or Data Access Protection) should be enabled for all
- // executables for security and debugging reasons.
- $AdditionalOptions "$BASE /NXCOMPAT"
- // Suppress this warning using the undocumented /ignore linker switch
- // schemalib.lib(schemaclassinfo.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
- $AdditionalOptions "$BASE /ignore:4221"
- $AdditionalDependencies "%(AdditionalDependencies)" [$VS2010]
- $TargetMachine "MachineX86 (/MACHINE:X86)" [$WIN32]
- $TargetMachine "MachineX64 (/MACHINE:X64)" [$WIN64]
- }
}
// Skeleton Project - All derived projects get this as a starting base
@@ -106,33 +98,13 @@ $Project
}
}
}
-
- // Implement __imp__EncodePointer and __imp__DecodePointer so that we can run on XP SP1
- // when building with VS 2010.
- $File "$SRCDIR\public\tier0\pointeroverride.asm" [$WIN32 && $VS2010]
- {
- $Configuration
- {
- $CustomBuildStep
- {
- // General
- $CommandLine "$QUOTE$(VCInstallDir)bin\ml.exe$QUOTE /c /Cp /Zi /Fo$QUOTE$(IntDir)\$(InputName).obj$QUOTE $QUOTE$(InputPath)$QUOTE"
- $Description "Compiling pointeroverride.asm"
- $Outputs "$(IntDir)\$(InputName).obj"
- }
- }
- }
}
$Folder "Link Libraries"
{
- $DynamicFile "$SRCDIR\lib\public\tier0.lib" [$NOAPPENDPLATSUBDIR]
- $DynamicFile "$SRCDIR\lib\public\tier1.lib" [$NOAPPENDPLATSUBDIR]
- $DynamicFile "$SRCDIR\lib\public\vstdlib.lib" [$NOAPPENDPLATSUBDIR]
-
- $DynamicFile "$SRCDIR\lib\public$PLATSUBDIR\tier0.lib" [!$NOAPPENDPLATSUBDIR]
- $DynamicFile "$SRCDIR\lib\public$PLATSUBDIR\tier1.lib" [!$NOAPPENDPLATSUBDIR]
- $DynamicFile "$SRCDIR\lib\public$PLATSUBDIR\vstdlib.lib" [!$NOAPPENDPLATSUBDIR]
+ $Implib "$LIBPUBLIC\tier0"
+ $Lib "$LIBPUBLIC\tier1"
+ $Implib "$LIBPUBLIC\vstdlib"
}
}
diff --git a/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc b/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc
index 06d2401b..e3728d6e 100644
--- a/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc
+++ b/mp/src/vpc_scripts/source_exe_win_win32_debug.vpc
@@ -6,18 +6,25 @@
$IgnoreRedundancyWarning "ON"
-$MacroRequired "PLATSUBDIR"
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME"
$MacroRequired "OUTBINDIR"
+$MacroRequired "LIBPUBLIC"
+$MacroRequired "LIBCOMMON"
+$MacroRequired "PLATSUBDIR"
+$MacroRequiredAllowEmpty "GAMENAME"
+$MacroRequiredAllowEmpty "INTERMEDIATESUBDIR"
+$MacroRequiredAllowEmpty "_UNITYSUBDIR"
+$MacroRequiredAllowEmpty "_STATICSUBDIR"
+$Macro "_SUBDIRSUFFIX" "$INTERMEDIATESUBDIR$_STATICSUBDIR$GAMENAME$PLATSUBDIR$_UNITYSUBDIR"
$Configuration "Debug"
{
$General
{
// General
- $OutputDirectory ".\Debug$PLATSUBDIR"
- $IntermediateDirectory ".\Debug$PLATSUBDIR"
+ $OutputDirectory ".\Debug$_SUBDIRSUFFIX"
+ $IntermediateDirectory ".\Debug$_SUBDIRSUFFIX"
$ExtensionsToDeleteOnClean
$BuildLogFile
$InheritedProjectPropertySheets
@@ -50,11 +57,10 @@ $Configuration "Debug"
// General
$AdditionalIncludeDirectories "$SRCDIR\common;$SRCDIR\public;$SRCDIR\public\tier0;$SRCDIR\public\tier1"
$Resolve#UsingReferences
- $DebugInformationFormat "Program Database for Edit & Continue (/ZI)" [!$EANDCDISABLED && !$WIN64]
- $DebugInformationFormat "Program Database (/Zi)" [$EANDCDISABLED || $WIN64]
+ $DebugInformationFormat "Program Database for Edit & Continue (/ZI)" [$WIN32]
+ $DebugInformationFormat "Program Database (/Zi)" [$WIN64]
$SuppressStartupBanner
$WarningLevel "Level 4 (/W4)"
- $Detect64bitPortabilityIssues "Yes (/Wp64)"
$TreatWarningsAsErrors "No"
$UseUNICODEResponseFiles "No"
@@ -68,8 +74,7 @@ $Configuration "Debug"
$WholeProgramOptimization
// Preprocessor
- $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
- $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+ $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
$IgnoreStandardIncludePath
$GeneratePreprocessedFile
$KeepComments
@@ -89,7 +94,6 @@ $Configuration "Debug"
$BufferSecurityCheck "Yes"
$EnableFunctionLevelLinking
$EnableEnhancedInstructionSet
- $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" [$WIN32]
$FloatingPointModel "Fast (/fp:fast)"
$EnableFloatingPointExceptions
@@ -128,12 +132,12 @@ $Configuration "Debug"
$ShowIncludes
$UndefinePreprocessorDefinitions
$UndefineAllPreprocessorDefinitions
- $UseFullPaths
+ $UseFullPaths "Yes (/FC)"
$OmitDefaultLibraryNames
$ErrorReporting "Prompt Immediately (/errorReport:prompt)"
// Command Line
- $AdditionalOptions "$BASE /MP"
+ $AdditionalOptions
}
$Linker
@@ -163,18 +167,16 @@ $Configuration "Debug"
$AssemblyLinkResource
// Manifest File
- $GenerateManifest "No" [!$VS2010]
- $GenerateManifest "Yes" [$VS2010]
+ $GenerateManifest "Yes"
$ManifestFile
$AdditionalManifestDependencies
$AllowIsolation
+ $UACExecutionLevel
// Debugging
$GenerateDebugInfo "Yes (/DEBUG)"
$GenerateProgramDatabaseFile "$(IntDir)/$(TargetName).pdb"
$StripPrivateSymbols
- $GenerateMapFile "No"
- $MapFileName "$(IntDir)/$(TargetName).map"
$MapExports
$DebuggableAssembly
@@ -190,6 +192,9 @@ $Configuration "Debug"
$SwapRunFromNetwork
$Driver
+ // DYNAMICBASE/ASLR in debug builds is annoying and not helpful.
+ $RandomizedBaseAddress "false"
+
// Optimization
$References
$EnableCOMDATFolding
@@ -215,6 +220,7 @@ $Configuration "Debug"
$DelayLoadedDLL
$ImportLibrary
$MergeSections
+ $TargetMachine
$Profile
$CLRThreadAttribute
$CLRImageType
@@ -223,12 +229,9 @@ $Configuration "Debug"
$DelaySign
$ErrorReporting "Prompt Immediately (/ERRORREPORT:PROMPT)"
$CLRUnmanagedCodeCheck
- }
- $Linker [$VS2010]
- {
- // SAFE_SEH should always be disabled on debug builds.
- $ImageHasSafeExceptionHandlers "false"
+ // Command Line
+ $AdditionalOptions
}
$ManifestTool
diff --git a/mp/src/vpc_scripts/source_exe_win_win32_release.vpc b/mp/src/vpc_scripts/source_exe_win_win32_release.vpc
index 9948bf15..eed85c40 100644
--- a/mp/src/vpc_scripts/source_exe_win_win32_release.vpc
+++ b/mp/src/vpc_scripts/source_exe_win_win32_release.vpc
@@ -6,18 +6,33 @@
$IgnoreRedundancyWarning "ON"
-$MacroRequired "PLATSUBDIR"
+// Disable frame pointer omission to allow fast stack walking, necessary for
+// good ETW profiling.
+$Macro NOFPO "1"
+
$MacroRequired "SRCDIR"
$MacroRequired "OUTBINNAME"
$MacroRequired "OUTBINDIR"
+$MacroRequired "LIBPUBLIC"
+$MacroRequired "LIBCOMMON"
+$MacroRequired "PLATSUBDIR"
+$MacroRequiredAllowEmpty "GAMENAME"
+$MacroRequiredAllowEmpty "INTERMEDIATESUBDIR"
+$MacroRequiredAllowEmpty "_UNITYSUBDIR"
+$MacroRequiredAllowEmpty "_STATICSUBDIR"
+$Macro "_SUBDIRSUFFIX" "$INTERMEDIATESUBDIR$_STATICSUBDIR$GAMENAME$PLATSUBDIR$_UNITYSUBDIR"
$Configuration "Release"
{
$General
{
// General
- $OutputDirectory ".\Release$PLATSUBDIR"
- $IntermediateDirectory ".\Release$PLATSUBDIR"
+ $OutputDirectory ".\Release$_SUBDIRSUFFIX" [!$RETAIL && !$PROFILE]
+ $IntermediateDirectory ".\Release$_SUBDIRSUFFIX" [!$RETAIL && !$PROFILE]
+ $OutputDirectory ".\Retail$_SUBDIRSUFFIX" [$RETAIL]
+ $IntermediateDirectory ".\Retail$_SUBDIRSUFFIX" [$RETAIL]
+ $OutputDirectory ".\Profile$_SUBDIRSUFFIX" [!$RETAIL && $PROFILE]
+ $IntermediateDirectory ".\Profile$_SUBDIRSUFFIX" [!$RETAIL && $PROFILE]
$ExtensionsToDeleteOnClean
$BuildLogFile
$InheritedProjectPropertySheets
@@ -29,7 +44,7 @@ $Configuration "Release"
$MinimizeCRTUseInATL
$CharacterSet "Use Multi-Byte Character Set"
$CommonLanguageRuntimeSupport
- $WholeProgramOptimization
+ $WholeProgramOptimization "Use Link Time Code Generation" [$LTCG]
}
$Debugging
@@ -53,7 +68,6 @@ $Configuration "Release"
$DebugInformationFormat "Program Database (/Zi)"
$SuppressStartupBanner
$WarningLevel "Level 4 (/W4)"
- $Detect64bitPortabilityIssues "Yes (/Wp64)"
$TreatWarningsAsErrors
$UseUnicodeResponseFiles
@@ -67,10 +81,8 @@ $Configuration "Release"
$WholeProgramOptimization
// Preprocessor
- $PreprocessorDefinitions "WIN32;_WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
- // Enable asserts in release builds if /define:releaseasserts is specified on the VPC command line.
- $PreprocessorDefinitions "$BASE;RELEASEASSERTS" [$RELEASEASSERTS]
- $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+ $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS]
$IgnoreStandardIncludePath
$GeneratePreprocessedFile
$KeepComments
@@ -83,11 +95,10 @@ $Configuration "Release"
$BasicRuntimeChecks
$RuntimeLibrary "Multi-threaded (/MT)"
$StructMemberAlignment
- $BufferSecurityCheck "Yes" [$STAGING_ONLY]
- $BufferSecurityCheck "No" [!$STAGING_ONLY]
+ $BufferSecurityCheck "No" [$RETAIL]
+ $BufferSecurityCheck "Yes" [!$RETAIL]
$EnableFunctionLevelLinking "Yes (/Gy)"
$EnableEnhancedInstructionSet
- $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" [$WIN32]
$FloatingPointModel "Fast (/fp:fast)"
$EnableFloatingPointExceptions
@@ -126,14 +137,14 @@ $Configuration "Release"
$ShowIncludes
$UndefinePreprocessorDefinitions
$UndefineAllPreprocessorDefinitions
- $UseFullPaths
+ $UseFullPaths "Yes (/FC)"
$OmitDefaultLibraryNames
$ErrorReporting "Prompt Immediately (/errorReport:prompt)"
- // Command Line
- $AdditionalOptions "$BASE /MP"
// Enable extra debugging information.
- $AdditionalOptions "$BASE /d2Zi+"
+ $AdditionalOptions "$BASE /d2Zi+" [$VS2010]
+ // Command Line
+ $AdditionalOptions "$BASE /Oy-" [$NOFPO]
}
$Linker
@@ -163,18 +174,16 @@ $Configuration "Release"
$AssemblyLinkResource
// Manifest File
- $GenerateManifest "No" [!$VS2010]
- $GenerateManifest "Yes" [$VS2010]
+ $GenerateManifest "Yes"
$ManifestFile
$AdditionalManifestDependencies
$AllowIsolation
+ $UACExecutionLevel
// Debugging
$GenerateDebugInfo "Yes (/DEBUG)"
$GenerateProgramDatabaseFile "$(IntDir)/$(TargetName).pdb"
$StripPrivateSymbols
- $GenerateMapFile "No"
- $MapFileName "$(IntDir)/$(TargetName).map"
$MapExports
$DebuggableAssembly
@@ -190,9 +199,22 @@ $Configuration "Release"
$SwapRunFromNetwork
$Driver
+ // RandomizeBaseAddress (/DYNAMICBASE, /ASLR) is a hugely important security setting.
+ // However it can cause confusion during development and can make tracking down certain
+ // bugs tricky by making code/stack/heap addresses change between runs. Enable for retail,
+ // but disable for development builds.
+ $RandomizedBaseAddress "true" [$RETAIL]
+ $RandomizedBaseAddress "false" [!$RETAIL]
+
// Optimization
$References "Eliminate Unreferenced Data (/OPT:REF)"
- $EnableCOMDATFolding "Remove Redundant COMDATs (/OPT:ICF)"
+ // COMDAT folding can be very confusing when debugging and profiling because it can
+ // cause execution to go through nonsensical functions (that happen to be binary
+ // equivalent to the logical function). The performance benefit is small enough that
+ // it is not worth enabling in the development builds. It should be enabled on retail
+ // builds.
+ $EnableCOMDATFolding "Remove Redundant COMDATs (/OPT:ICF)" [$RETAIL]
+ $EnableCOMDATFolding "No (/OPT:NOICF)" [!$RETAIL]
$OptimizeForWindows98
$FunctionOrder
$ProfileGuidedDatabase
@@ -210,12 +232,13 @@ $Configuration "Release"
$NoEntryPoint
$SetChecksum
$BaseAddress "$LOADADDRESS_DEVELOPMENT"
- $BaseAddress "$LOADADDRESS_RETAIL" [$RETAIL]
+ //$BaseAddress "$LOADADDRESS_RETAIL" [$RETAIL]
$FixedBaseAddress
$TurnOffAssemblyGeneration
$DelayLoadedDLL
$ImportLibrary
$MergeSections
+ $TargetMachine
$Profile
$CLRThreadAttribute
$CLRImageType
@@ -226,7 +249,7 @@ $Configuration "Release"
$CLRUnmanagedCodeCheck
// Command Line
- $AdditionalOptions "$BASE /DYNAMICBASE"
+ $AdditionalOptions
}
$ManifestTool
diff --git a/mp/src/vpc_scripts/source_lib_base.vpc b/mp/src/vpc_scripts/source_lib_base.vpc
index eeeb2ba1..9a07dbe7 100644
--- a/mp/src/vpc_scripts/source_lib_base.vpc
+++ b/mp/src/vpc_scripts/source_lib_base.vpc
@@ -1,20 +1,22 @@
-//-----------------------------------------------------------------------------
-// source_lib_base.VPC
-//
-// Project Script
-//-----------------------------------------------------------------------------
-
+$Include "$SRCDIR\vpc_scripts\platform_dirs.vpc"
$include "$SRCDIR\vpc_scripts\source_base.vpc"
-$Macro PLATSUBDIR "\linux32" [$LINUX32]
-$Macro OUTBINDIR "$OUTBINDIR" [$LINUX32]
-$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR" [$LINUX32]
-$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR" [$LINUX32]
+$MacroRequired OUTLIBDIR "$SRCDIR\lib\public$PLATSUBDIR"
-$MacroRequired "OUTLIBDIR" "$SRCDIR\lib\public\$PLATFORM" [$LINUX]
-$MacroRequired "OUTLIBCOMMONDIR" "$SRCDIR\lib\common\$PLATFORM" [$LINUX]
-$include "$SRCDIR\vpc_scripts\source_lib_linux_base.vpc" [$LINUX]
-$include "$SRCDIR\vpc_scripts\source_lib_win32_base.vpc" [$WINDOWS]
-$include "$SRCDIR\vpc_scripts\source_lib_posix_base.vpc" [$POSIX && !$LINUX]
+$include "$SRCDIR\vpc_scripts\source_lib_posix_base.vpc" [$POSIX]
+$include "$SRCDIR\vpc_scripts\source_lib_win32_base.vpc" [$WIN32 || $WIN64]
$include "$SRCDIR\vpc_scripts\source_lib_x360_base.vpc" [$X360]
-$Include "$SRCDIR\vpc_scripts\source_video_base.vpc"
+$include "$SRCDIR\vpc_scripts\source_ppu_lib_ps3_base.vpc" [$PS3]
+
+$include "$SRCDIR\vpc_scripts\source_video_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;DEV_BUILD" [!$PUBLISH]
+ $PreprocessorDefinitions "$BASE;_PROFILE" [$PROFILE && !$RETAIL]
+ $PreprocessorDefinitions "$BASE;RETAIL_ASSERTS" [$RETAIL && $RETAILASSERTS]
+ $PreprocessorDefinitions "$BASE;FRAME_POINTER_OMISSION_DISABLED" [$NOFPO || $VS2010]
+ }
+}
diff --git a/mp/src/vpc_scripts/source_lib_posix_base.vpc b/mp/src/vpc_scripts/source_lib_posix_base.vpc
index 5a5e4747..4b163986 100644
--- a/mp/src/vpc_scripts/source_lib_posix_base.vpc
+++ b/mp/src/vpc_scripts/source_lib_posix_base.vpc
@@ -1,18 +1,19 @@
-$Include "$SRCDIR\vpc_scripts\source_posix_base.vpc"
-$include "$SRCDIR\tier0\tier0_exclude.vpc" [$POSIX]
$MacroRequired "OUTLIBNAME" "$PROJECTNAME"
+$Macro IS_LIB_PROJECT "1"
+
+$Include "$SRCDIR\vpc_scripts\source_posix_base.vpc"
$Configuration
{
- $General
- {
- $ConfigurationType "Static Library (.lib)"
- $GameOutputFile "$SRCDIR/lib/$PLATFORM/$OUTLIBNAME$_STATICLIB_EXT"
+ $General
+ {
+ $ConfigurationType "Static Library (.lib)"
+ $GameOutputFile "$OUTLIBDIR/$OUTLIBNAME$_STATICLIB_EXT"
}
$Linker
{
- $OutputFile "$SRCDIR/lib/$PLATFORM/$OUTLIBNAME$_STATICLIB_EXT"
- }
+ $OutputFile "$OUTLIBDIR/$OUTLIBNAME$_STATICLIB_EXT"
+ }
}
diff --git a/mp/src/vpc_scripts/source_lib_qt_base.vpc b/mp/src/vpc_scripts/source_lib_qt_base.vpc
new file mode 100644
index 00000000..68894746
--- /dev/null
+++ b/mp/src/vpc_scripts/source_lib_qt_base.vpc
@@ -0,0 +1,2 @@
+// include either the windows base or the currently non-existing ones for other platforms
+$include "$SRCDIR\vpc_scripts\source_lib_qt_win32_base.vpc"
diff --git a/mp/src/vpc_scripts/source_lib_qt_win32_base.vpc b/mp/src/vpc_scripts/source_lib_qt_win32_base.vpc
new file mode 100644
index 00000000..d386ac86
--- /dev/null
+++ b/mp/src/vpc_scripts/source_lib_qt_win32_base.vpc
@@ -0,0 +1,22 @@
+//===================== Copyright (c) Valve Corporation. All Rights Reserved. ======================
+//
+//==================================================================================================
+
+$Macro QT_ROOT "$SRCDIR\thirdparty\lgpl\qt"
+
+$Include "$SRCDIR\vpc_scripts\source_lib_base.vpc"
+$Include "$SRCDIR\vpc_scripts\qt_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE;.\;$SRCDIR\game\shared;$QT_ROOT\include;.\$QT_TARGET_SUBDIR"
+ $PreprocessorDefinitions "$BASE;QT_LARGEFILE_SUPPORT;QT_DLL;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT"
+ $PreprocessorDefinitions "$BASE;QT_NO_DEBUG" [!$QTDEBUG]
+ $DisableSpecificWarnings "4127;4512;$BASE"
+
+ // Causes a bunch of bogus compiler warnings for now; let's disable it
+ $Detect64bitPortabilityIssues "No"
+ }
+}
diff --git a/mp/src/vpc_scripts/source_lib_win32_base.vpc b/mp/src/vpc_scripts/source_lib_win32_base.vpc
index e2f6766e..b775614c 100644
--- a/mp/src/vpc_scripts/source_lib_win32_base.vpc
+++ b/mp/src/vpc_scripts/source_lib_win32_base.vpc
@@ -6,15 +6,12 @@
$Include "$SRCDIR\vpc_scripts\version.vpc"
-$Macro NOAPPENDPLATSUBDIR "1" [!$WIN64]
-
-$MacroRequired "PLATSUBDIR"
$MacroRequired "SRCDIR"
$MacroRequired "OUTLIBNAME" "$PROJECTNAME"
$MacroRequired "OUTLIBDIR"
-// Fix up directories for targets like win64
-$Macro OUTLIBDIR "$OUTLIBDIR$PLATSUBDIR" [!$NOAPPENDPLATSUBDIR]
+$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR"
+$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR"
$Include "$SRCDIR\vpc_scripts\source_lib_win32_debug.vpc"
$Include "$SRCDIR\vpc_scripts\source_lib_win32_release.vpc"
@@ -25,38 +22,41 @@ $IgnoreRedundancyWarning "ON"
// Common Configuration
$Configuration
{
- $General [$VS2010]
+ $General [$VS2010]
{
- $TargetName "$OUTLIBNAME"
+ $TargetName "$OUTLIBNAME"
}
- $General
- {
- $OutputDirectory "$OUTLIBDIR"
- }
$Compiler
{
+ $PreprocessorDefinitions "$BASE;PLATFORM_64BITS;WIN64;_WIN64;COMPILER_MSVC64" [$WIN64]
+ $PreprocessorDefinitions "$BASE;COMPILER_MSVC32" [$WIN32]
+ $PreprocessorDefinitions "$BASE;COMPILER_MSVC;_DLL_EXT=$_DLL_EXT"
$PreprocessorDefinitions "$BASE;LIBNAME=$OUTLIBNAME"
- $PreprocessorDefinitions "$BASE;RAD_TELEMETRY_DISABLED" [$SOURCESDK]
+ }
+
+ $Compiler [$WIN32]
+ {
+ $EnableEnhancedInstructionSet "Streaming SIMD Extensions 2 (/arch:SSE2)"
}
$PreBuildEvent
{
$CommandLine "if EXIST $OUTLIBDIR\$(TargetName).lib ( for /f $QUOTEdelims=$QUOTE %%A in ('attrib $QUOTE$OUTLIBDIR\$(TargetName).lib$QUOTE') do set valveTmpIsReadOnly=$QUOTE%%A$QUOTE" "\n" \
- ") else ( mkdir $OUTLIBDIR )" "\n" \
+ ") else ( if not EXIST $OUTLIBDIR mkdir $OUTLIBDIR )" "\n" \
"set valveTmpIsReadOnlyLetter=%valveTmpIsReadOnly:~6,1%" "\n" \
"if $QUOTE%valveTmpIsReadOnlyLetter%$QUOTE==$QUOTER$QUOTE (" "\n" \
" attrib -r $OUTLIBDIR\$(TargetName).lib" "\n" \
" $SRCDIR\devtools\bin\gnu\touch.exe -d $QUOTE1999-01-01$QUOTE $OUTLIBDIR\$(TargetName).lib" "\n" \
" attrib +r $OUTLIBDIR\$(TargetName).lib" "\n" \
")" "\n" \
- "$CRCCHECK" "\n" [!$SOURCESDK]
+ "$CRCCHECK" "\n"
}
- $PreLinkEvent
+ $PreLinkEvent [!$ANALYZE && !$SOURCESDK]
{
- $CommandLine "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTLIBDIR\$(TargetName).lib $SRCDIR" [!$SOURCESDK ]
+ $CommandLine "call $SRCDIR\vpc_scripts\valve_p4_edit.cmd $OUTLIBDIR\$(TargetName).lib $SRCDIR"
}
$Librarian
@@ -64,13 +64,6 @@ $Configuration
// Suppress this warning using the undocumented /ignore linker switch
// schemalib.lib(schemaclassinfo.obj) : warning LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
$AdditionalOptions "$BASE /ignore:4221"
-
- // This option is from the devil. Basically, it causes the link inputs
- // to vary depending on what is in the solution. This is anathema
- // to the way that we use projects and solutions here at Valve.
- // It also exposes a bug in VS2005 causing files to be recompiled/linked
- // even if nothing changed.
- $LinkLibraryDependencies "false"
}
}
diff --git a/mp/src/vpc_scripts/source_lib_win32_debug.vpc b/mp/src/vpc_scripts/source_lib_win32_debug.vpc
index a3eba728..981300da 100644
--- a/mp/src/vpc_scripts/source_lib_win32_debug.vpc
+++ b/mp/src/vpc_scripts/source_lib_win32_debug.vpc
@@ -6,17 +6,26 @@
$IgnoreRedundancyWarning "ON"
-$MacroRequired "PLATSUBDIR"
$MacroRequired "SRCDIR"
$MacroRequired "OUTLIBNAME"
$MacroRequired "OUTLIBDIR"
+$MacroRequired "LIBPUBLIC"
+$MacroRequired "LIBCOMMON"
+$MacroRequired "PLATSUBDIR"
+$MacroRequiredAllowEmpty "GAMENAME"
+$MacroRequiredAllowEmpty "INTERMEDIATESUBDIR"
+$MacroRequiredAllowEmpty "_UNITYSUBDIR"
+$MacroRequiredAllowEmpty "_STATICSUBDIR"
+$Macro "_SUBDIRSUFFIX" "$INTERMEDIATESUBDIR$_STATICSUBDIR$GAMENAME$PLATSUBDIR$_UNITYSUBDIR"
$Configuration "Debug"
{
$General
{
// General
- $IntermediateDirectory ".\Debug$PLATSUBDIR"
+ $OutputDirectory ".\Debug$_SUBDIRSUFFIX" [!$VS2010]
+ $OutputDirectory "$OUTLIBDIR" [$VS2010]
+ $IntermediateDirectory ".\Debug$_SUBDIRSUFFIX"
$ExtensionsToDeleteOnClean
$BuildLogFile
$InheritedProjectPropertySheets
@@ -48,8 +57,8 @@ $Configuration "Debug"
// General
$AdditionalIncludeDirectories "$SRCDIR\common;$SRCDIR\public;$SRCDIR\public\tier0;$SRCDIR\public\tier1"
$Resolve#UsingReferences
- $DebugInformationFormat "Program Database for Edit & Continue (/ZI)" [!$EANDCDISABLED && !$WIN64]
- $DebugInformationFormat "Program Database (/Zi)" [$EANDCDISABLED || $WIN64]
+ $DebugInformationFormat "Program Database for Edit & Continue (/ZI)" [$WIN32]
+ $DebugInformationFormat "Program Database (/Zi)" [$WIN64]
$SuppressStartupBanner
$WarningLevel "Level 4 (/W4)"
$Detect64bitPortabilityIssues "Yes (/Wp64)"
@@ -66,7 +75,7 @@ $Configuration "Debug"
$WholeProgramOptimization
// Preprocessor
- $PreprocessorDefinitions "_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ $PreprocessorDefinitions "$BASE;_HAS_ITERATOR_DEBUGGING=0;WIN32;_WIN32;_DEBUG;DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
$IgnoreStandardIncludePath
$GeneratePreprocessedFile
$KeepComments
@@ -86,7 +95,6 @@ $Configuration "Debug"
$BufferSecurityCheck "Yes"
$EnableFunctionLevelLinking
$EnableEnhancedInstructionSet
- $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" [$WIN32]
$FloatingPointModel "Fast (/fp:fast)"
$EnableFloatingPointExceptions
@@ -125,12 +133,12 @@ $Configuration "Debug"
$ShowIncludes
$UndefinePreprocessorDefinitions
$UndefineAllPreprocessorDefinitions
- $UseFullPaths
+ $UseFullPaths "Yes (/FC)"
$OmitDefaultLibraryNames
$ErrorReporting "Prompt Immediately (/errorReport:prompt)"
- // Command Line
- $AdditionalOptions "$BASE /MP"
+ // Command Line (L4D adding /MP)
+ $AdditionalOptions "/MP" [$VS2005]
}
$Librarian
@@ -199,4 +207,4 @@ $Configuration "Debug"
$Outputs
$AdditionalDependencies
}
-} \ No newline at end of file
+}
diff --git a/mp/src/vpc_scripts/source_lib_win32_release.vpc b/mp/src/vpc_scripts/source_lib_win32_release.vpc
index 8f80eefc..c3138590 100644
--- a/mp/src/vpc_scripts/source_lib_win32_release.vpc
+++ b/mp/src/vpc_scripts/source_lib_win32_release.vpc
@@ -6,17 +6,34 @@
$IgnoreRedundancyWarning "ON"
-$MacroRequired "PLATSUBDIR"
+// Disable frame pointer omission to allow fast stack walking, necessary for
+// good ETW profiling.
+$Macro NOFPO "1"
+
$MacroRequired "SRCDIR"
$MacroRequired "OUTLIBNAME"
$MacroRequired "OUTLIBDIR"
+$MacroRequired "LIBPUBLIC"
+$MacroRequired "LIBCOMMON"
+$MacroRequired "PLATSUBDIR"
+$MacroRequiredAllowEmpty "GAMENAME"
+$MacroRequiredAllowEmpty "INTERMEDIATESUBDIR"
+$MacroRequiredAllowEmpty "_UNITYSUBDIR"
+$MacroRequiredAllowEmpty "_STATICSUBDIR"
+$Macro "_SUBDIRSUFFIX" "$INTERMEDIATESUBDIR$_STATICSUBDIR$GAMENAME$PLATSUBDIR$_UNITYSUBDIR"
$Configuration "Release"
{
$General
{
// General
- $IntermediateDirectory ".\Release$PLATSUBDIR"
+ $OutputDirectory ".\Release$_SUBDIRSUFFIX" [!$VS2010 && !$RETAIL && !$PROFILE]
+ $OutputDirectory ".\Retail$_SUBDIRSUFFIX" [!$VS2010 && $RETAIL]
+ $OutputDirectory ".\Profile$_SUBDIRSUFFIX" [!$VS2010 && !$RETAIL && $PROFILE]
+ $OutputDirectory "$OUTLIBDIR" [$VS2010]
+ $IntermediateDirectory ".\Release$_SUBDIRSUFFIX" [!$RETAIL && !$PROFILE]
+ $IntermediateDirectory ".\Retail$_SUBDIRSUFFIX" [$RETAIL]
+ $IntermediateDirectory ".\Profile$_SUBDIRSUFFIX" [!$RETAIL && $PROFILE]
$ExtensionsToDeleteOnClean
$BuildLogFile
$InheritedProjectPropertySheets
@@ -28,7 +45,7 @@ $Configuration "Release"
$MinimizeCRTUseInATL
$CharacterSet "Use Multi-Byte Character Set"
$CommonLanguageRuntimeSupport
- $WholeProgramOptimization
+ $WholeProgramOptimization "Use Link Time Code Generation" [$LTCG]
}
$Debugging
@@ -65,9 +82,8 @@ $Configuration "Release"
$WholeProgramOptimization
// Preprocessor
- $PreprocessorDefinitions "WIN32;_WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
- // Enable asserts in release builds if /define:releaseasserts is specified on the VPC command line.
- $PreprocessorDefinitions "$BASE;RELEASEASSERTS" [$RELEASEASSERTS]
+ $PreprocessorDefinitions "$BASE;WIN32;_WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ $PreprocessorDefinitions "$BASE;RELEASE_ASSERTS" [$RELEASEASSERTS]
$IgnoreStandardIncludePath
$GeneratePreprocessedFile
$KeepComments
@@ -80,11 +96,10 @@ $Configuration "Release"
$BasicRuntimeChecks
$RuntimeLibrary "Multi-threaded (/MT)"
$StructMemberAlignment
- $BufferSecurityCheck "Yes" [$STAGING_ONLY]
- $BufferSecurityCheck "No" [!$STAGING_ONLY]
+ $BufferSecurityCheck "No" [$RETAIL]
+ $BufferSecurityCheck "Yes" [!$RETAIL]
$EnableFunctionLevelLinking "Yes (/Gy)"
$EnableEnhancedInstructionSet
- $EnableEnhancedInstructionSet "Streaming SIMD Extensions (/arch:SSE)" [$WIN32]
$FloatingPointModel "Fast (/fp:fast)"
$EnableFloatingPointExceptions
@@ -123,14 +138,15 @@ $Configuration "Release"
$ShowIncludes
$UndefinePreprocessorDefinitions
$UndefineAllPreprocessorDefinitions
- $UseFullPaths
+ $UseFullPaths "Yes (/FC)"
$OmitDefaultLibraryNames
$ErrorReporting "Prompt Immediately (/errorReport:prompt)"
- // Command Line
- $AdditionalOptions "$BASE /MP"
+ // Command Line (L4D adding /MP)
+ $AdditionalOptions "/MP"
// Enable extra debugging information.
- $AdditionalOptions "$BASE /d2Zi+"
+ $AdditionalOptions "$BASE /d2Zi+" [$VS2010]
+ $AdditionalOptions "$BASE /Oy-" [$NOFPO]
}
$Librarian
@@ -199,4 +215,4 @@ $Configuration "Release"
$Outputs
$AdditionalDependencies
}
-} \ No newline at end of file
+}
diff --git a/mp/src/vpc_scripts/source_linux_base_project.vpc b/mp/src/vpc_scripts/source_linux_base_project.vpc
index 8dd136ba..f7fd40d5 100644
--- a/mp/src/vpc_scripts/source_linux_base_project.vpc
+++ b/mp/src/vpc_scripts/source_linux_base_project.vpc
@@ -1,4 +1,9 @@
+$Include "$SRCDIR\vpc_scripts\version.vpc"
+$Macro PLATSUBDIR "\linux32" [$LINUX32]
+
+$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR"
+$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR"
$MacroRequired "SRCDIR"
@@ -8,7 +13,7 @@ $Configuration "Debug"
$Compiler
{
$PreprocessorDefinitions "DEBUG;_DEBUG"
- $OptimizerLevel "-gdwarf-2 -g $(OptimizerLevel_CompilerSpecific)"
+ $OptimizerLevel "-gdwarf-2 -g2 $(OptimizerLevel_CompilerSpecific)"
}
}
@@ -18,7 +23,7 @@ $Configuration "Release"
{
$PreprocessorDefinitions "NDEBUG"
$PreprocessorDefinitions "$BASE;RELEASEASSERTS" [$RELEASEASSERTS]
- $OptimizerLevel "-gdwarf-2 -g $(OptimizerLevel_CompilerSpecific)"
+ $OptimizerLevel "-gdwarf-2 -g2 $(OptimizerLevel_CompilerSpecific)"
}
}
@@ -32,23 +37,14 @@ $Configuration
$Compiler
{
$AdditionalIncludeDirectories "$SRCDIR\common;$SRCDIR\public;$SRCDIR\public\tier0;$SRCDIR\public\tier1"
- $AdditionalIncludeDirectories "$BASE;/usr/include/malloc" [$OSX]
- $PreprocessorDefinitions "$BASE;POSIX;GNUC"
+ $PreprocessorDefinitions "$BASE;GNUC;POSIX;COMPILER_GCC;MEMOVERRIDE_MODULE=$PROJECTNAME;_DLL_EXT=$_DLL_EXT"
$PreprocessorDefinitions "$BASE;DEDICATED" [$DEDICATED]
- $PreprocessorDefinitions "$BASE;LINUX;_LINUX" [$LINUXALL]
- $PreprocessorDefinitions "$BASE;_OSX;OSX;_DARWIN_UNLIMITED_SELECT;FD_SETSIZE=10240;" [$OSX32 || $OSX64]
- $PreprocessorDefinitions "$BASE;_DEMO" [$DEMO]
+ $PreprocessorDefinitions "$BASE;_LINUX;LINUX" [$LINUXALL]
$SymbolVisibility "hidden" [$POSIX]
- $GCC_ExtraCompilerFlags "$BASE -U_FORTIFY_SOURCE" [$LINUXALL]
- $GCC_ExtraCompilerFlags "$BASE -faddress-sanitizer" [$ADDRESSSANITIZER && $LINUXALL]
-
- // Pass on appropriate branch define to preprocessor
- $PreprocessorDefinitions "$BASE;STAGING_ONLY" [$STAGING_ONLY]
- $PreprocessorDefinitions "$BASE;TF_BETA" [$TF_BETA]
- }
- $Linker
- {
- $GCC_ExtraLinkerFlags "$BASE -faddress-sanitizer" [$ADDRESSSANITIZER && $LINUXALL]
+ $PreprocessorDefinitions "$BASE;POSIX;_POSIX" [$POSIX]
+
+ $GCC_ExtraCompilerFlags "-U_FORTIFY_SOURCE" [$LINUXALL]
+ $Create/UsePCHThroughFile "stdafx.h"
}
}
@@ -56,9 +52,8 @@ $Project
{
$Folder "Link Libraries"
{
- $ImpLib tier0 [!$IS_LIB_PROJECT]
- $Lib tier1 [!$IS_LIB_PROJECT]
- $ImpLib vstdlib [!$IS_LIB_PROJECT]
- $Lib $SRCDIR/thirdparty/clang+llvm-3.1-x86-linux-ubuntu_12.04/lib/clang/3.1/lib/linux/libclang_rt.asan-i386 [$ADDRESSSANITIZER && $LINUXALL]
+ $ImpLib "$LIBPUBLIC\tier0" [!$IS_LIB_PROJECT]
+ $Lib "$LIBPUBLIC\tier1" [!$IS_LIB_PROJECT]
+ $ImpLib "$LIBPUBLIC\vstdlib" [!$IS_LIB_PROJECT]
}
}
diff --git a/mp/src/vpc_scripts/source_mll_qt_base.vpc b/mp/src/vpc_scripts/source_mll_qt_base.vpc
new file mode 100644
index 00000000..099c658f
--- /dev/null
+++ b/mp/src/vpc_scripts/source_mll_qt_base.vpc
@@ -0,0 +1,35 @@
+//====== Copyright (c) 1996-2010, Valve Corporation, All rights reserved. =====
+//
+// Maya Plugin For Win32 - Same As source_dll_qt_win32_base.vpc except:
+// * QT_ROOT is left unspecified, the part VPC script needs to define it
+// as it varies with the version of Maya
+// * QT_NO_DEBUG is always defined.
+// * Only release versions of Qt libraries are linked
+// Maya is linked with release Qt libs, linking a plug-in with debug
+// libs will crash when a Qt widget is created
+//
+//=============================================================================
+
+$MacroRequired "QT_ROOT"
+
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
+$Include "$SRCDIR\vpc_scripts\qt_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalIncludeDirectories "$BASE;.\;$QT_ROOT\include;.\$QT_TARGET_SUBDIR"
+ $PreprocessorDefinitions "$BASE;QT_LARGEFILE_SUPPORT;QT_DLL;QT_GUI_LIB;QT_CORE_LIB;QT_THREAD_SUPPORT;QT_NO_DEBUG"
+ $DisableSpecificWarnings "4127;4512;$BASE"
+ }
+}
+
+$Project
+{
+ $Folder "Link Libraries"
+ {
+ $Lib "$QT_ROOT\lib\qtcore4"
+ $Lib "$QT_ROOT\lib\qtgui4"
+ }
+}
diff --git a/mp/src/vpc_scripts/source_posix_base.vpc b/mp/src/vpc_scripts/source_posix_base.vpc
index 0db13bcb..8e0fc436 100644
--- a/mp/src/vpc_scripts/source_posix_base.vpc
+++ b/mp/src/vpc_scripts/source_posix_base.vpc
@@ -1,14 +1,8 @@
+$Include "$SRCDIR\vpc_scripts\version.vpc"
-$Macro PLATSUBDIR "\linux32" [$LINUX32]
-//$Macro PLATSUBDIR "\linux64" [$LINUX64]
-$Macro PLATSUBDIR "\osx32" [$OSX32]
-$Macro PLATSUBDIR "\osx64" [$OSX64]
-
-$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR" [$LINUX]
-$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR" [$LINUX]
-
-
+$Macro LIBPUBLIC "$SRCDIR\lib\public$PLATSUBDIR"
+$Macro LIBCOMMON "$SRCDIR\lib\common$PLATSUBDIR"
$MacroRequired "SRCDIR"
@@ -17,8 +11,8 @@ $Configuration "Debug"
{
$Compiler
{
- $PreprocessorDefinitions "DEBUG;_DEBUG"
- $OptimizerLevel "-gdwarf-2 -g $(OptimizerLevel_CompilerSpecific)"
+ $PreprocessorDefinitions "$BASE;DEBUG;_DEBUG"
+ $OptimizerLevel "-gdwarf-2 -g2 $(OptimizerLevel_CompilerSpecific)"
}
}
@@ -26,8 +20,8 @@ $Configuration "Release"
{
$Compiler
{
- $PreprocessorDefinitions "NDEBUG"
- $OptimizerLevel "-gdwarf-2 -g $(OptimizerLevel_CompilerSpecific)"
+ $PreprocessorDefinitions "$BASE;NDEBUG"
+ $OptimizerLevel "-gdwarf-2 -g2 $(OptimizerLevel_CompilerSpecific)"
}
}
@@ -41,32 +35,37 @@ $Configuration
$Compiler
{
$AdditionalIncludeDirectories "$SRCDIR\common;$SRCDIR\public;$SRCDIR\public\tier0;$SRCDIR\public\tier1"
- $PreprocessorDefinitions "$BASE;GNUC;POSIX"
+ $AdditionalLibraryDirectories "$LIBCOMMON;$LIBPUBLIC" [$OSXALL]
+ $PreprocessorDefinitions "$BASE;GNUC;POSIX;COMPILER_GCC;_DLL_EXT=$_DLL_EXT"
$PreprocessorDefinitions "$BASE;DEDICATED" [$DEDICATED]
// the 10240 in the following line is the output of `sysctl -n kern.maxfilesperproc`
- $PreprocessorDefinitions "$BASE;_OSX;OSX;_DARWIN_UNLIMITED_SELECT;FD_SETSIZE=10240;" [$OSX32 || $OSX64]
- $PreprocessorDefinitions "$BASE;_LINUX;LINUX;" [$LINUX]
- $PreprocessorDefinitions "$BASE;_CYGWIN;CYGWIN;" [$CYGWIN]
+ $PreprocessorDefinitions "$BASE;_OSX;OSX;_DARWIN_UNLIMITED_SELECT;FD_SETSIZE=10240;" [$OSXALL]
+ $PreprocessorDefinitions "$BASE;OVERRIDE_V_DEFINES" [$OSXALL]
+ $PreprocessorDefinitions "$BASE;_LINUX;LINUX;" [$LINUXALL]
+ $SymbolVisibility "hidden" [$POSIX]
+ $PreprocessorDefinitions "$BASE;POSIX;_POSIX" [$POSIX]
- // Pass on appropriate branch define to preprocessor
- $PreprocessorDefinitions "$BASE;STAGING_ONLY" [$STAGING_ONLY]
- $PreprocessorDefinitions "$BASE;TF_BETA" [$TF_BETA]
+ $PreprocessorDefinitions "$BASE;PLATFORM_64BITS" [$OSX64]
+ $GCC_ExtraCompilerFlags "$BASE -arch x86_64" [$OSX64]
$Create/UsePCHThroughFile "stdafx.h"
}
+
+ $Linker
+ {
+ $GCC_ExtraLinkerFlags "$BASE -arch x86_64" [$OSX64]
+ }
+
}
$Project
{
- $Folder "Link Libraries"
+ $Folder "Link Libraries"
{
- $ImpLib tier0 [$LINUXALL]
- $Lib tier1 [$LINUXALL]
- $ImpLib vstdlib [$LINUXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXtier0$_IMPLIB_EXT" [!$LINUXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXvstdlib$_IMPLIB_EXT" [!$LINUXALL]
- $DynamicFile "$SRCDIR\lib\$PLATFORM\tier1$_STATICLIB_EXT" [!$LINUXALL]
+ $ImpLib "$LIBPUBLIC\tier0" [!$IS_LIB_PROJECT]
+ $Lib "$LIBPUBLIC\tier1" [!$IS_LIB_PROJECT]
+ $ImpLib "$LIBPUBLIC\vstdlib" [!$IS_LIB_PROJECT]
}
}
-
+
diff --git a/mp/src/vpc_scripts/source_video_base.vpc b/mp/src/vpc_scripts/source_video_base.vpc
index dd7f3653..4ccafb63 100644
--- a/mp/src/vpc_scripts/source_video_base.vpc
+++ b/mp/src/vpc_scripts/source_video_base.vpc
@@ -16,18 +16,15 @@
//-----------------------------------------------------------------------------
-// We use Quicktime exclusively (and usually only quicktime) on the Mac
+// We use Quicktime exclusively (and only quicktime) on the Mac
//
// We have two configurations for Win32.
-//
-// if the QUICKTIME_WIN32 Macro is enabled, QuickTime operation is enabled, along with Bink, AVI, and WMV video
-// if the QUICKTIME_WIN32 Macro is not enabled, we only build for Bink, AVI and WMV
-//
-// On the Mac OSX we enable Quicktime only, and set the FORCE_QUICKTIME define, which causes requests to play
-// other media file types to look for a quicktime compatible version of the media file first
-//
+//
+// 1) Comment out the following $macro line out to enable BINK (and AVI and WMV) playback of videos
+// 2) Uncomment the following $macro line out to enable Quicktime (and AVI and WMV) playback of videos and
+// - the Quicktime file override ( the Quicktime .mov is played if present even if a .bnk, .avi or .wmv file was specified )
-//$Macro QUICKTIME_WIN32 1 [$WIN32 && !$X360]
+// $macro QUICKTIME_WIN32 1
$Macro GL "1" [!$DEDICATED && !$WIN32 && !$WIN64]
// If we're using OpenGL, we're implicitly using SDL.
@@ -37,34 +34,17 @@ $Configuration
{
$Compiler
{
- // OSX Builds
- $PreprocessorDefinitions "$BASE;QUICKTIME_VIDEO;FORCE_QUICKTIME" [$OSXALL]
+ $PreprocessorDefinitions "$BASE;QUICKTIME_VIDEO;FORCE_QUICKTIME" [$OSXALL]
// Windows PC, without Quicktime, and with Quicktime
- $PreprocessorDefinitions "$BASE;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO" [$WIN32 && !$X360 && !$QUICKTIME_WIN32]
- $PreprocessorDefinitions "$BASE;AVI_VIDEO;WMV_VIDEO;QUICKTIME_VIDEO" [$WIN32 && !$X360 && $QUICKTIME_WIN32]
-
- // Xbox 360 builds
- $PreprocessorDefinitions "$BASE;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO" [$X360]
- // Linux
+ $PreprocessorDefinitions "$BASE;BINK_VIDEO;AVI_VIDEO;WMV_VIDEO" [$WIN32&&!$QUICKTIME_WIN32]
+ $PreprocessorDefinitions "$BASE;AVI_VIDEO;WMV_VIDEO;QUICKTIME_VIDEO" [$WIN32&&$QUICKTIME_WIN32]
+ $PreprocessorDefinitions "$BASE;BINK_VIDEO" [$X360]
$PreprocessorDefinitions "$BASE;BINK_VIDEO" [$LINUXALL]
-
- // OpenGL
- $PreprocessorDefinitions "$BASE;GL_GLEXT_PROTOTYPES;DX_TO_GL_ABSTRACTION" [$GL]
-
- // SDL
- $PreprocessorDefinitions "$BASE;USE_SDL" [$SDL]
+
+ $PreprocessorDefinitions "$BASE;GL_GLEXT_PROTOTYPES;DX_TO_GL_ABSTRACTION" [$GL]
+ $PreprocessorDefinitions "$BASE;USE_SDL" [$SDL]
$AdditionalIncludeDirectories "$BASE;$SRCDIR\thirdparty\SDL2" [$SDL || $DEDICATED]
}
-
}
-
-$Project
-{
- $Folder "Link Libraries" [$OSXALL && $SDL]
- {
- $DynamicFile "$SRCDIR\lib\public\$PLATFORM\$_IMPLIB_PREFIXSDL2$_IMPLIB_EXT"
- }
-}
-
diff --git a/mp/src/vpc_scripts/source_win32_base.vpc b/mp/src/vpc_scripts/source_win32_base.vpc
index 04ef53b8..4c509098 100644
--- a/mp/src/vpc_scripts/source_win32_base.vpc
+++ b/mp/src/vpc_scripts/source_win32_base.vpc
@@ -1,12 +1,13 @@
$Configuration
{
- $General [$VS2012]
+ $General
{
- // Request the VS 11 (VS 2012) compiler toolset.
- $PlatformToolset "v110"
+ // Request a specific compiler toolset.
+ $PlatformToolset "v110" [$VS2012] // VS 11
+ $PlatformToolset "v120" [$VS2013] // VS 12
}
- $General [$VS2010 || $VS2012]
+ $General
{
$ExecutableDirectories "$(ExecutablePath);$(Path)"
// We need to override mt.exe for Win7 compatibiity. Append paths before $(ExecutablePath) if you need VS to use your tools rather than its own
@@ -14,11 +15,14 @@ $Configuration
// VS 2012 compiles fine but does not link. We want to redirect to stub versions of
// the tools (like link.exe and mt.exe) so that the link stage will be NOPed when
// doing /analyze builds.
- $ExecutableDirectories "$SRCDIR\devtools\vs_nop_tools;$BASE" [$ANALYZE && $VS2012]
+ $ExecutableDirectories "$SRCDIR\devtools\vs_nop_tools;$BASE" [$ANALYZE && ($VS2012 || $VS2013)]
}
$Compiler
{
+ // warning C4316: object allocated on the heap may not be aligned 16
+ $DisableSpecificWarnings "$BASE;4316" [$VS2013]
+
// When using /analyze (triggered with /define:ANALYZE on the vpc command line) we want
// to use /MP but not at its most aggressive setting, and we want to forcibly disable lots
// of warnings (also disabled in platform.h but not everybody includes that).
@@ -26,11 +30,13 @@ $Configuration
// warning C6318: Ill-defined __try/__except: use of the constant EXCEPTION_CONTINUE_SEARCH -- bogus
// warning C6322: Empty _except block
// Set the stack size threshold to 100,000 to avoid noisy warnings on functions with modest stack usage
- $AdditionalOptions "/MP3 /analyze /analyze:stacksize100000 /wd6308 /wd6255 /wd6387 /wd6309 /wd6011 /wd6211 /wd6031 /wd6326 /wd6239 " \
- "/wd6285 /wd6237 /wd6235 /wd6240 /wd6323 /wd6326 /wd6335 /wd6320 /wd6250 /wd6384 /wd6318 /wd6322" [$ANALYZE]
+ // Note that /analyze for VS 2010 only works with the 32-bit compiler, but for VS 2012 it works on 64-bit
+ // as well.
+ $DisableSpecificWarnings "$BASE;6308;6255;6387;6309;6011;6211;6031;6326;6239;6285;6237;6235;6240;6323;6326;6335;6320;6250;6384;6318;6322" [$ANALYZE]
+ $AdditionalOptions "$BASE /MP3 /analyze /analyze:stacksize100000" [$ANALYZE]
// Specify /define:ALLOWSHADOWING to suppress variable shadowing warnings
- $AdditionalOptions "$BASE /wd6244 /wd6246" [$ANALYZE && $ALLOWSHADOWING]
+ $DisableSpecificWarnings "$BASE;6244;6246" [$ANALYZE && $ALLOWSHADOWING]
// New warnings in VS 2012 that we want to ignore.
// warning C4005: 'DXGI_STATUS_OCCLUDED' : macro redefinition
@@ -46,22 +52,15 @@ $Configuration
// warning C28301: No annotations for first declaration of 'InitializeCriticalSection'. See d:\clients\tf3\staging\src\public\tier0\threadtools.h(1373).
// warning C28195: The function was declared as acquiring memory in 'return' and exited without doing so.
// warning C6340: Mismatch on sign: 'unsigned short' passed as parameter '6' when some signed type is required in call to 'V_snprintf'.
- // warning C6330: 'const char' passed as parameter '1' when 'unsigned char' is required in call to 'isspace'.
- $AdditionalOptions "$BASE /wd6014 /wd28159 /wd28182 /wd28183 /wd28197 /wd28198 /wd28204 /wd28247 /wd28251 /wd28301 /wd28195 /wd6340 /wd6330" [$ANALYZE && $VS2012]
-
- // Having lots of warnings makes it harder to notice new, and possibly
- // important warnings, both on buildbot and in the output window. Lots
- // of warnings also makes it harder to skip through errors in the output
- // window since F8 stops on both warnings and errors. The only way to
- // keep the warning count down is to have warnings-as-errors.
- // We will not be warning free on 64-bit for a while...
- $TreatWarningsAsErrors "Yes (/WX)" [!$ANALYZE && !$WIN64]
+ // This warning only applies to Windows XP in low-memory situations:
+ // warning C28125: The function 'InitializeCriticalSection' must be called from within a try\except block
+ // warning C28160: Error annotation: Calling VirtualFreeEx without the MEM_RELEASE flag frees memory but not address descriptors (VADs); results in address space leaks.
+ // warning C6248: Setting a SECURITY_DESCRIPTOR's DACL to NULL will result in an unprotected object.
+ // warning C6102: Using value from failed function call
+ $DisableSpecificWarnings "$BASE;6014;28159;28182;28183;28197;28198;28204;28247;28251;28301;28195;6340;28125;28160;6248;6102" [$ANALYZE && ($VS2012 || $VS2013)]
- $PreprocessorDefinitions "$BASE;WIN64;_WIN64;COMPILER_MSVC64" [$WIN64]
+ // Defines to differentiate 32 from 64 bit builds
+ $PreprocessorDefinitions "$BASE;PLATFORM_64BITS;WIN64;_WIN64;COMPILER_MSVC64" [$WIN64]
$PreprocessorDefinitions "$BASE;COMPILER_MSVC32" [$WIN32]
-
- // Pass on appropriate branch define to preprocessor
- $PreprocessorDefinitions "$BASE;STAGING_ONLY" [$STAGING_ONLY]
- $PreprocessorDefinitions "$BASE;TF_BETA" [$TF_BETA]
}
}
diff --git a/mp/src/vpc_scripts/version.vpc b/mp/src/vpc_scripts/version.vpc
index dbefdb83..1aa2536a 100644
--- a/mp/src/vpc_scripts/version.vpc
+++ b/mp/src/vpc_scripts/version.vpc
@@ -9,4 +9,4 @@
// file will cause the CRC checking to fail, and thus cause a rebuild.
// DO NOT CHANGE THIS UNLESS YOU !!!REALLY!!! NEED TO FORCE EVERY SINGLE VCPROJ TO REGENERATE
-$Macro "InternalVersion" "101" \ No newline at end of file
+$Macro "InternalVersion" "104" \ No newline at end of file
diff --git a/mp/src/vstdlib/vstdlib_exclude.vpc b/mp/src/vstdlib/vstdlib_exclude.vpc
index dab96f26..c9c7f968 100644
--- a/mp/src/vstdlib/vstdlib_exclude.vpc
+++ b/mp/src/vstdlib/vstdlib_exclude.vpc
@@ -10,8 +10,7 @@ $Project
{
$Folder "Link Libraries"
{
- -$File "$SRCDIR\lib\$PLATFORM\$_IMPLIB_PREFIXvstdlib$_IMPLIB_EXT" [$OSXALL]
- -$Implib vstdlib [$LINUX]
+ -$Implib vstdlib [$POSIX]
-$File "$SRCDIR\lib\public\$_IMPLIB_PREFIXvstdlib$_IMPLIB_EXT" [$WIN32]
-$File "$SRCDIR\lib\public$PLATSUBDIR\$_IMPLIB_PREFIXvstdlib$_IMPLIB_EXT" [$WIN64]
-$File "$SRCDIR\lib\public\vstdlib_360.lib" [$X360]