Changeset - r26228:5af29289e582
[Not reviewed]
master
0 8 0
Tyler Trahan - 3 years ago 2021-11-26 19:11:16
tyler@tylertrahan.com
Codechange: Revenue is not the same as Income

Income is revenue minus costs. Let's name things correctly (without breaking the script API).
8 files changed with 29 insertions and 29 deletions:
0 comments (0 inline, 0 general)
src/aircraft.h
Show inline comments
 
@@ -91,7 +91,7 @@ struct Aircraft FINAL : public Specializ
 

	
 
	void MarkDirty();
 
	void UpdateDeltaXY();
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_INC : EXPENSES_AIRCRAFT_RUN; }
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_AIRCRAFT_REVENUE : EXPENSES_AIRCRAFT_RUN; }
 
	bool IsPrimaryVehicle() const                  { return this->IsNormalAircraft(); }
 
	void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
 
	int GetDisplaySpeed() const    { return this->cur_speed; }
src/company_cmd.cpp
Show inline comments
 
@@ -219,17 +219,17 @@ static void SubtractMoneyFromAnyCompany(
 
	c->money -= cost.GetCost();
 
	c->yearly_expenses[0][cost.GetExpensesType()] += cost.GetCost();
 

	
 
	if (HasBit(1 << EXPENSES_TRAIN_INC    |
 
	           1 << EXPENSES_ROADVEH_INC  |
 
	           1 << EXPENSES_AIRCRAFT_INC |
 
	           1 << EXPENSES_SHIP_INC, cost.GetExpensesType())) {
 
	if (HasBit(1 << EXPENSES_TRAIN_REVENUE    |
 
	           1 << EXPENSES_ROADVEH_REVENUE  |
 
	           1 << EXPENSES_AIRCRAFT_REVENUE |
 
	           1 << EXPENSES_SHIP_REVENUE, cost.GetExpensesType())) {
 
		c->cur_economy.income -= cost.GetCost();
 
	} else if (HasBit(1 << EXPENSES_TRAIN_RUN    |
 
	                  1 << EXPENSES_ROADVEH_RUN  |
 
	                  1 << EXPENSES_AIRCRAFT_RUN |
 
	                  1 << EXPENSES_SHIP_RUN     |
 
	                  1 << EXPENSES_PROPERTY     |
 
	                  1 << EXPENSES_LOAN_INT, cost.GetExpensesType())) {
 
	                  1 << EXPENSES_LOAN_INTEREST, cost.GetExpensesType())) {
 
		c->cur_economy.expenses -= cost.GetCost();
 
	}
 

	
src/economy.cpp
Show inline comments
 
@@ -831,7 +831,7 @@ static void CompaniesPayInterest()
 
		Money up_to_previous_month = yearly_fee * _cur_month / 12;
 
		Money up_to_this_month = yearly_fee * (_cur_month + 1) / 12;
 

	
 
		SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INT, up_to_this_month - up_to_previous_month));
 
		SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INTEREST, up_to_this_month - up_to_previous_month));
 

	
 
		SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price[PR_STATION_VALUE] >> 2));
 
	}
src/economy_type.h
Show inline comments
 
@@ -162,11 +162,11 @@ enum ExpensesType : byte {
 
	EXPENSES_AIRCRAFT_RUN,        ///< Running costs aircraft.
 
	EXPENSES_SHIP_RUN,            ///< Running costs ships.
 
	EXPENSES_PROPERTY,            ///< Property costs.
 
	EXPENSES_TRAIN_INC,           ///< Income from trains.
 
	EXPENSES_ROADVEH_INC,         ///< Income from road vehicles.
 
	EXPENSES_AIRCRAFT_INC,        ///< Income from aircraft.
 
	EXPENSES_SHIP_INC,            ///< Income from ships.
 
	EXPENSES_LOAN_INT,            ///< Interest payments over the loan.
 
	EXPENSES_TRAIN_REVENUE,       ///< Revenue from trains.
 
	EXPENSES_ROADVEH_REVENUE,     ///< Revenue from road vehicles.
 
	EXPENSES_AIRCRAFT_REVENUE,    ///< Revenue from aircraft.
 
	EXPENSES_SHIP_REVENUE,        ///< Revenue from ships.
 
	EXPENSES_LOAN_INTEREST,       ///< Interest payments over the loan.
 
	EXPENSES_OTHER,               ///< Other expenses.
 
	EXPENSES_END,                 ///< Number of expense types.
 
	INVALID_EXPENSES      = 0xFF, ///< Invalid expense type.
src/roadveh.h
Show inline comments
 
@@ -126,7 +126,7 @@ struct RoadVehicle FINAL : public Ground
 

	
 
	void MarkDirty();
 
	void UpdateDeltaXY();
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_REVENUE : EXPENSES_ROADVEH_RUN; }
 
	bool IsPrimaryVehicle() const { return this->IsFrontEngine(); }
 
	void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
 
	int GetDisplaySpeed() const { return this->gcache.last_speed / 2; }
src/script/api/script_company.hpp
Show inline comments
 
@@ -100,20 +100,20 @@ public:
 
	 * @api -ai
 
	 */
 
	enum ExpensesType : byte {
 
		EXPENSES_CONSTRUCTION = ::EXPENSES_CONSTRUCTION, ///< Construction costs.
 
		EXPENSES_NEW_VEHICLES = ::EXPENSES_NEW_VEHICLES, ///< New vehicles.
 
		EXPENSES_TRAIN_RUN    = ::EXPENSES_TRAIN_RUN,    ///< Running costs trains.
 
		EXPENSES_ROADVEH_RUN  = ::EXPENSES_ROADVEH_RUN,  ///< Running costs road vehicles.
 
		EXPENSES_AIRCRAFT_RUN = ::EXPENSES_AIRCRAFT_RUN, ///< Running costs aircraft.
 
		EXPENSES_SHIP_RUN     = ::EXPENSES_SHIP_RUN,     ///< Running costs ships.
 
		EXPENSES_PROPERTY     = ::EXPENSES_PROPERTY,     ///< Property costs.
 
		EXPENSES_TRAIN_INC    = ::EXPENSES_TRAIN_INC,    ///< Income from trains.
 
		EXPENSES_ROADVEH_INC  = ::EXPENSES_ROADVEH_INC,  ///< Income from road vehicles.
 
		EXPENSES_AIRCRAFT_INC = ::EXPENSES_AIRCRAFT_INC, ///< Income from aircraft.
 
		EXPENSES_SHIP_INC     = ::EXPENSES_SHIP_INC,     ///< Income from ships.
 
		EXPENSES_LOAN_INT     = ::EXPENSES_LOAN_INT,     ///< Interest payments over the loan.
 
		EXPENSES_OTHER        = ::EXPENSES_OTHER,        ///< Other expenses.
 
		EXPENSES_INVALID      = ::INVALID_EXPENSES,      ///< Invalid expense type.
 
		EXPENSES_CONSTRUCTION = ::EXPENSES_CONSTRUCTION,     ///< Construction costs.
 
		EXPENSES_NEW_VEHICLES = ::EXPENSES_NEW_VEHICLES,     ///< New vehicles.
 
		EXPENSES_TRAIN_RUN    = ::EXPENSES_TRAIN_RUN,        ///< Running costs trains.
 
		EXPENSES_ROADVEH_RUN  = ::EXPENSES_ROADVEH_RUN,      ///< Running costs road vehicles.
 
		EXPENSES_AIRCRAFT_RUN = ::EXPENSES_AIRCRAFT_RUN,     ///< Running costs aircraft.
 
		EXPENSES_SHIP_RUN     = ::EXPENSES_SHIP_RUN,         ///< Running costs ships.
 
		EXPENSES_PROPERTY     = ::EXPENSES_PROPERTY,         ///< Property costs.
 
		EXPENSES_TRAIN_INC    = ::EXPENSES_TRAIN_REVENUE,    ///< Revenue from trains.
 
		EXPENSES_ROADVEH_INC  = ::EXPENSES_ROADVEH_REVENUE,  ///< Revenue from road vehicles.
 
		EXPENSES_AIRCRAFT_INC = ::EXPENSES_AIRCRAFT_REVENUE, ///< Revenue from aircraft.
 
		EXPENSES_SHIP_INC     = ::EXPENSES_SHIP_REVENUE,     ///< Revenue from ships.
 
		EXPENSES_LOAN_INT     = ::EXPENSES_LOAN_INTEREST,    ///< Interest payments over the loan.
 
		EXPENSES_OTHER        = ::EXPENSES_OTHER,            ///< Other expenses.
 
		EXPENSES_INVALID      = ::INVALID_EXPENSES,          ///< Invalid expense type.
 
	};
 

	
 
	/**
src/ship.h
Show inline comments
 
@@ -37,7 +37,7 @@ struct Ship FINAL : public SpecializedVe
 

	
 
	void MarkDirty();
 
	void UpdateDeltaXY();
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_REVENUE : EXPENSES_SHIP_RUN; }
 
	void PlayLeaveStationSound() const;
 
	bool IsPrimaryVehicle() const { return true; }
 
	void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
src/train.h
Show inline comments
 
@@ -109,7 +109,7 @@ struct Train FINAL : public GroundVehicl
 

	
 
	void MarkDirty();
 
	void UpdateDeltaXY();
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
 
	ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_REVENUE : EXPENSES_TRAIN_RUN; }
 
	void PlayLeaveStationSound() const;
 
	bool IsPrimaryVehicle() const { return this->IsFrontEngine(); }
 
	void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const;
0 comments (0 inline, 0 general)