689 Commits

Author SHA1 Message Date
Amos
35bec64a5f Fix dedicated compile errors 2024-04-05 17:19:29 +02:00
Kawe Mazidjatari
714674ae33 Engine: reversed some CGame field names
Reversable thanks to the CInputSystem rebuild.
2024-04-05 17:19:28 +02:00
Kawe Mazidjatari
81ccefb74d NVIDIA: limit to 1 sleep per frame
The purpose of this bool was to only limit nv sleep to 1 per frame, but the bool was never reset.
2024-04-05 17:19:28 +02:00
Kawe Mazidjatari
c954640527 InputSystem: rename function parameter 2024-04-05 17:12:53 +02:00
Kawe Mazidjatari
735a9e0489 NVIDIA: properly enqueue frame ID
Sync Frame ID between main thread and render thread, this changes makes the integration PASS the reflex test utility.
2024-04-05 17:12:52 +02:00
Kawe Mazidjatari
4d521b60c9 Engine: fix incorrect function names
Was actually pointing to Host_Init_DuringVideo, not Host_Init. Added all Host_Init functions to avoid confusion in the future.
2024-04-05 17:12:52 +02:00
Kawe Mazidjatari
65bff96db1 NVIDIA: low latency code decouple 2024-04-05 17:12:52 +02:00
Kawe Mazidjatari
fd8b2f255e NVIDIA: add TRIGGER_FLASH marker to input event handler 2024-04-05 17:12:52 +02:00
Kawe Mazidjatari
13fa6d902b EngineAPI: key event dispatcher rebuild 2024-04-05 17:12:51 +02:00
Kawe Mazidjatari
99a24d9254 InputSystem: add reversed KeyInfo_t and KeyEvent_t struct
Almost fully mapped out, the unknown fields seem to be unused or padding.
2024-04-05 17:10:59 +02:00
Kawe Mazidjatari
7d0b2d7450 Add/update core headers 2024-04-05 16:53:51 +02:00
Kawe Mazidjatari
59e0bfa10b NVIDIA: initial implementation of latency markers 2024-04-05 16:45:05 +02:00
Kawe Mazidjatari
d3d80398e3 Add new reversed packet header flags
These flags only exist in the respawn version of the engine. Renamed 'CNetChan::unknown_challenge_var' to 'CNetChan::m_nRealTimePackets'. This field counts the number of packets sent while the frame time wasn't prescaled with the 'host_timescale' cvar, see r5apex.exe+0x3093C0 (140309FC0).
2024-04-05 16:41:11 +02:00
Kawe Mazidjatari
51b866f6a1 NVIDIA: check if adapter is from NVIDIA in GFX_SetLatencyMarker()
Moved adapter vendor check to its own func, added a global which could be used to fully disable the low latency system. Also added groundwork for the (future) PCL stats implementation.
2024-04-05 16:41:11 +02:00
Kawe Mazidjatari
144d5f62e1 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2024-04-05 16:41:09 +02:00
Kawe Mazidjatari
c86f0c5c6a Check if we have enough room for new execution markers
Make sure we always have enough room for new execution markers. Engine normally truncates the head of the vector if out of room; we want to avoid it as this will cause the cookies to shift, and thus cause them to misalign with their respective commands.
2024-04-05 16:41:08 +02:00
Kawe Mazidjatari
b24e5815bc Fix memory leak in token authentication system
Must free claims after creating them!
2024-04-05 16:34:29 +02:00
Kawe Mazidjatari
c6f2c99619 Improve client-side online authentication error handling and UX
Display the error to the user without having to open the developer console or terminal window. This patch also adds printing to COM_ExplainDisconnection (which has been stripped out of the retail binary).
2024-04-05 16:34:28 +02:00
Kawe Mazidjatari
5e53a75571 Drop a warning when someone fails authentication 2024-04-05 16:34:28 +02:00
Kawe Mazidjatari
b37a3bdeba Add comments on newly added code 2024-04-05 16:28:59 +02:00
Kawe Mazidjatari
cbf370019d Don't query JWT token if we connect to localhost
Localhost in many cases implies usage of listen server; these don't require auth on loopback connections.
2024-04-05 16:24:47 +02:00
Kawe Mazidjatari
cd2d47b959 Add configurable server cvars for auth system
The command execute is now guarded off on the client with the cvar 'sv_allowClientSideCfgExec' instead of 'sv_cheats'.
2024-04-05 16:24:46 +02:00
Kawe Mazidjatari
0eaa226dce Change JSON field types send to master server
They were all strings; changed them to what made most sense for each field type. Changes:
"hidden": string -> bool
"port": string -> int
"checksum": string -> uint
"playerCount": string -> int
"maxPlayers": string -> int
2024-04-05 16:24:46 +02:00
Kawe Mazidjatari
909977452e Client token authentication implementation
The game internally obtains a auth token from Origin. On connect to a gameserver, it will send it to the masterserver. The master server will create a JWT token and send this back to the client. The client stores this token in 3 userinfo cvars (token, sig1, sig2). the sig1 and sig2 cvars are there to compensate for the truncation caused by sending the cvar, as each cvar string length could be up to 255 (byte max). The server verifies this token (the signature, timestamp, expiry); if they are valid, the has successfully authenticated and will connect.
2024-04-05 16:24:45 +02:00
Kawe Mazidjatari
bfea8023eb Reduce duplicate code
Make a method for setting the host state.
2024-04-05 16:24:45 +02:00
Kawe Mazidjatari
6b246e0ce8 Netchan: comment out unused code 2024-04-05 16:21:45 +02:00
Kawe Mazidjatari
48256955af Null console commands past the 512th byte
A mistake has been made, certain area's of the engine actually do allow strings larger than 128 bytes, just one routine that doesn't (console commands). Tokenizer only tokenizes it up to 512 bytes, so null all the other bytes past this. This still fixes the flaw mentioned in the comment at the place where the nulling happens.
2024-04-05 15:57:33 +02:00
Kawe Mazidjatari
7b7177240d Improve NavMesh render performance 2024-04-05 15:57:33 +02:00
Kawe Mazidjatari
d6fd782601 Add new RPak types and rename existing
Rename to enforce consistency.
2024-04-05 15:57:33 +02:00
Kawe Mazidjatari
feffcdfa94 Light pluginsystem cleanup
Light cleanup and improvements. Always load plugin dll's from "GAME" first before searching through mods to prevent mods from overriding them.
2023-09-17 20:33:57 +02:00
Kawe Mazidjatari
5af364f325 Remove extraneous check
Should not fire this code if that cvar is set.
2023-09-17 17:19:32 +02:00
Kawe Mazidjatari
71d0332dca Add CCommonHostState to SDK
The previous 'interval_per_tick' global belongs to the 'g_pCommonHostState' singleton.
2023-09-17 16:44:18 +02:00
Kawe Mazidjatari
1323703251 Move process time rate limit back to caller hook
Move it back to caller hook instead of in the ProcessMessages function as there were crash reports when running the listen server. Moving this back solved the intermittent crash problem entirely while still rate limiting process time.
2023-09-16 22:03:39 +02:00
Kawe Mazidjatari
228b9222b3 Fix compiler error
Define this out for client dll.
2023-09-16 22:02:04 +02:00
Kawe Mazidjatari
00e79268d7 Fix infinite memalloc exploit in NET_SetConVar
Reported by Wanderer. Don't allow the creation of new ConVar entries in CClient::m_ConVars after the initial creation.
2023-09-16 16:18:18 +02:00
Kawe Mazidjatari
66daec04db Fix compile errors in non cert builds 2023-09-16 13:10:12 +02:00
Kawe Mazidjatari
c9637196b8 Improve CEngineAPI signatures 2023-09-16 13:09:22 +02:00
Kawe Mazidjatari
5bab1bc6af Move CClient pointer adjuster to separate function
All process methods have a shifted CClient pointer, so this will be used more often.
2023-09-16 12:18:32 +02:00
Amos
95cd34eb23 Replace hardcoded sleep threshold constant
Replaced with a cvar.
2023-09-14 09:17:03 +02:00
Kawe Mazidjatari
eaa5347fa3 Only run NVIDIA Reflex if the display driver vendor is NVIDIA
This is to ensure we don't cause any performance hits when running the game on an AMD or Intel GPU.
2023-09-13 22:24:59 +02:00
Kawe Mazidjatari
907e582f55 Remove latency markers
Some parts of the engine have to be rebuild in order to implement this correctly, therefore, it has been removed for now to avoid potential performance problems.

fps_max_rt and fps_max_gfx have been limited to 295 to avoid a contest with the engine's hard limit causing huge performance hits.
2023-09-13 17:37:09 +02:00
Kawe Mazidjatari
4927654da0 Bugfix: only run NVIDIA Reflex if we ran an actual engine frame
CEngine::Frame() tends to return out early if we are ahead of frame time, and therefore need to sleep. In this particular engine, CEngine::Frame() returns true if it had actually executed an engine frame, else it returns false.

Therefore, we end up calling 'NvAPI_D3D_Sleep()' multiple times a frame, and thus causing a major loss in performance. Now we check if we have actually ran a frame (incrementing reflex frame if so). If the frame was not incremented, but 'GFX_RunLowLatencyFrame()' was called, it will not call 'NvAPI_D3D_Sleep()'.

Code has been tested and appears to work on my system (never called twice or more per frame). Needs more testing on other systems to make sure its good.
2023-09-12 20:50:38 +02:00
Kawe Mazidjatari
384ad649bf Update CEngineAPI::PumpMessages() signature
Function has been modified internally.
2023-09-12 17:44:58 +02:00
Kawe Mazidjatari
51a3f4a1c4 Only call 'NvAPI_D3D_SetSleepMode(...)' on pending changes
No need to keep calling this if there are no pending changes.
2023-09-12 17:44:24 +02:00
Kawe Mazidjatari
b87d7bf1c3 More improvements to the comment
Make a bit more sense.
2023-09-12 17:13:12 +02:00
Kawe Mazidjatari
bf29365e04 Fix typo
Should be tick as its possible to run more frames per simulation tick.
2023-09-12 17:09:19 +02:00
Kawe Mazidjatari
bcf7d03d90 Properly place PC_LATENCY_PING marker
Call once we peeked a message.
2023-09-12 13:20:13 +02:00
Kawe Mazidjatari
ea6c15df4c Initial implementation of NVIDIA Reflex Low Latency timing
Propagated latency markers in an attempt to further reduce input latency. Code is pending rigorous testing on several systems, including systems powered by an AMD GPU to make sure we are not impacting performance on systems that does NOT support NVIDIA Reflex.
2023-09-12 11:06:16 +02:00
Kawe Mazidjatari
9df90d4a25 Add cvar for low latency timing (work in progress)
Work in progress NVIDIA Low Latency timing implementation.
2023-09-12 00:19:47 +02:00
Kawe Mazidjatari
804f96625b Move NVIDIA Reflex implementation to library function
Improve code, there will be more NVIDIA GeForce related stuff soon.
2023-09-12 00:08:46 +02:00