widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #14412
[Merge] lp:~widelands-dev/widelands/const_portdock_fleet_and_ship_functions into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/const_portdock_fleet_and_ship_functions into lp:widelands.
Commit message:
Made as many functions as possible const in portdock, fleet and ship and followed the snowball effect
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/const_portdock_fleet_and_ship_functions/+merge/354301
const functions give the compiler more room for optimization.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/const_portdock_fleet_and_ship_functions into lp:widelands.
=== modified file 'src/ai/defaultai_seafaring.cc'
--- src/ai/defaultai_seafaring.cc 2018-08-16 16:10:43 +0000
+++ src/ai/defaultai_seafaring.cc 2018-09-05 07:39:19 +0000
@@ -126,7 +126,7 @@
for (const WarehouseSiteObserver& wh_obs : warehousesites) {
if (wh_obs.bo->is(BuildingAttribute::kPort)) {
ports_count += 1;
- if (Widelands::PortDock* pd = wh_obs.site->get_portdock()) {
+ if (const Widelands::PortDock* pd = wh_obs.site->get_portdock()) {
if (pd->expedition_started()) {
expeditions_in_prep += 1;
}
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2018-08-09 11:11:15 +0000
+++ src/economy/flag.cc 2018-09-05 07:39:19 +0000
@@ -967,7 +967,7 @@
flag.molog("BUG: flag_job_request_callback: worker not found in list\n");
}
-void Flag::log_general_info(const Widelands::EditorGameBase& egbase) {
+void Flag::log_general_info(const Widelands::EditorGameBase& egbase) const {
molog("Flag at %i,%i\n", position_.x, position_.y);
Widelands::PlayerImmovable::log_general_info(egbase);
=== modified file 'src/economy/flag.h'
--- src/economy/flag.h 2018-08-09 11:11:15 +0000
+++ src/economy/flag.h 2018-09-05 07:39:19 +0000
@@ -163,7 +163,7 @@
void add_flag_job(Game&, DescriptionIndex workerware, const std::string& programname);
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
protected:
bool init(EditorGameBase&) override;
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2018-04-07 16:59:00 +0000
+++ src/economy/fleet.cc 2018-09-05 07:39:19 +0000
@@ -324,11 +324,11 @@
return true;
}
-uint32_t Fleet::count_ships() {
+uint32_t Fleet::count_ships() const {
return ships_.size();
}
-uint32_t Fleet::count_ships_heading_here(EditorGameBase& egbase, PortDock* port) {
+uint32_t Fleet::count_ships_heading_here(EditorGameBase& egbase, PortDock* port) const {
uint32_t ships_on_way = 0;
for (uint16_t s = 0; s < ships_.size(); s += 1) {
if (ships_[s]->get_destination(egbase) == port) {
@@ -339,10 +339,10 @@
return ships_on_way;
}
-uint32_t Fleet::count_ports() {
+uint32_t Fleet::count_ports() const {
return ports_.size();
}
-bool Fleet::get_act_pending() {
+bool Fleet::get_act_pending() const {
return act_pending_;
}
@@ -568,7 +568,7 @@
}
}
-bool Fleet::has_ports() {
+bool Fleet::has_ports() const {
return !ports_.empty();
}
@@ -863,7 +863,7 @@
}
}
-void Fleet::log_general_info(const EditorGameBase& egbase) {
+void Fleet::log_general_info(const EditorGameBase& egbase) const {
MapObject::log_general_info(egbase);
molog("%" PRIuS " ships and %" PRIuS " ports\n", ships_.size(), ports_.size());
=== modified file 'src/economy/fleet.h'
--- src/economy/fleet.h 2018-04-16 07:03:12 +0000
+++ src/economy/fleet.h 2018-09-05 07:39:19 +0000
@@ -92,17 +92,17 @@
void remove_ship(EditorGameBase& egbase, Ship* ship);
void add_port(EditorGameBase& egbase, PortDock* port);
void remove_port(EditorGameBase& egbase, PortDock* port);
- bool has_ports();
+ bool has_ports() const;
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
bool get_path(PortDock& start, PortDock& end, Path& path);
void add_neighbours(PortDock& pd, std::vector<RoutingNodeNeighbour>& neighbours);
- uint32_t count_ships();
- uint32_t count_ships_heading_here(EditorGameBase& egbase, PortDock* port);
- uint32_t count_ports();
- bool get_act_pending();
+ uint32_t count_ships() const;
+ uint32_t count_ships_heading_here(EditorGameBase& egbase, PortDock* port) const;
+ uint32_t count_ports() const;
+ bool get_act_pending() const;
protected:
void act(Game&, uint32_t data) override;
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2018-04-16 07:03:12 +0000
+++ src/economy/portdock.cc 2018-09-05 07:39:19 +0000
@@ -384,10 +384,10 @@
/**
* Return the number of wares or workers of the given type that are waiting at the dock.
*/
-uint32_t PortDock::count_waiting(WareWorker waretype, DescriptionIndex wareindex) {
+uint32_t PortDock::count_waiting(WareWorker waretype, DescriptionIndex wareindex) const {
uint32_t count = 0;
- for (ShippingItem& shipping_item : waiting_) {
+ for (const ShippingItem& shipping_item : waiting_) {
WareInstance* ware;
Worker* worker;
shipping_item.get(owner().egbase(), &ware, &worker);
@@ -407,12 +407,12 @@
/**
* Return the number of wares or workers waiting at the dock.
*/
-uint32_t PortDock::count_waiting() {
+uint32_t PortDock::count_waiting() const {
return waiting_.size();
}
/// \returns whether an expedition was started or is even ready
-bool PortDock::expedition_started() {
+bool PortDock::expedition_started() const {
return (expedition_bootstrap_ != nullptr) || expedition_ready_;
}
@@ -423,7 +423,7 @@
expedition_bootstrap_->start();
}
-ExpeditionBootstrap* PortDock::expedition_bootstrap() {
+ExpeditionBootstrap* PortDock::expedition_bootstrap() const {
return expedition_bootstrap_.get();
}
@@ -440,7 +440,7 @@
expedition_bootstrap_.reset(nullptr);
}
-void PortDock::log_general_info(const EditorGameBase& egbase) {
+void PortDock::log_general_info(const EditorGameBase& egbase) const {
PlayerImmovable::log_general_info(egbase);
if (warehouse_) {
@@ -454,7 +454,7 @@
fleet_ ? fleet_->serial() : 0, need_ship_ ? "true" : "false", waiting_.size());
}
- for (ShippingItem& shipping_item : waiting_) {
+ for (const ShippingItem& shipping_item : waiting_) {
molog(" IT %u, destination %u\n", shipping_item.object_.serial(),
shipping_item.destination_dock_.serial());
}
=== modified file 'src/economy/portdock.h'
--- src/economy/portdock.h 2018-04-07 16:59:00 +0000
+++ src/economy/portdock.h 2018-09-05 07:39:19 +0000
@@ -115,13 +115,13 @@
void ship_arrived(Game&, Ship&);
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
- uint32_t count_waiting(WareWorker waretype, DescriptionIndex wareindex);
- uint32_t count_waiting();
+ uint32_t count_waiting(WareWorker waretype, DescriptionIndex wareindex) const;
+ uint32_t count_waiting() const;
// Returns true if a expedition is started or ready to be send out.
- bool expedition_started();
+ bool expedition_started() const;
// Called when the button in the warehouse window is pressed.
void start_expedition();
@@ -129,7 +129,7 @@
// May return nullptr when there is no expedition ongoing or if the
// expedition ship is already underway.
- ExpeditionBootstrap* expedition_bootstrap();
+ ExpeditionBootstrap* expedition_bootstrap() const;
// Gets called by the ExpeditionBootstrap as soon as all wares and workers are available.
void expedition_bootstrap_complete(Game& game);
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2018-07-12 06:02:15 +0000
+++ src/economy/road.cc 2018-09-05 07:39:19 +0000
@@ -632,7 +632,7 @@
// Don't bother with checks here, since the next ware will cause them anyway
}
-void Road::log_general_info(const EditorGameBase& egbase) {
+void Road::log_general_info(const EditorGameBase& egbase) const {
PlayerImmovable::log_general_info(egbase);
molog("wallet: %i\n", wallet_);
}
=== modified file 'src/economy/road.h'
--- src/economy/road.h 2018-07-12 06:02:15 +0000
+++ src/economy/road.h 2018-09-05 07:39:19 +0000
@@ -124,7 +124,7 @@
void remove_worker(Worker&) override;
void assign_carrier(Carrier&, uint8_t);
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
protected:
bool init(EditorGameBase&) override;
=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc 2018-04-07 16:59:00 +0000
+++ src/economy/ware_instance.cc 2018-09-05 07:39:19 +0000
@@ -502,7 +502,7 @@
return transfer_ ? dynamic_cast<PlayerImmovable*>(transfer_nextstep_.get(game)) : nullptr;
}
-void WareInstance::log_general_info(const EditorGameBase& egbase) {
+void WareInstance::log_general_info(const EditorGameBase& egbase) const {
MapObject::log_general_info(egbase);
molog("Ware: %s\n", descr().name().c_str());
=== modified file 'src/economy/ware_instance.h'
--- src/economy/ware_instance.h 2018-04-07 16:59:00 +0000
+++ src/economy/ware_instance.h 2018-09-05 07:39:19 +0000
@@ -93,7 +93,7 @@
return transfer_;
}
- void log_general_info(const EditorGameBase& egbase) override;
+ void log_general_info(const EditorGameBase& egbase) const override;
private:
ObjectPointer location_;
=== modified file 'src/logic/map_objects/bob.cc'
--- src/logic/map_objects/bob.cc 2018-04-27 06:11:05 +0000
+++ src/logic/map_objects/bob.cc 2018-09-05 07:39:19 +0000
@@ -902,7 +902,7 @@
}
/// Give debug information.
-void Bob::log_general_info(const EditorGameBase& egbase) {
+void Bob::log_general_info(const EditorGameBase& egbase) const {
FORMAT_WARNINGS_OFF;
molog("Owner: %p\n", owner_);
FORMAT_WARNINGS_ON;
=== modified file 'src/logic/map_objects/bob.h'
--- src/logic/map_objects/bob.h 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/bob.h 2018-09-05 07:39:19 +0000
@@ -270,7 +270,7 @@
RenderTarget* dst) const;
// For debug
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
// default tasks
void reset_tasks(Game&);
=== modified file 'src/logic/map_objects/immovable.cc'
--- src/logic/map_objects/immovable.cc 2018-07-13 07:46:36 +0000
+++ src/logic/map_objects/immovable.cc 2018-09-05 07:39:19 +0000
@@ -1332,7 +1332,7 @@
/**
* Dump general information
*/
-void PlayerImmovable::log_general_info(const EditorGameBase& egbase) {
+void PlayerImmovable::log_general_info(const EditorGameBase& egbase) const {
BaseImmovable::log_general_info(egbase);
FORMAT_WARNINGS_OFF;
=== modified file 'src/logic/map_objects/immovable.h'
--- src/logic/map_objects/immovable.h 2018-07-08 16:10:50 +0000
+++ src/logic/map_objects/immovable.h 2018-09-05 07:39:19 +0000
@@ -357,7 +357,7 @@
return workers_;
}
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
/**
* These functions are called when a ware or worker arrives at
=== modified file 'src/logic/map_objects/map_object.cc'
--- src/logic/map_objects/map_object.cc 2018-07-23 09:04:47 +0000
+++ src/logic/map_objects/map_object.cc 2018-09-05 07:39:19 +0000
@@ -543,7 +543,7 @@
logsink_ = sink;
}
-void MapObject::log_general_info(const EditorGameBase&) {
+void MapObject::log_general_info(const EditorGameBase&) const {
}
/**
=== modified file 'src/logic/map_objects/map_object.h'
--- src/logic/map_objects/map_object.h 2018-05-12 04:18:21 +0000
+++ src/logic/map_objects/map_object.h 2018-09-05 07:39:19 +0000
@@ -302,7 +302,7 @@
void set_logsink(LogSink*);
/// Called when a new logsink is set. Used to give general information.
- virtual void log_general_info(const EditorGameBase&);
+ virtual void log_general_info(const EditorGameBase&) const;
Player* get_owner() const {
return owner_;
=== modified file 'src/logic/map_objects/tribes/building.cc'
--- src/logic/map_objects/tribes/building.cc 2018-04-27 06:11:05 +0000
+++ src/logic/map_objects/tribes/building.cc 2018-09-05 07:39:19 +0000
@@ -669,7 +669,7 @@
}
}
-void Building::log_general_info(const EditorGameBase& egbase) {
+void Building::log_general_info(const EditorGameBase& egbase) const {
PlayerImmovable::log_general_info(egbase);
molog("position: (%i, %i)\n", position_.x, position_.y);
=== modified file 'src/logic/map_objects/tribes/building.h'
--- src/logic/map_objects/tribes/building.h 2018-05-24 10:19:21 +0000
+++ src/logic/map_objects/tribes/building.h 2018-09-05 07:39:19 +0000
@@ -282,7 +282,7 @@
return old_buildings_;
}
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
// Use on training sites only.
virtual void change_train_priority(uint32_t, int32_t) {
=== modified file 'src/logic/map_objects/tribes/carrier.cc'
--- src/logic/map_objects/tribes/carrier.cc 2018-08-13 05:50:58 +0000
+++ src/logic/map_objects/tribes/carrier.cc 2018-09-05 07:39:19 +0000
@@ -406,7 +406,7 @@
return start_task_movepath(game, path, idx, descr().get_right_walk_anims(does_carry_ware()));
}
-void Carrier::log_general_info(const Widelands::EditorGameBase& egbase) {
+void Carrier::log_general_info(const Widelands::EditorGameBase& egbase) const {
molog("Carrier at %i,%i\n", get_position().x, get_position().y);
Worker::log_general_info(egbase);
=== modified file 'src/logic/map_objects/tribes/carrier.h'
--- src/logic/map_objects/tribes/carrier.h 2018-08-09 11:11:15 +0000
+++ src/logic/map_objects/tribes/carrier.h 2018-09-05 07:39:19 +0000
@@ -62,7 +62,7 @@
void start_task_transport(Game&, int32_t fromflag);
bool start_task_walktoflag(Game&, int32_t flag, bool offset = false);
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
static Task const taskRoad;
=== modified file 'src/logic/map_objects/tribes/productionsite.cc'
--- src/logic/map_objects/tribes/productionsite.cc 2018-06-19 08:52:49 +0000
+++ src/logic/map_objects/tribes/productionsite.cc 2018-09-05 07:39:19 +0000
@@ -739,7 +739,7 @@
return true;
}
-void ProductionSite::log_general_info(const EditorGameBase& egbase) {
+void ProductionSite::log_general_info(const EditorGameBase& egbase) const {
Building::log_general_info(egbase);
molog("is_stopped: %u\n", is_stopped_);
=== modified file 'src/logic/map_objects/tribes/productionsite.h'
--- src/logic/map_objects/tribes/productionsite.h 2018-07-08 16:10:50 +0000
+++ src/logic/map_objects/tribes/productionsite.h 2018-09-05 07:39:19 +0000
@@ -165,7 +165,7 @@
explicit ProductionSite(const ProductionSiteDescr& descr);
~ProductionSite() override;
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
bool is_stopped() const {
return is_stopped_;
=== modified file 'src/logic/map_objects/tribes/ship.cc'
--- src/logic/map_objects/tribes/ship.cc 2018-07-08 15:16:16 +0000
+++ src/logic/map_objects/tribes/ship.cc 2018-09-05 07:39:19 +0000
@@ -1027,7 +1027,7 @@
scale, dst);
}
-void Ship::log_general_info(const EditorGameBase& egbase) {
+void Ship::log_general_info(const EditorGameBase& egbase) const {
Bob::log_general_info(egbase);
molog("Ship belongs to fleet: %u\n destination: %s\n lastdock: %s\n",
=== modified file 'src/logic/map_objects/tribes/ship.h'
--- src/logic/map_objects/tribes/ship.h 2018-07-12 05:44:15 +0000
+++ src/logic/map_objects/tribes/ship.h 2018-09-05 07:39:19 +0000
@@ -117,7 +117,7 @@
uint32_t calculate_sea_route(Game& game, PortDock& pd, Path* finalpath = nullptr) const;
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
uint32_t get_nritems() const {
return items_.size();
@@ -196,7 +196,7 @@
}
// whether the ship's expedition is in state "island-exploration" (circular movement)
- bool is_exploring_island() {
+ bool is_exploring_island() const {
return expedition_->island_exploration;
}
=== modified file 'src/logic/map_objects/tribes/soldier.cc'
--- src/logic/map_objects/tribes/soldier.cc 2018-07-13 10:35:16 +0000
+++ src/logic/map_objects/tribes/soldier.cc 2018-09-05 07:39:19 +0000
@@ -1546,7 +1546,7 @@
}
}
-void Soldier::log_general_info(const EditorGameBase& egbase) {
+void Soldier::log_general_info(const EditorGameBase& egbase) const {
Worker::log_general_info(egbase);
molog("[Soldier]\n");
molog("Levels: %d/%d/%d/%d\n", health_level_, attack_level_, defense_level_, evade_level_);
=== modified file 'src/logic/map_objects/tribes/soldier.h'
--- src/logic/map_objects/tribes/soldier.h 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/soldier.h 2018-09-05 07:39:19 +0000
@@ -258,7 +258,7 @@
void heal(uint32_t);
void damage(uint32_t); /// Damage quantity of health points
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
bool is_on_battlefield();
bool is_attacking_player(Game&, Player&);
=== modified file 'src/logic/map_objects/tribes/warehouse.cc'
--- src/logic/map_objects/tribes/warehouse.cc 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/warehouse.cc 2018-09-05 07:39:19 +0000
@@ -1337,17 +1337,16 @@
return portdock_->expedition_bootstrap()->inputqueue(index, type);
}
-void Warehouse::log_general_info(const EditorGameBase& egbase) {
+void Warehouse::log_general_info(const EditorGameBase& egbase) const {
Building::log_general_info(egbase);
if (descr().get_isport()) {
- PortDock* pd_tmp = portdock_;
- if (pd_tmp) {
- molog("Port dock: %u\n", pd_tmp->serial());
- molog("port needs ship: %s\n", (pd_tmp->get_need_ship()) ? "true" : "false");
- molog("wares and workers waiting: %u\n", pd_tmp->count_waiting());
- molog("exped. in progr.: %s\n", (pd_tmp->expedition_started()) ? "true" : "false");
- Fleet* fleet = pd_tmp->get_fleet();
+ if (portdock_) {
+ molog("Port dock: %u\n", portdock_->serial());
+ molog("port needs ship: %s\n", (portdock_->get_need_ship()) ? "true" : "false");
+ molog("wares and workers waiting: %u\n", portdock_->count_waiting());
+ molog("exped. in progr.: %s\n", (portdock_->expedition_started()) ? "true" : "false");
+ Fleet* fleet = portdock_->get_fleet();
if (fleet) {
molog("* fleet: %u\n", fleet->serial());
molog(" ships: %u, ports: %u\n", fleet->count_ships(), fleet->count_ports());
=== modified file 'src/logic/map_objects/tribes/warehouse.h'
--- src/logic/map_objects/tribes/warehouse.h 2018-04-07 16:59:00 +0000
+++ src/logic/map_objects/tribes/warehouse.h 2018-09-05 07:39:19 +0000
@@ -214,7 +214,7 @@
// Will throw an exception otherwise.
InputQueue& inputqueue(DescriptionIndex, WareWorker) override;
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
private:
class SoldierControl : public Widelands::SoldierControl {
=== modified file 'src/logic/map_objects/tribes/worker.cc'
--- src/logic/map_objects/tribes/worker.cc 2018-08-09 11:11:15 +0000
+++ src/logic/map_objects/tribes/worker.cc 2018-09-05 07:39:19 +0000
@@ -1051,7 +1051,7 @@
}
/// Log basic information.
-void Worker::log_general_info(const EditorGameBase& egbase) {
+void Worker::log_general_info(const EditorGameBase& egbase) const {
Bob::log_general_info(egbase);
if (upcast(PlayerImmovable, loc, location_.get(egbase))) {
=== modified file 'src/logic/map_objects/tribes/worker.h'
--- src/logic/map_objects/tribes/worker.h 2018-07-26 11:28:05 +0000
+++ src/logic/map_objects/tribes/worker.h 2018-09-05 07:39:19 +0000
@@ -138,7 +138,7 @@
}
// debug
- void log_general_info(const EditorGameBase&) override;
+ void log_general_info(const EditorGameBase&) const override;
// worker-specific tasks
void start_task_transfer(Game&, Transfer*);
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2018-07-11 08:32:54 +0000
+++ src/scripting/lua_map.cc 2018-09-05 07:39:19 +0000
@@ -4569,7 +4569,7 @@
EditorGameBase& egbase = get_egbase(L);
if (is_a(Game, &egbase)) {
- PortDock* pd = get(L, egbase)->get_portdock();
+ const PortDock* pd = get(L, egbase)->get_portdock();
if (pd) {
if (pd->expedition_started()) {
return 1;
@@ -4932,7 +4932,7 @@
}
if (upcast(Game, game, &egbase)) {
- PortDock* pd = wh->get_portdock();
+ const PortDock* pd = wh->get_portdock();
if (!pd) {
return 0;
}
@@ -4963,7 +4963,7 @@
}
if (upcast(Game, game, &egbase)) {
- PortDock* pd = wh->get_portdock();
+ const PortDock* pd = wh->get_portdock();
if (!pd) {
return 0;
}
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2018-09-01 08:36:08 +0000
+++ src/wui/buildingwindow.cc 2018-09-05 07:39:19 +0000
@@ -204,7 +204,7 @@
if (can_act) {
// Check if this is a port building and if yes show expedition button
if (upcast(Widelands::Warehouse const, warehouse, building)) {
- if (Widelands::PortDock* pd = warehouse->get_portdock()) {
+ if (const Widelands::PortDock* pd = warehouse->get_portdock()) {
expeditionbtn_ = new UI::Button(
capsbuttons, "start_or_cancel_expedition", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
g_gr->images().get("images/wui/buildings/start_expedition.png"));
@@ -537,7 +537,7 @@
void BuildingWindow::create_input_queue_panel(UI::Box* const box,
Widelands::Building& b,
- Widelands::InputQueue* const iq,
+ const Widelands::InputQueue& iq,
bool show_only) {
// The *max* width should be larger than the default width
box->add(new InputQueueDisplay(box, 0, 0, *igbase(), b, iq, show_only));
=== modified file 'src/wui/buildingwindow.h'
--- src/wui/buildingwindow.h 2018-08-10 07:42:57 +0000
+++ src/wui/buildingwindow.h 2018-09-05 07:39:19 +0000
@@ -89,7 +89,7 @@
void clicked_goto();
void
- create_input_queue_panel(UI::Box*, Widelands::Building&, Widelands::InputQueue*, bool = false);
+ create_input_queue_panel(UI::Box*, Widelands::Building&, const Widelands::InputQueue&, bool = false);
bool is_dying_;
=== modified file 'src/wui/constructionsitewindow.cc'
--- src/wui/constructionsitewindow.cc 2018-08-14 13:40:46 +0000
+++ src/wui/constructionsitewindow.cc 2018-09-05 07:39:19 +0000
@@ -55,7 +55,7 @@
// Add the wares queue
for (uint32_t i = 0; i < construction_site->get_nrwaresqueues(); ++i)
box.add(new InputQueueDisplay(
- &box, 0, 0, *igbase(), *construction_site, construction_site->get_waresqueue(i)));
+ &box, 0, 0, *igbase(), *construction_site, *construction_site->get_waresqueue(i)));
get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), &box, _("Building materials"));
=== modified file 'src/wui/dismantlesitewindow.cc'
--- src/wui/dismantlesitewindow.cc 2018-07-14 11:22:51 +0000
+++ src/wui/dismantlesitewindow.cc 2018-09-05 07:39:19 +0000
@@ -49,7 +49,7 @@
// Add the wares queue
for (uint32_t i = 0; i < dismantle_site->get_nrwaresqueues(); ++i)
BuildingWindow::create_input_queue_panel(
- &box, *dismantle_site, dismantle_site->get_waresqueue(i), true);
+ &box, *dismantle_site, *dismantle_site->get_waresqueue(i), true);
get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), &box, _("Building materials"));
think();
=== modified file 'src/wui/inputqueuedisplay.cc'
--- src/wui/inputqueuedisplay.cc 2018-07-23 01:18:36 +0000
+++ src/wui/inputqueuedisplay.cc 2018-09-05 07:39:19 +0000
@@ -38,7 +38,7 @@
int32_t const y,
InteractiveGameBase& igb,
Widelands::Building& building,
- Widelands::InputQueue* const queue,
+ const Widelands::InputQueue& queue,
bool show_only)
: UI::Panel(parent, x, y, 0, 28),
igb_(igb),
@@ -47,21 +47,21 @@
priority_radiogroup_(nullptr),
increase_max_fill_(nullptr),
decrease_max_fill_(nullptr),
- index_(queue->get_index()),
- type_(queue->get_type()),
+ index_(queue.get_index()),
+ type_(queue.get_type()),
max_fill_indicator_(g_gr->images().get(pic_max_fill_indicator)),
- cache_size_(queue->get_max_size()),
- cache_max_fill_(queue->get_max_fill()),
+ cache_size_(queue.get_max_size()),
+ cache_max_fill_(queue.get_max_fill()),
total_height_(0),
show_only_(show_only) {
if (type_ == Widelands::wwWARE) {
const Widelands::WareDescr& ware =
- *queue->owner().tribe().get_ware_descr(queue_->get_index());
+ *queue.owner().tribe().get_ware_descr(queue_.get_index());
set_tooltip(ware.descname().c_str());
icon_ = ware.icon();
} else {
const Widelands::WorkerDescr& worker =
- *queue->owner().tribe().get_worker_descr(queue_->get_index());
+ *queue.owner().tribe().get_worker_descr(queue_.get_index());
set_tooltip(worker.descname().c_str());
icon_ = worker.icon();
}
@@ -92,7 +92,7 @@
uint32_t pbs = show_only_ ? 0 : PriorityButtonSize;
uint32_t ctrl_b_size = show_only_ ? 0 : 2 * WARE_MENU_PIC_WIDTH;
- cache_size_ = queue_->get_max_size();
+ cache_size_ = queue_.get_max_size();
update_priority_buttons();
update_max_fill_buttons();
@@ -109,12 +109,12 @@
* Compare the current InputQueue state with the cached state; update if necessary.
*/
void InputQueueDisplay::think() {
- if (static_cast<uint32_t>(queue_->get_max_size()) != cache_size_)
+ if (static_cast<uint32_t>(queue_.get_max_size()) != cache_size_)
max_size_changed();
// TODO(sirver): It seems cache_max_fill_ is not really useful for anything.
- if (static_cast<uint32_t>(queue_->get_max_fill()) != cache_max_fill_) {
- cache_max_fill_ = queue_->get_max_fill();
+ if (static_cast<uint32_t>(queue_.get_max_fill()) != cache_max_fill_) {
+ cache_max_fill_ = queue_.get_max_fill();
compute_max_fill_buttons_enabled_state();
}
}
@@ -126,11 +126,11 @@
if (!cache_size_)
return;
- cache_max_fill_ = queue_->get_max_fill();
+ cache_max_fill_ = queue_.get_max_fill();
- uint32_t nr_inputs_to_draw = std::min(queue_->get_filled(), cache_size_);
+ uint32_t nr_inputs_to_draw = std::min(queue_.get_filled(), cache_size_);
uint32_t nr_missing_to_draw =
- std::min(queue_->get_missing(), cache_max_fill_) + cache_size_ - cache_max_fill_;
+ std::min(queue_.get_missing(), cache_max_fill_) + cache_size_ - cache_max_fill_;
if (nr_inputs_to_draw > cache_max_fill_) {
nr_missing_to_draw -= nr_inputs_to_draw - cache_max_fill_;
}
@@ -160,7 +160,7 @@
uint16_t pw = max_fill_indicator_->width();
point.y = Border;
point.x = Border + CellWidth + CellSpacing +
- (queue_->get_max_fill() * (CellWidth + CellSpacing)) - CellSpacing / 2 - pw / 2;
+ (queue_.get_max_fill() * (CellWidth + CellSpacing)) - CellSpacing / 2 - pw / 2;
dst.blit(point, max_fill_indicator_);
}
}
@@ -349,7 +349,7 @@
}
void InputQueueDisplay::increase_max_fill_clicked() {
- assert(cache_max_fill_ < queue_->get_max_size());
+ assert(cache_max_fill_ < queue_.get_max_size());
if (!igb_.can_act(building_.owner().player_number())) {
return;
}
@@ -370,6 +370,6 @@
if (decrease_max_fill_)
decrease_max_fill_->set_enabled(cache_max_fill_ > 0);
if (increase_max_fill_)
- increase_max_fill_->set_enabled(cache_max_fill_ < queue_->get_max_size());
+ increase_max_fill_->set_enabled(cache_max_fill_ < queue_.get_max_size());
}
}
=== modified file 'src/wui/inputqueuedisplay.h'
--- src/wui/inputqueuedisplay.h 2018-04-07 16:59:00 +0000
+++ src/wui/inputqueuedisplay.h 2018-09-05 07:39:19 +0000
@@ -56,7 +56,7 @@
int32_t y,
InteractiveGameBase& igb,
Widelands::Building& building,
- Widelands::InputQueue* queue,
+ const Widelands::InputQueue& queue,
bool = false);
~InputQueueDisplay() override;
@@ -66,7 +66,7 @@
private:
InteractiveGameBase& igb_;
Widelands::Building& building_;
- Widelands::InputQueue* queue_;
+ const Widelands::InputQueue& queue_;
UI::Radiogroup* priority_radiogroup_;
UI::Button* increase_max_fill_;
UI::Button* decrease_max_fill_;
=== modified file 'src/wui/portdockwaresdisplay.cc'
--- src/wui/portdockwaresdisplay.cc 2018-04-07 16:59:00 +0000
+++ src/wui/portdockwaresdisplay.cc 2018-09-05 07:39:19 +0000
@@ -36,24 +36,24 @@
* Display wares or workers that are waiting to be shipped from a port.
*/
struct PortDockWaresDisplay : AbstractWaresDisplay {
- PortDockWaresDisplay(Panel* parent, uint32_t width, PortDock& pd, Widelands::WareWorker type);
+ PortDockWaresDisplay(Panel* parent, uint32_t width, const PortDock& pd, Widelands::WareWorker type);
std::string info_for_ware(Widelands::DescriptionIndex ware) override;
private:
- PortDock& portdock_;
+ const PortDock& portdock_;
};
PortDockWaresDisplay::PortDockWaresDisplay(Panel* parent,
uint32_t width,
- PortDock& pd,
+ const Widelands::PortDock& pd,
Widelands::WareWorker type)
: AbstractWaresDisplay(parent, 0, 0, pd.owner().tribe(), type, false), portdock_(pd) {
set_inner_size(width, 0);
}
std::string PortDockWaresDisplay::info_for_ware(Widelands::DescriptionIndex ware) {
- uint32_t count = portdock_.count_waiting(get_type(), ware);
+ const uint32_t count = portdock_.count_waiting(get_type(), ware);
return boost::lexical_cast<std::string>(count);
}
@@ -64,7 +64,7 @@
*/
AbstractWaresDisplay* create_portdock_wares_display(UI::Panel* parent,
uint32_t width,
- PortDock& pd,
+ const PortDock& pd,
Widelands::WareWorker type) {
return new PortDockWaresDisplay(parent, width, pd, type);
}
@@ -75,8 +75,8 @@
UI::Box& box = *new UI::Box(parent, 0, 0, UI::Box::Vertical);
// Add the input queues.
- for (InputQueue* wq : wh.get_portdock()->expedition_bootstrap()->queues()) {
- box.add(new InputQueueDisplay(&box, 0, 0, igb, wh, wq, true));
+ for (const InputQueue* wq : wh.get_portdock()->expedition_bootstrap()->queues()) {
+ box.add(new InputQueueDisplay(&box, 0, 0, igb, wh, *wq, true));
}
return &box;
=== modified file 'src/wui/portdockwaresdisplay.h'
--- src/wui/portdockwaresdisplay.h 2018-04-07 16:59:00 +0000
+++ src/wui/portdockwaresdisplay.h 2018-09-05 07:39:19 +0000
@@ -30,7 +30,7 @@
AbstractWaresDisplay* create_portdock_wares_display(UI::Panel* parent,
uint32_t width,
- Widelands::PortDock& pd,
+ const Widelands::PortDock& pd,
Widelands::WareWorker type);
UI::Box* create_portdock_expedition_display(UI::Panel* parent,
=== modified file 'src/wui/productionsitewindow.cc'
--- src/wui/productionsitewindow.cc 2018-08-14 13:40:46 +0000
+++ src/wui/productionsitewindow.cc 2018-09-05 07:39:19 +0000
@@ -82,7 +82,7 @@
for (uint32_t i = 0; i < inputqueues.size(); ++i) {
prod_box->add(
- new InputQueueDisplay(prod_box, 0, 0, *igbase(), *production_site, inputqueues[i]));
+ new InputQueueDisplay(prod_box, 0, 0, *igbase(), *production_site, *inputqueues[i]));
}
get_tabs()->add("wares", g_gr->images().get(pic_tab_wares), prod_box, _("Wares"));
=== modified file 'src/wui/warehousewindow.cc'
--- src/wui/warehousewindow.cc 2018-08-14 13:40:46 +0000
+++ src/wui/warehousewindow.cc 2018-09-05 07:39:19 +0000
@@ -193,7 +193,7 @@
new WarehouseWaresPanel(get_tabs(), Width, *igbase(), *warehouse, Widelands::wwWORKER),
_("Workers"));
- if (Widelands::PortDock* pd = warehouse->get_portdock()) {
+ if (const Widelands::PortDock* pd = warehouse->get_portdock()) {
get_tabs()->add("dock_wares", g_gr->images().get(pic_tab_dock_wares),
create_portdock_wares_display(get_tabs(), Width, *pd, Widelands::wwWARE),
_("Wares waiting to be shipped"));
Follow ups