(svn r27756) -Codechange: Add StringTab enum
[openttd.git] / src / economy_base.h
blob60b0964a956ee2036fe6a8b80f6ceb79c09ed81a
1 /* $Id$ */
3 /*
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/>.
8 */
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"
18 /** Type of pool to store cargo payments in; little over 1 million. */
19 typedef Pool<CargoPayment, CargoPaymentID, 512, 0xFF000> CargoPaymentPool;
20 /** The actual pool to store cargo payments in. */
21 extern CargoPaymentPool _cargo_payment_pool;
23 /**
24 * Helper class to perform the cargo payment.
26 struct CargoPayment : CargoPaymentPool::PoolItem<&_cargo_payment_pool> {
27 Vehicle *front; ///< The front vehicle to do the payment of
28 Money route_profit; ///< The amount of money to add/remove from the bank account
29 Money visual_profit; ///< The visual profit to show
30 Money visual_transfer; ///< The transfer credits to be shown
32 /* Unsaved variables */
33 Company *owner; ///< The owner of the vehicle
34 StationID current_station; ///< The current station
35 CargoID ct; ///< The currently handled cargo type
37 /** Constructor for pool saveload */
38 CargoPayment() {}
39 CargoPayment(Vehicle *front);
40 ~CargoPayment();
42 Money PayTransfer(const CargoPacket *cp, uint count);
43 void PayFinalDelivery(const CargoPacket *cp, uint count);
45 /**
46 * Sets the currently handled cargo type.
47 * @param ct the cargo type to handle from now on.
49 void SetCargo(CargoID ct) { this->ct = ct; }
52 /**
53 * Iterate over all cargo payments from a given start position.
54 * @param var The variable used for iterating.
55 * @param start The start of the iteration.
57 #define FOR_ALL_CARGO_PAYMENTS_FROM(var, start) FOR_ALL_ITEMS_FROM(CargoPayment, cargo_payment_index, var, start)
59 /**
60 * Iterate over all cargo payments.
61 * @param var The variable used for iterating.
63 #define FOR_ALL_CARGO_PAYMENTS(var) FOR_ALL_CARGO_PAYMENTS_FROM(var, 0)
65 #endif /* ECONOMY_BASE_H */