better managed ownership (two new functions in level.h)

This commit is contained in:
2024-07-16 23:36:31 -04:00
parent 3b164bbe9f
commit 3232d91ac1
14 changed files with 74 additions and 50 deletions

View File

@ -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();
}