116 Commits

Author SHA1 Message Date
Kawe Mazidjatari
fa76747baa Show a more detailed error if the EULA request failed 2024-04-05 16:34:29 +02:00
Kawe Mazidjatari
2fe902061e Don't check for accepted EULA versions if this is a dedicated server 2024-04-05 16:34:28 +02:00
Kawe Mazidjatari
b37a3bdeba Add comments on newly added code 2024-04-05 16:28:59 +02:00
Kawe Mazidjatari
22c82d6f1d EULA dialog implementation
Display the EULA (fetched from masterserver), which the end user MUST accept before they can make use of the multiplayer features of R5Reloaded. NOTE: user doesn't need to agree to this to use the listenserver.
2024-04-05 16:26:18 +02:00
Kawe Mazidjatari
0eaa226dce Change JSON field types send to master server
They were all strings; changed them to what made most sense for each field type. Changes:
"hidden": string -> bool
"port": string -> int
"checksum": string -> uint
"playerCount": string -> int
"maxPlayers": string -> int
2024-04-05 16:24:46 +02:00
Kawe Mazidjatari
909977452e Client token authentication implementation
The game internally obtains a auth token from Origin. On connect to a gameserver, it will send it to the masterserver. The master server will create a JWT token and send this back to the client. The client stores this token in 3 userinfo cvars (token, sig1, sig2). the sig1 and sig2 cvars are there to compensate for the truncation caused by sending the cvar, as each cvar string length could be up to 255 (byte max). The server verifies this token (the signature, timestamp, expiry); if they are valid, the has successfully authenticated and will connect.
2024-04-05 16:24:45 +02:00
Kawe Mazidjatari
b3e768190c Pylon: fix use after free
The member must contain a copy of the string, pointing it to the buffer used by the language cvar results in undefined behavior. Several cases were the string pointed to random data were reported.
2024-04-05 16:21:45 +02:00
Kawe Mazidjatari
1d41b23abb Make sure language is never NULL
* Initialize CPylon::m_Language to "english".
* Make sure cvar change callback is always setting values instead of returning out early.
2023-09-16 00:45:11 +02:00
Kawe Mazidjatari
f0bbc7dbf0 Change logging context
Should be engine.
2023-09-07 22:46:12 +02:00
O-Robotic
51dd17ad2a Validate json root is an object before trying to retrieve members from it. 2023-09-07 20:32:09 +01:00
Kawe Mazidjatari
b85003a9ac Replace JSON library with RapidJSON
Less copies and overall CPU time parsing/constructing JSON's as we are mostly still using string pointers rather than STL string container.
2023-09-07 11:17:05 +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
rexx
1c179434d3 fix dedi compile
sets pylon language in a cvar change callback instead of accessing directly, as networksystem does not have a DEDICATED define
2023-08-17 20:22:28 +01:00
rexx
356f0ce7c0 send language to MS 2023-08-17 20:02:42 +01:00
Kawe Mazidjatari
5f64cd83d8 Fix FileSystem size integer truncation
The implementation in the engine always took/returned signed 64bit size types, but I made a mistake when reversing the virtual function table. All types have been changed to what they should be (mostly signed 64bit, very few unsigned), and usage in-SDK has been adjusted accordingly.
2023-08-09 14:43:54 +02:00
Kawe Mazidjatari
9e9d3342b3 CURL tools improvement
- Added wrapper for downloading files.
- Moved many function arguments to dedicated parameters structure.
2023-07-28 14:47:20 +02:00
Kawe Mazidjatari
31d92b439f Move cvars from curlutils.cpp
Move it elsewhere so this code can be shared among tools that don't feature the ConVar class.
2023-07-26 16:52:49 +02:00
Kawe Mazidjatari
54536a2652 Parameterize changelevel or map in CServerListManager::LaunchServer()
Parameterized; whether or not to drop all clients (map = drop, changelevel = keep).
2023-07-19 02:21:58 +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
7455d4da2d CPylon: add getters and setters for error/token fields 2023-07-19 02:17:28 +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
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
Amos
b13cc071a9 Improve ban commands
The ban commands have the 'sv_' prefix removed. CBaseEntity::InputKill expects 'kickid' to be present, it uses this to kick the player once the entity has been destroyed. Not doing so could lead into a crash or other undesired behavior.
2023-06-22 09:09:38 +02:00
Amos
ac4ab6aa1a Add reason parameter to kick/ban commands
Reason parameters are optional. For scripts, to use the default message, pass in an empty string. The function for the script system should be centralized soon to avoid more duplicate code.
2023-06-20 08:44:03 +02:00
Kawe Mazidjatari
3f8baf6f68 Allow setting compile options for specific targets
Previously, it was all controlled from the global init (applied to all projects), but some projects need different options. With these changes, you can disable the common options applied in the 'add_module' macro, and set your own if desired.
2023-06-17 00:45:27 +02:00
Kawe Mazidjatari
e891d74656 Fix cURL error logging for dedicated
Since this file no longer gets build along with the DLL project, but as a static lib instead, the 'DEDICATED' define no longer worked, and therefore this became broken after the CMake port. The 'CURLHandleError' helper function now takes a bool determining whether or not to log the error, and the caller disables it for dedicated (dedicated should only log the error once, this happens from within the caller class).
2023-06-02 00:05:23 +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
0138ac025f Fix bug when trying to print the host token
Should return ptr to string (caught from compiler warnings).
2023-05-15 00:54:33 +02:00
Kawe Mazidjatari
6a86ae2606 Cleanup CMakeLists files
Light cleanup in CMakeLists files. Split protocols and improve filter names.
2023-05-14 17:36:08 +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
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
2748c61fe2 Put json value getters in try catch
Put 'nlohmann::json::value' operations in try catch, as these could raise an exception.
2023-04-29 14:58:46 +02:00
Kawe Mazidjatari
145bc3797f Only check token field if the server is hidden 2023-04-29 13:15:18 +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
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
fcc4b410f3 Improve formatting in pylon code 2023-04-26 23:31:16 +02:00
Kawe Mazidjatari
9872b4042a Improve pylon error logging
Improve error formatting.
2023-04-25 22:57:06 +02:00
Kawe Mazidjatari
73fe590f99 Fix small bug
Fixed bug caused by const char* to const string& conversion, resulting in the request message not always getting sent properly.
2023-04-25 22:51:06 +02:00
Kawe Mazidjatari
000f7c7f82 CPylon parsing/logging code deduplication
Deduplicated parsing and logging code. Results are a lot more consistent and comprehensive.
2023-04-25 00:45:39 +02:00
Kawe Mazidjatari
f0a561552b CPylon server query code deduplication
Created another dedicated wrapper for handling API requests; significantly reduced duplicate code.
2023-04-24 01:55:37 +02:00
Kawe Mazidjatari
aff4b6125e CPylon error handling code deduplication
Deduplicate code.
2023-04-24 00:32:27 +02:00
Kawe Mazidjatari
02bef4c2dd Light cleanup in CPylon
Force consistency.
2023-04-22 22:00:20 +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
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
53c693f6e1 Avoid creating a unnecessary copy
Avoid copying the string out of the vector.
2023-04-03 11:21:31 +02:00
Kawe Mazidjatari
e1f0e72af4 /W4: Fix type demotion warnings
Explicitly demote to 'int' to suppress pesky compiler warnings.
2023-04-02 16:03:01 +02:00
Kawe Mazidjatari
7c8fc3a67d CPylon: explicitly cast status in string format to int
Newer versions of the 'fmt::format' library require these to be casted as such.
2023-03-18 13:29:40 +01:00