This commit fixes an issue where the console window would shrink with 1 unit when calling 'SetConsoleBackgroundColor'. The bottom should be incremented by 1 each time its getting called, as it appears to be decremented again in WINAPI 'SetConsoleScreenBufferInfoEx'.
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.
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.
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.
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.
The shutdown patch from commit '48c2401c' created another bug where all inputs get collated, and once drawn, emitted to the ImGui interfaces. The patch has been undone, and the 'ImGui_ImplDX11_Shutdown()' call has been placed before 'ImGui_ImplWin32_Shutdown()', as this was how it was performed according to the official documentation and examples provided by Dear ImGui. The call 'ImGui::DestroyContext()' has also been added (taken from the examples). Removed redundant static global bool.
Fix a rare crash that occurs in AMD driver code, when ImGui shutdown was called. The crash did not occur if the library was shutdown after having rendered one of the ImGui panels for one frame. The fix is to just never call 'ImGui_ImplDX11_NewFrame()', 'ImGui_ImplWin32_NewFrame()' and 'ImGui::NewFrame()', 'ImGui::EndFrame()', 'ImGui::Render()' if none of the windows are visible. code has been tested on a system that would trigger the crash, and after the patch, the crash no longer happened.
This commit significantly reduces output code size, and a noticeable increase in performance. Changes are:
- Removed all extraneous std::string and std::vector copy constructions; use raw pointers instead to boost performance.
- Marked simple getters in CModule inline.
- Marked several functions in CModule const.
- Slightly reordered CModule class.
- 'CMemory::CheckOpCodes' and 'CMemory::Patch' now take a const reference.
Moved, and renamed to 'CreateTextureResource'. Reason for move was that the rtech libraries is used by server and client, and using this on dedicated requires linking directx libraries, as it has to be hooked (even when not used). Moved to client only code to avoid having to hook it. Material system is no longer linked to the dedicated server module, as nothing from it was getting used.
* 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!
RCON upgrade with additional logging system improvements:
* Netconsole's can now log received messages in color, even when the RCON server has ANSI colors disabled; logs are fully composed locally.
* RCON server now also sends the log type over the wire, along with the (already existing) context.
* SDK logging code is now shared with the standalone netconsole application.
* Improved logging readability for the standalone netconsole application.
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'.
This menu isn't in much need, in fact; we didn't even knew it existed until someone started to complain about it! Currently, the drawing logic isn't setup to support this properly either. Disabled the shortcut menu.
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.
TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
This commit fixes a bug causing all input to be lost. This gets triggered when either the console or server browser window is drawing while the user tabs out of the full-screen window, or resizes the game window.
'ImGuiConfig::Load()' was loading from the new path, however 'ImGuiConfig::Save()' was not. Defined path as constant expression to avoid this problem in the future. Also loading the files through the engine's API from now on.
* Fix history duplication by removing trailing white space characters from submitted commands in console.
* Fix out of range exception caused by caching svConVar.size() in CConsole::BuildSummary while we are modifying it.
* Fixed memory leak caused by extraneous Strdup calls in CConsole.
* Renamed variables and structure members, static vars in id3dx.cpp are not prefixed with s_, IBrowser_Config is now m_BrowserConfig.
* Performed code cleanup in id3dx.cpp.
Previously we enabled/disabled the input system each frame, depending on the state of the ImGui windows. This commit changes the behavior into only enabling/disabling when the menu's are closed (either through the keyboard or the close button).
I added a simple callback to ImGui::Begin which will be called when the close button on the ImGui panel is pressed and the callback pointer isn't nullptr, this was required as there was otherwise no way to determine when the close button was clicked.
* Replaced the boolean 'fatal' parameter with a error code parameter, anything non-null will prompt a message (fatal) and terminate the process with given error code.
* Fixed bug where the global ostreamsink for spdlog did NOT get cleared in 'SQVM_PrintFunc' when cvar 'sq_showvmoutput' was < 3. Moved to global scope.
* Added error message for when detouring the process has failed, with the error code.
* Only call 'Plat_GetProcessUpTime()' once per log, (improves performance and fixes bug where the error message box would show a different time stamp than what is logged into the console or file).
* All TIER0 loggers only log to notify and console when the SDK engine has fully initialized and detoured all functions.
* Only run '_DownloadPlaylists_f()' in the main thread, schedule for next frame if we aren't in the main thread. (this should fix crash cases related to disconnecting from the game).
* Locked read/write to CBrowser members (thread for obtaining the server list is detached, but once the 'slow' post operation in this thread is complete, mutex lock is acquired (locking the render thread if the browser is active) to set the string members of CBrowser, this operation is very fast as we only set the string and the color after the http post operation (this never caused a crash, but the behavior without any lock mechanism is technically undefined regardless).
* Obtain the host name dynamically from the ConVar 'pylon_matchmaking_hostname' (atomic operation). Initial approach was deleting the whole master server pointer just to construct a new httpclient object..
When fatal is set, the function will show a error dialogue, which will halt the process and close when the message is dismissed. Else we will end up in a crash.
Run all Cbuf_Execute calls in the main thread. This should fix every problem related to (but not only):
* Connecting to server while RUI dialogue is still open.
* Connecting to server while in an active game.
* Running 'weapon_reparse'.
* 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.