This flag doesn't exist in this game, and is also mapped to printableonly. The map order has also been corrected, from least significant to most significant.
Previously, we had 3 containers mapping ConVar flags for utilities, and none of them contained all flags. This refactor moved everything into a single container class where user can get strings by flags, or the other way around. The new class contains every flag. This also means that every flag can be used to list convars by flags using the command 'convar_findByFlags'. The 'ConVar_ParseFlagString' now also supports every flag. Code has been tested and confirmed to work as designed.
- Use std::map for mapping vtables to interface objects, previously done with a set and a vector.
- Objects are no longer inline, which significantly reduced output code size as all redundant dynamic initializers (created for each translation unit) have been pruned.
Ambiguous overload caused by having 2 constructors who's parameters have types that are equal in size. Since these container size types have been explicitly converted to 64bits to align it with the code compiled in the engine, the compiler no longer knows which constructor to call. Added explicit casts to solve the problem. This error was triggered by declaring: static CUtlMap<const char*, int> s_ConVarFlags(DefLessFunc(const char*));
Should be made static to avoid unwanted bloat in compiled output, as each translation unit will create a new initializer/destructor. -10KiB compiled code for GameSDK.
- Set character set to multi-byte (this is because the game is also build with it).
- Utility function 'FileExists' now takes a raw string pointer, this avoids having to construct a fs::path each time its getting called (which is quite a lot!).
- Performed overall cleanup to code containing logic to override load paths. Mostly removing unnecessary copy constructions.
The game's memalloc does not support memory expansion, the base expansion function couldn't be shadowed properly without linker errors. However we want to make sure no instances of it get compiled into the module, ever. Therefore, the duplicate symbol is kept in memoverride (_expand_base), and the only usage has been removed from LZHAM's 'lzham_mem'. If a linkage is attempted to anything utilizing '_expand', a linker error will be emitted and no image will be generated.
Find regex pattern:
inline auto ([a-zA-Z0-9_]+) = ([a-zA-Z0-9_]+)\.RCast<([a-zA-Z0-9_:<>*]+) *\(\*\)\(([^)]*)\)>\(\);
Replace regex pattern:
inline $3(*$1)($4);
This commit also removes the unnecessary initialization (which was required to type the auto variables),
and therefore removed 6kb of unnecessary dynamic initialization code.
Member offset for 'm_bGamePaused' did not align with the executable, moving the member 'm_hPlayerViewEntity' before the first bool in this row results in correct code generation (also aligns properly in the disassembly of the game's code).
Rebuild of the 'CServerGameClients::ProcessUserCmds' and 'CPlayer::ProcessUserCmds' methods. The rebuild is pretty much identical to the original implementation, but with additional checks for the number of commands, and total commands in 'CServerGameClients::ProcessUserCmds'. In the future, additional clamps and checks between CPlayer and the recv'd UserCMD should be incorporated in these functions.
* Added and utilized auto lock/unlock mechanism.
* Rebuild CThreadFastMutex's 'Lock' and 'Unlock' methods in the SDK.
* Forced thread intrinsics and ID checkers as inline.
Don't run the 'ImGui_ImplWin32_WndProcHandler' if we are shutting down. During rare occasions when closing the game while hovering over the game window, 'ImGui_ImplWin32_WndProcHandler' is getting called while parts or all of the ImGui systems have been shut down, leading to a crash. The fix is to check if the engine is restarting or shutting down before running the ImGui window procedure logic.
Since the SDK loader (loader.dll) is taking care of loading the DLL with the process, the SDK launcher no longer needs to inject it. Replaced call 'DetourCreateProcessWithDllsA' with 'CreateProcessA', and performed additional cleanup
Moved CModule statics to a separate translation unit, preventing the linker to link unused stuff into the loader module, thus allowing us to drop the linkage of unused libraries.
Don't recreate it in the engine (LauncherMain) if its already created in the SDK. This solution toggles a hybrid between creating it in the SDK, or in the engine when -noworkerdll is passed to the loader.
Before, we had to do a hack of capturing the command line using GetCommandLineA, and then checking if a certain argument is present. This was required due to how early the GameSDK dll was loaded (the g_CmdLine object was far from initialized in the engine). Due to the loader refactor, the commandline can be used directly after creation in the game's entry point (which is the time the SDK is getting loaded). Therefore, no copies of the command line are required anymore.
This commit contains the following changes:
- Correctly ordered the initialization, and deinitialization of systems (first init = last shutdown).
- Factored out command line string copy in favor of game's implementation.
- Factored the R5Reloaded emblem print into its own function.
- Removed 'SpdLog_PostInit()', we can now directly call DevMsg() once SpdLog_Init() has been called, the logger callback sink deals with the formatting of the output.
- Fixed a bug where the logger did not print the correct color for 'SYSTEM_WARNING' and 'SYSTEM_ERROR' in the external console.
- Fixed a bug where the command line did not work when the game wasn't launched with the '-launcher' parameter.
- Logs now equally appear on the external, and in-game console windows.
* Override debug malloc functions, doesn't seem to be properly supported by the visual studio libraries, but it has to be done, else we crash trying to initialize the DLL (must use the same allocator as the game), a linker flag '/FORCE:MULTIPLE' had to be set to make this work, this should be set for only DEBUG builds in the future!.
* Fixed a bug in '_recalloc_base' where the allocation size was not calculated properly. Only the size was taken into account, but it should had been multiplied by the count.
* Stubbed additional CRT debug only memory debugging code, it will crash on our implementation in debug.
Else everything linked against tier0 will have to use the game's memalloc implementation, which requires it to run with the game process. Only limit this to DLL's that run with the game process.
This covers the entire source code, including thirdparty libraries if memstd.cpp is compiled.
Things left to be done:
- Utilize the debug methods of the CStdMemAlloc class by routing the debug variants to those.
- Move this to a standalone library, so tools and stuff not interfacing directly with the game engine can still link against tier0.
- Uncommented 'CCommand::Tokenize' and changed size types to 64bits. CUtlBuffer has been implemented so this code can be used.
- Removed extraneous string copy from 'CCommand::HasOnlyDigits', just iterate over the raw character pointer.
Added recalloc. _expand should be replaced as well in the nearby future. The functions should override the _xxxx_base variants instead, and be moved to a separate lib to cover the executable globally.
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.