2006-06-05 11:23:18 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-04-03 20:19:04 +01:00
|
|
|
/** @file src/roadveh.h Road vehicle states */
|
2007-03-28 21:41:35 +01:00
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#ifndef ROADVEH_H
|
|
|
|
#define ROADVEH_H
|
|
|
|
|
2006-06-05 11:23:18 +01:00
|
|
|
#include "vehicle.h"
|
2007-08-29 22:27:16 +01:00
|
|
|
#include "engine.h"
|
|
|
|
#include "variables.h"
|
2006-06-05 11:23:18 +01:00
|
|
|
|
2007-06-11 15:00:16 +01:00
|
|
|
enum RoadVehicleSubType {
|
|
|
|
RVST_FRONT,
|
|
|
|
RVST_ARTIC_PART,
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool IsRoadVehFront(const Vehicle *v)
|
|
|
|
{
|
|
|
|
assert(v->type == VEH_ROAD);
|
|
|
|
return v->subtype == RVST_FRONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetRoadVehFront(Vehicle *v)
|
|
|
|
{
|
|
|
|
assert(v->type == VEH_ROAD);
|
|
|
|
v->subtype = RVST_FRONT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsRoadVehArticPart(const Vehicle *v)
|
|
|
|
{
|
|
|
|
assert(v->type == VEH_ROAD);
|
|
|
|
return v->subtype == RVST_ARTIC_PART;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetRoadVehArticPart(Vehicle *v)
|
|
|
|
{
|
|
|
|
assert(v->type == VEH_ROAD);
|
|
|
|
v->subtype = RVST_ARTIC_PART;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool RoadVehHasArticPart(const Vehicle *v)
|
|
|
|
{
|
|
|
|
assert(v->type == VEH_ROAD);
|
|
|
|
return v->next != NULL && IsRoadVehArticPart(v->next);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-07-24 18:01:23 +01:00
|
|
|
static inline bool IsRoadVehInDepot(const Vehicle *v)
|
2006-06-05 11:23:18 +01:00
|
|
|
{
|
2007-03-08 16:27:54 +00:00
|
|
|
assert(v->type == VEH_ROAD);
|
2006-06-05 11:23:18 +01:00
|
|
|
return v->u.road.state == 254;
|
|
|
|
}
|
|
|
|
|
2007-07-24 18:01:23 +01:00
|
|
|
static inline bool IsRoadVehInDepotStopped(const Vehicle *v)
|
2006-06-05 11:23:18 +01:00
|
|
|
{
|
|
|
|
return IsRoadVehInDepot(v) && v->vehstatus & VS_STOPPED;
|
|
|
|
}
|
2006-09-27 16:40:55 +01:00
|
|
|
|
2007-01-22 02:09:51 +00:00
|
|
|
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
|
2006-09-28 19:42:35 +01:00
|
|
|
|
2007-04-29 22:24:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This class 'wraps' Vehicle; you do not actually instantiate this class.
|
|
|
|
* You create a Vehicle using AllocateVehicle, so it is added to the pool
|
|
|
|
* and you reinitialize that to a Train using:
|
|
|
|
* v = new (v) RoadVehicle();
|
|
|
|
*
|
|
|
|
* As side-effect the vehicle type is set correctly.
|
|
|
|
*/
|
|
|
|
struct RoadVehicle : public Vehicle {
|
|
|
|
/** Initializes the Vehicle to a road vehicle */
|
|
|
|
RoadVehicle() { this->type = VEH_ROAD; }
|
|
|
|
|
|
|
|
/** We want to 'destruct' the right class. */
|
2007-08-05 18:43:04 +01:00
|
|
|
virtual ~RoadVehicle() { this->PreDestructor(); }
|
2007-04-29 22:24:08 +01:00
|
|
|
|
2007-05-02 10:39:11 +01:00
|
|
|
const char *GetTypeString() const { return "road vehicle"; }
|
2007-04-29 23:33:51 +01:00
|
|
|
void MarkDirty();
|
2007-05-01 17:35:14 +01:00
|
|
|
void UpdateDeltaXY(Direction direction);
|
2007-05-02 10:39:11 +01:00
|
|
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
|
|
|
|
WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; }
|
2007-06-11 15:00:16 +01:00
|
|
|
bool IsPrimaryVehicle() const { return IsRoadVehFront(this); }
|
|
|
|
bool HasFront() const { return true; }
|
2007-07-01 20:11:47 +01:00
|
|
|
int GetImage(Direction direction) const;
|
2007-08-26 21:43:22 +01:00
|
|
|
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
2007-08-28 07:46:33 +01:00
|
|
|
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
2007-08-29 22:27:16 +01:00
|
|
|
Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * _price.roadveh_running; }
|
2007-07-01 20:24:54 +01:00
|
|
|
void Tick();
|
2007-04-29 22:24:08 +01:00
|
|
|
};
|
|
|
|
|
2007-06-11 15:00:16 +01:00
|
|
|
byte GetRoadVehLength(const Vehicle *v);
|
|
|
|
|
|
|
|
void RoadVehUpdateCache(Vehicle *v);
|
|
|
|
|
2006-09-28 19:42:35 +01:00
|
|
|
#endif /* ROADVEH_H */
|