58 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
75b5148e65 Light changes for RTech::PakProcessGuidRelationsForAsset
* Use Warning() for deadlock detection debug log.
* Use const qualifiers where possible.
* Cache rtech_debug->GetBool().
* Renamed 'RPakAssetEntry' to 'RPakAssetEntry_t'.
* Renamed 'RPakDescriptor' to 'RPakDescriptor_t'.
2022-11-01 00:44:09 +01:00
Marvin D
6e42f18ed9 PakProcessGuidRelationsForAsset rebuilt
Some unknown fields are still present.
Structs and some naming credits to @r-ex
2022-10-30 20:17:50 +01:00
Kawe Mazidjatari
47beb282f2 RTech cleanup and improvements
* Combined members of TextureHeader_t and RTechTextureInfo_t.
* Renamed 's_pRTechBytesPerPixel' to 's_pBytesPerPixel' and declared const.
* Renamed 'dxgiToRPakFormat' to 's_DxgiToTxtrTable' and declared const.
* Renamed 'rpakToDxgiFormat' to 's_TxtrToDxgiTable' and declared const.
* Moved 'g_DxgiToTxtrTable' and 'g_TxtrToDxgiTable' to 'texture.g.h'.
* Moved 's_pBytesPerPixel' to 'texture.g.h'.
* Fixed defect where we used the [] operator on a std::map that should be const (s_TxtrToDxgiTable), replaced with the const version of std::map::at.
2022-10-13 21:59:06 +02:00
Marvin D
514a407e4c RPakHeader_t/RPakLoadedInfo_t additions 2022-09-18 13:55:44 +02:00
Kawe Mazidjatari
34a06147d7 Fix spelling errors
Overall spelling improvements and cleanup..
2022-09-09 19:47:31 +02:00
Kawe Mazidjatari
23e85cae37 Use type alias for all pak handle variables
* Use type alias 'RPakHandle_t'.
* Improved debug/exception messages.
2022-08-29 17:00:50 +02:00
Kawe Mazidjatari
5bc798fe97 Merge 'Sys_LoadAssetHelper' with 'RTech::OpenFile' and rehook.
Removed clashing hook and merged logic into RTech::OpenFile, and re-enabled hook.
2022-08-18 12:34:33 +02:00
Kawe Mazidjatari
5548a74d59 Major cleanup (see description)
* Fix all compiler error for GameSDK on S0 and S1.
* Remove some unused patterns and globals (launch performance gains of 100ms).
* Remove most duplicate patterns.
* Relocate globals from engine to a more appropriate location.
* Renamed some unknown vars to a more appropriate name (most of these where obtained a while back, but as we reversed more parts of the engine, some of these vars become known).
* Renamed some vars to fit the naming convention used in the SDK.
* Fixed pattern debug logging using the wrong pointer, thus displaying the wrong address.
2022-08-18 02:15:23 +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
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Marvin D
587b92659e dedicated compile fix for RTech changes. 2022-08-06 00:34:26 +02:00
PixieCore
1cd0ae5c87 General code cleanup, Rebuild and hooked RTech::OpenFile
* RTech std namespace removal
* RTech::OpenFile Rebuild.
* FileHandleTracker_t fully reversed, grabbing m_FileHandles from memory now.
* RTech::FindFreeSlotInFiles needs more research.
*
2022-08-06 00:16:11 +02:00
rexx
2e3b4205c0 remove streamoverlay hook 2022-07-21 17:05:19 +01:00
rexx
cb4e422724 reimplement stream overlay drawing 2022-07-20 22:50:55 +01:00
PixieCore
f57da25341 RTech changes.
* Added RPakAssetBinding_t.
* Added RPakUnknownStruct_t
* PatternScan the global RPakUnknownStruct_t.
* Renamed Members of CMaterialGlue
* RTechTextureInfo_t now has another unknown member named.
2022-07-20 11:27:42 +02:00
PixieCore
afc312d86d Removed s_pBitsPerPixelWord and implemented it properly. 2022-07-10 13:11:48 +02:00
PixieCore
0eec5c6361 Updated RTech.
* Further cleanup of RTech::CreateDXTexture.
* New field in RTechTextureInfo_t which counts the total streamed mips.
* Added a few comments.
2022-07-09 10:41:02 +02:00
PixieCore
c4977a39aa Add field to RTechTextureInfo_t. 2022-07-08 23:38:33 +02:00
PixieCore
d51ceddf38 RTech::CreateDXTexture cleanup.
* Separated RPakTextureHeader_t and made an RTech version.
* Fixed up RTechTextureInfo_t struct.
* Still needs testing with 4K textures.
2022-07-08 23:18:15 +02:00
PixieCore
ff7ae51718 RTech::CreateDXTexture works now.
* Will clean up the function next.
2022-07-08 20:31:27 +02:00
PixieCore
1b2c0cecd0 CShaderGlue changes and RTech implementation.
* Added RTech::LoadShaderSet for the asset load routine
* Grabbing CShaderGlue::SetupShader and CShaderGlue::m_pVTable dynamically now
* Everything verified for every season, cross-compatible!
2022-07-04 22:52:10 +02:00
PixieCore
8bf08af7b9 Start of RTech::CreateDXTexture rebuild.
* Currently crashes due to stack corruption.
2022-06-19 18:07:43 +02:00
Kawe Mazidjatari
e110aa5832 RTech decompress cleanup
Cast to proper types
2022-06-17 18:42:13 +02:00
PixieCore
5655b8c759 Implementation for rpak swap. Read description.
* RTech::GetPakLoadedInfo returns a reference now instead of a copy. Make sure to check the pointer is valid from now on if dealing with the returned pak entry.
* RTech::GetPakLoadedInfo now has a overloaded function that takes string as argument for searching an pak entry.
* new ConCommand pak_swap which has Pak_Swap_f as callback.
* Pak_Swap_f performs pak unload and then load again.
* pak_requestunload can now be used with pak name
2022-05-19 00:47:16 +02:00
Kawe Mazidjatari
2ef4f087c5 RPakLoadedInfo_t backwards compatibility
Padded struct with 48 bytes (extra FF padding in memory) to match the size with earlier builds (<S3)
2022-05-17 01:33:45 +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
215f205508 Improve CMDLCache::GetMaterialTable()
This should also be backwards compatible now
2022-05-06 02:32:25 +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
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
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
PixieCore
56a71aba56 A few RTech changes.
* Renamed pak_asyncload to pak_requestload
* Added new ConCommand to unload rpaks. It's called pak_requestunload.
* When CHostState requests an rpak unload, it will now print the name of it.
* Turned a few static addresses onto patternscans.
2022-03-28 18:47:11 +02:00