The WebSocket system is now fully split up. The global network module initialization is moved to DLL init so the websocket class could be used for anything. The LiveAPI system now also mostly runs in the server frame thread, the convar change callbacks still need to be latched to the server frame thread however.
Properly implement the ConCommandBase and ConCommand classes so we could statically construct all ConCommand objects in the global scope of each translation unit, this way we don't need to put them in a global file and deal with preprocessor directives to compile then in/out for certain projects.
Fix syntax error on page protection flags check when determining whether we encountered a return address. Also limit the amount of dynamic memory allocation calls, offer a large enough static buffer where we can just write into when we crash without needing to alloc or realloc anything. Also removed some hacky code like the whitelist set, and made the module handle array static into the class as well. The CrashHandler singleton is now a static class instance.
Moved construction logic to separate method, and call that from constructor instead. When willing to change the entire context on the same object, you can now just call 'InitFromXXXX()'. Previously, a whole new object would be generated and copied into ours, and then deleted again.
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.
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.
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.
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.
After the CMake refactor, this became broken as the 'DEDICATED' define does not work in tier0 headers. These were the last ones; moved to the DLL project instead. This commit also fixes a bug where the command line file gets parsed twice, while there was already a global containing the args (initialized on DLL init).
* All libraries have been isolated from each other, and build into separate artifacts.
* Project has been restructured to support isolating libraries.
* CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example).
* Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp).
TODO:
* Add a batch file to autogenerate all projects.
* Add support for dedicated server.
* Add support for client dll.
Bugs:
* Game crashes on the title screen after the UI script compiler has finished (root cause unknown).
* Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
Fix initialization order bug; 'CheckCPU()' and 'MathLib_Init()' have to be initialized before any other function is called. 'strstr(...)' also uses intrinsics not supported on some processors.
Unregister gamesdk's crash handler if -noworkerdll is passed. This is required as both crashhandlers will be called during an exception, and on one, the whitelist wouldn't work.
Initialize console and spdlog before anything else that is using the console to log errors to (in this case, winsock init errors were never getting logged).
Refactored code to only feature game pointers, this avoids the unnecessary overhead that was previously caused by creating our own device pointers, swapchain, etc.. This commit also fixes the classic 'black screen' problem when the aspect ratio is set to 4:3 - 5:4, however, a similar bug returned for this causing Dear ImGui to not draw at all when the aspect ratio is set to 4:3 - 5:4. This commit also moves the old HwndProc hook to 'CGame::WindowProc'.
Kept in for dedicated as the main executable imports the same DLL used for 'EnumDisplayDevices'. No GPU will be displayed if there is none installed or set as primary.
This allows for loading the game with the client.dll without loading the main worker/sdk dll. gamesdk.dll is imported by the game executable, so we cannot circumvent its loading without some hacks, so instead, we just check if -noworkerdll is passed and not perform any init if its present.
Check for SSE 3, SSSE 3 and POPCNT in CheckCPU(), and SSE, SSE2 in MathLib_Init().
This should fix all crash cases caused by launching the game on unsupported CPU's.
* Use c++ methods as much as possible.
* Use enum types for accessing NavMesh objects from array.
* Use size_t for for loops when testing against size types.
* Don't compute strlen twice of more on the same string.
* Don't use unnecessary c string casts if there is a method with a std::string overload.
* Don't create string objects from string pointers if we could use them directly.
* Don't initialize RCON password twice on each change, and don't set if the new password equals the old.
* Renamed 'r5apexsdkd64.dll' to 'gamesdk.dll'.
* Added required dedicated parameters to code instead.
* Bug fixes around CCommandLine class (fixed misaligned VTable indexes).
* SDK now supports being directly launched by the game executable.
The SDK launcher will pass '-launcher' to the game, which indicated its being launched by the launcher. If the game does not receive '-launcher', it assumes its being launched directly from the game executable, which will instead load 'startup_(dedi_)default.cfg'.
The sdk dll's are now added to the game's IAT by their dummy exports allowing for them to be loaded when the exe is loaded (the dll's do everything on init).
* Dedicated SDK now supports ASLR enabled executables.
* Complete removal of CEngineClient on the dedicated server.
* Complete removal of gHLClient and g_pHLClient on the dedicated server.
* Performance improvements for the dedicated server frame loop.
* ConVar 'CVCallback_t' structure rebuild.
* Reduced overhead throughout SDK.
Systems where not getting shutdown properly. For dedicated 'ExitProcess()' in the GameDLL caused 'abort()' to get called even when systems where shutdown properly. We call TerminateProcess after all systems have shutdown properly in the SDK and GameDLL.
* Ansi colors can now be enabled with the '-ansiclr- flag.
* All loggers have been optimized and are all initialized only once at process startup.
* New hook for 'Warning()' print function with warning level.