1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-11-21 17:05:20 +01:00

Revert part of 16013 - restore liquid updates to the client (#16663)

This reverts 00addc3e5d
Fixes: #16662
This commit is contained in:
lhofhansl
2025-11-11 11:10:49 -08:00
committed by GitHub
parent 760b20504f
commit 6ac8346c6d
5 changed files with 20 additions and 29 deletions

View File

@@ -46,9 +46,6 @@ struct MapEditEvent
MapNode n = CONTENT_AIR; MapNode n = CONTENT_AIR;
std::vector<v3s16> modified_blocks; // Represents a set std::vector<v3s16> modified_blocks; // Represents a set
bool is_private_change = false; bool is_private_change = false;
// Setting low_priority to true allows the server
// to send this change to clients with some delay.
bool low_priority = false;
MapEditEvent() = default; MapEditEvent() = default;

View File

@@ -765,7 +765,6 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
if (!modified_blocks.empty()) { if (!modified_blocks.empty()) {
MapEditEvent event; MapEditEvent event;
event.type = MEET_OTHER; event.type = MEET_OTHER;
event.low_priority = true;
event.setModifiedBlocks(modified_blocks); event.setModifiedBlocks(modified_blocks);
m_env->getMap().dispatchEvent(event); m_env->getMap().dispatchEvent(event);
} }
@@ -1023,7 +1022,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
} }
case MEET_OTHER: case MEET_OTHER:
prof.add("MEET_OTHER", 1); prof.add("MEET_OTHER", 1);
m_clients.markBlocksNotSent(event->modified_blocks, event->low_priority); m_clients.markBlocksNotSent(event->modified_blocks);
break; break;
default: default:
prof.add("unknown", 1); prof.add("unknown", 1);
@@ -1039,7 +1038,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
*/ */
for (const u16 far_player : far_players) { for (const u16 far_player : far_players) {
if (RemoteClient *client = getClient(far_player)) if (RemoteClient *client = getClient(far_player))
client->SetBlocksNotSent(event->modified_blocks, event->low_priority); client->SetBlocksNotSent(event->modified_blocks);
} }
delete event; delete event;

View File

@@ -426,34 +426,30 @@ void RemoteClient::SentBlock(v3s16 p)
" already in m_blocks_sending"<<std::endl; " already in m_blocks_sending"<<std::endl;
} }
void RemoteClient::SetBlockNotSent(v3s16 p, bool low_priority) void RemoteClient::SetBlockNotSent(v3s16 p)
{ {
m_nothing_to_send_pause_timer = 0; m_nothing_to_send_pause_timer = 0;
// remove the block from sending and sent sets, // remove the block from sending and sent sets,
// and reset the scan loop if found // and reset the scan loop if found
if (m_blocks_sending.erase(p) + m_blocks_sent.erase(p) > 0) { if (m_blocks_sending.erase(p) + m_blocks_sent.erase(p) > 0) {
// If this is a low priority event, do not reset m_nearest_unsent_d. // Note that we do NOT use the euclidean distance here.
// Instead, the send loop will get to the block in the next full loop iteration. // getNextBlocks builds successive cube-surfaces in the send loop.
if (!low_priority) { // This resets the distance to the maximum cube size that
// Note that we do NOT use the euclidean distance here. // still guarantees that this block will be scanned again right away.
// getNextBlocks builds successive cube-surfaces in the send loop. //
// This resets the distance to the maximum cube size that // Using m_last_center is OK, as a change in center
// still guarantees that this block will be scanned again right away. // will reset m_nearest_unsent_d to 0 anyway (see getNextBlocks).
// p -= m_last_center;
// Using m_last_center is OK, as a change in center s16 this_d = std::max({std::abs(p.X), std::abs(p.Y), std::abs(p.Z)});
// will reset m_nearest_unsent_d to 0 anyway (see getNextBlocks). m_nearest_unsent_d = std::min(m_nearest_unsent_d, this_d);
p -= m_last_center;
s16 this_d = std::max({std::abs(p.X), std::abs(p.Y), std::abs(p.Z)});
m_nearest_unsent_d = std::min(m_nearest_unsent_d, this_d);
}
} }
} }
void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks, bool low_priority) void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks)
{ {
for (v3s16 p : blocks) { for (v3s16 p : blocks) {
SetBlockNotSent(p, low_priority); SetBlockNotSent(p);
} }
} }
@@ -677,12 +673,12 @@ std::vector<session_t> ClientInterface::getClientIDs(ClientState min_state)
return reply; return reply;
} }
void ClientInterface::markBlocksNotSent(const std::vector<v3s16> &positions, bool low_priority) void ClientInterface::markBlocksNotSent(const std::vector<v3s16> &positions)
{ {
RecursiveMutexAutoLock clientslock(m_clients_mutex); RecursiveMutexAutoLock clientslock(m_clients_mutex);
for (const auto &client : m_clients) { for (const auto &client : m_clients) {
if (client.second->getState() >= CS_Active) if (client.second->getState() >= CS_Active)
client.second->SetBlocksNotSent(positions, low_priority); client.second->SetBlocksNotSent(positions);
} }
} }

View File

@@ -250,8 +250,8 @@ public:
void SentBlock(v3s16 p); void SentBlock(v3s16 p);
void SetBlockNotSent(v3s16 p, bool low_priority = false); void SetBlockNotSent(v3s16 p);
void SetBlocksNotSent(const std::vector<v3s16> &blocks, bool low_priority = false); void SetBlocksNotSent(const std::vector<v3s16> &blocks);
/** /**
* tell client about this block being modified right now. * tell client about this block being modified right now.
@@ -442,7 +442,7 @@ public:
std::vector<session_t> getClientIDs(ClientState min_state=CS_Active); std::vector<session_t> getClientIDs(ClientState min_state=CS_Active);
/* mark blocks as not sent on all active clients */ /* mark blocks as not sent on all active clients */
void markBlocksNotSent(const std::vector<v3s16> &positions, bool low_priority = false); void markBlocksNotSent(const std::vector<v3s16> &positions);
/* verify if server user limit was reached */ /* verify if server user limit was reached */
bool isUserLimitReached(); bool isUserLimitReached();

View File

@@ -774,7 +774,6 @@ MapBlock *ServerMap::loadBlock(const std::string &blob, v3s16 p3d, bool save_aft
if (!modified_blocks.empty()) { if (!modified_blocks.empty()) {
MapEditEvent event; MapEditEvent event;
event.type = MEET_OTHER; event.type = MEET_OTHER;
event.low_priority = true;
event.setModifiedBlocks(modified_blocks); event.setModifiedBlocks(modified_blocks);
dispatchEvent(event); dispatchEvent(event);
} }