763 Commits

Author SHA1 Message Date
rexx
d521c67367 Hook CMapLoadHelper ctor
This will be used for enabling bsp_lump file loading in the future
2023-05-19 20:21:11 +01:00
Kawe Mazidjatari
53788d5ba5 Potential fix for intermittent crash during playlists reload
This should fix a rare crash that happens when the playlists file is reloaded during disconnect. The client fetches the playlists from the server on connect. On disconnect, we want to reload the one from the client so that if the player want's to create his own game, that he would have his own playlists. The fix is to delay the reload of the playlists file to the beginning of the next frame.
2023-05-16 00:44:59 +02:00
Kawe Mazidjatari
8acfad5556 Fix aligned memalloc singleton
Properly fix the aligned memalloc singleton in the SDK; the implementation now uses a callback based approach for calling the allocator and deallocator.
2023-05-15 20:47:17 +02:00
Kawe Mazidjatari
7ddd33c8de Force name consistency
Renamed to just 'netconsole' as it was phrased like that throughout other files.
2023-05-15 18:00:51 +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
11864f8902 Add all public headers to CMake projects
Added all public headers to CMake projects, also moved some files around in the public directory. Translation units have been moved to the libraries that were responsible for implementing them, as this game is monolithic.
2023-05-15 14:47:03 +02:00
Kawe Mazidjatari
9f44bcc818 Treat compiler warnings as errors
Treat them as errors globally. Most of the time a warning is a bug, or problem in code that could be solved in a different (better) manner. Thirdparty code have this disabled. The warnings as errors option can be globally disabled through the CMake GUI, but this is not recommended.
2023-05-15 09:44:26 +02:00
Kawe Mazidjatari
904976e4f5 Move shared files from server 2023-05-13 22:54:15 +02:00
Kawe Mazidjatari
67fb566dfb Compile launcher as separate library again 2023-05-13 20:03:42 +02:00
Kawe Mazidjatari
b94a9dcd7c Add dedicated server engine library
Added to CMake projects.
2023-05-13 17:48:00 +02:00
Kawe Mazidjatari
8dbc2024c6 CMake code improvements
Use the 'add_module' macro to add modules without creating duplicate code. This macro also takes a reuse PCH as parameter, so modules that need a precompiled header, could reuse those from different targets that compile them. This commit also restructures the group order of the generated solution files for easier code navigation.
2023-05-13 00:14:53 +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
359820615f Move low level code to tier0/tier1
Moved to tier0/tier1 so it could be compiled into a static library in the future.
2023-05-06 22:59:01 +02:00
Kawe Mazidjatari
d825fb9f58 Adjust type for 'g_pMallocPool' and rename
Adjusted type to 'CAlignedMemAlloc' and renamed it to 'g_pAlignedMemAlloc'. This global allocates  memory aligned.
2023-05-06 17:48:43 +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
f97cf6c249 RCON socket bind improvement
Check 'net_usesocketsforloopback' before binding sockets; allows binding to loopback as well.
2023-04-30 11:32:51 +02:00
Kawe Mazidjatari
90cf742fb5 Don't check for ban if client is a loopback address 2023-04-30 11:31:05 +02:00
Kawe Mazidjatari
17c8a5e49c Add const getter for 'CNetChan::remote_address'
Return as const reference.
2023-04-30 11:11:33 +02:00
Kawe Mazidjatari
f319fc0846 Use server global variables for client loops
Use server global variables for determining the num clients to loop over. This is cheaper and better than always looping over MAX_PLAYERS.
2023-04-30 01:50:38 +02:00
Kawe Mazidjatari
6b23570beb Ban system bug fix and improvements
* Format the ip as '[ip]:port' in all logging calls for consistency.
* Fixed a bug causing the IP to be send up as full instead of base only to master server (should always be base only).
* Temporarily uncommented the plugin callback logic.
2023-04-30 01:29:54 +02:00
Kawe Mazidjatari
98f09b25de CClient: Member type improvements
* Made 'm_nUserID' signed.
2023-04-30 01:26:37 +02:00
Kawe Mazidjatari
4ec8e67d9b CNetChan: Getters improvements
* Allow for requesting address base only.
* Added new getter 'GetPort'.
2023-04-30 01:24:45 +02:00
Kawe Mazidjatari
78a86fed6a Log address of 'SV_BroadcastVoiceData' 2023-04-29 21:07:45 +02:00
Kawe Mazidjatari
55aa254e6b Merge branch 'bulk_check' into indev 2023-04-29 21:01:59 +02:00
Kawe Mazidjatari
a5bc2f77cb Fix broken 'SV_IsClientBanned' implementation
SV_IsClientBanned is now checked after the creating of CClient, and thus 'CServer::AuthClient' has been inlined into 'CServer::ConnectClient'. Since we have to request the master server to check whether or not this particular client is globally banned, we have to detach it into a separate thread, and process the results back into the main thread once finished. This takes too much time, so we connect the client anyways and if the master server marked it as 'banned', we disconnect it right away.
2023-04-29 20:36:29 +02:00
Kawe Mazidjatari
3ea49766c6 Light banning code improvements
* Removed extraneous std::string constructors (everything using the bansystem used raw char pointers).
* Improved logging and function comments.
2023-04-29 12:15:51 +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
ab9d36e0d8 Send client's persona name to the master server
Will be used on the master server for additional checking.
2023-04-29 00:05:47 +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
a1c97e1b39 Fix assignment bug
Sigscan results returned to the wrong var.
2023-04-26 23:31:03 +02:00
Kawe Mazidjatari
d9fa611418 Add new callbacks to server functions
A few new callback hooks which are perhaps useful in the future.
2023-04-25 00:46:45 +02:00
rexx
3eb660c9f7 enable pluginsystem 2023-04-23 22:28:16 +01:00
Kawe Mazidjatari
59b685b7ee Fix unreachable code warning
This code isn't reachable, removed.
2023-04-23 20:35:08 +02:00
Kawe Mazidjatari
615de70b1f Fix shutdown crash
Fixed crash due to destructor of CSocketCreator being called during shutdown. If the socket fails to close, an error is logged. But at this point, all sockets have been closed already and the logger system has already been destroyed. Allocated as dynamic memory to avoid destructor being called at this stage.
2023-04-23 18:01:30 +02:00
Kawe Mazidjatari
1eef4aacb4 Improve signatures
Better signatures, and fix signature/compile errors for s1 and s2.
2023-04-23 17:05:00 +02:00
Kawe Mazidjatari
b11e5d539c Light code cleanup
Compiler output did not change; logic remained identical.
2023-04-23 11:35:09 +02:00
Kawe Mazidjatari
df81d52398 Improve assert
Fix assert condition where iSocket and GetAcceptedSocketCount are both 0.
2023-04-22 21:46:05 +02:00
Kawe Mazidjatari
13fcdaa442 Fix bug in 'CServer::AuthClient'
The IP that is sent to the server should be in base format only (no brackets or port). The buffer size was also too small to contain the entire length of the full IP address with port and brackets.
2023-04-22 20:30:53 +02:00
Kawe Mazidjatari
d56c24ce05 'CNetConBase::Recv' cleanup 2023-04-22 18:13:42 +02:00
Kawe Mazidjatari
50b3273101 Add change callback for 'sv_rcon_maxconnections'
If 'sv_rcon_maxconnections' is set higher than current auth socket count, reopen listen socket. If its set lower, close all sockets until auth socket count matches 'sv_rcon_maxconnections'. Sockets are getting closed in reverse order, so the netcon that connected last will be disconnected first.
2023-04-22 16:51:18 +02:00
Kawe Mazidjatari
9b65c7e59c Light cleanup 2023-04-22 16:49:22 +02:00
Kawe Mazidjatari
be61c93c85 RCON system improvements
* Added more error handling throughout code.
* Marked function parameters 'const' where possible.
* Updated comments.
2023-04-22 16:02:54 +02:00
Kawe Mazidjatari
39445eecc4 Add missing check
This fixes the bug where RCON address couldn't be set from the '[::]:port' format.
2023-04-19 01:52:05 +02:00
Kawe Mazidjatari
179bd31ee6 Initial large refactor of the RCON implementation
* Decoding and encoding is done into a single buffer, from raw buffers to avoid extraneous copies.
* Added base class holding all core logic for encoding, decoding, receiving and processing of the RCON protocol. This code was initially identical between all implementations of RCON, deduplicating this avoids bugs.
* Added more sophisticated error handling, stop right away when decoding for example fails.
* Added ability to have more than one active authenticated net console on the server. Controlled by cvar 'sv_rcon_maxconnections' (default 1).
* Max packet size for accepted, but not authenticated sockets is now controled by cvar 'sv_rcon_maxpacketsize' (default 1024).
2023-04-19 01:35:31 +02:00
rexx
f520cab44b fix static prop exceptions
This fixes the exceptions that were caused by loading ported bsps with replaced models
CStaticProp::Init was using static prop lump data to request non-existent skins due to the replaced models, causing invalid material pointers to be fetched.
When encountered, these skins will be forced to 0 and an error will be printed.
Ideally these issues are fixed from within the bsp file before they are shipped.
2023-04-18 16:56:35 +01:00
Kawe Mazidjatari
85f586bd2e RCON server improvements
* Prevent attacker from being able to abuse and overflow the banned list vector.
* Improved IPv6 comparison performance.
* Change size fields of payload frame from unsigned to signed.
* Close all accepted sockets on RCON server shutdown.
2023-04-16 17:51:48 +02:00
Kawe Mazidjatari
bd1bec3cfe Several RCON bug fixes and improvements
* Fixed uncontrolled format specifier in 'NetMsg' call on the RCON client.
* Removed extraneous call to 'PrintPercentageEscape'.
* Compare, and disable RCON logs if user attempts to connect to listen server's RCON.
2023-04-16 12:05:39 +02:00
Kawe Mazidjatari
a11012f3bf Set port on global netadr object
Set the port so it could be used to compare addresses.
2023-04-16 11:58:37 +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