SourceSDK mathlib port with light modifications.
Renamed Vector to Vector3D (to avoid confusion with std::vector (declared as vector) and Vector2D/Vector4D).
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.
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.
* 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.
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).
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.
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)
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.
* 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
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).
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
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.
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'
* Partially rebuild CGlobalVarsBase and CGlobalVars struct.
* Partially implement BuildAINFile (disk builder) written by BobTheBob9. All that needs to be found are the addresses/offsets for 'pUnkStruct0Count' and 'pUnkLinkStruct1Count' (see ai_node.h). I didn't have time for it yet.
* Patch call which restarts the engine once AIN file has been build (so it doesn't get cleared from memory).
* Temporarily patch write operation in 'Detours_LevelInit()' which writes out of scope since the navmesh structure is misaligned somewhere still with a few bytes.
NOTE: 'CAI_NetworkBuilder::BuildFile()' is for now commented out until the 2 other structs are found in the game dll. Once found then we could start fixing the struct offsets and hope it works as-is.
* Add CServerGameDLL interface to SDK (unfinished)
* Inline all CHostState members. Calling discrete member functions will result in a corrupt stack. It also alters with the VTable layout in the engine since we assign our SDK instance directly to it. Forcing everything to be inline (like the assembled counterpart within the executable itself) will ensure no virtual calls will get created and misalign the base VTable.
* Patch SQVM_CompileError to call SQVM_Error with the severity flag set to false (0 = do not terminate process, 1 is terminate process).