mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
moved a if block feeling good
This commit is contained in:
parent
e47821416a
commit
b825e5685b
@ -361,32 +361,6 @@ bool TNetwork::TCPSend(TClient& c, const std::string& Data, bool IsSync) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (!c.IsSyncing() && c.IsSynced() && c.MissedPacketQueueSize() != 0) {
|
|
||||||
debug("sending " + std::to_string(c.MissedPacketQueueSize()) + " queued packets");
|
|
||||||
while (c.MissedPacketQueueSize() > 0) {
|
|
||||||
std::string QData {};
|
|
||||||
{ // locked context
|
|
||||||
std::unique_lock lock(c.MissedPacketQueueMutex());
|
|
||||||
if (c.MissedPacketQueueSize() <= 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
QData = c.MissedPacketQueue().front();
|
|
||||||
c.MissedPacketQueue().pop();
|
|
||||||
} // end locked context
|
|
||||||
// debug("sending a missed packet: " + QData);
|
|
||||||
if (!TCPSend(c, QData, true)) {
|
|
||||||
if (c.GetStatus() > -1)
|
|
||||||
c.SetStatus(-1);
|
|
||||||
{
|
|
||||||
std::unique_lock lock(c.MissedPacketQueueMutex());
|
|
||||||
while(!c.MissedPacketQueue().empty()){
|
|
||||||
c.MissedPacketQueue().pop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CloseSocketProper(c.GetTCPSock());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,6 +501,33 @@ void TNetwork::TCPClient(const std::weak_ptr<TClient>& c) {
|
|||||||
debug("client status < 0, breaking client loop");
|
debug("client status < 0, breaking client loop");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!Client->IsSyncing() && Client->IsSynced() && Client->MissedPacketQueueSize() != 0) {
|
||||||
|
debug("sending " + std::to_string(Client->MissedPacketQueueSize()) + " queued packets");
|
||||||
|
while (Client->MissedPacketQueueSize() > 0) {
|
||||||
|
std::string QData {};
|
||||||
|
{ // locked context
|
||||||
|
std::unique_lock lock(Client->MissedPacketQueueMutex());
|
||||||
|
if (Client->MissedPacketQueueSize() <= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
QData = Client->MissedPacketQueue().front();
|
||||||
|
Client->MissedPacketQueue().pop();
|
||||||
|
} // end locked context
|
||||||
|
// debug("sending a missed packet: " + QData);
|
||||||
|
if (!TCPSend(*Client, QData, true)) {
|
||||||
|
if (Client->GetStatus() > -1)
|
||||||
|
Client->SetStatus(-1);
|
||||||
|
{
|
||||||
|
std::unique_lock lock(Client->MissedPacketQueueMutex());
|
||||||
|
while (!Client->MissedPacketQueue().empty()) {
|
||||||
|
Client->MissedPacketQueue().pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CloseSocketProper(Client->GetTCPSock());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
auto res = TCPRcv(*Client);
|
auto res = TCPRcv(*Client);
|
||||||
if (res == "") {
|
if (res == "") {
|
||||||
debug("TCPRcv error, break client loop");
|
debug("TCPRcv error, break client loop");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user