76 Commits

Author SHA1 Message Date
Kawe Mazidjatari
1a551739b4 Core: fix incorrect typedef for f64 (double-precision floating point)
f64 was unused but will be used.
2024-09-07 00:26:48 +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
d298ad0c22 Client: initial rebuild of the curve look function
This function didn't decompile properly, so a bunch of manual assembly work had to be used to reconstruct the truncated bits. The code does work correct for the most part. The call to the subroutine 'sub_1405AD760' has been commented as the parameter appears incorrect; passes in the address of a bool but indexes 4 bytes outside the size of a bool. Most likely incorrect decompile/disasm. Currently being investigated.
2024-08-04 14:12:15 +02:00
Kawe Mazidjatari
7eb6017c16 Core: update copyright notice headers
Fix corrupted copyright symbol.
2024-07-29 21:09:55 +02:00
Kawe Mazidjatari
6c6a9b0140 Core: move all base integral types to dedicated header
There was always a problem dealing with core integral types accros various projects, since we typically only use IDA's pseudo definitions for rebuilding decompiled functions. It however did define almost all the integral types we use throughout the SDK. These types have been commented out and a new header has been made that defines everything we need (and we can add more in the future if this deems necessary). This new header is included with tier0/basetypes.h, so all projects have access to it and the tier0 headers will work out of the box without defining anything new.
2024-07-06 17:10:21 +02:00
Kawe Mazidjatari
2896dc0d37 Engine: fix code bug when running "uiscript_reset" during init or load screens
Make sure this command cannot be executed before the UI VM is initialized or during load screens, doing so will hard crash the engine.
2024-07-01 01:30:01 +02:00
Kawe Mazidjatari
b5f166085d Engine: mark cvar 'fps_max' as FCVAR_ARCHIVE
The new scripts now show a dedicated FPS limit option in the video settings, there is also a demand for having this cvar to persist its value. Marked as FCVAR_ARCHIVE so it gets saved to user profile settings.
2024-05-31 14:03:04 +02:00
Kawe Mazidjatari
d1c4d6f1d6 Engine: fix CLC voice data netmessage structures
The field 'void* unk0' is actually 'CNetMessage::m_pMessageHandler'. Since this type was taken from the IDB (in which this field is actually part of the netmessage implementation itself, since SVC messages use a different vtable and its the only way to have it show correctly in the output), an extra 8 bytes shift occurred rendering the system defective. Removed the field and the structure now matches that of the game executable.
2024-05-31 13:43:47 +02:00
Kawe Mazidjatari
20d3a66b8e Engine: add functionality to run game without the platform system
Unbind the game from the platform system, which is useful when developing for or debugging the game. This was supposed to make it into the SDK back in 2021, but wasn't due to the ability to spoof usernames. This is no longer possible on servers requiring authentication as the player's name is actually checked along with the Nucleus ID.
2024-05-17 11:12:57 +02:00
Kawe Mazidjatari
a61c475379 Engine: fix numerous exploitable bugs in voice protocol
- Fixed stack smash in CClient:ProcessVoiceData (oob read on bitbuf).
- Fixed stack smash in CClient:ProcessDurangoVoiceData (oob read on bitbuf).
- Fixed ability to bypass team check on Durango voice packets if forced as reliable from the sender (client).
- Incorporated the following missing checks in the durango version of voice broadcasting:
  - Enforce chat between multiple teams using cvar 'sv_alltalk'.
  - Ability to also disable Durango voice data with cvar 'sv_voiceenable'.
  - Ability to echo voice with Durango voice data using cvar 'sv_voiceEcho'.
2024-05-07 14:05:11 +02:00
Kawe Mazidjatari
3e8cda22b3 Common: unmark "set" command from FCVAR_DEVELOPMENTONLY from dedicated
"set" is already marked as FCVAR_CHEATS, and typically used when sv_cheats 1; remove FCVAR_DEVELOPMENTONLY from dedi builds as well.
2024-05-05 11:31:03 +02:00
Kawe Mazidjatari
b8bde9ad0e Engine: use dedicated convar to determine rcon server socket bind
Decoupled from net_usesocketforloopback since we actually don't want this to be tied with that of the game. Now it by default does not bind to the loopback socket unlike the game.
2024-04-14 16:11:58 +02:00
Kawe Mazidjatari
6294bb539d Engine: add cvar 'sv_lagpushticks' to SDK
Will be used for reworking some parts of the lag compensation system in the future.
2024-04-12 20:37:13 +02:00
Kawe Mazidjatari
2ca3baa77d UserCmd: limit command backlog to prevent exploitation
Implement UserCmd command backlog limiting (the new convar 'sv_maxUserCmdProcessTicks' dictates how many ticks can be processed per second). Defaulted to 10, which is (default tick interval (0.05) * default cvar val (10) = 0.5ms window), which is equal to the default of cvar 'sv_maxunlag'.

Before this patch, you could stuff several seconds worth of usercmd's in one second and achieve speed hacking.
2024-04-12 01:51:11 +02:00
Kawe Mazidjatari
ec14bf70de Engine: move rcon_password entirely to server
The client doesn't need this convar, client only needs cl_rcon_address.
2024-04-10 15:15:27 +02:00
Kawe Mazidjatari
f8dd1fe88c Engine: implement encryption for RCON protocol
RCON lacked encryption, added AES-CTR encryption on RCON frames. Slightly adjusted protocol to take this into account (sending nonces, encrypted data itself, etc).
2024-04-10 14:08:52 +02:00
Kawe Mazidjatari
3c5a1a1203 Engine: flip order of checks
Check for cvar or state first before checking the current thread. The cvar/state check is slightly cheaper.
2024-04-01 01:06:32 +02:00
Kawe Mazidjatari
276289966c Engine: reimplement netmsg debuggers
Reimplement logic for cvars: "net_showmsg", "net_blockmsg", "net_showpeaks".
2024-03-31 16:13:04 +02:00
Kawe Mazidjatari
63237361e9 NetworkSystem: fix numerous issues
This patch splits host logic from CServerListManager. CServerListManager is actually meant for the client to manage the server list to which the client could connect to. The hosting logic has been moved to the new CServerHostManager class.

Previously, we stored all the hosting details in CServerListManager, with connection criteria in CPylon, this data has been moved over to CServerHostManager as well.

Previously, we also needed a mutex to access the server host data, function HostState_KeepAlive() has been refactored to the point this mutex is no longer necessary as the only threaded process is the actual request, the rest is being applied in the main thread. We also now only construct a NetGameServer_t struct if we actually plan to host.

Access to CPylon::m_Language is now also protected by a mutex, as the change callback of cvar 'language' and the threaded method 'CPylon::QueryServer()' are competing for access.
2024-03-10 01:57:04 +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
79f8b46d62 RTech: major cleanup of pak globals and improvement
Add missing types to fully mapped out PakGlobals_s struct, which is a 13MiB+ structure! This covers the vast majority of the pakfile system which is why we had to change a bunch of stuff for this patch. This patch also comes with:

- Reversed 'JobFifoLock_s' structure
- Reversed 'PakTracker_s' structure
- Reversed 'PakAssetTracker_s' structure

Many globals have been dropped as they were covered by the large PakGlobals_s singleton.

The pak decoder logic has been changed up as well, we now use a decode mode enumerant which will make it easier to add in more decoders for the pak files in the future.
2024-02-22 02:09:28 +01:00
Kawe Mazidjatari
77c8e3a994 Engine: remove deprecated cvar 'cl_move_use_dt'
No longer used, the vftable call made when this was false is stubbed and thus will cause movement to bug when unset; removed.
2024-02-21 01:17:48 +01:00
Kawe Mazidjatari
4ae9852291 Engine: cleanup data block sender/receiver and add types
* Move member vars to correct place, to match it with the engine.
* Added out-of-band network message ID's for the R5 engine.

Also implemented 'ServerDataBlockSender::SendDataBlock()' and 'ClientDataBlockReceiver::AcknowledgeTransmission()'. NOTE that these are currently not tested, and also not in use! The code uses the version stored in the vftable which is what the engine itself provides. These have been implemented for reference only. If they need to be used, they need to be thoroughly tested first!
2024-02-21 01:16:10 +01:00
Kawe Mazidjatari
155c221a70 Engine: rebuild CClientState::ProcessCreateStringTable()
Rebuild CClientState::ProcessCreateStringTable() and add notes for multiple 'potential' exploit vectors that are currently in place. Also add wrappers for compressing/decompressing net packets.
2024-02-19 21:24:00 +01:00
Kawe Mazidjatari
802e1f42eb Engine: partial rebuild for data block sender/receiver
This patch partially rebuilds the data block sender/receiver. The receiver leaks memory if the sender sends a bogus LZ4 packet, it would allocate memory to copy the encoded data into, from which it would decode it to the scratch buffer, but it would never deallocate this temporary buffer is the LZ4 decoder failed. This has been fixed. The second reason to rebuild these was to look into potential compression optimization. The data block rebuild now also features the latest LZ4 codec.
2024-02-19 21:24:00 +01:00
Kawe Mazidjatari
b3cd76aa70 Engine: fix bug in networking code caused by incorrect constants
Mixed MAX_BACKUP_COMMANDS with MAX_NEW_COMMANDS, added proper (confirmed) defines. Also fixed MAX_BACKUP_COMMANDS_PROCESS, which was 60 but was supposed to be 64, so we were 4 backup commands short in CPlayer::ProcessUsercmds().
2024-02-19 21:22:24 +01:00
Kawe Mazidjatari
8b338ce682 Add signed size type defines 2024-02-10 01:18:55 +01:00
Kawe Mazidjatari
b29be00d82 Engine: revert server tick msg rebuild to old behavior
Only update statistics, this code was mainly added for testing, but testing revealed no additional performance or smoothness improvements, even during >6 hour sessions. The clock drift already gets corrected each frame from Host_RunFrame(). Only update statistics to update CPU and frame times on the client's debug panels if enabled.
2024-02-06 14:42:36 +01:00
Kawe Mazidjatari
c12c8fb7fe NVIDIA: disable gfx_nvnUseMarkersToOptimize by default
Causes rubber banding on some systems.
2024-02-04 14:42:39 +01:00
Kawe Mazidjatari
52edcc6d84 RTech: fix bug when trying to print fourcc as string
The printf specifier does not allow limiting buffer reads. Made the FourCCToString more performant by using a fixed size stack array and creating the fourcc into that which we now use to properly print out the asset magic.
2024-01-29 23:00:18 +01:00
Kawe Mazidjatari
5ddf69c764 RTech: minor cleanup and renaming 2024-01-29 23:00:18 +01:00
Kawe Mazidjatari
a2d869d572 RTech: add buffered decompress function, cleanup and bug fixes
The pak_decompress callback has been fully moved to a dedicated buffered pak decoder function, also added descriptive error to the buffered pak encode function. Fixed a bug in the streamed pak decoder where the next required streamed buffer size would always be below actually required on any subsequent patch rpaks that are getting loaded. Also fixed assert in Pak_ZStreamDecode, as the inbuf position can equal total streamed size, but shall never exceed it!
2024-01-29 23:00:18 +01:00
Kawe Mazidjatari
26ce3c50c2 RTech: cleanup ZStd pak decoder and fix bugs
* Pak_InitDecoder() now takes the output buf and mask as parameters.
* Pak_InitDecoder() checks if provided masks are a power of 2 (required).
* Pak_ComputeRingBufferFrame() now uses the bit mask instead of modulo to determine # bytes used.
* Fixed a bug where PakDecoder_t::bufferSizeNeeded could be bigger than the file stream, causing a deadlock.
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
9b9562c8d9 RTech: properly implement ring buffer stream decode for Zstd decoder
The new decoder can now decode patched and custom rpaks files, all issues so far have been fixed. The code still needs some testing and bench marking to make sure
2024-01-29 23:00:17 +01:00
Kawe Mazidjatari
31e9042eee RTech: add simple pak encoder command
Encodes a pak file with ZSTD.
2024-01-29 23:00:16 +01:00
Kawe Mazidjatari
1410ecd79c MaterialSystem: rename CMaterialGlue member vars 2024-01-29 23:00:15 +01:00
Kawe Mazidjatari
8911bfa81a GameUI: cleanup and fix race condition
* Use CThreadFastMutex instead
* Rename ISurface to IDebugSurface to prevent a potential name collision with VGUI's ISurface iface if we ever add it
* Fix race condition when setting CPylon::m_HostIP from materialsystem thread, this has been dispatched to the main thread
* Marked 'pylon_matchmaking_hostname' FCVAR_MATERIAL_SYSTEM_THREAD as we use it in the server browser panel.
2024-01-21 23:06:26 +01:00
Kawe Mazidjatari
f6e6e7c30b Engine: fix out of bound access
Even though this is handles by the class, it really shouldn't happen.
2024-01-21 21:53:48 +01:00
Kawe Mazidjatari
1361bfb172 Make singletons use static memory
Avoid heap memory allocation and a level of indirection. This allows the compiler to optimize the program even more. No logic has been changed in this patch.
2024-01-21 21:29:23 +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
f48bdbfa82 Engine: fix compiler warning caused by empty control statement
Remove trailing ';', else this branch wouldn't even be compiled in.
2024-01-14 02:03:27 +01:00
Kawe Mazidjatari
f49fbffa9a Sync ReVPK fixes to packedstore concommand
* Check if workspace directory exists.
* Check if VPK directory tree file was successfully parsed.
2024-01-14 01:51:17 +01:00
Kawe Mazidjatari
dd4fdb6cbd VokLib: rename pack/unpack methods
More correct names.
2024-01-13 14:09:37 +01:00
Kawe Mazidjatari
0dd630e13a ReVPK: add option for num helper threads and compress levels
Allow the user to set the # amount of helper threads and the compress level of the VPK's.
2024-01-13 14:02:46 +01:00
Kawe Mazidjatari
3fec8793e9 RTech: fix bug in pakfile decompress callback
* Fix decompress size check.
* Fix incorrect decompress buffer allocation size.
2024-01-12 11:07:16 +01:00
Kawe Mazidjatari
a92847fa7a VpkLib: rename CPackedStore to CPackedStoreBuilder
Avoid confusion with the game's CPackedStore class.
2024-01-12 11:02:54 +01:00
Kawe Mazidjatari
106670d940 VpkLib: cleanup packed store class
Make the utility methods statics within the implementation so it could be used by other structs/classes of the VPK builder as well, these utility functions weren't useful outside the class. This also allowed for the removal of the singleton which had no purpose whatsoever.
2024-01-12 11:01:04 +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
f428e09654 Patch: make const 2024-01-02 17:30:39 +01:00