widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #02466
[Merge] lp:~widelands-dev/widelands/bug-1203629 into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1203629 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1203629 in widelands: "Replace boost::foreach and container iterate with range based for loops"
https://bugs.launchpad.net/widelands/+bug/1203629
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1203629/+merge/228203
There are still some instances of container_iterate and container_iterate_const left, but they are all tricky cases (lua_map.cc) or depend on iterator manipulation. Maybe we should get these in now and do the rest later, unless someone else wants to take over this branch.
--
https://code.launchpad.net/~widelands-dev/widelands/bug-1203629/+merge/228203
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1203629 into lp:widelands.
=== modified file 'src/ai/computer_player.cc'
--- src/ai/computer_player.cc 2014-07-16 08:23:42 +0000
+++ src/ai/computer_player.cc 2014-07-24 20:54:16 +0000
@@ -69,9 +69,10 @@
{
const ImplementationVector & vec = getImplementations();
- container_iterate_const(ImplementationVector, vec, i)
- if ((*i.current)->name == name)
- return *i.current;
-
+ for (const Computer_Player::Implementation* implementation : vec) {
+ if (implementation->name == name) {
+ return implementation;
+ }
+ }
return vec[0];
}
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2014-07-23 15:58:57 +0000
+++ src/ai/defaultai.cc 2014-07-24 20:54:16 +0000
@@ -296,10 +296,12 @@
const ProductionSite_Descr& prod =
ref_cast<ProductionSite_Descr const, Building_Descr const>(bld);
bo.type = bld.get_ismine() ? BuildingObserver::MINE : BuildingObserver::PRODUCTIONSITE;
- container_iterate_const(BillOfMaterials, prod.inputs(), j)
- bo.inputs_.push_back(j.current->first);
- container_iterate_const(ProductionSite_Descr::Output, prod.output_ware_types(), j)
- bo.outputs_.push_back(*j.current);
+ for (const WareAmount& temp_input : prod.inputs()) {
+ bo.inputs_.push_back(temp_input.first);
+ }
+ for (const Ware_Index& temp_output : prod.output_ware_types()) {
+ bo.outputs_.push_back(temp_output);
+ }
if (bo.type == BuildingObserver::MINE) {
// get the resource needed by the mine
@@ -688,10 +690,10 @@
or(dynamic_cast<Road const*>(imm) && (fse.field->nodecaps() & BUILDCAPS_FLAG)))
field.preferred_ = true;
- container_iterate_const(std::vector<ImmovableFound>, immovables, i) {
- if (dynamic_cast<Flag const*>(i.current->object))
+ for (const ImmovableFound& temp_immovable : immovables) {
+ if (dynamic_cast<Flag const*>(temp_immovable.object))
field.reachable = true;
- else if (upcast(Building const, bld, i.current->object)) {
+ else if (upcast(Building const, bld, temp_immovable.object)) {
if (bld->descr().get_ismine()) {
++field.mines_nearby_;
} else if (upcast(ConstructionSite const, cs, bld)) {
@@ -1535,13 +1537,15 @@
// improves current road system
bool DefaultAI::improve_roads(int32_t gametime) {
// Remove flags of dead end roads, as long as no more wares are stored on them
- container_iterate(std::list<EconomyObserver*>, economies, i)
- container_iterate(std::list<Flag const*>, (*i.current)->flags, j)
+ for (EconomyObserver* eco_obs : economies) {
+ container_iterate(std::list<Flag const*>, eco_obs->flags, j) {
- if ((*j.current)->is_dead_end() && (*j.current)->current_wares() == 0) {
- game().send_player_bulldoze(*const_cast<Flag*>((*j.current)));
- j.current = (*i.current)->flags.erase(j.current);
- return true;
+ if ((*j.current)->is_dead_end() && (*j.current)->current_wares() == 0) {
+ game().send_player_bulldoze(*const_cast<Flag*>((*j.current)));
+ j.current = eco_obs->flags.erase(j.current);
+ return true;
+ }
+ }
}
// force a split on roads that are longer than 3 parts
@@ -1635,15 +1639,15 @@
bool found = false;
check.set_openend(false);
Coords closest;
- container_iterate_const(std::vector<Coords>, reachable, i) {
+ for (const Coords& reachable_coords : reachable) {
Path* path2 = new Path();
- if (map.findpath(flag.get_position(), *i.current, 0, *path2, check) >= 0) {
+ if (map.findpath(flag.get_position(), reachable_coords, 0, *path2, check) >= 0) {
if (!found || path->get_nsteps() > path2->get_nsteps()) {
delete path;
path = path2;
path2 = nullptr;
- closest = *i.current;
+ closest = reachable_coords;
found = true;
}
}
@@ -1808,10 +1812,11 @@
// Get max radius of recursive workarea
Workarea_Info::size_type radius = 0;
const Workarea_Info& workarea_info = site.bo->desc->m_workarea_info;
- container_iterate_const(Workarea_Info, workarea_info, i)
-
- if (radius < i.current->first)
- radius = i.current->first;
+ for (const std::pair<uint32_t, std::set<std::string> > & temp_info : workarea_info) {
+ if (radius < temp_info.first) {
+ radius = temp_info.first;
+ }
+ }
Map& map = game().map();
@@ -2427,19 +2432,19 @@
if (upcast(Building const, building, &pi))
lose_building(*building);
else if (upcast(Flag const, flag, &pi)) {
- container_iterate_const(std::list<EconomyObserver*>, economies, i)
- container_iterate(std::list<Flag const*>, (*i.current)->flags, j)
-
- if (*j.current == flag) {
- (*i.current)->flags.erase(j.current);
- return;
+ for (EconomyObserver* temp_observer : economies) {
+ container_iterate(std::list<Flag const*>, temp_observer->flags, j) {
+ if (*j.current == flag) {
+ temp_observer->flags.erase(j.current);
+ return;
+ }
+ }
}
-
- container_iterate(std::list<Flag const*>, new_flags, i)
-
- if (*i.current == flag) {
- new_flags.erase(i.current);
- return;
+ container_iterate(std::list<Flag const*>, new_flags, i) {
+ if (*i.current == flag) {
+ new_flags.erase(i.current);
+ return;
+ }
}
} else if (upcast(Road const, road, &pi))
roads.remove(road);
@@ -2559,15 +2564,16 @@
// NOTE: This is not needed anymore and it seems it is not missed neither
bool DefaultAI::check_supply(const BuildingObserver& bo) {
size_t supplied = 0;
- container_iterate_const(std::vector<int16_t>, bo.inputs_, i)
- container_iterate_const(std::vector<BuildingObserver>, buildings_, j)
-
- if (j.current->cnt_built_ &&
- std::find(j.current->outputs_.begin(), j.current->outputs_.end(), *i.current) !=
- j.current->outputs_.end() &&
- check_supply(*j.current)) {
- ++supplied;
- break;
+ for (const int16_t& temp_inputs : bo.inputs_) {
+ for (const BuildingObserver& temp_building : buildings_) {
+ if (temp_building.cnt_built_ &&
+ std::find(temp_building.outputs_.begin(), temp_building.outputs_.end(), temp_inputs) !=
+ temp_building.outputs_.end() &&
+ check_supply(temp_building)) {
+ ++supplied;
+ break;
+ }
+ }
}
return supplied == bo.inputs_.size();
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2014-07-22 09:54:49 +0000
+++ src/economy/economy.cc 2014-07-24 20:54:16 +0000
@@ -299,11 +299,12 @@
flag.set_economy(nullptr);
// fast remove
- container_iterate(Flags, m_flags, i)
+ container_iterate(Flags, m_flags, i) {
if (*i.current == &flag) {
*i.current = *(i.get_end() - 1);
return m_flags.pop_back();
}
+ }
throw wexception("trying to remove nonexistent flag");
}
@@ -313,8 +314,9 @@
*/
void Economy::_reset_all_pathfinding_cycles()
{
- container_iterate(Flags, m_flags, i)
- (*i.current)->reset_path_finding_cycle();
+ for (Flag * flag : m_flags) {
+ flag->reset_path_finding_cycle();
+ }
}
/**
@@ -500,8 +502,8 @@
bool Economy::needs_ware(Ware_Index const ware_type) const {
uint32_t const t = ware_target_quantity(ware_type).permanent;
uint32_t quantity = 0;
- container_iterate_const(std::vector<Warehouse *>, m_warehouses, wh) {
- quantity += (*wh)->get_wares().stock(ware_type);
+ for (const Warehouse * wh : m_warehouses) {
+ quantity += wh->get_wares().stock(ware_type);
if (t <= quantity)
return false;
}
@@ -512,8 +514,8 @@
bool Economy::needs_worker(Ware_Index const worker_type) const {
uint32_t const t = worker_target_quantity(worker_type).permanent;
uint32_t quantity = 0;
- container_iterate_const(std::vector<Warehouse *>, m_warehouses, wh) {
- quantity += (*wh)->get_workers().stock(worker_type);
+ for (const Warehouse * wh : m_warehouses) {
+ quantity += wh->get_workers().stock(worker_type);
if (t <= quantity)
return false;
}
@@ -591,8 +593,8 @@
e.m_worker_target_quantities[i] = m_worker_target_quantities[i];
}
- container_iterate_const(std::set<OPtr<Flag> >, flags, it) {
- Flag & flag = *it.current->get(owner().egbase());
+ for (const OPtr<Flag> temp_flag : flags) {
+ Flag & flag = *temp_flag.get(owner().egbase());
assert(m_flags.size() > 1); // We will not be deleted in remove_flag, right?
remove_flag(flag);
e.add_flag(flag);
@@ -712,8 +714,8 @@
*/
void Economy::_process_requests(Game & game, RSPairStruct & s)
{
- container_iterate_const(RequestList, m_requests, i) {
- Request & req = **i.current;
+ for (Request * temp_req : m_requests) {
+ Request & req = *temp_req;
// We somehow get desynced request lists that don't trigger desync
// alerts, so add info to the sync stream here.
@@ -827,8 +829,8 @@
}
- container_iterate_const(RequestList, m_requests, j) {
- const Request & req = **j.current;
+ for (const Request * temp_req : m_requests) {
+ const Request & req = *temp_req;
if (req.get_type() != wwWORKER || req.get_index() != index)
continue;
@@ -886,8 +888,8 @@
uint32_t can_create = std::numeric_limits<uint32_t>::max();
uint32_t idx = 0;
uint32_t scarcest_idx = 0;
- container_iterate_const(Worker_Descr::Buildcost, cost, bc) {
- uint32_t cc = total_available[idx] / bc.current->second;
+ for (const std::pair<std::string, uint8_t>& bc : cost) {
+ uint32_t cc = total_available[idx] / bc.second;
if (cc <= can_create) {
scarcest_idx = idx;
can_create = cc;
@@ -1021,11 +1023,11 @@
ss.Unsigned32(0x02decafa); // appears as facade02 in sync stream
ss.Unsigned32(assignments.size());
- container_iterate_const(Assignments, assignments, it) {
- ss.Unsigned32(it.current->first->get_position(game)->serial());
- ss.Unsigned32(it.current->second->serial());
+ for (const std::pair<Supply *, Warehouse *>& temp_assignment : assignments) {
+ ss.Unsigned32(temp_assignment.first->get_position(game)->serial());
+ ss.Unsigned32(temp_assignment.second->serial());
- it.current->first->send_to_storage(game, it.current->second);
+ temp_assignment.first->send_to_storage(game, temp_assignment.second);
}
}
=== modified file 'src/economy/flag.cc'
--- src/economy/flag.cc 2014-07-14 14:40:42 +0000
+++ src/economy/flag.cc 2014-07-24 20:54:16 +0000
@@ -184,8 +184,9 @@
if (m_building)
m_building->set_economy(e);
- container_iterate_const(FlagJobs, m_flag_jobs, i)
- i.current->request->set_economy(e);
+ for (const FlagJob& temp_job : m_flag_jobs) {
+ temp_job.request->set_economy(e);
+ }
for (int8_t i = 0; i < 6; ++i) {
if (m_roads[i])
@@ -795,7 +796,7 @@
assert(w);
- container_iterate(FlagJobs, flag.m_flag_jobs, i)
+ container_iterate(FlagJobs, flag.m_flag_jobs, i) {
if (i.current->request == &rq) {
delete &rq;
@@ -804,6 +805,7 @@
flag.m_flag_jobs.erase(i.current);
return;
}
+ }
flag.molog("BUG: flag_job_request_callback: worker not found in list\n");
}
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2014-07-22 09:54:49 +0000
+++ src/economy/fleet.cc 2014-07-24 20:54:16 +0000
@@ -100,8 +100,8 @@
#endif
if (upcast(Game, game, &owner().egbase())) {
- container_iterate_const(std::vector<Ship *>, m_ships, shipit) {
- (*shipit.current)->set_economy(*game, e);
+ for (Ship * temp_ship : m_ships) {
+ temp_ship->set_economy(*game, e);
}
}
}
@@ -155,15 +155,15 @@
Map & map = egbase.map();
MapAStar<StepEvalFindFleet> astar(map, StepEvalFindFleet());
- container_iterate_const(std::vector<Ship *>, m_ships, it) {
- astar.push((*it.current)->get_position());
+ for (const Ship * temp_ship : m_ships) {
+ astar.push(temp_ship->get_position());
}
- container_iterate_const(std::vector<PortDock *>, m_ports, it) {
- BaseImmovable::PositionList pos = (*it.current)->get_positions(egbase);
+ for (const PortDock * temp_port : m_ports) {
+ BaseImmovable::PositionList pos = temp_port->get_positions(egbase);
- container_iterate_const(BaseImmovable::PositionList, pos, posit) {
- astar.push(*posit.current);
+ for (const Coords& temp_pos : pos) {
+ astar.push(temp_pos);
}
}
@@ -421,8 +421,8 @@
int32_t estimate(Map & map, FCoords pos) const
{
int32_t est = std::numeric_limits<int32_t>::max();
- container_iterate_const(std::vector<Target>, targets, it) {
- est = std::min(est, map.calc_cost_estimate(pos, it.current->pos));
+ for (const Target& temp_target : targets) {
+ est = std::min(est, map.calc_cost_estimate(pos, temp_target.pos));
}
return std::max(0, est - 5 * map.calc_cost(0));
}
@@ -467,8 +467,8 @@
MapAStar<StepEvalFindPorts> astar(map, se);
BaseImmovable::PositionList src(m_ports[idx]->get_positions(egbase));
- container_iterate_const(BaseImmovable::PositionList, src, it) {
- astar.push(*it.current);
+ for (const Coords& temp_pos : src) {
+ astar.push(temp_pos);
}
int32_t cost;
@@ -503,9 +503,9 @@
if (reverse)
ppath.path->reverse();
- container_iterate(std::vector<StepEvalFindPorts::Target>, se.targets, it) {
- if (it.current->idx == otheridx) {
- *it.current = se.targets.back();
+ for (StepEvalFindPorts::Target& temp_target : se.targets) {
+ if (temp_target.idx == otheridx) {
+ temp_target = se.targets.back();
se.targets.pop_back();
break;
}
@@ -571,9 +571,9 @@
*/
PortDock * Fleet::get_dock(Flag & flag) const
{
- container_iterate_const(std::vector<PortDock *>, m_ports, portit) {
- if (&(*portit.current)->base_flag() == &flag)
- return *portit.current;
+ for (PortDock * temp_port : m_ports) {
+ if (&temp_port->base_flag() == &flag)
+ return temp_port;
}
return nullptr;
@@ -622,13 +622,13 @@
molog("Fleet::act\n");
- container_iterate_const(std::vector<Ship *>, m_ships, shipit) {
- Ship & ship = **shipit.current;
+ for (Ship * temp_ship : m_ships) {
+ Ship & ship = *temp_ship;
if (ship.get_nritems() > 0 && !ship.get_destination(game)) {
molog("Ship %u has items\n", ship.serial());
bool found_dst = false;
- container_iterate(std::vector<ShippingItem>, ship.m_items, it) {
- PortDock * dst = it->get_destination(game);
+ for (ShippingItem& temp_item : ship.m_items) {
+ PortDock * dst = temp_item.get_destination(game);
if (dst) {
molog("... sending to portdock %u\n", dst->serial());
ship.set_destination(game, *dst);
@@ -651,8 +651,8 @@
molog("Port %u needs ship\n", pd.serial());
bool success = false;
- container_iterate_const(std::vector<Ship *>, m_ships, shipit) {
- Ship & ship = **shipit.current;
+ for (Ship * temp_ship : m_ships) {
+ Ship & ship = *temp_ship;
// Check whether ship is in TRANSPORT state
if (ship.get_ship_state() != Ship::TRANSPORT)
continue;
@@ -731,12 +731,12 @@
// changes to the pending state.
bool save_act_pending = fleet.m_act_pending;
- container_iterate_const(std::vector<uint32_t>, m_ships, it) {
- fleet.m_ships.push_back(&mol().get<Ship>(*it));
+ for (const uint32_t& temp_ship : m_ships) {
+ fleet.m_ships.push_back(&mol().get<Ship>(temp_ship));
fleet.m_ships.back()->set_fleet(&fleet);
}
- container_iterate_const(std::vector<uint32_t>, m_ports, it) {
- fleet.m_ports.push_back(&mol().get<PortDock>(*it));
+ for (const uint32_t& temp_port: m_ports) {
+ fleet.m_ports.push_back(&mol().get<PortDock>(temp_port));
fleet.m_ports.back()->set_fleet(&fleet);
}
@@ -799,12 +799,12 @@
Map_Object::save(egbase, mos, fw);
fw.Unsigned32(m_ships.size());
- container_iterate_const(std::vector<Ship *>, m_ships, it) {
- fw.Unsigned32(mos.get_object_file_index(**it));
+ for (const Ship * temp_ship : m_ships) {
+ fw.Unsigned32(mos.get_object_file_index(*temp_ship));
}
fw.Unsigned32(m_ports.size());
- container_iterate_const(std::vector<PortDock *>, m_ports, it) {
- fw.Unsigned32(mos.get_object_file_index(**it));
+ for (const PortDock * temp_port : m_ports) {
+ fw.Unsigned32(mos.get_object_file_index(*temp_port));
}
fw.Unsigned8(m_act_pending);
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2014-07-16 05:33:19 +0000
+++ src/economy/portdock.cc 2014-07-24 20:54:16 +0000
@@ -142,8 +142,8 @@
m_fleet->set_economy(e);
if (upcast(Game, game, &owner().egbase())) {
- container_iterate(std::vector<ShippingItem>, m_waiting, it) {
- it->set_economy(*game, e);
+ for (ShippingItem& shipping_item : m_waiting) {
+ shipping_item.set_economy(*game, e);
}
}
@@ -162,8 +162,8 @@
{
PlayerImmovable::init(egbase);
- container_iterate_const(PositionList, m_dockpoints, it) {
- set_position(egbase, *it.current);
+ for (const Coords& coords: m_dockpoints) {
+ set_position(egbase, coords);
}
init_fleet(egbase);
@@ -203,16 +203,16 @@
}
if (upcast(Game, game, &egbase)) {
- container_iterate(std::vector<ShippingItem>, m_waiting, it) {
- it.current->remove(*game);
+ for (ShippingItem& shipping_item : m_waiting) {
+ shipping_item.remove(*game);
}
}
if (m_fleet)
m_fleet->remove_port(egbase, this);
- container_iterate_const(PositionList, m_dockpoints, it) {
- unset_position(egbase, *it.current);
+ for (const Coords& coords: m_dockpoints) {
+ unset_position(egbase, coords);
}
if (m_expedition_bootstrap) {
@@ -251,7 +251,7 @@
container_iterate(std::vector<ShippingItem>, m_waiting, it) {
if (it.current->m_object.serial() == ware.serial()) {
_update_shippingitem(game, it.current);
- return;
+ return;
}
}
}
@@ -275,7 +275,7 @@
container_iterate(std::vector<ShippingItem>, m_waiting, it) {
if (it.current->m_object.serial() == worker.serial()) {
_update_shippingitem(game, it.current);
- return;
+ return;
}
}
}
@@ -310,9 +310,9 @@
std::vector<ShippingItem> items_brought_by_ship;
ship.withdraw_items(game, *this, items_brought_by_ship);
- container_iterate(std::vector<ShippingItem>, items_brought_by_ship, it) {
- it->set_location(game, m_warehouse);
- it->end_shipping(game);
+ for (ShippingItem& shipping_item : items_brought_by_ship) {
+ shipping_item.set_location(game, m_warehouse);
+ shipping_item.end_shipping(game);
}
if (m_expedition_ready) {
@@ -390,10 +390,10 @@
{
uint32_t count = 0;
- container_iterate(std::vector<ShippingItem>, m_waiting, it) {
+ for (ShippingItem& shipping_item : m_waiting) {
WareInstance * ware;
Worker * worker;
- it.current->get(owner().egbase(), &ware, &worker);
+ shipping_item.get(owner().egbase(), &ware, &worker);
if (waretype == wwWORKER) {
if (worker && worker->descr().worker_index() == wareindex)
@@ -451,11 +451,11 @@
m_need_ship ? "true" : "false",
m_waiting.size());
- container_iterate(std::vector<ShippingItem>, m_waiting, it) {
+ for (ShippingItem& shipping_item : m_waiting) {
molog
(" IT %u, destination %u\n",
- it.current->m_object.serial(),
- it.current->m_destination_dock.serial());
+ shipping_item.m_object.serial(),
+ shipping_item.m_destination_dock.serial());
}
}
@@ -484,8 +484,8 @@
pd.m_need_ship = fr.Unsigned8();
m_waiting.resize(fr.Unsigned32());
- container_iterate(std::vector<ShippingItem::Loader>, m_waiting, it) {
- it->load(fr);
+ for (ShippingItem::Loader& shipping_loader : m_waiting) {
+ shipping_loader.load(fr);
}
if (version >= 3) {
@@ -560,15 +560,15 @@
fw.Unsigned32(mos.get_object_file_index(*m_warehouse));
fw.Unsigned16(m_dockpoints.size());
- container_iterate_const(PositionList, m_dockpoints, it) {
- WriteCoords32(&fw, *it);
+ for (const Coords& coords: m_dockpoints) {
+ WriteCoords32(&fw, coords);
}
fw.Unsigned8(m_need_ship);
fw.Unsigned32(m_waiting.size());
- container_iterate(std::vector<ShippingItem>, m_waiting, it) {
- it->save(egbase, mos, fw);
+ for (ShippingItem& shipping_item : m_waiting) {
+ shipping_item.save(egbase, mos, fw);
}
// Expedition specific stuff
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2014-07-23 14:49:10 +0000
+++ src/economy/road.cc 2014-07-24 20:54:16 +0000
@@ -74,8 +74,9 @@
*/
Road::~Road()
{
- container_iterate_const(SlotVector, m_carrier_slots, i)
- delete i.current->carrier_request;
+ for (CarrierSlot& slot: m_carrier_slots) {
+ delete slot.carrier_request;
+ }
}
/**
@@ -282,17 +283,19 @@
* If a carrier is set assign it to this road, else
* request a new carrier
*/
- if (upcast(Game, game, &egbase))
- container_iterate(SlotVector, m_carrier_slots, i) {
- if (Carrier * const carrier = i.current->carrier.get(*game)) {
- // This happens after a road split. Tell the carrier what's going on.
- carrier->set_location (this);
- carrier->update_task_road(*game);
- } else if
- (not i.current->carrier_request and
- (i.current->carrier_type == 1 or
- m_type == Road_Busy))
- _request_carrier(*i.current);
+ if (upcast(Game, game, &egbase)) {
+ for (CarrierSlot& slot : m_carrier_slots) {
+ if (Carrier * const carrier = slot.carrier.get(*game)) {
+ // This happens after a road split. Tell the carrier what's going on.
+ carrier->set_location (this);
+ carrier->update_task_road(*game);
+ } else if
+ (!slot.carrier_request &&
+ (slot.carrier_type == 1 ||
+ m_type == Road_Busy)) {
+ _request_carrier(slot);
+ }
+ }
}
}
@@ -302,12 +305,12 @@
void Road::cleanup(Editor_Game_Base & egbase)
{
- container_iterate(SlotVector, m_carrier_slots, i) {
- delete i.current->carrier_request;
- i.current->carrier_request = nullptr;
+ for (CarrierSlot& slot : m_carrier_slots) {
+ delete slot.carrier_request;
+ slot.carrier_request = nullptr;
// carrier will be released via PlayerImmovable::cleanup
- i.current->carrier = nullptr;
+ slot.carrier = nullptr;
}
// Unmark Fields
@@ -335,9 +338,11 @@
{
PlayerImmovable::set_economy(e);
- container_iterate_const(SlotVector, m_carrier_slots, i)
- if (i.current->carrier_request)
- i.current->carrier_request->set_economy(e);
+ for (CarrierSlot& slot: m_carrier_slots) {
+ if (slot.carrier_request) {
+ slot.carrier_request->set_economy(e);
+ }
+ }
}
/**
@@ -378,16 +383,17 @@
Road & road = ref_cast<Road, PlayerImmovable>(target);
- container_iterate(SlotVector, road.m_carrier_slots, i)
- if (i.current->carrier_request == &rq) {
+ for (CarrierSlot& slot : road.m_carrier_slots) {
+ if (slot.carrier_request == &rq) {
Carrier & carrier = ref_cast<Carrier, Worker> (*w);
- i.current->carrier_request = nullptr;
- i.current->carrier = &carrier;
+ slot.carrier_request = nullptr;
+ slot.carrier = &carrier;
carrier.start_task_road(game);
delete &rq;
return;
}
+ }
/*
* Oops! We got a request_callback but don't have the request.
@@ -407,13 +413,13 @@
{
Editor_Game_Base & egbase = owner().egbase();
- container_iterate(SlotVector, m_carrier_slots, i) {
- Carrier const * carrier = i.current->carrier.get(egbase);
+ for (CarrierSlot& slot : m_carrier_slots) {
+ Carrier const * carrier = slot.carrier.get(egbase);
if (carrier == &w) {
- i.current->carrier = nullptr;
+ slot.carrier = nullptr;
carrier = nullptr;
- _request_carrier(*i.current);
+ _request_carrier(slot);
}
}
@@ -476,11 +482,13 @@
secondpath.starttrim(index);
molog("splitting road: first part:\n");
- container_iterate_const(std::vector<Coords>, path.get_coords(), i)
- molog("* (%i, %i)\n", i.current->x, i.current->y);
+ for (const Coords& coords : path.get_coords()) {
+ molog("* (%i, %i)\n", coords.x, coords.y);
+ }
molog(" second part:\n");
- container_iterate_const(std::vector<Coords>, secondpath.get_coords(), i)
- molog("* (%i, %i)\n", i.current->x, i.current->y);
+ for (const Coords& coords : secondpath.get_coords()) {
+ molog("* (%i, %i)\n", coords.x, coords.y);
+ }
// change road size and reattach
m_flags[FlagEnd] = &flag;
@@ -506,12 +514,10 @@
// the worker around; there's obviously nothing wrong with that.
std::vector<Worker *> const workers = get_workers();
-
std::vector<Worker *> reassigned_workers;
- container_iterate_const(std::vector<Worker *>, workers, i) {
- Worker & w = **i.current;
- int32_t idx = path.get_index(w.get_position());
+ for (Worker * w : workers) {
+ int32_t idx = path.get_index(w->get_position());
// Careful! If the worker is currently inside the building at our
// starting flag, we *must not* reassign him.
@@ -520,42 +526,44 @@
if (idx < 0) {
if
(dynamic_cast<Building const *>
- (map.get_immovable(w.get_position())))
+ (map.get_immovable(w->get_position())))
{
Coords pos;
- map.get_brn(w.get_position(), &pos);
+ map.get_brn(w->get_position(), &pos);
if (pos == path.get_start())
idx = 0;
}
}
if (idx < 0) {
- reassigned_workers.push_back(&w);
+ reassigned_workers.push_back(w);
/*
* The current worker is not on this road. Search him
* in this road and remove him. Than add him to the new road
*/
- container_iterate(SlotVector, m_carrier_slots, j) {
- Carrier const * const carrier = j.current->carrier.get(game);
+ for (CarrierSlot& old_slot : m_carrier_slots) {
+ Carrier const * const carrier = old_slot.carrier.get(game);
- if (carrier == &w) {
- j.current->carrier = nullptr;
- container_iterate(SlotVector, newroad.m_carrier_slots, k)
+ if (carrier == w) {
+ old_slot.carrier = nullptr;
+ for (CarrierSlot& new_slot : newroad.m_carrier_slots) {
if
- (not k.current->carrier.get(game) and
- not k.current->carrier_request and
- k.current->carrier_type == j.current->carrier_type)
+ (!new_slot.carrier.get(game) &&
+ !new_slot.carrier_request &&
+ new_slot.carrier_type == old_slot.carrier_type)
{
- k.current->carrier = &ref_cast<Carrier, Worker> (w);
+ upcast(Carrier, new_carrier, w);
+ new_slot.carrier = new_carrier;
break;
}
+ }
}
}
}
// Cause a worker update in any case
- w.send_signal(game, "road");
+ w->send_signal(game, "road");
}
// Initialize the new road
@@ -563,19 +571,22 @@
// Actually reassign workers after the new road has initialized,
// so that the reassignment is safe
- container_iterate_const(std::vector<Worker *>, reassigned_workers, i)
- (*i.current)->set_location(&newroad);
+ for (Worker *& w : reassigned_workers) {
+ w->set_location(&newroad);
+ }
// Request a new carrier for this road if necessary. This must be done
// _after_ the new road initializes, otherwise request routing might not
// work correctly
- container_iterate(SlotVector, m_carrier_slots, i)
+ for (CarrierSlot& slot : m_carrier_slots) {
if
- (not i.current->carrier.get(game) and
- not i.current->carrier_request and
- (i.current->carrier_type == 1 or
- m_type == Road_Busy))
- _request_carrier(*i.current);
+ (!slot.carrier.get(game) &&
+ !slot.carrier_request &&
+ (slot.carrier_type == 1 ||
+ m_type == Road_Busy)) {
+ _request_carrier(slot);
+ }
+ }
// Make sure wares waiting on the original endpoint flags are dealt with.
m_flags[FlagStart]->update_wares(game, &oldend);
@@ -593,8 +604,8 @@
uint32_t const tdelta = gametime - m_busyness_last_update;
// Iterate over all carriers and try to find one which takes the ware.
- container_iterate(SlotVector, m_carrier_slots, i)
- if (Carrier * const carrier = i.current->carrier.get(game))
+ for (CarrierSlot& slot : m_carrier_slots) {
+ if (Carrier * const carrier = slot.carrier.get(game))
if (carrier->notify_ware(game, flagid)) {
// notify_ware returns false if the carrier currently can not take
// the ware. If we get here, the carrier took the ware. So we
@@ -628,6 +639,7 @@
}
return true;
}
+ }
// If we get here, no carrier took the ware. So we check if we should
// increment the usage counter. m_busyness_last_update prevents that the
@@ -637,12 +649,14 @@
if (500 < (m_busyness += 10)) {
m_type = Road_Busy;
_mark_map(game);
- container_iterate(SlotVector, m_carrier_slots, i)
+ for (CarrierSlot& slot : m_carrier_slots) {
if
- (not i.current->carrier.get(game) and
- not i.current->carrier_request and
- i.current->carrier_type != 1)
- _request_carrier(*i.current);
+ (!slot.carrier.get(game) &&
+ !slot.carrier_request &&
+ slot.carrier_type != 1) {
+ _request_carrier(slot);
+ }
+ }
}
}
return false;
=== modified file 'src/economy/routeastar.h'
--- src/economy/routeastar.h 2014-07-05 16:41:51 +0000
+++ src/economy/routeastar.h 2014-07-24 20:54:16 +0000
@@ -136,8 +136,8 @@
current->get_neighbours(m_type, m_neighbours);
- container_iterate_const(RoutingNodeNeighbours, m_neighbours, it) {
- RoutingNode & neighbour = *it.current->get_neighbour();
+ for (RoutingNodeNeighbour& temp_neighbour : m_neighbours) {
+ RoutingNode & neighbour = *temp_neighbour.get_neighbour();
// We have already found the best path
// to this neighbour, no need to visit it again.
@@ -146,7 +146,7 @@
!neighbour.cookie().is_active())
continue;
- int32_t realcost = current->mpf_realcost + it.current->get_cost();
+ int32_t realcost = current->mpf_realcost + temp_neighbour.get_cost();
push(neighbour, realcost, current);
}
=== modified file 'src/economy/supply_list.cc'
--- src/economy/supply_list.cc 2014-07-05 12:17:03 +0000
+++ src/economy/supply_list.cc 2014-07-24 20:54:16 +0000
@@ -39,12 +39,12 @@
*/
void SupplyList::remove_supply(Supply & supp)
{
- container_iterate(Supplies, m_supplies, i)
+ container_iterate(Supplies, m_supplies, i) {
if (*i.current == &supp) {
*i.current = *(i.get_end() - 1);
return m_supplies.pop_back();
}
-
+ }
throw wexception("SupplyList::remove: not in list");
}
=== modified file 'src/economy/test/test_routing.cc'
--- src/economy/test/test_routing.cc 2014-07-22 09:54:49 +0000
+++ src/economy/test/test_routing.cc 2014-07-24 20:54:16 +0000
@@ -75,10 +75,11 @@
Flag _flag;
};
void TestingRoutingNode::get_neighbours(WareWorker type, RoutingNodeNeighbours & n) {
- container_iterate_const(Neigbours, _neighbours, i)
+ for (TestingRoutingNode * nb : _neighbours) {
// second parameter is walktime in ms from this flag to the neighbour.
// only depends on slope
- n.push_back(RoutingNodeNeighbour(*i.current, 1000 * ((type == wwWARE)?1 + _waitcost:1)));
+ n.push_back(RoutingNodeNeighbour(nb, 1000 * ((type == wwWARE)?1 + _waitcost:1)));
+ }
}
bool TestingRoutingNode::all_members_zeroed() {
bool integers_zero =
@@ -111,9 +112,11 @@
int32_t get_length() {return nodes.size();}
bool has_node(RoutingNode * const n) {
- container_iterate_const(Nodes, nodes, i)
- if (*i.current == n)
+ for (RoutingNode * temp_node : nodes) {
+ if (temp_node == n) {
return true;
+ }
+ }
return false;
}
bool has_chain(Nodes & n) {
@@ -491,8 +494,9 @@
*/
void reset()
{
- container_iterate(Nodes, nodes, i)
- (*i.current)->reset_path_finding_cycle();
+ for (RoutingNode * node : nodes) {
+ node->reset_path_finding_cycle();
+ }
}
TestingRoutingNode * d0;
Nodes nodes;
=== modified file 'src/game_io/game_loader.cc'
--- src/game_io/game_loader.cc 2014-07-05 13:14:42 +0000
+++ src/game_io/game_loader.cc 2014-07-24 20:54:16 +0000
@@ -99,9 +99,9 @@
Player_Number const nr_players = m_game.map().get_nrplayers();
iterate_players_existing_const(p, nr_players, m_game, player) {
const MessageQueue & messages = player->messages();
- container_iterate_const(MessageQueue, messages, i) {
- Message* m = i.current->second;
- Message_Id m_id = i.current->first;
+ for (std::pair<Message_Id, Message *> temp_message : messages) {
+ Message* m = temp_message.second;
+ Message_Id m_id = temp_message.first;
// Renew expire commands
Duration const duration = m->duration();
=== modified file 'src/game_io/game_player_economies_data_packet.cc'
--- src/game_io/game_player_economies_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/game_io/game_player_economies_data_packet.cc 2014-07-24 20:54:16 +0000
@@ -52,11 +52,11 @@
Player::Economies & economies = player->m_economies;
uint16_t const nr_economies = economies.size();
Player::Economies ecos(nr_economies);
- container_iterate(Player::Economies, ecos, i) {
+ for (Economy * temp_eco : ecos) {
uint32_t value = fr.Unsigned32();
if (value < 0xffffffff) {
if (upcast(Flag const, flag, map[value].get_immovable())) {
- *i.current = flag->get_economy();
+ temp_eco = flag->get_economy();
EconomyDataPacket d(flag->get_economy());
d.Read(fr);
} else {
@@ -106,13 +106,13 @@
Player_Number const nr_players = map.get_nrplayers();
iterate_players_existing_const(p, nr_players, game, player) {
const Player::Economies & economies = player->m_economies;
- container_iterate_const(Player::Economies, economies, i) {
+ for (Economy * temp_economy : economies) {
bool wrote_this_economy = false;
// Walk the map so that we find a representative Flag.
for (Field const * field = &field_0; field < &map[map.max_index()]; ++field) {
if (upcast(Flag const, flag, field->get_immovable())) {
- if (flag->get_economy() == *i.current) {
+ if (flag->get_economy() == temp_economy) {
fw.Unsigned32(field - &field_0);
EconomyDataPacket d(flag->get_economy());
@@ -132,7 +132,7 @@
Bob* bob = field->get_first_bob();
while (bob) {
if (upcast(Ship const, ship, bob)) {
- if (ship->get_economy() == *i.current) {
+ if (ship->get_economy() == temp_economy) {
// TODO(sirver): the 0xffffffff is ugly and fragile.
fw.Unsigned32(0xffffffff); // Sentinel value.
fw.Unsigned32(field - &field_0);
=== modified file 'src/graphic/text_parser.cc'
--- src/graphic/text_parser.cc 2014-07-05 14:22:44 +0000
+++ src/graphic/text_parser.cc 2014-07-24 20:54:16 +0000
@@ -117,8 +117,8 @@
split_words(block_text, &unwrapped_words);
//Handle user defined line breaks, and save them
- container_iterate_const(std::vector<std::string>, unwrapped_words, i)
- for (std::string line = *i.current;;) {
+ for (const std::string& temp_words : unwrapped_words) {
+ for (std::string line = temp_words;;) {
std::string::size_type next_break = line.find("<br>");
// Replace < with <
@@ -140,6 +140,7 @@
line_breaks.push_back(words.size());
line.erase(0, next_break + 4);
}
+ }
return extract_more;
}
=== modified file 'src/logic/bob.cc'
--- src/logic/bob.cc 2014-07-15 10:02:22 +0000
+++ src/logic/bob.cc 2014-07-24 20:54:16 +0000
@@ -650,8 +650,9 @@
molog
("ERROR: (%i, %i) is not on the given path:\n",
get_position().x, get_position().y);
- container_iterate_const(std::vector<Coords>, path.get_coords(), i)
- molog("* (%i, %i)\n", i.current->x, i.current->y);
+ for (const Coords& coords : path.get_coords()) {
+ molog("* (%i, %i)\n", coords.x, coords.y);
+ }
log_general_info(game);
log("%s", get_backtrace().c_str());
throw wexception
@@ -917,9 +918,9 @@
(Area<FCoords>(field, 0), &soldiers, FindBobEnemySoldier(get_owner()));
if (!soldiers.empty()) {
- container_iterate(std::vector<Bob *>, soldiers, i) {
- Soldier & soldier = ref_cast<Soldier, Bob>(**i.current);
- if (soldier.getBattle())
+ for (Bob * temp_bob : soldiers) {
+ upcast(Soldier, soldier, temp_bob);
+ if (soldier->getBattle())
return true;
}
}
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2014-07-24 05:21:20 +0000
+++ src/logic/building.cc 2014-07-24 20:54:16 +0000
@@ -506,7 +506,8 @@
#define FORMAT(key, value) case key: result << value; break
std::string Building::info_string(const std::string & format) {
std::ostringstream result;
- container_iterate_const(std::string, format, i)
+
+ container_iterate_const(std::string, format, i) {
if (*i.current == '%') {
if (i.advance().empty()) { // unterminated format sequence
result << '%';
@@ -554,6 +555,7 @@
}
} else
result << *i.current;
+ }
const std::string result_str = result.str();
return result_str.empty() ? result_str : as_uifont(result_str);
}
=== modified file 'src/logic/checkstep.cc'
--- src/logic/checkstep.cc 2013-07-26 20:19:36 +0000
+++ src/logic/checkstep.cc 2014-07-24 20:54:16 +0000
@@ -63,19 +63,21 @@
CheckStep::StepId const id)
const
{
- container_iterate_const(std::vector<CheckStep>, subs, i)
- if (!i.current->allowed(map, start, end, dir, id))
+ for (const CheckStep& checkstep : subs) {
+ if (!checkstep.allowed(map, start, end, dir, id)) {
return false;
-
+ }
+ }
return true;
}
bool CheckStepAnd::reachabledest(Map & map, FCoords const dest) const
{
- container_iterate_const(std::vector<CheckStep>, subs, i)
- if (!i.current->reachabledest(map, dest))
+ for (const CheckStep& checkstep : subs) {
+ if (!checkstep.reachabledest(map, dest)) {
return false;
-
+ }
+ }
return true;
}
=== modified file 'src/logic/constructionsite.cc'
--- src/logic/constructionsite.cc 2014-07-22 09:54:49 +0000
+++ src/logic/constructionsite.cc 2014-07-24 20:54:16 +0000
@@ -101,9 +101,9 @@
=======
*/
WaresQueue & ConstructionSite::waresqueue(Ware_Index const wi) {
- container_iterate_const(Wares, m_wares, i) {
- if ((*i.current)->get_ware() == wi) {
- return **i.current;
+ for (WaresQueue * ware : m_wares) {
+ if (ware->get_ware() == wi) {
+ return *ware;
}
}
throw wexception
@@ -270,8 +270,8 @@
}
// Drop all the wares that are too much out to the flag.
- container_iterate(Wares, m_wares, iqueue) {
- WaresQueue * queue = *iqueue;
+ for (WaresQueue * iqueue: m_wares) {
+ WaresQueue * queue = iqueue;
if (queue->get_filled() > queue->get_max_fill()) {
queue->set_filled(queue->get_filled() - 1);
const WareDescr & wd = *descr().tribe().get_ware_descr(queue->get_ware());
=== modified file 'src/logic/critter_bob.cc'
--- src/logic/critter_bob.cc 2014-06-21 10:24:12 +0000
+++ src/logic/critter_bob.cc 2014-07-24 20:54:16 +0000
@@ -207,8 +207,9 @@
}
Critter_Bob_Descr::~Critter_Bob_Descr() {
- container_iterate_const(Programs, m_programs, i)
- delete i.current->second;
+ for (std::pair<std::string, Critter_BobProgram *> program : m_programs) {
+ delete program.second;
+ }
}
bool Critter_Bob_Descr::is_swimming() const {
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2014-07-22 09:54:49 +0000
+++ src/logic/editor_game_base.cc 2014-07-24 20:54:16 +0000
@@ -82,9 +82,9 @@
delete map_;
delete player_manager_.release();
- container_iterate_const(Tribe_Vector, tribes_, i)
- delete *i.current;
-
+ for (Tribe_Descr* tribe_descr : tribes_) {
+ delete tribe_descr;
+ }
if (g_gr) { // dedicated does not use the sound_handler
assert(this == g_sound_handler.egbase_);
g_sound_handler.egbase_ = nullptr;
@@ -150,9 +150,11 @@
const Tribe_Descr & Editor_Game_Base::manually_load_tribe
(const std::string & tribe)
{
- container_iterate_const(Tribe_Vector, tribes_, i)
- if ((*i.current)->name() == tribe)
- return **i.current;
+ for (const Tribe_Descr* tribe_descr : tribes_) {
+ if (tribe_descr->name() == tribe) {
+ return *tribe_descr;
+ }
+ }
Tribe_Descr & result = *new Tribe_Descr(tribe, *this);
//resize the configuration of our wares if they won't fit in the current window (12 = info label size)
@@ -273,9 +275,9 @@
{
loader_ui.step(_("Loading world data"));
- container_iterate_const(Tribe_Vector, tribes_, i) {
+ for (Tribe_Descr* tribe_descr : tribes_) {
loader_ui.stepf(_("Loading tribes"));
- (*i.current)->load_graphics();
+ tribe_descr->load_graphics();
}
// TODO(unknown): load player graphics? (maybe)
@@ -768,31 +770,31 @@
// find all immovables that need fixing
m.find_immovables(area, &immovables, FindImmovablePlayerImmovable());
- container_iterate_const(std::vector<ImmovableFound>, immovables, i) {
- PlayerImmovable & imm =
- ref_cast<PlayerImmovable, BaseImmovable>(*i.current->object);
+ for (const ImmovableFound& temp_imm : immovables) {
+ upcast(PlayerImmovable, imm, temp_imm.object);
if
- (not
- m[i.current->coords].is_interior(imm.owner().player_number()))
+ (!m[temp_imm.coords].is_interior(imm->owner().player_number())) {
if
- (std::find(burnlist.begin(), burnlist.end(), &imm)
+ (std::find(burnlist.begin(), burnlist.end(), imm)
==
- burnlist.end())
- burnlist.push_back(&imm);
+ burnlist.end()) {
+ burnlist.push_back(imm);
+ }
+ }
}
// fix all immovables
upcast(Game, game, this);
- container_iterate_const(std::vector<PlayerImmovable *>, burnlist, i) {
- if (upcast(Building, building, *i.current))
+ for (PlayerImmovable * temp_imm : burnlist) {
+ if (upcast(Building, building, temp_imm))
building->set_defeating_player(area.player_number);
- else if (upcast(Flag, flag, *i.current))
+ else if (upcast(Flag, flag, temp_imm))
if (Building * const flag_building = flag->get_building())
flag_building->set_defeating_player(area.player_number);
if (game)
- (*i.current)->schedule_destroy(*game);
+ temp_imm->schedule_destroy(*game);
else
- (*i.current)->remove(*this);
+ temp_imm->remove(*this);
}
}
=== modified file 'src/logic/findnode.cc'
--- src/logic/findnode.cc 2014-07-05 12:17:03 +0000
+++ src/logic/findnode.cc 2014-07-24 20:54:16 +0000
@@ -39,10 +39,11 @@
}
bool FindNodeAnd::accept(const Map & map, const FCoords & coord) const {
- container_iterate_const(std::vector<Subfunctor>, m_subfunctors, i)
- if (i.current->findfield.accept(map, coord) == i.current->negate)
+ for (const Subfunctor& subfunctor : m_subfunctors) {
+ if (subfunctor.findfield.accept(map, coord) == subfunctor.negate) {
return false;
-
+ }
+ }
return true;
}
=== modified file 'src/logic/game.cc'
--- src/logic/game.cc 2014-07-23 14:49:10 +0000
+++ src/logic/game.cc 2014-07-24 20:54:16 +0000
@@ -641,8 +641,11 @@
m_state = gs_notrunning;
Editor_Game_Base::cleanup_for_load();
- container_iterate_const(std::vector<Tribe_Descr *>, tribes_, i)
- delete *i.current;
+
+ for (Tribe_Descr* tribe : tribes_) {
+ delete tribe;
+ }
+
tribes_.clear();
cmdqueue().flush();
=== modified file 'src/logic/immovable_program.h'
--- src/logic/immovable_program.h 2014-07-14 19:48:07 +0000
+++ src/logic/immovable_program.h 2014-07-24 20:54:16 +0000
@@ -195,8 +195,9 @@
Immovable_Descr &);
~ImmovableProgram() {
- container_iterate_const(Actions, m_actions, i)
- delete *i.current;
+ for (Action * action : m_actions) {
+ delete action;
+ }
}
const std::string & name() const {return m_name;}
=== modified file 'src/logic/instances.cc'
--- src/logic/instances.cc 2014-07-05 12:17:03 +0000
+++ src/logic/instances.cc 2014-07-24 20:54:16 +0000
@@ -188,8 +188,9 @@
std::vector<Serial> Object_Manager::all_object_serials_ordered () const {
std::vector<Serial> rv;
- container_iterate_const(objmap_t, m_objects, o)
- rv.push_back(o->first);
+ for (const std::pair<Serial, Map_Object *>& o : m_objects) {
+ rv.push_back(o.first);
+ }
std::sort(rv.begin(), rv.end());
@@ -233,9 +234,11 @@
* Add this animation for this map object under this name
*/
bool Map_Object_Descr::is_animation_known(const std::string & animname) const {
- container_iterate_const(Anims, m_anims, i)
- if (i.current->first == animname)
+ for (const std::pair<std::string, uint32_t>& anim : m_anims) {
+ if (anim.first == animname) {
return true;
+ }
+ }
return false;
}
@@ -243,19 +246,24 @@
(const std::string & animname, uint32_t const anim)
{
#ifndef NDEBUG
- container_iterate_const(Anims, m_anims, i)
- if (i.current->first == animname)
+ for (const std::pair<std::string, uint32_t>& temp_anim : m_anims) {
+ if (temp_anim.first == animname) {
throw wexception
("adding already existing animation \"%s\"", animname.c_str());
+ }
+ }
#endif
m_anims.insert(std::pair<std::string, uint32_t>(animname, anim));
}
std::string Map_Object_Descr::get_animation_name(uint32_t const anim) const {
- container_iterate_const(Anims, m_anims, i)
- if (i.current->second == anim)
- return i.current->first;
+
+ for (const std::pair<std::string, uint32_t>& temp_anim : m_anims) {
+ if (temp_anim.second == anim) {
+ return temp_anim.first;
+ }
+ }
// Never here
assert(false);
@@ -267,9 +275,11 @@
* Search for the attribute in the attribute list
*/
bool Map_Object_Descr::has_attribute(uint32_t const attr) const {
- container_iterate_const(Attributes, m_attributes, i)
- if (*i.current == attr)
+ for (const uint32_t& attrib : m_attributes) {
+ if (attrib == attr) {
return true;
+ }
+ }
return false;
}
=== modified file 'src/logic/map.cc'
--- src/logic/map.cc 2014-07-23 14:49:10 +0000
+++ src/logic/map.cc 2014-07-24 20:54:16 +0000
@@ -847,11 +847,13 @@
find_reachable(area, checkstep, cb);
- container_iterate_const(std::vector<ImmovableFound>, duplist, i) {
- BaseImmovable & obj = *i.current->object;
- if (std::find(list.begin(), list.end(), &obj) == list.end())
- if (functor.accept(obj))
+ for (ImmovableFound& imm_found : duplist) {
+ BaseImmovable & obj = *imm_found.object;
+ if (std::find(list.begin(), list.end(), &obj) == list.end()) {
+ if (functor.accept(obj)) {
list.push_back(&obj);
+ }
+ }
}
return list.size();
=== modified file 'src/logic/militarysite.cc'
--- src/logic/militarysite.cc 2014-07-23 15:58:57 +0000
+++ src/logic/militarysite.cc 2014-07-24 20:54:16 +0000
@@ -147,14 +147,14 @@
upcast(Game, game, &egbase);
- const std::vector<Worker*>& ws = get_workers();
- container_iterate_const(std::vector<Worker *>, ws, i)
- if (upcast(Soldier, soldier, *i.current)) {
+ for (Worker * worker : get_workers()) {
+ if (upcast(Soldier, soldier, worker)) {
soldier->set_location_initially(*this);
assert(!soldier->get_state()); // Should be newly created.
if (game)
soldier->start_task_buildingwork(*game);
}
+ }
update_soldier_request();
// schedule the first healing
@@ -665,12 +665,13 @@
{
std::vector<Soldier *> soldiers;
- const std::vector<Worker *>& w = get_workers();
- container_iterate_const(std::vector<Worker *>, w, i)
- if (upcast(Soldier, soldier, *i.current))
- if (isPresent(*soldier))
+ for (Worker * worker : get_workers()) {
+ if (upcast(Soldier, soldier, worker)) {
+ if (isPresent(*soldier)) {
soldiers.push_back(soldier);
-
+ }
+ }
+ }
return soldiers;
}
@@ -679,11 +680,11 @@
{
std::vector<Soldier *> soldiers;
- const std::vector<Worker *>& w = get_workers();
- container_iterate_const(std::vector<Worker *>, w, i)
- if (upcast(Soldier, soldier, *i.current))
+ for (Worker * worker : get_workers()) {
+ if (upcast(Soldier, soldier, worker)) {
soldiers.push_back(soldier);
-
+ }
+ }
return soldiers;
}
@@ -768,17 +769,19 @@
// policy as to how many soldiers are allowed to leave as defenders
std::vector<Soldier *> present = presentSoldiers();
- if (1 < present.size())
- container_iterate_const(std::vector<Soldier *>, present, i)
- if (!haveSoldierJob(**i.current)) {
+ if (1 < present.size()) {
+ for (Soldier * temp_soldier : present) {
+ if (!haveSoldierJob(*temp_soldier)) {
SoldierJob sj;
- sj.soldier = *i.current;
+ sj.soldier = temp_soldier;
sj.enemy = &enemy;
sj.stayhome = false;
m_soldierjobs.push_back(sj);
- (*i.current)->update_task_buildingwork(game);
+ temp_soldier->update_task_buildingwork(game);
return;
}
+ }
+ }
// Inform the player, that we are under attack by adding a new entry to the
// message queue - a sound will automatically be played.
@@ -795,20 +798,22 @@
if (!present.empty()) {
// Find soldier with greatest hitpoints
uint32_t current_max = 0;
- container_iterate_const(std::vector<Soldier *>, present, i)
- if ((*i.current)->get_current_hitpoints() > current_max) {
- defender = *i.current;
+ for (Soldier * temp_soldier : present) {
+ if (temp_soldier->get_current_hitpoints() > current_max) {
+ defender = temp_soldier;
current_max = defender->get_current_hitpoints();
}
+ }
} else {
// If one of our stationed soldiers is currently walking into the
// building, give us another chance.
std::vector<Soldier *> stationed = stationedSoldiers();
- container_iterate_const(std::vector<Soldier *>, stationed, i)
- if ((*i.current)->get_position() == get_position()) {
- defender = *i.current;
+ for (Soldier * temp_soldier : stationed) {
+ if (temp_soldier->get_position() == get_position()) {
+ defender = temp_soldier;
break;
}
+ }
}
if (defender) {
@@ -986,10 +991,11 @@
bool MilitarySite::haveSoldierJob(Soldier & soldier)
{
- container_iterate_const(std::vector<SoldierJob>, m_soldierjobs, i)
- if (i.current->soldier == &soldier)
+ for (const SoldierJob& temp_job : m_soldierjobs) {
+ if (temp_job.soldier == &soldier) {
return true;
-
+ }
+ }
return false;
}
=== modified file 'src/logic/partially_finished_building.cc'
--- src/logic/partially_finished_building.cc 2014-07-22 09:54:49 +0000
+++ src/logic/partially_finished_building.cc 2014-07-24 20:54:16 +0000
@@ -58,9 +58,9 @@
m_builder_request = nullptr;
}
- container_iterate_const(Wares, m_wares, i) {
- (*i.current)->cleanup();
- delete *i.current;
+ for (WaresQueue * temp_ware : m_wares) {
+ temp_ware->cleanup();
+ delete temp_ware;
}
m_wares.clear();
@@ -84,17 +84,19 @@
*/
void Partially_Finished_Building::set_economy(Economy * const e)
{
- if (Economy * const old = get_economy())
- container_iterate_const(Wares, m_wares, i)
- (*i.current)->remove_from_economy(*old);
-
+ if (Economy * const old = get_economy()) {
+ for (WaresQueue * temp_ware : m_wares) {
+ temp_ware->remove_from_economy(*old);
+ }
+ }
Building::set_economy(e);
if (m_builder_request)
m_builder_request->set_economy(e);
if (e)
- container_iterate_const(Wares, m_wares, i)
- (*i.current)->add_to_economy(*e);
+ for (WaresQueue * temp_ware : m_wares) {
+ temp_ware->add_to_economy(*e);
+ }
}
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2014-07-23 14:49:10 +0000
+++ src/logic/player.cc 2014-07-24 20:54:16 +0000
@@ -346,15 +346,16 @@
const Map & map = game.map ();
uint32_t const gametime = game.get_gametime();
Coords const position = m .position ();
- container_iterate_const(MessageQueue, messages(), i)
+ for (std::pair<Message_Id, Message *> tmp_message : messages()) {
if
- (i.current->second->sender() == m.sender() and
- gametime < i.current->second->sent() + timeout and
- map.calc_distance(i.current->second->position(), position) <= radius)
+ (tmp_message.second->sender() == m.sender() and
+ gametime < tmp_message.second->sent() + timeout and
+ map.calc_distance(tmp_message.second->position(), position) <= radius)
{
delete &m;
return Message_Id::Null();
}
+ }
return add_message(game, m);
}
@@ -768,8 +769,9 @@
// However, they are no longer associated with the building as
// workers of that buiding, which is why they will leave for a
// warehouse.
- container_iterate_const(std::vector<Worker *>, workers, i)
- (*i.current)->set_location(building);
+ for (Worker * temp_worker : workers) {
+ temp_worker->set_location(building);
+ }
}
}
@@ -825,9 +827,11 @@
}
bool Player::has_economy(Economy & economy) const {
- container_iterate_const(Economies, m_economies, i)
- if (*i.current == &economy)
+ for (Economy * temp_economy : m_economies) {
+ if (temp_economy == &economy) {
return true;
+ }
+ }
return false;
}
@@ -909,9 +913,9 @@
if (flags.empty())
return 0;
- container_iterate_const(std::vector<BaseImmovable *>, flags, i) {
- const Flag * attackerflag = static_cast<Flag *>(*i.current);
- const MilitarySite * ms = static_cast<MilitarySite *>(attackerflag->get_building());
+ for (BaseImmovable * temp_flag : flags) {
+ upcast(Flag, attackerflag, temp_flag);
+ upcast(MilitarySite, ms, attackerflag->get_building());
std::vector<Soldier *> const present = ms->presentSoldiers();
uint32_t const nr_staying = ms->minSoldierCapacity();
uint32_t const nr_present = present.size();
@@ -944,19 +948,22 @@
attacker, player_number());
else if (count == 0)
log("enemyflagaction: count is 0\n");
- else if (is_hostile(flag.owner()))
- if (Building * const building = flag.get_building())
- if (upcast(Attackable, attackable, building))
+ else if (is_hostile(flag.owner())) {
+ if (Building * const building = flag.get_building()) {
+ if (upcast(Attackable, attackable, building)) {
if (attackable->canAttack()) {
std::vector<Soldier *> attackers;
findAttackSoldiers(flag, &attackers, count);
assert(attackers.size() <= count);
- container_iterate_const(std::vector<Soldier *>, attackers, i)
- ref_cast<MilitarySite, PlayerImmovable>
- (*(*i.current)->get_location(egbase()))
- .sendAttacker(**i.current, *building);
+ for (Soldier * temp_attacker : attackers) {
+ upcast(MilitarySite, ms, temp_attacker->get_location(egbase()));
+ ms->sendAttacker(*temp_attacker, *building);
+ }
}
+ }
+ }
+ }
}
=== modified file 'src/logic/production_program.cc'
--- src/logic/production_program.cc 2014-07-23 15:58:57 +0000
+++ src/logic/production_program.cc 2014-07-24 20:54:16 +0000
@@ -281,23 +281,24 @@
(const ProductionSite & ps) const
{
uint8_t count = group.second;
- container_iterate_const(ProductionSite::Input_Queues, ps.warequeues(), i)
- if (group.first.count((*i.current)->get_ware())) {
- uint8_t const filled = (*i.current)->get_filled();
+ for (WaresQueue * ip_queue : ps.warequeues()) {
+ if (group.first.count(ip_queue->get_ware())) {
+ uint8_t const filled = ip_queue->get_filled();
if (count <= filled)
return true;
count -= filled;
}
+ }
return false;
}
std::string ProductionProgram::ActReturn::Site_Has::description
(const Tribe_Descr & tribe) const
{
std::string condition = "";
- container_iterate_const(std::set<Ware_Index>, group.first, i) {
+ for (const Ware_Index& temp_ware : group.first) {
condition =
/** TRANSLATORS: Adds a ware to list of wares in 'Failed/Skipped ...' messages. */
- (boost::format(_("%1$s %2$s")) % condition % tribe.get_ware_descr(*i.current)->descname())
+ (boost::format(_("%1$s %2$s")) % condition % tribe.get_ware_descr(temp_ware)->descname())
.str();
/** TRANSLATORS: Separator for list of wares in 'Failed/Skipped ...' messages. */
condition = (boost::format(_("%s,")) % condition).str();
@@ -476,8 +477,9 @@
}
ProductionProgram::ActReturn::~ActReturn() {
- container_iterate_const(Conditions, m_conditions, i)
- delete *i.current;
+ for (Condition * condition : m_conditions) {
+ delete condition;
+ }
}
void ProductionProgram::ActReturn::execute
@@ -669,18 +671,19 @@
// name, so it also validates the parameter.
const Workarea_Info & worker_workarea_info =
main_worker_descr.get_program(m_program)->get_workarea_info();
- Workarea_Info & building_workarea_info = descr->m_workarea_info;
- container_iterate_const(Workarea_Info, worker_workarea_info, i) {
+
+ // local typedef for iterator
+ for (const std::pair<uint32_t, std::set<std::string> >& area_info : worker_workarea_info) {
std::set<std::string> & building_radius_infos =
- building_workarea_info[i.current->first];
- const std::set<std::string> & descriptions = i.current->second;
- container_iterate_const(std::set<std::string>, descriptions, de) {
+ descr->m_workarea_info[area_info.first];
+
+ for (const std::string& worker_descname : area_info.second) {
std::string description = descr->descname();
description += ' ';
description += production_program_name;
description += " worker ";
description += main_worker_descr.name();
- description += *de.current;
+ description += worker_descname;
building_radius_infos.insert(description);
}
}
=== modified file 'src/logic/production_program.h'
--- src/logic/production_program.h 2014-07-23 15:58:57 +0000
+++ src/logic/production_program.h 2014-07-24 20:54:16 +0000
@@ -512,8 +512,9 @@
const World&,
ProductionSite_Descr*);
~ProductionProgram() {
- container_iterate_const(Actions, m_actions, i)
- delete *i.current;
+ for (Action * action : m_actions) {
+ delete action;
+ }
}
const std::string & name() const {return m_name;}
=== modified file 'src/logic/productionsite.cc'
--- src/logic/productionsite.cc 2014-07-23 04:47:30 +0000
+++ src/logic/productionsite.cc 2014-07-24 20:54:16 +0000
@@ -96,9 +96,11 @@
try {
Ware_Index const idx = tribe().ware_index(val->get_name());
if (idx != INVALID_INDEX) {
- container_iterate_const(BillOfMaterials, inputs(), i)
- if (i.current->first == idx)
+ for (const WareAmount& temp_inputs : inputs()) {
+ if (temp_inputs.first == idx) {
throw wexception("duplicated");
+ }
+ }
int32_t const value = val->get_int();
if (value < 1 or 255 < value)
throw wexception("count is out of range 1 .. 255");
@@ -117,9 +119,11 @@
try {
Ware_Index const woi = tribe().worker_index(v->get_name());
if (woi != INVALID_INDEX) {
- container_iterate_const(BillOfMaterials, working_positions(), i)
- if (i.current->first == woi)
+ for (const WareAmount& wp : working_positions()) {
+ if (wp.first == woi) {
throw wexception("duplicated");
+ }
+ }
m_working_positions.push_back(std::pair<Ware_Index, uint32_t>(woi, v->get_positive()));
} else
throw wexception("invalid");
@@ -270,10 +274,12 @@
WaresQueue & ProductionSite::waresqueue(Ware_Index const wi) {
- container_iterate_const(Input_Queues, m_input_queues, i)
- if ((*i.current)->get_ware() == wi)
- return **i.current;
- throw wexception("%s (%u) has no WaresQueue for %u", descr().name().c_str(), serial(), wi);
+ for (WaresQueue * ip_queue : m_input_queues) {
+ if (ip_queue->get_ware() == wi) {
+ return *ip_queue;
+ }
+ }
+ throw wexception("%s (%u) has no WaresQueue for %u", descr().name().c_str(), serial(), wi);
}
/**
@@ -355,9 +361,9 @@
// Request missing workers.
Working_Position * wp = m_working_positions;
- container_iterate_const(BillOfMaterials, descr().working_positions(), i) {
- Ware_Index const worker_index = i.current->first;
- for (uint32_t j = i.current->second; j; --j, ++wp)
+ for (const WareAmount& temp_wp : descr().working_positions()) {
+ Ware_Index const worker_index = temp_wp.first;
+ for (uint32_t j = temp_wp.second; j; --j, ++wp)
if (Worker * const worker = wp->worker)
worker->set_location(this);
else
@@ -375,18 +381,22 @@
*/
void ProductionSite::set_economy(Economy * const e)
{
- if (Economy * const old = get_economy())
- container_iterate_const(Input_Queues, m_input_queues, i)
- (*i.current)->remove_from_economy(*old);
+ if (Economy * const old = get_economy()) {
+ for (WaresQueue * ip_queue : m_input_queues) {
+ ip_queue->remove_from_economy(*old);
+ }
+ }
Building::set_economy(e);
for (uint32_t i = descr().nr_working_positions(); i;)
if (Request * const r = m_working_positions[--i].worker_request)
r->set_economy(e);
- if (e)
- container_iterate_const(Input_Queues, m_input_queues, i)
- (*i.current)->add_to_economy(*e);
+ if (e) {
+ for (WaresQueue * ip_queue : m_input_queues) {
+ ip_queue->add_to_economy(*e);
+ }
+ }
}
/**
@@ -468,9 +478,9 @@
molog("%s leaving\n", w.descr().descname().c_str());
Working_Position * wp = m_working_positions;
- container_iterate_const(BillOfMaterials, descr().working_positions(), i) {
- Ware_Index const worker_index = i.current->first;
- for (uint32_t j = i.current->second; j; --j, ++wp) {
+ for (const WareAmount& temp_wp : descr().working_positions()) {
+ Ware_Index const worker_index = temp_wp.first;
+ for (uint32_t j = temp_wp.second; j; --j, ++wp) {
Worker * const worker = wp->worker;
if (worker && worker == &w) {
// do not request the type of worker that is currently assigned - maybe a trained worker was
@@ -775,8 +785,7 @@
}
// Drop all the wares that are too much out to the flag.
- container_iterate(Input_Queues, m_input_queues, iqueue) {
- WaresQueue * queue = *iqueue;
+ for (WaresQueue * queue : m_input_queues) {
if (queue->get_filled() > queue->get_max_fill()) {
queue->set_filled(queue->get_filled() - 1);
const WareDescr & wd = *descr().tribe().get_ware_descr(queue->get_ware());
=== modified file 'src/logic/productionsite.h'
--- src/logic/productionsite.h 2014-07-22 12:09:26 +0000
+++ src/logic/productionsite.h 2014-07-24 20:54:16 +0000
@@ -69,8 +69,9 @@
uint32_t nr_working_positions() const {
uint32_t result = 0;
- container_iterate_const(BillOfMaterials, working_positions(), i)
- result += i.current->second;
+ for (const WareAmount& working_pos : working_positions()) {
+ result += working_pos.second;
+ }
return result;
}
const BillOfMaterials & working_positions() const {
=== modified file 'src/logic/requirements.cc'
--- src/logic/requirements.cc 2014-07-05 12:17:03 +0000
+++ src/logic/requirements.cc 2014-07-24 20:54:16 +0000
@@ -116,9 +116,11 @@
bool RequireOr::check(const Map_Object & obj) const
{
- container_iterate_const(std::vector<Requirements>, m, i)
- if (i.current->check(obj))
+ for (const Requirements& req : m) {
+ if (req.check(obj)) {
return true;
+ }
+ }
return false;
}
@@ -130,8 +132,9 @@
assert(m.size() == static_cast<uint16_t>(m.size()));
fw.Unsigned16(m.size());
- container_iterate_const(std::vector<Requirements>, m, i)
- i.current->Write(fw, egbase, mos);
+ for (const Requirements& req : m) {
+ req.Write(fw, egbase, mos);
+ }
}
static Requirements readOr
@@ -159,10 +162,11 @@
bool RequireAnd::check(const Map_Object & obj) const
{
- container_iterate_const(std::vector<Requirements>, m, i)
- if (!i.current->check(obj))
+ for (const Requirements& req : m) {
+ if (!req.check(obj)) {
return false;
-
+ }
+ }
return true;
}
@@ -173,8 +177,9 @@
assert(m.size() == static_cast<uint16_t>(m.size()));
fw.Unsigned16(m.size());
- container_iterate_const(std::vector<Requirements>, m, i)
- i.current->Write(fw, egbase, mos);
+ for (const Requirements& req : m) {
+ req.Write(fw, egbase, mos);
+ }
}
static Requirements readAnd
=== modified file 'src/logic/ship.cc'
--- src/logic/ship.cc 2014-07-22 09:54:49 +0000
+++ src/logic/ship.cc 2014-07-24 20:54:16 +0000
@@ -690,8 +690,8 @@
// we rely that wares really get reassigned our economy.
m_economy = e;
- container_iterate(std::vector<ShippingItem>, m_items, it) {
- it->set_economy(game, e);
+ for (ShippingItem& shipping_item : m_items) {
+ shipping_item.set_economy(game, e);
}
}
@@ -882,11 +882,11 @@
m_destination.serial(), m_lastdock.serial(),
m_items.size());
- container_iterate(std::vector<ShippingItem>, m_items, it) {
+ for (const ShippingItem& shipping_item : m_items) {
molog
(" IT %u, destination %u\n",
- it.current->m_object.serial(),
- it.current->m_destination_dock.serial());
+ shipping_item.m_object.serial(),
+ shipping_item.m_destination_dock.serial());
}
}
@@ -990,8 +990,8 @@
m_destination = fr.Unsigned32();
m_items.resize(fr.Unsigned32());
- container_iterate(std::vector<ShippingItem::Loader>, m_items, it) {
- it->load(fr);
+ for (ShippingItem::Loader& item_loader : m_items) {
+ item_loader.load(fr);
}
}
}
@@ -1117,8 +1117,8 @@
fw.Unsigned32(mos.get_object_file_index_or_zero(m_destination.get(egbase)));
fw.Unsigned32(m_items.size());
- container_iterate(std::vector<ShippingItem>, m_items, it) {
- it->save(egbase, mos, fw);
+ for (ShippingItem& shipping_item : m_items) {
+ shipping_item.save(egbase, mos, fw);
}
}
=== modified file 'src/logic/soldier.cc'
--- src/logic/soldier.cc 2014-07-16 08:25:35 +0000
+++ src/logic/soldier.cc 2014-07-24 20:54:16 +0000
@@ -87,8 +87,9 @@
if (list.size() != 2)
throw game_data_error
("expected %s but found \"%s\"", "\"min-max\"", attack);
- container_iterate(std::vector<std::string>, list, i)
- remove_spaces(*i.current);
+ for (std::string& temp_str : list) {
+ remove_spaces(temp_str);
+ }
char * endp;
m_min_attack = strtol(list[0].c_str(), &endp, 0);
if (*endp or 0 == m_min_attack)
@@ -205,15 +206,15 @@
"\"anim_name[,another_anim,...]\"", anim_string);
// Sanitation
- container_iterate(std::vector<std::string>, list, i) {
- remove_spaces(*i.current);
+ for (std::string& temp_str : list) {
+ remove_spaces(temp_str);
// Check that section exists
Section &
- anim_s = prof.get_safe_section((*i.current).c_str());
+ anim_s = prof.get_safe_section(temp_str.c_str());
add_animation
- ((*i.current).c_str(), g_gr->animations().load(directory, anim_s));
+ (temp_str.c_str(), g_gr->animations().load(directory, anim_s));
}
} catch (const _wexception & e) {
throw game_data_error("%s : %s", anim_name, e.what());
@@ -1205,10 +1206,10 @@
&soldiers,
FindBobEnemySoldier(get_owner()));
- container_iterate_const(std::vector<Bob *>, soldiers, i) {
- if (upcast(Soldier, soldier, *i.current)) {
- if (soldier->canBeChallenged()) {
- new Battle(game, *this, *soldier);
+ for (Bob * temp_bob : soldiers) {
+ if (upcast(Soldier, temp_soldier, temp_bob)) {
+ if (temp_soldier->canBeChallenged()) {
+ new Battle(game, *this, *temp_soldier);
return start_task_battle(game);
}
}
@@ -1280,10 +1281,10 @@
// Go through soldiers
std::vector<SoldierDistance> targets;
- container_iterate_const(std::vector<Bob *>, soldiers, i) {
+ for (Bob * temp_bob : soldiers) {
// If enemy is in our land, then go after it!
- if (upcast(Soldier, soldier, *i.current)) {
+ if (upcast(Soldier, soldier, temp_bob)) {
assert(soldier != this);
Field const f = game.map().operator[](soldier->get_position());
@@ -1782,10 +1783,13 @@
&soldiers,
FindBobSoldierOnBattlefield());
- container_iterate_const(std::vector<Bob *>, soldiers, i)
- if (upcast(Soldier, soldier, *i.current))
- if (soldier != this)
+ for (Bob * temp_soldier : soldiers) {
+ if (upcast(Soldier, soldier, temp_soldier)) {
+ if (soldier != this) {
soldier->send_signal(game, "wakeup");
+ }
+ }
+ }
Player_Number const land_owner = get_position().field->get_owned_by();
if (land_owner != owner().player_number()) {
@@ -1796,13 +1800,15 @@
CheckStepWalkOn(descr().movecaps(), false),
FindImmovableAttackable());
- container_iterate_const(std::vector<BaseImmovable *>, attackables, i)
+ for (BaseImmovable * temp_attackable : attackables) {
if
- (ref_cast<PlayerImmovable const, BaseImmovable const>(**i.current)
+ (ref_cast<PlayerImmovable const, BaseImmovable const>(*temp_attackable)
.get_owner()->player_number()
==
- land_owner)
- dynamic_cast<Attackable &>(**i.current).aggressor(*this);
+ land_owner) {
+ dynamic_cast<Attackable &>(*temp_attackable).aggressor(*this);
+ }
+ }
}
}
=== modified file 'src/logic/trainingsite.cc'
--- src/logic/trainingsite.cc 2014-07-22 09:54:49 +0000
+++ src/logic/trainingsite.cc 2014-07-24 20:54:16 +0000
@@ -206,12 +206,13 @@
upcast(Game, game, &egbase);
- container_iterate_const(std::vector<Soldier *>, m_soldiers, i) {
- (*i.current)->set_location_initially(*this);
- assert(not (*i.current)->get_state()); // Should be newly created.
+ for (Soldier * soldier : m_soldiers) {
+ soldier->set_location_initially(*this);
+ assert(!soldier->get_state()); // Should be newly created.
- if (game)
- (*i.current)->start_task_idle(*game, 0, -1);
+ if (game) {
+ soldier->start_task_idle(*game, 0, -1);
+ }
}
update_soldier_request();
}
@@ -465,8 +466,9 @@
// Drop soldiers only now, so that changes in the soldiers array don't
// mess things up
- container_iterate_const(std::vector<Soldier *>, droplist, i)
- dropSoldier(**i.current);
+ for (Soldier * soldier : droplist) {
+ dropSoldier(*soldier);
+ }
}
/**
@@ -590,16 +592,16 @@
uint32_t maxprio = 0;
uint32_t maxcredit = 0;
- container_iterate(std::vector<Upgrade>, m_upgrades, i) {
- if (i.current->credit >= 10) {
- i.current->credit -= 10;
- return start_upgrade(game, *i.current);
+ for (Upgrade& upgrade : m_upgrades) {
+ if (upgrade.credit >= 10) {
+ upgrade.credit -= 10;
+ return start_upgrade(game, upgrade);
}
- if (maxprio < i.current->prio)
- maxprio = i.current->prio;
- if (maxcredit < i.current->credit)
- maxcredit = i.current->credit;
+ if (maxprio < upgrade.prio)
+ maxprio = upgrade.prio;
+ if (maxcredit < upgrade.credit)
+ maxcredit = upgrade.credit;
}
if (maxprio == 0)
@@ -607,8 +609,9 @@
uint32_t const multiplier = 1 + (10 - maxcredit) / maxprio;
- container_iterate(std::vector<Upgrade>, m_upgrades, i)
- i.current->credit += multiplier * i.current->prio;
+ for (Upgrade& upgrade : m_upgrades) {
+ upgrade.credit += multiplier * upgrade.prio;
+ }
}
}
@@ -622,8 +625,8 @@
int32_t minlevel = upgrade.max;
int32_t maxlevel = upgrade.min;
- container_iterate_const(std::vector<Soldier *>, m_soldiers, i) {
- int32_t const level = (*i.current)->get_level(upgrade.attribute);
+ for (Soldier * soldier : m_soldiers) {
+ int32_t const level = soldier->get_level(upgrade.attribute);
if (level > upgrade.max || level < upgrade.min)
continue;
@@ -671,10 +674,11 @@
TrainingSite::Upgrade * TrainingSite::get_upgrade(tAttribute const atr)
{
- container_iterate(std::vector<Upgrade>, m_upgrades, i)
- if (i.current->attribute == atr)
- return &*i.current;
-
+ for (Upgrade& upgrade : m_upgrades) {
+ if (upgrade.attribute == atr) {
+ return &upgrade;
+ }
+ }
return nullptr;
}
@@ -684,10 +688,11 @@
*/
int32_t TrainingSite::get_pri(tAttribute atr)
{
- container_iterate_const(std::vector<Upgrade>, m_upgrades, i)
- if (i.current->attribute == atr)
- return i.current->prio;
-
+ for (const Upgrade& upgrade : m_upgrades) {
+ if (upgrade.attribute == atr) {
+ return upgrade.prio;
+ }
+ }
return 0;
}
@@ -699,11 +704,12 @@
if (prio < 0)
prio = 0;
- container_iterate(std::vector<Upgrade>, m_upgrades, i)
- if (i.current->attribute == atr) {
- i.current->prio = prio;
+ for (Upgrade& upgrade : m_upgrades) {
+ if (upgrade.attribute == atr) {
+ upgrade.prio = prio;
return;
}
+ }
}
/**
=== modified file 'src/logic/tribe.cc'
--- src/logic/tribe.cc 2014-07-22 09:54:49 +0000
+++ src/logic/tribe.cc 2014-07-24 20:54:16 +0000
@@ -350,8 +350,9 @@
}
std::sort(tribes.begin(), tribes.end(), TribeBasicComparator());
- container_iterate_const(std::vector<TribeBasicInfo>, tribes, i)
- tribenames.push_back(i.current->name);
+ for (const TribeBasicInfo& tribe : tribes) {
+ tribenames.push_back(tribe.name);
+ }
return tribenames;
}
=== modified file 'src/logic/warehouse.cc'
--- src/logic/warehouse.cc 2014-07-22 09:54:49 +0000
+++ src/logic/warehouse.cc 2014-07-24 20:54:16 +0000
@@ -495,8 +495,8 @@
m_portdock = new PortDock(this);
m_portdock->set_owner(get_owner());
m_portdock->set_economy(get_economy());
- container_iterate_const(std::vector<Coords>, dock, it) {
- m_portdock->add_position(*it.current);
+ for (const Coords& coords : dock) {
+ m_portdock->add_position(coords);
}
m_portdock->init(egbase);
@@ -658,12 +658,10 @@
m_supply->set_economy(e);
Building::set_economy(e);
- container_iterate_const
- (std::vector<PlannedWorkers>, m_planned_workers, pw_it)
- {
- container_iterate_const
- (std::vector<Request *>, pw_it.current->requests, req_it)
- (*req_it.current)->set_economy(e);
+ for (const PlannedWorkers& pw : m_planned_workers) {
+ for (Request * req : pw.requests) {
+ req->set_economy(e);
+ }
}
if (m_portdock)
@@ -688,10 +686,10 @@
PlayerImmovable::Workers Warehouse::get_incorporated_workers()
{
PlayerImmovable::Workers all_workers;
- container_iterate(IncorporatedWorkers, m_incorporated_workers, cpair) {
- WorkerList & clist = cpair->second;
- container_iterate(WorkerList, clist, w) {
- all_workers.push_back(*w.current);
+
+ for (const std::pair<Ware_Index, WorkerList>& worker_pair : m_incorporated_workers) {
+ for (Worker * worker : worker_pair.second) {
+ all_workers.push_back(worker);
}
}
return all_workers;
@@ -756,14 +754,13 @@
// NOTE: This code lies about the tAttributes of non-instantiated workers.
if (m_incorporated_workers.count(ware)) {
- WorkerList & incorporated_workers = m_incorporated_workers[ware];
-
- container_iterate_const(WorkerList, incorporated_workers, cworker)
- if (!req.check(**cworker)) {
+ for (Worker * worker : m_incorporated_workers[ware]) {
+ if (!req.check(*worker)) {
// This is one of the workers in our sum.
// But he is too stupid for this job
--sum;
}
+ }
}
ware = descr().tribe().get_worker_descr(ware)->becomes();
@@ -961,15 +958,14 @@
return false;
// see if we have the resources
- const Worker_Descr::Buildcost & buildcost = w_desc.buildcost();
- container_iterate_const(Worker_Descr::Buildcost, buildcost, it) {
- const std::string & input_name = it.current->first;
+ for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
+ const std::string & input_name = buildcost.first;
Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
- if (m_supply->stock_wares(id_w) < it.current->second)
+ if (m_supply->stock_wares(id_w) < buildcost.second)
return false;
} else if ((id_w = descr().tribe().worker_index(input_name)) != INVALID_INDEX) {
- if (m_supply->stock_workers(id_w) < it.current->second)
+ if (m_supply->stock_workers(id_w) < buildcost.second)
return false;
} else
throw wexception
@@ -986,16 +982,16 @@
assert(can_create_worker (game, worker));
const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(worker);
- const Worker_Descr::Buildcost & buildcost = w_desc.buildcost();
- container_iterate_const(Worker_Descr::Buildcost, buildcost, i) {
- const std::string & input = i.current->first;
+
+ for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
+ const std::string & input = buildcost.first;
Ware_Index const id_ware = descr().tribe().ware_index(input);
if (id_ware != INVALID_INDEX) {
- remove_wares (id_ware, i.current->second);
+ remove_wares (id_ware, buildcost.second);
//update statistic accordingly
- owner().ware_consumed(id_ware, i.current->second);
+ owner().ware_consumed(id_ware, buildcost.second);
} else
- remove_workers(descr().tribe().safe_worker_index(input), i.current->second);
+ remove_workers(descr().tribe().safe_worker_index(input), buildcost.second);
}
incorporate_worker(game, &w_desc.create(game, owner(), this, m_position));
@@ -1004,9 +1000,9 @@
// may have been called directly by the Economy.
// Do not update anything else about PlannedWorkers here, because this
// function is called by _update_planned_workers, so avoid recursion
- container_iterate(std::vector<PlannedWorkers>, m_planned_workers, pw_it) {
- if (pw_it.current->index == worker && pw_it.current->amount)
- pw_it.current->amount--;
+ for (PlannedWorkers& planned_worker : m_planned_workers) {
+ if (planned_worker.index == worker && planned_worker.amount)
+ planned_worker.amount--;
}
}
@@ -1016,11 +1012,10 @@
*/
uint32_t Warehouse::get_planned_workers(Game & /* game */, Ware_Index index) const
{
- container_iterate_const(std::vector<PlannedWorkers>, m_planned_workers, i) {
- if (i.current->index == index)
- return i.current->amount;
+ for (const PlannedWorkers& pw : m_planned_workers) {
+ if (pw.index == index)
+ return pw.amount;
}
-
return 0;
}
@@ -1034,11 +1029,10 @@
(Game & /* game */, Ware_Index index) const
{
const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(index);
- const Worker_Descr::Buildcost & cost = w_desc.buildcost();
std::vector<uint32_t> available;
- container_iterate_const(Worker_Descr::Buildcost, cost, bc) {
- const std::string & input_name = bc.current->first;
+ for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
+ const std::string & input_name = buildcost.first;
Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
available.push_back(get_wares().stock(id_w));
@@ -1050,12 +1044,13 @@
input_name.c_str());
}
- container_iterate_const(std::vector<PlannedWorkers>, m_planned_workers, i) {
- if (i.current->index == index) {
- assert(available.size() == i.current->requests.size());
+ for (const PlannedWorkers& pw : m_planned_workers) {
+ if (pw.index == index) {
+ assert(available.size() == pw.requests.size());
- for (uint32_t idx = 0; idx < available.size(); ++idx)
- available[idx] += i.current->requests[idx]->get_num_transfers();
+ for (uint32_t idx = 0; idx < available.size(); ++idx) {
+ available[idx] += pw.requests[idx]->get_num_transfers();
+ }
}
}
@@ -1071,9 +1066,9 @@
{
PlannedWorkers * pw = nullptr;
- container_iterate(std::vector<PlannedWorkers>, m_planned_workers, i) {
- if (i.current->index == index) {
- pw = &*i.current;
+ for (PlannedWorkers& planned_worker : m_planned_workers) {
+ if (planned_worker.index == index) {
+ pw = &planned_worker;
break;
}
}
@@ -1088,9 +1083,8 @@
pw->amount = 0;
const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(pw->index);
- const Worker_Descr::Buildcost & cost = w_desc.buildcost();
- container_iterate_const(Worker_Descr::Buildcost, cost, cost_it) {
- const std::string & input_name = cost_it.current->first;
+ for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
+ const std::string & input_name = buildcost.first;
Ware_Index id_w = descr().tribe().ware_index(input_name);
if (id_w != INVALID_INDEX) {
@@ -1119,14 +1113,15 @@
(Game & game, Warehouse::PlannedWorkers & pw)
{
const Worker_Descr & w_desc = *descr().tribe().get_worker_descr(pw.index);
- const Worker_Descr::Buildcost & cost = w_desc.buildcost();
- while (pw.amount && can_create_worker(game, pw.index))
+ while (pw.amount && can_create_worker(game, pw.index)) {
create_worker(game, pw.index);
+ }
uint32_t idx = 0;
- container_iterate_const(Worker_Descr::Buildcost, cost, cost_it) {
- const std::string & input_name = cost_it.current->first;
+ for (const std::pair<std::string, uint8_t>& buildcost : w_desc.buildcost()) {
+
+ const std::string & input_name = buildcost.first;
uint32_t supply;
Ware_Index id_w = descr().tribe().ware_index(input_name);
@@ -1138,11 +1133,11 @@
throw wexception
("_update_planned_workers: bad buildcost '%s'", input_name.c_str());
- if (supply >= pw.amount * cost_it.current->second)
+ if (supply >= pw.amount * buildcost.second)
pw.requests[idx]->set_count(0);
else
pw.requests[idx]->set_count
- (pw.amount * cost_it.current->second - supply);
+ (pw.amount * buildcost.second - supply);
++idx;
}
@@ -1339,8 +1334,9 @@
if (sidx != m_incorporated_workers.end()) {
const WorkerList & soldiers = sidx->second;
- container_iterate_const(WorkerList, soldiers, i)
- rv.push_back(static_cast<Soldier *>(*i));
+ for (Worker * temp_soldier: soldiers) {
+ rv.push_back(static_cast<Soldier *>(temp_soldier));
+ }
}
return rv;
=== modified file 'src/logic/worker.cc'
--- src/logic/worker.cc 2014-07-24 05:21:20 +0000
+++ src/logic/worker.cc 2014-07-24 20:54:16 +0000
@@ -2532,15 +2532,15 @@
Flag * best = nullptr;
molog("[fugitive]: found a flag connected to warehouse(s)\n");
+ for (const ImmovableFound& tmp_flag : flags) {
- container_iterate_const(std::vector<ImmovableFound>, flags, i) {
- Flag & flag = ref_cast<Flag, BaseImmovable>(*i.current->object);
+ Flag & flag = ref_cast<Flag, BaseImmovable>(*tmp_flag.object);
if (game.logic_rand() % 2 == 0)
continue;
int32_t const dist =
- map.calc_distance(get_position(), i.current->coords);
+ map.calc_distance(get_position(), tmp_flag.coords);
if (!best || bestdist > dist) {
best = &flag;
=== modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc'
--- src/map_io/widelands_map_buildingdata_data_packet.cc 2014-07-16 08:25:35 +0000
+++ src/map_io/widelands_map_buildingdata_data_packet.cc 2014-07-24 20:54:16 +0000
@@ -115,7 +115,7 @@
{
Building::Leave_Queue & leave_queue = building.m_leave_queue;
leave_queue.resize(fr.Unsigned16());
- container_iterate(Building::Leave_Queue, leave_queue, i)
+ container_iterate(Building::Leave_Queue, leave_queue, i) {
if (uint32_t const leaver_serial = fr.Unsigned32())
try {
// The check that this worker actually has a
@@ -128,11 +128,12 @@
throw game_data_error
("leave queue item #%lu (%u): %s",
static_cast<long int>
- (i.current - leave_queue.begin()),
+ (i.current - leave_queue.begin()),
leaver_serial, e.what());
}
else
*i.current = nullptr;
+ }
}
building.m_leave_time = fr.Unsigned32();
@@ -1190,10 +1191,10 @@
{
const Building::Leave_Queue & leave_queue = building->m_leave_queue;
fw.Unsigned16(leave_queue.size());
- container_iterate_const(Building::Leave_Queue, leave_queue, j) {
- assert(mos.is_object_known(*j.current->get(egbase)));
+ for (const OPtr<Worker >& temp_queue: leave_queue) {
+ assert(mos.is_object_known(*temp_queue.get(egbase)));
fw.Unsigned32
- (mos.get_object_file_index(*j.current->get(egbase)));
+ (mos.get_object_file_index(*temp_queue.get(egbase)));
}
}
fw.Unsigned32(building->m_leave_time);
@@ -1363,15 +1364,16 @@
// Incorporated workers, write sorted after file-serial.
uint32_t nworkers = 0;
- container_iterate_const(Warehouse::IncorporatedWorkers, warehouse.m_incorporated_workers, cwt)
- nworkers += cwt->second.size();
+ for (const std::pair<Ware_Index, Warehouse::WorkerList>& cwt: warehouse.m_incorporated_workers) {
+ nworkers += cwt.second.size();
+ }
fw.Unsigned16(nworkers);
typedef std::map<uint32_t, const Worker *> TWorkerMap;
TWorkerMap workermap;
- container_iterate_const(Warehouse::IncorporatedWorkers, warehouse.m_incorporated_workers, cwt) {
- container_iterate_const(Warehouse::WorkerList, cwt->second, i) {
- const Worker & w = *(*i);
+ for (const std::pair<Ware_Index, Warehouse::WorkerList>& cwt : warehouse.m_incorporated_workers) {
+ for (Worker * temp_worker : cwt.second) {
+ const Worker & w = *temp_worker;
assert(mos.is_object_known(w));
workermap.insert
(std::pair<uint32_t, const Worker *>
@@ -1379,9 +1381,8 @@
}
}
- container_iterate_const(TWorkerMap, workermap, i)
- {
- const Worker & obj = *i.current->second;
+ for (const std::pair<uint32_t, const Worker *>& temp_worker : workermap) {
+ const Worker & obj = *temp_worker.second;
assert(mos.is_object_known(obj));
fw.Unsigned32(mos.get_object_file_index(obj));
}
@@ -1403,17 +1404,15 @@
fw.Unsigned8(0); // terminator for spawn times
fw.Unsigned32(warehouse.m_planned_workers.size());
- container_iterate_const
- (std::vector<Warehouse::PlannedWorkers>,
- warehouse.m_planned_workers, pw_it)
- {
- fw.CString(tribe.get_worker_descr(pw_it.current->index)->name());
- fw.Unsigned32(pw_it.current->amount);
-
- fw.Unsigned32(pw_it.current->requests.size());
- container_iterate_const
- (std::vector<Request *>, pw_it.current->requests, req_it)
- (*req_it.current)->Write(fw, game, mos);
+ for (const Warehouse::PlannedWorkers& temp_worker : warehouse.m_planned_workers) {
+ fw.CString(tribe.get_worker_descr(temp_worker.index)->name());
+ fw.Unsigned32(temp_worker.amount);
+
+ fw.Unsigned32(temp_worker.requests.size());
+
+ for (Request * temp_request : temp_worker.requests) {
+ temp_request->Write(fw, game, mos);
+ }
}
fw.Unsigned32(warehouse.m_next_stock_remove_act);
@@ -1517,11 +1516,10 @@
<=
std::numeric_limits<uint8_t>::max());
fw.Unsigned8(productionsite.m_skipped_programs.size());
- container_iterate_const
- (ProductionSite::Skipped_Programs, productionsite.m_skipped_programs, i)
- {
- fw.String (i.current->first);
- fw.Unsigned32(i.current->second);
+
+ for (const std::pair<std::string, Time>& temp_program : productionsite.m_skipped_programs) {
+ fw.String (temp_program.first);
+ fw.Unsigned32(temp_program.second);
}
// state
=== modified file 'src/map_io/widelands_map_flagdata_data_packet.cc'
--- src/map_io/widelands_map_flagdata_data_packet.cc 2014-07-03 19:26:30 +0000
+++ src/map_io/widelands_map_flagdata_data_packet.cc 2014-07-24 20:54:16 +0000
@@ -282,8 +282,8 @@
const Flag::CapacityWaitQueue & capacity_wait =
flag->m_capacity_wait;
fw.Unsigned16(capacity_wait.size());
- container_iterate_const(Flag::CapacityWaitQueue, capacity_wait, i) {
- Worker const * const obj = i.current->get(egbase);
+ for (const OPtr<Worker >& temp_worker : capacity_wait) {
+ Worker const * const obj = temp_worker.get(egbase);
assert
(obj);
assert
@@ -297,16 +297,16 @@
}
const Flag::FlagJobs & flag_jobs = flag->m_flag_jobs;
fw.Unsigned16(flag_jobs.size());
- container_iterate_const(Flag::FlagJobs, flag_jobs, i) {
- if (i.current->request) {
+
+ for (const Flag::FlagJob& temp_job : flag_jobs) {
+ if (temp_job.request) {
fw.Unsigned8(1);
- i.current->request->Write
+ temp_job.request->Write
(fw, ref_cast<Game, Editor_Game_Base>(egbase), mos);
} else
fw.Unsigned8(0);
-
- fw.String(i.current->program);
+ fw.String(temp_job.program);
}
mos.mark_object_as_saved(*flag);
=== modified file 'src/map_io/widelands_map_map_object_saver.cc'
--- src/map_io/widelands_map_map_object_saver.cc 2014-07-05 12:17:03 +0000
+++ src/map_io/widelands_map_map_object_saver.cc 2014-07-24 20:54:16 +0000
@@ -153,10 +153,10 @@
* Return the number of unsaved objects
*/
void Map_Map_Object_Saver::detect_unsaved_objects() const {
- container_iterate_const(Map_Object_Map, m_objects, i) {
- if (!i.current->second.saved) {
+ for (const std::pair<const Map_Object *, MapObjectRec>& temp_map : m_objects) {
+ if (!temp_map.second.saved) {
throw wexception
- ("%s has not been saved", i.current->second.description.c_str());
+ ("%s has not been saved", temp_map.second.description.c_str());
}
}
}
=== modified file 'src/map_io/widelands_map_object_packet.cc'
--- src/map_io/widelands_map_object_packet.cc 2014-06-21 10:24:12 +0000
+++ src/map_io/widelands_map_object_packet.cc 2014-07-24 20:54:16 +0000
@@ -108,22 +108,22 @@
void Map_Object_Packet::LoadFinish() {
// load_pointer stage
- container_iterate_const(LoaderSet, loaders, i) {
+ for (Map_Object::Loader* temp_loader : loaders) {
try {
- (*i.current)->load_pointers();
+ temp_loader->load_pointers();
} catch (const std::exception & e) {
- throw wexception("load_pointers for %s: %s", (*i.current)->get_object()->type_name(), e.what());
+ throw wexception("load_pointers for %s: %s", temp_loader->get_object()->type_name(), e.what());
}
}
// load_finish stage
- container_iterate_const(LoaderSet, loaders, i) {
+ for (Map_Object::Loader* temp_loader : loaders) {
try {
- (*i.current)->load_finish();
+ temp_loader->load_finish();
} catch (const std::exception & e) {
- throw wexception("load_finish for %s: %s", (*i.current)->get_object()->type_name(), e.what());
+ throw wexception("load_finish for %s: %s", temp_loader->get_object()->type_name(), e.what());
}
- (*i.current)->mol().mark_object_as_loaded(*(*i.current)->get_object());
+ temp_loader->mol().mark_object_as_loaded(*temp_loader->get_object());
}
}
=== modified file 'src/map_io/widelands_map_players_messages_data_packet.cc'
--- src/map_io/widelands_map_players_messages_data_packet.cc 2014-06-08 21:02:17 +0000
+++ src/map_io/widelands_map_players_messages_data_packet.cc 2014-07-24 20:54:16 +0000
@@ -179,9 +179,9 @@
("packet_version", CURRENT_PACKET_VERSION);
const MessageQueue & messages = player->messages();
Map_Message_Saver & message_saver = mos.message_savers[p - 1];
- container_iterate_const(MessageQueue, messages, i) {
- message_saver.add (i.current->first);
- const Message & message = *i.current->second;
+ for (const std::pair<Message_Id, Message *>& temp_message : messages) {
+ message_saver.add (temp_message.first);
+ const Message & message = *temp_message.second;
assert(message.sent() <= static_cast<uint32_t>(egbase.get_gametime()));
assert
(message.duration() == Forever() or
=== modified file 'src/map_io/widelands_map_roaddata_data_packet.cc'
--- src/map_io/widelands_map_roaddata_data_packet.cc 2014-07-22 09:54:49 +0000
+++ src/map_io/widelands_map_roaddata_data_packet.cc 2014-07-24 20:54:16 +0000
@@ -263,28 +263,24 @@
fw.Unsigned32(r->m_carrier_slots.size());
- container_iterate_const
- (std::vector<Road::CarrierSlot>, r->m_carrier_slots, iter)
- {
-
+ for (const Road::CarrierSlot& temp_slot : r->m_carrier_slots) {
if
(Carrier const * const carrier =
- iter.current->carrier.get(egbase))
- {
+ temp_slot.carrier.get(egbase)) {
assert(mos.is_object_known(*carrier));
fw.Unsigned32(mos.get_object_file_index(*carrier));
} else {
fw.Unsigned32(0);
}
- if (iter.current->carrier_request) {
+ if (temp_slot.carrier_request) {
fw.Unsigned8(1);
- iter.current->carrier_request->Write
+ temp_slot.carrier_request->Write
(fw, ref_cast<Game, Editor_Game_Base>(egbase), mos);
} else {
fw.Unsigned8(0);
}
- fw.Unsigned32(iter.current->carrier_type);
+ fw.Unsigned32(temp_slot.carrier_type);
}
mos.mark_object_as_saved(*r);
}
=== modified file 'src/network/nethost.cc'
--- src/network/nethost.cc 2014-07-22 09:54:49 +0000
+++ src/network/nethost.cc 2014-07-24 20:54:16 +0000
@@ -1314,8 +1314,8 @@
directories.resize(directories.size() - 1);
Widelands::Map map;
const filenameset_t & gamefiles = files;
- container_iterate_const(filenameset_t, gamefiles, i) {
- char const * const name = i.current->c_str();
+ for (const std::string& temp_filenames : gamefiles) {
+ char const * const name = temp_filenames.c_str();
std::unique_ptr<Widelands::Map_Loader> ml = map.get_correct_loader(name);
if (ml) {
map.set_filename(name);
@@ -1346,8 +1346,8 @@
Widelands::Game game;
Widelands::Game_Preload_Data_Packet gpdp;
const filenameset_t & gamefiles = files;
- container_iterate_const(filenameset_t, gamefiles, i) {
- char const * const name = i.current->c_str();
+ for (const std::string& temp_filenames : gamefiles) {
+ char const * const name = temp_filenames.c_str();
try {
Widelands::Game_Loader gl(name, game);
gl.preload_game(gpdp);
@@ -1646,10 +1646,10 @@
actual_tribe = d->settings.tribes.at(random).name;
}
- container_iterate_const(std::vector<TribeBasicInfo>, d->settings.tribes, i)
- if (i.current->name == player.tribe) {
+ for (const TribeBasicInfo& temp_tribeinfo : d->settings.tribes) {
+ if (temp_tribeinfo.name == player.tribe) {
player.tribe = actual_tribe;
- if (i.current->initializations.size() <= player.initialization_index)
+ if (temp_tribeinfo.initializations.size() <= player.initialization_index)
player.initialization_index = 0;
// broadcast changes
@@ -1660,6 +1660,7 @@
broadcast(s);
return;
}
+ }
log
("Player %u attempted to change to tribe %s; not a valid tribe\n",
number, tribe.c_str());
@@ -1675,9 +1676,9 @@
if (player.initialization_index == index)
return;
- container_iterate_const(std::vector<TribeBasicInfo>, d->settings.tribes, i)
- if (i.current->name == player.tribe) {
- if (index < i.current->initializations.size()) {
+ for (const TribeBasicInfo& temp_tribeinfo : d->settings.tribes) {
+ if (temp_tribeinfo.name == player.tribe) {
+ if (index < temp_tribeinfo.initializations.size()) {
player.initialization_index = index;
// broadcast changes
@@ -1693,6 +1694,7 @@
"for player %u.\n", index, number);
return;
}
+ }
assert(false);
}
@@ -1918,9 +1920,11 @@
// Send the packet to all properly connected clients
void NetHost::broadcast(SendPacket & packet)
{
- container_iterate_const(std::vector<Client>, d->clients, i)
- if (i.current->playernum != UserSettings::notConnected())
- packet.send(i.current->sock);
+ for (const Client& client : d->clients) {
+ if (client.playernum != UserSettings::notConnected()) {
+ packet.send(client.sock);
+ }
+ }
}
void NetHost::writeSettingMap(SendPacket & packet)
=== modified file 'src/network/network_lan_promotion.cc'
--- src/network/network_lan_promotion.cc 2014-07-05 14:22:44 +0000
+++ src/network/network_lan_promotion.cc 2014-07-24 20:54:16 +0000
@@ -137,10 +137,10 @@
void LAN_Base::broadcast
(void const * const buf, size_t const len, uint16_t const port)
{
- container_iterate_const(std::list<in_addr_t>, broadcast_addresses, i) {
+ for (const in_addr_t& temp_address : broadcast_addresses) {
sockaddr_in addr;
addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = *i.current;
+ addr.sin_addr.s_addr = temp_address;
DIAG_OFF("-Wold-style-cast")
addr.sin_port = htons(port);
DIAG_ON("-Wold-style-cast")
=== modified file 'src/network/network_player_settings_backend.cc'
--- src/network/network_player_settings_backend.cc 2014-07-03 18:20:45 +0000
+++ src/network/network_player_settings_backend.cc 2014-07-24 20:54:16 +0000
@@ -106,14 +106,16 @@
return;
const PlayerSettings & player = settings.players[id];
- container_iterate_const(std::vector<TribeBasicInfo>, settings.tribes, j)
- if (j.current->name == player.tribe)
+ for (const TribeBasicInfo& temp_tribeinfo : settings.tribes) {
+ if (temp_tribeinfo.name == player.tribe) {
return
s->setPlayerInit
(id,
(player.initialization_index + 1)
%
- j.current->initializations.size());
+ temp_tribeinfo.initializations.size());
+ }
+ }
assert(false);
}
=== modified file 'src/profile/profile.cc'
--- src/profile/profile.cc 2014-06-23 20:17:05 +0000
+++ src/profile/profile.cc 2014-07-24 20:54:16 +0000
@@ -216,20 +216,24 @@
*/
void Section::check_used() const
{
- container_iterate_const(Value_list, m_values, i)
- if (not i.current->is_used())
+ for (const Value& temp_value : m_values) {
+ if (!temp_value.is_used()) {
m_profile->error
("Section [%s], key '%s' not used (did you spell the name "
"correctly?)",
- get_name(), i.current->get_name());
+ get_name(), temp_value.get_name());
+ }
+ }
}
bool Section::has_val(char const * const name) const
{
- container_iterate_const(Value_list, m_values, i)
- if (not strcasecmp(i.current->get_name(), name))
+ for (const Value& temp_value : m_values) {
+ if (!strcasecmp(temp_value.get_name(), name)) {
return true;
+ }
+ }
return false;
}
@@ -242,11 +246,12 @@
*/
Section::Value * Section::get_val(char const * const name)
{
- container_iterate(Value_list, m_values, i)
- if (!strcasecmp(i.current->get_name(), name)) {
- i.current->mark_used();
- return &*i.current;
+ for (Value& value : m_values) {
+ if (!strcasecmp(value.get_name(), name)) {
+ value.mark_used();
+ return &value;
}
+ }
return nullptr;
}
@@ -259,24 +264,26 @@
*/
Section::Value * Section::get_next_val(char const * const name)
{
- container_iterate(Value_list, m_values, i)
- if (not i.current->is_used())
- if (!name || !strcasecmp(i.current->get_name(), name)) {
- i.current->mark_used();
- return &*i.current;
+ for (Value& value : m_values) {
+ if (!value.is_used()) {
+ if (!name || !strcasecmp(value.get_name(), name)) {
+ value.mark_used();
+ return &value;
}
-
+ }
+ }
return nullptr;
}
Section::Value & Section::create_val
(char const * const name, char const * const value)
{
- container_iterate(Value_list, m_values, i)
- if (!strcasecmp(i.current->get_name(), name)) {
- i.current->set_string(value);
- return *i.current;
+ for (Value& temp_value : m_values) {
+ if (!strcasecmp(temp_value.get_name(), name)) {
+ temp_value.set_string(value);
+ return temp_value;
}
+ }
return create_val_duplicate(name, value);
}
@@ -572,13 +579,16 @@
*/
void Profile::check_used() const
{
- container_iterate_const(Section_list, m_sections, i)
- if (!i.current->is_used())
+ for (const Section& temp_section : m_sections) {
+ if (!temp_section.is_used()) {
error
("Section [%s] not used (did you spell the name correctly?)",
- i.current->get_name());
- else
- i.current->check_used();
+ temp_section.get_name());
+ }
+ else {
+ temp_section.check_used();
+ }
+ }
}
/**
@@ -590,12 +600,12 @@
*/
Section * Profile::get_section(const std::string & name)
{
- container_iterate(Section_list, m_sections, i)
- if (!strcasecmp(i.current->get_name(), name.c_str())) {
- i.current->mark_used();
- return &*i.current;
+ for (Section& temp_section : m_sections) {
+ if (!strcasecmp(temp_section.get_name(), name.c_str())) {
+ temp_section.mark_used();
+ return &temp_section;
}
-
+ }
return nullptr;
}
@@ -633,22 +643,25 @@
*/
Section * Profile::get_next_section(char const * const name)
{
- container_iterate(Section_list, m_sections, i)
- if (not i.current->is_used())
- if (!name || !strcasecmp(i.current->get_name(), name)) {
- i.current->mark_used();
- return &*i.current;
+ for (Section& section : m_sections) {
+ if (!section.is_used()) {
+ if (!name || !strcasecmp(section.get_name(), name)) {
+ section.mark_used();
+ return §ion;
}
-
+ }
+ }
return nullptr;
}
Section & Profile::create_section (char const * const name)
{
- container_iterate(Section_list, m_sections, i)
- if (!strcasecmp(i.current->get_name(), name))
- return *i.current;
+ for (Section& section : m_sections) {
+ if (!strcasecmp(section.get_name(), name)) {
+ return section;
+ }
+ }
return create_section_duplicate(name);
}
@@ -843,20 +856,20 @@
("# Automatically created by Widelands %s (%s)\n",
build_id().c_str(), build_type().c_str());
- container_iterate_const(Section_list, m_sections, s) {
- if (used_only && !s.current->is_used())
+ for (const Section& temp_section : m_sections) {
+ if (used_only && !temp_section.is_used())
continue;
- fw.Printf("\n[%s]\n", s.current->get_name());
+ fw.Printf("\n[%s]\n", temp_section.get_name());
- container_iterate_const(Section::Value_list, s.current->m_values, v) {
- if (used_only && !v.current->is_used())
+ for (const Section::Value& temp_value : temp_section.m_values) {
+ if (used_only && !temp_value.is_used())
continue;
- char const * const str = v.current->get_string();
+ char const * const str = temp_value.get_string();
if (*str) {
- uint32_t spaces = strlen(v.current->get_name());
+ uint32_t spaces = strlen(temp_value.get_name());
bool multiline = false;
for (uint32_t i = 0; i < strlen(str); ++i) {
@@ -895,9 +908,9 @@
// End of multilined text.
tempstr += '"';
- fw.Printf("%s=\"%s\"\n", v.current->get_name(), tempstr.c_str());
+ fw.Printf("%s=\"%s\"\n", temp_value.get_name(), tempstr.c_str());
} else
- fw.Printf("%s=\n", v.current->get_name());
+ fw.Printf("%s=\n", temp_value.get_name());
}
}
=== modified file 'src/scripting/lua_game.cc'
--- src/scripting/lua_game.cc 2014-07-05 14:22:44 +0000
+++ src/scripting/lua_game.cc 2014-07-24 20:54:16 +0000
@@ -202,12 +202,12 @@
lua_newtable(L);
uint32_t cidx = 1;
- container_iterate_const(MessageQueue, p.messages(), m) {
- if (m.current->second->status() == Message::Archived)
+ for (const std::pair<Message_Id, Message *>& temp_message : p.messages()) {
+ if (temp_message.second->status() == Message::Archived)
continue;
lua_pushuint32(L, cidx ++);
- to_lua<L_Message>(L, new L_Message(player_number(), m.current->first));
+ to_lua<L_Message>(L, new L_Message(player_number(), temp_message.first));
lua_rawset(L, -3);
}
@@ -694,12 +694,12 @@
lua_newtable(L);
uint32_t cidx = 1;
- container_iterate_const(std::vector<Building_Index>, houses, i) {
+ for (const Building_Index& house : houses) {
const std::vector<Widelands::Player::Building_Stats> & vec =
- p.get_building_statistics(*i.current);
+ p.get_building_statistics(house);
if (return_array) {
- lua_pushstring(L, p.tribe().get_building_descr(*i.current)->name());
+ lua_pushstring(L, p.tribe().get_building_descr(house)->name());
lua_newtable(L);
cidx = 1;
}
@@ -794,10 +794,11 @@
}
for (uint32_t j = player.get_nr_economies(); j;) {
Economy & economy = *player.get_economy_by_number(--j);
- container_iterate_const
- (std::vector<Warehouse *>, economy.warehouses(), k)
- (*k.current)->enable_spawn
+
+ for (Warehouse * warehouse : economy.warehouses()) {
+ warehouse->enable_spawn
(game, worker_types_without_cost_index);
+ }
}
}
}
@@ -864,9 +865,9 @@
std::vector<Building_Index> houses;
m_parse_building_list(L, p.tribe(), houses);
- container_iterate_const(std::vector<Building_Index>, houses, i)
- p.allow_building_type(*i.current, allow);
-
+ for (const Building_Index& house : houses) {
+ p.allow_building_type(house, allow);
+ }
return 0;
}
=== modified file 'src/scripting/lua_map.cc'
--- src/scripting/lua_map.cc 2014-07-24 05:21:20 +0000
+++ src/scripting/lua_map.cc 2014-07-24 20:54:16 +0000
@@ -195,9 +195,9 @@
WaresMap count_wares_on_flag_(Flag& f, const Tribe_Descr & tribe) {
WaresMap rv;
- Flag::Wares current_wares = f.get_wares();
- container_iterate_const(Flag::Wares, current_wares, w) {
- Ware_Index i = tribe.ware_index((*w.current)->descr().name());
+
+ for (const WareInstance * ware : f.get_wares()) {
+ Ware_Index i = tribe.ware_index(ware->descr().name());
if (!rv.count(i))
rv.insert(Widelands::WareAmount(i, 1));
else
@@ -2213,9 +2213,9 @@
lua_createtable(L, pl.size(), 0);
uint32_t idx = 1;
- container_iterate_const(BaseImmovable::PositionList, pl, f) {
+ for (const Coords& coords : pl) {
lua_pushuint32(L, idx++);
- to_lua<L_Field>(L, new L_Field(f->x, f->y));
+ to_lua<L_Field>(L, new L_Field(coords.x, coords.y));
lua_rawset(L, -3);
}
return 1;
@@ -2334,21 +2334,22 @@
WaresMap c_wares = count_wares_on_flag_(*f, tribe);
uint32_t nwares = 0;
- container_iterate_const(WaresMap, c_wares, c) {
+
+ for (const std::pair<Widelands::Ware_Index, uint32_t>& ware : c_wares) {
// all wares currently on the flag without a setpoint should be removed
- if (!setpoints.count(c->first))
- setpoints.insert(Widelands::WareAmount(c->first, 0));
- nwares += c->second;
+ if (!setpoints.count(ware.first))
+ setpoints.insert(Widelands::WareAmount(ware.first, 0));
+ nwares += ware.second;
}
// The idea is to change as little as possible on this flag
- container_iterate_const(WaresMap, setpoints, sp) {
+ for (const std::pair<Widelands::Ware_Index, uint32_t>& sp : setpoints) {
uint32_t cur = 0;
- WaresMap::iterator i = c_wares.find(sp->first);
+ WaresMap::iterator i = c_wares.find(sp.first);
if (i != c_wares.end())
cur = i->second;
- int d = sp->second - cur;
+ int d = sp.second - cur;
nwares += d;
if (f->total_capacity() < nwares)
@@ -2356,10 +2357,9 @@
if (d < 0) {
while (d) {
- Flag::Wares current_wares = f->get_wares();
- container_iterate_const(Flag::Wares, current_wares, w) {
- if (tribe.ware_index((*w.current)->descr().name()) == sp->first) {
- const_cast<WareInstance *>(*w.current)->remove(egbase);
+ for (const WareInstance * ware : f->get_wares()) {
+ if (tribe.ware_index(ware->descr().name()) == sp.first) {
+ const_cast<WareInstance *>(ware)->remove(egbase);
++d;
break;
}
@@ -2367,9 +2367,9 @@
}
} else if (d > 0) {
// add wares
- const WareDescr & wd = *tribe.get_ware_descr(sp->first);
+ const WareDescr & wd = *tribe.get_ware_descr(sp.first);
for (int32_t j = 0; j < d; j++) {
- WareInstance & ware = *new WareInstance(sp->first, &wd);
+ WareInstance & ware = *new WareInstance(sp.first, &wd);
ware.init(egbase);
f->add_ware(egbase, ware);
}
@@ -2390,23 +2390,25 @@
if (wares_set.size() == tribe.get_nrwares()) { // Want all returned
wares_set.clear();
- container_iterate_const(WaresMap, wares, w)
- wares_set.insert(w->first);
+
+ for (const std::pair<Widelands::Ware_Index, uint32_t>& ware : wares) {
+ wares_set.insert(ware.first);
+ }
}
if (!return_number)
lua_newtable(L);
- container_iterate_const(WaresSet, wares_set, w) {
+ for (const Widelands::Ware_Index& ware : wares_set) {
uint32_t count = 0;
- if (wares.count(*w))
- count = wares[*w];
+ if (wares.count(ware))
+ count = wares[ware];
if (return_number) {
lua_pushuint32(L, count);
break;
} else {
- lua_pushstring(L, tribe.get_ware_descr(*w)->name());
+ lua_pushstring(L, tribe.get_ware_descr(ware)->name());
lua_pushuint32(L, count);
lua_rawset(L, -3);
}
@@ -2851,9 +2853,9 @@
const Tribe_Descr & tribe = ps->owner().tribe();
lua_newtable(L);
- container_iterate_const(BillOfMaterials, ps->descr().inputs(), i) {
- lua_pushstring(L, tribe.get_ware_descr(i.current->first)->name());
- lua_pushuint32(L, i.current->second);
+ for (const WareAmount& input_ware : ps->descr().inputs()) {
+ lua_pushstring(L, tribe.get_ware_descr((input_ware.first))->name());
+ lua_pushuint32(L, input_ware.second);
lua_rawset(L, -3);
}
return 1;
@@ -2879,20 +2881,20 @@
WaresMap setpoints = m_parse_set_wares_arguments(L, tribe);
WaresSet valid_wares;
- container_iterate_const(BillOfMaterials, ps->descr().inputs(), i)
- valid_wares.insert(i->first);
-
- container_iterate_const(WaresMap, setpoints, i) {
- if (!valid_wares.count(i->first))
- report_error(
- L, "<%s> can't be stored here!", tribe.get_ware_descr(i->first)->name().c_str());
-
- WaresQueue & wq = ps->waresqueue(i->first);
- if (i->second > wq.get_max_size())
- report_error(
- L, "Not enough space for %u items, only for %i", i->second, wq.get_max_size());
-
- wq.set_filled(i->second);
+ for (const WareAmount& input_ware : ps->descr().inputs()) {
+ valid_wares.insert(input_ware.first);
+ }
+ for (const std::pair<Widelands::Ware_Index, uint32_t>& sp : setpoints) {
+ if (!valid_wares.count(sp.first)) {
+ report_error(
+ L, "<%s> can't be stored here!", tribe.get_ware_descr(sp.first)->name().c_str());
+ }
+ WaresQueue & wq = ps->waresqueue(sp.first);
+ if (sp.second > wq.get_max_size()) {
+ report_error(
+ L, "Not enough space for %u items, only for %i", sp.second, wq.get_max_size());
+ }
+ wq.set_filled(sp.second);
}
return 0;
@@ -2907,8 +2909,9 @@
WaresSet wares_set = m_parse_get_wares_arguments(L, tribe, &return_number);
WaresSet valid_wares;
- container_iterate_const(BillOfMaterials, ps->descr().inputs(), i)
- valid_wares.insert(i.current->first);
+ for (const WareAmount& input_ware : ps->descr().inputs()) {
+ valid_wares.insert(input_ware.first);
+ }
if (wares_set.size() == tribe.get_nrwares()) // Want all returned
wares_set = valid_wares;
@@ -2916,16 +2919,16 @@
if (!return_number)
lua_newtable(L);
- container_iterate_const(WaresSet, wares_set, i) {
+ for (const Widelands::Ware_Index& ware : wares_set) {
uint32_t cnt = 0;
- if (valid_wares.count(*i.current))
- cnt = ps->waresqueue(*i.current).get_filled();
+ if (valid_wares.count(ware))
+ cnt = ps->waresqueue(ware).get_filled();
if (return_number) { // this is the only thing the customer wants to know
lua_pushuint32(L, cnt);
break;
} else {
- lua_pushstring(L, tribe.get_ware_descr(*i.current)->name());
+ lua_pushstring(L, tribe.get_ware_descr(ware)->name());
lua_pushuint32(L, cnt);
lua_rawset(L, -3);
}
@@ -3793,11 +3796,11 @@
// Push the players with military influence
uint32_t cidx = 1;
- container_iterate_const (std::vector<PlrInfluence>, claimers, i) {
- if (i.current->second <= 0)
+ for (const PlrInfluence& claimer : claimers) {
+ if (claimer.second <= 0)
continue;
lua_pushuint32(L, cidx ++);
- get_factory(L).push_player(L, i.current->first);
+ get_factory(L).push_player(L, claimer.first);
lua_rawset(L, -3);
}
=== modified file 'src/scripting/lua_ui.cc'
--- src/scripting/lua_ui.cc 2014-07-05 12:48:58 +0000
+++ src/scripting/lua_ui.cc 2014-07-24 20:54:16 +0000
@@ -145,9 +145,9 @@
_put_all_tabs_into_table(L, f);
if (upcast(UI::Tab_Panel, t, f))
- container_iterate_const(UI::Tab_Panel::TabList, t->tabs(), tab) {
- lua_pushstring(L, (*tab)->get_name());
- to_lua<L_Tab>(L, new L_Tab(*tab));
+ for (UI::Tab* tab : t->tabs()) {
+ lua_pushstring(L, tab->get_name());
+ to_lua<L_Tab>(L, new L_Tab(tab));
lua_rawset(L, -3);
}
}
=== modified file 'src/sound/sound_handler.cc'
--- src/sound/sound_handler.cc 2014-07-23 14:49:10 +0000
+++ src/sound/sound_handler.cc 2014-07-24 20:54:16 +0000
@@ -76,8 +76,13 @@
/// themselves.
Sound_Handler::~Sound_Handler()
{
- container_iterate_const (FXset_map, fxs_, i) delete i.current->second;
- container_iterate_const(Songset_map, songs_, i) delete i.current->second;
+ for (const std::pair<std::string, FXset *> fx_pair : fxs_) {
+ delete fx_pair.second;
+ }
+
+ for (const std::pair<std::string, Songset *> song_pair : songs_) {
+ delete song_pair.second;
+ }
if (fx_lock_)
{
@@ -380,13 +385,17 @@
// Access to active_fx_ is protected because it can
// be accessed from callback
if (fx_lock_) SDL_LockMutex(fx_lock_);
- container_iterate_const(Activefx_map, active_fx_, i)
+
+ // starting a block, so I can define a local type for iterating
{
- if (i->second == fx_name) {
- already_running = true;
- break;
+ for (const std::pair<uint32_t, std::string> fx_pair : active_fx_) {
+ if (fx_pair.second == fx_name) {
+ already_running = true;
+ break;
+ }
}
}
+
if (fx_lock_) SDL_UnlockMutex(fx_lock_);
if (!allow_multiple && already_running)
=== modified file 'src/ui_basic/listselect.cc'
--- src/ui_basic/listselect.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/listselect.cc 2014-07-24 20:54:16 +0000
@@ -98,8 +98,9 @@
* Remove all entries from the listselect
*/
void BaseListselect::clear() {
- container_iterate_const(Entry_Record_deque, m_entry_records, i)
- delete *i.current;
+ for (Entry_Record * entry : m_entry_records) {
+ delete entry;
+ }
m_entry_records.clear();
m_scrollbar.set_steps(1);
@@ -165,8 +166,9 @@
Entry_Record * er = new Entry_Record();
er->m_entry = 0;
- container_iterate_const(Entry_Record_deque, m_entry_records, i)
- ++(*i.current)->m_entry;
+ for (Entry_Record * temp_entry : m_entry_records) {
+ ++(temp_entry)->m_entry;
+ }
er->pic = pic;
er->use_clr = false;
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/progresswindow.cc 2014-07-24 20:54:16 +0000
@@ -52,9 +52,9 @@
}
ProgressWindow::~ProgressWindow() {
- const VisualizationArray & visualizations = m_visualizations;
- container_iterate_const(VisualizationArray, visualizations, i)
- (*i.current)->stop(); // inform visualizations
+ for (IProgressVisualization * visualization : m_visualizations) {
+ visualization->stop(); // inform visualizations
+ }
}
void ProgressWindow::draw_background
@@ -128,10 +128,9 @@
}
void ProgressWindow::update(bool const repaint) {
- VisualizationArray & visualizations = m_visualizations;
- container_iterate_const(VisualizationArray, visualizations, i)
- (*i.current)->update(repaint); // let visualizations do their work
-
+ for (IProgressVisualization * visualization : m_visualizations) {
+ visualization->update(repaint); // let visualizations do their work
+ }
g_gr->refresh(false);
}
@@ -159,11 +158,12 @@
void ProgressWindow::remove_visualization(IProgressVisualization * instance) {
VisualizationArray & visualizations = m_visualizations;
- container_iterate(VisualizationArray, visualizations, i)
+ container_iterate(VisualizationArray, visualizations, i) {
if (*i.current == instance) {
m_visualizations.erase (i.current);
break;
}
+ }
}
}
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2014-07-14 10:45:44 +0000
+++ src/ui_basic/table.cc 2014-07-24 20:54:16 +0000
@@ -72,8 +72,9 @@
*/
Table<void *>::~Table()
{
- container_iterate_const(Entry_Record_vector, m_entry_records, i)
- delete *i.current;
+ for (const Entry_Record * entry : m_entry_records) {
+ delete entry;
+ }
}
/// Add a new column to this table.
@@ -88,8 +89,9 @@
assert(size() == 0);
uint32_t complete_width = 0;
- container_iterate_const(Columns, m_columns, i)
- complete_width += i.current->width;
+ for (const Column& col : m_columns) {
+ complete_width += col.width;
+ }
m_total_width += width;
set_desired_size(m_total_width, get_h());
@@ -202,10 +204,11 @@
(const void * const entry) const
{
- container_iterate_const(Entry_Record_vector, m_entry_records, i)
- if ((*i.current)->entry() == entry)
- return *i.current;
-
+ for (Entry_Record * temp_entry : m_entry_records) {
+ if (temp_entry->entry() == entry) {
+ return temp_entry;
+ }
+ }
return nullptr;
}
@@ -230,8 +233,9 @@
*/
void Table<void *>::clear()
{
- container_iterate_const(Entry_Record_vector, m_entry_records, i)
- delete *i.current;
+ for (const Entry_Record * entry : m_entry_records) {
+ delete entry;
+ }
m_entry_records.clear();
if (m_scrollbar)
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2014-07-14 10:45:44 +0000
+++ src/ui_fsmenu/mapselect.cc 2014-07-24 20:54:16 +0000
@@ -539,8 +539,9 @@
void Fullscreen_Menu_MapSelect::_tagbox_changed(int32_t id, bool to) {
if (id == 0) { // Show all maps checbox
if (to) {
- container_iterate(std::vector<UI::Checkbox *>, m_tags_checkboxes, it)
- (*it)->set_state(false);
+ for (UI::Checkbox * checkbox : m_tags_checkboxes) {
+ checkbox->set_state(false);
+ }
}
} else { // Any tag
if (to)
=== modified file 'src/wui/encyclopedia_window.cc'
--- src/wui/encyclopedia_window.cc 2014-07-24 05:21:20 +0000
+++ src/wui/encyclopedia_window.cc 2014-07-24 20:54:16 +0000
@@ -172,14 +172,13 @@
const ProductionProgram::Actions & actions =
programIt->second->actions();
- container_iterate_const(ProductionProgram::Actions, actions, i)
- if (upcast(ProductionProgram::ActConsume const, action, *i.current)) {
+ for (const ProductionProgram::Action * temp_action : actions) {
+ if (upcast(ProductionProgram::ActConsume const, action, temp_action)) {
const ProductionProgram::ActConsume::Groups & groups =
action->groups();
- container_iterate_const
- (ProductionProgram::ActConsume::Groups, groups, j)
- {
- const std::set<Ware_Index> & ware_types = j.current->first;
+
+ for (const ProductionProgram::Ware_Type_Group& temp_group : groups) {
+ const std::set<Ware_Index> & ware_types = temp_group.first;
assert(ware_types.size());
std::string ware_type_names;
for
@@ -196,9 +195,9 @@
// Make sure to detect if someone changes the type so that it
// needs more than 3 decimal digits to represent.
- static_assert(sizeof(j.current->second) == 1, "Number is too big for 3 char string.");
+ static_assert(sizeof(temp_group.second) == 1, "Number is too big for 3 char string.");
char amount_string[4]; // Space for 3 digits + terminator.
- sprintf(amount_string, "%u", j.current->second);
+ sprintf(amount_string, "%u", temp_group.second);
// picture only of first ware type in group
UI::Table<uintptr_t>::Entry_Record & tableEntry =
@@ -210,5 +209,6 @@
condTable.sort();
}
}
+ }
}
}
=== modified file 'src/wui/game_debug_ui.cc'
--- src/wui/game_debug_ui.cc 2014-07-16 08:25:35 +0000
+++ src/wui/game_debug_ui.cc 2014-07-24 20:54:16 +0000
@@ -22,6 +22,8 @@
#include <cstdio>
+#include <boost/format.hpp>
+
#include "base/i18n.h"
#include "graphic/graphic.h"
#include "logic/bob.h"
@@ -429,11 +431,12 @@
idx--; //reiter the same index
}
// Add remaining
- container_iterate_const(std::vector<Widelands::Bob *>, bobs, j) {
- snprintf
- (buffer, sizeof(buffer),
- "%s (%u)", (*j.current)->descr().name().c_str(), (*j.current)->serial());
- m_ui_bobs.add(buffer, (*j.current)->serial());
+ for (const Widelands::Bob * temp_bob : bobs) {
+ m_ui_bobs.add(
+ (boost::format("%s (%u)")
+ % temp_bob->descr().name()
+ % temp_bob->serial()).str().c_str(),
+ temp_bob->serial());
}
}
=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc 2014-07-22 09:54:49 +0000
+++ src/wui/game_message_menu.cc 2014-07-24 20:54:16 +0000
@@ -170,9 +170,9 @@
}
// Add new messages to the list
- container_iterate_const(MessageQueue, mq, i) {
- Message_Id const id = i.current->first;
- const Message & message = *i.current->second;
+ for (const std::pair<Message_Id, Message *>& temp_message : mq) {
+ Message_Id const id = temp_message.first;
+ const Message & message = *temp_message.second;
Message::Status const status = message.status();
if ((mode == Archive) != (status == Message::Archived))
continue;
=== modified file 'src/wui/interactive_base.cc'
--- src/wui/interactive_base.cc 2014-07-22 09:54:49 +0000
+++ src/wui/interactive_base.cc 2014-07-24 20:54:16 +0000
@@ -727,9 +727,9 @@
{
Widelands::CheckStepLimited cstep;
{
- const std::vector<Coords> & road_cp = m_buildroad->get_coords();
- container_iterate_const(std::vector<Coords>, road_cp, i)
- cstep.add_allowed_location(*i.current);
+ for (const Coords& coord : m_buildroad->get_coords()) {
+ cstep.add_allowed_location(coord);
+ }
}
map.findpath
(m_buildroad->get_start(), field, 0, path, cstep, Map::fpBidiCost);
=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc 2014-07-03 19:26:30 +0000
+++ src/wui/interactive_gamebase.cc 2014-07-24 20:54:16 +0000
@@ -85,8 +85,8 @@
if (!map.find_bobs(area, &ships, Widelands::FindBobShip()))
return false;
- container_iterate_const(std::vector<Widelands::Bob *>, ships, it) {
- if (upcast(Widelands::Ship, ship, *it.current)) {
+ for (Widelands::Bob * temp_ship : ships) {
+ if (upcast(Widelands::Ship, ship, temp_ship)) {
if (can_see(ship->get_owner()->player_number())) {
ship->show_window(*this);
return true;
=== modified file 'src/wui/multiplayersetupgroup.cc'
--- src/wui/multiplayersetupgroup.cc 2014-07-05 14:22:44 +0000
+++ src/wui/multiplayersetupgroup.cc 2014-07-24 20:54:16 +0000
@@ -360,11 +360,9 @@
else {
std::string tribepath("tribes/" + player_setting.tribe);
i18n::Textdomain td(tribepath); // for translated initialisation
- container_iterate_const
- (std::vector<TribeBasicInfo>, settings.tribes, i)
- {
- if (i.current->name == player_setting.tribe) {
- init->set_title(_(i.current->initializations.at(player_setting.initialization_index).second));
+ for (const TribeBasicInfo& tribeinfo : settings.tribes) {
+ if (tribeinfo.name == player_setting.tribe) {
+ init->set_title(_(tribeinfo.initializations.at(player_setting.initialization_index).second));
break;
}
}
=== modified file 'src/wui/playerdescrgroup.cc'
--- src/wui/playerdescrgroup.cc 2014-07-05 14:22:44 +0000
+++ src/wui/playerdescrgroup.cc 2014-07-24 20:54:16 +0000
@@ -198,13 +198,11 @@
{
i18n::Textdomain td(tribepath); // for translated initialisation
- container_iterate_const
- (std::vector<TribeBasicInfo>, settings.tribes, i)
- {
- if (i.current->name == player.tribe) {
+ for (const TribeBasicInfo& tribeinfo : settings.tribes) {
+ if (tribeinfo.name == player.tribe) {
d->btnPlayerInit->set_title
(_
- (i.current->initializations.at
+ (tribeinfo.initializations.at
(player.initialization_index)
.second));
break;
@@ -325,13 +323,16 @@
return;
const PlayerSettings & player = settings.players[d->plnum];
- container_iterate_const(std::vector<TribeBasicInfo>, settings.tribes, j)
- if (j.current->name == player.tribe)
+
+ for (const TribeBasicInfo& tribeinfo : settings.tribes) {
+ if (tribeinfo.name == player.tribe) {
return
d->settings->setPlayerInit
(d->plnum,
(player.initialization_index + 1)
%
- j.current->initializations.size());
+ tribeinfo.initializations.size());
+ }
+ }
assert(false);
}
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2014-07-15 05:12:37 +0000
+++ src/wui/soldierlist.cc 2014-07-24 20:54:16 +0000
@@ -132,12 +132,11 @@
set_think(true);
// Initialize the icons
- std::vector<Soldier *> soldierlist = m_soldiers.presentSoldiers();
uint32_t row = 0;
uint32_t col = 0;
- container_iterate_const(std::vector<Soldier *>, soldierlist, sit) {
+ for (Soldier * soldier : m_soldiers.presentSoldiers()) {
Icon icon;
- icon.soldier = *sit.current;
+ icon.soldier = soldier;
icon.row = row;
icon.col = col;
icon.pos = calc_pos(row, col);
@@ -239,8 +238,7 @@
int32_t maxdist = dt * AnimateSpeed / 1000;
m_last_animate_time = curtime;
- container_iterate(std::vector<Icon>, m_icons, icon_it) {
- Icon & icon = *icon_it.current;
+ for (Icon& icon : m_icons) {
Point goal = calc_pos(icon.row, icon.col);
Point dp = goal - icon.pos;
@@ -294,8 +292,7 @@
RGBAColor(0, 0, 0, 0));
// Draw icons
- container_iterate_const(std::vector<Icon>, m_icons, icon_it) {
- const Icon & icon = *icon_it.current;
+ for (const Icon& icon : m_icons) {
const Soldier * soldier = icon.soldier.get(egbase());
if (!soldier)
continue;
@@ -314,10 +311,11 @@
*/
const Soldier * SoldierPanel::find_soldier(int32_t x, int32_t y) const
{
- container_iterate_const(std::vector<Icon>, m_icons, icon_it) {
- Rect r(icon_it.current->pos, m_icon_width, m_icon_height);
- if (r.contains(Point(x, y)))
- return icon_it.current->soldier.get(egbase());
+ for (const Icon& icon : m_icons) {
+ Rect r(icon.pos, m_icon_width, m_icon_height);
+ if (r.contains(Point(x, y))) {
+ return icon.soldier.get(egbase());
+ }
}
return nullptr;
Follow ups