mirror of
https://github.com/glest/glest-source.git
synced 2025-10-04 19:31:32 +02:00
attempt to fix menu disconnect timeout issues
This commit is contained in:
@@ -663,7 +663,7 @@ void ClientInterface::updateLobby() {
|
|||||||
NetworkMessagePing networkMessagePing;
|
NetworkMessagePing networkMessagePing;
|
||||||
if(receiveMessage(&networkMessagePing)) {
|
if(receiveMessage(&networkMessagePing)) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
lastPingInfo = networkMessagePing;
|
this->setLastPingInfo(networkMessagePing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -675,6 +675,8 @@ void ClientInterface::updateLobby() {
|
|||||||
if(receiveMessage(&networkMessageSynchNetworkGameData)) {
|
if(receiveMessage(&networkMessageSynchNetworkGameData)) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageSynchNetworkGameData, getTechCRCFileCount() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageSynchNetworkGameData.getTechCRCFileCount());
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got NetworkMessageSynchNetworkGameData, getTechCRCFileCount() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,networkMessageSynchNetworkGameData.getTechCRCFileCount());
|
||||||
|
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
|
|
||||||
networkGameDataSynchCheckOkMap = false;
|
networkGameDataSynchCheckOkMap = false;
|
||||||
networkGameDataSynchCheckOkTile = false;
|
networkGameDataSynchCheckOkTile = false;
|
||||||
networkGameDataSynchCheckOkTech = false;
|
networkGameDataSynchCheckOkTech = false;
|
||||||
@@ -764,6 +766,8 @@ void ClientInterface::updateLobby() {
|
|||||||
NetworkMessageSynchNetworkGameDataFileCRCCheck networkMessageSynchNetworkGameDataFileCRCCheck;
|
NetworkMessageSynchNetworkGameDataFileCRCCheck networkMessageSynchNetworkGameDataFileCRCCheck;
|
||||||
if(receiveMessage(&networkMessageSynchNetworkGameDataFileCRCCheck))
|
if(receiveMessage(&networkMessageSynchNetworkGameDataFileCRCCheck))
|
||||||
{
|
{
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
|
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
string file = networkMessageSynchNetworkGameDataFileCRCCheck.getFileName();
|
string file = networkMessageSynchNetworkGameDataFileCRCCheck.getFileName();
|
||||||
checksum.addFile(file);
|
checksum.addFile(file);
|
||||||
@@ -809,6 +813,8 @@ void ClientInterface::updateLobby() {
|
|||||||
NetworkMessageText networkMessageText;
|
NetworkMessageText networkMessageText;
|
||||||
if(receiveMessage(&networkMessageText))
|
if(receiveMessage(&networkMessageText))
|
||||||
{
|
{
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtText\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtText\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
||||||
|
|
||||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
||||||
@@ -821,6 +827,7 @@ void ClientInterface::updateLobby() {
|
|||||||
{
|
{
|
||||||
NetworkMessageMarkCell networkMessageMarkCell;
|
NetworkMessageMarkCell networkMessageMarkCell;
|
||||||
if(receiveMessage(&networkMessageMarkCell)) {
|
if(receiveMessage(&networkMessageMarkCell)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtMarkCell\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtMarkCell\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
||||||
|
|
||||||
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
MarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||||
@@ -835,6 +842,7 @@ void ClientInterface::updateLobby() {
|
|||||||
{
|
{
|
||||||
NetworkMessageUnMarkCell networkMessageMarkCell;
|
NetworkMessageUnMarkCell networkMessageMarkCell;
|
||||||
if(receiveMessage(&networkMessageMarkCell)) {
|
if(receiveMessage(&networkMessageMarkCell)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtMarkCell\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtMarkCell\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
||||||
|
|
||||||
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
|
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||||
@@ -847,6 +855,7 @@ void ClientInterface::updateLobby() {
|
|||||||
{
|
{
|
||||||
NetworkMessageHighlightCell networkMessageHighlightCell;
|
NetworkMessageHighlightCell networkMessageHighlightCell;
|
||||||
if(receiveMessage(&networkMessageHighlightCell)) {
|
if(receiveMessage(&networkMessageHighlightCell)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtHighlightCell\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got nmtHighlightCell\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
|
||||||
|
|
||||||
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
MarkedCell msg(networkMessageHighlightCell.getTarget(),
|
||||||
@@ -864,6 +873,8 @@ void ClientInterface::updateLobby() {
|
|||||||
|
|
||||||
NetworkMessageLaunch networkMessageLaunch;
|
NetworkMessageLaunch networkMessageLaunch;
|
||||||
if(receiveMessage(&networkMessageLaunch)) {
|
if(receiveMessage(&networkMessageLaunch)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
|
|
||||||
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
@@ -919,6 +930,7 @@ void ClientInterface::updateLobby() {
|
|||||||
{
|
{
|
||||||
PlayerIndexMessage playerIndexMessage(-1);
|
PlayerIndexMessage playerIndexMessage(-1);
|
||||||
if(receiveMessage(&playerIndexMessage)) {
|
if(receiveMessage(&playerIndexMessage)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
playerIndex= playerIndexMessage.getPlayerIndex();
|
playerIndex= playerIndexMessage.getPlayerIndex();
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got nmtPlayerIndexMessage, playerIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] got nmtPlayerIndexMessage, playerIndex = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,playerIndex);
|
||||||
@@ -932,6 +944,7 @@ void ClientInterface::updateLobby() {
|
|||||||
{
|
{
|
||||||
NetworkMessageReady networkMessageReady;
|
NetworkMessageReady networkMessageReady;
|
||||||
if(receiveMessage(&networkMessageReady)) {
|
if(receiveMessage(&networkMessageReady)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
MutexSafeWrapper safeMutexFlags(flagAccessor,CODE_AT_LINE);
|
MutexSafeWrapper safeMutexFlags(flagAccessor,CODE_AT_LINE);
|
||||||
this->readyForInGameJoin = true;
|
this->readyForInGameJoin = true;
|
||||||
}
|
}
|
||||||
@@ -950,6 +963,7 @@ void ClientInterface::updateLobby() {
|
|||||||
if(gotCmd == false) {
|
if(gotCmd == false) {
|
||||||
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
|
throw megaglest_runtime_error("error retrieving nmtCommandList returned false!");
|
||||||
}
|
}
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -961,7 +975,7 @@ void ClientInterface::updateLobby() {
|
|||||||
if(gotCmd == false) {
|
if(gotCmd == false) {
|
||||||
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
|
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
|
||||||
}
|
}
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
setQuit(true);
|
setQuit(true);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -971,6 +985,7 @@ void ClientInterface::updateLobby() {
|
|||||||
{
|
{
|
||||||
NetworkMessageLoadingStatus networkMessageLoadingStatus(nmls_NONE);
|
NetworkMessageLoadingStatus networkMessageLoadingStatus(nmls_NONE);
|
||||||
if(receiveMessage(&networkMessageLoadingStatus)) {
|
if(receiveMessage(&networkMessageLoadingStatus)) {
|
||||||
|
this->setLastPingInfoToNow();
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1131,7 +1146,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
NetworkMessagePing networkMessagePing;
|
NetworkMessagePing networkMessagePing;
|
||||||
if(receiveMessage(&networkMessagePing)) {
|
if(receiveMessage(&networkMessagePing)) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
lastPingInfo = networkMessagePing;
|
this->setLastPingInfo(networkMessagePing);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) 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() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
@@ -1157,7 +1172,6 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
|
|
||||||
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
|
throw megaglest_runtime_error("error retrieving nmtQuit returned false!");
|
||||||
}
|
}
|
||||||
|
|
||||||
setQuit(true);
|
setQuit(true);
|
||||||
done= true;
|
done= true;
|
||||||
}
|
}
|
||||||
@@ -1178,7 +1192,6 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
|
|
||||||
throw megaglest_runtime_error("error retrieving nmtText returned false!");
|
throw megaglest_runtime_error("error retrieving nmtText returned false!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) 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() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
|
||||||
|
|
||||||
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
ChatMsgInfo msg(networkMessageText.getText().c_str(),networkMessageText.getTeamIndex(),networkMessageText.getPlayerIndex(),networkMessageText.getTargetLanguage());
|
||||||
@@ -1237,6 +1250,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
|
|||||||
|
|
||||||
NetworkMessageLaunch networkMessageLaunch;
|
NetworkMessageLaunch networkMessageLaunch;
|
||||||
if(receiveMessage(&networkMessageLaunch)) {
|
if(receiveMessage(&networkMessageLaunch)) {
|
||||||
|
|
||||||
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
@@ -2118,7 +2132,7 @@ bool ClientInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
|||||||
discard = true;
|
discard = true;
|
||||||
NetworkMessagePing msg = NetworkMessagePing();
|
NetworkMessagePing msg = NetworkMessagePing();
|
||||||
this->receiveMessage(&msg);
|
this->receiveMessage(&msg);
|
||||||
lastPingInfo = msg;
|
this->setLastPingInfo(msg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case nmtLaunch:
|
case nmtLaunch:
|
||||||
|
@@ -166,6 +166,20 @@ bool NetworkInterface::isConnected(){
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetworkInterface::setLastPingInfo(const NetworkMessagePing &ping) {
|
||||||
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
|
MutexSafeWrapper safeMutex(networkAccessMutex,mutexOwnerId);
|
||||||
|
|
||||||
|
this->lastPingInfo = ping;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkInterface::setLastPingInfoToNow() {
|
||||||
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
|
MutexSafeWrapper safeMutex(networkAccessMutex,mutexOwnerId);
|
||||||
|
|
||||||
|
this->lastPingInfo.setPingReceivedLocalTime(time(NULL));
|
||||||
|
}
|
||||||
|
|
||||||
NetworkMessagePing NetworkInterface::getLastPingInfo() {
|
NetworkMessagePing NetworkInterface::getLastPingInfo() {
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
MutexSafeWrapper safeMutex(networkAccessMutex,mutexOwnerId);
|
MutexSafeWrapper safeMutex(networkAccessMutex,mutexOwnerId);
|
||||||
|
@@ -263,6 +263,8 @@ public:
|
|||||||
|
|
||||||
virtual bool getConnectHasHandshaked() const= 0;
|
virtual bool getConnectHasHandshaked() const= 0;
|
||||||
|
|
||||||
|
void setLastPingInfo(const NetworkMessagePing &ping);
|
||||||
|
void setLastPingInfoToNow();
|
||||||
NetworkMessagePing getLastPingInfo();
|
NetworkMessagePing getLastPingInfo();
|
||||||
double getLastPingLag();
|
double getLastPingLag();
|
||||||
|
|
||||||
|
@@ -195,6 +195,7 @@ public:
|
|||||||
int32 getPingFrequency() const {return data.pingFrequency;}
|
int32 getPingFrequency() const {return data.pingFrequency;}
|
||||||
int64 getPingTime() const {return data.pingTime;}
|
int64 getPingTime() const {return data.pingTime;}
|
||||||
int64 getPingReceivedLocalTime() const { return pingReceivedLocalTime; }
|
int64 getPingReceivedLocalTime() const { return pingReceivedLocalTime; }
|
||||||
|
void setPingReceivedLocalTime(int64 pingTime) { pingReceivedLocalTime = pingTime; }
|
||||||
|
|
||||||
virtual bool receive(Socket* socket);
|
virtual bool receive(Socket* socket);
|
||||||
virtual void send(Socket* socket);
|
virtual void send(Socket* socket);
|
||||||
|
Reference in New Issue
Block a user