mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Mark liquid and light updates low priority
This commit is contained in:
parent
2a3427a39c
commit
00addc3e5d
5 changed files with 29 additions and 20 deletions
|
@ -47,6 +47,9 @@ 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;
|
||||||
|
|
||||||
|
|
|
@ -755,6 +755,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
@ -1006,7 +1007,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);
|
m_clients.markBlocksNotSent(event->modified_blocks, event->low_priority);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
prof.add("unknown", 1);
|
prof.add("unknown", 1);
|
||||||
|
@ -1022,7 +1023,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);
|
client->SetBlocksNotSent(event->modified_blocks, event->low_priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete event;
|
delete event;
|
||||||
|
|
|
@ -422,13 +422,16 @@ void RemoteClient::SentBlock(v3s16 p)
|
||||||
" already in m_blocks_sending"<<std::endl;
|
" already in m_blocks_sending"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteClient::SetBlockNotSent(v3s16 p)
|
void RemoteClient::SetBlockNotSent(v3s16 p, bool low_priority)
|
||||||
{
|
{
|
||||||
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.
|
||||||
|
// Instead, the send loop will get to the block in the next full loop iteration.
|
||||||
|
if (!low_priority) {
|
||||||
// Note that we do NOT use the euclidean distance here.
|
// Note that we do NOT use the euclidean distance here.
|
||||||
// getNextBlocks builds successive cube-surfaces in the send loop.
|
// getNextBlocks builds successive cube-surfaces in the send loop.
|
||||||
// This resets the distance to the maximum cube size that
|
// This resets the distance to the maximum cube size that
|
||||||
|
@ -440,12 +443,13 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
|
||||||
s16 this_d = std::max({std::abs(p.X), std::abs(p.Y), std::abs(p.Z)});
|
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);
|
m_nearest_unsent_d = std::min(m_nearest_unsent_d, this_d);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks)
|
void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks, bool low_priority)
|
||||||
{
|
{
|
||||||
for (v3s16 p : blocks) {
|
for (v3s16 p : blocks) {
|
||||||
SetBlockNotSent(p);
|
SetBlockNotSent(p, low_priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,12 +668,12 @@ std::vector<session_t> ClientInterface::getClientIDs(ClientState min_state)
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientInterface::markBlocksNotSent(const std::vector<v3s16> &positions)
|
void ClientInterface::markBlocksNotSent(const std::vector<v3s16> &positions, bool low_priority)
|
||||||
{
|
{
|
||||||
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);
|
client.second->SetBlocksNotSent(positions, low_priority);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,8 +251,8 @@ public:
|
||||||
|
|
||||||
void SentBlock(v3s16 p);
|
void SentBlock(v3s16 p);
|
||||||
|
|
||||||
void SetBlockNotSent(v3s16 p);
|
void SetBlockNotSent(v3s16 p, bool low_priority = false);
|
||||||
void SetBlocksNotSent(const std::vector<v3s16> &blocks);
|
void SetBlocksNotSent(const std::vector<v3s16> &blocks, bool low_priority = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tell client about this block being modified right now.
|
* tell client about this block being modified right now.
|
||||||
|
@ -443,7 +443,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);
|
void markBlocksNotSent(const std::vector<v3s16> &positions, bool low_priority = false);
|
||||||
|
|
||||||
/* verify is server user limit was reached */
|
/* verify is server user limit was reached */
|
||||||
bool isUserLimitReached();
|
bool isUserLimitReached();
|
||||||
|
|
|
@ -714,6 +714,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue