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.
* 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.
CMDLCache::FindMDL missed a check for 'DC_INVALID_HANDLE'. Adding in this check solved the issue. Other functions have been slightly cleaned up/optimized.
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.
*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.
* 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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
- 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.
Previously, it was all controlled from the global init (applied to all projects), but some projects need different options. With these changes, you can disable the common options applied in the 'add_module' macro, and set your own if desired.