OpenTTD Source 20260206-master-g4d4e37dbf1
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
9
10#ifndef ECONOMY_BASE_H
11#define ECONOMY_BASE_H
12
13#include "cargopacket.h"
14
18extern CargoPaymentPool _cargo_payment_pool;
19
23struct 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
32 CargoPayment(CargoPaymentID index) : CargoPaymentPool::PoolItem<&_cargo_payment_pool>(index) {}
33 CargoPayment(CargoPaymentID index, Vehicle *front);
35
36 Money PayTransfer(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile);
37 void PayFinalDelivery(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile);
38};
39
40#endif /* ECONOMY_BASE_H */
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
Base class for cargo packets.
Pool< CargoPayment, CargoPaymentID, 512 > CargoPaymentPool
Type of pool to store cargo payments in; little over 1 million.
CargoPaymentPool _cargo_payment_pool
The actual pool to store cargo payments in.
Container for cargo from the same location and time.
Definition cargopacket.h:41
Helper class to perform the cargo payment.
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:1210
StationID current_station
NOSAVE: The current station.
Money PayTransfer(CargoType cargo, const CargoPacket *cp, uint count, TileIndex current_tile)
Handle payment for transfer of the given cargo packet.
Definition economy.cpp:1228
Vehicle * front
The front vehicle to do the payment of.
Money visual_transfer
The transfer credits to be shown.
Money visual_profit
The visual profit to show.
Money route_profit
The amount of money to add/remove from the bank account.
Base class for all pools.
Vehicle data structure.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition tile_type.h:92