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

Function importCompany

src/OpenLoco/src/S5/S5Company.cpp:303–453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301 }
302
303 OpenLoco::Company importCompany(const S5::Company& src)
304 {
305 OpenLoco::Company dst{};
306 dst.name = src.name;
307 dst.ownerName = src.ownerName;
308 dst.challengeFlags = static_cast<CompanyFlags>(src.challengeFlags);
309 dst.cash = src.cash;
310 dst.currentLoan = src.currentLoan;
311 dst.updateCounter = src.updateCounter;
312 dst.performanceIndex = src.performanceIndex;
313 dst.competitorId = src.competitorId;
314 dst.ownerEmotion = static_cast<Emotion>(src.ownerEmotion);
315 dst.mainColours.primary = static_cast<Colour>(src.mainColours[0]);
316 dst.mainColours.secondary = static_cast<Colour>(src.mainColours[1]);
317 for (auto i = 0U; i < std::size(src.vehicleColours); ++i)
318 {
319 dst.vehicleColours[i].primary = static_cast<Colour>(src.vehicleColours[i][0]);
320 dst.vehicleColours[i].secondary = static_cast<Colour>(src.vehicleColours[i][1]);
321 }
322 dst.customVehicleColoursSet = src.customVehicleColoursSet;
323 for (auto i = 0U; i < 224; ++i)
324 {
325 dst.unlockedVehicles[i] = (src.unlockedVehicles[i / 32] >> static_cast<uint32_t>(i % 32)) & 0x1;
326 }
327 dst.availableVehicles = src.availableVehicles;
328 dst.aiPlaystyleFlags = static_cast<AiPlaystyleFlags>(src.aiPlaystyleFlags);
329 dst.aiPlaystyleTownId = src.aiPlaystyleTownId;
330 dst.numExpenditureYears = src.numExpenditureYears;
331 std::memcpy(dst.expenditures, src.expenditures, kExpenditureHistoryCapacity * ExpenditureType::Count * sizeof(currency32_t));
332 dst.startedDate = src.startedDate;
333 dst.var_49C = src.var_49C;
334 dst.var_4A0 = src.var_4A0;
335 dst.var_4A4 = static_cast<AiThinkState>(src.var_4A4);
336 dst.var_4A5 = src.var_4A5;
337 dst.var_4A6 = static_cast<AiPlaceVehicleState>(src.var_4A6);
338 dst.var_4A7 = src.var_4A7;
339 // Copy AI thoughts
340 for (auto i = 0U; i < kMaxAiThoughts; ++i)
341 {
342 auto& srcThought = src.aiThoughts[i];
343 auto& dstThought = dst.aiThoughts[i];
344 dstThought.type = static_cast<AiThoughtType>(srcThought.type);
345 dstThought.destinationA = srcThought.destinationA;
346 dstThought.destinationB = srcThought.destinationB;
347 dstThought.numStations = srcThought.numStations;
348 dstThought.stationLength = srcThought.stationLength;
349 for (auto j = 0U; j < std::size(srcThought.stations); ++j)
350 {
351 dstThought.stations[j].id = static_cast<StationId>(srcThought.stations[j].id);
352 dstThought.stations[j].var_02 = static_cast<AiThoughtStationFlags>(srcThought.stations[j].var_02);
353 dstThought.stations[j].rotation = srcThought.stations[j].rotation;
354 dstThought.stations[j].pos = srcThought.stations[j].pos;
355 dstThought.stations[j].baseZ = srcThought.stations[j].baseZ;
356 dstThought.stations[j].var_9 = srcThought.stations[j].var_9;
357 dstThought.stations[j].var_A = srcThought.stations[j].var_A;
358 dstThought.stations[j].var_B = srcThought.stations[j].var_B;
359 dstThought.stations[j].var_C = srcThought.stations[j].var_C;
360 }

Callers 1

importGameStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected