130 Commits

Author SHA1 Message Date
Kawe Mazidjatari
bfea8023eb Reduce duplicate code
Make a method for setting the host state.
2024-04-05 16:24:45 +02:00
Kawe Mazidjatari
cb1a69e82a Ban system refactor
Use CUtlVector, and remove every copy caused by passing vectors by value. CUtlVector does not support copying. Also removed all extraneous std::string copies caused by calling itoa instead of std::to_string, or std::stoll, etc. All features have been tested and work as designed.
2023-08-31 00:16:25 +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
849372d68e Show server CPU, frame time and current tick as well 2023-08-08 12:55:17 +02:00
Kawe Mazidjatari
e67fcfd1fb Remove static keyword
Can't be isolated to translation unit if only std::thread's ctor references it, triggers a compiler warning (C4505) that is treated as an error.
2023-07-19 02:33:22 +02:00
Kawe Mazidjatari
6cecc3297e Move KeepAlive function to HostState
Only used in HostState, moved to HostState with static linkage.
2023-07-19 02:19:43 +02:00
Kawe Mazidjatari
afb09e1d05 Cleanup CFG directory
Move to dedicated subdirectories.
2023-07-13 23:15:10 +02:00
Kawe Mazidjatari
efe119a5f2 Remove unnecessary parentheses from check in 'CHostState::FrameUpdate'
Unnecessary.
2023-06-18 17:13:42 +02:00
Kawe Mazidjatari
04856caf05 Display and host using playlists instead of gamemode
This should show the actual playlist rather than the gamemode.
2023-05-29 21:13:28 +02:00
Kawe Mazidjatari
f120354e96 Initial port to CMake
* All libraries have been isolated from each other, and build into separate artifacts.
* Project has been restructured to support isolating libraries.
* CCrashHandler now calls a callback on crash (setup from core/dllmain.cpp, this can be setup in any way for any project. This callback is getting called when the apllication crashes. Useful for flushing buffers before closing handles to logging files for example).
* Tier0 'CoreMsgV' function now calls a callback sink, which could be set by the user (currently setup to the SDK's internal logger in core/dllmain.cpp).

TODO:
* Add a batch file to autogenerate all projects.
* Add support for dedicated server.
* Add support for client dll.

Bugs:
* Game crashes on the title screen after the UI script compiler has finished (root cause unknown).
* Curl error messages are getting logged twice for the dedicated server due to the removal of all "DEDICATED" preprocessor directives to support isolating projects. This has to be fixed properly!
2023-05-10 00:05:38 +02:00
Kawe Mazidjatari
75ccebb4b6 Squirrel system restructure
Properly decouple squirrel and game code. This makes it easier to reverse engineer more of this squirrel system, and to compile them as individual libraries later on when moving to CMake to significantly decrease compile times.
2023-05-06 16:23:56 +02:00
Kawe Mazidjatari
848098c71d Update state machine initialization order
* Run autoexec(_dev).cfg before anything else.
* Always initialize RCON (only gets ran if an actual password is set).
* Removed 'Cbuf_Execute()' call from 'CHostState::LoadConfig', let it run in the frame loop instead.
* Removed hardcoded set call for 'net_usesocketsforloopback', will be set in autoexec from now on.
2023-04-30 11:39:20 +02:00
Kawe Mazidjatari
48bc69b028 Initial implementation of bulk ban checking
Initial implementation of the bulk ban check system. This implementation takes a snapshot of the currently connected clients, sends it up to the master server, and the master server returns anything within this list that is marked 'banned'. The server would then kick the player from the server. This commit also removes the global banned list cache, as the bulk checking system offers a lot more freedom regarding banning specific players and have it sync across all available servers.
2023-04-28 23:47:58 +02:00
Kawe Mazidjatari
35e0d9e8c8 Disable 'cl_threaded_bone_setup' at all times
Disabled in the gamesdk at all times as users have reported issues that causes the game to freeze when switching from a remote server to a listen server. The engine bug still needs to be addressed.
2023-04-16 11:57:45 +02:00
Kawe Mazidjatari
c6915fcf42 Cleanup 'CHostState::Think'
Reordered code and cleanup preprocessor directives.
2023-04-10 23:11:52 +02:00
Kawe Mazidjatari
b75fb7913f Rename symbols 2023-04-10 19:14:59 +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
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
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
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
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
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
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
15e9259b77 Use server current time for reload logic
Use server's current time for reload logic instead of a dedicated fast timer.
2023-02-12 15:32:34 +01:00
Kawe Mazidjatari
612ab83b20 Use 'GetNumClients' for hosting and status bar
Use 'GetNumClients' instead of iterating over the client array twice. Also fixed a bug causing the status bar only to display real clients, buts were never counted.
2023-02-12 15:21:33 +01:00
Kawe Mazidjatari
1db53a135f Fix dedicated.dll compile error
'g_svNetKey' no longer exists.
2023-02-12 11:49:39 +01:00
Kawe Mazidjatari
8b6e22473e Fix clang-cl compile errors
Unfortunately clang-cl doesn't support __FUNCTION__ macro concat. Some SSE stuff in mathlib/navmesh rendering also needs to be made portable at some point.
2023-01-31 14:31:17 +01:00
Kawe Mazidjatari
5f56c23af2 Compile CRConServer for gamesdk
RCON can now be used on the host game as well (previously dedicated exclusive).
2023-01-29 16:07:02 +01:00
Kawe Mazidjatari
6df498e5c8 Rename 'v_netadr_t' to 'netadr_t'
Name was used for compatibility reasons. No longer necessary.
2023-01-29 15:12:27 +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
Marvin D
75b90d9294 Forgot changing HS_SHUTDOWN 2022-12-22 00:53:09 +01:00
Marvin D
841ae89261 Unify string conversion and __FUNCTION__ uses in hoststate 2022-12-22 00:44:53 +01:00
Kawe Mazidjatari
9c1efe20ad Remove ConVar and ConCommand singletons
Extraneous singletons.
2022-11-18 22:10:20 +01:00
Kawe Mazidjatari
3511aff224 Execute "bind.cfg" on startup
Users could put custom binds in here.
I also unbound all dev-only binds by default to suppress warnings or prevent issues.
2022-11-10 15:42:27 +01:00
Kawe Mazidjatari
5c92fde569 Rename no map title to 'menu_main' 2022-11-10 11:59:29 +01:00
Kawe Mazidjatari
0c13ca4e3f Only run threaded bone setup when we don't run the listen server
The Season 3 versions of the executable deadlock when threaded bone setup has been enabled on the client while the listen server has ran at least once during the process lifetime.
2022-11-10 11:47:02 +01:00
Kawe Mazidjatari
3af0c7c0b0 Fix dedicated.dll compile errors 2022-09-22 00:22:43 +02:00
Kawe Mazidjatari
df986f7d3b ConVar renames
Renamed:
- sv_pylonRefreshInterval => sv_pylonRefreshRate.
- sv_banlistRefreshInterval  => sv_banlistRefreshRate.
- sv_statusRefreshInterval => sv_statusRefreshRate.
2022-09-21 21:23:09 +02:00
Marvin D
514a407e4c RPakHeader_t/RPakLoadedInfo_t additions 2022-09-18 13:55:44 +02:00
Kawe Mazidjatari
d9ddb575e2 Add ConVar to auto-reload the server after x seconds.
This should allow users to host dedicated servers without looking back, as you should reload/restart a server every 3 hours (a full process restart is the most recommended option, but a 'soft' reload works like a charm most of the time).
2022-09-15 01:37:45 +02:00
Kawe Mazidjatari
9dd49af1dc Reset idle name on shutdown 2022-09-14 21:59:32 +02:00
Kawe Mazidjatari
d32a4f2df0 Fix bug where restart commands don't work
We reset the idle name in HS_GAME_SHUTDOWN, but the restart command callback uses the name field to 'map' into the same map (restarting), which causes issues when we reset it to 'server_idle'.
Changed behavior to only reset name (non recursive) if we are running but do not have an active game.
2022-09-14 21:51:15 +02:00
Kawe Mazidjatari
729475c74c Light cleanup
Use NO_ERROR instead of NULL for error code parameter passed to Error(..).
2022-09-14 01:14:51 +02:00
Kawe Mazidjatari
3d6d6644bd Logging bug fix and error handling improvements
* Replaced the boolean 'fatal' parameter with a error code parameter, anything non-null will prompt a message (fatal) and terminate the process with given error code.
* Fixed bug where the global ostreamsink for spdlog did NOT get cleared in 'SQVM_PrintFunc' when cvar 'sq_showvmoutput' was < 3. Moved to global scope.
* Added error message for when detouring the process has failed, with the error code.
* Only call 'Plat_GetProcessUpTime()' once per log, (improves performance and fixes bug where the error message box would show a different time stamp than what is logged into the console or file).
* All TIER0 loggers only log to notify and console when the SDK engine has fully initialized and detoured all functions.
2022-09-14 00:39:38 +02:00
Kawe Mazidjatari
b1e1765124 Set the correct datatype for what was originally 'm_bSplitScreenConnect'
Bool is a char on this platform, and UINT8_MAX is 0xff (255), yet we set this char to 256 causing arithmetic overflow. Looking at the assembly of the game, this really is a uint16_t, and gets set to 256 in CHostState::Init, parsed to State_NewGame as 256 before the lowbyte is being reset to 0.
2022-09-09 20:16:55 +02:00
Kawe Mazidjatari
83ce041b65 Fix client.dll compile errors. 2022-09-01 01:32:32 +02:00
Kawe Mazidjatari
1285d15623 Ban system and authentication improvements
* Fixed bug where multiple of the same entries get added to the global ban/refuse list.
* Fixed bug where we still use the client instance after deleting it in 'CBanSystem::BanListCheck()'.
* Load banlist at a later state (not at construction of class), this is needed for a future change of adapting the 'business' code to feature the game's FileSystem.
* CServer cleanup.
* More detailed ban messages (banned, added to refused list, removed from slot, etc..).
* Use localization key for banned message ("#Valve_Reject_Banned").
* Add const qualifiers to all CPylon methods.

Note:
* This commit requires changes on the master server, these changes are already performed, however the new master server isn't live yet until we publish the new release.
2022-08-30 12:07:09 +02:00
Kawe Mazidjatari
532b4125d5 More thread safety improvements
* Run 'CHostState::Think()' in the main thread.
* Construct 'NetGameServer_t' objects in main thread before dispatching (TODO: browser).
* Dispatch the call to 'CBanSystem::AddConnectionRefuse' from 'SV_IsClientBanned' to the main thread if we aren't main.
* Return bool for CBanSystem::AddEntry and CBanSystem::DeleteEntry for future optimizations (next commit).
2022-08-27 23:45:58 +02:00
Kawe Mazidjatari
2010e11310 Add 'fatal' functionality to Error()
When fatal is set, the function will show a error dialogue, which will halt the process and close when the message is dismissed. Else we will end up in a crash.
2022-08-22 12:42:41 +02:00
Kawe Mazidjatari
8df311d126 Flip Cbuf_Execute() removal
Removed the wrong call
2022-08-21 01:44:01 +02:00