mirror of https://github.com/OpenTTD/OpenTTD
(svn r16959) -Codechange: make the station joiner a bit more aware of the difference between waypoints and stations.
parent
83b61a75c3
commit
5b576e6e7a
|
@ -551,8 +551,8 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
|
||||||
|
|
||||||
/* Make sure the station can accept the goods type. */
|
/* Make sure the station can accept the goods type. */
|
||||||
bool is_passengers = IsCargoInClass(i, CC_PASSENGERS);
|
bool is_passengers = IsCargoInClass(i, CC_PASSENGERS);
|
||||||
if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) ||
|
if ((!is_passengers && !(st->facilities & ~FACIL_BUS_STOP)) ||
|
||||||
(is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP))) {
|
(is_passengers && !(st->facilities & ~FACIL_TRUCK_STOP))) {
|
||||||
amt = 0;
|
amt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ static void UpdateStationAcceptance(Station *st, bool show_msg)
|
||||||
if (old_acc == new_acc) return;
|
if (old_acc == new_acc) return;
|
||||||
|
|
||||||
/* show a message to report that the acceptance was changed? */
|
/* show a message to report that the acceptance was changed? */
|
||||||
if (show_msg && st->owner == _local_company && st->facilities) {
|
if (show_msg && st->owner == _local_company && st->IsInUse()) {
|
||||||
/* List of accept and reject strings for different number of
|
/* List of accept and reject strings for different number of
|
||||||
* cargo types */
|
* cargo types */
|
||||||
static const StringID accept_msg[] = {
|
static const StringID accept_msg[] = {
|
||||||
|
|
|
@ -1076,22 +1076,15 @@ struct TileAndStation {
|
||||||
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
|
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
|
||||||
static SmallVector<StationID, 8> _stations_nearby_list;
|
static SmallVector<StationID, 8> _stations_nearby_list;
|
||||||
|
|
||||||
/** Context for FindStationsNearby */
|
|
||||||
struct FindNearbyStationContext {
|
|
||||||
TileIndex tile; ///< Base tile of station to be built
|
|
||||||
uint w; ///< Width of station to be built
|
|
||||||
uint h; ///< Height of station to be built
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add station on this tile to _stations_nearby_list if it's fully within the
|
* Add station on this tile to _stations_nearby_list if it's fully within the
|
||||||
* station spread.
|
* station spread.
|
||||||
* @param tile Tile just being checked
|
* @param tile Tile just being checked
|
||||||
* @param user_data Pointer to FindNearbyStationContext context
|
* @param user_data Pointer to TileArea context
|
||||||
*/
|
*/
|
||||||
static bool AddNearbyStation(TileIndex tile, void *user_data)
|
static bool AddNearbyStation(TileIndex tile, void *user_data)
|
||||||
{
|
{
|
||||||
FindNearbyStationContext *ctx = (FindNearbyStationContext *)user_data;
|
TileArea *ctx = (TileArea *)user_data;
|
||||||
|
|
||||||
/* First check if there were deleted stations here */
|
/* First check if there were deleted stations here */
|
||||||
for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
|
for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
|
||||||
|
@ -1107,6 +1100,10 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
|
||||||
if (!IsTileType(tile, MP_STATION)) return false;
|
if (!IsTileType(tile, MP_STATION)) return false;
|
||||||
|
|
||||||
StationID sid = GetStationIndex(tile);
|
StationID sid = GetStationIndex(tile);
|
||||||
|
|
||||||
|
/* This station is (likely) a waypoint */
|
||||||
|
if (!Station::IsValidID(sid)) return false;
|
||||||
|
|
||||||
Station *st = Station::Get(sid);
|
Station *st = Station::Get(sid);
|
||||||
if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
|
if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
|
||||||
|
|
||||||
|
@ -1129,7 +1126,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
|
||||||
**/
|
**/
|
||||||
static const Station *FindStationsNearby(TileIndex tile, int w, int h, bool distant_join)
|
static const Station *FindStationsNearby(TileIndex tile, int w, int h, bool distant_join)
|
||||||
{
|
{
|
||||||
FindNearbyStationContext ctx;
|
TileArea ctx;
|
||||||
ctx.tile = tile;
|
ctx.tile = tile;
|
||||||
ctx.w = w;
|
ctx.w = w;
|
||||||
ctx.h = h;
|
ctx.h = h;
|
||||||
|
@ -1139,13 +1136,13 @@ static const Station *FindStationsNearby(TileIndex tile, int w, int h, bool dist
|
||||||
|
|
||||||
/* Check the inside, to return, if we sit on another station */
|
/* Check the inside, to return, if we sit on another station */
|
||||||
BEGIN_TILE_LOOP(t, w, h, tile)
|
BEGIN_TILE_LOOP(t, w, h, tile)
|
||||||
if (t < MapSize() && IsTileType(t, MP_STATION)) return Station::GetByTile(t);
|
if (t < MapSize() && IsTileType(t, MP_STATION) && Station::IsValidID(GetStationIndex(t))) return Station::GetByTile(t);
|
||||||
END_TILE_LOOP(t, w, h, tile)
|
END_TILE_LOOP(t, w, h, tile)
|
||||||
|
|
||||||
/* Look for deleted stations */
|
/* Look for deleted stations */
|
||||||
const Station *st;
|
const BaseStation *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_BASE_STATIONS(st) {
|
||||||
if (st->facilities == 0 && st->owner == _local_company) {
|
if (Station::IsExpected(st) && !st->IsInUse() && st->owner == _local_company) {
|
||||||
/* Include only within station spread (yes, it is strictly less than) */
|
/* Include only within station spread (yes, it is strictly less than) */
|
||||||
if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) {
|
if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) {
|
||||||
TileAndStation *ts = _deleted_stations_nearby.Append();
|
TileAndStation *ts = _deleted_stations_nearby.Append();
|
||||||
|
|
Loading…
Reference in New Issue