85 Commits

Author SHA1 Message Date
Kawe Mazidjatari
d467989e7c Tier1: light cleanup on low level types
CCommand: use 'V_isdigit()' since that is faster, we don't need it to be locale aware.
CMemoryStack: move 'highest' var to string format directly to avoid compile warnings (unused loval variables) on more recent visual studio compilers when compiling the DLL in cert mode.
2024-04-05 18:01:22 +02:00
Kawe Mazidjatari
373b18ddb8 Tier1: use signed size types for buffer size field 2024-04-05 17:56:54 +02:00
Kawe Mazidjatari
a8312517f4 CCommand adjustments
Moved inlines to header; made ArgC return 32bit integer instead.
2024-04-05 16:34:30 +02:00
Kawe Mazidjatari
26c10dfd11 Restructure concommandbase classes
Move all classes deriving from ConCommandBase to a single file, and split out CCommand, CCvar, CCvarUtilities etc to their own files. This makes it possible to use CCommand and stuff in external tools without linker errors/warnings.
2023-08-04 14:32:06 +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
130f67dbe8 CCommand improvements
- Uncommented 'CCommand::Tokenize' and changed size types to 64bits. CUtlBuffer has been implemented so this code can be used.
- Removed extraneous string copy from 'CCommand::HasOnlyDigits', just iterate over the raw character pointer.
2023-06-27 22:06:47 +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
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
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
2607f024b9 Move ConVar to separate implementation file
Moved to 'tier1/cvar.h/cpp'.
2023-03-28 01:05:23 +02:00
Kawe Mazidjatari
9e7fbdca54 ConVar/ConCommand class refactor and bug fixes
* Refactored ConCommandBase, ConCommand and ConVar class to make them all virtual, so it could interface with the game's implementation.
* Properly initialize members for ConCommand and ConVar instead of just calling memset.
* Fixed bug in ConVar registration function causing the virtual base table pointer to point to the ConCommand implementation instead of the ConVar implementation.
2023-03-28 00:50:08 +02:00
Kawe Mazidjatari
98a01e0ae2 Add pattern for 'ConCommand::AutoCompleteSuggest'
Added pattern for 'ConCommand::AutoCompleteSuggest' (will be used for the console autocomplete instead as it supports the old and new callback system).
2023-03-17 00:15:43 +01:00
Kawe Mazidjatari
cac2c6a917 Make 'sig_getadr' a console command
Changed to hidden ConCommand.
2023-03-15 21:11:20 +01:00
Kawe Mazidjatari
9573cfa8cb Add usage string parameter for concommand
Add usage string for concommand and move usage to there.
2023-02-23 23:47:27 +01:00
Kawe Mazidjatari
3f2216337e Add completion for pak decompress
* Renamed 'rtech_decompress' to 'pak_decompress'.
* Added completion func for 'pak_decompress'.
2023-02-19 13:38:06 +01:00
Kawe Mazidjatari
1e0248a442 Fix command quota warning message
Fix command not getting logged properly when user exceeds quota.
2023-02-17 23:55:27 +01:00
Kawe Mazidjatari
1051b3a427 Also compile for client.dll
Mask it off for client.dll as well.
2023-02-08 22:57:14 +01:00
Kawe Mazidjatari
f6df34d68d Fix bug caused by recent addition of completion funcs
'map' and 'map_background' were removed from the array, and thus 'FCVAR_DEVELOPMENTONLY' wasn't masked off. As of this commit, its getting masked off along with 'FCVAR_SERVER_CAN_EXECUTE'.
2023-02-08 22:54:35 +01:00
Kawe Mazidjatari
e4df03c4f2 Add RPak completion callbacks
Add completion for 'pak_requestload' and 'pak_requestunload'.
2023-02-06 02:16:02 +01:00
Kawe Mazidjatari
836839e6a5 Add completion logic for 'give' command
* Implemented class 'CAutoCompleteFileList' (features engine's implementation for 'AutoCompletionFunc').
* Added completion callback for 'give' command.
2023-02-05 23:01:01 +01:00
Kawe Mazidjatari
ddba8cf9b8 Install more robust 'map' completion callback
This one will list all maps, as maps should have a vpk file to be loaded correctly due to the way rpak files are formatted internally to be loaded/parsed.
2023-02-05 21:13:03 +01:00
Kawe Mazidjatari
b51baee6cd Correct vtable name
First vtable in the hierarchy of ConVar is the base table.
2023-01-31 23:09:22 +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
Amos
68f197dcef Initial fake client (bot) implementation
New bots can be added using 'sv_addbot <name> <teamid>'.
2023-01-16 15:52:33 +01:00
rexx
3c3e1c46df Add pak_listtypes command 2022-12-22 21:44:38 +00:00
Kawe Mazidjatari
4ba88963ff Fix bugs and many compiler warnings
* Promoted size types in CUtlBuffer to int64.
* Fixed bug where CUtlBuffer::GetPtr returns a 64bit pointer that was promoted from a 32bit integral type.
* Use int64/size_t for anything strlen, pointer subtraction, etc..
* Removed invalid structure alignment declarations.
2022-11-24 15:41:52 +01:00
Kawe Mazidjatari
9c1efe20ad Remove ConVar and ConCommand singletons
Extraneous singletons.
2022-11-18 22:10:20 +01:00
Kawe Mazidjatari
32a158903f Rename 'cl_showconsole' and 'cl_showbrowser' to 'toggleconsole' and 'togglebrowser'
Suppress engine warnings due to missing commands (stripped for retail but still bound to key).
2022-11-10 15:36:04 +01:00
Kawe Mazidjatari
dc8ad3dd53 Log all mounted/unmounted VPK files
* Log all mounted/unmounted VPK files.
* Add command for unmounting a VPK file.
* Increased logging buffer size to 4096 for all loggers that weren't updated to this yet.
2022-11-06 12:21:21 +01:00
Kawe Mazidjatari
4bd164a535 NavMesh hot swap system improvements
* Check if server is active in command callback before attempting to hot swap.
* Hook 'v_Detour_LevelInit', and log NavMeshes that failed to load.
* Split free/destroy logic into separate function.
* Created constants for NavMesh and AI Network paths/extensions.
* Added performance profiler for hot swap logic in command callback.
* Renamed "navmesh_reload" to "navmesh_hotswap".
* "navmesh_hotswap" is now development only.
2022-11-03 17:12:22 +01:00
Kawe Mazidjatari
ba252c8e98 Implement logic for hot swapping NavMesh
The new command 'navmesh_reload' hot swaps the current NavMesh for all hulls in memory, with that of the 'new' files on the disk. The memory of the old NavMesh gets freed and destroyed.
2022-11-03 10:44:59 +01:00
Kawe Mazidjatari
44f2f87460 CConsole: heavy cleanup
* Move all default assignments to constructor.
* Rename cvar 'con_max_size_logvector' to 'con_max_lines'.
* Rename cvar 'con_max_size_history' to 'con_max_history'.
* Use array indexes instead of hardcoding context prefixes.
* Added netcon context prefix to help legend.
* Added public method to obtain history as string vector.
* Added public method to clear history.
* Internal CConsole::AddLog no longer locks the mutex.
* CConsole::LoadFlagIcons accesses resource vector by reference.
* Implemented "HELP", "HISTORY" and "CLEAR" as real console commands: "con_help", "con_history", "con_clearlines".
* Added a new command "con_clearhistory" (clears the dev console submission history).
2022-10-20 12:29:50 +02:00
Kawe Mazidjatari
d113774a6d Console improvements and new command
* Commented "ImGui::SetItemDefaultFocus()", this seems to somewhat fix the issue where the input field does not claim focus on console invocation.
* Added command "con_removeline" (removes lines from start to end index).
2022-10-20 12:29:49 +02:00
Kawe Mazidjatari
2fa2fd1433 Make 'pak_listpaks' FCVAR_RELEASE 2022-09-24 22:44:57 +02:00
Kawe Mazidjatari
23eba316df Cmd: add rate limit logic for 'Cmd_ForwardToServer'
If the client happens to exceed the quota by accident, the client will not be disconnected. This is a quality of life change. Client could still increase cl_quota_stringCmdsPerSecond to allow more submissions per second, or disabling the throttle entirely by setting cl_quota_stringCmdsPerSecond to 0.
2022-09-22 21:37:58 +02:00
Kawe Mazidjatari
34b779735e Don't allow server to execute 'disconnect' on client
Removed extraneous 'FCVAR_SERVER_CAN_EXECUTE' flag. We disconnect clients using 'CClient::Disconnect(..)', relying on the client is useless without an anti-cheat and anti-tamper. Client can still use this to disconnect on its own though.

'migrateme' seemed useless as well, removed 'FCVAR_SERVER_CAN_EXECUTE'.

This makes all 'FCVAR_SERVER_CAN_EXECUTE' require 'FCVAR_DEVELOPMENTONLY' to be stripped, in order to execute without the '-devsdk' parameter (development launch arg),
2022-09-17 20:43:16 +02:00
Kawe Mazidjatari
9c9843a0fc Centralize kick/ban wrappers to CBanSystem and add new server functions for kicking/banning players 2022-09-15 23:13:37 +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
34a06147d7 Fix spelling errors
Overall spelling improvements and cleanup..
2022-09-09 19:47:31 +02:00
Kawe Mazidjatari
570f6419df Add 'reload_playlists' concommand.
Allows reloading the playlists file from the console or the dedicated server.
2022-09-08 01:02:22 +02:00
Kawe Mazidjatari
954165c2ea ConCommand: use FCVAR_GAMEDLL flags for several server commands.
These could only be ran if the server is running, and allows for running them as ServerCommand.
2022-09-05 23:02:54 +02:00
Kawe Mazidjatari
83ce041b65 Fix client.dll compile errors. 2022-09-01 01:32:32 +02:00
Kawe Mazidjatari
afad5b92ec Rename 'OriginID' to 'NucleusID'
Nucleus ID is the official internal term for the platform user id used by the OriginSDK.
2022-08-29 15:59:12 +02:00
Kawe Mazidjatari
ca0172ed1f Add cvar for RTech debugging and removed dev flag from 'launchplaylist' 2022-08-22 21:15:46 +02:00
Kawe Mazidjatari
2c7aaf531f Host_Changelevel_f rebuild 2022-08-22 03:53:38 +02:00
Kawe Mazidjatari
bd7a637286 Update command flags 2022-08-19 23:49:20 +02:00
Marvin D
b8cd006687 Update pszMaskedBases[] 2022-08-19 22:50:39 +02:00
Kawe Mazidjatari
5548a74d59 Major cleanup (see description)
* Fix all compiler error for GameSDK on S0 and S1.
* Remove some unused patterns and globals (launch performance gains of 100ms).
* Remove most duplicate patterns.
* Relocate globals from engine to a more appropriate location.
* Renamed some unknown vars to a more appropriate name (most of these where obtained a while back, but as we reversed more parts of the engine, some of these vars become known).
* Renamed some vars to fit the naming convention used in the SDK.
* Fixed pattern debug logging using the wrong pointer, thus displaying the wrong address.
2022-08-18 02:15:23 +02:00
Kawe Mazidjatari
8bf6dac3d8 Code improvements
* Use GetVirtualMethodTable for VFTable pointers.
* Pack CClientState to 4 bytes (this aligns it properly in memory).
* Use CClientState members directly for setting m_bRestrictServerCommands/m_bRestrictClientCommands.
2022-08-15 22:29:16 +02:00
Kawe Mazidjatari
8068bcf176 Mask off FCVAR_DEVELOPMENTONLY from essential commands
Only mask FCVAR_DEVELOPMENTONLY off from essential commands if launched in retail mode (this hardens security and increases performance).
2022-08-13 21:38:44 +02:00