MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateCache

Method UpdateCache

src/ship_cmd.cpp:231–244  ·  view source on GitHub ↗

* Update the caches of this ship. */

Source from the content-addressed store, hash-verified

229 * Update the caches of this ship.
230 */
231void Ship::UpdateCache()
232{
233 const ShipVehicleInfo *svi = ShipVehInfo(this->engine_type);
234
235 /* Get speed fraction for the current water type. Aqueducts are always canals. */
236 bool is_ocean = GetEffectiveWaterClass(this->tile) == WaterClass::Sea;
237 uint raw_speed = GetVehicleProperty(this, PROP_SHIP_SPEED, svi->max_speed);
238 this->vcache.cached_max_speed = svi->ApplyWaterClassSpeedFrac(raw_speed, is_ocean);
239
240 /* Update cargo aging period. */
241 this->vcache.cached_cargo_age_period = GetVehicleProperty(this, PROP_SHIP_CARGO_AGE_PERIOD, EngInfo(this->engine_type)->cargo_age_period);
242
243 this->UpdateVisualEffect();
244}
245
246Money Ship::GetRunningCost() const
247{

Callers 7

MarkDirtyMethod · 0.95
ShipControllerFunction · 0.80
CmdBuildShipFunction · 0.80
VehicleEnterDepotFunction · 0.80
CmdRefitVehicleFunction · 0.80
CheckCachesFunction · 0.80
AfterLoadVehiclesPhase2Function · 0.80

Calls 6

ShipVehInfoFunction · 0.85
GetEffectiveWaterClassFunction · 0.85
GetVehiclePropertyFunction · 0.85
EngInfoFunction · 0.85
UpdateVisualEffectMethod · 0.80

Tested by

no test coverage detected