|
|
|
@ -317,21 +317,6 @@ public:
|
|
|
|
|
*/
|
|
|
|
|
virtual uint Crash(bool flooded = false);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update vehicle sprite- and position caches
|
|
|
|
|
* @param moved Was the vehicle moved?
|
|
|
|
|
* @param turned Did the vehicle direction change?
|
|
|
|
|
*/
|
|
|
|
|
inline void UpdateViewport(bool moved, bool turned)
|
|
|
|
|
{
|
|
|
|
|
extern void VehicleMove(Vehicle *v, bool update_viewport);
|
|
|
|
|
|
|
|
|
|
if (turned) this->UpdateDeltaXY(this->direction);
|
|
|
|
|
SpriteID old_image = this->cur_image;
|
|
|
|
|
this->cur_image = this->GetImage(this->direction);
|
|
|
|
|
if (moved || this->cur_image != old_image) VehicleMove(this, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the Trackdir on which the vehicle is currently located.
|
|
|
|
|
* Works for trains and ships.
|
|
|
|
@ -661,6 +646,23 @@ struct SpecializedVehicle : public Vehicle {
|
|
|
|
|
assert(v->type == Type);
|
|
|
|
|
return (const T *)v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update vehicle sprite- and position caches
|
|
|
|
|
* @param moved Was the vehicle moved?
|
|
|
|
|
* @param turned Did the vehicle direction change?
|
|
|
|
|
*/
|
|
|
|
|
FORCEINLINE void UpdateViewport(bool moved, bool turned)
|
|
|
|
|
{
|
|
|
|
|
extern void VehicleMove(Vehicle *v, bool update_viewport);
|
|
|
|
|
|
|
|
|
|
/* Explicitly choose method to call to prevent vtable dereference -
|
|
|
|
|
* it gives ~3% runtime improvements in games with many vehicles */
|
|
|
|
|
if (turned) ((T *)this)->T::UpdateDeltaXY(this->direction);
|
|
|
|
|
SpriteID old_image = this->cur_image;
|
|
|
|
|
this->cur_image = ((T *)this)->T::GetImage(this->direction);
|
|
|
|
|
if (moved || this->cur_image != old_image) VehicleMove(this, true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define FOR_ALL_VEHICLES_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE)
|
|
|
|
|