| author | glx |
| Sat, 06 Oct 2007 22:30:24 +0000 | |
| branch | noai |
| changeset 9704 | 197cb8c6ae17 |
| parent 9703 | d2a6acdbd665 |
| child 9723 | eee46cb39750 |
| 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 |
|
| 3959 | 8 |
#include "vehicle.h" |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
9 |
#include "engine.h" |
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
10 |
#include "variables.h" |
| 3959 | 11 |
|
| 9627 | 12 |
enum RoadVehicleSubType {
|
13 |
RVST_FRONT, |
|
14 |
RVST_ARTIC_PART, |
|
15 |
}; |
|
16 |
||
17 |
static inline bool IsRoadVehFront(const Vehicle *v) |
|
18 |
{
|
|
19 |
assert(v->type == VEH_ROAD); |
|
20 |
return v->subtype == RVST_FRONT; |
|
21 |
} |
|
22 |
||
23 |
static inline void SetRoadVehFront(Vehicle *v) |
|
24 |
{
|
|
25 |
assert(v->type == VEH_ROAD); |
|
26 |
v->subtype = RVST_FRONT; |
|
27 |
} |
|
28 |
||
29 |
static inline bool IsRoadVehArticPart(const Vehicle *v) |
|
30 |
{
|
|
31 |
assert(v->type == VEH_ROAD); |
|
32 |
return v->subtype == RVST_ARTIC_PART; |
|
33 |
} |
|
34 |
||
35 |
static inline void SetRoadVehArticPart(Vehicle *v) |
|
36 |
{
|
|
37 |
assert(v->type == VEH_ROAD); |
|
38 |
v->subtype = RVST_ARTIC_PART; |
|
39 |
} |
|
40 |
||
41 |
static inline bool RoadVehHasArticPart(const Vehicle *v) |
|
42 |
{
|
|
43 |
assert(v->type == VEH_ROAD); |
|
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
44 |
return v->Next() != NULL && IsRoadVehArticPart(v->Next()); |
| 9627 | 45 |
} |
46 |
||
47 |
||
|
6037
7409c8f581e1
(svn r8338) -Codechange: merged road vehicle build window into the other ones
bjarni
parents:
5726
diff
changeset
|
48 |
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
|
49 |
|
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
50 |
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
51 |
/** |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
52 |
* 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
|
53 |
* 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
|
54 |
* 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
|
55 |
* 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
|
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 |
* 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
|
58 |
*/ |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
59 |
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
|
60 |
/** 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
|
61 |
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
|
62 |
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
63 |
/** We want to 'destruct' the right class. */ |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
64 |
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
|
65 |
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
|
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
70 |
WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; }
|
| 9627 | 71 |
bool IsPrimaryVehicle() const { return IsRoadVehFront(this); }
|
|
9631
8a2d1c2ceb88
(svn r10461) [NoAI] -Sync with trunk r10349:r10460.
rubidium
parents:
9627
diff
changeset
|
72 |
int GetImage(Direction direction) const; |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
73 |
int GetDisplaySpeed() const { return this->cur_speed * 10 / 32; }
|
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
74 |
int GetDisplayMaxSpeed() const { return this->max_speed * 10 / 32; }
|
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
75 |
Money GetRunningCost() const { return RoadVehInfo(this->engine_type)->running_cost * _price.roadveh_running; }
|
|
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9694
diff
changeset
|
76 |
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
|
77 |
void Tick(); |
|
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
78 |
}; |
|
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9574
diff
changeset
|
79 |
|
| 9627 | 80 |
byte GetRoadVehLength(const Vehicle *v); |
81 |
||
82 |
void RoadVehUpdateCache(Vehicle *v); |
|
83 |
||
|
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
|
84 |
#endif /* ROADVEH_H */ |