146 Commits

Author SHA1 Message Date
Kawe Mazidjatari
bfe96e9ccd Game: use cached string lengths where possible
Avoid doing internal strlen() when length is already known.
2025-02-07 21:47:36 +01:00
Kawe Mazidjatari
8646dfa516 Client: use cached string lengths where possible
Avoid doing internal strlen() when length is already known.
2025-02-07 21:47:09 +01:00
Kawe Mazidjatari
24bce8ee73 Revert "LiveAPI: make code compatible with coroutines"
This reverts commit 9b2034d897e68e2c8677df739e14c77a59901652.
Squirrel coroutines cannot stop during native code execution, it can only happen after a native call has been completed which means that commit 9b2034d897e68e2c8677df739e14c77a59901652 is unnecessary. Revert back to using static objects as this is a lot more performant than allocating/freeing the message each time an event occurs.
2025-02-03 12:13:37 +01:00
Kawe Mazidjatari
8339c44c25 Client: fix underflow and overflow vulnerability in entitylist
Reported by @dr3murr
CClientEntityList::GetClientNetworkable() and CClientEntityList::GetClientEntity() lacked a proper clamp on the 'entNum' parameter. CClientEntityList::GetClientEntity() only handled entNum == -1 cases prior to this patch.
2025-02-02 23:46:59 +01:00
Kawe Mazidjatari
452c226316 Server: improve error message on empty class var value
Should be value as this is a key value system.
2025-02-02 14:32:11 +01:00
Kawe Mazidjatari
66a271d003 Server: fix member variable typo 2025-02-02 14:31:20 +01:00
Kawe Mazidjatari
8490344d93 Server: fix bug in CC_CreateFakePlayer_f
- We don't need to call CVEngineServer::LockNetworkStringTables, as CVEngineServer::CreateFakeClient already does this.
- We should never run CVEngineServer::CreateFakeClient() and CServerGameClients::ClientFullyConnect() when we aren't doing this from the server frame thread, or when we are doing it outside the server frame thread while its active. We not wait and help with other jobs until the server frame thread is finished before adding our bot.
- Removed team number check, this is already performed in CClient::SetTeam().
2024-12-05 20:10:07 +01:00
Kawe Mazidjatari
3209af9a6c Engine: large server host code refactor
This code was written at the start of the project before much of the engine was reverse engineered. There were some design problems where core server functions were shared with UI script.

A second problem was that not everything was properly synced between another; CServerHostManager held its own instance of the server name and server description, while the engine has actual convars to store these. So scripters weren't able to get the server name and server description if the server was a listen server and launched through the title screen.

The CServerHostManager class has been reworked to not keep a second instance, and the script functions for creating the servers have been reworked to always store the name and description in aforementioned convars.

Also moved the CreateServer and DestroyServer function to the UI namespace of scripts, and it is now only registered in UI context. The server should use GameRules_ChangeMap() to switch levels instead.

UI script also no longer registers core server functions, this was a design mistake and has been fully factored out in this patch.

The server script function 'SetClassVarSynced' has also been deprecated and removed, since calling this sends a netmsg to all connected clients, and running this once will not apply the new class var values to clients connecting afterwards. This should be managed through player.SetClassVar in the connect codecallbacks in scripts.
2024-12-05 15:53:40 +01:00
Kawe Mazidjatari
745024d198 LiveAPI: always set POD stack var if loop has ran, don't check it
No point checking on this, removes an extra instruction.
2024-11-18 01:36:32 +01:00
Kawe Mazidjatari
9b2034d897 LiveAPI: make code compatible with coroutines
The script engine supports running coroutines, which means we cannot use statics for each message as 2 coroutines could fight for a event mesage

I.e. we have 2 coroutines handling a player damaged event, the message could be populated with a mix of data between the 2 coroutines.

Therefore, we cannot optimize this by statically allocating it and must allocate it for each coroutine separately. The extra memory and cpu overhead caused by this is still very low.
2024-11-18 01:32:32 +01:00
Kawe Mazidjatari
c0a451f90d LiveAPI: remove newline character from error message
SQVM::RaiseError() does not need a newline character, remove it to keep consistency with the rest of the file.
2024-11-14 01:19:23 +01:00
Kawe Mazidjatari
2813c0e24f Server: improve ConVar help string
Improved the helpstring for ConVar navmesh_always_reachable.
2024-11-13 14:18:05 +01:00
Kawe Mazidjatari
a809b1f262 Server: remove exraneous client pointer check
CServer::GetClient() will never return NULL as it returns address of client in array. Removed extraneous checks as its misleading, and added const where possible.
2024-11-11 17:47:36 +01:00
Kawe Mazidjatari
5ed734a4ff Client: fix controller curve look
The rebuild was wrong, the reported issue was that during auto-aim, the rotation speed is higher than original with a weaker magnet. Since the dissasembly and decompile of this function wasn't correct, along with not being able to reproduce the issue locally, it was hard to debug the problem (the difference between the rebuild and the original implementation was very small, where only experienced players noticed it). Since I have concluded that we don't need this function rebuilt as nothing else in the function needed adjustments, we can therefore just hook it and add the multiplication scalars on the computed joy angles. This now seems to yield correct behavior based on new tests that were performed with these changes.
2024-11-11 17:39:53 +01:00
Kawe Mazidjatari
427860e6e9 InputSystem: add option to run the old CurveLook implementation
The rebuild should be correct, but to rule out any problems we might have after releasing this build, we should have a simple option to force the old implementation.
2024-11-10 14:02:49 +01:00
Kawe Mazidjatari
c72e34606b Server: only run the loop if we have an attached NavMesh 2024-11-10 12:27:14 +01:00
Kawe Mazidjatari
652b5d7018 Game: make navmesh render plane culling optional
Plane culling is too aggressive on larger tiles, make it optional.
2024-11-06 14:12:12 +01:00
Kawe Mazidjatari
8d5bc23cf6 Game: improve in-game navmesh rendering
Draw inner and outer poly boundaries, and only draw detail meshes if this was specified by the user. Most of the time we don't want to draw detail as this has a huge performance cost.
2024-11-01 13:37:32 +01:00
Kawe Mazidjatari
ac6da44a18 Recast: properly implement navmesh destructor
Reverse engineered the last types that were mostly unused and unneeded by the navmesh. But to properly implement the destructor it had to go in. Cells and hints now get freed as well and we can now rely on our own destructor for the navmesh data allocated by the game.
2024-10-22 11:56:26 +02:00
Kawe Mazidjatari
9f430a455e Recast: traverse over every tile in the array
dtNavMesh::getTileCount returns the total number of added tiles, the issue with this is that if the navmesh gets pruned, that means disabling unlinked polygons and removing dead tiles, then some tile instances in the m_tiles array may become empty. Less tiles will be installed and since there are null tiles in between, we won't be traversing each tile.
2024-10-13 21:36:46 +02:00
Kawe Mazidjatari
b91fd983f9 Server: light LiveAPI improvements
Increase nesting limit to 128, this should make sure it will always be enough while also making sure no infinite recursions occur. Also improved error print formatting.
2024-10-04 13:00:09 +02:00
Kawe Mazidjatari
ed62ebec9f Server: map IServerGameClients interface out
Not everything has been reversed yet.
2024-10-04 12:53:05 +02:00
Kawe Mazidjatari
cf7031866f Server: make inline method const 2024-10-04 12:50:31 +02:00
Kawe Mazidjatari
d312597c91 Engine: rework class var command and netmsg design
New command '_setClassVarClient' only sets the class var on the client, similar to how '_setClassVarServer' only sets it on the server. Command 'set' still has its old behavior, setting it on the server and client. The netmsg SVC_SetClassVar now only runs the _setClassVarClient handler, and if the netmsg was successfully sent, the code runs the _setClassVarServer handler directly instead of relying on the client to NET_StringMsg it in. This is a lot more reliable, secure and performant than the previous approach and drops the requirement of setting sv_cheats to function.
2024-09-28 12:43:11 +02:00
Kawe Mazidjatari
ba5801cce6 Server: implement script utility to set class variables on connected players
Allows setting class var changes on all connected players (SetClassVarSynced(key, val)), or on individual players (player.SetClassVar(key, val)).
2024-09-25 20:12:14 +02:00
Kawe Mazidjatari
9a68b15412 VScript: run initial registration code class callbacks first
Must be ran within the hook as otherwise engine code class functions won't be registered.
2024-09-25 15:39:01 +02:00
Kawe Mazidjatari
3b3127c2cf VScript: add code class script globals and registraction callbacks
Will be used to register custom script class functions.
2024-09-25 14:36:20 +02:00
Kawe Mazidjatari
3259b03fdd Server: name unknown field in CAI_TraverseNode
Confirmed to be the traverse type.
2024-09-18 01:50:19 +02:00
Kawe Mazidjatari
0eb0d73ae1 Game: make AI utility class instance static
Static allocation instead of dynamic.
2024-09-16 14:15:15 +02:00
Kawe Mazidjatari
d5abb89d9b Client: remove version from convar string
In case more anti-lag versions get released, since this is the highest level cvar controlling the system.
2024-09-15 12:16:09 +02:00
Kawe Mazidjatari
b182a8eca8 Client: add AMD Anti-Lag 2 settings convar
Used to hook it up to scripts.
2024-09-14 12:51:45 +02:00
Kawe Mazidjatari
e019de8dcd Recast: make detail triangle flags enum shared
The same constants are used between Recast and Detour, but Recast had to declare and match the constant locally as it couldn't access the one from the Detour library. This patch avoids duplicate definitions and potential issues during refactors.
2024-09-04 16:19:19 +02:00
Kawe Mazidjatari
9113b36bfd Core: fix typo's in function comment headers
Small typo's, fixed to retain consistency.
2024-09-04 01:09:09 +02:00
Kawe Mazidjatari
f5c0b428cb Recast: add hook bodies for NavMesh functions
Used for debugging the Detour implementation of the engine.
2024-09-04 00:57:26 +02:00
Kawe Mazidjatari
c64f28be25 Server: fix rare NavMesh hotswap crash
Detour_LevelInit resets the global NavMesh query, but if code is going to utilize the global Detour query for an existing query on a subsequent frame without attaching a NavMesh in the mean time, the code will crash. The previously attached NavMesh type has to be reattached after the hotswap.
2024-09-04 00:48:54 +02:00
Kawe Mazidjatari
05b6e23a75 Recast: fix naming consistency of helper function
Should be upper case to match the rest.
2024-08-29 22:43:15 +02:00
Kawe Mazidjatari
8fce111502 Recast: fix BVTree calculations and rendering (XZY -> XYZ)
Should've been converted to the source engine coordinate system as well, but we missed this as then rendering thereof was 'fixed' incorrectly causing incorrect bounding volumes to appear correctly. Fixed the renderer and the calculation; the AI now never gets stuck in-game regardless whether 256 or 512 sized tiles are used.
2024-08-21 14:40:33 +02:00
R5 Mkos
5705aba459
Update vscript_client.cpp 2024-08-16 23:07:13 -04:00
Kawe Mazidjatari
06b673dc84 Recast: rename constant
A more descriptive and correct name.
2024-08-14 11:34:07 +02:00
Kawe Mazidjatari
b63cb1d52c Recast: improve naming consistency for the traverse system
Traversal and traverse were mixed in variable/function naming. Forced consistency. No logic was changed this patch.
2024-08-09 14:35:47 +02:00
Kawe Mazidjatari
c4ac63ed69 Server: disable view punch by default
View punch on player in Hip is also disabled in retail apparently. Reflect behavior in SDK.
2024-08-08 14:32:21 +02:00
Kawe Mazidjatari
deb59074c1 Server: only disable view punch during aim by default 2024-08-07 17:35:29 +02:00
Kawe Mazidjatari
ffb8c5992d Server: add cvar that allows enabling/disabling view punch when taking damage 2024-08-07 13:01:50 +02:00
Kawe Mazidjatari
8cfce5ea9a Client: cleanup and optimize C_Player::CurveLook
Don't call C_BaseCombatCharacter::GetActiveWeapon twice.
2024-08-06 20:30:07 +02:00
Kawe Mazidjatari
2348a2dc61 Client: make C_WeaponX::HasTargetZoomFOV() const 2024-08-06 20:29:16 +02:00
Kawe Mazidjatari
07fd1cef8e Client: add method to check if weapon is melee 2024-08-06 20:28:52 +02:00
Kawe Mazidjatari
2914027574 Client: fix aim magnet bug and several other issues with CurveLook
The decompile of this function was still incorrect, after looking at the raw disassembly, bool v36 and bool v35 are now set correctly. Also, a float was never set and the decompiler assigned a local to an incorrect one for some math that was supposed to set the inputSampleFrametime, causing it to work as a counter magnet when target compensation was activated. This now also has been set correctly according to the assembly of the function itself, and now works as intended. So far, all bugs appear to be fixed in this function, its pending tests by users.
2024-08-06 00:59:59 +02:00
Kawe Mazidjatari
886f1c6a53 Client: fix numerous issues with CurveLook rebuild
Fix incorrect type for g_aimCurveConfig, its a static array, so it needs to be a single pointer not a double. Also fixed several blocks inside CurveLook that did not match the assembly code of the game. The aim-assist code is still broken however, pending research.
2024-08-05 20:06:26 +02:00
Kawe Mazidjatari
08a69db020 Client: fix nullptr deref crash when auto aim is enabled 2024-08-05 02:09:03 +02:00
Kawe Mazidjatari
f8331d7ac7 Client: only run ADS per-optic when zoomed in
Should only fire this code when zoomed in.
2024-08-05 01:42:24 +02:00