author | truebrain |
Thu, 12 Jun 2008 21:07:25 +0000 | |
branch | noai |
changeset 10943 | 5f5a5dd407d8 |
parent 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
3959 | 1 |
/* $Id$ */ |
2 |
||
9574 | 3 |
/** @file src/roadveh.h Road vehicle states */ |
4 |
||
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
5 |
#ifndef ROADVEH_H |
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
6 |
#define ROADVEH_H |
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
7 |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9703
diff
changeset
|
8 |
#include "vehicle_base.h" |
9837
c9ec4f82e0d0
(svn r12503) [NoAI] -Sync: with trunk r12461:12501.
rubidium
parents:
9732
diff
changeset
|
9 |
#include "engine_func.h" |
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
10355
diff
changeset
|
10 |
#include "engine_base.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9703
diff
changeset
|
11 |
#include "economy_func.h" |
3959 | 12 |
|
9627 | 13 |
enum RoadVehicleSubType { |
14 |
RVST_FRONT, |
|
15 |
RVST_ARTIC_PART, |
|
16 |
}; |
|
17 |
||
18 |
static inline bool IsRoadVehFront(const Vehicle *v) |
|
19 |
{ |
|
20 |
assert(v->type == VEH_ROAD); |
|
21 |
return v->subtype == RVST_FRONT; |
|
22 |
} |
|
23 |
||
24 |
static inline void SetRoadVehFront(Vehicle *v) |
|
25 |
{ |
|
26 |
assert(v->type == VEH_ROAD); |
|
27 |
v->subtype = RVST_FRONT; |
|
28 |
} |
|
29 |
||
30 |
static inline bool IsRoadVehArticPart(const Vehicle *v) |
|
31 |
{ |
|
32 |
assert(v->type == VEH_ROAD); |
|
33 |
return v->subtype == RVST_ARTIC_PART; |
|
34 |
} |
|
35 |
||
36 |
static inline void SetRoadVehArticPart(Vehicle *v) |
|
37 |
{ |
|
38 |
assert(v->type == VEH_ROAD); |
|
39 |
v->subtype = RVST_ARTIC_PART; |
|
40 |
} |
|
41 |
||
42 |
static inline bool RoadVehHasArticPart(const Vehicle *v) |
|
43 |
{ |
|
44 |
assert(v->type == VEH_ROAD); |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
45 |
return v->Next() != NULL && IsRoadVehArticPart(v->Next()); |
9627 | 46 |
} |
47 |
||
48 |
||
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5726
diff
changeset
|
49 |
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2); |
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
50 |
|
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9869
diff
changeset
|
51 |
byte GetRoadVehLength(const Vehicle *v); |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9869
diff
changeset
|
52 |
|
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9869
diff
changeset
|
53 |
void RoadVehUpdateCache(Vehicle *v); |
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9869
diff
changeset
|
54 |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
55 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
56 |
/** |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
57 |
* This class 'wraps' Vehicle; you do not actually instantiate this class. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
58 |
* You create a Vehicle using AllocateVehicle, so it is added to the pool |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
59 |
* and you reinitialize that to a Train using: |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
60 |
* v = new (v) RoadVehicle(); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
61 |
* |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
62 |
* As side-effect the vehicle type is set correctly. |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
63 |
*/ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
64 |
struct RoadVehicle : public Vehicle { |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
65 |
/** Initializes the Vehicle to a road vehicle */ |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
66 |
RoadVehicle() { this->type = VEH_ROAD; } |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
67 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
68 |
/** We want to 'destruct' the right class. */ |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
69 |
virtual ~RoadVehicle() { this->PreDestructor(); } |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
70 |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
71 |
const char *GetTypeString() const { return "road vehicle"; } |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
72 |
void MarkDirty(); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
73 |
void UpdateDeltaXY(Direction direction); |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
74 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; } |
9627 | 75 |
bool IsPrimaryVehicle() const { return IsRoadVehFront(this); } |
10294 | 76 |
SpriteID GetImage(Direction direction) const; |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
77 |
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; } |
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
78 |
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; } |
9732 | 79 |
Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * GetPriceByIndex(RoadVehInfo(this->engine_type)->running_cost_class); } |
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
80 |
bool IsInDepot() const { return this->u.road.state == RVSB_IN_DEPOT; } |
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9627
diff
changeset
|
81 |
void Tick(); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
82 |
void OnNewDay(); |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
83 |
TileIndex GetOrderStationLocation(StationID station); |
10142
56ee7da4ad56
(svn r12673) [NoAI] -Sync: with trunk r12596:12672. Note that due to the order rewrite AIOrder.ChangeOrder does currently not work as expected.
rubidium
parents:
9869
diff
changeset
|
84 |
bool FindClosestDepot(TileIndex *location, DestinationID *destination, bool *reverse); |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
85 |
}; |
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
86 |
|
4666
850b5b6e4bac
(svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents:
4653
diff
changeset
|
87 |
#endif /* ROADVEH_H */ |