mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(svn r16722) -Codechange: unify the naming of the Is/Set/HasArticulatedPart functions
This commit is contained in:
parent
f97bd41ed4
commit
18fbe0aac4
@ -412,8 +412,8 @@
|
||||
|
||||
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||
switch (v->type) {
|
||||
case VEH_ROAD: return ::RoadVehicle::From(v)->RoadVehHasArticPart();
|
||||
case VEH_TRAIN: return ::Train::From(v)->EngineHasArticPart();
|
||||
case VEH_ROAD: return ::RoadVehicle::From(v)->HasArticulatedPart();
|
||||
case VEH_TRAIN: return ::Train::From(v)->HasArticulatedPart();
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
@ -207,11 +207,11 @@ bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *carg
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN:
|
||||
v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
|
||||
v = Train::From(v)->HasArticulatedPart() ? GetNextArticPart(Train::From(v)) : NULL;
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
v = RoadVehicle::From(v)->RoadVehHasArticPart() ? v->Next() : NULL;
|
||||
v = RoadVehicle::From(v)->HasArticulatedPart() ? v->Next() : NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -254,11 +254,11 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
||||
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN:
|
||||
v = Train::From(v)->EngineHasArticPart() ? GetNextArticPart(Train::From(v)) : NULL;
|
||||
v = Train::From(v)->HasArticulatedPart() ? GetNextArticPart(Train::From(v)) : NULL;
|
||||
break;
|
||||
|
||||
case VEH_ROAD:
|
||||
v = RoadVehicle::From(v)->RoadVehHasArticPart() ? v->Next() : NULL;
|
||||
v = RoadVehicle::From(v)->HasArticulatedPart() ? v->Next() : NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -860,7 +860,7 @@ struct DepotWindow : Window {
|
||||
loaded [w->cargo_type] += w->cargo.Count();
|
||||
}
|
||||
|
||||
if (w->type == VEH_TRAIN && !Train::From(w)->EngineHasArticPart()) {
|
||||
if (w->type == VEH_TRAIN && !Train::From(w)->HasArticulatedPart()) {
|
||||
num++;
|
||||
if (!whole_chain) break;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ RoadStop *RoadStop::GetNextRoadStop(const RoadVehicle *v) const
|
||||
/* The vehicle cannot go to this roadstop (different roadtype) */
|
||||
if ((GetRoadTypes(rs->xy) & v->compatible_roadtypes) == ROADTYPES_NONE) continue;
|
||||
/* The vehicle is articulated and can therefor not go the a standard road stop */
|
||||
if (IsStandardRoadStopTile(rs->xy) && v->RoadVehHasArticPart()) continue;
|
||||
if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
|
||||
|
||||
/* The vehicle can actually go to this road stop. So, return it! */
|
||||
return rs;
|
||||
|
@ -151,7 +151,7 @@ struct RoadVehicle : public SpecializedVehicle<RoadVehicle, VEH_ROAD> {
|
||||
* Check if an engine has an articulated part.
|
||||
* @return True if the engine has an articulated part.
|
||||
*/
|
||||
FORCEINLINE bool RoadVehHasArticPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
|
||||
FORCEINLINE bool HasArticulatedPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
|
||||
};
|
||||
|
||||
#define FOR_ALL_ROADVEHICLES(var) FOR_ALL_VEHICLES_OF_TYPE(RoadVehicle, var)
|
||||
|
@ -916,7 +916,7 @@ static void RoadVehCheckOvertake(RoadVehicle *v, RoadVehicle *u)
|
||||
if (IsTileType(v->tile, MP_STATION)) return;
|
||||
|
||||
/* For now, articulated road vehicles can't overtake anything. */
|
||||
if (v->RoadVehHasArticPart()) return;
|
||||
if (v->HasArticulatedPart()) return;
|
||||
|
||||
/* Vehicles are not driving in same direction || direction is not a diagonal direction */
|
||||
if (v->direction != u->direction || !(v->direction & 1)) return;
|
||||
@ -1027,7 +1027,7 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection
|
||||
} else if (IsTileType(tile, MP_STATION) && IsStandardRoadStopTile(tile)) {
|
||||
/* Standard road stop (drive-through stops are treated as normal road) */
|
||||
|
||||
if (!IsTileOwner(tile, v->owner) || GetRoadStopDir(tile) == enterdir || v->RoadVehHasArticPart()) {
|
||||
if (!IsTileOwner(tile, v->owner) || GetRoadStopDir(tile) == enterdir || v->HasArticulatedPart()) {
|
||||
/* different station owner or wrong orientation or the vehicle has articulated parts */
|
||||
trackdirs = TRACKDIR_BIT_NONE;
|
||||
} else {
|
||||
|
@ -26,7 +26,7 @@ void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
|
||||
{
|
||||
const RoadVehicle *rv = RoadVehicle::From(v);
|
||||
|
||||
uint y_offset = rv->RoadVehHasArticPart() ? 15 : 0;
|
||||
uint y_offset = rv->HasArticulatedPart() ? 15 : 0;
|
||||
StringID str;
|
||||
Money feeder_share = 0;
|
||||
|
||||
@ -35,7 +35,7 @@ void DrawRoadVehDetails(const Vehicle *v, int left, int right, int y)
|
||||
SetDParam(2, v->value);
|
||||
DrawString(left, right, y + y_offset, STR_VEHICLE_INFO_BUILT_VALUE);
|
||||
|
||||
if (rv->RoadVehHasArticPart()) {
|
||||
if (rv->HasArticulatedPart()) {
|
||||
CargoArray max_cargo;
|
||||
StringID subtype_text[NUM_CARGO];
|
||||
char capacity[512];
|
||||
|
@ -1870,7 +1870,7 @@ bool AfterLoadGame()
|
||||
FOR_ALL_DISASTERVEHICLES(v) {
|
||||
if (v->subtype == 2/*ST_SMALL_UFO*/ && v->current_order.GetDestination() != 0) {
|
||||
const Vehicle *u = Vehicle::GetIfValid(v->dest_tile);
|
||||
if (u == NULL || u->type != VEH_ROAD || !IsRoadVehFront(u)) {
|
||||
if (u == NULL || u->type != VEH_ROAD || !RoadVehicle::From(u)->IsRoadVehFront()) {
|
||||
delete v;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
||||
/* The vehicle cannot go to this roadstop (different roadtype) */
|
||||
if ((GetRoadTypes(rs->xy) & v->compatible_roadtypes) == ROADTYPES_NONE) continue;
|
||||
/* The vehicle is articulated and can therefor not go the a standard road stop */
|
||||
if (IsStandardRoadStopTile(rs->xy) && v->RoadVehHasArticPart()) continue;
|
||||
if (IsStandardRoadStopTile(rs->xy) && v->HasArticulatedPart()) continue;
|
||||
|
||||
/* The vehicle can actually go to this road stop. So, return it! */
|
||||
break;
|
||||
|
@ -2570,7 +2570,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i
|
||||
|
||||
/* For normal (non drive-through) road stops
|
||||
* Check if station is busy or if there are no free bays or whether it is a articulated vehicle. */
|
||||
if (rs->IsEntranceBusy() || !rs->HasFreeBay() || rv->RoadVehHasArticPart()) return VETSB_CANNOT_ENTER;
|
||||
if (rs->IsEntranceBusy() || !rs->HasFreeBay() || rv->HasArticulatedPart()) return VETSB_CANNOT_ENTER;
|
||||
|
||||
SetBit(rv->state, RVS_IN_ROAD_STOP);
|
||||
|
||||
|
10
src/train.h
10
src/train.h
@ -259,7 +259,7 @@ struct Train : public SpecializedVehicle<Train, VEH_TRAIN> {
|
||||
* Check if an engine has an articulated part.
|
||||
* @return True if the engine has an articulated part.
|
||||
*/
|
||||
FORCEINLINE bool EngineHasArticPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
|
||||
FORCEINLINE bool HasArticulatedPart() const { return this->Next() != NULL && this->Next()->IsArticulatedPart(); }
|
||||
|
||||
};
|
||||
|
||||
@ -267,12 +267,12 @@ struct Train : public SpecializedVehicle<Train, VEH_TRAIN> {
|
||||
|
||||
/**
|
||||
* Get the next part of a multi-part engine.
|
||||
* Will only work on a multi-part engine (v->EngineHasArticPart() == true),
|
||||
* Will only work on a multi-part engine (v->HasArticulatedPart() == true),
|
||||
* Result is undefined for normal engine.
|
||||
*/
|
||||
static inline Train *GetNextArticPart(const Train *v)
|
||||
{
|
||||
assert(v->EngineHasArticPart());
|
||||
assert(v->HasArticulatedPart());
|
||||
return v->Next();
|
||||
}
|
||||
|
||||
@ -282,7 +282,7 @@ static inline Train *GetNextArticPart(const Train *v)
|
||||
*/
|
||||
static inline Train *GetLastEnginePart(Train *v)
|
||||
{
|
||||
while (v->EngineHasArticPart()) v = GetNextArticPart(v);
|
||||
while (v->HasArticulatedPart()) v = GetNextArticPart(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ static inline Train *GetLastEnginePart(Train *v)
|
||||
*/
|
||||
static inline Train *GetNextVehicle(const Train *v)
|
||||
{
|
||||
while (v->EngineHasArticPart()) v = GetNextArticPart(v);
|
||||
while (v->HasArticulatedPart()) v = GetNextArticPart(v);
|
||||
|
||||
/* v now contains the last artic part in the engine */
|
||||
return v->Next();
|
||||
|
@ -437,9 +437,9 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
if (CmdSucceeded(cost)) total_cost.AddCost(cost);
|
||||
}
|
||||
|
||||
if (w->type == VEH_TRAIN && Train::From(w)->EngineHasArticPart()) {
|
||||
if (w->type == VEH_TRAIN && Train::From(w)->HasArticulatedPart()) {
|
||||
w = GetNextArticPart(Train::From(w));
|
||||
} else if (w->type == VEH_ROAD && RoadVehicle::From(w)->RoadVehHasArticPart()) {
|
||||
} else if (w->type == VEH_ROAD && RoadVehicle::From(w)->HasArticulatedPart()) {
|
||||
w = w->Next();
|
||||
} else {
|
||||
break;
|
||||
@ -453,9 +453,9 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||
}
|
||||
}
|
||||
|
||||
if (v->type == VEH_TRAIN && Train::From(v)->EngineHasArticPart()) {
|
||||
if (v->type == VEH_TRAIN && Train::From(v)->HasArticulatedPart()) {
|
||||
v = GetNextArticPart(Train::From(v));
|
||||
} else if (v->type == VEH_ROAD && RoadVehicle::From(v)->RoadVehHasArticPart()) {
|
||||
} else if (v->type == VEH_ROAD && RoadVehicle::From(v)->HasArticulatedPart()) {
|
||||
v = v->Next();
|
||||
} else {
|
||||
break;
|
||||
|
@ -1355,7 +1355,7 @@ struct VehicleDetailsWindow : Window {
|
||||
case VEH_ROAD: {
|
||||
this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_QUERY_RENAME_ROAD_CAPTION;
|
||||
|
||||
if (!RoadVehicle::From(v)->RoadVehHasArticPart()) break;
|
||||
if (!RoadVehicle::From(v)->HasArticulatedPart()) break;
|
||||
|
||||
/* Draw the text under the vehicle instead of next to it, minus the
|
||||
* height already allocated for the cargo of the first vehicle. */
|
||||
|
Loading…
Reference in New Issue
Block a user