42 Commits

Author SHA1 Message Date
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
30031e3275 Don't allow stringcmd's if client isn't active
Potential exploit vector, executing stringcmd's during signon states where it shouldn't be used.
2023-08-08 19:25:12 +02:00
Kawe Mazidjatari
9a9d6b290a Fix typo 2023-08-08 19:05:12 +02:00
Kawe Mazidjatari
89431cc61f Fix crasher by clamping stringcmd length before tokenizing it
Possible crasher is to send a stringcmd >= 512 in size with funny UTF8 characters and have CUtlBuffer::ParseToken() read past it. Apparently seems to be mostly a problem on 32bit? I was unable to initiate a crash, though one string caused interesting behavior before, and there was one report of the dedicated server being 'crashed' with this. There is no reason to tokenize it up to 512 bytes if the game is only ever going to allow 128, so clamp it to 129 and if the user exceeds it then they still get the message and we just jettison it.
2023-08-07 16:52:35 +02:00
Kawe Mazidjatari
ad6466fa6c Add 'engine_cl' project to SDK and fix compiler errors
The 'engine_cl' library defines 'CLIENT_DLL', which prunes server specific code. This is used for the 'client.dll' project. Also fixed a compile error in 'CClient::VActivatePlayer', as it used a server only cvar. Ideally, this entire file gets ifdef'd out for engine_cl, currently it doesn't matter as nothing gets compiled in.
2023-07-19 02:30:07 +02:00
Kawe Mazidjatari
e7d7c47531 Make 'CClient::IsHumanPlayer' inline 2023-07-17 17:38:21 +02:00
Kawe Mazidjatari
b5f68df826 Fix rare crasher due to missing NULL check on netchan
Netchan could be NULL, add a check in.
2023-07-17 17:08:37 +02:00
Kawe Mazidjatari
a738e58985 Remove legacy code
The persistence enabled field was no longer needed a while ago, but never removed.
2023-07-16 13:47:07 +02:00
Amos
2f209ddb60 Remove 'g_pClient' pointer
The whole array is part of the CServer class.
2023-07-12 09:14:33 +02:00
Amos
c6a9b855a2 Make simple CClient getters, inline
Small enough to be inline.
2023-07-12 09:11:31 +02:00
Amos
ccdfed1c19 Use CServer's 'GetClient'
Use the CServer's 'GetClient' method for obtaining clients by index.
2023-07-12 08:56:17 +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
Kawe Mazidjatari
ef69611435 Replace memalloc calls throughout entire SDK
Global 'direct' usage of 'MemAllocSingleton()' has been jettisoned. Where possible, smart pointers were used instead. During the refactor, the following bugs were addressed and fixed:
- The virtual destructor of 'CCVarIteratorInternal' was NOT called on destruction.
- Class function 'KeyValues::MakeCopy' did NOT calculate the buffer size of the wide string correctly, the original calculation was 'len+1*sizeof(wchar_t)', but should've been '(len+1)*sizeof(wchar_t)'.

Some other code changes include:
- Tier0 include 'memstd.h' has been moved above all thirdparty includes, to make sure the memalloc functions get shadowed with ours in third party libraries as well.
- RPak file paths string literals are now defines.
- 'DestroyOverlay' has been refactored to match the assembly of the game.
2023-06-26 22:34:24 +02:00
Kawe Mazidjatari
0f5b171b67 Cleanup warning string on invalid string cmd
Remove the UTF-8 part.
2023-06-24 00:56:45 +02:00
Kawe Mazidjatari
a93824b2db Discard invalid string commands
Must be UTF-8 encoded, currently there are no checks.
2023-06-22 23:45:19 +02:00
Kawe Mazidjatari
619bbd161c Fix stringcmd replay exploit
This commit fixes an engine bug where netmessages are getting copied into the replay buffer, while these messages should never be replayed. The engine performs an internal check on 'CNetMessage::m_nGroup', and if its NOT 2, the message is getting copied into the replay buffer. All messages returning false in 'ShouldReplayMessage' are not getting copied into the replay buffer anymore. This exploit has been used in the past to route clients that were watching a replay to an arbitrary server, which essentially forms an info leak as the client attempts to connect to the arbitrary server on its own. The exploit also allows for some form of remote code execution, depending on if the client was launched in developer mode or not.
2023-05-30 23:01:46 +02:00
Kawe Mazidjatari
552f5f750c Fix crash in 'CClient::ActivatePlayer'
Set the persistence fields to 'ready' in 'CClient::ActivatePlayer', before executing the rest of the function. Previously, it was set in 'CVEngineServer::PersistenceAvailable', but this is too late. The function 'FairFight_Init' was actually 'CClient::ActivatePlayer', and thus it has been moved to the correct file, and the old file defining it previously has been removed.
2023-05-15 17:19:18 +02:00
Kawe Mazidjatari
98f09b25de CClient: Member type improvements
* Made 'm_nUserID' signed.
2023-04-30 01:26:37 +02:00
rexx
dca27475ec (re)implement sv_alltalk
Rebuilds SV_BroadcastVoiceData with an additional check of "sv_alltalk" cvar to disable team checking, allowing for servers to enable global voice chat
2023-04-29 11:11:10 +01:00
Kawe Mazidjatari
43dd1ea813 Remove extraneous include 2023-02-18 00:10:01 +01:00
Kawe Mazidjatari
2ed56d7317 More mapped out fields for server and client class 2023-02-17 23:59:37 +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
21f4d0fa07 Initial working bots implementation
* Changed 'CClient' handle time to 'edict_t' which is an alias of 'uint16_t'.
* Changed 'g_pServerGameDLL' and 'g_pServerGameClients' init (obtain from factory instead).
* Use interface version macro's for obtaining factory pointers instead.
* Added 'g_pServerGameEntities'.
2023-01-16 21:09:21 +01:00
Kawe Mazidjatari
484f3251d1 Variable rename for readability 2022-09-22 21:20:37 +02:00
Kawe Mazidjatari
42c6be9e08 Fix client.dll compile errors 2022-09-22 00:08:49 +02:00
Kawe Mazidjatari
7a48c5ab6e Use shifted pointer 2022-09-21 00:38:46 +02: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
58cadb529b 'Bad behaving player' systems improvement
* Use 'CClient::Disconnect(..)' for all kicks and bans (this automatically clears the entire CClient slot, and removes the net channel).
* Only force disconnect when 'CNetChan::m_nSignonState' has a value that is not NULL.
* Clear the ServerPlayer slot on 'CClient::Disconnect(..)' and 'CClient::Connect(..)'.
* Only kick player for NetChannel overflow when value exceeds processing budget (not equals).
2022-09-19 01:28:43 +02:00
Kawe Mazidjatari
fdd74aa622 Implement net message processing budget
Implement net message process budget (channel gets removed if value is exceeded).
Use 'net_processLimit' to enable the implementation on the server. It will get enabled by default after testing and some cleanup. This helps against people trying to slow the server down by spamming net messages with a higher rate, e.g. using 'bind "mousewheel_up" "status"'.
2022-09-18 23:19:50 +02:00
Kawe Mazidjatari
34a06147d7 Fix spelling errors
Overall spelling improvements and cleanup..
2022-09-09 19:47:31 +02:00
Kawe Mazidjatari
afad5b92ec Rename 'OriginID' to 'NucleusID'
Nucleus ID is the official internal term for the platform user id used by the OriginSDK.
2022-08-29 15:59:12 +02:00
Kawe Mazidjatari
ea5f17b4ca Light cleanup
* Moved ConVar usage text that where part of the help string to the usage string parameter.
* Flagged ConVar 'bhit_abs_origin' as FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED.
* Flagged ConCommand 'bhit' as FCVAR_DEVELOPMENTONLY | FCVAR_GAMEDLL.
* Check 'bhit_enable' before running the 'bhit' command callback.
* Fixed spelling in a few area's.
2022-08-04 16:34:23 +02:00
Kawe Mazidjatari
034df40755 CClient::GetClient improvements 2022-06-16 18:04:43 +02:00
Amos
39dd70f929 Update client.cpp comments
client.cpp (holding CClient) is in 'engine/client' based on asserts from the game module
2022-06-15 13:33:47 +02:00
PixieCore
15f6fd3123 Few comments 2022-06-15 11:59:37 +02:00
Kawe Mazidjatari
ff59db1b95 Light improvements
Update comments.
Proper type for 'user_creds::m_nUserID'.
Proper type for 'CClient::SetUserID'.
Added 'CClient::SetHandle'.
2022-06-14 21:53:03 +02:00
Kawe Mazidjatari
c708d73c02 Improve comments 2022-06-14 21:43:32 +02:00
Kawe Mazidjatari
e5f412bcb2 CClient improvements
Mapped out new fields in CClient
2022-06-14 21:41:35 +02:00
Kawe Mazidjatari
ebf4921063 Ban system improvements
NucleusID/OriginID is an unsigned type, changed all types to uint64_t and cleaned up redundant code.
2022-06-14 20:56:55 +02:00
Kawe Mazidjatari
62f3108909 Cleanup 'NET_DisconnectClient()' 2022-05-21 18:56:56 +02:00
Kawe Mazidjatari
52883808e1 Reversed CServer structure (almost complete). See desc
* Mostly rebuild CServer structure.
* Partially rebuild CNetworkStringTable structure.
* Partially rebuild CNetworkStringTableContainer structure.
* Removed redundant patterns which are now covered in the data structure.
2022-05-20 20:14:39 +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