mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r26863) -Codechange: move a number of Vehicle* functions into the Vehicle class
This commit is contained in:
parent
c4311903b7
commit
6c2abf0930
|
@ -337,8 +337,8 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
|
|||
|
||||
UpdateAircraftCache(v, true);
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
VehicleUpdatePosition(u);
|
||||
v->UpdatePosition();
|
||||
u->UpdatePosition();
|
||||
|
||||
/* Aircraft with 3 vehicles (chopper)? */
|
||||
if (v->subtype == AIR_HELICOPTER) {
|
||||
|
@ -359,7 +359,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
|
|||
w->UpdateDeltaXY(INVALID_DIR);
|
||||
|
||||
u->SetNext(w);
|
||||
VehicleUpdatePosition(w);
|
||||
w->UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ static void HelicopterTickHandler(Aircraft *v)
|
|||
|
||||
u->cur_image = img;
|
||||
|
||||
VehicleUpdatePositionAndViewport(u);
|
||||
u->UpdatePositionAndViewport();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -503,7 +503,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
|||
v->y_pos = y;
|
||||
v->z_pos = z;
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateViewport(true, false);
|
||||
if (v->subtype == AIR_HELICOPTER) v->Next()->Next()->cur_image = GetRotorImage(v, EIT_ON_MAP);
|
||||
|
||||
|
@ -518,7 +518,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
|||
u->z_pos = GetSlopePixelZ(safe_x, safe_y);
|
||||
u->cur_image = v->cur_image;
|
||||
|
||||
VehicleUpdatePositionAndViewport(u);
|
||||
u->UpdatePositionAndViewport();
|
||||
|
||||
u = u->Next();
|
||||
if (u != NULL) {
|
||||
|
@ -526,7 +526,7 @@ void SetAircraftPosition(Aircraft *v, int x, int y, int z)
|
|||
u->y_pos = y;
|
||||
u->z_pos = z + ROTOR_Z_OFFSET;
|
||||
|
||||
VehicleUpdatePositionAndViewport(u);
|
||||
u->UpdatePositionAndViewport();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -445,6 +445,6 @@ void AddArticulatedParts(Vehicle *first)
|
|||
|
||||
if (flip_image) v->spritenum++;
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ static void InitializeDisasterVehicle(DisasterVehicle *v, int x, int y, int z, D
|
|||
v->current_order.Free();
|
||||
|
||||
DisasterVehicleUpdateImage(v);
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
}
|
||||
|
||||
static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
|
||||
|
@ -162,7 +162,7 @@ static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
|
|||
v->tile = TileVirtXY(x, y);
|
||||
|
||||
DisasterVehicleUpdateImage(v);
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
|
||||
DisasterVehicle *u = v->Next();
|
||||
if (u != NULL) {
|
||||
|
@ -176,13 +176,13 @@ static void SetDisasterVehiclePos(DisasterVehicle *v, int x, int y, int z)
|
|||
u->direction = v->direction;
|
||||
|
||||
DisasterVehicleUpdateImage(u);
|
||||
VehicleUpdatePositionAndViewport(u);
|
||||
u->UpdatePositionAndViewport();
|
||||
|
||||
if ((u = u->Next()) != NULL) {
|
||||
u->x_pos = x;
|
||||
u->y_pos = y;
|
||||
u->z_pos = z + 5;
|
||||
VehicleUpdatePositionAndViewport(u);
|
||||
u->UpdatePositionAndViewport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -476,7 +476,7 @@ static bool DisasterTick_Helicopter_Rotors(DisasterVehicle *v)
|
|||
|
||||
if (++v->cur_image > SPR_ROTOR_MOVING_3) v->cur_image = SPR_ROTOR_MOVING_1;
|
||||
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ static bool ChimneySmokeTick(EffectVehicle *v)
|
|||
v->cur_image = SPR_CHIMNEY_SMOKE_0;
|
||||
}
|
||||
v->progress = 7;
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -79,7 +79,7 @@ static bool SteamSmokeTick(EffectVehicle *v)
|
|||
moved = true;
|
||||
}
|
||||
|
||||
if (moved) VehicleUpdatePositionAndViewport(v);
|
||||
if (moved) v->UpdatePositionAndViewport();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -96,11 +96,11 @@ static bool DieselSmokeTick(EffectVehicle *v)
|
|||
|
||||
if ((v->progress & 3) == 0) {
|
||||
v->z_pos++;
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
} else if ((v->progress & 7) == 1) {
|
||||
if (v->cur_image != SPR_DIESEL_SMOKE_5) {
|
||||
v->cur_image++;
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
} else {
|
||||
delete v;
|
||||
return false;
|
||||
|
@ -124,7 +124,7 @@ static bool ElectricSparkTick(EffectVehicle *v)
|
|||
v->progress = 0;
|
||||
if (v->cur_image != SPR_ELECTRIC_SPARK_5) {
|
||||
v->cur_image++;
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
} else {
|
||||
delete v;
|
||||
return false;
|
||||
|
@ -161,7 +161,7 @@ static bool SmokeTick(EffectVehicle *v)
|
|||
moved = true;
|
||||
}
|
||||
|
||||
if (moved) VehicleUpdatePositionAndViewport(v);
|
||||
if (moved) v->UpdatePositionAndViewport();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ static bool ExplosionLargeTick(EffectVehicle *v)
|
|||
if ((v->progress & 3) == 0) {
|
||||
if (v->cur_image != SPR_EXPLOSION_LARGE_F) {
|
||||
v->cur_image++;
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
} else {
|
||||
delete v;
|
||||
return false;
|
||||
|
@ -203,7 +203,7 @@ static bool BreakdownSmokeTick(EffectVehicle *v)
|
|||
} else {
|
||||
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
|
||||
}
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
}
|
||||
|
||||
v->animation_state--;
|
||||
|
@ -227,7 +227,7 @@ static bool ExplosionSmallTick(EffectVehicle *v)
|
|||
if ((v->progress & 3) == 0) {
|
||||
if (v->cur_image != SPR_EXPLOSION_SMALL_B) {
|
||||
v->cur_image++;
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
} else {
|
||||
delete v;
|
||||
return false;
|
||||
|
@ -304,7 +304,7 @@ static bool BulldozerTick(EffectVehicle *v)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -477,7 +477,7 @@ static bool BubbleTick(EffectVehicle *v)
|
|||
if (v->spritenum == 0) {
|
||||
v->cur_image++;
|
||||
if (v->cur_image < SPR_BUBBLE_GENERATE_3) {
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
return true;
|
||||
}
|
||||
if (v->animation_substate != 0) {
|
||||
|
@ -523,7 +523,7 @@ static bool BubbleTick(EffectVehicle *v)
|
|||
v->z_pos += b->z;
|
||||
v->cur_image = SPR_BUBBLE_0 + b->image;
|
||||
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -607,7 +607,7 @@ EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
|
|||
|
||||
_effect_init_procs[type](v);
|
||||
|
||||
VehicleUpdatePositionAndViewport(v);
|
||||
v->UpdatePositionAndViewport();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
|||
/* Initialize cached values for realistic acceleration. */
|
||||
if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) v->CargoChanged();
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
|
||||
CheckConsistencyOfArticulatedVehicle(v);
|
||||
}
|
||||
|
@ -1017,7 +1017,7 @@ static bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
|
|||
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateInclination(true, true);
|
||||
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
|
@ -1146,15 +1146,15 @@ bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *prev)
|
|||
/* Vehicle has just entered a bridge or tunnel */
|
||||
v->x_pos = gp.x;
|
||||
v->y_pos = gp.y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateInclination(true, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
v->x_pos = gp.x;
|
||||
v->y_pos = gp.y;
|
||||
VehicleUpdatePosition(v);
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) VehicleUpdateViewport(v, true);
|
||||
v->UpdatePosition();
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) v->Vehicle::UpdateViewport(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ again:
|
|||
}
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
RoadZPosAffectSpeed(v, v->UpdateInclination(true, true));
|
||||
return true;
|
||||
}
|
||||
|
@ -1369,7 +1369,7 @@ again:
|
|||
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
RoadZPosAffectSpeed(v, v->UpdateInclination(true, true));
|
||||
return true;
|
||||
}
|
||||
|
@ -1457,7 +1457,7 @@ again:
|
|||
v->frame++;
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
RoadZPosAffectSpeed(v, v->UpdateInclination(true, false));
|
||||
return true;
|
||||
}
|
||||
|
@ -1506,7 +1506,7 @@ again:
|
|||
if (!HasBit(r, VETS_ENTERED_WORMHOLE)) v->frame++;
|
||||
v->x_pos = x;
|
||||
v->y_pos = y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
RoadZPosAffectSpeed(v, v->UpdateInclination(false, true));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -459,8 +459,8 @@ void AfterLoadVehicles(bool part_of_load)
|
|||
|
||||
v->UpdateDeltaXY(v->direction);
|
||||
v->coord.left = INVALID_COORD;
|
||||
VehicleUpdatePosition(v);
|
||||
VehicleUpdateViewport(v, false);
|
||||
v->UpdatePosition();
|
||||
v->UpdateViewport(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -625,8 +625,8 @@ static void ShipController(Ship *v)
|
|||
if (!IsTileType(gp.new_tile, MP_TUNNELBRIDGE) || !HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
|
||||
v->x_pos = gp.x;
|
||||
v->y_pos = gp.y;
|
||||
VehicleUpdatePosition(v);
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) VehicleUpdateViewport(v, true);
|
||||
v->UpdatePosition();
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) v->Vehicle::UpdateViewport(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -638,7 +638,7 @@ static void ShipController(Ship *v)
|
|||
v->z_pos = GetSlopePixelZ(gp.x, gp.y);
|
||||
|
||||
getout:
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateViewport(true, true);
|
||||
return;
|
||||
|
||||
|
@ -722,7 +722,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, u
|
|||
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
|
|
|
@ -642,7 +642,7 @@ static CommandCost CmdBuildRailWagon(TileIndex tile, DoCommandFlag flags, const
|
|||
|
||||
_new_vehicle_id = v->index;
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->First()->ConsistChanged(CCF_ARRANGE);
|
||||
UpdateTrainGroupID(v->First());
|
||||
|
||||
|
@ -705,7 +705,7 @@ static void AddRearEngineToMultiheadedTrain(Train *v)
|
|||
v->SetMultiheaded();
|
||||
u->SetMultiheaded();
|
||||
v->SetNext(u);
|
||||
VehicleUpdatePosition(u);
|
||||
u->UpdatePosition();
|
||||
|
||||
/* Now we need to link the front and rear engines together */
|
||||
v->other_multiheaded_part = u;
|
||||
|
@ -777,7 +777,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
|||
v->SetFrontEngine();
|
||||
v->SetEngine();
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
|
||||
if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
|
||||
AddRearEngineToMultiheadedTrain(v);
|
||||
|
@ -1565,14 +1565,14 @@ static void UpdateStatusAfterSwap(Train *v)
|
|||
/* We have just left the wormhole, possibly set the
|
||||
* "goingdown" bit. UpdateInclination() can be used
|
||||
* because we are at the border of the tile. */
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateInclination(true, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateViewport(true, true);
|
||||
}
|
||||
|
||||
|
@ -2183,7 +2183,7 @@ static bool CheckTrainStayInDepot(Train *v)
|
|||
v->cur_speed = 0;
|
||||
|
||||
v->UpdateViewport(true, true);
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
|
||||
v->UpdateAcceleration();
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
|
@ -3334,8 +3334,8 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
|
|||
} else {
|
||||
v->x_pos = gp.x;
|
||||
v->y_pos = gp.y;
|
||||
VehicleUpdatePosition(v);
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) VehicleUpdateViewport(v, true);
|
||||
v->UpdatePosition();
|
||||
if ((v->vehstatus & VS_HIDDEN) == 0) v->Vehicle::UpdateViewport(true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -3345,7 +3345,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
|
|||
|
||||
v->x_pos = gp.x;
|
||||
v->y_pos = gp.y;
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
|
||||
/* update the Z position of the vehicle */
|
||||
int old_z = v->UpdateInclination(gp.new_tile != gp.old_tile, false);
|
||||
|
@ -3515,7 +3515,7 @@ static void ChangeTrainDirRandomly(Train *v)
|
|||
* a bridge, because UpdateInclination() will put the vehicle under
|
||||
* the bridge in that case */
|
||||
if (v->track != TRACK_BIT_WORMHOLE) {
|
||||
VehicleUpdatePosition(v);
|
||||
v->UpdatePosition();
|
||||
v->UpdateInclination(false, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ uint Vehicle::Crash(bool flooded)
|
|||
/* We do not transfer reserver cargo back, so TotalCount() instead of StoredCount() */
|
||||
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo.TotalCount();
|
||||
v->vehstatus |= VS_CRASHED;
|
||||
MarkSingleVehicleDirty(v);
|
||||
v->MarkAllViewportsDirty();
|
||||
}
|
||||
|
||||
/* Dirty some windows */
|
||||
|
@ -809,7 +809,7 @@ Vehicle::~Vehicle()
|
|||
|
||||
/* sometimes, eg. for disaster vehicles, when company bankrupts, when removing crashed/flooded vehicles,
|
||||
* it may happen that vehicle chain is deleted when visible */
|
||||
if (!(this->vehstatus & VS_HIDDEN)) MarkSingleVehicleDirty(this);
|
||||
if (!(this->vehstatus & VS_HIDDEN)) this->MarkAllViewportsDirty();
|
||||
|
||||
Vehicle *v = this->Next();
|
||||
this->SetNext(NULL);
|
||||
|
@ -1464,45 +1464,43 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
/**
|
||||
* Update the position of the vehicle. This will update the hash that tells
|
||||
* which vehicles are on a tile.
|
||||
* @param v The vehicle to update.
|
||||
*/
|
||||
void VehicleUpdatePosition(Vehicle *v)
|
||||
void Vehicle::UpdatePosition()
|
||||
{
|
||||
UpdateVehicleTileHash(v, false);
|
||||
UpdateVehicleTileHash(this, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the vehicle on the viewport, updating the right hash and setting the
|
||||
* new coordinates.
|
||||
* @param v The vehicle to update.
|
||||
* @param dirty Mark the (new and old) coordinates of the vehicle as dirty.
|
||||
*/
|
||||
void VehicleUpdateViewport(Vehicle *v, bool dirty)
|
||||
void Vehicle::UpdateViewport(bool dirty)
|
||||
{
|
||||
int img = v->cur_image;
|
||||
Point pt = RemapCoords(v->x_pos + v->x_offs, v->y_pos + v->y_offs, v->z_pos);
|
||||
int img = this->cur_image;
|
||||
Point pt = RemapCoords(this->x_pos + this->x_offs, this->y_pos + this->y_offs, this->z_pos);
|
||||
const Sprite *spr = GetSprite(img, ST_NORMAL);
|
||||
|
||||
pt.x += spr->x_offs;
|
||||
pt.y += spr->y_offs;
|
||||
|
||||
UpdateVehicleViewportHash(v, pt.x, pt.y);
|
||||
UpdateVehicleViewportHash(this, pt.x, pt.y);
|
||||
|
||||
Rect old_coord = v->coord;
|
||||
v->coord.left = pt.x;
|
||||
v->coord.top = pt.y;
|
||||
v->coord.right = pt.x + spr->width + 2 * ZOOM_LVL_BASE;
|
||||
v->coord.bottom = pt.y + spr->height + 2 * ZOOM_LVL_BASE;
|
||||
Rect old_coord = this->coord;
|
||||
this->coord.left = pt.x;
|
||||
this->coord.top = pt.y;
|
||||
this->coord.right = pt.x + spr->width + 2 * ZOOM_LVL_BASE;
|
||||
this->coord.bottom = pt.y + spr->height + 2 * ZOOM_LVL_BASE;
|
||||
|
||||
if (dirty) {
|
||||
if (old_coord.left == INVALID_COORD) {
|
||||
MarkSingleVehicleDirty(v);
|
||||
this->MarkAllViewportsDirty();
|
||||
} else {
|
||||
MarkAllViewportsDirty(
|
||||
min(old_coord.left, v->coord.left),
|
||||
min(old_coord.top, v->coord.top),
|
||||
max(old_coord.right, v->coord.right) + 1 * ZOOM_LVL_BASE,
|
||||
max(old_coord.bottom, v->coord.bottom) + 1 * ZOOM_LVL_BASE
|
||||
::MarkAllViewportsDirty(
|
||||
min(old_coord.left, this->coord.left),
|
||||
min(old_coord.top, this->coord.top),
|
||||
max(old_coord.right, this->coord.right) + 1 * ZOOM_LVL_BASE,
|
||||
max(old_coord.bottom, this->coord.bottom) + 1 * ZOOM_LVL_BASE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1510,21 +1508,19 @@ void VehicleUpdateViewport(Vehicle *v, bool dirty)
|
|||
|
||||
/**
|
||||
* Update the position of the vehicle, and update the viewport.
|
||||
* @param v The vehicle to update.
|
||||
*/
|
||||
void VehicleUpdatePositionAndViewport(Vehicle *v)
|
||||
void Vehicle::UpdatePositionAndViewport()
|
||||
{
|
||||
VehicleUpdatePosition(v);
|
||||
VehicleUpdateViewport(v, true);
|
||||
this->UpdatePosition();
|
||||
this->UpdateViewport(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks viewports dirty where the vehicle's image is.
|
||||
* @param v vehicle to mark dirty
|
||||
*/
|
||||
void MarkSingleVehicleDirty(const Vehicle *v)
|
||||
void Vehicle::MarkAllViewportsDirty() const
|
||||
{
|
||||
MarkAllViewportsDirty(v->coord.left, v->coord.top, v->coord.right + 1 * ZOOM_LVL_BASE, v->coord.bottom + 1 * ZOOM_LVL_BASE);
|
||||
::MarkAllViewportsDirty(this->coord.left, this->coord.top, this->coord.right + 1 * ZOOM_LVL_BASE, this->coord.bottom + 1 * ZOOM_LVL_BASE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -696,6 +696,11 @@ public:
|
|||
void UpdateVisualEffect(bool allow_power_change = true);
|
||||
void ShowVisualEffect() const;
|
||||
|
||||
void UpdatePosition();
|
||||
void UpdateViewport(bool dirty);
|
||||
void UpdatePositionAndViewport();
|
||||
void MarkAllViewportsDirty() const;
|
||||
|
||||
inline uint16 GetServiceInterval() const { return this->service_interval; }
|
||||
|
||||
inline void SetServiceInterval(uint16 interval) { this->service_interval = interval; }
|
||||
|
@ -1067,14 +1072,12 @@ struct SpecializedVehicle : public Vehicle {
|
|||
*/
|
||||
inline void UpdateViewport(bool force_update, bool update_delta)
|
||||
{
|
||||
extern void VehicleUpdateViewport(Vehicle *v, bool dirty);
|
||||
|
||||
/* Explicitly choose method to call to prevent vtable dereference -
|
||||
* it gives ~3% runtime improvements in games with many vehicles */
|
||||
if (update_delta) ((T *)this)->T::UpdateDeltaXY(this->direction);
|
||||
SpriteID old_image = this->cur_image;
|
||||
this->cur_image = ((T *)this)->T::GetImage(this->direction, EIT_ON_MAP);
|
||||
if (force_update || this->cur_image != old_image) VehicleUpdateViewport(this, true);
|
||||
if (force_update || this->cur_image != old_image) this->Vehicle::UpdateViewport(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -67,11 +67,6 @@ void CheckVehicleBreakdown(Vehicle *v);
|
|||
void AgeVehicle(Vehicle *v);
|
||||
void VehicleEnteredDepotThisTick(Vehicle *v);
|
||||
|
||||
void VehicleUpdatePosition(Vehicle *v);
|
||||
void VehicleUpdateViewport(Vehicle *v, bool dirty);
|
||||
void VehicleUpdatePositionAndViewport(Vehicle *v);
|
||||
void MarkSingleVehicleDirty(const Vehicle *v);
|
||||
|
||||
UnitID GetFreeUnitNumber(VehicleType type);
|
||||
|
||||
void VehicleEnterDepot(Vehicle *v);
|
||||
|
|
Loading…
Reference in New Issue