100 Commits
Author SHA1 Message Date
Kawe Mazidjatari c49e0d2123 Tier2: improve branch prediction for JSON_StringToNumber()
Check for error before checking if the iterator points to the end of the string.
2025-06-22 14:09:45 +02:00
Kawe Mazidjatari 02cba0fb86 Tier2: fix incorrect return type for JSON_TypeToString()
Should return const char*, function is currently unused so this wasn't noticed until now.
2025-06-22 14:08:23 +02:00
Kawe Mazidjatari 4d34fff29f BanSystem: lookup performance overhaul
The ban system now uses an hash map containing 16-byte IPv6 entries which uses a custom simple hashing algorithm accelerated by SIMD. This is much faster than the previous approach which used a raw vector containing the string representations of the IPv6 entries (which also used the slow string comparisons). The new system has an average constant time complexity, so users with large amount of banned ip adresses and nucleus id's will not experience performance regressions.
2025-06-21 16:30:36 +02:00
Kawe Mazidjatari 21787ba131 CMake: suppress wd4706 warnings in thrdparty projects
Triggered by Mbed TLS, suppress it (thirdparty only!).
2025-06-21 16:16:44 +02:00
Kawe Mazidjatari b46061ea89 Engine: server-side RCON improvements
- Use the new IPv6 lookup system for fast IP address lookup, now uses the actual 16 byte address storage (which is much faster to lookup and compare while being smaller than the string represenation).
- Check return value of CNetAdr::SetFromString() and handle errors.
- Clear banned list on shutdown (fixes the edge-case bug where remote console access would be disabled during the life of the process once the banned list overflowed as a reboot wouldn't clear it).
- Only try to initialize the socket once, stop as soon as a rare error occurs instead of retrying every frame.
- Only print hacking attempts warnings when the cvar `rcon_debug` is enabled as this can be verbose during attacks.
2025-06-21 16:15:34 +02:00
Kawe Mazidjatari 1f1a5cbee3 Tier2: add utilities for fast IPv6 storage and lookup
Fast utilities for a pending BanSystem performance overhaul.
2025-06-21 16:05:42 +02:00
Kawe Mazidjatari 28712e26d1 Engine: allow DNS lookup for RCON address
Allow DNS address lookup, just like the game's UDP socket.
2025-06-21 15:52:37 +02:00
Kawe Mazidjatari b3f4295665 Engine: adjust use cases of CNetAdr::CompareAdr()
Light API change in commit afb3a9aca7 to make it more clear and avoid future bugs -- the type NA_LOOPBACK is now checked on the passed-in instance instead.
2025-06-21 15:50:24 +02:00
Kawe Mazidjatari 5b74b42cbc Tier2: CSocketCreater class improvements
- Const correctness.
- Check return value of CNetAdr::SetFromSockadr() and handle it.
- Light cleanup in intermediate code and documentation.
2025-06-21 15:47:38 +02:00
Kawe Mazidjatari 7a1f30cf25 Tier1: CNetAdr class improvements
- Const correctness.
- Document all methods.
- Make CompareAdr() check if the passed-in netadr_t instance if off type NA_LOOPBACK instead (should avoid confusion in the future, this change requires a few use cases to be adjusted as well in the code base which will come in a future patch).
- Make CompareAdr() cheaper.
- Fix bug in ToString() where the buffer might not be null-terminated after the call to strncpy.
- Fix bug in SetFromSockadr() where inet_ntop() recv'd the incorrect size for string buffer.
- Check for error on inet_ntop() call in SetFromSockadr().
- Properly check for characters in string before determining whether to format the address as IPv4 or IPv6 (now matches the game's implementation).
2025-06-21 15:45:49 +02:00
Kawe Mazidjatari afb3a9aca7 Tier1: improve CNetAdr::ToString()
Return the number of characters written.
2025-06-20 22:32:50 +02:00
Kawe Mazidjatari 5e19ac6453 Tier1: simplify CNetAdr::ToSockadr()
- Make user responsible for giving a clear sockaddr_storage instance (SDK nulls it on all use cases already).
- Remove the need for inet_pton -- we already have a valid, ready to use in6_addr structure.
2025-06-20 22:29:28 +02:00
Kawe Mazidjatari 39e3d4456f Launcher: auto-detect numeric base for processor affinity mask
Minor UX improvement.
2025-06-19 12:21:06 +02:00
Kawe Mazidjatari 85a46ea79f Launcher: minor code cleanup
Use remap indices to reduce code complexity.
2025-06-19 12:20:52 +02:00
Kawe Mazidjatari bca9ff69b1 Launcher: store main panel data to VDF as well
The SDK Launcher now remembers every entry.
2025-06-19 12:20:15 +02:00
Kawe Mazidjatari 8c55ee9e32 Engine: minor remote console (RCON) improvements
- Improve ConnectedNetConsoleData_s member variable naming consistency.
- Use exactly the number of bytes needed for storing the Base64 AES-128 netkey for RCON encryption, and use the size to copy the results from the stack faster.
- Use the correct integral size types.
2025-06-19 12:12:43 +02:00
Kawe Mazidjatari a445ad2ad7 UISDK: create SDK plugin for RUI
Slightly different plugin than PluginSDK; this loads using the RPak dll loading tech.
2025-06-19 12:11:13 +02:00
Kawe Mazidjatari 0a04bbe23a Rui: improve Rui structures 2025-06-19 12:08:46 +02:00
Kawe Mazidjatari d1766f955f Thirdparty: upgrade Mbed TLS to v3.6.3.1 2025-06-19 12:05:47 +02:00
Kawe Mazidjatari aa789c31fa Thirdparty: upgrade SpdLog to 1.15.3 2025-06-19 12:03:39 +02:00
Kawe Mazidjatari e718e512a7 Client: don't bind client core functions to UI VM
UI VM doesn't need 3D debug drawing from code.
2025-05-26 22:44:20 +02:00
Kawe Mazidjatari 3339ff730a Client: remove script only console variables
Cleanup: these have been moved to the SDK's core mod which is a script made for dealing with stuff like this.
2025-05-26 22:41:45 +02:00
Kawe Mazidjatari 9d67e46c75 Server: rename GetServerID() to GetSessionID()
Avoid confusion with GetServerID() introduced in commit 2da030ba19.
2025-05-26 22:40:33 +02:00
Kawe Mazidjatari 2da030ba19 Client: implement GetServerID()
Allow CLIENT and UI VM to retrieve the current game server ID.
2025-05-26 22:39:41 +02:00
Kawe Mazidjatari 31f37eaef8 Engine: implement remote session ID for host
Replicated cvar containing the session ID for remote which the clients could use as the server ID.
2025-05-26 22:37:51 +02:00
Kawe Mazidjatari ae28a059fc Detours: only check ASLR registry entry on NT 6.0 and NT 6.1
MoveImages no longer exists on NT 6.2 and higher; ASLR is always enabled so we should use the ASLR code regardless of this registry entry.
2025-05-26 17:32:21 +02:00
Kawe Mazidjatari e0ea354350 Detours: fix incorrect skip count for reserved system DLL address ranges
This regression was caused in commit 9ad1cae791, we should've used the old constants again to increment this.
2025-05-26 17:30:06 +02:00
Kawe Mazidjatari 848eb08d2f Detours: remove unused DETOUR_TRACE() call
These variables no longer exists, fixes compile errors when enabling DETOUR_TRACE().
2025-05-26 17:28:10 +02:00
Kawe Mazidjatari e6df40b380 VScript: rewrite ModSystem script parser
Before, we compiled all our mod scripts after the core scripts had been compiled. This required several hacks to get working (deferring compile buffer freeing, appending a mod identifier to the path and scanning for it, etc..). Even after all the hacks, it still didn't work properly as local structures couldn't be defined in mod scripts without crashing the engine. The system has now been completely rewritten to append mod scripts into the same array all the core scripts are being added into, and compile everything in 1 go. This allows for removing every hack that was added to get the previous system to work, and also ensures we never load more scripts than MAX_SCRIPT_FILES_TO_LOAD, and enforces that every script (even from mods!) has an unique file name. This new implementation appears very robust during my extensive tests.
2025-05-26 13:09:17 +02:00
Kawe Mazidjatari 6c5c2f8b0a RTech: add timer to Pak_RequestSwap_f()
Report how long the hot swap took.
2025-05-26 10:39:19 +02:00
Kawe Mazidjatari 7e3919c6e8 PluginSDK: minor formatting fix
Make it consistent with the rest of the file.
2025-05-26 10:34:52 +02:00
Kawe Mazidjatari f75670e274 Tier0: increment sigcache version
Force full rebuild on next launch to improve subsequent launch speeds.
2025-05-24 01:03:03 +02:00
Kawe Mazidjatari 978de2aaa9 RTech: use full arg string for RPak tools commands to fix break set
Patch paks contain characters that are filtered by the break set causing autocomplete to fail on them. Use the full argument string after the 0th arg to avoid this.
2025-05-24 00:43:33 +02:00
Kawe Mazidjatari 0dfbb7ccef Tier1: support checking if ArgS() is all num
Currently, CCommand::HasOnlyDigits() only supports args in the argument vector, but not ArgS() which is also commonly used.
2025-05-24 00:35:46 +02:00
Kawe Mazidjatari bb1dd80149 RTech: fix UAF in Pak_RequestSwap_f()
We cannot use members of the pak info structure after the unload was initiated as they get clobbered and freed. Store them on the stack until the unload job is finished and provide it back to Pak_LoadAsync(). This is a development only feature so this bug doesn't affect the rest of the game's runtime.
2025-05-24 00:08:09 +02:00
Kawe Mazidjatari 581bdff6c1 RTech: change bit for ZStd pak encoder
Respawn started using 1<<9 for Oodle 2 weeks after the R5sdk implemented ZStd using the same bit. Changed to the last bit to fix the current conflict and avoid future conflicts. Lets hope they don't use this bit!
This is a breaking change and requires all encoded SDK RPak files to be rebuilt.
2025-05-22 21:10:27 +02:00
Kawe Mazidjatari 9ad1cae791 Thirdparty: fix Detours system DLL memory avoidance when ASLR is disabled
Some users reported issues with the game no longer launching if operated on a system with ASLR disabled. This patch takes these scenarios into account. We should not look for ASLR address space if ASLR is disabled as this will fail.
2025-05-22 14:28:09 +02:00
Kawe Mazidjatari e1bc098a70 Resource: update NavMesh build script
Updated to use the Recast project files instead now, and added newly shipped maps.
2025-05-21 18:09:48 +02:00
Kawe Mazidjatari 4547884a30 Resource: add RPak build script
Script for RPak build automation.
2025-05-21 18:08:02 +02:00
Kawe Mazidjatari d45c792dcd Resource: update VPK build script
Updated to reflect new changes in commit 7acac73432, and added newly shipped maps.
2025-05-21 18:07:34 +02:00
Kawe Mazidjatari 7acac73432 ReVPK: improve command line interface
Use '-' prefix for consistency with the rest of the tools and code base. Also slightly improved usage guide print.
2025-05-21 17:56:00 +02:00
Kawe Mazidjatari e7210b7107 Resource: enable rui_codeAsserts by default on dev
Enabled by default on development configurations.
2025-05-17 23:22:23 +02:00
Kawe Mazidjatari c2765e1f0c RTech: disable rui_codeAsserts by default
Can get verbose on level changes.
2025-05-17 23:19:12 +02:00
Kawe Mazidjatari eb9cd4be24 RTech: implement code assertion handler for Rui library
The Rui library contains assertions but if they fail they never get logged anywhere. Implemented handler that will log it to the console if cvar `rui_codeAsserts` is set (enabled by default because these are very rare/never happen and we should catch and fix them at all times).
2025-05-17 18:10:22 +02:00
Kawe Mazidjatari cc2e24cf57 Engine: fix incorrect member order for clock drift mgr tick counts
Server tick comes before Client tick. Server tick is at 0x8C while Client tick is at 0x90.
2025-05-17 18:03:27 +02:00
Kawe Mazidjatari 3ed1b67663 Recast: make application background uniform
Make it uniform until an artificial horizon or skybox variant is implemented.
2025-05-14 20:37:15 +02:00
Kawe Mazidjatari 7991c2e18d Recast: fix typo in comment 2025-05-14 20:30:08 +02:00
Kawe Mazidjatari 6f106998bc RTech: rename array manager class
Its not a hash map but a fixed array manager.
2025-05-14 20:29:49 +02:00
Kawe Mazidjatari 2e1f967bf8 Resource: properly fix the HUD scaling regression
This fixes every overlay (including the VGui sprite animations for the SRAM rocket launcher). This is the correct way of fixing the function as it was clearly not updated to match the new changes unlike Hud_SetScaleX() and Hud_SetScaleY().
2025-05-11 13:57:50 +02:00
Kawe Mazidjatari 9a73a944ad Common: cmd "weapon_reparse" should be FCVAR_GAMEDLL for dedicated
If sv_cheats is 1 and we run "weapon_reparse" on the client, the client will forward this command to the server as well so the server could reload its weapon scripts and be in-sync. However this command did not have the proper flags for this to function. Dedicated builds now have the right flags for this command, it now functions as intended.
2025-05-10 15:32:17 +02:00
Kawe Mazidjatari 5d05b1d7ab Recast: minor optimization for dtUpdateNavMeshData()
The std::set::insert() call already deals with finding the entry, we only have to check if we inserted it or not.
2025-05-10 15:30:01 +02:00
Kawe Mazidjatari 3e9e45e6b2 Resource: fix rare crash if we run out of tracing slots
We should return with the result -1 instead of executing the rest of the code because a slot idx of -1 is invalid and our structure pointer will be NULL. Very rare crash but it has happened a few times since the initial release of this project!
2025-05-10 14:42:58 +02:00
Kawe Mazidjatari dcc4cf7831 Tier0: bump SDK version 2025-05-09 16:42:17 +02:00
Kawe Mazidjatari e6b7c62454 Resource: fix smart weapon overlays regression
Engine bug that was caused after a refactor of the HUD system. The scalars were set to a child object instead of the root structure which is what Hud_SetScale() expects. Reworked the assembly code and the overlays now draw properly on the smart pistol and rocket launcher.
2025-05-09 16:41:18 +02:00
Kawe Mazidjatari df4e182160 Engine: fix crash when using IVEngineClient VFTable
g_pEngineClient is an interface only class (does not contain any members), however it was pointing directly to the vftable instead of to a pointer to a vftable, therefore, using its vftable would cause a crash or otherwise undefined behavior. Changed initialization to point to the pointer to the vftable instead to yield correct behavior.
2025-05-09 11:22:43 +02:00
Kawe Mazidjatari b9f1af341e Resource: improve instruction encoding for tex stream mgr patch
All 3 elements are of type i32, set dword instead of qword wide; reduces stack frame with 2 bytes and ensures we do not write past our array. Also fixed a type in a comment.
2025-05-09 01:35:35 +02:00
Kawe Mazidjatari 6fe852f51f MaterialSystem: fix alphasort world textures not streaming when GPU driven
When using the gpu driven texture streaming system, alphasort world textures wouldn't stream because the compute shader was never executed during the alphasort render pass. The system has been modified to accomodate for the 3rd render pass, and the compute shaders now gets executed when alphasort gets rendered. Translucent materials now appear correct and stream in properly on all levels.
2025-05-08 16:55:15 +02:00
Kawe Mazidjatari d05db5bb92 Resource: fix texture streaming crash on 'all' mode
A code path was missed during the static texture array increase; r15 was set to module base but should've been set to the address of our new static texture array. The crash occurs when setting the cvar `stream_mode` to "all". After this change, all stream modes work as intended. This is so far the only issue that has encountered after increasing the array in commit 4de8a7d8ae.
2025-05-08 12:41:33 +02:00
Kawe Mazidjatari 07cf3fca0b BanSystem: rework and improve banned list format
The JSON root is now an array of objects, instead of an object with enumerated objects who's total size was controlled by another field name. This significantly simplifies the file format and parsing code. Also added a object type check for each ban entry to make sure we don't process faulty entries; these get reported to the console as a warning.
2025-05-07 14:40:32 +02:00
Kawe Mazidjatari 062da45499 BanSystem: allocate buffer of optimal read size and handle unicode files
Use an optimal read size for buffer size, and allocate enough to allow null-terminating unicode files as well in case we encounter one.
2025-05-07 14:31:54 +02:00
Kawe Mazidjatari 16e8ad8f79 RTech: allocate buffer of optimal read size and handle unicode files
Use an optimal read size for buffer size, and allocate enough to allow null-terminating unicode files as well in case we encounter one.
2025-05-07 14:26:16 +02:00
Kawe Mazidjatari 83b4460c79 Tier1: allocate buffer of optimal read size and handle unicode files
Use an optimal read size for buffer size, and allocate enough to allow null-terminating unicode files as well in case we encounter one.
2025-05-07 14:25:41 +02:00
Kawe Mazidjatari a0c93d410e Tier1: fix resource leak in KeyValues::LoadFromFile()
Resource leak if file is empty as the handle was never closed. filesystem->Size() can also return <0, so we need to check for that as well.
2025-05-07 13:59:00 +02:00
Kawe Mazidjatari 687ac01c59 FileSystem: implement GetOptimalReadSize()
Simple helper for optimimal filesystem reads.
2025-05-07 13:56:35 +02:00
Kawe Mazidjatari c387b6854e FileSystem: fix prototype for AllocOptimalReadBuffer()
The prototype was incorrect; filesystem_std now also implements a minimal version AllocOptimalReadBuffer() and FreeOptimalReadBuffer().
2025-05-07 13:55:31 +02:00
Kawe Mazidjatari 1ef40e7d51 VpkLib: improve debug logging formatting 2025-05-07 11:52:07 +02:00
Kawe Mazidjatari d40d413871 RTech: improve debug logging formatting 2025-05-07 11:50:57 +02:00
Kawe Mazidjatari d426d1d57b Recast: improve debug logging formatting 2025-05-07 11:48:14 +02:00
Kawe Mazidjatari 77a6c7fdba ReVPK: improve debug logging formatting 2025-05-07 11:47:54 +02:00
Kawe Mazidjatari dcf659facb Server: improve debug logging formatting 2025-05-07 11:47:33 +02:00
Kawe Mazidjatari 8c47399aa8 FileSystem: improve debug logging formatting 2025-05-07 11:46:57 +02:00
Kawe Mazidjatari cf7e645d18 Common: improve debug logging formatting 2025-05-07 11:46:40 +02:00
Kawe Mazidjatari ee05ebd1c3 Miles: improve debug logging formatting 2025-05-07 11:46:27 +02:00
Kawe Mazidjatari 20c3803a51 Engine: improve debug logging formatting 2025-05-07 11:46:10 +02:00
Kawe Mazidjatari a0b540c247 Loader: remove extraneous statics for NtCurrentPeb()
NtCurrentPeb() is extremely cheap, no need to cache the pointers off.
2025-05-06 19:51:40 +02:00
Kawe Mazidjatari 46e1414550 Launcher: adjust parameter builder for -norandomkey
Use the new -norandomkey command line argument introduced in 53c104670c.
2025-05-06 19:48:19 +02:00
Kawe Mazidjatari 360d3f153d Resource: adjust development autoexec for -norandomkey
Use the new -norandomkey command line argument introduced in 53c104670c.
2025-05-06 19:47:20 +02:00
Kawe Mazidjatari 53c104670c Engine: create dedicated command line argument to disable random net keys
The net key is configured before the first Cbuf_Execute() call is fired, this results in the key getting configured twice when using  `+net_useRandomKey <val>` over the command line. Make a dedicated command line argument (`-norandomkey`) to fix this problem.
2025-05-06 19:29:07 +02:00
Kawe Mazidjatari 1ff08210de Miles: fix regression when selecting Mandarin language
The game is supposed to load the Mandarin streaming source file when schinese or tchinese is selected, however this didn't happen as the game's language is handled slightly different. Load mandaring streaming source files when either of the 2 languages are selected as these files contain the required audio for both. Fixes the issue where Mandarin audio couldn't be used when using schinese or tchinese language.
2025-05-06 19:24:52 +02:00
Kawe Mazidjatari f5c760aafb PluginSDK: function PluginSDK_LoggerSink() can be static 2025-05-05 00:04:03 +02:00
Kawe Mazidjatari c83ba30ce9 Loader: fix declaration regression
DllMain() cannot be static.
2025-05-04 12:23:37 +02:00
Kawe Mazidjatari 0937d65681 Loader: move assert to Loader_FatalError()
Make sure we always assert in case of an error.
2025-05-04 12:12:12 +02:00
Kawe Mazidjatari f724d04e9b Loader: add error for when process module name couldn't be retrieved
Very rare edge case, but error here as well in case it does happens.
2025-05-04 12:10:15 +02:00
Kawe Mazidjatari df4b388798 Loader: improve SDK load failure prints
Make it more specific.
2025-05-04 12:08:45 +02:00
Kawe Mazidjatari 66dfebe0d2 Loader: minor code cleanup
- Use static where possible.
- Use const where possible.
- Make symbol naming consistent with the rest of the SDK.
2025-05-04 12:05:21 +02:00
Kawe Mazidjatari ad3c5516a2 Engine: normalize slashes in Mod_FormatPakPath()
Small consistency improvement; FS_OpenAsyncFile directly interfaces with the OS file system API, which technically expects normalized slashes.
2025-05-04 01:50:35 +02:00
Kawe Mazidjatari 81401b5299 RTech: fix LoadLibrary() failure on paks loaded from mods
We need to look for the library from the directory the RPak was being loaded from. Use the new feature introduced in commit 17c07be6af to make sure we always attempt to LoadLibrary() the image exactly from where the rpak was loaded from.
2025-05-04 01:49:35 +02:00
Kawe Mazidjatari 17c07be6af RTech: allow retrieval of actual open path from FS_OpenAsyncFile()
This is useful for when we load an from a mod directory, and this rpak has a .dll which needs to be loaded along with the rpak, instead of going over each mod again (since caller doesn't know actual open path) we can just retrieve the actual load path of our rpak and from there LoadLibrary the linked image file.
2025-05-04 01:46:09 +02:00
Kawe Mazidjatari a39ff18bce Tier0: bump SDK version
Bumped to 015.
2025-05-03 20:51:27 +02:00
Kawe Mazidjatari 0035898867 Thirdparty: upgrade Detours library
Upgrade to latest from main (detours/detours@ea6c4ae7f3), and merge PR microsoft/Detours#325
2025-05-03 20:50:39 +02:00
Kawe Mazidjatari 8c1a9ccfbf Engine: use "GAME" path ID for looking up level VPK's
Use the same path ID as that of where mods and plugins are looked up from.
2025-05-03 20:45:23 +02:00
Kawe Mazidjatari 5f69b5b3e8 Tier2: minor comment cleanup 2025-05-03 20:05:33 +02:00
Kawe Mazidjatari f5cf984747 VScript: mark default case for Script_GetScriptHandle() unreachable
This is unreachable code.
2025-05-03 19:59:04 +02:00
Kawe Mazidjatari e5435a03b5 VScript: remove non-existent context name
"NONE" doesn't exist, and is also unreachable. If we ever index there then there is a bad bug somewhere, but this is not the case. Removed.
2025-05-03 19:56:58 +02:00
Kawe Mazidjatari 7cd927d427 VScript: small optimization for loading mod script files
Only look for the ::MOD:: identifier when we are compiling mod scripts.
2025-05-03 19:56:17 +02:00
Kawe Mazidjatari 3dc560ac4b VScript: fix incorrect type for Script_LoadScriptFile()
The first argument is CSquirrelVM, not HSQUIRRELVM. Correct the type to avoid bugs in the future.
2025-05-03 19:55:10 +02:00
Kawe Mazidjatari b9e1cc44c5 Tier0: don't export logging functions
This is no longer needed as they are now available through the plugin system interface.
2025-05-03 17:55:23 +02:00
Kawe Mazidjatari 3a3ca4d240 Tier0: move PEB structures and getters to thirdparty/
Makes this easier to maintain.
2025-05-03 17:53:11 +02:00
Kawe Mazidjatari 160a8a138b PluginSystem: improve initialization/shutdown code
Add command line arguments to allow disabling the plugin system, also placed the debug prints behind a convar that can be toggled through the command line and developer console. The actual instance loading/unloading code has also been moved into the class.
2025-05-03 17:49:12 +02:00
Kawe Mazidjatari c303e01def Game: fix "weapon_reparse" command crashing on dedicated server
The command handler used the IVEngineClient interface to check if we are connected and are on a listen server. This interface is NULL on the dedicated server. The command handler has been rewritten to take this into account now.
2025-05-03 17:46:39 +02:00