Changeset - r19878:34102534d9f9
[Not reviewed]
master
0 7 0
michi_cc - 11 years ago 2012-12-20 19:44:02
michi_cc@openttd.org
(svn r24833) -Codechange: Replace magic numbers for invalidating vehicle-related windows with an enum.
7 files changed with 32 insertions and 24 deletions:
0 comments (0 inline, 0 general)
src/order_cmd.cpp
Show inline comments
 
@@ -915,7 +915,7 @@ static CommandCost DecloneOrder(Vehicle 
 
{
 
	if (flags & DC_EXEC) {
 
		DeleteVehicleOrders(dst);
 
		InvalidateVehicleOrder(dst, -1);
 
		InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
 
		InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
 
	}
 
	return CommandCost();
 
@@ -1054,7 +1054,7 @@ CommandCost CmdSkipToOrder(TileIndex til
 

	
 
		if (v->current_order.IsType(OT_LOADING)) v->LeaveStation();
 

	
 
		InvalidateVehicleOrder(v, -2);
 
		InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS);
 
	}
 

	
 
	/* We have an aircraft/ship, they have a mini-schedule, so update them all */
 
@@ -1393,7 +1393,7 @@ CommandCost CmdModifyOrder(TileIndex til
 
					u->current_order.GetLoadType() != order->GetLoadType()) {
 
				u->current_order.SetLoadType(order->GetLoadType());
 
			}
 
			InvalidateVehicleOrder(u, -2);
 
			InvalidateVehicleOrder(u, VIWD_MODIFY_ORDERS);
 
		}
 
	}
 

	
 
@@ -1503,8 +1503,8 @@ CommandCost CmdCloneOrder(TileIndex tile
 
				/* Link this vehicle in the shared-list */
 
				dst->AddToShared(src);
 

	
 
				InvalidateVehicleOrder(dst, -1);
 
				InvalidateVehicleOrder(src, -2);
 
				InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
 
				InvalidateVehicleOrder(src, VIWD_MODIFY_ORDERS);
 

	
 
				InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
 
			}
 
@@ -1566,7 +1566,7 @@ CommandCost CmdCloneOrder(TileIndex tile
 
					dst->orders.list = new OrderList(first, dst);
 
				}
 

	
 
				InvalidateVehicleOrder(dst, -1);
 
				InvalidateVehicleOrder(dst, VIWD_REMOVE_ALL_ORDERS);
 

	
 
				InvalidateWindowClassesData(GetWindowClassForVehicleType(dst->type), 0);
 
			}
 
@@ -1624,7 +1624,7 @@ CommandCost CmdOrderRefit(TileIndex tile
 

	
 
		for (Vehicle *u = v->FirstShared(); u != NULL; u = u->NextShared()) {
 
			/* Update any possible open window of the vehicle */
 
			InvalidateVehicleOrder(u, -2);
 
			InvalidateVehicleOrder(u, VIWD_MODIFY_ORDERS);
 

	
 
			/* If the vehicle already got the current depot set as current order, then update current order as well */
 
			if (u->cur_real_order_index == order_number && (u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
 
@@ -2093,7 +2093,7 @@ bool ProcessOrders(Vehicle *v)
 
	/* Otherwise set it, and determine the destination tile. */
 
	v->current_order = *order;
 

	
 
	InvalidateVehicleOrder(v, -2);
 
	InvalidateVehicleOrder(v, VIWD_MODIFY_ORDERS);
 
	switch (v->type) {
 
		default:
 
			NOT_REACHED();
src/order_gui.cpp
Show inline comments
 
@@ -820,7 +820,7 @@ public:
 

	
 
			if (station_orders < 2) this->OrderClick_Goto(0);
 
		}
 
		this->OnInvalidateData(-2);
 
		this->OnInvalidateData(VIWD_MODIFY_ORDERS);
 
	}
 

	
 
	virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
 
@@ -866,13 +866,13 @@ public:
 
		VehicleOrderID to   = INVALID_VEH_ORDER_ID;
 

	
 
		switch (data) {
 
			case -666:
 
			case VIWD_AUTOREPLACE:
 
				/* Autoreplace replaced the vehicle */
 
				this->vehicle = Vehicle::Get(this->window_number);
 
				this->UpdateAutoRefitState();
 
				break;
 

	
 
			case -1:
 
			case VIWD_REMOVE_ALL_ORDERS:
 
				/* Removed / replaced all orders (after deleting / sharing) */
 
				if (this->selected_order == -1) break;
 

	
 
@@ -881,7 +881,7 @@ public:
 
				this->selected_order = -1;
 
				break;
 

	
 
			case -2:
 
			case VIWD_MODIFY_ORDERS:
 
				/* Some other order changes */
 
				break;
 

	
src/settings.cpp
Show inline comments
 
@@ -960,7 +960,7 @@ static bool TownFoundingChanged(int32 p1
 

	
 
static bool InvalidateVehTimetableWindow(int32 p1)
 
{
 
	InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, -2);
 
	InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS);
 
	return true;
 
}
 

	
src/timetable_gui.cpp
Show inline comments
 
@@ -236,12 +236,12 @@ struct TimetableWindow : Window {
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		switch (data) {
 
			case -666:
 
			case VIWD_AUTOREPLACE:
 
				/* Autoreplace replaced the vehicle */
 
				this->vehicle = Vehicle::Get(this->window_number);
 
				break;
 

	
 
			case -1:
 
			case VIWD_REMOVE_ALL_ORDERS:
 
				/* Removed / replaced all orders (after deleting / sharing) */
 
				if (this->sel_index == -1) break;
 

	
 
@@ -249,7 +249,7 @@ struct TimetableWindow : Window {
 
				this->sel_index = -1;
 
				break;
 

	
 
			case -2:
 
			case VIWD_MODIFY_ORDERS:
 
				if (!gui_scope) break;
 
				this->UpdateSelectionStates();
 
				this->ReInit();
src/train_cmd.cpp
Show inline comments
 
@@ -241,7 +241,7 @@ void Train::ConsistChanged(bool same_len
 
	if (this->IsFrontEngine()) {
 
		this->UpdateAcceleration();
 
		SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
 
		InvalidateWindowData(WC_VEHICLE_REFIT, this->index);
 
		InvalidateWindowData(WC_VEHICLE_REFIT, this->index, VIWD_CONSIST_CHANGED);
 
	}
 
}
 

	
 
@@ -1076,7 +1076,7 @@ static void NormaliseTrainHead(Train *he
 
	if (!head->IsFrontEngine()) return;
 

	
 
	/* Update the refit button and window */
 
	InvalidateWindowData(WC_VEHICLE_REFIT, head->index);
 
	InvalidateWindowData(WC_VEHICLE_REFIT, head->index, VIWD_CONSIST_CHANGED);
 
	SetWindowWidgetDirty(WC_VEHICLE_VIEW, head->index, WID_VV_REFIT);
 

	
 
	/* If we don't have a unit number yet, set one. */
src/vehicle_gui.cpp
Show inline comments
 
@@ -534,7 +534,7 @@ struct RefitWindow : public Window {
 
			if (this->sel == -1) this->vscroll->ScrollTowards(0);
 
		} else {
 
			/* Rebuild the refit list */
 
			this->OnInvalidateData(0);
 
			this->OnInvalidateData(VIWD_CONSIST_CHANGED);
 
		}
 
	}
 

	
 
@@ -707,8 +707,8 @@ struct RefitWindow : public Window {
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		switch (data) {
 
			case -666: // Autoreplace replaced the vehicle; selected_vehicle became invalid.
 
			case 0: { // The consist has changed; rebuild the entire list.
 
			case VIWD_AUTOREPLACE: // Autoreplace replaced the vehicle; selected_vehicle became invalid.
 
			case VIWD_CONSIST_CHANGED: { // The consist has changed; rebuild the entire list.
 
				/* Clear the selection. */
 
				Vehicle *v = Vehicle::Get(this->window_number);
 
				this->selected_vehicle = v->index;
 
@@ -1127,7 +1127,7 @@ static inline void ChangeVehicleWindow(W
 
		}
 

	
 
		/* Notify the window. */
 
		w->InvalidateData(-666, false);
 
		w->InvalidateData(VIWD_AUTOREPLACE, false);
 
	}
 
}
 

	
 
@@ -1760,7 +1760,7 @@ struct VehicleDetailsWindow : Window {
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (data == -666) {
 
		if (data == VIWD_AUTOREPLACE) {
 
			/* Autoreplace replaced the vehicle.
 
			 * Nothing to do for this window. */
 
			return;
 
@@ -2585,7 +2585,7 @@ public:
 
	 */
 
	virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
 
	{
 
		if (data == -666) {
 
		if (data == VIWD_AUTOREPLACE) {
 
			/* Autoreplace replaced the vehicle.
 
			 * Nothing to do for this window. */
 
			return;
src/vehicle_gui.h
Show inline comments
 
@@ -29,6 +29,14 @@ enum TrainDetailsWindowTabs {
 
	TDW_TAB_TOTALS,    ///< Tab with sum of total cargo transported
 
};
 

	
 
/** Special values for vehicle-related windows for the data parameter of #InvalidateWindowData. */
 
enum VehicleInvalidateWindowData {
 
	VIWD_REMOVE_ALL_ORDERS = -1, ///< Removed / replaced all orders (after deleting / sharing).
 
	VIWD_MODIFY_ORDERS     = -2, ///< Other order modifications.
 
	VIWD_CONSIST_CHANGED   = -3, ///< Vehicle composition was changed.
 
	VIWD_AUTOREPLACE       = -4, ///< Autoreplace replaced the vehicle.
 
};
 

	
 
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number);
 

	
 
void DrawTrainImage(const Train *v, int left, int right, int y, VehicleID selection, EngineImageType image_type, int skip, VehicleID drag_dest = INVALID_VEHICLE);
0 comments (0 inline, 0 general)