summaryrefslogtreecommitdiff
path: root/utils/bsppack
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/bsppack
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/bsppack')
-rw-r--r--utils/bsppack/bsppack.cpp112
-rw-r--r--utils/bsppack/bsppack.vpc57
-rw-r--r--utils/bsppack/xbox/xbox.def3
3 files changed, 172 insertions, 0 deletions
diff --git a/utils/bsppack/bsppack.cpp b/utils/bsppack/bsppack.cpp
new file mode 100644
index 0000000..973d40a
--- /dev/null
+++ b/utils/bsppack/bsppack.cpp
@@ -0,0 +1,112 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "bsplib.h"
+#include "ibsppack.h"
+#include "cmdlib.h"
+#include "zip_utils.h"
+
+class CBSPPack : public IBSPPack
+{
+public:
+ void LoadBSPFile( IFileSystem *pFileSystem, char *filename );
+ void WriteBSPFile( char *filename );
+ void ClearPackFile( void );
+ void AddFileToPack( const char *relativename, const char *fullpath );
+ void AddBufferToPack( const char *relativename, void *data, int length, bool bTextMode );
+ void SetHDRMode( bool bHDR );
+ bool SwapBSPFile( IFileSystem *pFileSystem, const char *filename, const char *swapFilename, bool bSwapOnLoad, VTFConvertFunc_t pVTFConvertFunc, VHVFixupFunc_t pVHVFixupFunc, CompressFunc_t pCompressFunc );
+ bool RepackBSP( CUtlBuffer &inputBuffer, CUtlBuffer &outputBuffer, eRepackBSPFlags repackFlags );
+ bool GetPakFileLump( IFileSystem *pFileSystem, const char *pBSPFilename, void **pPakData, int *pPakSize );
+ bool SetPakFileLump( IFileSystem *pFileSystem, const char *pBSPFilename, const char *pNewFilename, void *pPakData, int pakSize );
+ bool GetBSPDependants( IFileSystem *pFileSystem, const char *pBSPFilename, CUtlVector< CUtlString > *pList );
+};
+
+void CBSPPack::LoadBSPFile( IFileSystem *pFileSystem, char *filename )
+{
+ MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f );
+
+ // This is shady, but the engine is the only client here and we want the same search paths it has.
+ g_pFileSystem = g_pFullFileSystem = pFileSystem;
+
+ ::LoadBSPFile( filename );
+}
+
+void CBSPPack::WriteBSPFile( char *filename )
+{
+ ::WriteBSPFile( filename );
+}
+
+void CBSPPack::ClearPackFile( void )
+{
+ ::ClearPakFile( GetPakFile() );
+}
+
+void CBSPPack::AddFileToPack( const char *relativename, const char *fullpath )
+{
+ // Compressing at this point would work, but the usual usage is creating a BSP and using RepackBSP() to apply lump
+ // and pack compression as a final pass
+ ::AddFileToPak( GetPakFile(), relativename, fullpath, IZip::eCompressionType_None );
+}
+
+void CBSPPack::AddBufferToPack( const char *relativename, void *data, int length, bool bTextMode )
+{
+ // Compressing at this point would work, but the usual usage is creating a BSP and using RepackBSP() to apply lump
+ // and pack compression as a final pass
+ ::AddBufferToPak( GetPakFile(), relativename, data, length, bTextMode, IZip::eCompressionType_None );
+}
+
+void CBSPPack::SetHDRMode( bool bHDR )
+{
+ ::SetHDRMode( bHDR );
+}
+
+bool CBSPPack::SwapBSPFile(
+IFileSystem *pFileSystem,
+const char *filename,
+const char *swapFilename,
+bool bSwapOnLoad,
+VTFConvertFunc_t pVTFConvertFunc,
+VHVFixupFunc_t pVHVFixupFunc,
+CompressFunc_t pCompressFunc )
+{
+ // This is shady, but the engine is the only client here and we want the same search paths it has.
+ g_pFileSystem = g_pFullFileSystem = pFileSystem;
+
+ return ::SwapBSPFile( filename, swapFilename, bSwapOnLoad, pVTFConvertFunc, pVHVFixupFunc, pCompressFunc );
+}
+
+bool CBSPPack::RepackBSP( CUtlBuffer &inputBuffer, CUtlBuffer &outputBuffer, eRepackBSPFlags repackFlags )
+{
+ return ::RepackBSP( inputBuffer, outputBuffer,
+ ( repackFlags & eRepackBSP_CompressLumps ) ? RepackBSPCallback_LZMA : NULL,
+ ( repackFlags & eRepackBSP_CompressPackfile ) ? IZip::eCompressionType_LZMA : IZip::eCompressionType_None );
+}
+
+bool CBSPPack::GetPakFileLump( IFileSystem *pFileSystem, const char *pBSPFilename, void **pPakData, int *pPakSize )
+{
+ g_pFileSystem = g_pFullFileSystem = pFileSystem;
+
+ return ::GetPakFileLump( pBSPFilename, pPakData, pPakSize );
+}
+
+bool CBSPPack::SetPakFileLump( IFileSystem *pFileSystem, const char *pBSPFilename, const char *pNewFilename, void *pPakData, int pakSize )
+{
+ g_pFileSystem = g_pFullFileSystem = pFileSystem;
+
+ return ::SetPakFileLump( pBSPFilename, pNewFilename, pPakData, pakSize );
+}
+
+bool CBSPPack::GetBSPDependants( IFileSystem *pFileSystem, const char *pBSPFilename, CUtlVector< CUtlString > *pList )
+{
+ g_pFileSystem = g_pFullFileSystem = pFileSystem;
+
+ return ::GetBSPDependants( pBSPFilename, pList );
+}
+
+EXPOSE_SINGLE_INTERFACE( CBSPPack, IBSPPack, IBSPPACK_VERSION_STRING );
+
diff --git a/utils/bsppack/bsppack.vpc b/utils/bsppack/bsppack.vpc
new file mode 100644
index 0000000..602757e
--- /dev/null
+++ b/utils/bsppack/bsppack.vpc
@@ -0,0 +1,57 @@
+//-----------------------------------------------------------------------------
+// BSPPACK.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+
+$include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;BSPPACK_EXPORTS;ZIP_SUPPORT_LZMA_ENCODE"
+ $PreprocessorDefinitions "$BASE;WIN_ERROR;_USRDLL" [$WIN32]
+ $PreprocessorDefinitions "$BASE;WIN_ERROR;_USRDLL;BSP_USE_LESS_MEMORY" [$X360]
+ $AdditionalIncludeDirectories "..\common;$BASE"
+ }
+ $Linker
+ {
+ $SystemLibraries "iconv" [$OSXALL]
+ }
+}
+
+$Project "bsppack"
+{
+ $Folder "Source Files"
+ {
+ $File "..\common\bsplib.cpp"
+ $File "bsppack.cpp"
+ $File "..\common\cmdlib.cpp"
+ $File "$SRCDIR\public\filesystem_helpers.cpp"
+ $File "$SRCDIR\public\filesystem_helpers.h"
+ $File "$SRCDIR\public\filesystem_init.cpp"
+ $File "..\common\filesystem_tools.cpp"
+ $File "..\common\filesystem_tools.h"
+ $File "$SRCDIR\public\lumpfiles.cpp"
+ $File "..\common\scriplib.cpp"
+ $File "$SRCDIR\public\zip_utils.cpp"
+ $File "$SRCDIR\filesystem\linux_support.cpp" [$POSIX]
+ }
+
+ $Folder "Public Header Files"
+ {
+ $File "$SRCDIR\public\ibsppack.h"
+ $File "$SRCDIR\public\bspfile.h"
+ }
+
+ $Folder "Link Libraries"
+ {
+ $Lib mathlib
+ $Lib tier2
+ $Lib "$LIBCOMMON/lzma"
+ }
+}
diff --git a/utils/bsppack/xbox/xbox.def b/utils/bsppack/xbox/xbox.def
new file mode 100644
index 0000000..992cb21
--- /dev/null
+++ b/utils/bsppack/xbox/xbox.def
@@ -0,0 +1,3 @@
+LIBRARY bsppack_360.dll
+EXPORTS
+ CreateInterface @1