mirror of https://github.com/OpenTTD/OpenTTD
(svn r13165) -Codechange: replace some RebuildXXXList/ResortXXXList+InvalidateWindowXXX with InvalidateWindowXXXData.
parent
aab9e191f5
commit
9defec7876
|
@ -446,7 +446,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
if (IsLocalPlayer())
|
||||||
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); //updates the replace Aircraft window
|
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); //updates the replace Aircraft window
|
||||||
|
@ -461,11 +461,10 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
static void DoDeleteAircraft(Vehicle *v)
|
static void DoDeleteAircraft(Vehicle *v)
|
||||||
{
|
{
|
||||||
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
||||||
RebuildVehicleLists();
|
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
DeleteDepotHighlightOfVehicle(v);
|
DeleteDepotHighlightOfVehicle(v);
|
||||||
DeleteVehicleChain(v);
|
DeleteVehicleChain(v);
|
||||||
InvalidateWindowClasses(WC_AIRCRAFT_LIST);
|
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sell an aircraft.
|
/** Sell an aircraft.
|
||||||
|
@ -656,7 +655,7 @@ CommandCost CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
v->cargo_subtype = new_subtype;
|
v->cargo_subtype = new_subtype;
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
|
|
|
@ -1781,7 +1781,10 @@ static void DoAcquireCompany(Player *p)
|
||||||
p->is_active = false;
|
p->is_active = false;
|
||||||
|
|
||||||
DeletePlayerWindows(pi);
|
DeletePlayerWindows(pi);
|
||||||
RebuildVehicleLists(); //Updates the open windows to add the newly acquired vehicles to the lists
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
|
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
|
||||||
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
||||||
|
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int GetAmountOwnedBy(const Player *p, PlayerID owner);
|
extern int GetAmountOwnedBy(const Player *p, PlayerID owner);
|
||||||
|
|
|
@ -286,8 +286,8 @@ struct VehicleGroupWindow : public Window, public VehicleListBase {
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
virtual void OnInvalidateData(int data)
|
||||||
{
|
{
|
||||||
this->vehicles.flags |= VL_REBUILD;
|
this->vehicles.flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
|
||||||
this->groups.flags |= VL_REBUILD;
|
this->groups.flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
|
||||||
if (!(IsAllGroupID(this->group_sel) || IsDefaultGroupID(this->group_sel) || IsValidGroupID(this->group_sel))) {
|
if (!(IsAllGroupID(this->group_sel) || IsDefaultGroupID(this->group_sel) || IsValidGroupID(this->group_sel))) {
|
||||||
this->group_sel = ALL_GROUP;
|
this->group_sel = ALL_GROUP;
|
||||||
HideDropDownMenu(this);
|
HideDropDownMenu(this);
|
||||||
|
|
|
@ -546,7 +546,7 @@ CommandCost CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure to rebuild the whole list */
|
/* Make sure to rebuild the whole list */
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
@ -561,7 +561,7 @@ static CommandCost DecloneOrder(Vehicle *dst, uint32 flags)
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
DeleteVehicleOrders(dst);
|
DeleteVehicleOrders(dst);
|
||||||
InvalidateVehicleOrder(dst);
|
InvalidateVehicleOrder(dst);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||||
}
|
}
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ CommandCost CmdDeleteOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
cur_order_id++;
|
cur_order_id++;
|
||||||
}
|
}
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
@ -811,7 +811,7 @@ CommandCost CmdMoveOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure to rebuild the whole list */
|
/* Make sure to rebuild the whole list */
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
@ -1075,7 +1075,7 @@ CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
InvalidateVehicleOrder(dst);
|
InvalidateVehicleOrder(dst);
|
||||||
InvalidateVehicleOrder(src);
|
InvalidateVehicleOrder(src);
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -1134,7 +1134,7 @@ CommandCost CmdCloneOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
InvalidateVehicleOrder(dst);
|
InvalidateVehicleOrder(dst);
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
VehiclePositionChanged(v);
|
VehiclePositionChanged(v);
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
if (IsLocalPlayer())
|
||||||
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Road window
|
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Road window
|
||||||
|
@ -381,7 +381,7 @@ CommandCost CmdSellRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
// Invalidate depot
|
// Invalidate depot
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
||||||
DeleteDepotHighlightOfVehicle(v);
|
DeleteDepotHighlightOfVehicle(v);
|
||||||
|
@ -574,7 +574,7 @@ static void DeleteLastRoadVeh(Vehicle *v)
|
||||||
|
|
||||||
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
|
|
||||||
if (IsTileType(v->tile, MP_STATION)) ClearCrashedStation(v);
|
if (IsTileType(v->tile, MP_STATION)) ClearCrashedStation(v);
|
||||||
|
@ -2116,7 +2116,7 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
v->cargo_subtype = new_subtype;
|
v->cargo_subtype = new_subtype;
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (only_this) break;
|
if (only_this) break;
|
||||||
|
|
|
@ -814,7 +814,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
VehiclePositionChanged(v);
|
VehiclePositionChanged(v);
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer())
|
if (IsLocalPlayer())
|
||||||
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
|
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
|
||||||
|
@ -851,7 +851,7 @@ CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
|
||||||
DeleteDepotHighlightOfVehicle(v);
|
DeleteDepotHighlightOfVehicle(v);
|
||||||
|
@ -997,7 +997,7 @@ CommandCost CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
v->cargo_subtype = new_subtype;
|
v->cargo_subtype = new_subtype;
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_SHIPS_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cost;
|
return cost;
|
||||||
|
|
|
@ -74,8 +74,7 @@ Station::~Station()
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkDirty();
|
MarkDirty();
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, this->owner, 0);
|
||||||
InvalidateWindowClasses(WC_STATION_LIST);
|
|
||||||
|
|
||||||
DeleteWindowById(WC_STATION_VIEW, index);
|
DeleteWindowById(WC_STATION_VIEW, index);
|
||||||
|
|
||||||
|
|
|
@ -650,8 +650,7 @@ static void DeleteStationIfEmpty(Station *st)
|
||||||
{
|
{
|
||||||
if (st->facilities == 0) {
|
if (st->facilities == 0) {
|
||||||
st->delete_ctr = 0;
|
st->delete_ctr = 0;
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
||||||
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
||||||
}
|
}
|
||||||
/* station remains but it probably lost some parts - station sign should stay in the station boundaries */
|
/* station remains but it probably lost some parts - station sign should stay in the station boundaries */
|
||||||
UpdateStationSignCoord(st);
|
UpdateStationSignCoord(st);
|
||||||
|
@ -1051,8 +1050,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
|
||||||
st->MarkTilesDirty(false);
|
st->MarkTilesDirty(false);
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
UpdateStationAcceptance(st, false);
|
UpdateStationAcceptance(st, false);
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
||||||
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
||||||
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1410,8 +1408,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
UpdateStationAcceptance(st, false);
|
UpdateStationAcceptance(st, false);
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
||||||
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
||||||
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
|
||||||
}
|
}
|
||||||
return cost;
|
return cost;
|
||||||
|
@ -1723,8 +1720,7 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
UpdateStationAcceptance(st, false);
|
UpdateStationAcceptance(st, false);
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
||||||
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
||||||
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1820,8 +1816,7 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
UpdateStationAcceptance(st, false);
|
UpdateStationAcceptance(st, false);
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
||||||
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
||||||
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1979,8 +1974,7 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
UpdateStationVirtCoordDirty(st);
|
UpdateStationVirtCoordDirty(st);
|
||||||
UpdateStationAcceptance(st, false);
|
UpdateStationAcceptance(st, false);
|
||||||
RebuildStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 0);
|
||||||
InvalidateWindow(WC_STATION_LIST, st->owner);
|
|
||||||
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2637,7 +2631,7 @@ CommandCost CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
st->name = strdup(_cmd_text);
|
st->name = strdup(_cmd_text);
|
||||||
|
|
||||||
UpdateStationVirtCoord(st);
|
UpdateStationVirtCoord(st);
|
||||||
ResortStationLists();
|
InvalidateWindowData(WC_STATION_LIST, st->owner, 1);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2858,8 +2852,7 @@ static void ChangeTileOwner_Station(TileIndex tile, PlayerID old_player, PlayerI
|
||||||
|
|
||||||
SetTileOwner(tile, new_player);
|
SetTileOwner(tile, new_player);
|
||||||
if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
|
if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
|
||||||
RebuildStationLists();
|
InvalidateWindowClassesData(WC_STATION_LIST, 0);
|
||||||
InvalidateWindowClasses(WC_STATION_LIST);
|
|
||||||
} else {
|
} else {
|
||||||
if (IsDriveThroughStopTile(tile)) {
|
if (IsDriveThroughStopTile(tile)) {
|
||||||
/* Remove the drive-through road stop */
|
/* Remove the drive-through road stop */
|
||||||
|
|
|
@ -167,39 +167,6 @@ static int CDECL StationRatingMaxSorter(const void *a, const void *b)
|
||||||
|
|
||||||
typedef GUIList<const Station*> GUIStationList;
|
typedef GUIList<const Station*> GUIStationList;
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the station sort flag for all station-list windows.
|
|
||||||
* @param sl_flag Sort list flag to set for all station-list windows
|
|
||||||
*/
|
|
||||||
static void SetStationListsFlag(SortListFlags sl_flag)
|
|
||||||
{
|
|
||||||
Window *const *wz;
|
|
||||||
|
|
||||||
FOR_ALL_WINDOWS(wz) {
|
|
||||||
Window *w = *wz;
|
|
||||||
if (w->window_class == WC_STATION_LIST) {
|
|
||||||
dynamic_cast<GUIStationList*>(w)->flags |= sl_flag;
|
|
||||||
w->SetDirty();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the 'VL_REBUILD' flag for all station lists
|
|
||||||
*/
|
|
||||||
void RebuildStationLists()
|
|
||||||
{
|
|
||||||
SetStationListsFlag(VL_REBUILD);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the 'VL_RESORT' flag for all station lists
|
|
||||||
*/
|
|
||||||
void ResortStationLists()
|
|
||||||
{
|
|
||||||
SetStationListsFlag(VL_RESORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rebuild station list if the VL_REBUILD flag is set
|
* Rebuild station list if the VL_REBUILD flag is set
|
||||||
*
|
*
|
||||||
|
@ -605,6 +572,11 @@ struct PlayerStationsWindow : public Window, public GUIStationList
|
||||||
{
|
{
|
||||||
this->vscroll.cap += delta.y / 10;
|
this->vscroll.cap += delta.y / 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnInvalidateData(int data)
|
||||||
|
{
|
||||||
|
this->flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Listing PlayerStationsWindow::station_sort = {0, 0};
|
Listing PlayerStationsWindow::station_sort = {0, 0};
|
||||||
|
|
|
@ -48,10 +48,6 @@ enum StationViewWidgets {
|
||||||
SVW_RESIZE, ///< Resize button
|
SVW_RESIZE, ///< Resize button
|
||||||
};
|
};
|
||||||
|
|
||||||
/* sorter stuff */
|
|
||||||
void RebuildStationLists();
|
|
||||||
void ResortStationLists();
|
|
||||||
|
|
||||||
enum StationCoverageType {
|
enum StationCoverageType {
|
||||||
SCT_PASSENGERS_ONLY,
|
SCT_PASSENGERS_ONLY,
|
||||||
SCT_NON_PASSENGERS_ONLY,
|
SCT_NON_PASSENGERS_ONLY,
|
||||||
|
|
|
@ -803,7 +803,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
InvalidateWindow(WC_COMPANY, v->owner);
|
InvalidateWindow(WC_COMPANY, v->owner);
|
||||||
if (IsLocalPlayer()) {
|
if (IsLocalPlayer()) {
|
||||||
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
|
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
|
||||||
|
@ -1272,7 +1272,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, dst_head->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, dst_head->tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
@ -1353,7 +1353,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
DeleteWindowById(WC_VEHICLE_VIEW, first->index);
|
DeleteWindowById(WC_VEHICLE_VIEW, first->index);
|
||||||
}
|
}
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandCost cost(EXPENSES_NEW_VEHICLES);
|
CommandCost cost(EXPENSES_NEW_VEHICLES);
|
||||||
|
@ -2001,7 +2001,7 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32
|
||||||
v->cargo_subtype = new_subtype;
|
v->cargo_subtype = new_subtype;
|
||||||
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2805,7 +2805,7 @@ static void SetVehicleCrashed(Vehicle *v)
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
|
|
||||||
BEGIN_ENUM_WAGONS(v)
|
BEGIN_ENUM_WAGONS(v)
|
||||||
v->vehstatus |= VS_CRASHED;
|
v->vehstatus |= VS_CRASHED;
|
||||||
|
@ -3152,7 +3152,7 @@ static void DeleteLastWagon(Vehicle *v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
|
|
||||||
MarkSingleVehicleDirty(v);
|
MarkSingleVehicleDirty(v);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "order_func.h"
|
#include "order_func.h"
|
||||||
#include "engine_func.h"
|
#include "engine_func.h"
|
||||||
#include "engine_base.h"
|
#include "engine_base.h"
|
||||||
|
#include "window_func.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
@ -43,7 +44,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
found = GetLastVehicleInChain(found);
|
found = GetLastVehicleInChain(found);
|
||||||
/* put the new wagon at the end of the loco. */
|
/* put the new wagon at the end of the loco. */
|
||||||
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
|
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
|
||||||
RebuildVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1733,7 +1733,7 @@ CommandCost CmdNameVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
free(v->name);
|
free(v->name);
|
||||||
v->name = strdup(_cmd_text);
|
v->name = strdup(_cmd_text);
|
||||||
ResortVehicleLists();
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 1);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,47 +86,6 @@ const StringID _vehicle_sort_listing[] = {
|
||||||
INVALID_STRING_ID
|
INVALID_STRING_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Set sort list flag for all vehicle list windows
|
|
||||||
* @param sl_flag Sort list flag to set
|
|
||||||
*/
|
|
||||||
static void SetVehicleListsFlag(SortListFlags sl_flag)
|
|
||||||
{
|
|
||||||
Window* const *wz;
|
|
||||||
|
|
||||||
FOR_ALL_WINDOWS(wz) {
|
|
||||||
Window *w = *wz;
|
|
||||||
|
|
||||||
switch (w->window_class) {
|
|
||||||
case WC_TRAINS_LIST:
|
|
||||||
case WC_ROADVEH_LIST:
|
|
||||||
case WC_SHIPS_LIST:
|
|
||||||
case WC_AIRCRAFT_LIST:
|
|
||||||
dynamic_cast<VehicleListBase*>(w)->vehicles.flags |= sl_flag;
|
|
||||||
w->SetDirty();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rebuild all vehicle list windows
|
|
||||||
*/
|
|
||||||
void RebuildVehicleLists()
|
|
||||||
{
|
|
||||||
SetVehicleListsFlag(VL_REBUILD);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resort all vehicle list windows
|
|
||||||
*/
|
|
||||||
void ResortVehicleLists()
|
|
||||||
{
|
|
||||||
SetVehicleListsFlag(VL_RESORT);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildVehicleList(VehicleListBase *vl, PlayerID owner, uint16 index, uint16 window_type)
|
void BuildVehicleList(VehicleListBase *vl, PlayerID owner, uint16 index, uint16 window_type)
|
||||||
{
|
{
|
||||||
if (!(vl->vehicles.flags & VL_REBUILD)) return;
|
if (!(vl->vehicles.flags & VL_REBUILD)) return;
|
||||||
|
@ -1187,6 +1146,11 @@ struct VehicleListWindow : public Window, public VehicleListBase {
|
||||||
this->vscroll.cap += delta.y / (int)this->resize.step_height;
|
this->vscroll.cap += delta.y / (int)this->resize.step_height;
|
||||||
this->widget[VLW_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
|
this->widget[VLW_WIDGET_LIST].data = (this->vscroll.cap << 8) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnInvalidateData(int data)
|
||||||
|
{
|
||||||
|
this->vehicles.flags |= (data == 0 ? VL_REBUILD : VL_RESORT);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _player_vehicle_list_train_desc = {
|
static const WindowDesc _player_vehicle_list_train_desc = {
|
||||||
|
|
|
@ -133,8 +133,6 @@ struct Sorting {
|
||||||
extern Sorting _sorting;
|
extern Sorting _sorting;
|
||||||
|
|
||||||
/* sorter stuff */
|
/* sorter stuff */
|
||||||
void RebuildVehicleLists();
|
|
||||||
void ResortVehicleLists();
|
|
||||||
void SortVehicleList(VehicleListBase *vl);
|
void SortVehicleList(VehicleListBase *vl);
|
||||||
void BuildVehicleList(VehicleListBase *vl, PlayerID owner, uint16 index, uint16 window_type);
|
void BuildVehicleList(VehicleListBase *vl, PlayerID owner, uint16 index, uint16 window_type);
|
||||||
|
|
||||||
|
|
|
@ -838,20 +838,21 @@ static void FloodVehicle(Vehicle *v)
|
||||||
case VEH_TRAIN:
|
case VEH_TRAIN:
|
||||||
if (IsFrontEngine(v)) pass += 4; // driver
|
if (IsFrontEngine(v)) pass += 4; // driver
|
||||||
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
|
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
|
||||||
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
if (IsRoadVehFront(v)) pass += 1; // driver
|
if (IsRoadVehFront(v)) pass += 1; // driver
|
||||||
v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast
|
v->u.road.crashed_ctr = 2000; // max 2220, disappear pretty fast
|
||||||
|
InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_AIRCRAFT:
|
case VEH_AIRCRAFT:
|
||||||
pass += 2; // driver
|
pass += 2; // driver
|
||||||
v->u.air.crashed_counter = 9000; // max 10000, disappear pretty fast
|
v->u.air.crashed_counter = 9000; // max 10000, disappear pretty fast
|
||||||
|
InvalidateWindowClassesData(WC_AIRCRAFT_LIST, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RebuildVehicleLists();
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue