Commit graph

20 commits

Author SHA1 Message Date
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
Robert Müller 5aa9003180 Remove unused ver parameter of MACRO_INTERFACE 2023-11-28 21:46:03 +01:00
furo 6599b7e14b Save unknown commands from settings_ddnet.cfg 2023-11-11 19:09:13 +01:00
def d787a4832b Implement "reset" command
to reset specific config to default value
2021-12-27 01:13:11 +01:00
Alexander Akulich c2f276cee1 Port CConfig API from the upstream (0.7.5)
The old (g_Config) API is kept to not break the stuff.

See commits:
    de5859b371
    78076761eb
2021-01-10 17:10:19 +03:00
Dennis Felsing 2ba9535529 Use warnings popups for some io failures 2020-10-02 16:06:16 +02:00
timgame 2874e18ce0 dont restore empty config values at start 2015-11-16 20:31:56 +01:00
oy 06115dd49d added "Whitespace and line Endings cleanup" by GreYFoX 2011-04-13 20:37:12 +02:00
Sworddragon fc9211c777 Updated copyrights 2010-11-20 21:26:06 +01:00
oy 1cde96ef79 restore empty strings in the config to their defaults on startup 2010-08-11 00:31:42 +02:00
Magnus Auvinen 72c06a2589 copied refactor to trunk 2010-05-29 07:25:38 +00:00
Magnus Auvinen a2566b3ebd cleaned up code structure a bit 2007-12-15 10:24:49 +00:00
Magnus Auvinen a0e5181e42 added license info 2007-11-25 19:42:40 +00:00
Joel de Vahl f6216e9a3a Fixed win32 compile. 2007-10-09 09:04:57 +00:00
Magnus Auvinen 8b3c16e615 major engine cleanup. dependency on baselib removed. engine is now C code (not ansi tho). some other cruft removed aswell 2007-08-22 07:52:33 +00:00
Magnus Auvinen 501558f881 increased vb size. added support for settings config variables from the chat line 2007-07-27 00:03:28 +00:00
Jakob Fries f18df70e53 2007-06-01 12:24:13 +00:00
Jakob Fries 187134010d config stuff 2007-06-01 12:02:27 +00:00
Jakob Fries 4e5fa4db0b 2007-06-01 11:17:10 +00:00
Jakob Fries 8a66e11280 2007-06-01 11:12:48 +00:00
Renamed from src/engine/config/config.h (Browse further)