Bomb* SimpleStoresMgr::getNextBombImp() { Bomb* bomb = nullptr; base::PairStream* list = getWeapons(); if (list != nullptr) { // find the first free (inactive) bomb base::List::Item* item = list->getFirstItem(); while (item != nullptr && bomb == nullptr) { base::Pair* pair = static_cast<base::Pair*>(item->getValue()); Bomb* p = dynamic_cast<Bomb*>(pair->object()); if (p != nullptr) { if (p->isInactive() || p->isReleaseHold()) { bomb = static_cast<Bomb*>(p->getPointer()); } } item = item->getNext(); } list->unref(); } return bomb; }
// Get the next free bomb of type 'bombType' Bomb* SimpleStoresMgr::getSpecificBomb(const base::String* const bombType) { Bomb* bomb = nullptr; if (bombType != nullptr) { base::PairStream* list = getWeapons(); if (list != nullptr) { // Find the first free (inactive) bomb base::List::Item* item = list->getFirstItem(); while (item != nullptr && bomb == nullptr) { base::Pair* pair = static_cast<base::Pair*>(item->getValue()); Bomb* p = dynamic_cast<Bomb*>(pair->object()); if (p != nullptr && p->isInactive()) { // Ok, we have a bomb, but is it the type we want? if (*p->getType() == *bombType) { p->ref(); bomb = p; } } item = item->getNext(); } list->unref(); } } return bomb; }
Bomb* SimpleStoresMgr::getNextBombImp() { Bomb* bomb = 0; Basic::PairStream* list = getWeapons(); if (list != 0) { Basic::List::Item* item = list->getFirstItem(); while (item != 0 && bomb == 0) { Basic::Pair* pair = (Basic::Pair*) item->getValue(); Bomb* p = dynamic_cast<Bomb*>( pair->object() ); if (p != 0) { if (p->isInactive() || p->isReleaseHold()) { bomb = (Bomb*) p->getPointer(); } } item = item->getNext(); } list->unref(); } return bomb; }