Skip to content

Commit

Permalink
Extend sanity checks in ActiveBlockList::update
Browse files Browse the repository at this point in the history
also fixes the space indentation
  • Loading branch information
sfan5 committed Dec 29, 2023
1 parent c99196d commit 431444b
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/serverenvironment.cpp
Expand Up @@ -394,19 +394,23 @@ void ActiveBlockList::update(std::vector<PlayerSAO*> &active_players,
std::inserter(blocks_removed, blocks_removed.end()));

/*
Some sanity checks
*/
Do some least-effort sanity checks to hopefully catch code bugs.
*/
assert(newlist.size() >= extralist.size());
assert(blocks_removed.size() <= m_list.size());
if (!blocks_added.empty())
assert(newlist.count(*blocks_added.begin()) > 0);
if (!blocks_added.empty()) {
assert(newlist.count(*blocks_added.begin()) > 0);
assert(blocks_removed.count(*blocks_added.begin()) == 0);
}
if (!extra_blocks_added.empty()) {
assert(newlist.count(*extra_blocks_added.begin()) > 0);
assert(blocks_added.count(*extra_blocks_added.begin()) == 0);
assert(newlist.count(*extra_blocks_added.begin()) > 0);
assert(extralist.count(*extra_blocks_added.begin()) > 0);
assert(blocks_added.count(*extra_blocks_added.begin()) == 0);
}
if (!blocks_removed.empty()) {
assert(newlist.count(*blocks_removed.begin()) == 0);
assert(m_list.count(*blocks_removed.begin()) > 0);
assert(newlist.count(*blocks_removed.begin()) == 0);
assert(extralist.count(*blocks_removed.begin()) == 0);
assert(m_list.count(*blocks_removed.begin()) > 0);
}

/*
Expand Down

0 comments on commit 431444b

Please sign in to comment.