203 Commits

Author SHA1 Message Date
Kawe Mazidjatari
329621c6ad Move all public headers into root of 'public' 2022-08-09 17:18:07 +02:00
Kawe Mazidjatari
e92b5d1300 General cleanup
Use c++ methods, remove unnecessary casts, unnecessary use of auto, etc..
2022-08-09 15:19:12 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Kawe Mazidjatari
9d06a02614 General cleanup
* Use Cbuf functions for executing commands in ImGui panels.
* Use const qualifiers for all vftable indexes.
2022-08-09 02:35:00 +02:00
Kawe Mazidjatari
93375d9a1f Improve NavMesh debug draw colors 2022-07-25 20:40:28 +02:00
Kawe Mazidjatari
086489a000 AIN/NavMesh debug draw improvements
* Move AIN/NavMesh debug draw to ai_utility_shared.cpp.
* Use shift index + range for AIN debug draw.
* Added cvar for determining max distance between camera and tile (anything outside this range doesn't get draw).
2022-07-25 16:39:07 +02:00
Kawe Mazidjatari
799dac882a Add 'MainViewOrigin()' and 'MainViewAngles()'
Implemented g_vecRenderOrigin and g_vecRenderAngles to SDK.
2022-07-25 12:46:57 +02:00
Kawe Mazidjatari
f314b9b4e7 Start of C_Player reversing 2022-07-24 12:59:40 +02:00
Kawe Mazidjatari
be42e98197 CAI_NetworkBuilder::SaveNetworkGraph improvements 2022-07-20 21:06:19 +02:00
Kawe Mazidjatari
5486923f47 Improve CAI_NetworkBuilder::SaveNetworkGraph
* Use proper format specifier for short.
* Remove redundant IsBadReadPtrV2 call when writing script nodes (this was initially for debugging but hasn't been removed after development finished).
2022-07-20 16:22:03 +02:00
Kawe Mazidjatari
bd0edc663d Add 'g_pHullMasks' into SDK
Static array of hull masks
2022-07-20 12:33:39 +02:00
Kawe Mazidjatari
59dd3e2228 NavMesh system improvements
* Confirmed DT_MAX_AREAS size being 32 (originally 64).
* header->offMeshEnds to -1.
* Added pointer to 'g_pHullMask'.
2022-07-19 22:00:40 +02:00
Kawe Mazidjatari
0026723aef Add g_pNavMeshQuery signature to SDK 2022-07-17 12:55:38 +02:00
Kawe Mazidjatari
c79cfa4968 Declare GetNavMeshForHull() 2022-07-13 11:44:38 +02:00
Kawe Mazidjatari
2dd66662b2 Add g_pNavMesh to SDK
Add g_pNavMesh to SDK and a simple wrapper for obtaining NavMesh from array.
2022-07-13 11:42:07 +02:00
Kawe Mazidjatari
96abdf619c Rebuild 'ai_script_nodes_draw'
Originally stripped from retail.
2022-07-11 12:00:08 +02:00
Kawe Mazidjatari
7d89a42b56 Mathlib implementation
SourceSDK mathlib port with light modifications.
Renamed Vector to Vector3D (to avoid confusion with std::vector (declared as vector) and Vector2D/Vector4D).
2022-07-06 21:11:32 +02:00
Kawe Mazidjatari
fbcee16f97 CAI_NetworkBuilder::SaveNetworkGraph improvements
Use CIOStream class.
Use proper type for CAI_Network::m_iNumNodes.
Improved CIOStream to take std::filesystem::path instead of std::string.
2022-06-24 16:56:28 +02:00
Kawe Mazidjatari
79372aa485 Prefix internal function pointers with 'v_' 2022-06-12 13:24:30 +02:00
Kawe Mazidjatari
49be7e4e96 Update ai_networkmanager.cpp 2022-05-26 01:44:54 +02:00
Kawe Mazidjatari
4b72afb74f Light refactor for logging
Moved logging functions to dbg.h (tier0) and export them from the dll.
Added additional functions for checking bad pointers (debug only!).
Reduced output code size.
2022-05-25 14:18:29 +02:00
Kawe Mazidjatari
efb7c36408 Light project restructure
Moved server/client headers and implementations into dedicated subfolder.
Renamed Some classes to match the game binary (e.g. CBaseClient is now CClient).
Removed redundant files.
2022-05-20 11:52:19 +02:00
Kawe Mazidjatari
3144227ec8 Update GetAdr implementations to feature spdlog
Fixed all alignments and reduced code verbosity
2022-05-13 14:53:25 +02:00
Kawe Mazidjatari
611ea6447a Console performance improvements and bug fixes
* Heavily reduced string compares for coloring logs (the left overs require a dedicated hook, this is for the future)
The new method uses a ImVec 4 constant containing the color obtained via a switch case by context, this is then out into the new CConLog structure where the loop in the console will now gather the colors directly from.
Error/Warning use a single constant.

* Fixed bugs in several log locations where the ostringstream was cleared before the emission causing double logs.

* Added global log mutex to log wrappers that lacked those.
2022-05-09 02:20:07 +02:00
Kawe Mazidjatari
c1da90db33 Update ai_networkmanager.cpp 2022-05-08 19:09:31 +02:00
Kawe Mazidjatari
34fddf723a Use uppercase for hex 2022-05-06 16:28:13 +02:00
Kawe Mazidjatari
d0974f7317 Validate AI Network during load
Compares AINet version, map version and NavMesh (large) checksum, warns and logs to console if conditions aren't satisfied.
2022-05-06 16:20:51 +02:00
Kawe Mazidjatari
7dd107916c Fix rare crash
Rare crash when the sqvm tries to look for an animation sequence on a missing prop_dynamic model (mdl/error.rmdl doesn't support animations), its purely to indicate there is a problem).
2022-04-30 18:59:55 +02:00
Kawe Mazidjatari
3cb4976c23 Start or 'mdl/error.rmdl' fallback implementation (see description)
In 'datacache/mdlcache.cpp' the function 'CMDLCache::FindMDL' attempts to find 'mdl/error.rmdl' and assigns the studiohdr and handle to the members of CMDLFallback.

In 'CMDLCache::FindUncachedMDL' we check if a model exists, if a model does not exist, we replace the studiohdr with the one of error.rmdl we stored in the CMDLFallback structure.

This does actually work (on the dedicated server it doesn't crash at all!), but on the client it crashes when trying to gather props (right before rendering), setting the ConVar* 'old_gather_props' does interesting things (check IDA around this ConVar*). setting this to 1 causes it to crash in another CMDLCache method when trying to deref something in the global cache pool.

This method is easy to rebuild. I will do this soon and attempt to return error.rmdl parts from here as well if results are null (this might actually just work).

Leaving 'old_gather_props' to 0 causes it to crash in the middle of the function which is supposed to gather the props the 'new' way.

The gather props functions are kind of daunting

NOTE: Currently only confirmed to work somewhat properly on the dedicated server for prop_static. prop_dynamic is unconfirmed. And (almost?) works on the client.
2022-04-29 05:30:06 +02:00
Kawe Mazidjatari
e32cc6ae6a Code overhaul
Moved every pattern to IDetour interface. This allows for debugging patterns scans more easily, and create threads during pattern searching (Operation is now fired in APIENTRY).

Also cleaned up some unused code/extraneous comments.
Slightly increased performance by purging duplicate patterns.
Made variable search less dependent from other results (except if pattern-to-scan results is within the same header)
2022-04-18 03:35:08 +02:00
Kawe Mazidjatari
7ba4f4021b Remove last hardcoded addresses for GameSDK 2022-04-13 01:25:33 +02:00
Kawe Mazidjatari
e1f5e7d46b Un-hardcode all CHostState dependencies
The SDK now works on executables with ASLR enabled.
!TODO: Dedicated.
2022-04-12 02:48:46 +02:00
Kawe Mazidjatari
092b7e9d43 Start of migration to IDetour interface
Migrating to this to initialize all patterns and prototypes in Systems_Init() instead.
This should make debugging missing/not found patterns easier and allow for opting out variable/constant search (some of these require other patterns to be found, thus resulting in seg faults..).

Also added check to detect if user has a eligible CPU to run this SDK.
The game requires SSE and SSE2 instruction sets. Our SDK requires this too due to the use of SSE intrinsics, so we cannot let the game handle this. We have to check it ourselves.
2022-04-11 01:44:30 +02:00
Kawe Mazidjatari
8c1dfb50f4 Address class cleanup/improvements
* Move most definitions to implementation file to avoid recompiling whole program for small changes
* Pass strings by reference for where possible.
* Split Module class to dedicated file.
* Add const qualifiers to all eligible methods for address/module class
* Some renaming
2022-04-10 19:59:34 +02:00
Kawe Mazidjatari
2dcbf59041 Move ConVar/ConCommand stuff to tier1 instead and cleanup KeyValues/KeyValuesSystem 2022-04-09 16:16:40 +02:00
Kawe Mazidjatari
b3631facbe Update all function casts 2022-04-09 06:05:47 +02:00
Kawe Mazidjatari
e2f06a8a68 Massive performance improvements
Inline every signature defined in the SDK (previously each translation unit had its own copy of the signature and function prototype). DLL init is near instant now (85% speed improvements).
2022-04-09 02:18:57 +02:00
Kawe Mazidjatari
aa57170e0d Start of pattern search refactor 2022-04-09 01:14:22 +02:00
Kawe Mazidjatari
f4b263b412 Cleanup 2022-04-05 01:13:27 +02:00
Kawe Mazidjatari
7258a35ff5 Add AI Network methods and add hook for AIN connection debug 2022-04-03 03:10:48 +02:00
Amos
378df25d4c Fix struct padding for AIN
Small fixes
2022-03-24 16:31:53 +01:00
Kawe Mazidjatari
05b37bf111 Fix 2 crash cases during AIN build 2022-03-24 02:08:27 +01:00
Kawe Mazidjatari
328fc61b27 Fix MSVC compiler errors 2022-03-23 19:23:53 +01:00
Kawe Mazidjatari
bd990ef0f9 Fix crash cases during buildAINFile 2022-03-22 17:18:29 +01:00
Kawe Mazidjatari
3110bbfb78 Calculate CRC for AIN (for later)
Add CRC calculated from large NavMesh (used to build AIN..)  for later.
The future check will compare AIN CRC and NavMesh CRC and warn if they don't match (recommend a update, and auto run update if cvar set).

Also added better profiling to SaveNetworkGraph code
2022-03-22 01:59:02 +01:00
Kawe Mazidjatari
a49a5bb781 AIN build and saving now fully works
AI is pretty much completed.
All that has to be done currently is making a simplified mesh of a map to cast a NavMesh on.
2022-03-21 13:48:34 +01:00
Kawe Mazidjatari
b99f310198 Parsing Titanfall 2 AIN's now fully works
The AIN structure, including the in-memory structures seem identical to Titanfall 2. I mapped quite a few 'CAI_Network' related functions out and everything seems to line up. But I haven't figured the script nodes out (yet), but looking at this, it seems like they got completely stripped? TODO..

I also found where it creates nodes/links from input NavMesh, the poly structure also seems identical to Titanfall 2, but still haven't found where this extra field gets used.
2022-03-21 00:28:14 +01:00
Kawe Mazidjatari
92edf22b07 The beginning of SaveAINFile 2022-03-20 17:03:46 +01:00
Kawe Mazidjatari
35ad8554a5 Somewhat correct working navmesh
The reachability table needs to be figured out still. The issue should be very small, but at the moment I do not have time for it.

The pointer to the table, and table pointers to data is correct, however, not a single poly is ever getting marked as 'reachable' (0xffffffff). This could be either within recast itself (see build_link_table() and set_reachable() functions), or the way the engine parses the data. The function that determines whether poly is reachable is located at '0x140F448E0'
2022-03-18 03:14:07 +01:00
Amos
ff06cb71eb Fix build for S1 2022-03-07 11:36:45 +01:00