(svn r21098) -Codechange: Ships now store their max speed in the cache instead of recalculating it every time.

This commit is contained in:
terkhen
2010-11-06 13:03:17 +00:00
parent c8a56f17f8
commit 25d1b2f54b
7 changed files with 42 additions and 18 deletions

View File

@@ -35,7 +35,7 @@ struct Ship: public SpecializedVehicle<Ship, VEH_SHIP> {
bool IsPrimaryVehicle() const { return true; }
SpriteID GetImage(Direction direction) const;
int GetDisplaySpeed() const { return this->cur_speed / 2; }
int GetDisplayMaxSpeed() const { return this->max_speed / 2; }
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
Money GetRunningCost() const;
bool IsInDepot() const { return this->state == TRACK_BIT_DEPOT; }
bool Tick();
@@ -43,6 +43,7 @@ struct Ship: public SpecializedVehicle<Ship, VEH_SHIP> {
Trackdir GetVehicleTrackdir() const;
TileIndex GetOrderStationLocation(StationID station);
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
void UpdateCache();
};
#define FOR_ALL_SHIPS(var) FOR_ALL_VEHICLES_OF_TYPE(Ship, var)