4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file economy_base.h Base classes related to the economy. */
12 #ifndef ECONOMY_BASE_H
13 #define ECONOMY_BASE_H
15 #include "cargopacket.h"
16 #include "company_type.h"
19 * Helper class to perform the cargo payment.
21 struct CargoPayment
: PooledItem
<CargoPayment
, CargoPaymentID
, 512, 0xFF000> {
22 Vehicle
*front
; ///< The front vehicle to do the payment of
23 Money route_profit
; ///< The amount of money to add/remove from the bank account
24 Money visual_profit
; ///< The visual profit to show
25 Money visual_transfer
; ///< The transfer credits to be shown
27 /* Unsaved variables */
28 Company
*owner
; ///< The owner of the vehicle
29 StationID current_station
; ///< The current station
30 CargoID ct
; ///< The currently handled cargo type
32 /** Constructor for pool saveload */
34 CargoPayment(Vehicle
*front
);
37 Money
PayTransfer(const CargoPacket
*cp
, uint count
);
38 void PayFinalDelivery(const CargoPacket
*cp
, uint count
);
41 * Sets the currently handled cargo type.
42 * @param ct the cargo type to handle from now on.
44 void SetCargo(CargoID ct
) { this->ct
= ct
; }
48 * Iterate over all cargo payments from a given start position.
49 * @param var The variable used for iterating.
50 * @param start The start of the iteration.
52 #define FOR_ALL_CARGO_PAYMENTS_FROM(var, start) FOR_ALL_ITEMS_FROM(CargoPayment, cargo_payment_index, var, start)
55 * Iterate over all cargo payments.
56 * @param var The variable used for iterating.
58 #define FOR_ALL_CARGO_PAYMENTS(var) FOR_ALL_CARGO_PAYMENTS_FROM(var, 0)
60 #endif /* ECONOMY_BASE_H */