# HG changeset patch # User rubidium # Date 2009-07-02 09:06:15 # Node ID bb9023f5462885bdf52942ffe8351f270887e2fd # Parent 7f9f5ab6fe8533d4beb100488ab2754f1e04c036 (svn r16722) -Codechange: unify the naming of the Is/Set/HasArticulatedPart functions diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp --- a/src/ai/api/ai_vehicle.cpp +++ b/src/ai/api/ai_vehicle.cpp @@ -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(); } } diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -207,11 +207,11 @@ bool IsArticulatedVehicleCarryingDiffere 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 CheckConsistencyOfArticulatedVehicl 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: diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -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; } diff --git a/src/roadstop.cpp b/src/roadstop.cpp --- a/src/roadstop.cpp +++ b/src/roadstop.cpp @@ -40,7 +40,7 @@ RoadStop *RoadStop::GetNextRoadStop(cons /* 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; diff --git a/src/roadveh.h b/src/roadveh.h --- a/src/roadveh.h +++ b/src/roadveh.h @@ -151,7 +151,7 @@ struct RoadVehicle : public SpecializedV * 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) diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -916,7 +916,7 @@ static void RoadVehCheckOvertake(RoadVeh 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(RoadV } 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 { diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp --- a/src/roadveh_gui.cpp +++ b/src/roadveh_gui.cpp @@ -26,7 +26,7 @@ void DrawRoadVehDetails(const Vehicle *v { 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 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]; diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -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; } } diff --git a/src/station.cpp b/src/station.cpp --- a/src/station.cpp +++ b/src/station.cpp @@ -121,7 +121,7 @@ RoadStop *Station::GetPrimaryRoadStop(co /* 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; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -2570,7 +2570,7 @@ static VehicleEnterTileStatus VehicleEnt /* 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); diff --git a/src/train.h b/src/train.h --- a/src/train.h +++ b/src/train.h @@ -259,7 +259,7 @@ struct Train : public SpecializedVehicle * 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 /** * 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(co */ 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(T */ 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(); diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -437,9 +437,9 @@ CommandCost CmdCloneVehicle(TileIndex ti 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 ti } } - 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; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -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. */