83 Commits

Author SHA1 Message Date
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
193abdc18a Remove scriptfunc stubs
Not really ideal, needs a different solution.
2023-07-19 17:17:38 +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
f39de84d15 Create macro for scriptfunc definitions
Create a macro to make registration easier, by reducing the parameters.
2023-07-19 12:09:42 +02:00
Kawe Mazidjatari
6ccf3baa5a Split server/client specific game utils
Split into their respective libraries, this is to avoid linker errors regarding undefined symbols.
2023-07-19 02:27:28 +02:00
Kawe Mazidjatari
dccb897c27 Make 'sv_usercmd_dualwield_enable' server and client
Must be for server and client, as its used in shared code.
2023-07-19 02:14:09 +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
Amos
6e223d1730 Make shared code separate
The work is partial, and does not compile.
2023-07-18 21:05:29 +02:00
Kawe Mazidjatari
e33b566f88 Split server and client into separate libs
Work in progress; does not compile!
Moved script registration function to static gamedll libs instead, and used a pointer callback approach for calling them to avoid duplicate symbols during linkage.
2023-07-18 00:17:49 +02:00
Kawe Mazidjatari
46390ba875 Additional reduction of untyped variables
These were not caught by the regex due to typos, or additional symbols that were not taken into account when making the regex.
2023-07-03 00:02:08 +02:00
Kawe Mazidjatari
87f9420889 Globally reduce the use of auto for function pointer declarations
Find regex pattern:
inline auto ([a-zA-Z0-9_]+) = ([a-zA-Z0-9_]+)\.RCast<([a-zA-Z0-9_:<>*]+) *\(\*\)\(([^)]*)\)>\(\);
Replace regex pattern:
inline $3(*$1)($4);

This commit also removes the unnecessary initialization (which was required to type the auto variables),
and therefore removed 6kb of unnecessary dynamic initialization code.
2023-07-02 23:01:29 +02:00
Kawe Mazidjatari
64453b0661 Add CUserCmd constructor to SDK
Internal constructor from the engine.
2023-07-02 21:31:19 +02:00
Amos
ac4ab6aa1a Add reason parameter to kick/ban commands
Reason parameters are optional. For scripts, to use the default message, pass in an empty string. The function for the script system should be centralized soon to avoid more duplicate code.
2023-06-20 08:44:03 +02:00
Kawe Mazidjatari
c8648b9289 Fix typo
Typo.
2023-06-17 16:31:45 +02:00
Kawe Mazidjatari
51ea9c7c4f CUserCmd hardening
Fix several exploitable bugs in the CUserCmd class. Some of these have been used to exploit/cheat in-game. Fixes contain:
- Camera position clamping (the only patch that hasn't been tested yet!)
- Weapon activity exploit, allowing player to infinitely throw ordnances, and perform other 'cheats'.
- Akimbo exploit + server crasher, allowing client to set multiple inventory weapons as active. The active weapon index bounds were also not checked, a properly crafter CUserCmd message would therefore be able to crash the server.

Note that this does not fix all issues related to the UserCmd class; further reversing and testing revealed there is more to be fixed, these fixes will get implemented with a future commit.
2023-06-13 17:43:32 +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
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
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
aac74c11b2 Use 'IsDedicated()' inline 2023-06-01 22:55:36 +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
ee636477ce Uncomment
Header file exists, but is stubbed; uncomment.
2023-05-11 21:35:54 +02:00
Kawe Mazidjatari
359820615f Move low level code to tier0/tier1
Moved to tier0/tier1 so it could be compiled into a static library in the future.
2023-05-06 22:59:01 +02:00
Kawe Mazidjatari
75ccebb4b6 Squirrel system restructure
Properly decouple squirrel and game code. This makes it easier to reverse engineer more of this squirrel system, and to compile them as individual libraries later on when moving to CMake to significantly decrease compile times.
2023-05-06 16:23:56 +02:00
Kawe Mazidjatari
b8035120de Assign unused constructor parameter 2023-04-16 01:23:38 +02:00
Kawe Mazidjatari
4079956356 Fix non-portable include paths
Portable include paths are case sensitive.
2023-04-08 18:52:33 +02:00
Kawe Mazidjatari
b0d2665550 /W4: Fix compiler compatibility
Clang doesn't support function-style casts with types containing a space.
2023-04-02 17:34:42 +02:00
Kawe Mazidjatari
4e7693bae6 /W4: Fix name shadowing warnings 2023-04-02 17:25:18 +02:00
Kawe Mazidjatari
42b3e49840 /W4: Properly pack server animation structures
Manually add fields to align structure properly. This suppresses many pesky compiler warnings.
2023-04-02 17:19:13 +02:00
Kawe Mazidjatari
a4a2f34c10 /W4: Fix signed/unsigned mismatch
This commit fixes warnings and bugs caused by signed/unsigned mismatch.
2023-04-02 12:09:43 +02:00
Kawe Mazidjatari
e9fac084fe Fix struct -> class compiler warning
'dtMeshTile' is defined as struct, but declared as class, causing a compiler warning. Fixed by declaring it as struct.
2023-04-02 01:23:07 +02:00
Kawe Mazidjatari
69624baa10 NavMesh debug draw code refactor
* Use mathlib SIMD wrappers instead, this is to maintain compatibility across different platforms/compilers.
* Moved camera distance logic to separate method.
2023-04-01 20:54:10 +02:00
Kawe Mazidjatari
f2d1b9e643 Fix crash caused by returning unsigned values
Function returned '-1' as 'ULONG_MAX'. This patch fixes this problem while suppressing compiler warnings.
2023-04-01 17:39:22 +02:00
Kawe Mazidjatari
371e15db41 Fix many verbose compiler warnings
Many compiler warnings regarding implicit conversions.
2023-03-18 16:45:43 +01:00
Kawe Mazidjatari
0b85476011 Belongs to the previous commit 2023-02-13 23:47:12 +01:00
Kawe Mazidjatari
b1f2f47058 Update names across codebase 2023-02-12 15:06:08 +01:00
Kawe Mazidjatari
918535ff0f Fix crash during bots simulation
Wrong ptr to 'CUserCmd::Reset'.
2023-01-31 00:03:40 +01:00
Amos
d76ed1098a Improve VFTable address logging
More standardized VFTable address logging.
2023-01-25 11:19:53 +01:00
Kawe Mazidjatari
a618990937 Detour code refactor
This change was planned for a long time. This moves all REGISTER calls to a single translation unit, this is required as we currently added a very dirty workaround for not registering duplicates by checking if VFTable pointer was already present in the vector... Registering from single translation unit prevents duplicate instances that gets created if header is included by more cpp files.
Reworking this reduced 100kb+ of compiled code. This commit also reworked the way functions/variables/constant gets logged with their addresses; the new code formats them on the fly, and allows for resize at any time. Formatting is no longer required by programmer.

TODO: currently there are some compile errors for dedicated and client dll's. These will be resolved very soon as they need to be properly worked out still (server & client only stuff needs to be properly split). Use the 'main' (stable) branch for the time being if you need to compile these dll's.
2023-01-25 02:26:52 +01:00
Kawe Mazidjatari
19447f1122 Improve debug draw depth test toggle logic
* Add box depth test cvar from engine for 'CBaseAnimating::DrawServerHitboxes'.
* Use noDepthTest field from OverlayBox_t instead of the cvar.
2023-01-24 12:05:09 +01:00
Kawe Mazidjatari
66ef9fb6a0 Fix crash in hitbox drawing code and light restructure
* Fix null pointer dereference crash in server hitbox drawing code; implemented a proper getter for CStudioHdr.
* Moved 'baseentity.h/cpp' to 'game/server/' instead.
* Overall light cleanup.
2023-01-23 23:21:29 +01:00
Kawe Mazidjatari
502a1d2324 Switch box overlay transform type to 'matrix3x4_t'
Actual type turned out to be 'matrix3x4_t' after further reverse engineering.
2023-01-23 02:20:21 +01:00
Kawe Mazidjatari
07ef57536d Add modelinfo vftable pointers 2023-01-22 16:48:16 +01:00
Kawe Mazidjatari
4b5d24a51f Fix trace filter shadow bug
Shadow: VFTable was never set.
2023-01-22 13:05:26 +01:00
Kawe Mazidjatari
d7f3209525 Mapped out hit group standards
Mapped out from Squirrel code.
2023-01-22 12:06:05 +01:00
Kawe Mazidjatari
15429d3f8f Add 'CTraceFilterSimple' to SDK 2023-01-21 16:22:16 +01:00
Kawe Mazidjatari
eff106e415 Improve CCollisionProperty
Set 'm_pOuter' to CBaseEntity*.
2023-01-21 16:18:12 +01:00
Kawe Mazidjatari
9720d8b0f1 Fix 'g_pGlobals' and 'UTIL_PlayerByIndex()'
'UTIL_PlayerByIndex' now returns the player from the edict array properly, 'g_pGlobals' had to be dereferenced twice.
2023-01-20 14:07:25 +01:00