summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2007-06-08 09:35:39 +0000
committerpeter1138 <peter1138@openttd.org>2007-06-08 09:35:39 +0000
commitf2e0912ce9dd919fca681339521a001ad9689c74 (patch)
tree2e4dbdfce24473a173e2061ef009fc3d4a98f929
parent906385eb3d07ed913066e9c92fcb9da9f3758fa3 (diff)
downloadopenttd-f2e0912ce9dd919fca681339521a001ad9689c74.tar.xz
(svn r10062) -Codechange: Don't redraw all station tiles when cargo is added or removed if the station has no custom graphics.
-rw-r--r--src/economy.cpp2
-rw-r--r--src/station.cpp11
-rw-r--r--src/station.h2
-rw-r--r--src/station_cmd.cpp6
-rw-r--r--src/vehicle.cpp2
5 files changed, 16 insertions, 7 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index b6966ead0..194c535f3 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1697,7 +1697,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
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);
diff --git a/src/station.cpp b/src/station.cpp
index 2234e8417..9ddebb10e 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -133,7 +133,7 @@ void Station::MarkDirty() const
}
}
-void Station::MarkTilesDirty() const
+void Station::MarkTilesDirty(bool cargo_change) const
{
TileIndex tile = train_tile;
int w, h;
@@ -141,6 +141,15 @@ void Station::MarkTilesDirty() const
/* 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)) {
diff --git a/src/station.h b/src/station.h
index fb3bbd727..86857860a 100644
--- a/src/station.h
+++ b/src/station.h
@@ -182,7 +182,7 @@ struct Station {
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;
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index abee202b0..3adb4d1bb 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -978,7 +978,7 @@ int32 CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint3
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 @@ int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint
// 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 @@ static void UpdateStationWaiting(Station *st, CargoID type, uint amount)
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
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 83550c226..d813414d4 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2964,7 +2964,7 @@ void Vehicle::BeginLoading()
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();
}