From 4d11adf66fa1f53f0843435ded01fc3cdad8d9f7 Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Sat, 26 Jul 2025 17:38:46 +0300 Subject: [PATCH 01/14] Add fgdlib and vbsp to CMake --- src/CMakeLists.txt | 19 +- src/fgdlib/CMakeLists.txt | 55 +++++ src/fgdlib/gamedata.cpp | 2 +- src/fgdlib/gdvar.cpp | 4 +- src/fgdlib/inputoutput.cpp | 4 +- src/fgdlib/wckeyvalues.cpp | 20 +- src/game/server/CMakeLists.txt | 5 + src/materialsystem/stdshaders/CMakeLists.txt | 1 + src/mathlib/CMakeLists.txt | 129 +++++------ src/public/chunkfile.cpp | 2 +- src/public/fgdlib/fgdlib.h | 4 +- src/public/fgdlib/gamedata.h | 6 +- src/public/fgdlib/gdclass.h | 8 +- src/public/fgdlib/gdvar.h | 4 +- src/public/fgdlib/helperinfo.h | 2 +- src/public/fgdlib/ieditortexture.h | 2 +- src/public/fgdlib/inputoutput.h | 2 +- src/public/fgdlib/wckeyvalues.h | 8 +- src/public/filesystem_init.cpp | 4 +- src/public/loadcmdline.cpp | 2 +- src/tier1/CMakeLists.txt | 18 +- src/utils/CMakeLists.txt | 2 + src/utils/common/bsplib.cpp | 35 +-- src/utils/common/bsplib.h | 16 +- src/utils/common/map_shared.h | 2 +- src/utils/common/utilmatlib.cpp | 4 +- src/utils/lzma/CMakeLists.txt | 51 +++++ src/utils/vbsp/CMakeLists.txt | 213 ++++++++++++++++++ src/utils/vbsp/boundbox.cpp | 2 +- src/utils/vbsp/brushbsp.cpp | 6 +- src/utils/vbsp/cubemap.cpp | 4 +- src/utils/vbsp/detailobjects.cpp | 10 +- src/utils/vbsp/disp_vbsp.cpp | 2 +- src/utils/vbsp/ivp.cpp | 4 +- src/utils/vbsp/manifest.cpp | 2 +- src/utils/vbsp/manifest.h | 2 +- src/utils/vbsp/map.cpp | 28 +-- src/utils/vbsp/materialpatch.cpp | 2 +- src/utils/vbsp/portals.cpp | 3 +- src/utils/vbsp/staticprop.cpp | 16 +- src/utils/vbsp/vbsp.cpp | 8 +- src/utils/vbsp/vbsp.h | 2 +- src/utils/vbsp/worldvertextransitionfixup.cpp | 2 +- src/utils/vbsp/writebsp.cpp | 7 +- src/vgui2/vgui_controls/CMakeLists.txt | 7 +- 45 files changed, 535 insertions(+), 196 deletions(-) create mode 100644 src/fgdlib/CMakeLists.txt create mode 100644 src/utils/CMakeLists.txt create mode 100644 src/utils/lzma/CMakeLists.txt create mode 100644 src/utils/vbsp/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 481b1c3ef3..0b6cd36855 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,6 +37,7 @@ option(NEO_BUILD_WEAPON_PBK56S "Build PBK56S weapon" OFF) option(NEO_BUILD_TIER1 "Build tier1 library" ON) option(NEO_BUILD_MATHLIB "Build mathlib library" ON) option(NEO_BUILD_VGUI_CONTROLS "Build vgui_controls library" ON) +option(NEO_BUILD_UTILS "Build utils" ON) option(NEO_COPY_LIBRARIES "Copy libraries to bin directory by default" ON) option(NEO_EXTRA_ASSETS "Copy extra assets into game/neo" ON) set(NEO_EXTRA_ASSETS_ALT_PATH "" CACHE PATH "Alternate location to fetch the extra assets") @@ -66,6 +67,7 @@ message(STATUS "Build PBK56S weapon (INCLUDE_WEP_PBK): ${NEO_BUILD_WEAPON_PBK56S message(STATUS "Build tier1 library: ${NEO_BUILD_TIER1}") message(STATUS "Build mathlib library: ${NEO_BUILD_MATHLIB}") message(STATUS "Build vgui_controls library: ${NEO_BUILD_VGUI_CONTROLS}") +message(STATUS "Build utils: ${NEO_BUILD_UTILS}") message(STATUS "Copy libraries to bin directory by default: ${NEO_COPY_LIBRARIES}") message(STATUS "Copy extra assets into game/neo: ${NEO_EXTRA_ASSETS}") message(STATUS "Alternate location to fetch the extra assets: ${NEO_EXTRA_ASSETS_ALT_PATH}") @@ -95,7 +97,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE) set(CMAKE_POSITION_INDEPENDENT_CODE FALSE) set(SOURCESDK TRUE) -set(SOURCE_HAS_FREETYPE TRUE) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions( @@ -211,7 +212,6 @@ if(OS_WINDOWS) _ALLOW_RUNTIME_LIBRARY_MISMATCH _ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH _ALLOW_MSC_VER_MISMATCH - fopen=dont_use_fopen _MBCS ) @@ -351,7 +351,6 @@ if(OS_LINUX OR OS_MACOS) -fdiagnostics-show-option -Wformat -Wformat-security - -Usprintf -Ustrncpy @@ -365,6 +364,15 @@ if(OS_LINUX OR OS_MACOS) #-fms-extensions ) + if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + add_compile_options( + #-fno-strict-aliasing + -ffast-math + -fno-omit-frame-pointer + -ftree-vectorize + ) + endif() + # Disable option for older compiler in docker if(NOT CMAKE_CXX_COMPILER_VERSION STREQUAL "4.8.4") add_compile_options( @@ -621,5 +629,10 @@ if(NEO_EXTRA_ASSETS) endif() endif() +if(NEO_BUILD_UTILS AND OS_WINDOWS) + add_subdirectory(fgdlib) + add_subdirectory(utils) +endif() + add_subdirectory(tests) diff --git a/src/fgdlib/CMakeLists.txt b/src/fgdlib/CMakeLists.txt new file mode 100644 index 0000000000..d89548f286 --- /dev/null +++ b/src/fgdlib/CMakeLists.txt @@ -0,0 +1,55 @@ +add_library(fgdlib STATIC) + +add_library(fgdlib::fgdlib ALIAS fgdlib) + +set_target_properties(fgdlib PROPERTIES PREFIX "") + +target_include_directories(fgdlib + PRIVATE + ${CMAKE_SOURCE_DIR}/common + ${CMAKE_SOURCE_DIR}/public + ${CMAKE_SOURCE_DIR}/utils/common +) + +target_compile_options(fgdlib + PRIVATE + /wd4091 + /wd4316 + /wd4355 + /wd4577 + /wd5033 + /wd5054 + /wd5055 +) + +target_link_libraries(fgdlib + PRIVATE + tier0::tier0 + tier1::tier1 + mathlib::mathlib +) + +target_sources_grouped( + TARGET fgdlib + NAME "Source Files" + FILES + gamedata.cpp + gdclass.cpp + gdvar.cpp + inputoutput.cpp + wckeyvalues.cpp +) + +target_sources_grouped( + TARGET fgdlib + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/fgdlib/fgdlib.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/gamedata.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/gdclass.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/gdvar.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/helperinfo.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/ieditortexture.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/inputoutput.h + ${CMAKE_SOURCE_DIR}/public/fgdlib/wckeyvalues.h +) diff --git a/src/fgdlib/gamedata.cpp b/src/fgdlib/gamedata.cpp index f3689ee998..0e33763e54 100644 --- a/src/fgdlib/gamedata.cpp +++ b/src/fgdlib/gamedata.cpp @@ -88,7 +88,7 @@ static bool DoGetToken(TokenReader &tr, char **ppszStore, int nSize, trtoken_t t // We didn't get the expected token type but no expected // string was specified. // - char *pszTokenName; + const char *pszTokenName; switch (ttexpecting) { case IDENT: diff --git a/src/fgdlib/gdvar.cpp b/src/fgdlib/gdvar.cpp index 38c30febbf..9b24f421c5 100644 --- a/src/fgdlib/gdvar.cpp +++ b/src/fgdlib/gdvar.cpp @@ -18,7 +18,7 @@ typedef struct { GDIV_TYPE eType; // The enumeration of this type. - char *pszName; // The name of this type. + const char *pszName; // The name of this type. trtoken_t eStoreAs; // How this type is stored (STRING, INTEGER, etc). } TypeMap_t; @@ -64,7 +64,7 @@ static TypeMap_t TypeMap[] = }; -char *GDinputvariable::m_pszEmpty = ""; +const char *GDinputvariable::m_pszEmpty = ""; //----------------------------------------------------------------------------- diff --git a/src/fgdlib/inputoutput.cpp b/src/fgdlib/inputoutput.cpp index ea810c1345..6e8c5dd3e8 100644 --- a/src/fgdlib/inputoutput.cpp +++ b/src/fgdlib/inputoutput.cpp @@ -15,11 +15,11 @@ typedef struct { InputOutputType_t eType; // The enumeration of this type. - char *pszName; // The name of this type. + const char *pszName; // The name of this type. } TypeMap_t; -char *CClassInputOutputBase::g_pszEmpty = ""; +const char *CClassInputOutputBase::g_pszEmpty = ""; //----------------------------------------------------------------------------- diff --git a/src/fgdlib/wckeyvalues.cpp b/src/fgdlib/wckeyvalues.cpp index de733aceff..bd9b1113e7 100644 --- a/src/fgdlib/wckeyvalues.cpp +++ b/src/fgdlib/wckeyvalues.cpp @@ -143,8 +143,8 @@ WCKeyValuesT::~WCKeyValuesT(void) template const char *WCKeyValuesT::GetValue(const char *pszKey, int *piIndex) const { - int i = FindByKeyName( pszKey ); - if ( i == GetInvalidIndex() ) + int i = WCKeyValuesT::FindByKeyName( pszKey ); + if ( i == WCKeyValuesT::GetInvalidIndex() ) { return NULL; } @@ -153,7 +153,7 @@ const char *WCKeyValuesT::GetValue(const char *pszKey, int *piIndex) const if(piIndex) piIndex[0] = i; - return m_KeyValues[i].szValue; + return this->m_KeyValues[i].szValue; } } @@ -195,7 +195,7 @@ void StripEdgeWhiteSpace(char *psz) psz++; } - int iLen = strlen(psz) - 1; + int iLen = static_cast(strlen(psz)) - 1; if ( iLen >= 0 ) { @@ -237,8 +237,8 @@ void WCKeyValuesT::SetValue(const char *pszKey, const char *pszValue) StripEdgeWhiteSpace(szTmpKey); StripEdgeWhiteSpace(szTmpValue); - int i = FindByKeyName( szTmpKey ); - if ( i == GetInvalidIndex() ) + int i = WCKeyValuesT::FindByKeyName( szTmpKey ); + if ( i == WCKeyValuesT::GetInvalidIndex() ) { if ( pszValue ) { @@ -248,21 +248,21 @@ void WCKeyValuesT::SetValue(const char *pszKey, const char *pszValue) MDkeyvalue newkv; Q_strncpy( newkv.szKey, szTmpKey, sizeof( newkv.szKey ) ); Q_strncpy( newkv.szValue, szTmpValue, sizeof( newkv.szValue ) ); - InsertKeyValue( newkv ); + WCKeyValuesT::InsertKeyValue( newkv ); } } else { if (pszValue != NULL) { - V_strncpy(m_KeyValues[i].szValue, szTmpValue, sizeof(m_KeyValues[i].szValue)); + V_strncpy(this->m_KeyValues[i].szValue, szTmpValue, sizeof(this->m_KeyValues[i].szValue)); } // // If we are setting to a NULL value, delete the key. // else { - RemoveKeyAt( i ); + WCKeyValuesT::RemoveKeyAt( i ); } } } @@ -274,7 +274,7 @@ void WCKeyValuesT::SetValue(const char *pszKey, const char *pszValue) template void WCKeyValuesT::RemoveAll(void) { - m_KeyValues.RemoveAll(); + this->m_KeyValues.RemoveAll(); } diff --git a/src/game/server/CMakeLists.txt b/src/game/server/CMakeLists.txt index 4866f13b63..2013ee763e 100644 --- a/src/game/server/CMakeLists.txt +++ b/src/game/server/CMakeLists.txt @@ -99,6 +99,11 @@ if(OS_LINUX OR OS_MACOS) endif() if(OS_WINDOWS) + target_compile_definitions(server + PRIVATE + fopen=dont_use_fopen + ) + target_link_libraries(server PRIVATE winmm.lib diff --git a/src/materialsystem/stdshaders/CMakeLists.txt b/src/materialsystem/stdshaders/CMakeLists.txt index d6ce822ad5..e780a8d514 100644 --- a/src/materialsystem/stdshaders/CMakeLists.txt +++ b/src/materialsystem/stdshaders/CMakeLists.txt @@ -32,6 +32,7 @@ if(OS_WINDOWS) target_compile_definitions(game_shader_dx9 PRIVATE USE_ACTUAL_DX + fopen=dont_use_fopen ) target_link_libraries(game_shader_dx9 diff --git a/src/mathlib/CMakeLists.txt b/src/mathlib/CMakeLists.txt index 4856db4729..0d2e42d73a 100644 --- a/src/mathlib/CMakeLists.txt +++ b/src/mathlib/CMakeLists.txt @@ -10,53 +10,32 @@ set_target_properties(mathlib PROPERTIES target_include_directories(mathlib PRIVATE - ${CMAKE_SOURCE_DIR}/public/mathlib - ${CMAKE_SOURCE_DIR}/common + ${CMAKE_SOURCE_DIR}/public/mathlib + ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/public ${CMAKE_SOURCE_DIR}/public/tier0 ) target_compile_definitions(mathlib PRIVATE - MATHLIB_LIB + MATHLIB_LIB ) target_link_libraries(mathlib - PRIVATE - tier1::tier1 + PRIVATE + tier1::tier1 ) -if (OS_LINUX) +if(OS_WINDOWS) + target_compile_definitions(mathlib + PRIVATE + fopen=dont_use_fopen + ) +elseif(OS_LINUX) set_target_properties(mathlib PROPERTIES POSITION_INDEPENDENT_CODE ON ) -endif () - -set(UNITY_SOURCE_MATHLIB - color_conversion.cpp - halton.cpp - lightdesc.cpp - mathlib_base.cpp - powsse.cpp - sparse_convolution_noise.cpp - sseconst.cpp - sse.cpp - ssenoise.cpp - anorms.cpp - bumpvects.cpp - IceKey.cpp - polyhedron.cpp - randsse.cpp - spherical.cpp - simdvectormatrix.cpp - vmatrix.cpp - almostequal.cpp -) - -set_source_files_properties( - ${UNITY_SOURCE_MATHLIB} - PROPERTIES UNITY_GROUP mathlib -) +endif() target_sources_grouped( TARGET mathlib @@ -78,64 +57,64 @@ if(OS_LINUX OR OS_MACOS) endif() if(OS_WINDOWS OR OS_LINUX) - target_sources_grouped( - TARGET mathlib - NAME "Source Files" - FILES - 3dnow.cpp - ) + target_sources_grouped( + TARGET mathlib + NAME "Source Files" + FILES + 3dnow.cpp + ) endif() target_sources_grouped( TARGET mathlib NAME Public Header Files FILES - ${CMAKE_SOURCE_DIR}/public/mathlib/anorms.h - ${CMAKE_SOURCE_DIR}/public/mathlib/bumpvects.h - ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_3d_unitvec.h - ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_light_cube.h - ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_vector.h - ${CMAKE_SOURCE_DIR}/public/mathlib/halton.h - ${CMAKE_SOURCE_DIR}/public/mathlib/IceKey.H - ${CMAKE_SOURCE_DIR}/public/mathlib/lightdesc.h - ${CMAKE_SOURCE_DIR}/public/mathlib/math_pfns.h - ${CMAKE_SOURCE_DIR}/public/mathlib/mathlib.h - ${CMAKE_SOURCE_DIR}/public/mathlib/noise.h - ${CMAKE_SOURCE_DIR}/public/mathlib/polyhedron.h - ${CMAKE_SOURCE_DIR}/public/mathlib/quantize.h - ${CMAKE_SOURCE_DIR}/public/mathlib/simdvectormatrix.h - ${CMAKE_SOURCE_DIR}/public/mathlib/spherical_geometry.h - ${CMAKE_SOURCE_DIR}/public/mathlib/ssemath.h - ${CMAKE_SOURCE_DIR}/public/mathlib/ssequaternion.h - ${CMAKE_SOURCE_DIR}/public/mathlib/vector.h - ${CMAKE_SOURCE_DIR}/public/mathlib/vector2d.h - ${CMAKE_SOURCE_DIR}/public/mathlib/vector4d.h - ${CMAKE_SOURCE_DIR}/public/mathlib/vmatrix.h - ${CMAKE_SOURCE_DIR}/public/mathlib/vplane.h + ${CMAKE_SOURCE_DIR}/public/mathlib/anorms.h + ${CMAKE_SOURCE_DIR}/public/mathlib/bumpvects.h + ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_3d_unitvec.h + ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_light_cube.h + ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_vector.h + ${CMAKE_SOURCE_DIR}/public/mathlib/halton.h + ${CMAKE_SOURCE_DIR}/public/mathlib/IceKey.H + ${CMAKE_SOURCE_DIR}/public/mathlib/lightdesc.h + ${CMAKE_SOURCE_DIR}/public/mathlib/math_pfns.h + ${CMAKE_SOURCE_DIR}/public/mathlib/mathlib.h + ${CMAKE_SOURCE_DIR}/public/mathlib/noise.h + ${CMAKE_SOURCE_DIR}/public/mathlib/polyhedron.h + ${CMAKE_SOURCE_DIR}/public/mathlib/quantize.h + ${CMAKE_SOURCE_DIR}/public/mathlib/simdvectormatrix.h + ${CMAKE_SOURCE_DIR}/public/mathlib/spherical_geometry.h + ${CMAKE_SOURCE_DIR}/public/mathlib/ssemath.h + ${CMAKE_SOURCE_DIR}/public/mathlib/ssequaternion.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector2d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector4d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vmatrix.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vplane.h ) if(OS_WINDOWS OR OS_LINUX) - target_sources_grouped( - TARGET mathlib - NAME "Public Header Files" - FILES - ${CMAKE_SOURCE_DIR}/public/mathlib/amd3dx.h - ) + target_sources_grouped( + TARGET mathlib + NAME "Public Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/mathlib/amd3dx.h + ) endif() target_sources_grouped( TARGET mathlib NAME "Header Files" FILES - noisedata.h - sse.h + noisedata.h + sse.h ) if(OS_WINDOWS OR OS_LINUX) - target_sources_grouped( - TARGET mathlib - NAME "Header Files" - FILES - 3dnow.h - ) + target_sources_grouped( + TARGET mathlib + NAME "Header Files" + FILES + 3dnow.h + ) endif() diff --git a/src/public/chunkfile.cpp b/src/public/chunkfile.cpp index 81a77dd3b1..d06d5aceb7 100644 --- a/src/public/chunkfile.cpp +++ b/src/public/chunkfile.cpp @@ -151,7 +151,7 @@ ChunkHandler_t CChunkHandlerMap::GetHandler(const char *pszChunkName, void **ppD pNode = pNode->pNext; } - return(false); + return nullptr; } diff --git a/src/public/fgdlib/fgdlib.h b/src/public/fgdlib/fgdlib.h index 76051cfb56..db7f06b8f9 100644 --- a/src/public/fgdlib/fgdlib.h +++ b/src/public/fgdlib/fgdlib.h @@ -10,8 +10,8 @@ #pragma once #endif -#include "HelperInfo.h" -#include "GameData.h" +#include "helperinfo.h" +#include "gamedata.h" #include "GDClass.h" #include "InputOutput.h" diff --git a/src/public/fgdlib/gamedata.h b/src/public/fgdlib/gamedata.h index cf8b5be12d..803fc92055 100644 --- a/src/public/fgdlib/gamedata.h +++ b/src/public/fgdlib/gamedata.h @@ -14,8 +14,8 @@ #pragma warning(disable:4701 4702 4530) #include #pragma warning(pop) -#include "TokenReader.h" -#include "GDClass.h" +#include "tokenreader.h" +#include "gdclass.h" #include "InputOutput.h" #include "UtlString.h" #include "utlvector.h" @@ -25,7 +25,7 @@ class MDkeyvalue; class GameData; class KeyValues; -enum TEXTUREFORMAT; +enum class TEXTUREFORMAT : int; typedef void (*GameDataMessageFunc_t)(int level, PRINTF_FORMAT_STRING const char *fmt, ...); diff --git a/src/public/fgdlib/gdclass.h b/src/public/fgdlib/gdclass.h index fe81bb3759..8fa3d07cee 100644 --- a/src/public/fgdlib/gdclass.h +++ b/src/public/fgdlib/gdclass.h @@ -17,10 +17,10 @@ #pragma once #endif -#include "HelperInfo.h" -#include "TokenReader.h" -#include "GDVar.h" -#include "InputOutput.h" +#include "helperinfo.h" +#include "tokenreader.h" +#include "gdvar.h" +#include "inputoutput.h" #include "mathlib/vector.h" class CHelperInfo; diff --git a/src/public/fgdlib/gdvar.h b/src/public/fgdlib/gdvar.h index e8211d1d3a..51927e29c2 100644 --- a/src/public/fgdlib/gdvar.h +++ b/src/public/fgdlib/gdvar.h @@ -10,7 +10,7 @@ #pragma once #include -#include // dvs: for MAX_STRING. Fix. +#include // dvs: for MAX_STRING. Fix. class MDkeyvalue; @@ -133,7 +133,7 @@ class GDinputvariable // for choices/flags: CUtlVector m_Items; - static char *m_pszEmpty; + static const char *m_pszEmpty; char m_szName[MAX_IDENT]; char m_szLongName[MAX_STRING]; diff --git a/src/public/fgdlib/helperinfo.h b/src/public/fgdlib/helperinfo.h index affd5666ae..c8f51b18f7 100644 --- a/src/public/fgdlib/helperinfo.h +++ b/src/public/fgdlib/helperinfo.h @@ -80,7 +80,7 @@ inline bool CHelperInfo::AddParameter(const char *pszParameter) { if ((pszParameter != NULL) && (pszParameter[0] != '\0')) { - int nLen = strlen(pszParameter); + auto nLen = strlen(pszParameter); if (nLen > 0) { diff --git a/src/public/fgdlib/ieditortexture.h b/src/public/fgdlib/ieditortexture.h index 076839efcc..cba58e9ddb 100644 --- a/src/public/fgdlib/ieditortexture.h +++ b/src/public/fgdlib/ieditortexture.h @@ -35,7 +35,7 @@ class IMaterial; // // Texture formats. hack: MUST correlate with radio buttons in IDD_OPTIONS_CONFIGS. // -enum TEXTUREFORMAT +enum class TEXTUREFORMAT : int { tfNone = -1, tfWAD = 0, diff --git a/src/public/fgdlib/inputoutput.h b/src/public/fgdlib/inputoutput.h index e8efa79a7b..b7fc4fa592 100644 --- a/src/public/fgdlib/inputoutput.h +++ b/src/public/fgdlib/inputoutput.h @@ -53,7 +53,7 @@ class CClassInputOutputBase protected: - static char *g_pszEmpty; + static const char *g_pszEmpty; char m_szName[MAX_IO_NAME_LEN]; InputOutputType_t m_eType; diff --git a/src/public/fgdlib/wckeyvalues.h b/src/public/fgdlib/wckeyvalues.h index 730d92d195..0092181b24 100644 --- a/src/public/fgdlib/wckeyvalues.h +++ b/src/public/fgdlib/wckeyvalues.h @@ -188,7 +188,7 @@ typedef WCKeyValuesT WCKeyValuesVector; template inline const char *WCKeyValuesT::GetKey(int nIndex) const { - return(m_KeyValues.Element(nIndex).szKey); + return(this->m_KeyValues.Element(nIndex).szKey); } @@ -200,7 +200,7 @@ inline const char *WCKeyValuesT::GetKey(int nIndex) const template inline MDkeyvalue &WCKeyValuesT::GetKeyValue(int nIndex) { - return(m_KeyValues.Element(nIndex)); + return(this->m_KeyValues.Element(nIndex)); } @@ -212,7 +212,7 @@ inline MDkeyvalue &WCKeyValuesT::GetKeyValue(int nIndex) template inline const MDkeyvalue& WCKeyValuesT::GetKeyValue(int nIndex) const { - return(m_KeyValues.Element(nIndex)); + return(this->m_KeyValues.Element(nIndex)); } @@ -223,7 +223,7 @@ inline const MDkeyvalue& WCKeyValuesT::GetKeyValue(int nIndex) const template inline const char *WCKeyValuesT::GetValue(int nIndex) const { - return(m_KeyValues.Element(nIndex).szValue); + return(this->m_KeyValues.Element(nIndex).szValue); } diff --git a/src/public/filesystem_init.cpp b/src/public/filesystem_init.cpp index f471afca2d..31374e0a84 100644 --- a/src/public/filesystem_init.cpp +++ b/src/public/filesystem_init.cpp @@ -417,11 +417,11 @@ void LaunchVConfig() Q_AppendSlash( vconfigExe, sizeof( vconfigExe ) ); Q_strncat( vconfigExe, "vconfig.exe", sizeof( vconfigExe ), COPY_ALL_CHARACTERS ); - char *argv[] = + const char *argv[] = { vconfigExe, "-allowdebug", - NULL + nullptr }; _spawnv( _P_NOWAIT, vconfigExe, argv ); diff --git a/src/public/loadcmdline.cpp b/src/public/loadcmdline.cpp index 30c616f319..fc809c3cdd 100644 --- a/src/public/loadcmdline.cpp +++ b/src/public/loadcmdline.cpp @@ -7,7 +7,7 @@ #include "KeyValues.h" #include "tier1/strtools.h" -#include "FileSystem_Tools.h" +#include "filesystem_tools.h" #include "tier1/utlstring.h" // So we know whether or not we own argv's memory diff --git a/src/tier1/CMakeLists.txt b/src/tier1/CMakeLists.txt index 87f2ce6a92..30338bcb47 100644 --- a/src/tier1/CMakeLists.txt +++ b/src/tier1/CMakeLists.txt @@ -30,9 +30,23 @@ target_include_directories(tier1 ) if(OS_WINDOWS) - target_link_libraries(tier1 PRIVATE Rpcrt4.lib Ws2_32.lib) + target_compile_definitions(tier1 + PRIVATE + fopen=dont_use_fopen + ) + + target_link_libraries(tier1 + PRIVATE + Rpcrt4.lib + Ws2_32.lib + ) elseif(OS_LINUX) - target_link_libraries(tier1 PUBLIC + set_target_properties(tier1 PROPERTIES + POSITION_INDEPENDENT_CODE ON + ) + + target_link_libraries(tier1 + PUBLIC dl ) endif() diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt new file mode 100644 index 0000000000..0c5bcd1a73 --- /dev/null +++ b/src/utils/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(lzma) +add_subdirectory(vbsp) diff --git a/src/utils/common/bsplib.cpp b/src/utils/common/bsplib.cpp index bcda4c50c3..2411108ea4 100644 --- a/src/utils/common/bsplib.cpp +++ b/src/utils/common/bsplib.cpp @@ -718,6 +718,8 @@ CGameLump g_GameLumps; static IZip *s_pakFile = 0; +const char *g_pszEmpty = ""; + //----------------------------------------------------------------------------- // Keep the file position aligned to an arbitrary boundary. // Returns updated file position. @@ -3147,21 +3149,21 @@ void SetKeyValue(entity_t *ent, const char *key, const char *value) ep->value = copystring(value); } -char *ValueForKey (entity_t *ent, char *key) +const char* ValueForKey (entity_t *ent, const char *key) { for (epair_t *ep=ent->epairs ; ep ; ep=ep->next) if (!Q_stricmp (ep->key, key) ) return ep->value; - return ""; + return ""; } -vec_t FloatForKey (entity_t *ent, char *key) +vec_t FloatForKey (entity_t *ent, const char *key) { - char *k = ValueForKey (ent, key); + auto k = ValueForKey (ent, key); return atof(k); } -vec_t FloatForKeyWithDefault (entity_t *ent, char *key, float default_value) +vec_t FloatForKeyWithDefault (entity_t *ent, const char *key, float default_value) { for (epair_t *ep=ent->epairs ; ep ; ep=ep->next) if (!Q_stricmp (ep->key, key) ) @@ -3171,24 +3173,24 @@ vec_t FloatForKeyWithDefault (entity_t *ent, char *key, float default_value) -int IntForKey (entity_t *ent, char *key) +int IntForKey (entity_t *ent, const char *key) { - char *k = ValueForKey (ent, key); + auto k = ValueForKey (ent, key); return atol(k); } -int IntForKeyWithDefault(entity_t *ent, char *key, int nDefault ) +int IntForKeyWithDefault(entity_t *ent, const char *key, int nDefault ) { - char *k = ValueForKey (ent, key); - if ( !k[0] ) + auto k = ValueForKey (ent, key); + if ( !k ) return nDefault; return atol(k); } -void GetVectorForKey (entity_t *ent, char *key, Vector& vec) +void GetVectorForKey (entity_t *ent, const char *key, Vector& vec) { - char *k = ValueForKey (ent, key); + auto k = ValueForKey (ent, key); // scanf into doubles, then assign, so it is vec_t size independent double v1, v2, v3; v1 = v2 = v3 = 0; @@ -3198,11 +3200,11 @@ void GetVectorForKey (entity_t *ent, char *key, Vector& vec) vec[2] = v3; } -void GetVector2DForKey (entity_t *ent, char *key, Vector2D& vec) +void GetVector2DForKey (entity_t *ent, const char *key, Vector2D& vec) { double v1, v2; - char *k = ValueForKey (ent, key); + auto k = ValueForKey (ent, key); // scanf into doubles, then assign, so it is vec_t size independent v1 = v2 = 0; sscanf (k, "%lf %lf", &v1, &v2); @@ -3210,12 +3212,11 @@ void GetVector2DForKey (entity_t *ent, char *key, Vector2D& vec) vec[1] = v2; } -void GetAnglesForKey (entity_t *ent, char *key, QAngle& angle) +void GetAnglesForKey (entity_t *ent, const char *key, QAngle& angle) { - char *k; double v1, v2, v3; - k = ValueForKey (ent, key); + auto k = ValueForKey (ent, key); // scanf into doubles, then assign, so it is vec_t size independent v1 = v2 = v3 = 0; sscanf (k, "%lf %lf %lf", &v1, &v2, &v3); diff --git a/src/utils/common/bsplib.h b/src/utils/common/bsplib.h index 18a907f27a..d613bf2c20 100644 --- a/src/utils/common/bsplib.h +++ b/src/utils/common/bsplib.h @@ -313,15 +313,15 @@ void UnparseEntities (void); void PrintEntity (entity_t *ent); void SetKeyValue (entity_t *ent, const char *key, const char *value); -char *ValueForKey (entity_t *ent, char *key); +const char *ValueForKey (entity_t *ent, const char *key); // will return "" if not present -int IntForKey (entity_t *ent, char *key); -int IntForKeyWithDefault(entity_t *ent, char *key, int nDefault ); -vec_t FloatForKey (entity_t *ent, char *key); -vec_t FloatForKeyWithDefault (entity_t *ent, char *key, float default_value); -void GetVectorForKey (entity_t *ent, char *key, Vector& vec); -void GetVector2DForKey (entity_t *ent, char *key, Vector2D& vec); -void GetAnglesForKey (entity_t *ent, char *key, QAngle& vec); +int IntForKey (entity_t *ent, const char *key); +int IntForKeyWithDefault(entity_t *ent, const char *key, int nDefault ); +vec_t FloatForKey (entity_t *ent,const char *key); +vec_t FloatForKeyWithDefault (entity_t *ent, const char *key, float default_value); +void GetVectorForKey (entity_t *ent, const char *key, Vector& vec); +void GetVector2DForKey (entity_t *ent, const char *key, Vector2D& vec); +void GetAnglesForKey (entity_t *ent, const char *key, QAngle& vec); epair_t *ParseEpair (void); void StripTrailing (char *e); diff --git a/src/utils/common/map_shared.h b/src/utils/common/map_shared.h index 5f2b2b62d7..dd5f6d00c7 100644 --- a/src/utils/common/map_shared.h +++ b/src/utils/common/map_shared.h @@ -11,7 +11,7 @@ #endif -#include "ChunkFile.h" +#include "chunkfile.h" #include "bsplib.h" #include "cmdlib.h" diff --git a/src/utils/common/utilmatlib.cpp b/src/utils/common/utilmatlib.cpp index f2dc49fa83..cca1757480 100644 --- a/src/utils/common/utilmatlib.cpp +++ b/src/utils/common/utilmatlib.cpp @@ -15,10 +15,10 @@ #include #include "utilmatlib.h" #include "tier0/dbg.h" -#include +//#include #include "filesystem.h" #include "materialsystem/materialsystem_config.h" -#include "mathlib/Mathlib.h" +#include "mathlib/mathlib.h" void LoadMaterialSystemInterface( CreateInterfaceFn fileSystemFactory ) { diff --git a/src/utils/lzma/CMakeLists.txt b/src/utils/lzma/CMakeLists.txt new file mode 100644 index 0000000000..ec3664b33b --- /dev/null +++ b/src/utils/lzma/CMakeLists.txt @@ -0,0 +1,51 @@ +add_library(lzma STATIC) + +add_library(lzma::lzma ALIAS lzma) + +set_target_properties(lzma PROPERTIES PREFIX "") + +target_include_directories(lzma + PRIVATE + ${CMAKE_SOURCE_DIR}/public + C +) + +target_compile_definitions(lzma + PRIVATE + _NO_EXCEPTIONS + _LZMA_PROB32 + _7ZIP_ST +) + +# target_compile_options(lzma +# PRIVATE + +# ) + +target_link_libraries(lzma + PRIVATE + tier0::tier0 + tier1::tier1 + mathlib::mathlib +) + +target_sources_grouped( + TARGET lzma + NAME "Source Files" + FILES + lzma.cpp +) + +target_sources_grouped( + TARGET lzma + NAME "7Zip Common" + FILES + C/7zTypes.h + C/LzmaEnc.h + C/LzmaEnc.c + C/LzmaDec.c + C/LzmaDec.h + C/LzFind.h + C/LzFind.c + C/LzHash.h +) diff --git a/src/utils/vbsp/CMakeLists.txt b/src/utils/vbsp/CMakeLists.txt new file mode 100644 index 0000000000..bdee85ece2 --- /dev/null +++ b/src/utils/vbsp/CMakeLists.txt @@ -0,0 +1,213 @@ +add_executable(vbsp) + +target_include_directories(vbsp + PRIVATE + ${CMAKE_SOURCE_DIR}/common + ${CMAKE_SOURCE_DIR}/public + ${CMAKE_SOURCE_DIR}/utils + ${CMAKE_SOURCE_DIR}/utils/common + ${CMAKE_SOURCE_DIR}/utils/vmpi +) + +target_compile_definitions(vbsp + PRIVATE + MACRO_MATHLIB + PROTECTED_THINGS_DISABLE +) + +target_compile_options(vbsp + PRIVATE + /wd4091 + /wd4316 + /wd4355 + /wd4577 + /wd5033 + /wd5054 + /wd5055 +) + +if(OS_WINDOWS) + target_link_libraries(vbsp + PRIVATE + ws2_32.lib + odbc32.lib + odbccp32.lib + winmm.lib + ) +endif() + +target_link_libraries(vbsp + PRIVATE + bitmap::bitmap + fgdlib::fgdlib + mathlib::mathlib + tier0::tier0 + tier1::tier1 + tier2::tier2 + vtf::vtf + lzma::lzma + vstdlib::vstdlib +) + +target_sources_grouped( + TARGET vbsp + NAME "Source Files" + FILES + ${CMAKE_SOURCE_DIR}/public/collisionutils.cpp + ${CMAKE_SOURCE_DIR}/public/disp_common.cpp + ${CMAKE_SOURCE_DIR}/public/disp_powerinfo.cpp + ${CMAKE_SOURCE_DIR}/public/loadcmdline.cpp + ${CMAKE_SOURCE_DIR}/public/lumpfiles.cpp + ${CMAKE_SOURCE_DIR}/public/scratchpad3d.cpp + ${CMAKE_SOURCE_DIR}/public/zip_utils.cpp + ../common/mstristrip.cpp + ../common/physdll.cpp + ../common/scratchpad_helpers.cpp + ../common/utilmatlib.cpp + boundbox.cpp + brushbsp.cpp + csg.cpp + cubemap.cpp + detail.cpp + detailobjects.cpp + disp_ivp.cpp + disp_vbsp.cpp + faces.cpp + glfile.cpp + ivp.cpp + leakfile.cpp + manifest.cpp + map.cpp + materialpatch.cpp + materialsub.cpp + nodraw.cpp + normals.cpp + overlay.cpp + portals.cpp + prtfile.cpp + staticprop.cpp + textures.cpp + tree.cpp + vbsp.cpp + worldvertextransitionfixup.cpp + writebsp.cpp +) + +target_sources_grouped( + TARGET vbsp + NAME "Common Files" + FILES + ${CMAKE_SOURCE_DIR}/public/builddisp.cpp + ${CMAKE_SOURCE_DIR}/public/chunkfile.cpp + ${CMAKE_SOURCE_DIR}/public/filesystem_helpers.cpp + ${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp + ../common/bsplib.cpp + ../common/cmdlib.cpp + ../common/filesystem_tools.cpp + ../common/map_shared.cpp + ../common/pacifier.cpp + ../common/polylib.cpp + ../common/scriplib.cpp + ../common/threads.cpp + ../common/tools_minidump.cpp + ../common/tools_minidump.h +) + +target_sources_grouped( + TARGET vbsp + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/disp_powerinfo.h + ${CMAKE_SOURCE_DIR}/public/disp_vertindex.h + ../common/scratchpad_helpers.h + boundbox.h + csg.h + detail.h + disp_vbsp.h + faces.h + manifest.h + map.h + materialpatch.h + materialsub.h + vbsp.h + worldvertextransitionfixup.h + writebsp.h +) + +target_sources_grouped( + TARGET vbsp + NAME "Common header files" + FILES + ${CMAKE_SOURCE_DIR}/public/builddisp.h + ${CMAKE_SOURCE_DIR}/public/chunkfile.h + ${CMAKE_SOURCE_DIR}/public/filesystem.h + ${CMAKE_SOURCE_DIR}/public/filesystem_helpers.h + ${CMAKE_SOURCE_DIR}/public/gamebspfile.h + ${CMAKE_SOURCE_DIR}/public/tier1/interface.h + ${CMAKE_SOURCE_DIR}/public/tier1/tokenreader.h + ${CMAKE_SOURCE_DIR}/public/zip_uncompressed.h + ../common/bsplib.h + ../common/cmdlib.h + ../common/filesystem_tools.h + ../common/map_shared.h + ../common/pacifier.h + ../common/polylib.h + ../common/utilmatlib.h + ../vmpi/vmpi.h + disp_ivp.h + ivp.h +) + +target_sources_grouped( + TARGET vbsp + NAME "Public Headers" + FILES + ${CMAKE_SOURCE_DIR}/public/arraystack.h + ${CMAKE_SOURCE_DIR}/public/bspfile.h + ${CMAKE_SOURCE_DIR}/public/bspflags.h + ${CMAKE_SOURCE_DIR}/public/bsptreedata.h + #${CMAKE_SOURCE_DIR}/public/btree.h + ${CMAKE_SOURCE_DIR}/public/cmodel.h + ${CMAKE_SOURCE_DIR}/public/collisionutils.h + ${CMAKE_SOURCE_DIR}/public/disp_common.h + ${CMAKE_SOURCE_DIR}/public/iscratchpad3d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/amd3dx.h + ${CMAKE_SOURCE_DIR}/public/mathlib/bumpvects.h + ${CMAKE_SOURCE_DIR}/public/mathlib/mathlib.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector2d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector4d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vmatrix.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vplane.h + ${CMAKE_SOURCE_DIR}/public/nmatrix.h + ${CMAKE_SOURCE_DIR}/public/nvector.h + ${CMAKE_SOURCE_DIR}/public/phyfile.h + ${CMAKE_SOURCE_DIR}/public/scratchpad3d.h + ${CMAKE_SOURCE_DIR}/public/studio.h + ${CMAKE_SOURCE_DIR}/public/tier0/basetypes.h + ${CMAKE_SOURCE_DIR}/public/tier0/commonmacros.h + ${CMAKE_SOURCE_DIR}/public/tier0/dbg.h + ${CMAKE_SOURCE_DIR}/public/tier1/byteswap.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlbuffer.h + ${CMAKE_SOURCE_DIR}/public/tier1/utllinkedlist.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlmemory.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlrbtree.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlsymbol.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlvector.h + ${CMAKE_SOURCE_DIR}/public/vcollide.h + ${CMAKE_SOURCE_DIR}/public/vphysics_interface.h + ${CMAKE_SOURCE_DIR}/public/wadtypes.h + ${CMAKE_SOURCE_DIR}/public/worldsize.h + ../common/mstristrip.h + ../common/physdll.h + ../common/qfiles.h + ../common/scriplib.h + ../common/threads.h +) + +target_sources_grouped( + TARGET vbsp + NAME "Other files" + FILES + "notes.txt" +) diff --git a/src/utils/vbsp/boundbox.cpp b/src/utils/vbsp/boundbox.cpp index a62e9e2f7a..3bb5e2b705 100644 --- a/src/utils/vbsp/boundbox.cpp +++ b/src/utils/vbsp/boundbox.cpp @@ -6,7 +6,7 @@ //=============================================================================// #include "vbsp.h" -#include "BoundBox.h" +#include "boundbox.h" //#include "hammer_mathlib.h" //#include "MapDefs.h" diff --git a/src/utils/vbsp/brushbsp.cpp b/src/utils/vbsp/brushbsp.cpp index d455f30b7e..13b7be6376 100644 --- a/src/utils/vbsp/brushbsp.cpp +++ b/src/utils/vbsp/brushbsp.cpp @@ -335,11 +335,11 @@ bspbrush_t *AllocBrush (int numsides) static int s_BrushId = 0; bspbrush_t *bb; - int c; + size_t c; - c = (int)&(((bspbrush_t *)0)->sides[numsides]); + c = (size_t)&(((bspbrush_t *)0)->sides[numsides]); bb = (bspbrush_t*)malloc(c); - memset (bb, 0, c); + memset ((void*)bb, 0, c); bb->id = s_BrushId++; if (numthreads == 1) c_active_brushes++; diff --git a/src/utils/vbsp/cubemap.cpp b/src/utils/vbsp/cubemap.cpp index 829efdfb9e..1cce5dc6da 100644 --- a/src/utils/vbsp/cubemap.cpp +++ b/src/utils/vbsp/cubemap.cpp @@ -7,7 +7,7 @@ #include "vbsp.h" #include "bsplib.h" -#include "tier1/UtlBuffer.h" +#include "tier1/utlbuffer.h" #include "tier1/utlvector.h" #include "bitmap/imageformat.h" #include @@ -99,7 +99,7 @@ static const char *FindSkyboxMaterialName( void ) { for( int i = 0; i < g_MainMap->num_entities; i++ ) { - char* pEntity = ValueForKey(&g_MainMap->entities[i], "classname"); + auto pEntity = ValueForKey(&g_MainMap->entities[i], "classname"); if (!strcmp(pEntity, "worldspawn")) { return ValueForKey( &g_MainMap->entities[i], "skyname" ); diff --git a/src/utils/vbsp/detailobjects.cpp b/src/utils/vbsp/detailobjects.cpp index c6c1fc2bec..0d74915ba7 100644 --- a/src/utils/vbsp/detailobjects.cpp +++ b/src/utils/vbsp/detailobjects.cpp @@ -132,8 +132,8 @@ static void ParseDetailGroup( int detailId, KeyValues* pGroupKeyValues ) DetailModel_t &model = group.m_Models[i]; - model.m_ModelName = pIter->GetString( "model", 0 ); - if (model.m_ModelName != UTL_INVAL_SYMBOL) + model.m_ModelName = pIter->GetString( "model", nullptr ); + if (model.m_ModelName) { model.m_Type = DETAIL_PROP_TYPE_MODEL; } @@ -285,7 +285,7 @@ static const char *FindDetailVBSPName( void ) { for( int i = 0; i < num_entities; i++ ) { - char* pEntity = ValueForKey( &entities[i], "classname" ); + auto pEntity = ValueForKey( &entities[i], "classname" ); if ( !strcmp( pEntity, "worldspawn" ) ) { const char *pDetailVBSP = ValueForKey( &entities[i], "detailvbsp" ); @@ -904,12 +904,12 @@ void EmitDetailModels() Vector2D tex[2]; for (int i = 0; i < num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if (!strcmp(pEntity, "detail_prop") || !strcmp(pEntity, "prop_detail")) { GetVectorForKey( &entities[i], "origin", origin ); GetAnglesForKey( &entities[i], "angles", angles ); - char* pModelName = ValueForKey( &entities[i], "model" ); + auto pModelName = ValueForKey( &entities[i], "model" ); int nOrientation = IntForKey( &entities[i], "detailOrientation" ); AddDetailToLump( pModelName, origin, angles, nOrientation ); diff --git a/src/utils/vbsp/disp_vbsp.cpp b/src/utils/vbsp/disp_vbsp.cpp index f368859543..00c5b35d51 100644 --- a/src/utils/vbsp/disp_vbsp.cpp +++ b/src/utils/vbsp/disp_vbsp.cpp @@ -626,7 +626,7 @@ void DispGetFaceInfo( mapbrush_t *pBrush ) // we don't support displacement on entities at the moment!! if( pBrush->entitynum != 0 ) { - char* pszEntityName = ValueForKey( &g_LoadingMap->entities[pBrush->entitynum], "classname" ); + auto pszEntityName = ValueForKey( &g_LoadingMap->entities[pBrush->entitynum], "classname" ); Error( "Error: displacement found on a(n) %s entity - not supported (entity %d, brush %d)\n", pszEntityName, pBrush->entitynum, pBrush->brushnum ); } diff --git a/src/utils/vbsp/ivp.cpp b/src/utils/vbsp/ivp.cpp index 5ab6eb5f95..2d9a60b945 100644 --- a/src/utils/vbsp/ivp.cpp +++ b/src/utils/vbsp/ivp.cpp @@ -16,7 +16,7 @@ #include "phyfile.h" #include #include "KeyValues.h" -#include "UtlBuffer.h" +#include "utlbuffer.h" #include "utlsymbol.h" #include "utlrbtree.h" #include "ivp.h" @@ -432,7 +432,7 @@ class CPlaneList private: - CPhysConvex *CPlaneList::BuildConvexForBrush( int brushnumber, float shrink, CPhysCollide *pCollideTest, float shrinkMinimum ); + CPhysConvex *BuildConvexForBrush( int brushnumber, float shrink, CPhysCollide *pCollideTest, float shrinkMinimum ); public: CUtlVector m_convex; diff --git a/src/utils/vbsp/manifest.cpp b/src/utils/vbsp/manifest.cpp index 7e6248368d..c2ccfb1d15 100644 --- a/src/utils/vbsp/manifest.cpp +++ b/src/utils/vbsp/manifest.cpp @@ -267,7 +267,7 @@ ChunkFileResult_t CManifest::LoadManifestCordoningPrefsCallback( CChunkFile *pFi // pValue - the value of the pair // Output : returns a newly created epair structure //----------------------------------------------------------------------------- -epair_t *CManifest::CreateEPair( char *pKey, char *pValue ) +epair_t *CManifest::CreateEPair( const char *pKey, const char *pValue ) { epair_t *pEPair = new epair_t; diff --git a/src/utils/vbsp/manifest.h b/src/utils/vbsp/manifest.h index e7b801e1b5..9adab65f11 100644 --- a/src/utils/vbsp/manifest.h +++ b/src/utils/vbsp/manifest.h @@ -53,7 +53,7 @@ class CManifest static ChunkFileResult_t LoadManifestCordoningPrefsCallback( CChunkFile *pFile, CManifest *pManifest ); bool LoadSubMaps( CMapFile *pMapFile, const char *pszFileName ); - epair_t *CreateEPair( char *pKey, char *pValue ); + epair_t *CreateEPair( const char *pKey, const char *pValue ); bool LoadVMFManifest( const char *pszFileName ); const char *GetInstancePath( ) { return m_InstancePath; } diff --git a/src/utils/vbsp/map.cpp b/src/utils/vbsp/map.cpp index ffdb59bc08..ea47788677 100644 --- a/src/utils/vbsp/map.cpp +++ b/src/utils/vbsp/map.cpp @@ -1240,9 +1240,9 @@ int CMapFile::SideIDToIndex( int brushSideID ) // Input : *mapent - // *key - //----------------------------------------------------------------------------- -void ConvertSideList( entity_t *mapent, char *key ) +void ConvertSideList( entity_t *mapent, const char *key ) { - char *pszSideList = ValueForKey( mapent, key ); + auto pszSideList = ValueForKey( mapent, key ); if (pszSideList) { @@ -1290,10 +1290,10 @@ void ConvertSideList( entity_t *mapent, char *key ) ChunkFileResult_t HandleNoDynamicShadowsEnt( entity_t *pMapEnt ) { // Get the list of the sides. - char *pSideList = ValueForKey( pMapEnt, "sides" ); + auto pSideList = const_cast(ValueForKey( pMapEnt, "sides" )); // Parse the side list. - char *pScan = strtok( pSideList, " " ); + auto pScan = strtok( pSideList, " " ); if( pScan ) { do @@ -1811,7 +1811,7 @@ void CMapFile::ForceFuncAreaPortalWindowContents() { // Now go through all areaportal entities and force CONTENTS_WINDOW // on the brushes of the bmodels they point at. - char *targets[] = {"target", "BackgroundBModel"}; + const char *targets[] = {"target", "BackgroundBModel"}; int nTargets = sizeof(targets) / sizeof(targets[0]); for( int i=0; i < num_entities; i++ ) @@ -2019,10 +2019,10 @@ void CMapFile::CheckForInstances( const char *pszFileName ) // automatically done in this processing. for ( int i = 0; i < num_entities; i++ ) { - char *pEntity = ValueForKey( &entities[ i ], "classname" ); + auto pEntity = ValueForKey( &entities[ i ], "classname" ); if ( !strcmp( pEntity, "func_instance" ) ) { - char *pInstanceFile = ValueForKey( &entities[ i ], "file" ); + auto pInstanceFile = ValueForKey( &entities[ i ], "file" ); if ( pInstanceFile[ 0 ] ) { char InstancePath[ MAX_PATH ]; @@ -2337,8 +2337,8 @@ void CMapFile::MergeEntities( entity_t *pInstanceEntity, CMapFile *Instance, Vec entity_t *WorldspawnEnt = NULL; GameData::TNameFixup FixupStyle; - char *pTargetName = ValueForKey( pInstanceEntity, "targetname" ); - char *pName = ValueForKey( pInstanceEntity, "name" ); + auto pTargetName = ValueForKey( pInstanceEntity, "targetname" ); + auto pName = ValueForKey( pInstanceEntity, "name" ); if ( pTargetName[ 0 ] ) { sprintf( NameFixup, "%s", pTargetName ); @@ -2354,7 +2354,7 @@ void CMapFile::MergeEntities( entity_t *pInstanceEntity, CMapFile *Instance, Vec for( int i = 0; i < num_entities; i++ ) { - char *pID = ValueForKey( &entities[ i ], "hammerid" ); + auto pID = ValueForKey( &entities[ i ], "hammerid" ); if ( pID[ 0 ] ) { int value = atoi( pID ); @@ -2374,7 +2374,7 @@ void CMapFile::MergeEntities( entity_t *pInstanceEntity, CMapFile *Instance, Vec entity_t *entity = &entities[ num_entities + i ]; entity->firstbrush += ( nummapbrushes - Instance->nummapbrushes ); - char *pID = ValueForKey( entity, "hammerid" ); + auto pID = ValueForKey( entity, "hammerid" ); if ( pID[ 0 ] ) { int value = atoi( pID ); @@ -2384,7 +2384,7 @@ void CMapFile::MergeEntities( entity_t *pInstanceEntity, CMapFile *Instance, Vec SetKeyValue( entity, "hammerid", temp ); } - char *pEntity = ValueForKey( entity, "classname" ); + auto pEntity = ValueForKey( entity, "classname" ); if ( strcmpi( pEntity, "worldspawn" ) == 0 ) { WorldspawnEnt = entity; @@ -2410,7 +2410,7 @@ void CMapFile::MergeEntities( entity_t *pInstanceEntity, CMapFile *Instance, Vec for( int i = 0; i < EntClass->GetVariableCount(); i++ ) { GDinputvariable *EntVar = EntClass->GetVariableAt( i ); - char *pValue = ValueForKey( entity, ( char * )EntVar->GetName() ); + auto pValue = ValueForKey( entity, ( char * )EntVar->GetName() ); if ( GD.RemapKeyValue( EntVar->GetName(), pValue, temp, FixupStyle ) ) { #ifdef MERGE_INSTANCE_DEBUG_INFO @@ -3146,7 +3146,7 @@ void CMapFile::TestExpandBrushes (void) side_t *s; int i, j, bn; winding_t *w; - char *name = "expanded.map"; + const char *name = "expanded.map"; mapbrush_t *brush; vec_t dist; diff --git a/src/utils/vbsp/materialpatch.cpp b/src/utils/vbsp/materialpatch.cpp index 96a30edbfb..146f3922d9 100644 --- a/src/utils/vbsp/materialpatch.cpp +++ b/src/utils/vbsp/materialpatch.cpp @@ -6,7 +6,7 @@ // //=============================================================================// #include "vbsp.h" -#include "UtlBuffer.h" +#include "utlbuffer.h" #include "utlsymbol.h" #include "utlrbtree.h" #include "KeyValues.h" diff --git a/src/utils/vbsp/portals.cpp b/src/utils/vbsp/portals.cpp index 6c59cffa17..7f44c873ef 100644 --- a/src/utils/vbsp/portals.cpp +++ b/src/utils/vbsp/portals.cpp @@ -745,7 +745,6 @@ qboolean FloodEntities (tree_t *tree) { int i; Vector origin; - char *cl; qboolean inside; node_t *headnode; @@ -760,7 +759,7 @@ qboolean FloodEntities (tree_t *tree) if (VectorCompare(origin, vec3_origin)) continue; - cl = ValueForKey (&entities[i], "classname"); + auto cl = ValueForKey (&entities[i], "classname"); origin[2] += 1; // so objects on floor are ok diff --git a/src/utils/vbsp/staticprop.cpp b/src/utils/vbsp/staticprop.cpp index 3ba775ead5..b00c37a42b 100644 --- a/src/utils/vbsp/staticprop.cpp +++ b/src/utils/vbsp/staticprop.cpp @@ -11,14 +11,14 @@ #include "utlvector.h" #include "bspfile.h" #include "gamebspfile.h" -#include "VPhysics_Interface.h" -#include "Studio.h" +#include "vphysics_interface.h" +#include "studio.h" #include "byteswap.h" -#include "UtlBuffer.h" -#include "CollisionUtils.h" +#include "utlbuffer.h" +#include "collisionutils.h" #include -#include "CModel.h" -#include "PhysDll.h" +#include "cmodel.h" +#include "physdll.h" #include "utlsymbol.h" #include "tier1/strtools.h" #include "KeyValues.h" @@ -581,7 +581,7 @@ void EmitStaticProps() int i; for ( i = 0; i < num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if (!Q_strcmp(pEntity, "info_lighting")) { s_LightingInfo.AddToTail(i); @@ -591,7 +591,7 @@ void EmitStaticProps() // Emit specifically specified static props for ( i = 0; i < num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if (!strcmp(pEntity, "static_prop") || !strcmp(pEntity, "prop_static")) { StaticPropBuild_t build; diff --git a/src/utils/vbsp/vbsp.cpp b/src/utils/vbsp/vbsp.cpp index 7b8c05936d..0d44a365a1 100644 --- a/src/utils/vbsp/vbsp.cpp +++ b/src/utils/vbsp/vbsp.cpp @@ -787,7 +787,7 @@ static void Compute3DSkyboxAreas( node_t *headnode, CUtlVector& areas ) { for (int i = 0; i < g_MainMap->num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if (!strcmp(pEntity, "sky_camera")) { // Found a 3D skybox camera, get a leaf that lies in it @@ -1332,7 +1332,8 @@ int RunVBSP( int argc, char **argv ) g_nCubemapSamples = 0; // Mark as stale since the lighting could be screwed with new ents. - AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false ); + auto data = "stale"; + AddBufferToPak( GetPakFile(), "stale.txt", (void *)(data), strlen(data) + 1, false ); LoadMapFile (name); SetModelNumbers (); @@ -1389,7 +1390,8 @@ int RunVBSP( int argc, char **argv ) { LoadBSPFile_FileSystemOnly (mapFile); // Mark as stale since the lighting could be screwed with new ents. - AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false ); + auto data = "stale"; + AddBufferToPak( GetPakFile(), "stale.txt", (void *)(data), strlen(data) + 1, false ); } LoadMapFile (name); diff --git a/src/utils/vbsp/vbsp.h b/src/utils/vbsp/vbsp.h index 689bbaa874..79c44acd0f 100644 --- a/src/utils/vbsp/vbsp.h +++ b/src/utils/vbsp/vbsp.h @@ -18,7 +18,7 @@ #include "bsplib.h" #include "qfiles.h" #include "utilmatlib.h" -#include "ChunkFile.h" +#include "chunkfile.h" #ifdef WIN32 #pragma warning( disable: 4706 ) diff --git a/src/utils/vbsp/worldvertextransitionfixup.cpp b/src/utils/vbsp/worldvertextransitionfixup.cpp index f97f393378..86d528711a 100644 --- a/src/utils/vbsp/worldvertextransitionfixup.cpp +++ b/src/utils/vbsp/worldvertextransitionfixup.cpp @@ -6,7 +6,7 @@ #include "bsplib.h" #include "vbsp.h" -#include "tier1/UtlBuffer.h" +#include "tier1/utlbuffer.h" #include "tier1/utlvector.h" #include "KeyValues.h" #include "materialpatch.h" diff --git a/src/utils/vbsp/writebsp.cpp b/src/utils/vbsp/writebsp.cpp index 005990d645..4d5663ae7f 100644 --- a/src/utils/vbsp/writebsp.cpp +++ b/src/utils/vbsp/writebsp.cpp @@ -982,7 +982,6 @@ SetLightStyles void SetLightStyles (void) { int stylenum; - char *t; entity_t *e; int i, j; char value[10]; @@ -997,7 +996,7 @@ void SetLightStyles (void) { e = &entities[i]; - t = ValueForKey (e, "classname"); + auto t = ValueForKey (e, "classname"); if (Q_strncasecmp (t, "light", 5)) continue; @@ -1021,7 +1020,7 @@ void SetLightStyles (void) stylenum++; } sprintf (value, "%i", 32 + j); - char *pCurrentStyle = ValueForKey( e, "style" ); + auto pCurrentStyle = ValueForKey( e, "style" ); // the designer has set a default lightstyle as well as making the light switchable if ( pCurrentStyle ) { @@ -1537,7 +1536,7 @@ void ComputeBoundsNoSkybox( ) // Add the bounds to the worldspawn data for (int i = 0; i < num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if (!strcmp(pEntity, "worldspawn")) { char string[32]; diff --git a/src/vgui2/vgui_controls/CMakeLists.txt b/src/vgui2/vgui_controls/CMakeLists.txt index 94be59dcef..e59ab606bf 100644 --- a/src/vgui2/vgui_controls/CMakeLists.txt +++ b/src/vgui2/vgui_controls/CMakeLists.txt @@ -20,7 +20,12 @@ target_link_libraries(vgui_controls tier1::tier1 ) -if (OS_LINUX) +if(OS_WINDOWS) + target_compile_definitions(vgui_controls + PRIVATE + fopen=dont_use_fopen + ) +elseif (OS_LINUX) set_target_properties(vgui_controls PROPERTIES POSITION_INDEPENDENT_CODE ON ) From 84e944b1035a480e8f2e94754659b133eed15e35 Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Sun, 21 Jun 2026 17:14:28 +0300 Subject: [PATCH 02/14] Add vvis, vmpi, lzma to CMake --- src/CMakeLists.txt | 3 + src/cmake/FindLibZ.cmake | 22 ++++ src/cmake/FindTier0.cmake | 7 +- src/cmake/FindTier2.cmake | 11 +- src/cmake/FindTier3.cmake | 11 +- src/fgdlib/CMakeLists.txt | 3 - src/game/client/CMakeLists.txt | 5 - src/game/server/CMakeLists.txt | 5 - src/lib/CMakeLists.txt | 9 +- src/materialsystem/stdshaders/CMakeLists.txt | 10 +- src/mathlib/CMakeLists.txt | 5 +- src/thirdparty/CMakeLists.txt | 26 ++++ src/utils/CMakeLists.txt | 2 + src/utils/common/vmpi_tools_shared.cpp | 11 +- src/utils/lzma/CMakeLists.txt | 1 - src/utils/vbsp/CMakeLists.txt | 4 - src/utils/vmpi/CMakeLists.txt | 84 ++++++++++++ src/utils/vmpi/ThreadedTCPSocket.cpp | 2 +- src/utils/vmpi/vmpi.cpp | 2 +- src/utils/vmpi/vmpi.h | 2 +- src/utils/vmpi/vmpi_filesystem.cpp | 2 +- src/utils/vvis/CMakeLists.txt | 129 +++++++++++++++++++ src/utils/vvis/vvis.cpp | 20 +-- src/utils/vvis_launcher/CMakeLists.txt | 24 ++++ src/utils/vvis_launcher/vvis_launcher.cpp | 4 +- src/vgui2/vgui_controls/CMakeLists.txt | 11 +- 26 files changed, 354 insertions(+), 61 deletions(-) create mode 100644 src/cmake/FindLibZ.cmake create mode 100644 src/thirdparty/CMakeLists.txt create mode 100644 src/utils/vmpi/CMakeLists.txt create mode 100644 src/utils/vvis/CMakeLists.txt create mode 100644 src/utils/vvis_launcher/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b6cd36855..c6f44821ed 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,6 +38,7 @@ option(NEO_BUILD_TIER1 "Build tier1 library" ON) option(NEO_BUILD_MATHLIB "Build mathlib library" ON) option(NEO_BUILD_VGUI_CONTROLS "Build vgui_controls library" ON) option(NEO_BUILD_UTILS "Build utils" ON) +option(NEO_VMPI "Use VMPI in utils" ON) option(NEO_COPY_LIBRARIES "Copy libraries to bin directory by default" ON) option(NEO_EXTRA_ASSETS "Copy extra assets into game/neo" ON) set(NEO_EXTRA_ASSETS_ALT_PATH "" CACHE PATH "Alternate location to fetch the extra assets") @@ -68,6 +69,7 @@ message(STATUS "Build tier1 library: ${NEO_BUILD_TIER1}") message(STATUS "Build mathlib library: ${NEO_BUILD_MATHLIB}") message(STATUS "Build vgui_controls library: ${NEO_BUILD_VGUI_CONTROLS}") message(STATUS "Build utils: ${NEO_BUILD_UTILS}") +message(STATUS "Use VMPI in utils: ${NEO_VMPI}") message(STATUS "Copy libraries to bin directory by default: ${NEO_COPY_LIBRARIES}") message(STATUS "Copy extra assets into game/neo: ${NEO_EXTRA_ASSETS}") message(STATUS "Alternate location to fetch the extra assets: ${NEO_EXTRA_ASSETS_ALT_PATH}") @@ -435,6 +437,7 @@ if(NEO_USE_CCACHE) ) endif() +add_subdirectory(thirdparty) add_subdirectory(lib) if(NEO_GENERATE_GAMEDATA) diff --git a/src/cmake/FindLibZ.cmake b/src/cmake/FindLibZ.cmake new file mode 100644 index 0000000000..248d30717d --- /dev/null +++ b/src/cmake/FindLibZ.cmake @@ -0,0 +1,22 @@ +if(OS_WINDOWS) + set(LIBZ_LIBRARY_NAME libz.lib) +elseif(OS_LINUX OR OS_MACOS) + return() # TODO Linux +endif() + +find_file(LIBZ_LIBRARY + NAMES ${LIBZ_LIBRARY_NAME} + PATHS "${LIBPUBLIC}" + NO_CACHE + NO_DEFAULT_PATH + REQUIRED +) + +mark_as_advanced(LIBZ_LIBRARY) + +add_library(libz_libz STATIC IMPORTED GLOBAL) +add_library(libz::libz ALIAS libz_libz) + +set_target_properties(libz_libz PROPERTIES + IMPORTED_LOCATION "${LIBZ_LIBRARY}" +) diff --git a/src/cmake/FindTier0.cmake b/src/cmake/FindTier0.cmake index 6da95a07f0..294a872e3c 100644 --- a/src/cmake/FindTier0.cmake +++ b/src/cmake/FindTier0.cmake @@ -38,4 +38,9 @@ elseif(OS_LINUX OR OS_MACOS) ) endif() -set_target_properties(tier0_tier0 PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/public/tier0") +target_include_directories(tier0_tier0 + INTERFACE + "${CMAKE_SOURCE_DIR}/common" + "${CMAKE_SOURCE_DIR}/public" + "${CMAKE_SOURCE_DIR}/public/tier0" +) diff --git a/src/cmake/FindTier2.cmake b/src/cmake/FindTier2.cmake index 36cca4b458..23e5c2f9bf 100644 --- a/src/cmake/FindTier2.cmake +++ b/src/cmake/FindTier2.cmake @@ -19,5 +19,14 @@ add_library(tier2::tier2 ALIAS tier2_tier2) set_target_properties(tier2_tier2 PROPERTIES IMPORTED_LOCATION "${TIER2_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/public/tier2" +) + +target_include_directories(tier2_tier2 + INTERFACE + "${CMAKE_SOURCE_DIR}/public/tier2" +) + +target_link_libraries(tier2_tier2 + INTERFACE + tier1::tier1 ) diff --git a/src/cmake/FindTier3.cmake b/src/cmake/FindTier3.cmake index 84b3354230..d12f940ae9 100644 --- a/src/cmake/FindTier3.cmake +++ b/src/cmake/FindTier3.cmake @@ -19,5 +19,14 @@ add_library(tier3::tier3 ALIAS tier3_tier3) set_target_properties(tier3_tier3 PROPERTIES IMPORTED_LOCATION "${TIER3_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/public/tier3" +) + +target_include_directories(tier3_tier3 + INTERFACE + "${CMAKE_SOURCE_DIR}/public/tier3" +) + +target_link_libraries(tier3_tier3 + INTERFACE + tier2::tier2 ) diff --git a/src/fgdlib/CMakeLists.txt b/src/fgdlib/CMakeLists.txt index d89548f286..0d1c34744d 100644 --- a/src/fgdlib/CMakeLists.txt +++ b/src/fgdlib/CMakeLists.txt @@ -6,8 +6,6 @@ set_target_properties(fgdlib PROPERTIES PREFIX "") target_include_directories(fgdlib PRIVATE - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/public ${CMAKE_SOURCE_DIR}/utils/common ) @@ -24,7 +22,6 @@ target_compile_options(fgdlib target_link_libraries(fgdlib PRIVATE - tier0::tier0 tier1::tier1 mathlib::mathlib ) diff --git a/src/game/client/CMakeLists.txt b/src/game/client/CMakeLists.txt index 9902db9f94..14f26aefcf 100644 --- a/src/game/client/CMakeLists.txt +++ b/src/game/client/CMakeLists.txt @@ -18,7 +18,6 @@ endif() target_include_directories(client PRIVATE - ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/game/client ${CMAKE_SOURCE_DIR}/game/shared ${CMAKE_SOURCE_DIR}/game/shared/hl2 @@ -26,7 +25,6 @@ target_include_directories(client ${CMAKE_SOURCE_DIR}/game/shared/Multiplayer ${CMAKE_SOURCE_DIR}/game/shared/neo ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons - ${CMAKE_SOURCE_DIR}/public ${CMAKE_SOURCE_DIR}/thirdparty/sixensesdk/include ${CMAKE_SOURCE_DIR}/vendor ${CMAKE_SOURCE_DIR}/game/client/NextBot @@ -58,9 +56,6 @@ target_link_libraries(client mathlib::mathlib choreo_objects::choreo_objects dmx_loader::dmx_loader - tier0::tier0 - tier1::tier1 - tier2::tier2 tier3::tier3 matsys_controls::matsys_controls vstdlib::vstdlib diff --git a/src/game/server/CMakeLists.txt b/src/game/server/CMakeLists.txt index 2013ee763e..804c49e8c2 100644 --- a/src/game/server/CMakeLists.txt +++ b/src/game/server/CMakeLists.txt @@ -35,7 +35,6 @@ endif() target_include_directories(server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/common ${CMAKE_SOURCE_DIR}/game/server ${CMAKE_SOURCE_DIR}/game/server/hl2 ${CMAKE_SOURCE_DIR}/game/server/hl2mp @@ -48,7 +47,6 @@ target_include_directories(server ${CMAKE_SOURCE_DIR}/game/shared/neo ${CMAKE_SOURCE_DIR}/game/shared/neo/weapons ${CMAKE_SOURCE_DIR}/utils/common - ${CMAKE_SOURCE_DIR}/public ) target_compile_definitions(server @@ -73,9 +71,6 @@ target_link_libraries(server choreo_objects::choreo_objects dmx_loader::dmx_loader particles::particles - tier0::tier0 - tier1::tier1 - tier2::tier2 tier3::tier3 vstdlib::vstdlib steam_api::steam_api diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index bb5bd11152..3464804aca 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -1,7 +1,10 @@ -find_package(Appframework) +find_package(AppFramework) find_package(Bitmap) find_package(ChoreoObjects) +#find_package(DataModel) find_package(DMXLoader) +#find_package(GCSDK) +find_package(LibZ) find_package(MatSysControls) if(NEO_BUILD_MATHLIB) @@ -11,6 +14,7 @@ else() endif() find_package(Particles) +#find_package(ShaderLib) find_package(SteamAPI) find_package(Tier0) @@ -29,5 +33,6 @@ else() find_package(VGUIControls) endif() +#find_package(VPKLib) find_package(VSTDLib) -find_package(VTF) \ No newline at end of file +find_package(VTF) diff --git a/src/materialsystem/stdshaders/CMakeLists.txt b/src/materialsystem/stdshaders/CMakeLists.txt index e780a8d514..12a76128d9 100644 --- a/src/materialsystem/stdshaders/CMakeLists.txt +++ b/src/materialsystem/stdshaders/CMakeLists.txt @@ -14,11 +14,9 @@ endif() target_include_directories(game_shader_dx9 PRIVATE - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/public - fxctmp9 - vshtmp9 - include + fxctmp9 + vshtmp9 + include ) target_compile_definitions(game_shader_dx9 @@ -52,8 +50,6 @@ endif() target_link_libraries(game_shader_dx9 PRIVATE - tier0::tier0 - tier1::tier1 tier2::tier2 mathlib::mathlib vstdlib::vstdlib diff --git a/src/mathlib/CMakeLists.txt b/src/mathlib/CMakeLists.txt index 0d2e42d73a..c37a61f4b9 100644 --- a/src/mathlib/CMakeLists.txt +++ b/src/mathlib/CMakeLists.txt @@ -11,9 +11,6 @@ set_target_properties(mathlib PROPERTIES target_include_directories(mathlib PRIVATE ${CMAKE_SOURCE_DIR}/public/mathlib - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/public - ${CMAKE_SOURCE_DIR}/public/tier0 ) target_compile_definitions(mathlib @@ -67,7 +64,7 @@ endif() target_sources_grouped( TARGET mathlib - NAME Public Header Files + NAME "Public Header Files" FILES ${CMAKE_SOURCE_DIR}/public/mathlib/anorms.h ${CMAKE_SOURCE_DIR}/public/mathlib/bumpvects.h diff --git a/src/thirdparty/CMakeLists.txt b/src/thirdparty/CMakeLists.txt new file mode 100644 index 0000000000..a2f44b6214 --- /dev/null +++ b/src/thirdparty/CMakeLists.txt @@ -0,0 +1,26 @@ +set(BUILD_LIBCURL_DOCS OFF) +set(BUILD_MISC_DOCS OFF) +set(ENABLE_CURL_MANUAL OFF) +set(BUILD_CURL_EXE OFF) +set(BUILD_SHARED_LIBS OFF) +set(BUILD_STATIC_LIBS ON) +set(CURL_DISABLE_INSTALL ON) +set(ENABLE_UNICODE ON) +#set(CURL_STATIC_CRT ON) +set(HTTP_ONLY ON) +set(CURL_USE_LIBPSL OFF) +set(BUILD_TESTING OFF) +set(BUILD_EXAMPLES OFF) + +set(Perl_FIND_QUIETLY TRUE) +set(ZLIB_FIND_QUIETLY TRUE) +set(Brotli_FIND_QUIETLY TRUE) +set(Zstd_FIND_QUIETLY TRUE) +set(NGHTTP2_FIND_QUIETLY TRUE) +set(Libidn2_FIND_QUIETLY TRUE) +set(Libssh2_FIND_QUIETLY TRUE) + +message(STATUS "Adding libcurl:") +list(APPEND CMAKE_MESSAGE_INDENT " ") +add_subdirectory(libcurl) +list(POP_BACK CMAKE_MESSAGE_INDENT) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 0c5bcd1a73..bf9074d937 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,2 +1,4 @@ add_subdirectory(lzma) add_subdirectory(vbsp) +add_subdirectory(vvis) +add_subdirectory(vvis_launcher) diff --git a/src/utils/common/vmpi_tools_shared.cpp b/src/utils/common/vmpi_tools_shared.cpp index 247569f4f1..93050033e6 100644 --- a/src/utils/common/vmpi_tools_shared.cpp +++ b/src/utils/common/vmpi_tools_shared.cpp @@ -187,6 +187,7 @@ int VMPI_SendFileChunk( const void *pvChunkPrefix, int lenPrefix, tchar const *p HANDLE hFile = NULL; HANDLE hMapping = NULL; void const *pvMappedData = NULL; + int iMappedFileSize = INVALID_FILE_SIZE; int iResult = 0; hFile = ::CreateFile( ptchFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); @@ -201,7 +202,7 @@ int VMPI_SendFileChunk( const void *pvChunkPrefix, int lenPrefix, tchar const *p if ( !pvMappedData ) goto done; - int iMappedFileSize = ::GetFileSize( hFile, NULL ); + iMappedFileSize = ::GetFileSize( hFile, NULL ); if ( INVALID_FILE_SIZE == iMappedFileSize ) goto done; @@ -290,8 +291,8 @@ void VMPI_ExceptionFilter( unsigned long uCode, void *pvExceptionInfo ) #define ERR_RECORD( name ) { name, #name } struct { - int code; - char *pReason; + DWORD code; + const char *pReason; } errors[] = { ERR_RECORD( EXCEPTION_ACCESS_VIOLATION ), @@ -319,7 +320,7 @@ void VMPI_ExceptionFilter( unsigned long uCode, void *pvExceptionInfo ) int nErrors = sizeof( errors ) / sizeof( errors[0] ); int i=0; - char *pchReason = NULL; + const char *pchReason = nullptr; char chUnknownBuffer[32]; for ( i; ( i < nErrors ) && !pchReason; i++ ) { @@ -329,7 +330,7 @@ void VMPI_ExceptionFilter( unsigned long uCode, void *pvExceptionInfo ) if ( i == nErrors ) { - sprintf( chUnknownBuffer, "Error code 0x%08X", uCode ); + sprintf( chUnknownBuffer, "Error code 0x%08lX", uCode ); pchReason = chUnknownBuffer; } diff --git a/src/utils/lzma/CMakeLists.txt b/src/utils/lzma/CMakeLists.txt index ec3664b33b..509a417cec 100644 --- a/src/utils/lzma/CMakeLists.txt +++ b/src/utils/lzma/CMakeLists.txt @@ -24,7 +24,6 @@ target_compile_definitions(lzma target_link_libraries(lzma PRIVATE - tier0::tier0 tier1::tier1 mathlib::mathlib ) diff --git a/src/utils/vbsp/CMakeLists.txt b/src/utils/vbsp/CMakeLists.txt index bdee85ece2..e430f27213 100644 --- a/src/utils/vbsp/CMakeLists.txt +++ b/src/utils/vbsp/CMakeLists.txt @@ -2,8 +2,6 @@ add_executable(vbsp) target_include_directories(vbsp PRIVATE - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/public ${CMAKE_SOURCE_DIR}/utils ${CMAKE_SOURCE_DIR}/utils/common ${CMAKE_SOURCE_DIR}/utils/vmpi @@ -41,8 +39,6 @@ target_link_libraries(vbsp bitmap::bitmap fgdlib::fgdlib mathlib::mathlib - tier0::tier0 - tier1::tier1 tier2::tier2 vtf::vtf lzma::lzma diff --git a/src/utils/vmpi/CMakeLists.txt b/src/utils/vmpi/CMakeLists.txt new file mode 100644 index 0000000000..ca4676545a --- /dev/null +++ b/src/utils/vmpi/CMakeLists.txt @@ -0,0 +1,84 @@ +add_library(vmpi STATIC) + +add_library(vmpi::vmpi ALIAS vmpi) + +set_target_properties(vmpi PROPERTIES PREFIX "") + +target_include_directories(vmpi + PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/utils/common + ${CMAKE_SOURCE_DIR}/thirdparty/libcurl/include + ZLib +) + +target_compile_definitions(vmpi + PRIVATE + PROTECTED_THINGS_DISABLE +) + +if(NEO_VMPI) + target_compile_definitions(vmpi + PUBLIC + MPI + ) +endif() + +target_link_libraries(vmpi + PUBLIC + ZLib.lib + CURL::libcurl_static + + PRIVATE + tier1::tier1 + vstdlib::vstdlib + libz::libz +) + +target_link_directories(vmpi + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_sources_grouped( + TARGET vmpi + NAME "Source Files" + FILES + ${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp + ../common/filesystem_tools.cpp + ThreadedTCPSocket.cpp + ThreadedTCPSocketEmu.cpp + iphelpers.cpp + loopback_channel.cpp + messbuf.cpp + threadhelpers.cpp + vmpi.cpp + vmpi_distribute_tracker.cpp + vmpi_distribute_work.cpp + vmpi_distribute_work_default.cpp + vmpi_distribute_work_sdk.cpp + vmpi_filesystem.cpp + vmpi_filesystem_internal.h + vmpi_filesystem_master.cpp + vmpi_filesystem_worker.cpp + vmpi_logfile.cpp + vmpi_logfile.h +) + +target_sources_grouped( + TARGET vmpi + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/tier1/bitbuf.h + IThreadedTCPSocket.h + ThreadedTCPSocketEmu.h + ichannel.h + iphelpers.h + loopback_channel.h + messbuf.h + tcpsocket.h + threadhelpers.h + vmpi.h + vmpi_defs.h + vmpi_filesystem.h +) diff --git a/src/utils/vmpi/ThreadedTCPSocket.cpp b/src/utils/vmpi/ThreadedTCPSocket.cpp index 7cb3608b7e..bb46411b72 100644 --- a/src/utils/vmpi/ThreadedTCPSocket.cpp +++ b/src/utils/vmpi/ThreadedTCPSocket.cpp @@ -809,7 +809,7 @@ class CTCPConnectSocket_Listener : public ITCPConnectSocket listen( pRet->m_Socket, nQueueLength == -1 ? SOMAXCONN : nQueueLength ) != 0 ) { pRet->Release(); - return false; + return nullptr; } pRet->m_pHandler = pHandlerCreator; diff --git a/src/utils/vmpi/vmpi.cpp b/src/utils/vmpi/vmpi.cpp index f205a2df60..a5aece2afd 100644 --- a/src/utils/vmpi/vmpi.cpp +++ b/src/utils/vmpi/vmpi.cpp @@ -966,7 +966,7 @@ class CMasterBroadcaster int m_JobID[4]; char m_Password[256]; char m_WorkerExeFilename[MAX_PATH]; - CUtlVector m_Args; + CUtlVector m_Args; char m_PatchVersion[32]; // 0 if not patching. }; diff --git a/src/utils/vmpi/vmpi.h b/src/utils/vmpi/vmpi.h index 348753c2cb..7afdd2c2dd 100644 --- a/src/utils/vmpi/vmpi.h +++ b/src/utils/vmpi/vmpi.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// +//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// // // Purpose: // diff --git a/src/utils/vmpi/vmpi_filesystem.cpp b/src/utils/vmpi/vmpi_filesystem.cpp index 4d3a395cfd..951b07361a 100644 --- a/src/utils/vmpi/vmpi_filesystem.cpp +++ b/src/utils/vmpi/vmpi_filesystem.cpp @@ -8,7 +8,7 @@ #include "vmpi_filesystem_internal.h" #include "tier1/utlbuffer.h" - +#include // TODO for min/max only, pls replace bool g_bDisableFileAccess = false; diff --git a/src/utils/vvis/CMakeLists.txt b/src/utils/vvis/CMakeLists.txt new file mode 100644 index 0000000000..b05412130c --- /dev/null +++ b/src/utils/vvis/CMakeLists.txt @@ -0,0 +1,129 @@ +add_library(vvis_library SHARED) + +target_include_directories(vvis_library + PRIVATE + ${CMAKE_SOURCE_DIR}/utils + ${CMAKE_SOURCE_DIR}/utils/common + ${CMAKE_SOURCE_DIR}/utils/vmpi +) + +target_compile_definitions(vvis_library + PRIVATE + PROTECTED_THINGS_DISABLE +) + +target_compile_options(vvis_library + PRIVATE + /wd4091 + /wd4316 + /wd4355 + /wd4577 + /wd5033 + /wd5054 + /wd5055 +) + +if(OS_WINDOWS) + target_link_libraries(vvis_library + PRIVATE + odbc32.lib + odbccp32.lib + ws2_32.lib + vmpi::vmpi + ) +endif() + +target_link_libraries(vvis_library + PRIVATE + mathlib::mathlib + tier2::tier2 + lzma::lzma +) + +target_sources_grouped( + TARGET vvis_library + NAME "Source Files" + FILES + ${CMAKE_SOURCE_DIR}/public/collisionutils.cpp + ${CMAKE_SOURCE_DIR}/public/filesystem_helpers.cpp + ${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp + ${CMAKE_SOURCE_DIR}/public/loadcmdline.cpp + ${CMAKE_SOURCE_DIR}/public/lumpfiles.cpp + ${CMAKE_SOURCE_DIR}/public/scratchpad3d.cpp + #${CMAKE_SOURCE_DIR}/public/tier0/memoverride.cpp" + ${CMAKE_SOURCE_DIR}/public/zip_utils.cpp + ../common/MySqlDatabase.cpp + ../common/bsplib.cpp + ../common/cmdlib.cpp + ../common/filesystem_tools.cpp + ../common/pacifier.cpp + ../common/scratchpad_helpers.cpp + ../common/scriplib.cpp + ../common/threads.cpp + ../common/tools_minidump.cpp + ../common/tools_minidump.h + WaterDist.cpp + flow.cpp + vvis.cpp +) + +if(OS_WINDOWS) + target_sources_grouped( + TARGET vvis_library + NAME "Source Files" + FILES + ../common/mpi_stats.cpp + ../common/vmpi_tools_shared.cpp + mpivis.cpp + ) +endif() + +target_sources_grouped( + TARGET vvis_library + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/BSPFILE.H + ${CMAKE_SOURCE_DIR}/public/BSPTreeData.h + ${CMAKE_SOURCE_DIR}/public/GameBSPFile.h + ${CMAKE_SOURCE_DIR}/public/bspflags.h + ${CMAKE_SOURCE_DIR}/public/cmodel.h + ${CMAKE_SOURCE_DIR}/public/mathlib/amd3dx.h + ${CMAKE_SOURCE_DIR}/public/mathlib/bumpvects.h + ${CMAKE_SOURCE_DIR}/public/mathlib/mathlib.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector2d.h + ${CMAKE_SOURCE_DIR}/public/tier0/basetypes.h + ${CMAKE_SOURCE_DIR}/public/tier0/commonmacros.h + ${CMAKE_SOURCE_DIR}/public/tier1/byteswap.h + ${CMAKE_SOURCE_DIR}/public/tier1/checksum_crc.h + ${CMAKE_SOURCE_DIR}/public/tier1/checksum_md5.h + ${CMAKE_SOURCE_DIR}/public/tier1/strtools.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlbuffer.h + ${CMAKE_SOURCE_DIR}/public/tier1/utllinkedlist.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlmemory.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlrbtree.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlsymbol.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlvector.h + ${CMAKE_SOURCE_DIR}/public/vcollide.h + ${CMAKE_SOURCE_DIR}/public/vstdlib/vstdlib.h + ${CMAKE_SOURCE_DIR}/public/wadtypes.h + ../common/ISQLDBReplyTarget.h + ../common/MySqlDatabase.h + ../common/bsplib.h + ../common/cmdlib.h + ../common/pacifier.h + ../common/scriplib.h + ../common/threads.h + vis.h +) + +if(OS_WINDOWS) + target_sources_grouped( + TARGET vvis_library + NAME "Header Files" + FILES + ../common/vmpi_tools_shared.h + ../vmpi/vmpi_distribute_work.h + mpivis.h + ) +endif() diff --git a/src/utils/vvis/vvis.cpp b/src/utils/vvis/vvis.cpp index a544c76820..131fab764d 100644 --- a/src/utils/vvis/vvis.cpp +++ b/src/utils/vvis/vvis.cpp @@ -890,7 +890,7 @@ float DetermineVisRadius( ) // Check the max vis range to determine the vis radius for (int i = 0; i < num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if (!stricmp(pEntity, "env_fog_controller")) { flRadius = FloatForKey (&entities[i], "farz"); @@ -1090,12 +1090,19 @@ int RunVVis( int argc, char **argv ) Msg( "Valve Software - vvis.exe (%s)\n", __DATE__ ); - verbose = false; + verbose = false; LoadCmdLineFromFile( argc, argv, source, "vvis" ); int i = ParseCommandLine( argc, argv ); - CmdLib_InitFileSystem( argv[ argc - 1 ] ); + if (i != argc - 1) + { + PrintUsage( argc, argv ); + DeleteCmdLine( argc, argv ); + CmdLib_Exit( 1 ); + } + + CmdLib_InitFileSystem( argv[ argc - 1 ] ); // The ExpandPath is just for VMPI. VMPI's file system needs the basedir in front of all filenames, // so we prepend qdir here. @@ -1112,13 +1119,6 @@ int RunVVis( int argc, char **argv ) V_strncpy( source, mapFile, sizeof( mapFile ) ); V_StripExtension( source, source, sizeof( source ) ); - if (i != argc - 1) - { - PrintUsage( argc, argv ); - DeleteCmdLine( argc, argv ); - CmdLib_Exit( 1 ); - } - start = Plat_FloatTime(); #ifdef MPI diff --git a/src/utils/vvis_launcher/CMakeLists.txt b/src/utils/vvis_launcher/CMakeLists.txt new file mode 100644 index 0000000000..b5bd12c2d9 --- /dev/null +++ b/src/utils/vvis_launcher/CMakeLists.txt @@ -0,0 +1,24 @@ +add_executable(vvis) + +target_link_libraries(vvis + PRIVATE + tier1::tier1 +) + +target_sources_grouped( + TARGET vvis + NAME "Source Files" + FILES + vvis_launcher.cpp + StdAfx.cpp +) + +target_sources_grouped( + TARGET vvis + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/tier1/interface.h + StdAfx.h +) + +target_precompile_headers(vvis PUBLIC StdAfx.h) diff --git a/src/utils/vvis_launcher/vvis_launcher.cpp b/src/utils/vvis_launcher/vvis_launcher.cpp index edf03d251b..3a39d47670 100644 --- a/src/utils/vvis_launcher/vvis_launcher.cpp +++ b/src/utils/vvis_launcher/vvis_launcher.cpp @@ -45,8 +45,8 @@ char* GetLastErrorString() int main(int argc, char* argv[]) { CommandLine()->CreateCmdLine( argc, argv ); - const char *pDLLName = "vvis_dll.dll"; - + const char *pDLLName = "vvis_library.dll"; + CSysModule *pModule = Sys_LoadModule( pDLLName ); if ( !pModule ) { diff --git a/src/vgui2/vgui_controls/CMakeLists.txt b/src/vgui2/vgui_controls/CMakeLists.txt index e59ab606bf..55c2e3be56 100644 --- a/src/vgui2/vgui_controls/CMakeLists.txt +++ b/src/vgui2/vgui_controls/CMakeLists.txt @@ -8,15 +8,14 @@ set_target_properties(vgui_controls PROPERTIES UNITY_BUILD_MODE GROUP ) -target_include_directories(vgui_controls - PRIVATE - ${CMAKE_SOURCE_DIR}/common - ${CMAKE_SOURCE_DIR}/public -) +# target_include_directories(vgui_controls +# PRIVATE +# ${CMAKE_SOURCE_DIR}/common +# ${CMAKE_SOURCE_DIR}/public +# ) target_link_libraries(vgui_controls PRIVATE - tier0::tier0 tier1::tier1 ) From 92d50de2d5beb75010d514d1a83ac3be24a76998 Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Sun, 3 Aug 2025 01:27:44 +0300 Subject: [PATCH 03/14] Do not compile vmpi and libcurl when DNEO_VMPI is OFF --- src/thirdparty/CMakeLists.txt | 50 ++++++++++++++++++----------------- src/utils/CMakeLists.txt | 5 ++++ src/utils/vvis/CMakeLists.txt | 11 ++++++-- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/src/thirdparty/CMakeLists.txt b/src/thirdparty/CMakeLists.txt index a2f44b6214..7133b2c1b5 100644 --- a/src/thirdparty/CMakeLists.txt +++ b/src/thirdparty/CMakeLists.txt @@ -1,26 +1,28 @@ -set(BUILD_LIBCURL_DOCS OFF) -set(BUILD_MISC_DOCS OFF) -set(ENABLE_CURL_MANUAL OFF) -set(BUILD_CURL_EXE OFF) -set(BUILD_SHARED_LIBS OFF) -set(BUILD_STATIC_LIBS ON) -set(CURL_DISABLE_INSTALL ON) -set(ENABLE_UNICODE ON) -#set(CURL_STATIC_CRT ON) -set(HTTP_ONLY ON) -set(CURL_USE_LIBPSL OFF) -set(BUILD_TESTING OFF) -set(BUILD_EXAMPLES OFF) +if(DNEO_VMPI) + set(BUILD_LIBCURL_DOCS OFF) + set(BUILD_MISC_DOCS OFF) + set(ENABLE_CURL_MANUAL OFF) + set(BUILD_CURL_EXE OFF) + set(BUILD_SHARED_LIBS OFF) + set(BUILD_STATIC_LIBS ON) + set(CURL_DISABLE_INSTALL ON) + set(ENABLE_UNICODE ON) + #set(CURL_STATIC_CRT ON) + set(HTTP_ONLY ON) + set(CURL_USE_LIBPSL OFF) + set(BUILD_TESTING OFF) + set(BUILD_EXAMPLES OFF) -set(Perl_FIND_QUIETLY TRUE) -set(ZLIB_FIND_QUIETLY TRUE) -set(Brotli_FIND_QUIETLY TRUE) -set(Zstd_FIND_QUIETLY TRUE) -set(NGHTTP2_FIND_QUIETLY TRUE) -set(Libidn2_FIND_QUIETLY TRUE) -set(Libssh2_FIND_QUIETLY TRUE) + set(Perl_FIND_QUIETLY TRUE) + set(ZLIB_FIND_QUIETLY TRUE) + set(Brotli_FIND_QUIETLY TRUE) + set(Zstd_FIND_QUIETLY TRUE) + set(NGHTTP2_FIND_QUIETLY TRUE) + set(Libidn2_FIND_QUIETLY TRUE) + set(Libssh2_FIND_QUIETLY TRUE) -message(STATUS "Adding libcurl:") -list(APPEND CMAKE_MESSAGE_INDENT " ") -add_subdirectory(libcurl) -list(POP_BACK CMAKE_MESSAGE_INDENT) + message(STATUS "Adding libcurl:") + list(APPEND CMAKE_MESSAGE_INDENT " ") + add_subdirectory(libcurl) + list(POP_BACK CMAKE_MESSAGE_INDENT) +endif() diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index bf9074d937..516d3cb027 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,4 +1,9 @@ add_subdirectory(lzma) add_subdirectory(vbsp) + +if(DNEO_VMPI) + add_subdirectory(vmpi) +endif() + add_subdirectory(vvis) add_subdirectory(vvis_launcher) diff --git a/src/utils/vvis/CMakeLists.txt b/src/utils/vvis/CMakeLists.txt index b05412130c..d74f1a627f 100644 --- a/src/utils/vvis/CMakeLists.txt +++ b/src/utils/vvis/CMakeLists.txt @@ -29,8 +29,15 @@ if(OS_WINDOWS) odbc32.lib odbccp32.lib ws2_32.lib - vmpi::vmpi + vstdlib::vstdlib ) + + if(DNEO_VMPI) + target_link_libraries(vvis_library + PRIVATE + vmpi::vmpi + ) + endif() endif() target_link_libraries(vvis_library @@ -67,7 +74,7 @@ target_sources_grouped( vvis.cpp ) -if(OS_WINDOWS) +if(OS_WINDOWS AND DNEO_VMPI) target_sources_grouped( TARGET vvis_library NAME "Source Files" From 962eef42fe926e3ca5875e9e5c12db7b77f8fda9 Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Sun, 3 Aug 2025 03:15:05 +0300 Subject: [PATCH 04/14] Add vrad and vice to CMake --- src/CMakeLists.txt | 1 + src/raytrace/CMakeLists.txt | 23 ++ src/thirdparty/CMakeLists.txt | 2 +- src/utils/CMakeLists.txt | 5 +- src/utils/lzma/CMakeLists.txt | 5 - src/utils/vice/CMakeLists.txt | 32 +++ src/utils/vrad/CMakeLists.txt | 265 ++++++++++++++++++++++ src/utils/vrad/lightmap.cpp | 22 +- src/utils/vrad/macro_texture.cpp | 2 +- src/utils/vrad/vrad.cpp | 6 +- src/utils/vrad/vrad.h | 4 +- src/utils/vrad/vraddll.cpp | 2 +- src/utils/vrad_launcher/CMakeLists.txt | 25 ++ src/utils/vrad_launcher/vrad_launcher.cpp | 6 +- src/utils/vvis/CMakeLists.txt | 4 +- 15 files changed, 373 insertions(+), 31 deletions(-) create mode 100644 src/raytrace/CMakeLists.txt create mode 100644 src/utils/vice/CMakeLists.txt create mode 100644 src/utils/vrad/CMakeLists.txt create mode 100644 src/utils/vrad_launcher/CMakeLists.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c6f44821ed..af7f79b5c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -462,6 +462,7 @@ if(NOT NEO_DEDICATED) endif() add_subdirectory(game/server) +add_subdirectory(raytrace) if(NEO_COPY_LIBRARIES) set(COPY_ALL_LIBS_FLAG ALL) diff --git a/src/raytrace/CMakeLists.txt b/src/raytrace/CMakeLists.txt new file mode 100644 index 0000000000..ca2bc07577 --- /dev/null +++ b/src/raytrace/CMakeLists.txt @@ -0,0 +1,23 @@ +add_library(raytrace OBJECT) + +add_library(raytrace::raytrace ALIAS raytrace) + +target_include_directories(raytrace + PRIVATE + ${CMAKE_SOURCE_DIR}/utils + ${CMAKE_SOURCE_DIR}/utils/common +) + +target_link_libraries(raytrace + PRIVATE + tier1::tier1 +) + +target_sources_grouped( + TARGET raytrace + NAME "Source Files" + FILES + raytrace.cpp + trace2.cpp + trace3.cpp +) diff --git a/src/thirdparty/CMakeLists.txt b/src/thirdparty/CMakeLists.txt index 7133b2c1b5..4281122ed7 100644 --- a/src/thirdparty/CMakeLists.txt +++ b/src/thirdparty/CMakeLists.txt @@ -1,4 +1,4 @@ -if(DNEO_VMPI) +if(NEO_VMPI) set(BUILD_LIBCURL_DOCS OFF) set(BUILD_MISC_DOCS OFF) set(ENABLE_CURL_MANUAL OFF) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 516d3cb027..e4e256b869 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,9 +1,12 @@ add_subdirectory(lzma) add_subdirectory(vbsp) -if(DNEO_VMPI) +if(NEO_VMPI) add_subdirectory(vmpi) endif() add_subdirectory(vvis) add_subdirectory(vvis_launcher) +add_subdirectory(vrad) +add_subdirectory(vrad_launcher) +add_subdirectory(vice) diff --git a/src/utils/lzma/CMakeLists.txt b/src/utils/lzma/CMakeLists.txt index 509a417cec..abf9ac354e 100644 --- a/src/utils/lzma/CMakeLists.txt +++ b/src/utils/lzma/CMakeLists.txt @@ -17,11 +17,6 @@ target_compile_definitions(lzma _7ZIP_ST ) -# target_compile_options(lzma -# PRIVATE - -# ) - target_link_libraries(lzma PRIVATE tier1::tier1 diff --git a/src/utils/vice/CMakeLists.txt b/src/utils/vice/CMakeLists.txt new file mode 100644 index 0000000000..8199cf0b42 --- /dev/null +++ b/src/utils/vice/CMakeLists.txt @@ -0,0 +1,32 @@ +add_executable(vice) + +target_include_directories(vice + PRIVATE + ${CMAKE_SOURCE_DIR}/utils + ${CMAKE_SOURCE_DIR}/utils/common +) + +target_link_libraries(vice + PRIVATE + mathlib::mathlib + tier2::tier2 + vstdlib::vstdlib +) + +target_sources_grouped( + TARGET vice + NAME "Source Files" + FILES + ${CMAKE_SOURCE_DIR}/public/filesystem_helpers.cpp + ${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp + ../common/cmdlib.cpp + ../common/filesystem_tools.cpp + vice.cpp +) + +target_sources_grouped( + TARGET vice + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/mathlib/IceKey.H +) diff --git a/src/utils/vrad/CMakeLists.txt b/src/utils/vrad/CMakeLists.txt new file mode 100644 index 0000000000..dd7b877e2e --- /dev/null +++ b/src/utils/vrad/CMakeLists.txt @@ -0,0 +1,265 @@ +add_library(vrad_library SHARED) + +target_include_directories(vrad_library + PRIVATE + ${CMAKE_SOURCE_DIR}/utils + ${CMAKE_SOURCE_DIR}/utils/common + ${CMAKE_SOURCE_DIR}/utils/vmpi +) + +target_compile_definitions(vrad_library + PRIVATE + PROTECTED_THINGS_DISABLE + VRAD +) + +target_link_libraries(vrad_library + PRIVATE + mathlib::mathlib + tier2::tier2 + lzma::lzma + bitmap::bitmap + raytrace::raytrace + vtf::vtf + vstdlib::vstdlib +) + +if(OS_WINDOWS) + target_link_libraries(vrad_library + PRIVATE + ws2_32.lib + ) + + if(NEO_VMPI) + target_link_libraries(vrad_library + PRIVATE + vmpi::vmpi + ) + endif() +endif() + +target_sources_grouped( + TARGET vrad_library + NAME "Source Files" + FILES + ${CMAKE_SOURCE_DIR}/public/BSPTreeData.cpp + ${CMAKE_SOURCE_DIR}/public/disp_common.cpp + ${CMAKE_SOURCE_DIR}/public/disp_powerinfo.cpp + ${CMAKE_SOURCE_DIR}/public/loadcmdline.cpp + ${CMAKE_SOURCE_DIR}/public/lumpfiles.cpp + ${CMAKE_SOURCE_DIR}/public/zip_utils.cpp + ../common/MySqlDatabase.cpp + ../common/pacifier.cpp + ../common/physdll.cpp + ../common/utilmatlib.cpp + SampleHash.cpp + VRAD_DispColl.cpp + VRadDisps.cpp + VRadStaticProps.cpp + VradDetailProps.cpp + disp_vrad.cpp + imagepacker.cpp + incremental.cpp + leaf_ambient_lighting.cpp + lightmap.cpp + macro_texture.cpp + radial.cpp + trace.cpp + vismat.cpp + vrad.cpp + vraddll.cpp +) + +if(OS_WINDOWS) + target_sources_grouped( + TARGET vrad_library + NAME "Source Files" + FILES + ../common/mpi_stats.cpp + ../common/vmpi_tools_shared.cpp + ../common/vmpi_tools_shared.h + mpivrad.cpp + + # These files were [!$WIN32] in vpc + ${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp + ../common/filesystem_tools.cpp + ) +endif() + +target_sources_grouped( + TARGET vrad_library + NAME "Common Files" + FILES + ${CMAKE_SOURCE_DIR}/public/ChunkFile.cpp + ${CMAKE_SOURCE_DIR}/public/DispColl_Common.cpp + ${CMAKE_SOURCE_DIR}/public/builddisp.cpp + ../common/bsplib.cpp + ../common/cmdlib.cpp + ../common/map_shared.cpp + ../common/polylib.cpp + ../common/scriplib.cpp + ../common/threads.cpp + ../common/tools_minidump.cpp + ../common/tools_minidump.h + notes.txt +) + +target_sources_grouped( + TARGET vrad_library + NAME "Public Files" + FILES + ${CMAKE_SOURCE_DIR}/public/CollisionUtils.cpp + ${CMAKE_SOURCE_DIR}/public/ScratchPad3D.cpp + ${CMAKE_SOURCE_DIR}/public/ScratchPadUtils.cpp + ${CMAKE_SOURCE_DIR}/public/filesystem_helpers.cpp +) + +target_sources_grouped( + TARGET vrad_library + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/bitmap/tgawriter.h + ${CMAKE_SOURCE_DIR}/public/map_utils.h + VRAD_DispColl.h + disp_vrad.h + iincremental.h + imagepacker.h + incremental.h + leaf_ambient_lighting.h + lightmap.h + macro_texture.h + radial.h + vismat.h + vrad.h + vraddetailprops.h + vraddll.h +) + +if(OS_WINDOWS) + target_sources_grouped( + TARGET vrad_library + NAME "Header Files" + FILES + mpivrad.h + ) +endif() + +target_sources_grouped( + TARGET vrad_library + NAME "Common Header Files" + FILES + ../common/ISQLDBReplyTarget.h + ../common/MySqlDatabase.h + ../common/bsplib.h + ../common/cmdlib.h + ../common/consolewnd.h + ../common/map_shared.h + ../common/pacifier.h + ../common/polylib.h + ../common/scriplib.h + ../common/threads.h + ../common/utilmatlib.h +) + +if(OS_WINDOWS) + target_sources_grouped( + TARGET vrad_library + NAME "Common Header Files" + FILES + ../common/mpi_stats.h + ../vmpi/ichannel.h + ../vmpi/imysqlwrapper.h + ../vmpi/iphelpers.h + ../vmpi/messbuf.h + ../vmpi/threadhelpers.h + ../vmpi/vmpi_defs.h + ../vmpi/vmpi_dispatch.h + ../vmpi/vmpi_distribute_work.h + ../vmpi/vmpi_filesystem.h + ) +endif() + +target_sources_grouped( + TARGET vrad_library + NAME "Public Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/BSPFILE.H + ${CMAKE_SOURCE_DIR}/public/BSPTreeData.h + ${CMAKE_SOURCE_DIR}/public/ChunkFile.h + ${CMAKE_SOURCE_DIR}/public/CollisionUtils.h + ${CMAKE_SOURCE_DIR}/public/DispColl_Common.h + ${CMAKE_SOURCE_DIR}/public/GameBSPFile.h + ${CMAKE_SOURCE_DIR}/public/ScratchPad3D.h + ${CMAKE_SOURCE_DIR}/public/ScratchPadUtils.h + ${CMAKE_SOURCE_DIR}/public/appframework/IAppSystem.h + ${CMAKE_SOURCE_DIR}/public/basehandle.h + ${CMAKE_SOURCE_DIR}/public/bitvec.h + ${CMAKE_SOURCE_DIR}/public/bspflags.h + ${CMAKE_SOURCE_DIR}/public/builddisp.h + ${CMAKE_SOURCE_DIR}/public/cmodel.h + ${CMAKE_SOURCE_DIR}/public/const.h + ${CMAKE_SOURCE_DIR}/public/coordsize.h + ${CMAKE_SOURCE_DIR}/public/disp_common.h + ${CMAKE_SOURCE_DIR}/public/disp_powerinfo.h + ${CMAKE_SOURCE_DIR}/public/disp_vertindex.h + ${CMAKE_SOURCE_DIR}/public/filesystem.h + ${CMAKE_SOURCE_DIR}/public/filesystem_helpers.h + ${CMAKE_SOURCE_DIR}/public/gametrace.h + ${CMAKE_SOURCE_DIR}/public/ihandleentity.h + ${CMAKE_SOURCE_DIR}/public/iscratchpad3d.h + ${CMAKE_SOURCE_DIR}/public/ivraddll.h + ${CMAKE_SOURCE_DIR}/public/materialsystem/hardwareverts.h + ${CMAKE_SOURCE_DIR}/public/materialsystem/imaterial.h + ${CMAKE_SOURCE_DIR}/public/materialsystem/imaterialsystem.h + ${CMAKE_SOURCE_DIR}/public/materialsystem/imaterialvar.h + ${CMAKE_SOURCE_DIR}/public/materialsystem/materialsystem_config.h + ${CMAKE_SOURCE_DIR}/public/mathlib/ANORMS.H + ${CMAKE_SOURCE_DIR}/public/mathlib/amd3dx.h + ${CMAKE_SOURCE_DIR}/public/mathlib/bumpvects.h + ${CMAKE_SOURCE_DIR}/public/mathlib/compressed_vector.h + ${CMAKE_SOURCE_DIR}/public/mathlib/halton.h + ${CMAKE_SOURCE_DIR}/public/mathlib/mathlib.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector2d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vector4d.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vmatrix.h + ${CMAKE_SOURCE_DIR}/public/mathlib/vplane.h + ${CMAKE_SOURCE_DIR}/public/optimize.h + ${CMAKE_SOURCE_DIR}/public/phyfile.h + ${CMAKE_SOURCE_DIR}/public/string_t.h + ${CMAKE_SOURCE_DIR}/public/studio.h + ${CMAKE_SOURCE_DIR}/public/tier0/basetypes.h + ${CMAKE_SOURCE_DIR}/public/tier0/commonmacros.h + ${CMAKE_SOURCE_DIR}/public/tier0/dbg.h + ${CMAKE_SOURCE_DIR}/public/tier0/fasttimer.h + ${CMAKE_SOURCE_DIR}/public/tier0/icommandline.h + ${CMAKE_SOURCE_DIR}/public/tier0/memdbgon.h + ${CMAKE_SOURCE_DIR}/public/tier0/platform.h + ${CMAKE_SOURCE_DIR}/public/tier0/protected_things.h + ${CMAKE_SOURCE_DIR}/public/tier0/vprof.h + ${CMAKE_SOURCE_DIR}/public/tier1/bitbuf.h + ${CMAKE_SOURCE_DIR}/public/tier1/byteswap.h + ${CMAKE_SOURCE_DIR}/public/tier1/characterset.h + ${CMAKE_SOURCE_DIR}/public/tier1/checksum_crc.h + ${CMAKE_SOURCE_DIR}/public/tier1/checksum_md5.h + ${CMAKE_SOURCE_DIR}/public/tier1/interface.h + ${CMAKE_SOURCE_DIR}/public/tier1/strtools.h + ${CMAKE_SOURCE_DIR}/public/tier1/tokenreader.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlbuffer.h + ${CMAKE_SOURCE_DIR}/public/tier1/utldict.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlhash.h + ${CMAKE_SOURCE_DIR}/public/tier1/utllinkedlist.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlmemory.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlrbtree.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlsymbol.h + ${CMAKE_SOURCE_DIR}/public/tier1/utlvector.h + ${CMAKE_SOURCE_DIR}/public/trace.h + ${CMAKE_SOURCE_DIR}/public/vcollide.h + ${CMAKE_SOURCE_DIR}/public/vphysics_interface.h + ${CMAKE_SOURCE_DIR}/public/vstdlib/random.h + ${CMAKE_SOURCE_DIR}/public/vstdlib/vstdlib.h + ${CMAKE_SOURCE_DIR}/public/vtf/vtf.h + ${CMAKE_SOURCE_DIR}/public/wadtypes.h + ${CMAKE_SOURCE_DIR}/public/worldsize.h + ../common/physdll.h +) diff --git a/src/utils/vrad/lightmap.cpp b/src/utils/vrad/lightmap.cpp index 0aaea29f41..be4a266cb5 100644 --- a/src/utils/vrad/lightmap.cpp +++ b/src/utils/vrad/lightmap.cpp @@ -938,15 +938,15 @@ int numdlights; FindTargetEntity ================== */ -entity_t *FindTargetEntity (char *target) +entity_t *FindTargetEntity (const char *target) { int i; - char *n; + const char *n; for (i=0 ; ilight.style = (int)FloatForKey (e, "style"); @@ -1462,7 +1460,7 @@ void BuildVisForLightEnvironment( void ) } } -static char *ValueForKeyWithDefault (entity_t *ent, char *key, char *default_value = NULL) +static char *ValueForKeyWithDefault (entity_t *ent, const char *key, char *default_value = NULL) { epair_t *ep; @@ -1544,7 +1542,7 @@ void CreateDirectLights (void) CPatch *p = NULL; directlight_t *dl = NULL; entity_t *e = NULL; - char *name; + const char *name; Vector dest; numdlights = 0; diff --git a/src/utils/vrad/macro_texture.cpp b/src/utils/vrad/macro_texture.cpp index cd0eac1233..1b1c964bec 100644 --- a/src/utils/vrad/macro_texture.cpp +++ b/src/utils/vrad/macro_texture.cpp @@ -86,7 +86,7 @@ void InitMacroTexture( const char *pBSPFilename ) int i = 0; for (i; i < num_entities; ++i) { - char* pEntity = ValueForKey(&entities[i], "classname"); + auto pEntity = ValueForKey(&entities[i], "classname"); if( !strcmp(pEntity, "worldspawn") ) { GetVectorForKey( &entities[i], "world_mins", g_MacroWorldMins ); diff --git a/src/utils/vrad/vrad.cpp b/src/utils/vrad/vrad.cpp index 241771524c..0956c905a9 100644 --- a/src/utils/vrad/vrad.cpp +++ b/src/utils/vrad/vrad.cpp @@ -363,7 +363,7 @@ MAKE FACES WindingFromFace ============= */ -winding_t *WindingFromFace (dface_t *f, Vector& origin ) +winding_t *WindingFromFace (dface_t *f, const Vector& origin ) { int i; int se; @@ -667,7 +667,7 @@ void MakePatchForFace (int fn, winding_t *w) entity_t *EntityForModel (int modnum) { int i; - char *s; + const char *s; char name[16]; sprintf (name, "*%i", modnum); @@ -1306,7 +1306,7 @@ void WriteWorld (char *name, int iBump) g_pFileSystem->Close( out ); } -void WriteRTEnv (char *name) +void WriteRTEnv (const char *name) { FileHandle_t out; diff --git a/src/utils/vrad/vrad.h b/src/utils/vrad/vrad.h index e741ee6b4d..58db17f0e7 100644 --- a/src/utils/vrad/vrad.h +++ b/src/utils/vrad/vrad.h @@ -397,7 +397,7 @@ void AddBrushesForRayTrace ( void ); void BaseLightForFace( dface_t *f, Vector& light, float *parea, Vector& reflectivity ); void CreateDirectLights (void); void GetPhongNormal( int facenum, Vector const& spot, Vector& phongnormal ); -int LightForString( char *pLight, Vector& intensity ); +int LightForString(const char *pLight, Vector& intensity ); void MakeTransfer( int ndxPatch1, int ndxPatch2, transfer_t *all_transfers ); void MakeScales( int ndxPatch, transfer_t *all_transfers ); @@ -416,7 +416,7 @@ bool RadWorld_Go(); dleaf_t *PointInLeaf (Vector const& point); int ClusterFromPoint( Vector const& point ); -winding_t *WindingFromFace (dface_t *f, Vector& origin ); +winding_t *WindingFromFace (dface_t *f, const Vector &origin ); void WriteWinding (FileHandle_t out, winding_t *w, Vector& color ); void WriteNormal( FileHandle_t out, Vector const &nPos, Vector const &nDir, diff --git a/src/utils/vrad/vraddll.cpp b/src/utils/vrad/vraddll.cpp index bc9f2f457a..1cc127a184 100644 --- a/src/utils/vrad/vraddll.cpp +++ b/src/utils/vrad/vraddll.cpp @@ -33,7 +33,7 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CVRadDLL, ILaunchableDLL, LAUNCHABLE_DLL_INTE class dat { public: - char *name; + const char *name; int size; }; #define DATENTRY(name) {#name, sizeof(name)} diff --git a/src/utils/vrad_launcher/CMakeLists.txt b/src/utils/vrad_launcher/CMakeLists.txt new file mode 100644 index 0000000000..1d149ee9fd --- /dev/null +++ b/src/utils/vrad_launcher/CMakeLists.txt @@ -0,0 +1,25 @@ +add_executable(vrad) + +target_link_libraries(vrad + PRIVATE + tier1::tier1 +) + +target_sources_grouped( + TARGET vrad + NAME "Source Files" + FILES + vrad_launcher.cpp + StdAfx.cpp +) + +target_sources_grouped( + TARGET vrad + NAME "Header Files" + FILES + ${CMAKE_SOURCE_DIR}/public/tier1/interface.h + ${CMAKE_SOURCE_DIR}/public/ivraddll.h + StdAfx.h +) + +target_precompile_headers(vvis PUBLIC StdAfx.h) diff --git a/src/utils/vrad_launcher/vrad_launcher.cpp b/src/utils/vrad_launcher/vrad_launcher.cpp index a4d3183423..a47483dd74 100644 --- a/src/utils/vrad_launcher/vrad_launcher.cpp +++ b/src/utils/vrad_launcher/vrad_launcher.cpp @@ -107,7 +107,7 @@ int main(int argc, char* argv[]) // If it didn't load the module above, then use the if ( !pModule ) { - strcpy( dllName, "vrad_dll.dll" ); + strcpy( dllName, "vrad_library.dll" ); pModule = Sys_LoadModule( dllName ); } @@ -120,7 +120,7 @@ int main(int argc, char* argv[]) CreateInterfaceFn fn = Sys_GetFactory( pModule ); if( !fn ) { - printf( "vrad_launcher error: can't get factory from vrad_dll.dll\n" ); + printf( "vrad_launcher error: can't get factory from vrad_library.dll\n" ); Sys_UnloadModule( pModule ); return 2; } @@ -129,7 +129,7 @@ int main(int argc, char* argv[]) IVRadDLL *pDLL = (IVRadDLL*)fn( VRAD_INTERFACE_VERSION, &retCode ); if( !pDLL ) { - printf( "vrad_launcher error: can't get IVRadDLL interface from vrad_dll.dll\n" ); + printf( "vrad_launcher error: can't get IVRadDLL interface from vrad_library.dll\n" ); Sys_UnloadModule( pModule ); return 3; } diff --git a/src/utils/vvis/CMakeLists.txt b/src/utils/vvis/CMakeLists.txt index d74f1a627f..ffb00d1066 100644 --- a/src/utils/vvis/CMakeLists.txt +++ b/src/utils/vvis/CMakeLists.txt @@ -32,7 +32,7 @@ if(OS_WINDOWS) vstdlib::vstdlib ) - if(DNEO_VMPI) + if(NEO_VMPI) target_link_libraries(vvis_library PRIVATE vmpi::vmpi @@ -74,7 +74,7 @@ target_sources_grouped( vvis.cpp ) -if(OS_WINDOWS AND DNEO_VMPI) +if(OS_WINDOWS AND NEO_VMPI) target_sources_grouped( TARGET vvis_library NAME "Source Files" From 469ea700afa3521fb2c1992b67afe345aa84f702 Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Tue, 12 Aug 2025 22:09:48 +0300 Subject: [PATCH 05/14] More utils changes --- src/CMakeLists.txt | 2 +- ...framework.cmake => FindAppFramework.cmake} | 0 src/cmake/FindVSTDLib.cmake | 5 +- src/fgdlib/CMakeLists.txt | 24 +- src/fgdlib/gamedata.cpp | 14 +- src/fgdlib/gdclass.cpp | 4 +- src/fgdlib/gdvar.cpp | 4 +- src/fgdlib/inputoutput.cpp | 2 +- src/fgdlib/wckeyvalues.cpp | 2 +- src/public/fgdlib/fgdlib.h | 4 +- src/public/fgdlib/gamedata.h | 4 +- src/public/fgdlib/inputoutput.h | 2 +- src/public/filesystem_init.cpp | 4 +- src/public/scratchpad3d.cpp | 5 - src/public/togl/linuxwin/glmdisplay.h | 2 +- src/public/togl/linuxwin/glmgrbasics.h | 2 +- src/thirdparty/CMakeLists.txt | 2 +- src/utils/CMakeLists.txt | 18 +- src/utils/common/cmdlib.cpp | 44 +-- src/utils/common/filesystem_tools.cpp | 2 + src/utils/common/mstristrip.cpp | 9 + src/utils/common/scriplib.cpp | 53 ++- src/utils/common/threads.cpp | 160 ++++----- src/utils/common/threads.h | 7 +- src/utils/common/tools_minidump.cpp | 12 +- src/utils/common/utilmatlib.cpp | 319 +++++++++++++++++- src/utils/common/vmpi_tools_shared.cpp | 2 +- src/utils/vbsp/CMakeLists.txt | 55 ++- src/utils/vbsp/brushbsp.cpp | 6 +- src/utils/vbsp/detailobjects.cpp | 13 +- src/utils/vbsp/leakfile.cpp | 2 +- src/utils/vbsp/manifest.cpp | 11 +- src/utils/vbsp/staticprop.cpp | 2 +- src/utils/vbsp/vbsp.cpp | 4 +- src/utils/vrad/vrad.cpp | 2 +- src/utils/vvis/vvis.cpp | 2 +- 36 files changed, 567 insertions(+), 238 deletions(-) rename src/cmake/{FindAppframework.cmake => FindAppFramework.cmake} (100%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index af7f79b5c9..579a3a2c3d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -633,7 +633,7 @@ if(NEO_EXTRA_ASSETS) endif() endif() -if(NEO_BUILD_UTILS AND OS_WINDOWS) +if(NEO_BUILD_UTILS) add_subdirectory(fgdlib) add_subdirectory(utils) endif() diff --git a/src/cmake/FindAppframework.cmake b/src/cmake/FindAppFramework.cmake similarity index 100% rename from src/cmake/FindAppframework.cmake rename to src/cmake/FindAppFramework.cmake diff --git a/src/cmake/FindVSTDLib.cmake b/src/cmake/FindVSTDLib.cmake index da03e490b5..1387ea47ce 100644 --- a/src/cmake/FindVSTDLib.cmake +++ b/src/cmake/FindVSTDLib.cmake @@ -38,4 +38,7 @@ elseif(OS_LINUX OR OS_MACOS) ) endif() -set_target_properties(vstdlib_vstdlib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/public/vstdlib") +target_include_directories(vstdlib_vstdlib + INTERFACE + "${CMAKE_SOURCE_DIR}/public/vstdlib" +) diff --git a/src/fgdlib/CMakeLists.txt b/src/fgdlib/CMakeLists.txt index 0d1c34744d..dcccc91027 100644 --- a/src/fgdlib/CMakeLists.txt +++ b/src/fgdlib/CMakeLists.txt @@ -9,16 +9,20 @@ target_include_directories(fgdlib ${CMAKE_SOURCE_DIR}/utils/common ) -target_compile_options(fgdlib - PRIVATE - /wd4091 - /wd4316 - /wd4355 - /wd4577 - /wd5033 - /wd5054 - /wd5055 -) +if(OS_WINDOWS) + target_compile_options(fgdlib + PRIVATE + /wd4091 + /wd4316 + /wd4355 + /wd4577 + /wd5033 + /wd5054 + /wd5055 + ) +elseif(OS_LINUX) + +endif() target_link_libraries(fgdlib PRIVATE diff --git a/src/fgdlib/gamedata.cpp b/src/fgdlib/gamedata.cpp index 0e33763e54..873fccce53 100644 --- a/src/fgdlib/gamedata.cpp +++ b/src/fgdlib/gamedata.cpp @@ -2,12 +2,15 @@ // //============================================================================= +#ifdef WIN32 #include -#include #include -#include -#include "fgdlib/GameData.h" -#include "fgdlib/HelperInfo.h" +#endif + +#include +#include +#include "fgdlib/gamedata.h" +#include "fgdlib/helperinfo.h" #include "KeyValues.h" #include "filesystem_tools.h" #include "tier1/strtools.h" @@ -24,6 +27,7 @@ const int MAX_ERRORS = 5; static GameDataMessageFunc_t g_pMsgFunc = NULL; +extern IFileSystem *g_pFullFileSystem; //----------------------------------------------------------------------------- // Sets the function used for emitting error messages while loading gamedata files. @@ -280,7 +284,7 @@ BOOL GameData::Load(const char *pszFilename) { TokenReader tr; - if(GetFileAttributes(pszFilename) == 0xffffffff) + if(!g_pFullFileSystem->FileExists( pszFilename )) // TODO check if works correctly return FALSE; if(!tr.Open(pszFilename)) diff --git a/src/fgdlib/gdclass.cpp b/src/fgdlib/gdclass.cpp index 1de57b6a7e..779d0b64f0 100644 --- a/src/fgdlib/gdclass.cpp +++ b/src/fgdlib/gdclass.cpp @@ -4,8 +4,8 @@ // //============================================================================= -#include "fgdlib/GameData.h" // FGDLIB: eliminate dependency -#include "fgdlib/GDClass.h" +#include "fgdlib/gamedata.h" // FGDLIB: eliminate dependency +#include "fgdlib/gdclass.h" // memdbgon must be the last include file in a .cpp file!!! #include diff --git a/src/fgdlib/gdvar.cpp b/src/fgdlib/gdvar.cpp index 9b24f421c5..8621d8c548 100644 --- a/src/fgdlib/gdvar.cpp +++ b/src/fgdlib/gdvar.cpp @@ -3,8 +3,8 @@ //============================================================================= #include "fgdlib/fgdlib.h" -#include "fgdlib/GameData.h" -#include "fgdlib/WCKeyValues.h" +#include "fgdlib/gamedata.h" +#include "fgdlib/wckeyvalues.h" #include "fgdlib/gdvar.h" #ifdef _WIN32 diff --git a/src/fgdlib/inputoutput.cpp b/src/fgdlib/inputoutput.cpp index 6e8c5dd3e8..2b9852f4ce 100644 --- a/src/fgdlib/inputoutput.cpp +++ b/src/fgdlib/inputoutput.cpp @@ -6,7 +6,7 @@ #include -#include "fgdlib/InputOutput.h" +#include "fgdlib/inputoutput.h" // memdbgon must be the last include file in a .cpp file!!! #include diff --git a/src/fgdlib/wckeyvalues.cpp b/src/fgdlib/wckeyvalues.cpp index bd9b1113e7..1509d4b8eb 100644 --- a/src/fgdlib/wckeyvalues.cpp +++ b/src/fgdlib/wckeyvalues.cpp @@ -4,7 +4,7 @@ // //============================================================================= -#include "fgdlib/WCKeyValues.h" +#include "fgdlib/wckeyvalues.h" #ifdef _WIN32 #define snprintf _snprintf diff --git a/src/public/fgdlib/fgdlib.h b/src/public/fgdlib/fgdlib.h index db7f06b8f9..c7856f28d4 100644 --- a/src/public/fgdlib/fgdlib.h +++ b/src/public/fgdlib/fgdlib.h @@ -12,7 +12,7 @@ #include "helperinfo.h" #include "gamedata.h" -#include "GDClass.h" -#include "InputOutput.h" +#include "gdclass.h" +#include "inputoutput.h" #endif // FGDLIB_H diff --git a/src/public/fgdlib/gamedata.h b/src/public/fgdlib/gamedata.h index 803fc92055..2881db33bc 100644 --- a/src/public/fgdlib/gamedata.h +++ b/src/public/fgdlib/gamedata.h @@ -16,8 +16,8 @@ #pragma warning(pop) #include "tokenreader.h" #include "gdclass.h" -#include "InputOutput.h" -#include "UtlString.h" +#include "inputoutput.h" +#include "utlstring.h" #include "utlvector.h" diff --git a/src/public/fgdlib/inputoutput.h b/src/public/fgdlib/inputoutput.h index b7fc4fa592..13a04b8583 100644 --- a/src/public/fgdlib/inputoutput.h +++ b/src/public/fgdlib/inputoutput.h @@ -10,7 +10,7 @@ #include -#include "fgdlib/EntityDefs.h" +#include "fgdlib/entitydefs.h" enum InputOutputType_t diff --git a/src/public/filesystem_init.cpp b/src/public/filesystem_init.cpp index 31374e0a84..92b6b5b254 100644 --- a/src/public/filesystem_init.cpp +++ b/src/public/filesystem_init.cpp @@ -1211,7 +1211,9 @@ void SetSteamAppUser( KeyValues *pSteamInfo, const char *steamInstallPath, CStea char fullFilename[MAX_PATH]; Q_strncpy( fullFilename, steamInstallPath, sizeof( fullFilename ) ); Q_AppendSlash( fullFilename, sizeof( fullFilename ) ); - Q_strncat( fullFilename, "config\\SteamAppData.vdf", sizeof( fullFilename ), COPY_ALL_CHARACTERS ); + Q_strncat( fullFilename, "config", sizeof( fullFilename ), COPY_ALL_CHARACTERS ); + Q_AppendSlash( fullFilename, sizeof( fullFilename ) ); + Q_strncat( fullFilename, "SteamAppData.vdf", sizeof( fullFilename ), COPY_ALL_CHARACTERS ); KeyValues *pSteamAppData = ReadKeyValuesFile( fullFilename ); if ( !pSteamAppData || (pTempAppUser = pSteamAppData->GetString( "AutoLoginUser", NULL )) == NULL ) diff --git a/src/public/scratchpad3d.cpp b/src/public/scratchpad3d.cpp index 6ca5973467..89c903b2fe 100644 --- a/src/public/scratchpad3d.cpp +++ b/src/public/scratchpad3d.cpp @@ -12,9 +12,6 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" -#ifndef POSIX -// NOTE - linux doesn't need any of this code! - extern "C" { extern void __stdcall Sleep( unsigned long ms ); @@ -631,5 +628,3 @@ IScratchPad3D* ScratchPad3D_Create( char const *pFilename ) CScratchPad3D *pRet = new CScratchPad3D( pFilename, pFileSystem, true ); return pRet; } -#endif // POSIX - diff --git a/src/public/togl/linuxwin/glmdisplay.h b/src/public/togl/linuxwin/glmdisplay.h index dfab74ca5b..6797a0c854 100644 --- a/src/public/togl/linuxwin/glmdisplay.h +++ b/src/public/togl/linuxwin/glmdisplay.h @@ -33,7 +33,7 @@ #pragma once #ifdef USE_SDL -#include "SDL_opengl.h" +#include "SDL2/SDL_opengl.h" #endif #ifdef OSX diff --git a/src/public/togl/linuxwin/glmgrbasics.h b/src/public/togl/linuxwin/glmgrbasics.h index 56eef65bb1..590fffb8ab 100644 --- a/src/public/togl/linuxwin/glmgrbasics.h +++ b/src/public/togl/linuxwin/glmgrbasics.h @@ -33,7 +33,7 @@ #pragma once #ifdef USE_SDL -#include "SDL_opengl.h" +#include "SDL2/SDL_opengl.h" #endif #ifdef OSX diff --git a/src/thirdparty/CMakeLists.txt b/src/thirdparty/CMakeLists.txt index 4281122ed7..cea9a230a6 100644 --- a/src/thirdparty/CMakeLists.txt +++ b/src/thirdparty/CMakeLists.txt @@ -1,4 +1,4 @@ -if(NEO_VMPI) +if(NEO_VMPI AND NEO_BUILD_UTILS AND OS_WINDOWS) set(BUILD_LIBCURL_DOCS OFF) set(BUILD_MISC_DOCS OFF) set(ENABLE_CURL_MANUAL OFF) diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index e4e256b869..0efa76cc46 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -1,12 +1,14 @@ +#set(CMAKE_SKIP_RPATH FALSE) + add_subdirectory(lzma) add_subdirectory(vbsp) -if(NEO_VMPI) - add_subdirectory(vmpi) -endif() +# if(NEO_VMPI) +# add_subdirectory(vmpi) +# endif() -add_subdirectory(vvis) -add_subdirectory(vvis_launcher) -add_subdirectory(vrad) -add_subdirectory(vrad_launcher) -add_subdirectory(vice) +# add_subdirectory(vvis) +# add_subdirectory(vvis_launcher) +# add_subdirectory(vrad) +# add_subdirectory(vrad_launcher) +# add_subdirectory(vice) diff --git a/src/utils/common/cmdlib.cpp b/src/utils/common/cmdlib.cpp index 645181128e..cda559b504 100644 --- a/src/utils/common/cmdlib.cpp +++ b/src/utils/common/cmdlib.cpp @@ -42,6 +42,8 @@ #include "xbox/xbox_win32stubs.h" #endif +#include + #include "tier0/memdbgon.h" // set these before calling CheckParm @@ -61,8 +63,6 @@ CUtlLinkedList g_ExtraSpewHooks; bool g_bStopOnExit = false; void (*g_ExtraSpewHook)(const char*) = NULL; -#if defined( _WIN32 ) || defined( WIN32 ) - void CmdLib_FPrintf( FileHandle_t hFile, const char *pFormat, ... ) { static CUtlVector buf; @@ -128,7 +128,7 @@ char* CmdLib_FGets( char *pOut, int outSize, FileHandle_t hFile ) return pOut; } -#if !defined( _X360 ) +#ifdef WIN32 #include #endif @@ -141,7 +141,11 @@ class CExitStopper if ( g_bStopOnExit ) { Warning( "\nPress any key to quit.\n" ); +#ifdef WIN32 getch(); +#else + getchar(); +#endif } } } g_ExitStopper; @@ -153,7 +157,7 @@ static unsigned short g_BadColor = 0xFFFF; static WORD g_BackgroundFlags = 0xFFFF; static void GetInitialColors( ) { -#if !defined( _X360 ) +#ifdef WIN32 // Get the old background attributes. CONSOLE_SCREEN_BUFFER_INFO oldInfo; GetConsoleScreenBufferInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &oldInfo ); @@ -175,8 +179,7 @@ static void GetInitialColors( ) WORD SetConsoleTextColor( int red, int green, int blue, int intensity ) { WORD ret = g_LastColor; -#if !defined( _X360 ) - +#ifdef WIN32 g_LastColor = 0; if( red ) g_LastColor |= FOREGROUND_RED; if( green ) g_LastColor |= FOREGROUND_GREEN; @@ -194,7 +197,7 @@ WORD SetConsoleTextColor( int red, int green, int blue, int intensity ) void RestoreConsoleTextColor( WORD color ) { -#if !defined( _X360 ) +#ifdef WIN32 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), color | g_BackgroundFlags ); g_LastColor = color; #endif @@ -216,23 +219,21 @@ void Error( char const *pMsg, ... ) #else -CRITICAL_SECTION g_SpewCS; -bool g_bSpewCSInitted = false; +std::mutex g_SpewCS; bool g_bSuppressPrintfOutput = false; -SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) +// TODO move to platform.h? +void OutputDebugString(char const *pMsg) { - // Hopefully two threads won't call this simultaneously right at the start! - if ( !g_bSpewCSInitted ) - { - InitializeCriticalSection( &g_SpewCS ); - g_bSpewCSInitted = true; - } + //printf("OutputDebugString: %s", pMsg); +} +SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) +{ WORD old; SpewRetval_t retVal; - EnterCriticalSection( &g_SpewCS ); + g_SpewCS.lock(); { if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG )) { @@ -317,11 +318,11 @@ SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) RestoreConsoleTextColor( old ); } - LeaveCriticalSection( &g_SpewCS ); + g_SpewCS.unlock(); if ( type == SPEW_ERROR ) { - CmdLib_Exit( 1 ); + CmdLib_Exit( EXIT_FAILURE ); } return retVal; @@ -366,7 +367,7 @@ void InstallAllocationFunctions() void SetSpewFunctionLogFile( char const *pFilename ) { Assert( (!g_pLogFile) ); - g_pLogFile = g_pFileSystem->Open( pFilename, "a" ); + g_pLogFile = g_pFileSystem->Open( pFilename, "w" ); Assert( g_pLogFile ); if (!g_pLogFile) @@ -413,14 +414,13 @@ void CmdLib_Cleanup() void CmdLib_Exit( int exitCode ) { - TerminateProcess( GetCurrentProcess(), 1 ); + std::exit(exitCode); } #endif -#endif diff --git a/src/utils/common/filesystem_tools.cpp b/src/utils/common/filesystem_tools.cpp index 9401c4ad69..d6da433613 100644 --- a/src/utils/common/filesystem_tools.cpp +++ b/src/utils/common/filesystem_tools.cpp @@ -62,7 +62,9 @@ void FileSystem_SetupStandardDirectories( const char *pFilename, const char *pGa Q_MakeAbsolutePath( qdir, sizeof( qdir ), pFilename, NULL ); Q_StripFilename( qdir ); +#ifdef WIN32 Q_strlower( qdir ); +#endif if ( qdir[0] != 0 ) { Q_AppendSlash( qdir, sizeof( qdir ) ); diff --git a/src/utils/common/mstristrip.cpp b/src/utils/common/mstristrip.cpp index 41b6efc51b..8d89ec5d04 100644 --- a/src/utils/common/mstristrip.cpp +++ b/src/utils/common/mstristrip.cpp @@ -24,11 +24,16 @@ #include #include #include +#include #include +#include + +#ifdef WIN32 #ifdef _DEBUG #include #endif +#endif #include "mstristrip.h" @@ -756,6 +761,7 @@ bool CVertCache::Add(int strip, int vertindex) } #ifdef _DEBUG +#ifdef WIN32 //========================================================================= // Turn on c runtime leak checking, etc. //========================================================================= @@ -789,6 +795,7 @@ void EnableLeakChecking() // _CrtSetBreakAlloc(0); } #endif +#endif //========================================================================= // Main Stripify routine @@ -799,7 +806,9 @@ int Stripify(int numtris, WORD *ptriangles, int *pnumindices, WORD **ppstripindi return 0; #ifdef _DEBUG +#ifdef WIN32 // EnableLeakChecking(); +#endif #endif CStripper stripper(numtris, (TRIANGLELIST)ptriangles); diff --git a/src/utils/common/scriplib.cpp b/src/utils/common/scriplib.cpp index ec15161a58..a805f0f91c 100644 --- a/src/utils/common/scriplib.cpp +++ b/src/utils/common/scriplib.cpp @@ -16,7 +16,6 @@ #include "xbox\xbox_win32stubs.h" #endif #if defined(POSIX) -#include "../../filesystem/linux_support.h" #include #endif /* @@ -1018,15 +1017,15 @@ bool CScriptLib::WriteBufferToFile( const char *pTargetName, CUtlBuffer &buffer, // create path // prime and skip to first seperator strcpy( dirPath, pTargetName ); - ptr = strchr( dirPath, '\\' ); + ptr = strchr( dirPath, CORRECT_PATH_SEPARATOR ); while ( ptr ) { - ptr = strchr( ptr+1, '\\' ); + ptr = strchr( ptr+1, CORRECT_PATH_SEPARATOR ); if ( ptr ) { *ptr = '\0'; _mkdir( dirPath ); - *ptr = '\\'; + *ptr = CORRECT_PATH_SEPARATOR; } } @@ -1155,16 +1154,16 @@ int CScriptLib::GetFileList( const char* pDirPath, const char* pPattern, CUtlVec int len = (int)strlen( sourcePath ); if ( !len ) { - strcpy( sourcePath, ".\\" ); + strcpy( sourcePath, "." CORRECT_PATH_SEPARATOR_S ); } - else if ( sourcePath[len-1] != '\\' ) + else if ( sourcePath[len-1] != CORRECT_PATH_SEPARATOR ) { - sourcePath[len] = '\\'; + sourcePath[len] = CORRECT_PATH_SEPARATOR; sourcePath[len+1] = '\0'; } strcpy( fullPath, sourcePath ); - if ( pPattern[0] == '\\' && pPattern[1] == '\0' ) + if ( pPattern[0] == CORRECT_PATH_SEPARATOR && pPattern[1] == '\0' ) { // find directories only bFindDirs = true; @@ -1219,39 +1218,26 @@ int CScriptLib::GetFileList( const char* pDirPath, const char* pPattern, CUtlVec _findclose( h ); #elif defined(POSIX) - FIND_DATA findData; Q_FixSlashes( fullPath ); - void *h = FindFirstFile( fullPath, &findData ); - if ( (intp)h == -1 ) - { - return 0; - } - do + FileFindHandle_t findHdl; + for (const char *pszFilename = g_pFullFileSystem->FindFirst(fullPath, &findHdl); + pszFilename; + pszFilename = g_pFullFileSystem->FindNext(findHdl)) { - // dos attribute complexities i.e. _A_NORMAL is 0 - if ( bFindDirs ) - { - // skip non dirs - if ( !( findData.dwFileAttributes & S_IFDIR ) ) - continue; - } - else - { - // skip dirs - if ( findData.dwFileAttributes & S_IFDIR ) - continue; - } + if (bFindDirs != g_pFullFileSystem->FindIsDirectory(findHdl)) + continue; - if ( !stricmp( findData.cFileName, "." ) ) + if ( !stricmp( pszFilename, "." ) ) // TODO check if needed continue; - if ( !stricmp( findData.cFileName, ".." ) ) + if ( !stricmp( pszFilename, ".." ) ) // TODO check if needed continue; + // TODO check if pszFilename is just a filename or a full path char fileName[MAX_PATH]; strcpy( fileName, sourcePath ); - strcat( fileName, findData.cFileName ); + strcat( fileName, pszFilename ); int j = fileList.AddToTail(); fileList[j].fileName.Set( fileName ); @@ -1265,9 +1251,8 @@ int CScriptLib::GetFileList( const char* pDirPath, const char* pPattern, CUtlVec else fileList[j].timeWrite = 0; } - while ( !FindNextFile( h, &findData ) ); - FindClose( h ); + g_pFullFileSystem->FindClose(findHdl); #else #error @@ -1284,7 +1269,7 @@ void CScriptLib::RecurseFileTree_r( const char* pDirPath, int depth, CUtlVector< { // recurse from source directory, get directories only CUtlVector< fileList_t > fileList; - int dirCount = GetFileList( pDirPath, "\\", fileList ); + int dirCount = GetFileList( pDirPath, CORRECT_PATH_SEPARATOR_S, fileList ); if ( !dirCount ) { // add directory name to search tree diff --git a/src/utils/common/threads.cpp b/src/utils/common/threads.cpp index 74e457a9ce..4cdee7da93 100644 --- a/src/utils/common/threads.cpp +++ b/src/utils/common/threads.cpp @@ -13,12 +13,19 @@ #define USED +#ifdef WIN32 #include +#endif + #include "cmdlib.h" #define NO_THREAD_NAMES #include "threads.h" #include "pacifier.h" +#include +#include +#include + #define MAX_THREADS 16 @@ -32,25 +39,22 @@ class CRunThreadsData CRunThreadsData g_RunThreadsData[MAX_THREADS]; +int dispatch; +int workcount; +qboolean pacifier; -int dispatch; -int workcount; -qboolean pacifier; - -qboolean threaded; +qboolean threaded; bool g_bLowPriorityThreads = false; -HANDLE g_ThreadHandles[MAX_THREADS]; - +std::vector g_ThreadHandles; +ThreadWorkerFn workfunction; -/* -============= -GetThreadWork +int numthreads = -1; +std::mutex crit; +static int enter; -============= -*/ -int GetThreadWork (void) +int GetThreadWork (void) { int r; @@ -71,12 +75,9 @@ int GetThreadWork (void) return r; } - -ThreadWorkerFn workfunction; - void ThreadWorkerFunction( int iThread, void *pUserData ) { - int work; + int work; while (1) { @@ -97,47 +98,21 @@ void RunThreadsOnIndividual (int workcnt, qboolean showpacifier, ThreadWorkerFn RunThreadsOn (workcnt, showpacifier, ThreadWorkerFunction); } - -/* -=================================================================== - -WIN32 - -=================================================================== -*/ - -int numthreads = -1; -CRITICAL_SECTION crit; -static int enter; - - -class CCritInit -{ -public: - CCritInit() - { - InitializeCriticalSection (&crit); - } -} g_CritInit; - - - void SetLowPriority() { +#ifdef WIN32 SetPriorityClass( GetCurrentProcess(), IDLE_PRIORITY_CLASS ); +#else + // TODO +#endif } void ThreadSetDefault (void) { - SYSTEM_INFO info; - - if (numthreads == -1) // not set manually + if (numthreads == -1) // not set manually { - GetSystemInfo (&info); - numthreads = info.dwNumberOfProcessors; - if (numthreads < 1 || numthreads > 32) - numthreads = 1; + numthreads = std::thread::hardware_concurrency(); } Msg ("%i threads\n", numthreads); @@ -148,7 +123,7 @@ void ThreadLock (void) { if (!threaded) return; - EnterCriticalSection (&crit); + crit.lock(); if (enter) Error ("Recursive ThreadLock\n"); enter = 1; @@ -161,18 +136,16 @@ void ThreadUnlock (void) if (!enter) Error ("ThreadUnlock without lock\n"); enter = 0; - LeaveCriticalSection (&crit); + crit.unlock(); } - // This runs in the thread and dispatches a RunThreadsFn call. -DWORD WINAPI InternalRunThreadsFn( LPVOID pParameter ) -{ - CRunThreadsData *pData = (CRunThreadsData*)pParameter; - pData->m_Fn( pData->m_iThread, pData->m_pUserData ); - return 0; -} - +// DWORD WINAPI InternalRunThreadsFn( LPVOID pParameter ) +// { +// CRunThreadsData *pData = (CRunThreadsData*)pParameter; +// pData->m_Fn( pData->m_iThread, pData->m_pUserData ); +// return 0; +// } void RunThreads_Start( RunThreadsFn fn, void *pUserData, ERunThreadsPriority ePriority ) { @@ -182,49 +155,50 @@ void RunThreads_Start( RunThreadsFn fn, void *pUserData, ERunThreadsPriority ePr if ( numthreads > MAX_TOOL_THREADS ) numthreads = MAX_TOOL_THREADS; - for ( int i=0; i < numthreads ;i++ ) + for ( int i = 0; i < numthreads; i++ ) { - g_RunThreadsData[i].m_iThread = i; - g_RunThreadsData[i].m_pUserData = pUserData; - g_RunThreadsData[i].m_Fn = fn; - - DWORD dwDummy; - g_ThreadHandles[i] = CreateThread( - NULL, // LPSECURITY_ATTRIBUTES lpsa, - 0, // DWORD cbStack, - InternalRunThreadsFn, // LPTHREAD_START_ROUTINE lpStartAddr, - &g_RunThreadsData[i], // LPVOID lpvThreadParm, - 0, // DWORD fdwCreate, - &dwDummy ); - - if ( ePriority == k_eRunThreadsPriority_UseGlobalState ) - { - if( g_bLowPriorityThreads ) - SetThreadPriority( g_ThreadHandles[i], THREAD_PRIORITY_LOWEST ); - } - else if ( ePriority == k_eRunThreadsPriority_Idle ) - { - SetThreadPriority( g_ThreadHandles[i], THREAD_PRIORITY_IDLE ); - } + // g_RunThreadsData[i].m_iThread = i; + // g_RunThreadsData[i].m_pUserData = pUserData; + // g_RunThreadsData[i].m_Fn = fn; + + // DWORD dwDummy; + // g_ThreadHandles[i] = CreateThread( + // NULL, // LPSECURITY_ATTRIBUTES lpsa, + // 0, // DWORD cbStack, + // InternalRunThreadsFn, // LPTHREAD_START_ROUTINE lpStartAddr, + // &g_RunThreadsData[i], // LPVOID lpvThreadParm, + // 0, // DWORD fdwCreate, + // &dwDummy ); + + // if ( ePriority == k_eRunThreadsPriority_UseGlobalState ) + // { + // if( g_bLowPriorityThreads ) + // SetThreadPriority( g_ThreadHandles[i], THREAD_PRIORITY_LOWEST ); + // } + // else if ( ePriority == k_eRunThreadsPriority_Idle ) + // { + // SetThreadPriority( g_ThreadHandles[i], THREAD_PRIORITY_IDLE ); + // } + + g_ThreadHandles.emplace_back(fn, i, pUserData); } } void RunThreads_End() { - WaitForMultipleObjects( numthreads, g_ThreadHandles, TRUE, INFINITE ); - for ( int i=0; i < numthreads; i++ ) - CloseHandle( g_ThreadHandles[i] ); + //WaitForMultipleObjects( numthreads, g_ThreadHandles, TRUE, INFINITE ); + for (auto& thread : g_ThreadHandles) + { + if (thread.joinable()) + { + thread.join(); + } + } threaded = false; } - -/* -============= -RunThreadsOn -============= -*/ void RunThreadsOn( int workcnt, qboolean showpacifier, RunThreadsFn fn, void *pUserData ) { int start, end; @@ -241,11 +215,9 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, RunThreadsFn fn, void *pU return; #endif - RunThreads_Start( fn, pUserData ); RunThreads_End(); - end = Plat_FloatTime(); if (pacifier) { @@ -253,5 +225,3 @@ void RunThreadsOn( int workcnt, qboolean showpacifier, RunThreadsFn fn, void *pU printf (" (%i)\n", end-start); } } - - diff --git a/src/utils/common/threads.h b/src/utils/common/threads.h index 0908b67ad0..78ca8012fd 100644 --- a/src/utils/common/threads.h +++ b/src/utils/common/threads.h @@ -13,16 +13,16 @@ #ifndef THREADS_H #define THREADS_H -#pragma once +#include "basetypes.h" // Arrays that are indexed by thread should always be MAX_TOOL_THREADS+1 // large so THREADINDEX_MAIN can be used from the main thread. -#define MAX_TOOL_THREADS 16 +#define MAX_TOOL_THREADS 32 #define THREADINDEX_MAIN (MAX_TOOL_THREADS) -extern int numthreads; +extern int numthreads; // If set to true, then all the threads that are created are low priority. extern bool g_bLowPriorityThreads; @@ -30,7 +30,6 @@ extern bool g_bLowPriorityThreads; typedef void (*ThreadWorkerFn)( int iThread, int iWorkItem ); typedef void (*RunThreadsFn)( int iThread, void *pUserData ); - enum ERunThreadsPriority { k_eRunThreadsPriority_UseGlobalState=0, // Default.. uses g_bLowPriorityThreads to decide what to set the priority to. diff --git a/src/utils/common/tools_minidump.cpp b/src/utils/common/tools_minidump.cpp index a7659200d5..d0c527f41a 100644 --- a/src/utils/common/tools_minidump.cpp +++ b/src/utils/common/tools_minidump.cpp @@ -5,8 +5,11 @@ // $NoKeywords: $ //=============================================================================// +#ifdef WIN32 #include #include +#endif + #include "tier0/minidump.h" #include "tools_minidump.h" @@ -18,6 +21,7 @@ static ToolsExceptionHandler g_pCustomExceptionHandler = NULL; // Internal helpers. // --------------------------------------------------------------------------------- // +#ifdef WIN32 static LONG __stdcall ToolsExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo ) { // Non VMPI workers write a minidump and show a crash dialog like normal. @@ -36,7 +40,7 @@ static LONG __stdcall ToolsExceptionFilter_Custom( struct _EXCEPTION_POINTERS *E g_pCustomExceptionHandler( ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo ); return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway) } - +#endif // --------------------------------------------------------------------------------- // // Interface functions. @@ -50,12 +54,18 @@ void EnableFullMinidumps( bool bFull ) void SetupDefaultToolsMinidumpHandler() { +#ifdef WIN32 SetUnhandledExceptionFilter( ToolsExceptionFilter ); +#endif } void SetupToolsMinidumpHandler( ToolsExceptionHandler fn ) { +#ifdef WIN32 g_pCustomExceptionHandler = fn; SetUnhandledExceptionFilter( ToolsExceptionFilter_Custom ); +#else + (void)fn; +#endif } diff --git a/src/utils/common/utilmatlib.cpp b/src/utils/common/utilmatlib.cpp index cca1757480..0e62999a44 100644 --- a/src/utils/common/utilmatlib.cpp +++ b/src/utils/common/utilmatlib.cpp @@ -20,38 +20,339 @@ #include "materialsystem/materialsystem_config.h" #include "mathlib/mathlib.h" +#if defined(POSIX) && defined(USE_SDL) +#include + +static CreateInterfaceFn g_fileSystemFactory; + +class FakeLauncherMgr : public ILauncherMgr +{ +public: + FakeLauncherMgr() + { + setbuf(stdout, NULL); + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual bool Connect( CreateInterfaceFn factory ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return true; + } + + virtual void Disconnect() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void *QueryInterface( const char *pInterfaceName ) + { + printf("%s\n", __PRETTY_FUNCTION__); + + if (V_strcmp(pInterfaceName, SDLMGR_INTERFACE_VERSION) == 0) + { + return this; + } + + return nullptr; + } + + virtual InitReturnVal_t Init() + { + printf("%s\n", __PRETTY_FUNCTION__); + //return (InitReturnVal_t) 0; + return INIT_OK; + } + + virtual void Shutdown() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual bool CreateGameWindow( const char *pTitle, bool bWindowed, int width, int height ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return true; + } + + virtual void IncWindowRefCount() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void DecWindowRefCount() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual int GetEvents( CCocoaEvent *pEvents, int nMaxEventsToReturn, bool debugEvents = false ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return 0; + } + +#ifdef LINUX + virtual int PeekAndRemoveKeyboardEvents( bool *pbEsc, bool *pbReturn, bool *pbSpace, bool debugEvents = false ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return 0; + } +#endif + + virtual void SetCursorPosition( int x, int y ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void SetWindowFullScreen( bool bFullScreen, int nWidth, int nHeight ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual bool IsWindowFullScreen() + { + printf("%s\n", __PRETTY_FUNCTION__); + return true; + } + + virtual void MoveWindow( int x, int y ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void SizeWindow( int width, int tall ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void PumpWindowsMessageLoop() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void DestroyGameWindow() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + virtual void SetApplicationIcon( const char *pchAppIconFile ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void GetMouseDelta( int &x, int &y, bool bIgnoreNextMouseDelta = false ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void GetNativeDisplayInfo( int nDisplay, uint &nWidth, uint &nHeight, uint &nRefreshHz ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void RenderedSize( uint &width, uint &height, bool set ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void DisplayedSize( uint &width, uint &height ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + +#if defined( DX_TO_GL_ABSTRACTION ) + virtual PseudoGLContextPtr GetMainContext() + { + printf("%s\n", __PRETTY_FUNCTION__); + return NULL; + } + + virtual PseudoGLContextPtr GetGLContextForWindow( void* windowref ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return NULL; + } + + virtual PseudoGLContextPtr CreateExtraContext() + { + printf("%s\n", __PRETTY_FUNCTION__); + return NULL; + } + + virtual void DeleteContext( PseudoGLContextPtr hContext ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual bool MakeContextCurrent( PseudoGLContextPtr hContext ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return true; + } + + virtual GLMDisplayDB *GetDisplayDB( void ) + { + printf("%s\n", __PRETTY_FUNCTION__); + return NULL; + } + + virtual void GetDesiredPixelFormatAttribsAndRendererInfo( uint **ptrOut, uint *countOut, GLMRendererInfoFields *rendInfoOut ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void ShowPixels( CShowPixelsParams *params ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } +#endif + + virtual void GetStackCrawl( CStackCrawlParams *params ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void WaitUntilUserInput( int msSleepTime ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void *GetWindowRef() + { + printf("%s\n", __PRETTY_FUNCTION__); + return NULL; + } + + virtual void SetMouseVisible( bool bState ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void SetMouseCursor( SDL_Cursor *hCursor ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void SetForbidMouseGrab( bool bForbidMouseGrab ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void OnFrameRendered() + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual void SetGammaRamp( const uint16 *pRed, const uint16 *pGreen, const uint16 *pBlue ) + { + printf("%s\n", __PRETTY_FUNCTION__); + } + + virtual double GetPrevGLSwapWindowTime() + { + printf("%s\n", __PRETTY_FUNCTION__); + return 0.0; + } + +} g_FakeLauncherMgr; + +#endif + +#ifdef USE_SDL +void* SDLMgrFactoryRedirector( const char *pName, int *pReturnCode ) +{ + printf("!!! SDLMgrFactoryRedirector pName=%s\n", pName); + + if (strcmp(SDLMGR_INTERFACE_VERSION, pName) == 0) + { + return &g_FakeLauncherMgr; + } + + return g_fileSystemFactory(pName, pReturnCode); + +} +#endif + void LoadMaterialSystemInterface( CreateInterfaceFn fileSystemFactory ) { if( g_pMaterialSystem ) return; + +#if defined(POSIX) && defined(USE_SDL) + // The materialsystem shared object currently asks our fileSystemFactory for + // the SDLMgrInterface001 interface, which it doesn't provide. After that, + // materialsystem self-destructs because it can't load our shaderapiempty + // shared object. However, materialsystem doesn't really need that interface + // so we'll simply set up a redirector that catches the request and returns + // a dummy object it won't really use. + g_fileSystemFactory = fileSystemFactory; + fileSystemFactory = SDLMgrFactoryRedirector; +#endif - // materialsystem.dll should be in the path, it's in bin along with vbsp. - const char *pDllName = "materialsystem.dll"; + // materialsystem library should be in the path, it's in bin along with vbsp. + +#ifdef WIN32 + const char *pMaterialSystemLibraryName = "materialsystem.dll"; +#else + const char *pMaterialSystemLibraryName = "materialsystem.so"; +#endif + CSysModule *materialSystemDLLHInst; - materialSystemDLLHInst = g_pFullFileSystem->LoadModule( pDllName ); + materialSystemDLLHInst = g_pFullFileSystem->LoadModule( pMaterialSystemLibraryName ); if( !materialSystemDLLHInst ) { - Error( "Can't load MaterialSystem.dll\n" ); + Error( "Can't load %s", pMaterialSystemLibraryName ); } CreateInterfaceFn clientFactory = Sys_GetFactory( materialSystemDLLHInst ); if ( clientFactory ) { - g_pMaterialSystem = (IMaterialSystem *)clientFactory( MATERIAL_SYSTEM_INTERFACE_VERSION, NULL ); + int pReturnCode; + g_pMaterialSystem = (IMaterialSystem *)clientFactory( MATERIAL_SYSTEM_INTERFACE_VERSION, &pReturnCode ); if ( !g_pMaterialSystem ) { - Error( "Could not get the material system interface from materialsystem.dll (" __FILE__ ")" ); + Error( "Could not get the material system interface from %s (" __FILE__ ")", pMaterialSystemLibraryName ); } + + // if ( !g_pMaterialSystemHardwareConfig ) + // { + // g_pMaterialSystemHardwareConfig = ( IMaterialSystemHardwareConfig * )clientFactory( MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, NULL ); + // if ( !g_pMaterialSystemHardwareConfig ) + // { + // Error( "Could not get the material system interface from %s (" __FILE__ ")", pMaterialSystemLibraryName ); + // } + // } + // else + // { + // Error("!!! g_pMaterialSystemHardwareConfig is not null"); + // } } else { - Error( "Could not find factory interface in library MaterialSystem.dll" ); + Error( "Could not find factory interface in library %s", pMaterialSystemLibraryName ); } - if (!g_pMaterialSystem->Init( "shaderapiempty.dll", 0, fileSystemFactory )) +#ifdef WIN32 + const char *pShaderApiEmptyLibraryName = "shaderapiempty.dll"; +#else + const char *pShaderApiEmptyLibraryName = "shaderapiempty.so"; // shaderapiempty shaderapivk shaderapidx9 +#endif + +#if 1 + //Warning("!!! g_pMaterialSystem->GetRenderBackend()=%s\n", GetRenderBackendName(g_pMaterialSystem->GetRenderBackend())); + + if (!g_pMaterialSystem->Init( pShaderApiEmptyLibraryName, 0, fileSystemFactory )) + { + Error( "Could not start the empty shader (%s)!", pShaderApiEmptyLibraryName ); + } +#else + g_pMaterialSystem->SetShaderAPI(pShaderApiEmptyLibraryName); + + + if (!g_pMaterialSystem->Init()) { - Error( "Could not start the empty shader (shaderapiempty.dll)!" ); + Error( "Could not start the empty shader (%s)!", pShaderApiEmptyLibraryName ); } +#endif } void InitMaterialSystem( const char *materialBaseDirPath, CreateInterfaceFn fileSystemFactory ) diff --git a/src/utils/common/vmpi_tools_shared.cpp b/src/utils/common/vmpi_tools_shared.cpp index 93050033e6..dd868913c4 100644 --- a/src/utils/common/vmpi_tools_shared.cpp +++ b/src/utils/common/vmpi_tools_shared.cpp @@ -85,7 +85,7 @@ bool SharedDispatch( MessageBuffer *pBuf, int iSource, int iPacketID ) if ( char *pch = strrchr( chModuleName, '.' ) ) *pch = 0; - if ( char *pch = strrchr( chModuleName, '\\' ) ) + if ( char *pch = strrchr( chModuleName, CORRECT_PATH_SEPARATOR ) ) *pch = 0, pModuleName = pch + 1; // Current time diff --git a/src/utils/vbsp/CMakeLists.txt b/src/utils/vbsp/CMakeLists.txt index e430f27213..58dc1608c2 100644 --- a/src/utils/vbsp/CMakeLists.txt +++ b/src/utils/vbsp/CMakeLists.txt @@ -1,3 +1,6 @@ +#add_compile_options(-fsanitize=address) +#add_link_options(-fsanitize=address) + add_executable(vbsp) target_include_directories(vbsp @@ -13,18 +16,18 @@ target_compile_definitions(vbsp PROTECTED_THINGS_DISABLE ) -target_compile_options(vbsp - PRIVATE - /wd4091 - /wd4316 - /wd4355 - /wd4577 - /wd5033 - /wd5054 - /wd5055 -) - if(OS_WINDOWS) + target_compile_options(vbsp + PRIVATE + /wd4091 + /wd4316 + /wd4355 + /wd4577 + /wd5033 + /wd5054 + /wd5055 + ) + target_link_libraries(vbsp PRIVATE ws2_32.lib @@ -32,15 +35,43 @@ if(OS_WINDOWS) odbccp32.lib winmm.lib ) +elseif(OS_LINUX) + target_compile_definitions(vbsp + PRIVATE + #GL_GLEXT_PROTOTYPES + #DX_TO_GL_ABSTRACTION + USE_SDL + ALLOW_NOSHADERAPI + ) + + # target_compile_options(vbsp + # PRIVATE + # -gdwarf-4 + # ) + + # set_target_properties(vbsp PROPERTIES + # #BUILD_RPATH "$ORIGIN" + # #BUILD_RPATH_USE_ORIGIN TRUE + + # #BUILD_WITH_INSTALL_RPATH TRUE + # ) + + # target_link_options(vbsp + # PRIVATE + # -Wl,--disable-new-dtags + # -Wl,-rpath,$ORIGIN + # -Wl,-z,origin + # #-Wl,-rpath=. + # ) endif() target_link_libraries(vbsp PRIVATE - bitmap::bitmap fgdlib::fgdlib mathlib::mathlib tier2::tier2 vtf::vtf + bitmap::bitmap lzma::lzma vstdlib::vstdlib ) diff --git a/src/utils/vbsp/brushbsp.cpp b/src/utils/vbsp/brushbsp.cpp index 13b7be6376..5ebcaa959e 100644 --- a/src/utils/vbsp/brushbsp.cpp +++ b/src/utils/vbsp/brushbsp.cpp @@ -394,10 +394,12 @@ bspbrush_t *CopyBrush (bspbrush_t *brush) int size; int i; - size = (int)&(((bspbrush_t *)0)->sides[brush->numsides]); + // TODO compare + size = (int)(std::ptrdiff_t)&(((bspbrush_t *)0)->sides[brush->numsides]); + size = offsetof(bspbrush_t, numsides) + sizeof(bspbrush_t::sides) * brush->numsides; newbrush = AllocBrush (brush->numsides); - memcpy (newbrush, brush, size); + memcpy ((void*)newbrush, brush, size); for (i=0 ; inumsides ; i++) { diff --git a/src/utils/vbsp/detailobjects.cpp b/src/utils/vbsp/detailobjects.cpp index 0d74915ba7..6ab9798c53 100644 --- a/src/utils/vbsp/detailobjects.cpp +++ b/src/utils/vbsp/detailobjects.cpp @@ -6,26 +6,29 @@ // $NoKeywords: $ //=============================================================================// +#ifdef WIN32 #include +#include +#endif + #include "vbsp.h" #include "bsplib.h" #include "KeyValues.h" #include "utlsymbol.h" #include "utlvector.h" -#include #include "bspfile.h" #include "utilmatlib.h" #include "gamebspfile.h" -#include "mathlib/VMatrix.h" +#include "mathlib/vmatrix.h" #include "materialpatch.h" #include "pacifier.h" #include "vstdlib/random.h" #include "builddisp.h" #include "disp_vbsp.h" -#include "UtlBuffer.h" -#include "CollisionUtils.h" +#include "utlbuffer.h" +#include "collisionutils.h" #include -#include "UtlLinkedList.h" +#include "utllinkedlist.h" #include "byteswap.h" #include "writebsp.h" diff --git a/src/utils/vbsp/leakfile.cpp b/src/utils/vbsp/leakfile.cpp index d6038830f0..ed37d64b48 100644 --- a/src/utils/vbsp/leakfile.cpp +++ b/src/utils/vbsp/leakfile.cpp @@ -7,7 +7,7 @@ //=============================================================================// #include "vbsp.h" -#include "color.h" +#include "Color.h" /* ============================================================================== diff --git a/src/utils/vbsp/manifest.cpp b/src/utils/vbsp/manifest.cpp index c2ccfb1d15..da06f048ca 100644 --- a/src/utils/vbsp/manifest.cpp +++ b/src/utils/vbsp/manifest.cpp @@ -3,7 +3,10 @@ #include "map_shared.h" #include "fgdlib/fgdlib.h" #include "manifest.h" -#include "windows.h" + +#ifdef WIN32 +#include +#endif //----------------------------------------------------------------------------- // Purpose: default constructor @@ -355,10 +358,14 @@ bool CManifest::LoadSubMaps( CMapFile *pMapFile, const char *pszFileName ) bool CManifest::LoadVMFManifestUserPrefs( const char *pszFileName ) { char UserName[ MAX_PATH ], FileName[ MAX_PATH ], UserPrefsFileName[ MAX_PATH ]; - DWORD UserNameSize; +#ifdef WIN32 + DWORD UserNameSize; UserNameSize = sizeof( UserName ); if ( GetUserName( UserName, &UserNameSize ) == 0 ) +#else + if ( getlogin_r(UserName, sizeof(UserName)) != 0 ) +#endif { strcpy( UserPrefsFileName, "default" ); } diff --git a/src/utils/vbsp/staticprop.cpp b/src/utils/vbsp/staticprop.cpp index b00c37a42b..d2dd334107 100644 --- a/src/utils/vbsp/staticprop.cpp +++ b/src/utils/vbsp/staticprop.cpp @@ -247,7 +247,7 @@ static CPhysCollide* GetCollisionModel( char const* pModelName ) // Convert to a common string char* pTemp = (char*)_alloca(strlen(pModelName) + 1); strcpy( pTemp, pModelName ); - _strlwr( pTemp ); + strlwr( pTemp ); char* pSlash = strchr( pTemp, '\\' ); while( pSlash ) diff --git a/src/utils/vbsp/vbsp.cpp b/src/utils/vbsp/vbsp.cpp index 0d44a365a1..4cbedde254 100644 --- a/src/utils/vbsp/vbsp.cpp +++ b/src/utils/vbsp/vbsp.cpp @@ -1241,7 +1241,7 @@ int RunVBSP( int argc, char **argv ) DeleteCmdLine( argc, argv ); CmdLib_Cleanup(); - CmdLib_Exit( 1 ); + CmdLib_Exit( EXIT_FAILURE ); } // Sanity check @@ -1252,7 +1252,7 @@ int RunVBSP( int argc, char **argv ) "Use the bspzip utility to update embedded files.\n" ); DeleteCmdLine( argc, argv ); CmdLib_Cleanup(); - CmdLib_Exit( 1 ); + CmdLib_Exit( EXIT_FAILURE ); } start = Plat_FloatTime(); diff --git a/src/utils/vrad/vrad.cpp b/src/utils/vrad/vrad.cpp index 0956c905a9..bb477058a8 100644 --- a/src/utils/vrad/vrad.cpp +++ b/src/utils/vrad/vrad.cpp @@ -2925,7 +2925,7 @@ int RunVRAD( int argc, char **argv ) { PrintUsage( argc, argv ); DeleteCmdLine( argc, argv ); - CmdLib_Exit( 1 ); + CmdLib_Exit( EXIT_FAILURE ); } // Initialize the filesystem, so additional commandline options can be loaded diff --git a/src/utils/vvis/vvis.cpp b/src/utils/vvis/vvis.cpp index 131fab764d..84623e10f5 100644 --- a/src/utils/vvis/vvis.cpp +++ b/src/utils/vvis/vvis.cpp @@ -1099,7 +1099,7 @@ int RunVVis( int argc, char **argv ) { PrintUsage( argc, argv ); DeleteCmdLine( argc, argv ); - CmdLib_Exit( 1 ); + CmdLib_Exit( EXIT_FAILURE ); } CmdLib_InitFileSystem( argv[ argc - 1 ] ); From 13f81c1f592da961a66e58b76261ddea808c172d Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Tue, 10 Feb 2026 00:32:54 +0300 Subject: [PATCH 06/14] Fix warnings --- src/public/builddisp.cpp | 72 ++++++++++++++++++------------------- src/utils/vbsp/boundbox.h | 4 +-- src/utils/vbsp/cubemap.cpp | 10 +++--- src/utils/vbsp/faces.cpp | 4 +-- src/utils/vbsp/leakfile.cpp | 4 +-- src/utils/vbsp/manifest.cpp | 8 ++--- src/utils/vbsp/portals.cpp | 4 +-- src/utils/vbsp/prtfile.cpp | 2 +- src/utils/vbsp/textures.cpp | 2 +- src/utils/vbsp/vbsp.cpp | 8 ++--- src/utils/vbsp/writebsp.cpp | 6 ++-- 11 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/public/builddisp.cpp b/src/public/builddisp.cpp index 3cce06dc67..74b005f8db 100644 --- a/src/public/builddisp.cpp +++ b/src/public/builddisp.cpp @@ -1299,8 +1299,8 @@ float CCoreDispInfo::GetMaxErrorFromChildren( int nodeIndex, int level ) //----------------------------------------------------------------------------- void CCoreDispInfo::CalcErrorTermAtNode( int nodeIndex, int level ) { - if( level == m_Power ) - return; + if( level == m_Power ) + return; // // get the vertex indices @@ -1319,40 +1319,40 @@ void CCoreDispInfo::CalcErrorTermAtNode( int nodeIndex, int level ) Vector segment; Vector v; - VectorAdd( m_pVerts[neighborVertIndices[5]].m_Vert, m_pVerts[neighborVertIndices[4]].m_Vert, v ); - VectorScale( v, 0.5f, v ); - VectorSubtract( m_pVerts[neighborVertIndices[0]].m_Vert, v, segment ); - float errorTerm = ( float )VectorLength( segment ); - - VectorAdd( m_pVerts[neighborVertIndices[5]].m_Vert, m_pVerts[neighborVertIndices[6]].m_Vert, v ); - VectorScale( v, 0.5f, v ); - VectorSubtract( m_pVerts[neighborVertIndices[1]].m_Vert, v, segment ); - if( errorTerm < ( float )VectorLength( segment ) ) - errorTerm = ( float )VectorLength( segment ); - - VectorAdd( m_pVerts[neighborVertIndices[6]].m_Vert, m_pVerts[neighborVertIndices[7]].m_Vert, v ); - VectorScale( v, 0.5f, v ); - VectorSubtract( m_pVerts[neighborVertIndices[2]].m_Vert, v, segment ); - if( errorTerm < ( float )VectorLength( segment ) ) - errorTerm = ( float )VectorLength( segment ); - - VectorAdd( m_pVerts[neighborVertIndices[7]].m_Vert, m_pVerts[neighborVertIndices[4]].m_Vert, v ); - VectorScale( v, 0.5f, v ); - VectorSubtract( m_pVerts[neighborVertIndices[3]].m_Vert, v, segment ); - if( errorTerm < ( float )VectorLength( segment ) ) - errorTerm = ( float )VectorLength( segment ); - - VectorAdd( m_pVerts[neighborVertIndices[4]].m_Vert, m_pVerts[neighborVertIndices[6]].m_Vert, v ); - VectorScale( v, 0.5f, v ); - VectorSubtract( m_pVerts[neighborVertIndices[8]].m_Vert, v, segment ); - if( errorTerm < ( float )VectorLength( segment ) ) - errorTerm = ( float )VectorLength( segment ); - - VectorAdd( m_pVerts[neighborVertIndices[5]].m_Vert, m_pVerts[neighborVertIndices[7]].m_Vert, v ); - VectorScale( v, 0.5f, v ); - VectorSubtract( m_pVerts[neighborVertIndices[8]].m_Vert, v, segment ); - if( errorTerm < ( float )VectorLength( segment ) ) - errorTerm = ( float )VectorLength( segment ); + VectorAdd( m_pVerts[neighborVertIndices[5]].m_Vert, m_pVerts[neighborVertIndices[4]].m_Vert, v ); + VectorScale( v, 0.5f, v ); + VectorSubtract( m_pVerts[neighborVertIndices[0]].m_Vert, v, segment ); + float errorTerm = ( float )VectorLength( segment ); + + VectorAdd( m_pVerts[neighborVertIndices[5]].m_Vert, m_pVerts[neighborVertIndices[6]].m_Vert, v ); + VectorScale( v, 0.5f, v ); + VectorSubtract( m_pVerts[neighborVertIndices[1]].m_Vert, v, segment ); + if( errorTerm < ( float )VectorLength( segment ) ) + errorTerm = ( float )VectorLength( segment ); + + VectorAdd( m_pVerts[neighborVertIndices[6]].m_Vert, m_pVerts[neighborVertIndices[7]].m_Vert, v ); + VectorScale( v, 0.5f, v ); + VectorSubtract( m_pVerts[neighborVertIndices[2]].m_Vert, v, segment ); + if( errorTerm < ( float )VectorLength( segment ) ) + errorTerm = ( float )VectorLength( segment ); + + VectorAdd( m_pVerts[neighborVertIndices[7]].m_Vert, m_pVerts[neighborVertIndices[4]].m_Vert, v ); + VectorScale( v, 0.5f, v ); + VectorSubtract( m_pVerts[neighborVertIndices[3]].m_Vert, v, segment ); + if( errorTerm < ( float )VectorLength( segment ) ) + errorTerm = ( float )VectorLength( segment ); + + VectorAdd( m_pVerts[neighborVertIndices[4]].m_Vert, m_pVerts[neighborVertIndices[6]].m_Vert, v ); + VectorScale( v, 0.5f, v ); + VectorSubtract( m_pVerts[neighborVertIndices[8]].m_Vert, v, segment ); + if( errorTerm < ( float )VectorLength( segment ) ) + errorTerm = ( float )VectorLength( segment ); + + VectorAdd( m_pVerts[neighborVertIndices[5]].m_Vert, m_pVerts[neighborVertIndices[7]].m_Vert, v ); + VectorScale( v, 0.5f, v ); + VectorSubtract( m_pVerts[neighborVertIndices[8]].m_Vert, v, segment ); + if( errorTerm < ( float )VectorLength( segment ) ) + errorTerm = ( float )VectorLength( segment ); // // add the max child's error term diff --git a/src/utils/vbsp/boundbox.h b/src/utils/vbsp/boundbox.h index 4720a40e27..80e04f6cec 100644 --- a/src/utils/vbsp/boundbox.h +++ b/src/utils/vbsp/boundbox.h @@ -23,7 +23,7 @@ enum AXIS_Z }; -class BoundBox +class BoundBox final { public: @@ -39,7 +39,7 @@ class BoundBox void GetBoundsCenter(Vector& ptdest); inline void GetBounds(Vector& Mins, Vector& Maxs); - virtual bool IsIntersectingBox(const Vector& pfMins, const Vector& pfMaxs) const; + bool IsIntersectingBox(const Vector& pfMins, const Vector& pfMaxs) const; bool IsInsideBox(const Vector& pfMins, const Vector& pfMaxs) const; bool ContainsPoint(const Vector& pt) const; bool IsValidBox(void) const; diff --git a/src/utils/vbsp/cubemap.cpp b/src/utils/vbsp/cubemap.cpp index 1cce5dc6da..7c28c0b05b 100644 --- a/src/utils/vbsp/cubemap.cpp +++ b/src/utils/vbsp/cubemap.cpp @@ -286,12 +286,8 @@ void CreateDefaultCubemaps( bool bHDR ) // NOTE: This implementation depends on the fact that all VTF files contain // all mipmap levels const char *pSkyboxBaseName = FindSkyboxMaterialName(); - char skyboxMaterialName[MAX_PATH]; - Q_snprintf( skyboxMaterialName, MAX_PATH, "skybox/%s", pSkyboxBaseName ); - - IVTFTexture *pSrcVTFTextures[6]; - if( !skyboxMaterialName ) + if( !pSkyboxBaseName ) { if( s_DefaultCubemapNames.Count() ) { @@ -300,6 +296,10 @@ void CreateDefaultCubemaps( bool bHDR ) return; } + char skyboxMaterialName[MAX_PATH]; + Q_snprintf( skyboxMaterialName, MAX_PATH, "skybox/%s", pSkyboxBaseName ); + + IVTFTexture *pSrcVTFTextures[6]; int unionTextureFlags = 0; if( !LoadSrcVTFFiles( pSrcVTFTextures, skyboxMaterialName, &unionTextureFlags, bHDR ) ) { diff --git a/src/utils/vbsp/faces.cpp b/src/utils/vbsp/faces.cpp index f6ec3ee311..596149b9df 100644 --- a/src/utils/vbsp/faces.cpp +++ b/src/utils/vbsp/faces.cpp @@ -1096,8 +1096,8 @@ face_t *TryMerge (face_t *f1, face_t *f2, Vector& planenormal) return NULL; if (f1->contents != f2->contents) return NULL; - if ( f1->originalface->smoothingGroups != f2->originalface->smoothingGroups ) - return NULL; + if ( f1->originalface->smoothingGroups != f2->originalface->smoothingGroups ) + return NULL; if ( !OverlaysAreEqual( f1, f2 ) ) return NULL; if ( nomergewater && ( FaceOnWaterBrush( f1 ) || FaceOnWaterBrush( f2 ) ) ) diff --git a/src/utils/vbsp/leakfile.cpp b/src/utils/vbsp/leakfile.cpp index ed37d64b48..10744322cf 100644 --- a/src/utils/vbsp/leakfile.cpp +++ b/src/utils/vbsp/leakfile.cpp @@ -32,7 +32,7 @@ void LeakFile (tree_t *tree) { Vector mid; FILE *linefile; - char filename[1024]; + char filename[1024 + 4]; node_t *node; int count; @@ -96,7 +96,7 @@ void AreaportalLeakFile( tree_t *tree, portal_t *pStartPortal, portal_t *pEndPor { Vector mid; FILE *linefile; - char filename[1024]; + char filename[1024 + 4]; node_t *node; int count; diff --git a/src/utils/vbsp/manifest.cpp b/src/utils/vbsp/manifest.cpp index da06f048ca..5dac521354 100644 --- a/src/utils/vbsp/manifest.cpp +++ b/src/utils/vbsp/manifest.cpp @@ -309,9 +309,9 @@ bool CManifest::LoadSubMaps( CMapFile *pMapFile, const char *pszFileName ) { // if ( m_Maps[ i ]->m_bTopLevelMap == false ) { - char FileName[ MAX_PATH ]; + //char FileName[ MAX_PATH ]; - sprintf( FileName, "%s%s", m_InstancePath, m_Maps[ i ]->m_RelativeMapFileName ); + //snprintf( FileName, sizeof(FileName), "%s%s", m_InstancePath, m_Maps[ i ]->m_RelativeMapFileName ); InstanceEntity = &pMapFile->entities[ pMapFile->num_entities ]; pMapFile->num_entities++; @@ -357,7 +357,7 @@ bool CManifest::LoadSubMaps( CMapFile *pMapFile, const char *pszFileName ) //----------------------------------------------------------------------------- bool CManifest::LoadVMFManifestUserPrefs( const char *pszFileName ) { - char UserName[ MAX_PATH ], FileName[ MAX_PATH ], UserPrefsFileName[ MAX_PATH ]; + char UserName[ MAX_PATH - 12 ], FileName[ MAX_PATH ], UserPrefsFileName[ MAX_PATH ]; #ifdef WIN32 DWORD UserNameSize; @@ -370,7 +370,7 @@ bool CManifest::LoadVMFManifestUserPrefs( const char *pszFileName ) strcpy( UserPrefsFileName, "default" ); } - sprintf( UserPrefsFileName, "\\%s.vmm_prefs", UserName ); + snprintf( UserPrefsFileName, sizeof(UserPrefsFileName), "\\%s.vmm_prefs", UserName ); V_StripExtension( pszFileName, FileName, sizeof( FileName ) ); strcat( FileName, UserPrefsFileName ); diff --git a/src/utils/vbsp/portals.cpp b/src/utils/vbsp/portals.cpp index 7f44c873ef..50db99adb7 100644 --- a/src/utils/vbsp/portals.cpp +++ b/src/utils/vbsp/portals.cpp @@ -1177,8 +1177,8 @@ void FindPortalsLeadingToArea_R( if( !p->nodes[0]->occupied || !p->nodes[1]->occupied ) continue; - if( p->nodes[1]->area == iDestArea && p->nodes[0]->area == iSrcArea || - p->nodes[0]->area == iDestArea && p->nodes[1]->area == iSrcArea ) + if( (p->nodes[1]->area == iDestArea && p->nodes[0]->area == iSrcArea) || + (p->nodes[0]->area == iDestArea && p->nodes[1]->area == iSrcArea) ) { // Make sure the plane normals point the same way. plane_t *pMapPlane = &g_MainMap->mapplanes[p->onnode->planenum]; diff --git a/src/utils/vbsp/prtfile.cpp b/src/utils/vbsp/prtfile.cpp index 71d7e5cc3a..dc396c353d 100644 --- a/src/utils/vbsp/prtfile.cpp +++ b/src/utils/vbsp/prtfile.cpp @@ -322,7 +322,7 @@ WritePortalFile */ void WritePortalFile (tree_t *tree) { - char filename[1024]; + char filename[1024 + 4]; node_t *headnode; int start = Plat_FloatTime(); diff --git a/src/utils/vbsp/textures.cpp b/src/utils/vbsp/textures.cpp index 4f49c5d475..8f4c42ad91 100644 --- a/src/utils/vbsp/textures.cpp +++ b/src/utils/vbsp/textures.cpp @@ -251,7 +251,7 @@ int FindMiptex (const char *name) g_bHasWater = true; } const char *pShaderName = GetMaterialShaderName(matID); - if ( !bKeepLighting && !Q_strncasecmp( pShaderName, "water", 5 ) || !Q_strncasecmp( pShaderName, "UnlitGeneric", 12 ) ) + if ( (!bKeepLighting && !Q_strncasecmp( pShaderName, "water", 5 )) || !Q_strncasecmp( pShaderName, "UnlitGeneric", 12 ) ) { //if ( !(textureref[i].flags & SURF_NOLIGHT) ) // Warning("Forcing lit materal %s to nolight\n", name ); diff --git a/src/utils/vbsp/vbsp.cpp b/src/utils/vbsp/vbsp.cpp index 4cbedde254..ced12b2713 100644 --- a/src/utils/vbsp/vbsp.cpp +++ b/src/utils/vbsp/vbsp.cpp @@ -25,7 +25,7 @@ extern float g_maxLightmapDimension; char source[1024]; char mapbase[ 64 ]; char name[1024]; -char materialPath[1024]; +char materialPath[1024 + 16]; vec_t microvolume = 1.0; qboolean noprune; @@ -885,7 +885,7 @@ int RunVBSP( int argc, char **argv ) { int i; double start, end; - char path[1024]; + char path[1024 + 4]; CommandLine()->CreateCmdLine( argc, argv ); MathLib_Init( 2.2f, 2.2f, 0.0f, OVERBRIGHT, false, false, false, false ); @@ -1280,7 +1280,7 @@ int RunVBSP( int argc, char **argv ) numthreads = 1; // multiple threads aren't helping... // Setup the logfile. - char logFile[512]; + char logFile[sizeof(source) + 4]; _snprintf( logFile, sizeof(logFile), "%s.log", source ); SetSpewFunctionLogFile( logFile ); @@ -1293,7 +1293,7 @@ int RunVBSP( int argc, char **argv ) Msg( "basegamedir: %s This is the base engine + base game directory (e.g. e:/hl2/hl2/, or d:/tf2/tf2/ )\n", basegamedir ); #endif - sprintf( materialPath, "%smaterials", gamedir ); + snprintf( materialPath, sizeof(materialPath), "%smaterials", gamedir ); InitMaterialSystem( materialPath, CmdLib_GetFileSystemFactory() ); Msg( "materialPath: %s\n", materialPath ); diff --git a/src/utils/vbsp/writebsp.cpp b/src/utils/vbsp/writebsp.cpp index 4d5663ae7f..bac1b2bd54 100644 --- a/src/utils/vbsp/writebsp.cpp +++ b/src/utils/vbsp/writebsp.cpp @@ -966,7 +966,7 @@ void SetModelNumbers (void) } else { - sprintf (value, ""); + //sprintf (value, ""); } SetKeyValue (&entities[i], "model", value); } @@ -984,7 +984,7 @@ void SetLightStyles (void) int stylenum; entity_t *e; int i, j; - char value[10]; + char value[12]; char lighttargets[MAX_SWITCHED_LIGHTS][64]; @@ -1019,7 +1019,7 @@ void SetLightStyles (void) strcpy (lighttargets[j], t); stylenum++; } - sprintf (value, "%i", 32 + j); + snprintf (value, sizeof(value), "%i", 32 + j); auto pCurrentStyle = ValueForKey( e, "style" ); // the designer has set a default lightstyle as well as making the light switchable if ( pCurrentStyle ) From f8d611ad58ab053170dc7848036b212c6c47fe4c Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Sun, 21 Jun 2026 17:03:31 +0300 Subject: [PATCH 07/14] Fix some bugs in vbsp --- src/mathlib/CMakeLists.txt | 26 ++++++++++++++++++++++++++ src/tier1/CMakeLists.txt | 1 + src/utils/common/utilmatlib.cpp | 9 +++++++++ src/utils/vbsp/CMakeLists.txt | 6 +++++- src/utils/vbsp/brushbsp.cpp | 4 +--- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/src/mathlib/CMakeLists.txt b/src/mathlib/CMakeLists.txt index c37a61f4b9..7018eae9ca 100644 --- a/src/mathlib/CMakeLists.txt +++ b/src/mathlib/CMakeLists.txt @@ -34,6 +34,32 @@ elseif(OS_LINUX) ) endif() +set(UNITY_SOURCE_MATHLIB + color_conversion.cpp + halton.cpp + lightdesc.cpp + mathlib_base.cpp + powsse.cpp + sparse_convolution_noise.cpp + sseconst.cpp + sse.cpp + ssenoise.cpp + anorms.cpp + bumpvects.cpp + IceKey.cpp + polyhedron.cpp + randsse.cpp + spherical.cpp + simdvectormatrix.cpp + vmatrix.cpp + almostequal.cpp +) + +set_source_files_properties( + ${UNITY_SOURCE_MATHLIB} + PROPERTIES UNITY_GROUP mathlib +) + target_sources_grouped( TARGET mathlib NAME "Source Files" diff --git a/src/tier1/CMakeLists.txt b/src/tier1/CMakeLists.txt index 30338bcb47..b311f01d99 100644 --- a/src/tier1/CMakeLists.txt +++ b/src/tier1/CMakeLists.txt @@ -53,6 +53,7 @@ endif() target_link_libraries(tier1 PUBLIC + vstdlib::vstdlib tier0::tier0 ) diff --git a/src/utils/common/utilmatlib.cpp b/src/utils/common/utilmatlib.cpp index 0e62999a44..7a4f169fdd 100644 --- a/src/utils/common/utilmatlib.cpp +++ b/src/utils/common/utilmatlib.cpp @@ -267,6 +267,15 @@ void* SDLMgrFactoryRedirector( const char *pName, int *pReturnCode ) return &g_FakeLauncherMgr; } + // materialsystem.so's Connect() resolves its own interface from the factory + // we pass to Init(). Our fileSystemFactory doesn't know about it, so hand + // back the material system pointer we already obtained above; otherwise + // materialsystem caches a NULL self-pointer and crashes dereferencing it. + if (strcmp(MATERIAL_SYSTEM_INTERFACE_VERSION, pName) == 0) + { + return g_pMaterialSystem; + } + return g_fileSystemFactory(pName, pReturnCode); } diff --git a/src/utils/vbsp/CMakeLists.txt b/src/utils/vbsp/CMakeLists.txt index 58dc1608c2..237957bb57 100644 --- a/src/utils/vbsp/CMakeLists.txt +++ b/src/utils/vbsp/CMakeLists.txt @@ -39,7 +39,7 @@ elseif(OS_LINUX) target_compile_definitions(vbsp PRIVATE #GL_GLEXT_PROTOTYPES - #DX_TO_GL_ABSTRACTION + DX_TO_GL_ABSTRACTION USE_SDL ALLOW_NOSHADERAPI ) @@ -140,6 +140,10 @@ target_sources_grouped( ../common/tools_minidump.h ) +set_source_files_properties(${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp PROPERTIES + COMPILE_OPTIONS "-D_DLL_EXT=${SRV_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX};-D_EXTERNAL_DLL_EXT=${SRV_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX}" +) + target_sources_grouped( TARGET vbsp NAME "Header Files" diff --git a/src/utils/vbsp/brushbsp.cpp b/src/utils/vbsp/brushbsp.cpp index 5ebcaa959e..0b33477758 100644 --- a/src/utils/vbsp/brushbsp.cpp +++ b/src/utils/vbsp/brushbsp.cpp @@ -394,9 +394,7 @@ bspbrush_t *CopyBrush (bspbrush_t *brush) int size; int i; - // TODO compare - size = (int)(std::ptrdiff_t)&(((bspbrush_t *)0)->sides[brush->numsides]); - size = offsetof(bspbrush_t, numsides) + sizeof(bspbrush_t::sides) * brush->numsides; + size = offsetof(bspbrush_t, sides) + sizeof(brush->sides[0]) * brush->numsides; newbrush = AllocBrush (brush->numsides); memcpy ((void*)newbrush, brush, size); From 12af7f335d1a8beaeb44e7c37cfaa06e66effe7d Mon Sep 17 00:00:00 2001 From: Masterkatze Date: Sun, 21 Jun 2026 23:15:26 +0300 Subject: [PATCH 08/14] Remove VMPI --- src/CMakeLists.txt | 3 - src/thirdparty/CMakeLists.txt | 28 - src/utils/CMakeLists.txt | 4 - src/utils/common/cmdlib.cpp | 41 - src/utils/common/filesystem_tools.cpp | 40 +- src/utils/common/filesystem_tools.h | 2 +- src/utils/common/mpi_stats.cpp | 839 ----- src/utils/common/mpi_stats.h | 59 - src/utils/common/vmpi_tools_shared.cpp | 375 -- src/utils/common/vmpi_tools_shared.h | 45 - src/utils/vbsp/CMakeLists.txt | 6 +- src/utils/vmpi/CMakeLists.txt | 84 - src/utils/vmpi/IThreadedTCPSocket.h | 180 - src/utils/vmpi/ThreadedTCPSocket.cpp | 1095 ------ src/utils/vmpi/ThreadedTCPSocketEmu.cpp | 349 -- src/utils/vmpi/ThreadedTCPSocketEmu.h | 26 - src/utils/vmpi/WaitAndRestart/StdAfx.cpp | 15 - src/utils/vmpi/WaitAndRestart/StdAfx.h | 32 - .../vmpi/WaitAndRestart/WaitAndRestart.cpp | 149 - src/utils/vmpi/ZLib.lib | Bin 83274 -> 0 bytes src/utils/vmpi/ZLib/deflate.h | 318 -- src/utils/vmpi/ZLib/infblock.h | 39 - src/utils/vmpi/ZLib/infcodes.h | 27 - src/utils/vmpi/ZLib/inffast.h | 17 - src/utils/vmpi/ZLib/inffixed.h | 151 - src/utils/vmpi/ZLib/inftrees.h | 58 - src/utils/vmpi/ZLib/infutil.h | 98 - src/utils/vmpi/ZLib/trees.h | 128 - src/utils/vmpi/ZLib/zconf.h | 279 -- src/utils/vmpi/ZLib/zlib.h | 893 ----- src/utils/vmpi/ZLib/zutil.h | 220 -- src/utils/vmpi/ichannel.h | 49 - src/utils/vmpi/idle_dialog.cpp | 46 - src/utils/vmpi/idle_dialog.h | 48 - src/utils/vmpi/imysqlwrapper.h | 115 - src/utils/vmpi/iphelpers.cpp | 610 ---- src/utils/vmpi/iphelpers.h | 162 - src/utils/vmpi/loopback_channel.cpp | 98 - src/utils/vmpi/loopback_channel.h | 22 - src/utils/vmpi/messagemgr.cpp | 300 -- src/utils/vmpi/messagemgr.h | 39 - src/utils/vmpi/messbuf.cpp | 279 -- src/utils/vmpi/messbuf.h | 62 - src/utils/vmpi/mysql_async.cpp | 275 -- src/utils/vmpi/mysql_async.h | 56 - src/utils/vmpi/mysql_wrapper.h | 104 - src/utils/vmpi/net_view_thread.cpp | 215 -- src/utils/vmpi/net_view_thread.h | 47 - src/utils/vmpi/serviceinfo.h | 50 - src/utils/vmpi/tcpsocket.cpp | 1178 ------ src/utils/vmpi/tcpsocket.h | 84 - src/utils/vmpi/tcpsocket_helpers.cpp | 48 - src/utils/vmpi/tcpsocket_helpers.h | 21 - .../testapps/MessageWatch/MessageRecvMgr.h | 22 - .../testapps/MessageWatch/MessageWatch.cpp | 77 - .../vmpi/testapps/MessageWatch/MessageWatch.h | 56 - .../testapps/MessageWatch/MessageWatch.rc | 194 - .../testapps/MessageWatch/MessageWatchDlg.cpp | 324 -- .../testapps/MessageWatch/MessageWatchDlg.h | 100 - .../vmpi/testapps/MessageWatch/StdAfx.cpp | 15 - src/utils/vmpi/testapps/MessageWatch/StdAfx.h | 33 - .../MessageWatch/res/MessageWatch.ico | Bin 766 -> 0 bytes .../MessageWatch/res/MessageWatch.rc2 | 13 - .../vmpi/testapps/MessageWatch/resource.h | 29 - .../vmpi/testapps/MessageWatch/win_idle.cpp | 123 - .../vmpi/testapps/MessageWatch/win_idle.h | 78 - .../testapps/ThreadedTCPSocketTest/StdAfx.cpp | 15 - .../testapps/ThreadedTCPSocketTest/StdAfx.h | 31 - .../ThreadedTCPSocketTest.cpp | 198 -- src/utils/vmpi/testapps/pingpong/StdAfx.cpp | 15 - src/utils/vmpi/testapps/pingpong/StdAfx.h | 29 - src/utils/vmpi/testapps/pingpong/pingpong.cpp | 308 -- .../testapps/socket_stresstest/StdAfx.cpp | 15 - .../vmpi/testapps/socket_stresstest/StdAfx.h | 33 - .../socket_stresstest/socket_stresstest.cpp | 274 -- .../vmpi/testapps/vmpi_launch/StdAfx.cpp | 15 - src/utils/vmpi/testapps/vmpi_launch/StdAfx.h | 30 - .../vmpi/testapps/vmpi_launch/vmpi_launch.cpp | 256 -- src/utils/vmpi/testapps/vmpi_ping/StdAfx.cpp | 15 - src/utils/vmpi/testapps/vmpi_ping/StdAfx.h | 30 - .../vmpi/testapps/vmpi_ping/vmpi_ping.cpp | 196 - src/utils/vmpi/threadhelpers.cpp | 157 - src/utils/vmpi/threadhelpers.h | 112 - src/utils/vmpi/vmpi.cpp | 3167 ----------------- src/utils/vmpi/vmpi.h | 262 -- src/utils/vmpi/vmpi_browser_helpers.cpp | 43 - src/utils/vmpi/vmpi_browser_helpers.h | 18 - src/utils/vmpi/vmpi_defs.h | 152 - src/utils/vmpi/vmpi_dispatch.cpp | 13 - src/utils/vmpi/vmpi_dispatch.h | 15 - src/utils/vmpi/vmpi_distribute_tracker.cpp | 579 --- src/utils/vmpi/vmpi_distribute_tracker.h | 32 - src/utils/vmpi/vmpi_distribute_work.cpp | 644 ---- src/utils/vmpi/vmpi_distribute_work.h | 86 - .../vmpi/vmpi_distribute_work_default.cpp | 602 ---- .../vmpi/vmpi_distribute_work_internal.h | 251 -- src/utils/vmpi/vmpi_distribute_work_sdk.cpp | 699 ---- src/utils/vmpi/vmpi_filesystem.cpp | 374 -- src/utils/vmpi/vmpi_filesystem.h | 53 - src/utils/vmpi/vmpi_filesystem_internal.h | 129 - src/utils/vmpi/vmpi_filesystem_master.cpp | 1616 --------- src/utils/vmpi/vmpi_filesystem_worker.cpp | 865 ----- .../vmpi/vmpi_job_search/JobSearchDlg.cpp | 473 --- src/utils/vmpi/vmpi_job_search/JobSearchDlg.h | 86 - src/utils/vmpi/vmpi_job_search/StdAfx.cpp | 15 - src/utils/vmpi/vmpi_job_search/StdAfx.h | 36 - .../res/vmpi_browser_job_search.ico | Bin 1078 -> 0 bytes .../res/vmpi_browser_job_search.rc2 | 13 - src/utils/vmpi/vmpi_job_search/resource.h | 32 - .../vmpi_browser_job_search.cpp | 75 - .../vmpi_job_search/vmpi_browser_job_search.h | 56 - .../vmpi_browser_job_search.rc | 184 - .../vmpi/vmpi_job_watch/GraphControl.cpp | 246 -- src/utils/vmpi/vmpi_job_watch/GraphControl.h | 86 - src/utils/vmpi/vmpi_job_watch/JobWatchDlg.cpp | 648 ---- src/utils/vmpi/vmpi_job_watch/JobWatchDlg.h | 134 - src/utils/vmpi/vmpi_job_watch/StdAfx.cpp | 15 - src/utils/vmpi/vmpi_job_watch/StdAfx.h | 36 - .../res/vmpi_browser_job_watch.ico | Bin 1078 -> 0 bytes .../res/vmpi_browser_job_watch.rc2 | 13 - src/utils/vmpi/vmpi_job_watch/resource.h | 32 - .../vmpi_job_watch/vmpi_browser_job_watch.cpp | 75 - .../vmpi_job_watch/vmpi_browser_job_watch.h | 56 - .../vmpi_job_watch/vmpi_browser_job_watch.rc | 183 - src/utils/vmpi/vmpi_logfile.cpp | 98 - src/utils/vmpi/vmpi_logfile.h | 23 - src/utils/vmpi/vmpi_parameters.h | 31 - src/utils/vmpi/vmpi_registry_query_thread.cpp | 139 - src/utils/vmpi/vmpi_registry_query_thread.h | 38 - .../vmpi/vmpi_services_watch/PatchTimeout.cpp | 49 - .../vmpi/vmpi_services_watch/PatchTimeout.h | 56 - .../vmpi/vmpi_services_watch/ServicesDlg.cpp | 1286 ------- .../vmpi/vmpi_services_watch/ServicesDlg.h | 115 - .../vmpi_services_watch/SetPasswordDlg.cpp | 49 - .../vmpi/vmpi_services_watch/SetPasswordDlg.h | 54 - src/utils/vmpi/vmpi_services_watch/StdAfx.cpp | 15 - src/utils/vmpi/vmpi_services_watch/StdAfx.h | 35 - .../vmpi/vmpi_services_watch/res/vmpi.ico | Bin 3310 -> 0 bytes .../res/vmpi_browser_services.ico | Bin 1078 -> 0 bytes .../res/vmpi_browser_services.rc2 | 13 - src/utils/vmpi/vmpi_services_watch/resource.h | 51 - .../vmpi_browser_services.cpp | 90 - .../vmpi_browser_services.h | 56 - .../vmpi_browser_services.rc | 285 -- .../vmpi/vmpi_transfer/vmpi_transfer.cpp | 163 - src/utils/vmpi/vmpi_transfer/vmpi_transfer.h | 14 - src/utils/vmpi/win_idle.cpp | 122 - src/utils/vmpi/win_idle.h | 78 - src/utils/vmpi/window_anchor_mgr.cpp | 94 - src/utils/vmpi/window_anchor_mgr.h | 59 - src/utils/vrad/CMakeLists.txt | 42 - src/utils/vrad/leaf_ambient_lighting.cpp | 45 - src/utils/vrad/lightmap.cpp | 11 +- src/utils/vrad/mpivrad.cpp | 498 --- src/utils/vrad/mpivrad.h | 33 - src/utils/vrad/vismat.cpp | 30 +- src/utils/vrad/vismat.h | 8 +- src/utils/vrad/vrad.cpp | 122 +- src/utils/vrad/vrad.h | 5 - src/utils/vrad/vraddetailprops.cpp | 43 - src/utils/vrad/vradstaticprops.cpp | 119 +- src/utils/vvis/CMakeLists.txt | 54 +- src/utils/vvis/flow.cpp | 14 - src/utils/vvis/mpivis.cpp | 635 ---- src/utils/vvis/mpivis.h | 21 - src/utils/vvis/vvis.cpp | 138 +- 166 files changed, 35 insertions(+), 29191 deletions(-) delete mode 100644 src/thirdparty/CMakeLists.txt delete mode 100644 src/utils/common/mpi_stats.cpp delete mode 100644 src/utils/common/mpi_stats.h delete mode 100644 src/utils/common/vmpi_tools_shared.cpp delete mode 100644 src/utils/common/vmpi_tools_shared.h delete mode 100644 src/utils/vmpi/CMakeLists.txt delete mode 100644 src/utils/vmpi/IThreadedTCPSocket.h delete mode 100644 src/utils/vmpi/ThreadedTCPSocket.cpp delete mode 100644 src/utils/vmpi/ThreadedTCPSocketEmu.cpp delete mode 100644 src/utils/vmpi/ThreadedTCPSocketEmu.h delete mode 100644 src/utils/vmpi/WaitAndRestart/StdAfx.cpp delete mode 100644 src/utils/vmpi/WaitAndRestart/StdAfx.h delete mode 100644 src/utils/vmpi/WaitAndRestart/WaitAndRestart.cpp delete mode 100644 src/utils/vmpi/ZLib.lib delete mode 100644 src/utils/vmpi/ZLib/deflate.h delete mode 100644 src/utils/vmpi/ZLib/infblock.h delete mode 100644 src/utils/vmpi/ZLib/infcodes.h delete mode 100644 src/utils/vmpi/ZLib/inffast.h delete mode 100644 src/utils/vmpi/ZLib/inffixed.h delete mode 100644 src/utils/vmpi/ZLib/inftrees.h delete mode 100644 src/utils/vmpi/ZLib/infutil.h delete mode 100644 src/utils/vmpi/ZLib/trees.h delete mode 100644 src/utils/vmpi/ZLib/zconf.h delete mode 100644 src/utils/vmpi/ZLib/zlib.h delete mode 100644 src/utils/vmpi/ZLib/zutil.h delete mode 100644 src/utils/vmpi/ichannel.h delete mode 100644 src/utils/vmpi/idle_dialog.cpp delete mode 100644 src/utils/vmpi/idle_dialog.h delete mode 100644 src/utils/vmpi/imysqlwrapper.h delete mode 100644 src/utils/vmpi/iphelpers.cpp delete mode 100644 src/utils/vmpi/iphelpers.h delete mode 100644 src/utils/vmpi/loopback_channel.cpp delete mode 100644 src/utils/vmpi/loopback_channel.h delete mode 100644 src/utils/vmpi/messagemgr.cpp delete mode 100644 src/utils/vmpi/messagemgr.h delete mode 100644 src/utils/vmpi/messbuf.cpp delete mode 100644 src/utils/vmpi/messbuf.h delete mode 100644 src/utils/vmpi/mysql_async.cpp delete mode 100644 src/utils/vmpi/mysql_async.h delete mode 100644 src/utils/vmpi/mysql_wrapper.h delete mode 100644 src/utils/vmpi/net_view_thread.cpp delete mode 100644 src/utils/vmpi/net_view_thread.h delete mode 100644 src/utils/vmpi/serviceinfo.h delete mode 100644 src/utils/vmpi/tcpsocket.cpp delete mode 100644 src/utils/vmpi/tcpsocket.h delete mode 100644 src/utils/vmpi/tcpsocket_helpers.cpp delete mode 100644 src/utils/vmpi/tcpsocket_helpers.h delete mode 100644 src/utils/vmpi/testapps/MessageWatch/MessageRecvMgr.h delete mode 100644 src/utils/vmpi/testapps/MessageWatch/MessageWatch.cpp delete mode 100644 src/utils/vmpi/testapps/MessageWatch/MessageWatch.h delete mode 100644 src/utils/vmpi/testapps/MessageWatch/MessageWatch.rc delete mode 100644 src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.cpp delete mode 100644 src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.h delete mode 100644 src/utils/vmpi/testapps/MessageWatch/StdAfx.cpp delete mode 100644 src/utils/vmpi/testapps/MessageWatch/StdAfx.h delete mode 100644 src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.ico delete mode 100644 src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.rc2 delete mode 100644 src/utils/vmpi/testapps/MessageWatch/resource.h delete mode 100644 src/utils/vmpi/testapps/MessageWatch/win_idle.cpp delete mode 100644 src/utils/vmpi/testapps/MessageWatch/win_idle.h delete mode 100644 src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.cpp delete mode 100644 src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.h delete mode 100644 src/utils/vmpi/testapps/ThreadedTCPSocketTest/ThreadedTCPSocketTest.cpp delete mode 100644 src/utils/vmpi/testapps/pingpong/StdAfx.cpp delete mode 100644 src/utils/vmpi/testapps/pingpong/StdAfx.h delete mode 100644 src/utils/vmpi/testapps/pingpong/pingpong.cpp delete mode 100644 src/utils/vmpi/testapps/socket_stresstest/StdAfx.cpp delete mode 100644 src/utils/vmpi/testapps/socket_stresstest/StdAfx.h delete mode 100644 src/utils/vmpi/testapps/socket_stresstest/socket_stresstest.cpp delete mode 100644 src/utils/vmpi/testapps/vmpi_launch/StdAfx.cpp delete mode 100644 src/utils/vmpi/testapps/vmpi_launch/StdAfx.h delete mode 100644 src/utils/vmpi/testapps/vmpi_launch/vmpi_launch.cpp delete mode 100644 src/utils/vmpi/testapps/vmpi_ping/StdAfx.cpp delete mode 100644 src/utils/vmpi/testapps/vmpi_ping/StdAfx.h delete mode 100644 src/utils/vmpi/testapps/vmpi_ping/vmpi_ping.cpp delete mode 100644 src/utils/vmpi/threadhelpers.cpp delete mode 100644 src/utils/vmpi/threadhelpers.h delete mode 100644 src/utils/vmpi/vmpi.cpp delete mode 100644 src/utils/vmpi/vmpi.h delete mode 100644 src/utils/vmpi/vmpi_browser_helpers.cpp delete mode 100644 src/utils/vmpi/vmpi_browser_helpers.h delete mode 100644 src/utils/vmpi/vmpi_defs.h delete mode 100644 src/utils/vmpi/vmpi_dispatch.cpp delete mode 100644 src/utils/vmpi/vmpi_dispatch.h delete mode 100644 src/utils/vmpi/vmpi_distribute_tracker.cpp delete mode 100644 src/utils/vmpi/vmpi_distribute_tracker.h delete mode 100644 src/utils/vmpi/vmpi_distribute_work.cpp delete mode 100644 src/utils/vmpi/vmpi_distribute_work.h delete mode 100644 src/utils/vmpi/vmpi_distribute_work_default.cpp delete mode 100644 src/utils/vmpi/vmpi_distribute_work_internal.h delete mode 100644 src/utils/vmpi/vmpi_distribute_work_sdk.cpp delete mode 100644 src/utils/vmpi/vmpi_filesystem.cpp delete mode 100644 src/utils/vmpi/vmpi_filesystem.h delete mode 100644 src/utils/vmpi/vmpi_filesystem_internal.h delete mode 100644 src/utils/vmpi/vmpi_filesystem_master.cpp delete mode 100644 src/utils/vmpi/vmpi_filesystem_worker.cpp delete mode 100644 src/utils/vmpi/vmpi_job_search/JobSearchDlg.cpp delete mode 100644 src/utils/vmpi/vmpi_job_search/JobSearchDlg.h delete mode 100644 src/utils/vmpi/vmpi_job_search/StdAfx.cpp delete mode 100644 src/utils/vmpi/vmpi_job_search/StdAfx.h delete mode 100644 src/utils/vmpi/vmpi_job_search/res/vmpi_browser_job_search.ico delete mode 100644 src/utils/vmpi/vmpi_job_search/res/vmpi_browser_job_search.rc2 delete mode 100644 src/utils/vmpi/vmpi_job_search/resource.h delete mode 100644 src/utils/vmpi/vmpi_job_search/vmpi_browser_job_search.cpp delete mode 100644 src/utils/vmpi/vmpi_job_search/vmpi_browser_job_search.h delete mode 100644 src/utils/vmpi/vmpi_job_search/vmpi_browser_job_search.rc delete mode 100644 src/utils/vmpi/vmpi_job_watch/GraphControl.cpp delete mode 100644 src/utils/vmpi/vmpi_job_watch/GraphControl.h delete mode 100644 src/utils/vmpi/vmpi_job_watch/JobWatchDlg.cpp delete mode 100644 src/utils/vmpi/vmpi_job_watch/JobWatchDlg.h delete mode 100644 src/utils/vmpi/vmpi_job_watch/StdAfx.cpp delete mode 100644 src/utils/vmpi/vmpi_job_watch/StdAfx.h delete mode 100644 src/utils/vmpi/vmpi_job_watch/res/vmpi_browser_job_watch.ico delete mode 100644 src/utils/vmpi/vmpi_job_watch/res/vmpi_browser_job_watch.rc2 delete mode 100644 src/utils/vmpi/vmpi_job_watch/resource.h delete mode 100644 src/utils/vmpi/vmpi_job_watch/vmpi_browser_job_watch.cpp delete mode 100644 src/utils/vmpi/vmpi_job_watch/vmpi_browser_job_watch.h delete mode 100644 src/utils/vmpi/vmpi_job_watch/vmpi_browser_job_watch.rc delete mode 100644 src/utils/vmpi/vmpi_logfile.cpp delete mode 100644 src/utils/vmpi/vmpi_logfile.h delete mode 100644 src/utils/vmpi/vmpi_parameters.h delete mode 100644 src/utils/vmpi/vmpi_registry_query_thread.cpp delete mode 100644 src/utils/vmpi/vmpi_registry_query_thread.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/PatchTimeout.cpp delete mode 100644 src/utils/vmpi/vmpi_services_watch/PatchTimeout.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/ServicesDlg.cpp delete mode 100644 src/utils/vmpi/vmpi_services_watch/ServicesDlg.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/SetPasswordDlg.cpp delete mode 100644 src/utils/vmpi/vmpi_services_watch/SetPasswordDlg.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/StdAfx.cpp delete mode 100644 src/utils/vmpi/vmpi_services_watch/StdAfx.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/res/vmpi.ico delete mode 100644 src/utils/vmpi/vmpi_services_watch/res/vmpi_browser_services.ico delete mode 100644 src/utils/vmpi/vmpi_services_watch/res/vmpi_browser_services.rc2 delete mode 100644 src/utils/vmpi/vmpi_services_watch/resource.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/vmpi_browser_services.cpp delete mode 100644 src/utils/vmpi/vmpi_services_watch/vmpi_browser_services.h delete mode 100644 src/utils/vmpi/vmpi_services_watch/vmpi_browser_services.rc delete mode 100644 src/utils/vmpi/vmpi_transfer/vmpi_transfer.cpp delete mode 100644 src/utils/vmpi/vmpi_transfer/vmpi_transfer.h delete mode 100644 src/utils/vmpi/win_idle.cpp delete mode 100644 src/utils/vmpi/win_idle.h delete mode 100644 src/utils/vmpi/window_anchor_mgr.cpp delete mode 100644 src/utils/vmpi/window_anchor_mgr.h delete mode 100644 src/utils/vrad/mpivrad.cpp delete mode 100644 src/utils/vrad/mpivrad.h delete mode 100644 src/utils/vvis/mpivis.cpp delete mode 100644 src/utils/vvis/mpivis.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 579a3a2c3d..0e69337774 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,7 +38,6 @@ option(NEO_BUILD_TIER1 "Build tier1 library" ON) option(NEO_BUILD_MATHLIB "Build mathlib library" ON) option(NEO_BUILD_VGUI_CONTROLS "Build vgui_controls library" ON) option(NEO_BUILD_UTILS "Build utils" ON) -option(NEO_VMPI "Use VMPI in utils" ON) option(NEO_COPY_LIBRARIES "Copy libraries to bin directory by default" ON) option(NEO_EXTRA_ASSETS "Copy extra assets into game/neo" ON) set(NEO_EXTRA_ASSETS_ALT_PATH "" CACHE PATH "Alternate location to fetch the extra assets") @@ -69,7 +68,6 @@ message(STATUS "Build tier1 library: ${NEO_BUILD_TIER1}") message(STATUS "Build mathlib library: ${NEO_BUILD_MATHLIB}") message(STATUS "Build vgui_controls library: ${NEO_BUILD_VGUI_CONTROLS}") message(STATUS "Build utils: ${NEO_BUILD_UTILS}") -message(STATUS "Use VMPI in utils: ${NEO_VMPI}") message(STATUS "Copy libraries to bin directory by default: ${NEO_COPY_LIBRARIES}") message(STATUS "Copy extra assets into game/neo: ${NEO_EXTRA_ASSETS}") message(STATUS "Alternate location to fetch the extra assets: ${NEO_EXTRA_ASSETS_ALT_PATH}") @@ -437,7 +435,6 @@ if(NEO_USE_CCACHE) ) endif() -add_subdirectory(thirdparty) add_subdirectory(lib) if(NEO_GENERATE_GAMEDATA) diff --git a/src/thirdparty/CMakeLists.txt b/src/thirdparty/CMakeLists.txt deleted file mode 100644 index cea9a230a6..0000000000 --- a/src/thirdparty/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -if(NEO_VMPI AND NEO_BUILD_UTILS AND OS_WINDOWS) - set(BUILD_LIBCURL_DOCS OFF) - set(BUILD_MISC_DOCS OFF) - set(ENABLE_CURL_MANUAL OFF) - set(BUILD_CURL_EXE OFF) - set(BUILD_SHARED_LIBS OFF) - set(BUILD_STATIC_LIBS ON) - set(CURL_DISABLE_INSTALL ON) - set(ENABLE_UNICODE ON) - #set(CURL_STATIC_CRT ON) - set(HTTP_ONLY ON) - set(CURL_USE_LIBPSL OFF) - set(BUILD_TESTING OFF) - set(BUILD_EXAMPLES OFF) - - set(Perl_FIND_QUIETLY TRUE) - set(ZLIB_FIND_QUIETLY TRUE) - set(Brotli_FIND_QUIETLY TRUE) - set(Zstd_FIND_QUIETLY TRUE) - set(NGHTTP2_FIND_QUIETLY TRUE) - set(Libidn2_FIND_QUIETLY TRUE) - set(Libssh2_FIND_QUIETLY TRUE) - - message(STATUS "Adding libcurl:") - list(APPEND CMAKE_MESSAGE_INDENT " ") - add_subdirectory(libcurl) - list(POP_BACK CMAKE_MESSAGE_INDENT) -endif() diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 0efa76cc46..d6ff29b2fe 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -3,10 +3,6 @@ add_subdirectory(lzma) add_subdirectory(vbsp) -# if(NEO_VMPI) -# add_subdirectory(vmpi) -# endif() - # add_subdirectory(vvis) # add_subdirectory(vvis_launcher) # add_subdirectory(vrad) diff --git a/src/utils/common/cmdlib.cpp b/src/utils/common/cmdlib.cpp index cda559b504..45ac7b8381 100644 --- a/src/utils/common/cmdlib.cpp +++ b/src/utils/common/cmdlib.cpp @@ -26,14 +26,6 @@ #include "KeyValues.h" #include "filesystem_tools.h" -#if defined( MPI ) - - #include "vmpi.h" - #include "vmpi_tools_shared.h" - -#endif - - #if defined( _WIN32 ) || defined( WIN32 ) #include #endif @@ -258,31 +250,6 @@ SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_DEBUGGER; - -#ifdef MPI - // VMPI workers don't want to bring up dialogs and suchlike. - // They need to have a special function installed to handle - // the exceptions and write the minidumps. - // Install the function after VMPI_Init with a call: - // SetupToolsMinidumpHandler( VMPI_ExceptionFilter ); - if ( g_bUseMPI && !g_bMPIMaster && !Plat_IsInDebugSession() ) - { - // Generating an exception and letting the - // installed handler handle it - ::RaiseException - ( - 0, // dwExceptionCode - EXCEPTION_NONCONTINUABLE, // dwExceptionFlags - 0, // nNumberOfArguments, - NULL // const ULONG_PTR* lpArguments - ); - - // Never get here (non-continuable exception) - - VMPI_HandleCrash( pMsg, NULL, true ); - exit( 0 ); - } -#endif } else if( type == SPEW_ERROR ) { @@ -401,14 +368,6 @@ void CmdLib_Cleanup() FOR_EACH_LL( g_CleanupFunctions, i ) g_CleanupFunctions[i](); - -#if defined( MPI ) - // Unfortunately, when you call exit(), even if you have things registered with atexit(), - // threads go into a seemingly undefined state where GetExitCodeThread gives STILL_ACTIVE - // and WaitForSingleObject will stall forever on the thread. Because of this, we must cleanup - // everything that uses threads before exiting. - VMPI_Finalize(); -#endif } diff --git a/src/utils/common/filesystem_tools.cpp b/src/utils/common/filesystem_tools.cpp index d6da433613..6f275c49da 100644 --- a/src/utils/common/filesystem_tools.cpp +++ b/src/utils/common/filesystem_tools.cpp @@ -20,12 +20,6 @@ #include "KeyValues.h" #include "tier2/tier2.h" -#ifdef MPI - #include "vmpi.h" - #include "vmpi_tools_shared.h" - #include "vmpi_filesystem.h" -#endif - // memdbgon must be the last include file in a .cpp file!!! #include @@ -148,41 +142,13 @@ bool FileSystem_Init_Normal( const char *pFilename, FSInitType_t initType, bool bool FileSystem_Init( const char *pBSPFilename, int maxMemoryUsage, FSInitType_t initType, bool bOnlyUseFilename ) { Assert( CommandLine()->GetCmdLine() != NULL ); // Should have called CreateCmdLine by now. - - // If this app uses VMPI, then let VMPI intercept all filesystem calls. -#if defined( MPI ) - if ( g_bUseMPI ) - { - if ( g_bMPIMaster ) - { - if ( !FileSystem_Init_Normal( pBSPFilename, initType, bOnlyUseFilename ) ) - return false; - - g_pFileSystem = g_pFullFileSystem = VMPI_FileSystem_Init( maxMemoryUsage, g_pFullFileSystem ); - SendQDirInfo(); - } - else - { - g_pFileSystem = g_pFullFileSystem = VMPI_FileSystem_Init( maxMemoryUsage, NULL ); - RecvQDirInfo(); - } - return true; - } -#endif - + return FileSystem_Init_Normal( pBSPFilename, initType, bOnlyUseFilename ); } void FileSystem_Term() { -#if defined( MPI ) - if ( g_bUseMPI ) - { - g_pFileSystem = g_pFullFileSystem = VMPI_FileSystem_Term(); - } -#endif - if ( g_pFullFileSystem ) { g_pFullFileSystem->Shutdown(); @@ -200,9 +166,5 @@ void FileSystem_Term() CreateInterfaceFn FileSystem_GetFactory() { -#if defined( MPI ) - if ( g_bUseMPI ) - return VMPI_FileSystem_GetFactory(); -#endif return Sys_GetFactory( g_pFullFileSystemModule ); } diff --git a/src/utils/common/filesystem_tools.h b/src/utils/common/filesystem_tools.h index ada82ad501..8524189392 100644 --- a/src/utils/common/filesystem_tools.h +++ b/src/utils/common/filesystem_tools.h @@ -34,7 +34,7 @@ enum FSInitType_t }; // -// Initializes qdir, and gamedir. Also initializes the VMPI filesystem if MPI is defined. +// Initializes qdir, and gamedir. // // pFilename can be NULL if you want to rely on vproject and qproject. If it's specified, FileSystem_Init // will go up directories from pFilename looking for gameinfo.txt (if vproject isn't specified). diff --git a/src/utils/common/mpi_stats.cpp b/src/utils/common/mpi_stats.cpp deleted file mode 100644 index 71da6f580e..0000000000 --- a/src/utils/common/mpi_stats.cpp +++ /dev/null @@ -1,839 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -// Nasty headers! -#include "MySqlDatabase.h" -#include "tier1/strtools.h" -#include "vmpi.h" -#include "vmpi_dispatch.h" -#include "mpi_stats.h" -#include "cmdlib.h" -#include "imysqlwrapper.h" -#include "threadhelpers.h" -#include "vmpi_tools_shared.h" -#include "tier0/icommandline.h" - -/* - --- MySQL code to create the databases, create the users, and set access privileges. --- You only need to ever run this once. - -create database vrad; - -use mysql; - -create user vrad_worker; -create user vmpi_browser; - --- This updates the "user" table, which is checked when someone tries to connect to the database. -grant select,insert,update on vrad.* to vrad_worker; -grant select on vrad.* to vmpi_browser; -flush privileges; - -/* - --- SQL code to (re)create the tables. - --- Master generates a unique job ID (in job_master_start) and sends it to workers. --- Each worker (and the master) make a job_worker_start, link it to the primary job ID, --- get their own unique ID, which represents that process in that job. --- All JobWorkerID fields link to the JobWorkerID field in job_worker_start. - --- NOTE: do a "use vrad" or "use vvis" first, depending on the DB you want to create. - - -use vrad; - - -drop table job_master_start; -create table job_master_start ( - JobID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, index id( JobID, MachineName(5) ), - BSPFilename TINYTEXT NOT NULL, - StartTime TIMESTAMP NOT NULL, - MachineName TEXT NOT NULL, - RunningTimeMS INTEGER UNSIGNED NOT NULL, - NumWorkers INTEGER UNSIGNED NOT NULL default 0 - ); - -drop table job_master_end; -create table job_master_end ( - JobID INTEGER UNSIGNED NOT NULL, PRIMARY KEY ( JobID ), - NumWorkersConnected SMALLINT UNSIGNED NOT NULL, - NumWorkersDisconnected SMALLINT UNSIGNED NOT NULL, - ErrorText TEXT NOT NULL - ); - -drop table job_worker_start; -create table job_worker_start ( - JobWorkerID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, - index index_jobid( JobID ), - index index_jobworkerid( JobWorkerID ), - - JobID INTEGER UNSIGNED NOT NULL, -- links to job_master_start::JobID - IsMaster BOOL NOT NULL, -- Set to 1 if this "worker" is the master process. - RunningTimeMS INTEGER UNSIGNED NOT NULL default 0, - MachineName TEXT NOT NULL, - WorkerState SMALLINT UNSIGNED NOT NULL default 0, -- 0 = disconnected, 1 = connected - NumWorkUnits INTEGER UNSIGNED NOT NULL default 0, -- how many work units this worker has completed - CurrentStage TINYTEXT NOT NULL, -- which compile stage is it on - Thread0WU INTEGER NOT NULL default 0, -- which WU thread 0 is on - Thread1WU INTEGER NOT NULL default 0, -- which WU thread 1 is on - Thread2WU INTEGER NOT NULL default 0, -- which WU thread 2 is on - Thread3WU INTEGER NOT NULL default 0 -- which WU thread 3 is on - ); - -drop table text_messages; -create table text_messages ( - JobWorkerID INTEGER UNSIGNED NOT NULL, index id( JobWorkerID, MessageIndex ), - MessageIndex INTEGER UNSIGNED NOT NULL, - Text TEXT NOT NULL - ); - -drop table graph_entry; -create table graph_entry ( - JobWorkerID INTEGER UNSIGNED NOT NULL, index id( JobWorkerID ), - MSSinceJobStart INTEGER UNSIGNED NOT NULL, - BytesSent INTEGER UNSIGNED NOT NULL, - BytesReceived INTEGER UNSIGNED NOT NULL - ); - -drop table events; -create table events ( - JobWorkerID INTEGER UNSIGNED NOT NULL, index id( JobWorkerID ), - Text TEXT NOT NULL - ); -*/ - - - -// Stats set by the app. -int g_nWorkersConnected = 0; -int g_nWorkersDisconnected = 0; - - -DWORD g_StatsStartTime; - -CMySqlDatabase *g_pDB = NULL; - -IMySQL *g_pSQL = NULL; -CSysModule *g_hMySQLDLL = NULL; - -char g_BSPFilename[256]; - -bool g_bMaster = false; -unsigned long g_JobPrimaryID = 0; // This represents this job, but doesn't link to a particular machine. -unsigned long g_JobWorkerID = 0; // A unique key in the DB that represents this machine in this job. -char g_MachineName[MAX_COMPUTERNAME_LENGTH+1] = {0}; - -unsigned long g_CurrentMessageIndex = 0; - - -HANDLE g_hPerfThread = NULL; -DWORD g_PerfThreadID = 0xFEFEFEFE; -HANDLE g_hPerfThreadExitEvent = NULL; - -// These are set by the app and they go into the database. -extern uint64 g_ThreadWUs[4]; - -extern uint64 VMPI_GetNumWorkUnitsCompleted( int iProc ); - - -// ---------------------------------------------------------------------------------------------------- // -// This is a helper class to build queries like the stream IO. -// ---------------------------------------------------------------------------------------------------- // - -class CMySQLQuery -{ -friend class CMySQL; - -public: - // This is like a sprintf, but it will grow the string as necessary. - void Format( const char *pFormat, ... ); - - int Execute( IMySQL *pDB ); - -private: - CUtlVector m_QueryText; -}; - - -void CMySQLQuery::Format( const char *pFormat, ... ) -{ - #define QUERYTEXT_GROWSIZE 1024 - - // This keeps growing the buffer and calling _vsnprintf until the buffer is - // large enough to hold all the data. - m_QueryText.SetSize( QUERYTEXT_GROWSIZE ); - while ( 1 ) - { - va_list marker; - va_start( marker, pFormat ); - int ret = _vsnprintf( m_QueryText.Base(), m_QueryText.Count(), pFormat, marker ); - va_end( marker ); - - if ( ret < 0 ) - { - m_QueryText.SetSize( m_QueryText.Count() + QUERYTEXT_GROWSIZE ); - } - else - { - m_QueryText[ m_QueryText.Count() - 1 ] = 0; - break; - } - } -} - - -int CMySQLQuery::Execute( IMySQL *pDB ) -{ - int ret = pDB->Execute( m_QueryText.Base() ); - m_QueryText.Purge(); - return ret; -} - - - -// ---------------------------------------------------------------------------------------------------- // -// This inserts the necessary backslashes in front of backslashes or quote characters. -// ---------------------------------------------------------------------------------------------------- // - -char* FormatStringForSQL( const char *pText ) -{ - // First, count the quotes in the string. We need to put a backslash in front of each one. - int nChars = 0; - const char *pCur = pText; - while ( *pCur != 0 ) - { - if ( *pCur == '\"' || *pCur == '\\' ) - ++nChars; - - ++pCur; - ++nChars; - } - - pCur = pText; - char *pRetVal = new char[nChars+1]; - for ( int i=0; i < nChars; ) - { - if ( *pCur == '\"' || *pCur == '\\' ) - pRetVal[i++] = '\\'; - - pRetVal[i++] = *pCur; - ++pCur; - } - pRetVal[nChars] = 0; - - return pRetVal; -} - - - -// -------------------------------------------------------------------------------- // -// Commands to add data to the database. -// -------------------------------------------------------------------------------- // -class CSQLDBCommandBase : public ISQLDBCommand -{ -public: - virtual ~CSQLDBCommandBase() - { - } - - virtual void deleteThis() - { - delete this; - } -}; - -class CSQLDBCommand_WorkerStats : public CSQLDBCommandBase -{ -public: - virtual int RunCommand() - { - int nCurConnections = VMPI_GetCurrentNumberOfConnections(); - - - // Update the NumWorkers entry. - char query[2048]; - Q_snprintf( query, sizeof( query ), "update job_master_start set NumWorkers=%d where JobID=%lu", - nCurConnections, - g_JobPrimaryID ); - g_pSQL->Execute( query ); - - - // Update the job_master_worker_stats stuff. - for ( int i=1; i < nCurConnections; i++ ) - { - unsigned long jobWorkerID = VMPI_GetJobWorkerID( i ); - - if ( jobWorkerID != 0xFFFFFFFF ) - { - Q_snprintf( query, sizeof( query ), "update " - "job_worker_start set WorkerState=%d, NumWorkUnits=%d where JobWorkerID=%lu", - VMPI_IsProcConnected( i ), - (int) VMPI_GetNumWorkUnitsCompleted( i ), - VMPI_GetJobWorkerID( i ) - ); - g_pSQL->Execute( query ); - } - } - return 1; - } -}; - -class CSQLDBCommand_JobMasterEnd : public CSQLDBCommandBase -{ -public: - - virtual int RunCommand() - { - CMySQLQuery query; - query.Format( "insert into job_master_end values ( %lu, %d, %d, \"no errors\" )", g_JobPrimaryID, g_nWorkersConnected, g_nWorkersDisconnected ); - query.Execute( g_pSQL ); - - // Now set RunningTimeMS. - unsigned long runningTimeMS = GetTickCount() - g_StatsStartTime; - query.Format( "update job_master_start set RunningTimeMS=%lu where JobID=%lu", runningTimeMS, g_JobPrimaryID ); - query.Execute( g_pSQL ); - return 1; - } -}; - - -void UpdateJobWorkerRunningTime() -{ - unsigned long runningTimeMS = GetTickCount() - g_StatsStartTime; - - char curStage[256]; - VMPI_GetCurrentStage( curStage, sizeof( curStage ) ); - - CMySQLQuery query; - query.Format( "update job_worker_start set RunningTimeMS=%lu, CurrentStage=\"%s\", " - "Thread0WU=%d, Thread1WU=%d, Thread2WU=%d, Thread3WU=%d where JobWorkerID=%lu", - runningTimeMS, - curStage, - (int) g_ThreadWUs[0], - (int) g_ThreadWUs[1], - (int) g_ThreadWUs[2], - (int) g_ThreadWUs[3], - g_JobWorkerID ); - query.Execute( g_pSQL ); -} - - -class CSQLDBCommand_GraphEntry : public CSQLDBCommandBase -{ -public: - - CSQLDBCommand_GraphEntry( DWORD msTime, DWORD nBytesSent, DWORD nBytesReceived ) - { - m_msTime = msTime; - m_nBytesSent = nBytesSent; - m_nBytesReceived = nBytesReceived; - } - - virtual int RunCommand() - { - CMySQLQuery query; - query.Format( "insert into graph_entry (JobWorkerID, MSSinceJobStart, BytesSent, BytesReceived) " - "values ( %lu, %lu, %lu, %lu )", - g_JobWorkerID, - m_msTime, - m_nBytesSent, - m_nBytesReceived ); - - query.Execute( g_pSQL ); - - UpdateJobWorkerRunningTime(); - - ++g_CurrentMessageIndex; - return 1; - } - - DWORD m_nBytesSent; - DWORD m_nBytesReceived; - DWORD m_msTime; -}; - - - -class CSQLDBCommand_TextMessage : public CSQLDBCommandBase -{ -public: - - CSQLDBCommand_TextMessage( const char *pText ) - { - m_pText = FormatStringForSQL( pText ); - } - - virtual ~CSQLDBCommand_TextMessage() - { - delete [] m_pText; - } - - virtual int RunCommand() - { - CMySQLQuery query; - query.Format( "insert into text_messages (JobWorkerID, MessageIndex, Text) values ( %lu, %lu, \"%s\" )", g_JobWorkerID, g_CurrentMessageIndex, m_pText ); - query.Execute( g_pSQL ); - - ++g_CurrentMessageIndex; - return 1; - } - - char *m_pText; -}; - - -// -------------------------------------------------------------------------------- // -// Internal helpers. -// -------------------------------------------------------------------------------- // - -// This is the spew output before it has connected to the MySQL database. -CVMPICriticalSection g_SpewTextCS; -CUtlVector g_SpewText( 1024 ); - - -void VMPI_Stats_SpewHook( const char *pMsg ) -{ - CVMPICriticalSectionLock csLock( &g_SpewTextCS ); - csLock.Lock(); - - // Queue the text up so we can send it to the DB right away when we connect. - g_SpewText.AddMultipleToTail( strlen( pMsg ), pMsg ); -} - - -void PerfThread_SendSpewText() -{ - // Send the spew text to the database. - CVMPICriticalSectionLock csLock( &g_SpewTextCS ); - csLock.Lock(); - - if ( g_SpewText.Count() > 0 ) - { - g_SpewText.AddToTail( 0 ); - - if ( g_bMPI_StatsTextOutput ) - { - g_pDB->AddCommandToQueue( new CSQLDBCommand_TextMessage( g_SpewText.Base() ), NULL ); - } - else - { - // Just show one message in the vmpi_job_watch window to let them know that they need - // to use a command line option to get the output. - static bool bFirst = true; - if ( bFirst ) - { - char msg[512]; - V_snprintf( msg, sizeof( msg ), "%s not enabled", VMPI_GetParamString( mpi_Stats_TextOutput ) ); - bFirst = false; - g_pDB->AddCommandToQueue( new CSQLDBCommand_TextMessage( msg ), NULL ); - } - } - - g_SpewText.RemoveAll(); - } - - csLock.Unlock(); -} - - -void PerfThread_AddGraphEntry( DWORD startTicks, DWORD &lastSent, DWORD &lastReceived ) -{ - // Send the graph entry with data transmission info. - DWORD curSent = g_nBytesSent + g_nMulticastBytesSent; - DWORD curReceived = g_nBytesReceived + g_nMulticastBytesReceived; - - g_pDB->AddCommandToQueue( - new CSQLDBCommand_GraphEntry( - GetTickCount() - startTicks, - curSent - lastSent, - curReceived - lastReceived ), - NULL ); - - lastSent = curSent; - lastReceived = curReceived; -} - - -// This function adds a graph_entry into the database periodically. -DWORD WINAPI PerfThreadFn( LPVOID pParameter ) -{ - DWORD lastSent = 0; - DWORD lastReceived = 0; - DWORD startTicks = GetTickCount(); - - while ( WaitForSingleObject( g_hPerfThreadExitEvent, 1000 ) != WAIT_OBJECT_0 ) - { - PerfThread_AddGraphEntry( startTicks, lastSent, lastReceived ); - - // Send updates for text output. - PerfThread_SendSpewText(); - - // If we're the master, update all the worker stats. - if ( g_bMaster ) - { - g_pDB->AddCommandToQueue( - new CSQLDBCommand_WorkerStats, - NULL ); - } - } - - // Add the remaining text and one last graph entry (which will include the current stage info). - PerfThread_SendSpewText(); - PerfThread_AddGraphEntry( startTicks, lastSent, lastReceived ); - - SetEvent( g_hPerfThreadExitEvent ); - return 0; -} - - -// -------------------------------------------------------------------------------- // -// VMPI_Stats interface. -// -------------------------------------------------------------------------------- // - -void VMPI_Stats_InstallSpewHook() -{ - InstallExtraSpewHook( VMPI_Stats_SpewHook ); -} - - -void UnloadMySQLWrapper() -{ - if ( g_hMySQLDLL ) - { - if ( g_pSQL ) - { - g_pSQL->Release(); - g_pSQL = NULL; - } - - Sys_UnloadModule( g_hMySQLDLL ); - g_hMySQLDLL = NULL; - } -} - - -bool LoadMySQLWrapper( - const char *pHostName, - const char *pDBName, - const char *pUserName - ) -{ - UnloadMySQLWrapper(); - - // Load the DLL and the interface. - if ( !Sys_LoadInterface( "mysql_wrapper", MYSQL_WRAPPER_VERSION_NAME, &g_hMySQLDLL, (void**)&g_pSQL ) ) - return false; - - // Try to init the database. - if ( !g_pSQL->InitMySQL( pDBName, pHostName, pUserName ) ) - { - UnloadMySQLWrapper(); - return false; - } - - return true; -} - - -bool VMPI_Stats_Init_Master( - const char *pHostName, - const char *pDBName, - const char *pUserName, - const char *pBSPFilename, - unsigned long *pDBJobID ) -{ - Assert( !g_pDB ); - - g_bMaster = true; - - // Connect the database. - g_pDB = new CMySqlDatabase; - if ( !g_pDB || !g_pDB->Initialize() || !LoadMySQLWrapper( pHostName, pDBName, pUserName ) ) - { - delete g_pDB; - g_pDB = NULL; - return false; - } - - DWORD size = sizeof( g_MachineName ); - GetComputerName( g_MachineName, &size ); - - // Create the job_master_start row. - Q_FileBase( pBSPFilename, g_BSPFilename, sizeof( g_BSPFilename ) ); - - g_JobPrimaryID = 0; - CMySQLQuery query; - query.Format( "insert into job_master_start ( BSPFilename, StartTime, MachineName, RunningTimeMS ) values ( \"%s\", null, \"%s\", %lu )", g_BSPFilename, g_MachineName, RUNNINGTIME_MS_SENTINEL ); - query.Execute( g_pSQL ); - - g_JobPrimaryID = g_pSQL->InsertID(); - if ( g_JobPrimaryID == 0 ) - { - delete g_pDB; - g_pDB = NULL; - return false; - } - - - // Now init the worker portion. - *pDBJobID = g_JobPrimaryID; - return VMPI_Stats_Init_Worker( NULL, NULL, NULL, g_JobPrimaryID ); -} - - - -bool VMPI_Stats_Init_Worker( const char *pHostName, const char *pDBName, const char *pUserName, unsigned long DBJobID ) -{ - g_StatsStartTime = GetTickCount(); - - // If pDBServerName is null, then we're the master and we just want to make the job_worker_start entry. - if ( pHostName ) - { - Assert( !g_pDB ); - - // Connect the database. - g_pDB = new CMySqlDatabase; - if ( !g_pDB || !g_pDB->Initialize() || !LoadMySQLWrapper( pHostName, pDBName, pUserName ) ) - { - delete g_pDB; - g_pDB = NULL; - return false; - } - - // Get our machine name to store in the database. - DWORD size = sizeof( g_MachineName ); - GetComputerName( g_MachineName, &size ); - } - - - g_JobPrimaryID = DBJobID; - g_JobWorkerID = 0; - - CMySQLQuery query; - query.Format( "insert into job_worker_start ( JobID, CurrentStage, IsMaster, MachineName ) values ( %lu, \"none\", %d, \"%s\" )", - g_JobPrimaryID, g_bMaster, g_MachineName ); - query.Execute( g_pSQL ); - - g_JobWorkerID = g_pSQL->InsertID(); - if ( g_JobWorkerID == 0 ) - { - delete g_pDB; - g_pDB = NULL; - return false; - } - - // Now create a thread that samples perf data and stores it in the database. - g_hPerfThreadExitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); - g_hPerfThread = CreateThread( - NULL, - 0, - PerfThreadFn, - NULL, - 0, - &g_PerfThreadID ); - - return true; -} - - -void VMPI_Stats_Term() -{ - if ( !g_pDB ) - return; - - // Stop the thread. - SetEvent( g_hPerfThreadExitEvent ); - WaitForSingleObject( g_hPerfThread, INFINITE ); - - CloseHandle( g_hPerfThreadExitEvent ); - g_hPerfThreadExitEvent = NULL; - - CloseHandle( g_hPerfThread ); - g_hPerfThread = NULL; - - if ( g_bMaster ) - { - // (Write a job_master_end entry here). - g_pDB->AddCommandToQueue( new CSQLDBCommand_JobMasterEnd, NULL ); - } - - // Wait for up to a second for the DB to finish writing its data. - DWORD startTime = GetTickCount(); - while ( GetTickCount() - startTime < 1000 ) - { - if ( g_pDB->QueriesInOutQueue() == 0 ) - break; - } - - delete g_pDB; - g_pDB = NULL; - - UnloadMySQLWrapper(); -} - - -static bool ReadStringFromFile( FILE *fp, char *pStr, int strSize ) -{ - int i=0; - for ( i; i < strSize-2; i++ ) - { - if ( fread( &pStr[i], 1, 1, fp ) != 1 || - pStr[i] == '\n' ) - { - break; - } - } - - pStr[i] = 0; - return i != 0; -} - - -// This looks for pDBInfoFilename in the same path as pBaseExeFilename. -// The file has 3 lines: machine name (with database), database name, username -void GetDBInfo( const char *pDBInfoFilename, CDBInfo *pInfo ) -{ - char baseExeFilename[512]; - if ( !GetModuleFileName( GetModuleHandle( NULL ), baseExeFilename, sizeof( baseExeFilename ) ) ) - Error( "GetModuleFileName failed." ); - - // Look for the info file in the same directory as the exe. - char dbInfoFilename[512]; - Q_strncpy( dbInfoFilename, baseExeFilename, sizeof( dbInfoFilename ) ); - Q_StripFilename( dbInfoFilename ); - - if ( dbInfoFilename[0] == 0 ) - Q_strncpy( dbInfoFilename, ".", sizeof( dbInfoFilename ) ); - - Q_strncat( dbInfoFilename, "/", sizeof( dbInfoFilename ), COPY_ALL_CHARACTERS ); - Q_strncat( dbInfoFilename, pDBInfoFilename, sizeof( dbInfoFilename ), COPY_ALL_CHARACTERS ); - - FILE *fp = fopen( dbInfoFilename, "rt" ); - if ( !fp ) - { - Error( "Can't open %s for database info.\n", dbInfoFilename ); - } - - if ( !ReadStringFromFile( fp, pInfo->m_HostName, sizeof( pInfo->m_HostName ) ) || - !ReadStringFromFile( fp, pInfo->m_DBName, sizeof( pInfo->m_DBName ) ) || - !ReadStringFromFile( fp, pInfo->m_UserName, sizeof( pInfo->m_UserName ) ) - ) - { - Error( "%s is not a valid database info file.\n", dbInfoFilename ); - } - - fclose( fp ); -} - - -void RunJobWatchApp( char *pCmdLine ) -{ - STARTUPINFO si; - memset( &si, 0, sizeof( si ) ); - si.cb = sizeof( si ); - - PROCESS_INFORMATION pi; - memset( &pi, 0, sizeof( pi ) ); - - // Working directory should be the same as our exe's directory. - char dirName[512]; - if ( GetModuleFileName( NULL, dirName, sizeof( dirName ) ) != 0 ) - { - char *s1 = V_strrchr( dirName, '\\' ); - char *s2 = V_strrchr( dirName, '/' ); - if ( s1 || s2 ) - { - // Get rid of the last slash. - s1 = max( s1, s2 ); - s1[0] = 0; - - if ( !CreateProcess( - NULL, - pCmdLine, - NULL, // security - NULL, - TRUE, - 0, // flags - NULL, // environment - dirName, // current directory - &si, - &pi ) ) - { - Warning( "%s - error launching '%s'\n", VMPI_GetParamString( mpi_Job_Watch ), pCmdLine ); - } - } - } -} - - -void StatsDB_InitStatsDatabase( - int argc, - char **argv, - const char *pDBInfoFilename ) -{ - // Did they disable the stats database? - if ( !g_bMPI_Stats && !VMPI_IsParamUsed( mpi_Job_Watch ) ) - return; - - unsigned long jobPrimaryID; - - // Now open the DB. - if ( g_bMPIMaster ) - { - CDBInfo dbInfo; - GetDBInfo( pDBInfoFilename, &dbInfo ); - - if ( !VMPI_Stats_Init_Master( dbInfo.m_HostName, dbInfo.m_DBName, dbInfo.m_UserName, argv[argc-1], &jobPrimaryID ) ) - { - Warning( "VMPI_Stats_Init_Master( %s, %s, %s ) failed.\n", dbInfo.m_HostName, dbInfo.m_DBName, dbInfo.m_UserName ); - - // Tell the workers not to use stats. - dbInfo.m_HostName[0] = 0; - } - - char cmdLine[2048]; - Q_snprintf( cmdLine, sizeof( cmdLine ), "vmpi_job_watch -JobID %d", jobPrimaryID ); - - Msg( "\nTo watch this job, run this command line:\n%s\n\n", cmdLine ); - - if ( VMPI_IsParamUsed( mpi_Job_Watch ) ) - { - // Convenience thing to automatically launch the job watch for this job. - RunJobWatchApp( cmdLine ); - } - - // Send the database info to all the workers. - SendDBInfo( &dbInfo, jobPrimaryID ); - } - else - { - // Wait to get DB info so we can connect to the MySQL database. - CDBInfo dbInfo; - unsigned long jobPrimaryID; - RecvDBInfo( &dbInfo, &jobPrimaryID ); - - if ( dbInfo.m_HostName[0] != 0 ) - { - if ( !VMPI_Stats_Init_Worker( dbInfo.m_HostName, dbInfo.m_DBName, dbInfo.m_UserName, jobPrimaryID ) ) - Error( "VMPI_Stats_Init_Worker( %s, %s, %s, %d ) failed.\n", dbInfo.m_HostName, dbInfo.m_DBName, dbInfo.m_UserName, jobPrimaryID ); - } - } -} - - -unsigned long StatsDB_GetUniqueJobID() -{ - return g_JobPrimaryID; -} - - -unsigned long VMPI_Stats_GetJobWorkerID() -{ - return g_JobWorkerID; -} \ No newline at end of file diff --git a/src/utils/common/mpi_stats.h b/src/utils/common/mpi_stats.h deleted file mode 100644 index 841db3a2d3..0000000000 --- a/src/utils/common/mpi_stats.h +++ /dev/null @@ -1,59 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef MPI_STATS_H -#define MPI_STATS_H -#ifdef _WIN32 -#pragma once -#endif - - -// The VMPI stats module reports a bunch of statistics to a MySQL server, and the -// stats can be used to trace and graph a compile session. -// - -// Call this as soon as possible to initialize spew hooks. -void VMPI_Stats_InstallSpewHook(); - -// -// pDBServerName is the hostname (or dotted IP address) of the MySQL server to connect to. -// pBSPFilename is the last argument on the command line. -// pMachineIP is the dotted IP address of this machine. -// jobID is an 8-byte unique identifier for this job. -// -bool VMPI_Stats_Init_Master( const char *pHostName, const char *pDBName, const char *pUserName, const char *pBSPFilename, unsigned long *pDBJobID ); -bool VMPI_Stats_Init_Worker( const char *pHostName, const char *pDBName, const char *pUserName, unsigned long DBJobID ); -void VMPI_Stats_Term(); - -// Add a generic text event to the database. -void VMPI_Stats_AddEventText( const char *pText ); - -class CDBInfo -{ -public: - char m_HostName[128]; - char m_DBName[128]; - char m_UserName[128]; -}; - -// If you're the master, this loads pDBInfoFilename, sends that info to the workers, and -// connects to the database. -// -// If you're a worker, this waits for the DB info, then connects to the database. -void StatsDB_InitStatsDatabase( - int argc, - char **argv, - const char *pDBInfoFilename ); - -// The database gives back a unique ID for the job. -unsigned long StatsDB_GetUniqueJobID(); - -// Get the worker ID (used for the JobWorkerID fields in the database). -unsigned long VMPI_Stats_GetJobWorkerID(); - - -#endif // MPI_STATS_H diff --git a/src/utils/common/vmpi_tools_shared.cpp b/src/utils/common/vmpi_tools_shared.cpp deleted file mode 100644 index dd868913c4..0000000000 --- a/src/utils/common/vmpi_tools_shared.cpp +++ /dev/null @@ -1,375 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#include -#include -#include "vmpi.h" -#include "cmdlib.h" -#include "vmpi_tools_shared.h" -#include "tier1/strtools.h" -#include "mpi_stats.h" -#include "iphelpers.h" -#include "tier0/minidump.h" - - -// ----------------------------------------------------------------------------- // -// Globals. -// ----------------------------------------------------------------------------- // - -static bool g_bReceivedDirectoryInfo = false; // Have we gotten the qdir info yet? - -static bool g_bReceivedDBInfo = false; -static CDBInfo g_DBInfo; -static unsigned long g_JobPrimaryID; - -static int g_nDisconnects = 0; // Tracks how many remote processes have disconnected ungracefully. - - -// ----------------------------------------------------------------------------- // -// Shared dispatch code. -// ----------------------------------------------------------------------------- // - -bool SharedDispatch( MessageBuffer *pBuf, int iSource, int iPacketID ) -{ - char *pInPos = &pBuf->data[2]; - - switch ( pBuf->data[1] ) - { - case VMPI_SUBPACKETID_DIRECTORIES: - { - Q_strncpy( gamedir, pInPos, sizeof( gamedir ) ); - pInPos += strlen( pInPos ) + 1; - - Q_strncpy( qdir, pInPos, sizeof( qdir ) ); - - g_bReceivedDirectoryInfo = true; - } - return true; - - case VMPI_SUBPACKETID_DBINFO: - { - g_DBInfo = *((CDBInfo*)pInPos); - pInPos += sizeof( CDBInfo ); - g_JobPrimaryID = *((unsigned long*)pInPos); - - g_bReceivedDBInfo = true; - } - return true; - - case VMPI_SUBPACKETID_CRASH: - { - char const chCrashInfoType = *pInPos; - pInPos += 2; - switch ( chCrashInfoType ) - { - case 't': - Warning( "\nWorker '%s' dead: %s\n", VMPI_GetMachineName( iSource ), pInPos ); - break; - case 'f': - { - int iFileSize = * reinterpret_cast< int const * >( pInPos ); - pInPos += sizeof( iFileSize ); - - // Temp folder - char const *szFolder = NULL; - if ( !szFolder ) szFolder = getenv( "TEMP" ); - if ( !szFolder ) szFolder = getenv( "TMP" ); - if ( !szFolder ) szFolder = "c:"; - - // Base module name - char chModuleName[_MAX_PATH], *pModuleName = chModuleName; - ::GetModuleFileName( NULL, chModuleName, sizeof( chModuleName ) / sizeof( chModuleName[0] ) ); - - if ( char *pch = strrchr( chModuleName, '.' ) ) - *pch = 0; - if ( char *pch = strrchr( chModuleName, CORRECT_PATH_SEPARATOR ) ) - *pch = 0, pModuleName = pch + 1; - - // Current time - time_t currTime = ::time( NULL ); - struct tm * pTime = ::localtime( &currTime ); - - // Number of minidumps this run - static int s_numMiniDumps = 0; - ++ s_numMiniDumps; - - // Prepare the filename - char chSaveFileName[ 2 * _MAX_PATH ] = { 0 }; - sprintf( chSaveFileName, "%s\\vmpi_%s_on_%s_%d%.2d%2d%.2d%.2d%.2d_%d.mdmp", - szFolder, - pModuleName, - VMPI_GetMachineName( iSource ), - pTime->tm_year + 1900, /* Year less 2000 */ - pTime->tm_mon + 1, /* month (0 - 11 : 0 = January) */ - pTime->tm_mday, /* day of month (1 - 31) */ - pTime->tm_hour, /* hour (0 - 23) */ - pTime->tm_min, /* minutes (0 - 59) */ - pTime->tm_sec, /* seconds (0 - 59) */ - s_numMiniDumps - ); - - if ( FILE *fDump = fopen( chSaveFileName, "wb" ) ) - { - fwrite( pInPos, 1, iFileSize, fDump ); - fclose( fDump ); - - Warning( "\nSaved worker crash minidump '%s', size %d byte(s).\n", - chSaveFileName, iFileSize ); - } - else - { - Warning( "\nReceived worker crash minidump size %d byte(s), failed to save.\n", iFileSize ); - } - } - break; - } - } - return true; - } - - return false; -} - -CDispatchReg g_SharedDispatchReg( VMPI_SHARED_PACKET_ID, SharedDispatch ); - - - -// ----------------------------------------------------------------------------- // -// Module interfaces. -// ----------------------------------------------------------------------------- // - -void SendQDirInfo() -{ - char cPacketID[2] = { VMPI_SHARED_PACKET_ID, VMPI_SUBPACKETID_DIRECTORIES }; - - MessageBuffer mb; - mb.write( cPacketID, 2 ); - mb.write( gamedir, strlen( gamedir ) + 1 ); - mb.write( qdir, strlen( qdir ) + 1 ); - - VMPI_SendData( mb.data, mb.getLen(), VMPI_PERSISTENT ); -} - - -void RecvQDirInfo() -{ - while ( !g_bReceivedDirectoryInfo ) - VMPI_DispatchNextMessage(); -} - - -void SendDBInfo( const CDBInfo *pInfo, unsigned long jobPrimaryID ) -{ - char cPacketInfo[2] = { VMPI_SHARED_PACKET_ID, VMPI_SUBPACKETID_DBINFO }; - const void *pChunks[] = { cPacketInfo, pInfo, &jobPrimaryID }; - int chunkLengths[] = { 2, sizeof( CDBInfo ), sizeof( jobPrimaryID ) }; - - VMPI_SendChunks( pChunks, chunkLengths, ARRAYSIZE( pChunks ), VMPI_PERSISTENT ); -} - - -void RecvDBInfo( CDBInfo *pInfo, unsigned long *pJobPrimaryID ) -{ - while ( !g_bReceivedDBInfo ) - VMPI_DispatchNextMessage(); - - *pInfo = g_DBInfo; - *pJobPrimaryID = g_JobPrimaryID; -} - -// If the file is successfully opened, read and sent returns the size of the file in bytes -// otherwise returns 0 and nothing is sent -int VMPI_SendFileChunk( const void *pvChunkPrefix, int lenPrefix, tchar const *ptchFileName ) -{ - HANDLE hFile = NULL; - HANDLE hMapping = NULL; - void const *pvMappedData = NULL; - int iMappedFileSize = INVALID_FILE_SIZE; - int iResult = 0; - - hFile = ::CreateFile( ptchFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - if ( !hFile || ( hFile == INVALID_HANDLE_VALUE ) ) - goto done; - - hMapping = ::CreateFileMapping( hFile, NULL, PAGE_READONLY, 0, 0, NULL ); - if ( !hMapping || ( hMapping == INVALID_HANDLE_VALUE ) ) - goto done; - - pvMappedData = ::MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 ); - if ( !pvMappedData ) - goto done; - - iMappedFileSize = ::GetFileSize( hFile, NULL ); - if ( INVALID_FILE_SIZE == iMappedFileSize ) - goto done; - - // Send the data over VMPI - if ( VMPI_Send3Chunks( - pvChunkPrefix, lenPrefix, - &iMappedFileSize, sizeof( iMappedFileSize ), - pvMappedData, iMappedFileSize, - VMPI_MASTER_ID ) ) - iResult = iMappedFileSize; - - // Fall-through for cleanup code to execute -done: - if ( pvMappedData ) - ::UnmapViewOfFile( pvMappedData ); - - if ( hMapping && ( hMapping != INVALID_HANDLE_VALUE ) ) - ::CloseHandle( hMapping ); - - if ( hFile && ( hFile != INVALID_HANDLE_VALUE ) ) - ::CloseHandle( hFile ); - - return iResult; -} - -void VMPI_HandleCrash( const char *pMessage, void *pvExceptionInfo, bool bAssert ) -{ - static LONG crashHandlerCount = 0; - if ( InterlockedIncrement( &crashHandlerCount ) == 1 ) - { - Msg( "\nFAILURE: '%s' (assert: %d)\n", pMessage, bAssert ); - - // Send a message to the master. - char crashMsg[4] = { VMPI_SHARED_PACKET_ID, VMPI_SUBPACKETID_CRASH, 't', ':' }; - - VMPI_Send2Chunks( - crashMsg, - sizeof( crashMsg ), - pMessage, - strlen( pMessage ) + 1, - VMPI_MASTER_ID ); - - // Now attempt to create a minidump with the given exception information - if ( pvExceptionInfo ) - { - struct _EXCEPTION_POINTERS *pvExPointers = ( struct _EXCEPTION_POINTERS * ) pvExceptionInfo; - tchar tchMinidumpFileName[_MAX_PATH] = { 0 }; - bool bSucceededWritingMinidump = WriteMiniDumpUsingExceptionInfo( - pvExPointers->ExceptionRecord->ExceptionCode, - pvExPointers, - ( MINIDUMP_TYPE )( MiniDumpWithDataSegs | MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithProcessThreadData ), - // ( MINIDUMP_TYPE )( MiniDumpWithDataSegs | MiniDumpWithFullMemory | MiniDumpWithHandleData | MiniDumpWithUnloadedModules | MiniDumpWithIndirectlyReferencedMemory | MiniDumpWithProcessThreadData | MiniDumpWithPrivateReadWriteMemory ), - // ( MINIDUMP_TYPE )( MiniDumpNormal ), - tchMinidumpFileName ); - if ( bSucceededWritingMinidump ) - { - crashMsg[2] = 'f'; - VMPI_SendFileChunk( crashMsg, sizeof( crashMsg ), tchMinidumpFileName ); - ::DeleteFile( tchMinidumpFileName ); - } - } - - // Let the messages go out. - Sleep( 500 ); - } - - InterlockedDecrement( &crashHandlerCount ); -} - - -// This is called if we crash inside our crash handler. It just terminates the process immediately. -LONG __stdcall VMPI_SecondExceptionFilter( struct _EXCEPTION_POINTERS *ExceptionInfo ) -{ - TerminateProcess( GetCurrentProcess(), 2 ); - return EXCEPTION_EXECUTE_HANDLER; // (never gets here anyway) -} - - -void VMPI_ExceptionFilter( unsigned long uCode, void *pvExceptionInfo ) -{ - // This is called if we crash inside our crash handler. It just terminates the process immediately. - SetUnhandledExceptionFilter( VMPI_SecondExceptionFilter ); - - //DWORD code = ExceptionInfo->ExceptionRecord->ExceptionCode; - - #define ERR_RECORD( name ) { name, #name } - struct - { - DWORD code; - const char *pReason; - } errors[] = - { - ERR_RECORD( EXCEPTION_ACCESS_VIOLATION ), - ERR_RECORD( EXCEPTION_ARRAY_BOUNDS_EXCEEDED ), - ERR_RECORD( EXCEPTION_BREAKPOINT ), - ERR_RECORD( EXCEPTION_DATATYPE_MISALIGNMENT ), - ERR_RECORD( EXCEPTION_FLT_DENORMAL_OPERAND ), - ERR_RECORD( EXCEPTION_FLT_DIVIDE_BY_ZERO ), - ERR_RECORD( EXCEPTION_FLT_INEXACT_RESULT ), - ERR_RECORD( EXCEPTION_FLT_INVALID_OPERATION ), - ERR_RECORD( EXCEPTION_FLT_OVERFLOW ), - ERR_RECORD( EXCEPTION_FLT_STACK_CHECK ), - ERR_RECORD( EXCEPTION_FLT_UNDERFLOW ), - ERR_RECORD( EXCEPTION_ILLEGAL_INSTRUCTION ), - ERR_RECORD( EXCEPTION_IN_PAGE_ERROR ), - ERR_RECORD( EXCEPTION_INT_DIVIDE_BY_ZERO ), - ERR_RECORD( EXCEPTION_INT_OVERFLOW ), - ERR_RECORD( EXCEPTION_INVALID_DISPOSITION ), - ERR_RECORD( EXCEPTION_NONCONTINUABLE_EXCEPTION ), - ERR_RECORD( EXCEPTION_PRIV_INSTRUCTION ), - ERR_RECORD( EXCEPTION_SINGLE_STEP ), - ERR_RECORD( EXCEPTION_STACK_OVERFLOW ), - ERR_RECORD( EXCEPTION_ACCESS_VIOLATION ), - }; - - int nErrors = sizeof( errors ) / sizeof( errors[0] ); - int i=0; - const char *pchReason = nullptr; - char chUnknownBuffer[32]; - for ( i; ( i < nErrors ) && !pchReason; i++ ) - { - if ( errors[i].code == uCode ) - pchReason = errors[i].pReason; - } - - if ( i == nErrors ) - { - sprintf( chUnknownBuffer, "Error code 0x%08lX", uCode ); - pchReason = chUnknownBuffer; - } - - VMPI_HandleCrash( pchReason, pvExceptionInfo, true ); - - TerminateProcess( GetCurrentProcess(), 1 ); -} - - -void HandleMPIDisconnect( int procID, const char *pReason ) -{ - int nLiveWorkers = VMPI_GetCurrentNumberOfConnections() - g_nDisconnects - 1; - - // We ran into the size limit before and it wasn't readily apparent that the size limit had - // been breached, so make sure to show errors about invalid packet sizes.. - bool bOldSuppress = g_bSuppressPrintfOutput; - g_bSuppressPrintfOutput = ( Q_stristr( pReason, "invalid packet size" ) == 0 ); - - Warning( "\n\n--- WARNING: lost connection to '%s' (%s).\n", VMPI_GetMachineName( procID ), pReason ); - - if ( g_bMPIMaster ) - { - Warning( "%d workers remain.\n\n", nLiveWorkers ); - - ++g_nDisconnects; - /* - if ( VMPI_GetCurrentNumberOfConnections() - g_nDisconnects <= 1 ) - { - Error( "All machines disconnected!" ); - } - */ - } - else - { - VMPI_HandleAutoRestart(); - Error( "Worker quitting." ); - } - - g_bSuppressPrintfOutput = bOldSuppress; -} - - diff --git a/src/utils/common/vmpi_tools_shared.h b/src/utils/common/vmpi_tools_shared.h deleted file mode 100644 index 980552e8a8..0000000000 --- a/src/utils/common/vmpi_tools_shared.h +++ /dev/null @@ -1,45 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#ifndef VMPI_TOOLS_SHARED_H -#define VMPI_TOOLS_SHARED_H -#ifdef _WIN32 -#pragma once -#endif - - -// Packet IDs. - #define VMPI_SUBPACKETID_DIRECTORIES 0 // qdir directories. - #define VMPI_SUBPACKETID_DBINFO 1 // MySQL database info. - #define VMPI_SUBPACKETID_CRASH 3 // A worker saying it crashed. - #define VMPI_SUBPACKETID_MULTICAST_ADDR 4 // Filesystem multicast address. - - -class CDBInfo; -class CIPAddr; - - -// Send/receive the qdir info. -void SendQDirInfo(); -void RecvQDirInfo(); - -void SendDBInfo( const CDBInfo *pInfo, unsigned long jobPrimaryID ); -void RecvDBInfo( CDBInfo *pInfo, unsigned long *pJobPrimaryID ); - -void SendMulticastIP( const CIPAddr *pAddr ); -void RecvMulticastIP( CIPAddr *pAddr ); - -void VMPI_HandleCrash( const char *pMessage, void *pvExceptionInfo, bool bAssert ); - -// Call this from an exception handler (set by SetUnhandledExceptionHandler). -// uCode = ExceptionInfo->ExceptionRecord->ExceptionCode. -// pvExceptionInfo = ExceptionInfo -void VMPI_ExceptionFilter( unsigned long uCode, void *pvExceptionInfo ); - -void HandleMPIDisconnect( int procID, const char *pReason ); - - -#endif // VMPI_TOOLS_SHARED_H diff --git a/src/utils/vbsp/CMakeLists.txt b/src/utils/vbsp/CMakeLists.txt index 237957bb57..477b3afe8f 100644 --- a/src/utils/vbsp/CMakeLists.txt +++ b/src/utils/vbsp/CMakeLists.txt @@ -7,13 +7,16 @@ target_include_directories(vbsp PRIVATE ${CMAKE_SOURCE_DIR}/utils ${CMAKE_SOURCE_DIR}/utils/common - ${CMAKE_SOURCE_DIR}/utils/vmpi ) target_compile_definitions(vbsp PRIVATE MACRO_MATHLIB PROTECTED_THINGS_DISABLE + + DX_TO_GL_ABSTRACTION + USE_SDL + ALLOW_NOSHADERAPI ) if(OS_WINDOWS) @@ -184,7 +187,6 @@ target_sources_grouped( ../common/pacifier.h ../common/polylib.h ../common/utilmatlib.h - ../vmpi/vmpi.h disp_ivp.h ivp.h ) diff --git a/src/utils/vmpi/CMakeLists.txt b/src/utils/vmpi/CMakeLists.txt deleted file mode 100644 index ca4676545a..0000000000 --- a/src/utils/vmpi/CMakeLists.txt +++ /dev/null @@ -1,84 +0,0 @@ -add_library(vmpi STATIC) - -add_library(vmpi::vmpi ALIAS vmpi) - -set_target_properties(vmpi PROPERTIES PREFIX "") - -target_include_directories(vmpi - PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/utils/common - ${CMAKE_SOURCE_DIR}/thirdparty/libcurl/include - ZLib -) - -target_compile_definitions(vmpi - PRIVATE - PROTECTED_THINGS_DISABLE -) - -if(NEO_VMPI) - target_compile_definitions(vmpi - PUBLIC - MPI - ) -endif() - -target_link_libraries(vmpi - PUBLIC - ZLib.lib - CURL::libcurl_static - - PRIVATE - tier1::tier1 - vstdlib::vstdlib - libz::libz -) - -target_link_directories(vmpi - PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) - -target_sources_grouped( - TARGET vmpi - NAME "Source Files" - FILES - ${CMAKE_SOURCE_DIR}/public/filesystem_init.cpp - ../common/filesystem_tools.cpp - ThreadedTCPSocket.cpp - ThreadedTCPSocketEmu.cpp - iphelpers.cpp - loopback_channel.cpp - messbuf.cpp - threadhelpers.cpp - vmpi.cpp - vmpi_distribute_tracker.cpp - vmpi_distribute_work.cpp - vmpi_distribute_work_default.cpp - vmpi_distribute_work_sdk.cpp - vmpi_filesystem.cpp - vmpi_filesystem_internal.h - vmpi_filesystem_master.cpp - vmpi_filesystem_worker.cpp - vmpi_logfile.cpp - vmpi_logfile.h -) - -target_sources_grouped( - TARGET vmpi - NAME "Header Files" - FILES - ${CMAKE_SOURCE_DIR}/public/tier1/bitbuf.h - IThreadedTCPSocket.h - ThreadedTCPSocketEmu.h - ichannel.h - iphelpers.h - loopback_channel.h - messbuf.h - tcpsocket.h - threadhelpers.h - vmpi.h - vmpi_defs.h - vmpi_filesystem.h -) diff --git a/src/utils/vmpi/IThreadedTCPSocket.h b/src/utils/vmpi/IThreadedTCPSocket.h deleted file mode 100644 index eef4fb326c..0000000000 --- a/src/utils/vmpi/IThreadedTCPSocket.h +++ /dev/null @@ -1,180 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef ITHREADEDTCPSOCKET_H -#define ITHREADEDTCPSOCKET_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "iphelpers.h" - - -class IThreadedTCPSocket; - - -class CTCPPacket -{ -public: - // Access the contents of the packet. - const char* GetData() const; - int GetLen() const; - - // You can attach some user data to the packet. - int GetUserData() const; - void SetUserData( int userData ); - - // Free resources associated with the packet. - void Release(); - -public: - friend class CThreadedTCPSocket; - ~CTCPPacket(); // Use Release(), not delete. - - int m_UserData; - int m_Len; - char m_Data[1]; -}; - - -inline const char* CTCPPacket::GetData() const -{ - return m_Data; -} - - -inline int CTCPPacket::GetLen() const -{ - return m_Len; -} - - -// The application implements this to handle packets that are received. -// Note that the implementation must be thread-safe because these functions can be called -// from various threads. -class ITCPSocketHandler -{ -public: - - enum - { - SocketError=0, - ConnectionTimedOut - }; - - // This is called right when the socket becomes ready to have data sent through it and - // before OnPacketReceive is ever called. - virtual void Init( IThreadedTCPSocket *pSocket ) = 0; - - // This is called when a packet arrives. NOTE: you are responsible for freeing the packet - // by calling CTCPPacket::Release() on it. - virtual void OnPacketReceived( CTCPPacket *pPacket ) = 0; - - // Handle errors inside the socket. After this is called, the socket is no longer alive. - // Note: this might be called from ANY thread (the main thread, the send thread, or the receive thread). - // - // errorCode is one of the enums above (SocketError, ConnectionTimedOut, etc). - virtual void OnError( int errorCode, const char *pErrorString ) = 0; - - virtual void Release( bool bForce = false ) = 0; - - virtual int GetConnectionID( ) = 0; -}; - - -// -// This is the main threaded TCP socket class. -// The way these work is that they have a thread for sending and a thread for receiving data. -// -// The send thread is continually pushing your data out the door. -// -// The receive thread is continually receiving data. When it receives data, it calls your HandlePacketFn -// to allow the user to handle it. Be very careful in your HandlePacketFn, since it is in another thread. -// Anything it accesses should be protected by mutexes and the like. -// -class IThreadedTCPSocket -{ -public: - // Cleanup everything and exit. - // Note: if the receive thread is inside your HandlePacketFn returns, this function blocks until that function returns. - virtual void Release() = 0; - - // Returns the address of whoever you are connected to. - virtual CIPAddr GetRemoteAddr() const = 0; - - // Returns true if the socket is connected and ready to go. If this returns false, then the socket won't - // send or receive data any more. It also means that your ITCPSocketHandler's OnError function has been called. - virtual bool IsValid() = 0; - - // Send data. Any thread can call these functions, and they don't block. They make a copy of the data, then - // enqueue it for sending. - virtual bool Send( const void *pData, int len ) = 0; - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) = 0; - - virtual ITCPSocketHandler *GetHandler( ) = 0; -}; - - - -// Use these to get incoming connections. -class ITCPConnectSocket -{ -public: - // Call this to stop listening for connections and delete the object. - virtual void Release() = 0; - - // Keep calling this as long as you want to wait for connections. - // - // If it returns true and pSocket is NULL, it means it hasn't connected yet. - // If it returns true and pSocket is non-NULL, then it has connected. - // If it returns false, then the connection attempt failed and all further Update() calls will return false. - virtual bool Update( IThreadedTCPSocket **pSocket, unsigned long milliseconds=0 ) = 0; -}; - - -// This class is implemented by the app and passed into CreateListener. When the listener makes -// a new connection, it calls CreateNewHandler() to have the app create something that will handle -// the received packets and errors for the new socket. -class IHandlerCreator -{ -public: - // This function must return a valid value. - virtual ITCPSocketHandler* CreateNewHandler() = 0; - virtual bool DeleteHandlersOnTerm() { return true; } -}; - - -// Use this to listen for TCP connections. The ITCPConnectSocket will keep returning connections -// until you call Release(). -ITCPConnectSocket* ThreadedTCP_CreateListener( - IHandlerCreator *pHandlerCreator, // This handles messages from the socket. - const unsigned short port, // Listen on this port. - int nQueueLength = 5 // How many connections - ); - - -// Use this to connect to a remote process. After Update() returns a non-NULL value, you should -// call Release() on the ITCPConnectSocket because it won't ever return another connection. -ITCPConnectSocket* ThreadedTCP_CreateConnector( - const CIPAddr &addr, // Who to connect to. - const CIPAddr &localAddr, // Local address to bind to. Leave uninitialized (pass in CIPAddr()) and it will - // an interface and a port for you. You can also just fill in the port, and it will - // use that port and choose an interface for you. - IHandlerCreator *pHandlerCreator// If it connects, it asks this thing to make a handler for the connection. - ); - - -// Enable or disable timeouts. -void ThreadedTCP_EnableTimeouts( bool bEnable ); - -// This should be called at init time. If set to true, it'll set the send and recv threads to low priority. -// (Default is true). -void ThreadedTCP_SetTCPSocketThreadPriorities( bool bSetTCPSocketThreadPriorities ); - - -#endif // ITHREADEDTCPSOCKET_H diff --git a/src/utils/vmpi/ThreadedTCPSocket.cpp b/src/utils/vmpi/ThreadedTCPSocket.cpp deleted file mode 100644 index bb46411b72..0000000000 --- a/src/utils/vmpi/ThreadedTCPSocket.cpp +++ /dev/null @@ -1,1095 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// ThreadedTCPSocket.cpp : Defines the entry point for the console application. -// - -#include -#include -#include "IThreadedTCPSocket.h" -#include "utllinkedlist.h" -#include "threadhelpers.h" -#include "iphelpers.h" -#include "tier1/strtools.h" - - -#define SEND_KEEPALIVE_INTERVAL 3000 -#define KEEPALIVE_TIMEOUT 25000 // The sockets timeout after this long. - -#define KEEPALIVE_SENTINEL -12345 // When first 4 bytes of a packet = this, then it's just a keepalive. - - -static int g_KeepaliveSentinel = KEEPALIVE_SENTINEL; -bool g_bHandleTimeouts = true; - -// If true, it'll set the socket thread priorities lower than normal. -bool g_bSetTCPSocketThreadPriorities = true; - -// We get crashes at runtime if they don't link in the multithreaded runtime libraries, -// so raise a ruckus if they're using singlethreaded libraries. -#ifndef _MT - #pragma message( "**** WARNING **** ThreadedTCPSocket requires multithreaded runtime libraries to be used.\n" ) - class MTChecker - { - public: - MTChecker() { Assert( false ); } - } g_MTChecker; -#endif - - - -// ------------------------------------------------------------------------------------------------ // -// Static helpers. -// ------------------------------------------------------------------------------------------------ // -static SOCKET TCPBind( const CIPAddr *pAddr ) -{ - // Create a socket to send and receive through. - SOCKET sock = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED ); - if ( sock == INVALID_SOCKET ) - { - Assert( false ); - return INVALID_SOCKET; - } - - // bind to it! - sockaddr_in addr; - IPAddrToSockAddr( pAddr, &addr ); - - int status = bind( sock, (sockaddr*)&addr, sizeof(addr) ); - if ( status == 0 ) - { - return sock; - } - else - { - closesocket( sock ); - return INVALID_SOCKET; - } -} - - - -// ------------------------------------------------------------------------------------------------ // -// CTCPPacket. -// ------------------------------------------------------------------------------------------------ // - -int CTCPPacket::GetUserData() const -{ - return m_UserData; -} - -void CTCPPacket::SetUserData( int userData ) -{ - m_UserData = userData; -} - -void CTCPPacket::Release() -{ - free( this ); -} - - -// ------------------------------------------------------------------------------------------------ // -// CThreadedTCPSocket. -// ------------------------------------------------------------------------------------------------ // -class CThreadedTCPSocket : public IThreadedTCPSocket -{ -public: - - static IThreadedTCPSocket* Create( SOCKET iSocket, CIPAddr remoteAddr, ITCPSocketHandler *pHandler, bool bDeleteHandler ) - { - CThreadedTCPSocket *pRet = new CThreadedTCPSocket; - if ( pRet->Init( iSocket, remoteAddr, pHandler, bDeleteHandler ) ) - { - return pRet; - } - else - { - pRet->Release(); - return NULL; - } - } - - -// IThreadedTCPSocket implementation. -public: - - virtual void Release() - { - delete this; - } - - virtual CIPAddr GetRemoteAddr() const - { - return m_RemoteAddr; - } - - virtual bool IsValid() - { - return !CheckErrorSignal(); - } - - virtual bool Send( const void *pData, int len ) - { - const void *pChunks[1] = { pData }; - return SendChunks( pChunks, &len, 1 ); - } - - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) - { - if ( CheckErrorSignal() ) - return false; - - return InternalSend( pChunks, pChunkLengths, nChunks, true ); - } - - virtual ITCPSocketHandler *GetHandler( ) { return m_pHandler; } - - -// Initialization. -private: - - CThreadedTCPSocket() - { - m_Socket = INVALID_SOCKET; - m_pHandler = NULL; - memset( &m_SendOverlapped, 0, sizeof( m_SendOverlapped ) ); - memset( &m_RecvOverlapped, 0, sizeof( m_RecvOverlapped ) ); - m_bWaitingForSendCompletion = false; - m_nBytesToReceive = -1; - m_bWaitingForSize = false; - m_bErrorSignal = false; - m_pRecvBuffer = NULL; - } - - virtual ~CThreadedTCPSocket() - { - Term(); - } - - bool Init( SOCKET iSocket, CIPAddr remoteAddr, ITCPSocketHandler *pHandler, bool bDeleteHandler ) - { - m_Socket = iSocket; - m_RemoteAddr = remoteAddr; - m_pHandler = pHandler; - m_bDeleteHandler = bDeleteHandler; - - SetInitialSocketOptions(); - - // Create all the event objects we'll use to communicate. - m_hExitThreadsEvent.Init( true, false ); - m_hSendCompletionEvent.Init( false, false ); - m_hReadyToSendEvent.Init( false, false ); - m_hRecvEvent.Init( false, false ); - - m_SendOverlapped.hEvent = m_hSendCompletionEvent.GetEventHandle(); - m_RecvOverlapped.hEvent = m_hRecvEvent.GetEventHandle(); - - // Create our threads. - DWORD dwSendThreadID, dwRecvThreadID; - m_hSendThread = CreateThread( NULL, 0, &CThreadedTCPSocket::StaticSendThreadFn, this, CREATE_SUSPENDED, &dwSendThreadID ); - m_hRecvThread = CreateThread( NULL, 0, &CThreadedTCPSocket::StaticRecvThreadFn, this, CREATE_SUSPENDED, &dwRecvThreadID ); - if ( !m_hSendThread || !m_hRecvThread ) - { - return false; - } - - if ( g_bSetTCPSocketThreadPriorities ) - { - SetThreadPriority( m_hSendThread, THREAD_PRIORITY_LOWEST ); - SetThreadPriority( m_hRecvThread, THREAD_PRIORITY_LOWEST ); - } - - //ThreadSetDebugName( (ThreadHandle_t)m_hSendThread, "TCPSend" ); - //ThreadSetDebugName( (ThreadHandle_t)m_hRecvThread, "TCPRecv" ); - - // Make sure to init the handler before the threads actually run, so it isn't handed data before initializing. - m_pHandler->Init( this ); - - ResumeThread( m_hSendThread ); - ResumeThread( m_hRecvThread ); - - return true; - } - - void Term() - { - // Signal our threads to exit. - m_hExitThreadsEvent.SetEvent(); - if ( m_hSendThread ) - { - WaitForSingleObject( m_hSendThread, INFINITE ); - CloseHandle( m_hSendThread ); - m_hSendThread = NULL; - } - - if ( m_hRecvThread ) - { - WaitForSingleObject( m_hRecvThread, INFINITE ); - CloseHandle( m_hRecvThread ); - m_hRecvThread = NULL; - } - m_hExitThreadsEvent.ResetEvent(); - - - if ( m_Socket != INVALID_SOCKET ) - { - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - } - - if ( m_bDeleteHandler == true && m_pHandler != NULL ) - { - m_pHandler->Release(); - m_pHandler = NULL; - } - } - - // Set the initial socket options that we want. - void SetInitialSocketOptions() - { - // Set nodelay to improve latency. - BOOL val = TRUE; - setsockopt( m_Socket, IPPROTO_TCP, TCP_NODELAY, (const char FAR *)&val, sizeof(BOOL) ); - - // Make it linger for 3 seconds when it exits. - LINGER linger; - linger.l_onoff = 1; - linger.l_linger = 3; - setsockopt( m_Socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof( linger ) ); - } - - -// Send thread functionality. -private: - - // This function copies off the payload and adds a SendChunk_t to the list of chunks to be sent. - // It also fires the ReadyToSend event so the thread will pick it up. - bool InternalSend( void const * const *pChunks, const int *pChunkLengths, int nChunks, bool bPrependLength ) - { - int totalLength = 0; - for ( int i=0; i < nChunks; i++ ) - totalLength += pChunkLengths[i]; - - if ( bPrependLength ) - { - if ( totalLength == 0 ) - return true; - - totalLength += 4; - } - - // Copy all the data into a SendData_t. - SendData_t *pSendData = (SendData_t*)malloc( sizeof( SendData_t ) - 1 + totalLength ); - pSendData->m_Len = totalLength; - - char *pOut = pSendData->m_Payload; - if ( bPrependLength ) - { - *((int*)pOut) = totalLength - 4; // The length we prepend is the size of the data, not data size + integer for length. - pOut += 4; - } - for ( int i=0; i < nChunks; i++ ) - { - memcpy( pOut, pChunks[i], pChunkLengths[i] ); - pOut += pChunkLengths[i]; - } - - CVMPICriticalSectionLock csLock( &m_SendCS ); - csLock.Lock(); - - m_SendDatas.AddToTail( pSendData ); - m_hReadyToSendEvent.SetEvent(); // Notify the thread that there is data to send. - - csLock.Unlock(); - - return true; - } - - void SendThread_HandleTimeout() - { - // Timeout.. send a keepalive. - // But only if we're not already sending something. - CVMPICriticalSectionLock csLock( &m_SendCS ); - csLock.Lock(); - int count = m_SendDatas.Count(); - csLock.Unlock(); - - if ( count == 0 ) - { - void *pBuf[1] = { &g_KeepaliveSentinel }; - int len[1] = { sizeof( g_KeepaliveSentinel ) }; - InternalSend( pBuf, len, 1, false ); - } - } - - bool SendThread_HandleSendCompletionEvent() - { - Assert( m_bWaitingForSendCompletion ); - m_bWaitingForSendCompletion = false; - - // A send operation just completed. Now do the next one. - DWORD cbTransfer, flags; - if ( !WSAGetOverlappedResult( m_Socket, &m_SendOverlapped, &cbTransfer, TRUE, &flags ) ) - { - HandleError( WSAGetLastError() ); - return false; - } - - if ( cbTransfer != m_nBytesToTransfer ) - { - char str[512]; - Q_snprintf( str, sizeof( str ), "Invalid # bytes transferred (%d) in send thread (should be %d)", cbTransfer, m_nBytesToTransfer ); - HandleError( ITCPSocketHandler::SocketError, str ); - return false; - } - - // Remove the block we just sent. - CVMPICriticalSectionLock csLock( &m_SendCS ); - csLock.Lock(); - - SendData_t *pSendData = m_SendDatas[ m_SendDatas.Head() ]; - free( pSendData ); - m_SendDatas.Remove( m_SendDatas.Head() ); - - m_bWaitingForSendCompletion = false; - - // Set our send event if there's anything else to send. - if ( m_SendDatas.Count() > 0 ) - m_hReadyToSendEvent.SetEvent(); - - csLock.Unlock(); - return true; - } - - bool SendThread_HandleReadyToSendEvent() - { - // We've got at least one buffer that's ready to be sent. - // NOTE: don't send anything until our current send is completed. - CVMPICriticalSectionLock csLock( &m_SendCS ); - csLock.Lock(); - - Assert( !m_bWaitingForSendCompletion ); - - // Send it off! - SendData_t *pSendData = m_SendDatas[ m_SendDatas.Head() ]; - WSABUF buf = { pSendData->m_Len, pSendData->m_Payload }; - - m_nBytesToTransfer = pSendData->m_Len; - m_bWaitingForSendCompletion = true; - - csLock.Unlock(); - - DWORD dwNumBytesSent = 0; - DWORD ret = WSASend( m_Socket, &buf, 1, &dwNumBytesSent, 0, &m_SendOverlapped, NULL ); - DWORD err = WSAGetLastError(); - if ( ret == 0 || ( ret == SOCKET_ERROR && err == WSA_IO_PENDING ) ) - { - // Either way, the operation completed successfully, and m_hSendCompletionEvent is now set. - return true; - } - else - { - HandleError( err ); - return false; - } - - return true; - } - - DWORD SendThreadFn() - { - while ( 1 ) - { - HANDLE handles[] = - { - m_hExitThreadsEvent.GetEventHandle(), - m_hSendCompletionEvent.GetEventHandle(), - m_hReadyToSendEvent.GetEventHandle() - }; - int nHandles = ARRAYSIZE( handles ); - - // While waiting for send completion, don't handle "ready to send" events. - if ( m_bWaitingForSendCompletion ) - --nHandles; - - DWORD waitValue = WaitForMultipleObjects( nHandles, handles, FALSE, SEND_KEEPALIVE_INTERVAL ); - switch ( waitValue ) - { - case WAIT_TIMEOUT: - { - if ( g_bHandleTimeouts ) - { - // We haven't sent anything in a bit. Send out a keepalive. - SendThread_HandleTimeout(); - } - } - break; - - case WAIT_OBJECT_0: - { - // The main thread is signaling us to exit. - return 0; - } - - case WAIT_OBJECT_0 + 1: - { - if ( !SendThread_HandleSendCompletionEvent() ) - return 1; - } - break; - - case WAIT_OBJECT_0 + 2: - { - if ( !SendThread_HandleReadyToSendEvent() ) - return 1; - } - break; - - case WAIT_FAILED: - { - // Uh oh. We're dead. Cleanup and signal an error. - HandleError( GetLastError() ); - return 1; - } - - default: - { - char str[512]; - Q_snprintf( str, sizeof( str ), "Unknown return value (%lu) from WaitForMultipleObjects", waitValue ); - HandleError( ITCPSocketHandler::SocketError, str ); - return 0; - } - } - } - - return 0; - } - - static DWORD WINAPI StaticSendThreadFn( LPVOID pParameter ) - { - return ((CThreadedTCPSocket*)pParameter)->SendThreadFn(); - } - - -// Receive thread functionality. -private: - - bool RecvThread_WaitToReceiveSize() - { - return RecvThread_InternalRecv( &m_NextPacketLen, sizeof( m_NextPacketLen ), false, true ); - } - - - bool RecvThread_InternalHandleRecvCompletion( DWORD dwTransfer ) - { - int cbTransfer = (int)dwTransfer; - int nBytesWanted = m_nBytesToReceive - m_nBytesReceivedSoFar; - if ( cbTransfer > nBytesWanted ) - { - char str[512]; - Q_snprintf( str, sizeof( str ), "Invalid # bytes received (%d) in recv thread (should be %d)", cbTransfer, m_nBytesToReceive ); - HandleError( ITCPSocketHandler::SocketError, str ); - return false; - } - else if ( cbTransfer < nBytesWanted ) - { - // We have to reissue the receive command because it didn't receive all the data. - m_nBytesReceivedSoFar += cbTransfer; - - char *pDest = (char*)&m_NextPacketLen; - if ( !m_bWaitingForSize ) - { - Assert( m_pRecvBuffer ); - pDest = m_pRecvBuffer->m_Data; - } - - return RecvThread_InternalRecv( &pDest[m_nBytesReceivedSoFar], m_nBytesToReceive - m_nBytesReceivedSoFar, true ); - } - - if ( m_bWaitingForSize ) - { - // If we were waiting for size, now wait for the data. - if ( m_NextPacketLen == KEEPALIVE_SENTINEL ) - { - // Ok, it was just a keepalive. Wait for size again. - return RecvThread_WaitToReceiveSize(); - } - else - { - if ( m_NextPacketLen < 1 || m_NextPacketLen > 1024*1024*75 ) - { - char str[512]; - Q_snprintf( str, sizeof( str ), "Invalid packet size in RecvThread (size = %d)", m_NextPacketLen ); - HandleError( ITCPSocketHandler::SocketError, str ); - return false; - } - else - { - Assert( !m_pRecvBuffer ); - m_pRecvBuffer = (CTCPPacket*)malloc( sizeof( CTCPPacket ) - 1 + m_NextPacketLen ); - m_pRecvBuffer->m_UserData = 0; - m_pRecvBuffer->m_Len = m_NextPacketLen; - - return RecvThread_InternalRecv( m_pRecvBuffer->m_Data, m_pRecvBuffer->m_Len, false, false ); - } - } - } - else - { - // Got a packet! Give it to the app. - m_pHandler->OnPacketReceived( m_pRecvBuffer ); - m_pRecvBuffer = NULL; - - return RecvThread_WaitToReceiveSize(); - } - } - - bool RecvThread_HandleRecvCompletionEvent() - { - // A send operation just completed. Now do the next one. - DWORD cbTransfer, flags; - if ( !WSAGetOverlappedResult( m_Socket, &m_RecvOverlapped, &cbTransfer, TRUE, &flags ) ) - { - HandleError( WSAGetLastError() ); - return false; - } - - return RecvThread_InternalHandleRecvCompletion( cbTransfer ); - } - - bool RecvThread_InternalRecv( void *pDest, int destSize, bool bContinuation, bool bWaitingForSize = false ) - { - WSABUF buf = { destSize, (char*)pDest }; - - if ( !bContinuation ) - { - // If this is not a continuation of whatever we were receiving before, then - m_bWaitingForSize = bWaitingForSize; - m_nBytesToReceive = destSize; - m_nBytesReceivedSoFar = 0; - } - - DWORD dwFlags = 0; - DWORD nBytesReceived = 0; - DWORD ret = WSARecv( m_Socket, &buf, 1, &nBytesReceived, &dwFlags, &m_RecvOverlapped, NULL ); - DWORD dwLastError = WSAGetLastError(); - if ( ret == 0 || ( ret == SOCKET_ERROR && dwLastError == WSA_IO_PENDING ) ) - { - // Note: m_hRecvEvent is in a signaled state, so the RecvThread will pick up the results next time around. - return true; - } - else - { - HandleError( dwLastError ); - return false; - } - } - - - - DWORD RecvThreadFn() - { - // Start us off by setting up to receive the first packet size. - if ( !RecvThread_WaitToReceiveSize() ) - return 1; - - HANDLE handles[] = - { - m_hExitThreadsEvent.GetEventHandle(), - m_hRecvEvent.GetEventHandle() - }; - - while ( 1 ) - { - DWORD waitValue = WaitForMultipleObjects( ARRAYSIZE( handles ), handles, FALSE, KEEPALIVE_TIMEOUT ); - switch ( waitValue ) - { - case WAIT_TIMEOUT: - { - if ( g_bHandleTimeouts ) - { - HandleError( ITCPSocketHandler::ConnectionTimedOut, "Connection timed out" ); - return 1; - } - } - break; - - case WAIT_OBJECT_0: - { - // We're being told to exit. - return 0; - } - - case WAIT_OBJECT_0 + 1: - { - // Just finished receiving something. - if ( !RecvThread_HandleRecvCompletionEvent() ) - return 1; - } - break; - - case WAIT_FAILED: - { - // Uh oh. We're dead. Cleanup and signal an error. - HandleError( GetLastError() ); - return 1; - } - - default: - { - char str[512]; - Q_snprintf( str, sizeof( str ), "Unknown return value (%lu) from WaitForMultipleObjects", waitValue ); - HandleError( ITCPSocketHandler::SocketError, str ); - return 1; - } - } - } - - return 0; - } - - static DWORD WINAPI StaticRecvThreadFn( LPVOID pParameter ) - { - return ((CThreadedTCPSocket*)pParameter)->RecvThreadFn(); - } - - - -// Error handling. -private: - - // This checks to see if either thread has signaled an error. If so, it shuts down the socket and returns true. - bool CheckErrorSignal() - { - return m_bErrorSignal; - } - - // This is called from any of the threads and signals that something went awry. It shuts down the object - // and makes it return false from all of its functions. - void HandleError( DWORD errorValue ) - { - char *lpMsgBuf; - - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (char*)&lpMsgBuf, - 0, - NULL - ); - - // Windows likes to stick a carriage return in there and we don't want it so get rid of it. - int len = strlen( lpMsgBuf ); - while ( len > 0 && ( lpMsgBuf[len-1] == '\n' || lpMsgBuf[len-1] == '\r' ) ) - { - --len; - lpMsgBuf[len] = 0; - } - - HandleError( ITCPSocketHandler::SocketError, lpMsgBuf ); - - LocalFree( lpMsgBuf ); - } - - - void HandleError( int errorCode, const char *pErrorString ) - { - //Assert( false ); - - // Tell the app. - m_pHandler->OnError( errorCode, pErrorString ); - - // Tell the threads to exit. - m_hExitThreadsEvent.SetEvent(); - - // Notify the main thread so it can call Term() when it gets a chance. - m_bErrorSignal = true; - } - - -private: - - // Data for the send thread. - typedef struct - { - //WSAOVERLAPPED m_Overlapped; - int m_Len; - char m_Payload[1]; - } SendData_t; - - HANDLE m_hSendThread; - WSAOVERLAPPED m_SendOverlapped; - CEvent m_hReadyToSendEvent; - CEvent m_hSendCompletionEvent; - - CVMPICriticalSection m_SendCS; - DWORD m_nBytesToTransfer; - bool m_bWaitingForSendCompletion; - CUtlLinkedList m_SendDatas; // Added to the tail, popped off the head for sending. - - - // Data for the recv thread. - HANDLE m_hRecvThread; - int m_nBytesToReceive; // This stores how many bytes we want to receive for the next packet. - int m_nBytesReceivedSoFar; // This stores how many bytes we've received so far. - bool m_bWaitingForSize; // This tells if we're trying to receive the next packet length or the next packet's data. - - int m_NextPacketLen; // Data is received INTO here before it receives each packet. This - // holds the length of each incoming packet. - - WSAOVERLAPPED m_RecvOverlapped; - CEvent m_hRecvEvent; - CTCPPacket *m_pRecvBuffer; // This is allocated for each packet we're receiving and given to the - // app when the packet is done being received. - - - volatile bool m_bErrorSignal; - - - CEvent m_hExitThreadsEvent; - - ITCPSocketHandler *m_pHandler; - bool m_bDeleteHandler; - - SOCKET m_Socket; - CIPAddr m_RemoteAddr; -}; - - -// ------------------------------------------------------------------------------------------------ // -// CTCPConnectSocket_Listener -// ------------------------------------------------------------------------------------------------ // -class CTCPConnectSocket_Listener : public ITCPConnectSocket -{ -public: - CTCPConnectSocket_Listener() - { - m_Socket = INVALID_SOCKET; - } - - - virtual ~CTCPConnectSocket_Listener() - { - if ( m_Socket != INVALID_SOCKET ) - { - closesocket( m_Socket ); - } - } - - - // The main function to create one of these suckers. - static ITCPConnectSocket* Create( - IHandlerCreator *pHandlerCreator, - const unsigned short port, - int nQueueLength - ) - { - CTCPConnectSocket_Listener *pRet = new CTCPConnectSocket_Listener; - if ( !pRet ) - return NULL; - - if ( nQueueLength < 0 ) - { - Error( "CTCPConnectSocket_Listener::Create - SOMAXCONN not allowed - causes some XP SP2 systems to stop receiving any network data (systemwide)." ); - } - - // Bind it to a socket and start listening. - CIPAddr addr( 0, 0, 0, 0, port ); // INADDR_ANY - pRet->m_Socket = TCPBind( &addr ); - if ( pRet->m_Socket == INVALID_SOCKET || - listen( pRet->m_Socket, nQueueLength == -1 ? SOMAXCONN : nQueueLength ) != 0 ) - { - pRet->Release(); - return nullptr; - } - - pRet->m_pHandler = pHandlerCreator; - return pRet; - } - - -// ITCPConnectSocket implementation. -public: - - virtual void Release() - { - delete this; - } - - virtual bool Update( IThreadedTCPSocket **pSocket, unsigned long milliseconds ) - { - *pSocket = NULL; - if ( m_Socket == INVALID_SOCKET ) - return false; - - // We're still ok.. just wait until the socket becomes writable (is connected) or we timeout. - fd_set readSet; - readSet.fd_count = 1; - readSet.fd_array[0] = m_Socket; - TIMEVAL timeVal = {0, milliseconds*1000}; - - // Wait until it connects. - int status = select( 0, &readSet, NULL, NULL, &timeVal ); - if ( status > 0 ) - { - sockaddr_in addr; - int addrSize = sizeof( addr ); - - // Now accept the final connection. - SOCKET newSock = accept( m_Socket, (struct sockaddr*)&addr, &addrSize ); - if ( newSock == INVALID_SOCKET ) - { - Assert( false ); - return true; - } - else - { - CIPAddr connectedAddr; - SockAddrToIPAddr( &addr, &connectedAddr ); - - IThreadedTCPSocket *pRet = CThreadedTCPSocket::Create( newSock, connectedAddr, m_pHandler->CreateNewHandler(), true ); - if ( !pRet ) - { - Assert( false ); - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - return false; - } - - *pSocket = pRet; - return true; - } - } - else if ( status == SOCKET_ERROR ) - { - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - return false; - } - else - { - return true; - } - } - - -private: - SOCKET m_Socket; - - IHandlerCreator *m_pHandler; -}; - - - -ITCPConnectSocket* ThreadedTCP_CreateListener( - IHandlerCreator *pHandlerCreator, - const unsigned short port, - int nQueueLength - ) -{ - return CTCPConnectSocket_Listener::Create( pHandlerCreator, port, nQueueLength ); -} - - - -// ------------------------------------------------------------------------------------------------ // -// CTCPConnectSocket_Connector -// ------------------------------------------------------------------------------------------------ // -class CTCPConnectSocket_Connector : public ITCPConnectSocket -{ -public: - - CTCPConnectSocket_Connector() - { - m_bConnected = false; - m_Socket = INVALID_SOCKET; - m_bError = false; - } - - virtual ~CTCPConnectSocket_Connector() - { - if ( m_Socket != INVALID_SOCKET ) - { - closesocket( m_Socket ); - } - } - - static ITCPConnectSocket* Create( - const CIPAddr &connectAddr, - const CIPAddr &localAddr, - IHandlerCreator *pHandlerCreator - ) - { - CTCPConnectSocket_Connector *pRet = new CTCPConnectSocket_Connector; - - pRet->m_Socket = TCPBind( &localAddr ); - if ( pRet->m_Socket == INVALID_SOCKET ) - { - pRet->Release(); - return NULL; - } - - sockaddr_in addr; - IPAddrToSockAddr( &connectAddr, &addr ); - - // We don't want the connect() call to block. - DWORD val = 1; - int status = ioctlsocket( pRet->m_Socket, FIONBIO, &val ); - if ( status != 0 ) - { - Assert( false ); - pRet->Release(); - return NULL; - } - - pRet->m_RemoteAddr = connectAddr; - pRet->m_pHandlerCreator = pHandlerCreator; - - int ret = connect( pRet->m_Socket, (struct sockaddr*)&addr, sizeof( addr ) ); - if ( ret == 0 ) - { - pRet->m_bConnected = true; - return pRet; - } - else if ( ret == SOCKET_ERROR && WSAGetLastError() == WSAEWOULDBLOCK ) - { - return pRet; - } - else - { - Assert( false ); - pRet->Release(); - return NULL; - } - } - - -// ITCPConnectSocket implementation. -public: - - virtual void Release() - { - delete this; - } - - - virtual bool Update( IThreadedTCPSocket **pSocket, unsigned long milliseconds ) - { - *pSocket = NULL; - - // If we got an error previously, keep returning false. - if ( m_bError ) - return false; - - // If this condition holds, then we already returned a valid socket and we're just waiting to be released. - if ( m_Socket == INVALID_SOCKET ) - return true; - - // Ok, see if we're connected now. - if ( !m_bConnected ) - { - TIMEVAL timeVal = { 0, milliseconds*1000 }; - - fd_set writeSet; - writeSet.fd_count = 1; - writeSet.fd_array[0] = m_Socket; - - int ret = select( 0, NULL, &writeSet, NULL, &timeVal ); - if ( ret > 0 ) - { - m_bConnected = true; - } - else if ( ret == SOCKET_ERROR ) - { - return EnterErrorMode(); - } - } - - if ( m_bConnected ) - { - // Ok, return a connected socket for them. - - // Make our socket blocking again. - DWORD val = 0; - int status = ioctlsocket( m_Socket, FIONBIO, &val ); - if ( status != 0 ) - { - Assert( false ); - m_bError = true; - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - return false; - } - - IThreadedTCPSocket *pRet = CThreadedTCPSocket::Create( m_Socket, m_RemoteAddr, m_pHandlerCreator->CreateNewHandler(), true ); - if ( pRet ) - { - m_Socket = INVALID_SOCKET; - *pSocket = pRet; - return true; - } - else - { - return EnterErrorMode(); - } - } - else - { - // Still waiting.. - return true; - } - } - - // Shutdown the socket and start returning false from Update(). - bool EnterErrorMode() - { - Assert( false ); - m_bError = true; - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - return false; - } - - -private: - - bool m_bError; - bool m_bConnected; - - SOCKET m_Socket; - CIPAddr m_RemoteAddr; - - IHandlerCreator *m_pHandlerCreator; -}; - - -ITCPConnectSocket* ThreadedTCP_CreateConnector( - const CIPAddr &addr, - const CIPAddr &localAddr, - IHandlerCreator *pHandlerCreator - ) -{ - return CTCPConnectSocket_Connector::Create( addr, localAddr, pHandlerCreator ); -} - - -void ThreadedTCP_EnableTimeouts( bool bEnable ) -{ - g_bHandleTimeouts = bEnable; -} - - -void ThreadedTCP_SetTCPSocketThreadPriorities( bool bSetTCPSocketThreadPriorities ) -{ - g_bSetTCPSocketThreadPriorities = bSetTCPSocketThreadPriorities; -} - diff --git a/src/utils/vmpi/ThreadedTCPSocketEmu.cpp b/src/utils/vmpi/ThreadedTCPSocketEmu.cpp deleted file mode 100644 index f7a0c3a075..0000000000 --- a/src/utils/vmpi/ThreadedTCPSocketEmu.cpp +++ /dev/null @@ -1,349 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#include -#include "tcpsocket.h" -#include "IThreadedTCPSocket.h" -#include "ThreadedTCPSocketEmu.h" -#include "ThreadHelpers.h" - - - -// ---------------------------------------------------------------------------------------- // -// CThreadedTCPSocketEmu. This uses IThreadedTCPSocket to emulate the polling-type interface -// in ITCPSocket. -// ---------------------------------------------------------------------------------------- // - -// This class uses the IThreadedTCPSocket interface to emulate the old ITCPSocket. -class CThreadedTCPSocketEmu : public ITCPSocket, public ITCPSocketHandler, public IHandlerCreator -{ -public: - - CThreadedTCPSocketEmu() - { - m_pSocket = NULL; - m_LocalPort = 0xFFFF; - m_pConnectSocket = NULL; - m_RecvPacketsEvent.Init( false, false ); - m_bError = false; - } - - virtual ~CThreadedTCPSocketEmu() - { - Term(); - } - - void Init( IThreadedTCPSocket *pSocket ) - { - m_pSocket = pSocket; - } - - void Term() - { - if ( m_pSocket ) - { - m_pSocket->Release(); - m_pSocket = NULL; - } - - if ( m_pConnectSocket ) - { - m_pConnectSocket->Release(); - m_pConnectSocket = NULL; - } - } - - -// ITCPSocketHandler implementation. -private: - - - virtual void OnPacketReceived( CTCPPacket *pPacket ) - { - CVMPICriticalSectionLock csLock( &m_RecvPacketsCS ); - csLock.Lock(); - - m_RecvPackets.AddToTail( pPacket ); - m_RecvPacketsEvent.SetEvent(); - } - - - virtual void OnError( int errorCode, const char *pErrorString ) - { - CVMPICriticalSectionLock csLock( &m_ErrorStringCS ); - csLock.Lock(); - - m_ErrorString.CopyArray( pErrorString, strlen( pErrorString ) + 1 ); - m_bError = true; - } - - virtual void Release( bool bForce = false ) - { - delete this; - } - -// IHandlerCreator implementation. -public: - - // This is used for connecting. - virtual ITCPSocketHandler* CreateNewHandler() - { - return this; - } - -// ITCPSocket implementation. -public: - - virtual void Release( ) - { - delete this; - } - - virtual bool BindToAny( const unsigned short port ) - { - m_LocalPort = port; - return true; - } - - virtual bool BeginConnect( const CIPAddr &addr ) - { - // They should have "bound" to a port before trying to connect. - Assert( m_LocalPort != 0xFFFF ); - - if ( m_pConnectSocket ) - m_pConnectSocket->Release(); - - m_pConnectSocket = ThreadedTCP_CreateConnector( - addr, - CIPAddr( 0, 0, 0, 0, m_LocalPort ), - this ); - - return m_pConnectSocket != 0; - } - - virtual bool UpdateConnect() - { - Assert( !m_pSocket ); - if ( !m_pConnectSocket ) - return false; - - if ( m_pConnectSocket->Update( &m_pSocket ) ) - { - if ( m_pSocket ) - { - // Ok, we're connected now. - m_pConnectSocket->Release(); - m_pConnectSocket = NULL; - return true; - } - else - { - return false; - } - } - else - { - Assert( false ); - m_pConnectSocket->Release(); - m_pConnectSocket = NULL; - return false; - } - } - - virtual bool IsConnected() - { - if ( m_bError ) - { - Term(); - return false; - } - else - { - return m_pSocket != NULL; - } - } - - virtual void GetDisconnectReason( CUtlVector &reason ) - { - CVMPICriticalSectionLock csLock( &m_ErrorStringCS ); - csLock.Lock(); - - reason = m_ErrorString; - } - - virtual bool Send( const void *pData, int size ) - { - Assert( m_pSocket ); - if ( !m_pSocket ) - return false; - - return m_pSocket->Send( pData, size ); - } - - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) - { - Assert( m_pSocket ); - if ( !m_pSocket || !m_pSocket->IsValid() ) - return false; - - return m_pSocket->SendChunks( pChunks, pChunkLengths, nChunks ); - } - - virtual bool Recv( CUtlVector &data, double flTimeout ) - { - // Use our m_RecvPacketsEvent event to determine if there is data to receive yet. - DWORD nMilliseconds = (DWORD)( flTimeout * 1000.0f ); - DWORD ret = WaitForSingleObject( m_RecvPacketsEvent.GetEventHandle(), nMilliseconds ); - if ( ret == WAIT_OBJECT_0 ) - { - // Ok, there's a packet. - CVMPICriticalSectionLock csLock( &m_RecvPacketsCS ); - csLock.Lock(); - - Assert( m_RecvPackets.Count() > 0 ); - - int iHead = m_RecvPackets.Head(); - CTCPPacket *pPacket = m_RecvPackets[ iHead ]; - - data.CopyArray( (const unsigned char*)pPacket->GetData(), pPacket->GetLen() ); - - pPacket->Release(); - m_RecvPackets.Remove( iHead ); - - // Re-set the event if there are more packets left to receive. - if ( m_RecvPackets.Count() > 0 ) - { - m_RecvPacketsEvent.SetEvent(); - } - - return true; - } - else - { - return false; - } - } - - virtual int GetConnectionID() { return -1; } - - -private: - - IThreadedTCPSocket *m_pSocket; - - unsigned short m_LocalPort; // The port we bind to when we want to connect. - ITCPConnectSocket *m_pConnectSocket; - - - // All the received data is stored in here. - CEvent m_RecvPacketsEvent; - CVMPICriticalSection m_RecvPacketsCS; - CUtlLinkedList m_RecvPackets; - - CVMPICriticalSection m_ErrorStringCS; - CUtlVector m_ErrorString; - bool m_bError; // Set to true when there's an error. Next chance we get in the main thread, we'll close the socket. -}; - - -ITCPSocket* CreateTCPSocketEmu() -{ - return new CThreadedTCPSocketEmu; -} - - -// ---------------------------------------------------------------------------------------- // -// CThreadedTCPListenSocketEmu implementation. -// ---------------------------------------------------------------------------------------- // - -class CThreadedTCPListenSocketEmu : public ITCPListenSocket, public IHandlerCreator -{ -public: - CThreadedTCPListenSocketEmu() - { - m_pListener = NULL; - m_pLastCreatedSocket = NULL; - } - - virtual ~CThreadedTCPListenSocketEmu() - { - if ( m_pListener ) - m_pListener->Release(); - } - - bool StartListening( const unsigned short port, int nQueueLength ) - { - m_pListener = ThreadedTCP_CreateListener( - this, - port, - nQueueLength ); - - return m_pListener != 0; - } - - -// ITCPListenSocket implementation. -private: - - virtual void Release() - { - delete this; - } - - virtual ITCPSocket* UpdateListen( CIPAddr *pAddr ) - { - if ( !m_pListener ) - return NULL; - - IThreadedTCPSocket *pSocket; - if ( m_pListener->Update( &pSocket ) && pSocket ) - { - *pAddr = pSocket->GetRemoteAddr(); - - // This is pretty hacky, but this stuff is just around for test code. - CThreadedTCPSocketEmu *pLast = m_pLastCreatedSocket; - pLast->Init( pSocket ); - m_pLastCreatedSocket = NULL; - return pLast; - } - else - { - return NULL; - } - } - - -// IHandlerCreator implementation. -private: - - virtual ITCPSocketHandler* CreateNewHandler() - { - m_pLastCreatedSocket = new CThreadedTCPSocketEmu; - return m_pLastCreatedSocket; - } - - -private: - - ITCPConnectSocket *m_pListener; - CThreadedTCPSocketEmu *m_pLastCreatedSocket; -}; - -ITCPListenSocket* CreateTCPListenSocketEmu( const unsigned short port, int nQueueLength ) -{ - CThreadedTCPListenSocketEmu *pSocket = new CThreadedTCPListenSocketEmu; - if ( pSocket->StartListening( port, nQueueLength ) ) - { - return pSocket; - } - else - { - delete pSocket; - return NULL; - } -} - diff --git a/src/utils/vmpi/ThreadedTCPSocketEmu.h b/src/utils/vmpi/ThreadedTCPSocketEmu.h deleted file mode 100644 index 1ed13806bb..0000000000 --- a/src/utils/vmpi/ThreadedTCPSocketEmu.h +++ /dev/null @@ -1,26 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef THREADEDTCPSOCKETEMU_H -#define THREADEDTCPSOCKETEMU_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "tcpsocket.h" - - -// This creates a class that's based on IThreadedTCPSocket, but emulates the old ITCPSocket interface. -// This is used for stress-testing IThreadedTCPSocket. -ITCPSocket* CreateTCPSocketEmu(); - - -ITCPListenSocket* CreateTCPListenSocketEmu( const unsigned short port, int nQueueLength = -1 ); - - -#endif // THREADEDTCPSOCKETEMU_H diff --git a/src/utils/vmpi/WaitAndRestart/StdAfx.cpp b/src/utils/vmpi/WaitAndRestart/StdAfx.cpp deleted file mode 100644 index bac634db71..0000000000 --- a/src/utils/vmpi/WaitAndRestart/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// WaitAndRestart.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/utils/vmpi/WaitAndRestart/StdAfx.h b/src/utils/vmpi/WaitAndRestart/StdAfx.h deleted file mode 100644 index 954e1f8327..0000000000 --- a/src/utils/vmpi/WaitAndRestart/StdAfx.h +++ /dev/null @@ -1,32 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__6E874DA8_5D18_47D5_B557_3E07B6171907__INCLUDED_) -#define AFX_STDAFX_H__6E874DA8_5D18_47D5_B557_3E07B6171907__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#include -#include -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__6E874DA8_5D18_47D5_B557_3E07B6171907__INCLUDED_) diff --git a/src/utils/vmpi/WaitAndRestart/WaitAndRestart.cpp b/src/utils/vmpi/WaitAndRestart/WaitAndRestart.cpp deleted file mode 100644 index 5e9175a2b9..0000000000 --- a/src/utils/vmpi/WaitAndRestart/WaitAndRestart.cpp +++ /dev/null @@ -1,149 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// WaitAndRestart.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "vmpi_defs.h" -#include "vmpi_logfile.h" - - -#pragma warning( disable : 4127 ) - - -char* GetLastErrorString() -{ - static char err[2048]; - - LPVOID lpMsgBuf; - FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); - strncpy( err, (char*)lpMsgBuf, sizeof( err ) ); - LocalFree( lpMsgBuf ); - - err[ sizeof( err ) - 1 ] = 0; - return err; -} - - -int main( int argc, char* argv[] ) -{ - if ( argc < 4 ) - { - VMPI_WriteToLogFile( "WaitAndRestart run with invalid command line args. Exiting. But first, you get to see the arguments:\n" ); - for ( int i=0; i < argc; i++ ) - { - VMPI_WriteToLogFile( "\targv[%d]: %s\n", i, argv[i] ); - } - - printf( "WaitAndRestart command line...\n" ); - return 1; - } - - const char *pTimeToWait = argv[1]; - const char *pWorkingDir = argv[2]; - - // If a * precedes the time-to-wait arg, then it's a process ID and we wait for that process to exit. - if ( pTimeToWait[0] == '*' ) - { - ++pTimeToWait; - DWORD dwProcessId; - sscanf( pTimeToWait, "%lu", &dwProcessId ); - - VMPI_WriteToLogFile( "Waiting for process %lu to exit. Press a key to cancel...\n", dwProcessId ); - - HANDLE hProcess = OpenProcess( SYNCHRONIZE, false, dwProcessId ); - if ( hProcess ) - { - while ( 1 ) - { - DWORD val = WaitForSingleObject( hProcess, 100 ); - if ( val == WAIT_OBJECT_0 ) - { - break; - } - else if ( val == WAIT_ABANDONED ) - { - VMPI_WriteToLogFile( "Got WAIT_ABANDONED (error). Waiting 5 seconds, then continuing.\n" ); - Sleep( 5000 ); - break; - } - - if ( kbhit() ) - return 2; - } - VMPI_WriteToLogFile( "Process %lu terminated. Continuing.\n", dwProcessId ); - } - else - { - VMPI_WriteToLogFile( "Process %lu not running. Continuing.\n", dwProcessId ); - } - - CloseHandle( hProcess ); - } - else - { - DWORD timeToWait = (DWORD)atoi( argv[1] ); - - VMPI_WriteToLogFile( "\n\nWaiting for %d seconds to launch ' ", timeToWait ); - VMPI_WriteToLogFile( "%s> ", pWorkingDir ); - for ( int i=3; i < argc; i++ ) - { - VMPI_WriteToLogFile( "%s ", argv[i] ); - } - VMPI_WriteToLogFile( "'\n\nPress a key to cancel... " ); - - DWORD startTime = GetTickCount(); - while ( GetTickCount() - startTime < (timeToWait*1000) ) - { - if ( kbhit() ) - return 2; - - Sleep( 100 ); - } - } - - // Ok, launch it! - char commandLine[1024] = {0}; - for ( int i=3; i < argc; i++ ) - { - strcat_s( commandLine, sizeof( commandLine ), "\"" ); - strcat_s( commandLine, sizeof( commandLine ), argv[i] ); - strcat_s( commandLine, sizeof( commandLine ), "\" " ); - } - - STARTUPINFO si; - memset( &si, 0, sizeof( si ) ); - si.cb = sizeof( si ); - - PROCESS_INFORMATION pi; - memset( &pi, 0, sizeof( pi ) ); - - if ( CreateProcess( - NULL, - commandLine, - NULL, // security - NULL, - FALSE, - 0, // flags - NULL, // environment - pWorkingDir, // current directory - &si, - &pi ) ) - { - VMPI_WriteToLogFile( "Process started.\n" ); - CloseHandle( pi.hThread ); // We don't care what the process does. - CloseHandle( pi.hProcess ); - } - else - { - VMPI_WriteToLogFile( "CreateProcess error!\n%s", GetLastErrorString() ); - } - - return 0; -} - diff --git a/src/utils/vmpi/ZLib.lib b/src/utils/vmpi/ZLib.lib deleted file mode 100644 index 23c3dfd70bb80bb8a3ffc44bd31ad2cf0f1eeb82..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 83274 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 KR= hash_bits - */ - - long block_start; - /* Window position at the beginning of the current output block. Gets - * negative when the window is moved backwards. - */ - - uInt match_length; /* length of best match */ - IPos prev_match; /* previous match */ - int match_available; /* set if previous match exists */ - uInt strstart; /* start of string to insert */ - uInt match_start; /* start of matching string */ - uInt lookahead; /* number of valid bytes ahead in window */ - - uInt prev_length; - /* Length of the best match at previous step. Matches not greater than this - * are discarded. This is used in the lazy match evaluation. - */ - - uInt max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. - */ - - uInt max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. - */ -# define max_insert_length max_lazy_match - /* Insert new strings in the hash table only if the match length is not - * greater than this length. This saves time but degrades compression. - * max_insert_length is used only for compression levels <= 3. - */ - - int level; /* compression level (1..9) */ - int strategy; /* favor or force Huffman coding*/ - - uInt good_match; - /* Use a faster search when the previous match is longer than this */ - - int nice_match; /* Stop searching when current match exceeds this */ - - /* used by trees.c: */ - /* Didn't use ct_data typedef below to supress compiler warning */ - struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ - struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ - struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ - - struct tree_desc_s l_desc; /* desc. for literal tree */ - struct tree_desc_s d_desc; /* desc. for distance tree */ - struct tree_desc_s bl_desc; /* desc. for bit length tree */ - - ush bl_count[MAX_BITS+1]; - /* number of codes at each bit length for an optimal tree */ - - int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ - int heap_len; /* number of elements in the heap */ - int heap_max; /* element of largest frequency */ - /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. - * The same heap array is used to build all trees. - */ - - uch depth[2*L_CODES+1]; - /* Depth of each subtree used as tie breaker for trees of equal frequency - */ - - uchf *l_buf; /* buffer for literals or lengths */ - - uInt lit_bufsize; - /* Size of match buffer for literals/lengths. There are 4 reasons for - * limiting lit_bufsize to 64K: - * - frequencies can be kept in 16 bit counters - * - if compression is not successful for the first block, all input - * data is still in the window so we can still emit a stored block even - * when input comes from standard input. (This can also be done for - * all blocks if lit_bufsize is not greater than 32K.) - * - if compression is not successful for a file smaller than 64K, we can - * even emit a stored file instead of a stored block (saving 5 bytes). - * This is applicable only for zip (not gzip or zlib). - * - creating new Huffman trees less frequently may not provide fast - * adaptation to changes in the input data statistics. (Take for - * example a binary file with poorly compressible code followed by - * a highly compressible string table.) Smaller buffer sizes give - * fast adaptation but have of course the overhead of transmitting - * trees more frequently. - * - I can't count above 4 - */ - - uInt last_lit; /* running index in l_buf */ - - ushf *d_buf; - /* Buffer for distances. To simplify the code, d_buf and l_buf have - * the same number of elements. To use different lengths, an extra flag - * array would be necessary. - */ - - ulg opt_len; /* bit length of current block with optimal trees */ - ulg static_len; /* bit length of current block with static trees */ - uInt matches; /* number of string matches in current block */ - int last_eob_len; /* bit length of EOB code for last block */ - -#ifdef DEBUG - ulg compressed_len; /* total bit length of compressed file mod 2^32 */ - ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ -#endif - - ush bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ - int bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ - -} FAR deflate_state; - -/* Output a byte on the stream. - * IN assertion: there is enough room in pending_buf. - */ -#define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - - -#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) -/* Minimum amount of lookahead, except at the end of the input file. - * See deflate.c for comments about the MIN_MATCH+1. - */ - -#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) -/* In order to simplify the code, particularly on 16 bit machines, match - * distances are limited to MAX_DIST instead of WSIZE. - */ - - /* in trees.c */ -void _tr_init OF((deflate_state *s)); -int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); -void _tr_align OF((deflate_state *s)); -void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, - int eof)); - -#define d_code(dist) \ - ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) -/* Mapping from a distance to a distance code. dist is the distance - 1 and - * must not have side effects. _dist_code[256] and _dist_code[257] are never - * used. - */ - -#ifndef DEBUG -/* Inline versions of _tr_tally for speed: */ - -#if defined(GEN_TREES_H) || !defined(STDC) - extern uch _length_code[]; - extern uch _dist_code[]; -#else - extern const uch _length_code[]; - extern const uch _dist_code[]; -#endif - -# define _tr_tally_lit(s, c, flush) \ - { uch cc = (c); \ - s->d_buf[s->last_lit] = 0; \ - s->l_buf[s->last_lit++] = cc; \ - s->dyn_ltree[cc].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -# define _tr_tally_dist(s, distance, length, flush) \ - { uch len = (length); \ - ush dist = (distance); \ - s->d_buf[s->last_lit] = dist; \ - s->l_buf[s->last_lit++] = len; \ - dist--; \ - s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ - s->dyn_dtree[d_code(dist)].Freq++; \ - flush = (s->last_lit == s->lit_bufsize-1); \ - } -#else -# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) -# define _tr_tally_dist(s, distance, length, flush) \ - flush = _tr_tally(s, distance, length) -#endif - -#endif diff --git a/src/utils/vmpi/ZLib/infblock.h b/src/utils/vmpi/ZLib/infblock.h deleted file mode 100644 index bd25c80753..0000000000 --- a/src/utils/vmpi/ZLib/infblock.h +++ /dev/null @@ -1,39 +0,0 @@ -/* infblock.h -- header to use infblock.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -struct inflate_blocks_state; -typedef struct inflate_blocks_state FAR inflate_blocks_statef; - -extern inflate_blocks_statef * inflate_blocks_new OF(( - z_streamp z, - check_func c, /* check function */ - uInt w)); /* window size */ - -extern int inflate_blocks OF(( - inflate_blocks_statef *, - z_streamp , - int)); /* initial return code */ - -extern void inflate_blocks_reset OF(( - inflate_blocks_statef *, - z_streamp , - uLongf *)); /* check value on output */ - -extern int inflate_blocks_free OF(( - inflate_blocks_statef *, - z_streamp)); - -extern void inflate_set_dictionary OF(( - inflate_blocks_statef *s, - const Bytef *d, /* dictionary */ - uInt n)); /* dictionary length */ - -extern int inflate_blocks_sync_point OF(( - inflate_blocks_statef *s)); diff --git a/src/utils/vmpi/ZLib/infcodes.h b/src/utils/vmpi/ZLib/infcodes.h deleted file mode 100644 index 6c750d896f..0000000000 --- a/src/utils/vmpi/ZLib/infcodes.h +++ /dev/null @@ -1,27 +0,0 @@ -/* infcodes.h -- header to use infcodes.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -struct inflate_codes_state; -typedef struct inflate_codes_state FAR inflate_codes_statef; - -extern inflate_codes_statef *inflate_codes_new OF(( - uInt, uInt, - inflate_huft *, inflate_huft *, - z_streamp )); - -extern int inflate_codes OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -extern void inflate_codes_free OF(( - inflate_codes_statef *, - z_streamp )); - diff --git a/src/utils/vmpi/ZLib/inffast.h b/src/utils/vmpi/ZLib/inffast.h deleted file mode 100644 index 8facec5531..0000000000 --- a/src/utils/vmpi/ZLib/inffast.h +++ /dev/null @@ -1,17 +0,0 @@ -/* inffast.h -- header to use inffast.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -extern int inflate_fast OF(( - uInt, - uInt, - inflate_huft *, - inflate_huft *, - inflate_blocks_statef *, - z_streamp )); diff --git a/src/utils/vmpi/ZLib/inffixed.h b/src/utils/vmpi/ZLib/inffixed.h deleted file mode 100644 index 77f7e76314..0000000000 --- a/src/utils/vmpi/ZLib/inffixed.h +++ /dev/null @@ -1,151 +0,0 @@ -/* inffixed.h -- table for decoding fixed codes - * Generated automatically by the maketree.c program - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -local uInt fixed_bl = 9; -local uInt fixed_bd = 5; -local inflate_huft fixed_tl[] = { - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},192}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},160}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},224}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},144}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},208}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},176}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},240}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},200}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},168}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},232}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},152}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},216}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},184}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},248}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},196}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},164}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},228}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},148}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},212}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},180}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},244}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},204}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},172}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},236}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},156}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},220}, - {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},188}, - {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},252}, - {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},194}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},162}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},226}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},146}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},210}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},178}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},242}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},202}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},170}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},234}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},154}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},218}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},186}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},250}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},198}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},166}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},230}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},150}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},214}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},182}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},246}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},206}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},174}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},238}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},158}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},222}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},190}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},254}, - {{{96,7}},256}, {{{0,8}},80}, {{{0,8}},16}, {{{84,8}},115}, - {{{82,7}},31}, {{{0,8}},112}, {{{0,8}},48}, {{{0,9}},193}, - {{{80,7}},10}, {{{0,8}},96}, {{{0,8}},32}, {{{0,9}},161}, - {{{0,8}},0}, {{{0,8}},128}, {{{0,8}},64}, {{{0,9}},225}, - {{{80,7}},6}, {{{0,8}},88}, {{{0,8}},24}, {{{0,9}},145}, - {{{83,7}},59}, {{{0,8}},120}, {{{0,8}},56}, {{{0,9}},209}, - {{{81,7}},17}, {{{0,8}},104}, {{{0,8}},40}, {{{0,9}},177}, - {{{0,8}},8}, {{{0,8}},136}, {{{0,8}},72}, {{{0,9}},241}, - {{{80,7}},4}, {{{0,8}},84}, {{{0,8}},20}, {{{85,8}},227}, - {{{83,7}},43}, {{{0,8}},116}, {{{0,8}},52}, {{{0,9}},201}, - {{{81,7}},13}, {{{0,8}},100}, {{{0,8}},36}, {{{0,9}},169}, - {{{0,8}},4}, {{{0,8}},132}, {{{0,8}},68}, {{{0,9}},233}, - {{{80,7}},8}, {{{0,8}},92}, {{{0,8}},28}, {{{0,9}},153}, - {{{84,7}},83}, {{{0,8}},124}, {{{0,8}},60}, {{{0,9}},217}, - {{{82,7}},23}, {{{0,8}},108}, {{{0,8}},44}, {{{0,9}},185}, - {{{0,8}},12}, {{{0,8}},140}, {{{0,8}},76}, {{{0,9}},249}, - {{{80,7}},3}, {{{0,8}},82}, {{{0,8}},18}, {{{85,8}},163}, - {{{83,7}},35}, {{{0,8}},114}, {{{0,8}},50}, {{{0,9}},197}, - {{{81,7}},11}, {{{0,8}},98}, {{{0,8}},34}, {{{0,9}},165}, - {{{0,8}},2}, {{{0,8}},130}, {{{0,8}},66}, {{{0,9}},229}, - {{{80,7}},7}, {{{0,8}},90}, {{{0,8}},26}, {{{0,9}},149}, - {{{84,7}},67}, {{{0,8}},122}, {{{0,8}},58}, {{{0,9}},213}, - {{{82,7}},19}, {{{0,8}},106}, {{{0,8}},42}, {{{0,9}},181}, - {{{0,8}},10}, {{{0,8}},138}, {{{0,8}},74}, {{{0,9}},245}, - {{{80,7}},5}, {{{0,8}},86}, {{{0,8}},22}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},118}, {{{0,8}},54}, {{{0,9}},205}, - {{{81,7}},15}, {{{0,8}},102}, {{{0,8}},38}, {{{0,9}},173}, - {{{0,8}},6}, {{{0,8}},134}, {{{0,8}},70}, {{{0,9}},237}, - {{{80,7}},9}, {{{0,8}},94}, {{{0,8}},30}, {{{0,9}},157}, - {{{84,7}},99}, {{{0,8}},126}, {{{0,8}},62}, {{{0,9}},221}, - {{{82,7}},27}, {{{0,8}},110}, {{{0,8}},46}, {{{0,9}},189}, - {{{0,8}},14}, {{{0,8}},142}, {{{0,8}},78}, {{{0,9}},253}, - {{{96,7}},256}, {{{0,8}},81}, {{{0,8}},17}, {{{85,8}},131}, - {{{82,7}},31}, {{{0,8}},113}, {{{0,8}},49}, {{{0,9}},195}, - {{{80,7}},10}, {{{0,8}},97}, {{{0,8}},33}, {{{0,9}},163}, - {{{0,8}},1}, {{{0,8}},129}, {{{0,8}},65}, {{{0,9}},227}, - {{{80,7}},6}, {{{0,8}},89}, {{{0,8}},25}, {{{0,9}},147}, - {{{83,7}},59}, {{{0,8}},121}, {{{0,8}},57}, {{{0,9}},211}, - {{{81,7}},17}, {{{0,8}},105}, {{{0,8}},41}, {{{0,9}},179}, - {{{0,8}},9}, {{{0,8}},137}, {{{0,8}},73}, {{{0,9}},243}, - {{{80,7}},4}, {{{0,8}},85}, {{{0,8}},21}, {{{80,8}},258}, - {{{83,7}},43}, {{{0,8}},117}, {{{0,8}},53}, {{{0,9}},203}, - {{{81,7}},13}, {{{0,8}},101}, {{{0,8}},37}, {{{0,9}},171}, - {{{0,8}},5}, {{{0,8}},133}, {{{0,8}},69}, {{{0,9}},235}, - {{{80,7}},8}, {{{0,8}},93}, {{{0,8}},29}, {{{0,9}},155}, - {{{84,7}},83}, {{{0,8}},125}, {{{0,8}},61}, {{{0,9}},219}, - {{{82,7}},23}, {{{0,8}},109}, {{{0,8}},45}, {{{0,9}},187}, - {{{0,8}},13}, {{{0,8}},141}, {{{0,8}},77}, {{{0,9}},251}, - {{{80,7}},3}, {{{0,8}},83}, {{{0,8}},19}, {{{85,8}},195}, - {{{83,7}},35}, {{{0,8}},115}, {{{0,8}},51}, {{{0,9}},199}, - {{{81,7}},11}, {{{0,8}},99}, {{{0,8}},35}, {{{0,9}},167}, - {{{0,8}},3}, {{{0,8}},131}, {{{0,8}},67}, {{{0,9}},231}, - {{{80,7}},7}, {{{0,8}},91}, {{{0,8}},27}, {{{0,9}},151}, - {{{84,7}},67}, {{{0,8}},123}, {{{0,8}},59}, {{{0,9}},215}, - {{{82,7}},19}, {{{0,8}},107}, {{{0,8}},43}, {{{0,9}},183}, - {{{0,8}},11}, {{{0,8}},139}, {{{0,8}},75}, {{{0,9}},247}, - {{{80,7}},5}, {{{0,8}},87}, {{{0,8}},23}, {{{192,8}},0}, - {{{83,7}},51}, {{{0,8}},119}, {{{0,8}},55}, {{{0,9}},207}, - {{{81,7}},15}, {{{0,8}},103}, {{{0,8}},39}, {{{0,9}},175}, - {{{0,8}},7}, {{{0,8}},135}, {{{0,8}},71}, {{{0,9}},239}, - {{{80,7}},9}, {{{0,8}},95}, {{{0,8}},31}, {{{0,9}},159}, - {{{84,7}},99}, {{{0,8}},127}, {{{0,8}},63}, {{{0,9}},223}, - {{{82,7}},27}, {{{0,8}},111}, {{{0,8}},47}, {{{0,9}},191}, - {{{0,8}},15}, {{{0,8}},143}, {{{0,8}},79}, {{{0,9}},255} - }; -local inflate_huft fixed_td[] = { - {{{80,5}},1}, {{{87,5}},257}, {{{83,5}},17}, {{{91,5}},4097}, - {{{81,5}},5}, {{{89,5}},1025}, {{{85,5}},65}, {{{93,5}},16385}, - {{{80,5}},3}, {{{88,5}},513}, {{{84,5}},33}, {{{92,5}},8193}, - {{{82,5}},9}, {{{90,5}},2049}, {{{86,5}},129}, {{{192,5}},24577}, - {{{80,5}},2}, {{{87,5}},385}, {{{83,5}},25}, {{{91,5}},6145}, - {{{81,5}},7}, {{{89,5}},1537}, {{{85,5}},97}, {{{93,5}},24577}, - {{{80,5}},4}, {{{88,5}},769}, {{{84,5}},49}, {{{92,5}},12289}, - {{{82,5}},13}, {{{90,5}},3073}, {{{86,5}},193}, {{{192,5}},24577} - }; diff --git a/src/utils/vmpi/ZLib/inftrees.h b/src/utils/vmpi/ZLib/inftrees.h deleted file mode 100644 index 85853e097b..0000000000 --- a/src/utils/vmpi/ZLib/inftrees.h +++ /dev/null @@ -1,58 +0,0 @@ -/* inftrees.h -- header to use inftrees.c - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* Huffman code lookup table entry--this entry is four bytes for machines - that have 16-bit pointers (e.g. PC's in the small or medium model). */ - -typedef struct inflate_huft_s FAR inflate_huft; - -struct inflate_huft_s { - union { - struct { - Byte Exop; /* number of extra bits or operation */ - Byte Bits; /* number of bits in this code or subcode */ - } what; - uInt pad; /* pad structure to a power of 2 (4 bytes for */ - } word; /* 16-bit, 8 bytes for 32-bit int's) */ - uInt base; /* literal, length base, distance base, - or table offset */ -}; - -/* Maximum size of dynamic tree. The maximum found in a long but non- - exhaustive search was 1004 huft structures (850 for length/literals - and 154 for distances, the latter actually the result of an - exhaustive search). The actual maximum is not known, but the - value below is more than safe. */ -#define MANY 1440 - -extern int inflate_trees_bits OF(( - uIntf *, /* 19 code lengths */ - uIntf *, /* bits tree desired/actual depth */ - inflate_huft * FAR *, /* bits tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_dynamic OF(( - uInt, /* number of literal/length codes */ - uInt, /* number of distance codes */ - uIntf *, /* that many (total) code lengths */ - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - inflate_huft *, /* space for trees */ - z_streamp)); /* for messages */ - -extern int inflate_trees_fixed OF(( - uIntf *, /* literal desired/actual bit depth */ - uIntf *, /* distance desired/actual bit depth */ - inflate_huft * FAR *, /* literal/length tree result */ - inflate_huft * FAR *, /* distance tree result */ - z_streamp)); /* for memory allocation */ diff --git a/src/utils/vmpi/ZLib/infutil.h b/src/utils/vmpi/ZLib/infutil.h deleted file mode 100644 index 99d1135d06..0000000000 --- a/src/utils/vmpi/ZLib/infutil.h +++ /dev/null @@ -1,98 +0,0 @@ -/* infutil.h -- types and macros common to blocks and codes - * Copyright (C) 1995-1998 Mark Adler - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -#ifndef _INFUTIL_H -#define _INFUTIL_H - -typedef enum { - TYPE, /* get type bits (3, including end bit) */ - LENS, /* get lengths for stored */ - STORED, /* processing stored block */ - TABLE, /* get table lengths */ - BTREE, /* get bit lengths tree for a dynamic block */ - DTREE, /* get length, distance trees for a dynamic block */ - CODES, /* processing fixed or dynamic block */ - DRY, /* output remaining window bytes */ - DONE, /* finished last block, done */ - BAD} /* got a data error--stuck here */ -inflate_block_mode; - -/* inflate blocks semi-private state */ -struct inflate_blocks_state { - - /* mode */ - inflate_block_mode mode; /* current inflate_block mode */ - - /* mode dependent information */ - union { - uInt left; /* if STORED, bytes left to copy */ - struct { - uInt table; /* table lengths (14 bits) */ - uInt index; /* index into blens (or border) */ - uIntf *blens; /* bit lengths of codes */ - uInt bb; /* bit length tree depth */ - inflate_huft *tb; /* bit length decoding tree */ - } trees; /* if DTREE, decoding info for trees */ - struct { - inflate_codes_statef - *codes; - } decode; /* if CODES, current state */ - } sub; /* submode */ - uInt last; /* true if this block is the last block */ - - /* mode independent information */ - uInt bitk; /* bits in bit buffer */ - uLong bitb; /* bit buffer */ - inflate_huft *hufts; /* single malloc for tree space */ - Bytef *window; /* sliding window */ - Bytef *end; /* one byte after sliding window */ - Bytef *read; /* window read pointer */ - Bytef *write; /* window write pointer */ - check_func checkfn; /* check function */ - uLong check; /* check on output */ - -}; - - -/* defines for inflate input/output */ -/* update pointers and return */ -#define UPDBITS {s->bitb=b;s->bitk=k;} -#define UPDIN {z->avail_in=n;z->total_in+=p-z->next_in;z->next_in=p;} -#define UPDOUT {s->write=q;} -#define UPDATE {UPDBITS UPDIN UPDOUT} -#define LEAVE {UPDATE return inflate_flush(s,z,r);} -/* get bytes and bits */ -#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} -#define NEEDBYTE {if(n)r=Z_OK;else LEAVE} -#define NEXTBYTE (n--,*p++) -#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<>=(j);k-=(j);} -/* output bytes */ -#define WAVAIL (uInt)(qread?s->read-q-1:s->end-q) -#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} -#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} -#define FLUSH {UPDOUT r=inflate_flush(s,z,r); LOADOUT} -#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE}}r=Z_OK;} -#define OUTBYTE(a) {*q++=(Byte)(a);m--;} -/* load local pointers */ -#define LOAD {LOADIN LOADOUT} - -/* masks for lower bits (size given to avoid silly warnings with Visual C++) */ -extern uInt inflate_mask[17]; - -/* copy as much as possible from the sliding window to the output area */ -extern int inflate_flush OF(( - inflate_blocks_statef *, - z_streamp , - int)); - -struct internal_state {int dummy;}; /* for buggy compilers */ - -#endif diff --git a/src/utils/vmpi/ZLib/trees.h b/src/utils/vmpi/ZLib/trees.h deleted file mode 100644 index 72facf900f..0000000000 --- a/src/utils/vmpi/ZLib/trees.h +++ /dev/null @@ -1,128 +0,0 @@ -/* header created automatically with -DGEN_TREES_H */ - -local const ct_data static_ltree[L_CODES+2] = { -{{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, -{{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, -{{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, -{{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, -{{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, -{{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, -{{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, -{{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, -{{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, -{{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, -{{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, -{{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, -{{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, -{{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, -{{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, -{{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, -{{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, -{{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, -{{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, -{{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, -{{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, -{{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, -{{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, -{{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, -{{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, -{{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, -{{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, -{{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, -{{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, -{{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, -{{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, -{{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, -{{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, -{{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, -{{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, -{{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, -{{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, -{{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, -{{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, -{{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, -{{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, -{{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, -{{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, -{{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, -{{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, -{{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, -{{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, -{{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, -{{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, -{{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, -{{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, -{{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, -{{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, -{{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, -{{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, -{{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, -{{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, -{{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} -}; - -local const ct_data static_dtree[D_CODES] = { -{{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, -{{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, -{{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, -{{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, -{{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, -{{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} -}; - -const uch _dist_code[DIST_CODE_LEN] = { - 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, - 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, -10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, -14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, -18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, -28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 -}; - -const uch _length_code[MAX_MATCH-MIN_MATCH+1]= { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, -13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, -17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, -19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, -22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, -23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, -25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 -}; - -local const int base_length[LENGTH_CODES] = { -0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, -64, 80, 96, 112, 128, 160, 192, 224, 0 -}; - -local const int base_dist[D_CODES] = { - 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, - 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, - 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 -}; - diff --git a/src/utils/vmpi/ZLib/zconf.h b/src/utils/vmpi/ZLib/zconf.h deleted file mode 100644 index 6d450fc793..0000000000 --- a/src/utils/vmpi/ZLib/zconf.h +++ /dev/null @@ -1,279 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef _ZCONF_H -#define _ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - */ -#ifdef Z_PREFIX -# define deflateInit_ z_deflateInit_ -# define deflate z_deflate -# define deflateEnd z_deflateEnd -# define inflateInit_ z_inflateInit_ -# define inflate z_inflate -# define inflateEnd z_inflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateSetDictionary z_deflateSetDictionary -# define deflateCopy z_deflateCopy -# define deflateReset z_deflateReset -# define deflateParams z_deflateParams -# define inflateInit2_ z_inflateInit2_ -# define inflateSetDictionary z_inflateSetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateReset z_inflateReset -# define compress z_compress -# define compress2 z_compress2 -# define uncompress z_uncompress -# define adler32 z_adler32 -# define crc32 z_crc32 -# define get_crc_table z_get_crc_table - -# define Byte z_Byte -# define uInt z_uInt -# define uLong z_uLong -# define Bytef z_Bytef -# define charf z_charf -# define intf z_intf -# define uIntf z_uIntf -# define uLongf z_uLongf -# define voidpf z_voidpf -# define voidp z_voidp -#endif - -#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) -# define WIN32 -#endif -#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) -# ifndef __32BIT__ -# define __32BIT__ -# endif -#endif -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#if defined(MSDOS) && !defined(__32BIT__) -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) -# define STDC -#endif -#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) -# ifndef STDC -# define STDC -# endif -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const -# endif -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Old Borland C incorrectly complains about missing returns: */ -#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) -# define NEED_DUMMY_RETURN -#endif - - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -#endif -#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) -# ifndef __32BIT__ -# define SMALL_MEDIUM -# define FAR _far -# endif -#endif - -/* Compile with -DZLIB_DLL for Windows DLL support */ -#if defined(ZLIB_DLL) -# if defined(_WINDOWS) || defined(WINDOWS) -# ifdef FAR -# undef FAR -# endif -# include -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR _cdecl _export -# endif -# endif -# if defined (__BORLANDC__) -# if (__BORLANDC__ >= 0x0500) && defined (WIN32) -# include -# define ZEXPORT __declspec(dllexport) WINAPI -# define ZEXPORTRVA __declspec(dllexport) WINAPIV -# else -# if defined (_Windows) && defined (__DLL__) -# define ZEXPORT _export -# define ZEXPORTVA _export -# endif -# endif -# endif -#endif - -#if defined (__BEOS__) -# if defined (ZLIB_DLL) -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -#endif - -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif -#ifndef ZEXTERN -# define ZEXTERN extern -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(MACOS) && !defined(TARGET_OS_MAC) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#ifdef HAVE_UNISTD_H -# include /* for off_t */ -# include /* for SEEK_* and off_t */ -# define z_off_t off_t -#endif -#ifndef SEEK_SET -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif -#ifndef z_off_t -# define z_off_t long -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) -# pragma map(deflateInit_,"DEIN") -# pragma map(deflateInit2_,"DEIN2") -# pragma map(deflateEnd,"DEEND") -# pragma map(inflateInit_,"ININ") -# pragma map(inflateInit2_,"ININ2") -# pragma map(inflateEnd,"INEND") -# pragma map(inflateSync,"INSY") -# pragma map(inflateSetDictionary,"INSEDI") -# pragma map(inflate_blocks,"INBL") -# pragma map(inflate_blocks_new,"INBLNE") -# pragma map(inflate_blocks_free,"INBLFR") -# pragma map(inflate_blocks_reset,"INBLRE") -# pragma map(inflate_codes_free,"INCOFR") -# pragma map(inflate_codes,"INCO") -# pragma map(inflate_fast,"INFA") -# pragma map(inflate_flush,"INFLU") -# pragma map(inflate_mask,"INMA") -# pragma map(inflate_set_dictionary,"INSEDI2") -# pragma map(inflate_copyright,"INCOPY") -# pragma map(inflate_trees_bits,"INTRBI") -# pragma map(inflate_trees_dynamic,"INTRDY") -# pragma map(inflate_trees_fixed,"INTRFI") -# pragma map(inflate_trees_free,"INTRFR") -#endif - -#endif /* _ZCONF_H */ diff --git a/src/utils/vmpi/ZLib/zlib.h b/src/utils/vmpi/ZLib/zlib.h deleted file mode 100644 index 49f56b43bc..0000000000 --- a/src/utils/vmpi/ZLib/zlib.h +++ /dev/null @@ -1,893 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.1.3, July 9th, 1998 - - Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt - (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). -*/ - -#ifndef _ZLIB_H -#define _ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.1.3" - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed - data. This version of the library supports only one compression method - (deflation) but other algorithms will be added later and will have the same - stream interface. - - Compression can be done in a single step if the buffers are large - enough (for example if an input file is mmap'ed), or can be done by - repeated calls of the compression function. In the latter case, the - application must provide more input and/or consume the output - (providing more output space) before each call. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never - crash even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total nb of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total nb of bytes output so far */ - - char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: ascii or binary */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - The application must update next_in and avail_in when avail_in has - dropped to zero. It must update next_out and avail_out when avail_out - has dropped to zero. The application must initialize zalloc, zfree and - opaque before calling the init function. All other fields are set by the - compression library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this - if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, - pointers returned by zalloc for objects of exactly 65536 bytes *must* - have their offset normalized to zero. The default allocation function - provided by this library ensures this (see zutil.c). To reduce memory - requirements and avoid any allocation of 64K objects, at the expense of - compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or - progress reports. After compression, total_in holds the total size of - the uncompressed data and may be saved for use in the decompressor - (particularly if the decompressor wants to decompress everything in - a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -/* Allowed flush values; see deflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative - * values are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_ASCII 1 -#define Z_UNKNOWN 2 -/* Possible values of the data_type field */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is - not compatible with the zlib.h header file used by the application. - This check is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. - If zalloc and zfree are set to Z_NULL, deflateInit updates them to - use default allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at - all (the input data is simply copied a block at a time). - Z_DEFAULT_COMPRESSION requests a default compromise between speed and - compression (currently equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if level is not a valid compression level, - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). - msg is set to null if there is no error message. deflateInit does not - perform any compression: this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce some - output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). - Some output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating avail_in or avail_out accordingly; avail_out - should never be zero before the call. The application can consume the - compressed output when it wants, for example when the output buffer is full - (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK - and with zero avail_out, it must be called again after making room in the - output buffer because there might be more output pending. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In particular - avail_in is zero after the call if enough output space has been provided - before the call.) Flushing may degrade compression for some compression - algorithms and so it should be used only when necessary. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - the compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there - was enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the - stream are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least - 0.1% larger than avail_in plus 12 bytes. If deflate does not return - Z_STREAM_END, then it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update data_type if it can make a good guess about - the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered - binary. This field is only for information purposes and does not affect - the compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, - msg may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the exact - value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller. msg is set to null if there is no error - message. inflateInit does not perform any decompression apart from reading - the zlib header if present: this will be done by inflate(). (So next_in and - avail_in may be modified, but next_out and avail_out are unchanged.) -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may some - introduce some output latency (reading input without producing any output) - except when forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing - will resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there - is no more input data or no more space in the output buffer (see below - about the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming - more output, and updating the next_* and avail_* values accordingly. - The application can consume the uncompressed output when it wants, for - example when the output buffer is full (avail_out == 0), or after each - call of inflate(). If inflate returns Z_OK and with zero avail_out, it - must be called again after making room in the output buffer because there - might be more output pending. - - If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much - output as possible to the output buffer. The flushing behavior of inflate is - not specified for values of the flush parameter other than Z_SYNC_FLUSH - and Z_FINISH, but the current implementation actually flushes as much output - as possible anyway. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step - (a single call of inflate), the parameter flush should be set to - Z_FINISH. In this case all pending input is processed and all pending - output is flushed; avail_out must be large enough to hold all the - uncompressed data. (The size of the uncompressed data may have been saved - by the compressor for this purpose.) The next operation on this stream must - be inflateEnd to deallocate the decompression state. The use of Z_FINISH - is never required, but can be used to inform inflate that a faster routine - may be used for the single inflate() call. - - If a preset dictionary is needed at this point (see inflateSetDictionary - below), inflate sets strm-adler to the adler32 checksum of the - dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise - it sets strm->adler to the adler32 checksum of all output produced - so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or - an error code as described below. At the end of the stream, inflate() - checks that its computed adler32 checksum is equal to that saved by the - compressor and returns Z_STREAM_END only if the checksum is correct. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect - adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent - (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if no progress is possible or if there was not - enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR - case, the application may then call inflateSync to look for a good - compression block. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any - pending output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by - the caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but - is slow and reduces compression ratio; memLevel=9 uses maximum memory - for optimal speed. The default value is 8. See zconf.h for total memory - usage as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match). Filtered data consists mostly of small values with a - somewhat random distribution. In this case, the compression algorithm is - tuned to compress them better. The effect of Z_FILTERED is to force more - Huffman coding and less string matching; it is somewhat intermediate - between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects - the compression ratio but not the correctness of the compressed output even - if it is not set appropriately. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid - method). msg is set to null if there is no error message. deflateInit2 does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. This function must be called - immediately after deflateInit, deflateInit2 or deflateReset, before any - call of deflate. The compressor and decompressor must use exactly the same - dictionary (see inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size in - deflate or deflate2. Thus the strings most likely to be useful should be - put at the end of the dictionary, not at the front. - - Upon return of this function, strm->adler is set to the Adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The Adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if the compression method is bsort). deflateSetDictionary does not - perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and - can consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. - The stream will keep the same compression level and any other attributes - that may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different - strategy. If the compression level is changed, the input available so far - is compressed with the old level (and may be flushed); the new level will - take effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to - be compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR - if strm->avail_out was zero. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. If a compressed stream with a larger window size is given as - input, inflate() will return with the error code Z_DATA_ERROR instead of - trying to allocate a larger window. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative - memLevel). msg is set to null if there is no error message. inflateInit2 - does not perform any decompression apart from reading the zlib header if - present: this will be done by inflate(). (So next_in and avail_in may be - modified, but next_out and avail_out are unchanged.) -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate - if this call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the Adler32 value returned by this call of - inflate. The compressor and decompressor must use exactly the same - dictionary (see deflateSetDictionary). - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (such as NULL dictionary) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect Adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a full flush point (see above the - description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR - if no more input was provided, Z_DATA_ERROR if no flush point has been found, - or Z_STREAM_ERROR if the stream structure was inconsistent. In the success - case, the application may save the current current value of total_in which - indicates where valid compressed data was found. In the error case, the - application may repeatedly call inflateSync, providing more input each time, - until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. - The stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being NULL). -*/ - - - /* utility functions */ - -/* - The following utility functions are implemented on top of the - basic stream-oriented functions. To simplify the interface, some - default options are assumed (compression level and memory usage, - standard memory allocation functions). The source code of these - utility functions can easily be modified if you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be at least 0.1% larger than - sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the - compressed buffer. - This function can be used to compress a whole file at once if the - input file is mmap'ed. - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least 0.1% larger than sourceLen plus - 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total - size of the destination buffer, which must be large enough to hold the - entire uncompressed data. (The size of the uncompressed data must have - been saved previously by the compressor and transmitted to the decompressor - by some mechanism outside the scope of this compression library.) - Upon exit, destLen is the actual size of the compressed buffer. - This function can be used to decompress a whole file at once if the - input file is mmap'ed. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted. -*/ - - -typedef voidp gzFile; - -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); -/* - Opens a gzip (.gz) file for reading or writing. The mode parameter - is as in fopen ("rb" or "wb") but can also include a compression level - ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for - Huffman only compression as in "wb1h". (See the description - of deflateInit2 for more information about the strategy parameter.) - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. - - gzopen returns NULL if the file could not be opened or if there was - insufficient memory to allocate the (de)compression state; errno - can be checked to distinguish the two cases (if errno is zero, the - zlib error is Z_MEM_ERROR). */ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen() associates a gzFile with the file descriptor fd. File - descriptors are obtained from calls like open, dup, creat, pipe or - fileno (in the file has been previously opened with fopen). - The mode parameter is as in gzopen. - The next call of gzclose on the returned gzFile will also close the - file descriptor fd, just like fclose(fdopen(fd), mode) closes the file - descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). - gzdopen returns NULL if there was insufficient memory to allocate - the (de)compression state. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. - If the input file was not in gzip format, gzread copies the given number - of bytes into the buffer. - gzread returns the number of uncompressed bytes actually read (0 for - end of file, -1 for error). */ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - const voidp buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes actually written - (0 in case of error). -*/ - -ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the args to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written (0 in case of error). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or - a newline character is read and transferred to buf, or an end-of-file - condition is encountered. The string is then terminated with a null - character. - gzgets returns buf, or Z_NULL in case of error. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. - gzputc returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte - or -1 in case of end of file or error. -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter - flush is as in the deflate() function. The return value is the zlib - error number (see function gzerror below). gzflush returns Z_OK if - the flush parameter is Z_FINISH and all output could be flushed. - gzflush should be called only when strictly necessary because it can - degrade compression. -*/ - -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); -/* - Sets the starting position for the next gzread or gzwrite on the - given compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); -/* - Returns the starting position for the next gzread or gzwrite on the - given compressed file. This position represents a number of bytes in the - uncompressed data stream. - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns 1 when EOF has previously been detected reading the given - input stream, otherwise zero. -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file - and deallocates all the (de)compression state. The return value is the zlib - error number (see function gzerror below). -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the - given compressed file. errnum is set to zlib error number. If an - error occurred in the file system and not in the compression library, - errnum is set to Z_ERRNO and the application may consult errno - to get the exact error code. -*/ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the - compression library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); - -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is NULL, this function returns - the required initial value for the checksum. - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running crc with the bytes buf[0..len-1] and return the updated - crc. If buf is NULL, this function returns the required initial value - for the crc. Pre- and post-conditioning (one's complement) is performed - within this function so it shouldn't be done by the application. - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) - - -#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; /* hack for buggy compilers */ -#endif - -ZEXTERN const char * ZEXPORT zError OF((int err)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); - -#ifdef __cplusplus -} -#endif - -#endif /* _ZLIB_H */ diff --git a/src/utils/vmpi/ZLib/zutil.h b/src/utils/vmpi/ZLib/zutil.h deleted file mode 100644 index 6f2cb97ca1..0000000000 --- a/src/utils/vmpi/ZLib/zutil.h +++ /dev/null @@ -1,220 +0,0 @@ -/* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-1998 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* WARNING: this file should *not* be used by applications. It is - part of the implementation of the compression library and is - subject to change. Applications should only use zlib.h. - */ - -/* @(#) $Id$ */ - -#ifndef _Z_UTIL_H -#define _Z_UTIL_H - -#include "zlib.h" - -#ifdef STDC -# include -# include -# include -#endif -#ifdef NO_ERRNO_H - extern int errno; -#else -# include -#endif - -#ifndef local -# define local static -#endif -/* compile with -Dlocal if your debugger can't find static symbols */ - -typedef unsigned char uch; -typedef uch FAR uchf; -typedef unsigned short ush; -typedef ush FAR ushf; -typedef unsigned long ulg; - -extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */ -/* (size given to avoid silly warnings with Visual C++) */ - -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] - -#define ERR_RETURN(strm,err) \ - return (strm->msg = (char*)ERR_MSG(err), (err)) -/* To be used only when the state is known to be valid */ - - /* common constants */ - -#ifndef DEF_WBITS -# define DEF_WBITS MAX_WBITS -#endif -/* default windowBits for decompression. MAX_WBITS is for compression only */ - -#if MAX_MEM_LEVEL >= 8 -# define DEF_MEM_LEVEL 8 -#else -# define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -/* default memLevel */ - -#define STORED_BLOCK 0 -#define STATIC_TREES 1 -#define DYN_TREES 2 -/* The three kinds of block type */ - -#define MIN_MATCH 3 -#define MAX_MATCH 258 -/* The minimum and maximum match lengths */ - -#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ - - /* target dependencies */ - -#ifdef MSDOS -# define OS_CODE 0x00 -# if defined(__TURBOC__) || defined(__BORLANDC__) -# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) - /* Allow compilation with ANSI keywords only enabled */ - void _Cdecl farfree( void *block ); - void *_Cdecl farmalloc( unsigned long nbytes ); -# else -# include -# endif -# else /* MSC or DJGPP */ -# include -# endif -#endif - -#ifdef OS2 -# define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -# define OS_CODE 0x0b -#endif - -#if defined(VAXC) || defined(VMS) -# define OS_CODE 0x02 -# define F_OPEN(name, mode) \ - fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") -#endif - -#ifdef AMIGA -# define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -# define OS_CODE 0x05 -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -# define OS_CODE 0x07 -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -# define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -# define OS_CODE 0x0a -#endif - -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) -# define fdopen(fd,type) _fdopen(fd,type) -#endif - - - /* Common defaults */ - -#ifndef OS_CODE -# define OS_CODE 0x03 /* assume Unix */ -#endif - -#ifndef F_OPEN -# define F_OPEN(name, mode) fopen((name), (mode)) -#endif - - /* functions */ - -#ifdef HAVE_STRERROR - extern char *strerror OF((int)); -# define zstrerror(errnum) strerror(errnum) -#else -# define zstrerror(errnum) "" -#endif - -#if defined(pyr) -# define NO_MEMCPY -#endif -#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) - /* Use our own functions for small and medium model with MSC <= 5.0. - * You may have to use the same strategy for Borland C (untested). - * The __SC__ check is for Symantec. - */ -# define NO_MEMCPY -#endif -#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) -# define HAVE_MEMCPY -#endif -#ifdef HAVE_MEMCPY -# ifdef SMALL_MEDIUM /* MSDOS small or medium model */ -# define zmemcpy _fmemcpy -# define zmemcmp _fmemcmp -# define zmemzero(dest, len) _fmemset(dest, 0, len) -# else -# define zmemcpy memcpy -# define zmemcmp memcmp -# define zmemzero(dest, len) memset(dest, 0, len) -# endif -#else - extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - extern void zmemzero OF((Bytef* dest, uInt len)); -#endif - -/* Diagnostic functions */ -#ifdef DEBUG -# include - extern int z_verbose; - extern void z_error OF((char *m)); -# define Assert(cond,msg) {if(!(cond)) z_error(msg);} -# define Trace(x) {if (z_verbose>=0) fprintf x ;} -# define Tracev(x) {if (z_verbose>0) fprintf x ;} -# define Tracevv(x) {if (z_verbose>1) fprintf x ;} -# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} -# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} -#else -# define Assert(cond,msg) -# define Trace(x) -# define Tracev(x) -# define Tracevv(x) -# define Tracec(c,x) -# define Tracecv(c,x) -#endif - - -typedef uLong (ZEXPORT *check_func) OF((uLong check, const Bytef *buf, - uInt len)); -voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); -void zcfree OF((voidpf opaque, voidpf ptr)); - -#define ZALLOC(strm, items, size) \ - (*((strm)->zalloc))((strm)->opaque, (items), (size)) -#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) -#define TRY_FREE(s, p) {if (p) ZFREE(s, p);} - -#endif /* _Z_UTIL_H */ diff --git a/src/utils/vmpi/ichannel.h b/src/utils/vmpi/ichannel.h deleted file mode 100644 index a26f034ce0..0000000000 --- a/src/utils/vmpi/ichannel.h +++ /dev/null @@ -1,49 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef ICHANNEL_H -#define ICHANNEL_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "tier1/utlvector.h" - - -class IChannel -{ -public: - // Note: this also releases any channels contained inside. So if you make a reliable - // channel that contains an unreliable channel and release the reliable one, - // it will automatically release the unreliable one it contains. - virtual void Release() = 0; - - // Send data to the destination. - virtual bool Send( const void *pData, int len ) = 0; - - // This version puts all the chunks into one packet and ships it off. - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) = 0; - - // Check for any packets coming in from the destination. - // Returns false if no packet was received. - // - // flTimeout can be used to make it wait for data. - // - // Note: this is most efficient if you keep the buffer around between calls so it only - // reallocates it when it needs more space. - virtual bool Recv( CUtlVector &data, double flTimeout=0 ) = 0; - - // Returns false if the connection has been broken. - virtual bool IsConnected() = 0; - - // If IsConnected returns false, you can call this to find out why the socket got disconnected. - virtual void GetDisconnectReason( CUtlVector &reason ) = 0; -}; - - -#endif // ICHANNEL_H diff --git a/src/utils/vmpi/idle_dialog.cpp b/src/utils/vmpi/idle_dialog.cpp deleted file mode 100644 index 5518fffb67..0000000000 --- a/src/utils/vmpi/idle_dialog.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#include "stdafx.h" -#include "idle_dialog.h" - - -#define WM_STARTIDLE (WM_USER + 565) - - -BEGIN_MESSAGE_MAP(CIdleDialog, CDialog) - //{{AFX_MSG_MAP(CVMPIBrowserDlg) - ON_MESSAGE(WM_STARTIDLE, OnStartIdle) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -CIdleDialog::CIdleDialog( int id, CWnd *pParent ) - : CDialog( id, pParent ) -{ -} - - -void CIdleDialog::StartIdleProcessing( DWORD msInterval ) -{ - m_cWinIdle.StartIdle( GetSafeHwnd(), WM_STARTIDLE, 0, 0, msInterval ); - m_cWinIdle.NextIdle(); -} - - -LONG CIdleDialog::OnStartIdle( UINT, LONG ) -{ - MSG msg; - - if ( !PeekMessage( &msg, GetSafeHwnd(), 0,0, PM_NOREMOVE ) ) - OnIdle(); - - m_cWinIdle.NextIdle(); - return 0; -} - - diff --git a/src/utils/vmpi/idle_dialog.h b/src/utils/vmpi/idle_dialog.h deleted file mode 100644 index 5dbe20c841..0000000000 --- a/src/utils/vmpi/idle_dialog.h +++ /dev/null @@ -1,48 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef IDLE_DIALOG_H -#define IDLE_DIALOG_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "win_idle.h" - - -// -// This is a base class that provides in-thread idle processing. -// -// To use it: -// 1. derive from it -// 2. Change your message map to point at this class instead of CDialog -// 3. Call StartIdleProcessing to begin receiving idle calls. -// 4. Override OnIdle(). -// - -class CIdleDialog : public CDialog -{ -public: - - CIdleDialog( int id, CWnd *pParent ); - - // Call this to start the idle processing. - void StartIdleProcessing( DWORD msInterval ); - - virtual void OnIdle() = 0; - - -private: - DECLARE_MESSAGE_MAP() - afx_msg LONG OnStartIdle(UINT, LONG); - - CWinIdle m_cWinIdle; -}; - - -#endif // IDLE_DIALOG_H diff --git a/src/utils/vmpi/imysqlwrapper.h b/src/utils/vmpi/imysqlwrapper.h deleted file mode 100644 index 2604128854..0000000000 --- a/src/utils/vmpi/imysqlwrapper.h +++ /dev/null @@ -1,115 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef MYSQL_WRAPPER_H -#define MYSQL_WRAPPER_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "utlvector.h" -#include "interface.h" - - -class IMySQLRowSet; - - -class CColumnValue -{ -public: - - CColumnValue( IMySQLRowSet *pSQL, int iColumn ); - - const char* String(); - long Int32(); - -private: - IMySQLRowSet *m_pSQL; - int m_iColumn; -}; - - - -class IMySQLRowSet -{ -public: - virtual void Release() = 0; - - // Get the number of columns in the data returned from the last query (if it was a select statement). - virtual int NumFields() = 0; - - // Get the name of each column returned by the last query. - virtual const char* GetFieldName( int iColumn ) = 0; - - // Call this in a loop until it returns false to iterate over all rows the query returned. - virtual bool NextRow() = 0; - - // You can call this to start iterating over the result set from the start again. - // Note: after calling this, you have to call NextRow() to actually get the first row's value ready. - virtual bool SeekToFirstRow() = 0; - - virtual CColumnValue GetColumnValue( int iColumn ) = 0; - virtual CColumnValue GetColumnValue( const char *pColumnName ) = 0; - - virtual const char* GetColumnValue_String( int iColumn ) = 0; - virtual long GetColumnValue_Int( int iColumn ) = 0; - - // You can call this to get the index of a column for faster lookups with GetColumnValue( int ). - // Returns -1 if the column can't be found. - virtual int GetColumnIndex( const char *pColumnName ) = 0; -}; - - -class IMySQL : public IMySQLRowSet -{ -public: - virtual bool InitMySQL( const char *pDBName, const char *pHostName="", const char *pUserName="", const char *pPassword="" ) = 0; - virtual void Release() = 0; - - // These execute SQL commands. They return 0 if the query was successful. - virtual int Execute( const char *pString ) = 0; - - // This reads in all of the data in the last row set you queried with Execute and builds a separate - // copy. This is useful in some of the VMPI tools to have a thread repeatedly execute a slow query, then - // store off the results for the main thread to parse. - virtual IMySQLRowSet* DuplicateRowSet() = 0; - - // If you just inserted rows into a table with an AUTO_INCREMENT column, - // then this returns the (unique) value of that column. - virtual unsigned long InsertID() = 0; - - // Returns the last error message, if an error took place - virtual const char * GetLastError() = 0; -}; - - -#define MYSQL_WRAPPER_VERSION_NAME "MySQLWrapper001" - - -// ------------------------------------------------------------------------------------------------ // -// Inlines. -// ------------------------------------------------------------------------------------------------ // - -inline CColumnValue::CColumnValue( IMySQLRowSet *pSQL, int iColumn ) -{ - m_pSQL = pSQL; - m_iColumn = iColumn; -} - -inline const char* CColumnValue::String() -{ - return m_pSQL->GetColumnValue_String( m_iColumn ); -} - -inline long CColumnValue::Int32() -{ - return m_pSQL->GetColumnValue_Int( m_iColumn ); -} - - -#endif // MYSQL_WRAPPER_H diff --git a/src/utils/vmpi/iphelpers.cpp b/src/utils/vmpi/iphelpers.cpp deleted file mode 100644 index 14707b21a9..0000000000 --- a/src/utils/vmpi/iphelpers.cpp +++ /dev/null @@ -1,610 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// - -#pragma warning (disable:4127) -#include -#include -#pragma warning (default:4127) - -#include "iphelpers.h" -#include "basetypes.h" -#include -#include "utllinkedlist.h" -#include "utlvector.h" -#include "tier1/strtools.h" -#include "tier0/fasttimer.h" - -// This automatically calls WSAStartup for the app at startup. -class CIPStarter -{ -public: - CIPStarter() - { - WSADATA wsaData; - WSAStartup( WINSOCK_VERSION, &wsaData ); - } -}; -static CIPStarter g_Starter; - - -unsigned long SampleMilliseconds() -{ - CCycleCount cnt; - cnt.Sample(); - return cnt.GetMilliseconds(); -} - - -// ------------------------------------------------------------------------------------------ // -// CChunkWalker. -// ------------------------------------------------------------------------------------------ // - -CChunkWalker::CChunkWalker( void const * const *pChunks, const int *pChunkLengths, int nChunks ) -{ - m_TotalLength = 0; - for ( int i=0; i < nChunks; i++ ) - m_TotalLength += pChunkLengths[i]; - - m_iCurChunk = 0; - m_iCurChunkPos = 0; - m_pChunks = pChunks; - m_pChunkLengths = pChunkLengths; - m_nChunks = nChunks; -} - -int CChunkWalker::GetTotalLength() const -{ - return m_TotalLength; -} - -void CChunkWalker::CopyTo( void *pOut, int nBytes ) -{ - unsigned char *pOutPos = (unsigned char*)pOut; - - int nBytesLeft = nBytes; - while ( nBytesLeft > 0 ) - { - int toCopy = nBytesLeft; - int curChunkLen = m_pChunkLengths[m_iCurChunk]; - - int amtLeft = curChunkLen - m_iCurChunkPos; - if ( nBytesLeft > amtLeft ) - { - toCopy = amtLeft; - } - - unsigned char *pCurChunkData = (unsigned char*)m_pChunks[m_iCurChunk]; - memcpy( pOutPos, &pCurChunkData[m_iCurChunkPos], toCopy ); - nBytesLeft -= toCopy; - pOutPos += toCopy; - - // Slide up to the next chunk if we're done with the one we're on. - m_iCurChunkPos += toCopy; - assert( m_iCurChunkPos <= curChunkLen ); - if ( m_iCurChunkPos == curChunkLen ) - { - ++m_iCurChunk; - m_iCurChunkPos = 0; - if ( m_iCurChunk == m_nChunks ) - { - assert( nBytesLeft == 0 ); - } - } - } -} - - -// ------------------------------------------------------------------------------------------ // -// CWaitTimer -// ------------------------------------------------------------------------------------------ // - -bool g_bForceWaitTimers = false; - -CWaitTimer::CWaitTimer( double flSeconds ) -{ - m_StartTime = SampleMilliseconds(); - m_WaitMS = (unsigned long)( flSeconds * 1000.0 ); -} - - -bool CWaitTimer::ShouldKeepWaiting() -{ - if ( m_WaitMS == 0 ) - { - return false; - } - else - { - return ( SampleMilliseconds() - m_StartTime ) <= m_WaitMS || g_bForceWaitTimers; - } -} - - - -// ------------------------------------------------------------------------------------------ // -// CIPAddr. -// ------------------------------------------------------------------------------------------ // - -CIPAddr::CIPAddr() -{ - Init( 0, 0, 0, 0, 0 ); -} - - -CIPAddr::CIPAddr( const int inputIP[4], const int inputPort ) -{ - Init( inputIP[0], inputIP[1], inputIP[2], inputIP[3], inputPort ); -} - - -CIPAddr::CIPAddr( int ip0, int ip1, int ip2, int ip3, int ipPort ) -{ - Init( ip0, ip1, ip2, ip3, ipPort ); -} - - -void CIPAddr::Init( int ip0, int ip1, int ip2, int ip3, int ipPort ) -{ - ip[0] = (unsigned char)ip0; - ip[1] = (unsigned char)ip1; - ip[2] = (unsigned char)ip2; - ip[3] = (unsigned char)ip3; - port = (unsigned short)ipPort; -} - -bool CIPAddr::operator==( const CIPAddr &o ) const -{ - return ip[0] == o.ip[0] && ip[1] == o.ip[1] && ip[2] == o.ip[2] && ip[3] == o.ip[3] && port == o.port; -} - - -bool CIPAddr::operator!=( const CIPAddr &o ) const -{ - return !( *this == o ); -} - - -void CIPAddr::SetupLocal( int inPort ) -{ - ip[0] = 0x7f; - ip[1] = 0; - ip[2] = 0; - ip[3] = 1; - port = inPort; -} - - -// ------------------------------------------------------------------------------------------ // -// Static helpers. -// ------------------------------------------------------------------------------------------ // - -static double IP_FloatTime() -{ - CCycleCount cnt; - cnt.Sample(); - return cnt.GetSeconds(); -} - -TIMEVAL SetupTimeVal( double flTimeout ) -{ - TIMEVAL timeVal; - timeVal.tv_sec = (long)flTimeout; - timeVal.tv_usec = (long)( (flTimeout - (long)flTimeout) * 1000.0 ); - return timeVal; -} - -// Convert a CIPAddr to a sockaddr_in. -void IPAddrToInAddr( const CIPAddr *pIn, in_addr *pOut ) -{ - u_char *p = (u_char*)pOut; - p[0] = pIn->ip[0]; - p[1] = pIn->ip[1]; - p[2] = pIn->ip[2]; - p[3] = pIn->ip[3]; -} - -// Convert a CIPAddr to a sockaddr_in. -void IPAddrToSockAddr( const CIPAddr *pIn, struct sockaddr_in *pOut ) -{ - memset( pOut, 0, sizeof(*pOut) ); - pOut->sin_family = AF_INET; - pOut->sin_port = htons( pIn->port ); - - IPAddrToInAddr( pIn, &pOut->sin_addr ); -} - -// Convert a CIPAddr to a sockaddr_in. -void SockAddrToIPAddr( const struct sockaddr_in *pIn, CIPAddr *pOut ) -{ - const u_char *p = (const u_char*)&pIn->sin_addr; - pOut->ip[0] = p[0]; - pOut->ip[1] = p[1]; - pOut->ip[2] = p[2]; - pOut->ip[3] = p[3]; - pOut->port = ntohs( pIn->sin_port ); -} - - -class CIPSocket : public ISocket -{ -public: - CIPSocket() - { - m_Socket = INVALID_SOCKET; - m_bSetupToBroadcast = false; - } - - virtual ~CIPSocket() - { - Term(); - } - - -// ISocket implementation. -public: - - virtual void Release() - { - delete this; - } - - - virtual bool CreateSocket() - { - // Clear any old socket we had around. - Term(); - - // Create a socket to send and receive through. - SOCKET sock = socket( AF_INET, SOCK_DGRAM, IPPROTO_IP ); - if ( sock == INVALID_SOCKET ) - { - Assert( false ); - return false; - } - - // Nonblocking please.. - int status; - DWORD val = 1; - status = ioctlsocket( sock, FIONBIO, &val ); - if ( status != 0 ) - { - assert( false ); - closesocket( sock ); - return false; - } - - m_Socket = sock; - return true; - } - - - // Called after we have a socket. - virtual bool BindPart2( const CIPAddr *pAddr ) - { - Assert( m_Socket != INVALID_SOCKET ); - - // bind to it! - sockaddr_in addr; - IPAddrToSockAddr( pAddr, &addr ); - - int status = bind( m_Socket, (sockaddr*)&addr, sizeof(addr) ); - if ( status == 0 ) - { - return true; - } - else - { - Term(); - return false; - } - } - - - virtual bool Bind( const CIPAddr *pAddr ) - { - if ( !CreateSocket() ) - return false; - - return BindPart2( pAddr ); - } - - virtual bool BindToAny( const unsigned short port ) - { - // (INADDR_ANY) - CIPAddr addr; - addr.ip[0] = addr.ip[1] = addr.ip[2] = addr.ip[3] = 0; - addr.port = port; - return Bind( &addr ); - } - - virtual bool ListenToMulticastStream( const CIPAddr &addr, const CIPAddr &localInterface ) - { - ip_mreq mr; - IPAddrToInAddr( &addr, &mr.imr_multiaddr ); - IPAddrToInAddr( &localInterface, &mr.imr_interface ); - - // This helps a lot if the stream is sending really fast. - int rcvBuf = 1024*1024*2; - setsockopt( m_Socket, SOL_SOCKET, SO_RCVBUF, (char*)&rcvBuf, sizeof( rcvBuf ) ); - - if ( setsockopt( m_Socket, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*)&mr, sizeof( mr ) ) == 0 ) - { - // Remember this so we do IP_DEL_MEMBERSHIP on shutdown. - m_bMulticastGroupMembership = true; - m_MulticastGroupMREQ = mr; - return true; - } - else - { - return false; - } - } - - virtual bool Broadcast( const void *pData, const int len, const unsigned short port ) - { - assert( m_Socket != INVALID_SOCKET ); - - // Make sure we're setup to broadcast. - if ( !m_bSetupToBroadcast ) - { - BOOL bBroadcast = true; - if ( setsockopt( m_Socket, SOL_SOCKET, SO_BROADCAST, (char*)&bBroadcast, sizeof( bBroadcast ) ) != 0 ) - { - assert( false ); - return false; - } - - m_bSetupToBroadcast = true; - } - - CIPAddr addr; - addr.ip[0] = addr.ip[1] = addr.ip[2] = addr.ip[3] = 0xFF; - addr.port = port; - return SendTo( &addr, pData, len ); - } - - virtual bool SendTo( const CIPAddr *pAddr, const void *pData, const int len ) - { - return SendChunksTo( pAddr, &pData, &len, 1 ); - } - - virtual bool SendChunksTo( const CIPAddr *pAddr, void const * const *pChunks, const int *pChunkLengths, int nChunks ) - { - WSABUF bufs[32]; - if ( nChunks > 32 ) - { - Error( "CIPSocket::SendChunksTo: too many chunks (%d).", nChunks ); - } - - int nTotalBytes = 0; - for ( int i=0; i < nChunks; i++ ) - { - bufs[i].len = pChunkLengths[i]; - bufs[i].buf = (char*)pChunks[i]; - nTotalBytes += pChunkLengths[i]; - } - - assert( m_Socket != INVALID_SOCKET ); - - // Translate the address. - sockaddr_in addr; - IPAddrToSockAddr( pAddr, &addr ); - - DWORD dwNumBytesSent = 0; - DWORD ret = WSASendTo( - m_Socket, - bufs, - nChunks, - &dwNumBytesSent, - 0, - (sockaddr*)&addr, - sizeof( addr ), - NULL, - NULL - ); - - return ret == 0 && (int)dwNumBytesSent == nTotalBytes; - } - - virtual int RecvFrom( void *pData, int maxDataLen, CIPAddr *pFrom ) - { - assert( m_Socket != INVALID_SOCKET ); - - fd_set readSet; - readSet.fd_count = 1; - readSet.fd_array[0] = m_Socket; - - TIMEVAL timeVal = SetupTimeVal( 0 ); - - // See if it has a packet waiting. - int status = select( 0, &readSet, NULL, NULL, &timeVal ); - if ( status == 0 || status == SOCKET_ERROR ) - return -1; - - // Get the data. - sockaddr_in sender; - int fromSize = sizeof( sockaddr_in ); - status = recvfrom( m_Socket, (char*)pData, maxDataLen, 0, (struct sockaddr*)&sender, &fromSize ); - if ( status == 0 || status == SOCKET_ERROR ) - { - return -1; - } - else - { - if ( pFrom ) - { - SockAddrToIPAddr( &sender, pFrom ); - } - - m_flLastRecvTime = IP_FloatTime(); - return status; - } - } - - virtual double GetRecvTimeout() - { - return IP_FloatTime() - m_flLastRecvTime; - } - - -private: - - void Term() - { - if ( m_Socket != INVALID_SOCKET ) - { - if ( m_bMulticastGroupMembership ) - { - // Undo our multicast group membership. - setsockopt( m_Socket, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char*)&m_MulticastGroupMREQ, sizeof( m_MulticastGroupMREQ ) ); - } - - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - } - - m_bSetupToBroadcast = false; - m_bMulticastGroupMembership = false; - } - - -private: - - SOCKET m_Socket; - - bool m_bMulticastGroupMembership; // Did we join a multicast group? - ip_mreq m_MulticastGroupMREQ; - - bool m_bSetupToBroadcast; - double m_flLastRecvTime; - bool m_bListenSocket; -}; - - - -ISocket* CreateIPSocket() -{ - return new CIPSocket; -} - - -ISocket* CreateMulticastListenSocket( - const CIPAddr &addr, - const CIPAddr &localInterface ) -{ - CIPSocket *pSocket = new CIPSocket; - - CIPAddr bindAddr = localInterface; - bindAddr.port = addr.port; - - if ( pSocket->Bind( &bindAddr ) && - pSocket->ListenToMulticastStream( addr, localInterface ) - ) - { - return pSocket; - } - else - { - pSocket->Release(); - return NULL; - } -} - - -bool ConvertStringToIPAddr( const char *pStr, CIPAddr *pOut ) -{ - char ipStr[512]; - - const char *pColon = strchr( pStr, ':' ); - if ( pColon ) - { - int toCopy = pColon - pStr; - if ( toCopy < 2 || toCopy > sizeof(ipStr)-1 ) - { - assert( false ); - return false; - } - - memcpy( ipStr, pStr, toCopy ); - ipStr[toCopy] = 0; - - pOut->port = (unsigned short)atoi( pColon+1 ); - } - else - { - strncpy( ipStr, pStr, sizeof( ipStr ) ); - ipStr[ sizeof(ipStr)-1 ] = 0; - } - - if ( ipStr[0] >= '0' && ipStr[0] <= '9' ) - { - // It's numbers. - int ip[4]; - sscanf( ipStr, "%d.%d.%d.%d", &ip[0], &ip[1], &ip[2], &ip[3] ); - pOut->ip[0] = (unsigned char)ip[0]; - pOut->ip[1] = (unsigned char)ip[1]; - pOut->ip[2] = (unsigned char)ip[2]; - pOut->ip[3] = (unsigned char)ip[3]; - } - else - { - // It's a text string. - struct hostent *pHost = gethostbyname( ipStr ); - if( !pHost ) - return false; - - pOut->ip[0] = pHost->h_addr_list[0][0]; - pOut->ip[1] = pHost->h_addr_list[0][1]; - pOut->ip[2] = pHost->h_addr_list[0][2]; - pOut->ip[3] = pHost->h_addr_list[0][3]; - } - - return true; -} - - -bool ConvertIPAddrToString( const CIPAddr *pIn, char *pOut, int outLen ) -{ - in_addr addr; - addr.S_un.S_un_b.s_b1 = pIn->ip[0]; - addr.S_un.S_un_b.s_b2 = pIn->ip[1]; - addr.S_un.S_un_b.s_b3 = pIn->ip[2]; - addr.S_un.S_un_b.s_b4 = pIn->ip[3]; - - HOSTENT *pEnt = gethostbyaddr( (char*)&addr, sizeof( addr ), AF_INET ); - if ( pEnt ) - { - Q_strncpy( pOut, pEnt->h_name, outLen ); - return true; - } - else - { - return false; - } -} - - -void IP_GetLastErrorString( char *pStr, int maxLen ) -{ - char *lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - - Q_strncpy( pStr, lpMsgBuf, maxLen ); - LocalFree( lpMsgBuf ); -} - diff --git a/src/utils/vmpi/iphelpers.h b/src/utils/vmpi/iphelpers.h deleted file mode 100644 index acd356a95b..0000000000 --- a/src/utils/vmpi/iphelpers.h +++ /dev/null @@ -1,162 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// - -#ifndef IPHELPERS_H -#define IPHELPERS_H - - -#include "ichannel.h" - - -// Loops that poll sockets should Sleep for this amount of time between iterations -// so they don't hog all the CPU. -#define LOOP_POLL_INTERVAL 5 - - -// Useful for putting the arguments into a printf statement. -#define EXPAND_ADDR( x ) (x).ip[0], (x).ip[1], (x).ip[2], (x).ip[3], (x).port - - -// This is a simple wrapper layer for UDP sockets. -class CIPAddr -{ -public: - CIPAddr(); - CIPAddr( const int inputIP[4], const int inputPort ); - CIPAddr( int ip0, int ip1, int ip2, int ip3, int ipPort ); - - void Init( int ip0, int ip1, int ip2, int ip3, int ipPort ); - bool operator==( const CIPAddr &o ) const; - bool operator!=( const CIPAddr &o ) const; - - // Setup to send to the local machine on the specified port. - void SetupLocal( int inPort ); - -public: - - unsigned char ip[4]; - unsigned short port; -}; - - - -// The chunk walker provides an easy way to copy data out of the chunks as though it were a -// single contiguous chunk of memory.s -class CChunkWalker -{ -public: - CChunkWalker( void const * const *pChunks, const int *pChunkLengths, int nChunks ); - - int GetTotalLength() const; - void CopyTo( void *pOut, int nBytes ); - -private: - - void const * const *m_pChunks; - const int *m_pChunkLengths; - int m_nChunks; - - int m_iCurChunk; - int m_iCurChunkPos; - - int m_TotalLength; -}; - - -// This class makes loop that wait on something look nicer. ALL loops using this class -// should follow this pattern, or they can wind up with unforeseen delays that add a whole -// lot of lag. -// -// CWaitTimer waitTimer( 5.0 ); -// while ( 1 ) -// { -// do your thing here like Recv() from a socket. -// -// if ( waitTimer.ShouldKeepWaiting() ) -// Sleep() for some time interval like 5ms so you don't hog the CPU -// else -// BREAK HERE -// } -class CWaitTimer -{ -public: - CWaitTimer( double flSeconds ); - - bool ShouldKeepWaiting(); - -private: - unsigned long m_StartTime; - unsigned long m_WaitMS; -}; - - -// Helper function to get time in milliseconds. -unsigned long SampleMilliseconds(); - - -class ISocket -{ -public: - - // Call this when you're done. - virtual void Release() = 0; - - - // Bind the socket so you can send and receive with it. - // If you bind to port 0, then the system will select the port for you. - virtual bool Bind( const CIPAddr *pAddr ) = 0; - virtual bool BindToAny( const unsigned short port ) = 0; - - - // Broadcast some data. - virtual bool Broadcast( const void *pData, const int len, const unsigned short port ) = 0; - - // Send a packet. - virtual bool SendTo( const CIPAddr *pAddr, const void *pData, const int len ) = 0; - virtual bool SendChunksTo( const CIPAddr *pAddr, void const * const *pChunks, const int *pChunkLengths, int nChunks ) = 0; - - // Receive a packet. Returns the length received or -1 if no data came in. - // If pFrom is set, then it is filled in with the sender's IP address. - virtual int RecvFrom( void *pData, int maxDataLen, CIPAddr *pFrom ) = 0; - - // How long has it been since we successfully received a packet? - virtual double GetRecvTimeout() = 0; -}; - -// Create a connectionless socket that you can send packets out of. -ISocket* CreateIPSocket(); - -// This sets up the socket to receive multicast data on the specified group. -// By default, localInterface is INADDR_ANY, but if you want to specify a specific interface -// the data should come in through, you can. -ISocket* CreateMulticastListenSocket( - const CIPAddr &addr, - const CIPAddr &localInterface = CIPAddr() - ); - - -// Setup a CIPAddr from the string. The string can be a dotted IP address or -// a hostname, and it can be followed by a colon and a port number like "1.2.3.4:3443" -// or "myhostname.valvesoftware.com:2342". -// -// Note: if the string does not contain a port, then pOut->port will be left alone. -bool ConvertStringToIPAddr( const char *pStr, CIPAddr *pOut ); - -// Do a DNS lookup on the IP. -// You can optionally get a service name back too. -bool ConvertIPAddrToString( const CIPAddr *pIn, char *pOut, int outLen ); - - -void IP_GetLastErrorString( char *pStr, int maxLen ); - -void SockAddrToIPAddr( const struct sockaddr_in *pIn, CIPAddr *pOut ); -void IPAddrToSockAddr( const CIPAddr *pIn, struct sockaddr_in *pOut ); - - -#endif - diff --git a/src/utils/vmpi/loopback_channel.cpp b/src/utils/vmpi/loopback_channel.cpp deleted file mode 100644 index 79b2fa6b31..0000000000 --- a/src/utils/vmpi/loopback_channel.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#include "loopback_channel.h" -#include "utllinkedlist.h" -#include "iphelpers.h" - - -// -------------------------------------------------------------------------------- // -// CLoopbackChannel. -// -------------------------------------------------------------------------------- // - -typedef struct -{ - int m_Len; - unsigned char m_Data[1]; -} LoopbackMsg_t; - - -class CLoopbackChannel : public IChannel -{ -public: - - virtual ~CLoopbackChannel() - { - FOR_EACH_LL( m_Messages, i ) - { - free( m_Messages[i] ); - } - m_Messages.Purge(); - } - - virtual void Release() - { - delete this; - } - - virtual bool Send( const void *pData, int len ) - { - const void *pChunks[1] = { pData }; - int chunkLengths[1] = { len }; - return SendChunks( pChunks, chunkLengths, 1 ); - } - - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) - { - CChunkWalker walker( pChunks, pChunkLengths, nChunks ); - - LoopbackMsg_t *pMsg = (LoopbackMsg_t*)malloc( sizeof( LoopbackMsg_t ) - 1 + walker.GetTotalLength() ); - walker.CopyTo( pMsg->m_Data, walker.GetTotalLength() ); - pMsg->m_Len = walker.GetTotalLength(); - m_Messages.AddToTail( pMsg ); - return true; - } - - virtual bool Recv( CUtlVector &data, double flTimeout ) - { - int iNext = m_Messages.Head(); - if ( iNext == m_Messages.InvalidIndex() ) - { - return false; - } - else - { - LoopbackMsg_t *pMsg = m_Messages[iNext]; - - data.CopyArray( pMsg->m_Data, pMsg->m_Len ); - - free( pMsg ); - m_Messages.Remove( iNext ); - - return true; - } - } - - virtual bool IsConnected() - { - return true; - } - - virtual void GetDisconnectReason( CUtlVector &reason ) - { - } - -private: - CUtlLinkedList m_Messages; // FIFO for messages we've sent. -}; - - -IChannel* CreateLoopbackChannel() -{ - return new CLoopbackChannel; -} - diff --git a/src/utils/vmpi/loopback_channel.h b/src/utils/vmpi/loopback_channel.h deleted file mode 100644 index 137efbe05c..0000000000 --- a/src/utils/vmpi/loopback_channel.h +++ /dev/null @@ -1,22 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef LOOPBACK_CHANNEL_H -#define LOOPBACK_CHANNEL_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "ichannel.h" - - -// Loopback sockets receive the same data they send. -IChannel* CreateLoopbackChannel(); - - -#endif // LOOPBACK_CHANNEL_H diff --git a/src/utils/vmpi/messagemgr.cpp b/src/utils/vmpi/messagemgr.cpp deleted file mode 100644 index 8d75f47e82..0000000000 --- a/src/utils/vmpi/messagemgr.cpp +++ /dev/null @@ -1,300 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#include -#include "messagemgr.h" -#include "tcpsocket.h" -#include "iphelpers.h" -#include "tier0/platform.h" -#include "threadhelpers.h" - - -#define MSGMGR_LISTEN_PORT_FIRST 22512 -#define MSGMGR_LISTEN_PORT_LAST 22520 - - - -#define BROADCAST_INTERVAL 2 // Broadcast our presence every N seconds. - -#define NUM_QUEUED_MESSAGES 200 - - - -class CMessageMgr : public IMessageMgr -{ -public: - CMessageMgr(); - ~CMessageMgr(); - - bool Init(); - void Term(); - - -// IMessageMgr overrides. -public: - - virtual void Print( const char *pMsg ); - - - -private: - - DWORD ThreadFn(); - static DWORD WINAPI StaticThreadFn( LPVOID pParameter ); - - -private: - - // Only our thread touches this, NOT the main thread. - CUtlLinkedList m_Sockets; - - HANDLE m_hThread; - DWORD m_dwThreadID; - - HANDLE m_hExitObj; // This is signalled when we want the thread to exit. - HANDLE m_hExitResponseObj; // The thread sets this when it exits. - - HANDLE m_hMessageObj; // This signals to the thread that there's a message to send. - HANDLE m_hMessageSentObj; // This signals back to the main thread that the message was sent. - const char *m_pMessageText; // The text to send. - - // This is only touched by the thread. - CUtlLinkedList m_MessageQ; // FIFO of NUM_QUEUED_MESSAGES. - - ITCPListenSocket *m_pListenSocket; - int m_iListenPort; - - ISocket *m_pBroadcastSocket; - double m_flLastBroadcast; - -}; - - - -CMessageMgr::CMessageMgr() -{ - m_pBroadcastSocket = NULL; - m_pListenSocket = NULL; - m_hThread = NULL; - m_hExitObj = m_hExitResponseObj = m_hMessageObj = m_hMessageSentObj = NULL; -} - - -CMessageMgr::~CMessageMgr() -{ - Term(); -} - - -bool CMessageMgr::Init() -{ - m_hExitObj = CreateEvent( NULL, false, false, NULL ); - m_hExitResponseObj = CreateEvent( NULL, false, false, NULL ); - m_hMessageObj = CreateEvent( NULL, false, false, NULL ); - m_hMessageSentObj = CreateEvent( NULL, false, false, NULL ); - if ( !m_hExitObj || !m_hExitResponseObj || !m_hMessageObj || !m_hMessageSentObj ) - return false; - - // Create the broadcast socket. - m_pBroadcastSocket = CreateIPSocket(); - if ( !m_pBroadcastSocket ) - return false; - - if ( !m_pBroadcastSocket->BindToAny( 0 ) ) - return false; - - - // Create the listen socket. - m_pListenSocket = NULL; - for ( m_iListenPort=MSGMGR_LISTEN_PORT_FIRST; m_iListenPort <= MSGMGR_LISTEN_PORT_LAST; m_iListenPort++ ) - { - m_pListenSocket = CreateTCPListenSocket( m_iListenPort ); - if ( m_pListenSocket ) - break; - } - if ( !m_pListenSocket ) - return false; - - - // Create our broadcast/connection thread. - m_flLastBroadcast = 0; - m_hThread = CreateThread( - NULL, - 0, - &CMessageMgr::StaticThreadFn, - this, - 0, - &m_dwThreadID ); - - if ( !m_hThread ) - return false; - - ThreadSetDebugName( m_dwThreadID, "MessageMgr" ); - return true; -} - - -void CMessageMgr::Term() -{ - // Wait for the thread to exit? - if ( m_hThread ) - { - DWORD dwExitCode = 0; - if ( GetExitCodeThread( m_hThread, &dwExitCode ) && dwExitCode == STILL_ACTIVE ) - { - SetEvent( m_hExitObj ); - WaitForSingleObject( m_hExitResponseObj, INFINITE ); - } - - CloseHandle( m_hThread ); - m_hThread = NULL; - } - - CloseHandle( m_hExitObj ); - m_hExitObj = NULL; - - CloseHandle( m_hExitResponseObj ); - m_hExitResponseObj = NULL; - - CloseHandle( m_hMessageObj ); - m_hMessageObj = NULL; - - CloseHandle( m_hMessageSentObj ); - m_hMessageSentObj = NULL; - - if ( m_pListenSocket ) - { - m_pListenSocket->Release(); - m_pListenSocket = NULL; - } - - if ( m_pBroadcastSocket ) - { - m_pBroadcastSocket->Release(); - m_pBroadcastSocket = NULL; - } -} - - -void CMessageMgr::Print( const char *pMsg ) -{ - m_pMessageText = pMsg; - SetEvent( m_hMessageObj ); - WaitForSingleObject( m_hMessageSentObj, INFINITE ); -} - - -DWORD CMessageMgr::ThreadFn() -{ - while ( 1 ) - { - // Broadcast our presence? - double flCurTime = Plat_FloatTime(); - if ( flCurTime - m_flLastBroadcast >= BROADCAST_INTERVAL ) - { - // Broadcast our presence. - char msg[9]; - msg[0] = MSGMGR_PACKETID_ANNOUNCE_PRESENCE; - *((int*)&msg[1]) = MSGMGR_VERSION; - *((int*)&msg[5]) = m_iListenPort; - m_pBroadcastSocket->Broadcast( msg, sizeof( msg ), MSGMGR_BROADCAST_PORT ); - - m_flLastBroadcast = flCurTime; - } - - - // Accept new connections. - CIPAddr addr; - ITCPSocket *pConn = m_pListenSocket->UpdateListen( &addr ); - if ( pConn ) - { - // Send what's in our queue. - FOR_EACH_LL( m_MessageQ, iQ ) - { - char *pMsg = m_MessageQ[iQ]; - int bufLen = strlen( pMsg ) + 1; - - char packetID = MSGMGR_PACKETID_MSG; - const void *data[2] = { &packetID, pMsg }; - int len[2] = { 1, bufLen }; - - // Send it out to our sockets. - pConn->SendChunks( data, len, 2 ); - } - - m_Sockets.AddToTail( pConn ); - } - - - // Should we exit? - HANDLE handles[2] = {m_hExitObj, m_hMessageObj}; - DWORD ret = WaitForMultipleObjects( 2, handles, FALSE, 200 ); - if ( ret == WAIT_OBJECT_0 ) - { - break; - } - else if ( ret == (WAIT_OBJECT_0+1) ) - { - // Add it to the queue. - int index; - if ( m_MessageQ.Count() >= NUM_QUEUED_MESSAGES ) - { - index = m_MessageQ.Tail(); - delete m_MessageQ[index]; - } - else - { - index = m_MessageQ.AddToTail(); - } - int bufLen = strlen( m_pMessageText ) + 1; - m_MessageQ[index] = new char[ bufLen ]; - strcpy( m_MessageQ[index], m_pMessageText ); - - - - // Ok, send out the message. - char packetID = MSGMGR_PACKETID_MSG; - const void *data[2] = { &packetID, m_pMessageText }; - int len[2] = { 1, bufLen }; - - // Send it out to our sockets. - FOR_EACH_LL( m_Sockets, i ) - { - m_Sockets[i]->SendChunks( data, len, 2 ); - } - - // Notify the main thread that we've sent it. - SetEvent( m_hMessageSentObj ); - } - } - - // Cleanup all our sockets (the main thread should never touch them). - FOR_EACH_LL( m_Sockets, i ) - m_Sockets[i]->Release(); - - m_Sockets.Purge(); - - m_MessageQ.PurgeAndDeleteElements(); - - SetEvent( m_hExitResponseObj ); - return 0; -} - - -DWORD CMessageMgr::StaticThreadFn( LPVOID pParameter ) -{ - return ((CMessageMgr*)pParameter)->ThreadFn(); -} - - -static CMessageMgr g_MessageMgr; - -IMessageMgr* GetMessageMgr() -{ - return &g_MessageMgr; -} - diff --git a/src/utils/vmpi/messagemgr.h b/src/utils/vmpi/messagemgr.h deleted file mode 100644 index cebbe76ac1..0000000000 --- a/src/utils/vmpi/messagemgr.h +++ /dev/null @@ -1,39 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef MESSAGEMGR_H -#define MESSAGEMGR_H -#ifdef _WIN32 -#pragma once -#endif - - -#define MSGMGR_VERSION 52314 -#define MSGMGR_BROADCAST_PORT 22511 - -#define MSGMGR_PACKETID_MSG 0 -#define MSGMGR_PACKETID_ANNOUNCE_PRESENCE 1 // followed by version # and port - - -// IMessageMgr provides a simple interface apps can use to generate output. Apps -// on the network can connect to the messagemgr to get its output and display it. -class IMessageMgr -{ -public: - virtual bool Init() = 0; - virtual void Term() = 0; - - virtual void Print( const char *pMsg ) = 0; -}; - - -// Get the message manager. It's a global singleton so this will always -// return the same value (null if the manager can't initialize). -IMessageMgr* GetMessageMgr(); - - -#endif // MESSAGEMGR_H diff --git a/src/utils/vmpi/messbuf.cpp b/src/utils/vmpi/messbuf.cpp deleted file mode 100644 index d0f65ebb21..0000000000 --- a/src/utils/vmpi/messbuf.cpp +++ /dev/null @@ -1,279 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// -// MessageBuffer - handy for serializing/unserializing -// structures to be sent as messages -// dal - 9/2002 -// -#include -#include -#include "messbuf.h" -#include "tier1/strtools.h" - - -/////////////////////////// -// -// -// -MessageBuffer::MessageBuffer() -{ - size = DEFAULT_MESSAGE_BUFFER_SIZE; - data = (char *) malloc(size); - len = 0; - offset = 0; -} - -/////////////////////////// -// -// -// -MessageBuffer::MessageBuffer(int minsize) -{ - size = minsize; - data = (char *) malloc(size); - len = 0; - offset = 0; -} - -/////////////////////////// -// -// -// -MessageBuffer::~MessageBuffer() -{ - free(data); -} - - -/////////////////////////// -// -// -// -int -MessageBuffer::getSize() -{ - return size; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::getLen() -{ - return len; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::setLen(int nlen) -{ - if (nlen < 0) return -1; - if (nlen > size) { - resize(nlen); - } - - int res = len; - len = nlen; - - return res; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::getOffset() -{ - return offset; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::setOffset(int noffset) -{ - if (noffset < 0 || noffset > len) return -1; - int res = offset; - offset = noffset; - - return res; -} - - -/////////////////////////// -// -// -// -int -MessageBuffer::write(void const * p, int bytes) -{ - if (bytes + len > size) { - resize(bytes + len); - } - memcpy(data + len, p, bytes); - int res = len; - len += bytes; - - return res; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::update(int loc, void const * p, int bytes) -{ - if (loc + bytes > size) { - resize(loc + bytes); - } - memcpy(data + loc, p, bytes); - - if (len < loc + bytes) { - len = loc + bytes; - } - - return len; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::extract(int loc, void * p, int bytes) -{ - if (loc + bytes > len) return -1; - memcpy(p, data + loc, bytes); - - return loc + bytes; -} - -/////////////////////////// -// -// -// -int -MessageBuffer::read(void * p, int bytes) -{ - if (offset + bytes > len) return -1; - memcpy(p, data + offset, bytes); - - offset += bytes; - return offset; -} - -int MessageBuffer::WriteString( const char *pString ) -{ - return write( pString, V_strlen( pString ) + 1 ); -} - -int MessageBuffer::ReadString( char *pOut, int bufferLength ) -{ - int nChars = 0; - while ( 1 ) - { - char ch; - if ( read( &ch, sizeof( ch ) ) == -1 ) - { - pOut[0] = 0; - return -1; - } - - if ( ch == 0 || nChars >= (bufferLength-1) ) - break; - - pOut[nChars] = ch; - ++nChars; - } - pOut[nChars] = 0; - return nChars + 1; -} - - -/////////////////////////// -// -// -// -void -MessageBuffer::clear() -{ - memset(data, 0, size); - offset = 0; - len = 0; -} - -/////////////////////////// -// -// -// -void -MessageBuffer::clear(int minsize) -{ - if (minsize > size) { - resize(minsize); - } - memset(data, 0, size); - offset = 0; - len = 0; -} - -/////////////////////////// -// -// -// -void -MessageBuffer::reset(int minsize) -{ - if (minsize > size) { - resize(minsize); - } - len = 0; - offset = 0; -} - -/////////////////////////// -// -// -// -void -MessageBuffer::resize(int minsize) -{ - if (minsize < size) return; - - if (size * 2 > minsize) minsize = size * 2; - - char * odata = data; - data = (char *) malloc(minsize); - memcpy(data, odata, len); - size = minsize; - free(odata); -} - - -/////////////////////////// -// -// -void -MessageBuffer::print(FILE * ofile, int num) -{ - fprintf(ofile, "Len: %d Offset: %d Size: %d\n", len, offset, size); - if (num > size) num = size; - for (int i=0; i -#define DEFAULT_MESSAGE_BUFFER_SIZE 2048 - -class MessageBuffer { - public: - char * data; - - MessageBuffer(); - MessageBuffer(int size); - ~MessageBuffer(); - - int getSize(); - int getLen(); - int setLen(int len); - int getOffset(); - int setOffset(int offset); - - int write(void const * p, int bytes); - int update(int loc, void const * p, int bytes); - int extract(int loc, void * p, int bytes); - int read(void * p, int bytes); - - int WriteString( const char *pString ); - int ReadString( char *pOut, int bufferLength ); - - void clear(); - void clear(int minsize); - void reset(int minsize); - void print(FILE * ofile, int num); - - void *GetReadPointer() - { - return ( void * )( data + offset ); - } - - int GetReadBytesLeft() - { - return len - offset; - } - - private: - void resize(int minsize); - int size; - int offset; - int len; -}; - -#endif diff --git a/src/utils/vmpi/mysql_async.cpp b/src/utils/vmpi/mysql_async.cpp deleted file mode 100644 index e4721a04e4..0000000000 --- a/src/utils/vmpi/mysql_async.cpp +++ /dev/null @@ -1,275 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#include -#include "imysqlwrapper.h" -#include "mysql_async.h" -#include "utllinkedlist.h" - - -static char* CopyString( const char *pStr ) -{ - char *pRet = new char[ strlen( pStr ) + 1 ]; - strcpy( pRet, pStr ); - return pRet; -} - - -class CMySQLAsync : public IMySQLAsync -{ -public: - - CMySQLAsync() - { - m_hThread = NULL; - m_pSQL = NULL; - - m_hExitEvent = CreateEvent( NULL, true, false, NULL ); // Use manual reset because we want it to cascade out without - // resetting the event if it gets set. - m_hPendingQueryEvent = CreateEvent( NULL, false, false, NULL ); - m_hQueryResultsEvent = CreateEvent( NULL, false, false, NULL ); - - InitializeCriticalSection( &m_ExecuteQueryCS ); - InitializeCriticalSection( &m_PendingQueryCS ); - } - - ~CMySQLAsync() - { - Term(); - - CloseHandle( m_hExitEvent ); - CloseHandle( m_hPendingQueryEvent ); - CloseHandle( m_hQueryResultsEvent ); - - DeleteCriticalSection( &m_ExecuteQueryCS ); - DeleteCriticalSection( &m_PendingQueryCS ); - } - - virtual void Release() - { - delete this; - } - - virtual IMySQLRowSet* ExecuteBlocking( const char *pStr ) - { - IMySQLRowSet *pRet; - - EnterCriticalSection( &m_ExecuteQueryCS ); - m_pSQL->Execute( pStr ); - pRet = m_pSQL->DuplicateRowSet(); - LeaveCriticalSection( &m_ExecuteQueryCS ); - - return pRet; - } - - virtual void Execute( const char *pStr, void *pUserData ) - { - EnterCriticalSection( &m_PendingQueryCS ); - - CPendingQuery query; - query.m_pStr = CopyString( pStr ); - query.m_pUserData = pUserData; - query.m_Timer.Start(); - - m_PendingQueries.AddToTail( query ); - SetEvent( m_hPendingQueryEvent ); - - LeaveCriticalSection( &m_PendingQueryCS ); - } - - virtual bool GetNextResults( CQueryResults &results ) - { - results.m_pResults = NULL; - - if ( WaitForSingleObject( m_hQueryResultsEvent, 0 ) == WAIT_OBJECT_0 ) - { - EnterCriticalSection( &m_PendingQueryCS ); - - Assert( m_QueryResults.Count() > 0 ); - int iHead = m_QueryResults.Head(); - results = m_QueryResults[iHead]; - m_QueryResults.Remove( iHead ); - - if ( m_QueryResults.Count() > 0 ) - SetEvent( m_hQueryResultsEvent ); - - LeaveCriticalSection( &m_PendingQueryCS ); - return true; - } - else - { - return false; - } - } - - bool Init( IMySQL *pSQL ) - { - Term(); - - DWORD dwThreadID; - m_hThread = CreateThread( NULL, 0, &CMySQLAsync::StaticThreadFn, this, 0, &dwThreadID ); - if ( m_hThread ) - { - m_pSQL = pSQL; - return true; - } - else - { - return false; - } - } - - void Term() - { - // Stop the thread. - if ( m_hThread ) - { - // Delete all our queries. - SetEvent( m_hExitEvent ); - WaitForSingleObject( m_hThread, INFINITE ); - CloseHandle( m_hThread ); - m_hThread = NULL; - } - - // Delete leftover queries. - FOR_EACH_LL( m_PendingQueries, iPendingQuery ) - { - delete [] m_PendingQueries[iPendingQuery].m_pStr; - } - m_PendingQueries.Purge(); - - FOR_EACH_LL( m_QueryResults, i ) - { - m_QueryResults[i].m_pResults->Release(); - } - m_QueryResults.Purge(); - - if ( m_pSQL ) - { - m_pSQL->Release(); - m_pSQL = NULL; - } - } - - -private: - - DWORD ThreadFn() - { - HANDLE hEvents[2] = { m_hExitEvent, m_hPendingQueryEvent }; - - // - while ( 1 ) - { - int ret = WaitForMultipleObjects( ARRAYSIZE( hEvents ), hEvents, false, INFINITE ); - if ( ret == WAIT_OBJECT_0 ) - break; - - if ( ret == WAIT_OBJECT_0+1 ) - { - // A new string has been queued up for us to execute. - EnterCriticalSection( &m_PendingQueryCS ); - - Assert( m_PendingQueries.Count() > 0 ); - int iHead = m_PendingQueries.Head(); - - CPendingQuery pending = m_PendingQueries[iHead]; - m_PendingQueries.Remove( iHead ); - - // Set the pending query event if there are more queries waiting to run. - if ( m_PendingQueries.Count() > 0 ) - SetEvent( m_hPendingQueryEvent ); - - LeaveCriticalSection( &m_PendingQueryCS ); - - - // Run the query. - EnterCriticalSection( &m_ExecuteQueryCS ); - - CQueryResults results; - results.m_pResults = NULL; - results.m_pUserData = pending.m_pUserData; - results.m_ExecuteTime.Init(); - pending.m_Timer.End(); - results.m_QueueTime = pending.m_Timer.GetDuration(); - - CFastTimer executeTimer; - executeTimer.Start(); - - if ( m_pSQL->Execute( pending.m_pStr ) == 0 ) - { - executeTimer.End(); - results.m_ExecuteTime = executeTimer.GetDuration(); - results.m_pResults = m_pSQL->DuplicateRowSet(); - } - - delete pending.m_pStr; - - LeaveCriticalSection( &m_ExecuteQueryCS ); - - - // Store the results. - EnterCriticalSection( &m_PendingQueryCS ); - - m_QueryResults.AddToTail( results ); - SetEvent( m_hQueryResultsEvent ); - - LeaveCriticalSection( &m_PendingQueryCS ); - } - } - - return 0; - } - - static DWORD WINAPI StaticThreadFn( LPVOID lpParameter ) - { - return ((CMySQLAsync*)lpParameter)->ThreadFn(); - } - -private: - - HANDLE m_hThread; - HANDLE m_hExitEvent; - HANDLE m_hPendingQueryEvent; // Signaled when a new query is added. - HANDLE m_hQueryResultsEvent; - - IMySQL *m_pSQL; - - CRITICAL_SECTION m_PendingQueryCS; - CRITICAL_SECTION m_ExecuteQueryCS; - - - // Outgoing query results. New ones are added to the tail. - CUtlLinkedList m_QueryResults; - - - // New ones added to the tail. - class CPendingQuery - { - public: - char *m_pStr; - void *m_pUserData; - CFastTimer m_Timer; // Times how long this query is in the queue. - }; - - CUtlLinkedList m_PendingQueries; -}; - - -IMySQLAsync* CreateMySQLAsync( IMySQL *pSQL ) -{ - CMySQLAsync *pRet = new CMySQLAsync; - if ( pRet->Init( pSQL ) ) - { - return pRet; - } - else - { - delete pRet; - return NULL; - } -} - diff --git a/src/utils/vmpi/mysql_async.h b/src/utils/vmpi/mysql_async.h deleted file mode 100644 index 03844a2fa8..0000000000 --- a/src/utils/vmpi/mysql_async.h +++ /dev/null @@ -1,56 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#ifndef MYSQL_ASYNC_H -#define MYSQL_ASYNC_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "tier0/fasttimer.h" - - -class IMySQL; - - -class CQueryResults -{ -public: - IMySQLRowSet *m_pResults; - void *m_pUserData; // This is the value passed to Execute. - CCycleCount m_ExecuteTime; // How long it took to execute this query in MySQL. - CCycleCount m_QueueTime; // How long it spent in the queue. -}; - - -// This provides a way to do asynchronous MySQL queries. They are executed in a thread, -// then you can pop the results off as they arrive. -class IMySQLAsync -{ -public: - - virtual void Release() = 0; - - // After finishing the current query, if there is one, this immediately executes - // the specified query and returns its results. - virtual IMySQLRowSet* ExecuteBlocking( const char *pStr ) = 0; - - // Queue up a query. - virtual void Execute( const char *pStr, void *pUserData ) = 0; - - // Poll this to pick up results from Execute(). - // NOTE: if this returns true, but pResults is set to NULL, then that query had an error. - virtual bool GetNextResults( CQueryResults &results ) = 0; -}; - -// Create an async mysql interface. Note: if this call returns a non-null value, -// then after this call, you do NOT own pSQL anymore and you shouldn't ever call -// a function in it again. -IMySQLAsync* CreateMySQLAsync( IMySQL *pSQL ); - - -#endif // MYSQL_ASYNC_H diff --git a/src/utils/vmpi/mysql_wrapper.h b/src/utils/vmpi/mysql_wrapper.h deleted file mode 100644 index 01ca9d988f..0000000000 --- a/src/utils/vmpi/mysql_wrapper.h +++ /dev/null @@ -1,104 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef MYSQL_WRAPPER_H -#define MYSQL_WRAPPER_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "utlvector.h" - - -class IMySQL; - - -// This is a helper class to build queries like the stream IO. -class CMySQLQuery -{ -friend class CMySQL; - -public: - // This is like a sprintf, but it will grow the string as necessary. - void Format( PRINTF_FORMAT_STRING const char *pFormat, ... ); - -private: - CUtlVector m_QueryText; -}; - - -class CColumnValue -{ -public: - - CColumnValue( CMySQL *pSQL, int iColumn ); - - const char* String(); - long Int32(); - unsigned long UInt32(); - -private: - CMySQL *m_pSQL; - int m_iColumn; -}; - - -class IMySQL -{ -public: - virtual void Release() = 0; - - // These execute SQL commands. They return 0 if the query was successful. - virtual int Execute( const char *pString ) = 0; - virtual int Execute( CMySQLQuery &query ) = 0; - - // If you just inserted rows into a table with an AUTO_INCREMENT column, - // then this returns the (unique) value of that column. - virtual unsigned long InsertID() = 0; - - // If you just executed a select statement, then you can use these functions to - // iterate over the result set. - - // Get the number of columns in the data returned from the last query (if it was a select statement). - virtual int NumFields() = 0; - - // Get the name of each column returned by the last query. - virtual const char* GetFieldName( int iColumn ) = 0; - - // Call this in a loop until it returns false to iterate over all rows the query returned. - virtual bool NextRow() = 0; - - // You can call this to start iterating over the result set from the start again. - // Note: after calling this, you have to call NextRow() to actually get the first row's value ready. - virtual bool SeekToFirstRow() = 0; - - virtual CColumnValue GetColumnValue( int iColumn ) = 0; - virtual CColumnValue GetColumnValue( const char *pColumnName ) = 0; - - // You can call this to get the index of a column for faster lookups with GetColumnValue( int ). - // Returns -1 if the column can't be found. - virtual int GetColumnIndex( const char *pColumnName ) = 0; -}; - - -IMySQL* InitMySQL( const char *pDBName, const char *pHostName="", const char *pUserName="", const char *pPassword="" ); - - - -// ------------------------------------------------------------------------------------------------ // -// Inlines. -// ------------------------------------------------------------------------------------------------ // - -inline CColumnValue::CColumnValue( CMySQL *pSQL, int iColumn ) -{ - m_pSQL = pSQL; - m_iColumn = iColumn; -} - - -#endif // MYSQL_WRAPPER_H diff --git a/src/utils/vmpi/net_view_thread.cpp b/src/utils/vmpi/net_view_thread.cpp deleted file mode 100644 index 8a101027e5..0000000000 --- a/src/utils/vmpi/net_view_thread.cpp +++ /dev/null @@ -1,215 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#include "stdafx.h" -#include "net_view_thread.h" - - -char* CopyAlloc( const char *pStr ) -{ - char *pRet = new char[ strlen( pStr ) + 1]; - strcpy( pRet, pStr ); - return pRet; -} - - -CNetViewThread::CNetViewThread() -{ - m_hThread = NULL; - m_hThreadExitEvent = NULL; - InitializeCriticalSection( &m_ComputerNamesCS ); -} - - -CNetViewThread::~CNetViewThread() -{ - Term(); - DeleteCriticalSection( &m_ComputerNamesCS ); -} - - -void CNetViewThread::Init() -{ - Term(); - - m_hThreadExitEvent = CreateEvent( NULL, false, false, NULL ); - - DWORD dwThreadID = 0; - m_hThread = CreateThread( - NULL, - 0, - &CNetViewThread::StaticThreadFn, - this, - 0, - &dwThreadID ); -} - - -void CNetViewThread::Term() -{ - if ( m_hThread ) - { - SetEvent( m_hThreadExitEvent ); - WaitForSingleObject( m_hThread, INFINITE ); - CloseHandle( m_hThread ); - m_hThread = NULL; - } - - if ( m_hThreadExitEvent ) - { - CloseHandle( m_hThreadExitEvent ); - m_hThreadExitEvent = NULL; - } - - m_ComputerNames.PurgeAndDeleteElements(); -} - - -void CNetViewThread::GetComputerNames( CUtlVector &computerNames, bool bRemoveFromList ) -{ - EnterCriticalSection( &m_ComputerNamesCS ); - - computerNames.Purge(); - for ( int i=0; i < m_ComputerNames.Count(); i++ ) - { - computerNames.AddToTail( CopyAlloc( m_ComputerNames[i] ) ); - } - - if ( bRemoveFromList ) - { - m_ComputerNames.PurgeAndDeleteElements(); - } - - LeaveCriticalSection( &m_ComputerNamesCS ); -} - - -void CNetViewThread::UpdateServicesFromNetView() -{ - HANDLE hChildStdoutRd, hChildStdoutWr; - - // Set the bInheritHandle flag so pipe handles are inherited. - SECURITY_ATTRIBUTES saAttr; - saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); - saAttr.bInheritHandle = TRUE; - saAttr.lpSecurityDescriptor = NULL; - - if( CreatePipe( &hChildStdoutRd, &hChildStdoutWr, &saAttr, 0 ) ) - { - STARTUPINFO si; - memset(&si, 0, sizeof si); - si.cb = sizeof(si); - si.dwFlags = STARTF_USESTDHANDLES; - si.hStdOutput = hChildStdoutWr; - - PROCESS_INFORMATION pi; - - if( CreateProcess( - NULL, - "net view", - NULL, // lpProcessAttributes - NULL, // lpThreadAttributes - TRUE, // bInheritHandls - DETACHED_PROCESS, // dwCreationFlags - NULL, // lpEnvironment - NULL, // lpCurrentDirectory - &si, // lpStartupInfo - &pi // lpProcessInformation - ) ) - { - // read from pipe.. - #define BUFFER_SIZE 8192 - char buffer[BUFFER_SIZE]; - BOOL bDone = FALSE; - CUtlVector totalBuffer; - - while(1) - { - DWORD dwCount = 0; - DWORD dwRead = 0; - - // read from input handle - PeekNamedPipe(hChildStdoutRd, NULL, NULL, NULL, &dwCount, NULL); - if (dwCount) - { - dwCount = min (dwCount, (DWORD)BUFFER_SIZE - 1); - ReadFile(hChildStdoutRd, buffer, dwCount, &dwRead, NULL); - } - if(dwRead) - { - buffer[dwRead] = 0; - totalBuffer.AddMultipleToTail( dwRead, buffer ); - } - // check process termination - else if( WaitForSingleObject( pi.hProcess, 1000 ) != WAIT_TIMEOUT ) - { - if ( bDone ) - break; - - bDone = TRUE; // next time we get it - } - } - - // Now parse the output. - totalBuffer.AddToTail( 0 ); - ParseComputerNames( totalBuffer.Base() ); - } - - CloseHandle( hChildStdoutRd ); - CloseHandle( hChildStdoutWr ); - } -} - - -void CNetViewThread::ParseComputerNames( const char *pNetViewOutput ) -{ - EnterCriticalSection( &m_ComputerNamesCS ); - - m_ComputerNames.PurgeAndDeleteElements(); - - const char *pCur = pNetViewOutput; - while ( *pCur != 0 ) - { - // If we get a \\, then it's a computer name followed by whitespace. - if ( pCur[0] == '\\' && pCur[1] == '\\' ) - { - char curComputerName[512]; - char *pOutPos = curComputerName; - - pCur += 2; - while ( *pCur && !V_isspace( *pCur ) && (pOutPos-curComputerName < 510) ) - { - *pOutPos++ = *pCur++; - } - *pOutPos = 0; - - m_ComputerNames.AddToTail( CopyAlloc( curComputerName ) ); - } - ++pCur; - } - - LeaveCriticalSection( &m_ComputerNamesCS ); -} - - -DWORD CNetViewThread::ThreadFn() -{ - // Update the services list every 30 seconds. - do - { - UpdateServicesFromNetView(); - } while ( WaitForSingleObject( m_hThreadExitEvent, 30000 ) != WAIT_OBJECT_0 ); - - return 0; -} - - -DWORD CNetViewThread::StaticThreadFn( LPVOID lpParameter ) -{ - return ((CNetViewThread*)lpParameter)->ThreadFn(); -} - - diff --git a/src/utils/vmpi/net_view_thread.h b/src/utils/vmpi/net_view_thread.h deleted file mode 100644 index 7ecd28972e..0000000000 --- a/src/utils/vmpi/net_view_thread.h +++ /dev/null @@ -1,47 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#ifndef NET_VIEW_THREAD_H -#define NET_VIEW_THREAD_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "utlvector.h" - - -class CNetViewThread -{ -public: - CNetViewThread(); - ~CNetViewThread(); - - // This creates the thread that periodically checks "net view" to get the current list of - // machines out on the network. - void Init(); - void Term(); - - // If bRemoveFromList is true, then it'll remove the names that it's returning from its internal - // list and it won't return those names again. - void GetComputerNames( CUtlVector &computerNames, bool bRemoveFromList ); - -private: - - void UpdateServicesFromNetView(); - void ParseComputerNames( const char *pNetViewOutput ); - - DWORD ThreadFn(); - static DWORD WINAPI StaticThreadFn( LPVOID lpParameter ); - - CUtlVector m_ComputerNames; - HANDLE m_hThread; - HANDLE m_hThreadExitEvent; - CRITICAL_SECTION m_ComputerNamesCS; -}; - - -#endif // NET_VIEW_THREAD_H diff --git a/src/utils/vmpi/serviceinfo.h b/src/utils/vmpi/serviceinfo.h deleted file mode 100644 index 62a206c7d7..0000000000 --- a/src/utils/vmpi/serviceinfo.h +++ /dev/null @@ -1,50 +0,0 @@ -//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#pragma once - -class CServiceInfo -{ -public: - - bool IsOff() const; // Returns true if the time since we've heard from this guy is too long. - CServiceInfo() : m_bFromRegistry( false ) {} - -public: - - CString m_ComputerName; - CString m_MasterName; - CString m_Password; - int m_iState; - - // Since the live time is always changing, we only update it every 10 seconds or so. - DWORD m_LiveTimeMS; // How long the service has been running (in milliseconds). - - DWORD m_WorkerAppTimeMS; // How long the worker app has been running (0 if it's not running). - - DWORD m_LastPingTimeMS; // Last time we heard from this machine. Used to detect if the service - // is off or not. - - // Used to detect if we need to re-sort the list. - const char *m_pLastStatusText; - DWORD m_LastLiveTimeMS; - CString m_LastMasterName; - - int m_CPUPercentage; - CString m_ExeName; - CString m_MapName; - int m_MemUsageMB; - - // Last time we updated the service in the listbox.. used to make sure we update its on/off status - // every once in a while. - DWORD m_LastUpdateTime; - - int m_ProtocolVersion; // i.e. the service's VMPI_SERVICE_PROTOCOL_VERSION. - char m_ServiceVersion[ 32 ]; // Version string. - - CIPAddr m_Addr; - bool m_bFromRegistry; -}; diff --git a/src/utils/vmpi/tcpsocket.cpp b/src/utils/vmpi/tcpsocket.cpp deleted file mode 100644 index 8ab67cf6b8..0000000000 --- a/src/utils/vmpi/tcpsocket.cpp +++ /dev/null @@ -1,1178 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - - -//#define PARANOID - -#if defined( PARANOID ) - #include - #include -#endif - -#include -#include -#include "tcpsocket.h" -#include "tier1/utllinkedlist.h" -#include -#include "threadhelpers.h" -#include "tier0/dbg.h" - - - -#error "I am TCPSocket and I suck. Use IThreadedTCPSocket or ThreadedTCPSocketEmu instead." - - -extern TIMEVAL SetupTimeVal( double flTimeout ); -extern void IPAddrToSockAddr( const CIPAddr *pIn, sockaddr_in *pOut ); -extern void SockAddrToIPAddr( const sockaddr_in *pIn, CIPAddr *pOut ); - - -#define SENTINEL_DISCONNECT -1 -#define SENTINEL_KEEPALIVE -2 - - -#define KEEPALIVE_INTERVAL_MS 3000 // keepalives are sent every N MS -#define KEEPALIVE_TIMEOUT_SECONDS 15.0 // connections timeout after this long - - -static bool g_bEnableTCPTimeout = true; - - -class CRecvData -{ -public: - int m_Count; - unsigned char m_Data[1]; -}; - - - -SOCKET TCPBind( const CIPAddr *pAddr ) -{ - // Create a socket to send and receive through. - SOCKET sock = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED ); - if ( sock == INVALID_SOCKET ) - { - Assert( false ); - return INVALID_SOCKET; - } - - // bind to it! - sockaddr_in addr; - IPAddrToSockAddr( pAddr, &addr ); - - int status = bind( sock, (sockaddr*)&addr, sizeof(addr) ); - if ( status == 0 ) - { - return sock; - } - else - { - closesocket( sock ); - return INVALID_SOCKET; - } -} - - - -// ---------------------------------------------------------------------------------------- // -// TCP sockets. -// ---------------------------------------------------------------------------------------- // - -enum -{ - OP_RECV=111, - OP_SEND -}; - -// We use this for all OVERLAPPED structures. -class COverlappedPlus : public WSAOVERLAPPED -{ -public: - COverlappedPlus() - { - memset( this, 0, sizeof( WSAOVERLAPPED ) ); - } - - int m_OPType; // One of the OP_ defines. -}; - -typedef struct SendBuf_t -{ - COverlappedPlus m_Overlapped; - int m_Index; // Index into m_SendBufs. - int m_DataLength; - char m_Data[1]; -} SendBuf_s; - - -// These manage a thread that calls SendKeepalive() on all TCPSockets. -// AddGlobalTCPSocket shouldn't be called until you're ready for SendKeepalive() to be called. -class CTCPSocket; -void AddGlobalTCPSocket( CTCPSocket *pSocket ); -void RemoveGlobalTCPSocket( CTCPSocket *pSocket ); - - - -// ------------------------------------------------------------------------------------------ // -// CTCPSocket implementation. -// ------------------------------------------------------------------------------------------ // - -class CTCPSocket : public ITCPSocket -{ -friend class CTCPListenSocket; - -public: - - CTCPSocket() - { - m_Socket = INVALID_SOCKET; - m_bConnected = false; - - m_hIOCP = NULL; - - m_bShouldExitThreads = false; - m_bConnectionLost = false; - m_nSizeBytesReceived = 0; - - m_pIncomingData = NULL; - - memset( &m_RecvOverlapped, 0, sizeof( m_RecvOverlapped ) ); - m_RecvOverlapped.m_OPType = OP_RECV; - - m_hRecvSignal = CreateEvent( NULL, FALSE, FALSE, NULL ); - m_RecvStage = -1; - - m_MainThreadID = GetCurrentThreadId(); - } - - virtual ~CTCPSocket() - { - Term(); - CloseHandle( m_hRecvSignal ); - } - - void Term() - { - Assert( GetCurrentThreadId() == m_MainThreadID ); - - RemoveGlobalTCPSocket( this ); - - if ( m_Socket != SOCKET_ERROR && !m_bConnectionLost ) - { - SendDisconnectSentinel(); - - // Give the sends a second to complete. SO_LINGER is having trouble for some reason. - WaitForSendsToComplete( 1 ); - } - - - StopThreads(); - - if ( m_Socket != INVALID_SOCKET ) - { - closesocket( m_Socket ); - m_Socket = INVALID_SOCKET; - } - - if ( m_hIOCP ) - { - CloseHandle( m_hIOCP ); - m_hIOCP = NULL; - } - - m_bConnected = false; - m_bConnectionLost = true; - m_RecvStage = -1; - - FOR_EACH_LL( m_SendBufs, i ) - { - SendBuf_t *pSendBuf = m_SendBufs[i]; - ParanoidMemoryCheck( pSendBuf ); - free( pSendBuf ); - } - m_SendBufs.Purge(); - - FOR_EACH_LL( m_RecvDatas, j ) - { - CRecvData *pRecvData = m_RecvDatas[j]; - ParanoidMemoryCheck( pRecvData ); - free( pRecvData ); - } - m_RecvDatas.Purge(); - - if ( m_pIncomingData ) - { - ParanoidMemoryCheck( m_pIncomingData ); - free( m_pIncomingData ); - m_pIncomingData = 0; - } - } - - virtual void Release() - { - delete this; - } - - - void ParanoidMemoryCheck( void *ptr = NULL ) - { -#if defined( PARANOID ) - Assert( _CrtIsValidHeapPointer( this ) ); - - if ( ptr ) - { - Assert( _CrtIsValidHeapPointer( ptr ) ); - } - - Assert( _CrtCheckMemory() == TRUE ); -#endif - } - - - virtual bool BindToAny( const unsigned short port ) - { - Term(); - - CIPAddr addr( 0, 0, 0, 0, port ); // INADDR_ANY - m_Socket = TCPBind( &addr ); - if ( m_Socket == INVALID_SOCKET ) - { - return false; - } - else - { - SetInitialSocketOptions(); - return true; - } - } - - - // Set the initial socket options that we want. - void SetInitialSocketOptions() - { - // Set nodelay to improve latency. - BOOL val = TRUE; - setsockopt( m_Socket, IPPROTO_TCP, TCP_NODELAY, (const char FAR *)&val, sizeof(BOOL) ); - - // Make it linger for 3 seconds when it exits. - LINGER linger; - linger.l_onoff = 1; - linger.l_linger = 3; - setsockopt( m_Socket, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof( linger ) ); - } - - - // Called only by main thread interface functions. - // Returns true if the connection is lost. - bool CheckConnectionLost() - { - Assert( GetCurrentThreadId() == m_MainThreadID ); - - if ( m_Socket == SOCKET_ERROR ) - return true; - - // Have we timed out? - if ( g_bEnableTCPTimeout && (Plat_FloatTime() - m_LastRecvTime > KEEPALIVE_TIMEOUT_SECONDS) ) - { - SetConnectionLost( "Connection timed out." ); - } - - // Has any thread posted that the connection has been lost? - CCriticalSectionLock postLock( &m_ConnectionLostCS ); - postLock.Lock(); - if ( m_bConnectionLost ) - { - Term(); - return true; - } - else - { - return false; - } - } - - // Called by any thread. All interface functions call CheckConnectionLost() and return errors if it's lost. - void SetConnectionLost( const char *pErrorString, int err = -1 ) - { - CCriticalSectionLock postLock( &m_ConnectionLostCS ); - postLock.Lock(); - m_bConnectionLost = true; - postLock.Unlock(); - - // Handle it right away if we're in the main thread. If we're in an IO thread, - // it has to wait until the next interface function calls CheckConnectionLost(). - if ( GetCurrentThreadId() == m_MainThreadID ) - { - Term(); - } - - if ( pErrorString ) - { - m_ErrorString.CopyArray( pErrorString, strlen( pErrorString ) + 1 ); - } - else - { - char *lpMsgBuf; - FormatMessage( - FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL - ); - - m_ErrorString.CopyArray( lpMsgBuf, strlen( lpMsgBuf ) + 1 ); - LocalFree( lpMsgBuf ); - } - } - - - // -------------------------------------------------------------------------------------------------- // - // The receive code. - // -------------------------------------------------------------------------------------------------- // - - virtual bool StartWaitingForSize( bool bFresh ) - { - Assert( m_Socket != INVALID_SOCKET ); - Assert( m_bConnected ); - - m_RecvStage = 0; - m_RecvDataSize = -1; - if ( bFresh ) - m_nSizeBytesReceived = 0; - - DWORD dwNumBytesReceived = 0; - WSABUF buf = { sizeof( &m_RecvDataSize ) - m_nSizeBytesReceived, ((char*)&m_RecvDataSize) + m_nSizeBytesReceived }; - DWORD dwFlags = 0; - - int status = WSARecv( - m_Socket, - &buf, - 1, - &dwNumBytesReceived, - &dwFlags, - &m_RecvOverlapped, - NULL ); - - int err = -1; - if ( status == SOCKET_ERROR && (err = WSAGetLastError()) != ERROR_IO_PENDING ) - { - SetConnectionLost( NULL, err ); - return false; - } - else - { - return true; - } - } - - - bool PostNextDataPart() - { - DWORD dwNumBytesReceived = 0; - WSABUF buf = { m_RecvDataSize - m_AmountReceived, (char*)m_pIncomingData->m_Data + m_AmountReceived }; - DWORD dwFlags = 0; - - int status = WSARecv( - m_Socket, - &buf, - 1, - &dwNumBytesReceived, - &dwFlags, - &m_RecvOverlapped, - NULL ); - - int err = -1; - if ( status == SOCKET_ERROR && (err = WSAGetLastError()) != ERROR_IO_PENDING ) - { - SetConnectionLost( NULL, err ); - return false; - } - else - { - return true; - } - } - - - bool StartWaitingForData() - { - Assert( m_Socket != INVALID_SOCKET ); - Assert( m_RecvStage == 0 ); - Assert( m_bConnected ); - Assert( m_RecvDataSize > 0 ); - - m_RecvStage = 1; - - // Add a CRecvData element. - ParanoidMemoryCheck(); - m_pIncomingData = (CRecvData*)malloc( sizeof( CRecvData ) - 1 + m_RecvDataSize ); - if ( !m_pIncomingData ) - { - char str[512]; - _snprintf( str, sizeof( str ), "malloc() failed. m_RecvDataSize = %d\n", m_RecvDataSize ); - SetConnectionLost( str ); - return false; - } - - m_pIncomingData->m_Count = m_RecvDataSize; - - m_AmountReceived = 0; - - return PostNextDataPart(); - } - - virtual bool Recv( CUtlVector &data, double flTimeout ) - { - if ( CheckConnectionLost() ) - return false; - - // Wait in 50ms chunks, checking for disconnections along the way. - bool bGotData = false; - DWORD msToWait = (DWORD)( flTimeout * 1000.0 ); - do - { - DWORD curWaitTime = min( msToWait, 50 ); - DWORD ret = WaitForSingleObject( m_hRecvSignal, curWaitTime ); - if ( ret == WAIT_OBJECT_0 ) - { - bGotData = true; - break; - } - - // Did the connection timeout? - if ( CheckConnectionLost() ) - return false; - - msToWait -= curWaitTime; - } while ( msToWait ); - - // If we never got a WAIT_OBJECT_0, then we never received anything. - if ( !bGotData ) - return false; - - - CCriticalSectionLock csLock( &m_RecvDataCS ); - csLock.Lock(); - - // Pickup the head m_RecvDatas element. - CRecvData *pRecvData = m_RecvDatas[ m_RecvDatas.Head() ]; - data.CopyArray( pRecvData->m_Data, pRecvData->m_Count ); - - // Now free it. - m_RecvDatas.Remove( m_RecvDatas.Head() ); - ParanoidMemoryCheck( pRecvData ); - free( pRecvData ); - - // Set the event again for the next time around, if there is more data waiting. - if ( m_RecvDatas.Count() > 0 ) - SetEvent( m_hRecvSignal ); - - return true; - } - - // INSIDE IO THREAD. - void HandleRecvCompletion( COverlappedPlus *pInfo, DWORD dwNumBytes ) - { - if ( dwNumBytes == 0 ) - { - SetConnectionLost( "Got 0 bytes in HandleRecvCompletion" ); - return; - } - - m_LastRecvTime = Plat_FloatTime(); - if ( m_RecvStage == 0 ) - { - m_nSizeBytesReceived += dwNumBytes; - if ( m_nSizeBytesReceived == sizeof( m_RecvDataSize ) ) - { - // Size of -1 means the other size is breaking the connection. - if ( m_RecvDataSize == SENTINEL_DISCONNECT ) - { - SetConnectionLost( "Got a graceful disconnect message." ); - return; - } - else if ( m_RecvDataSize == SENTINEL_KEEPALIVE ) - { - // No data follows this. Just let m_LastRecvTime get updated. - StartWaitingForSize( true ); - return; - } - - StartWaitingForData(); - } - else if ( m_nSizeBytesReceived < sizeof( m_RecvDataSize ) ) - { - // Handle the case where we only got some of the data (maybe one of the clients got disconnected). - StartWaitingForSize( false ); - } - else - { - // This case should never ever happen! -#if defined( _DEBUG ) - __asm int 3; -#endif - - SetConnectionLost( "Received too much data in a packet!" ); - return; - } - } - else if ( m_RecvStage == 1 ) - { - // Got the data, make sure we got it all. - m_AmountReceived += dwNumBytes; - - // Sanity check. -#if defined( _DEBUG ) - Assert( m_RecvDataSize == m_pIncomingData->m_Count ); - Assert( m_AmountReceived <= m_RecvDataSize ); // TODO: make this threadsafe for multiple IO threads. -#endif - - if ( m_AmountReceived == m_RecvDataSize ) - { - m_RecvStage = 2; - - // Add the data to the list of packets waiting to be picked up. - CCriticalSectionLock csLock( &m_RecvDataCS ); - csLock.Lock(); - - m_RecvDatas.AddToTail( m_pIncomingData ); - m_pIncomingData = NULL; - - if ( m_RecvDatas.Count() == 1 ) - SetEvent( m_hRecvSignal ); // Notify the Recv() function. - - StartWaitingForSize( true ); - } - else - { - PostNextDataPart(); - } - } - else - { - Assert( false ); - } - } - - - // -------------------------------------------------------------------------------------------------- // - // The send code. - // -------------------------------------------------------------------------------------------------- // - - virtual void WaitForSendsToComplete( double flTimeout ) - { - CWaitTimer waitTimer( flTimeout ); - while ( 1 ) - { - CCriticalSectionLock sendBufLock( &m_SendCS ); - sendBufLock.Lock(); - if( m_SendBufs.Count() == 0 ) - return; - sendBufLock.Unlock(); - - if ( waitTimer.ShouldKeepWaiting() ) - Sleep( 10 ); - else - break; - } - } - - - // This is called in the keepalive thread. - void SendKeepalive() - { - // Send a message saying we're exiting. - ParanoidMemoryCheck(); - SendBuf_t *pBuf = (SendBuf_t*)malloc( sizeof( SendBuf_t ) - 1 + sizeof( int ) ); - if ( !pBuf ) - { - SetConnectionLost( "malloc() in SendKeepalive() failed." ); - return; - } - - pBuf->m_DataLength = sizeof( int ); - *((int*)pBuf->m_Data) = SENTINEL_KEEPALIVE; - InternalSendDataBuf( pBuf ); - } - - - void SendDisconnectSentinel() - { - // Send a message saying we're exiting. - ParanoidMemoryCheck(); - SendBuf_t *pBuf = (SendBuf_t*)malloc( sizeof( SendBuf_t ) - 1 + sizeof( int ) ); - if ( pBuf ) - { - pBuf->m_DataLength = sizeof( int ); - *((int*)pBuf->m_Data) = SENTINEL_DISCONNECT; // This signifies that we're exiting. - InternalSendDataBuf( pBuf ); - } - } - - - virtual bool Send( const void *pData, int len ) - { - const void *pChunks[1] = { pData }; - int chunkLengths[1] = { len }; - return SendChunks( pChunks, chunkLengths, 1 ); - } - - - virtual bool SendChunks( void const * const *pChunks, const int *pChunkLengths, int nChunks ) - { - if ( CheckConnectionLost() ) - return false; - - CChunkWalker walker( pChunks, pChunkLengths, nChunks ); - int totalLength = walker.GetTotalLength(); - - if ( !totalLength ) - return true; - - // Create a buffer to hold the data and copy the data in. - ParanoidMemoryCheck(); - SendBuf_t *pBuf = (SendBuf_t*)malloc( sizeof( SendBuf_t ) - 1 + totalLength + sizeof( int ) ); - if ( !pBuf ) - { - char str[512]; - _snprintf( str, sizeof( str ), "malloc() in SendChunks() failed. totalLength = %d.", totalLength ); - SetConnectionLost( str ); - return false; - } - - pBuf->m_DataLength = totalLength + sizeof( int ); - - int *pByteCountPos = (int*)pBuf->m_Data; - *pByteCountPos = totalLength; - - char *pDataPos = &pBuf->m_Data[ sizeof( int ) ]; - walker.CopyTo( pDataPos, totalLength ); - - int status = InternalSendDataBuf( pBuf ); - int err = -1; - if ( status == SOCKET_ERROR && (err = WSAGetLastError()) != ERROR_IO_PENDING ) - { - SetConnectionLost( NULL, err ); - return false; - } - else - { - return true; - } - } - - - int InternalSendDataBuf( SendBuf_t *pBuf ) - { - // Protect against interference from the keepalive thread. - CCriticalSectionLock csLock( &m_SendCS ); - csLock.Lock(); - - - pBuf->m_Overlapped.m_OPType = OP_SEND; - pBuf->m_Overlapped.hEvent = NULL; - - // Add it to our list of buffers. - pBuf->m_Index = m_SendBufs.AddToTail( pBuf ); - - // Tell Winsock to send it. - WSABUF buf = { pBuf->m_DataLength, pBuf->m_Data }; - - DWORD dwNumBytesSent = 0; - return WSASend( - m_Socket, - &buf, - 1, - &dwNumBytesSent, - 0, - &pBuf->m_Overlapped, - NULL ); - } - - - // INSIDE IO THREAD. - void HandleSendCompletion( COverlappedPlus *pInfo, DWORD dwNumBytes ) - { - if ( dwNumBytes == 0 ) - { - SetConnectionLost( "0 bytes in HandleSendCompletion." ); - return; - } - - // Just free the buffer. - SendBuf_t *pBuf = (SendBuf_t*)pInfo; - Assert( dwNumBytes == (DWORD)pBuf->m_DataLength ); - - CCriticalSectionLock sendBufLock( &m_SendCS ); - sendBufLock.Lock(); - m_SendBufs.Remove( pBuf->m_Index ); - sendBufLock.Unlock(); - - ParanoidMemoryCheck( pBuf ); - free( pBuf ); - } - - - // -------------------------------------------------------------------------------------------------- // - // The connect code. - // -------------------------------------------------------------------------------------------------- // - - virtual bool BeginConnect( const CIPAddr &inputAddr ) - { - sockaddr_in addr; - IPAddrToSockAddr( &inputAddr, &addr ); - - m_bConnected = false; - int ret = connect( m_Socket, (struct sockaddr*)&addr, sizeof( addr ) ); - ret=ret; - - return true; - } - - - virtual bool UpdateConnect() - { - // We're still ok.. just wait until the socket becomes writable (is connected) or we timeout. - fd_set writeSet; - writeSet.fd_count = 1; - writeSet.fd_array[0] = m_Socket; - TIMEVAL timeVal = SetupTimeVal( 0 ); - - // See if it has a packet waiting. - int status = select( 0, NULL, &writeSet, NULL, &timeVal ); - if ( status > 0 ) - { - SetupConnected(); - return true; - } - - return false; - } - - - void SetupConnected() - { - m_bConnected = true; - m_bConnectionLost = false; - m_LastRecvTime = Plat_FloatTime(); - - CreateThreads(); - StartWaitingForSize( true ); - AddGlobalTCPSocket( this ); - } - - - virtual bool IsConnected() - { - CheckConnectionLost(); - return m_bConnected; - } - - - virtual void GetDisconnectReason( CUtlVector &reason ) - { - reason = m_ErrorString; - } - - - // -------------------------------------------------------------------------------------------------- // - // Threads code. - // -------------------------------------------------------------------------------------------------- // - - // Create our IO Completion Port threads. - bool CreateThreads() - { - int nThreads = 1; - SetShouldExitThreads( false ); - - // Create our IO completion port and hook it to our socket. - m_hIOCP = CreateIoCompletionPort( - INVALID_HANDLE_VALUE, NULL, 0, 0); - - m_hIOCP = CreateIoCompletionPort( (HANDLE)m_Socket, m_hIOCP, (unsigned long)this, nThreads ); - - for ( int i=0; i < nThreads; i++ ) - { - DWORD dwThreadID = 0; - HANDLE hThread = CreateThread( - NULL, - 0, - &CTCPSocket::StaticThreadFn, - this, - 0, - &dwThreadID ); - - if ( hThread ) - { - SetThreadPriority( hThread, THREAD_PRIORITY_ABOVE_NORMAL ); - m_Threads.AddToTail( hThread ); - } - else - { - StopThreads(); - return false; - } - } - - return true; - } - - - void StopThreads() - { - // Tell the threads to exit, then wait for them to do so. - SetShouldExitThreads( true ); - WaitForMultipleObjects( m_Threads.Count(), m_Threads.Base(), TRUE, INFINITE ); - - for ( int i=0; i < m_Threads.Count(); i++ ) - { - CloseHandle( m_Threads[i] ); - } - m_Threads.Purge(); - } - - - void SetShouldExitThreads( bool bShouldExit ) - { - CCriticalSectionLock lock( &m_ThreadsCS ); - lock.Lock(); - m_bShouldExitThreads = bShouldExit; - } - - - bool ShouldExitThreads() - { - CCriticalSectionLock lock( &m_ThreadsCS ); - lock.Lock(); - - bool bRet = m_bShouldExitThreads; - return bRet; - } - - - DWORD ThreadFn() - { - while ( 1 ) - { - DWORD dwNumBytes = 0; - unsigned long pInputTCPSocket; - LPOVERLAPPED pOverlapped; - - if ( GetQueuedCompletionStatus( - m_hIOCP, // the port we're listening on - &dwNumBytes, // # bytes received on the port - &pInputTCPSocket,// "completion key" = CTCPSocket* - &pOverlapped, // the overlapped info that was passed into AcceptEx, WSARecv, or WSASend. - 100 // listen for 100ms at a time so we can exit gracefully when the socket is deleted. - ) ) - { - COverlappedPlus *pInfo = (COverlappedPlus*)pOverlapped; - ParanoidMemoryCheck( pInfo ); - - if ( pInfo->m_OPType == OP_RECV ) - { - Assert( pInfo == &m_RecvOverlapped ); - HandleRecvCompletion( pInfo, dwNumBytes ); - } - else - { - Assert( pInfo->m_OPType == OP_SEND ); - HandleSendCompletion( pInfo, dwNumBytes ); - } - } - - if ( ShouldExitThreads() ) - break; - } - - return 0; - } - - - static DWORD WINAPI StaticThreadFn( LPVOID pParameter ) - { - return ((CTCPSocket*)pParameter)->ThreadFn(); - } - - - -private: - - SOCKET m_Socket; - bool m_bConnected; - - - // m_RecvOverlapped is setup to first wait for the size, then the data. - // Then it is not posted until the app grabs the data. - HANDLE m_hRecvSignal; // Tells Recv() when we have data. - COverlappedPlus m_RecvOverlapped; - int m_RecvStage; // -1 = not initialized - // 0 = waiting for size - // 1 = waiting for data - // 2 = waiting for app to pickup the data - - CUtlLinkedList m_RecvDatas; // The head element is the next one to be picked up. - CRecvData *m_pIncomingData; // The packet we're currently receiving. - CCriticalSection m_RecvDataCS; // This protects adds and removes in the list. - - // These reference the element at the tail of m_RecvData. It is the current one getting - volatile int m_nSizeBytesReceived; // How much of m_RecvDataSize have we received yet? - int m_RecvDataSize; // this is received over the network - int m_AmountReceived; // How much we've received so far. - - // Last time we received anything from this connection. Used to determine if the connection is - // still active. - double m_LastRecvTime; - - - // Outgoing send buffers. - CUtlLinkedList m_SendBufs; - CCriticalSection m_SendCS; - - - // All the threads waiting for IO. - CUtlVector m_Threads; - HANDLE m_hIOCP; - - // Used during shutdown. - volatile bool m_bShouldExitThreads; - CCriticalSection m_ThreadsCS; - - // For debugging. - DWORD m_MainThreadID; - - // Set by the main thread or IO threads to signal connection lost. - bool m_bConnectionLost; - CCriticalSection m_ConnectionLostCS; - - // This is set when we get disconnected. - CUtlVector m_ErrorString; -}; - - -// ------------------------------------------------------------------------------------------ // -// ITCPListenSocket implementation. -// ------------------------------------------------------------------------------------------ // - -class CTCPListenSocket : public ITCPListenSocket -{ -public: - - CTCPListenSocket() - { - m_Socket = INVALID_SOCKET; - } - - - virtual ~CTCPListenSocket() - { - if ( m_Socket != INVALID_SOCKET ) - { - closesocket( m_Socket ); - } - } - - - // The main function to create one of these suckers. - static ITCPListenSocket* Create( const unsigned short port, int nQueueLength ) - { - CTCPListenSocket *pRet = new CTCPListenSocket; - if ( !pRet ) - return NULL; - - // Bind it to a socket and start listening. - CIPAddr addr( 0, 0, 0, 0, port ); // INADDR_ANY - pRet->m_Socket = TCPBind( &addr ); - if ( pRet->m_Socket == INVALID_SOCKET || - listen( pRet->m_Socket, nQueueLength == -1 ? SOMAXCONN : nQueueLength ) != 0 ) - { - pRet->Release(); - return false; - } - - return pRet; - } - - - virtual void Release() - { - delete this; - } - - - virtual ITCPSocket* UpdateListen( CIPAddr *pAddr ) - { - // We're still ok.. just wait until the socket becomes writable (is connected) or we timeout. - fd_set readSet; - readSet.fd_count = 1; - readSet.fd_array[0] = m_Socket; - TIMEVAL timeVal = SetupTimeVal( 0 ); - - // Wait until it connects. - int status = select( 0, &readSet, NULL, NULL, &timeVal ); - if ( status > 0 ) - { - sockaddr_in addr; - int addrSize = sizeof( addr ); - - // Now accept the final connection. - SOCKET newSock = accept( m_Socket, (struct sockaddr*)&addr, &addrSize ); - if ( newSock == INVALID_SOCKET ) - { - Assert( false ); - } - else - { - CTCPSocket *pRet = new CTCPSocket; - if ( !pRet ) - { - closesocket( newSock ); - return NULL; - } - - pRet->m_Socket = newSock; - pRet->SetInitialSocketOptions(); - pRet->SetupConnected(); - - // Report the address.. - SockAddrToIPAddr( &addr, pAddr ); - - return pRet; - } - } - - return NULL; - } - - -private: - SOCKET m_Socket; -}; - - - -ITCPListenSocket* CreateTCPListenSocket( const unsigned short port, int nQueueLength ) -{ - return CTCPListenSocket::Create( port, nQueueLength ); -} - - -ITCPSocket* CreateTCPSocket() -{ - return new CTCPSocket; -} - - -void TCPSocket_EnableTimeout( bool bEnable ) -{ - g_bEnableTCPTimeout = bEnable; -} - - -// --------------------------------------------------------------------------------- // -// This thread sends keepalives on all active TCP sockets. -// --------------------------------------------------------------------------------- // - -HANDLE g_hKeepaliveThread; -HANDLE g_hKeepaliveThreadSignal; -HANDLE g_hKeepaliveThreadReply; -CUtlLinkedList g_TCPSockets; -CCriticalSection g_TCPSocketsCS; - - -DWORD WINAPI TCPKeepaliveThread( LPVOID pParameter ) -{ - while ( 1 ) - { - if ( WaitForSingleObject( g_hKeepaliveThreadSignal, KEEPALIVE_INTERVAL_MS ) == WAIT_OBJECT_0 ) - break; - - // Tell all TCP sockets to send a keepalive. - CCriticalSectionLock csLock( &g_TCPSocketsCS ); - csLock.Lock(); - - FOR_EACH_LL( g_TCPSockets, i ) - { - g_TCPSockets[i]->SendKeepalive(); - } - } - - SetEvent( g_hKeepaliveThreadReply ); - return 0; -} - - -void AddGlobalTCPSocket( CTCPSocket *pSocket ) -{ - CCriticalSectionLock csLock( &g_TCPSocketsCS ); - csLock.Lock(); - - Assert( g_TCPSockets.Find( pSocket ) == g_TCPSockets.InvalidIndex() ); - g_TCPSockets.AddToTail( pSocket ); - - // If this is the first one, create the keepalive thread. - if ( g_TCPSockets.Count() == 1 ) - { - g_hKeepaliveThreadSignal = CreateEvent( NULL, false, false, NULL ); - g_hKeepaliveThreadReply = CreateEvent( NULL, false, false, NULL ); - - DWORD dwThreadID = 0; - g_hKeepaliveThread = CreateThread( - NULL, - 0, - TCPKeepaliveThread, - NULL, - 0, - &dwThreadID - ); - } -} - - -void RemoveGlobalTCPSocket( CTCPSocket *pSocket ) -{ - bool bThreadRunning = false; - DWORD dwExitCode = 0; - if ( GetExitCodeThread( g_hKeepaliveThread, &dwExitCode ) && dwExitCode == STILL_ACTIVE ) - { - bThreadRunning = true; - } - - CCriticalSectionLock csLock( &g_TCPSocketsCS ); - csLock.Lock(); - - int index = g_TCPSockets.Find( pSocket ); - if ( index != g_TCPSockets.InvalidIndex() ) - { - g_TCPSockets.Remove( index ); - - // If this was the last one, delete the thread. - if ( g_TCPSockets.Count() == 0 ) - { - csLock.Unlock(); - - if ( bThreadRunning ) - { - SetEvent( g_hKeepaliveThreadSignal ); - WaitForSingleObject( g_hKeepaliveThreadReply, INFINITE ); - } - - CloseHandle( g_hKeepaliveThreadSignal ); - CloseHandle( g_hKeepaliveThreadReply ); - CloseHandle( g_hKeepaliveThread ); - return; - } - } - - csLock.Unlock(); -} diff --git a/src/utils/vmpi/tcpsocket.h b/src/utils/vmpi/tcpsocket.h deleted file mode 100644 index 7cb2998679..0000000000 --- a/src/utils/vmpi/tcpsocket.h +++ /dev/null @@ -1,84 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef ITCPSOCKET_H -#define ITCPSOCKET_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "ichannel.h" -#include "iphelpers.h" - - -class ITCPSocket : public IChannel -{ -public: - virtual void Release() = 0; - - // Bind to the specified port on any address this host has. Note that the address the - // socket winds up with (and getsockname() returns) isn't decided until you send a packet. - virtual bool BindToAny( const unsigned short port ) = 0; - - - // Use these to connect to a remote listening socket without blocking. - // Call BeginConnect, then call UpdateConnect until it returns true. - virtual bool BeginConnect( const CIPAddr &addr ) = 0; - virtual bool UpdateConnect() = 0; - - - // Connection state. - virtual bool IsConnected() = 0; - - // If IsConnected returns false, you can call this to find out why the socket got disconnected. - virtual void GetDisconnectReason( CUtlVector &reason ) = 0; - - - // Send data. Returns true if successful. - // - // Note: TCP likes to clump your packets together in one, so the data multiple send() calls will - // get concatenated and returned in one recv() call. ITCPSocket FIXES this behavior so your recv() - // calls match your send() calls. - // - virtual bool Send( const void *pData, int size ) = 0; - - // Receive data. Returns the number of bytes received. - // This will wait as long as flTimeout for something to come in. - // Returns false if no data was waiting. - virtual bool Recv( CUtlVector &data, double flTimeout=0 ) = 0; -}; - - -// Use these to get incoming connections. -class ITCPListenSocket -{ -public: - // Call this to stop listening for connections and delete the object. - virtual void Release() = 0; - - // Keep calling this as long as you want to wait for connections. - virtual ITCPSocket* UpdateListen( CIPAddr *pAddr ) = 0; // pAddr is set to the remote process's address. -}; - - - - -// Use these to create the interfaces. -ITCPSocket* CreateTCPSocket(); - -// Create a socket to listen with. nQueueLength specifies how many connections to enqueue. -// When the queue runs out, connections can take a little longer to make. -ITCPListenSocket* CreateTCPListenSocket( const unsigned short port, int nQueueLength = -1 ); - - -// By default, timeouts are on. It's helpful to turn them off during debugging. -void TCPSocket_EnableTimeout( bool bEnable ); - - - -#endif // ITCPSOCKET_H diff --git a/src/utils/vmpi/tcpsocket_helpers.cpp b/src/utils/vmpi/tcpsocket_helpers.cpp deleted file mode 100644 index c336b21439..0000000000 --- a/src/utils/vmpi/tcpsocket_helpers.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#include -#include "tcpsocket_helpers.h" - - -// This connects to an ISocket listening with Listen(). -bool TCPSocket_Connect( ITCPSocket *pSocket, const CIPAddr *pAddr, double flTimeout ) -{ - pSocket->BeginConnect( *pAddr ); - - CWaitTimer waitTimer( flTimeout ); - while ( 1 ) - { - if ( pSocket->UpdateConnect() ) - return true; - - if ( waitTimer.ShouldKeepWaiting() ) - Sleep( 10 ); - else - break; - } - - return false; -} - - -ITCPSocket* TCPSocket_ListenForOneConnection( ITCPListenSocket *pSocket, CIPAddr *pAddr, double flTimeout ) -{ - CWaitTimer waitTimer( flTimeout ); - while ( 1 ) - { - ITCPSocket *pRet = pSocket->UpdateListen( pAddr ); - if ( pRet ) - return pRet; - - if ( waitTimer.ShouldKeepWaiting() ) - Sleep( 10 ); - else - break; - } - - return NULL; -} diff --git a/src/utils/vmpi/tcpsocket_helpers.h b/src/utils/vmpi/tcpsocket_helpers.h deleted file mode 100644 index 870e7e9a18..0000000000 --- a/src/utils/vmpi/tcpsocket_helpers.h +++ /dev/null @@ -1,21 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#ifndef TCPSOCKET_HELPERS_H -#define TCPSOCKET_HELPERS_H -#ifdef _WIN32 -#pragma once -#endif - - -#include "tcpsocket.h" - - -bool TCPSocket_Connect( ITCPSocket *pSocket, const CIPAddr *pAddr, double flTimeout ); -ITCPSocket* TCPSocket_ListenForOneConnection( ITCPListenSocket *pSocket, CIPAddr *pAddr, double flTimeout ); - - -#endif // TCPSOCKET_HELPERS_H diff --git a/src/utils/vmpi/testapps/MessageWatch/MessageRecvMgr.h b/src/utils/vmpi/testapps/MessageWatch/MessageRecvMgr.h deleted file mode 100644 index f570ddcc21..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/MessageRecvMgr.h +++ /dev/null @@ -1,22 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -//=============================================================================// - -#ifndef MESSAGERECVMGR_H -#define MESSAGERECVMGR_H -#ifdef _WIN32 -#pragma once -#endif - - -class IMessageRecvMgr -{ -public: - -}; - - -#endif // MESSAGERECVMGR_H diff --git a/src/utils/vmpi/testapps/MessageWatch/MessageWatch.cpp b/src/utils/vmpi/testapps/MessageWatch/MessageWatch.cpp deleted file mode 100644 index 4e8dab0145..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/MessageWatch.cpp +++ /dev/null @@ -1,77 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// MessageWatch.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "MessageWatch.h" -#include "MessageWatchDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchApp - -BEGIN_MESSAGE_MAP(CMessageWatchApp, CWinApp) - //{{AFX_MSG_MAP(CMessageWatchApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchApp construction - -CMessageWatchApp::CMessageWatchApp() -{ - // TODO: add construction code here, - // Place all significant initialization in InitInstance -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CMessageWatchApp object - -CMessageWatchApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchApp initialization - -BOOL CMessageWatchApp::InitInstance() -{ - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif - - CMessageWatchDlg dlg; - m_pMainWnd = &dlg; - int nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - } - - return FALSE; -} diff --git a/src/utils/vmpi/testapps/MessageWatch/MessageWatch.h b/src/utils/vmpi/testapps/MessageWatch/MessageWatch.h deleted file mode 100644 index 3ad65aba04..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/MessageWatch.h +++ /dev/null @@ -1,56 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// MessageWatch.h : main header file for the MESSAGEWATCH application -// - -#if !defined(AFX_MESSAGEWATCH_H__72A09EC9_2B19_4AC5_A281_5FAD41F6DFCA__INCLUDED_) -#define AFX_MESSAGEWATCH_H__72A09EC9_2B19_4AC5_A281_5FAD41F6DFCA__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchApp: -// See MessageWatch.cpp for the implementation of this class -// - -class CMessageWatchApp : public CWinApp -{ -public: - CMessageWatchApp(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMessageWatchApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CMessageWatchApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MESSAGEWATCH_H__72A09EC9_2B19_4AC5_A281_5FAD41F6DFCA__INCLUDED_) diff --git a/src/utils/vmpi/testapps/MessageWatch/MessageWatch.rc b/src/utils/vmpi/testapps/MessageWatch/MessageWatch.rc deleted file mode 100644 index bfbbbd55ae..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/MessageWatch.rc +++ /dev/null @@ -1,194 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\MessageWatch.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON DISCARDABLE "res\\MessageWatch.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_MESSAGEWATCH_DIALOG DIALOGEX 0, 0, 232, 147 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "MessageWatch" -FONT 8, "MS Sans Serif" -BEGIN - PUSHBUTTON "Quit",IDCANCEL,175,126,50,14 - LISTBOX IDC_MACHINES,7,7,218,114,LBS_SORT | LBS_NOINTEGRALHEIGHT | - WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "&Show All",IDSHOWALL,7,126,50,14 - PUSHBUTTON "&Hide All",IDHIDEALL,91,126,50,14 -END - -IDD_OUTPUT DIALOG DISCARDABLE 0, 0, 320, 225 -STYLE WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Output" -FONT 8, "MS Sans Serif" -BEGIN - EDITTEXT IDC_DEBUG_OUTPUT,7,7,306,211,ES_MULTILINE | ES_READONLY | - WS_VSCROLL -END - - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904B0" - BEGIN - VALUE "CompanyName", "\0" - VALUE "FileDescription", "MessageWatch MFC Application\0" - VALUE "FileVersion", "1, 0, 0, 1\0" - VALUE "InternalName", "MessageWatch\0" - VALUE "LegalCopyright", "Copyright (C) 2002\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "MessageWatch.EXE\0" - VALUE "ProductName", "MessageWatch Application\0" - VALUE "ProductVersion", "1, 0, 0, 1\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO DISCARDABLE -BEGIN - IDD_MESSAGEWATCH_DIALOG, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 225 - TOPMARGIN, 7 - BOTTOMMARGIN, 140 - END - - IDD_OUTPUT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 313 - TOPMARGIN, 7 - BOTTOMMARGIN, 218 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\MessageWatch.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.cpp b/src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.cpp deleted file mode 100644 index 9098caa5ab..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.cpp +++ /dev/null @@ -1,324 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// MessageWatchDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "MessageWatch.h" -#include "MessageWatchDlg.h" -#include "messagemgr.h" -#include "tier1/strtools.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - - -#define WM_STARTIDLE (WM_USER + 565) - - -// --------------------------------------------------------------------------- // -// CSender. -// --------------------------------------------------------------------------- // - -CSender::CSender() -{ - m_pSocket = NULL; - m_pConsoleWnd = NULL; -} - -CSender::~CSender() -{ - if ( m_pSocket ) - m_pSocket->Release(); - - if ( m_pConsoleWnd ) - m_pConsoleWnd->Release(); -} - - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchDlg dialog - -CMessageWatchDlg::CMessageWatchDlg(CWnd* pParent /*=NULL*/) - : CDialog(CMessageWatchDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CMessageWatchDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - - m_pListenSocket = NULL; -} - -CMessageWatchDlg::~CMessageWatchDlg() -{ - // destroy the sender objects. - - if ( m_pListenSocket ) - m_pListenSocket->Release(); -} - -void CMessageWatchDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CMessageWatchDlg) - DDX_Control(pDX, IDC_MACHINES, m_Machines); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CMessageWatchDlg, CDialog) - //{{AFX_MSG_MAP(CMessageWatchDlg) - ON_MESSAGE(WM_STARTIDLE, OnStartIdle) - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_LBN_DBLCLK(IDC_MACHINES, OnDblclkMachines) - ON_BN_CLICKED(IDSHOWALL, OnShowall) - ON_BN_CLICKED(IDHIDEALL, OnHideall) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchDlg message handlers - -BOOL CMessageWatchDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // Setup our listen socket and thread. - m_pListenSocket = CreateIPSocket(); - m_pListenSocket->BindToAny( MSGMGR_BROADCAST_PORT ); - - m_cWinIdle.StartIdle( GetSafeHwnd(), WM_STARTIDLE, 0, 0, 100 ); - m_cWinIdle.NextIdle(); - - return TRUE; // return TRUE unless you set the focus to a control -} - - -LONG CMessageWatchDlg::OnStartIdle( UINT, LONG ) -{ - MSG msg; - if (!PeekMessage(&msg, GetSafeHwnd(), 0,0, PM_NOREMOVE)) - OnIdle(); - m_cWinIdle.NextIdle(); - return 0; -} - - -void CMessageWatchDlg::OnIdle() -{ - // Kill dead connections. - int iNext; - for ( int iSender=m_Senders.Head(); iSender != m_Senders.InvalidIndex(); iSender = iNext ) - { - iNext = m_Senders.Next( iSender ); - - CSender *pSender = m_Senders[iSender]; - if ( pSender->m_pSocket && !pSender->m_pSocket->IsConnected() ) - { - // Just release the socket so the text stays there. - pSender->m_pSocket->Release(); - pSender->m_pSocket = NULL; - } - } - - // Look for new connections. - while ( 1 ) - { - CIPAddr ipFrom; - char data[16]; - int len = m_pListenSocket->RecvFrom( data, sizeof( data ), &ipFrom ); - if ( len == -1 ) - break; - - if ( data[0] == MSGMGR_PACKETID_ANNOUNCE_PRESENCE && - *((int*)&data[1]) == MSGMGR_VERSION ) - { - int iPort = *((int*)&data[5]); - - // See if we have a machine with this info yet. - CIPAddr connectAddr = ipFrom; - connectAddr.port = iPort; - - // NOTE: we'll accept connections from machines we were connected to earlier but - // lost the connection to. - CSender *pSender = FindSenderByAddr( ipFrom.ip ); - if ( !pSender || !pSender->m_pSocket ) - { - // 'nitiate the connection. - ITCPSocket *pNew = CreateTCPSocket(); - if ( pNew->BindToAny( 0 ) && TCPSocket_Connect( pNew, &connectAddr, 1000 ) ) - { - char nameStr[256]; - char title[512]; - if ( !ConvertIPAddrToString( &ipFrom, nameStr, sizeof( nameStr ) ) ) - Q_snprintf( nameStr, sizeof( nameStr ), "%d.%d.%d.%d", ipFrom.ip[0], ipFrom.ip[1], ipFrom.ip[2], ipFrom.ip[3] ); - - Q_snprintf( title, sizeof( title ), "%s:%d", nameStr, iPort ); - - // If the sender didn't exist yet, add a new one. - if ( !pSender ) - { - pSender = new CSender; - - IConsoleWnd *pWnd = CreateConsoleWnd( - AfxGetInstanceHandle(), - IDD_OUTPUT, - IDC_DEBUG_OUTPUT, - false - ); - - pSender->m_pConsoleWnd = pWnd; - pWnd->SetTitle( title ); - - Q_strncpy( pSender->m_Name, title, sizeof( pSender->m_Name ) ); - m_Senders.AddToTail( pSender ); - m_Machines.AddString( pSender->m_Name ); - } - - pSender->m_Addr = connectAddr; - pSender->m_pSocket = pNew; - } - else - { - pNew->Release(); - } - } - } - } - - - // Read input from our current connections. - FOR_EACH_LL( m_Senders, i ) - { - CSender *pSender = m_Senders[i]; - - while ( 1 ) - { - if ( !pSender->m_pSocket ) - break; - - CUtlVector data; - if ( !pSender->m_pSocket->Recv( data ) ) - break; - - if ( data[0] == MSGMGR_PACKETID_MSG ) - { - char *pMsg = (char*)&data[1]; - pSender->m_pConsoleWnd->PrintToConsole( pMsg ); - OutputDebugString( pMsg ); - } - } - } -} - - -void CMessageWatchDlg::OnDestroy() -{ - // Stop the idling thread - m_cWinIdle.EndIdle(); - CDialog::OnDestroy(); -} - - -CSender* CMessageWatchDlg::FindSenderByAddr( const unsigned char ip[4] ) -{ - FOR_EACH_LL( m_Senders, i ) - { - if ( memcmp( m_Senders[i]->m_Addr.ip, ip, 4 ) == 0 ) - return m_Senders[i]; - } - return NULL; -} - - -CSender* CMessageWatchDlg::FindSenderByName( const char *pName ) -{ - FOR_EACH_LL( m_Senders, i ) - { - if ( stricmp( pName, m_Senders[i]->m_Name ) == 0 ) - return m_Senders[i]; - } - return NULL; -} - - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CMessageWatchDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CMessageWatchDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void CMessageWatchDlg::OnDblclkMachines() -{ - int index = m_Machines.GetCurSel(); - if ( index != LB_ERR ) - { - CString str; - m_Machines.GetText( index, str ); - - CSender *pSender = FindSenderByName( str ); - if ( pSender ) - pSender->m_pConsoleWnd->SetVisible( true ); - } -} - -void CMessageWatchDlg::OnShowall() -{ - FOR_EACH_LL( m_Senders, i ) - { - m_Senders[i]->m_pConsoleWnd->SetVisible( true ); - } -} - -void CMessageWatchDlg::OnHideall() -{ - FOR_EACH_LL( m_Senders, i ) - { - m_Senders[i]->m_pConsoleWnd->SetVisible( false ); - } -} diff --git a/src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.h b/src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.h deleted file mode 100644 index e495a54669..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/MessageWatchDlg.h +++ /dev/null @@ -1,100 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// MessageWatchDlg.h : header file -// - -#if !defined(AFX_MESSAGEWATCHDLG_H__AB9CEAF4_0166_4CCA_9DEC_77C0918F78C4__INCLUDED_) -#define AFX_MESSAGEWATCHDLG_H__AB9CEAF4_0166_4CCA_9DEC_77C0918F78C4__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -#include "iphelpers.h" -#include "tcpsocket.h" -#include "threadhelpers.h" -#include "consolewnd.h" -#include "win_idle.h" - - -///////////////////////////////////////////////////////////////////////////// -// CMessageWatchDlg dialog - -class CSender -{ -public: - CSender(); - ~CSender(); - -public: - - CIPAddr m_Addr; - ITCPSocket *m_pSocket; - IConsoleWnd *m_pConsoleWnd; - char m_Name[128]; -}; - -class CMessageWatchDlg : public CDialog -{ -// Construction -public: - CMessageWatchDlg(CWnd* pParent = NULL); // standard constructor - ~CMessageWatchDlg(); - - - // Listen for broadcasts on this socket. - ISocket *m_pListenSocket; - - // Connections we've made. - CUtlLinkedList m_Senders; - - CCriticalSection m_SocketsCS; - CWinIdle m_cWinIdle; - - - CSender* FindSenderByAddr( const unsigned char ip[4] ); - CSender* FindSenderByName( const char *pName ); - - -// Dialog Data - //{{AFX_DATA(CMessageWatchDlg) - enum { IDD = IDD_MESSAGEWATCH_DIALOG }; - CListBox m_Machines; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMessageWatchDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - HICON m_hIcon; - - void OnIdle(); - - // Generated message map functions - //{{AFX_MSG(CMessageWatchDlg) - afx_msg void OnDestroy(); - afx_msg LONG OnStartIdle(UINT, LONG); - virtual BOOL OnInitDialog(); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnDblclkMachines(); - afx_msg void OnShowall(); - afx_msg void OnHideall(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MESSAGEWATCHDLG_H__AB9CEAF4_0166_4CCA_9DEC_77C0918F78C4__INCLUDED_) diff --git a/src/utils/vmpi/testapps/MessageWatch/StdAfx.cpp b/src/utils/vmpi/testapps/MessageWatch/StdAfx.cpp deleted file mode 100644 index 43fa619a68..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// MessageWatch.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - diff --git a/src/utils/vmpi/testapps/MessageWatch/StdAfx.h b/src/utils/vmpi/testapps/MessageWatch/StdAfx.h deleted file mode 100644 index adf866a74c..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/StdAfx.h +++ /dev/null @@ -1,33 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__70653A1B_FB34_4AD9_861C_580071240D6F__INCLUDED_) -#define AFX_STDAFX_H__70653A1B_FB34_4AD9_861C_580071240D6F__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__70653A1B_FB34_4AD9_861C_580071240D6F__INCLUDED_) diff --git a/src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.ico b/src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.ico deleted file mode 100644 index dc0d87df67a7da710e61c204cce8f1832c0eadcf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 766 zcmcgqF%H5o47>soW0;sT@(cJGd0L**k+BazggZMWZPWz`;ncCucH*mBVBm`J1j%Cu zoM|uANWD=99Jm9Cxot^IGLw=U?sSoJrd6WYgHq&CxfIg&9|_Z{Pnp7^wee_V=s7tr z5v*8&u*AI8AZ?Ai`C#^uG;FY8hhO0Sz8*WDnJ=vuG@f2iu?5U8}BwUFKPI9 qo^IZh*WFo=*%P>Gf+KLuz&`Ppl%kV4o>?=pR%dk9-mZR$zSkQAu_EjM diff --git a/src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.rc2 b/src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.rc2 deleted file mode 100644 index cf543e7070..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/res/MessageWatch.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// MESSAGEWATCH.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/src/utils/vmpi/testapps/MessageWatch/resource.h b/src/utils/vmpi/testapps/MessageWatch/resource.h deleted file mode 100644 index 05f2c75ed3..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/resource.h +++ /dev/null @@ -1,29 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by MessageWatch.rc -// -#define IDSHOWALL 3 -#define IDHIDEALL 4 -#define IDD_MESSAGEWATCH_DIALOG 102 -#define IDR_MAINFRAME 128 -#define IDD_OUTPUT 129 -#define IDC_MACHINES 1000 -#define IDC_DEBUG_OUTPUT 1000 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/src/utils/vmpi/testapps/MessageWatch/win_idle.cpp b/src/utils/vmpi/testapps/MessageWatch/win_idle.cpp deleted file mode 100644 index 69ac9da02b..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/win_idle.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// Class for sending idle messages to a window - -#include "stdafx.h" -#include "win_idle.h" - -// Stub function to get into the object's main thread loop -DWORD WINAPI CWinIdle::ThreadStub(LPVOID pIdle) -{ - return ((CWinIdle *)pIdle)->RunIdle(); -} - -CWinIdle::CWinIdle() : - m_hIdleThread(NULL), - m_hIdleEvent(NULL), - m_hStopEvent(NULL), - m_hWnd(0), - m_uMsg(0), - m_dwDelay(0) -{ -} - -CWinIdle::~CWinIdle() -{ - if (m_hIdleThread) - OutputDebugString("!!CWinIdle Warning!! Idle thread not shut down!\n"); -} - -DWORD CWinIdle::RunIdle() -{ - // Set up an event list - HANDLE aEvents[2]; - - aEvents[0] = m_hStopEvent; - aEvents[1] = m_hIdleEvent; - - // Wait for a stop or idle event - while (WaitForMultipleObjects(2, aEvents, FALSE, INFINITE) != WAIT_OBJECT_0) - { - // Send an idle message - PostMessage(m_hWnd, m_uMsg, m_wParam, m_lParam); - // Wait for a bit... - Sleep(m_dwDelay); - } - - return 0; -} - -BOOL CWinIdle::StartIdle(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam, DWORD dwDelay) -{ - // Make sure it's not already running - if (m_hIdleThread) - return FALSE; - - // Make sure they send in a valid handle.. - if (!hWnd) - return FALSE; - - // Create the events - m_hIdleEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - m_hStopEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - - // Make sure the events got created - if ((!m_hIdleEvent) || (!m_hStopEvent)) - return FALSE; - - // Create the thread - DWORD dwThreadID; - m_hIdleThread = CreateThread(NULL, 0, CWinIdle::ThreadStub, (void *)this, 0, &dwThreadID); - - if (m_hIdleThread) - { - SetThreadPriority(m_hIdleThread, THREAD_PRIORITY_IDLE); - - m_hWnd = hWnd; - m_uMsg = uMessage; - m_wParam = wParam; - m_lParam = lParam; - - m_dwDelay = dwDelay; - } - - return m_hIdleThread != 0; -} - -BOOL CWinIdle::EndIdle() -{ - // Make sure it's running - if (!m_hIdleThread) - return FALSE; - - // Stop the idle thread - SetEvent(m_hStopEvent); - WaitForSingleObject(m_hIdleThread, INFINITE); - CloseHandle(m_hIdleThread); - - // Get rid of the event objects - CloseHandle(m_hIdleEvent); - CloseHandle(m_hStopEvent); - - // Set everything back to 0 - m_hIdleEvent = 0; - m_hStopEvent = 0; - m_hIdleThread = 0; - - return TRUE; -} - -void CWinIdle::NextIdle() -{ - // Make sure the thread's running - if (!m_hIdleThread) - return; - - // Signal an idle message - SetEvent(m_hIdleEvent); -} diff --git a/src/utils/vmpi/testapps/MessageWatch/win_idle.h b/src/utils/vmpi/testapps/MessageWatch/win_idle.h deleted file mode 100644 index 6e2e3f381b..0000000000 --- a/src/utils/vmpi/testapps/MessageWatch/win_idle.h +++ /dev/null @@ -1,78 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// WinIdle.h - Defines a class for sending idle messages to a window from a secondary thread - -#ifndef __WINIDLE_H__ -#define __WINIDLE_H__ - - -class CWinIdle -{ -protected: - HANDLE m_hIdleEvent, m_hStopEvent; - - HWND m_hWnd; - UINT m_uMsg; - WPARAM m_wParam; - LPARAM m_lParam; - - DWORD m_dwDelay; - - HANDLE m_hIdleThread; - - // The thread calling stub - static DWORD WINAPI ThreadStub(LPVOID pIdle); - // The actual idle loop - virtual DWORD RunIdle(); - -public: - CWinIdle(); - virtual ~CWinIdle(); - - inline DWORD GetDelay() {return m_dwDelay;} - inline void SetDelay(DWORD delay) {m_dwDelay = delay;} - - // Member access - virtual HANDLE GetThreadHandle() const { return m_hIdleThread; }; - - // Start idling, and define the message and window to use - // Returns TRUE on success - virtual BOOL StartIdle(HWND hWnd, UINT uMessage, WPARAM wParam = 0, LPARAM lParam = 0, DWORD dwDelay = 0); - // Stop idling - // Returns TRUE on success - virtual BOOL EndIdle(); - // Notify the idle process that the message was received. - // Note : If this function is not called, the idle thread will not send any messages - virtual void NextIdle(); -}; - - -// Used to slow down the idle thread while dialogs are up. -class IdleChanger -{ -public: - IdleChanger(CWinIdle *pIdle, DWORD msDelay) - { - m_pIdle = pIdle; - m_OldDelay = pIdle->GetDelay(); - pIdle->SetDelay(msDelay); - } - - ~IdleChanger() - { - m_pIdle->SetDelay(m_OldDelay); - } - - CWinIdle *m_pIdle; - DWORD m_OldDelay; -}; - - - -#endif //__WINIDLE_H__ - diff --git a/src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.cpp b/src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.cpp deleted file mode 100644 index 538b0e0a07..0000000000 --- a/src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// ThreadedTCPSocketTest.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.h b/src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.h deleted file mode 100644 index e29801c547..0000000000 --- a/src/utils/vmpi/testapps/ThreadedTCPSocketTest/StdAfx.h +++ /dev/null @@ -1,31 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__AA10D99C_786F_4324_86C6_4D7CDE546561__INCLUDED_) -#define AFX_STDAFX_H__AA10D99C_786F_4324_86C6_4D7CDE546561__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#include -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__AA10D99C_786F_4324_86C6_4D7CDE546561__INCLUDED_) diff --git a/src/utils/vmpi/testapps/ThreadedTCPSocketTest/ThreadedTCPSocketTest.cpp b/src/utils/vmpi/testapps/ThreadedTCPSocketTest/ThreadedTCPSocketTest.cpp deleted file mode 100644 index 0b82c56d6b..0000000000 --- a/src/utils/vmpi/testapps/ThreadedTCPSocketTest/ThreadedTCPSocketTest.cpp +++ /dev/null @@ -1,198 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// ThreadedTCPSocketTest.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "IThreadedTCPSocket.h" -#include "threadhelpers.h" -#include "vstdlib/random.h" - - -CCriticalSection g_MsgCS; - - -IThreadedTCPSocket *g_pClientSocket = NULL; -IThreadedTCPSocket *g_pServerSocket = NULL; - -CEvent g_ClientPacketEvent; -CUtlVector g_ClientPacket; - - - -SpewRetval_t MySpewFunc( SpewType_t type, char const *pMsg ) -{ - CCriticalSectionLock csLock( &g_MsgCS ); - csLock.Lock(); - - printf( "%s", pMsg ); - OutputDebugString( pMsg ); - - csLock.Unlock(); - - if( type == SPEW_ASSERT ) - return SPEW_DEBUGGER; - else if( type == SPEW_ERROR ) - return SPEW_ABORT; - else - return SPEW_CONTINUE; -} - - -class CHandler_Server : public ITCPSocketHandler -{ -public: - virtual void Init( IThreadedTCPSocket *pSocket ) - { - } - - virtual void OnPacketReceived( CTCPPacket *pPacket ) - { - // Echo the data back. - g_pServerSocket->Send( pPacket->GetData(), pPacket->GetLen() ); - pPacket->Release(); - } - - virtual void OnError( int errorCode, const char *pErrorString ) - { - Msg( "Server error: %s\n", pErrorString ); - } -}; - - - -class CHandler_Client : public ITCPSocketHandler -{ -public: - virtual void Init( IThreadedTCPSocket *pSocket ) - { - } - - virtual void OnPacketReceived( CTCPPacket *pPacket ) - { - if ( g_ClientPacket.Count() < pPacket->GetLen() ) - g_ClientPacket.SetSize( pPacket->GetLen() ); - - memcpy( g_ClientPacket.Base(), pPacket->GetData(), pPacket->GetLen() ); - g_ClientPacketEvent.SetEvent(); - pPacket->Release(); - } - - virtual void OnError( int errorCode, const char *pErrorString ) - { - Msg( "Client error: %s\n", pErrorString ); - } -}; - - - -class CHandlerCreator_Server : public IHandlerCreator -{ -public: - virtual ITCPSocketHandler* CreateNewHandler() - { - return new CHandler_Server; - } -}; - -class CHandlerCreator_Client : public IHandlerCreator -{ -public: - virtual ITCPSocketHandler* CreateNewHandler() - { - return new CHandler_Client; - } -}; - - - -int main(int argc, char* argv[]) -{ - SpewOutputFunc( MySpewFunc ); - - // Figure out a random port to use. - CCycleCount cnt; - cnt.Sample(); - CUniformRandomStream randomStream; - randomStream.SetSeed( cnt.GetMicroseconds() ); - int iPort = randomStream.RandomInt( 20000, 30000 ); - - - g_ClientPacketEvent.Init( false, false ); - - - // Setup the "server". - CHandlerCreator_Server serverHandler; - CIPAddr addr( 127, 0, 0, 1, iPort ); - - ITCPConnectSocket *pListener = ThreadedTCP_CreateListener( - &serverHandler, - (unsigned short)iPort ); - - - // Setup the "client". - CHandlerCreator_Client clientCreator; - ITCPConnectSocket *pConnector = ThreadedTCP_CreateConnector( - CIPAddr( 127, 0, 0, 1, iPort ), - CIPAddr(), - &clientCreator ); - - - // Wait for them to connect. - while ( !g_pClientSocket ) - { - if ( !pConnector->Update( &g_pClientSocket ) ) - { - Error( "Error in client connector!\n" ); - } - } - pConnector->Release(); - - - while ( !g_pServerSocket ) - { - if ( !pListener->Update( &g_pServerSocket ) ) - Error( "Error in server connector!\n" ); - } - pListener->Release(); - - - // Send some data. - __int64 totalBytes = 0; - CCycleCount startTime; - int iPacket = 1; - - startTime.Sample(); - CUtlVector buf; - - while ( (GetAsyncKeyState( VK_SHIFT ) & 0x8000) == 0 ) - { - int size = randomStream.RandomInt( 1024*0, 1024*320 ); - if ( buf.Count() < size ) - buf.SetSize( size ); - - if ( g_pClientSocket->Send( buf.Base(), size ) ) - { - // Server receives the data and echoes it back. Verify that the data is good. - WaitForSingleObject( g_ClientPacketEvent.GetEventHandle(), INFINITE ); - Assert( memcmp( g_ClientPacket.Base(), buf.Base(), size ) == 0 ); - - totalBytes += size; - CCycleCount curTime, elapsed; - curTime.Sample(); - CCycleCount::Sub( curTime, startTime, elapsed ); - double flSeconds = elapsed.GetSeconds(); - Msg( "Packet %d, %d bytes, %dk/sec\n", iPacket++, size, (int)(((totalBytes+511)/1024) / flSeconds) ); - } - } - - g_pClientSocket->Release(); - g_pServerSocket->Release(); - return 0; -} - diff --git a/src/utils/vmpi/testapps/pingpong/StdAfx.cpp b/src/utils/vmpi/testapps/pingpong/StdAfx.cpp deleted file mode 100644 index 31353c4a37..0000000000 --- a/src/utils/vmpi/testapps/pingpong/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// pingpong.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/utils/vmpi/testapps/pingpong/StdAfx.h b/src/utils/vmpi/testapps/pingpong/StdAfx.h deleted file mode 100644 index 59dfc176c9..0000000000 --- a/src/utils/vmpi/testapps/pingpong/StdAfx.h +++ /dev/null @@ -1,29 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__13A3CFA6_6BF8_45A8_A2CD_91444DCFF7C0__INCLUDED_) -#define AFX_STDAFX_H__13A3CFA6_6BF8_45A8_A2CD_91444DCFF7C0__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__13A3CFA6_6BF8_45A8_A2CD_91444DCFF7C0__INCLUDED_) diff --git a/src/utils/vmpi/testapps/pingpong/pingpong.cpp b/src/utils/vmpi/testapps/pingpong/pingpong.cpp deleted file mode 100644 index e5891970f4..0000000000 --- a/src/utils/vmpi/testapps/pingpong/pingpong.cpp +++ /dev/null @@ -1,308 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// pingpong.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include -#include -#include "tcpsocket.h" -#include "tier0/fasttimer.h" -#include "vmpi.h" -#include "tcpsocket_helpers.h" - -//#define USE_MPI - - -#if defined( USE_MPI ) - #include "mpi/mpi.h" - #include "vmpi.h" - #include "tier1/bitbuf.h" - - int myProcId = -1; -#else - IChannel *g_pSocket = NULL; - int g_iPortNum = 27141; -#endif - - -int PrintUsage() -{ - printf( "pingpong <-server or -client ip>\n" ); - return 1; -} - - -void DoClientConnect( const char *pIP ) -{ -#if defined( USE_MPI ) - int argc = 1; - char *testargv[1] = { "-nounc" }; - char **argv = testargv; - if ( MPI_Init( &argc, &argv ) ) - { - assert( false ); - } - MPI_Comm_rank( MPI_COMM_WORLD, &myProcId ); - - int nProcs; - MPI_Comm_size( MPI_COMM_WORLD, &nProcs ); - if ( nProcs != 2 ) - { - assert( false ); - } -#else - // Try to connect, or listen. - ITCPSocket *pTCPSocket = CreateTCPSocket(); - if ( !pTCPSocket->BindToAny( 0 ) ) - { - assert( false ); - } - - CIPAddr addr; - if ( !ConvertStringToIPAddr( pIP, &addr ) ) - { - assert( false ); - } - - addr.port = g_iPortNum; - printf( "Client connecting to %d.%d.%d.%d:%d\n", addr.ip[0], addr.ip[1], addr.ip[2], addr.ip[3], addr.port ); - if ( !TCPSocket_Connect( pTCPSocket, &addr, 50000 ) ) - { - assert( false ); - } - - printf( "Client connected...\n "); - g_pSocket = pTCPSocket; -#endif -} - - -void DoServerConnect() -{ -#if defined( USE_MPI ) - ISocket *pSocket = CreateIPSocket(); - if ( !pSocket ) - { - printf( "Error creating a socket.\n" ); - assert( false ); - return; - } - else if ( !pSocket->BindToAny( VMPI_SERVICE_PORT ) ) - { - printf( "Error binding a socket to port %d.\n", VMPI_SERVICE_PORT ); - assert( false ); - return; - } - - printf( "Waiting for jobs...\n" ); - while ( 1 ) - { - // Any incoming packets? - char data[2048]; - CIPAddr ipFrom; - int len = pSocket->RecvFrom( data, sizeof( data ), &ipFrom ); - if ( len > 3 ) - { - bf_read buf( data, len ); - if ( buf.ReadByte() == VMPI_PROTOCOL_VERSION ) - { - if ( buf.ReadByte() == VMPI_LOOKING_FOR_WORKERS ) - { - // Read the listen port. - int iListenPort = buf.ReadLong(); - - static char ipString[128]; - _snprintf( ipString, sizeof( ipString ), "%d.%d.%d.%d:%d", ipFrom.ip[0], ipFrom.ip[1], ipFrom.ip[2], ipFrom.ip[3], iListenPort ); - - int argc = 3; - char *testargv[3]; - testargv[0] = ""; - testargv[1] = "-mpi_worker"; - testargv[2] = ipString; - - char **argv = testargv; - if ( MPI_Init( &argc, &argv ) ) - { - assert( false ); - } - MPI_Comm_rank( MPI_COMM_WORLD, &myProcId ); - - int nProcs; - MPI_Comm_size( MPI_COMM_WORLD, &nProcs ); - if ( nProcs != 2 ) - { - assert( false ); - } - break; - } - } - } - - Sleep( 100 ); - } - - pSocket->Release(); -#else - // Try to connect, or listen. - ITCPListenSocket *pListen = CreateTCPListenSocket( g_iPortNum ); - if ( !pListen ) - { - assert( false ); - } - - printf( "Server listening...\n" ); - - CIPAddr addr; - ITCPSocket *pTCPSocket = TCPSocket_ListenForOneConnection( pListen, &addr, 50000 ); - if ( !pTCPSocket ) - { - assert( false ); - } - pListen->Release(); - - printf( "Server connected...\n "); - g_pSocket = pTCPSocket; -#endif -} - - -void SendData( const void *pBuf, int size ) -{ -#if defined( USE_MPI ) - MPI_Send( (void*)pBuf, size, MPI_BYTE, !myProcId, 0, MPI_COMM_WORLD ); -#else - g_pSocket->Send( pBuf, size ); -#endif -} - - -void RecvData( CUtlVector &recvBuf ) -{ -#if defined( USE_MPI ) - MPI_Status stat; - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &stat); - - recvBuf.SetCount( stat.count ); - MPI_Recv( recvBuf.Base(), stat.count, MPI_BYTE, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &stat); -#else - if ( !g_pSocket->Recv( recvBuf, 50000 ) ) - { - g_pSocket->Release(); - g_pSocket = NULL; - } -#endif -} - - -int main( int argc, char* argv[] ) -{ - if ( argc < 2 ) - { - return PrintUsage(); - } - - const char *pClientOrServer = argv[1]; - const char *pIP = NULL; - - bool bClient = false; - if ( stricmp( pClientOrServer, "-client" ) == 0 ) - { - if ( argc < 3 ) - { - return PrintUsage(); - } - - bClient = true; - pIP = argv[2]; - } - - CUtlVector recvBuf; - if ( bClient ) - { - DoClientConnect( pIP ); - - // Ok, now start blasting packets of different sizes and measure how long it takes to get an ack back. - int nIterations = 30; - - for ( int size=350; size <= 350000; size += 512 ) - { - CUtlVector buf; - buf.SetCount( size ); - - double flTotalRoundTripTime = 0; - - CFastTimer throughputTimer; - throughputTimer.Start(); - - for ( int i=0; i < nIterations; i++ ) - { - for ( int z=0; z < size; z++ ) - buf[z] = (char)rand(); - - SendData( buf.Base(), buf.Count() ); - - CFastTimer timer; - timer.Start(); - RecvData( recvBuf ); - timer.End(); - - - // Make sure we got the same data back. - assert( recvBuf.Count() == buf.Count() ); - for ( z=0; z < size; z++ ) - { - assert( recvBuf[z] == buf[z] ); - } - - - //if ( i % 100 == 0 ) - // printf( "%05d\n", i ); -printf( "%d\n", i ); - flTotalRoundTripTime += timer.GetDuration().GetMillisecondsF(); - } - throughputTimer.End(); - double flTotalSeconds = throughputTimer.GetDuration().GetSeconds(); - - double flAvgRoundTripTime = flTotalRoundTripTime / nIterations; - printf( "%d: %.2f ms per roundtrip (%d bytes/sec) sec: %.2f megs: %.2f\n", - size, - flAvgRoundTripTime, - (int)((size*nIterations)/flTotalSeconds), - flTotalSeconds, - (double)(size*nIterations) / (1024*1024) ); - } - - // Send an 'end' message to the server. - int val = -1; - SendData( &val, sizeof( val ) ); - } - else - { - // Wait for a connection. - DoServerConnect(); - - // Wait for packets and ack them. - while ( 1 ) - { - RecvData( recvBuf ); - if ( !g_pSocket ) - break; - - if ( recvBuf.Count() < 4 ) - { - assert( false ); - } - - SendData( recvBuf.Base(), recvBuf.Count() ); - } - } - - return 0; -} - diff --git a/src/utils/vmpi/testapps/socket_stresstest/StdAfx.cpp b/src/utils/vmpi/testapps/socket_stresstest/StdAfx.cpp deleted file mode 100644 index 2b565b07ae..0000000000 --- a/src/utils/vmpi/testapps/socket_stresstest/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// socket_stresstest.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/utils/vmpi/testapps/socket_stresstest/StdAfx.h b/src/utils/vmpi/testapps/socket_stresstest/StdAfx.h deleted file mode 100644 index 3c554be659..0000000000 --- a/src/utils/vmpi/testapps/socket_stresstest/StdAfx.h +++ /dev/null @@ -1,33 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__7E382B26_1CB4_461A_8087_762358153941__INCLUDED_) -#define AFX_STDAFX_H__7E382B26_1CB4_461A_8087_762358153941__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#include -#include "tcpsocket.h" -#include -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__7E382B26_1CB4_461A_8087_762358153941__INCLUDED_) diff --git a/src/utils/vmpi/testapps/socket_stresstest/socket_stresstest.cpp b/src/utils/vmpi/testapps/socket_stresstest/socket_stresstest.cpp deleted file mode 100644 index 55ab97d3a3..0000000000 --- a/src/utils/vmpi/testapps/socket_stresstest/socket_stresstest.cpp +++ /dev/null @@ -1,274 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// socket_stresstest.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "utllinkedlist.h" - - -class CSocketInfo -{ -public: - - bool IsValid() - { - return m_pSocket != 0; - } - - void Term(); - - void ThreadFn(); - - - -public: - ITCPSocket *m_pSocket; - int m_iListenPort; - - DWORD m_CreateTime; // When this socket was created. - DWORD m_ExpireTime; -}; - - - -CSocketInfo g_Infos[132]; -CRITICAL_SECTION g_CS, g_PrintCS; -HANDLE g_hThreads[ ARRAYSIZE( g_Infos ) ]; -bool g_bShouldExit = false; -CUtlLinkedList g_ListenPorts; - - -SpewRetval_t StressTestSpew( SpewType_t type, char const *pMsg ) -{ - EnterCriticalSection( &g_PrintCS ); - printf( "%s", pMsg ); - LeaveCriticalSection( &g_PrintCS ); - - if( type == SPEW_ASSERT ) - return SPEW_DEBUGGER; - else if( type == SPEW_ERROR ) - return SPEW_ABORT; - else - return SPEW_CONTINUE; -} - - -void CSocketInfo::Term() -{ - if ( m_pSocket ) - { - m_pSocket->Release(); - m_pSocket = 0; - } -} - - -CSocketInfo* FindOldestSocketInfo( CSocketInfo *pInfos, int nInfos ) -{ - int iOldest = 0; - DWORD oldestTime = 0xFFFFFFFF; - for ( int i=0; i < nInfos; i++ ) - { - if ( !pInfos[i].IsValid() ) - return &pInfos[i]; - - if ( pInfos[i].m_CreateTime < oldestTime ) - { - oldestTime = pInfos[i].m_CreateTime; - iOldest = i; - } - } - return &pInfos[iOldest]; -} - - -int g_iNextExpire = -1; - -void CSocketInfo::ThreadFn() -{ - int iInfo = this - g_Infos; - - while ( !g_bShouldExit ) - { - DWORD curTime = GetTickCount(); - - // Break the connection after a certain amount of time. - if ( m_pSocket && curTime >= m_ExpireTime ) - { - Term(); - Msg( "%02d: expire.\n", iInfo, m_iListenPort ); - } - - if ( m_pSocket ) - { - EnterCriticalSection( &g_CS ); - if ( g_iNextExpire == -1 ) - { - g_iNextExpire = iInfo; - LeaveCriticalSection( &g_CS ); - - Msg( "%02d: forcing an expire.\n", iInfo, m_iListenPort ); - Sleep( 16000 ); - - EnterCriticalSection( &g_CS ); - g_iNextExpire = -1; - } - LeaveCriticalSection( &g_CS ); - - if ( m_pSocket->IsConnected() ) - { - // Receive whatever data it has waiting for it. - CUtlVector data; - while ( m_pSocket->Recv( data ) ) - { - Msg( "%02d: recv %d.\n", iInfo, data.Count() ); - } - - // Send some data. - int size = rand() % 8192; - data.SetSize( size ); - m_pSocket->Send( data.Base(), data.Count() ); - //Msg( "%02d: send %d.\n", iInfo, data.Count() ); - } - else - { - Term(); - } - } - else - { - // Not initialized.. either listen or connect. - int iConnectPort = -1; - if ( rand() > VALVE_RAND_MAX/2 ) - { - if ( rand() % 100 < 50 ) - Sleep( 500 ); - - EnterCriticalSection( &g_CS ); - int iHead = g_ListenPorts.Head(); - if ( iHead != g_ListenPorts.InvalidIndex() ) - iConnectPort = g_ListenPorts[iHead]; - LeaveCriticalSection( &g_CS ); - } - - if ( iConnectPort != -1 ) - { - CIPAddr addr( 127, 0, 0, 1, iConnectPort ); - - m_pSocket = CreateTCPSocket(); - m_pSocket->BindToAny( 0 ); - m_CreateTime = curTime; - m_ExpireTime = curTime + rand() % 5000; - if ( !TCPSocket_Connect( m_pSocket, &addr, 3.0f ) ) - { - Term(); - } - } - else - { - for ( int iTry=0; iTry < 32; iTry++ ) - { - m_iListenPort = 100 + rand() % (VALVE_RAND_MAX/2); - ITCPListenSocket *pListenSocket = CreateTCPListenSocket( m_iListenPort ); - if ( pListenSocket ) - { - Msg( "%02d: listen on %d.\n", iInfo, m_iListenPort ); - - // Add us to the list of ports to connect to. - EnterCriticalSection( &g_CS ); - g_ListenPorts.AddToTail( m_iListenPort ); - LeaveCriticalSection( &g_CS ); - - // Listen for a connection. - CIPAddr connectedAddr; - m_pSocket = TCPSocket_ListenForOneConnection( pListenSocket, &connectedAddr, 4.0 ); - - // Remove us from the list of ports to connect to. - EnterCriticalSection( &g_CS ); - g_ListenPorts.Remove( g_ListenPorts.Find( m_iListenPort ) ); - LeaveCriticalSection( &g_CS ); - - pListenSocket->Release(); - - if ( m_pSocket ) - { - Msg( "%02d: listen found connection.\n", iInfo ); - m_CreateTime = curTime; - m_ExpireTime = curTime + rand() % 5000; - } - break; - } - } - } - } - - Sleep( 1 ); - } - - g_hThreads[iInfo] = 0; -} - - -DWORD WINAPI ThreadFn( LPVOID lpParameter ) -{ - CSocketInfo *pInfo = (CSocketInfo*)lpParameter; - pInfo->ThreadFn(); - return 0; -} - - -void AllocError( unsigned long size ) -{ - Assert( false ); -} - - -int main(int argc, char* argv[]) -{ - memset( g_Infos, 0, sizeof( g_Infos ) ); - memset( g_hThreads, 0, sizeof( g_hThreads ) ); - - InitializeCriticalSection( &g_CS ); - InitializeCriticalSection( &g_PrintCS ); - - SpewOutputFunc( StressTestSpew ); - Plat_SetAllocErrorFn( AllocError ); - - SetPriorityClass( GetCurrentProcess(), IDLE_PRIORITY_CLASS ); - - for ( int i=0; i < ARRAYSIZE( g_Infos ); i++ ) - { - DWORD dwThreadID = 0; - g_hThreads[i] = CreateThread( - NULL, - 0, - ThreadFn, - &g_Infos[i], - 0, - &dwThreadID ); - } - - - while ( !kbhit() ) - { - } - - g_bShouldExit = true; - - HANDLE hZeroArray[ ARRAYSIZE( g_Infos ) ]; - memset( hZeroArray, 0, sizeof( hZeroArray ) ); - - while ( memcmp( hZeroArray, g_hThreads, sizeof( hZeroArray ) ) != 0 ) - { - Sleep( 10 ); - } - - return 0; -} - diff --git a/src/utils/vmpi/testapps/vmpi_launch/StdAfx.cpp b/src/utils/vmpi/testapps/vmpi_launch/StdAfx.cpp deleted file mode 100644 index 7d621ea6a2..0000000000 --- a/src/utils/vmpi/testapps/vmpi_launch/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// vmpi_launch.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/utils/vmpi/testapps/vmpi_launch/StdAfx.h b/src/utils/vmpi/testapps/vmpi_launch/StdAfx.h deleted file mode 100644 index a673b658b8..0000000000 --- a/src/utils/vmpi/testapps/vmpi_launch/StdAfx.h +++ /dev/null @@ -1,30 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__00616BF6_B7E2_4D94_8DC8_3F85BEBD1834__INCLUDED_) -#define AFX_STDAFX_H__00616BF6_B7E2_4D94_8DC8_3F85BEBD1834__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__00616BF6_B7E2_4D94_8DC8_3F85BEBD1834__INCLUDED_) diff --git a/src/utils/vmpi/testapps/vmpi_launch/vmpi_launch.cpp b/src/utils/vmpi/testapps/vmpi_launch/vmpi_launch.cpp deleted file mode 100644 index 7ecb47bf8c..0000000000 --- a/src/utils/vmpi/testapps/vmpi_launch/vmpi_launch.cpp +++ /dev/null @@ -1,256 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// vmpi_launch.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "iphelpers.h" -#include "bitbuf.h" -#include "vmpi.h" - -bool g_bBroadcast = false; - -int PrintUsage() -{ - printf( "vmpi_launch -machine -priority [-mpi_pw ] -command \"command line...\"\n" ); - printf( "-command must be the last switch..\n" ); - return 1; -} - - -int GetCurMicrosecondsAndSleep( int sleepLen ) -{ - Sleep( sleepLen ); - - int retVal; - __asm - { - rdtsc - mov retVal, eax - } - return retVal; -} - - -const char* FindArg( int argc, char **argv, const char *pName, const char *pDefault ) -{ - for ( int i=0; i < argc; i++ ) - { - if ( stricmp( argv[i], pName ) == 0 ) - { - if ( (i+1) < argc ) - return argv[i+1]; - else - return pDefault; - } - } - return NULL; -} - - -int ParseArgs( int argc, char **argv, CIPAddr &remoteIP, int &iPriority, int &iFirstArg ) -{ - if ( FindArg( argc, argv, "-broadcast", "1" ) ) - g_bBroadcast = true; - - if ( g_bBroadcast == false ) - { - const char *pRemoteIPStr = FindArg( argc, argv, "-machine", NULL ); - if ( !pRemoteIPStr || !ConvertStringToIPAddr( pRemoteIPStr, &remoteIP ) ) - { - printf( "%s is not a valid machine name or IP address.\n", pRemoteIPStr ); - return PrintUsage(); - } - } - - iPriority = 0; - const char *pPriorityStr = FindArg( argc, argv, "-priority", NULL ); - if ( pPriorityStr ) - iPriority = atoi( pPriorityStr ); - - if ( iPriority < 0 || iPriority > 1000 ) - { - printf( "%s is not a valid priority.\n", pPriorityStr ); - return PrintUsage(); - } - - const char *pCommand = FindArg( argc, argv, "-command", NULL ); - if ( !pCommand ) - { - return PrintUsage(); - } - for ( iFirstArg=1; iFirstArg < argc; iFirstArg++ ) - { - if ( argv[iFirstArg] == pCommand ) - break; - } - - return 0; -} - - -void SendJobRequest( - ISocket *pSocket, - int argc, - char **argv, - CIPAddr &remoteIP, - int &iPriority, - int &iFirstArg, - int jobID[4] ) -{ - // Build the packet to send out the job. - char packetData[4096]; - bf_write packetBuf; - - // Come up with a unique job ID. - jobID[0] = GetCurMicrosecondsAndSleep( 1 ); - jobID[1] = GetCurMicrosecondsAndSleep( 1 ); - jobID[2] = GetCurMicrosecondsAndSleep( 1 ); - jobID[3] = GetCurMicrosecondsAndSleep( 1 ); - - - // Broadcast out to tell all the machines we want workers. - packetBuf.StartWriting( packetData, sizeof( packetData ) ); - packetBuf.WriteByte( VMPI_PROTOCOL_VERSION ); - - const char *pPassword = FindArg( argc, argv, "-mpi_pw", "" ); - packetBuf.WriteString( pPassword ); - - packetBuf.WriteByte( VMPI_LOOKING_FOR_WORKERS ); - - packetBuf.WriteShort( 0 ); // Tell the port that we're listening on. - // In this case, there is no VMPI master waiting for the app to connect, so - // this parameter doesn't matter. - packetBuf.WriteShort( iPriority ); - - packetBuf.WriteLong( jobID[0] ); - packetBuf.WriteLong( jobID[1] ); - packetBuf.WriteLong( jobID[2] ); - packetBuf.WriteLong( jobID[3] ); - packetBuf.WriteWord( argc-iFirstArg ); // 1 command line argument.. - - // Write the alternate exe name. - for ( int iArg=iFirstArg; iArg < argc; iArg++ ) - packetBuf.WriteString( argv[iArg] ); - - for ( int iBroadcastPort=VMPI_SERVICE_PORT; iBroadcastPort <= VMPI_LAST_SERVICE_PORT; iBroadcastPort++ ) - { - remoteIP.port = iBroadcastPort; - - if ( g_bBroadcast == false ) - pSocket->SendTo( &remoteIP, packetBuf.GetBasePointer(), packetBuf.GetNumBytesWritten() ); - else - pSocket->Broadcast( packetBuf.GetBasePointer(), packetBuf.GetNumBytesWritten(), iBroadcastPort ); - } - - if ( g_bBroadcast == false ) - printf( "Sent command, waiting for reply...\n" ); - else - printf( "Sent command\n" ); -} - - -bool WaitForJobStart( ISocket *pSocket, const CIPAddr &remoteIP, const int jobID[4] ) -{ - while ( 1 ) - { - CIPAddr senderAddr; - char data[4096]; - int len = -1; - - if ( g_bBroadcast == false ) - pSocket->RecvFrom( data, sizeof( data ), &senderAddr ); - else - pSocket->RecvFrom( data, sizeof( data ), NULL ); - - if ( len == 19 && - memcmp( senderAddr.ip, remoteIP.ip, sizeof( senderAddr.ip ) ) == 0 && - data[1] == VMPI_NOTIFY_START_STATUS && - memcmp( &data[2], jobID, 16 ) == 0 ) - { - if ( data[18] == 0 ) - { - // Wasn't able to run. - printf( "Wasn't able to run on target machine.\n" ); - return false; - } - else - { - // Ok, the process is running now. - printf( "Process running, waiting for completion...\n" ); - return true; - } - } - - Sleep( 100 ); - } -} - - -void WaitForJobEnd( ISocket *pSocket, const CIPAddr &remoteIP, const int jobID[4] ) -{ - while ( 1 ) - { - CIPAddr senderAddr; - char data[4096]; - int len = pSocket->RecvFrom( data, sizeof( data ), &senderAddr ); - if ( len == 18 && - memcmp( senderAddr.ip, remoteIP.ip, sizeof( senderAddr.ip ) ) == 0 && - data[1] == VMPI_NOTIFY_END_STATUS && - memcmp( &data[2], jobID, 16 ) == 0 ) - { - int ret = *((int*)&data[2]); - printf( "Finished [%d].\n", ret ); - break; - } - - Sleep( 100 ); - } -} - - -int main(int argc, char* argv[]) -{ - if ( argc < 4 ) - { - return PrintUsage(); - } - - - // Parse the command line. - CIPAddr remoteIP; - int iFirstArg, iPriority; - int jobID[4]; - - int ret = ParseArgs( argc, argv, remoteIP, iPriority, iFirstArg ); - if ( ret != 0 ) - return ret; - - // Now send the command to the vmpi service on that machine. - ISocket *pSocket = CreateIPSocket(); - if ( !pSocket->BindToAny( 0 ) ) - { - printf( "Error binding a socket.\n" ); - return 1; - } - - SendJobRequest( pSocket, argc, argv, remoteIP, iPriority, iFirstArg, jobID ); - - // Wait for a reply, positive or negative. - if ( g_bBroadcast == false ) - { - if ( !WaitForJobStart( pSocket, remoteIP, jobID ) ) - return 2; - - WaitForJobEnd( pSocket, remoteIP, jobID ); - } - - pSocket->Release(); - return 0; -} - diff --git a/src/utils/vmpi/testapps/vmpi_ping/StdAfx.cpp b/src/utils/vmpi/testapps/vmpi_ping/StdAfx.cpp deleted file mode 100644 index 94441ca173..0000000000 --- a/src/utils/vmpi/testapps/vmpi_ping/StdAfx.cpp +++ /dev/null @@ -1,15 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.cpp : source file that includes just the standard includes -// vmpi_ping.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/utils/vmpi/testapps/vmpi_ping/StdAfx.h b/src/utils/vmpi/testapps/vmpi_ping/StdAfx.h deleted file mode 100644 index 1339f3d0c7..0000000000 --- a/src/utils/vmpi/testapps/vmpi_ping/StdAfx.h +++ /dev/null @@ -1,30 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__04B9E767_FE9B_4F2A_84A3_D6B85737214E__INCLUDED_) -#define AFX_STDAFX_H__04B9E767_FE9B_4F2A_84A3_D6B85737214E__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__04B9E767_FE9B_4F2A_84A3_D6B85737214E__INCLUDED_) diff --git a/src/utils/vmpi/testapps/vmpi_ping/vmpi_ping.cpp b/src/utils/vmpi/testapps/vmpi_ping/vmpi_ping.cpp deleted file mode 100644 index 17ddd8e1c9..0000000000 --- a/src/utils/vmpi/testapps/vmpi_ping/vmpi_ping.cpp +++ /dev/null @@ -1,196 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -// $NoKeywords: $ -// -//=============================================================================// -// vmpi_ping.cpp : Defines the entry point for the console application. -// - -#include "stdafx.h" -#include "iphelpers.h" -#include "vmpi.h" -#include "tier0/platform.h" -#include "bitbuf.h" -#include -#include - - -const char* FindArg( int argc, char **argv, const char *pName, const char *pDefault = "" ) -{ - for ( int i=0; i < argc; i++ ) - { - if ( stricmp( argv[i], pName ) == 0 ) - { - if ( (i+1) < argc ) - return argv[i+1]; - else - return pDefault; - } - } - return NULL; -} - - -int main(int argc, char* argv[]) -{ - CUtlVector addrs; - - printf( "\n" ); - printf( "vmpi_ping