3404 Commits

Author SHA1 Message Date
Kawe Mazidjatari
5c0e7a944f Utility: fix bug in CreateDirHierarchy
Fix bug where even the last path would be processed in the loop, making the return call always return an error as the path would've been created by that time. This ensures that we always return the value returned by mkdir when creating the last path
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
7a09219002 FileSystem: make CreateDirHierarchy and IsDirectory general function
Moved to general utility
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
26ce3c50c2 RTech: cleanup ZStd pak decoder and fix bugs
* Pak_InitDecoder() now takes the output buf and mask as parameters.
* Pak_InitDecoder() checks if provided masks are a power of 2 (required).
* Pak_ComputeRingBufferFrame() now uses the bit mask instead of modulo to determine # bytes used.
* Fixed a bug where PakDecoder_t::bufferSizeNeeded could be bigger than the file stream, causing a deadlock.
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
86f9dbe30f RTech: move ZStd free code to actual decoder
Let the decoder free it to avoid memory leaks
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
b81beecdf1 RTech: add info about small pak file's ring buffers 2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
9b9562c8d9 RTech: properly implement ring buffer stream decode for Zstd decoder
The new decoder can now decode patched and custom rpaks files, all issues so far have been fixed. The code still needs some testing and bench marking to make sure
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
e2898802e8 RTech: properly deal with patch headers when encoding pak files
Patch header must be updated to accommodate the new pak file sizes the patch pak patches.
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
7f25ce7e42 Tier0: add overload for reading pointer data and fix write overload
Write should've been a pointer instead.
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
b65d74e8c7 RTech: add helpers for parsing patch header data
Should significantly reduce noise in code
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
b707fba198 ZStd: fix typo in CMakeLists
Incorrect filter name
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
005453a606 ZStd: suppress thirdparty code warnings 2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
f61e2e1201 RTech: use define for invalid async file handle 2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
31e9042eee RTech: add simple pak encoder command
Encodes a pak file with ZSTD.
2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
1e949056ac RTech: remove temp debugging code 2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
095f41bbe2 RTech: fix bug in decompress error format
Must not include pak header size since we parse compressed frame header and determine actual frame size from there, else we get 2 equal number that somehow don't equal (Pak_InitDecoder returns frame size + pak header size)
2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
4803afe6d9 RTech: initial custom pak compression implementation
Allows paks compressed with ZSTD, to be stream decoded at run time. Currently seems to work pretty good, but needs to be further battle tested + cleaned up still.
2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
45e95039e8 Add ZSTD to SDK 2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
39d16fa4d7 NetworkSystem: rename NetGameServer_t member vars 2024-01-29 23:00:15 +01:00
Kawe Mazidjatari
1410ecd79c MaterialSystem: rename CMaterialGlue member vars 2024-01-29 23:00:15 +01:00
Kawe Mazidjatari
8911bfa81a GameUI: cleanup and fix race condition
* Use CThreadFastMutex instead
* Rename ISurface to IDebugSurface to prevent a potential name collision with VGUI's ISurface iface if we ever add it
* Fix race condition when setting CPylon::m_HostIP from materialsystem thread, this has been dispatched to the main thread
* Marked 'pylon_matchmaking_hostname' FCVAR_MATERIAL_SYSTEM_THREAD as we use it in the server browser panel.
2024-01-21 23:06:26 +01:00
Kawe Mazidjatari
f6e6e7c30b Engine: fix out of bound access
Even though this is handles by the class, it really shouldn't happen.
2024-01-21 21:53:48 +01:00
Kawe Mazidjatari
1361bfb172 Make singletons use static memory
Avoid heap memory allocation and a level of indirection. This allows the compiler to optimize the program even more. No logic has been changed in this patch.
2024-01-21 21:29:23 +01:00
Kawe Mazidjatari
c9b80a70cd Playlists: fix resource/memory leak
Remove workaround that was implemented to counter a crash during the beginning of this project, this issue was long solved but the workaround was never removed. Clearing the last precached VPK name prevents the engine from helping other threads to properly unload existing handles, if at all.
2024-01-21 20:24:44 +01:00
Kawe Mazidjatari
c9a9b01bf2 RTech: major pak system overhaul and rebuild
* split rtech_game and rtech_utils cpp files into multiple files
* rebuilt several large pak load routines for debugging and custom implementations
* moved rson code to rtech_game
* reworked and improved engine and sdk pak precache system
* reversed more of the jobthreads system
2024-01-21 20:23:25 +01:00
Kawe Mazidjatari
1c4419cc6d CMake: improve linker performance
Improve linker performance by either enabling GL and LTGC on certain projects at the same time, enabling it for all projects, or disabling it all together
2024-01-21 20:12:50 +01:00
Kawe Mazidjatari
f8107622ff Tier1: map out CCvar completely and get the ptr to the actual class instance
Previously we had a ptr to just its vtable; get the ptr to the actual class instance.
2024-01-21 17:34:22 +01:00
Kawe Mazidjatari
184365f135 Tier0: initialize CThreadFastMutex member vars
Must be null
2024-01-16 21:22:28 +01:00
Kawe Mazidjatari
8ce0412405 Tier0: cleanup CThreadFastMutex 2024-01-16 21:21:08 +01:00
Kawe Mazidjatari
65cdc0c75b Tier0: fix CThreadFastMutex bug
Must break if ThreadInterlockedCompareExchange returns null.
2024-01-16 20:57:28 +01:00
Kawe Mazidjatari
33e42b3374 MaterialSystem: fix stream debug formatting bug
Promote to actual 64bit signed size types.
2024-01-15 10:38:35 +01:00
Kawe Mazidjatari
5882debcc4 Tier1: add assert in CCommand::Arg()
This code path shouldn't be hit.
2024-01-14 22:57:52 +01:00
Kawe Mazidjatari
d8417ca455 ReVPK: improve logger name formatting 2024-01-14 22:57:04 +01:00
Kawe Mazidjatari
1f2d4462d3 VpkLib: fix bug when parsing directory tree base name
After the regex update in commit 5266a2e9, this function had to be updated as well since the underscore is no longer returned.
2024-01-14 22:56:52 +01:00
Kawe Mazidjatari
e51dfccc16 VpkLib: simplify tree header writer
Make sure the VPK header is always initialized to 0 instead of actual values, as otherwise it would cause the reader to succeed on truncated files if at least the first byte matches that of the VPK magic. This also lead to the simplification of the tree header writer; instead of writing the tree size apart from the header, write the whole thing at once.
2024-01-14 13:34:11 +01:00
Kawe Mazidjatari
884e1c5014 Netconsole: don't process empty input strings
Caught by assert in CUtlBuffer ctor when tokenizing the input.
2024-01-14 11:48:42 +01:00
Kawe Mazidjatari
1b0cc4d188 Netconsole: refactor & improvements
* Fix multiple issues related to threading, such as not locking the mutex when using thread-unsafe members or methods.
* Netconsole now logs its output to a file on the disk.
* Properly handle close events, to allow netconsole to shutdown properly, so stuff like log buffers could flush properly. Input is now ran in a separate thread so main thread could check if we need to shutdown, and do so if needed. This was needed as previously input was ran in the main thread and the issue is that its blocking until an input is given.
2024-01-14 11:31:16 +01:00
Kawe Mazidjatari
0d1104bc0e System: handle other close events as well
Give the engine and SDK time to shutdown properly.
2024-01-14 11:25:50 +01:00
Kawe Mazidjatari
a809816f70 SpdLog: flush the tools logger
Must manually kill the pointer on shutdown to flush it since this one is allocated by us and thus not managed by SpdLog.
2024-01-14 11:24:42 +01:00
Kawe Mazidjatari
3fa0f25616 SpdLog: add truncate option for tools file logger, and default it on
By default spdlog will append on top of existing logs, but for ReVPK we want to truncate the old ones and start over again.
2024-01-14 02:14:22 +01:00
Kawe Mazidjatari
ecfb1fe2bf SpdLog: fix warning for tools code
Static linkage and not used for tools; idfed'd out.
2024-01-14 02:07:31 +01:00
Kawe Mazidjatari
f48bdbfa82 Engine: fix compiler warning caused by empty control statement
Remove trailing ';', else this branch wouldn't even be compiled in.
2024-01-14 02:03:27 +01:00
Kawe Mazidjatari
2a4516f3cb SpdLog: fix compile error caused by undeclared function
SpdLog_Create() is no longer externed through its header as its a static internal function. Moved SpdLog_Create() above SpdLog_Init() to fix the compile error and rename it to SpdLog_CreateRotatingLoggers(), which is a more suitable name.
2024-01-14 02:01:42 +01:00
Kawe Mazidjatari
f49fbffa9a Sync ReVPK fixes to packedstore concommand
* Check if workspace directory exists.
* Check if VPK directory tree file was successfully parsed.
2024-01-14 01:51:17 +01:00
Kawe Mazidjatari
5266a2e9de ReVPK: bug fixes & improvements
* Make sure the workspace path actually exists before attempting to pack it.
* Make sure the VPK directory tree file was parsed correctly before unpacking store.
* Log debug output for each pack operation to a file.
* Fix bug in s_DirFileRegex regex pattern, which would include a trailing '_' in the context part of the directory tree file name.
* Fix bug in 'GetLevelName()' and 'GetDirNameParts()' causing it to parse the path as well, prune the path before running the regex.
* Renamed 'GetLevelName()' to 'PackedStore_GetDirLevelName()'.
* Renamed 'GetDirNameParts()' to 'PackedStore_GetDirNameParts()'.
* Write a front-end enable file when building client VPK's.
2024-01-14 01:39:11 +01:00
Kawe Mazidjatari
65a80914ec VpkLib: move header check to dir construction and flag error on failure
Moved the construction as otherwise we would iterate over potentially bad or incompatible data.
2024-01-14 00:43:15 +01:00
Kawe Mazidjatari
b1199efc64 VpkLib: add comments to name sanitizer
Make it clear what it does.
2024-01-14 00:18:30 +01:00
Kawe Mazidjatari
0dc4b1d697 VpkLib: fix bug in dir tree file name sanitizer
The sanitizer never worked as we never replaced the corresponding string.
2024-01-13 23:58:31 +01:00
Kawe Mazidjatari
11fd516b50 VpkLib: fix bug in GetManifest()
Check if the parsing was actually successful, else free and return nullptr. The null check at call site never worked since we never return null on failure.
2024-01-13 23:56:47 +01:00
Kawe Mazidjatari
069daff4f0 VpkLib: check for manifest file first before opening the pack file
We do this as if we happen to not have any manifest whatsoever, but already opened the block file, and the block file already existed and was still valid, it would be emptied out. Only open it if we are actually going to write into it!
2024-01-13 23:55:01 +01:00
Kawe Mazidjatari
8eb2561fcf FileSystem: implement IsDirectory in STD implementation 2024-01-13 19:38:06 +01:00