mirror of https://github.com/OpenTTD/OpenTTD
Change: Set the DepotID as the window number of WC_VEHICLE_DEPOT windows instead of a TileIndex.
parent
9e7e84fd10
commit
dc0bd387b6
|
@ -1490,7 +1490,7 @@ void AircraftLeaveHangar(Aircraft *v, Direction exit_dir)
|
|||
VehicleServiceInDepot(v);
|
||||
v->LeaveUnbunchingDepot();
|
||||
SetAircraftPosition(v, v->x_pos, v->y_pos, v->z_pos);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
if (IsHangarTile(v->tile)) InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
SetWindowClassesDirty(WC_AIRCRAFT_LIST);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ Depot::~Depot()
|
|||
RemoveOrderFromAllVehicles(OT_GOTO_DEPOT, this->index);
|
||||
|
||||
/* Delete the depot-window */
|
||||
CloseWindowById(WC_VEHICLE_DEPOT, this->xy);
|
||||
CloseWindowById(WC_VEHICLE_DEPOT, this->index);
|
||||
|
||||
/* Delete the depot list */
|
||||
VehicleType vt = GetDepotVehicleType(this->xy);
|
||||
|
|
|
@ -68,7 +68,7 @@ CommandCost CmdRenameDepot(DoCommandFlag flags, DepotID depot_id, const std::str
|
|||
|
||||
/* Update the orders and depot */
|
||||
SetWindowClassesDirty(WC_VEHICLE_ORDERS);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, d->xy);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, d->index);
|
||||
|
||||
/* Update the depot list */
|
||||
VehicleType vt = GetDepotVehicleType(d->xy);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "vehicle_type.h"
|
||||
#include "slope_func.h"
|
||||
|
||||
void ShowDepotWindow(TileIndex tile, VehicleType type);
|
||||
void ShowDepotWindow(DepotID depot_id);
|
||||
void InitDepotWindowBlockSizes();
|
||||
|
||||
void DeleteDepotHighlightOfVehicle(const Vehicle *v);
|
||||
|
|
|
@ -266,15 +266,17 @@ struct DepotWindow : Window {
|
|||
Scrollbar *hscroll; ///< Only for trains.
|
||||
Scrollbar *vscroll;
|
||||
|
||||
DepotWindow(WindowDesc &desc, TileIndex tile, VehicleType type) : Window(desc)
|
||||
DepotWindow(WindowDesc &desc, DepotID depot_id) : Window(desc)
|
||||
{
|
||||
assert(IsCompanyBuildableVehicleType(type)); // ensure that we make the call with a valid type
|
||||
assert(Depot::IsValidID(depot_id));
|
||||
Depot *depot = Depot::Get(depot_id);
|
||||
assert(IsCompanyBuildableVehicleType(GetDepotVehicleType(depot->xy)));
|
||||
|
||||
this->sel = INVALID_VEHICLE;
|
||||
this->vehicle_over = INVALID_VEHICLE;
|
||||
this->generate_list = true;
|
||||
this->hovered_widget = -1;
|
||||
this->type = type;
|
||||
this->type = GetDepotVehicleType(depot->xy);
|
||||
this->num_columns = 1; // for non-trains this gets set in FinishInitNested()
|
||||
this->unitnumber_digits = 2;
|
||||
|
||||
|
@ -282,22 +284,22 @@ struct DepotWindow : Window {
|
|||
this->hscroll = (this->type == VEH_TRAIN ? this->GetScrollbar(WID_D_H_SCROLL) : nullptr);
|
||||
this->vscroll = this->GetScrollbar(WID_D_V_SCROLL);
|
||||
/* Don't show 'rename button' of aircraft hangar */
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_RENAME)->SetDisplayedPlane(type == VEH_AIRCRAFT ? SZSP_NONE : 0);
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_RENAME)->SetDisplayedPlane(this->type == VEH_AIRCRAFT ? SZSP_NONE : 0);
|
||||
/* Only train depots have a horizontal scrollbar and a 'sell chain' button */
|
||||
if (type == VEH_TRAIN) this->GetWidget<NWidgetCore>(WID_D_MATRIX)->widget_data = 1 << MAT_COL_START;
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_H_SCROLL)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_HORIZONTAL);
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_SELL_CHAIN)->SetDisplayedPlane(type == VEH_TRAIN ? 0 : SZSP_NONE);
|
||||
this->SetupWidgetData(type);
|
||||
this->FinishInitNested(tile);
|
||||
if (this->type == VEH_TRAIN) this->GetWidget<NWidgetCore>(WID_D_MATRIX)->widget_data = 1 << MAT_COL_START;
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_H_SCROLL)->SetDisplayedPlane(this->type == VEH_TRAIN ? 0 : SZSP_HORIZONTAL);
|
||||
this->GetWidget<NWidgetStacked>(WID_D_SHOW_SELL_CHAIN)->SetDisplayedPlane(this->type == VEH_TRAIN ? 0 : SZSP_NONE);
|
||||
this->SetupWidgetData(this->type);
|
||||
this->FinishInitNested(depot_id);
|
||||
|
||||
this->owner = GetTileOwner(tile);
|
||||
this->owner = GetTileOwner(depot->xy);
|
||||
OrderBackup::Reset();
|
||||
}
|
||||
|
||||
void Close([[maybe_unused]] int data = 0) override
|
||||
{
|
||||
CloseWindowById(WC_BUILD_VEHICLE, this->window_number);
|
||||
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->GetDepotIndex()).Pack(), false);
|
||||
CloseWindowById(GetWindowClassForVehicleType(this->type), VehicleListIdentifier(VL_DEPOT_LIST, this->type, this->owner, this->window_number).Pack(), false);
|
||||
OrderBackup::Reset(this->window_number);
|
||||
this->Window::Close();
|
||||
}
|
||||
|
@ -426,7 +428,7 @@ struct DepotWindow : Window {
|
|||
if (widget != WID_D_CAPTION) return;
|
||||
|
||||
SetDParam(0, this->type);
|
||||
SetDParam(1, this->GetDepotIndex());
|
||||
SetDParam(1, (this->type == VEH_AIRCRAFT) ? GetStationIndex(Depot::Get(this->window_number)->xy) : this->window_number);
|
||||
}
|
||||
|
||||
struct GetDepotVehiclePtData {
|
||||
|
@ -711,7 +713,7 @@ struct DepotWindow : Window {
|
|||
if (this->generate_list) {
|
||||
/* Generate the vehicle list
|
||||
* It's ok to use the wagon pointers for non-trains as they will be ignored */
|
||||
BuildDepotVehicleList(this->type, this->window_number, &this->vehicle_list, &this->wagon_list);
|
||||
BuildDepotVehicleList(this->type, Depot::Get(this->window_number)->xy, &this->vehicle_list, &this->wagon_list);
|
||||
this->generate_list = false;
|
||||
DepotSortList(&this->vehicle_list);
|
||||
|
||||
|
@ -742,8 +744,7 @@ struct DepotWindow : Window {
|
|||
}
|
||||
|
||||
/* Setup disabled buttons. */
|
||||
TileIndex tile = this->window_number;
|
||||
this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
|
||||
this->SetWidgetsDisabledState(this->owner != _local_company,
|
||||
WID_D_STOP_ALL,
|
||||
WID_D_START_ALL,
|
||||
WID_D_SELL,
|
||||
|
@ -759,6 +760,8 @@ struct DepotWindow : Window {
|
|||
|
||||
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
|
||||
{
|
||||
TileIndex tile = Depot::Get(this->window_number)->xy;
|
||||
|
||||
switch (widget) {
|
||||
case WID_D_MATRIX: // List
|
||||
this->DepotClick(pt.x, pt.y);
|
||||
|
@ -766,7 +769,7 @@ struct DepotWindow : Window {
|
|||
|
||||
case WID_D_BUILD: // Build vehicle
|
||||
ResetObjectToPlace();
|
||||
ShowBuildVehicleWindow(this->window_number, this->type);
|
||||
ShowBuildVehicleWindow(Depot::Get(this->window_number)->xy, this->type);
|
||||
break;
|
||||
|
||||
case WID_D_CLONE: // Clone button
|
||||
|
@ -789,20 +792,20 @@ struct DepotWindow : Window {
|
|||
if (_ctrl_pressed) {
|
||||
ShowExtraViewportWindow(this->window_number);
|
||||
} else {
|
||||
ScrollMainWindowToTile(this->window_number);
|
||||
ScrollMainWindowToTile(tile);
|
||||
}
|
||||
break;
|
||||
|
||||
case WID_D_RENAME: // Rename button
|
||||
SetDParam(0, this->type);
|
||||
SetDParam(1, Depot::GetByTile((TileIndex)this->window_number)->index);
|
||||
SetDParam(1, this->window_number);
|
||||
ShowQueryString(STR_DEPOT_NAME, STR_DEPOT_RENAME_DEPOT_CAPTION, MAX_LENGTH_DEPOT_NAME_CHARS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT | QSF_LEN_IN_CHARS);
|
||||
break;
|
||||
|
||||
case WID_D_STOP_ALL:
|
||||
case WID_D_START_ALL: {
|
||||
VehicleListIdentifier vli(VL_DEPOT_LIST, this->type, this->owner);
|
||||
Command<CMD_MASS_START_STOP>::Post(this->window_number, widget == WID_D_START_ALL, false, vli);
|
||||
Command<CMD_MASS_START_STOP>::Post(tile, widget == WID_D_START_ALL, false, vli);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -810,7 +813,7 @@ struct DepotWindow : Window {
|
|||
/* Only open the confirmation window if there are anything to sell */
|
||||
if (!this->vehicle_list.empty() || !this->wagon_list.empty()) {
|
||||
SetDParam(0, this->type);
|
||||
SetDParam(1, this->GetDepotIndex());
|
||||
SetDParam(1, this->window_number);
|
||||
ShowQuery(
|
||||
STR_DEPOT_CAPTION,
|
||||
STR_DEPOT_SELL_CONFIRMATION_TEXT,
|
||||
|
@ -821,11 +824,11 @@ struct DepotWindow : Window {
|
|||
break;
|
||||
|
||||
case WID_D_VEHICLE_LIST:
|
||||
ShowVehicleListWindow(GetTileOwner(this->window_number), this->type, (TileIndex)this->window_number);
|
||||
ShowVehicleListWindow(this->owner, this->type, Depot::Get(this->window_number)->xy);
|
||||
break;
|
||||
|
||||
case WID_D_AUTOREPLACE:
|
||||
Command<CMD_DEPOT_MASS_AUTOREPLACE>::Post(this->window_number, this->type);
|
||||
Command<CMD_DEPOT_MASS_AUTOREPLACE>::Post(tile, this->type);
|
||||
break;
|
||||
|
||||
}
|
||||
|
@ -836,7 +839,7 @@ struct DepotWindow : Window {
|
|||
if (!str.has_value()) return;
|
||||
|
||||
/* Do depot renaming */
|
||||
Command<CMD_RENAME_DEPOT>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->GetDepotIndex(), *str);
|
||||
Command<CMD_RENAME_DEPOT>::Post(STR_ERROR_CAN_T_RENAME_DEPOT, this->window_number, *str);
|
||||
}
|
||||
|
||||
bool OnRightClick([[maybe_unused]] Point pt, WidgetID widget) override
|
||||
|
@ -902,10 +905,10 @@ struct DepotWindow : Window {
|
|||
{
|
||||
if (_ctrl_pressed) {
|
||||
/* Share-clone, do not open new viewport, and keep tool active */
|
||||
Command<CMD_CLONE_VEHICLE>::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, this->window_number, v->index, true);
|
||||
Command<CMD_CLONE_VEHICLE>::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, Depot::Get(this->window_number)->xy, v->index, true);
|
||||
} else {
|
||||
/* Copy-clone, open viewport for new vehicle, and deselect the tool (assume player wants to change things on new vehicle) */
|
||||
if (Command<CMD_CLONE_VEHICLE>::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, CcCloneVehicle, this->window_number, v->index, false)) {
|
||||
if (Command<CMD_CLONE_VEHICLE>::Post(STR_ERROR_CAN_T_BUY_TRAIN + v->type, CcCloneVehicle, Depot::Get(this->window_number)->xy, v->index, false)) {
|
||||
ResetObjectToPlace();
|
||||
}
|
||||
}
|
||||
|
@ -1111,43 +1114,33 @@ struct DepotWindow : Window {
|
|||
|
||||
return ES_NOT_HANDLED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DepotID of the current window.
|
||||
* In the case of airports, this is the station ID.
|
||||
* @return Depot or station ID of this window.
|
||||
*/
|
||||
inline uint16_t GetDepotIndex() const
|
||||
{
|
||||
return (this->type == VEH_AIRCRAFT) ? ::GetStationIndex(this->window_number) : ::GetDepotIndex(this->window_number);
|
||||
}
|
||||
};
|
||||
|
||||
static void DepotSellAllConfirmationCallback(Window *win, bool confirmed)
|
||||
{
|
||||
if (confirmed) {
|
||||
DepotWindow *w = (DepotWindow*)win;
|
||||
TileIndex tile = w->window_number;
|
||||
VehicleType vehtype = w->type;
|
||||
Command<CMD_DEPOT_SELL_ALL_VEHICLES>::Post(tile, vehtype);
|
||||
assert(Depot::IsValidID(win->window_number));
|
||||
Depot *d = Depot::Get(win->window_number);
|
||||
Command<CMD_DEPOT_SELL_ALL_VEHICLES>::Post(d->xy, GetDepotVehicleType(d->xy));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a depot window
|
||||
* @param tile The tile where the depot/hangar is located
|
||||
* @param type The type of vehicles in the depot
|
||||
* Opens a depot window.
|
||||
* @param depot_id Index of the depot.
|
||||
*/
|
||||
void ShowDepotWindow(TileIndex tile, VehicleType type)
|
||||
void ShowDepotWindow(DepotID depot_id)
|
||||
{
|
||||
if (BringWindowToFrontById(WC_VEHICLE_DEPOT, tile) != nullptr) return;
|
||||
assert(Depot::IsValidID(depot_id));
|
||||
if (BringWindowToFrontById(WC_VEHICLE_DEPOT, depot_id) != nullptr) return;
|
||||
|
||||
switch (type) {
|
||||
Depot *d = Depot::Get(depot_id);
|
||||
switch (GetDepotVehicleType(d->xy)) {
|
||||
default: NOT_REACHED();
|
||||
case VEH_TRAIN: new DepotWindow(_train_depot_desc, tile, type); break;
|
||||
case VEH_ROAD: new DepotWindow(_road_depot_desc, tile, type); break;
|
||||
case VEH_SHIP: new DepotWindow(_ship_depot_desc, tile, type); break;
|
||||
case VEH_AIRCRAFT: new DepotWindow(_aircraft_depot_desc, tile, type); break;
|
||||
case VEH_TRAIN: new DepotWindow(_train_depot_desc, depot_id); break;
|
||||
case VEH_ROAD: new DepotWindow(_road_depot_desc, depot_id); break;
|
||||
case VEH_SHIP: new DepotWindow(_ship_depot_desc, depot_id); break;
|
||||
case VEH_AIRCRAFT: new DepotWindow(_aircraft_depot_desc, depot_id); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1157,11 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v)
|
|||
*/
|
||||
if (_special_mouse_mode != WSM_DRAGDROP) return;
|
||||
|
||||
w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, v->tile));
|
||||
/* For shadows and rotors, do nothing. */
|
||||
if (v->type == VEH_AIRCRAFT && !Aircraft::From(v)->IsNormalAircraft()) return;
|
||||
|
||||
assert(IsDepotTile(v->tile));
|
||||
w = dynamic_cast<DepotWindow*>(FindWindowById(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile)));
|
||||
if (w != nullptr) {
|
||||
if (w->sel == v->index) ResetObjectToPlace();
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "core/pool_func.hpp"
|
||||
#include "order_backup.h"
|
||||
#include "group_cmd.h"
|
||||
#include "depot_map.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
|
@ -579,7 +580,7 @@ std::tuple<CommandCost, GroupID> CmdAddVehicleGroup(DoCommandFlag flags, GroupID
|
|||
}
|
||||
}
|
||||
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
if (IsDepotTypeTile(v->tile, (TransportType)v->type)) SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, v->index);
|
||||
SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
|
||||
InvalidateWindowData(WC_VEHICLE_VIEW, v->index);
|
||||
|
|
|
@ -1654,8 +1654,9 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
YapfNotifyTrackLayoutChange(tile, GetRailDepotTrack(tile));
|
||||
|
||||
/* Update build vehicle window related to this depot */
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
|
||||
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
|
||||
DepotID depot_id = GetDepotIndex(tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, depot_id);
|
||||
InvalidateWindowData(WC_BUILD_VEHICLE, depot_id);
|
||||
}
|
||||
found_convertible_track = true;
|
||||
cost.AddCost(RailConvertCost(type, totype));
|
||||
|
@ -2774,7 +2775,7 @@ static bool ClickTile_Track(TileIndex tile)
|
|||
{
|
||||
if (!IsRailDepot(tile)) return false;
|
||||
|
||||
ShowDepotWindow(tile, VEH_TRAIN);
|
||||
ShowDepotWindow(GetDepotIndex(tile));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2973,7 +2974,7 @@ static VehicleEnterTileStatus VehicleEnter_Track(Vehicle *u, TileIndex tile, int
|
|||
if (v->Next() == nullptr) VehicleEnterDepot(v->First());
|
||||
v->tile = tile;
|
||||
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
return VETSB_ENTERED_WORMHOLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -2081,7 +2081,7 @@ static bool ClickTile_Road(TileIndex tile)
|
|||
{
|
||||
if (!IsRoadDepot(tile)) return false;
|
||||
|
||||
ShowDepotWindow(tile, VEH_ROAD);
|
||||
ShowDepotWindow(GetDepotIndex(tile));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2269,7 +2269,7 @@ static VehicleEnterTileStatus VehicleEnter_Road(Vehicle *v, TileIndex tile, int,
|
|||
if (rv->Next() == nullptr) VehicleEnterDepot(rv->First());
|
||||
rv->tile = tile;
|
||||
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, rv->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(rv->tile));
|
||||
return VETSB_ENTERED_WORMHOLE;
|
||||
}
|
||||
break;
|
||||
|
@ -2543,8 +2543,8 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
|||
|
||||
if (IsRoadDepotTile(tile)) {
|
||||
/* Update build vehicle window related to this depot */
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
|
||||
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(tile));
|
||||
InvalidateWindowData(WC_BUILD_VEHICLE, GetDepotIndex(tile));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1043,7 +1043,7 @@ bool RoadVehLeaveDepot(RoadVehicle *v, bool first)
|
|||
v->UpdatePosition();
|
||||
v->UpdateInclination(true, true);
|
||||
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -424,12 +424,13 @@ static bool CheckShipLeaveDepot(Ship *v)
|
|||
|
||||
v->cur_speed = 0;
|
||||
v->UpdateViewport(true, true);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
DepotID depot_id = GetDepotIndex(v->tile);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, depot_id);
|
||||
|
||||
VehicleServiceInDepot(v);
|
||||
v->LeaveUnbunchingDepot();
|
||||
v->PlayLeaveStationSound();
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, depot_id);
|
||||
SetWindowClassesDirty(WC_SHIPS_LIST);
|
||||
|
||||
return false;
|
||||
|
|
|
@ -2682,7 +2682,6 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags)
|
|||
for (uint i = 0; i < st->airport.GetNumHangars(); ++i) {
|
||||
TileIndex tile_cur = st->airport.GetHangarTile(i);
|
||||
OrderBackup::Reset(tile_cur, false);
|
||||
CloseWindowById(WC_VEHICLE_DEPOT, tile_cur);
|
||||
}
|
||||
st->airport.RemoveHangar();
|
||||
|
||||
|
@ -3698,8 +3697,8 @@ static bool ClickTile_Station(TileIndex tile)
|
|||
if (bst->facilities & FACIL_WAYPOINT) {
|
||||
ShowWaypointWindow(Waypoint::From(bst));
|
||||
} else if (IsHangar(tile)) {
|
||||
const Station *st = Station::From(bst);
|
||||
ShowDepotWindow(st->airport.GetHangarTile(st->airport.GetHangarNum(tile)), VEH_AIRCRAFT);
|
||||
assert(Station::From(bst)->airport.HasHangar());
|
||||
ShowDepotWindow(Station::From(bst)->airport.hangar->index);
|
||||
} else {
|
||||
ShowStationViewWindow(bst->index);
|
||||
}
|
||||
|
|
|
@ -615,6 +615,8 @@ void GetTrainSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs,
|
|||
static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const Engine *e, Vehicle **ret)
|
||||
{
|
||||
const RailVehicleInfo *rvi = &e->u.rail;
|
||||
assert(IsRailDepotTile(tile));
|
||||
DepotID depot_id = GetDepotIndex(tile);
|
||||
|
||||
/* Check that the wagon can drive on the track in question */
|
||||
if (!IsCompatibleRail(rvi->railtype, GetRailType(tile))) return CMD_ERROR;
|
||||
|
@ -645,7 +647,7 @@ static CommandCost CmdBuildRailWagon(DoCommandFlag flags, TileIndex tile, const
|
|||
v->SetWagon();
|
||||
|
||||
v->SetFreeWagon();
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, depot_id);
|
||||
|
||||
v->cargo_type = e->GetDefaultCargoType();
|
||||
assert(IsValidCargoID(v->cargo_type));
|
||||
|
@ -1363,7 +1365,7 @@ CommandCost CmdMoveRailVehicle(DoCommandFlag flags, VehicleID src_veh, VehicleID
|
|||
if (dst_head != nullptr) dst_head->First()->MarkDirty();
|
||||
|
||||
/* We are undoubtedly changing something in the depot and train list. */
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, src->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(src->tile));
|
||||
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||
} else {
|
||||
/* We don't want to execute what we're just tried. */
|
||||
|
@ -1447,7 +1449,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, bool sell_chain, b
|
|||
NormaliseTrainHead(new_head);
|
||||
|
||||
/* We are undoubtedly changing something in the depot and train list. */
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||
|
||||
/* Actually delete the sold 'goods' */
|
||||
|
@ -1966,7 +1968,7 @@ void ReverseTrainDirection(Train *v)
|
|||
{
|
||||
if (IsRailDepotTile(v->tile)) {
|
||||
if (IsWholeTrainInsideDepot(v)) return;
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
}
|
||||
|
||||
/* Clear path reservation in front if train is not stuck. */
|
||||
|
@ -1989,7 +1991,7 @@ void ReverseTrainDirection(Train *v)
|
|||
AdvanceWagonsAfterSwap(v);
|
||||
|
||||
if (IsRailDepotTile(v->tile)) {
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
}
|
||||
|
||||
ToggleBit(v->flags, VRF_TOGGLE_REVERSE);
|
||||
|
@ -2079,7 +2081,7 @@ CommandCost CmdReverseTrainDirection(DoCommandFlag flags, VehicleID veh_id, bool
|
|||
ToggleBit(v->flags, VRF_REVERSE_DIRECTION);
|
||||
|
||||
front->ConsistChanged(CCF_ARRANGE);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
|
||||
if (IsRailDepotTile(front->tile)) SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(front->tile));
|
||||
SetWindowDirty(WC_VEHICLE_DETAILS, front->index);
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, front->index);
|
||||
SetWindowClassesDirty(WC_TRAINS_LIST);
|
||||
|
@ -2273,7 +2275,7 @@ static bool CheckTrainStayInDepot(Train *v)
|
|||
/* if the train got no power, then keep it in the depot */
|
||||
if (v->gcache.cached_power == 0) {
|
||||
v->vehstatus |= VS_STOPPED;
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2334,7 +2336,7 @@ static bool CheckTrainStayInDepot(Train *v)
|
|||
v->UpdatePosition();
|
||||
UpdateSignalsOnSegment(v->tile, INVALID_DIAGDIR, v->owner);
|
||||
v->UpdateAcceleration();
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -3628,7 +3630,7 @@ static void DeleteLastWagon(Train *v)
|
|||
/* Update the depot window if the first vehicle is in depot -
|
||||
* if v == first, then it is updated in PreDestructor() */
|
||||
if (first->track == TRACK_BIT_DEPOT) {
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, first->tile);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(first->tile));
|
||||
}
|
||||
v->last_station_visited = first->last_station_visited; // for PreDestructor
|
||||
}
|
||||
|
|
|
@ -297,7 +297,7 @@ uint Vehicle::Crash(bool)
|
|||
InvalidateWindowClassesData(GetWindowClassForVehicleType(this->type), 0);
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, this->index, WID_VV_START_STOP);
|
||||
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, this->tile);
|
||||
if (IsDepotTile(this->tile)) SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(this->tile));
|
||||
|
||||
delete this->cargo_payment;
|
||||
assert(this->cargo_payment == nullptr); // cleared by ~CargoPayment
|
||||
|
@ -868,8 +868,8 @@ void Vehicle::PreDestructor()
|
|||
if (v->disaster_vehicle != INVALID_VEHICLE) ReleaseDisasterVehicle(v->disaster_vehicle);
|
||||
}
|
||||
|
||||
if (this->Previous() == nullptr) {
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, this->tile);
|
||||
if (this->Previous() == nullptr && IsDepotTile(this->tile)) {
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(this->tile));
|
||||
}
|
||||
|
||||
if (this->IsPrimaryVehicle()) {
|
||||
|
@ -1554,6 +1554,7 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
/* Always work with the front of the vehicle */
|
||||
assert(v == v->First());
|
||||
|
||||
DepotID depot_id = GetDepotIndex(v->tile);
|
||||
switch (v->type) {
|
||||
case VEH_TRAIN: {
|
||||
Train *t = Train::From(v);
|
||||
|
@ -1580,7 +1581,7 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
ship->state = TRACK_BIT_DEPOT;
|
||||
ship->UpdateCache();
|
||||
ship->UpdateViewport(true, true);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, depot_id);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1595,9 +1596,9 @@ void VehicleEnterDepot(Vehicle *v)
|
|||
if (v->type != VEH_TRAIN) {
|
||||
/* Trains update the vehicle list when the first unit enters the depot and calls VehicleEnterDepot() when the last unit enters.
|
||||
* We only increase the number of vehicles when the first one enters, so we will not need to search for more vehicles in the depot */
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, depot_id);
|
||||
}
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, depot_id);
|
||||
|
||||
v->vehstatus |= VS_HIDDEN;
|
||||
v->cur_speed = 0;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "roadveh_cmd.h"
|
||||
#include "train_cmd.h"
|
||||
#include "ship_cmd.h"
|
||||
#include "depot_base.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -178,7 +179,7 @@ std::tuple<CommandCost, VehicleID, uint, uint16_t, CargoArray> CmdBuildVehicle(D
|
|||
NormalizeTrainVehInDepot(Train::From(v));
|
||||
}
|
||||
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||
InvalidateWindowData(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0);
|
||||
SetWindowDirty(WC_COMPANY, _current_company);
|
||||
if (IsLocalCompany()) {
|
||||
|
@ -553,7 +554,7 @@ std::tuple<CommandCost, uint, uint16_t, CargoArray> CmdRefitVehicle(DoCommandFla
|
|||
InvalidateWindowData(WC_VEHICLE_DETAILS, front->index);
|
||||
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
||||
}
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
|
||||
if (IsDepotTile(front->tile)) SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(front->tile));
|
||||
} else {
|
||||
/* Always invalidate the cache; querycost might have filled it. */
|
||||
v->InvalidateNewGRFCacheOfChain();
|
||||
|
@ -639,7 +640,7 @@ CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool eval
|
|||
|
||||
v->MarkDirty();
|
||||
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, WID_VV_START_STOP);
|
||||
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
|
||||
if (IsDepotTile(v->tile)) SetWindowDirty(WC_VEHICLE_DEPOT, GetDepotIndex(v->tile));
|
||||
SetWindowClassesDirty(GetWindowClassForVehicleType(v->type));
|
||||
InvalidateWindowData(WC_VEHICLE_VIEW, v->index);
|
||||
}
|
||||
|
|
|
@ -1334,7 +1334,7 @@ static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode,
|
|||
static bool ClickTile_Water(TileIndex tile)
|
||||
{
|
||||
if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
|
||||
ShowDepotWindow(GetShipDepotNorthTile(tile), VEH_SHIP);
|
||||
ShowDepotWindow(GetDepotIndex(tile));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -346,7 +346,7 @@ enum WindowClass {
|
|||
|
||||
/**
|
||||
* Depot view; %Window numbers:
|
||||
* - #TileIndex = #DepotWidgets
|
||||
* - #DepotID = #DepotWidgets
|
||||
*/
|
||||
WC_VEHICLE_DEPOT,
|
||||
|
||||
|
|
Loading…
Reference in New Issue