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

Function vehiclePickup

src/OpenLoco/src/GameCommands/Vehicles/VehiclePickup.cpp:30–72  ·  view source on GitHub ↗

0x004B0826

Source from the content-addressed store, hash-verified

28{
29 // 0x004B0826
30 static uint32_t vehiclePickup(const uint8_t flags, EntityId headId)
31 {
32 GameCommands::setExpenditureType(ExpenditureType::TrainRunningCosts);
33
34 auto* head = EntityManager::get<Vehicles::VehicleHead>(headId);
35 if (head == nullptr)
36 {
37 return kFailure;
38 }
39 auto train = Vehicles::Vehicle(*head);
40 auto* veh2 = train.veh2;
41
42 GameCommands::setPosition(veh2->position);
43
44 if (!GameCommands::sub_431E6A(head->owner))
45 {
46 return kFailure;
47 }
48
49 if (!head->canBeModified())
50 {
51 return kFailure;
52 }
53
54 if (!(flags & GameCommands::Flags::apply))
55 {
56 return 0;
57 }
58
59 if (!(flags & GameCommands::Flags::ghost))
60 {
61 Vehicles::playPickupSound(veh2);
62 }
63
64 head->liftUpVehicle();
65
66 // Clear ghost flag on primary vehicle pieces and all car components.
67 train.applyToComponents([](auto& component) { component.var_38 &= ~Vehicles::Flags38::isGhost; });
68
69 head->vehicleFlags |= Vehicles::VehicleFlags::commandStop;
70
71 return 0;
72 }
73
74 void vehiclePickup(registers& regs)
75 {

Callers

nothing calls this directly

Calls 9

setExpenditureTypeFunction · 0.85
setPositionFunction · 0.85
sub_431E6AFunction · 0.85
playPickupSoundFunction · 0.85
EntityIdEnum · 0.85
canBeModifiedMethod · 0.80
liftUpVehicleMethod · 0.80
VehicleClass · 0.50
applyToComponentsMethod · 0.45

Tested by

no test coverage detected