mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Some RemoteClient improvements
* Simplications * Remove RemoteClient::m_blocks_modified * Remove unneeded nearest_emergefull_d
This commit is contained in:
parent
0cf1c47f6c
commit
99150fadd1
2 changed files with 14 additions and 49 deletions
|
@ -195,13 +195,6 @@ void RemoteClient::GetNextBlocks (
|
||||||
m_last_camera_dir = camera_dir;
|
m_last_camera_dir = camera_dir;
|
||||||
m_map_send_completion_timer = 0.0f;
|
m_map_send_completion_timer = 0.0f;
|
||||||
}
|
}
|
||||||
if (m_nearest_unsent_d > 0) {
|
|
||||||
// make sure any blocks modified since the last time we sent blocks are resent
|
|
||||||
for (const v3s16 &p : m_blocks_modified) {
|
|
||||||
m_nearest_unsent_d = std::min(m_nearest_unsent_d, center.getDistanceFrom(p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_blocks_modified.clear();
|
|
||||||
|
|
||||||
s16 d_start = m_nearest_unsent_d;
|
s16 d_start = m_nearest_unsent_d;
|
||||||
|
|
||||||
|
@ -241,7 +234,6 @@ void RemoteClient::GetNextBlocks (
|
||||||
camera_fov = camera_fov / (1 + dot / 300.0f);
|
camera_fov = camera_fov / (1 + dot / 300.0f);
|
||||||
|
|
||||||
s32 nearest_emerged_d = -1;
|
s32 nearest_emerged_d = -1;
|
||||||
s32 nearest_emergefull_d = -1;
|
|
||||||
s32 nearest_sent_d = -1;
|
s32 nearest_sent_d = -1;
|
||||||
//bool queue_is_full = false;
|
//bool queue_is_full = false;
|
||||||
|
|
||||||
|
@ -364,17 +356,12 @@ void RemoteClient::GetNextBlocks (
|
||||||
Add inexistent block to emerge queue.
|
Add inexistent block to emerge queue.
|
||||||
*/
|
*/
|
||||||
if (want_emerge) {
|
if (want_emerge) {
|
||||||
if (emerge->enqueueBlockEmerge(peer_id, p, generate)) {
|
if (nearest_emerged_d == -1)
|
||||||
if (nearest_emerged_d == -1)
|
nearest_emerged_d = d;
|
||||||
nearest_emerged_d = d;
|
if (emerge->enqueueBlockEmerge(peer_id, p, generate))
|
||||||
} else {
|
continue;
|
||||||
if (nearest_emergefull_d == -1)
|
else
|
||||||
nearest_emergefull_d = d;
|
|
||||||
goto queue_full_break;
|
goto queue_full_break;
|
||||||
}
|
|
||||||
|
|
||||||
// get next one.
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nearest_sent_d == -1)
|
if (nearest_sent_d == -1)
|
||||||
|
@ -383,9 +370,7 @@ void RemoteClient::GetNextBlocks (
|
||||||
/*
|
/*
|
||||||
Add block to send queue
|
Add block to send queue
|
||||||
*/
|
*/
|
||||||
PrioritySortedBlockTransfer q((float)dist, p, peer_id);
|
dest.emplace_back((float)dist, p, peer_id);
|
||||||
|
|
||||||
dest.push_back(q);
|
|
||||||
|
|
||||||
num_blocks_selected += 1;
|
num_blocks_selected += 1;
|
||||||
}
|
}
|
||||||
|
@ -396,8 +381,6 @@ queue_full_break:
|
||||||
// emerging, continue next time browsing from here
|
// emerging, continue next time browsing from here
|
||||||
if (nearest_emerged_d != -1) {
|
if (nearest_emerged_d != -1) {
|
||||||
new_nearest_unsent_d = nearest_emerged_d;
|
new_nearest_unsent_d = nearest_emerged_d;
|
||||||
} else if (nearest_emergefull_d != -1) {
|
|
||||||
new_nearest_unsent_d = nearest_emergefull_d;
|
|
||||||
} else {
|
} else {
|
||||||
if (d > full_d_max) {
|
if (d > full_d_max) {
|
||||||
new_nearest_unsent_d = 0;
|
new_nearest_unsent_d = 0;
|
||||||
|
@ -423,8 +406,7 @@ queue_full_break:
|
||||||
|
|
||||||
void RemoteClient::GotBlock(v3s16 p)
|
void RemoteClient::GotBlock(v3s16 p)
|
||||||
{
|
{
|
||||||
if (m_blocks_sending.find(p) != m_blocks_sending.end()) {
|
if (m_blocks_sending.erase(p) > 0) {
|
||||||
m_blocks_sending.erase(p);
|
|
||||||
// only add to sent blocks if it actually was sending
|
// only add to sent blocks if it actually was sending
|
||||||
// (it might have been modified since)
|
// (it might have been modified since)
|
||||||
m_blocks_sent.insert(p);
|
m_blocks_sent.insert(p);
|
||||||
|
@ -435,9 +417,7 @@ void RemoteClient::GotBlock(v3s16 p)
|
||||||
|
|
||||||
void RemoteClient::SentBlock(v3s16 p)
|
void RemoteClient::SentBlock(v3s16 p)
|
||||||
{
|
{
|
||||||
if (m_blocks_sending.find(p) == m_blocks_sending.end())
|
if (!m_blocks_sending.insert(p).second)
|
||||||
m_blocks_sending[p] = 0.0f;
|
|
||||||
else
|
|
||||||
infostream<<"RemoteClient::SentBlock(): Sent block"
|
infostream<<"RemoteClient::SentBlock(): Sent block"
|
||||||
" already in m_blocks_sending"<<std::endl;
|
" already in m_blocks_sending"<<std::endl;
|
||||||
}
|
}
|
||||||
|
@ -447,20 +427,16 @@ 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 mark as modified 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) {
|
||||||
m_blocks_modified.insert(p);
|
m_nearest_unsent_d = std::min(m_nearest_unsent_d, m_last_center.getDistanceFrom(p));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks)
|
void RemoteClient::SetBlocksNotSent(const std::vector<v3s16> &blocks)
|
||||||
{
|
{
|
||||||
m_nothing_to_send_pause_timer = 0;
|
|
||||||
|
|
||||||
for (v3s16 p : blocks) {
|
for (v3s16 p : blocks) {
|
||||||
// remove the block from sending and sent sets,
|
SetBlockNotSent(p);
|
||||||
// and mark as modified if found
|
|
||||||
if (m_blocks_sending.erase(p) + m_blocks_sent.erase(p) > 0)
|
|
||||||
m_blocks_modified.insert(p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -388,19 +388,8 @@ private:
|
||||||
- The size of this list is limited to some value
|
- The size of this list is limited to some value
|
||||||
Block is added when it is sent with BLOCKDATA.
|
Block is added when it is sent with BLOCKDATA.
|
||||||
Block is removed when GOTBLOCKS is received.
|
Block is removed when GOTBLOCKS is received.
|
||||||
Value is time from sending. (not used at the moment)
|
|
||||||
*/
|
*/
|
||||||
std::unordered_map<v3s16, float> m_blocks_sending;
|
std::unordered_set<v3s16> m_blocks_sending;
|
||||||
|
|
||||||
/*
|
|
||||||
Blocks that have been modified since blocks were
|
|
||||||
sent to the client last (getNextBlocks()).
|
|
||||||
This is used to reset the unsent distance, so that
|
|
||||||
modified blocks are resent to the client.
|
|
||||||
|
|
||||||
List of block positions.
|
|
||||||
*/
|
|
||||||
std::unordered_set<v3s16> m_blocks_modified;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Count of excess GotBlocks().
|
Count of excess GotBlocks().
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue