mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r11670) -Feature [FS#1565]: list neutral stations where the player has service in the station list too
This commit is contained in:
parent
5b49e75453
commit
4a80cf8482
|
@ -294,6 +294,8 @@ uint GetNumRoadStops(const Station* st, RoadStop::Type type);
|
|||
RoadStop * AllocateRoadStop();
|
||||
void ClearSlot(Vehicle *v);
|
||||
|
||||
bool HasStationInUse(StationID station, PlayerID player);
|
||||
|
||||
void DeleteOilRig(TileIndex t);
|
||||
|
||||
#endif /* STATION_H */
|
||||
|
|
|
@ -1868,15 +1868,20 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
|||
return CommandCost(_price.build_dock);
|
||||
}
|
||||
|
||||
/* Checks if any ship is servicing the buoy specified. Returns yes or no */
|
||||
static bool CheckShipsOnBuoy(Station *st)
|
||||
/**
|
||||
* Tests whether the player's vehicles have this station in orders
|
||||
* When player == INVALID_PLAYER, then check all vehicles
|
||||
* @param station station ID
|
||||
* @param player player ID, INVALID_PLAYER to disable the check
|
||||
*/
|
||||
bool HasStationInUse(StationID station, PlayerID player)
|
||||
{
|
||||
const Vehicle *v;
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (v->type == VEH_SHIP) {
|
||||
if (player == INVALID_PLAYER || v->owner == player) {
|
||||
const Order *order;
|
||||
FOR_VEHICLE_ORDERS(v, order) {
|
||||
if (order->type == OT_GOTO_STATION && order->dest == st->index) {
|
||||
if (order->type == OT_GOTO_STATION && order->dest == station) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1892,7 +1897,7 @@ static CommandCost RemoveBuoy(Station *st, uint32 flags)
|
|||
|
||||
TileIndex tile = st->dock_tile;
|
||||
|
||||
if (CheckShipsOnBuoy(st)) return_cmd_error(STR_BUOY_IS_IN_USE);
|
||||
if (HasStationInUse(st->index, INVALID_PLAYER)) return_cmd_error(STR_BUOY_IS_IN_USE);
|
||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "helpers.hpp"
|
||||
#include "cargotype.h"
|
||||
#include "station_gui.h"
|
||||
#include "station.h"
|
||||
|
||||
typedef int CDECL StationSortListingTypeFunction(const void*, const void*);
|
||||
|
||||
|
@ -233,7 +234,7 @@ static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities,
|
|||
DEBUG(misc, 3, "Building station list for player %d", owner);
|
||||
|
||||
FOR_ALL_STATIONS(st) {
|
||||
if (st->owner == owner) {
|
||||
if (st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy() && HasStationInUse(st->index, owner))) {
|
||||
if (facilities & st->facilities) { //only stations with selected facilities
|
||||
int num_waiting_cargo = 0;
|
||||
for (CargoID j = 0; j < NUM_CARGO; j++) {
|
||||
|
@ -380,7 +381,10 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
|
|||
int x;
|
||||
|
||||
assert(st->xy != 0);
|
||||
assert(st->owner == owner);
|
||||
|
||||
/* Do not do the complex check HasStationInUse here, it may be even false
|
||||
* when the order had been removed and the station list hasn't been removed yet */
|
||||
assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
|
||||
|
||||
SetDParam(0, st->index);
|
||||
SetDParam(1, st->facilities);
|
||||
|
@ -410,7 +414,8 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
|
|||
if (id_v >= sl->list_length) return; // click out of list bound
|
||||
|
||||
const Station *st = sl->sort_list[id_v];
|
||||
assert(st->owner == owner);
|
||||
/* do not check HasStationInUse - it is slow and may be invalid */
|
||||
assert(st->owner == owner || (st->owner == OWNER_NONE && !st->IsBuoy()));
|
||||
ScrollMainWindowToTile(st->xy);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue