1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-13 08:35:20 +02:00

Remove attached sounds when the active object is removed (#14341)

This commit is contained in:
sfence
2024-02-25 23:10:39 +01:00
committed by GitHub
parent 39b1311a1b
commit 63a9853811
7 changed files with 44 additions and 12 deletions

View File

@@ -1253,10 +1253,7 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
return false;
}
// Tell the object about removal
obj->removingFromEnvironment();
// Deregister in scripting api
m_script->removeObjectReference(obj);
processActiveObjectRemove(obj, id);
// Delete active object
return true;
@@ -1976,10 +1973,7 @@ void ServerEnvironment::removeRemovedObjects()
}
}
// Tell the object about removal
obj->removingFromEnvironment();
// Deregister in scripting api
m_script->removeObjectReference(obj);
processActiveObjectRemove(obj, id);
// Delete
return true;
@@ -2216,10 +2210,7 @@ void ServerEnvironment::deactivateFarObjects(bool _force_delete)
return false;
}
// Tell the object about removal
obj->removingFromEnvironment();
// Deregister in scripting api
m_script->removeObjectReference(obj);
processActiveObjectRemove(obj, id);
// Delete active object
return true;
@@ -2282,6 +2273,16 @@ bool ServerEnvironment::saveStaticToBlock(
return true;
}
void ServerEnvironment::processActiveObjectRemove(ServerActiveObject *obj, u16 id)
{
// Tell the object about removal
obj->removingFromEnvironment();
// Deregister in scripting api
m_script->removeObjectReference(obj);
// stop attached sounds
m_server->stopAttachedSounds(id);
}
PlayerDatabase *ServerEnvironment::openPlayerDatabase(const std::string &name,
const std::string &savedir, const Settings &conf)
{