Commit Graph

2374 Commits (62afd94b47d7c48ef2045540be9a62ec63a4827b)

Author SHA1 Message Date
Jonathan G Rennison 87948d8029 Thread: Adjust checks for whether current thread is the game thread 3 years ago
Rubidium 281a65b3e1 Cleanup: simplify some boolean expressions 3 years ago
Rubidium 357af686dc Cleanup: use true/false instead of 1/0 where applicable 3 years ago
Patric Stout 8e91527251 Codechange: mark chunks that are not stored as CH_READONLY
This makes it easier to spot chunks that have a save_proc that
is a nullptr, but also prevents confusion, where it looks like
the CH_ type of a chunk has influence on how it is being read.
It is not, it is only used for saving.
3 years ago
Patric Stout 4c4b55ecbd Change: rework GLOG chunk to be more like the rest
Basically it is very similar to Vehicles, where there first is
a type field, followed by data of that type. So this commit makes
it looks like how Vehicles solved that.
This removes a lot of custom "keeping track of length" stuff.
3 years ago
Patric Stout 88edfd4ef1 Change: rework several CH_RIFF chunks to use CH_ARRAY instead
This adds two byte extra to those chunks, and might feel a bit
silly at first. But in later changes we will prefix CH_ARRAY with
a table header, and then this change shines.

Without this, we could still add headers to these chunks, but any
external reader wouldn't know if the CH_RIFF has them or not. This
way is much more practical, as they are now more like any other
chunk.
3 years ago
Patric Stout b9ab9e4d05 Codechange: add the ability to save/load a std::vector
std::vector<bool> is not possible, as .. that is a nice special
case in C++.

This new type will be used in next commit.
3 years ago
Patric Stout 97b94bdc9a Change: prefix SL_ARR with the length of the array
This means that during loading we can validate that what is saved
is also that what is expected. Additionally, this makes all list
types similar to how they are stored on disk:
First a gamma to indicate length, followed by the data.
The size still depends on the type.
3 years ago
Patric Stout f67af5cbe5 Codechange: make it more obvious SlArray supports SLE_VAR_NULL
In the end, the code was already doing the right thing, but a few
functions deep, and not really obvious. When validating what objects
can handle SLE_VAR_NULL, it is nicer to just have this obvious.
3 years ago
Patric Stout d5cda58158 Codechange: use SL_NULL if you want to store null-bytes or load to nothing
Using SL_ARR for this gives us a bit of trouble later on, where we
add a length-field to SL_ARR. This of course is not the intention
of SLE_CONDNULL. So better seperate it.
3 years ago
Patric Stout 0d2e3437e3 Change: switch SL_DEQUE and SL_REFLIST length field to a gamma
The current SaveLoad is a bit inconsistent how long a length field
is. Sometimes it is a 32bit, sometimes a gamma. Make it consistent
across the board by making them all gammas.
3 years ago
Patric Stout 75e7451151 Change: indicate in the savegame if a SL_STRUCT contains any data
This helps external tooling to understand if a SL_STRUCT should
be skipped when reading. Basically, this transforms an SL_STRUCT
into a SL_STRUCTLIST with either 0 or 1 length.
3 years ago
Patric Stout a146bcfe93 Change: store length of SL_STRUCTLIST in the savegame
This wasn't consistently done, and often variables were used that
were read by an earlier blob. By moving it next to the struct
itself, the code becomes a bit more self-contained and easier to
read.

Additionally, this allows for external tooling to know how many
structs to expect, instead of having to know where to find the
length-field or a hard-coded value that can change at any moment.
3 years ago
Patric Stout 7b135a8269 Codechange: use SLE_STRUCT(LIST) for Linkgraph chunks 3 years ago
Patric Stout 5cd0c65787 Codechange: move Save/Load functions of same chunk next to each other 3 years ago
Patric Stout af3aba7a88 Codechange: use SLE_STRUCT(LIST) for GameScript chunks 3 years ago
Patric Stout aa02bf27f6 Codechange: use as much of STNN code for STNS as possible
There was a lot of code duplication for no real reason. Now with
SLEG_STRUCT support, we can just re-use the code, hopefully making
it easier for future-us to make changes to this, without breaking
everything for old games.
3 years ago
Patric Stout 0bdca02bdf Codechange: use SLE_STRUCT(LIST) for Station chunks 3 years ago
Patric Stout af43fc3d62 Codechange: use SLE_STRUCT(LIST) for Company chunks 3 years ago
Patric Stout 0bb1d2fa8e Codechange: use SLE_STRUCT(LIST) for Town chunks 3 years ago
Patric Stout 4e4720f217 Codechange: remove the special station/vehicle code from SaveLoad
With the new SLEG_STRUCT it is much easier to embed a struct
in a struct, where the sub-struct has limitations on when it is
being used.
This makes both the code easier to read (less magic) and avoids
the SaveLoad needing to know all these things about Stations
and Vehicles.
3 years ago
Patric Stout 4600d289b5 Codechange: ability to store structs and list of structs in savegames
The commits following this will use this new functionality.

Currently, a few places do this manually. This has as drawback that
the Save() and Load() code need to be in sync, and that any change
can result in (old) savegames no longer loading. In general, it is
annoying code to maintain.

By putting everything in a description table, and use that for
both Save() and Load(), it becomes easier to see what is going on,
and hopefully less likely for people to make mistakes.
3 years ago
Patric Stout 1e432fbd71
Fix 81062163: for (really) old games, station bus/truck station cache was not updated (#9366) 3 years ago
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 3 years ago
Jonathan G Rennison 1002c6d9d2 Fix various compiler warnings
See: #267
3 years ago
Tyler Trahan d09210e1c6 Feature: Configurable subsidy duration 3 years ago
Patric Stout 174952440a Codechange: rework CHTS-chunk save/load to be more like the others 3 years ago
Patric Stout 8f323855b1 Codechange: rename SL_LST to SL_REFLIST to highlight the "reference" part
You can easily mistake SlList / SL_LST to be a list of SL_VAR, but
it is a list of SL_REF. With this rename, it hopefully saves a few
people from "wtf?" moments.
3 years ago
Patric Stout aa6443d57a Codechange: refactor SlList to use SlStorageHelper 3 years ago
Patric Stout 23857af693 Codechange: refactor SlDequeueHelper to work with unsigned and be more generic
Future additions will start using it for std::list too.
3 years ago
Patric Stout a2147d437e Codechange: use wrappers to get Var[Mem|File]Type, instead of GB() 3 years ago
Patric Stout fba86f711f Codechange: move GetVariableAddress inside SlObjectMember
Also move it to static, as nobody else is using it.
3 years ago
Patric Stout f997eb6ca4
Fix: compatible NewGRFs in crash-log reported wrong md5 (#9340)
The text suggests it reports the original md5, but it does in fact
report the replaced md5. Now it reports both.
3 years ago
Patric Stout 1e564b333f
Codechange: make [Save|Load]Settings() behave more like other Save/Load code (#9335)
Prepare the full description and send it to SlObject. This does
require some code to be able to read to a SLE_VAR_NULL, like strings
etc, as there is no way to know their length beforehand.
3 years ago
Patric Stout 7572603c9d Codechange: remove the unused SLF_HEX flag 3 years ago
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.
3 years ago
Patric Stout 264991dfa5 Codechange: move SLF_NO_NETWORK_SYNC into settings
It is a settings-only flag, so don't pollute SaveLoad code with it.
3 years ago
Patric Stout 414e12d26b Codechange: move SLF_NOT_IN_SAVE into settings
It is a settings-only flag, so don't pollute SaveLoad code with it.
3 years ago
glx22 c27afdf3f6 Codechange: Remove FOR_ALL_CHUNK_HANDLERS
Co-Authored-By: Patric Stout <truebrain@openttd.org>
3 years ago
Patric Stout 28e90769f7 Codechange: use "[[maybe_unused]]" instead of a wide variety of other ways we had
While at it, replace OTTD_ASSERT with WITH_ASSERT, as this
is always set if assert() is valid. No matter if NDEBUG is set
or not.
3 years ago
Patric Stout 9fff00ba20
Codechange: C++-ify lists for SaveLoad (#9323)
Basically, this changes "SaveLoad *" to either:
1) "SaveLoadTable" if a list of SaveLoads was meant
2) "SaveLoad &" if a single entry was meant

As added bonus, this removes SL_END / SLE_END / SLEG_END. This
also adds core/span.hpp, a "std::span"-lite.
3 years ago
Patric Stout 0c96884700
Codechange: add a wrapper function to find all settings based on prefix (#9312) 3 years ago
Patric Stout ca9a7df752
Codechange: rename str_validate to StrMakeValid(InPlace) (#9304)
This to be more explicit the function changes the value, and not
returns yes/no.
3 years ago
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.
3 years ago
rubidium42 425d50372f Codechange: let SettingDesc extend SettingDescBase 3 years ago
Jonathan G Rennison 0579c8755c Add tracerestrict action: No PBS signal back PF penalty 3 years ago
Jonathan G Rennison 6d3a1935a0 Fix "(undefined string)" message when SlError called when saving 3 years ago
Jonathan G Rennison 3ecda2b735 Fix handling of SlError when called from game thread 3 years ago
Jonathan G Rennison a15e26f369 NewGRF: Elide unmasked vehicle callbacks where possible
This includes:
* CBID_VEHICLE_32DAY_CALLBACK
* CBID_VEHICLE_REFIT_COST
* CBID_VEHICLE_MODIFY_PROPERTY
  This is on a per-property basis

The main benefit of this is to avoid callbacks not handled by the
vehicle's current sprite group from using the full graphics chain as
the "default" branch in the callback switch.
In the case where the graphics chain is long/expensive, a lot of work
had to be done before a callback failure result was eventually returned.
3 years ago
rubidium42 44ca7d9377 Change: Use gender-neutral pronouns 3 years ago
rubidium42 ddaedaf32a Fix: empty undocumented branches 3 years ago
Rubidium bb9121dbd4 Fix: comparison of narrow type to wide type in loop (potential for infinite loops) 3 years ago
PeterN 66cac92028 Fix #9202: Invalid test for unset NewGRF override mapping. (#9226)
(cherry picked from commit 3d9436bd75)
3 years ago
PeterN f52da3de3a Codechange: Don't save unused NewGRF override mappings. (#9202)
(cherry picked from commit 69e5da0b54)
3 years ago
William Davis 879de9781b Change: Use gender-neutral pronouns in console command messages (and comments) (#9203)
(cherry picked from commit 881e1da51d)
3 years ago
Jonathan G Rennison 2e28bc8e6a Tracerestrict: Add engine class conditional 3 years ago
rubidium42 0f062b3882 Codechange: clean up C-string support from settings 3 years ago
rubidium42 a032714dc4 Codechange: move script settings to std::string 3 years ago
rubidium42 95386dc2b8 Codechange: move misc settings to std::string 3 years ago
glx22 38c97e1492 Codechange: Replace TILE_AREA_LOOP with range-based for loops 3 years ago
Patric Stout b136e65cf9
Change: reworked the debug levels for network facility (#9251)
It now follows very simple rules:
0 - Fatal, user should know about this
1 - Error, but we are recovering
2 - Warning, wrong but okay if you don't know
3 - Info, information you might care about
4 -
5 - Debug #1 - High level debug messages
6 - Debug #2 - Low level debug messages
7 - Trace information
3 years ago
PeterN 3d9436bd75
Fix #9202: Invalid test for unset NewGRF override mapping. (#9226) 3 years ago
PeterN 69e5da0b54
Codechange: Don't save unused NewGRF override mappings. (#9202) 3 years ago
William Davis 881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 3 years ago
glx22 8333323090 Codechange: Replace FOR_ALL_ROADTRAMTYPES with range-based for loops
(cherry picked from commit 2feb801e56)
3 years ago
PeterN 43fe7463ba Fix: Update text effect size when font zoom is changed. (#9174)
(cherry picked from commit 18651dd8b1)
3 years ago
Loïc Guilloux 88bc7bd235 Fix: [MinGW] Set minimum OS version to Windows XP (#9135)
(cherry picked from commit 356bbbb90a)
3 years ago
Jonathan G Rennison 95ca147445 Add cheat: town local authority ratings fixed as Outstanding 3 years ago
Jonathan G Rennison a9515456cb Merge branch 'master' into jgrpp
# Conflicts:
#	src/network/core/os_abstraction.h
#	src/network/core/tcp_content.h
#	src/network/core/udp.cpp
#	src/table/currency_settings.ini
#	src/table/settings.h.preamble
3 years ago
glx22 2feb801e56 Codechange: Replace FOR_ALL_ROADTRAMTYPES with range-based for loops 3 years ago
PeterN 18651dd8b1
Fix: Update text effect size when font zoom is changed. (#9174) 3 years ago
Loïc Guilloux 356bbbb90a
Fix: [MinGW] Set minimum OS version to Windows XP (#9135) 3 years ago
Jonathan G Rennison 253772e9af Merge branch 'master' into jgrpp
# Conflicts:
#	CMakeLists.txt
#	COMPILING.md
#	src/console.cpp
#	src/console_cmds.cpp
#	src/console_internal.h
#	src/rev.cpp.in
3 years ago
Jonathan G Rennison ba418f9d0d Merge branch 'master' into jgrpp
# Conflicts:
#	src/lang/simplified_chinese.txt
#	src/network/core/tcp_content.cpp
#	src/network/core/udp.cpp
#	src/network/network_server.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/table/gameopt_settings.ini
3 years ago
peter1138 a05bc04b63 Feature: Per-group wagon removal flag. 3 years ago
peter1138 27a956ba62 Codechange: Replace Group::replace_protection with Group::flags 3 years ago
Jonathan G Rennison 14636d2512 Check multi-tile ID-translated houses after house ID limit change
(Or when reloading NewGRFs)
If an overriding house type which newly fit in the limit changed the
tile layout, existing houses on the map could have the wrong layout

See: #243
3 years ago
Jonathan G Rennison 6a3e87114a Add a min_version parameter to SlXvIsFeatureMissing 3 years ago
Milek7 aade177d79
Fix: Corrupted savegame could cause heap corruption by writing outside link graph edge matrix. (#9046) 3 years ago
Milek7 da55286c2c
Fix: Corrupted savegame could crash the game by providing invalid gamelog enums. (#9045) 3 years ago
Jonathan G Rennison b514d29db1 Replace TrainCache::cached_tilt with a flags field 3 years ago
Jonathan G Rennison cb5c6902db Fix order dest refcount mismatch warning when loading very old savegames 3 years ago
Jonathan G Rennison 9e3ac646fa Fix desync warning messages when loading game with non-matching train braking model 3 years ago
Jonathan G Rennison e623560120 Fix 4c2e42fa: Wrong town caches when loading pre more-houses savegame 3 years ago
Jonathan G Rennison 7faa279250 Fix 26a123b7: Wrong variable size in VENC chunk saver 3 years ago
Jonathan G Rennison 6c62bce1ac Bump water flooding savegame version and clear states on load 3 years ago
Jonathan G Rennison 737b538492 Bump savegame version, copy town to city multipliers for old savegames 3 years ago
Jonathan G Rennison d7b23733b3 Bump realistic braking savegame version 3 years ago
Jonathan G Rennison 5d88030feb
Merge pull request #238 from reldred/newhouses_limits_tweaks
Extra House IDs
3 years ago
Jonathan G Rennison 4c2e42fae0 Add savegame conversion and version bump for more house IDs 3 years ago
Jonathan G Rennison f1cab62140 Add cheat to fix station ratings at 100% 3 years ago
Jonathan G Rennison f39b6f4ba3 Merge branch 'master' into jgrpp
# Conflicts:
#	src/cheat_gui.cpp
#	src/genworld_gui.cpp
#	src/landscape.cpp
#	src/lang/english.txt
#	src/saveload/afterload.cpp
#	src/screenshot.cpp
#	src/settings_gui.cpp
#	src/settings_internal.h
#	src/settings_type.h
#	src/table/settings.ini
#	src/tile_type.h
#	src/widgets/genworld_widget.h
3 years ago
Jonathan G Rennison 5e14b54a0c Merge branch 'master' into jgrpp 3 years ago
Jonathan G Rennison 26a123b708 Realistic braking: Cache offset of centre of mass of train 3 years ago
Jonathan G Rennison 912c62d749 Add timetable lateness/earliness conditional order 3 years ago
Patric Stout 13a5264438 Fix: store the recent new game_creation settings in savegames
This allows us to later on see what someone did, and makes sure
that "restart" command still knows how the game was created.
3 years ago
Patric Stout 1a1049bc0d Change: rename setting "max_heightlevel" to "map_height_limit"
This better reflects what it is, and hopefully removes a bit of
the confusion people are having what this setting actually does.

Additionally, update the text on the setting to better inform
users what it is doing exactly, so they can make an educated
decision on how to change it.

Next commit will introduce an "auto" value, which should be the
new default. The rename has as added benefit that everyone will
start out on the "auto" value.
3 years ago
Jonathan G Rennison a670e369db Add setting for no vehicles introduced after given year 3 years ago
Patric Stout 9bfa7198fd
Change: Heading for 1.12 now (#8862) 3 years ago
Jonathan G Rennison 4361a6dbf4 Avoid undefined behaviour const_casting std::string c_str()
Use non-const data() instead

See: #224
3 years ago