782 Commits

Author SHA1 Message Date
Kawe Mazidjatari
45508847e3 Engine: check for bitbuf overflow after reading voice data 2024-06-01 11:52:55 +02:00
Kawe Mazidjatari
d1c80ad6fd Engine: make debug statement a warning 2024-06-01 11:52:54 +02:00
Kawe Mazidjatari
661874025f Engine: add functionality to run game without the platform system
Unbind the game from the platform system, which is useful when developing for or debugging the game. This was supposed to make it into the SDK back in 2021, but wasn't due to the ability to spoof usernames. This is no longer possible on servers requiring authentication as the player's name is actually checked along with the Nucleus ID.
2024-06-01 11:52:54 +02:00
Kawe Mazidjatari
02b5d77d2f Engine: fix client dll compile error
This code should not compile for client.dll.
2024-06-01 11:52:53 +02:00
Kawe Mazidjatari
eaaa32eb64 Engine: fix stack smash in client side UserMessage processor
Unclamped CBitRead::ReadBits() call on stack buffer of MAX_USER_MSG_DATA bytes. Function has been rebuilt with additional clamping to mitigate the problem.
2024-06-01 11:52:53 +02:00
Kawe Mazidjatari
df363414df Engine: fix numerous exploitable bugs in voice protocol
- Fixed stack smash in CClient:ProcessVoiceData (oob read on bitbuf).
- Fixed stack smash in CClient:ProcessDurangoVoiceData (oob read on bitbuf).
- Fixed ability to bypass team check on Durango voice packets if forced as reliable from the sender (client).
- Incorporated the following missing checks in the durango version of voice broadcasting:
  - Enforce chat between multiple teams using cvar 'sv_alltalk'.
  - Ability to also disable Durango voice data with cvar 'sv_voiceenable'.
  - Ability to echo voice with Durango voice data using cvar 'sv_voiceEcho'.
2024-06-01 11:52:52 +02:00
Kawe Mazidjatari
84abfced6a VpkLib: make regex available to other code and utilize those instead
Prevent copies or similar patterns that might not work as good.
2024-06-01 11:49:16 +02:00
Kawe Mazidjatari
8cfcc00bc5 PluginSystem: add callback for chatroom receiver
Allow plugins to block chat msg's based on their text.
2024-06-01 11:49:15 +02:00
Kawe Mazidjatari
101962f5ce Engine: simplify "script" command callback for server
Code actually doesn't need to be ran in the server frame thread. All the code really does is preparation work. Run it in the main thread but do join the server frame thread (FCVAR_SERVER_FRAME_THREAD) as we can't do concurrent work on the server VM.
2024-06-01 11:49:14 +02:00
Kawe Mazidjatari
1b6d37725b Engine: don't broadcast voice data on training dedi
Training dedi doesn't support broadcasting voice data, return out.
2024-06-01 11:49:14 +02:00
Kawe Mazidjatari
9db094b98d Engine: add command line statics for dedicated server and light cleanup
CGameServer::SpawnServer() pointer to engine/server/server.h, and renamed it to CServer::SpawnServer().
2024-06-01 11:49:14 +02:00
Kawe Mazidjatari
0cea07ab8f VScript: properly implement script command callback
Previously we did sq_pushroottable() and a subsequent sq_call() after compiling the text buffer, but this didn't work for code that was threaded, or using Get/SetNetVar* functions.

The second issue was that the callback for the "script" command was ran in the main thread. Server script should always run in the server frame thread, the Set/GetNetVar* functions check thread id to retrieve the correct VM context, so running server script from the main thread ended up with Set/GetNetVar* functions retrieving the client VM context rather than server's, causing undefined behavior.

Script commands are now queued to the server frame thread, ultimately fixing this bug.

Also fixed a small bug with function 'sq_compilebuffer()'; it takes an extra argument but this wasn't taken into account in the SDK.
2024-06-01 11:49:13 +02:00
Kawe Mazidjatari
b201ca7a5b Engine: fix incorrect assignment on rcon socket bind
The assignment on the ternary operator should be flipped, bug was spotted during beta testing.
2024-06-01 11:43:09 +02:00
Kawe Mazidjatari
88bb1307be Engine: move unrestricted command exec code to separate function 2024-06-01 11:43:09 +02:00
Kawe Mazidjatari
5d38b3762b Engine: enforce rcon convar name consistency
Removed extra '_' from sv_rcon_whitelist_address, its now sv_rcon_whitelistaddress.
2024-06-01 11:43:08 +02:00
Kawe Mazidjatari
6eee25a4e9 Engine: use dedicated convar to determine rcon server socket bind
Decoupled from net_usesocketforloopback since we actually don't want this to be tied with that of the game. Now it by default does not bind to the loopback socket unlike the game.
2024-06-01 11:43:08 +02:00
Kawe Mazidjatari
84831f53b6 Engine: remove extraneous trailing semi-colon 2024-06-01 11:36:23 +02:00
Kawe Mazidjatari
5a2dfaf03a Server: add option to respect game state when performing auto reload
Can be toggled with the new cvar 'host_autoReloadRespectGameState', and used in combination with the new server script func 'SetAutoReloadState( bool state )'. This makes sure that even when the timer reaches 'host_autoReloadRate', it would wait with the reload until the game itself is finished (which is when SetAutoReloadState( true ) is being called from scripts).
2024-06-01 11:30:35 +02:00
Kawe Mazidjatari
19069f039b Engine: exec liveapi.cfg on start
Allow configuration of the LiveAPI system
2024-06-01 11:30:35 +02:00
Kawe Mazidjatari
e0ee5d9a05 Engine: fix typo in CClientState member variable name
Renamed from m_nProcesseedDeltaTick to m_nProcessedDeltaTick.
2024-06-01 11:30:35 +02:00
Kawe Mazidjatari
14e851cc64 Engine: add newly reversed fields to CClient class 2024-06-01 11:30:35 +02:00
Kawe Mazidjatari
9236008159 Engine: light cleanup to CL_MoveEx()
Make *chan and commandTick const.
2024-06-01 11:30:35 +02:00
Kawe Mazidjatari
42e02b4569 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-06-01 11:29:29 +02:00
Kawe Mazidjatari
2587392f88 RTech: use more consistent type names
Force consistency between type names (follow scheme used in tier0 and rtech_game export symbols).
2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
dea96ddf31 RTech: rename pak defines
More correct and consistent naming.
2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
64f8f27bc8 Engine: initiate rcon connection from address change callback
A more user friendly approach.
2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
85f9d26d23 Engine: use tier2 random generator for netkey
Limit usage to only 1 algorithm provider.
2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
90e4711425 Tier2: move random generator from tier0 to tier2
Moved into cryptutils.cpp.
2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
14c0746212 Engine: move rcon_password entirely to server
The client doesn't need this convar, client only needs cl_rcon_address.
2024-06-01 11:25:57 +02:00
Kawe Mazidjatari
b26ed2f746 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-06-01 11:24:47 +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
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
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
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
bea1deeb9d LiveAPI: initial WebSocket implementation
Working WebSocket implementation (foundation for game LiveAPI).
2024-04-05 18:30:22 +02:00
Kawe Mazidjatari
430b2877ad Cleanup/add some comments 2024-04-05 18:27:10 +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
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
bfc985ea79 Engine: fix return value for game wndproc
Should return LRESULT, not int.
2024-04-05 18:24:35 +02:00
Kawe Mazidjatari
1f8cd45626 ImGui: make config singleton static
Avoid indirection, also deduplicate common style var assignments.
2024-04-05 18:24:33 +02:00
Kawe Mazidjatari
44d663bf1c ImGui: cleanup and improvement to surface implementation
* Properly run fade in-out animations
* Make common methods/members shared
* Remove extraneous SDK thread
2024-04-05 18:22:56 +02:00
Kawe Mazidjatari
23a3c8fc00 Engine: make task queue singleton static
Compile it as static object & renamed to more correct names. Also made the integral type for frame delay an unsigned int instead
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
85c7db410d ImguiSystem: properly implement ImGui and fix several bugs
Moved implementation to dedicated class 'CImguiSystem' with the following changes:

* Added mutex for ImGui_ImplWin32_WndProcHandler(), the window proc is ran from a different thread than CImguiSystem::SampleFrame() is being called from. Needs a mutex as both functions interact with the input queue list.

* Added init stages for debugging and preventing the system from running certain parts of the code if a certain stage hasn't been reached yet.

* NULL out ImGuiContext::ConfigNavWindowingKeyNext , we don't need any nav window shortcuts as users don't need then in-game, and it also interferes with certain key binds some users have.

* CImguiSystem::SampleFrame() (previously ImguiSystem_SampleFrame()), is now being called from CMaterialSystem::SwapBuffers(), as that function is called from the main thread while also getting updated during level loads/etc, so instead of switching between 2 static buffers for as long as the levels are being loaded, we imgui updates properly too and directly swap afterwards.

* Removed hack in CGame::WindowProc() where we would only run windowproc if we aren't shutting the game down. This was needed as there was a chance of a crash at some rare cases, but this was simply due to a missing mutex which has been addressed and fixed as of this commit.

* Lock mutex during init and shutdown.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
a5e6859f4b Update sdk_dll.cpp
Mark 'sdk_fixedframe_tickinterval' FCVAR_ACCESSIBLE_FROM_THREADS.
2024-04-05 18:19:39 +02:00
Kawe Mazidjatari
b9c7cabda9 ImGui: move initialization code to DX hook setups
Also removed unused global declaration 'g_bImGuiInitialized'.
2024-04-05 18:19:38 +02:00