Changeset - r6562:78a6f5c47c90
[Not reviewed]
master
0 7 0
rubidium - 17 years ago 2007-05-02 09:29:41
rubidium@openttd.org
(svn r9764) -Codechange: replace some lookup tables by functions.
7 files changed with 22 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/aircraft.h
Show inline comments
 
@@ -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 */
src/openttd.h
Show inline comments
 
@@ -473,7 +473,7 @@ enum WindowClass {
 
};
 

	
 

	
 
enum {
 
enum ExpensesType {
 
	EXPENSES_CONSTRUCTION =  0,
 
	EXPENSES_NEW_VEHICLES =  1,
 
	EXPENSES_TRAIN_RUN    =  2,
src/roadveh.h
Show inline comments
 
@@ -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 */
src/ship.h
Show inline comments
 
@@ -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 */
src/train.h
Show inline comments
 
@@ -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 */
src/vehicle.cpp
Show inline comments
 
@@ -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);
src/vehicle.h
Show inline comments
 
@@ -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; }
 
};
 

	
 
/**
0 comments (0 inline, 0 general)