119 Commits

Author SHA1 Message Date
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
ebf7bb5e0b Fix engine bug regarding forcing application borders
In Respawn's engine, the '-forceborder' command line parameter does the same thing as '-noborder'. '-forceborder' should remove the flags (nand) while '-noborder' should append the borderless flag. This code is an attempt to mitigate the problem. There was not enough bytes to assemble the nand operation for this code path without involving code caves or shifting.
2022-12-06 00:48:11 +01:00
Kawe Mazidjatari
2501c37044 Globally convert all byte patterns to strings
These get reconverted to masked byte patterns at runtime. With the signature map cache system, this will only happen when building the cache.
2022-12-01 22:44:55 +01:00
Kawe Mazidjatari
41dbf77715 Add type alias uintp and intp
Commonly used types across Valve Source SDK.
2022-11-29 20:36:45 +01:00
rexx
b15b876eed Revert "add more miles debug hooks"
This reverts commit feeaf5c54536a6ff7dae385314f9036ff45c4cd2.
2022-11-27 20:26:58 +00:00
rexx
feeaf5c545 add more miles debug hooks 2022-11-27 20:14:41 +00:00
Kawe Mazidjatari
03dc4eada5 Move Miles and Bink hooks/implementations to shared 'codecs' folder 2022-11-27 17:27:35 +01:00
Kawe Mazidjatari
4b1c5dd5a3 RCON system light refactor
* Used 'htonl'/'ntohl' for constructing the length prefix.
* Used static socket/address members instead of pointers.
* Used const qualifier where possible.
* Changed length prefix field type to 'u_long'.
* Removed extraneous include.
* Properly escaped percentage characters on the RCON game client for the ImGui console.
2022-11-14 21:00:41 +01:00
Kawe Mazidjatari
f341919aad Properly initialize VPK and cache system for the dedicated server
server loads "vpk/server_mp_lobby.bsp" instead of "vpk/client_mp_common.bsp" and "vpk/client_frontend.bsp". Also removed the old hack we used to patch string constants to format VPK string paths as we have a proper implementation now using CEngineAPI::SetStartupInfo.
2022-11-07 23:11:12 +01:00
Kawe Mazidjatari
4bd164a535 NavMesh hot swap system improvements
* Check if server is active in command callback before attempting to hot swap.
* Hook 'v_Detour_LevelInit', and log NavMeshes that failed to load.
* Split free/destroy logic into separate function.
* Created constants for NavMesh and AI Network paths/extensions.
* Added performance profiler for hot swap logic in command callback.
* Renamed "navmesh_reload" to "navmesh_hotswap".
* "navmesh_hotswap" is now development only.
2022-11-03 17:12:22 +01:00
Kawe Mazidjatari
7804241376 CClient: add rate limit logic for 'ProcessStringCmd'
Client's can run string commands on the server with no rate limit. This means when you run 50k+ commands that are unknown, or spam 30k 'status' commands, you will be able to hang the server for 800/1200ms (15k/30kms if script printing to console is enabled!). Although the netchan processing budget system will kick you, the damage has already been done at this point. This change effectively breaks the ability to DOS the server from the client using networked string commands.
In easier words; binding 'status' to your mousewheel will get you kicked from the server, without hitching the server.
2022-09-20 22:48:55 +02:00
Kawe Mazidjatari
34a06147d7 Fix spelling errors
Overall spelling improvements and cleanup..
2022-09-09 19:47:31 +02:00
Kawe Mazidjatari
dff3f2f53e Remove deprecated patch 2022-08-28 00:13:53 +02:00
Marvin D
806cfbc8c4 Update opcodes.cpp 2022-08-22 14:45:34 +02:00
Marvin D
3a8647b6f4 Load .starpak from /Win32/ support
* S3< not tested.
2022-08-22 14:43:06 +02:00
Marvin D
eeec292238 Don't need to run CBuf_Execute. Game does it itself.
* How did I forget to remember that for almost a year..
* Connect and disconnect commands also fixed now.
2022-08-19 22:25:26 +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
bb6a05cb81 More mapped out network interface classes
More interface classes directly usable with the engine.
2022-08-15 14:44:54 +02:00
Kawe Mazidjatari
e6f45aaa9b CBitBuf improvements
* Use proper types reflecting assembly from the engine in 'CBitRead::Seek' (some values are 64bit, either changed by Respawn or the compiler used by Respawn).
* Confirmed changes made to NETMSG_TYPE_BITS (now 511 instead of 255) and NETMSG_LENGTH_BITS (now 12 which is 511 max instead of 255).
* Confirmed msg HUD types.
* Enforce NET_MIN_MESSAGE on 'SVC_UserMessage::Process'.
* Remove unnecessary padding and add proper symbols where padding was actually used.
2022-08-15 02:59:41 +02:00
Kawe Mazidjatari
61dbda67f7 Address reported issues
Addressed:
* 'Expression: vector subscript out of range' (we only ever ensured capacity upon construction).
* Compiler error as AssertMsg1 is unimplemented, used Assert instead.
2022-08-14 00:48:29 +02:00
Kawe Mazidjatari
329621c6ad Move all public headers into root of 'public' 2022-08-09 17:18:07 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Kawe Mazidjatari
cc3d7d3afc Update comment regarding server VPK's 2022-08-08 17:51:35 +02:00
Kawe Mazidjatari
9775fc4bba RCON system overhaul
* Implemented robust length-prefix framing logic for non-blocking sockets (previously used character sequences to determine length, but you cannot use character sequences on protocol buffers as its binary data. This logic should fix all problems regarding some commands not getting networked properly to the server and stuff not getting printed on the client).
* Increased buffer size to std::vector::max_size when netconsole is authenticated (MAX_NETCONSOLE_INPUT_LEN still remains enforced on accepted but not authenticated connections to prevent attackers from crashing the server).
* Process max 1024 bytes each recv buffer iteration.
* Additional optimizations and cleanup.
2022-08-02 23:58:43 +02:00
Kawe Mazidjatari
58e0d96e22 Disable CAI_NetworkManager::ShouldRebuild 'restart\n' patch.
AIN rebuilding and saving works, the patch is no longer needed.
2022-07-26 03:13:10 +02:00
PixieCore
178aeeb3fd Use GetVirtualMethodTable for VTable consts. 2022-07-21 20:36:47 +02:00
Kawe Mazidjatari
b3ed5d4052 Fix client.dll compile errors
Stripped more server only stuff from client.dll.
2022-07-21 15:13:48 +02:00
Kawe Mazidjatari
3d0162038a Improved navmesh structs
New member: header->offMeshEnds (this is used in Detour_LevelInit which sets fields to -1 starting at the pointer to end of offMeshCons array).

Currently set to 0 so the paths in opcodes.cpp could be disabled.
2022-07-18 21:38:07 +02:00
Kawe Mazidjatari
e14934d244 Fix persistence state for s0/s1 builds
CVEngineServer::IsPersistenceAvailable() is inline with Persistence_SetXP in S0 and S1. the virtual function never gets fired.
The approach for S0/S1 will call CVEngineServer::IsPersistenceAvailable() when Persistence_SetXP() is ran (the first function to ever use pClient->m_nPersistenceState after the SendServerInfo query).
2022-07-08 23:42:28 +02:00
Amos
fb0795c789 Fix dedicated compile 2022-07-04 01:08:36 +02:00
PixieCore
540b282998 Remove redundant function. 2022-07-03 13:05:14 +02:00
Kawe Mazidjatari
fd64556462 Find pattern instead of using offsets 2022-06-30 20:20:32 +02:00
PixieCore
7eb6952df0 Use const in memaddr.cpp where its supposed to be. 2022-06-29 16:32:40 +02:00
Kawe Mazidjatari
5f64a14a87 Add 'ssize_t' to skdefs.h (size error type) 2022-06-24 12:12:59 +02:00
PixieCore
1da841d4dd Remove troll function from HLClient. 2022-06-23 21:08:56 +02:00
Kawe Mazidjatari
965b4f4367 Remove VecNetMessages and VecNetDataFragments
Improved and used CUtlVector class instead.
2022-06-23 19:52:58 +02:00
Kawe Mazidjatari
1b6f40d941 Fix for SVC_UserMessage
Removed padding that was causing the structure to misalign with the game's one.
Enabled 'SVC_UserMessage::Process()' hook (function works properly after the structure alignment).
2022-06-23 18:20:17 +02:00
Kawe Mazidjatari
9fd39d4e21 CModule class optimizations
Module segments are now part of the class to eliminate unnecessary re-inits and copies.
2022-06-13 23:34:06 +02:00
Kawe Mazidjatari
cdf257ad32 Dedicated VPK switch improvements
Check for 'vpk\\server_mp_common.bsp.pak000_000.vpk' presence instead of 'vpk\\client_frontend.bsp.pak000_000.vpk' absence before switching to server VPK's.
2022-06-12 12:42:07 +02:00
Kawe Mazidjatari
b3dd9c8ad6 Revert declaration 2022-06-04 01:30:18 +02:00
Kawe Mazidjatari
655d1c65b2 Proper VPK repacking
Initial proper implementation pending cleanup.

The new system builds a manifest file when a VPK is unpacked. The manifest files contains data such as the entry flags and texture flags. It also contains a field determining whether the file should be compressed or not.

When a user repacks a pack, the system attempts to load this manifest file and does a lookup to the object to retrieve the flags (most of these flags are unknown, but they are used by the engine and are necessary for stuff like cubemaps and texture files to work correctly. Cubemaps won't work with proper flags, and textures (decals, particle system components, etc..) will look washed out without them.

I think some also determine whether a file within the VPK should be cached or not, so simply marking everything as 0x101 will probably end up in more CPU time and higher filesystem cache usage (depot/ is only 0x1, I don't think anything there is getting cached ever without the 0x100 flag).

User could also repack a VPK while excluding anything that is not in the manifest file. So you could unpack all VPK's into a single directory (each VPK has its own manifest file tied to its level name), and rebuild all the VPK's with only the files that where originally in them.

fs_pack_vpk command usage: <locale> <context> <level_name> <manifest_only>

locale determines the pak language (default english), context determines whether is a server/client vpk, level_name determines the BSP name of the pak, manifest_only determines whether the pack system should only include files within the manifest (leaving this arg out will build all files into the vpk).

The VPK workspace path is determined with ConVar 'fs_packedstore_workspace'.
2022-06-04 01:08:23 +02:00
Kawe Mazidjatari
b3583cf005 Declare more common types in the global scope
This should had gone before the prior commit
2022-05-30 01:50:53 +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
f74371327e Reduce CPU time on dedicated server
Don't run 'CInputSystem::RunFrameIME()' each frame
2022-05-21 13:11:10 +02:00
Kawe Mazidjatari
4680f8cecc Reduce CPU time on dedicated server
Additional functions and statements found during performance profiling.
Swapped 'Community_Frame()' C3 patch in favor of using shipped ConVar instead.
2022-05-21 12:42:28 +02:00
Kawe Mazidjatari
853dd03f84 Remove additional overhead from dedicated server
This should reduce CPU time even more (2 whole frame loops for chat room (client only) and discord presence (client only)).

Idle mem has been reduced by .8MiB.
2022-05-21 01:57:21 +02:00
Kawe Mazidjatari
efb7c36408 Light project restructure
Moved server/client headers and implementations into dedicated subfolder.
Renamed Some classes to match the game binary (e.g. CBaseClient is now CClient).
Removed redundant files.
2022-05-20 11:52:19 +02:00
Kawe Mazidjatari
72a2d07e66 Improve dedicated server performance
Prevent 'CClientState::Disconnect()' from being ran in 'Host_Disconnect()'.
2022-05-20 10:16:21 +02:00
Kawe Mazidjatari
77303e44b5 Optimize RCON
Don't run CheckForBan each iteration if no failed attempts are made
2022-05-13 21:41:03 +02:00