59 Commits

Author SHA1 Message Date
Kawe Mazidjatari
ca423c0dcf CMDLCache: light cleanup 2023-07-08 02:45: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
9b74ac2e53 Improve threadtools
* Added and utilized auto lock/unlock mechanism.
* Rebuild CThreadFastMutex's 'Lock' and 'Unlock' methods in the SDK.
* Forced thread intrinsics and ID checkers as inline.
2023-07-02 11:38:36 +02:00
Kawe Mazidjatari
31f4e562a8 Set correct mutex type for 'm_MDLMutex'
Should be 'CRITICAL_SECTION'.
2023-06-25 14:56:30 +02:00
Kawe Mazidjatari
420a41d095 Fix CMDLCache crash on missing models
CMDLCache::FindMDL missed a check for 'DC_INVALID_HANDLE'. Adding in this check solved the issue. Other functions have been slightly cleaned up/optimized.
2023-06-25 14:56:04 +02:00
Kawe Mazidjatari
15b78f966d Fix unreachable code in CMDLCache
This code was part of an invalid string check, but is no longer necessary and was causing the unreachable code bug. Removed.
2023-06-25 02:31:50 +02:00
Kawe Mazidjatari
abe68def03 CMDLCache code improvements
Slightly mapped out the CMDLCache class, to the point the pointers to its members are no longer needed. Also fixed a bug were the studiodata pointer was dereferenced before checking if its not null, this check did exist, but was performed too late. Fully implemented the CUtlDict class for m_MDLDict. Slightly optimized the initialization of the error model handles.
2023-06-19 13:53:56 +02:00
Kawe Mazidjatari
f87fb2b2d6 Fix shutdown crash on debug builds
The destruction of these crashed due to dereferencing an invalid pointer. Not making them inline fixes the problem. This problem only occurred on debug builds, other build configurations were not affected.
2023-06-18 23:55:58 +02:00
Kawe Mazidjatari
3f8baf6f68 Allow setting compile options for specific targets
Previously, it was all controlled from the global init (applied to all projects), but some projects need different options. With these changes, you can disable the common options applied in the 'add_module' macro, and set your own if desired.
2023-06-17 00:45:27 +02:00
Kawe Mazidjatari
9f44bcc818 Treat compiler warnings as errors
Treat them as errors globally. Most of the time a warning is a bug, or problem in code that could be solved in a different (better) manner. Thirdparty code have this disabled. The warnings as errors option can be globally disabled through the CMake GUI, but this is not recommended.
2023-05-15 09:44:26 +02:00
Kawe Mazidjatari
6a86ae2606 Cleanup CMakeLists files
Light cleanup in CMakeLists files. Split protocols and improve filter names.
2023-05-14 17:36:08 +02:00
Kawe Mazidjatari
d809a9f633 Use PCH generated from VPC globally
This reduced output code size with 40KiB, improved compile times and appeared to improve runtime performance as well.
2023-05-14 02:10:17 +02:00
Kawe Mazidjatari
8dbc2024c6 CMake code improvements
Use the 'add_module' macro to add modules without creating duplicate code. This macro also takes a reuse PCH as parameter, so modules that need a precompiled header, could reuse those from different targets that compile them. This commit also restructures the group order of the generated solution files for easier code navigation.
2023-05-13 00:14:53 +02:00
Kawe Mazidjatari
f120354e96 Initial port to CMake
* All libraries have been isolated from each other, and build into separate artifacts.
* Project has been restructured to support isolating libraries.
* CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example).
* Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp).

TODO:
* Add a batch file to autogenerate all projects.
* Add support for dedicated server.
* Add support for client dll.

Bugs:
* Game crashes on the title screen after the UI script compiler has finished (root cause unknown).
* Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
2023-05-10 00:05:38 +02:00
Kawe Mazidjatari
1eef4aacb4 Improve signatures
Better signatures, and fix signature/compile errors for s1 and s2.
2023-04-23 17:05:00 +02:00
Kawe Mazidjatari
a20b66e93c CMDLCache error handling code improvements
* Use unordered_set for mdl handles, and use insertion logic in 'CMDLCache::IsKnownBadModel' to determine if it already exists or not.
* Only set 'old_gather_props' to true if its false instead of forcing it every time 'mdl/error.rmdl' is obtained (this has to be properly fixed still in the future!).
2023-02-13 23:50:37 +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
2501c37044 Globally convert all byte patterns to strings
These get reconverted to masked byte patterns at runtime. With the signature map cache system, this will only happen when building the cache.
2022-12-01 22:44:55 +01:00
Kawe Mazidjatari
62f0e2aaf0 Removed extraneous string copy constructor in CMDLCache::FindMDL
Removed extraneous copy constructor, and added const qualifier to string 'svStudio'.
2022-10-24 00:51:47 +02:00
Kawe Mazidjatari
9e9f29f4db CMDLCache: fix bug and light cleanup
* Fixed bug where we did not reset m_pErrorHDR to nullptr (m_pEmptyHDR was reset twice).
* Light code cleanup.
2022-10-15 00:07:51 +02:00
Kawe Mazidjatari
84dbc529d7 Reorder tier1 header include in mdlcache.cpp 2022-10-14 02:31:10 +02:00
Kawe Mazidjatari
2675fca219 Use Q_stricmp macro 2022-10-11 01:24:08 +02:00
Kawe Mazidjatari
729475c74c Light cleanup
Use NO_ERROR instead of NULL for error code parameter passed to Error(..).
2022-09-14 01:14:51 +02:00
Kawe Mazidjatari
3d6d6644bd Logging bug fix and error handling improvements
* Replaced the boolean 'fatal' parameter with a error code parameter, anything non-null will prompt a message (fatal) and terminate the process with given error code.
* Fixed bug where the global ostreamsink for spdlog did NOT get cleared in 'SQVM_PrintFunc' when cvar 'sq_showvmoutput' was < 3. Moved to global scope.
* Added error message for when detouring the process has failed, with the error code.
* Only call 'Plat_GetProcessUpTime()' once per log, (improves performance and fixes bug where the error message box would show a different time stamp than what is logged into the console or file).
* All TIER0 loggers only log to notify and console when the SDK engine has fully initialized and detoured all functions.
2022-09-14 00:39:38 +02:00
Kawe Mazidjatari
2010e11310 Add 'fatal' functionality to Error()
When fatal is set, the function will show a error dialogue, which will halt the process and close when the message is dismissed. Else we will end up in a crash.
2022-08-22 12:42:41 +02:00
Kawe Mazidjatari
88b3336758 Many small code improvements and optimizations
* Use c++ methods as much as possible.
* Use enum types for accessing NavMesh objects from array.
* Use size_t for for loops when testing against size types.
* Don't compute strlen twice of more on the same string.
* Don't use unnecessary c string casts if there is a method with a std::string overload.
* Don't create string objects from string pointers if we could use them directly.
* Don't initialize RCON password twice on each change, and don't set if the new password equals the old.
2022-08-11 11:07:45 +02:00
Kawe Mazidjatari
329621c6ad Move all public headers into root of 'public' 2022-08-09 17:18:07 +02:00
Kawe Mazidjatari
a399e1e190 Use 'std::string::compare' instead 2022-08-09 10:56:57 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Amos
3cd38b6003 Fix format specifiers 2022-06-08 14:02:43 +02:00
Kawe Mazidjatari
fc74a692fa Prefix global vectors with 'g_v' 2022-05-27 02:21: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
6bd1643dfb Fix SDK for S1 bin 2022-05-18 02:04:37 +02:00
Kawe Mazidjatari
32487b4230 Fix SDK for S2 bin 2022-05-18 01:00:46 +02:00
Kawe Mazidjatari
ea3caa1a0b Fix crash case on invalid pointer 2022-05-16 02:41:35 +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
ca3fcc941d Fix small mistake 2022-05-06 14:54:28 +02:00
Kawe Mazidjatari
17c5d14390 Update mdlcache.cpp 2022-05-06 13:21:42 +02:00
Kawe Mazidjatari
46a8228dad More MDLCache cleanup and error handling improvements 2022-05-06 13:19:06 +02:00
Kawe Mazidjatari
1308ae30bf Additional CMDLCache cleanup 2022-05-06 02:49:38 +02:00
Kawe Mazidjatari
215f205508 Improve CMDLCache::GetMaterialTable()
This should also be backwards compatible now
2022-05-06 02:32:25 +02:00
Kawe Mazidjatari
72289f9f33 CMDLCache::GetStudioHardware improvements
Slightly mapped out the structure more.
The function should now be compatible with earlier game dll's.
CStudioHWDataRef::SetFlags has to be rebuild as these are declared inline for earlier game dll's.
2022-05-06 00:51:49 +02:00
Kawe Mazidjatari
31c4f36aa3 CMDLCache::FindUncachedMDL cleanup 2022-05-05 20:36:13 +02:00
Kawe Mazidjatari
ec7956622b Make CMDLCache::FindMDL and CMDLCache::FindCachedMDL backwards compatible
Mapped out some of the structs
2022-05-05 17:53:05 +02:00
Kawe Mazidjatari
4d2c819544 Fix statement not getting compiled into the resulting binary 2022-05-05 14:53:48 +02:00
Kawe Mazidjatari
13ff58efcf Fix crash during dereference of 'PSRWLOCK' pointer
Studio hardware ref crash
2022-05-05 14:52:03 +02:00
Kawe Mazidjatari
24dae59cb8 Improve CMDLCache::FindMDL 2022-05-05 02:54:17 +02:00
Kawe Mazidjatari
325fee107b Some mdlcache error handling improvements 2022-05-04 12:44:01 +02:00
Kawe Mazidjatari
c3f31d694a Improved mod RPak loading between changelevel
Note: this does not work reliably still.

The only way we could make this work 100% reliable would be to fully rebuild '0x140341D40' in the SDK and load our pak files among with the pre-existing g_pakLoadApi->AsyncLoad() call in this function, as this will ensure everything will be ran synchronously.

The current approach by taking some JT fifolock wrapper will only work reliably between one level change, unsure why the second and up fail.
2022-05-04 02:25:27 +02:00
Kawe Mazidjatari
26af720f7d Fill out cull map 2022-05-03 13:17:42 +02:00