Commit Graph

42 Commits

Author SHA1 Message Date
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
Michael Lutz 178249e7cc Codechange: Saveload macros for entries with a custom table name. 2023-02-26 21:41:24 +01:00
Rubidium ede3f79475 Codechange: use the name string in SaveLoad for the name of the Setting as well 2021-07-09 22:53:30 +02:00
Patric Stout 1ed2405907 Cleanup: remove SLE_NULL and friends
We no longer need them. If you want to remove a field .. just
remove it! Because of the headers in the savegame, on loading,
it will do the right thing and skip the field.

Do remember to bump the savegame version, as otherwise older
clients can still load the game, but will reset the field you
have removed .. that might be unintentially.
2021-07-02 22:21:58 +02:00
Patric Stout 7dd5fd6ed4 Feature: framework to make savegames self-descriptive
We won't be able to make it fully self-descriptive (looking at you
MAP-chunks), but anything else can. With this framework, we can
add headers for each chunk explaining how each chunk looks like
in detail.

They also will all be tables, making it a lot easier to read in
external tooling, and opening the way to consider a database
(like SQLite) to use as savegame format.

Lastly, with the headers in the savegame, you can freely add
fields without needing a savegame version bump; older versions
of OpenTTD will simply ignore the new field. This also means
we can remove all the SLE_CONDNULL, as they are irrelevant.

The next few commits will start using this framework.
2021-07-02 22:21:58 +02:00
rubidium42 98e653dacc Fix #9386: compilers failing to compile with LTO by using variants instead of new + unique_ptr
With std::variant all memory can be figured out at compile time, so the compiler needs to keep track of fewer elements. It also saves out a unique_ptr and its memory management, over a slight impact for resolving a setting.
2021-06-26 20:28:34 +02:00
Patric Stout 648ee88a02 Codechange: merge guiflags and flags in settings .ini files
It was rather confusing which one was for what, especially as some
SaveLoad flags were settings-only. Clean up this mess a bit by
having only Setting flags.
2021-06-06 21:45:01 +02:00
rubidium42 08308d808c Codechange: use separate pre and post callbacks for int settings 2021-05-29 10:07:30 +02:00
rubidium42 e2f5d9e561 Codechange: use separate pre and post callbacks for string settings 2021-05-29 10:07:30 +02:00
rubidium42 86c9ef8134 Codechange: remove SettingDescType in lieu of the actual classes 2021-05-27 18:49:43 +02:00
rubidium42 e666a962b1 Codechange: let OneOfMany and ManyOfMany be their own classes as well 2021-05-27 18:49:43 +02:00
rubidium42 860003458f Codechange: make BoolSettingDesc its own sub class 2021-05-27 18:49:43 +02:00
rubidium42 d8125fa46e Codechange: make sub classes of SettingDesc for the different types of settings 2021-05-27 18:49:43 +02:00
rubidium42 91b3d697c5 Codechange: make SettingDesc an instance in the setting table to allow for sub classes 2021-05-27 18:49:43 +02:00
rubidium42 3bb6ce8827 Codechange: use initializer_lists for the settings tables
Not using vectors as those require copying from the initializer list and that
makes unique_ptrs to the actual SettingDesc objects later impossible.
2021-05-27 18:49:43 +02:00
rubidium42 ac99a38175 Cleanup: remove and/or fix some confusing comments
The comments for SettingDescType; it is a byte, so not 4 bytes and since it is not a flag there are about 250 other possibilities left instead of 9.
SettingGuiFlag is uint16 so has 2 bytes allocated.
SettingDescGlobVarList and related comments imply that global vars cannot be used elsewhere, but they are used for settings just fine. Even then the type is not used anywhere else but the definition of the table.
2021-05-27 18:49:43 +02:00
rubidium42 0f062b3882 Codechange: clean up C-string support from settings 2021-05-13 23:13:17 +02:00
rubidium42 2022e34824 Codechange: move locale settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 16437b7c0d Codechange: move client name in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 c73d64adf9 Codechange: move passwords in settings to std::string 2021-05-13 23:13:17 +02:00
rubidium42 b54d8a49fb Feature: allow non-ASCII currency separators 2021-04-27 19:41:51 +02:00
Michael Lutz 00c66e7096 Codechange: Allow early-load settings that are not misc settings. 2021-02-17 21:01:21 +01:00
Michael Lutz 7845434270 Codechange: Don't use cpp_offsetof in the save/load code.
Many of the member variables that are used in save/load are inside types
that are not standard layout types. Using pointer arithmetics to determine
addresses of members inside types that are not standard layout is generally
undefined behaviour. If we'd use C++17, it is conditionally supported, which means
each compiler may or may not support it. And even then using it for individual
array elements is syntactically not supported the the standard offsetof function.

Unfortunately, the trickery employed for saving linkgraph settings causes quite some
clutter in the settings ini files.
2021-02-13 20:08:53 +01:00
TechGeekNZ 012fea301d Cleanup: Add note explaining how settings.h is generated from source. 2020-06-05 08:38:40 +02:00
TechGeekNZ f246f8faef Cleanup: Fix typo in settings.h.preamble. 2020-06-05 08:38:40 +02:00
Michael Lutz a49fdb7ebb Codechange: Store base set related texts in std::strings. 2020-05-21 20:02:34 +02:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
JMcKiern 04f659e768 Fix: Some typos found using codespell 2019-09-29 21:27:32 +01:00
Charles Pigott 644f4c3547 Codechange: Set size of SettingGuiFlag & SettingDescType enums, and use them properly 2019-04-29 17:40:22 +01:00
peter1138 c0836bccef Codechange: NULL -> nullptr in settings files. 2019-04-11 13:00:55 +01:00
Charles Pigott 2aacddd412 Codechange: lengthof is not defined for runtime-length strings, use sizeof instead 2018-06-27 22:54:46 +02:00
matthijs 97decad061 (svn r24991) -Doc: Clarify comments regarding settings macros. 2013-02-14 11:06:01 +00:00
frosch 69a62452be (svn r24671) -Feature [FS#5355]: Add basic/advanced/expert filters to adv. settings GUI. (Eagle_rainbow) 2012-11-08 10:04:00 +00:00
alberth 1d58838a97 (svn r24234) -Add: Add help-string infrastructure to the ini files 2012-05-12 10:09:00 +00:00
frosch 615e435677 (svn r22522) -Fix (r22489): (size_t)(uint32)(-1) != (size_t)-1 2011-05-29 18:35:31 +00:00
alberth 9fe65f93fe (svn r22210) -Add: Add a variable for the value strings in the settings tables. 2011-03-06 15:51:44 +00:00
alberth 02bf850d95 (svn r22209) -Codechange: Move function declarations from settings.h.preamble to the ini file that uses it. 2011-03-06 10:35:40 +00:00
rubidium f90044d343 (svn r22202) -Codechange: make MusicFileSettings a proper citizen of the client settings 2011-03-05 18:00:48 +00:00
rubidium b8d3c42de2 (svn r22199) -Cleanup-ish: replace the shortcut macros for (gui)flags with their more clearly named (longer) constant names 2011-03-05 11:34:31 +00:00
rubidium e48967541a (svn r22198) -Codechange: make some constants name more explicit 2011-03-05 11:16:44 +00:00
rubidium 2636a4809b (svn r22197) -Cleanup: remove the distinction between conditional and non-conditional settings; with default from and to savegame versions all can be conditional. They previously were as well; the non-conditional ones were macros of the conditionals with to/from saveload versions hardcoded 2011-03-05 10:47:49 +00:00
alberth 7477f92029 (svn r22173) -Add: Add preamble and postamble files before and after the generated settings data. 2011-03-03 21:06:24 +00:00