mercredi 26 juillet 2017

Changing value of map

I have a little problem and I cannot find out what is causing it.

for (auto const &entry : currentHealableItems) {
    Item* item = entry.second;
    if (item->isUsable()) {
        item->use();
        return item->getAddress();
    }
}

I am iterating over a map which has a const char* as a key and an Item* object as a value. I am searching for an item which I can use in this map. It is usable when timeNow - lastUsed >= coolDownOfItem.

All I want to do is that the time, when the item was last used, is getting saved in the "use" function. But every time I run this loop the time when I last used the item is still 0, hence it doesn't get saved when I iterate over the map.

Can anybody tell my why this is happening?

Aucun commentaire:

Enregistrer un commentaire