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:
2025-01-02 20:48:23 +00:00
committed by GitHub
parent 810dc23215
commit 810e442203
19 changed files with 216 additions and 93 deletions

View File

@@ -1387,7 +1387,7 @@ static void MaybeCrashAirplane(Aircraft *v)
/* Crash the airplane. Remove all goods stored at the station. */
for (GoodsEntry &ge : st->goods) {
ge.rating = 1;
ge.cargo.Truncate();
if (ge.HasData()) ge.GetData().cargo.Truncate();
}
CrashAirplane(v);