mirror of https://github.com/OpenTTD/OpenTTD
(svn r9764) -Codechange: replace some lookup tables by functions.
parent
1bea3b55a6
commit
dce7dcb664
|
@ -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 */
|
||||
|
|
|
@ -473,7 +473,7 @@ enum WindowClass {
|
|||
};
|
||||
|
||||
|
||||
enum {
|
||||
enum ExpensesType {
|
||||
EXPENSES_CONSTRUCTION = 0,
|
||||
EXPENSES_NEW_VEHICLES = 1,
|
||||
EXPENSES_TRAIN_RUN = 2,
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue