2885 Commits

Author SHA1 Message Date
Kawe Mazidjatari
8cb46354e6 Permanently fix aligned memalloc crash
It was still crashing as the thisptr should actually be passed into the alloc callback. Changed and the function call is now identical to engine's impl. Tested in Debug, Profile and Release, Release has also been tested with LTCG.
2023-07-10 13:49:36 +02:00
Kawe Mazidjatari
cb2850f938 Update packedstore.cpp 2023-07-10 01:38:29 +02:00
Kawe Mazidjatari
804b46998f Enable the modsystem again
The initialization crash has been fixed in commit '15244bf2', where if the 'platform/mods' folder didn't exist, an exception would be raised and the process would be aborted. Now, when that folder is absent, the mod system won't initialize.
2023-07-09 22:51:14 +02:00
Kawe Mazidjatari
15244bf27a Modsystem improvements
- Added command line parameter '-modsystem_debug' to allow debugging during init, as we initialize before the first Cbuf_Execute() call (responsible for executing command line post engine init).
- Added warning to 'CLocalize::LoadLocalizationFileLists', when a mod localization file fails to load.
- All mod instances are now added to a single vector, but their 'state' determine whether or not they are enabled. This allows for toggling them on while in-game in the future, without having to rebuild the engine mod list.
- Changed all filesystem calls to use that of the engine instead.
- Changed all container types to valve ones, to maintain compatibility with the filesystem of the engine, and perhaps other things in the future.
- Forced all loads/writes to "PLATFORM" path (this is where the 'mods' folder resides).
- Forced localization files to be only read from the mod instance's directory.
- Allocated each mod instance dynamically, and stored their pointers in the modlist vector to reduce memory overhead during the move operation to modlist, and potential growth of modlist vector (which if required, will reallocate everything, and thus move it all. This especially is expensive with nested vectors (CUtlVector anly supports being nested as a pointer)).
2023-07-09 22:49:46 +02:00
Kawe Mazidjatari
e4a3bdbb2e Add internal CLocalize functions to address getters 2023-07-09 22:24:29 +02:00
Kawe Mazidjatari
5e880ec92a Added function documentation to RSON class 2023-07-09 22:20:26 +02:00
Kawe Mazidjatari
b1147a9a42 Let the caller deal with checking for NULL 2023-07-09 22:17:42 +02:00
Kawe Mazidjatari
d5f74dc245 Add constants for script paths
Game script path and its compile list.
2023-07-09 20:12:09 +02:00
Kawe Mazidjatari
e2bf1b7a99 Add CUtlString less function
Used for CUtlMap.
2023-07-09 20:10:53 +02:00
Kawe Mazidjatari
91a8ad7cfd RSON::LoadFromFile light cleanup and bug fix
Remove 'FileExists' check, if open fails, NULL file handle is returned and we just check on that. Also, commit 'a90302f0' introduced the option to open RSON files from path ID's, but the ID was only passed in the FileExist function, the actual 'Open' call did not receive the path ID argument, and therefore, did not open from there.
2023-07-09 20:09:50 +02:00
Kawe Mazidjatari
4e8b27a1e9 Allow overriding path separator to list generated by 'RecursiveFindFilesMatchingName' 2023-07-09 20:05:47 +02:00
Kawe Mazidjatari
248efc114b Fix aligned memalloc crash when compiled with LTCG
Crash occurred as the arguments to the alloc/free callbacks would involve the 'this' pointer, and therefore, the registers would shift and misalign. The fix is to just make the functions static and call the pointers directly from the singleton exposed by the engine. Additional cleanup has been performed by adding typedefs for the function pointers.
2023-07-09 20:03:57 +02:00
Kawe Mazidjatari
a90302f09f Allow loading RSON files by path ID 2023-07-08 22:45:35 +02:00
Kawe Mazidjatari
4f806ee2ba Remove dead cvar
No longer used.
2023-07-08 18:28:27 +02:00
Kawe Mazidjatari
6891d88294 Add usage text to modsystem cvar init
Allow adding usage texts as well. Renamed 'helpString' field to 'helpText'.
2023-07-08 13:28:44 +02:00
Kawe Mazidjatari
8f480d924b Add cvars for modsystem
Add cvars to enable/disable the modsystem, also added cvars to toggle modsystem debug.
2023-07-08 13:22:30 +02:00
Kawe Mazidjatari
f6650df951 Remove 'SVC_PlaylistOverrides' patch
Only block 'CLC_SetPlaylistVarOverride' messages when cheats are disabled. The server still needs to be able to override client playlist vars (using 'SVC_PlaylistOverrides'). This isn't a problem, as on any disconnect, the client will reload its own bundled copy.
2023-07-08 03:07:19 +02:00
Kawe Mazidjatari
8d78b3a7e8 More suitable way of obtaining module handles
The SDK module handle was available in DLL init, executable module can be retrieved with PEB.
2023-07-08 03:05:10 +02:00
Kawe Mazidjatari
b4cd72034e CModule: light cleanup
Remove the option to disable dynamic init, it was broken anyways as the string was getting constructed, and therefore, dynamic memory could be allocated if string exceeds a certain size where it has to be moved from stack to heap. The only functions we were interested in, while not allocating anything have been made static instead in the last refactor round.
2023-07-08 03:01:54 +02:00
Kawe Mazidjatari
ca423c0dcf CMDLCache: light cleanup 2023-07-08 02:45:08 +02:00
Kawe Mazidjatari
2afec89c2f CCrashHandler: light cleanup 2023-07-08 02:44:33 +02:00
Kawe Mazidjatari
0110cd91c2 Fix typos 2023-07-08 02:20:33 +02:00
Kawe Mazidjatari
2565ff44ef Light VPK code optimizations
Cache string buffer ptr.
2023-07-08 02:18:18 +02:00
Amos
e9335d062f Fix playlist overrides exploit
Only allow playlist overrides when cheats are enabled on the server.
2023-07-07 09:14:39 +02:00
Kawe Mazidjatari
deb913e47b Merge recastnavigation/recastnavigation@603dc88e5d 2023-07-06 10:10:50 +02:00
Kawe Mazidjatari
2e12a581e5 Merge recastnavigation/recastnavigation@99b6c3306e 2023-07-06 10:09:36 +02:00
Kawe Mazidjatari
43aeaeb19c
Merge pull request #102 from Mauler125/vpklib_fix
Vpklib fix
2023-07-06 00:52:26 +02:00
Kawe Mazidjatari
c215fcc171 VPK utility code improvements
- Only process referenced pack files, previously, if an entry in the VPK file was build into a pack of index 128, the code would generate a list of pack files from 0 to 128.
- Added documentation to VPK structure.
2023-07-06 00:49:17 +02:00
Kawe Mazidjatari
5939e05331 Fix incorrect VPK tree during build
This commit fixes the following bugs:
- Use of STL map on CUtlString, CUtlString does not have a lesser operator, thus it always fails to check whether or not the string is already present in the map. The tree structure cannot contain duplicates per tree scope.
- Use of backward slashes in vpk file tree structure, path separators should always be a forwards slash. The code was originally designed to be forwards slash only, but some paths were adjusted to take backwards slash, as the KeyValues class treats the '/' char as a delimiter for subfields. This has therefore lead into the whole code changing to it. The code has now been changed to the point where only the KeyValues utilities take the backward slash paths.
- Trailing slash character on file path, that ended up getting written as-is in the path tree.

The VPK tree builder is now part of a separate nested class in 'VPKDir_t'.
2023-07-05 23:04:07 +02:00
Kawe Mazidjatari
77299dd3de Remove extraneous 'V_FixSlashes' call
No need to fix slashes when stripping last dir. We can always fix them up on a subsequent call to 'V_FixSlashes' if we ever need to.
2023-07-05 22:08:32 +02:00
Kawe Mazidjatari
42d12a644e Fix bug in 'V_StripLastDir' and 'CUtlString::DirName'
In some code paths of 'V_StripLastDir', the string length value was never set. The return type of this function has changed to return always return the length of the new string. An additional bug in 'CUtlString::DirName' has been fixed, where the length was only set if the trailing slashed weren't stripped.
2023-07-05 21:50:36 +02:00
Kawe Mazidjatari
819b3aeb16 Move and rename 'IsValidUTF8', 'UTF8CharLength'
Moved to strtools (tier1); utility will be renamed and decoupled into 'stl_utility' soon.
2023-07-04 23:01:13 +02:00
Kawe Mazidjatari
434b04379a Light string formatting improvements
Nothing major this time around.
2023-07-04 22:36:29 +02:00
Kawe Mazidjatari
c6e75967bf CPackedStore: light code cleanup
Light code cleanup: use references instead of pointers as much as possible, additional use of const qualifiers, and usage of provided iteration macros for CUtlVector.
2023-07-04 22:08:44 +02:00
Kawe Mazidjatari
eed83f8815 Always make sure a slash gets appended to the filepath
On the game's filesystem, the slash always appeared, when running this code on a reimplemented filesystem, no slash was found at the end of the path. This change ensures there is always a slash.
2023-07-04 21:39:31 +02:00
Kawe Mazidjatari
c330273508 Set correct return type for 'IFileSystem::CreateDirHierarchy'
Returns a 32bit int from the internal call to 'mkdir'.
2023-07-04 21:12:53 +02:00
Kawe Mazidjatari
86ac910e5e Full fix for the console shrinking problem
The lower right bound should be incremented as well.
2023-07-04 21:07:56 +02:00
Amos
6ae47b744e Fix console window shrinking with 1 unit
This commit fixes an issue where the console window would shrink with 1 unit when calling 'SetConsoleBackgroundColor'. The bottom should be incremented by 1 each time its getting called, as it appears to be decremented again in WINAPI 'SetConsoleScreenBufferInfoEx'.
2023-07-04 18:32:35 +02:00
Kawe Mazidjatari
615889948b Extern playlists/maplist vec mutex
Reduces initialization overhead.
2023-07-03 17:26:18 +02:00
Kawe Mazidjatari
89b92342d7 Add option to enable LTCG
CMake option for link-time code generation.
2023-07-03 15:40:45 +02:00
Kawe Mazidjatari
2ca1a290e2 Revert back to using verctors for detours
Enabling LTCG caused the emplacement order to be different, which is most likely due to additional optimizations for the binary search logic. Reverted to fix this bug.
2023-07-03 15:37:25 +02:00
Kawe Mazidjatari
261a9ea204 Reduced ConVar flags array size
This was supposed to be part of commit 3e4d02af.
2023-07-03 14:35:23 +02:00
Kawe Mazidjatari
3e4d02afe1 Remove non-existent ConVar flag
This flag doesn't exist in this game, and is also mapped to printableonly. The map order has also been corrected, from least significant to most significant.
2023-07-03 14:32:52 +02:00
Kawe Mazidjatari
398c0f1ddc ConVar flags tools refactor
Previously, we had 3 containers mapping ConVar flags for utilities, and none of them contained all flags. This refactor moved everything into a single container class where user can get strings by flags, or the other way around. The new class contains every flag. This also means that every flag can be used to list convars by flags using the command 'convar_findByFlags'. The 'ConVar_ParseFlagString' now also supports every flag. Code has been tested and confirmed to work as designed.
2023-07-03 13:48:13 +02:00
Kawe Mazidjatari
7762c4b2ce Light refactor of the IDetour interface
- Use std::map for mapping vtables to interface objects, previously done with a set and a vector.
- Objects are no longer inline, which significantly reduced output code size as all redundant dynamic initializers (created for each translation unit) have been pruned.
2023-07-03 13:37:41 +02:00
Kawe Mazidjatari
ed1b365c12 CUtlRBTree: Fix ambiguous overload compiler errors
Ambiguous overload caused by having 2 constructors who's parameters have types that are equal in size. Since these container size types have been explicitly converted to 64bits to align it with the code compiled in the engine, the compiler no longer knows which constructor to call. Added explicit casts to solve the problem. This error was triggered by declaring: static CUtlMap<const char*, int> s_ConVarFlags(DefLessFunc(const char*));
2023-07-03 11:02:42 +02:00
Kawe Mazidjatari
87958822b9 Fix debug compiler errors
Compiler errors when compiling in debug.
2023-07-03 10:59:29 +02:00
Kawe Mazidjatari
56da0576a6 Make static to source file
Should be made static to avoid unwanted bloat in compiled output, as each translation unit will create a new initializer/destructor. -10KiB compiled code for GameSDK.
2023-07-03 02:27:09 +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
22f68ff22a Fix utlstring bug
Fixed V_strstr overloading by swapping order of parameters.
2023-07-03 02:06:40 +02:00