# roadveh.h

Go to the documentation of this file.

    00001 /* $Id: roadveh.h 14267 2008-09-07 21:41:47Z rubidium $ */
    00002
    00005 #ifndef ROADVEH_H
    00006 #define ROADVEH_H
    00007
    00008 #include "vehicle_base.h"
    00009 #include "engine.h"
    00010 #include "economy_func.h"
    00011
    00012 enum RoadVehicleSubType {
    00013   RVST_FRONT,
    00014   RVST_ARTIC_PART,
    00015 };
    00016
    00017 static inline bool IsRoadVehFront(const Vehicle *v)
    00018 {
    00019   assert(v->type == VEH_ROAD);
    00020   return v->subtype == RVST_FRONT;
    00021 }
    00022
    00023 static inline void SetRoadVehFront(Vehicle *v)
    00024 {
    00025   assert(v->type == VEH_ROAD);
    00026   v->subtype = RVST_FRONT;
    00027 }
    00028
    00029 static inline bool IsRoadVehArticPart(const Vehicle *v)
    00030 {
    00031   assert(v->type == VEH_ROAD);
    00032   return v->subtype == RVST_ARTIC_PART;
    00033 }
    00034
    00035 static inline void SetRoadVehArticPart(Vehicle *v)
    00036 {
    00037   assert(v->type == VEH_ROAD);
    00038   v->subtype = RVST_ARTIC_PART;
    00039 }
    00040
    00041 static inline bool RoadVehHasArticPart(const Vehicle *v)
    00042 {
    00043   assert(v->type == VEH_ROAD);
    00044   return v->Next() != NULL && IsRoadVehArticPart(v->Next());
    00045 }
    00046
    00047
    00048 void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
    00049
    00050
    00059 struct RoadVehicle : public Vehicle {
    00061   RoadVehicle() { this->type = VEH_ROAD; }
    00062
    00064   virtual ~RoadVehicle() { this->PreDestructor(); }
    00065
    00066   const char *GetTypeString() const { return "road vehicle"; }
    00067   void MarkDirty();
    00068   void UpdateDeltaXY(Direction direction);
    00069   ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
    00070   WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; }
    00071   bool IsPrimaryVehicle() const { return IsRoadVehFront(this); }
    00072   int GetImage(Direction direction) const;
    00073   int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
    00074   int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
    00075   Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * GetPriceByIndex(RoadVehInfo(this->engine_type)->running_cost_class); }
    00076   bool IsInDepot() const { return this->u.road.state == RVSB_IN_DEPOT; }
    00077   bool IsStoppedInDepot() const;
    00078   void Tick();
    00079   void OnNewDay();
    00080 };
    00081
    00082 byte GetRoadVehLength(const Vehicle *v);
    00083
    00084 void RoadVehUpdateCache(Vehicle *v);
    00085
    00086 #endif /* ROADVEH_H */