188 Commits

Author SHA1 Message Date
Kawe Mazidjatari
89bb7f35c8 KeyValues: fix singleton accessor compile errors
Make each instance implement the accessor instead of the KeyValues system itself.
2024-04-05 17:46:51 +02:00
Kawe Mazidjatari
51986ec1c6 VstdLib: reimplement CKeyValuesSystem
NOTE: reimplementation is for tools only, the game and SDK still uses the engine's implementation.
2024-04-05 17:36:37 +02:00
Kawe Mazidjatari
edc52ad669 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-04-05 17:19:32 +02:00
Kawe Mazidjatari
144d5f62e1 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2024-04-05 16:41:09 +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
21f64bc572 Adjust logging contexts
Adjust the context properly, some were wrong (e.g. 'ENGINE' in 'COMMON' code).
2023-07-22 21:14:04 +02:00
Kawe Mazidjatari
be93929b26 Map out CKeyValuesSystem class
Mapped out members of the CKeyValuesSystem class. Singleton accessor has also been declared inline in this commit.
2023-07-02 02:51:12 +02:00
Kawe Mazidjatari
3f8baf6f68 Allow setting compile options for specific targets
Previously, it was all controlled from the global init (applied to all projects), but some projects need different options. With these changes, you can disable the common options applied in the 'add_module' macro, and set your own if desired.
2023-06-17 00:45:27 +02:00
Kawe Mazidjatari
95316ab1c8 Improve code for uniform random stream
Use 'std::lock_guard' for mutex management. Also fixed a compiler warning that got triggered by having a mutex unlock placed at an unreachable code path in 'CGaussianRandomStream::RandomFloat'.
2023-05-15 20:45:57 +02:00
Kawe Mazidjatari
11864f8902 Add all public headers to CMake projects
Added all public headers to CMake projects, also moved some files around in the public directory. Translation units have been moved to the libraries that were responsible for implementing them, as this game is monolithic.
2023-05-15 14:47:03 +02:00
Kawe Mazidjatari
9f44bcc818 Treat compiler warnings as errors
Treat them as errors globally. Most of the time a warning is a bug, or problem in code that could be solved in a different (better) manner. Thirdparty code have this disabled. The warnings as errors option can be globally disabled through the CMake GUI, but this is not recommended.
2023-05-15 09:44:26 +02:00
Kawe Mazidjatari
6a86ae2606 Cleanup CMakeLists files
Light cleanup in CMakeLists files. Split protocols and improve filter names.
2023-05-14 17:36:08 +02:00
Kawe Mazidjatari
8dbc2024c6 CMake code improvements
Use the 'add_module' macro to add modules without creating duplicate code. This macro also takes a reuse PCH as parameter, so modules that need a precompiled header, could reuse those from different targets that compile them. This commit also restructures the group order of the generated solution files for easier code navigation.
2023-05-13 00:14:53 +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
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
Kawe Mazidjatari
8eea3546a6 Add reason to RCON client disconnect 2023-04-30 12:03:17 +02:00
Kawe Mazidjatari
c6748edcc9 Reboot RCON server if 'net_usesocketsforloopback' changed
Reboot so it could update accordingly, just like the game's UDP sockets.
2023-04-30 11:34:47 +02:00
Kawe Mazidjatari
50b3273101 Add change callback for 'sv_rcon_maxconnections'
If 'sv_rcon_maxconnections' is set higher than current auth socket count, reopen listen socket. If its set lower, close all sockets until auth socket count matches 'sv_rcon_maxconnections'. Sockets are getting closed in reverse order, so the netcon that connected last will be disconnected first.
2023-04-22 16:51:18 +02:00
Kawe Mazidjatari
be61c93c85 RCON system improvements
* Added more error handling throughout code.
* Marked function parameters 'const' where possible.
* Updated comments.
2023-04-22 16:02:54 +02:00
Kawe Mazidjatari
179bd31ee6 Initial large refactor of the RCON implementation
* Decoding and encoding is done into a single buffer, from raw buffers to avoid extraneous copies.
* Added base class holding all core logic for encoding, decoding, receiving and processing of the RCON protocol. This code was initially identical between all implementations of RCON, deduplicating this avoids bugs.
* Added more sophisticated error handling, stop right away when decoding for example fails.
* Added ability to have more than one active authenticated net console on the server. Controlled by cvar 'sv_rcon_maxconnections' (default 1).
* Max packet size for accepted, but not authenticated sockets is now controled by cvar 'sv_rcon_maxpacketsize' (default 1024).
2023-04-19 01:35:31 +02:00
Kawe Mazidjatari
85f586bd2e RCON server improvements
* Prevent attacker from being able to abuse and overflow the banned list vector.
* Improved IPv6 comparison performance.
* Change size fields of payload frame from unsigned to signed.
* Close all accepted sockets on RCON server shutdown.
2023-04-16 17:51:48 +02:00
Kawe Mazidjatari
21ea4dff52 Return maps based on partial input
Return maps based on partial input from user in main 'map' completion callback function.
2023-04-08 18:19:14 +02:00
Kawe Mazidjatari
e1f0e72af4 /W4: Fix type demotion warnings
Explicitly demote to 'int' to suppress pesky compiler warnings.
2023-04-02 16:03:01 +02:00
Kawe Mazidjatari
afcbd42e90 /W4: Fixed bug caused by dead code
Fixed bug caused by calling CBaseFileSystem::Size on a closed file handle, the results weren't used at all which triggered the warning.
2023-04-02 09:35:25 +02:00
Kawe Mazidjatari
678199d6ca /W4: Fixed name shadowing warning 2023-04-02 09:23:53 +02:00
Kawe Mazidjatari
cd40081a20 Rename RPak header magic constant to 'RPAK_MAGIC'
A more descriptive name.
2023-04-02 01:26:38 +02:00
Kawe Mazidjatari
4357c9dbf3 Fix many compiler warnings
Fix many compiler warnings indicating potentially unwanted implicit conversions/truncations.
2023-04-02 00:59:24 +02:00
Kawe Mazidjatari
16ea75d5a2 Fix clang-cl compile errors
Cannot concatenate __FUNCTION__ macro like this.
2023-04-01 13:10:22 +02:00
Kawe Mazidjatari
29616f4810 Rename 'g_vAllMaps' to 'g_InstalledMaps' 2023-03-31 00:35:01 +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
5a0be4a275 Fix ConVar crash
Fix crash caused by vftable error. Since we are not implementing anything, but only interfacing with the game executable, we need to rename the IConVar variant's due to name ambiguity. Re-defining them in the actual class will lead into vftable misalignment and cause a crash (or other undesired behavior) as a result.
2023-03-28 01:24:55 +02:00
Kawe Mazidjatari
d12ecd80d8 Default 'GetSymbolForString(CaseSensitive)' creation overload to true
Default creation overload of 'GetSymbolForString' and 'GetSymbolForStringCaseSensitive' to true.
2023-03-25 17:31:41 +01:00
Kawe Mazidjatari
0f58137167 Light symbol cleanup 2023-03-25 17:26:42 +01:00
Kawe Mazidjatari
371e15db41 Fix many verbose compiler warnings
Many compiler warnings regarding implicit conversions.
2023-03-18 16:45:43 +01:00
Kawe Mazidjatari
cac2c6a917 Make 'sig_getadr' a console command
Changed to hidden ConCommand.
2023-03-15 21:11:20 +01:00
Kawe Mazidjatari
e12de45eaa Light RTech code cleanup
Use dedicated function for returning pak status as string instead of std::map. reduced compiled code size by 10kb.
2023-02-26 19:43:02 +01:00
Kawe Mazidjatari
3f2216337e Add completion for pak decompress
* Renamed 'rtech_decompress' to 'pak_decompress'.
* Added completion func for 'pak_decompress'.
2023-02-19 13:38:06 +01:00
Kawe Mazidjatari
7649d16e6a Rename 'CAutoCompleteFileList'
Rename 'CAutoCompleteFileList' to 'CBaseAutoCompleteFileList' (official name).
2023-02-19 13:26:38 +01:00
Kawe Mazidjatari
354e25633c Don't compile for client.dll
Don't compile 'CC_CreateFakePlayer_f' for the client.dll.
2023-02-06 23:01:53 +01:00
Kawe Mazidjatari
f9245a4070 Fix bug in RPak auto completion
RPaks that have a name larger than 123 chars will have their extension delimiter removed due to the way 'CAutoCompleteFileList::AutoCompletionFunc' works. Ideally this functions receives a full rewrite in the SDK to support dynamic extension lengths.
2023-02-06 21:46:03 +01:00
Kawe Mazidjatari
e4df03c4f2 Add RPak completion callbacks
Add completion for 'pak_requestload' and 'pak_requestunload'.
2023-02-06 02:16:02 +01:00
Kawe Mazidjatari
836839e6a5 Add completion logic for 'give' command
* Implemented class 'CAutoCompleteFileList' (features engine's implementation for 'AutoCompletionFunc').
* Added completion callback for 'give' command.
2023-02-05 23:01:01 +01:00
Kawe Mazidjatari
ddba8cf9b8 Install more robust 'map' completion callback
This one will list all maps, as maps should have a vpk file to be loaded correctly due to the way rpak files are formatted internally to be loaded/parsed.
2023-02-05 21:13:03 +01:00
Kawe Mazidjatari
c17913bfe9 Light cleanup of pak load api var names
* Rename some pakload api vars.
* Removed 2 duplicate pointers from (g_ClientState_Shifted and g_pakLoadJobID).
* Removed unnecessary signonstate check in 'Mod_ProcessPakQueue' for dedicated.
2023-01-31 16:09:30 +01:00
Kawe Mazidjatari
5f56c23af2 Compile CRConServer for gamesdk
RCON can now be used on the host game as well (previously dedicated exclusive).
2023-01-29 16:07:02 +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
e281aea990 Fix client.dll/dedicated.dll compile errors 2023-01-24 18:39:12 +01:00
Kawe Mazidjatari
19447f1122 Improve debug draw depth test toggle logic
* Add box depth test cvar from engine for 'CBaseAnimating::DrawServerHitboxes'.
* Use noDepthTest field from OverlayBox_t instead of the cvar.
2023-01-24 12:05:09 +01:00
Kawe Mazidjatari
4ebe031341 Disable BHit raytrace z-buffer by default 2023-01-22 12:28:48 +01:00