Skip to content

Commit 6e5d003

Browse files
committed
Ship::removeCargo - const added to shipCargoAmount and iterator
1 parent 68939f4 commit 6e5d003

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

shm/ship.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ void Ship::addCargo(Cargo * item)
6363

6464
void Ship::removeCargo(Cargo * item, size_t amount)
6565
{
66-
auto shipCargoAmount = findMatchCargo(item)->getAmount();
66+
const auto shipCargoAmount = findMatchCargo(item)->getAmount();
6767
if(shipCargoAmount == amount)
6868
{
69-
auto it = std::find_if(begin(shipCargo), end(shipCargo), [item](const auto* el){ return *el == *item; });
69+
const auto it = std::find_if(begin(shipCargo), end(shipCargo), [item](const auto* el){ return *el == *item; });
7070
if(it != end(shipCargo)) {
7171
shipCargo.erase(it);
7272
}
@@ -96,7 +96,6 @@ void Ship::load(Cargo * loadCargo, size_t amount)
9696
Cargo* toAdd;
9797
if(Fruit* f = dynamic_cast<Fruit*>(loadCargo)){
9898
toAdd = new Fruit(*f);
99-
10099
}
101100
if(Item* i = dynamic_cast<Item*>(loadCargo)){
102101
toAdd = new Item(*i);

0 commit comments

Comments
 (0)