OpenTTD Source: src/economy_base.h Source File

OpenTTD Source 15.3

economy_base.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef ECONOMY_BASE_H
11#define ECONOMY_BASE_H
12
13#include "cargopacket.h"
14
16 using CargoPaymentPool = Pool<CargoPayment, CargoPaymentID, 512>;
18extern CargoPaymentPool _cargo_payment_pool;
19
23 struct CargoPayment : CargoPaymentPool::PoolItem<&_cargo_payment_pool> {
24 /* CargoPaymentID index member of CargoPaymentPool is 4 bytes. */
25 StationID current_station = StationID::Invalid();
26
27 Vehicle *front = nullptr;
28 Money route_profit = 0;
29 Money visual_profit = 0;
30 Money visual_transfer = 0;
31
33 CargoPayment() {}
34 CargoPayment(Vehicle *front);
35 ~CargoPayment();
36
37 Money PayTransfer(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile);
38 void PayFinalDelivery(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile);
39};
40
41#endif /* ECONOMY_BASE_H */
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
cargopacket.h
Base class for cargo packets.
OverflowSafeInt< int64_t >
_cargo_payment_pool
CargoPaymentPool _cargo_payment_pool
The actual pool to store cargo payments in.
CargoPacket
Container for cargo from the same location and time.
Definition cargopacket.h:41
CargoPayment
Helper class to perform the cargo payment.
Definition economy_base.h:23
CargoPayment::PayFinalDelivery
void PayFinalDelivery(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for final delivery of the given cargo packet.
Definition economy.cpp:1217
CargoPayment::CargoPayment
CargoPayment()
Constructor for pool saveload.
Definition economy_base.h:33
CargoPayment::current_station
StationID current_station
NOSAVE: The current station.
Definition economy_base.h:25
CargoPayment::PayTransfer
Money PayTransfer(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for transfer of the given cargo packet.
Definition economy.cpp:1235
CargoPayment::front
Vehicle * front
The front vehicle to do the payment of.
Definition economy_base.h:27
CargoPayment::visual_transfer
Money visual_transfer
The transfer credits to be shown.
Definition economy_base.h:30
CargoPayment::visual_profit
Money visual_profit
The visual profit to show.
Definition economy_base.h:29
CargoPayment::route_profit
Money route_profit
The amount of money to add/remove from the bank account.
Definition economy_base.h:28
PoolID< uint16_t, struct StationIDTag, 64000, 0xFFFF >
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:285
Pool
Base class for all pools.
Definition pool_type.hpp:133
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
Vehicle
Vehicle data structure.
Definition vehicle_base.h:205