330 Commits

Author SHA1 Message Date
Kawe Mazidjatari
27f9d6b110 SQVM logging improvements
* Allow setting logging level in retail mode.
* Also color log on error to the in-game console overlays when log level < 2.
2022-08-14 15:20:28 +02:00
Kawe Mazidjatari
9f7d4f57d3 CCVarIteratorInternal cleanup
* Improve readability.
* Free allocated iterator memory.
* Enforce FCVAR_HIDDEN ConVar's in ImGui console (there are only 17 ConVar's marked 'hidden', and most of these are stryder/platform related stuff. This is usefull for if we ever wish to create a hidden cvar).
2022-08-14 02:51:15 +02:00
Kawe Mazidjatari
61dbda67f7 Address reported issues
Addressed:
* 'Expression: vector subscript out of range' (we only ever ensured capacity upon construction).
* Compiler error as AssertMsg1 is unimplemented, used Assert instead.
2022-08-14 00:48:29 +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
Kawe Mazidjatari
515487c63a Changed behavior of ConCommandBase::IsFlagSet (read description)
This commit breaks the indev branch for the time being (this will be solved very soon).
We no longer mask off dev flags from every commandbase, we only mask them off from the essential ones (map, connect, give, etc..), unless the SDK is launched as dev, then we mask everything off like usual, but this time at initialization and not whenever we encounter a var with this flag.
2022-08-13 20:21:32 +02:00
Kawe Mazidjatari
fad1a092e4 More CCvar reversing
Still work-in-progress
2022-08-13 19:41:45 +02:00
Kawe Mazidjatari
b18f9148e4 Renames
* Rename FCVAR_ARCHIVE_GAMECONSOLE to FCVAR_ARCHIVE_PLAYERPROFILE.
* Rename CONVARFLAG(UNLOGGED, "log") to CONVARFLAG(UNLOGGED, "ulog").
2022-08-13 15:35:38 +02:00
Kawe Mazidjatari
8740c7261a Add ARCHIVE_GAMECONSOLE to g_ConVarFlags 2022-08-13 13:58:27 +02:00
Kawe Mazidjatari
e4eb6d278f Hook up 'convar_findByFlags' command callback
In-engine implementation has logging stripped.
2022-08-13 13:06:30 +02:00
Kawe Mazidjatari
f08fbc8745 Hook up 'help' command callback
In-engine implementation has logging stripped.
2022-08-13 12:57:52 +02:00
Kawe Mazidjatari
dbdfdc2b3a Only log changed convars for 'convar_differences' 2022-08-13 12:53:08 +02:00
Kawe Mazidjatari
4551f6d494 Implement convar_list and convar_differences
Also added more CCvarUtilities methods which are yet to be implemented.
2022-08-13 12:39:57 +02:00
Kawe Mazidjatari
4cc0d085d4 Add generichash, utlfixedmemory and utlrbtree
Generichash for future reversing of CCvar.
2022-08-12 15:53:58 +02:00
Kawe Mazidjatari
3b160b6ac6 Free memory properly 2022-08-12 15:45:49 +02:00
Kawe Mazidjatari
88b3336758 Many small code improvements and optimizations
* Use c++ methods as much as possible.
* Use enum types for accessing NavMesh objects from array.
* Use size_t for for loops when testing against size types.
* Don't compute strlen twice of more on the same string.
* Don't use unnecessary c string casts if there is a method with a std::string overload.
* Don't create string objects from string pointers if we could use them directly.
* Don't initialize RCON password twice on each change, and don't set if the new password equals the old.
2022-08-11 11:07:45 +02:00
Kawe Mazidjatari
f9ea1b0f65 Rename bits.h/.cpp to fbits.h/.cpp (floatbits) 2022-08-09 18:07:32 +02:00
Kawe Mazidjatari
329621c6ad Move all public headers into root of 'public' 2022-08-09 17:18:07 +02:00
Kawe Mazidjatari
e92b5d1300 General cleanup
Use c++ methods, remove unnecessary casts, unnecessary use of auto, etc..
2022-08-09 15:19:12 +02:00
Kawe Mazidjatari
0b4eb06dd2 Use compare method instead of strcmp on std::string 2022-08-09 14:01:29 +02:00
Kawe Mazidjatari
8c6ee8a834 Remove 'm' prefix from dll globals
Large commit.
2022-08-09 03:02:00 +02:00
Kawe Mazidjatari
9d06a02614 General cleanup
* Use Cbuf functions for executing commands in ImGui panels.
* Use const qualifiers for all vftable indexes.
2022-08-09 02:35:00 +02:00
Kawe Mazidjatari
f97b347d88 Fix ConVar's and ConCommand's creation memory leak
Using the 'new' keyword and then assigning *this to *pNewConVar will lead to having 2 copies of the same constructed data, and one being used in the SDK whilst the other one being used by the engine.
We unfortunately cannot write the code exactly like the engine, as we hook the engine and dependent heavily on its global memalloc singleton.
This commit fixes the memory leak and allows the engine to free the memory as well whenever it wants to.
2022-08-08 01:40:28 +02:00
Kawe Mazidjatari
df81a1e277 Update rui_drawEnable help text 2022-08-04 17:56:54 +02:00
Kawe Mazidjatari
0cad187587 Fix client.dll compile errors 2022-08-04 17:52:34 +02:00
Kawe Mazidjatari
8f513a519f Properly implement ConCommand callbacks
COMMAND_COMPLETION_MAXITEMS and COMMAND_COMPLETION_ITEM_LENGTH are confirmed to be 128 (original code is 64).
New register func sets the callback bit fields accordingly (no longer hardcoded).
2022-08-04 17:37:30 +02:00
Kawe Mazidjatari
ea5f17b4ca Light cleanup
* Moved ConVar usage text that where part of the help string to the usage string parameter.
* Flagged ConVar 'bhit_abs_origin' as FCVAR_DEVELOPMENTONLY | FCVAR_REPLICATED.
* Flagged ConCommand 'bhit' as FCVAR_DEVELOPMENTONLY | FCVAR_GAMEDLL.
* Check 'bhit_enable' before running the 'bhit' command callback.
* Fixed spelling in a few area's.
2022-08-04 16:34:23 +02:00
Kawe Mazidjatari
68b3185a41 Use ssize_t for size types in CUtlMemory 2022-08-04 11:51:38 +02:00
Kawe Mazidjatari
6d92fdf15f Use game's global malloc singleton for allocating/reallocating memory in CUtlMemory
This ensures anything we create in the SDK will be usable within the game engine (Realloc, Free, GetSize, etc..), as we share the global singleton.
2022-08-04 11:33:40 +02:00
Kawe Mazidjatari
238e145818 Implement ConVar change callbacks
CUtlVector containing callbacks (you can have several callbacks for each ConVar).

also, in 'ConVar::InternalSetValue' Valve and Respawn run V_atod (atof) on function param 'pszValue', but they also check if input param 'pszValue' is a nullptr (which in this case, 'pszNewValue' gets set to an empty string), but yet they deref 'pszValue' (nullptr or not) in 'SetColorFromString' and V_atod, is this correct behavior?

For now I swapped these out with 'pszNewValue' for the very rare event the string happens to be nullptr.
2022-08-04 11:06:56 +02:00
Kawe Mazidjatari
babbcbe6d5 Add CStdMemAlloc::GetSize() to SDK
Returns the size of the buffer allocated with MemAllocSingleton()->Alloc() etc.
2022-08-04 02:02:09 +02:00
Kawe Mazidjatari
20d1fabd0c Implement CUtlMemory, CUtlBlockMemory and CUtlVector
CUtlMemory has been modified to fit the size of the in-engine structure.
The new types seem to be either int64 or unsigned (size_t?).
2022-08-04 01:28:07 +02:00
Kawe Mazidjatari
0fe554b3d1 Fix crash cases when setting ConVar string using SetValue
Added IsMaterialThreadSetAllowed and QueueMaterialThreadSetValue checks.
2022-08-04 00:21:48 +02:00
Kawe Mazidjatari
19d057fc5e Add 'bhit_enable' ConVar and only run bhit callback if set 2022-08-03 18:27:25 +02:00
Kawe Mazidjatari
5795d15c83 Netconsole and ConVar improvements
Implemented StringSplit() (split string with a delimiter, and stop splitting after either the last delimiter has been reached, or nMax, so when nMax is 2, then 'SET mat_sky_color 255 255 0 255' gets split into: "SET" "mat_sky_color" "255 255 0 255").

Netconsole now sends ConVar's/ConCommands and values separately with use of StringSplit.

ConVar now uses internal ChangeStringValue (this runs the callback).
2022-07-31 17:07:35 +02:00
Kawe Mazidjatari
7730d72416 Use proper flags for 'bhit' 2022-07-30 00:57:32 +02:00
Kawe Mazidjatari
068e50ea40 'bhit' command implementation
The command is only implemented on the dedicated server or debug servers, so i cannot tell for sure what exactly 'bhit' does. But its either some form of telemetry or debug.
The command sends the player index that got hit on the prediction engine, the bullet fire origin and the angles relative to the target that got hit.
For now the command draws the bullet trajectory if it hits a player.
This commit also fixes the 'Unknown command: bhit' message.
2022-07-30 00:54:33 +02:00
Kawe Mazidjatari
55c5048951 Fix compile error 2022-07-30 00:43:40 +02:00
Kawe Mazidjatari
9556b05209 CCommand improvements
Add constructor and work-in-progress tokenizer.
2022-07-29 17:30:05 +02:00
Kawe Mazidjatari
25e2581f2b Implement fully mapped out ConCommandBase VFTable interface class 2022-07-25 20:06:06 +02:00
Kawe Mazidjatari
19d264ec11 Implement RCON_PasswordChanged_f and ConVar improvements
* Changing RCON passwords on the server now closes all connections and re-initializes the system.
* Fully mapped out VFTable interface for IConVar* (used for ConVar callbacks, see callback.cpp).
2022-07-25 19:35:08 +02:00
Kawe Mazidjatari
086489a000 AIN/NavMesh debug draw improvements
* Move AIN/NavMesh debug draw to ai_utility_shared.cpp.
* Use shift index + range for AIN debug draw.
* Added cvar for determining max distance between camera and tile (anything outside this range doesn't get draw).
2022-07-25 16:39:07 +02:00
Kawe Mazidjatari
65cbdb5465 Use ConVar::ChangeStringValue() instead for purging hostnames
Now possible without crashing with the new memalloc singleton.
2022-07-22 17:18:54 +02:00
Kawe Mazidjatari
c405c23934 Implement memory allocation singleton wrappers
* Pointer to g_pMemAllocSingleton
* New wrapper for returning the singleton, and creating one if not yet initialized (game shares the same pointer, and is aware of its creation).
2022-07-22 16:34:10 +02:00
Kawe Mazidjatari
8198866f6f Add tile range for NavMesh debug draw
New cvar 'navmesh_debug_tile_range' (tile shift index to this cvar gets drawn).
2022-07-22 12:44:33 +02:00
rexx
2e3b4205c0 remove streamoverlay hook 2022-07-21 17:05:19 +01:00
Kawe Mazidjatari
b3ed5d4052 Fix client.dll compile errors
Stripped more server only stuff from client.dll.
2022-07-21 15:13:48 +02:00
Kawe Mazidjatari
9758f988ec Add NavMesh poly debug overlay
Can be toggled and shifted through tiles using 'navmesh_draw_polys'.
2022-07-21 14:48:50 +02:00
Kawe Mazidjatari
c850d52d1b Add NavMesh poly bounds debug overlay 2022-07-21 02:21:59 +02:00
Kawe Mazidjatari
e21ae20f4a Add NavMesh tile portal debug overlay
navmesh_draw_portal > -1 enables the overlay, with this cvar you can also shift through tiles.
navmesh_debug_type [0 - 4] selects the NavMesh (small, med_short, medium, large, extra_large).
2022-07-21 01:24:07 +02:00
rexx
cb4e422724 reimplement stream overlay drawing 2022-07-20 22:50:55 +01:00