2965 Commits

Author SHA1 Message Date
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
Kawe Mazidjatari
789ecbc234 Fully disable memory expansion
The game's memalloc does not support memory expansion, the base expansion function couldn't be shadowed properly without linker errors. However we want to make sure no instances of it get compiled into the module, ever. Therefore, the duplicate symbol is kept in memoverride (_expand_base), and the only usage has been removed from LZHAM's 'lzham_mem'. If a linkage is attempted to anything utilizing '_expand', a linker error will be emitted and no image will be generated.
2023-07-03 00:25:15 +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
4a5abcf577
Merge pull request #101 from Mauler125/untyped_reduction
Globally reduce the use of auto for function pointer declarations
2023-07-02 23:16:29 +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
5032644b7f Remove duplicate plugin interface version string literal 2023-07-02 22:23:20 +02:00
Kawe Mazidjatari
a0419eec11 Add method for obtaining PEB
Inline method for obtaining process environment block.
2023-07-02 22:02:31 +02:00
Kawe Mazidjatari
892fd19c4a Fix incorrect CPlayer member offset
Member offset for 'm_bGamePaused' did not align with the executable, moving the member 'm_hPlayerViewEntity' before the first bool in this row results in correct code generation (also aligns properly in the disassembly of the game's code).
2023-07-02 21:54:21 +02:00
Kawe Mazidjatari
32d28d4285 *::ProcessUserCmds rebuild
Rebuild of the 'CServerGameClients::ProcessUserCmds' and 'CPlayer::ProcessUserCmds' methods. The rebuild is pretty much identical to the original implementation, but with additional checks for the number of commands, and total commands in 'CServerGameClients::ProcessUserCmds'. In the future, additional clamps and checks between CPlayer and the recv'd UserCMD should be incorporated in these functions.
2023-07-02 21:49:35 +02:00
Kawe Mazidjatari
64453b0661 Add CUserCmd constructor to SDK
Internal constructor from the engine.
2023-07-02 21:31:19 +02:00
Kawe Mazidjatari
7d456b8b61 Add 'player_userCmdsQueueWarning' cvar to SDK
Will be used for the 'CPlayer::ProcessUserCmds' rebuild.
2023-07-02 21:28:49 +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
bfd093d22b Fix rare crash in 'ImGui_ImplWin32_WndProcHandler'
Don't run the 'ImGui_ImplWin32_WndProcHandler' if we are shutting down. During rare occasions when closing the game while hovering over the game window, 'ImGui_ImplWin32_WndProcHandler' is getting called while parts or all of the ImGui systems have been shut down, leading to a crash. The fix is to check if the engine is restarting or shutting down before running the ImGui window procedure logic.
2023-07-02 11:28:07 +02:00
Kawe Mazidjatari
be93929b26 Map out CKeyValuesSystem class
Mapped out members of the CKeyValuesSystem class. Singleton accessor has also been declared inline in this commit.
2023-07-02 02:51:12 +02:00
Kawe Mazidjatari
8ea2eac0fc Move launcher/loader consts
Move to shared PCH as these are low level defines.
2023-07-02 02:46:58 +02:00
Kawe Mazidjatari
0207c69b36 Fix SDK launcher compatibility with SDK loader
Since the SDK loader (loader.dll) is taking care of loading the DLL with the process, the SDK launcher no longer needs to inject it. Replaced call 'DetourCreateProcessWithDllsA' with 'CreateProcessA', and performed additional cleanup
2023-07-01 23:27:29 +02:00
Kawe Mazidjatari
c1a0276951 Fix unresolved external symbol errors for loader.dll
Moved CModule statics to a separate translation unit, preventing the linker to link unused stuff into the loader module, thus allowing us to drop the linkage of unused libraries.
2023-07-01 22:29:34 +02:00
Kawe Mazidjatari
a82b4c950c Compute MHz instead 2023-07-01 21:45:32 +02:00
Kawe Mazidjatari
71148b691c Mark the build id yellow 2023-07-01 21:27:37 +02:00
Kawe Mazidjatari
75a394a85f
Merge pull request #100 from Mauler125/cmdline_export
Cmdline export
2023-07-01 11:29:34 +02:00
Kawe Mazidjatari
d7245a04e4 Test recursive shutdown on global init bool
Test on this instead, it has to be unset anyways.
2023-07-01 11:20:44 +02:00