245 Commits

Author SHA1 Message Date
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
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
6bc15b50b5 Put lag compensation clamping in a separate method, under a cvar that is disabled for now
There have been reports of hit registration issues, this is most likely caused by the clamping system to mitigate an exploit. Put behind a convar and disabled for now until debugged.
2024-04-05 16:34:29 +02:00
Kawe Mazidjatari
fa76747baa Show a more detailed error if the EULA request failed 2024-04-05 16:34:29 +02:00
Kawe Mazidjatari
22c82d6f1d EULA dialog implementation
Display the EULA (fetched from masterserver), which the end user MUST accept before they can make use of the multiplayer features of R5Reloaded. NOTE: user doesn't need to agree to this to use the listenserver.
2024-04-05 16:26:18 +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
c1c01d2302 Swap SSE4.1 instruction with an SSE2 instruction
The min spec is SSSE3, using SSE4.1 instructions (_mm_extract_epi64) will break compatibility. The code containing the defect is debug only, and %90+ of the user base uses an SSE4.1 capable processor.
2024-04-05 15:57:33 +02:00
Kawe Mazidjatari
f2058c9ecd Fix typo
Second statement should be checking on vecMaxBound.
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
bc59f1349d Use CUtlVector for map list 2023-09-05 17:34:22 +02:00
Kawe Mazidjatari
2e03139c39 Recover AIN runtime checksum validation
The runtime checksum is now also written to the file, as any changes to the info node entities will cause this checksum to change, and therefore we should warn the user that the file needs to be rebuilt. The NavMesh CRC is now written at the END of the AIN file, and only checked if a NavMesh is present for that particular level. The same warning gets printed if this checksum mismatches as the user should rebuilt it.

NOTE: the NavMesh checks are custom and are not part of the official AIN file structure of this game. This is added as the NavMeshes are frequently rebuilt.
2023-08-29 23:48:41 +02:00
Kawe Mazidjatari
a9b1d950e5 Read data from memory buffer instead of loading it from disk
Safe resources and potential failures.
2023-08-29 00:33:12 +02:00
Kawe Mazidjatari
f081fe6f67 Dump hull data blocks as well
The AIN dumper is now finished. Giving it a valid r1 AIN will make it spit out an identical AIN (minus the CRC header, but this is intended).
2023-08-28 23:17:03 +02:00
Kawe Mazidjatari
25e5ea0c83 CAI_NetworkBuilder::SaveNetworkGraph() rewrite
- Use CUtlBuffer instead to construct the data.
- Dump traverse ex nodes as well (CAI_TraverseNode).
2023-08-28 20:01:45 +02:00
Kawe Mazidjatari
51ac0bf353 Cleanup 2023-08-28 02:44:39 +02:00
Kawe Mazidjatari
5397ba4481 Fix return types
They are voids.
2023-08-27 12:13:07 +02:00
Kawe Mazidjatari
909a08a80b Remove testing code
No longer of use.
2023-08-27 11:38:44 +02:00
Kawe Mazidjatari
f22e7890b0 CAI_NetworkBuilder::SaveNetworkGraph: Fix bug
Iterated over the wrong vector, dumped AIN's from r2 are now 100% identical, the function has been debugged and is complete.
2023-08-27 11:38:02 +02:00
Kawe Mazidjatari
9d2801929a Map out 'CAI_NetworkManager' 2023-08-27 11:36:58 +02:00
Kawe Mazidjatari
3d0d8c7081 Get rid of disk structures
Less maintenance work; write the fields out directly from memory structures.
2023-08-27 00:56:38 +02:00
Kawe Mazidjatari
7e3f812a97 Rename fields
These are vtable pointers.
2023-08-27 00:29:31 +02:00
Kawe Mazidjatari
ea2c71242e Map out entity structures more
More types and improvements for base entity classes.
2023-08-27 00:20:23 +02:00
Amos
5ddc9d1884 Write each field individually
Cluster links were written with an additional padding as the struct is 11 in size, so it gets padded to 12. Cluster links now get correctly written to the disk.
2023-08-25 08:47:12 +02:00
Kawe Mazidjatari
52bc73abb0 Fix AIN building bugs
Fixed writing of:
- Path nodes
- Node links
- Path clusters
- Cluster links

The previous globals 'g_pppAiNodeClusters' and 'g_pppAiNodeClusterLinks' were of type CUtlVector. These have been retyped and renamed accordingly.

Also mapped the CAI_Cluster class out slightly more.
Rebuild of path clusters and cluster links are still not correct; parsing a file in from r2, results in a different file on the disk, at the very offset the clusters are being written in (one field is off, this will be investigated soon).
2023-08-24 23:44:57 +02:00
Kawe Mazidjatari
c21747c4c6 CAI_NetworkBuilder::SaveNetworkGraph() improvements
Always create safe path, cache index pointer and make heavy prints non-cert only.
2023-08-24 10:35:54 +02:00
Kawe Mazidjatari
c8752420a0 Use new Dev* logger functions
These get compiled in if IsCert() returns false.
2023-08-21 20:38:07 +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
c7c4672b27 Make it a discrete function
Cheaper for runtime.
2023-08-20 13:44:06 +02:00
Amos
6e292359d9 CBaseEntity::m_rgflCoordinateFrame is a matrix3x4_t
Change type and add static assert to prevent mistakes made by accidentally making the struct bigger (which will create many bugs).
2023-08-18 00:44:52 +02:00
Amos
bacfff184c Fix clock correction subtraction bug
Must be converted to actual msecs in floats since 'sv_clockcorrection_msecs' uses msec as base to store the cvar value.
2023-08-18 00:43:44 +02:00
Amos
4601c65bc6 Fix bots stuck in air
Make sure we set a frame time and command time.
2023-08-17 02:00:50 +02:00
Amos
5e47e45d83 Take clock drift into account during lag compensation clamp
Client's clock could be behind or ahead of the server's, take this into account. Note that this code has been tested over night and only had a few hits when new baseline snapshots were applied on the server, or when there was a clock drift. It still requires an actual playtest with several players on low and high latency to determine if this is even needed.
2023-08-17 01:59:54 +02:00
Amos
c7f1cfbaaa Improve unlag exploit fix
- Check and clamp if commandTime is above serverTime (too far in future).
- Check commandTime delta before checking if above serverTime or below lastCommandTime.
2023-08-15 22:53:42 +02:00
Amos
75e327e447 Normalize pitch angles
Prob not needed, but other unclamped angles/vectors were able to crash games in the past, so just normalize this too.
2023-08-15 20:19:38 +02:00
Amos
3ff85c174a Finish unlag exploit fix
- Make sure cmdTime is never lower than last.
- Make sure delta doesn't exceed maxUnlag.
- Make sure latency gets clamped to maxUnlag (clamp appears to be missing in the engine).
- Only check for cmdTime if we are not discarding the cmd; previously, already processed queued cmd's got checked before being discarded.
2023-08-15 00:45:58 +02:00
Amos
631e6d9e17 Work in progress unlag exploit fix
Temporary lag compensation exploit fix by clamping the difference. Exploiter could carefully control the detonation time of a grenade, or alter the ability cool downs by altering the 'CUserCmd::command_time' field before sending it up.
2023-08-14 20:47:02 +02:00
Amos
abb9f30753 Add inlines for getting edict and names 2023-08-13 20:26:08 +02:00
Amos
8136374693 Make inline
Make inline.
2023-08-13 20:20:01 +02:00
Amos
cf41004f74 Cleanup 'CServerGameClients::ProcessUserCmds'
Client gets dropped if buffer overflow flag is set, remove old code and just print the warning.
2023-08-13 18:08:14 +02:00
rexx
25bd407b39 add ScriptError script func 2023-08-12 22:41:48 +01:00
Kawe Mazidjatari
5f64cd83d8 Fix FileSystem size integer truncation
The implementation in the engine always took/returned signed 64bit size types, but I made a mistake when reversing the virtual function table. All types have been changed to what they should be (mostly signed 64bit, very few unsigned), and usage in-SDK has been adjusted accordingly.
2023-08-09 14:43:54 +02:00
Kawe Mazidjatari
d59a320d69 Remove 'Error(EXIT_FAILURE)' call from 'CreateWeaponBolt()'
The bug has been fixed in the engine.
2023-08-09 02:56:58 +02:00
Kawe Mazidjatari
38785bfc9b Fix kick/ban script function parameters
It requires a second parameter, as this contains the reason text.
2023-07-20 21:45:38 +02:00
Kawe Mazidjatari
a0f0b79266 Add callback for registering script constants, and added 'LISTEN_SERVER'
All listen server code should be compiled out of the scripts using 'LISTEN_SERVER'. The constant must have a non-null value.
2023-07-19 18:52:00 +02:00
Kawe Mazidjatari
80fecd2cb0 Improve help string and add a note 2023-07-19 18:50:07 +02:00
Kawe Mazidjatari
193abdc18a Remove scriptfunc stubs
Not really ideal, needs a different solution.
2023-07-19 17:17:38 +02:00
Kawe Mazidjatari
ee1fdca7a9 Register admin panel/core server scriptfunc stubs for client.dll
Stubbed to avoid compile errors.
2023-07-19 16:19:34 +02:00
Kawe Mazidjatari
904352498c Fix missing 'arguments' parameter to stub macro 2023-07-19 16:18:04 +02:00
Kawe Mazidjatari
cb4a037433 Fix typo 2023-07-19 16:17:49 +02:00
Kawe Mazidjatari
d860c43f79 Deduplicate code
Small deduplication.
2023-07-19 12:25:43 +02:00