3574 Commits

Author SHA1 Message Date
Kawe Mazidjatari
12485342ae Tier1: optimize V_GetFileExtension()
If we are going to do a strlen to do a reverse check, then just check from the start and avoid another loop.
2024-04-05 18:02:39 +02:00
Kawe Mazidjatari
2bed5d4437 Tier1: add CUtlHashTable 2024-04-05 18:01:23 +02:00
Kawe Mazidjatari
a26821759e Engine: fix bug regarding packet compression override
Only encrypt and decrypt packets if the initial argument tells it to do so. Some connectionless packets aren't supposed to be encrypted
2024-04-05 18:01:22 +02:00
Kawe Mazidjatari
d467989e7c Tier1: light cleanup on low level types
CCommand: use 'V_isdigit()' since that is faster, we don't need it to be locale aware.
CMemoryStack: move 'highest' var to string format directly to avoid compile warnings (unused loval variables) on more recent visual studio compilers when compiling the DLL in cert mode.
2024-04-05 18:01:22 +02:00
Kawe Mazidjatari
f18a4c17a4 Engine: rebuild CClientState::ProcessCreateStringTable()
Rebuild CClientState::ProcessCreateStringTable() and add notes for multiple 'potential' exploit vectors that are currently in place. Also add wrappers for compressing/decompressing net packets.
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
ee64d07e5b Tier0: emit text to debug console if debugger is attached
Small quality of life improvement while debugging the application.
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
0d390955fd Engine: partial rebuild for data block sender/receiver
This patch partially rebuilds the data block sender/receiver. The receiver leaks memory if the sender sends a bogus LZ4 packet, it would allocate memory to copy the encoded data into, from which it would decode it to the scratch buffer, but it would never deallocate this temporary buffer is the LZ4 decoder failed. This has been fixed. The second reason to rebuild these was to look into potential compression optimization. The data block rebuild now also features the latest LZ4 codec.
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
c786d86eae Engine: fix netchan bugs and add SendData()
Fixed bug in CNetChan::SendNetMsg() where the return value of INetMessage::WriteToBuffer() was not checked, nor did we return if the stream we added the message in was overflowed. If the function gets to the stage of writing the msg in the buffer, we need to return true only if we didn't overflow AND if the msg was successfully written. Also added a method for sending bitbuf data into stream of choice.
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
8b53027264 Engine: fix bug in networking code caused by incorrect constants
Mixed MAX_BACKUP_COMMANDS with MAX_NEW_COMMANDS, added proper (confirmed) defines. Also fixed MAX_BACKUP_COMMANDS_PROCESS, which was 60 but was supposed to be 64, so we were 4 backup commands short in CPlayer::ProcessUsercmds().
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
b68deadba0 CMake: regroup thirdparty libs in filters 2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
04613822ae Thirdparty: add LZ4 to project
Will be used for data block sender/receiver rebuild
2024-04-05 17:58:51 +02:00
Kawe Mazidjatari
373b18ddb8 Tier1: use signed size types for buffer size field 2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
20dd5783a3 Tier1: use correct format specifier CCountedStringPoolBase 2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
b883cd6807 Tier1: make utlbuffer flags clear
Use 'FLAGS_NONE' as default.
2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
c42ebe2cfc Tier1: use correct index types for template classes
This ensures that we can never allocate more memory than the maximum value that type could hold, without triggering a compile warning. There was a mention about shorts being slow on PowerPC platforms for utllinkedlist, but the index local type could be overridden (defaults to index storage type). In case it gets used for PowerPC, use 32bit ints as index local types; as the local type gets used for arithmetic operations while storage type is what's getting cached off in memory. This patch had no effect on generated output code, it was mostly implemented to avoid future problems.
2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
b27769fdb5 Tier1: use the Max defined in platform headers
This one is the preferred Max as per Valve Source.
2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
1378a5e5f4 Tier1: use SSIZE_MAX for default str slice buf end
Will be INT_MAX on 32bit platform and INT64_MAX on 64bit.
2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
57d5429505 Add signed size type defines 2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
172ac8f313 Tier1: optimize V_UnqualifiedFileName()
If we are going to do a strlen, then check the chars from the start
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
d22800b43b Engine: fix bug causing level assets to not load properly
The level has changed when strcmp returns a non-null value.
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
ab5e009f8b Engine: remove unused variable
No longer used as of commit b29be00d.
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
fe32055f7c Tier1: properly implement UtlString methods
Determine proper stack buf size for ssize_t += operator. If its 64bits then the buf should be doubled to accommodate for the maximum number of digits in a 64bit decimal number. Also properly determine stack buf size of double += operator. For FormatV, instead of a fixed stack buffer, perform a dry run to determine required buflen, reserve num char bytes of memory and write into it again on the next call.
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
b094040c64 Engine: revert server tick msg rebuild to old behavior
Only update statistics, this code was mainly added for testing, but testing revealed no additional performance or smoothness improvements, even during >6 hour sessions. The clock drift already gets corrected each frame from Host_RunFrame(). Only update statistics to update CPU and frame times on the client's debug panels if enabled.
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
a17a2c9feb Recast: remove use of auto
Useless use of auto
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
115b8e214a utility: fix STL string formatter bug
Must reserve a buf size of len+1 before resizing it, else we are 1 byte too short when copying the entire string. Also just clear when 0.
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
60a3cee531 Engine: hoststate loop cleanup
Logic hasn't been changed, conditions have been brought into the loop itself
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
8feffd2487 Engine: add missing include
Needed for NucleusID_t.
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
f27454aef1 NVIDIA: disable gfx_nvnUseMarkersToOptimize by default
Causes rubber banding on some systems.
2024-04-05 17:56:52 +02:00
Kawe Mazidjatari
ff9aa78d0d Thirdparty: upgrade SpdLog to 1.13.0 2024-04-05 17:56:52 +02:00
Kawe Mazidjatari
f0907ca9f1 BanSystem: refactor & fix bugs
* Make sure we read the banlist from platform as well, just like how we write to it.
* Use strtoull() instead of atoll() for nucleus id values, nucleus id is unsigned so we must convert to unsigned.
* Remove extraneous try catches, these were previously used for integral type conversions that threw exceptions, but the current ones do not throw so the try catch is unnecessary.
2024-04-05 17:56:52 +02:00
Kawe Mazidjatari
e59c6c88c9 Tier1: add V_IsAllDigit()
This function checks if a string consists of only numeric characters.
2024-04-05 17:56:52 +02:00
Kawe Mazidjatari
dd20e9f4aa Engine: use NucleusID_t type for CClient 2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
4f4b029538 RapidJSON: use iterative parsing instead
Use iterative parsing to protect against stack overflows in rare cases
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
c8e5d263bd Thirdparty: upgrade to latest RapidJSON 2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
6edd80e506 RTech: mark const 2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
f5424f4bd0 Core: use forward slash when formatting logger files
Minor cleanup
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
6434b8abe9 Tier0: crash handler refactor & bug fix
Fix syntax error on page protection flags check when determining whether we encountered a return address. Also limit the amount of dynamic memory allocation calls, offer a large enough static buffer where we can just write into when we crash without needing to alloc or realloc anything. Also removed some hacky code like the whitelist set, and made the module handle array static into the class as well. The CrashHandler singleton is now a static class instance.
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
a2ceab52da Tier1: fix type demotion warning
Promote type to signed size type.
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
eae0d0964b Tier0: iostream light cleanup
- Take const char* directly instead of making extraneous copies
- Add overload for reading strings into fixed size buffers
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
fed4ce80bf RTech: properly disable asset streaming on dedicated server
Just set the mode to 0, required as we rebuilt the functions and can't really check for dedicated there, we have to initialize it with this mode.
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
79cee02a62 Tier0: bump sigcache minor version
Force rebuild of local cache since many signatures have changed.
2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
41a114bb54 ReVPK:
Fix usage text, there were some errors in it.
2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
241aefd6f3 VpkLib: actually search for corresponding data block file
Instead of just using English as default, actually scan for all supported directory tree files, error if not found. This completes the sanitization logic which allows the user to only pass in the data block file to load the directory tree file
2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
6a60a46fc0 RTech: make PakPatchDataHeader_t fields unsigned and add static assert for struct size 2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
63f55578eb RTech: rename AsyncHandleTracker_t fields
Better names
2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
f78d04dda8 RTech: use Max() from our own headers 2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
29c7cc9e58 ZStd: explicitly set debug level
Explicitly set to 0 for release
2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
ff98df556c Fix unresolved external symbols
These projects used 'V_FixSlashes' but weren't licked to Tier1.
2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
0b7805101c RTech: cleanup & const correctness 2024-04-05 17:56:50 +02:00
Kawe Mazidjatari
b92c2daea1 RTech: fix bug when string is NULL
Fixes a crash because string can be NULL when this is called
2024-04-05 17:56:50 +02:00