2690 Commits

Author SHA1 Message Date
Kawe Mazidjatari
975c40876a CModule and CMemory class improvements
This commit significantly reduces output code size, and a noticeable increase in performance. Changes are:
- Removed all extraneous std::string and std::vector copy constructions; use raw pointers instead to boost performance.
- Marked simple getters in CModule inline.
- Marked several functions in CModule const.
- Slightly reordered CModule class.
- 'CMemory::CheckOpCodes' and 'CMemory::Patch' now take a const reference.
2023-06-12 18:40:16 +02:00
Kawe Mazidjatari
c874b7c4d8 Implement 'SVC_UserMessage' print handler properly
Check if the actual message type is 'TextMsg' before printing, since other data is binary and could be read as 'HUD_PRINTCONSOLE', 'HUD_PRINTCENTER', etc.. resulting in printing binary data. This fix permanently solves that problem. The check has also been applied to the 'ShouldReplayMessage' function.
2023-06-12 02:02:29 +02:00
Kawe Mazidjatari
4290b08fd0 Fix desync in CUtlbuffer::ParseToken in assembled code
See commit 4969a840300bbafbc5a47f06fef41751a5620fc9, the same fix has been applied to the game executable.
2023-06-07 22:15:28 +02:00
Kawe Mazidjatari
4969a84030 Fix desync in CUtlbuffer::ParseToken
The if statement comparing 'nLen' with 'nMaxLen' increments 'nLen' first at all times, but the statement below that checks the delimiters seeks -1 from current pos, causing a desync. This could result in reading arbitrary memory on certain strings. This fix also fixes the useless need to 'snag' the delimiters from tokens.
2023-06-07 21:21:55 +02:00
Kawe Mazidjatari
a2468bb184 Normalize view angles in client's usercmd
Must be normalized, bad values (NAN or FLT_MAX) will crash the game. There is more that needs to be clamped, but before we can do this CUserCmd has to be reversed more.
2023-06-06 00:53:05 +02:00
Kawe Mazidjatari
70f89c1bd8 Fix incorrect ConVar string assignment in executable
This ConVar's name was set to its helpstring. This patch solves it by assigning the name field to an existing string that makes sense, and moving the helpstring into the actual helpstring field. An additional instruction has been inserted to load the NULL string address into RAX, which required light instruction shifting. After performing this patch, the ConVar now could be ser in the console.
2023-06-05 10:27:23 +02:00
Kawe Mazidjatari
2ae8a74ad9 Remove duplicate call to 'CNetChan::SetChoked()'
Should only be called if client is active.
2023-06-05 08:07:04 +02:00
Kawe Mazidjatari
8e1019a265 Make simple CNetAdr methods inline
Should be inline for their simplicity to improve performance.
2023-06-05 01:45:33 +02:00
Kawe Mazidjatari
4ed2e7a12a Mark as const
Mark as const.
2023-06-05 01:37:00 +02:00
Kawe Mazidjatari
11fd49efde Fix speed hack exploit
The frame time send from CL_Move is not sanitized on the server; clamp it to the same cvars the client is clamping them to so players busting out the clamps cannot speed hack. The values are replicated between the server and client, so if someone wants to tweak the values, it won't mess up on either the server or client.
2023-06-05 01:24:23 +02:00
Kawe Mazidjatari
9f2b1b1bb5 Improve CL_Move rebuild
Ported the logic from the more recent builds into the SDK rebuild. Note that this isn't all that has changed in the live builds, but were the only things worth porting back. Frame times are now properly clamped on the client. Some testing revealed that the movement now feels identical to the live version of the game, which was the target. This commit also fixes a bug in CL_Move were the datagram was not send, and the next cmd time wasn't set if the client was NOT active, while it should have.
2023-06-05 00:27:36 +02:00
Kawe Mazidjatari
671528cb2b Add max backup commands defines
In R5, its 4 bits for backup commands.
2023-06-04 22:00:15 +02:00
Kawe Mazidjatari
bba1cdd8b2 Fix dedicated server compile errors
These files should have been placed into the client only group.
2023-06-04 11:19:30 +02:00
Kawe Mazidjatari
1afa75fec3 Fix >190FPS input system/simulation problems
Function 'CL_Move' has been fully rebuild in the SDK. Originally, the game checked if the delta time exceeded an amount defined by an immediate value, and dropped usercmd's if that was the case. This logic has been replaced with a more dynamic solution, and the console variable regulating this ('fps_input_max') is set to 200.0 by default (the same as the fix applied in the Season 9.1 Genesis update). This function also has been slightly optimized by removing duplicate operations that were performed in the original function. A second fix has been applied to 'CInput::JoyStickApplyMovement' that was also found changed in the Season 9.1 Genesis executable. In that function, an extraneous clamp was performed on the frame time causing viewstick problems when usercmd's get dropped in CL_Move.
2023-06-03 21:20:23 +02:00
Kawe Mazidjatari
b567d8d74f Add 'CHLClient::CreateMove' to SDK 2023-06-03 18:21:13 +02:00
Kawe Mazidjatari
58f8bae127 Add CNetChan methods to SDK
Added 'CNetChan::CanPacket' and 'CNetChan::SendDatagram'.
2023-06-03 18:19:28 +02:00
Kawe Mazidjatari
693b378618 Remove left over function declaration
This function no longer exists.
2023-06-03 18:11:59 +02:00
Kawe Mazidjatari
cf3688a164 Add 'host_initialized' to SDK
Should had been part of commit '19df5a18'.
2023-06-03 18:11:20 +02:00
Kawe Mazidjatari
3d18be9ebb Add splitscreen types to SDK
R5 'MAX_SPLITSCREEN_CLIENTS' appears to be max 1.
2023-06-03 18:10:32 +02:00
Kawe Mazidjatari
3d80049ad4 Fix incorrect padding in CFrameSnapshot
'CFrameSnapshot::m_TickUpdate::m_nCommandTick' was at 0x44, the shifting was fixed by removing the extraneous padding.
2023-06-03 18:08:16 +02:00
Kawe Mazidjatari
cef62d7f4d Properly implement 'CClientState::IsPaused()'
Should check if host is initialized, and if the VGui system is paused as well. Also added 'CClientState::GetFrameTime()'.
2023-06-03 18:06:35 +02:00
Kawe Mazidjatari
19df5a188b Add 'CEngineVGui::ShouldPause()' virtual method 2023-06-03 18:05:09 +02:00
Kawe Mazidjatari
63ca5d9d98 Make small bitbuf methods inline
Make inline to boost performance.
2023-06-03 18:04:38 +02:00
Kawe Mazidjatari
f30ee91d4e Add CLC_ClientTick netmessage to SDK 2023-06-03 18:03:14 +02:00
Kawe Mazidjatari
e891d74656 Fix cURL error logging for dedicated
Since this file no longer gets build along with the DLL project, but as a static lib instead, the 'DEDICATED' define no longer worked, and therefore this became broken after the CMake port. The 'CURLHandleError' helper function now takes a bool determining whether or not to log the error, and the caller disables it for dedicated (dedicated should only log the error once, this happens from within the caller class).
2023-06-02 00:05:23 +02:00
Kawe Mazidjatari
a8f7336d78 Fix default CFG file loading
After the CMake refactor, this became broken as the 'DEDICATED' define does not work in tier0 headers. These were the last ones; moved to the DLL project instead. This commit also fixes a bug where the command line file gets parsed twice, while there was already a global containing the args (initialized on DLL init).
2023-06-01 23:44:55 +02:00
Kawe Mazidjatari
aac74c11b2 Use 'IsDedicated()' inline 2023-06-01 22:55:36 +02:00
Kawe Mazidjatari
840c6c869b Add 'IsDedicated()' inline 2023-06-01 22:54:47 +02:00
Kawe Mazidjatari
d77dbdafb9 Remove extraneous subtraction from array size constant
The subtraction is not needed.
2023-06-01 00:08:22 +02:00
Kawe Mazidjatari
b886014abd Fix typo 2023-05-31 23:58:24 +02:00
Kawe Mazidjatari
8e379457bf Fix server code crasher in 'FireWeaponBolt'
The function 'FireWeaponBolt' calls 'CreateWeaponBolt' to create a bolt entity, but it can return NULL. 'FireWeaponBolt' does NOT check for NULL and derefs the pointer regardless. This rarely happens though; in all cases, it was caused by a defect in scripts. Code has been hooked to throw an engine error instead of crashing.
2023-05-31 23:58:10 +02:00
Kawe Mazidjatari
177cf2ca55 Add 'UTIL_GetEntityScriptInfo' to SDK
Retrieves information for an entity, formats it as <className> <scriptName> [<edict>] or <className> [<edict>].
2023-05-31 23:55:18 +02:00
Kawe Mazidjatari
4c40114106 Fix incorrect format for error message box
Should use the formatted text, not the text with the context and colors concatenated to it.
2023-05-31 23:52:19 +02:00
Kawe Mazidjatari
b65e06a390 Make const
Make const.
2023-05-31 22:07:54 +02:00
Kawe Mazidjatari
a061f7dd00 Optimize C2S_CONNECT vuln fix
Save 2 bytes from segment padding by performing zero test at original address followed by the long jump to patch, there were 5 bytes, zero test only requires 2, thus only 3 bytes were nopped with these changes.
2023-05-31 21:25:16 +02:00
Kawe Mazidjatari
619bbd161c Fix stringcmd replay exploit
This commit fixes an engine bug where netmessages are getting copied into the replay buffer, while these messages should never be replayed. The engine performs an internal check on 'CNetMessage::m_nGroup', and if its NOT 2, the message is getting copied into the replay buffer. All messages returning false in 'ShouldReplayMessage' are not getting copied into the replay buffer anymore. This exploit has been used in the past to route clients that were watching a replay to an arbitrary server, which essentially forms an info leak as the client attempts to connect to the arbitrary server on its own. The exploit also allows for some form of remote code execution, depending on if the client was launched in developer mode or not.
2023-05-30 23:01:46 +02:00
Kawe Mazidjatari
c3cbdea12c Add netmessage enumeration
Enumeration of all netmessage types.
2023-05-30 21:55:47 +02:00
Kawe Mazidjatari
c2799ff68c Fix bug in vulnerability patch
Value should be treated as unsigned, else negative values could still be used to read outside the static buffer.
2023-05-30 20:24:52 +02:00
Amos
46fafef60c Fix vulnerability in C2S_CONNECT message parser
Thanks Robotic for reporting the crash!
2023-05-30 10:03:53 +02:00
Kawe Mazidjatari
abef34d3ef CPackedStore refactor
* Improve naming convention, and make it more consistent.
* Use engine types as much as possible.
* Reduced the amount of string copy constructions.
2023-05-29 21:41:17 +02:00
Kawe Mazidjatari
7f15b94cd9 String tools improvements
* Add 'V_IsValidPath'.
* Add optional parameter to 'V_StripLastDir', in which the new length of the string gets written into.
2023-05-29 21:37:15 +02:00
Kawe Mazidjatari
7e2b249ef6 CUtlString improvements
* Add method for finding a substring ('CUtlString::Find').
* Add method for appending a slash ('CUtlString::AppendSlash').
* Add 'CUtlString' overload for 'CUtlString::IsEqual_CaseSensitive'.
* Add 'CUtlString' overload for 'CUtlString::IsEqual_CaseInsensitive'.
* Add optional parameter to strip trailing slashes in 'CUtlString::DirName'.
* Add optional parameter to strip trailing slashes in 'CUtlString::StripFilename'.
2023-05-29 21:35:12 +02:00
Kawe Mazidjatari
04856caf05 Display and host using playlists instead of gamemode
This should show the actual playlist rather than the gamemode.
2023-05-29 21:13:28 +02:00
Kawe Mazidjatari
e2338d8231 Disable client project
Disabled for now due to errors.
2023-05-29 21:11:36 +02:00
Kawe Mazidjatari
b4cc52c3d9 Rename protocol projects
Renamed
2023-05-29 21:11:17 +02:00
Kawe Mazidjatari
0fe6af008c Fix data truncation on VPK unpack
If the chunk if uncompressed, continue the loop instead of breaking out of it. Only 2 files were affected by this bug from original VPK's: 'notosansjp-regular.vfont' and 'notosanstc-regular.vfont'.
2023-05-29 15:56:59 +02:00
Kawe Mazidjatari
71b7770968 Add BSP converter batch file
Automate BSP version conversions.
2023-05-29 01:04:39 +02:00
Kawe Mazidjatari
054b123004 Don't load certain lumps for dedicated
This significantly reduces disk size, and also reduces memory usage.
2023-05-29 01:03:27 +02:00
Kawe Mazidjatari
245d13cea8 Create map rename script
Rename all files associated to a BSP with a single command.
2023-05-28 10:31:17 +02:00
Kawe Mazidjatari
417e91b8d9 Merge recastnavigation/recastnavigation@9432fd6381 2023-05-27 16:02:48 +02:00