Codechange: Revenue is not the same as Income

Income is revenue minus costs. Let's name things correctly (without breaking the script API).
pull/390/head
Tyler Trahan 3 years ago committed by Patric Stout
parent e79724ea22
commit f4ca94d3f6

@ -91,7 +91,7 @@ struct Aircraft FINAL : public SpecializedVehicle<Aircraft, VEH_AIRCRAFT> {
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; }

@ -219,17 +219,17 @@ static void SubtractMoneyFromAnyCompany(Company *c, const CommandCost &cost)
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();
}

@ -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));
}

@ -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.

@ -126,7 +126,7 @@ struct RoadVehicle FINAL : public GroundVehicle<RoadVehicle, VEH_ROAD> {
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; }

@ -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.
};
/**

@ -37,7 +37,7 @@ struct Ship FINAL : public SpecializedVehicle<Ship, VEH_SHIP> {
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;

@ -109,7 +109,7 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
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;

Loading…
Cancel
Save