mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-16 17:02:37 +01:00
Codechange: Split GoodsEntry cargo and flows data to unique_ptr. (#13058)
This allows cargo packets and cargo flow data to be empty if not in use, which is the case for the majority of station goods entries, and data is allocated when needed. This reduces the initial size of a Station from 9192 bytes to 2024 bytes (on 64 bit platforms), although an allocation of 120 bytes is made for each active cargo type at a station. Based on similar changes in JGRPP.
This commit is contained in:
@@ -170,11 +170,14 @@ void CheckCaches()
|
||||
|
||||
for (Station *st : Station::Iterate()) {
|
||||
for (GoodsEntry &ge : st->goods) {
|
||||
[[maybe_unused]] const auto a = ge.cargo.PeriodsInTransit();
|
||||
[[maybe_unused]] const auto b = ge.cargo.TotalCount();
|
||||
ge.cargo.InvalidateCache();
|
||||
assert(a == ge.cargo.PeriodsInTransit());
|
||||
assert(b == ge.cargo.TotalCount());
|
||||
if (!ge.HasData()) continue;
|
||||
|
||||
StationCargoList &cargo_list = ge.GetData().cargo;
|
||||
[[maybe_unused]] const auto a = cargo_list.PeriodsInTransit();
|
||||
[[maybe_unused]] const auto b = cargo_list.TotalCount();
|
||||
cargo_list.InvalidateCache();
|
||||
assert(a == cargo_list.PeriodsInTransit());
|
||||
assert(b == cargo_list.TotalCount());
|
||||
}
|
||||
|
||||
/* Check docking tiles */
|
||||
|
||||
Reference in New Issue
Block a user