equal
deleted
inserted
replaced
|
1 /* $Id$ */ |
|
2 |
1 #include "stdafx.h" |
3 #include "stdafx.h" |
2 #include "openttd.h" |
4 #include "openttd.h" |
3 #include "functions.h" |
|
4 #include "rail_map.h" |
5 #include "rail_map.h" |
5 #include "road.h" |
|
6 #include "road_map.h" |
6 #include "road_map.h" |
|
7 #include "road_internal.h" |
7 #include "water_map.h" |
8 #include "water_map.h" |
8 #include "macros.h" |
9 #include "genworld.h" |
|
10 #include "player_func.h" |
|
11 #include "player_base.h" |
|
12 #include "engine.h" |
|
13 #include "settings_type.h" |
|
14 #include "date_func.h" |
9 |
15 |
10 bool IsPossibleCrossing(const TileIndex tile, Axis ax) |
16 bool IsPossibleCrossing(const TileIndex tile, Axis ax) |
11 { |
17 { |
12 return (IsTileType(tile, MP_RAILWAY) && |
18 return (IsTileType(tile, MP_RAILWAY) && |
13 !HasSignals(tile) && |
19 !HasSignals(tile) && |
65 } |
71 } |
66 } |
72 } |
67 |
73 |
68 return org_rb; |
74 return org_rb; |
69 } |
75 } |
|
76 |
|
77 bool HasRoadTypesAvail(const PlayerID p, const RoadTypes rts) |
|
78 { |
|
79 RoadTypes avail_roadtypes; |
|
80 |
|
81 if (p == OWNER_TOWN || _game_mode == GM_EDITOR || IsGeneratingWorld()) { |
|
82 avail_roadtypes = ROADTYPES_ROAD; |
|
83 } else { |
|
84 if (!IsValidPlayer(p)) return false; |
|
85 avail_roadtypes = (RoadTypes)GetPlayer(p)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody |
|
86 } |
|
87 return (rts & ~avail_roadtypes) == 0; |
|
88 } |
|
89 |
|
90 bool ValParamRoadType(const RoadType rt) |
|
91 { |
|
92 return HasRoadTypesAvail(_current_player, RoadTypeToRoadTypes(rt)); |
|
93 } |
|
94 |
|
95 RoadTypes GetPlayerRoadtypes(PlayerID p) |
|
96 { |
|
97 RoadTypes rt = ROADTYPES_NONE; |
|
98 |
|
99 for (EngineID i = 0; i != TOTAL_NUM_ENGINES; i++) { |
|
100 const Engine* e = GetEngine(i); |
|
101 const EngineInfo *ei = EngInfo(i); |
|
102 |
|
103 if (e->type == VEH_ROAD && HasBit(ei->climates, _opt.landscape) && |
|
104 (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) { |
|
105 SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD); |
|
106 } |
|
107 } |
|
108 |
|
109 return rt; |
|
110 } |