better managed ownership (two new functions in level.h)
This commit is contained in:
@ -47,15 +47,10 @@ void potion::print(output *out) {
|
||||
out->print_char(pos, 'P', COLOR_PAIR(COLOR_GREEN));
|
||||
}
|
||||
|
||||
potion *get_potion_at(const position &pos, potion_list &plist) {
|
||||
potion *ret = nullptr;
|
||||
|
||||
size_t get_potion_at(const position &pos, const potion_list &plist) {
|
||||
for (size_t i = 0; i < plist.size(); ++i)
|
||||
if (plist[i]->get_pos() == pos) {
|
||||
ret = plist[i];
|
||||
plist.erase(plist.begin() + i);
|
||||
return ret;
|
||||
}
|
||||
if (plist[i]->get_pos() == pos)
|
||||
return i;
|
||||
|
||||
return ret;
|
||||
return plist.size();
|
||||
}
|
||||
|
Reference in New Issue
Block a user