Move count to checkpoint manager

This commit is contained in:
Ashnal 2025-04-26 18:57:35 -04:00
parent 18d33e8589
commit 1366f43ddd
2 changed files with 5 additions and 8 deletions

View file

@ -37,7 +37,6 @@ struct MobjList
{
ptr->next(front());
front(ptr);
count_++;
}
void erase(T* node)
@ -46,7 +45,6 @@ struct MobjList
{
front(node->next());
node->next(nullptr);
count_--;
return;
}
@ -71,7 +69,6 @@ struct MobjList
{
prev->next(node->next());
node->next(nullptr);
count_--;
break;
}
}
@ -88,12 +85,9 @@ struct MobjList
auto begin() const { return view().begin(); }
auto end() const { return view().end(); }
auto count() { return count_; }
private:
void front(T* ptr) { Mobj::ManagedPtr {Head} = ptr; }
auto view() const { return MobjListView(front(), [](T* node) { return node->next(); }); }
UINT32 count_ = 0;
};
}; // namespace srb2

View file

@ -497,6 +497,7 @@ struct CheckpointManager
if (chk->linetag())
lines_.try_emplace(chk->linetag(), std::move(tagged_lines(chk->linetag())));
list_.push_front(chk);
count_ += 1; // Mobjlist can't have a count on it, so we keep it here
}
chk->gingerbread();
@ -505,10 +506,11 @@ struct CheckpointManager
void clear()
{
lines_.clear();
list_.clear();
list_.clear();
count_ = 0;
}
auto count() { return list_.count(); }
auto count() { return count_; }
const srb2::Vector<line_t*>* lines_for(const Checkpoint* chk) const
{
@ -517,6 +519,7 @@ struct CheckpointManager
}
private:
INT32 count_;
srb2::MobjList<Checkpoint, svg_checkpoints> list_;
srb2::HashMap<INT32, srb2::Vector<line_t*>> lines_;