summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aircraft.h2
-rw-r--r--src/openttd.h2
-rw-r--r--src/roadveh.h2
-rw-r--r--src/ship.h2
-rw-r--r--src/train.h2
-rw-r--r--src/vehicle.cpp8
-rw-r--r--src/vehicle.h11
7 files changed, 22 insertions, 7 deletions
diff --git a/src/aircraft.h b/src/aircraft.h
index a66b3a177..34c4cdc6a 100644
--- a/src/aircraft.h
+++ b/src/aircraft.h
@@ -133,6 +133,8 @@ struct Aircraft : public Vehicle {
const char *GetTypeString() { return "aircraft"; }
void MarkDirty();
void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
+ WindowClass GetVehicleListWindowClass() { return WC_AIRCRAFT_LIST; }
};
#endif /* AIRCRAFT_H */
diff --git a/src/openttd.h b/src/openttd.h
index ca19a0481..187804cf9 100644
--- a/src/openttd.h
+++ b/src/openttd.h
@@ -473,7 +473,7 @@ enum WindowClass {
};
-enum {
+enum ExpensesType {
EXPENSES_CONSTRUCTION = 0,
EXPENSES_NEW_VEHICLES = 1,
EXPENSES_TRAIN_RUN = 2,
diff --git a/src/roadveh.h b/src/roadveh.h
index 340a74076..c3d8cbf94 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -41,6 +41,8 @@ struct RoadVehicle : public Vehicle {
const char *GetTypeString() { return "road vehicle"; }
void MarkDirty();
void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
+ WindowClass GetVehicleListWindowClass() { return WC_ROADVEH_LIST; }
};
#endif /* ROADVEH_H */
diff --git a/src/ship.h b/src/ship.h
index e277f91c4..0d4e324ae 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -42,6 +42,8 @@ struct Ship: public Vehicle {
const char *GetTypeString() { return "ship"; }
void MarkDirty();
void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
+ WindowClass GetVehicleListWindowClass() { return WC_SHIPS_LIST; }
};
#endif /* SHIP_H */
diff --git a/src/train.h b/src/train.h
index 317d93c2d..eaebf04bc 100644
--- a/src/train.h
+++ b/src/train.h
@@ -246,6 +246,8 @@ struct Train : public Vehicle {
const char *GetTypeString() { return "train"; }
void MarkDirty();
void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
+ WindowClass GetVehicleListWindowClass() { return WC_TRAINS_LIST; }
};
#endif /* TRAIN_H */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 143f1fc36..20f67c771 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2970,13 +2970,9 @@ void Vehicle::BeginLoading()
current_order.type = OT_LOADING;
GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
- static const int expense_type[] = { EXPENSES_TRAIN_INC, EXPENSES_ROADVEH_INC, EXPENSES_SHIP_INC, EXPENSES_AIRCRAFT_INC };
- SET_EXPENSES_TYPE(expense_type[this->type]);
-
+ SET_EXPENSES_TYPE(this->GetExpenseType(true));
if (LoadUnloadVehicle(this, true) != 0) {
- static const WindowClass invalidate_windows[] = { WC_TRAINS_LIST, WC_ROADVEH_LIST, WC_SHIPS_LIST, WC_AIRCRAFT_LIST };
- InvalidateWindow(invalidate_windows[this->type], this->owner);
-
+ InvalidateWindow(this->GetVehicleListWindowClass(), this->owner);
this->MarkDirty();
}
InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, STATUS_BAR);
diff --git a/src/vehicle.h b/src/vehicle.h
index dd9ca71ba..1b2be2eb1 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -365,6 +365,17 @@ struct Vehicle {
* @param direction the direction the vehicle is facing
*/
virtual void UpdateDeltaXY(Direction direction) {}
+
+ /**
+ * Sets the expense type associated to this vehicle type
+ * @param income whether this is income or (running) expenses of the vehicle
+ */
+ virtual ExpensesType GetExpenseType(bool income) { return EXPENSES_OTHER; }
+
+ /**
+ * Invalidates the vehicle list window of this type of vehicle
+ */
+ virtual WindowClass GetVehicleListWindowClass() { return WC_NONE; }
};
/**