(svn r10062) -Codechange: Don't redraw all station tiles when cargo is added or removed if the station has no custom graphics.
--- a/src/economy.cpp Fri Jun 08 06:27:58 2007 +0000
+++ b/src/economy.cpp Fri Jun 08 09:35:39 2007 +0000
@@ -1697,7 +1697,7 @@
InvalidateWindow(v->GetVehicleListWindowClass(), v->owner);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
- st->MarkTilesDirty();
+ st->MarkTilesDirty(true);
v->MarkDirty();
if (result & 2) InvalidateWindow(WC_STATION_VIEW, last_visited);
--- a/src/station.cpp Fri Jun 08 06:27:58 2007 +0000
+++ b/src/station.cpp Fri Jun 08 09:35:39 2007 +0000
@@ -133,7 +133,7 @@
}
}
-void Station::MarkTilesDirty() const
+void Station::MarkTilesDirty(bool cargo_change) const
{
TileIndex tile = train_tile;
int w, h;
@@ -141,6 +141,15 @@
/* XXX No station is recorded as 0, not INVALID_TILE... */
if (tile == 0) return;
+ /* cargo_change is set if we're refreshing the tiles due to cargo moving
+ * around. */
+ if (cargo_change) {
+ /* Don't waste time updating if there are no custom station graphics
+ * that might change. Even if there are custom graphics, they might
+ * not change. Unfortunately we have no way of telling. */
+ if (this->num_specs == 0) return;
+ }
+
for (h = 0; h < trainst_h; h++) {
for (w = 0; w < trainst_w; w++) {
if (TileBelongsToRailStation(tile)) {
--- a/src/station.h Fri Jun 08 06:27:58 2007 +0000
+++ b/src/station.h Fri Jun 08 09:35:39 2007 +0000
@@ -182,7 +182,7 @@
void AddFacility(byte new_facility_bit, TileIndex facil_xy);
void MarkDirty() const;
- void MarkTilesDirty() const;
+ void MarkTilesDirty(bool cargo_change) const;
bool TileBelongsToRailStation(TileIndex tile) const;
uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
uint GetPlatformLength(TileIndex tile) const;
--- a/src/station_cmd.cpp Fri Jun 08 06:27:58 2007 +0000
+++ b/src/station_cmd.cpp Fri Jun 08 09:35:39 2007 +0000
@@ -978,7 +978,7 @@
tile_org += tile_delta ^ TileDiffXY(1, 1); // perpendicular to tile_delta
} while (--numtracks);
- st->MarkTilesDirty();
+ st->MarkTilesDirty(false);
UpdateStationVirtCoordDirty(st);
UpdateStationAcceptance(st, false);
RebuildStationLists();
@@ -1105,7 +1105,7 @@
// now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges.
// we also need to adjust train_tile.
MakeRailwayStationAreaSmaller(st);
- st->MarkTilesDirty();
+ st->MarkTilesDirty(false);
UpdateStationSignCoord(st);
// if we deleted the whole station, delete the train facility.
@@ -2484,7 +2484,7 @@
st->goods[type].enroute_from = st->index;
st->goods[type].enroute_from_xy = st->xy;
InvalidateWindow(WC_STATION_VIEW, st->index);
- st->MarkTilesDirty();
+ st->MarkTilesDirty(true);
}
/** Rename a station
--- a/src/vehicle.cpp Fri Jun 08 06:27:58 2007 +0000
+++ b/src/vehicle.cpp Fri Jun 08 09:35:39 2007 +0000
@@ -2964,7 +2964,7 @@
InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
InvalidateWindow(WC_STATION_VIEW, this->last_station_visited);
- GetStation(this->last_station_visited)->MarkTilesDirty();
+ GetStation(this->last_station_visited)->MarkTilesDirty(true);
this->MarkDirty();
}