2802 Commits

Author SHA1 Message Date
Kawe Mazidjatari
33dfe63f67 Fix incorrect ICVarIteratorInternal function order
The destructor is the last function.
2023-06-26 22:42:54 +02:00
Kawe Mazidjatari
ef69611435 Replace memalloc calls throughout entire SDK
Global 'direct' usage of 'MemAllocSingleton()' has been jettisoned. Where possible, smart pointers were used instead. During the refactor, the following bugs were addressed and fixed:
- The virtual destructor of 'CCVarIteratorInternal' was NOT called on destruction.
- Class function 'KeyValues::MakeCopy' did NOT calculate the buffer size of the wide string correctly, the original calculation was 'len+1*sizeof(wchar_t)', but should've been '(len+1)*sizeof(wchar_t)'.

Some other code changes include:
- Tier0 include 'memstd.h' has been moved above all thirdparty includes, to make sure the memalloc functions get shadowed with ours in third party libraries as well.
- RPak file paths string literals are now defines.
- 'DestroyOverlay' has been refactored to match the assembly of the game.
2023-06-26 22:34:24 +02:00
Kawe Mazidjatari
ae52aa0081 Replace memalloc calls for Valve container types
Utilize new malloc system using the conventional approach, see commit 708a2495.
2023-06-26 21:18:44 +02:00
Kawe Mazidjatari
d0bdbcd2b0 Mod_ProcessPakQueue cleanup
* Reset 'old_gather_props' cvar, so that we can re-evaluate on the next level load, and use the new one instead if no errors were found that time around.
* Removed extraneous operators.
2023-06-26 16:50:25 +02:00
Kawe Mazidjatari
31f4e562a8 Set correct mutex type for 'm_MDLMutex'
Should be 'CRITICAL_SECTION'.
2023-06-25 14:56:30 +02:00
Kawe Mazidjatari
420a41d095 Fix CMDLCache crash on missing models
CMDLCache::FindMDL missed a check for 'DC_INVALID_HANDLE'. Adding in this check solved the issue. Other functions have been slightly cleaned up/optimized.
2023-06-25 14:56:04 +02:00
Kawe Mazidjatari
708a249507 Internal memalloc replacement
This commit replaces the standard memalloc system with that of the game. This means we can share the same allocated memory objects between the game and SDK without having to use 'MemAllocSingleton()' and manually call the constructors/destructors. This also means we can create ConVar's and ConCommands in the global scope, and a bunch more cool stuff. The explanation in 'r5dev\loader\loader.cpp' documents the new loading system.
2023-06-25 11:37:52 +02:00
Kawe Mazidjatari
b76f4aa3bd CModule class improvements
*Use unordered_map to get mpdule sections instead, as this is more performant than comparing strings.
* Removed 'm_SectionName' field from ModuleSections_t, as the unordered map now keeps track of them.
* Removed all extraneous module section copies.
* Renamed 'GetImportedFunction' to 'GetImportedSymbol'.
* Renamed 'GetExportedFunction' to 'GetExportedSymbol'.
*Made a static version of 'GetImportedSymbol' and 'GetExportedSymbol', so it could be used on raw module base addresses.
*Created inlines for getting the DOS and NT headers.
*Improved formatting so the code could be read more easily on a vertical monitor.
2023-06-25 10:29:42 +02:00
Kawe Mazidjatari
f31788c6c2 Add missing include guards
Causes compile errors.
2023-06-25 08:57:10 +02:00
Kawe Mazidjatari
15b78f966d Fix unreachable code in CMDLCache
This code was part of an invalid string check, but is no longer necessary and was causing the unreachable code bug. Removed.
2023-06-25 02:31:50 +02:00
Kawe Mazidjatari
884decd090 Set default debugger parameters
The debugger can now be immediately invoked on all runtime projects after generating the solution without having to set anything up.
2023-06-24 15:46:56 +02:00
Kawe Mazidjatari
0f5b171b67 Cleanup warning string on invalid string cmd
Remove the UTF-8 part.
2023-06-24 00:56:45 +02:00
Kawe Mazidjatari
59a3f50c00 Valve container fixups
* Fix missing "HasElement" method in CUtlRBTree.
* Change iterator types to "unsigned short" to avoid compiler warnings (default template argument for the index type is unsigned short).
2023-06-24 00:56:00 +02:00
Kawe Mazidjatari
cfa2172322 Undo CUtlBuffer::ParseToken patch
The bug was only reproduced on the compiled implementation in the game executable. The CUtlBuffer::ParseToken implementation in the SDK did not bug on the same input string. More research is required, and a possible good fix would be to just hook and replace the game's implementation with that of the SDK.
2023-06-23 00:27:24 +02:00
Kawe Mazidjatari
a93824b2db Discard invalid string commands
Must be UTF-8 encoded, currently there are no checks.
2023-06-22 23:45:19 +02:00
Amos
89458eb23e Fix dedicated server compiler error
Client exclusive, moved to client only group.
2023-06-22 18:26:29 +02:00
Amos
b13cc071a9 Improve ban commands
The ban commands have the 'sv_' prefix removed. CBaseEntity::InputKill expects 'kickid' to be present, it uses this to kick the player once the entity has been destroyed. Not doing so could lead into a crash or other undesired behavior.
2023-06-22 09:09:38 +02:00
Kawe Mazidjatari
d43ab4a850 Fix typo 2023-06-22 00:34:26 +02:00
Kawe Mazidjatari
f2615b10de Improve CClient class structure
* Added structure for send/recv datablocks vtable.
* Mapped out CClient structure more.
* Fixed incorrect tick member offsets for CClient.
2023-06-22 00:33:00 +02:00
Amos
ac4ab6aa1a Add reason parameter to kick/ban commands
Reason parameters are optional. For scripts, to use the default message, pass in an empty string. The function for the script system should be centralized soon to avoid more duplicate code.
2023-06-20 08:44:03 +02:00
Kawe Mazidjatari
6361e64b5c Improve readability
Break up lines so they fit on a vertical monitor.
2023-06-19 22:42:25 +02:00
Kawe Mazidjatari
bc995230fa Avoid extraneous string copy
Take raw pointer directly, this is currently the only way these functions get called with.
2023-06-19 22:36:46 +02:00
Kawe Mazidjatari
91ec38645c Formatting improvements in init.cpp
Make it easier to read on a vertical monitor.
2023-06-19 15:12:46 +02:00
Kawe Mazidjatari
0f9d12d506 Always pad 'build_id' field by 10
This is to maintain alignment, may it ever change.
2023-06-19 14:18:30 +02:00
Kawe Mazidjatari
a9338455aa Fix ImGui window procedure handler crash on shutdown
When and after 'Host_Shutdown()' is called, the window handle is still valid, thus the handler still gets called. This gets destroyed in 'OnShutdown()' called from 'CEngineAPI::RunListenServer()'. But we do shutdown the ImGui implementation in 'Host_Shutdown()'... Therefore, we should check if the implementation is initialized or not before running the window procedure handler.
2023-06-19 14:03:23 +02:00
Kawe Mazidjatari
abe68def03 CMDLCache code improvements
Slightly mapped out the CMDLCache class, to the point the pointers to its members are no longer needed. Also fixed a bug were the studiodata pointer was dereferenced before checking if its not null, this check did exist, but was performed too late. Fully implemented the CUtlDict class for m_MDLDict. Slightly optimized the initialization of the error model handles.
2023-06-19 13:53:56 +02:00
Kawe Mazidjatari
2cfed900d0 Add full CUtlDict implementation
CUtlDict from the SourceSDK.
2023-06-19 11:23:22 +02:00
Kawe Mazidjatari
a68a0c511a Log the SDK's 'build_id' under the emblem 2023-06-19 10:58:12 +02:00
Kawe Mazidjatari
acb68a559a Light optimization in engine logger sink
Only copy the string buffer our once.
2023-06-19 01:51:25 +02:00
Kawe Mazidjatari
d2fca23cf5 Fix typo in address logger
Technically not a pointer internally.
2023-06-19 01:46:05 +02:00
Kawe Mazidjatari
f024db1477 Use correct address logger
Should use the function logger instead.
2023-06-19 01:45:25 +02:00
Kawe Mazidjatari
18e4a262c8 Fix double crash dialog boxes bug
This occurs when the game's unhandled exception handler is getting called after ours. both will create a crashmsg process. This happened as CCrashHandler::End() was called before the in-game exception filter was fired, and therefore CCrashHandler::Handled would return false, and this fire the in-game exception filter. This commit removes the additional check, we just use our vectored exception handler entirely over the game's one, as this one captures everything an unhandled exception handler will capture, and more. The 'Handled' function/fields in CCrashHandler have been renamed to 'Handling', as this is a more appropriate name.
2023-06-19 01:35:10 +02:00
Kawe Mazidjatari
97a6b8b5cc Make CCrashHandler getters/setters inline
These could be just inline.
2023-06-19 01:19:47 +02:00
Kawe Mazidjatari
2ae1f88311 Improve crash handler file formatting
Only display hex comment on decimal ALU register if its above 9, and format it as such that it fits perfectly next to a register that is equal or lower than one million. Added additional comments.
2023-06-19 01:18:27 +02:00
Kawe Mazidjatari
f87fb2b2d6 Fix shutdown crash on debug builds
The destruction of these crashed due to dereferencing an invalid pointer. Not making them inline fixes the problem. This problem only occurred on debug builds, other build configurations were not affected.
2023-06-18 23:55:58 +02:00
Kawe Mazidjatari
165d80c541 Fix rare ImGui crash on shutdown
The 'DirectX_Init()' call was performed late in code, shortly after the window has been created (at this point all device objects and window handles are valid), but the 'DirectX_Shutdown()' call was performed on DLL_DETACH, which was way too late, as the objects were already destroyed at this point. This wasn't an issue before, as we created our own objects in the old DX code. But due to optimizations, we were using the same pointers as the game (noticeable performance boost), but did not adjust the shutdown to accommodate the changes. The shutdown is now performed while the device objects and window handles are valid. Code has been tested on Nvidia and AMD systems, and has confirmed to fix the aforementioned issues.
2023-06-18 22:16:43 +02:00
Kawe Mazidjatari
d5039de251 Make inline
Make them inline as these are just single member getters/setters.
2023-06-18 22:06:25 +02:00
Kawe Mazidjatari
b7cf2c6f64 Cleanup ImGui shutdown
Move to separate function.
2023-06-18 17:50:11 +02:00
Kawe Mazidjatari
b8304e116c Sync wrong field name with IDB
Synced with correct field name.
2023-06-18 17:21:25 +02:00
Kawe Mazidjatari
a33f569ad5 Proper fix for playlists reloading on disconnect
This fixes a crash/exception that would occur when getting disconnected from your own listenserver due to the playlists reload task dispatch. Moving this to client only code, in the disconnect routine (post disconnect) fixes this problem.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
f5151a74cf Add comments to 'SV_CheckForBan'
Some stuff was unclear and took a minute to understand again, these comments fixes this problem.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
efe119a5f2 Remove unnecessary parentheses from check in 'CHostState::FrameUpdate'
Unnecessary.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
0a6fc26529 Comment assert out
Verbose, libcurl free's null blocks.
2023-06-18 12:06:28 +02:00
Kawe Mazidjatari
4f7280ab4c Make inline
These type of functions should always be inline.
2023-06-18 01:25:49 +02:00
Kawe Mazidjatari
32c0e20e76 Init cURL with custom memory callbacks 2023-06-18 01:16:58 +02:00
Kawe Mazidjatari
982fe66570 Add memory callbacks similar to the game's implementation
Required for overriding memalloc callbacks in libraries to feature the game's implementation instead. Named using the 'R_' prefix, as the 'V_' versions were already used.
2023-06-18 01:16:24 +02:00
Kawe Mazidjatari
c8648b9289 Fix typo
Typo.
2023-06-17 16:31:45 +02:00
Kawe Mazidjatari
b64897d4c1 Remove extraneous cURL compile option
Because already set from global CMake init.
2023-06-17 16:31:26 +02:00
Kawe Mazidjatari
7691fa1b5f Light console optimizations 2023-06-17 16:30:10 +02:00
Kawe Mazidjatari
788f38b428 Adjust cURL compile options
- Disable function inlining entirely, this allows for much easier hooking between engine and SDK code (the compiled code is now identical between engine and SDK, except that the SDK has all relevant security problems patched as per https://curl.se/docs/vuln-7.54.0.html).
- Enable buffer security checks to avoid potential remote attacks.
2023-06-17 01:07:07 +02:00