|
@@ -119,49 +119,50 @@ void BaseStation::PostDestructor(size_t
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Get the primary road stop (the first road stop) that the given vehicle can load/unload.
|
|
|
* @param v the vehicle to get the first road stop for
|
|
|
* @return the first roadstop that this vehicle can load at
|
|
|
*/
|
|
|
RoadStop *Station::GetPrimaryRoadStop(const RoadVehicle *v) const
|
|
|
{
|
|
|
RoadStop *rs = this->GetPrimaryRoadStop(v->IsBus() ? ROADSTOP_BUS : ROADSTOP_TRUCK);
|
|
|
|
|
|
for (; rs != NULL; rs = rs->next) {
|
|
|
/* 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->HasArticulatedPart()) continue;
|
|
|
|
|
|
/* The vehicle can actually go to this road stop. So, return it! */
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
return rs;
|
|
|
}
|
|
|
|
|
|
/** Called when new facility is built on the station. If it is the first facility
|
|
|
/**
|
|
|
* Called when new facility is built on the station. If it is the first facility
|
|
|
* it initializes also 'xy' and 'random_bits' members */
|
|
|
void Station::AddFacility(StationFacility new_facility_bit, TileIndex facil_xy)
|
|
|
{
|
|
|
if (this->facilities == FACIL_NONE) {
|
|
|
this->xy = facil_xy;
|
|
|
this->random_bits = Random();
|
|
|
}
|
|
|
this->facilities |= new_facility_bit;
|
|
|
this->owner = _current_company;
|
|
|
this->build_date = _date;
|
|
|
}
|
|
|
|
|
|
void Station::MarkTilesDirty(bool cargo_change) const
|
|
|
{
|
|
|
TileIndex tile = this->train_station.tile;
|
|
|
int w, h;
|
|
|
|
|
|
if (tile == INVALID_TILE) return;
|
|
|
|
|
|
/* cargo_change is set if we're refreshing the tiles due to cargo moving
|
|
|
* around. */
|
|
|
if (cargo_change) {
|
|
|
/* Don't waste time updating if there are no custom station graphics
|
|
|
* that might change. Even if there are custom graphics, they might
|
|
@@ -196,49 +197,50 @@ void Station::MarkTilesDirty(bool cargo_
|
|
|
t = tile;
|
|
|
do {
|
|
|
t += delta;
|
|
|
len++;
|
|
|
} while (IsCompatibleTrainStationTile(t, tile));
|
|
|
|
|
|
return len - 1;
|
|
|
}
|
|
|
|
|
|
/* virtual */ uint Station::GetPlatformLength(TileIndex tile, DiagDirection dir) const
|
|
|
{
|
|
|
TileIndex start_tile = tile;
|
|
|
uint length = 0;
|
|
|
assert(IsRailStationTile(tile));
|
|
|
assert(dir < DIAGDIR_END);
|
|
|
|
|
|
do {
|
|
|
length++;
|
|
|
tile += TileOffsByDiagDir(dir);
|
|
|
} while (IsCompatibleTrainStationTile(tile, start_tile));
|
|
|
|
|
|
return length;
|
|
|
}
|
|
|
|
|
|
/** Determines the catchment radius of the station
|
|
|
/**
|
|
|
* Determines the catchment radius of the station
|
|
|
* @return The radius
|
|
|
*/
|
|
|
uint Station::GetCatchmentRadius() const
|
|
|
{
|
|
|
uint ret = CA_NONE;
|
|
|
|
|
|
if (_settings_game.station.modified_catchment) {
|
|
|
if (this->bus_stops != NULL) ret = max<uint>(ret, CA_BUS);
|
|
|
if (this->truck_stops != NULL) ret = max<uint>(ret, CA_TRUCK);
|
|
|
if (this->train_station.tile != INVALID_TILE) ret = max<uint>(ret, CA_TRAIN);
|
|
|
if (this->dock_tile != INVALID_TILE) ret = max<uint>(ret, CA_DOCK);
|
|
|
if (this->airport.tile != INVALID_TILE) ret = max<uint>(ret, this->airport.GetSpec()->catchment);
|
|
|
} else {
|
|
|
if (this->bus_stops != NULL || this->truck_stops != NULL || this->train_station.tile != INVALID_TILE || this->dock_tile != INVALID_TILE || this->airport.tile != INVALID_TILE) {
|
|
|
ret = CA_UNMODIFIED;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Determines catchment rectangle of this station
|
|
|
* @return clamped catchment rectangle
|