32 Commits

Author SHA1 Message Date
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
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
1eef4aacb4 Improve signatures
Better signatures, and fix signature/compile errors for s1 and s2.
2023-04-23 17:05:00 +02:00
Kawe Mazidjatari
b15d848c66 Cleanup 'user_creds_s'
Light cleanup.
2023-04-01 01:51:39 +02: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
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
2ed56d7317 More mapped out fields for server and client class 2023-02-17 23:59:37 +01:00
Kawe Mazidjatari
decf3552ea Add 'GetNumClients'
Gets the total amount of clients on the server (both fake and real clients).
2023-02-12 15:20:11 +01:00
Kawe Mazidjatari
e50601ed29 Rename 'g_bDedicated' to 'm_bIsDedicated' 2023-01-31 22:40:15 +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
61684ddf87 Create cvar for global banned list queries
This was planned to be changed a long time ago. This change allows dedicated server users to disable the logic as well.
2023-01-26 21:20:11 +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
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
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
811ecade86 Replace CServer::Think with CServer::FrameJob
Actual hook where we could also run anything in the server frame thread (the earliest function where equality to server thread id could be performed).
2022-11-05 00:12:45 +01:00
Kawe Mazidjatari
40566235e0 Server authentication code improvements
* Added validity checks for player names, they must be UTF-8 encoded, else game clients will crash attempting to set non-UTF-8 player names in RUI.
* CServer::RejectConnection now takes a 'v_netadr_t*', previously it was 'user_creds_s*', which worked as 'v_netadr_t' is the first member in 'user_creds_s'.
* Programmer must now manually pass a character buffer to 'v_net_adr::GetAddress(...)'.
2022-11-03 02:30:57 +01:00
Kawe Mazidjatari
42c6be9e08 Fix client.dll compile errors 2022-09-22 00:08:49 +02:00
Kawe Mazidjatari
529a28358a Update server.h 2022-08-30 17:20:50 +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
329621c6ad Move all public headers into root of 'public' 2022-08-09 17:18:07 +02:00
Kawe Mazidjatari
db90f3722c Add more information to global server/client global debug print 2022-08-09 10:55:13 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
rexx
35515f1ef5 fix clientsdk compilation 2022-07-13 19:46:55 +01:00
Kawe Mazidjatari
cdcc87b54b Renamed master server related stuff 2022-07-01 10:29:27 +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
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
84f6f37721 Rename unknown parameter
Unkmown parameter was socket (pServer + 0xC).
2022-05-28 23:36:29 +02:00
Kawe Mazidjatari
7bc18c8012 Align CServer structure with game's memory
Unknown fields have been padded to match the structure's size in memory. Iteration is now possible.
2022-05-28 23:14:01 +02:00
Kawe Mazidjatari
a75aa33cc3 More consistent member variable names 2022-05-21 12:42:46 +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