mirror of
https://github.com/glest/glest-source.git
synced 2025-08-27 09:54:26 +02:00
- attempt to fix crash on windows when server exits game
This commit is contained in:
@@ -154,41 +154,54 @@ void ClientInterface::update() {
|
|||||||
Chrono chrono;
|
Chrono chrono;
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
||||||
|
|
||||||
NetworkMessageCommandList networkMessageCommandList(currentFrameCount);
|
try {
|
||||||
|
NetworkMessageCommandList networkMessageCommandList(currentFrameCount);
|
||||||
|
|
||||||
//send as many commands as we can
|
//send as many commands as we can
|
||||||
while(requestedCommands.empty() == false) {
|
while(requestedCommands.empty() == false) {
|
||||||
if(networkMessageCommandList.addCommand(&requestedCommands.back())) {
|
if(networkMessageCommandList.addCommand(&requestedCommands.back())) {
|
||||||
requestedCommands.pop_back();
|
requestedCommands.pop_back();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
double lastSendElapsed = difftime((long int)time(NULL),lastNetworkCommandListSendTime);
|
double lastSendElapsed = difftime((long int)time(NULL),lastNetworkCommandListSendTime);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
|
|
||||||
if(networkMessageCommandList.getCommandCount() > 0 ||
|
|
||||||
(lastNetworkCommandListSendTime > 0 && lastSendElapsed >= ClientInterface::maxNetworkCommandListSendTimeWait)) {
|
|
||||||
lastNetworkCommandListSendTime = time(NULL);
|
|
||||||
sendMessage(&networkMessageCommandList);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
|
if(networkMessageCommandList.getCommandCount() > 0 ||
|
||||||
|
(lastNetworkCommandListSendTime > 0 && lastSendElapsed >= ClientInterface::maxNetworkCommandListSendTimeWait)) {
|
||||||
|
lastNetworkCommandListSendTime = time(NULL);
|
||||||
|
sendMessage(&networkMessageCommandList);
|
||||||
|
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Possible cause of out of synch since we have more commands that need
|
||||||
|
// to be sent in this frame
|
||||||
|
if(requestedCommands.empty() == false) {
|
||||||
|
//char szBuf[4096]="";
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,requestedCommands.size());
|
||||||
|
|
||||||
|
string sMsg = "may go out of synch: client requestedCommands.size() = " + intToStr(requestedCommands.size());
|
||||||
|
sendTextMessage(sMsg,-1, true,"");
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch(const megaglest_runtime_error &ex) {
|
||||||
|
if(this->isConnected() == false) {
|
||||||
|
string sErr = string(extractFileFromDirectoryPath(__FILE__).c_str()) + "::" + string(__FUNCTION__) + " network error: " + string(ex.what());
|
||||||
|
|
||||||
// Possible cause of out of synch since we have more commands that need
|
DisplayErrorMessage(sErr);
|
||||||
// to be sent in this frame
|
quit= true;
|
||||||
if(requestedCommands.empty() == false) {
|
}
|
||||||
//char szBuf[4096]="";
|
else {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] WARNING / ERROR, requestedCommands.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,requestedCommands.size());
|
throw megaglest_runtime_error(ex.what());
|
||||||
|
}
|
||||||
string sMsg = "may go out of synch: client requestedCommands.size() = " + intToStr(requestedCommands.size());
|
|
||||||
sendTextMessage(sMsg,-1, true,"");
|
|
||||||
sleep(1);
|
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
Reference in New Issue
Block a user