145 Commits

Author SHA1 Message Date
Kawe Mazidjatari
d6fd782601 Add new RPak types and rename existing
Rename to enforce consistency.
2024-04-05 15:57:33 +02:00
Kawe Mazidjatari
3fd898bf30 Fix crash during RPak load
* Added missing parameter to 'PakLoadFuncs_s::WaitAsync'.
* Fix offset to 'g_pakLoadApi'.
2023-09-09 20:57:00 +02:00
Kawe Mazidjatari
9cfc2b4b6a Use actual pakLoadApi pointer
Actual pakLoadApi pointer used internally.
2023-09-08 23:52:00 +02:00
Kawe Mazidjatari
71b0781715 Utilize 'DevMsg()' for uncertain builds only
Only uncertain builds will contain DevMsg()/DevWarning() prints. For retail, Msg() and Warning() should be used instead.
2023-08-21 19:12:29 +02:00
Kawe Mazidjatari
2118ee6b48 Move RPak types to public header 2023-07-17 02:40:06 +02:00
Kawe Mazidjatari
f6f3c7f9a2 More code cleanup
- Set character set to multi-byte (this is because the game is also build with it).
- Utility function 'FileExists' now takes a raw string pointer, this avoids having to construct a fs::path each time its getting called (which is quite a lot!).
- Performed overall cleanup to code containing logic to override load paths. Mostly removing unnecessary copy constructions.
2023-07-03 02:14:39 +02:00
Kawe Mazidjatari
46390ba875 Additional reduction of untyped variables
These were not caught by the regex due to typos, or additional symbols that were not taken into account when making the regex.
2023-07-03 00:02: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
ef69611435 Replace memalloc calls throughout entire SDK
Global 'direct' usage of 'MemAllocSingleton()' has been jettisoned. Where possible, smart pointers were used instead. During the refactor, the following bugs were addressed and fixed:
- The virtual destructor of 'CCVarIteratorInternal' was NOT called on destruction.
- Class function 'KeyValues::MakeCopy' did NOT calculate the buffer size of the wide string correctly, the original calculation was 'len+1*sizeof(wchar_t)', but should've been '(len+1)*sizeof(wchar_t)'.

Some other code changes include:
- Tier0 include 'memstd.h' has been moved above all thirdparty includes, to make sure the memalloc functions get shadowed with ours in third party libraries as well.
- RPak file paths string literals are now defines.
- 'DestroyOverlay' has been refactored to match the assembly of the game.
2023-06-26 22:34:24 +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
8acfad5556 Fix aligned memalloc singleton
Properly fix the aligned memalloc singleton in the SDK; the implementation now uses a callback based approach for calling the allocator and deallocator.
2023-05-15 20:47:17 +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
8d38de1ce0 Move client only code from rtech libraries
Moved, and renamed to 'CreateTextureResource'. Reason for move was that the rtech libraries is used by server and client, and using this on dedicated requires linking directx libraries, as it has to be hooked (even when not used). Moved to client only code to avoid having to hook it. Material system is no longer linked to the dedicated server module, as nothing from it was getting used.
2023-05-13 18:03:48 +02:00
Kawe Mazidjatari
d7ef449e15 Split RTech libraries 2023-05-13 10:34:23 +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
d825fb9f58 Adjust type for 'g_pMallocPool' and rename
Adjusted type to 'CAlignedMemAlloc' and renamed it to 'g_pAlignedMemAlloc'. This global allocates  memory aligned.
2023-05-06 17:48:43 +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
8a052f819d Improve error string 2023-04-08 20:15:16 +02:00
Kawe Mazidjatari
1d04f837f8 Fix many high level compiler warnings
* Put initializer values inside brackets.
* Put logical AND conditions within parentheses.
* Put assignments within conditional statements within parentheses.
* Mark unused variables as such to suppress compiler warnings.
* Fix vftable shadow warnings caused by ConVar::CreateInternal (does not implement, only interface. Renamed to yield desired behavior).
* Fix 'never' initialized class members for 'CCVarIteratorInternal'.
* Return values in interface vftables that cannot be pure virtual.
2023-04-08 19:00:28 +02:00
Kawe Mazidjatari
a4a2f34c10 /W4: Fix signed/unsigned mismatch
This commit fixes warnings and bugs caused by signed/unsigned mismatch.
2023-04-02 12:09:43 +02:00
Kawe Mazidjatari
b648378574 Turn 'TxtrAssetToDxgiFormat' into constant table
Turned into an actual constant.
2023-04-02 01:40:28 +02:00
Kawe Mazidjatari
cd40081a20 Rename RPak header magic constant to 'RPAK_MAGIC'
A more descriptive name.
2023-04-02 01:26:38 +02:00
Kawe Mazidjatari
ef0e64b639 Revert back to old RTech::Decompress implementation and monolithic lookup table
Reverted as the new implementation wouldn't work properly on clang-cl (crashed on several pak files), and only worked on msvc when suppressing compiler warnings. The original implementation (raw copy/paste assembly) works perfectly on both compiler with no warning suppressors.
2023-04-02 01:22:11 +02:00
Kawe Mazidjatari
2be8c69d6d Fix typo causing potential bug
This should be an unsigned 8-bit integer, as values within the array exceed the maximum value of a signed 8-bit integer.
2023-04-01 12:27:36 +02:00
Kawe Mazidjatari
7a521d1d27 Turn static map into jump table
Slightly increase performance and reduce overhead during texture creation.
2023-04-01 11:27:53 +02:00
Kawe Mazidjatari
5762f767b5 Make RTech code compatible with older compilers
Make it compatible with older versions of the Visual Studio 2017 compiler.
2023-03-20 00:05:04 +01:00
Kawe Mazidjatari
1cb95fe860 CPakFile::UnloadPak: Light cleanup 2023-03-16 20:24:34 +01:00
Kawe Mazidjatari
cae5037324 Initial fix for older game builds
SDK compiles and works for the S1 game now, still needs to be debugged further.
2023-03-01 00:09:38 +01:00
Kawe Mazidjatari
23f88c9542 Remove useless checks as result from recent cleanup
No longer need to catch these programmatically, see commit 353aee5c and a5440616.
2023-02-26 22:23:50 +01:00
Kawe Mazidjatari
e12de45eaa Light RTech code cleanup
Use dedicated function for returning pak status as string instead of std::map. reduced compiled code size by 10kb.
2023-02-26 19:43:02 +01:00
Kawe Mazidjatari
c0a38a6c26 Additional renames 2023-01-31 16:21:51 +01:00
Kawe Mazidjatari
c17913bfe9 Light cleanup of pak load api var names
* Rename some pakload api vars.
* Removed 2 duplicate pointers from (g_ClientState_Shifted and g_pakLoadJobID).
* Removed unnecessary signonstate check in 'Mod_ProcessPakQueue' for dedicated.
2023-01-31 16:09:30 +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
Marvin D
6177c1ebe7 Fix deadlock detection when processing relations 2022-12-22 16:48:47 +01:00
Marvin D
a8ecdd44a6 RPakAssetBinding_t new member names. 2022-12-20 22:56:55 +01:00
Marvin D
db9c1f5ae6 Fix S0/S1 RTech_CreateDXTexture 2022-12-20 01:04:45 +01:00
Marvin D
9994491551 RTech_RegisterAsset 2022-12-20 01:03:59 +01:00
Kawe Mazidjatari
1021a95068 Merge branch 'SignatureMap' into indev 2022-12-04 14:21:14 +01:00
Marvin D
c3158b6937 Slight improvements.
CModule::GetSectionByName adjustments.
RTech::CreateDXTexture improvements.
2022-12-04 00:01:31 +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
9e7495e407 Added new logger types (AudioSystem & VideoSystem)
These loggers are to be used for hooking and logging Miles Audio and Bink Video systems.
2022-11-27 10:19:23 +01:00
Kawe Mazidjatari
c13fe64abc Use correct types for RPak virtual pointers 2022-11-25 23:16:13 +01:00
Kawe Mazidjatari
adbd1816df Rename new RPak struct fields
Correct field names for RPakDescriptor_t, RPakMemPageInfo_t and RPakVirtualSegment_t.
2022-11-25 23:12:23 +01:00
Kawe Mazidjatari
8373cc70ca Rename/improve RPak structure fields
* Renamed for consistency.
* Added new structures for known fields.
2022-11-25 23:01:59 +01:00
Kawe Mazidjatari
ad690379ab Log RPak build date/time properly during decompress
Log the date stored in the RPak header in full detail.
2022-11-25 00:57:32 +01:00
Kawe Mazidjatari
57f17a3aad Use engine's FileSystem API for decompressing and patching RPak files 2022-11-25 00:11:17 +01:00
Kawe Mazidjatari
4ba88963ff Fix bugs and many compiler warnings
* Promoted size types in CUtlBuffer to int64.
* Fixed bug where CUtlBuffer::GetPtr returns a 64bit pointer that was promoted from a 32bit integral type.
* Use int64/size_t for anything strlen, pointer subtraction, etc..
* Removed invalid structure alignment declarations.
2022-11-24 15:41:52 +01:00
Kawe Mazidjatari
27d00215ac Use memalloc pool pointer directly 2022-11-24 12:10:11 +01:00
Kawe Mazidjatari
a92c72afc6 Improve string variable readability in CPakFile::LoadAsync 2022-11-10 01:22:00 +01:00