Commit Graph
100 Commits
Author SHA1 Message Date
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
Kawe Mazidjatari 64dd40dda0 Engine: implement partially reversed client.dll interface 2025-05-03 17:44:12 +02:00
Kawe Mazidjatari cc54bf2d3a Tier0: only concat string if encoding was successful
Only concat it if it was successful.
2025-05-03 13:44:56 +02:00
Kawe Mazidjatari 5c8a79973b Tier0: remove extraneous string clearing code
String is already empty and clean, no need to clear if if encoding failed.
2025-05-03 13:44:02 +02:00
Kawe Mazidjatari 64607f8d5c VStdLib: properly null-terminate format buffer on vsnprintf failure
vsnprintf always null terminates the array unless an error occured. However, we always null the last char in the array. If an error occured and we do not null the start of the array, we will print uninitialized memory (potentially until the end of the array). Check for error and null the start if encoding failed.
2025-05-03 13:42:22 +02:00
Kawe Mazidjatari 360f65e967 VScript: properly null-terminate format buffer on vsnprintf failure
vsnprintf always null terminates the array unless an error occured. However, we always null the last char in the array. If an error occured and we do not null the start of the array, we will print uninitialized memory (potentially until the end of the array). Check for error and null the start if encoding failed.
2025-05-03 13:40:56 +02:00
Kawe Mazidjatari fdae245f60 Loader: properly null-terminate format buffer on vsnprintf failure
vsnprintf always null terminates the array unless an error occured. However, we always null the last char in the array. If an error occured and we do not null the start of the array, we will print uninitialized memory (potentially until the end of the array). Check for error and null the start if encoding failed.
2025-05-03 13:40:16 +02:00
Kawe Mazidjatari 9c5c96023a Game: properly null-terminate format buffer on vsnprintf failure
vsnprintf always null terminates the array unless an error occured. However, we always null the last char in the array. If an error occured and we do not null the start of the array, we will print uninitialized memory (potentially until the end of the array). Check for error and null the start if encoding failed.
2025-05-03 13:40:00 +02:00
Kawe Mazidjatari 0634da36f3 Engine: properly null-terminate format buffer on vsnprintf failure
vsnprintf always null terminates the array unless an error occured. However, we always null the last char in the array. If an error occured and we do not null the start of the array, we will print uninitialized memory (potentially until the end of the array). Check for error and null the start if encoding failed.
2025-05-03 13:38:31 +02:00
Kawe Mazidjatari ed197be220 RTech: fix crash when loading decompressed RPak files
The tenary operator on the pak->maxCopySize member variable got optimized to always assign PAK_DECODE_OUT_RING_BUFFER_MASK. The result of the flag checks to determine if the pak is compressed has now been stored off in a stack variable which is reused. This now compiles to correct code and no longer crashes when loading. Also casted size values to 64 bit wide types to yield better output code.
2025-05-03 02:30:31 +02:00
Kawe Mazidjatari 59d875c40f PluginSDK: complete overhaul and new demo implementation
The pluginSDK has been overhauled with the newly finished interface (as of commit e2fb2d8632). The PluginSDK now implements its features and shows the basics (instantiating interfaces, creating console variables and console commands, creating script function bindings, etc..). The PluginSDK is now considered finished.
2025-05-02 22:47:11 +02:00
Kawe Mazidjatari 1485a7fd2b Engine: properly init and shutdown PluginSystem
Plugins are loaded/unloaded in FILO order; shutdown happens in CModAppSystemGroup::Destroy().
2025-05-02 22:11:53 +02:00
Kawe Mazidjatari 0019accfa2 Game: implement plugin function registration callbacks
Hook it to the plugin interface, which ultimately finalizes this implementation. These were introduced in commit e2fb2d8632.
2025-05-02 22:09:14 +02:00
Kawe Mazidjatari e2fb2d8632 PluginSystem: finish plugin interface
- Implemented proper pluginsystem shutdown routine
- Implemented logger interface (plugins can now log to all interfaces just like the SDK!)
- Added script function registration callbacks (the required code hooks for these will be added very soon)
2025-05-02 22:06:28 +02:00
Kawe Mazidjatari 20b500759b FileSystem: create CFileSystem_Stdio interface factory
Allow the engine's CFileSystem_Stdio interface to be instantiated (this was supposed to be exposed, but due to the game being static linked, this has been optimized out).
2025-05-02 21:56:00 +02:00
Kawe Mazidjatari 40a36cecb0 Tier1: create ICvar interface factory
Allow the engine's ICvar interface to be instantiated (this was supposed to be exposed, but due to the game being static linked, this has been optimized out).
2025-05-02 21:49:41 +02:00
Kawe Mazidjatari e4496dbdba Tier1: decouple SDK specific code
Avoid having the linker link this code inside our plugin libraries.
2025-05-02 21:46:41 +02:00
Kawe Mazidjatari 6975c23f8f VScript: implement simple CSquirrelVM bridge interface
Bridge exposing most commonly used functions allowing plugins to implement script functions.
2025-05-02 21:41:23 +02:00
Kawe Mazidjatari 8244db1cd8 VScript: sq_api improvements
- Implement `sq_settop`
- Implement `sq_pushnull`
- Implement `sq_pushobject`
- Fixed types and overal light cleanup
2025-05-02 21:35:45 +02:00
Kawe Mazidjatari 5ef6a74e59 VScript: fix mods precompiling before core scripts
In order for mods to interface with core scripts, they must be precompiled before the core scripts are. The internal SQVM_FreeCompileBuffer() call had to be defered until after our mod scripts are compiled to make this work.
2025-05-02 21:32:37 +02:00
Kawe Mazidjatari ef0ec4f026 VScript: allow code to override registration and error API's
Needed for plugin in the future to allow them to use the function binding API's, as these need to be bridged.
2025-05-02 21:32:37 +02:00
Kawe Mazidjatari 79beb48481 VScript: rework Warning() print func
Instead of hooking sqstd_format, hook the function directly and rebuild it. Also moved to the implementations to correct file.
2025-05-02 21:32:36 +02:00
Kawe Mazidjatari 82651d15b7 PluginSystem: rename member variables
Enforce codebase consistency.
2025-04-30 02:16:47 +02:00
Kawe Mazidjatari 5d7eef04e6 Engine: use plugin system accessor instead of the object directly
Enforce codebase consistency.
2025-04-30 02:15:02 +02:00
Kawe Mazidjatari 3a7a899315 Server: use pluginsystem accessor instead of the object directly
Enforce codebase consistency.
2025-04-30 02:14:37 +02:00
Kawe Mazidjatari 046db25cec MaterialSystem: only set new cvar value if it changed
Only set it if we changed it, this check is way cheaper than calling SetValue().
2025-04-30 01:50:47 +02:00
Kawe Mazidjatari 4446f0f9bd Engine: allow mod author to decide if paks are server or client only
Mod author can now decide if a given pak should only load on the server, client, or on both:
- 0 = server
- 1 = client
- 2 = both
- -1 = disabled
2025-04-30 01:49:14 +02:00
Kawe Mazidjatari ac2ec0ea80 Engine: implement HostState_IsTransitioningToLoad()
Allows us to determine if we are currently transitioning into loading a level. If this returns true we are the host, very robust way of checking if we are the host during the load of a level.
2025-04-30 01:47:05 +02:00
Kawe Mazidjatari 1755f31910 ModSystem: make sure Mod ID's don't contain disallowed characters 2025-04-30 01:44:30 +02:00
Kawe Mazidjatari 62a1ed8504 ModSystem: update note as to why reloading is dev-only 2025-04-30 01:44:30 +02:00
Kawe Mazidjatari c2ebb716cb RTech: never look through mods on absolute paths
We should never look through mods if the provided path is absolute! Skip these. CPackedStore::OpenPackFile() always provides an absolute path because CPackedStore::MountVPKFile() converts the relative path to an absolute one using Q_MakeAbsolutePath().
2025-04-30 01:44:30 +02:00
Kawe Mazidjatari b4cdd15f89 RTech: uncomment assert on NULL channel ID's
The inlined FS_OpenAsyncFile() functions have now been de-inlined at assembly level; the call sites have been completely reworked in StreamDB_Init(), ColorCorrection_LoadAsync() and CPackedStore::OpenPackFile(), all FS_OpenAsyncFile() calls are now routed properly to the SDK's implementation and therefore the debug channel id's will always be set. Uncommented the assert to catch any regressions caused by future changes.
2025-04-30 01:44:30 +02:00
Kawe Mazidjatari fe77a67b3e RTech: deprecate pakfile overrides
This is no longer needed because we have an actual mod system now. Deprecated since this avoids extra bloat in FS_OpenAsyncFile(). The path is now used for writing pak data (i.e. if we compress or decompress a pak, it will be written to this path now).
2025-04-30 01:44:29 +02:00
Kawe Mazidjatari d3cef0e005 Tier2: decouple request formatting code for CrashReporter
Light cleanup.
2025-04-30 01:10:31 +02:00
Kawe Mazidjatari f42f7f8754 Tier1: improve debug prints for cvar utils
The Msg() call is supposed to be an error.
2025-04-30 01:09:45 +02:00
Kawe Mazidjatari a763e9eb1a Windows: only call Cbuf_AddText() if text isn't empty
Don't submit empty text.
2025-04-30 01:08:49 +02:00
Kawe Mazidjatari de8c05bb8d Thirdparty: upgrade Boost.Regex to latest
Upgraded to boostorg/regex@f851a08050
2025-04-30 01:07:34 +02:00