From 5ccbaa69900efef10bed2dbfb4297dfd4191b16e Mon Sep 17 00:00:00 2001 From: Rubidium Date: Tue, 18 Feb 2025 18:27:49 +0100 Subject: [PATCH] Codechange: explicitly initialise OrderBackup and OrderList member variables --- src/order_backup.cpp | 6 +----- src/order_backup.h | 10 +++++----- src/order_base.h | 18 ++++++++---------- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/order_backup.cpp b/src/order_backup.cpp index dd72db55c7..401944cb0e 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -43,12 +43,8 @@ OrderBackup::~OrderBackup() * @param v The vehicle to make a backup of. * @param user The user that is requesting the backup. */ -OrderBackup::OrderBackup(const Vehicle *v, uint32_t user) +OrderBackup::OrderBackup(const Vehicle *v, uint32_t user) : user(user), tile(v->tile), group(v->group_id) { - this->user = user; - this->tile = v->tile; - this->group = v->group_id; - this->CopyConsistPropertiesFrom(v); /* If we have shared orders, store the vehicle we share the order with. */ diff --git a/src/order_backup.h b/src/order_backup.h index b445ca9c0b..20eea9ee57 100644 --- a/src/order_backup.h +++ b/src/order_backup.h @@ -34,12 +34,12 @@ struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist private: friend SaveLoadTable GetOrderBackupDescription(); ///< Saving and loading of order backups. friend struct BKORChunkHandler; ///< Creating empty orders upon savegame loading. - uint32_t user; ///< The user that requested the backup. - TileIndex tile; ///< Tile of the depot where the order was changed. - GroupID group; ///< The group the vehicle was part of. + uint32_t user = 0; ///< The user that requested the backup. + TileIndex tile = INVALID_TILE; ///< Tile of the depot where the order was changed. + GroupID group = GroupID::Invalid(); ///< The group the vehicle was part of. - const Vehicle *clone; ///< Vehicle this vehicle was a clone of. - Order *orders; ///< The actual orders if the vehicle was not a clone. + const Vehicle *clone = nullptr; ///< Vehicle this vehicle was a clone of. + Order *orders = nullptr; ///< The actual orders if the vehicle was not a clone. /** Creation for savegame restoration. */ OrderBackup() {} diff --git a/src/order_base.h b/src/order_base.h index ca7050623a..dd1cffcf17 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -260,20 +260,18 @@ private: friend void AfterLoadVehiclesPhase1(bool part_of_load); ///< For instantiating the shared vehicle chain friend SaveLoadTable GetOrderListDescription(); ///< Saving and loading of order lists. - VehicleOrderID num_orders; ///< NOSAVE: How many orders there are in the list. - VehicleOrderID num_manual_orders; ///< NOSAVE: How many manually added orders are there in the list. - uint num_vehicles; ///< NOSAVE: Number of vehicles that share this order list. - Vehicle *first_shared; ///< NOSAVE: pointer to the first vehicle in the shared order chain. - Order *first; ///< First order of the order list. + VehicleOrderID num_orders = INVALID_VEH_ORDER_ID; ///< NOSAVE: How many orders there are in the list. + VehicleOrderID num_manual_orders = 0; ///< NOSAVE: How many manually added orders are there in the list. + uint num_vehicles = 0; ///< NOSAVE: Number of vehicles that share this order list. + Vehicle *first_shared = nullptr; ///< NOSAVE: pointer to the first vehicle in the shared order chain. + Order *first = nullptr; ///< First order of the order list. - TimerGameTick::Ticks timetable_duration; ///< NOSAVE: Total timetabled duration of the order list. - TimerGameTick::Ticks total_duration; ///< NOSAVE: Total (timetabled or not) duration of the order list. + TimerGameTick::Ticks timetable_duration{}; ///< NOSAVE: Total timetabled duration of the order list. + TimerGameTick::Ticks total_duration{}; ///< NOSAVE: Total (timetabled or not) duration of the order list. public: /** Default constructor producing an invalid order list. */ - OrderList(VehicleOrderID num_orders = INVALID_VEH_ORDER_ID) - : num_orders(num_orders), num_manual_orders(0), num_vehicles(0), first_shared(nullptr), first(nullptr), - timetable_duration(0), total_duration(0) { } + OrderList(VehicleOrderID num_orders = INVALID_VEH_ORDER_ID) : num_orders(num_orders) { } /** * Create an order list with the given order chain for the given vehicle.