46 Commits

Author SHA1 Message Date
Kawe Mazidjatari
7440e2d5da Tier1: add function for checking if SDK ConVar's are registered 2024-10-06 11:49:15 +02:00
Kawe Mazidjatari
56f8a69114 Tier1: fix flag testing bug in ConVar::Create
The archive + playerprofile flags check was done on the uninitialized member variable 'm_nFlags', but it should've been performed on the function's input parameter 'flags' as m_nFlags is only initialized past this check in BaseClass::Create (its part of ConCommandBase). This caused statically initialized ConVar's flagged 'FCVAR_ARCHIVE | FCVAR_ARCHIVE_PLAYERPROFILE' to go undetected, and dynamically initialized ones (e.g. through mod settings) to have random memory and intermittently fail this check. The latter is how this bug was found and ultimately fixed in this patch.
2024-09-23 16:23:34 +02:00
Kawe Mazidjatari
3fc1bcd2b7 Tier1: properly fix V_SplitString2
Patch in commit 057a2c801a40c2f280193da9963b009adb9f75f6 was done incorrectly, causing intermittent string truncation as subtracting pFirstSeparator from pCurPos will leave with a window in the buffer of exactly that split string, but the previous patch subtracted another char from it whilst adding one in AllocString just for it to be nulled.
2024-09-23 16:19:53 +02:00
Kawe Mazidjatari
8c9d873fbe Tier1: use CUtlStringList for ConVar flag string parser
The previous implementation contained a bug causing it to add other flags intermittently. Utilize CUtlStringList instead as it was designed for this purpose.
2024-09-23 15:46:25 +02:00
Kawe Mazidjatari
057a2c801a Tier1: exclude delimiter from split string
A string "test3,test4" using the delimiter ',' would be split into "test3," and "test4", but should be "test3" and "test4". The delimiter should not be included. This patch fixes the issue.
2024-09-23 15:44:44 +02:00
Kawe Mazidjatari
3cd61a499d Tier1: constify ConVar_ParseFlagString 2024-09-19 00:12:27 +02:00
Kawe Mazidjatari
d95d071afd Tier1: properly implement ConVar change callbacks
Change callbacks actually take a structure of 2 pointers, one being for the callback itself, and the other being 'userdata' which typically is used to sync the ConVar with VGUI slider elements. This issue was noticed after implementing the ADS scalars and attempting to hook them up to VGUI, only to find out it would crash due to this lacking detail. All change callback prototypes had to be adjusted.
2024-08-05 00:45:30 +02:00
Kawe Mazidjatari
1e667c8f30 Engine: use CThreadMutex for installed maps global
Use the type used by the engine instead of STD.
2024-08-03 11:03:39 +02:00
Kawe Mazidjatari
51e18d5462 Tier1: fix misleading comment 2024-07-31 22:19:16 +02:00
Kawe Mazidjatari
7eb6017c16 Core: update copyright notice headers
Fix corrupted copyright symbol.
2024-07-29 21:09:55 +02:00
Kawe Mazidjatari
b5616999ab PluginSystem: add callback for chatroom receiver
Allow plugins to block chat msg's based on their text.
2024-04-20 23:27:00 +02:00
Kawe Mazidjatari
1fb9cf2625 Tier1: remove unrelevant comment
No mutex locking should take place here after careful research.
2024-04-10 14:09:35 +02:00
Kawe Mazidjatari
ab7e02ef36 Tier2: create modular WebSocket system
This code was actually part of the LiveAPI system, but there were many opportunities to make this particular code modular, so it has been decoupled and moved to Tier2. The LiveAPI system will soon use this class instead. The implementation has also been improved by adding dedicated routines for updating socket parameters, disconnecting/reconnecting and destroying sockets.

This commit also removes legacy workaround code in UtlVector which was used for before we had early enough access to the game's memalloc singleton. This code was no longer used.

This commit also implements the CUtlStringList class, which is now used for the new websocket class to split each socket connection up by a comma delimiter.
2024-03-30 02:53:12 +01:00
Kawe Mazidjatari
cd75f47007 Tier1: compile utlsymbol.cpp
Should also be compiled, now that its fully implemented.
2024-03-16 01:31:14 +01:00
Kawe Mazidjatari
d302be7b4d Cleanup/add some comments 2024-03-16 01:30:44 +01:00
Kawe Mazidjatari
35ba0cabf0 Tier1: use template index type for memory allocation
For CUtl* classes: use the index type rather than just ssize_t, this will throw compile warnings for code that constructs a CUtl* object allocating more memory than the index type allows (e.g. allocating UINT16_MAX while the index type has been set to UINT8_MAX).
2024-03-14 18:25:40 +01:00
Kawe Mazidjatari
e55ea0718c Tier1: fully implement CUtlSymbol(*)
The class has been modified to match the implementation of the engine, the only modifications done were changing size types, so they compile to the correct size based on the platform (in case of the GameSDK project, this will be 64 bits).
2024-03-14 02:37:39 +01:00
Kawe Mazidjatari
e967cb374b Engine: render ImGui in main thread and fix many threading bugs
ImGui drawing code now takes place in the main thread, a snapshot of the render data is created in CMaterialSystem::SwapBuffers(), and is being rendered in the render thread right before SpinPresent().

The reason why this was necessary, is because ConVar::GetString() isn't thread safe if its not marked FCVAR_MATERIAL_SYSTEM_THREAD or FCVAR_ACCESSIBLE_FROM_THREADS, and we used it for the console suggestions window, which iterates over every ConVar, accessible from threads or not.

This is overall also a better code architecture.

This change also forced changes in the ImGui server browser window, which contained a bunch of threading bugs too.

Engine changes:
- g_pCVar is no longer exported, as this wasn't necessary in the end.
- g_ThreadMainThreadID and g_ThreadServerFrameThreadID are now exported from the game executable, as these are required as soon as the DLL is loaded.
2024-02-25 20:12:56 +01:00
Kawe Mazidjatari
0ea4988416 Tier1: fix crashes on some commands & fix assert
The supplemental callback always seems to be linked to a nullsub, probably a debug only feature. Linked all registered concommands to this as well.
2024-02-24 13:57:23 +01:00
Kawe Mazidjatari
e34f3ad3c5 Tier1: fix ConCommand::Dispatch()
Fix incorrect function prototype and add additional logic implemented in the engine. The code was crashing as the first parameter is the command target, but appears unused, the second parameter was actually the parameter that contained a pointer to the CCommand object which we needed.
2024-02-24 11:43:16 +01:00
Kawe Mazidjatari
6828901815 Tier1: static construction of ConVar objects during link time
Fully implemented ConVar class so we could statically construct all SDK convars, this avoids a level of indirection, and allows for creating ConVar's everywhere in the project.

This patch also removed the settings tab of the ImGui server browser, as it has threading issues, while it technically never caused a crash yet, it has been removed as there was no point keeping it vs the work required to make it thread save (it only managed 2 convars which are perfectly manageable through cfg's or the in-game console).

Also temporarily disabled the creation of ConVar's in the mod system due to a memory leak, we would allocate and register a convar based on details parsed out of a mod file definition, but never unregister and free it.
2024-02-24 02:15:09 +01:00
Kawe Mazidjatari
3d36c87b08 Statically construct all ConCommand
Properly implement the ConCommandBase and ConCommand classes so we could statically construct all ConCommand objects in the global scope of each translation unit, this way we don't need to put them in a global file and deal with preprocessor directives to compile then in/out for certain projects.
2024-02-23 00:12:06 +01:00
Kawe Mazidjatari
6afb5fe593 Engine: improve CClient::Authenticate performance
- Removed 2 std::string copy constructions
- Removed 32 sprintf calls per token auth request.
- Fixed a bug where we format the NucleusID as s64 instead of u64.
- Added additional hardening for when token/sessionId stitching fails, this will now always reject the connection.
- Improved the macro to make sure we always free the JWT claims if it has been allocated.
2024-02-22 00:59:00 +01:00
Kawe Mazidjatari
51ba4c9dff Tier1: fully implement bitbuf classes
All routines are now fully implemented. This was delayed on purpose as some bit buffer functions have changed due to the use of 64bit integers for sizes, and also the coord types. The porting of this has to be done carefully; all
reimplemented functions have been changed to feature 64bit integers (where necessary) for syze types, and all values in coordsize.h have been tweaked to reflect the changes in the R5 engine 1:1, allowing us to properly implement the coord bit buffer functions as well.
2024-02-21 01:10:14 +01:00
Kawe Mazidjatari
e72f13ee0f Tier1: optimize V_GetFileExtension()
If we are going to do a strlen to do a reverse check, then just check from the start and avoid another loop.
2024-02-19 21:24:01 +01:00
Kawe Mazidjatari
21a383a20e Tier1: light cleanup on low level types
CCommand: use 'V_isdigit()' since that is faster, we don't need it to be locale aware.
CMemoryStack: move 'highest' var to string format directly to avoid compile warnings (unused loval variables) on more recent visual studio compilers when compiling the DLL in cert mode.
2024-02-19 21:24:01 +01:00
Kawe Mazidjatari
535ffe5562 Tier1: use signed size types for buffer size field 2024-02-10 01:35:24 +01:00
Kawe Mazidjatari
9b800a19f7 Tier1: optimize V_UnqualifiedFileName()
If we are going to do a strlen, then check the chars from the start
2024-02-07 14:30:37 +01:00
Kawe Mazidjatari
1a9e393d1b Tier1: properly implement UtlString methods
Determine proper stack buf size for ssize_t += operator. If its 64bits then the buf should be doubled to accommodate for the maximum number of digits in a 64bit decimal number. Also properly determine stack buf size of double += operator. For FormatV, instead of a fixed stack buffer, perform a dry run to determine required buflen, reserve num char bytes of memory and write into it again on the next call.
2024-02-06 14:48:11 +01:00
Kawe Mazidjatari
0dd19ab2dd Tier1: add V_IsAllDigit()
This function checks if a string consists of only numeric characters.
2024-02-04 12:52:46 +01:00
Kawe Mazidjatari
063d8d7cad Tier1: fix type demotion warning
Promote type to signed size type.
2024-02-03 23:53:22 +01:00
Kawe Mazidjatari
ea1befbb61 Tier1: remove parameter description that doesn't exist 2024-01-29 23:00:18 +01:00
Kawe Mazidjatari
c9a9b01bf2 RTech: major pak system overhaul and rebuild
* split rtech_game and rtech_utils cpp files into multiple files
* rebuilt several large pak load routines for debugging and custom implementations
* moved rson code to rtech_game
* reworked and improved engine and sdk pak precache system
* reversed more of the jobthreads system
2024-01-21 20:23:25 +01:00
Kawe Mazidjatari
4d1d737b48 KeyValues: fix bug when loading from file
Read file as binary, and check if the file we're opening has a size.
2024-01-12 03:08:31 +01:00
Kawe Mazidjatari
cd82e22ea3 Tier1: move KeyValues class to Tier1
The KeyValues class belongs here. Also reimplemented most loading methods for KeyValues, and adjusted the VPK building code to account for it. Pointers to the engine's implementation of KeyValues have been moved to a separate header ('keyvalues_iface.h'), as this allows external tools code to utilize the standalone KeyValues class implementation. Playlist utilities are completely separated from the KeyValues header; these have nothing to do with KeyValues other than manipulating a global KeyValues object for the playlists, and thus have been named as such and moved to rtech/playlists.
2024-01-12 00:52:07 +01:00
Kawe Mazidjatari
057ccd3f86 Tier1: enable CUtlBuffer char conversion
Changed types to const char* instead of char*.
2024-01-12 00:17:53 +01:00
Kawe Mazidjatari
05f12ab6cc Tier1: fix CUtlMemoryPool::CBlob structure
Only contains the 'previous' pointer, freeing memory now works.
2024-01-12 00:16:36 +01:00
Kawe Mazidjatari
8d4ca8a59f Tier1: update memstack implementation
CMemoryStack::m_unkSize is always initialized to 0x100000 in apex.
2024-01-09 00:58:31 +01:00
Kawe Mazidjatari
6bdc8f2426 Tier1: enable CMemoryStack and fix compile errors in debug
Define missing MemAlloc_* inlines.
2024-01-08 22:59:35 +01:00
Kawe Mazidjatari
92639b6793 Tier1: reimplement CUtlMemoryPool
Class is slightly modified; it uses 2 CBlob pointers instead of a single CBlob member. CUtlMemoryPool::m_pHeadOfFreeList is also replaced with the new CUtlMemoryPool::m_pPrev pointer. Code has been modified to accommodate this change and aligns with the assembly code of r5.
2024-01-08 22:48:58 +01:00
Kawe Mazidjatari
e825a1e7a8 IDetour: remove extraneous pointer assignments
Originally, we store the search results in a CMemory instance which we then assign to the actual function pointer. CMemory is just a pointer class; we can assign the results directly to the actual function pointer. This commit reduces a lot of code verbosity, and also reduced roughly 2KiB worth of static pointers in the resulting executable. This commit also officially deprecates the support for any GameDLL's below S3 (Season 3), since it makes more sense to port the assets from earlier/later games back to the version this SDK supports.
2024-01-02 15:21:36 +01:00
Kawe Mazidjatari
d76f3a712b Don't compile debug code in cert builds 2023-12-20 21:12:39 +01:00
Kawe Mazidjatari
e541814482 IDetour: code refactor
Utilize the new IDetour::DetourSetup() code, IDetour::Attach and IDetour::Detach have been removed in favor of this (significantly reduces chance of user error). Since the template check happens in the idetour header, it is much more aggressive on type mismatches, such as a difference in parameter types, between the function and detour, will now raise a compile time error. As a result, some type mismatches have been fixed in this commit as well.
2023-11-26 13:21:20 +01:00
Kawe Mazidjatari
7648d19fa9 Implement CCommandBuffer
Code is based on Valve's implementation, with the following changes:
- Usage of 64bit signed size types.
- Usage of const where possible.
- Removal of field 'CCommandBuffer::m_nLastUsedArgSSize'.

Code is tested and compiles on all supported compilers.
2023-11-25 12:00:47 +01:00
Kawe Mazidjatari
e5d8f46c61 CCommand adjustments
Moved inlines to header; made ArgC return 32bit integer instead.
2023-11-25 11:27:47 +01:00
Kawe Mazidjatari
fd3e227a86 Align folder structure with p4 2023-09-19 22:13:22 +02:00