63 Commits

Author SHA1 Message Date
Kawe Mazidjatari
5fc38d5c96 Fix bug where map names aren't captured correctly
In rare occasions (depending on the installation path), the regex might fail to extract the level name from the VPK file name. If the path has a similar pattern, or certain characters, it will capture the wrong string. This fix has been tested, and confirmed to fix the bug.
2023-07-15 21:36:14 +02:00
Kawe Mazidjatari
83d7f0b9f4 Light code cleanup
- Use game's filesystem in 'Mod_GetAllInstalledMaps'.
- Reorder parameters of 'AddFilesToList', and add option to override path separator.
2023-07-15 16:24:01 +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
d0bdbcd2b0 Mod_ProcessPakQueue cleanup
* Reset 'old_gather_props' cvar, so that we can re-evaluate on the next level load, and use the new one instead if no errors were found that time around.
* Removed extraneous operators.
2023-06-26 16:50:25 +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
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
b8d97d0d1c Cleanup 'Mod_GetAllInstalledMaps'
Light cleanup
2023-04-03 18:38:36 +02:00
Kawe Mazidjatari
b0d2665550 /W4: Fix compiler compatibility
Clang doesn't support function-style casts with types containing a space.
2023-04-02 17:34:42 +02:00
Kawe Mazidjatari
ae431c6ac2 /W4: Fix unreferenced symbol warnings
Fix verbose unreferenced symbol warnings.
2023-04-02 17:02:04 +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
29616f4810 Rename 'g_vAllMaps' to 'g_InstalledMaps' 2023-03-31 00:35:01 +02:00
Kawe Mazidjatari
a5440616e2 Cleanup for dedicated server as result from recent patch
Removed all checks for 'ui.rpak' and 'ui_mp.rpak'. None of these are useful for dedicated server. 'bUnconnected' has been changed to true (should had been in the first place). Promoted some integers to 64bit types to suppress compiler warnings, output code remained the same.
2023-02-26 22:22:45 +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
Kawe Mazidjatari
0d9a66a6cf Mod_GetAllInstalledMaps: light cleanup 2023-01-21 15:39:18 +01:00
Kawe Mazidjatari
69396d5f42 Fix edge case bug where client doesn't load pak files when connected to a remote server
We used the hoststate levelname string, but this only applies to the host. Keep the levelname that was passed to 'Mod_LoadPakForMap()', and set the init bool after we ran 'Mod_GetLevelSettings()'.
2022-11-25 02:34:34 +01:00
Kawe Mazidjatari
734e24b355 Fix edge case bug where level hasn't changed while it did
Fix bug where  'Mod_LevelHasChanged(...)' returns false even though it had changed. The static var was set in a different function which worked with the old system. The static var is now set within 'Mod_GetLevelSettings()', if 'Mod_LevelHasChanged()' returns true.
2022-11-24 15:47:14 +01:00
Kawe Mazidjatari
1f10bb1643 Check ptr for 's_pLevelSetKV' before deleting
Only delete if the pointer is valid to prevent segmentation fault.
2022-11-24 13:41:18 +01:00
Kawe Mazidjatari
27d00215ac Use memalloc pool pointer directly 2022-11-24 12:10:11 +01:00
Kawe Mazidjatari
c24e8a9f21 Rename 'MOD_' to 'Mod_'
The engine names these functions as 'Mod_'.
2022-11-24 11:58:32 +01:00
Kawe Mazidjatari
a7c33d4df3 Use KeyValues system for level settings file instead
Previously we used Json, however the rest of the game features KeyValues. I changed the system to feature KeyValues instead, to maintain consistency. Also improved the logic behind loading/parsing so we don't reparse the same level settings file if the pointer is still valid and we are on the same level.
2022-11-24 11:10:46 +01:00
Kawe Mazidjatari
a82674bbc8 Add 'KeyValues::RecursiveSaveToFile' to the SDK
Relies on the engine's implementation of 'KeyValues::RecursiveSaveToFile'. The IFileSystem methods have been fixed up with the CUtlBuffer class rebuild in which we could call these to write a KV memory structure as a file to the disk.
2022-11-22 09:04:28 +01:00
Kawe Mazidjatari
7a065ccd12 Parse/reparse map list on playlists file initialization.
Map list will now initialize with the playlist. User could also reparse the map list by reparsing the playlists file.
2022-11-06 14:21:27 +01:00
Kawe Mazidjatari
703caebe6b Unload SDK pak files before Engine pak files
This is required, as we use assets within the engine pak files. Unloading the engine pak files first will result in a seg fault during shutdown.
2022-10-07 22:22:32 +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
d946f9d1a1 Fixed bug when reading text files using internal file system
Small oversight causing defect, but found during extensive tests and code inspection.
2022-09-01 01:05:15 +02:00
Kawe Mazidjatari
ab8fc757c8 Fix concurrent access to 'g_vAllPlaylists' and 'g_vAllMaps' 2022-08-29 11:55:58 +02:00
Kawe Mazidjatari
48e708e498 CPylon: Exception handling for all 'json::parse' calls 2022-08-28 17:12:58 +02:00
Kawe Mazidjatari
260f862a69 Load level settings file using game's filesystem
This allows for loading the file from all search directories and the VPK's
2022-08-23 16:45:42 +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
b14f239971 Don't add 'common_sdk.rpak' and 'ui_mp.rpak' to the loaded handle vector
This prevents those 2 rpaks from being unloaded, they should never be auto-unloaded.
2022-08-18 12:41:35 +02:00
Kawe Mazidjatari
efd16fbc72 Implement 'ThreadInMainThread()' (originally tier0 export) 2022-08-18 12:00:01 +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
3c3da82154 Additional code improvements
* Removed some unused signatures.
* Named 2 CBaseFileSystem methods, and applied them to 'MOD_ProcessPakQueue()'.
* Renamed 'qword_1671061C8' to 'g_pMTVFTaskItem'.
* Renamed 'g_pMapVPKCache' to 'g_szMTVFItemName'.
* Only set first byte to 0 in 'g_szMTVFItemName' (actual size is 0x100, not 0x40).
2022-08-16 21:42:57 +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
e92b5d1300 General cleanup
Use c++ methods, remove unnecessary casts, unnecessary use of auto, etc..
2022-08-09 15:19:12 +02:00
Kawe Mazidjatari
0b4eb06dd2 Use compare method instead of strcmp on std::string 2022-08-09 14:01:29 +02:00
Kawe Mazidjatari
61e1180878 Rename type
Type is small enough where auto isn't needed
2022-06-14 22:33:01 +02:00
Kawe Mazidjatari
7c0c541405 FileExist cleanup
Use fs::path constructor for all strings.
Renamed CPakFile::AsyncLoad to CPakFile::LoadAsync.
Renamed CPakFile::Load to CPakFile::LoadPak.
2022-06-12 12:40:26 +02:00
Kawe Mazidjatari
aa29c3df18 Fix server browser bug
Fixed bug where map list would contain multiple same entries when server vpk's are installed among the client ones.
2022-06-06 16:46:09 +02:00
Kawe Mazidjatari
52b8755219 FileSystem improvements
* Added proper pointer to g_pFileSystem_Stdio.
* Renamed existing one to g_pFullFileSystem (correct name).
* Obtain g_pFileSystem from the same constructor as g_pFileSystem_Stdio.
2022-05-27 22:38:49 +02:00
Kawe Mazidjatari
fc74a692fa Prefix global vectors with 'g_v' 2022-05-27 02:21:54 +02:00
Kawe Mazidjatari
47d2e4c915 See description
* Added new function 'GetAvailablePlaylists' to all VM's.
* Moved function 'GetAvailableMaps' from UI VM to all VM's.
* Improved logic behind 'GetAvailableMaps'.
* Server browser and SQVM now rely on 'MOD_GetAllInstalledMaps'. This new function populates the global vector 'g_vAllMaps' with all installed maps.
* Improved 'KeyValues' structure to use union for shared members.
2022-05-27 02:08:51 +02:00
Kawe Mazidjatari
2f4f4ae838 Merge branch 'gui_launcher' into indev 2022-05-26 22:05:32 +02:00
Kawe Mazidjatari
7833eb9b1d Load ui_sdk.rpak upon init
Load ui_sdk.rpak after ui_mp.rpak.
Moved the loading of common_sdk.rpak to after common_sp.rpak/common_mp.rpak.
This should allow overriding existing assets.
2022-05-26 02:58:46 +02:00
Kawe Mazidjatari
c406147261 Load common_sdk.rpak upon init
The pak gets loaded before common_sp.rpak/common_mp.rpak gets loaded (this could be changed to after if needed).
2022-05-26 02:26:48 +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
32487b4230 Fix SDK for S2 bin 2022-05-18 01:00:46 +02:00
Kawe Mazidjatari
325b3d15dc Cleanup 2022-05-17 01:31:49 +02:00