3475 Commits

Author SHA1 Message Date
Kawe Mazidjatari
6828901815 Tier1: static construction of ConVar objects during link time
Fully implemented ConVar class so we could statically construct all SDK convars, this avoids a level of indirection, and allows for creating ConVar's everywhere in the project.

This patch also removed the settings tab of the ImGui server browser, as it has threading issues, while it technically never caused a crash yet, it has been removed as there was no point keeping it vs the work required to make it thread save (it only managed 2 convars which are perfectly manageable through cfg's or the in-game console).

Also temporarily disabled the creation of ConVar's in the mod system due to a memory leak, we would allocate and register a convar based on details parsed out of a mod file definition, but never unregister and free it.
2024-02-24 02:15:09 +01:00
Kawe Mazidjatari
3d36c87b08 Statically construct all ConCommand
Properly implement the ConCommandBase and ConCommand classes so we could statically construct all ConCommand objects in the global scope of each translation unit, this way we don't need to put them in a global file and deal with preprocessor directives to compile then in/out for certain projects.
2024-02-23 00:12:06 +01:00
Kawe Mazidjatari
02087fef5e Engine: reduce reason buffer stack size
64 chars will cover all reasons returned by l8w8jwt_get_validation_result_desc.
2024-02-22 14:56:20 +01:00
Kawe Mazidjatari
79f8b46d62 RTech: major cleanup of pak globals and improvement
Add missing types to fully mapped out PakGlobals_s struct, which is a 13MiB+ structure! This covers the vast majority of the pakfile system which is why we had to change a bunch of stuff for this patch. This patch also comes with:

- Reversed 'JobFifoLock_s' structure
- Reversed 'PakTracker_s' structure
- Reversed 'PakAssetTracker_s' structure

Many globals have been dropped as they were covered by the large PakGlobals_s singleton.

The pak decoder logic has been changed up as well, we now use a decode mode enumerant which will make it easier to add in more decoders for the pak files in the future.
2024-02-22 02:09:28 +01:00
Kawe Mazidjatari
6e23c39d40 Netconsole: fix race condition caused by misplaced mutex
Mutex should be locked before IsConnected(), as IsConnected() accesses CSocketCreator which checks a vector (not thread safe), lock the mutex in the correct place.
2024-02-22 02:00:09 +01:00
Kawe Mazidjatari
b1493215f1 Mathlib: remove unused SHA256 implementation
No longer used, SDK uses the MbedTLS implementation now.
2024-02-22 01:57:59 +01:00
Kawe Mazidjatari
acbe43a210 Engine: fix RCON bugs and improve security
- Upgraded hashing algorithm to SHA-512, and store the raw hash instead of a string copy, which is way cheaper to compute and compare.
- Only ever close sockets once in CRConServer::SetPassword().
- Made the game server & game client RCON singletons static.
- Added calls to gracefully shutdown RCON server and RCON client on Engine/SDK shutdown.
- Added more prints so RCON user knows when its shutdown, or when their password change is in effect, etc.
- Fixed bug where we could tokenize an empty string when we dispatch a console command.
2024-02-22 01:55:08 +01:00
Kawe Mazidjatari
6afb5fe593 Engine: improve CClient::Authenticate performance
- Removed 2 std::string copy constructions
- Removed 32 sprintf calls per token auth request.
- Fixed a bug where we format the NucleusID as s64 instead of u64.
- Added additional hardening for when token/sessionId stitching fails, this will now always reject the connection.
- Improved the macro to make sure we always free the JWT claims if it has been allocated.
2024-02-22 00:59:00 +01:00
Kawe Mazidjatari
bc5e14643c Engine: print COM_ExplainDisconnection() text as CLIENT
Only used on the client, print it as client.
2024-02-21 01:18:43 +01:00
Kawe Mazidjatari
77c8e3a994 Engine: remove deprecated cvar 'cl_move_use_dt'
No longer used, the vftable call made when this was false is stubbed and thus will cause movement to bug when unset; removed.
2024-02-21 01:17:48 +01:00
Kawe Mazidjatari
4ae9852291 Engine: cleanup data block sender/receiver and add types
* Move member vars to correct place, to match it with the engine.
* Added out-of-band network message ID's for the R5 engine.

Also implemented 'ServerDataBlockSender::SendDataBlock()' and 'ClientDataBlockReceiver::AcknowledgeTransmission()'. NOTE that these are currently not tested, and also not in use! The code uses the version stored in the vftable which is what the engine itself provides. These have been implemented for reference only. If they need to be used, they need to be thoroughly tested first!
2024-02-21 01:16:10 +01:00
Kawe Mazidjatari
51ba4c9dff Tier1: fully implement bitbuf classes
All routines are now fully implemented. This was delayed on purpose as some bit buffer functions have changed due to the use of 64bit integers for sizes, and also the coord types. The porting of this has to be done carefully; all
reimplemented functions have been changed to feature 64bit integers (where necessary) for syze types, and all values in coordsize.h have been tweaked to reflect the changes in the R5 engine 1:1, allowing us to properly implement the coord bit buffer functions as well.
2024-02-21 01:10:14 +01:00
Kawe Mazidjatari
5b0b386ea7 Tier1: assert on LZSS window size being a power of 2 2024-02-19 21:24:01 +01:00
Kawe Mazidjatari
e72f13ee0f 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-02-19 21:24:01 +01:00
Kawe Mazidjatari
9937e0b26a Tier1: add CUtlHashTable 2024-02-19 21:24:01 +01:00
Kawe Mazidjatari
0fbbae3732 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-02-19 21:24:01 +01:00
Kawe Mazidjatari
21a383a20e 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-02-19 21:24:01 +01:00
Kawe Mazidjatari
155c221a70 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-02-19 21:24:00 +01:00
Kawe Mazidjatari
def6d4da68 Tier0: emit text to debug console if debugger is attached
Small quality of life improvement while debugging the application.
2024-02-19 21:24:00 +01:00
Kawe Mazidjatari
802e1f42eb 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-02-19 21:24:00 +01:00
Kawe Mazidjatari
976f1ab5ae 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-02-19 21:24:00 +01:00
Kawe Mazidjatari
b3cd76aa70 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-02-19 21:22:24 +01:00
Kawe Mazidjatari
170ebe0703 CMake: regroup thirdparty libs in filters 2024-02-19 21:22:24 +01:00
Kawe Mazidjatari
b15b4dd524 Thirdparty: add LZ4 to project
Will be used for data block sender/receiver rebuild
2024-02-19 21:22:23 +01:00
Kawe Mazidjatari
535ffe5562 Tier1: use signed size types for buffer size field 2024-02-10 01:35:24 +01:00
Kawe Mazidjatari
a5a87f0847 Tier1: use correct format specifier CCountedStringPoolBase 2024-02-10 01:34:55 +01:00
Kawe Mazidjatari
a1fd351ccc Tier1: make utlbuffer flags clear
Use 'FLAGS_NONE' as default.
2024-02-10 01:34:37 +01:00
Kawe Mazidjatari
190da115a5 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-02-10 01:34:03 +01:00
Kawe Mazidjatari
35f684f9ac Tier1: use the Max defined in platform headers
This one is the preferred Max as per Valve Source.
2024-02-10 01:21:29 +01:00
Kawe Mazidjatari
24f41ef6c7 Tier1: use SSIZE_MAX for default str slice buf end
Will be INT_MAX on 32bit platform and INT64_MAX on 64bit.
2024-02-10 01:20:35 +01:00
Kawe Mazidjatari
8b338ce682 Add signed size type defines 2024-02-10 01:18:55 +01:00
Kawe Mazidjatari
9b800a19f7 Tier1: optimize V_UnqualifiedFileName()
If we are going to do a strlen, then check the chars from the start
2024-02-07 14:30:37 +01:00
Kawe Mazidjatari
92dd860079 Engine: fix bug causing level assets to not load properly
The level has changed when strcmp returns a non-null value.
2024-02-06 15:37:50 +01:00
Kawe Mazidjatari
340dcfd4bd Engine: remove unused variable
No longer used as of commit b29be00d.
2024-02-06 14:51:47 +01:00
Kawe Mazidjatari
1a9e393d1b 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-02-06 14:48:11 +01:00
Kawe Mazidjatari
b29be00d82 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-02-06 14:42:36 +01:00
Kawe Mazidjatari
7599aa4002 Recast: remove use of auto
Useless use of auto
2024-02-06 14:37:14 +01:00
Kawe Mazidjatari
cc8c5ee6b0 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-02-06 14:36:01 +01:00
Kawe Mazidjatari
c42b128672 Engine: hoststate loop cleanup
Logic hasn't been changed, conditions have been brought into the loop itself
2024-02-06 14:33:40 +01:00
Kawe Mazidjatari
7eff7f4ce2 Engine: add missing include
Needed for NucleusID_t.
2024-02-04 18:26:04 +01:00
Kawe Mazidjatari
c12c8fb7fe NVIDIA: disable gfx_nvnUseMarkersToOptimize by default
Causes rubber banding on some systems.
2024-02-04 14:42:39 +01:00
Kawe Mazidjatari
63d7a20531 Thirdparty: upgrade SpdLog to 1.13.0 2024-02-04 13:43:17 +01:00
Kawe Mazidjatari
ed5721eaa0 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-02-04 12:55:56 +01:00
Kawe Mazidjatari
0dd19ab2dd Tier1: add V_IsAllDigit()
This function checks if a string consists of only numeric characters.
2024-02-04 12:52:46 +01:00
Kawe Mazidjatari
8da31dd15c Engine: use NucleusID_t type for CClient 2024-02-04 12:50:36 +01:00
Kawe Mazidjatari
c72cf89465 RapidJSON: use iterative parsing instead
Use iterative parsing to protect against stack overflows in rare cases
2024-02-04 12:50:02 +01:00
Kawe Mazidjatari
5e10fde155 Thirdparty: upgrade to latest RapidJSON 2024-02-04 11:18:55 +01:00
Kawe Mazidjatari
bed3bc87a0 RTech: mark const 2024-02-04 00:55:48 +01:00
Kawe Mazidjatari
cd39a68b48 Core: use forward slash when formatting logger files
Minor cleanup
2024-02-04 00:55:33 +01:00
Kawe Mazidjatari
e728877035 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-02-04 00:55:07 +01:00