mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
This reverts functional changes of: * commitbf52d1e6
(#14436) * commit63a98538
(#14341)
This commit is contained in:
parent
2ba1d60ba5
commit
26deb26f17
4 changed files with 6 additions and 61 deletions
|
@ -2054,19 +2054,10 @@ void Server::SendActiveObjectRemoveAdd(RemoteClient *client, PlayerSAO *playersa
|
|||
// Removed objects
|
||||
pkt << static_cast<u16>(removed_objects.size());
|
||||
|
||||
std::vector<u16> sounds_to_stop;
|
||||
|
||||
for (auto &it : removed_objects) {
|
||||
const auto [gone, id] = it;
|
||||
ServerActiveObject *obj = m_env->getActiveObject(id);
|
||||
|
||||
// Stop sounds if objects go out of range.
|
||||
// This fixes https://github.com/minetest/minetest/issues/8094.
|
||||
// We may not remove sounds if an entity was removed on the server.
|
||||
// See https://github.com/minetest/minetest/issues/14422.
|
||||
if (!gone) // just out of range for client, not gone on server?
|
||||
sounds_to_stop.push_back(id);
|
||||
|
||||
pkt << id;
|
||||
|
||||
// Remove from known objects
|
||||
|
@ -2075,8 +2066,10 @@ void Server::SendActiveObjectRemoveAdd(RemoteClient *client, PlayerSAO *playersa
|
|||
obj->m_known_by_count--;
|
||||
}
|
||||
|
||||
if (!sounds_to_stop.empty())
|
||||
stopAttachedSounds(client->peer_id, sounds_to_stop);
|
||||
// Note: Do yet NOT stop or remove object-attached sounds where the object goes out
|
||||
// of range (client side). Such sounds would need to be re-sent when coming into range.
|
||||
// Currently, the client will initiate m_playing_sounds clean ups indirectly by
|
||||
// "Server::handleCommand_RemovedSounds".
|
||||
|
||||
// Added objects
|
||||
pkt << static_cast<u16>(added_objects.size());
|
||||
|
@ -2260,37 +2253,6 @@ void Server::fadeSound(s32 handle, float step, float gain)
|
|||
m_playing_sounds.erase(it);
|
||||
}
|
||||
|
||||
void Server::stopAttachedSounds(session_t peer_id,
|
||||
const std::vector<u16> &object_ids)
|
||||
{
|
||||
assert(peer_id != PEER_ID_INEXISTENT);
|
||||
assert(!object_ids.empty());
|
||||
|
||||
auto cb = [&] (const s32 id, ServerPlayingSound &sound) -> bool {
|
||||
if (!CONTAINS(object_ids, sound.object))
|
||||
return false;
|
||||
|
||||
auto clients_it = sound.clients.find(peer_id);
|
||||
if (clients_it == sound.clients.end())
|
||||
return false;
|
||||
|
||||
NetworkPacket pkt(TOCLIENT_STOP_SOUND, 4);
|
||||
pkt << id;
|
||||
Send(peer_id, &pkt);
|
||||
|
||||
sound.clients.erase(clients_it);
|
||||
// delete if client list empty
|
||||
return sound.clients.empty();
|
||||
};
|
||||
|
||||
for (auto it = m_playing_sounds.begin(); it != m_playing_sounds.end(); ) {
|
||||
if (cb(it->first, it->second))
|
||||
it = m_playing_sounds.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void Server::sendRemoveNode(v3s16 p, std::unordered_set<u16> *far_players,
|
||||
float far_d_nodes)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue