Commit Graph

139 Commits (e5438891e27c0895964e1a030c91295d3b6ef474)

Author SHA1 Message Date
Tyler Trahan e5438891e2
Cleanup: Keep spacing saveload versions by groups of five (#10576) 1 year ago
SamuXarick 6eabbaa751 Fix #10469, 5e14a20: [Script] League Table rating element is a int64 everywhere else 1 year ago
Michael Lutz 7352f812e6 Codechange: [Linkgraph] Only store present link graph edges and not all possible edges. 1 year ago
Michael Lutz 178249e7cc Codechange: Saveload macros for entries with a custom table name. 1 year ago
Jonathan G Rennison 4c1406a4b5 Add: NewGRF road stops 1 year ago
Rubidium 4e65ec1dc4 Codechange: do not declare functions in blocks 1 year ago
Rubidium 5863d78cb4 Codechange: use commented out code, or guard by #ifdef 1 year ago
Michael Lutz 150f05dc15
Change: Heading for 14 now. (#10302) 1 year ago
Tyler Trahan c19abebf8d
Feature: Multi-track level crossings (#9931) 2 years ago
Nicolas Chappe f8a7b76675 Fix #9665: [Linkgraph] Fix travel times of non-direct journeys 2 years ago
dP 548f0496a9
Change: Make _tick_counter 64bit to avoid wrapping (#10035) 2 years ago
SamuXarick e404d16929
Fix #9591: Update station docking tiles upon placing a water object on a docking tile (#9594) 3 years ago
Loïc Guilloux 38a64eb2aa
Change: Allow all tiles around docks to be docking tiles (#9578) 3 years ago
Patric Stout 394c749b6b
Change: Heading for 13 now (#9573) 3 years ago
Nicolas Chappe 977604ef08 Feature: [Linkgraph] Prioritize faster routes for passengers, mail and express cargo
Passengers usually prefer fast paths to short paths.
Average travel times of links are updated in real-time for use in Dijkstra's algorithm,
and newer travel times weigh more, just like capacities.
3 years ago
Loïc Guilloux 460991ecf4
Feature: Persistant rotation of numbered auto/netsave after restart (#9397)
It was always starting from 0 on openttd restart.
Now the most recent auto/netsave number will be used as a base to generate the next filename.
3 years ago
Stephan a70aa5df49
Add #9188: netsave now keeps multiple version around, similar to autosave (#9395) 3 years ago
glx22 6e627f35ac Cleanup: Remove now unneeded ChunkHandler members 3 years ago
glx22 c1a9fe6fbd Codechange: Use static array of references to ChunkHandler 3 years ago
glx22 f371a5ad70 Codechange: Preparation for ChunkHandler subclassing 3 years ago
Loïc Guilloux ddafc0de05
Fix 39e90ec: Integers for scripts are 64bit, but saved as 32bit (#9415) 3 years ago
Patric Stout 4e645ce749 Codechange: using "until" in function names can be confusing
IsSavegameVersionUntil() did a [0, N] check, not [0, N) as the
name suggests.

Until can be a confusing word, where people consider it to be
including the upperbound. Dictionary states it means "before",
excluding the upperbound. There are long debates about who is right.

So, simply remove away from this ambiguity, and call it "before"
and "before or at". This makes the world easier for everyone.
3 years ago
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.
3 years ago
Patric Stout 3826703bc3 Add: store headers for chunks with SL_STRUCTLIST 3 years ago
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.
3 years ago
rubidium42 f7f1d530b8 Codechange: instead of "naked" initializer lists, declare the type in the saveload macros
This to help variant's constructor to be able to resolve the constructor of the setting
3 years ago
Rubidium 281a65b3e1 Cleanup: simplify some boolean expressions 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 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 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 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 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
Tyler Trahan d09210e1c6 Feature: Configurable subsidy duration 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 fba86f711f Codechange: move GetVariableAddress inside SlObjectMember
Also move it to static, as nobody else is using it.
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 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 7572603c9d Codechange: remove the unused SLF_HEX flag 3 years ago
glx22 c27afdf3f6 Codechange: Remove FOR_ALL_CHUNK_HANDLERS
Co-Authored-By: Patric Stout <truebrain@openttd.org>
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
rubidium42 0f062b3882 Codechange: clean up C-string support from settings 3 years ago
rubidium42 95386dc2b8 Codechange: move misc settings to std::string 3 years ago
William Davis 881e1da51d
Change: Use gender-neutral pronouns in console command messages (and comments) (#9203) 3 years ago
peter1138 a05bc04b63 Feature: Per-group wagon removal flag. 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 9bfa7198fd
Change: Heading for 1.12 now (#8862) 3 years ago