mirror of
https://github.com/glest/glest-source.git
synced 2025-10-01 01:46:42 +02:00
bugfix - proper client shutdown on sudden disconnect during game play
This commit is contained in:
@@ -152,8 +152,10 @@ void ClientInterfaceThread::execute() {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
if(clientInterface == NULL || clientInterface->getSocket(true) == NULL || clientInterface->getSocket(true)->isConnected() == true) {
|
||||||
throw megaglest_runtime_error(ex.what());
|
throw megaglest_runtime_error(ex.what());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
snprintf(szBuf,8096,"In [%s::%s %d] UNKNOWN error\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
@@ -225,7 +227,7 @@ void ClientInterface::shutdownNetworkCommandListThread(MutexSafeWrapper &safeMut
|
|||||||
Chrono chronoElapsed(true);
|
Chrono chronoElapsed(true);
|
||||||
for(;chronoElapsed.getMillis() <= 10000;) {
|
for(;chronoElapsed.getMillis() <= 10000;) {
|
||||||
safeMutexWrapper.Lock();
|
safeMutexWrapper.Lock();
|
||||||
if(networkCommandListThread->canShutdown(false) == false &&
|
if(networkCommandListThread != NULL && networkCommandListThread->canShutdown(false) == false &&
|
||||||
networkCommandListThread->getRunningStatus() == true) {
|
networkCommandListThread->getRunningStatus() == true) {
|
||||||
safeMutexWrapper.ReleaseLock(true);
|
safeMutexWrapper.ReleaseLock(true);
|
||||||
if(chronoElapsed.getMillis() % 1000 == 0) {
|
if(chronoElapsed.getMillis() % 1000 == 0) {
|
||||||
@@ -234,6 +236,7 @@ void ClientInterface::shutdownNetworkCommandListThread(MutexSafeWrapper &safeMut
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
safeMutexWrapper.ReleaseLock(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
//printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
||||||
@@ -243,12 +246,17 @@ void ClientInterface::shutdownNetworkCommandListThread(MutexSafeWrapper &safeMut
|
|||||||
//printf("A === shutdownNetworkCommandListThread\n");
|
//printf("A === shutdownNetworkCommandListThread\n");
|
||||||
|
|
||||||
//sleep(0);
|
//sleep(0);
|
||||||
if(networkCommandListThread->canShutdown(true)) {
|
safeMutexWrapper.Lock();
|
||||||
|
if(networkCommandListThread != NULL && networkCommandListThread->canShutdown(true)) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
delete networkCommandListThread;
|
delete networkCommandListThread;
|
||||||
networkCommandListThread = NULL;
|
networkCommandListThread = NULL;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
networkCommandListThread = NULL;
|
||||||
|
}
|
||||||
|
//safeMutexWrapper.ReleaseLock(true);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
||||||
//printf("END === shutdownNetworkCommandListThread\n");
|
//printf("END === shutdownNetworkCommandListThread\n");
|
||||||
@@ -300,8 +308,8 @@ ClientInterface::~ClientInterface() {
|
|||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
delete clientSocket;
|
//delete clientSocket;
|
||||||
clientSocket = NULL;
|
//clientSocket = NULL;
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("%s Line: %d\n",__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
@@ -1020,7 +1028,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
clientSimulationLagStartTime = time(NULL);
|
clientSimulationLagStartTime = time(NULL);
|
||||||
}
|
}
|
||||||
if(difftime((long int)time(NULL),clientSimulationLagStartTime) <= Config::getInstance().getInt("SimulateClientLagDurationSeconds","0")) {
|
if(difftime((long int)time(NULL),clientSimulationLagStartTime) <= Config::getInstance().getInt("SimulateClientLagDurationSeconds","0")) {
|
||||||
sleep(Config::getInstance().getInt("SimulateClientLag","0"));
|
sleep(simulateLag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// END: Test simulating lag for the client
|
// END: Test simulating lag for the client
|
||||||
@@ -1039,6 +1047,13 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
NetworkMessageCommandList networkMessageCommandList;
|
NetworkMessageCommandList networkMessageCommandList;
|
||||||
bool gotCmd = receiveMessage(&networkMessageCommandList);
|
bool gotCmd = receiveMessage(&networkMessageCommandList);
|
||||||
if(gotCmd == false) {
|
if(gotCmd == false) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error retrieving nmtCommandList returned false!\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
if(isConnected() == false) {
|
||||||
|
setQuit(true);
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
|
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1111,6 +1126,13 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
// }
|
// }
|
||||||
bool gotCmd = receiveMessage(&networkMessageQuit);
|
bool gotCmd = receiveMessage(&networkMessageQuit);
|
||||||
if(gotCmd == false) {
|
if(gotCmd == false) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error retrieving nmtQuit returned false!\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
if(isConnected() == false) {
|
||||||
|
setQuit(true);
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
|
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1125,6 +1147,13 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
NetworkMessageText networkMessageText;
|
NetworkMessageText networkMessageText;
|
||||||
bool gotCmd = receiveMessage(&networkMessageText);
|
bool gotCmd = receiveMessage(&networkMessageText);
|
||||||
if(gotCmd == false) {
|
if(gotCmd == false) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error retrieving nmtText returned false!\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
if(isConnected() == false) {
|
||||||
|
setQuit(true);
|
||||||
|
close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
throw megaglest_runtime_error("error retrieving nmtText returned false!");
|
throw megaglest_runtime_error("error retrieving nmtText returned false!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user