50 Commits

Author SHA1 Message Date
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
PixieCore
096ecdd333 IClientEntityList and CUtlDict.
* IClientEntityList is the full virtual function table.
* CUtlDict "implementation" is temporary.
2022-05-01 23:03:20 +02:00
Kawe Mazidjatari
a479b4ac78 See description
Fixed rare crash in CMDLCache when buffer itteration returns invalid pointer (not null!) for handle.

Made all variables and functions used by BuildPropStaticFrustumCullMap searched dynamically (these should also work on s0, s1 and s2, they are compared but at the moment untested).

TODO: Fix deref crash properly (see bsplib.cpp l291).
2022-05-01 05:38:51 +02:00
Kawe Mazidjatari
97fb3fd8d4 Also lock the upgrade error behind already known bad model handles
Reduce console verbosity
2022-04-30 05:06:59 +02:00
Kawe Mazidjatari
a496254b93 Add mutex for CMDLCache methods
Als fall back to old GatherProps when at least one model is replaced with mdl/error.rmdl as the new GatherProps function does not support this yet.
2022-04-30 03:30:16 +02:00
Kawe Mazidjatari
1bf7b96641 Only print out missing models once
Don't print duplicated
2022-04-29 22:46:37 +02:00
Kawe Mazidjatari
7441bf156b Return proper studio hardware for mdl/error.rmdl
Now mdl/error.rmdl draws properly
2022-04-29 22:11:35 +02:00
Kawe Mazidjatari
d569d58378 Made missing model error handling more robust 2022-04-29 21:05:26 +02:00
Kawe Mazidjatari
827641b9b1 Early working implementation of the 'mdl/error.rmdl' fallback
Only works for prop_static (for the time being)
Only works for the S3 game_dll.

In order to get this to work: you must set 'old_gather_props' to nun-null and (for certain maps) perform the patch to prevent the frustum culling code to deref a bad pointer (see command 'opcodes test').
2022-04-29 18:25:54 +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