149 Commits

Author SHA1 Message Date
Kawe Mazidjatari
dd20e9f4aa Engine: use NucleusID_t type for CClient 2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
fcf3a09418 Make singletons use static memory
Avoid heap memory allocation and a level of indirection. This allows the compiler to optimize the program even more. No logic has been changed in this patch.
2024-04-05 17:52:57 +02:00
Kawe Mazidjatari
ee82d5d8e0 Tier1: move KeyValues class to Tier1
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
2024-04-05 17:42:05 +02:00
Kawe Mazidjatari
edc52ad669 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-04-05 17:19:32 +02:00
Kawe Mazidjatari
e2b508748d Server: improve extended client class
Use setters/getters and make members private and only accessible from CClient or CClientExtended.
2024-04-05 17:19:30 +02:00
Kawe Mazidjatari
8ae53d8336 CL_MoveEx: const correctness 2024-04-05 17:19:30 +02:00
Kawe Mazidjatari
e551e58a7d Server: rename 'ServerPlayer_t' to 'CClientExtended'
A more correct name + comments as to why this structure exists.
2024-04-05 17:19:30 +02:00
Amos
35bec64a5f Fix dedicated compile errors 2024-04-05 17:19:29 +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
59e0bfa10b NVIDIA: initial implementation of latency markers 2024-04-05 16:45:05 +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
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
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
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
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
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
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
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
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
d7448be952 Improve CClientState fields 2023-08-27 00:20:35 +02:00
Kawe Mazidjatari
4e1d99bf9d CClientState adjustments
Mapped out and aligned slightly more.
2023-08-26 01:25:07 +02:00
Kawe Mazidjatari
20cc4b1439 Rename CClientState field
Renamed to 'm_bUseLocalSendTableFile'. If set, the 'CClientState::ProcessSendTable()' method drops the SVC_SendTable message, and keeps using the local file instead.
2023-08-21 20:43:36 +02:00
Kawe Mazidjatari
71b0781715 Utilize 'DevMsg()' for uncertain builds only
Only uncertain builds will contain DevMsg()/DevWarning() prints. For retail, Msg() and Warning() should be used instead.
2023-08-21 19:12:29 +02:00
Kawe Mazidjatari
545ccac064 Improve CClient class
Added:
 - m_nDisconnectTick
 - m_nSendtableCRC
- m_nMmDev

Fixed incorrect placement for:
- m_LastMovementTick
2023-08-21 16:33:45 +02:00
Amos
00f7415380 Fixup CClient types 2023-08-14 00:30:20 +02:00
Kawe Mazidjatari
30031e3275 Don't allow stringcmd's if client isn't active
Potential exploit vector, executing stringcmd's during signon states where it shouldn't be used.
2023-08-08 19:25:12 +02:00
Kawe Mazidjatari
9a9d6b290a Fix typo 2023-08-08 19:05:12 +02:00
Kawe Mazidjatari
89431cc61f Fix crasher by clamping stringcmd length before tokenizing it
Possible crasher is to send a stringcmd >= 512 in size with funny UTF8 characters and have CUtlBuffer::ParseToken() read past it. Apparently seems to be mostly a problem on 32bit? I was unable to initiate a crash, though one string caused interesting behavior before, and there was one report of the dedicated server being 'crashed' with this. There is no reason to tokenize it up to 512 bytes if the game is only ever going to allow 128, so clamp it to 129 and if the user exceeds it then they still get the message and we just jettison it.
2023-08-07 16:52:35 +02:00
Kawe Mazidjatari
f2783ae93f Make use of 'CConnectedNetConsoleData::m_bInputOnly' properly
This member was in the class when RCON was added to the r5sdk, but it was never utilized. Now, each netconsole can toggle whether they are input only or not, the server only sends logs to netconsoles that are not input only. This patch also contains a fix in which the listen server sends logs to the client of its own process, causing an infinite recursive call to DevMsg.
2023-08-04 17:28:01 +02:00
Kawe Mazidjatari
ddfe027677 Pass by reference
CConnectedNetConsoleData was allocated and deallocated manually, but std::vector is able to do it on its own. The vector type has been swapped out with CUtlVector as this removed the need of having to cast size types to a 32bit int to make it more compatible with the other sdk/engine types without throwing compiler warnings.
2023-08-04 10:48:22 +02:00
Kawe Mazidjatari
6d39d99941 Fix mistake in comment 2023-07-19 18:47:25 +02:00
Kawe Mazidjatari
ad6466fa6c Add 'engine_cl' project to SDK and fix compiler errors
The 'engine_cl' library defines 'CLIENT_DLL', which prunes server specific code. This is used for the 'client.dll' project. Also fixed a compile error in 'CClient::VActivatePlayer', as it used a server only cvar. Ideally, this entire file gets ifdef'd out for engine_cl, currently it doesn't matter as nothing gets compiled in.
2023-07-19 02:30:07 +02:00
Kawe Mazidjatari
d5f35349a8 Decouple script function registration
Nicely decouple them. Everything server and client are now grouped as they should. The Ui namespace has been merged with Client.
2023-07-19 02:12:56 +02:00
Kawe Mazidjatari
e7d7c47531 Make 'CClient::IsHumanPlayer' inline 2023-07-17 17:38:21 +02:00
Kawe Mazidjatari
b5f68df826 Fix rare crasher due to missing NULL check on netchan
Netchan could be NULL, add a check in.
2023-07-17 17:08:37 +02:00
Kawe Mazidjatari
a738e58985 Remove legacy code
The persistence enabled field was no longer needed a while ago, but never removed.
2023-07-16 13:47:07 +02:00
Amos
2f209ddb60 Remove 'g_pClient' pointer
The whole array is part of the CServer class.
2023-07-12 09:14:33 +02:00
Amos
c6a9b855a2 Make simple CClient getters, inline
Small enough to be inline.
2023-07-12 09:11:31 +02:00
Amos
ccdfed1c19 Use CServer's 'GetClient'
Use the CServer's 'GetClient' method for obtaining clients by index.
2023-07-12 08:56:17 +02:00
Amos
126091d3bc Update CServer class
CClient array is part of the CPlayer class. The array has been added, filling up most of the 'unknown' gap. Vtable override functions have been added as the array is static, and therefore requires an implementation of the vtable, these are just stubs however, since the vtable pointer points to the implementation in the engine.
2023-07-11 08:42:02 +02:00
Kawe Mazidjatari
819b3aeb16 Move and rename 'IsValidUTF8', 'UTF8CharLength'
Moved to strtools (tier1); utility will be renamed and decoupled into 'stl_utility' soon.
2023-07-04 23:01:13 +02:00