summaryrefslogtreecommitdiff
path: root/src/roadveh.h
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2019-03-08 23:52:45 +0000
committerGitHub <noreply@github.com>2019-03-08 23:52:45 +0000
commit6c6971fb43514c4e4923c2ec3b1fdd9fe852617d (patch)
tree8dcb2138ea406a01392437dbb6312954484dba34 /src/roadveh.h
parentdae35188abdfd070ea833bb50ced79d92481a284 (diff)
downloadopenttd-6c6971fb43514c4e4923c2ec3b1fdd9fe852617d.tar.xz
Add: Road vehicle path cache. (#7261)
Diffstat (limited to 'src/roadveh.h')
-rw-r--r--src/roadveh.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/roadveh.h b/src/roadveh.h
index ca069b7ac..c2a799951 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -18,6 +18,7 @@
#include "track_func.h"
#include "road_type.h"
#include "newgrf_engine.h"
+#include <deque>
struct RoadVehicle;
@@ -82,10 +83,30 @@ static const byte RV_OVERTAKE_TIMEOUT = 35;
void RoadVehUpdateCache(RoadVehicle *v, bool same_length = false);
void GetRoadVehSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, int &yoffs, EngineImageType image_type);
+struct RoadVehPathCache {
+ std::deque<TrackdirByte> td;
+ std::deque<TileIndex> tile;
+
+ inline bool empty() const { return this->td.empty(); }
+
+ inline size_t size() const
+ {
+ assert(this->td.size() == this->tile.size());
+ return this->td.size();
+ }
+
+ inline void clear()
+ {
+ this->td.clear();
+ this->tile.clear();
+ }
+};
+
/**
* Buses, trucks and trams belong to this class.
*/
struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
+ RoadVehPathCache path; ///< Cached path.
byte state; ///< @see RoadVehicleStates
byte frame;
uint16 blocked_ctr;
@@ -125,6 +146,7 @@ struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
int GetCurrentMaxSpeed() const;
int UpdateSpeed();
+ void SetDestTile(TileIndex tile);
protected: // These functions should not be called outside acceleration code.