(svn r16390) -Codechange: move u.road to RoadVehicle.
This commit is contained in:
@@ -12,6 +12,41 @@
|
||||
|
||||
struct RoadVehicle;
|
||||
|
||||
/** Road vehicle states */
|
||||
enum RoadVehicleStates {
|
||||
/*
|
||||
* Lower 4 bits are used for vehicle track direction. (Trackdirs)
|
||||
* When in a road stop (bit 5 or bit 6 set) these bits give the
|
||||
* track direction of the entry to the road stop.
|
||||
* As the entry direction will always be a diagonal
|
||||
* direction (X_NE, Y_SE, X_SW or Y_NW) only bits 0 and 3
|
||||
* are needed to hold this direction. Bit 1 is then used to show
|
||||
* that the vehicle is using the second road stop bay.
|
||||
* Bit 2 is then used for drive-through stops to show the vehicle
|
||||
* is stopping at this road stop.
|
||||
*/
|
||||
|
||||
/* Numeric values */
|
||||
RVSB_IN_DEPOT = 0xFE, ///< The vehicle is in a depot
|
||||
RVSB_WORMHOLE = 0xFF, ///< The vehicle is in a tunnel and/or bridge
|
||||
|
||||
/* Bit numbers */
|
||||
RVS_USING_SECOND_BAY = 1, ///< Only used while in a road stop
|
||||
RVS_IS_STOPPING = 2, ///< Only used for drive-through stops. Vehicle will stop here
|
||||
RVS_DRIVE_SIDE = 4, ///< Only used when retrieving move data
|
||||
RVS_IN_ROAD_STOP = 5, ///< The vehicle is in a road stop
|
||||
RVS_IN_DT_ROAD_STOP = 6, ///< The vehicle is in a drive-through road stop
|
||||
|
||||
/* Bit sets of the above specified bits */
|
||||
RVSB_IN_ROAD_STOP = 1 << RVS_IN_ROAD_STOP, ///< The vehicle is in a road stop
|
||||
RVSB_IN_ROAD_STOP_END = RVSB_IN_ROAD_STOP + TRACKDIR_END,
|
||||
RVSB_IN_DT_ROAD_STOP = 1 << RVS_IN_DT_ROAD_STOP, ///< The vehicle is in a drive-through road stop
|
||||
RVSB_IN_DT_ROAD_STOP_END = RVSB_IN_DT_ROAD_STOP + TRACKDIR_END,
|
||||
|
||||
RVSB_TRACKDIR_MASK = 0x0F, ///< The mask used to extract track dirs
|
||||
RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09 ///< Only bits 0 and 3 are used to encode the trackdir for road stops
|
||||
};
|
||||
|
||||
/** State information about the Road Vehicle controller */
|
||||
enum {
|
||||
RDE_NEXT_TILE = 0x80, ///< We should enter the next tile
|
||||
@@ -84,6 +119,21 @@ void RoadVehUpdateCache(RoadVehicle *v);
|
||||
* As side-effect the vehicle type is set correctly.
|
||||
*/
|
||||
struct RoadVehicle : public Vehicle {
|
||||
byte state; ///< @see RoadVehicleStates
|
||||
byte frame;
|
||||
uint16 blocked_ctr;
|
||||
byte overtaking;
|
||||
byte overtaking_ctr;
|
||||
uint16 crashed_ctr;
|
||||
byte reverse_ctr;
|
||||
struct RoadStop *slot;
|
||||
byte slot_age;
|
||||
EngineID first_engine;
|
||||
byte cached_veh_length;
|
||||
|
||||
RoadType roadtype;
|
||||
RoadTypes compatible_roadtypes;
|
||||
|
||||
/** Initializes the Vehicle to a road vehicle */
|
||||
RoadVehicle() { this->type = VEH_ROAD; }
|
||||
|
||||
@@ -99,7 +149,7 @@ struct RoadVehicle : public Vehicle {
|
||||
int GetDisplaySpeed() const { return this->cur_speed / 2; }
|
||||
int GetDisplayMaxSpeed() const { return this->max_speed / 2; }
|
||||
Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * GetPriceByIndex(RoadVehInfo(this->engine_type)->running_cost_class); }
|
||||
bool IsInDepot() const { return this->u.road.state == RVSB_IN_DEPOT; }
|
||||
bool IsInDepot() const { return this->state == RVSB_IN_DEPOT; }
|
||||
bool IsStoppedInDepot() const;
|
||||
bool Tick();
|
||||
void OnNewDay();
|
||||
|
||||
Reference in New Issue
Block a user