1
0
Fork 0

Compare commits

...

3 Commits

4 changed files with 17 additions and 18 deletions

View File

@ -18,11 +18,11 @@ typedef Pool<Depot, DepotID, 64, 64000> DepotPool;
extern DepotPool _depot_pool;
struct Depot : DepotPool::PoolItem<&_depot_pool> {
/* DepotID index member of DepotPool is 2 bytes. */
uint16_t town_cn; ///< The N-1th depot for this town (consecutive number)
TileIndex xy;
Town *town;
std::string name;
TileIndex xy;
uint16_t town_cn; ///< The N-1th depot for this town (consecutive number)
TimerGameCalendar::Date build_date; ///< Date of construction
Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}

View File

@ -1188,8 +1188,8 @@ static void TriggerIndustryProduction(Industry *i)
* @param front The front of the train
*/
CargoPayment::CargoPayment(Vehicle *front) :
front(front),
current_station(front->last_station_visited)
current_station(front->last_station_visited),
front(front)
{
}

View File

@ -22,16 +22,16 @@ extern CargoPaymentPool _cargo_payment_pool;
* Helper class to perform the cargo payment.
*/
struct CargoPayment : CargoPaymentPool::PoolItem<&_cargo_payment_pool> {
/* CargoPaymentID index member of CargoPaymentPool is 4 bytes. */
StationID current_station; ///< NOSAVE: The current station
CargoID ct; ///< NOSAVE: The currently handled cargo type
Company *owner; ///< NOSAVE: The owner of the vehicle
Vehicle *front; ///< The front vehicle to do the payment of
Money route_profit; ///< The amount of money to add/remove from the bank account
Money visual_profit; ///< The visual profit to show
Money visual_transfer; ///< The transfer credits to be shown
/* Unsaved variables */
Company *owner; ///< The owner of the vehicle
StationID current_station; ///< The current station
CargoID ct; ///< The currently handled cargo type
/** Constructor for pool saveload */
CargoPayment() {}
CargoPayment(Vehicle *front);

View File

@ -267,9 +267,9 @@ static void TrainDetailsCapacityTab(const CargoSummaryItem *item, int left, int
* @param v Vehicle to process
* @param summary Space for the result
*/
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *summary)
static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary &summary)
{
summary->clear();
summary.clear();
do {
if (!v->GetEngine()->CanCarryCargo()) continue;
@ -278,10 +278,9 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary *su
new_item.subtype = GetCargoSubtypeText(v);
if (!IsValidCargoID(new_item.cargo) && new_item.subtype == STR_EMPTY) continue;
auto item = std::find(summary->begin(), summary->end(), new_item);
if (item == summary->end()) {
summary->emplace_back();
item = summary->end() - 1;
auto item = std::find(std::begin(summary), std::end(summary), new_item);
if (item == std::end(summary)) {
item = summary.emplace(std::end(summary));
item->cargo = new_item.cargo;
item->subtype = new_item.subtype;
item->capacity = 0;
@ -331,7 +330,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab)
num++; // needs one more because first line is description string
} else {
for (const Train *v = Train::Get(veh_id); v != nullptr; v = v->GetNextVehicle()) {
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
GetCargoSummaryOfArticulatedVehicle(v, _cargo_summary);
num += std::max(1u, (unsigned)_cargo_summary.size());
uint length = GetLengthOfArticulatedVehicle(v);
@ -363,7 +362,7 @@ void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16_t v
Direction dir = rtl ? DIR_E : DIR_W;
int x = rtl ? r.right : r.left;
for (; v != nullptr && vscroll_pos > -vscroll_cap; v = v->GetNextVehicle()) {
GetCargoSummaryOfArticulatedVehicle(v, &_cargo_summary);
GetCargoSummaryOfArticulatedVehicle(v, _cargo_summary);
/* Draw sprites */
uint dx = 0;