forked from Mirrorlandia_minetest/minetest
Drop less performant Server::setBlockNotSent for ClientInterface::markBlockposAsNotSent
This commit is contained in:
parent
b592c52f1c
commit
6036f865cb
@ -648,6 +648,15 @@ std::vector<session_t> ClientInterface::getClientIDs(ClientState min_state)
|
|||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClientInterface::markBlockposAsNotSent(const v3s16 &pos)
|
||||||
|
{
|
||||||
|
MutexAutoLock clientslock(m_clients_mutex);
|
||||||
|
for (const auto &client : m_clients) {
|
||||||
|
if (client.second->getState() >= CS_Active)
|
||||||
|
client.second->SetBlockNotSent(pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify if user limit was reached.
|
* Verify if user limit was reached.
|
||||||
* User limit count all clients from HelloSent state (MT protocol user) to Active state
|
* User limit count all clients from HelloSent state (MT protocol user) to Active state
|
||||||
|
@ -431,6 +431,9 @@ public:
|
|||||||
/* get list of active client id's */
|
/* get list of active client id's */
|
||||||
std::vector<session_t> getClientIDs(ClientState min_state=CS_Active);
|
std::vector<session_t> getClientIDs(ClientState min_state=CS_Active);
|
||||||
|
|
||||||
|
/* mark block as not sent to active client sessions */
|
||||||
|
void markBlockposAsNotSent(const v3s16 &pos);
|
||||||
|
|
||||||
/* verify is server user limit was reached */
|
/* verify is server user limit was reached */
|
||||||
bool isUserLimitReached();
|
bool isUserLimitReached();
|
||||||
|
|
||||||
|
@ -558,8 +558,7 @@ void Server::AsyncRunStep(bool initial_step)
|
|||||||
/*
|
/*
|
||||||
Set the modified blocks unsent for all the clients
|
Set the modified blocks unsent for all the clients
|
||||||
*/
|
*/
|
||||||
if(!modified_blocks.empty())
|
if (!modified_blocks.empty()) {
|
||||||
{
|
|
||||||
SetBlocksNotSent(modified_blocks);
|
SetBlocksNotSent(modified_blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -857,13 +856,13 @@ void Server::AsyncRunStep(bool initial_step)
|
|||||||
case MEET_BLOCK_NODE_METADATA_CHANGED:
|
case MEET_BLOCK_NODE_METADATA_CHANGED:
|
||||||
infostream << "Server: MEET_BLOCK_NODE_METADATA_CHANGED" << std::endl;
|
infostream << "Server: MEET_BLOCK_NODE_METADATA_CHANGED" << std::endl;
|
||||||
prof.add("MEET_BLOCK_NODE_METADATA_CHANGED", 1);
|
prof.add("MEET_BLOCK_NODE_METADATA_CHANGED", 1);
|
||||||
setBlockNotSent(event->p);
|
m_clients.markBlockposAsNotSent(event->p);
|
||||||
break;
|
break;
|
||||||
case MEET_OTHER:
|
case MEET_OTHER:
|
||||||
infostream << "Server: MEET_OTHER" << std::endl;
|
infostream << "Server: MEET_OTHER" << std::endl;
|
||||||
prof.add("MEET_OTHER", 1);
|
prof.add("MEET_OTHER", 1);
|
||||||
for (const v3s16 &modified_block : event->modified_blocks) {
|
for (const v3s16 &modified_block : event->modified_blocks) {
|
||||||
setBlockNotSent(modified_block);
|
m_clients.markBlockposAsNotSent(modified_block);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1262,7 +1261,7 @@ void Server::setInventoryModified(const InventoryLocation &loc, bool playerSend)
|
|||||||
if (block)
|
if (block)
|
||||||
block->raiseModified(MOD_STATE_WRITE_NEEDED);
|
block->raiseModified(MOD_STATE_WRITE_NEEDED);
|
||||||
|
|
||||||
setBlockNotSent(blockpos);
|
m_clients.markBlockposAsNotSent(blockpos);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InventoryLocation::DETACHED:
|
case InventoryLocation::DETACHED:
|
||||||
@ -2147,22 +2146,9 @@ void Server::sendAddNode(v3s16 p, MapNode n, u16 ignore_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Server::setBlockNotSent(v3s16 p)
|
|
||||||
{
|
|
||||||
std::vector<session_t> clients = m_clients.getClientIDs();
|
|
||||||
m_clients.lock();
|
|
||||||
for (const session_t i : clients) {
|
|
||||||
RemoteClient *client = m_clients.lockedGetClientNoEx(i);
|
|
||||||
client->SetBlockNotSent(p);
|
|
||||||
}
|
|
||||||
m_clients.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Server::SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver,
|
void Server::SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver,
|
||||||
u16 net_proto_version)
|
u16 net_proto_version)
|
||||||
{
|
{
|
||||||
v3s16 p = block->getPos();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Create a packet with the block in the right format
|
Create a packet with the block in the right format
|
||||||
*/
|
*/
|
||||||
@ -2174,7 +2160,7 @@ void Server::SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver,
|
|||||||
|
|
||||||
NetworkPacket pkt(TOCLIENT_BLOCKDATA, 2 + 2 + 2 + 2 + s.size(), peer_id);
|
NetworkPacket pkt(TOCLIENT_BLOCKDATA, 2 + 2 + 2 + 2 + s.size(), peer_id);
|
||||||
|
|
||||||
pkt << p;
|
pkt << block->getPos();
|
||||||
pkt.putRawString(s.c_str(), s.size());
|
pkt.putRawString(s.c_str(), s.size());
|
||||||
Send(&pkt);
|
Send(&pkt);
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,6 @@ private:
|
|||||||
void sendAddNode(v3s16 p, MapNode n, u16 ignore_id=0,
|
void sendAddNode(v3s16 p, MapNode n, u16 ignore_id=0,
|
||||||
std::vector<u16> *far_players=NULL, float far_d_nodes=100,
|
std::vector<u16> *far_players=NULL, float far_d_nodes=100,
|
||||||
bool remove_metadata=true);
|
bool remove_metadata=true);
|
||||||
void setBlockNotSent(v3s16 p);
|
|
||||||
|
|
||||||
// Environment and Connection must be locked when called
|
// Environment and Connection must be locked when called
|
||||||
void SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver, u16 net_proto_version);
|
void SendBlockNoLock(session_t peer_id, MapBlock *block, u8 ver, u16 net_proto_version);
|
||||||
|
Loading…
Reference in New Issue
Block a user