332 Commits

Author SHA1 Message Date
Kawe Mazidjatari
54ef6a78e8 RTech: finalize decouple of websocket system + improvements
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.
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
2b3b88518f Link against DirtySDK
Link against recently added libraries.
2024-04-05 18:29:54 +02:00
Kawe Mazidjatari
7c3d093c53 Protobuf: check version on startup
Properly check as per documentation.
2024-04-05 18:27:10 +02:00
Kawe Mazidjatari
db2b42cb03 ImGui: heavy optimizations to text logger (WIP)
This code originated from an imgui code editor, where it would make sense to have per-character colors. But for the console, we only ever do 1 color per line. Just store the string and one color instance, this also allows us to just take the string instead of manually reconstructing it which is very slow. The code now also only stores 32bits for color (per line) instead of 128 bits (ImVec4) as we only ever need to convert it once.

As a result, a bunch of rendering code could be dropped, and the pass filter is now also very fast as we don't need to reconstruct the string to check for the filter, we just pass a char* in which doesn't cost any perf.
2024-04-05 18:19:40 +02:00
Kawe Mazidjatari
609d705a0c Tier1: static construction of ConVar objects during link time
Fully implemented ConVar class so we could statically construct all SDK convars, this avoids a level of indirection, and allows for creating ConVar's everywhere in the project.

This patch also removed the settings tab of the ImGui server browser, as it has threading issues, while it technically never caused a crash yet, it has been removed as there was no point keeping it vs the work required to make it thread save (it only managed 2 convars which are perfectly manageable through cfg's or the in-game console).

Also temporarily disabled the creation of ConVar's in the mod system due to a memory leak, we would allocate and register a convar based on details parsed out of a mod file definition, but never unregister and free it.
2024-04-05 18:13:32 +02:00
Kawe Mazidjatari
d6b14fa12c Statically construct all ConCommand
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.
2024-04-05 18:13:31 +02:00
Kawe Mazidjatari
ff484c3f52 Engine: fix RCON bugs and improve security
- Upgraded hashing algorithm to SHA-512, and store the raw hash instead of a string copy, which is way cheaper to compute and compare.
- Only ever close sockets once in CRConServer::SetPassword().
- Made the game server & game client RCON singletons static.
- Added calls to gracefully shutdown RCON server and RCON client on Engine/SDK shutdown.
- Added more prints so RCON user knows when its shutdown, or when their password change is in effect, etc.
- Fixed bug where we could tokenize an empty string when we dispatch a console command.
2024-04-05 18:07:38 +02:00
Kawe Mazidjatari
99af2877a6 Tier1: fully implement bitbuf classes
All routines are now fully implemented. This was delayed on purpose as some bit buffer functions have changed due to the use of 64bit integers for sizes, and also the coord types. The porting of this has to be done carefully; all
reimplemented functions have been changed to feature 64bit integers (where necessary) for syze types, and all values in coordsize.h have been tweaked to reflect the changes in the R5 engine 1:1, allowing us to properly implement the coord bit buffer functions as well.
2024-04-05 18:02:39 +02:00
Kawe Mazidjatari
ee64d07e5b Tier0: emit text to debug console if debugger is attached
Small quality of life improvement while debugging the application.
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
0d390955fd Engine: partial rebuild for data block sender/receiver
This patch partially rebuilds the data block sender/receiver. The receiver leaks memory if the sender sends a bogus LZ4 packet, it would allocate memory to copy the encoded data into, from which it would decode it to the scratch buffer, but it would never deallocate this temporary buffer is the LZ4 decoder failed. This has been fixed. The second reason to rebuild these was to look into potential compression optimization. The data block rebuild now also features the latest LZ4 codec.
2024-04-05 17:59:53 +02:00
Kawe Mazidjatari
f5424f4bd0 Core: use forward slash when formatting logger files
Minor cleanup
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
6434b8abe9 Tier0: crash handler refactor & bug fix
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.
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
2b06bc8abb Add ZSTD to SDK 2024-04-05 17:53:22 +02:00
Kawe Mazidjatari
fcf3a09418 Make singletons use static memory
Avoid heap memory allocation and a level of indirection. This allows the compiler to optimize the program even more. No logic has been changed in this patch.
2024-04-05 17:52:57 +02:00
Kawe Mazidjatari
fe2a95e4ec RTech: major pak system overhaul and rebuild
* split rtech_game and rtech_utils cpp files into multiple files
* rebuilt several large pak load routines for debugging and custom implementations
* moved rson code to rtech_game
* reworked and improved engine and sdk pak precache system
* reversed more of the jobthreads system
2024-04-05 17:51:19 +02:00
Kawe Mazidjatari
974a5b2c24 SpdLog: flush the tools logger
Must manually kill the pointer on shutdown to flush it since this one is allocated by us and thus not managed by SpdLog.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
cdcd7b8272 SpdLog: add truncate option for tools file logger, and default it on
By default spdlog will append on top of existing logs, but for ReVPK we want to truncate the old ones and start over again.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
19e67499e6 SpdLog: fix warning for tools code
Static linkage and not used for tools; idfed'd out.
2024-04-05 17:46:55 +02:00
Kawe Mazidjatari
92323b7ba7 SpdLog: fix compile error caused by undeclared function
SpdLog_Create() is no longer externed through its header as its a static internal function. Moved SpdLog_Create() above SpdLog_Init() to fix the compile error and rename it to SpdLog_CreateRotatingLoggers(), which is a more suitable name.
2024-04-05 17:46:54 +02:00
Kawe Mazidjatari
bf59f6c2c5 ReVPK: bug fixes & improvements
* Make sure the workspace path actually exists before attempting to pack it.
* Make sure the VPK directory tree file was parsed correctly before unpacking store.
* Log debug output for each pack operation to a file.
* Fix bug in s_DirFileRegex regex pattern, which would include a trailing '_' in the context part of the directory tree file name.
* Fix bug in 'GetLevelName()' and 'GetDirNameParts()' causing it to parse the path as well, prune the path before running the regex.
* Renamed 'GetLevelName()' to 'PackedStore_GetDirLevelName()'.
* Renamed 'GetDirNameParts()' to 'PackedStore_GetDirNameParts()'.
* Write a front-end enable file when building client VPK's.
2024-04-05 17:46:54 +02:00
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
ee82d5d8e0 Tier1: move KeyValues class to Tier1
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
2024-04-05 17:42:05 +02:00
Kawe Mazidjatari
b2ce189ba1 Tools: rename NETCONSOLE define to _TOOLS
Rename since this would actually be used for all tools. Also moved 'plat_time.cpp' to tier0 so anything could compile it.
2024-04-05 17:35:10 +02:00
Kawe Mazidjatari
a8074b4c99 VPhysics: add CPhysicsCollision singleton
Used for CStudioVCollide::~CStudioVCollide().
2024-04-05 17:26:16 +02:00
Kawe Mazidjatari
2b53c32e1d Tier1: add refcount class 2024-04-05 17:21:08 +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
99a24d9254 InputSystem: add reversed KeyInfo_t and KeyEvent_t struct
Almost fully mapped out, the unknown fields seem to be unused or padding.
2024-04-05 17:10:59 +02:00
Kawe Mazidjatari
7d0b2d7450 Add/update core headers 2024-04-05 16:53:51 +02:00
Kawe Mazidjatari
59e0bfa10b NVIDIA: initial implementation of latency markers 2024-04-05 16:45:05 +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
8400ee769f Fix emblem misalignment 2024-04-05 16:34:29 +02:00
Kawe Mazidjatari
37139130be Update emblem for 2.4 release 2024-04-05 16:34:29 +02:00
Kawe Mazidjatari
22c82d6f1d EULA dialog implementation
Display the EULA (fetched from masterserver), which the end user MUST accept before they can make use of the multiplayer features of R5Reloaded. NOTE: user doesn't need to agree to this to use the listenserver.
2024-04-05 16:26:18 +02:00
Kawe Mazidjatari
967aa0dfd4 Bump sigcache version to 2.8 and rename methods
Bump version and rename CSigCache::LoadCache to CSigCache::ReacCache.
2024-04-05 16:24:46 +02:00
Kawe Mazidjatari
9c4fb57fa7 R5Reloaded 2.3 emblem 2024-04-05 16:24:46 +02:00
Kawe Mazidjatari
909977452e Client token authentication implementation
The game internally obtains a auth token from Origin. On connect to a gameserver, it will send it to the masterserver. The master server will create a JWT token and send this back to the client. The client stores this token in 3 userinfo cvars (token, sig1, sig2). the sig1 and sig2 cvars are there to compensate for the truncation caused by sending the cvar, as each cvar string length could be up to 255 (byte max). The server verifies this token (the signature, timestamp, expiry); if they are valid, the has successfully authenticated and will connect.
2024-04-05 16:24:45 +02:00
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
804f96625b Move NVIDIA Reflex implementation to library function
Improve code, there will be more NVIDIA GeForce related stuff soon.
2023-09-12 00:08:46 +02:00
Kawe Mazidjatari
21093ca1a1 Implement NVIDIA Reflex Low Latency technology 2023-09-09 15:12:58 +02:00
Kawe Mazidjatari
b85003a9ac Replace JSON library with RapidJSON
Less copies and overall CPU time parsing/constructing JSON's as we are mostly still using string pointers rather than STL string container.
2023-09-07 11:17:05 +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
822d9f2b19 CTextOverlay cleanup
Slightly improved performance, reduced number of copy constructions, reduced number of integral type casts by just using the CUtlVector class.
2023-08-07 22:10:06 +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
cb7d1b3709 Normalize module names
All lowercase.
2023-07-20 22:23:10 +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