86 Commits

Author SHA1 Message Date
Kawe Mazidjatari
e3429705eb Fix crash caused by CAppSystemGroup changes
* Moved 'm_pFileSystem' to 'CSourceAppSystemGroup' (actually belongs there, CAppSystemGroup has to be 0xA8 in size in order for 'm_bDedicated' to line up in 'CModAppSystemGroup').
* Prefixed all static functions with 'Static' to avoid name collisions.
2023-04-01 01:27:04 +02:00
Kawe Mazidjatari
122cd89aa9 Fix recursive initialization of convars/concommands
'CSourceAppSystemGroup::PreInit' could be called multiple times. Added check for its actual stage before running any initialization code. This fixes the recursive init problem.
2023-04-01 01:10:16 +02:00
Kawe Mazidjatari
9e7fbdca54 ConVar/ConCommand class refactor and bug fixes
* Refactored ConCommandBase, ConCommand and ConVar class to make them all virtual, so it could interface with the game's implementation.
* Properly initialize members for ConCommand and ConVar instead of just calling memset.
* Fixed bug in ConVar registration function causing the virtual base table pointer to point to the ConCommand implementation instead of the ConVar implementation.
2023-03-28 00:50:08 +02:00
Kawe Mazidjatari
a60609a0e8 Initialize concommand/convar as early as possible
'CSourceAppSystemGroup::PreInit' is as early as we can initialize them; CCvar gets initialized in 'CSourceAppSystemGroup::Create'.
2023-03-26 17:45:09 +02:00
Kawe Mazidjatari
aa332bad8a Format the function name out instead 2023-03-20 00:21:41 +01:00
Kawe Mazidjatari
a67de5bc58 Fix init crash on builds compiled with MSVC14
The MSVC14 (Visual Studio 2017) compiler doesn't support creating threads during dll entry. SDK fixed frame thread init has been moved to 'CModAppSystemGroup::Main'. SpdLog buffer flush worker init has been moved to 'SpdLog_PostInit', and 'SpdLog_PostInit' has been moved to 'LauncherMain'.
2023-03-18 21:42:30 +01:00
Kawe Mazidjatari
dc10b2305a Remove 'cdll_engine_int' from dedicated
No longer required.
2023-02-05 19:19:03 +01:00
Kawe Mazidjatari
e50601ed29 Rename 'g_bDedicated' to 'm_bIsDedicated' 2023-01-31 22:40:15 +01:00
Kawe Mazidjatari
34f69a5b1e Move crashhandler implementation to tier0 2023-01-31 22:13:40 +01:00
Kawe Mazidjatari
fd5d09d843 Fix small mistake
Input hooking must be done during SDK init, only DX should be initialized later due to late binding of game pointers.
2023-01-30 21:44:28 +01:00
Kawe Mazidjatari
f0512d7f92 Add 'CAppSystemGroup::Destroy' callback
* Add hook for 'CAppSystemGroup::Destroy'.
* Moved 'IAppSystem.h' header file to public.
2023-01-30 21:22:17 +01:00
Kawe Mazidjatari
c84622cfd6 DirectX hook refactor
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'.
2023-01-30 20:18:11 +01:00
Kawe Mazidjatari
a618990937 Detour code refactor
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.
2023-01-25 02:26:52 +01:00
Kawe Mazidjatari
2cd28ab304 Obtain debug overlay interface through factory 2023-01-22 13:08:02 +01:00
Kawe Mazidjatari
4ca0146499 EngineTrace improvements
Add server's EngineTrace to SDK, unfortunately it does not have a exposed factory interface unlike the client's version.
2023-01-21 16:24:36 +01:00
Kawe Mazidjatari
e9f907638f Improve plugin debugging code
Log using sdk loggers, warn if it failed to load.
2023-01-20 00:42:13 +01:00
Kawe Mazidjatari
dcf05a0adf CClientEntityList reversal
Slightly reversed CClientEntityList while looking around its singleton.
2023-01-20 00:28:49 +01:00
Kawe Mazidjatari
75406ab7bc Fix linker error for client DLL
Unresolved external symbol for g_pEngineServer VFTable.
2023-01-18 01:40:24 +01:00
Kawe Mazidjatari
21f4d0fa07 Initial working bots implementation
* Changed 'CClient' handle time to 'edict_t' which is an alias of 'uint16_t'.
* Changed 'g_pServerGameDLL' and 'g_pServerGameClients' init (obtain from factory instead).
* Use interface version macro's for obtaining factory pointers instead.
* Added 'g_pServerGameEntities'.
2023-01-16 21:09:21 +01:00
Kawe Mazidjatari
08ed169cf3 Only run game's exception filter if ours didn't handle it
This is required as otherwise the game's exception filter will be called after ours. If we didn't handle the exception, the game's implementation, or an exception handler associated to the exception raised by address will take care of it. Unlike the game's implementation, our exception handler does not handle unknown exceptions. We only do the low level stuff reliably.
2022-12-28 21:44:51 +01:00
Marvin D
b13c542ed1 CPluginCallbackList impl
* CPluginSystem allows for function callbacks now.
2022-12-12 17:16:39 +01:00
Kawe Mazidjatari
2501c37044 Globally convert all byte patterns to strings
These get reconverted to masked byte patterns at runtime. With the signature map cache system, this will only happen when building the cache.
2022-12-01 22:44:55 +01:00
Kawe Mazidjatari
009fd49e7f Null hlclient pointer on dedicated server properly
We have a pointer to a pointer, as we obtain the address in which the pointer to the hlclient structure is set.
2022-11-24 13:39:57 +01:00
Kawe Mazidjatari
d3b2893cdc Change ImGui config file path and use engine's FileSystem API
'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.
2022-11-24 10:45:42 +01:00
Kawe Mazidjatari
9c1efe20ad Remove ConVar and ConCommand singletons
Extraneous singletons.
2022-11-18 22:10:20 +01:00
Kawe Mazidjatari
7a065ccd12 Parse/reparse map list on playlists file initialization.
Map list will now initialize with the playlist. User could also reparse the map list by reparsing the playlists file.
2022-11-06 14:21:27 +01:00
Marvin D
82c60c466a CEngineTrace init 2022-10-13 16:48:56 +02:00
Kawe Mazidjatari
c4299cb758 Remove unnecessary launch params 2022-09-25 20:20:25 +02:00
Kawe Mazidjatari
af5c513ecd Remove useless parameters
'-lv' forces "low violence" which overrides the GAME path with _lv.
2022-09-25 15:33:28 +02:00
Kawe Mazidjatari
34a06147d7 Fix spelling errors
Overall spelling improvements and cleanup..
2022-09-09 19:47:31 +02:00
Kawe Mazidjatari
42dcfdbbec Rename R5Dev_ to SDK_ 2022-08-29 14:31:05 +02:00
Kawe Mazidjatari
1c29d5aed5 CEngineAPI vftable implementation 2022-08-29 01:14:53 +02:00
Kawe Mazidjatari
656b0be3ec Improve threading (work in progress)
* 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..
2022-08-27 18:57:56 +02:00
Marvin D
10b87b3bbc PluginSDK init and PluginSystem improvements
* Plugins can be loaded now (commented)
2022-08-21 00:59:55 +02:00
Kawe Mazidjatari
5284e8987f Use abstract class for CCommandLine 2022-08-20 03:15:51 +02:00
Kawe Mazidjatari
6764b5e56e Implement frame tasks
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'.
2022-08-19 21:33:31 +02:00
Kawe Mazidjatari
357e8640b0 Strip all dev flags from convars on dedi as well when '-devsdk' is passed 2022-08-17 02:02:44 +02:00
Kawe Mazidjatari
9f7d4f57d3 CCVarIteratorInternal cleanup
* Improve readability.
* Free allocated iterator memory.
* Enforce FCVAR_HIDDEN ConVar's in ImGui console (there are only 17 ConVar's marked 'hidden', and most of these are stryder/platform related stuff. This is usefull for if we ever wish to create a hidden cvar).
2022-08-14 02:51:15 +02:00
Kawe Mazidjatari
515487c63a Changed behavior of ConCommandBase::IsFlagSet (read description)
This commit breaks the indev branch for the time being (this will be solved very soon).
We no longer mask off dev flags from every commandbase, we only mask them off from the essential ones (map, connect, give, etc..), unless the SDK is launched as dev, then we mask everything off like usual, but this time at initialization and not whenever we encounter a var with this flag.
2022-08-13 20:21:32 +02:00
Kawe Mazidjatari
88b3336758 Many small code improvements and optimizations
* 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.
2022-08-11 11:07:45 +02:00
Kawe Mazidjatari
ade1de41a9 Implement abstract class 'IEngine'
Also reversed one new method: IEngine::GetPlaylistCount (gets the number of playlists read from the playlists file, the other 2 unknown methods after this one also do stuff with the playlists, but rather on KeyValues level, one checks if something exists i think, the other returns a const char. Haven't ran these yet).
2022-08-09 11:53:33 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Kawe Mazidjatari
81374e8682 Add VClientEntityList003 interface 2022-07-24 13:40:37 +02:00
Kawe Mazidjatari
8463811bb0 Remove unnecessary cast for string format 2022-06-17 18:29:17 +02:00
Amos
e07f59adbe Fix detach bug in PRX 2022-06-09 13:30:36 +02:00
Kawe Mazidjatari
326b751934 Light optimizations 2022-06-07 13:46:18 +02:00
Kawe Mazidjatari
bbe885689a Add define for compiling launcher for dedicated servers
This sets the selected mode to server by default upon launch
2022-06-06 01:31:20 +02:00
Kawe Mazidjatari
e6ef3d71f1 Rename variable 'g_pIConsole' to 'g_pConsole' 2022-05-27 02:46:13 +02:00
Kawe Mazidjatari
47d2e4c915 See description
* Added new function 'GetAvailablePlaylists' to all VM's.
* Moved function 'GetAvailableMaps' from UI VM to all VM's.
* Improved logic behind 'GetAvailableMaps'.
* Server browser and SQVM now rely on 'MOD_GetAllInstalledMaps'. This new function populates the global vector 'g_vAllMaps' with all installed maps.
* Improved 'KeyValues' structure to use union for shared members.
2022-05-27 02:08:51 +02:00
Kawe Mazidjatari
efb7c36408 Light project restructure
Moved server/client headers and implementations into dedicated subfolder.
Renamed Some classes to match the game binary (e.g. CBaseClient is now CClient).
Removed redundant files.
2022-05-20 11:52:19 +02:00