mirror of
https://github.com/minetest/minetest.git
synced 2024-08-20 13:34:17 +02:00
Reduce some instances of useless data shuffling
This commit is contained in:
parent
362e4505e8
commit
731b84d725
@ -480,12 +480,11 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
|
||||
m_blocks_modified.insert(p);
|
||||
}
|
||||
|
||||
void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
|
||||
void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks)
|
||||
{
|
||||
m_nothing_to_send_pause_timer = 0;
|
||||
|
||||
for (auto &block : blocks) {
|
||||
v3s16 p = block.first;
|
||||
for (v3s16 p : blocks) {
|
||||
// remove the block from sending and sent sets,
|
||||
// and mark as modified if found
|
||||
if (m_blocks_sending.erase(p) + m_blocks_sent.erase(p) > 0)
|
||||
@ -707,12 +706,12 @@ std::vector<session_t> ClientInterface::getClientIDs(ClientState min_state)
|
||||
return reply;
|
||||
}
|
||||
|
||||
void ClientInterface::markBlockposAsNotSent(const v3s16 &pos)
|
||||
void ClientInterface::markBlocksNotSent(const std::vector<v3s16> &positions)
|
||||
{
|
||||
RecursiveMutexAutoLock clientslock(m_clients_mutex);
|
||||
for (const auto &client : m_clients) {
|
||||
if (client.second->getState() >= CS_Active)
|
||||
client.second->SetBlockNotSent(pos);
|
||||
client.second->SetBlocksNotSent(positions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -267,7 +267,7 @@ public:
|
||||
void SentBlock(v3s16 p);
|
||||
|
||||
void SetBlockNotSent(v3s16 p);
|
||||
void SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks);
|
||||
void SetBlocksNotSent(const std::vector<v3s16> &blocks);
|
||||
|
||||
/**
|
||||
* tell client about this block being modified right now.
|
||||
@ -473,8 +473,8 @@ public:
|
||||
/* get list of active client id's */
|
||||
std::vector<session_t> getClientIDs(ClientState min_state=CS_Active);
|
||||
|
||||
/* mark block as not sent to active client sessions */
|
||||
void markBlockposAsNotSent(const v3s16 &pos);
|
||||
/* mark blocks as not sent on all active clients */
|
||||
void markBlocksNotSent(const std::vector<v3s16> &positions);
|
||||
|
||||
/* verify is server user limit was reached */
|
||||
bool isUserLimitReached();
|
||||
|
@ -950,9 +950,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
||||
}
|
||||
case MEET_OTHER:
|
||||
prof.add("MEET_OTHER", 1);
|
||||
for (const v3s16 &modified_block : event->modified_blocks) {
|
||||
m_clients.markBlockposAsNotSent(modified_block);
|
||||
}
|
||||
m_clients.markBlocksNotSent(event->modified_blocks);
|
||||
break;
|
||||
default:
|
||||
prof.add("unknown", 1);
|
||||
@ -964,19 +962,9 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
|
||||
/*
|
||||
Set blocks not sent to far players
|
||||
*/
|
||||
if (!far_players.empty()) {
|
||||
// Convert list format to that wanted by SetBlocksNotSent
|
||||
std::map<v3s16, MapBlock*> modified_blocks2;
|
||||
for (const v3s16 &modified_block : event->modified_blocks) {
|
||||
modified_blocks2[modified_block] =
|
||||
m_env->getMap().getBlockNoCreateNoEx(modified_block);
|
||||
}
|
||||
|
||||
// Set blocks not sent
|
||||
for (const u16 far_player : far_players) {
|
||||
if (RemoteClient *client = getClient(far_player))
|
||||
client->SetBlocksNotSent(modified_blocks2);
|
||||
}
|
||||
client->SetBlocksNotSent(event->modified_blocks);
|
||||
}
|
||||
|
||||
delete event;
|
||||
|
Loading…
Reference in New Issue
Block a user