3644 Commits

Author SHA1 Message Date
Kawe Mazidjatari
3e281d785c Merge branch 'indev' into launcher_rework 2024-06-01 11:13:27 +02:00
Kawe Mazidjatari
7a331284eb RTech: take string pointer alignment into account
There are 2 versions of this function, one requires the string ptr to be aligned by 4.
2024-04-05 18:42:31 +02:00
Kawe Mazidjatari
e0c9f1e57f Miles: fix bug, add bank patch debug logs and add reversed miles types 2024-04-05 18:42:31 +02:00
Kawe Mazidjatari
8f7b86ec8d Windows: improve console init/shutdown error messages 2024-04-05 18:42:31 +02:00
Kawe Mazidjatari
bf5dd318a7 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-05 18:42:30 +02:00
Kawe Mazidjatari
b4ad19275f ImGui: fix console scrollbar feedback loop bug
Make use of newly added flag "ImGuiWindowFlags_OverlayHorizontalScrollbar" as per commit 60e4514b7b5c56db89102a3d66ef28a14118b8fd. Also removed flag "ImGuiWindowFlags_AlwaysVerticalScrollbar", only show the vertical scrollbar when its visible. Enabled code that takes the scrollbar into account in function CTextLogger::EnsureCursorVisible().
2024-04-05 18:42:30 +02:00
Kawe Mazidjatari
07ca7e1231 ImGui: add flag to draw scrollbars over content
Custom flags: basically tells ImGui to draw the scrollbar as an overlay. This is useful for working around feedback loops caused by the appearance of the scrollbars (might be worth PR'ing into ImGui itself?)

See:
ocornut/imgui#1720
ocornut/imgui#1730
ocornut/imgui#2978
2024-04-05 18:42:30 +02:00
Kawe Mazidjatari
65eaade807 RTech: disable LiveAPI by default 2024-04-05 18:42:30 +02:00
Kawe Mazidjatari
d1b2fe805f RTech: use SQString's '_stringval' macro for LiveAPI
Light code cleanup, no logic has been modified.
2024-04-05 18:42:30 +02:00
Kawe Mazidjatari
6d8315626e Thirdparty: upgrade ZStd to 1.5.6 2024-04-05 18:42:29 +02:00
Kawe Mazidjatari
ebffccf587 Thirdparty: upgrade RapidJSON to latest
Upgraded to Tencent/rapidjson@5ec44fb920
2024-04-05 18:42:29 +02:00
Kawe Mazidjatari
873e20c121 RTech: implement Nucleus ID hashing for LiveAPI events
The field was supposed to be hashed, added cheap hashing logic and an option to truncate it to reduce overhead.
2024-04-05 18:42:29 +02:00
Kawe Mazidjatari
70c117b6ff Core: remove extraneous define
No longer needed, moved to dbg.h in commit ab0f925205f1b6ccf71cc1efa0ef7298d4493fe6.
2024-04-05 18:42:29 +02:00
Kawe Mazidjatari
9e5b8a541c VScript: map out CSquirrelVM structure more
More reversed fields.
2024-04-05 18:42:29 +02:00
Kawe Mazidjatari
7a24371f64 Tier1: add utlhash
Core SourceSDK type.
2024-04-05 18:40:37 +02:00
Kawe Mazidjatari
250fd504af VScript: properly implement 'sq_getstring' and 'sq_getinteger' + more
sq_getstring and sq_getinteger are now properly implemented (code matches squirrel code, and generated assembly matches that of the game). Adjusted call sites to accommodate the new implementation and added a few extra checks. Also added:
* sq_getfloat
* sq_getbool
* sq_getthread
2024-04-05 18:40:37 +02:00
Kawe Mazidjatari
ce64cc57a0 Server: fix NavMesh hotswap crash + add codecallbacks
Fix double destruction (calling delete instead of free, the 'v_Detour_FreeNavMesh' call is the destructor, but we don't have the destructor fully rebuilt yet in the SDK). Also added codecallbacks for scripts.
2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
564efaf394 Recast: reverse some fields 2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
4745bf5e8e VScript: add code for calling codecallbacks 2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
92edc4a252 RTech: improve LiveAPI error msg's 2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
1e8dd63e4c Tier0: move GetUnixTimeStamp() to utility code 2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
d1498240eb Protobuf: change space indentation
Use 4 space indentation instead of 1 when using the newline/space option.
2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
d853846189 Protobuf: don't wrap uint64/sint64 numbers in quote
Technically this is to support JavaScript as it supports up to 53 bits precision, but we want to stick to the same scheme RapidJSON is using.
2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
a26e51ae00 Tier0: fix pattern precaching
Fix taken from IcePixelx/silver-bun@e11bfb7fa7

We should migrate to the new header only implementation once there's more time to mifrate the code + testing it.
2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
a546836a10 RTech: small cleanup for PakDecoder_s
Removed unused union
2024-04-05 18:40:36 +02:00
Kawe Mazidjatari
5e1ecdb6b5 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-05 18:40:35 +02:00
Kawe Mazidjatari
e91b8cfcec 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-05 18:39:36 +02:00
Kawe Mazidjatari
80fecfa228 Tier1: create simple depth manager class
Will be used to manage depths of nested arrays
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
b2442164a7 Tier2: check initialization state before init/shutdown 2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
815cc95db7 Engine: remove extraneous include 2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
f6ac90f14b Engine: flip order of checks
Check for cvar or state first before checking the current thread. The cvar/state check is slightly cheaper.
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
d3f5c27492 Tier2: fix websocket bug
CWebSocket::ConnContext_s::webSocket can be null, added a check.
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
df8d920eea Engine: rcon code readability improvement
Remove the else statement since it will always be else there.
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
02d0ba918c Engine: fix string bug, extraneous copy
request.requestmsg() returns a reference but we assign the reference to a char*. Removed the c_str() call.
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
999ce009a8 Engine: properly deal with server frame thread commands/convars
Marked convars/concommands as FCVAR_SERVER_FRAME_THREAD and removed main thread dispatching code and comments that are no longer in effect. In the RCONServer execute handler, a ThreadJoinServerJob() is placed if the commandbase is flagged FCVAR_SERVER_FRAME_THREAD since RCON dispatches the command, or sets the convar directly.
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
25e5bb667d Tier0: add new thread tools
- Add ThreadInMainOrServerFrameThread()
- Add ThreadCouldDoServerWork()
- Add ThreadJoinServerJob()
- Properly implement ThreadInServerFrameThread()
- Export all these functions for external DLL usage (plugins, etc)
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
fa421f259c Tier0: JobThreads improvements
- Add JobUserData_s for JT functions (used as arguments for JT callbacks).
- Add JT_GetCurrentJob().
- Add JT_WaitForJobAndOnlyHelpWithJobTypes().
2024-04-05 18:35:05 +02:00
Kawe Mazidjatari
381da23f44 VScript: properly handle internal errors during return
Must always check for internal error before returning out of a script function. The macro SCRIPT_CHECK_AND_RETURN will deal with this. Replaced all returns in each script func.
2024-04-05 18:35:05 +02:00
Kawe Mazidjatari
1b039d52be VScript: remove ScriptLanguage_t
Doesn't exist in r5 and its unused in the SDK. The game only supports squirrel.
2024-04-05 18:35:05 +02:00
Kawe Mazidjatari
de06d51ef0 Server: upgrade live_api events.proto
Upgraded to "R5pc_r5-201_J29_CL6350311_EX6402312_6403685_2024_03_22".
2024-04-05 18:35:05 +02:00
Kawe Mazidjatari
44d7a252de 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-04-05 18:33:33 +02:00
Kawe Mazidjatari
9fd41688e2 Compile full protobuf library
Needed for LiveAPI as reflection/descriptors will be used.
2024-04-05 18:33:10 +02:00
Kawe Mazidjatari
d34b92ed61 Validate encoding for RapidJSON
Improves security. Add kParseValidateEncodingFlag to default flags.
2024-04-05 18:33:10 +02:00
Kawe Mazidjatari
8baef57ca3 Suppress w4295 for thirdparty
DirtySDK uses non-null terminated strings for lookup tables.
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
b942db837c Engine: reimplement netmsg debuggers
Reimplement logic for cvars: "net_showmsg", "net_blockmsg", "net_showpeaks".
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
b1b80d3be0 Tier0: fix DEBUG compile error
Only occurred in DEBUG as Assert otherwise gets compiled out, and CThreadSpinRWLock::m_iWriteDepth only exists when compiled with REENTRANT_THREAD_SPIN_RW_LOCK. The game does not feature this so this is not defined. Moved to the REENTRANT_THREAD_SPIN_RW_LOCK block to only check on this assert when this feature is enabled.
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
b290381804 Engine: add functions for getting build/platform strings 2024-04-05 18:33:09 +02:00
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
d7478d3228 Tier2: WebSocket system improvements
Naming improvements, additional new comments/documentation and a few assertions. No logic has been changed.
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
e48c9f58ba Tier2: only enforce retry timer on (state == CS_RETRY)
Fixes a bug where the initial connect is only initiated after lastQueryTime + params.retryTime seconds.
2024-04-05 18:33:09 +02:00