3705 Commits

Author SHA1 Message Date
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
Kawe Mazidjatari
e02f8f36fe 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-04-05 18:31:58 +02:00
Kawe Mazidjatari
1c32339305 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-04-05 18:31:06 +02:00
Kawe Mazidjatari
bea1deeb9d LiveAPI: initial WebSocket implementation
Working WebSocket implementation (foundation for game LiveAPI).
2024-04-05 18:30:22 +02:00
Kawe Mazidjatari
2b3b88518f Link against DirtySDK
Link against recently added libraries.
2024-04-05 18:29:54 +02:00
Kawe Mazidjatari
b3a68ed095 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-04-05 18:29:03 +02:00
Kawe Mazidjatari
9d7eb7b07b Pylon: rename field "playerCount" to "numPlayers"
Force consistency between code structure.
2024-04-05 18:28:26 +02:00
Kawe Mazidjatari
8c593f666f 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-04-05 18:28:26 +02:00
Kawe Mazidjatari
09b1e44dfe Squirrel: add more types and functions
More reversed types, more functions.
2024-04-05 18:27:10 +02:00
Kawe Mazidjatari
4d0c5dd3da Protobuf: fix compile error
template Delete<UnknownFieldSet>(); doesn't compile on vs2017 15.6, removed template qualifier.
2024-04-05 18:27:10 +02:00
Kawe Mazidjatari
dd708169d9 Tier1: compile utlsymbol.cpp
Should also be compiled, now that its fully implemented.
2024-04-05 18:27:10 +02:00
Kawe Mazidjatari
430b2877ad Cleanup/add some comments 2024-04-05 18:27:10 +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
6ac609f66e Squirrel: add functionality to register enums 2024-04-05 18:27:09 +02:00
Kawe Mazidjatari
f67d8e87b1 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-04-05 18:27:09 +02:00
Kawe Mazidjatari
582ec3791e 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-04-05 18:26:04 +02:00
Kawe Mazidjatari
615598c1b9 Tier0: implement CThreadSpinRWLock
Implementation matches that of the game executable, this will be used for CUtlStringTableMT.
2024-04-05 18:26:04 +02:00
Kawe Mazidjatari
4e96239e0f Engine: datablock sender cleanup
Mark cvar net_compressDataBlockLzAcceleration static.
2024-04-05 18:26:04 +02:00
Kawe Mazidjatari
7f4ab752b2 Engine: server bulk ban check bug fixes
If the code was ran in the main thread, it would never fire the actual check logic. This patch changed the code so it would always fire from the start of the frame. Also fixed a memory leak that occurred when passing in an external banned list to SV_CheckClientsForBan (previously, 'SV_CheckForBan'); the code always allocated a new banned list, but only freed it if no external banned list was provided. This patch changed the code so it only allocates it if no external one is provided.
2024-04-05 18:26:04 +02:00
Kawe Mazidjatari
a4d04c9357 ImGui: fix server visibility bug
If host status is set to offline after the server is launched, the browser would continue to broadcast the server. This patch makes sure that if the visibility has been set to offline, the server would no longer be broadcasted to the master server.
2024-04-05 18:26:04 +02:00
Kawe Mazidjatari
b8178e9299 NetworkSystem: fix numerous issues
This patch splits host logic from CServerListManager. CServerListManager is actually meant for the client to manage the server list to which the client could connect to. The hosting logic has been moved to the new CServerHostManager class.

Previously, we stored all the hosting details in CServerListManager, with connection criteria in CPylon, this data has been moved over to CServerHostManager as well.

Previously, we also needed a mutex to access the server host data, function HostState_KeepAlive() has been refactored to the point this mutex is no longer necessary as the only threaded process is the actual request, the rest is being applied in the main thread. We also now only construct a NetGameServer_t struct if we actually plan to host.

Access to CPylon::m_Language is now also protected by a mutex, as the change callback of cvar 'language' and the threaded method 'CPylon::QueryServer()' are competing for access.
2024-04-05 18:24:36 +02:00
Kawe Mazidjatari
ffdfb56c30 ImGui: constify local variable 2024-04-05 18:24:36 +02:00
Kawe Mazidjatari
91c878c719 ImGui: properly attach autocomplete suggest window to console
Make sure the autocomplete suggest window is always behind the console window with nothing in between. Previously, the server browser or modal panel ended up between the autocomplete suggest window and console window if the console was focused after the browser was invoked and moved partially on top of the console.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
2637ecc641 ImGui: add render frame stage and scope mutex 2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
d11718a956 ImGui: slightly improve cursor scrolling
Add +1 on the right to prevent the cursor from getting under the perimeter, also add note for when feedback loop issue is fixed to accommodate for scrollbar when scrolling.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
431621a1cc ImGui: constify local variables 2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
bd797a92db ImGui: fix cursor scrolling bug
* Fix bug where moving cursor all the way to the top + little bit, and then moving below will also scroll the text position below (cursor sticked to top rect).
* Fix bug where cursor skipped a column when moving it past the right perimeter of the console.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
3273b7112c ImGui: better name for blinker timer in logger 2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
bfc985ea79 Engine: fix return value for game wndproc
Should return LRESULT, not int.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
7dbf4133ee ImGui: remove extraneous window flag
No flags needed here, just pass ImGuiWindowFlags_None.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
a0c995c08a ImGui: make imgui flags constants instead 2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
b2481247c0 ImGui: fix server browser list clipper and pass filter bug
Filter results first before clipping them.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
5de3738d0c ImGui: always rebuild summary text on input text change
This fixes corner case bugs like selecting currently entered text, and deleting it at once. If we happen to show a ConVar's value, and do the mentioned action, it wouldn't clear it as "if (iData->BufTextLen)" won't satisfy.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
6d3bd818e1 ImGui: move summary text above input text
The pass filter has some features (including, or excluding with the '-' prefix), but this isn't very clear. Added the original 'usage' text back, which caused the following issue: the summary text (showing how many history items, or the currently selected convar's current value/default value) would clip outside the console window on ConVar's that had larger string values, like URL's. The summary text has been moved to just above the input text field to fix this issue. This patch also contains some slight improvement to styling of the console.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
ea7a377814 ImGui: pad last button in server browser correctly
Previously, it would clip with the resize handle due to commit eda8048a982f88611710bcded1d2245e9d42d95e
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
56feb56998 ImGui: clip server listings if they exceed rect
Use ImGuiListClipper to clip anything not visible.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
fda018785e ImGui: upgrade backend to 1.90.4 as well
This wasn't committed, but was supposed to be part of commit 7f6846a3
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
a59b704384 ImGui: don't use textures for autocomplete if the loading failed
Otherwise the indices will be incorrect and will cause undefined behavior.
2024-04-05 18:24:34 +02:00
Kawe Mazidjatari
c6edc47c18 ImGui: console and browser code style refactor
Made the style of the code more consistent. Not much logic-wise had changed during the refactor, but there are some.

Console:
* Removed m_bSuggestUpdate and the logic bound to it, this var was never set and the logic was never used. This was the initial workaround for resetting the autocomplete selection pos to kPark (-1), but this is currently done in a more mature way, but the old code was never removed
* CreateSuggestionsFromPartial() (previously, FindFromPartial()) would break if a ConCommand/ConVar was found that was already added in the list. Although this is an engine/sdk level bug, we shouldn't stop iterating there. Added an assert instead and made the loop continue.
* Removed member m_bCopyToClipBoard, this was used to check if the copy button was pressed, to copy the text the next frame. The copy now happens directly in the site of the Copy button which is a better approach.
* Due to the changes with removing m_bCopyToClipBoard, the mutex for m_colorTextLogger is now released right after rendering the color text to fully minimize blocking time between other threads.

Browser:
* Moved ImGui::Begin() call from RunFrame() to DrawSurface(), it fits better there and we can now also return false if the frame didn't render.
* Improved the "Broadcasting" text formatting when server browser is hosting and broadcasting without a server token (public server).

Both:
* Added virtual Shutdown() method.
2024-04-05 18:24:33 +02:00