From 45ea16384fdc077ca07e21e309170894bdf88860 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Nov 2013 20:05:56 +0000 Subject: Iterator cleanups. --- src/core/inventory.cc | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/core') diff --git a/src/core/inventory.cc b/src/core/inventory.cc index e079256..9c7ad2b 100644 --- a/src/core/inventory.cc +++ b/src/core/inventory.cc @@ -52,11 +52,9 @@ void Inventory::set_dirty(const bool dirty) void Inventory::add(Item *item) { - assert(item != (Item *) 0x81); - // assign an id unsigned int id = 0; - for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { if ((*it)->id() > id) { id = (*it)->id(); } @@ -69,7 +67,7 @@ void Inventory::add(Item *item) void Inventory::erase(Item *item) { - for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { if ((*it) == item) { delete (*it); (*it) = 0; @@ -82,7 +80,7 @@ void Inventory::erase(Item *item) void Inventory::erase(const unsigned int id) { - for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { if ((*it)->id() == id) { delete (*it); (*it) = 0; @@ -95,7 +93,7 @@ void Inventory::erase(const unsigned int id) Item *Inventory::find(Item *item) const { - for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { if ((*it) == item) { return item; } @@ -106,7 +104,7 @@ Item *Inventory::find(Item *item) const Item *Inventory::find(const Info *info) const { // sarch the inventory for a specified item type - for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { Item *item = (*it); if (item->info() == info) { return item; @@ -119,7 +117,7 @@ Item *Inventory::find(const Info *info) const Item *Inventory::find(const unsigned int id) const { // sarch the inventory for a specified item id - for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { Item *item = (*it); if (item->id() == id) { return item; @@ -131,7 +129,7 @@ Item *Inventory::find(const unsigned int id) const void Inventory::clear() { - for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { Item *item = (*it); delete item; } @@ -142,7 +140,7 @@ void Inventory::clear() void Inventory::recalculate() { inventory_capacity_used = 0; - for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); it++) { + for (Items::const_iterator it = inventory_items.begin(); it != inventory_items.end(); ++it) { const Item *item = (*it); inventory_capacity_used += item->amount() * item->info()->volume(); } -- cgit v1.2.3