ddnet/src/game
Robert Müller 159ddf5534 Refactor config manager, move config variable handling
Move all code for handling of config variables from console to config manager. The console no longer depends on the config manager, instead the config manager now depends on the console.

Add `struct`s to manage config variables of different types (int, color and string). The config manager now keeps a list of all config variables, so usage of the preprocessor can be avoided except for code to initially create all config variables. Additionally, a separate list of just the game config variables (config variables with `CFGFLAG_GAME`) is kept to optimize the `ResetGameSettings` function, as this function is called whenever connecting to a server and should be fast. Previously, this function was even less efficient because it preformed a linear search for every individual game config variable to find the respective command data.

Move console commands that opperate only on config variables (`reset`, `toggle` and `+toggle`) to config manager. Ensure that these commands only opperate on the desired config variables (client or server, respectively) by checking `IConsole::FlagMask`.

Add `IConfigManager::SetReadOnly` function to set/unset config variables as read-only instead of manually overriding the command handlers for the `sv_rescue` and `sv_test_cmds` config variables. This also fixes that read-only config variables could still be changed by using the `reset` command. A console message is now printed when trying to change a read-only config variable. Removing the special handling for these two config variables is additionally useful so the console does not need to keep a pointer to config values and manager.

Use a `CHeap` for the config variables, their help texts and the previous values of string config variables to avoid many separate allocations as well usage of static variables. Also use the heap to store the unknown commands instead of using `std::string`s.

Properly trigger command chain when resetting config variables with the `reset` command and when resetting game settings on map loading. Closes #7461.

Format default value for color variables as RGB/RGBA hex with dollar sign prefix. Closes #5523.

Add log message when using `reset` with a variable that does not exist. Use `log_error` instead of `dbg_msg` when saving config file fails.

Support unlimited number of config save callbacks instead of at most 16. The code also becomes more readable by using an `std::vector` instead of a fixed-size array and a separate num variable.

Consistently name `MACRO_CONFIG_*` parameters when declaring the macros.

Add `IConsole::CMDLINE_LENGTH` constant to represent the maximum length of the console input and thereby reduce usage of magic numbers for buffer sizes.
2023-11-30 20:26:00 +01:00
..
client Refactor config manager, move config variable handling 2023-11-30 20:26:00 +01:00
editor Hide "Allow unused" button when not using "DDNet" entities. 2023-11-24 16:55:36 +01:00
server Refactor config manager, move config variable handling 2023-11-30 20:26:00 +01:00
alloc.h Move alloc.h to game/ and use it in client/prediction/entity.h 2023-09-15 18:04:29 +03:00
collision.cpp Merge pull request #5398 from AssassinTee/feature/elasticity-tuning 2023-07-28 13:58:42 +00:00
collision.h Merge pull request #5398 from AssassinTee/feature/elasticity-tuning 2023-07-28 13:58:42 +00:00
ddracechat.h Add /lasttp 2023-09-21 21:02:55 +02:00
ddracecommands.h Add freeze/unfreeze testing commands 2023-11-01 17:26:29 +01:00
gamecore.cpp Revert the mess-chain #7247. Apply #7171 2023-11-22 18:34:42 +01:00
gamecore.h Replace 50 with SERVER_TICK_SPEED or TickSpeed() 2023-11-23 14:42:30 +01:00
layers.cpp Remove Parallax Zoom from map file 2023-10-29 23:43:19 +01:00
layers.h Remove Parallax Zoom from map file 2023-10-29 23:43:19 +01:00
localization.cpp Remove CLocConstString 2023-08-30 19:24:38 +02:00
localization.h Remove CLocConstString 2023-08-30 19:24:38 +02:00
mapbugs.cpp Remove obsolete clang-tidy NOLINT comments 2023-10-11 17:22:59 +02:00
mapbugs.h Remove code for CRC in most places, except where needed for net compat 2020-10-14 17:08:58 +02:00
mapbugs_list.h Revert "Add mapbug "stoppers-passthrough@ddnet.tw"" 2018-08-22 08:33:21 +02:00
mapitems.cpp Add IsSwitchTile(Flags|Number|Delay)Used functions 2023-04-26 19:04:56 +02:00
mapitems.h Fix client crash on maps with invalid image and sound indices 2023-10-29 17:55:20 +01:00
mapitems_ex.cpp Remove Parallax Zoom from map file 2023-10-29 23:43:19 +01:00
mapitems_ex.h Remove Parallax Zoom from map file 2023-10-29 23:43:19 +01:00
mapitems_ex_types.h Remove Parallax Zoom from map file 2023-10-29 23:43:19 +01:00
prng.cpp Huge variable naming format 2022-07-08 18:01:29 +02:00
prng.h Replace all usages of C standard headers with C++ headers 2023-03-01 19:26:51 +01:00
teamscore.cpp Remove unnecessary include in protocol, move definitions to cpp file 2023-01-03 14:10:58 +01:00
teamscore.h Remove unnecessary include in protocol, move definitions to cpp file 2023-01-03 14:10:58 +01:00
tuning.h Replace 50 with SERVER_TICK_SPEED or TickSpeed() 2023-11-23 14:42:30 +01:00
version.h Version 17.4 2023-11-19 00:50:29 +01:00
voting.h Run clang-format 2020-09-26 21:50:15 +02:00