Skip to content

Commit

Permalink
Fix >5 year old PlayerSAO deletion bug
Browse files Browse the repository at this point in the history
force_delete=true is usually set at shutdown in order to
also remove PlayerSAOs, however when too many objects
per block are detected force_delete is also set to true.
This was intended only for the current loop iteration but
obviously persisted to the next iterations thereby
deleting all other remaining SAOs.
  • Loading branch information
sfan5 committed Feb 15, 2017
1 parent eb49009 commit a5e4273
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/serverenvironment.cpp
Expand Up @@ -1941,11 +1941,14 @@ void ServerEnvironment::activateObjects(MapBlock *block, u32 dtime_s)
If block wasn't generated (not in memory or on disk),
*/
void ServerEnvironment::deactivateFarObjects(bool force_delete)
void ServerEnvironment::deactivateFarObjects(bool _force_delete)
{
std::vector<u16> objects_to_remove;
for(ActiveObjectMap::iterator i = m_active_objects.begin();
i != m_active_objects.end(); ++i) {
// force_delete might be overriden per object
bool force_delete = _force_delete;

ServerActiveObject* obj = i->second;
assert(obj);

Expand Down Expand Up @@ -2147,13 +2150,6 @@ void ServerEnvironment::deactivateFarObjects(bool force_delete)
continue;
}

if (!force_delete && obj->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
warningstream << "ServerEnvironment::deactivateFarObjects(): "
<< "Trying to delete player object, THIS SHOULD NEVER HAPPEN!"
<< std::endl;
continue;
}

verbosestream<<"ServerEnvironment::deactivateFarObjects(): "
<<"object id="<<id<<" is not known by clients"
<<"; deleting"<<std::endl;
Expand Down

0 comments on commit a5e4273

Please sign in to comment.