603 Commits

Author SHA1 Message Date
Kawe Mazidjatari
678c6dc833 Add proper timing logic for server statistics
Update rate is now controller by a cvar.
2023-04-09 11:06:55 +02:00
Kawe Mazidjatari
94d30b759d Fix potential security flaws caused by uncontrolled format strings
Make sure format strings are string literals to avoid an uncontrolled format string situation.
2023-04-08 20:13:06 +02:00
Kawe Mazidjatari
f09bdc472b Suppress compiler warning and avoid potential bug
The string literal will never change during runtime; this commit is to make sure no mistakes are made in future refactors.
2023-04-08 19:14:00 +02:00
Kawe Mazidjatari
a7cab1d891 Fix potential security flaws caused by uncontrolled format strings
Make sure format strings are string literals to avoid an uncontrolled format string situation.
2023-04-08 19:10:59 +02:00
Kawe Mazidjatari
1d04f837f8 Fix many high level compiler warnings
* Put initializer values inside brackets.
* Put logical AND conditions within parentheses.
* Put assignments within conditional statements within parentheses.
* Mark unused variables as such to suppress compiler warnings.
* Fix vftable shadow warnings caused by ConVar::CreateInternal (does not implement, only interface. Renamed to yield desired behavior).
* Fix 'never' initialized class members for 'CCVarIteratorInternal'.
* Return values in interface vftables that cannot be pure virtual.
2023-04-08 19:00:28 +02:00
Kawe Mazidjatari
a83d5737e7 Fix non-portable include paths
Portable include paths are case sensitive.
2023-04-08 18:54:31 +02:00
Kawe Mazidjatari
a2bb707902 Fix unhandled enumerants in switch statement 2023-04-08 18:30:38 +02:00
Kawe Mazidjatari
16910aa45c Use custom string formatter
Enforce consistency through code base by using the same format specifiers.
2023-04-08 10:50:32 +02:00
Kawe Mazidjatari
874faea430 Add hook to CLZSS::SafeUncompress
Added hook to use the SDK implementation of 'CLZSS::SafeUncompress' instead, since the one in the game executable does not check bounds on the iterator pointer. This fixes the problem of people crashing servers with malicious packets.
2023-04-06 00:28:58 +02:00
Kawe Mazidjatari
b8d97d0d1c Cleanup 'Mod_GetAllInstalledMaps'
Light cleanup
2023-04-03 18:38:36 +02:00
Kawe Mazidjatari
7de0ed24b1 Update CClient class
Members 'm_szServerName' and 'm_szClientName' are both 256 bytes in size.
2023-04-03 18:37:35 +02:00
Kawe Mazidjatari
3463d0070f Improve text formatting in 'Host_Status_PrintClient'
Better 'status' command output.
2023-04-03 14:56:03 +02:00
Kawe Mazidjatari
fe0cce731b Explicitly disable certain warnings in code
This code is good as-is, they cannot be adjusted to suppress the warnings while still guaranteeing its functionality.
2023-04-03 14:55:16 +02:00
Kawe Mazidjatari
e79ed464e9 Improve HexDump utility
* Improved formatting.
* Get default logger directly instead of using a string identifier.
* Promoted size type to 'size_t'.
* Removed extraneous static variables.
2023-04-02 21:51:15 +02:00
Kawe Mazidjatari
b0d2665550 /W4: Fix compiler compatibility
Clang doesn't support function-style casts with types containing a space.
2023-04-02 17:34:42 +02:00
Kawe Mazidjatari
bae2e0a99c /W4: Fix implicit type conversion warnings
Explicitly convert them to avoid any warnings or potential bugs.
2023-04-02 17:23:53 +02:00
Kawe Mazidjatari
ae431c6ac2 /W4: Fix unreferenced symbol warnings
Fix verbose unreferenced symbol warnings.
2023-04-02 17:02:04 +02:00
Kawe Mazidjatari
a4a2f34c10 /W4: Fix signed/unsigned mismatch
This commit fixes warnings and bugs caused by signed/unsigned mismatch.
2023-04-02 12:09:43 +02:00
Kawe Mazidjatari
48547325ee /W4: Properly pack CClientState structure
Pruned many compiler warnings by removing the packing directive and alignment modifiers. Padding that was otherwise performed by the modifiers, have been added manually. This change did not affect code generation.
2023-04-02 10:48:44 +02:00
Kawe Mazidjatari
1ef5287b56 /W4: Fixed name shadowing bug
'DrawAllOverlays' gets called with a boolean parameter indicating whether or not the render frame should be ran. This is so the rest of the logic could run in order to decay overlays to avoid memory leak or unnecessary high CPU time in overlay timing code. Parameter name has been renamed from 'bDraw' to 'bRender', and the local variable 'bDraw' which caused the shadow warning, has been renamed to 'bShouldDraw'. The local variable 'bOverlayEnabled' now takes into account the 'bRender' parameter.
2023-04-02 09:27:54 +02:00
Kawe Mazidjatari
2bf86375d7 /W4: Fix unreachable code 2023-04-02 02:17:52 +02:00
Kawe Mazidjatari
69624baa10 NavMesh debug draw code refactor
* Use mathlib SIMD wrappers instead, this is to maintain compatibility across different platforms/compilers.
* Moved camera distance logic to separate method.
2023-04-01 20:54:10 +02:00
Kawe Mazidjatari
b15d848c66 Cleanup 'user_creds_s'
Light cleanup.
2023-04-01 01:51:39 +02:00
Kawe Mazidjatari
67180e51ff Validate client's origin name on connect
Recently, there has been a sudden influx of players playing with a name that isn't valid. Names such as "    " or "@something $very !crazy". This patch fixes this problem by enforcing checks during connect by default.
2023-03-31 22:37:53 +02:00
Kawe Mazidjatari
29616f4810 Rename 'g_vAllMaps' to 'g_InstalledMaps' 2023-03-31 00:35:01 +02:00
Kawe Mazidjatari
47aabf244b Remove redundant tier1 files
These files are no longer necessary.
2023-03-28 01:30:09 +02:00
Kawe Mazidjatari
296a0df948 Add static assert for 'CClockDriftMgr' 2023-03-27 17:42:11 +02:00
Kawe Mazidjatari
5aea2f4261 RCON system upgrade
RCON upgrade with additional logging system improvements:
* Netconsole's can now log received messages in color, even when the RCON server has ANSI colors disabled; logs are fully composed locally.
* RCON server now also sends the log type over the wire, along with the (already existing) context.
* SDK logging code is now shared with the standalone netconsole application.
* Improved logging readability for the standalone netconsole application.
2023-03-27 02:01:48 +02:00
Kawe Mazidjatari
a60609a0e8 Initialize concommand/convar as early as possible
'CSourceAppSystemGroup::PreInit' is as early as we can initialize them; CCvar gets initialized in 'CSourceAppSystemGroup::Create'.
2023-03-26 17:45:09 +02:00
Kawe Mazidjatari
8b89c1d2b5 Init concommand/convars a bit earlier
Init in 'CEngineAPI::Init'.
2023-03-26 16:47:47 +02:00
Kawe Mazidjatari
793fcd62f2 End of logger refactor
Changed all loggers to use the internal 'CoreMsg/CoreMsgV' functions. Significantly reduced duplicate code and CPU time. Code is also much more robust.

* Code now only acquires mutex lock when the actual logging part takes place.
* Code now only checks and strip ANSI rows if its enabled to begin with.
* Code now supports setting log levels, which ultimately could be tweaked with a cvar.
* Changed logger and file names to be more readable.

TODO:
* The RCON protocol has to be modified to accommodate these changes.
2023-03-26 16:09:05 +02:00
Kawe Mazidjatari
1bdc0c466e De-inline CHostState
Force inlining this was a temporary solution in the past to overcome a crash caused by stack corruption. This problem seems to be solved, and thus its no longer necessary to force inline all methods.
2023-03-18 17:36:09 +01:00
Kawe Mazidjatari
371e15db41 Fix many verbose compiler warnings
Many compiler warnings regarding implicit conversions.
2023-03-18 16:45:43 +01:00
Kawe Mazidjatari
031eee80a1 RCONServer: send/serialize optimizations
Check if we are initialized, have at least one socket, and in case of a console log, if we have at least 1 authorized netconsole before serializing the message and sending the result.
2023-03-13 21:20:20 +01:00
Kawe Mazidjatari
cae5037324 Initial fix for older game builds
SDK compiles and works for the S1 game now, still needs to be debugged further.
2023-03-01 00:09:38 +01:00
Kawe Mazidjatari
a5440616e2 Cleanup for dedicated server as result from recent patch
Removed all checks for 'ui.rpak' and 'ui_mp.rpak'. None of these are useful for dedicated server. 'bUnconnected' has been changed to true (should had been in the first place). Promoted some integers to 64bit types to suppress compiler warnings, output code remained the same.
2023-02-26 22:22:45 +01:00
Kawe Mazidjatari
ffa8647e69 Change default console title map name
Changed 'CHostState::ResetLevelName' to set 'no_map' as default map name when called.
2023-02-26 19:44:16 +01:00
Kawe Mazidjatari
2637398fff 'InitVPKSystem' cleanup
More readable/portable code. changed dedi from loading 'mp_lobby' to 'mp_common'. The former caused hard to fix problems in pak loading code.
2023-02-26 19:37:12 +01:00
Kawe Mazidjatari
ef5a9b6348 Fix compiler warning
'_Warning' shouldn't return anything.
2023-02-26 19:34:42 +01:00
Kawe Mazidjatari
a80cf721d8 Fix flipped format specifier
Should be flipped, as nucleus id is before state.
2023-02-26 19:34:07 +01:00
Kawe Mazidjatari
8965d6f101 Error/Warning/Con_NPrintf log hook refactor
* Warning now only logs if error level < 5.
* Warning buffer size has been increased to '10000' (internal buffer size).
* Error is now hooked as well.
* Error buffer size has been increased to '4096' (internal buffer size).
* Con_NPrintf has been refactored; 'cl_showhoststats' has been removed.
* Con_NPrintf buffer size has been increased to '4096' (MAXPRINTMSG).
* CTextOverlay::Con_NPrintf now checks the first byte in the character buffer before rendering anything, and sets the first byte to a terminating null character after rendering. This fixes the bug causing the host_speeds overlay to be still drawn while the cvar 'host_speeds' was disabled.
2023-02-19 09:51:46 +01:00
Kawe Mazidjatari
9e61db4b60 Hook 'Host_Error'
'Host_Error' messages were never getting logged until now.
2023-02-19 09:43:12 +01:00
Kawe Mazidjatari
020986fc3b Remove unnecessary newline
Most error messages have newlines. If they are absent, they get appended automatically.
2023-02-19 00:44:43 +01:00
Kawe Mazidjatari
ad1f83523e CHostState improvements
Mapped out all members, also fixed the initialization of members. Some fields were never getting initialized, and m_iCurrentState was initialized improperly.
2023-02-18 19:18:00 +01:00
Kawe Mazidjatari
3e246a9d27 CServer improvements
* Added new member 'm_nSpawnCount'.
* Added hook for 'CServer::RunFrame'.
* Abstract class 'IServer' no longer exists in this engine, inherit from 'IConnectionlessPacketHandler' instead (see RTTI in engine executable).
2023-02-18 11:42:36 +01:00
Kawe Mazidjatari
74eb203f2f Client: CPU statistics update logic
Implements the client side CPU statistics logic. An additional check has been added which checks if 'SVC_ServerTick::m_NetTick.m_nCommandTick' equals '-1'. This instructs the client to only update the remote statistics; actual tick members won't get updated as this causes simulation problems.
2023-02-18 00:31:57 +01:00
Kawe Mazidjatari
872e33887a Server: CPU statistics update logic
Implements the server side CPU statistics update logic. In the retail product 'SVC_ServerTick' is only send during 'CClient::ActivatePlayer' and 'CClient::SendServerInfo', which is only called during/after connect, but not during the game. The new implementation sends server CPU statistics to the client every time the CPU usage has changed. This is indicated using the '-1' value in the 'SVC_ServerTick::m_NetTick.m_nCommandTick' member variable.
2023-02-18 00:24:02 +01:00
Kawe Mazidjatari
43dd1ea813 Remove extraneous include 2023-02-18 00:10:01 +01:00
Kawe Mazidjatari
1e8d872908 Add host frametime globals to SDK
Added:
* host_frametime_unbounded
* host_frametime_stddeviation
2023-02-18 00:08:10 +01:00
Kawe Mazidjatari
367b2cf5bc Renames and new setters for CNetChan
* Renamed hooking class to 'VNetChan'
* Added new setters for setting the remote frame times, and the remote server CPU statistics.
2023-02-18 00:05:55 +01:00