summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-08-08 18:45:12 +0000
committerfrosch <frosch@openttd.org>2009-08-08 18:45:12 +0000
commitefcaefd178410c303ae17db17200c300e4379298 (patch)
tree1c48cba6fda8b05d4663d3164ef58d008ca7ca95 /src/roadveh_cmd.cpp
parent87014fec05a845cc9eab22ac33b2d7e7440b0dcc (diff)
downloadopenttd-efcaefd178410c303ae17db17200c300e4379298.tar.xz
(svn r17121) -Fix [FS#3060]: Update vehicle position cache when the vehicle sprite changes.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp35
1 files changed, 12 insertions, 23 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 782e10100..9f160a70e 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -482,8 +482,7 @@ CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
void RoadVehicle::MarkDirty()
{
for (Vehicle *v = this; v != NULL; v = v->Next()) {
- v->cur_image = v->GetImage(v->direction);
- MarkSingleVehicleDirty(v);
+ v->UpdateViewport(false, false);
}
}
@@ -532,7 +531,7 @@ static void DeleteLastRoadVeh(RoadVehicle *v)
delete v;
}
-static byte SetRoadVehPosition(RoadVehicle *v, int x, int y)
+static byte SetRoadVehPosition(RoadVehicle *v, int x, int y, bool turned)
{
byte new_z, old_z;
@@ -544,7 +543,7 @@ static byte SetRoadVehPosition(RoadVehicle *v, int x, int y)
old_z = v->z_pos;
v->z_pos = new_z;
- VehicleMove(v, true);
+ v->UpdateViewport(true, turned);
return old_z;
}
@@ -558,9 +557,7 @@ static void RoadVehSetRandomDirection(RoadVehicle *v)
uint32 r = Random();
v->direction = ChangeDir(v->direction, delta[r & 3]);
- v->UpdateDeltaXY(v->direction);
- v->cur_image = v->GetImage(v->direction);
- SetRoadVehPosition(v, v->x_pos, v->y_pos);
+ SetRoadVehPosition(v, v->x_pos, v->y_pos, true);
} while ((v = v->Next()) != NULL);
}
@@ -1255,8 +1252,7 @@ static bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
v->state = tdir;
v->frame = RVC_DEPOT_START_FRAME;
- v->UpdateDeltaXY(v->direction);
- SetRoadVehPosition(v, x, y);
+ SetRoadVehPosition(v, x, y, true);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@@ -1383,8 +1379,7 @@ static bool IndividualRoadVehicleController(RoadVehicle *v, const RoadVehicle *p
if (IsTileType(gp.new_tile, MP_TUNNELBRIDGE) && HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
/* Vehicle has just entered a bridge or tunnel */
- v->UpdateDeltaXY(v->direction);
- SetRoadVehPosition(v, gp.x, gp.y);
+ SetRoadVehPosition(v, gp.x, gp.y, true);
return true;
}
@@ -1529,8 +1524,7 @@ again:
v->cur_speed -= v->cur_speed >> 2;
}
- v->UpdateDeltaXY(v->direction);
- RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
+ RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y, true));
return true;
}
@@ -1594,8 +1588,7 @@ again:
v->cur_speed -= v->cur_speed >> 2;
}
- v->UpdateDeltaXY(v->direction);
- RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
+ RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y, true));
return true;
}
@@ -1634,8 +1627,7 @@ again:
v->cur_speed -= (v->cur_speed >> 2);
if (old_dir != v->state) {
/* The vehicle is in a road stop */
- v->UpdateDeltaXY(v->direction);
- SetRoadVehPosition(v, v->x_pos, v->y_pos);
+ SetRoadVehPosition(v, v->x_pos, v->y_pos, true);
/* Note, return here means that the frame counter is not incremented
* for vehicles changing direction in a road stop. This causes frames to
* be repeated. (XXX) Is this intended? */
@@ -1682,7 +1674,7 @@ again:
v->slot_age = 14;
v->frame++;
- RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
+ RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y, false));
return true;
}
}
@@ -1757,8 +1749,7 @@ again:
* in a depot or entered a tunnel/bridge */
if (!HasBit(r, VETS_ENTERED_WORMHOLE)) v->frame++;
- v->UpdateDeltaXY(v->direction);
- RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
+ RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y, true));
return true;
}
@@ -1816,9 +1807,7 @@ static bool RoadVehController(RoadVehicle *v)
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
if ((u->vehstatus & VS_HIDDEN) != 0) continue;
- uint16 old_image = u->cur_image;
- u->cur_image = u->GetImage(u->direction);
- if (old_image != u->cur_image) VehicleMove(u, true);
+ u->UpdateViewport(false, false);
}
if (v->progress == 0) v->progress = j;