Commit Graph

119 Commits

Author SHA1 Message Date
Peter Nelson
8172e25273
Codechange: Use range-for when iterating station speclists. (#12212)
This replaces indexed access.
2024-03-03 16:41:02 +00:00
Peter Nelson
cff48c0f63 Codechange: Templatise SlStationSpecList to reduce duplication.
SlStationSpecList now handles both StationSpec and RoadStopSpec, and replaces indexed array access with range-for and reserve/emplace_back pattern.
2024-03-02 21:16:15 +00:00
Peter Nelson
41b3314d76 Codechange: Replace separate Station/RoadStopSpecList with template struct.
Reduces duplication and simplifies reuse.

Additionally naming an item that is used in a list as a ...List was
pretty weird.
2024-03-02 21:16:15 +00:00
Peter Nelson
f0a891c4f7
Cleanup: Remove unused last_num_specs from SlRoadStopTileData. (#12198)
Inadvertently copy & pasted from another Sl handler.
2024-03-01 02:00:13 +00:00
Peter Nelson
9602de474d Codechange: Use iterators and/or range-for on cargo related loops. 2023-10-19 17:03:25 +01:00
Peter Nelson
49dae08a3b Codechange: Add missing override specifiers. 2023-09-25 21:27:45 +01:00
Patric Stout
d1a0ca67be
Codechange: simplify splitting of CargoPacket (#11286) 2023-09-13 09:40:01 -04:00
Patric Stout
e6c02ebee6
Fix b0e73277: cargodist information got lost when splitting of cargo (#11280)
During b0e73277 we removed loaded_at_xy, but I kinda forgot that
it was a union with next_station. Now next_station wasn't copied
anymore, or checked in AreMergable.
2023-09-10 15:20:58 +02:00
Patric Stout
b0e73277d6
Codechange: remove loaded_at_xy from CargoPacket as it was unused (#11276) 2023-09-09 20:24:46 +01:00
Peter Nelson
9040d7813d Codechange: Use std::array and std::unique_ptr for PersistentStorageArrays.
This (mostly) avoids the need for manual memory management and copying.
2023-09-09 15:26:03 +01:00
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
rubidium42
9f6fec01cd
Codechange: rename cargo aging days to periods, as they are not really days (#11112) 2023-07-12 13:20:02 -04:00
Peter Nelson
e6740046ee Codechange: Use range-for iteration. 2023-05-11 07:58:55 +01:00
Peter Nelson
912eb68981 Change: Extend entity override manager and station spec lists to support 16 bit IDs. 2023-05-05 07:08:40 +01:00
Tyler Trahan
930f0a16d8 Codechange: Define Date/Year/Month/Day within TimerGameCalendar class 2023-04-26 07:14:03 -04:00
Rubidium
580d0a6343 Codechange: make use of Tile in for all direct map accesses 2023-02-28 07:11:48 +01:00
Jonathan G Rennison
4c1406a4b5 Add: NewGRF road stops 2023-02-26 21:28:30 +01:00
Rubidium
3c54344825 Fix: comparison of narrow type with wide type in loop condition
Technically this can't be triggered with the currently returned values though.
2023-01-06 19:34:35 +01:00
Peter Nelson
22803f997b Codechange: Use std::vector for station speclist
This removes manual memory allocation, although we still manage the list
size in roughly the same way.
2022-11-06 16:50:42 +01:00
glx22
6e627f35ac Cleanup: Remove now unneeded ChunkHandler members 2021-07-06 22:29:08 +02:00
glx22
2c941cd8b3 Codechange: Use ChunkHandlers sub-classes 2021-07-06 22:29:08 +02:00
glx22
c1a9fe6fbd Codechange: Use static array of references to ChunkHandler 2021-07-06 22:29:08 +02:00
Patric Stout
3826703bc3 Add: store headers for chunks with SL_STRUCTLIST 2021-07-02 22:21:58 +02:00
Patric Stout
cdb3dd0493 Add: store headers for most savegame chunks
When a header is added, the chunk changes from CH_ARRAY type to
CH_TABLE type.
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
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.
2021-06-15 19:36:15 +02:00
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.
2021-06-15 16:45:04 +02:00
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.
2021-06-14 21:58:05 +02:00
Patric Stout
0bdca02bdf Codechange: use SLE_STRUCT(LIST) for Station chunks 2021-06-14 21:58:05 +02:00
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.
2021-06-14 21:58:05 +02:00
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.
2021-06-10 19:18:24 +02:00
glx22
c27afdf3f6 Codechange: Remove FOR_ALL_CHUNK_HANDLERS
Co-Authored-By: Patric Stout <truebrain@openttd.org>
2021-06-06 19:35:06 +02:00
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.
2021-05-31 22:26:44 +02:00
glx22
38c97e1492 Codechange: Replace TILE_AREA_LOOP with range-based for loops 2021-05-13 00:13:54 +02:00
Michael Lutz
63ccb36ef3 Codechange: Use std::string for most of the user-settable custom names. 2020-05-21 20:02:34 +02:00
glx
bc8333723c Fix #8021: limit savegame range for docking tiles fixing 2020-05-06 23:12:59 +02:00
SamuXarick
57553cd809 Fix #8020: Add missing docking tiles around industry neutral stations 2020-03-30 08:21:40 +02:00
glx
b91abd3af9 Codechange: Replace FOR_ALL_ROADSTOPS with range-based for loops 2019-12-21 20:13:03 +01:00
glx
d8a1be48cd Codechange: Replace vehicle related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx
9892d90b26 Codechange: Replace order related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
glx
ddabfed1cd Codechange: Replace station related FOR_ALL with range-based for loops 2019-12-21 20:13:03 +01:00
S. D. Cloudt
13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
peter1138
f538179878 Feature: Multi-tile docks and docking points. 2019-06-30 16:46:32 +02:00
peter1138
4f052fc2a4 Cleanup: Fix alignment after NULL -> nullptr change. 2019-04-13 20:35:10 +01:00
Henry Wilson
7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Peter Nelson
e21ade375e Codechange: Change from numeric to descriptive SLV enum labels for last entries. 2019-02-02 21:39:06 +00:00
Peter Nelson
9de12521ec Codechange: Convert saveload numbers to enum values.
(This was mostly achieved with a few in-place regexes)
2019-02-02 21:39:06 +00:00
Peter Nelson
ea4ea62816 Codechange: Make saveload version upper bound exclusive, i.e. version object was removed instead of version object last appeared. 2019-02-02 21:39:06 +00:00
Peter Nelson
67633606b0 Codechange: Remove value mangling and field misuse in SLE_WRITEBYTE.
The original translation functionality hasn't been used since 2007.
2019-01-30 17:11:40 +00:00
Michael Lutz
4b0b4e0643 Feature: [NewGRF] Increase size of persistent storage to 256. 2018-09-02 21:31:15 +02:00