4717 Commits

Author SHA1 Message Date
Kawe Mazidjatari
d7ebf62c38 Detours: only keep duplication tracking code in debug builds
This serves no purpose in release builds as all these issues must be resolved first before making a release.
2025-02-05 00:36:48 +01:00
Kawe Mazidjatari
27285fc087 MaterialSystem: add pak load for startup_sdk.rpak
Allow the startup_sdk.rpak file to be loaded directly after startup.rpak, while also offering the ability to patch assets in startup.rpak.
2025-02-04 17:51:34 +01:00
Kawe Mazidjatari
eaf313ab7a Engine: don't wait on ui_sdk.rpak for dedicated
Dedicated shouldn't load any ui pak file.
2025-02-04 17:32:20 +01:00
Kawe Mazidjatari
e8fc542907 Engine: light cleanup for Mod_QueuedPakCacheFrame 2025-02-04 17:30:57 +01:00
Kawe Mazidjatari
3ac646da64 GameUI: fix bug in CBrowser::UpdateHostingStatus()
Member netGameServer::hidden should be set if serverVisibility == ServerVisibility_e::HIDDEN.
2025-02-03 21:20:37 +01:00
Kawe Mazidjatari
e55975100e Engine: wait for all paks before releasing FIFO lock
Make sure that every pak is fully loaded before we continue with the level load. Previously we would only wait on paks loaded by CommonPakData_s, but we should also wait on paks loaded by CustomPakData_s. This fixes all rare crash cases caused by this.
2025-02-03 21:15:42 +01:00
Kawe Mazidjatari
949b71a162 Engine: unload paks in FILO order
Due to the rework on repak and the ability to rebuilt entire map rpaks in original quality, we no longer need to do the hack of unloading paks in FIFO order. Properly unload all SDK paks in the same order engine paks are unloaded, which is FILO.
Custom level paks are now also loaded after mp_lobby.rpak, this allows custom level paks to use assets from mp_lobby too without having to copy them over.
2025-02-03 15:43:58 +01:00
Kawe Mazidjatari
c4bf79376e Engine: enforce type name consistency on runtime pak symbols
Make it consistent with the rest of the code base.
2025-02-03 14:06:45 +01:00
Kawe Mazidjatari
72cbe5bc63 Tier1: increase buffer sizes for help command
Text typically gets truncated on concommands/convars with long help texts, this code is also very old. Increasing the buffer sizes fixed the problem. Code now also logs the usage texts if this is available (usage texts is newer than this code, so it was never taken into account).
2025-02-03 13:58:47 +01:00
Kawe Mazidjatari
d810768895 Engine: use correct method for detouring datablock processor
Should be using DetourSetup here as that one handles attaching and detaching.
2025-02-03 13:22:37 +01:00
Kawe Mazidjatari
456a68af05 GameUI: use cached module handle to retrieve resources
Use the one we cache during the initialization of the SDK, which is faster than looking for it again.
2025-02-03 12:52:30 +01:00
Kawe Mazidjatari
b8550c9f32 VScript: map more fields out for SquirrelVM
Newly reverse engineered fields.
2025-02-03 12:14:50 +01:00
Kawe Mazidjatari
24bce8ee73 Revert "LiveAPI: make code compatible with coroutines"
This reverts commit 9b2034d897e68e2c8677df739e14c77a59901652.
Squirrel coroutines cannot stop during native code execution, it can only happen after a native call has been completed which means that commit 9b2034d897e68e2c8677df739e14c77a59901652 is unnecessary. Revert back to using static objects as this is a lot more performant than allocating/freeing the message each time an event occurs.
2025-02-03 12:13:37 +01:00
Kawe Mazidjatari
8339c44c25 Client: fix underflow and overflow vulnerability in entitylist
Reported by @dr3murr
CClientEntityList::GetClientNetworkable() and CClientEntityList::GetClientEntity() lacked a proper clamp on the 'entNum' parameter. CClientEntityList::GetClientEntity() only handled entNum == -1 cases prior to this patch.
2025-02-02 23:46:59 +01:00
Kawe Mazidjatari
5a6c655196 Recast: fix infinite loop in dtNavMeshQuery::raycast()
Status changes, but the code never acts accordingly on the new status.
2025-02-02 15:00:19 +01:00
Kawe Mazidjatari
56aba36b8c Codecs: disable Miles bank patch validation
The validation code uses internal structures of the Miles Sound System which is different for each version of the sound engine versions we support, which makes switching banks impossible without recompiling the SDK. The bank patches rarely fail, but if we decide to keep this we should seek for an alternative approach i.e. using the DLL interfaces directly.
2025-02-02 14:58:41 +01:00
Kawe Mazidjatari
f18dd71f4b Core: use correct format specifier for image build timestamp
_IMAGE_FILE_HEADER::TimeDateStamp is an unsigned 32 bit integer.
2025-02-02 14:55:03 +01:00
Kawe Mazidjatari
51931b59db RTech: rename member variable
This variable actually represents the structure size, which is the header + the rest of the data in the structure of the asset.
2025-02-02 14:53:48 +01:00
Kawe Mazidjatari
b288d072db Tier0: use cached results from GetInternalStreamMode()
No need to call it again.
2025-02-02 14:52:05 +01:00
Kawe Mazidjatari
e63660b549 Tier0: fix bug in CIOStream::Pad()
We must always use the remainder when writing out padding. The bug was that it would still do the full count or PAD_BUF_SIZE at all times even though the remainder is 20 for example. This fixes the last few rare alignment problems.
2025-02-02 14:51:29 +01:00
Kawe Mazidjatari
c8ee0d4333 Core: improve logger performance
- Drop the need for the ImGui logger sink, we can just use the buffer we already rendered into for the terminal sink.
- Remove ANSI rows inserted by the logger before file logging using offsets and ranges to significantly improve the performance.
- For ANSI row constants, use std::string so appending can use the precomputed string length instead of running strlen() each time internally.
2025-02-02 14:47:57 +01:00
Kawe Mazidjatari
b4f68d69ce Launcher: improve dropdown UI name
Name it "mode" as that is more known for gamers.
2025-02-02 14:41:20 +01:00
Kawe Mazidjatari
0f17987599 Common: improve SVC_SetClassVar member variable naming
This netmessage interfaces with the settings kay values system.
2025-02-02 14:34:57 +01:00
Kawe Mazidjatari
452c226316 Server: improve error message on empty class var value
Should be value as this is a key value system.
2025-02-02 14:32:11 +01:00
Kawe Mazidjatari
66a271d003 Server: fix member variable typo 2025-02-02 14:31:20 +01:00
Kawe Mazidjatari
c8c321e924 Server: use dedicated types for nucleus ID
This isn't a bug fix but a style fix as we should use NucleusID_t for anything that is a nucleus ID. This type is also of uint64.
2025-01-26 11:55:36 +01:00
Kawe Mazidjatari
a5bd66513a NetworkSystem: fix network address comparisons
Network addresses should always be stored as base only (without their port numbers), since all additional data can change on reconnects which will make comparisons impossible.
2025-01-26 11:53:39 +01:00
Kawe Mazidjatari
5584c2a87f NetworkSystem: fix incorrect function parameter
nRead was incorrectly placed, it should've been in the parse call. This is used to process the string buffer at once since we already know the size of the string buffer.
2025-01-26 11:48:21 +01:00
Kawe Mazidjatari
5f5bbb9164 Tier1: only return out early on material thread convars without FCVAR_STUDIO_SYSTEM
Anything belonging to the model datacache must have its value changed here too, based on how its implemented in the game engine.
2025-01-24 11:30:02 +01:00
Kawe Mazidjatari
726b5c9fbc Tier1: track convar value changes in ConVar::InternalSetValue too
Add the tracker call here too to allow for debugging changes and catching bugs. Remaned the function from TrackDefaultValue to TrackValueChange as its no longer exclusive to the create method.
2025-01-24 02:14:20 +01:00
Kawe Mazidjatari
bf7f128acf Tier1: properly handle null string values in ConVar::InternalSetValue
There is code that checks if the given string is nullptr, and if so, sets it to an empty string (""). But this new pointer wasn't used on InternalSetColorFromString and atof. InternalSetColorFromString calls sscanf on the given string which if null, is undefined behavior.

The bug was also present in the engine code, this has been patched on assembly level and confirmed correct.
2025-01-24 02:12:48 +01:00
Kawe Mazidjatari
291a99e3ae RTech: return the most recently loaded pak in Pak_GetPakInfo
Make sure to always return the most recently loaded pak instead of the first hit with provided name. The pak system supports live asset hot swapping so we need to take this into account here.
2025-01-22 13:57:44 +01:00
Kawe Mazidjatari
5742163756 RTech: fix typo in comment 2025-01-22 13:43:53 +01:00
Kawe Mazidjatari
bf3bd90dc7 RTech: use correct format specifiers for debug code
Types are unsigned. Also made the iterator unsigned for consistency.
2025-01-22 13:22:22 +01:00
Kawe Mazidjatari
9eeb0606e7 RTech: fix rare crash in pak listing and unloading debug commands
g_pakGlobals->loadedPakCount counts the total number of paks loaded in the runtime, which can exceed PAK_MAX_LOADED_PAKS, which is the absolute maximum number of live loaded paks. So we would overrun the buffer if we had loaded more than PAK_MAX_LOADED_PAKS (512) paks during the life of the process.

Just go over every pak memory instance and check if it isn't unloaded and then print out its details or perform the unload. We need to go over each slot because we can have a valid handle in slot 4 and slot 480 while having the rest inbetween marked as  PAK_STATUS_FREED.
2025-01-22 13:21:37 +01:00
Kawe Mazidjatari
1766530af1 Common: improve Mat_CrossHair_f() readability
Remove unnecessary indentation level.
2025-01-18 23:21:13 +01:00
Kawe Mazidjatari
2dc28bb742 Common: fix crash when GetMaterialAtCrossHair() returns NULL
We checked on the wrong far, materialGlue->Get() returns the static instance within the class, and since its always offset with 16 bytes, the address would be 0x10 if materialGlue is nullptr so the check would always be satisfied. Check on materialGlue itself now and only get the static instance if its available.
2025-01-18 23:19:28 +01:00
Kawe Mazidjatari
2083bc73fa GFX: add support for cubemap texture arrays
Previously we only supported cube textures, this patch implements support for cube texture arrays.
2025-01-15 14:00:56 +01:00
Kawe Mazidjatari
aa405dc4c3 GFX: improve CreateTexture error by logging the texture GUID as well
Most textures in the retail product do not have debug names. A GUID however is still very useful to have. Log the GUID here too.
The CreateShaderResourceView call already logs the GUID along with the texture debug name.
2025-01-15 13:57:40 +01:00
Kawe Mazidjatari
d3a2fd5238 InputSystem: rename function and corresponding enum
Returns the gamepad type. A confusion was made earlier when this was reverse engineered as this was used to determine the joystick deadzone index. But it is actually the controller type which it uses to index into the deadzone parameters.
2025-01-13 15:54:08 +01:00
Kawe Mazidjatari
d049b2df1c RapidJSON: add aligned memory allocator class
Added, but not implemented yet. We can revisit this in the future and check if its worth using the aligned memory allocator.
2025-01-13 15:52:27 +01:00
Kawe Mazidjatari
de4a3d294c NetworkSystem: provide buffer size to RapidJSON parser
We already know the buffer size, this avoids having to recalculate it in the parser.
2025-01-13 15:51:07 +01:00
Kawe Mazidjatari
9bcbf3187c RapidJSON: use 64bits wide size types
Promote to 64 bits since that is what our target uses.
2025-01-13 15:49:11 +01:00
Kawe Mazidjatari
18f2e27409 Engine: implement support for loading ui_mainmenu.rpak
For future updates, this allows for customizing the main menu to its full extend without modifying larger ui rpak files as we separate all title screen assets and put it into this new pak.
2025-01-09 17:08:47 +01:00
Kawe Mazidjatari
03dd7046a6 Engine: use correct format specifiers for edict_t
edict_t is an u16 and will always be as that is the type it uses in the engine itself.
2025-01-09 17:06:29 +01:00
Kawe Mazidjatari
eee6aed033 Engine: qualify functions as static where possible 2025-01-09 17:05:28 +01:00
Kawe Mazidjatari
ec9fc7d77f RTech: fix return type for 'PakLoadFuncs_s::WaitForAsyncLoad()'
WaitForAsyncLoad() returns a bool; returns false if pak status = PAK_STATUS_ERROR.
2025-01-09 17:03:45 +01:00
Kawe Mazidjatari
6827d1ed02 Tier0: make sure the memalloc singleton initializer is thread safe
Only enter code if the atomic exchange was performed.
2025-01-09 16:56:48 +01:00
Kawe Mazidjatari
716a3efa0c VGui: deprecate old texture streaming debug overlay
Replaced by the new imgui version which offers the ability to explore the real-time list, in commit c2deaaf3e8c50e08776e960934a161845f55addf.
2025-01-08 21:46:18 +01:00
Kawe Mazidjatari
c2deaaf3e8 DebugSurface: implement new texture streaming debug overlay
Implement a new imgui based texture streaming overlay. The old one typically clips out of the screen and cannot be explored.
2025-01-08 21:44:14 +01:00