161 Commits

Author SHA1 Message Date
Kawe Mazidjatari
f8fe90874a Only compile signature results in dev mode 2024-04-05 16:24:45 +02:00
Kawe Mazidjatari
723052eb6f Improve CPU detection code
Structure now fully aligns with that of the engine, with exception of newly added fields for the SDK (new fields are marked in the structure definition).
2024-04-05 16:21:45 +02:00
Kawe Mazidjatari
71b0781715 Utilize 'DevMsg()' for uncertain builds only
Only uncertain builds will contain DevMsg()/DevWarning() prints. For retail, Msg() and Warning() should be used instead.
2023-08-21 19:12:29 +02:00
Kawe Mazidjatari
26c10dfd11 Restructure concommandbase classes
Move all classes deriving from ConCommandBase to a single file, and split out CCommand, CCvar, CCvarUtilities etc to their own files. This makes it possible to use CCommand and stuff in external tools without linker errors/warnings.
2023-08-04 14:32:06 +02:00
Kawe Mazidjatari
e7a4a6f161 Make 3 versions of SigCache files
The 3 versions are now:
- cfg/server/startup.bin
- cfg/client/startup.bin
- cfg/startup.bin

The last one is used by the GameSDK. Bumped header version to 6.
2023-07-20 22:16:21 +02:00
Kawe Mazidjatari
a0f0b79266 Add callback for registering script constants, and added 'LISTEN_SERVER'
All listen server code should be compiled out of the scripts using 'LISTEN_SERVER'. The constant must have a non-null value.
2023-07-19 18:52:00 +02:00
Kawe Mazidjatari
193abdc18a Remove scriptfunc stubs
Not really ideal, needs a different solution.
2023-07-19 17:17:38 +02:00
Kawe Mazidjatari
ee1fdca7a9 Register admin panel/core server scriptfunc stubs for client.dll
Stubbed to avoid compile errors.
2023-07-19 16:19:34 +02:00
Kawe Mazidjatari
ddfaea6ce2 Fix client.dll loading
* Moved dedicated server command line parameter init to 'init.cpp'.
* Registered 'SV_Main' on the client, this is engine code (lower level 'local' server wrappers).
* Disabled registration of Weapon_Bolt, although this is shared game code, this particular file is only used for the SERVER at this moment.
* Added the '-noserverdll' command lien parameter to instruct our loader.dll to load the client.dll instead.
* Adjusted the loader and sdklauncher project to support the loading of client.dll.
2023-07-19 16:00:36 +02:00
Kawe Mazidjatari
d5f35349a8 Decouple script function registration
Nicely decouple them. Everything server and client are now grouped as they should. The Ui namespace has been merged with Client.
2023-07-19 02:12:56 +02:00
Kawe Mazidjatari
3637af34f6 Initialize the script register callbacks 2023-07-18 00:18:04 +02:00
Kawe Mazidjatari
b84cfc2760 Optimize CMaterialSystem::Init() for dedicated
Hook 'CMaterialSystem::Init()', and only load the 'startup.rpak' file, as that's all we need. This pak file might also not even be needed on the server, but removing this requires rebuilding 'common_early.rpak' to drop all texture/material assets and their references. The dedicated server is now also linked to a newly added 'No-DirectX' version of the materialsystem for patching.
2023-07-17 11:54:14 +02:00
Kawe Mazidjatari
434b04379a Light string formatting improvements
Nothing major this time around.
2023-07-04 22:36:29 +02:00
Kawe Mazidjatari
2ca1a290e2 Revert back to using verctors for detours
Enabling LTCG caused the emplacement order to be different, which is most likely due to additional optimizations for the binary search logic. Reverted to fix this bug.
2023-07-03 15:37:25 +02:00
Kawe Mazidjatari
7762c4b2ce Light refactor of the IDetour interface
- 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.
2023-07-03 13:37:41 +02:00
Kawe Mazidjatari
f6f3c7f9a2 More code cleanup
- 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.
2023-07-03 02:14:39 +02:00
Kawe Mazidjatari
a82b4c950c Compute MHz instead 2023-07-01 21:45:32 +02:00
Kawe Mazidjatari
9e6b0e567f Port everything to CCommandLine
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.
2023-07-01 01:20:47 +02:00
Kawe Mazidjatari
708a249507 Internal memalloc replacement
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.
2023-06-25 11:37:52 +02:00
Kawe Mazidjatari
f2615b10de Improve CClient class structure
* Added structure for send/recv datablocks vtable.
* Mapped out CClient structure more.
* Fixed incorrect tick member offsets for CClient.
2023-06-22 00:33:00 +02:00
Kawe Mazidjatari
91ec38645c Formatting improvements in init.cpp
Make it easier to read on a vertical monitor.
2023-06-19 15:12:46 +02:00
Kawe Mazidjatari
51ea9c7c4f CUserCmd hardening
Fix several exploitable bugs in the CUserCmd class. Some of these have been used to exploit/cheat in-game. Fixes contain:
- Camera position clamping (the only patch that hasn't been tested yet!)
- Weapon activity exploit, allowing player to infinitely throw ordnances, and perform other 'cheats'.
- Akimbo exploit + server crasher, allowing client to set multiple inventory weapons as active. The active weapon index bounds were also not checked, a properly crafter CUserCmd message would therefore be able to crash the server.

Note that this does not fix all issues related to the UserCmd class; further reversing and testing revealed there is more to be fixed, these fixes will get implemented with a future commit.
2023-06-13 17:43:32 +02:00
Kawe Mazidjatari
3d18be9ebb Add splitscreen types to SDK
R5 'MAX_SPLITSCREEN_CLIENTS' appears to be max 1.
2023-06-03 18:10:32 +02:00
Kawe Mazidjatari
8e379457bf Fix server code crasher in 'FireWeaponBolt'
The function 'FireWeaponBolt' calls 'CreateWeaponBolt' to create a bolt entity, but it can return NULL. 'FireWeaponBolt' does NOT check for NULL and derefs the pointer regardless. This rarely happens though; in all cases, it was caused by a defect in scripts. Code has been hooked to throw an engine error instead of crashing.
2023-05-31 23:58:10 +02:00
Kawe Mazidjatari
552f5f750c Fix crash in 'CClient::ActivatePlayer'
Set the persistence fields to 'ready' in 'CClient::ActivatePlayer', before executing the rest of the function. Previously, it was set in 'CVEngineServer::PersistenceAvailable', but this is too late. The function 'FairFight_Init' was actually 'CClient::ActivatePlayer', and thus it has been moved to the correct file, and the old file defining it previously has been removed.
2023-05-15 17:19:18 +02:00
Kawe Mazidjatari
8d38de1ce0 Move client only code from rtech libraries
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.
2023-05-13 18:03:48 +02:00
Kawe Mazidjatari
af21798a12 Fix crash caused by NULL Cbuf function pointers
Register was missing (code was moved elsewhere).
2023-05-11 21:05:09 +02:00
Kawe Mazidjatari
f120354e96 Initial port to CMake
* 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!
2023-05-10 00:05:38 +02:00
Kawe Mazidjatari
359820615f Move low level code to tier0/tier1
Moved to tier0/tier1 so it could be compiled into a static library in the future.
2023-05-06 22:59:01 +02:00
Kawe Mazidjatari
75ccebb4b6 Squirrel system restructure
Properly decouple squirrel and game code. This makes it easier to reverse engineer more of this squirrel system, and to compile them as individual libraries later on when moving to CMake to significantly decrease compile times.
2023-05-06 16:23:56 +02:00
rexx
bcc51460bc
new new modsystem pr (#96)
* modsystem v2 initial commit

* call CModSystem::Init

* clean up custom cvar value handling

* add mod script compiling support

* add error check to script rson loading

yes this error is a duplicate but this one exits the game

* fix typo

* fix compile error
2023-05-02 19:26:49 +01:00
Kawe Mazidjatari
d46061a55a Don't log GPU device on dedicated 2023-04-29 12:16:09 +02:00
rexx
f520cab44b fix static prop exceptions
This fixes the exceptions that were caused by loading ported bsps with replaced models
CStaticProp::Init was using static prop lump data to request non-existent skins due to the replaced models, causing invalid material pointers to be fetched.
When encountered, these skins will be forced to 0 and an error will be printed.
Ideally these issues are fixed from within the bsp file before they are shipped.
2023-04-18 16:56:35 +01:00
Kawe Mazidjatari
1d04f837f8 Fix many high level compiler warnings
* Put initializer values inside brackets.
* Put logical AND conditions within parentheses.
* Put assignments within conditional statements within parentheses.
* Mark unused variables as such to suppress compiler warnings.
* Fix vftable shadow warnings caused by ConVar::CreateInternal (does not implement, only interface. Renamed to yield desired behavior).
* Fix 'never' initialized class members for 'CCVarIteratorInternal'.
* Return values in interface vftables that cannot be pure virtual.
2023-04-08 19:00:28 +02:00
Kawe Mazidjatari
a4a2f34c10 /W4: Fix signed/unsigned mismatch
This commit fixes warnings and bugs caused by signed/unsigned mismatch.
2023-04-02 12:09:43 +02:00
Kawe Mazidjatari
7cc58a642f Rename and mark detour globals as static
Renamed to 'g_DetourVector' and 'g_DetourSet', marked as static.
2023-04-01 13:17:23 +02:00
Kawe Mazidjatari
69e6c4718e Rename static 'Init' method in ConVar
Renamed to 'StaticInit' to avoid base class override. Also commented '__restrict' qualifiers.
2023-04-01 13:09:02 +02:00
Kawe Mazidjatari
47aabf244b Remove redundant tier1 files
These files are no longer necessary.
2023-03-28 01:30:09 +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
68b5fc24fb Remove CSigCache singleton from PCH
Removed from precompiled header, and only used where needed.
2023-03-20 00:24:40 +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
4e7626dc4d Update system info formatting
Improve formatting; move logical processor count and virtual memory size to the same line.
2023-02-23 23:50:40 +01:00
Kawe Mazidjatari
526179878d Fix client.dll compile error
Must be included in init.cpp.
2023-02-18 13:22:34 +01:00
Kawe Mazidjatari
270cd8f1e7 Activate hook for server side CPU statistics 2023-02-18 00:32:29 +01:00
Kawe Mazidjatari
367b2cf5bc Renames and new setters for CNetChan
* Renamed hooking class to 'VNetChan'
* Added new setters for setting the remote frame times, and the remote server CPU statistics.
2023-02-18 00:05:55 +01:00
Kawe Mazidjatari
cd8b5d3111 Improve CPU info log format
Pack level cache and descriptors on the same line.
2023-02-11 16:25:26 +01:00
Kawe Mazidjatari
dc10b2305a Remove 'cdll_engine_int' from dedicated
No longer required.
2023-02-05 19:19:03 +01:00
Kawe Mazidjatari
df7e80077f Make sure winsock errors always gets logged
Make sure it always gets logged to the disk.
2023-02-04 19:14:45 +01:00
Kawe Mazidjatari
ad71360dcd Don't register 'HSV_Main' on client dll 2023-01-31 20:55:15 +01:00
Kawe Mazidjatari
b33c8794a0 Reorder registration order
Slight reorder, removed 'VStudioRenderContext' from dedicated.
2023-01-31 17:21:16 +01:00