MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / importIndustry

Function importIndustry

src/OpenLoco/src/S5/S5Industry.cpp:62–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 OpenLoco::Industry importIndustry(const S5::Industry& src)
63 {
64 OpenLoco::Industry dst{};
65 dst.name = src.name;
66 dst.x = src.x;
67 dst.y = src.y;
68 dst.flags = static_cast<IndustryFlags>(src.flags);
69 dst.prng = Core::Prng{ src.prng0, src.prng1 };
70 dst.objectId = src.objectId;
71 dst.under_construction = src.under_construction;
72 dst.foundingYear = src.foundingYear;
73 dst.numTiles = src.numTiles;
74 std::ranges::copy(src.tiles, dst.tiles);
75 dst.town = static_cast<TownId>(src.town);
76 dst.tileLoop = World::TileLoop{ src.tileLoop };
77 dst.numFarmTiles = src.numFarmTiles;
78 dst.numIdleFarmTiles = src.numIdleFarmTiles;
79 dst.productionRate = src.productionRate;
80 dst.owner = static_cast<CompanyId>(src.owner);
81 // Copy uint32_t array to stations in range bitset
82 for (auto i = 0U; i < Limits::kMaxStations; ++i)
83 {
84 dst.stationsInRange[i] = (src.stationsInRange[i / 32] >> (i % 32)) & 0x1;
85 }
86 for (auto i = 0U; i < 2; ++i)
87 {
88 for (auto j = 0U; j < 4; ++j)
89 {
90 dst.producedCargoStatsStation[i][j] = static_cast<StationId>(src.producedCargoStatsStation[i][j]);
91 }
92 }
93 std::memcpy(dst.producedCargoStatsRating, src.producedCargoStatsRating, sizeof(dst.producedCargoStatsRating));
94 std::ranges::copy(src.dailyProductionTarget, dst.dailyProductionTarget);
95 std::ranges::copy(src.dailyProduction, dst.dailyProduction);
96 std::ranges::copy(src.outputBuffer, dst.outputBuffer);
97 std::ranges::copy(src.producedCargoQuantityMonthlyTotal, dst.producedCargoQuantityMonthlyTotal);
98 std::ranges::copy(src.producedCargoQuantityPreviousMonth, dst.producedCargoQuantityPreviousMonth);
99 std::ranges::copy(src.receivedCargoQuantityMonthlyTotal, dst.receivedCargoQuantityMonthlyTotal);
100 std::ranges::copy(src.receivedCargoQuantityPreviousMonth, dst.receivedCargoQuantityPreviousMonth);
101 std::ranges::copy(src.receivedCargoQuantityDailyTotal, dst.receivedCargoQuantityDailyTotal);
102 std::ranges::copy(src.producedCargoQuantityDeliveredMonthlyTotal, dst.producedCargoQuantityDeliveredMonthlyTotal);
103 std::ranges::copy(src.producedCargoQuantityDeliveredPreviousMonth, dst.producedCargoQuantityDeliveredPreviousMonth);
104 std::ranges::copy(src.producedCargoPercentTransportedPreviousMonth, dst.producedCargoPercentTransportedPreviousMonth);
105 std::ranges::copy(src.producedCargoMonthlyHistorySize, dst.producedCargoMonthlyHistorySize);
106 std::ranges::copy(src.producedCargoMonthlyHistory1, dst.producedCargoMonthlyHistory1);
107 std::ranges::copy(src.producedCargoMonthlyHistory2, dst.producedCargoMonthlyHistory2);
108 std::ranges::copy(src.history_min_production, dst.history_min_production);
109
110 return dst;
111 }
112}

Callers 1

importGameStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected