106 Commits

Author SHA1 Message Date
Kawe Mazidjatari
28cc532e9c ReVPK: add option for num helper threads and compress levels
Allow the user to set the # amount of helper threads and the compress level of the VPK's.
2024-04-05 17:46:53 +02:00
Kawe Mazidjatari
2b0837fa93 VpkLib: allow directory recursion
This is offline tools code, no security risks here.
2024-04-05 17:46:53 +02:00
Kawe Mazidjatari
9b3dd97792 VpkLib: rename CPackedStore to CPackedStoreBuilder
Avoid confusion with the game's CPackedStore class.
2024-04-05 17:46:52 +02:00
Kawe Mazidjatari
6841f5bb19 VpkLib: cleanup packed store class
Make the utility methods statics within the implementation so it could be used by other structs/classes of the VPK builder as well, these utility functions weren't useful outside the class. This also allowed for the removal of the singleton which had no purpose whatsoever.
2024-04-05 17:46:52 +02:00
Kawe Mazidjatari
ee82d5d8e0 Tier1: move KeyValues class to Tier1
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
2024-04-05 17:42:05 +02:00
Amos
0634261c18 Move global language constants to single file
Deduplicate.
2023-09-15 18:25:31 +02:00
Kawe Mazidjatari
4b7ca6b439 Use size types
Make code more portable and modern.
2023-08-29 22:05:20 +02:00
Kawe Mazidjatari
71b0781715 Utilize 'DevMsg()' for uncertain builds only
Only uncertain builds will contain DevMsg()/DevWarning() prints. For retail, Msg() and Warning() should be used instead.
2023-08-21 19:12:29 +02:00
Kawe Mazidjatari
5f64cd83d8 Fix FileSystem size integer truncation
The implementation in the engine always took/returned signed 64bit size types, but I made a mistake when reversing the virtual function table. All types have been changed to what they should be (mostly signed 64bit, very few unsigned), and usage in-SDK has been adjusted accordingly.
2023-08-09 14:43:54 +02:00
Kawe Mazidjatari
9e50266649 Update format specifier
Use %lu.
2023-07-22 14:42:44 +02:00
Kawe Mazidjatari
ac6becffd8 Adjust types and format specifiers
Make it more correct.
2023-07-15 16:25:35 +02:00
Kawe Mazidjatari
cb2850f938 Update packedstore.cpp 2023-07-10 01:38:29 +02:00
Kawe Mazidjatari
2565ff44ef Light VPK code optimizations
Cache string buffer ptr.
2023-07-08 02:18:18 +02:00
Kawe Mazidjatari
c215fcc171 VPK utility code improvements
- Only process referenced pack files, previously, if an entry in the VPK file was build into a pack of index 128, the code would generate a list of pack files from 0 to 128.
- Added documentation to VPK structure.
2023-07-06 00:49:17 +02:00
Kawe Mazidjatari
5939e05331 Fix incorrect VPK tree during build
This commit fixes the following bugs:
- Use of STL map on CUtlString, CUtlString does not have a lesser operator, thus it always fails to check whether or not the string is already present in the map. The tree structure cannot contain duplicates per tree scope.
- Use of backward slashes in vpk file tree structure, path separators should always be a forwards slash. The code was originally designed to be forwards slash only, but some paths were adjusted to take backwards slash, as the KeyValues class treats the '/' char as a delimiter for subfields. This has therefore lead into the whole code changing to it. The code has now been changed to the point where only the KeyValues utilities take the backward slash paths.
- Trailing slash character on file path, that ended up getting written as-is in the path tree.

The VPK tree builder is now part of a separate nested class in 'VPKDir_t'.
2023-07-05 23:04:07 +02:00
Kawe Mazidjatari
c6e75967bf CPackedStore: light code cleanup
Light code cleanup: use references instead of pointers as much as possible, additional use of const qualifiers, and usage of provided iteration macros for CUtlVector.
2023-07-04 22:08:44 +02:00
Kawe Mazidjatari
eed83f8815 Always make sure a slash gets appended to the filepath
On the game's filesystem, the slash always appeared, when running this code on a reimplemented filesystem, no slash was found at the end of the path. This change ensures there is always a slash.
2023-07-04 21:39:31 +02:00
Kawe Mazidjatari
56da0576a6 Make static to source file
Should be made static to avoid unwanted bloat in compiled output, as each translation unit will create a new initializer/destructor. -10KiB compiled code for GameSDK.
2023-07-03 02:27:09 +02:00
Kawe Mazidjatari
ef69611435 Replace memalloc calls throughout entire SDK
Global 'direct' usage of 'MemAllocSingleton()' has been jettisoned. Where possible, smart pointers were used instead. During the refactor, the following bugs were addressed and fixed:
- The virtual destructor of 'CCVarIteratorInternal' was NOT called on destruction.
- Class function 'KeyValues::MakeCopy' did NOT calculate the buffer size of the wide string correctly, the original calculation was 'len+1*sizeof(wchar_t)', but should've been '(len+1)*sizeof(wchar_t)'.

Some other code changes include:
- Tier0 include 'memstd.h' has been moved above all thirdparty includes, to make sure the memalloc functions get shadowed with ours in third party libraries as well.
- RPak file paths string literals are now defines.
- 'DestroyOverlay' has been refactored to match the assembly of the game.
2023-06-26 22:34:24 +02:00
Kawe Mazidjatari
d77dbdafb9 Remove extraneous subtraction from array size constant
The subtraction is not needed.
2023-06-01 00:08:22 +02:00
Kawe Mazidjatari
abef34d3ef CPackedStore refactor
* Improve naming convention, and make it more consistent.
* Use engine types as much as possible.
* Reduced the amount of string copy constructions.
2023-05-29 21:41:17 +02:00
Kawe Mazidjatari
0fe6af008c Fix data truncation on VPK unpack
If the chunk if uncompressed, continue the loop instead of breaking out of it. Only 2 files were affected by this bug from original VPK's: 'notosansjp-regular.vfont' and 'notosanstc-regular.vfont'.
2023-05-29 15:56:59 +02:00
Kawe Mazidjatari
69775ca234 CPackedStore: Improve symbol naming 2023-04-05 20:09:23 +02:00
Kawe Mazidjatari
697d11cccb Improve VPKPair_t constructor
* Take string object by const reference.
* Emit warnings when locale or target specified by user isn't supported.
2023-04-04 00:41:53 +02:00
Kawe Mazidjatari
6da5206282 CPackedStore: Fix file handle bug
VPK directory file handle was never closed properly in 'VPKDir_t::Init()';
2023-04-03 22:48:29 +02:00
Kawe Mazidjatari
1f1a487af9 CPackedStore: Fix bug and improve code readability
Moved deduplication code to a separate function. Unnested packing and unpacking code a bit more.
2023-04-03 22:46:10 +02:00
Kawe Mazidjatari
081c548bdd Remove unnecessary member from 'VPKChunkDescriptor_t' 2023-04-03 21:16:15 +02:00
Kawe Mazidjatari
dc0fba9319 CPackedStore: Rename 'useDataSharing' to 'deDuplicate'
More descriptive in what it does (deduplication of existing copies).
2023-04-03 20:08:36 +02:00
Kawe Mazidjatari
b5bd4296e9 CPackedStore: Dynamically allocate source/destination buffers
This allows for multithreading the VPK build process.
2023-04-03 20:02:56 +02:00
Kawe Mazidjatari
475262fc24 Use C-style format specifiers in CPakFile
Enforce consistency within codebase.
2023-04-03 19:12:15 +02:00
Kawe Mazidjatari
417365fa77 /W4: Fix type truncation warnings 2023-04-02 17:39:16 +02:00
Kawe Mazidjatari
e1f0e72af4 /W4: Fix type demotion warnings
Explicitly demote to 'int' to suppress pesky compiler warnings.
2023-04-02 16:03:01 +02:00
Kawe Mazidjatari
cdb03a5d97 Use standalone filesystem functions instead
The member variants do not exist in experimental filesystem implementations.
2023-03-20 00:19:17 +01:00
Kawe Mazidjatari
5806f719c6 Should be u8string 2023-02-12 23:32:58 +01:00
Kawe Mazidjatari
4d68a2edbe Fix deadlock when file entry is truncated
* Fixed endless loop when condition is hit.
* Fixed file name not being formatted correctly.
2023-02-12 23:28:24 +01:00
Kawe Mazidjatari
60ab35b5c4 Light optimizations for string utils
* Changed 'CreateDirectories' to only copy sanitized path if pointer to string is passed.
* Changed 'IsValidBase64' to only tokenize base64 value if pointer to string is passed.
2023-02-04 15:59:45 +01:00
Kawe Mazidjatari
c49209bd1e Log truncated files if they are listed in the VPK build manifest 2023-01-26 03:00:53 +01:00
Kawe Mazidjatari
29b0bc389e Light CPackedStore cleanup 2022-12-04 14:17:14 +01:00
Kawe Mazidjatari
55b90781ee Remove experimental CRC implementation in LZHAM
This implementation was done to calculate buffer CRC on the go, as that was what the VPK file system uses for the file crc's. But it later turned out to be unnecessary, and was never reverted.
2022-12-04 01:33:10 +01:00
Kawe Mazidjatari
b8b79385e1 Open ignore file in text mode 2022-11-24 11:48:23 +01:00
Kawe Mazidjatari
368c4218b4 Move some CPackedStore methods to VPKDir_t
These methods where only used for and by the VPKDir_t structure.
Also renamed variable and method names to reflect new changes regarding the use of KeyValues by creating a structure with all values defined during file lookup rather than doing this during the pack process.
2022-11-23 17:09:48 +01:00
Kawe Mazidjatari
2e9aa9a77c Avoid string copy in 'VPKEntryBlock_t::VPKEntryBlock_t'
Avoid a copy when formatting string to that of the VPK directory tree structure.
2022-11-23 14:49:40 +01:00
Kawe Mazidjatari
2bc570800b Split 'VPKDir_t::Build' into multiple methods
Each process of writing out a VPK directory is now within its own method.
2022-11-23 12:27:57 +01:00
Kawe Mazidjatari
0ab31606eb CPackedStore refactor
The CPackedStore class now heavily relies on the engine's FileSystem and KeyValues API. Since its part of the engine, it would make more sense to utilize the engine's features instead. It also allows for easier modifications.
* The logic behind the build process hasn't changed.
2022-11-23 12:18:33 +01:00
Kawe Mazidjatari
8c7b58b9df Add convar for adjusting LZHAM compressor max helper threads 2022-11-17 20:37:12 +01:00
Kawe Mazidjatari
34d8ea578a Improve consistency throughout packedstore class
No modifications to the existing logic have been performed. Some parameter names have been renamed to improve code readability and maintainability.
2022-11-16 00:54:51 +01:00
Kawe Mazidjatari
f16d538aee CPackedStore: light optimizations
* Don't call copy constructor on entry blocks when building the directory file.
* Don't call copy constructor for string when we don't want to sanitize the directory file name.
2022-10-12 23:39:26 +02:00
Amos
780b968bc7 CPackedStore::GetDirectoryFile optimizations
Break when we have a locale, or found the context.
Removed extraneous logic/vars.
2022-10-11 16:31:00 +02:00
Amos
142c0d1de5 CPackedStore: fix directory file name sanitizer
The sanitizer can retrieve the directory file name from the block file name if this is passed instead. This was broken in the previous system. Sanitization can be opted out if the 3rd parameter of the 'fs_vpk_unpack' command is omitted.
2022-10-11 15:37:34 +02:00
Kawe Mazidjatari
99a33e95f1 Additional VPK lib cleanup and performance improvements 2022-10-09 12:08:54 +02:00