3584 Commits

Author SHA1 Message Date
Kawe Mazidjatari
5bbec8bdd9 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-03 18:30:57 +02:00
Kawe Mazidjatari
3a9d701495 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-03 14:53:39 +02:00
Kawe Mazidjatari
0e54998a36 Recast: reverse some fields 2024-04-03 14:52:12 +02:00
Kawe Mazidjatari
bcf994e210 VScript: add code for calling codecallbacks 2024-04-03 14:51:44 +02:00
Kawe Mazidjatari
cc19debbe6 RTech: improve LiveAPI error msg's 2024-04-03 14:51:13 +02:00
Kawe Mazidjatari
e40a661bca Tier0: move GetUnixTimeStamp() to utility code 2024-04-03 02:06:10 +02:00
Kawe Mazidjatari
5902f2e37d Protobuf: change space indentation
Use 4 space indentation instead of 1 when using the newline/space option.
2024-04-03 01:58:39 +02:00
Kawe Mazidjatari
0aad26ad20 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-03 01:57:38 +02:00
Kawe Mazidjatari
091e9efa96 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-03 01:44:08 +02:00
Kawe Mazidjatari
9ef05df84b RTech: small cleanup for PakDecoder_s
Removed unused union
2024-04-03 01:35:20 +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
8a3131c550 Tier1: create simple depth manager class
Will be used to manage depths of nested arrays
2024-04-03 01:12:44 +02:00
Kawe Mazidjatari
d910149648 Tier2: check initialization state before init/shutdown 2024-04-03 01:06:28 +02:00
Kawe Mazidjatari
801c3cee79 Engine: remove extraneous include 2024-04-03 01:04:13 +02:00
Kawe Mazidjatari
3c5a1a1203 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-01 01:06:32 +02:00
Kawe Mazidjatari
728038b9b1 Tier2: fix websocket bug
CWebSocket::ConnContext_s::webSocket can be null, added a check.
2024-04-01 01:04:58 +02:00
Kawe Mazidjatari
f5fcf8bd7a Engine: rcon code readability improvement
Remove the else statement since it will always be else there.
2024-04-01 01:04:27 +02:00
Kawe Mazidjatari
ff9261b773 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-01 01:02:59 +02:00
Kawe Mazidjatari
83b1f43dbc 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-01 01:02:02 +02:00
Kawe Mazidjatari
32828e4e52 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-01 00:46:21 +02:00
Kawe Mazidjatari
77c0f5031b Tier0: JobThreads improvements
- Add JobUserData_s for JT functions (used as arguments for JT callbacks).
- Add JT_GetCurrentJob().
- Add JT_WaitForJobAndOnlyHelpWithJobTypes().
2024-04-01 00:36:52 +02:00
Kawe Mazidjatari
cf93cb3101 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-03-31 17:01:32 +02:00
Kawe Mazidjatari
f86fc0d405 VScript: remove ScriptLanguage_t
Doesn't exist in r5 and its unused in the SDK. The game only supports squirrel.
2024-03-31 16:13:05 +02:00
Kawe Mazidjatari
7d2c192a46 Server: upgrade live_api events.proto
Upgraded to "R5pc_r5-201_J29_CL6350311_EX6402312_6403685_2024_03_22".
2024-03-31 16:13:05 +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
db7d0b589b Compile full protobuf library
Needed for LiveAPI as reflection/descriptors will be used.
2024-03-31 16:13:04 +02:00
Kawe Mazidjatari
f2320b5542 Validate encoding for RapidJSON
Improves security. Add kParseValidateEncodingFlag to default flags.
2024-03-31 16:13:04 +02:00
Kawe Mazidjatari
9e1182d4fa Suppress w4295 for thirdparty
DirtySDK uses non-null terminated strings for lookup tables.
2024-03-31 16:13:04 +02:00
Kawe Mazidjatari
276289966c Engine: reimplement netmsg debuggers
Reimplement logic for cvars: "net_showmsg", "net_blockmsg", "net_showpeaks".
2024-03-31 16:13:04 +02:00
Kawe Mazidjatari
551a24b130 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-03-31 16:13:04 +02:00
Kawe Mazidjatari
b7e61e4088 Engine: add functions for getting build/platform strings 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
5e8887c6d9 Tier2: WebSocket system improvements
Naming improvements, additional new comments/documentation and a few assertions. No logic has been changed.
2024-03-31 14:53:14 +02:00
Kawe Mazidjatari
f89ec937d4 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-03-30 02:57:59 +01:00
Kawe Mazidjatari
ab7e02ef36 Tier2: create modular WebSocket system
This code was actually part of the LiveAPI system, but there were many opportunities to make this particular code modular, so it has been decoupled and moved to Tier2. The LiveAPI system will soon use this class instead. The implementation has also been improved by adding dedicated routines for updating socket parameters, disconnecting/reconnecting and destroying sockets.

This commit also removes legacy workaround code in UtlVector which was used for before we had early enough access to the game's memalloc singleton. This code was no longer used.

This commit also implements the CUtlStringList class, which is now used for the new websocket class to split each socket connection up by a comma delimiter.
2024-03-30 02:53:12 +01:00
Kawe Mazidjatari
1836146efe Squirrel: reverse more squirrel types and structures
This patch removes a lot of old code. Context is now exclusively grabbed from the CSquirrelVM instance. This patch also comes with a few new types: SQArray and SQTable!

The implementation also allows pushing Vector3D's on the stack, but these are handled slightly differently.. The largest field in tagSQObjectValue is 8 bytes, Vector3D is 12 bytes unaligned, but the tagSQObjectValue field in the tagSQObject struct is aligned to a 8 byte boundary while the field prior is only 4 bytes, Vector3D starts right after the type field in the tagSQObject (at the padding) to keep the whole structure the same size, therefore a new field has been added in between the padding (_pad) with a simple Vector3D accessor.

Also added a hook to allow registering proper script enums.
2024-03-25 01:41:52 +01:00
Kawe Mazidjatari
2d084db3a3 LiveAPI: initial WebSocket implementation
Working WebSocket implementation (foundation for game LiveAPI).
2024-03-25 01:26:33 +01:00
Kawe Mazidjatari
aff556732e Link against DirtySDK
Link against recently added libraries.
2024-03-16 16:57:28 +01:00
Kawe Mazidjatari
d24d4a52dd Add EABase, EAThread and DirtySDK to R5sdk
DirtySDK (EA's Dirty Sockets library) will be used for the LiveAPI implementation, and depends on: EABase, EAThread.
2024-03-16 12:44:34 +01:00
Kawe Mazidjatari
57dc081d4a Pylon: rename field "playerCount" to "numPlayers"
Force consistency between code structure.
2024-03-16 11:55:20 +01:00
Kawe Mazidjatari
fcbf285b80 Miles: add global type and prevent non-existent banks from loading
This patch adds miles globals and additional code to prevent banks from loading that don't exist. It falls back to "english" if requested language isn't installed.
2024-03-16 11:47:59 +01:00
Kawe Mazidjatari
c0879dc59c Squirrel: add more types and functions
More reversed types, more functions.
2024-03-16 11:36:49 +01:00
Kawe Mazidjatari
2b104896a5 Protobuf: fix compile error
template Delete<UnknownFieldSet>(); doesn't compile on vs2017 15.6, removed template qualifier.
2024-03-16 01:33:47 +01:00
Kawe Mazidjatari
cd75f47007 Tier1: compile utlsymbol.cpp
Should also be compiled, now that its fully implemented.
2024-03-16 01:31:14 +01:00
Kawe Mazidjatari
d302be7b4d Cleanup/add some comments 2024-03-16 01:30:44 +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
78e2a67e84 Squirrel: add functionality to register enums 2024-03-16 01:27:18 +01:00
Kawe Mazidjatari
35ba0cabf0 Tier1: use template index type for memory allocation
For CUtl* classes: use the index type rather than just ssize_t, this will throw compile warnings for code that constructs a CUtl* object allocating more memory than the index type allows (e.g. allocating UINT16_MAX while the index type has been set to UINT8_MAX).
2024-03-14 18:25:40 +01:00
Kawe Mazidjatari
e55ea0718c Tier1: fully implement CUtlSymbol(*)
The class has been modified to match the implementation of the engine, the only modifications done were changing size types, so they compile to the correct size based on the platform (in case of the GameSDK project, this will be 64 bits).
2024-03-14 02:37:39 +01:00