Change: Add path cache for ships.

This commit is contained in:
Peter Nelson
2019-01-14 23:33:42 +00:00
committed by PeterN
parent 1c725fce47
commit 81330b8d6e
12 changed files with 67 additions and 21 deletions

View File

@@ -12,17 +12,22 @@
#ifndef SHIP_H
#define SHIP_H
#include <deque>
#include "vehicle_base.h"
#include "water_map.h"
void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
WaterClass GetEffectiveWaterClass(TileIndex tile);
typedef std::deque<TrackdirByte> ShipPathCache;
/**
* All ships have this type.
*/
struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
TrackBitsByte state; ///< The "track" the ship is following.
ShipPathCache path; ///< Cached path.
/** We don't want GCC to zero our struct! It already is zeroed and has an index! */
Ship() : SpecializedVehicleBase() {}
@@ -46,6 +51,7 @@ struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
TileIndex GetOrderStationLocation(StationID station);
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse);
void UpdateCache();
void SetDestTile(TileIndex tile);
};
static const uint SHIP_MAX_ORDER_DISTANCE = 130;