forked from Mirrorlandia_minetest/minetest
Remove attached sounds when the active object is removed (#14341)
This commit is contained in:
parent
39b1311a1b
commit
63a9853811
@ -2123,3 +2123,11 @@ const std::string &Client::getFormspecPrepend() const
|
|||||||
{
|
{
|
||||||
return m_env.getLocalPlayer()->formspec_prepend;
|
return m_env.getLocalPlayer()->formspec_prepend;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::removeActiveObjectSounds(u16 id)
|
||||||
|
{
|
||||||
|
for (auto it : m_sounds_to_objects) {
|
||||||
|
if (it.second == id)
|
||||||
|
m_sound->stopSound(it.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -471,6 +471,9 @@ private:
|
|||||||
|
|
||||||
bool canSendChatMessage() const;
|
bool canSendChatMessage() const;
|
||||||
|
|
||||||
|
// remove sounds attached to object
|
||||||
|
void removeActiveObjectSounds(u16 id);
|
||||||
|
|
||||||
float m_packetcounter_timer = 0.0f;
|
float m_packetcounter_timer = 0.0f;
|
||||||
float m_connection_reinit_timer = 0.1f;
|
float m_connection_reinit_timer = 0.1f;
|
||||||
float m_avg_rtt_timer = 0.0f;
|
float m_avg_rtt_timer = 0.0f;
|
||||||
|
@ -471,6 +471,7 @@ void Client::handleCommand_ActiveObjectRemoveAdd(NetworkPacket* pkt)
|
|||||||
for (u16 i = 0; i < removed_count; i++) {
|
for (u16 i = 0; i < removed_count; i++) {
|
||||||
*pkt >> id;
|
*pkt >> id;
|
||||||
m_env.removeActiveObject(id);
|
m_env.removeActiveObject(id);
|
||||||
|
removeActiveObjectSounds(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read added objects
|
// Read added objects
|
||||||
|
@ -2264,6 +2264,22 @@ void Server::fadeSound(s32 handle, float step, float gain)
|
|||||||
m_playing_sounds.erase(it);
|
m_playing_sounds.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Server::stopAttachedSounds(u16 id)
|
||||||
|
{
|
||||||
|
assert(id);
|
||||||
|
|
||||||
|
for (auto it = m_playing_sounds.begin(); it != m_playing_sounds.end(); ) {
|
||||||
|
const ServerPlayingSound &sound = it->second;
|
||||||
|
|
||||||
|
if (sound.object == id) {
|
||||||
|
// Remove sound reference
|
||||||
|
it = m_playing_sounds.erase(it);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Server::sendRemoveNode(v3s16 p, std::unordered_set<u16> *far_players,
|
void Server::sendRemoveNode(v3s16 p, std::unordered_set<u16> *far_players,
|
||||||
float far_d_nodes)
|
float far_d_nodes)
|
||||||
{
|
{
|
||||||
|
@ -239,6 +239,7 @@ public:
|
|||||||
s32 playSound(ServerPlayingSound ¶ms, bool ephemeral=false);
|
s32 playSound(ServerPlayingSound ¶ms, bool ephemeral=false);
|
||||||
void stopSound(s32 handle);
|
void stopSound(s32 handle);
|
||||||
void fadeSound(s32 handle, float step, float gain);
|
void fadeSound(s32 handle, float step, float gain);
|
||||||
|
void stopAttachedSounds(u16 id);
|
||||||
|
|
||||||
// Envlock
|
// Envlock
|
||||||
std::set<std::string> getPlayerEffectivePrivs(const std::string &name);
|
std::set<std::string> getPlayerEffectivePrivs(const std::string &name);
|
||||||
|
@ -1253,10 +1253,7 @@ void ServerEnvironment::clearObjects(ClearObjectsMode mode)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the object about removal
|
processActiveObjectRemove(obj, id);
|
||||||
obj->removingFromEnvironment();
|
|
||||||
// Deregister in scripting api
|
|
||||||
m_script->removeObjectReference(obj);
|
|
||||||
|
|
||||||
// Delete active object
|
// Delete active object
|
||||||
return true;
|
return true;
|
||||||
@ -1976,10 +1973,7 @@ void ServerEnvironment::removeRemovedObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the object about removal
|
processActiveObjectRemove(obj, id);
|
||||||
obj->removingFromEnvironment();
|
|
||||||
// Deregister in scripting api
|
|
||||||
m_script->removeObjectReference(obj);
|
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
return true;
|
return true;
|
||||||
@ -2216,10 +2210,7 @@ void ServerEnvironment::deactivateFarObjects(bool _force_delete)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the object about removal
|
processActiveObjectRemove(obj, id);
|
||||||
obj->removingFromEnvironment();
|
|
||||||
// Deregister in scripting api
|
|
||||||
m_script->removeObjectReference(obj);
|
|
||||||
|
|
||||||
// Delete active object
|
// Delete active object
|
||||||
return true;
|
return true;
|
||||||
@ -2282,6 +2273,16 @@ bool ServerEnvironment::saveStaticToBlock(
|
|||||||
return true;
|
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,
|
PlayerDatabase *ServerEnvironment::openPlayerDatabase(const std::string &name,
|
||||||
const std::string &savedir, const Settings &conf)
|
const std::string &savedir, const Settings &conf)
|
||||||
{
|
{
|
||||||
|
@ -454,6 +454,8 @@ private:
|
|||||||
bool saveStaticToBlock(v3s16 blockpos, u16 store_id,
|
bool saveStaticToBlock(v3s16 blockpos, u16 store_id,
|
||||||
ServerActiveObject *obj, const StaticObject &s_obj, u32 mod_reason);
|
ServerActiveObject *obj, const StaticObject &s_obj, u32 mod_reason);
|
||||||
|
|
||||||
|
void processActiveObjectRemove(ServerActiveObject *obj, u16 id);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Member variables
|
Member variables
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user