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

Function needsComponentChangeConfirm

src/OpenLoco/src/Ui/Windows/Vehicle.cpp:140–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

138 }
139
140 static bool needsComponentChangeConfirm(EntityId id, const bool checkKeepCargoCheat)
141 {
142 auto* vehBase = EntityManager::get<Vehicles::VehicleBase>(id);
143 if (vehBase == nullptr)
144 {
145 return false;
146 }
147
148 auto* head = EntityManager::get<Vehicles::VehicleHead>(vehBase->getHead());
149 if (head == nullptr)
150 {
151 return false;
152 }
153
154 if (!head->hasAnyCargo())
155 {
156 return false;
157 }
158
159 if (checkKeepCargoCheat && Config::get().keepCargoModifyPickup)
160 {
161 return false;
162 }
163
164 if (head->getCarCount() > 0 && CompanyManager::getControllingId() == head->owner)
165 {
166 return true;
167 }
168
169 return false;
170 }
171
172 static bool confirmComponentChange(const EntityId id, const OpenLoco::StringId windowTitle, const OpenLoco::StringId windowMessage, const OpenLoco::StringId windowConfirm, const bool checkKeepCargoCheat = true)
173 {

Callers 1

confirmComponentChangeFunction · 0.85

Calls 5

getControllingIdFunction · 0.85
getHeadMethod · 0.80
hasAnyCargoMethod · 0.80
getCarCountMethod · 0.80
getFunction · 0.50

Tested by

no test coverage detected