64 Commits

Author SHA1 Message Date
Kawe Mazidjatari
9968769e37 Core: update launch emblem
Updated to v2.5.
2024-11-09 01:23:09 +01:00
Kawe Mazidjatari
43e162711e Core: add option to run the game fully offline
The game can now be ran fully offline by providing '-offline' to the command line arguments. The engine will auto execute 'system/autoexec_offline.cfg' which overrides other autoexecs to ensure the game runs offline. The system/autoexec_offline.cfg file only overrides the variables it sets.
2024-11-09 01:22:43 +01:00
Kawe Mazidjatari
7a62cf8c8b Tier2: only show message boxes if -nomessagebox isn't passed in
Typically for dedicated servers you don't want any message boxes as they hang the process. The '-nomessagebox' helps solve this problem. Also removed extraneous check on MessageBoxA in EngineLoggerSink, we should always terminate regardless if MessageBoxA fails or not. The error will always be logged anyways.
2024-10-06 22:29:22 +02:00
Kawe Mazidjatari
3b3127c2cf VScript: add code class script globals and registraction callbacks
Will be used to register custom script class functions.
2024-09-25 14:36:20 +02:00
Kawe Mazidjatari
720584be25 AMD: Implement Anti-Lag 2 SDK
AMD's equivalent of NVIDIA Reflex.
2024-09-14 11:57:18 +02:00
Kawe Mazidjatari
cb61ff2875 Tier2: implement crash reporter
Submit all relevant crash details to the error collection server (backtrace), this allows us to catch all remaining bugs in the engine and sdk and fix them more effectively. The old local log file containing details of the crashing thread and system details are still logged since this system can be disabled with the console variable 'backtrace_enabled'.
2024-09-13 20:17:54 +02:00
Kawe Mazidjatari
98f4f57afe Tier0: crash handler reliability improvements
* Break out of loop when we found and cached the primary graphics device.
* Log total and available ram with more accuracy.
* (New) log total and available disk space the game is being ran from.
* Cache hardware details such as disk space, ram space and graphics device so the crash callback could also use it.
* Calculate highest XMM number as unsigned so an ABS call is not needed.
* Make the crash callback const.
* Provide pointer to instance to the crash callback.
* Fix crash callback not running properly; it should always be ran in the context of the current crash, not after. The callback is now ran after the crashmsg application has been started.
2024-09-13 20:01:40 +02:00
Kawe Mazidjatari
7ef0a77bb9 Core: improve CPU clock speeds formatting
Same length but the fractional component shows clock speed with more accuracy now.
2024-09-13 19:44:18 +02:00
Kawe Mazidjatari
d298ad0c22 Client: initial rebuild of the curve look function
This function didn't decompile properly, so a bunch of manual assembly work had to be used to reconstruct the truncated bits. The code does work correct for the most part. The call to the subroutine 'sub_1405AD760' has been commented as the parameter appears incorrect; passes in the address of a bool but indexes 4 bytes outside the size of a bool. Most likely incorrect decompile/disasm. Currently being investigated.
2024-08-04 14:12:15 +02:00
Kawe Mazidjatari
877d0f082f Tier0: make logger mutex static
There is no need to make this globally accessible.
2024-08-03 12:17:44 +02:00
Kawe Mazidjatari
892f415425 Server: reverse server entity list class
Fully reversed.
2024-07-31 17:44:30 +02:00
Kawe Mazidjatari
06ca0479b8 Client: get actual client entity list object 2024-07-31 15:28:29 +02:00
Kawe Mazidjatari
5c4a66f5b5 Server: add AI task debug code
Reimplement CAI_BaseNPC::TaskFail.
2024-07-28 22:36:05 +02:00
Kawe Mazidjatari
de1ec81690 Core: SDK init code should be exported as well
Regression caused in commit f989061e2d651da7f2559aee2cfc41b1f20f4790
2024-07-06 09:59:27 +02:00
Kawe Mazidjatari
2b16295d0e Recast: move implementation of alloc and assert to shared
Move the implementation as well, commit fa8d89d287752782ebdd5d9563f04fa72ef0bee9 was declaration (and some miscellaneous utility classes) only.
2024-07-04 20:36:04 +02:00
Kawe Mazidjatari
fb8ef4f379 InputSystem: add reverse engineered 'InputStackSystem' class
Reverse engineered as part of reverse engineering class 'CInput' which is for a future commit. Singleton pointer has been exposed to SDK through the pointer 'g_pInputStackSystem'.
2024-06-16 20:32:57 +02:00
Kawe Mazidjatari
328d88213c Miles: fix voice comm bus regression
Regression was caused in commit 3bb4ee625863c1dd503f07e0d480f4b3fd302c48. The new sound engine has breaking changes in its exports. Added shim layer to fix incompatibilities on the export 'MilesSampleSetSourceRaw'.
2024-06-01 02:23:55 +02:00
Kawe Mazidjatari
dacc4ac8f5 Core: allow launching dedicated server without terminal window
The terminal window isn't always necessary, especially on Linux systems. In fact, it causes issues on some Wine environments. Allow user to disable it with -noconsole. This option only exists on the dedicated server. The client builds have the console disabled by default, and can enable them with -wconsole.
2024-04-14 19:39:52 +02:00
Kawe Mazidjatari
2ca3baa77d UserCmd: limit command backlog to prevent exploitation
Implement UserCmd command backlog limiting (the new convar 'sv_maxUserCmdProcessTicks' dictates how many ticks can be processed per second). Defaulted to 10, which is (default tick interval (0.05) * default cvar val (10) = 0.5ms window), which is equal to the default of cvar 'sv_maxunlag'.

Before this patch, you could stuff several seconds worth of usercmd's in one second and achieve speed hacking.
2024-04-12 01:51:11 +02:00
Kawe Mazidjatari
f8dd1fe88c Engine: implement encryption for RCON protocol
RCON lacked encryption, added AES-CTR encryption on RCON frames. Slightly adjusted protocol to take this into account (sending nonces, encrypted data itself, etc).
2024-04-10 14:08:52 +02:00
Kawe Mazidjatari
504d042e60 Core: fix several initialization bugs
- Don't free console if the process is being closed from the console, this will cause the process to freeze within the FreeConsole() call
- Properly check for CPU features in order, and moved all checks to a single function utilizing the CPUInformation struct.
- Made SDK_Init() and SDK_Shutdown() more resilient against mistakes with new checks and error messages (added since they are exported now).
2024-04-04 18:49:00 +02:00
Kawe Mazidjatari
052c5a8d37 Core: remove extraneous define
No longer needed, moved to dbg.h in commit ab0f925205f1b6ccf71cc1efa0ef7298d4493fe6.
2024-04-03 18:58:35 +02:00
Kawe Mazidjatari
fce6d8e300 Loader: fix shutdown bug
Ever since we moved to the new loader setup, the shutdown of the SDK never got called as case DLL_PROCESS_DETACH is never hit on time in the SDK module due to the way its loaded/unloaded now.

The init/shutdown functions are now exported, and we let loader handle the load/unload of our SDK now. Loader now also hooks LauncherMain instead of WinMain as WinMain never returns, and therefore, we cannot shutdown the SDK from there. LauncherMain does return then the game is to be closed.
2024-04-03 01:34:25 +02:00
Kawe Mazidjatari
b916e11543 RTech: implement custom events and slight adjustments/improvements
Implemented CustomEvent in code, which supports:
- bool|int|float|string|vector|array|table
- nested arrays and tables, up to a depth of 64

Also improved foundation code for LiveAPI:
- added ability to log liveapi events to a file on the disk (rotates between each match or round, depending on how the abstracted functions are called in scripts)
- when the system is enabled through cvars, code will be invoked on the fly
- when the system is disabled through cvars, the system will be shutdown properly on the fly (properly handling socket closing, log file finishing, etc)
- if the socket system is enabled/disabled on the fly using cvars, related code will be called to initiate or shutdown the connections.

The generated proto.cpp/h file has been moved to the protoc project as it was causing some compiler warnings that we suppress on the thirdparty (vendored) code.
2024-04-03 01:26:53 +02:00
Kawe Mazidjatari
89ed3735af Server: implement LiveAPI into the game
Full implementation of all LiveAPI events into the game server.

NOTE: The only event left to be implemented in code is CustomEvent.

NOTE: ObserverSwitched and WeaponSwitched events are implemented in code, but they need a proper CodeCallback to hook them up properly in scripts.

The events.proto file is from build "R5pc_r5-200_J33_CL6243000_2024_02_27_14_53" with some slight modifications:

- PlayerStatChanged.newValue is now a oneof field, which can be either int, float or bool as Season 3 Apex still handles stats in one of those 3 types while retail was only int (which is most likely why they kept it just int only int he proto file).

- PlayerRespawnTeam.respawned is now a repeated Player field instead of a string. Initially the respawned field contained a comma separated list of player names that were respawned in the team, it now contains the actual Player data that is respawned as this was much easier to get from scripts, and also makes a bunch more sense than just string names.

- New CustomEvent event: since R5Reloaded is a modding platform, and we can't make new events for literally all gamemodes that modders create, we added another event "CustomEvent" which allows modders to sent their own data to their own tracker or anything while still remaining compatibility with the protocol.
2024-03-31 16:13:04 +02:00
Kawe Mazidjatari
c4a0c0d6c8 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-03-31 16:13:03 +02:00
Kawe Mazidjatari
aff556732e Link against DirtySDK
Link against recently added libraries.
2024-03-16 16:57:28 +01:00
Kawe Mazidjatari
e230fb8320 Protobuf: check version on startup
Properly check as per documentation.
2024-03-16 01:27:57 +01:00
Kawe Mazidjatari
3f74b4a2b6 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-02-28 19:16:31 +01:00
Kawe Mazidjatari
6828901815 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-02-24 02:15:09 +01:00
Kawe Mazidjatari
3d36c87b08 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-02-23 00:12:06 +01:00
Kawe Mazidjatari
acbe43a210 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-02-22 01:55:08 +01:00
Kawe Mazidjatari
51ba4c9dff 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-02-21 01:10:14 +01:00
Kawe Mazidjatari
def6d4da68 Tier0: emit text to debug console if debugger is attached
Small quality of life improvement while debugging the application.
2024-02-19 21:24:00 +01:00
Kawe Mazidjatari
802e1f42eb 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-02-19 21:24:00 +01:00
Kawe Mazidjatari
cd39a68b48 Core: use forward slash when formatting logger files
Minor cleanup
2024-02-04 00:55:33 +01:00
Kawe Mazidjatari
e728877035 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-02-04 00:55:07 +01:00
Kawe Mazidjatari
45e95039e8 Add ZSTD to SDK 2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
1361bfb172 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-01-21 21:29:23 +01:00
Kawe Mazidjatari
c9a9b01bf2 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-01-21 20:23:25 +01:00
Kawe Mazidjatari
a809816f70 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-01-14 11:24:42 +01:00
Kawe Mazidjatari
3fa0f25616 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-01-14 02:14:22 +01:00
Kawe Mazidjatari
ecfb1fe2bf SpdLog: fix warning for tools code
Static linkage and not used for tools; idfed'd out.
2024-01-14 02:07:31 +01:00
Kawe Mazidjatari
2a4516f3cb 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-01-14 02:01:42 +01:00
Kawe Mazidjatari
5266a2e9de 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-01-14 01:39:11 +01:00
Kawe Mazidjatari
1f6b1c7d60 KeyValues: fix singleton accessor compile errors
Make each instance implement the accessor instead of the KeyValues system itself.
2024-01-12 01:51:28 +01:00
Kawe Mazidjatari
cd82e22ea3 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-01-12 00:52:07 +01:00
Kawe Mazidjatari
078c241a0d 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-01-12 00:25:19 +01:00
Kawe Mazidjatari
fc1c911c81 VPhysics: add CPhysicsCollision singleton
Used for CStudioVCollide::~CStudioVCollide().
2024-01-07 14:19:31 +01:00
Kawe Mazidjatari
4df2c83247 Tier1: add refcount class 2024-01-04 16:08:27 +01:00