404 Commits

Author SHA1 Message Date
Kawe Mazidjatari
8cfcc00bc5 PluginSystem: add callback for chatroom receiver
Allow plugins to block chat msg's based on their text.
2024-06-01 11:49:15 +02:00
Kawe Mazidjatari
cc5eda3a7e Tier1: remove unrelevant comment
No mutex locking should take place here after careful research.
2024-06-01 11:25:57 +02:00
Kawe Mazidjatari
e02f8f36fe 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-04-05 18:31:58 +02:00
Kawe Mazidjatari
dd708169d9 Tier1: compile utlsymbol.cpp
Should also be compiled, now that its fully implemented.
2024-04-05 18:27:10 +02:00
Kawe Mazidjatari
430b2877ad Cleanup/add some comments 2024-04-05 18:27:10 +02:00
Kawe Mazidjatari
f67d8e87b1 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-04-05 18:27:09 +02:00
Kawe Mazidjatari
582ec3791e 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-04-05 18:26:04 +02:00
Kawe Mazidjatari
6cf88dc16c 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.
2024-04-05 18:17:12 +02:00
Kawe Mazidjatari
c17c11fbaa 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-04-05 18:13:33 +02:00
Kawe Mazidjatari
a89ab882af 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-04-05 18:13:32 +02:00
Kawe Mazidjatari
609d705a0c 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-04-05 18:13:32 +02:00
Kawe Mazidjatari
d6b14fa12c 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-04-05 18:13:31 +02:00
Kawe Mazidjatari
2baa80d253 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-04-05 18:07:38 +02:00
Kawe Mazidjatari
99af2877a6 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-04-05 18:02:39 +02:00
Kawe Mazidjatari
12485342ae 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-04-05 18:02:39 +02:00
Kawe Mazidjatari
d467989e7c 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-04-05 18:01:22 +02:00
Kawe Mazidjatari
373b18ddb8 Tier1: use signed size types for buffer size field 2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
172ac8f313 Tier1: optimize V_UnqualifiedFileName()
If we are going to do a strlen, then check the chars from the start
2024-04-05 17:56:53 +02:00
Kawe Mazidjatari
fe32055f7c 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-04-05 17:56:53 +02:00
Kawe Mazidjatari
e59c6c88c9 Tier1: add V_IsAllDigit()
This function checks if a string consists of only numeric characters.
2024-04-05 17:56:52 +02:00
Kawe Mazidjatari
a2ceab52da Tier1: fix type demotion warning
Promote type to signed size type.
2024-04-05 17:56:51 +02:00
Kawe Mazidjatari
2322e3a9be Tier1: remove parameter description that doesn't exist 2024-04-05 17:56:49 +02:00
Kawe Mazidjatari
fe2a95e4ec 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-04-05 17:51:19 +02:00
Kawe Mazidjatari
7cbb8a994d KeyValues: fix bug when loading from file
Read file as binary, and check if the file we're opening has a size.
2024-04-05 17:46:52 +02:00
Kawe Mazidjatari
ee82d5d8e0 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-04-05 17:42:05 +02:00
Kawe Mazidjatari
07cc5420bc Tier1: enable CUtlBuffer char conversion
Changed types to const char* instead of char*.
2024-04-05 17:31:35 +02:00
Kawe Mazidjatari
654da2c816 Tier1: fix CUtlMemoryPool::CBlob structure
Only contains the 'previous' pointer, freeing memory now works.
2024-04-05 17:31:35 +02:00
Kawe Mazidjatari
f5854cccb5 Tier1: update memstack implementation
CMemoryStack::m_unkSize is always initialized to 0x100000 in apex.
2024-04-05 17:31:35 +02:00
Kawe Mazidjatari
ae681fc118 Tier1: enable CMemoryStack and fix compile errors in debug
Define missing MemAlloc_* inlines.
2024-04-05 17:31:35 +02:00
Kawe Mazidjatari
5721ffd22b 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-04-05 17:29:12 +02:00
Kawe Mazidjatari
edc52ad669 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-04-05 17:19:32 +02:00
Kawe Mazidjatari
f609f16427 Don't compile debug code in cert builds 2024-04-05 16:41:11 +02:00
Kawe Mazidjatari
144d5f62e1 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.
2024-04-05 16:41:09 +02:00
Kawe Mazidjatari
699a4ce464 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'.
2024-04-05 16:39:22 +02:00
Kawe Mazidjatari
a8312517f4 CCommand adjustments
Moved inlines to header; made ArgC return 32bit integer instead.
2024-04-05 16:34:30 +02:00
Kawe Mazidjatari
4b7ca6b439 Use size types
Make code more portable and modern.
2023-08-29 22:05:20 +02:00
Kawe Mazidjatari
befd38bf51 Interface factory system rewrite
Removed all extraneous copies by adding the class 'InterfaceReg' which will construct a new interface, and link it to the engine's static register. The Source Engine macro 'EXPOSE_INTERFACE_FN' will help utilizing this. The game module from the plugin is not obtained through the process environment block, so the executable is no longer sensitive to names.
2023-08-22 01:11:49 +02:00
Kawe Mazidjatari
71b0781715 Utilize 'DevMsg()' for uncertain builds only
Only uncertain builds will contain DevMsg()/DevWarning() prints. For retail, Msg() and Warning() should be used instead.
2023-08-21 19:12:29 +02:00
Kawe Mazidjatari
8c87ad219f Add more bitbuf inlines
Added:
- Tell()
- GetNumBitsLeft()
- GetNumBytesLeft()
2023-08-21 16:14:54 +02:00
Kawe Mazidjatari
0066b82da7 Light cleanup 2023-08-21 11:35:24 +02:00
Kawe Mazidjatari
c344dde672 Add bitbuf getters 2023-08-21 11:28:55 +02:00
Kawe Mazidjatari
26c10dfd11 Restructure concommandbase classes
Move all classes deriving from ConCommandBase to a single file, and split out CCommand, CCvar, CCvarUtilities etc to their own files. This makes it possible to use CCommand and stuff in external tools without linker errors/warnings.
2023-08-04 14:32:06 +02:00
Kawe Mazidjatari
21f64bc572 Adjust logging contexts
Adjust the context properly, some were wrong (e.g. 'ENGINE' in 'COMMON' code).
2023-07-22 21:14:04 +02:00
Kawe Mazidjatari
00f349c745 Use ICVar iterator for console partial suggest
Added public interface to ICVarIteratorInternal, this class also deals with the deletion of the iterator. This fixes the problem of cvars not showing up that have been registered after 'CModAppSystemGroup::Create()' has been called. Currently, no cvar is registered after it. This will/could change when the plugin system is utilized.

Additional changes:
- Cvar 'con_suggestion_flags_realtime' has been removed, as we no longer keep an early copy anymore; real time flags are always shows from now on.
 - Fixed a bug in 'CConsole::FindFromPartial()' where we would return in the loop when 'm_vSuggest.size() >= con_suggestion_limit->GetInt()', instead of breaking out, which skips the element sorting process.
2023-07-22 14:51:15 +02:00
Kawe Mazidjatari
15c293126e Use fast tolower/toupper defines instead 2023-07-22 14:40:47 +02:00
Kawe Mazidjatari
e8e600f553 Add missing convar flags
Added:
- FCVAR_ACCESSIBLE_FROM_THREADS [1<<25]
- FCVAR_STUDIO_SYSTEM [1<<26]
- FCVAR_SERVER_FRAME_THREAD [1<<27]
- FCVAR_PLATFORM_SYSTEM [1<<31]

This commit also removes the 'FCVAR_MATERIAL_THREAD_MASK' from the ConVarFlags class (which is a helper struct for displaying flags on the developer console), as this is a mask and would therefore be marked as such in case a single bit in the mask matches, and all these bits are already added to the list.
2023-07-20 21:02:27 +02:00
Kawe Mazidjatari
dbb18e586d Add 'V_ComparePath'
Add function to compare paths for equality, while ignoring case and path separators.
2023-07-10 19:16:12 +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