3222 Commits

Author SHA1 Message Date
Kawe Mazidjatari
f5a8ca3e7a RTech: fix numeric overflow caused by massive pak files
Pak files above 4GB caused the async file system to throw an error about failing to load audio banks, removed casts and promoted everything correctly. Also removed irrelevant comments in the public pakfile header.
2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
4d74dc5052 RTech: fix bug when trying to print fourcc as string
The printf specifier does not allow limiting buffer reads. Made the FourCCToString more performant by using a fixed size stack array and creating the fourcc into that which we now use to properly print out the asset magic.
2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
082a8e4ef7 RTech: minor cleanup and renaming 2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
2322e3a9be Tier1: remove parameter description that doesn't exist 2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
05b51fbd8c RTech: update comment on pak header flag
Patches can actually use different compression algorithms, but the patch headers must accommodate for pak file sizes properly. One pak could also be compressed while the others aren't if patch headers present correct sizes (both RTech and ZStream)
2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
3b9626612f RTech: add buffered decompress function, cleanup and bug fixes
The pak_decompress callback has been fully moved to a dedicated buffered pak decoder function, also added descriptive error to the buffered pak encode function. Fixed a bug in the streamed pak decoder where the next required streamed buffer size would always be below actually required on any subsequent patch rpaks that are getting loaded. Also fixed assert in Pak_ZStreamDecode, as the inbuf position can equal total streamed size, but shall never exceed it!
2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
c7471dc472 RTech: add several new pak tools
Added tools to reduce noise in pak code in a planned refactor
2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
3eb3c27975 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-04-05 17:56:48 +02:00
Kawe Mazidjatari
22431e903c FileSystem: make CreateDirHierarchy and IsDirectory general function
Moved to general utility
2024-04-05 17:56:48 +02:00
Kawe Mazidjatari
1c2b02b972 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-04-05 17:56:48 +02:00
Kawe Mazidjatari
5ea886ab65 RTech: move ZStd free code to actual decoder
Let the decoder free it to avoid memory leaks
2024-04-05 17:56:48 +02:00
Kawe Mazidjatari
2d6533adf1 RTech: add info about small pak file's ring buffers 2024-04-05 17:56:48 +02:00
Kawe Mazidjatari
e1c889719a 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-04-05 17:56:48 +02:00
Kawe Mazidjatari
e90349cc0f 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-04-05 17:56:48 +02:00
Kawe Mazidjatari
10af9ac695 Tier0: add overload for reading pointer data and fix write overload
Write should've been a pointer instead.
2024-04-05 17:56:48 +02:00
Kawe Mazidjatari
a529a16822 RTech: add helpers for parsing patch header data
Should significantly reduce noise in code
2024-04-05 17:56:48 +02:00
Kawe Mazidjatari
cbae59a158 ZStd: fix typo in CMakeLists
Incorrect filter name
2024-04-05 17:56:47 +02:00
Kawe Mazidjatari
a9ed0762e1 ZStd: suppress thirdparty code warnings 2024-04-05 17:56:47 +02:00
Kawe Mazidjatari
f16bf580f4 RTech: use define for invalid async file handle 2024-04-05 17:56:47 +02:00
Kawe Mazidjatari
7a03238fc9 RTech: add simple pak encoder command
Encodes a pak file with ZSTD.
2024-04-05 17:54:06 +02:00
Kawe Mazidjatari
3020abeed7 RTech: remove temp debugging code 2024-04-05 17:54:06 +02:00
Kawe Mazidjatari
da0ecd8ae1 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-04-05 17:54:06 +02:00
Kawe Mazidjatari
c4691448c1 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-04-05 17:54:05 +02:00
Kawe Mazidjatari
2b06bc8abb Add ZSTD to SDK 2024-04-05 17:53:22 +02:00
Kawe Mazidjatari
dbec4be848 NetworkSystem: rename NetGameServer_t member vars 2024-04-05 17:52:58 +02:00
Kawe Mazidjatari
746cf16f2b MaterialSystem: rename CMaterialGlue member vars 2024-04-05 17:52:57 +02:00
Kawe Mazidjatari
e8be704276 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-04-05 17:52:57 +02:00
Kawe Mazidjatari
4042cb7915 Engine: fix out of bound access
Even though this is handles by the class, it really shouldn't happen.
2024-04-05 17:52:57 +02:00
Kawe Mazidjatari
fcf3a09418 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-04-05 17:52:57 +02:00
Kawe Mazidjatari
4662995f2e 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-04-05 17:52:57 +02:00
Kawe Mazidjatari
fe2a95e4ec 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-04-05 17:51:19 +02:00
Kawe Mazidjatari
1783db92b5 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-04-05 17:46:57 +02:00
Kawe Mazidjatari
6766f5be62 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-04-05 17:46:56 +02:00
Kawe Mazidjatari
3c74070285 Tier0: initialize CThreadFastMutex member vars
Must be null
2024-04-05 17:46:56 +02:00
Kawe Mazidjatari
50761d24a8 Tier0: cleanup CThreadFastMutex 2024-04-05 17:46:56 +02:00
Kawe Mazidjatari
177078813b Tier0: fix CThreadFastMutex bug
Must break if ThreadInterlockedCompareExchange returns null.
2024-04-05 17:46:56 +02:00
Kawe Mazidjatari
8d7ebeea26 MaterialSystem: fix stream debug formatting bug
Promote to actual 64bit signed size types.
2024-04-05 17:46:56 +02:00
Kawe Mazidjatari
8e0e42cdab Tier1: add assert in CCommand::Arg()
This code path shouldn't be hit.
2024-04-05 17:46:56 +02:00
Kawe Mazidjatari
d7e1b88569 ReVPK: improve logger name formatting 2024-04-05 17:46:56 +02:00
Kawe Mazidjatari
a1ba022fef 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-04-05 17:46:56 +02:00
Kawe Mazidjatari
5f09f1434c 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-04-05 17:46:55 +02:00
Kawe Mazidjatari
cb8f0902a4 Netconsole: don't process empty input strings
Caught by assert in CUtlBuffer ctor when tokenizing the input.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
3c10bf0e8d 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-04-05 17:46:55 +02:00
Kawe Mazidjatari
43d771e3cd System: handle other close events as well
Give the engine and SDK time to shutdown properly.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
974a5b2c24 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-04-05 17:46:55 +02:00
Kawe Mazidjatari
cdcd7b8272 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-04-05 17:46:55 +02:00
Kawe Mazidjatari
19e67499e6 SpdLog: fix warning for tools code
Static linkage and not used for tools; idfed'd out.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
22bb9eef4f Engine: fix compiler warning caused by empty control statement
Remove trailing ';', else this branch wouldn't even be compiled in.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
92323b7ba7 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-04-05 17:46:54 +02:00
Kawe Mazidjatari
21758f5c9c Sync ReVPK fixes to packedstore concommand
* Check if workspace directory exists.
* Check if VPK directory tree file was successfully parsed.
2024-04-05 17:46:54 +02:00