74 Commits

Author SHA1 Message Date
Kawe Mazidjatari
02303d0ffc Merge branch 'indev' into launcher_rework 2024-06-01 12:02:06 +02:00
Kawe Mazidjatari
33564c7351 Tier2: use utlvector for cylinder points and initialize buffer 2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
90e4711425 Tier2: move random generator from tier0 to tier2
Moved into cryptutils.cpp.
2024-06-01 11:25:58 +02:00
Kawe Mazidjatari
b26ed2f746 Engine: implement encryption for RCON protocol
RCON lacked encryption, added AES-CTR encryption on RCON frames. Slightly adjusted protocol to take this into account (sending nonces, encrypted data itself, etc).
2024-06-01 11:24:47 +02:00
Kawe Mazidjatari
3e281d785c Merge branch 'indev' into launcher_rework 2024-06-01 11:13:27 +02:00
Kawe Mazidjatari
b2442164a7 Tier2: check initialization state before init/shutdown 2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
d3f5c27492 Tier2: fix websocket bug
CWebSocket::ConnContext_s::webSocket can be null, added a check.
2024-04-05 18:35:06 +02:00
Kawe Mazidjatari
d7478d3228 Tier2: WebSocket system improvements
Naming improvements, additional new comments/documentation and a few assertions. No logic has been changed.
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
e48c9f58ba Tier2: only enforce retry timer on (state == CS_RETRY)
Fixes a bug where the initial connect is only initiated after lastQueryTime + params.retryTime seconds.
2024-04-05 18:33:09 +02:00
Kawe Mazidjatari
e02f8f36fe Tier2: create modular WebSocket system
This code was actually part of the LiveAPI system, but there were many opportunities to make this particular code modular, so it has been decoupled and moved to Tier2. The LiveAPI system will soon use this class instead. The implementation has also been improved by adding dedicated routines for updating socket parameters, disconnecting/reconnecting and destroying sockets.

This commit also removes legacy workaround code in UtlVector which was used for before we had early enough access to the game's memalloc singleton. This code was no longer used.

This commit also implements the CUtlStringList class, which is now used for the new websocket class to split each socket connection up by a comma delimiter.
2024-04-05 18:31:58 +02:00
Kawe Mazidjatari
b2ce189ba1 Tools: rename NETCONSOLE define to _TOOLS
Rename since this would actually be used for all tools. Also moved 'plat_time.cpp' to tier0 so anything could compile it.
2024-04-05 17:35:10 +02:00
Kawe Mazidjatari
633292a820 Add comprehensive error logging for downloads and fix CPU in progress callback
The game will now not be installed if the download fails (this should've never happened in the first place). The CPU usage fix should also fix download speed throttling.
2023-10-23 00:08:25 +02: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
ddfe027677 Pass by reference
CConnectedNetConsoleData was allocated and deallocated manually, but std::vector is able to do it on its own. The vector type has been swapped out with CUtlVector as this removed the need of having to cast size types to a 32bit int to make it more compatible with the other sdk/engine types without throwing compiler warnings.
2023-08-04 10:48:22 +02:00
Kawe Mazidjatari
8e8b2ace38 Add cURL parameter to enable 'CURLOPT_FOLLOWLOCATION'
Option to allow following redirects.
2023-08-01 02:20:53 +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
7ea51dda8a Set an user agent
Some end points require it.
2023-07-26 20:34:02 +02:00
Kawe Mazidjatari
ac0fdf2953 Fix unused parameter
Should be used as the write function pointer, this was overseen in commit '31d92b43'.
2023-07-26 20:28:55 +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
21f64bc572 Adjust logging contexts
Adjust the context properly, some were wrong (e.g. 'ENGINE' in 'COMMON' code).
2023-07-22 21:14:04 +02:00
Kawe Mazidjatari
83d7f0b9f4 Light code cleanup
- Use game's filesystem in 'Mod_GetAllInstalledMaps'.
- Reorder parameters of 'AddFilesToList', and add option to override path separator.
2023-07-15 16:24:01 +02:00
Kawe Mazidjatari
4e8b27a1e9 Allow overriding path separator to list generated by 'RecursiveFindFilesMatchingName' 2023-07-09 20:05:47 +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
b886014abd Fix typo 2023-05-31 23:58:24 +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
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
d809a9f633 Use PCH generated from VPC globally
This reduced output code size with 40KiB, improved compile times and appeared to improve runtime performance as well.
2023-05-14 02:10:17 +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
rexx
fc16e61deb allow AddFilestoList to search without extension 2023-05-08 16:12:37 +01:00
Kawe Mazidjatari
966b94c4a0 Add filesystem utilities
Filesystem utilities that reduce duplicate code.
2023-05-06 21:56:27 +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
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
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
Kawe Mazidjatari
2caede5099 Add asserts in CSocketCreator 2023-04-16 15:51:16 +02:00
Kawe Mazidjatari
3882b64b91 Fixed several bugs in socket creator class
* Fixed 'connect' socket bug preventing connection to IPv4 addresses, by making the method used by the listen socket and connect socket configurator shared (dual stack was disabled on connect, but not on listen).
* Removed extraneous member from the 'CSocketCreator' class, this member was a copy of the 'netadr_t' input, but nothing ever was done with it.
2023-04-16 00:28:33 +02:00
Kawe Mazidjatari
53e2ddb122 Fix compiler warning caused by signed/unsigned mismatch 2023-04-10 23:45:51 +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
9f428f1567 Move tier0 lib headers to public
This commit does not change any logic or behavior of the code.
2023-04-06 23:50:48 +02:00
Kawe Mazidjatari
a1f7cc9a0d Make code compatible with older C++ versions
Made compatible with earlier C++ versions without having verbose compiler warnings.
2023-04-03 01:41:46 +02:00
Kawe Mazidjatari
0c5a24152e /W4: Fix name shadowing warnings
Parameter 'hostname' shadows global cvar 'hostname'.
2023-04-02 17:40:15 +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
7de717d47c /W4: Use 'constexpr' to evaluate branch at compile time
Fixes many compiler warnings.
2023-04-02 11:19:23 +02:00
Kawe Mazidjatari
b3621ba53a Add cvar 'curl_timeout'
New cvar for setting the curl timeout determined in function 'CURLInitRequest'.
2023-03-15 21:33:16 +01:00
Kawe Mazidjatari
c58d8f646a CSocketCreator: add getter for authorized sockets
Add method for obtaining the amount of authorized sockets.
2023-03-13 20:39:49 +01:00
Kawe Mazidjatari
dcf6d12ae1 Fix memory leak in Curl util code
'curl_slist' pointer should be passed in as reference, as its destroyed elsewhere.
2023-02-09 22:56:13 +01:00
Kawe Mazidjatari
66f31916d1 Pylon logic imporvements
* Removed duplicate json parsing that was part of a PR that required a small refactor.
* Only check if response buffer is empty when we are going to parse the error message (this helps finding bugs in master server, since failure to parse has an exception handler).
* Log private server token and error messages to dedicated server console.
2023-02-04 19:18:18 +01:00
Kawe Mazidjatari
ca9143dde9 Add curl cvars for debugging 2023-01-30 00:04:11 +01:00