diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index dda5f96ec..bbabafd25 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -26,7 +26,7 @@ using namespace Shared::Platform; namespace Glest{ namespace Game{ const string mailString= "contact_game@glest.org"; -const string glestVersionString= "v3.3.5-beta14"; +const string glestVersionString= "v3.3.5-beta15"; string getCrashDumpFileName(){ return "glest" + glestVersionString + ".dmp"; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index ff73541c9..0fb979fe9 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -460,7 +460,6 @@ void Renderer::renderParticleManager(ResourceScope rs){ void Renderer::swapBuffers(){ //glFlush(); // should not be required - http://www.opengl.org/wiki/Common_Mistakes - glFlush(); // <--- this might actually be needed for better Render performance??? GraphicsInterface::getInstance().getCurrentContext()->swapBuffers(); } diff --git a/source/glest_game/network/connection_slot.cpp b/source/glest_game/network/connection_slot.cpp index 2db2f8b13..983523b06 100644 --- a/source/glest_game/network/connection_slot.cpp +++ b/source/glest_game/network/connection_slot.cpp @@ -33,12 +33,14 @@ namespace Glest{ namespace Game{ // class ConnectionSlotThread // ===================================================== -ConnectionSlotThread::ConnectionSlotThread() : BaseThread() { +ConnectionSlotThread::ConnectionSlotThread(int slotIndex) : BaseThread() { + this->slotIndex = slotIndex; this->slotInterface = NULL; this->event = NULL; } -ConnectionSlotThread::ConnectionSlotThread(ConnectionSlotCallbackInterface *slotInterface) : BaseThread() { +ConnectionSlotThread::ConnectionSlotThread(ConnectionSlotCallbackInterface *slotInterface,int slotIndex) : BaseThread() { + this->slotIndex = slotIndex; this->slotInterface = slotInterface; this->event = NULL; } @@ -80,13 +82,13 @@ void ConnectionSlotThread::setTaskCompleted(ConnectionSlotEvent *event) { } bool ConnectionSlotThread::isSignalCompleted() { - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); + //SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex); MutexSafeWrapper safeMutex(&triggerIdMutex); bool result = (this->event != NULL ? this->event->eventCompleted : true); safeMutex.ReleaseLock(); - SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); + if(result == false) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] slotIndex = %d, result = %d\n",__FILE__,__FUNCTION__,__LINE__,slotIndex,result); return result; } @@ -158,7 +160,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex this->lastReceiveCommandListTime = 0; this->socket = NULL; this->slotThreadWorker = NULL; - this->slotThreadWorker = new ConnectionSlotThread(this->serverInterface); + this->slotThreadWorker = new ConnectionSlotThread(this->serverInterface,playerIndex); this->slotThreadWorker->setUniqueID(__FILE__); this->slotThreadWorker->start(); @@ -213,7 +215,9 @@ void ConnectionSlot::update(bool checkForNewClients) { bool hasOpenSlots = (serverInterface->getOpenSlotCount() > 0); if(serverInterface->getServerSocket()->hasDataToRead() == true) { socket = serverInterface->getServerSocket()->accept(); - serverInterface->updateListen(); + if(socket != NULL) { + serverInterface->updateListen(); + } } //send intro message when connected if(socket != NULL) { @@ -549,9 +553,14 @@ void ConnectionSlot::signalUpdate(ConnectionSlotEvent *event) { bool ConnectionSlot::updateCompleted() { assert(slotThreadWorker != NULL); + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); + bool waitingForThread = (slotThreadWorker->isSignalCompleted() == false && slotThreadWorker->getQuitStatus() == false && slotThreadWorker->getRunningStatus() == true); + + SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] playerIndex = %d, waitingForThread = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,waitingForThread); + return (waitingForThread == false); } diff --git a/source/glest_game/network/connection_slot.h b/source/glest_game/network/connection_slot.h index 8d29ec40e..48a385133 100644 --- a/source/glest_game/network/connection_slot.h +++ b/source/glest_game/network/connection_slot.h @@ -74,17 +74,18 @@ protected: Semaphore semTaskSignalled; Mutex triggerIdMutex; ConnectionSlotEvent *event; + int slotIndex; virtual void setQuitStatus(bool value); virtual void setTaskCompleted(ConnectionSlotEvent *event); public: - ConnectionSlotThread(); - ConnectionSlotThread(ConnectionSlotCallbackInterface *slotInterface); + ConnectionSlotThread(int slotIndex); + ConnectionSlotThread(ConnectionSlotCallbackInterface *slotInterface,int slotIndex); virtual void execute(); void signalUpdate(ConnectionSlotEvent *event); bool isSignalCompleted(); - + int getSlotIndex() const {return slotIndex; } }; // ===================================================== diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 15e125fb0..dd49d3fa8 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -360,29 +360,33 @@ void ServerInterface::update() { connectionSlot->clearThreadErrorList(); } + // Not done waiting for data yet - if(connectionSlot->updateCompleted() == false) { - threadsDone = false; - break; - } - else { - // New lag check - bool clientLagExceeded = clientLagCheck(connectionSlot); - // If the client has exceeded lag and the server wants - // to pause while they catch up, re-trigger the - // client reader thread - if(clientLagExceeded == true && pauseGameForLaggedClients == true) { - bool socketTriggered = (connectionSlot != NULL && connectionSlot->getSocket() != NULL ? socketTriggeredList[connectionSlot->getSocket()->getSocketId()] : false); - ConnectionSlotEvent &event = eventList[i]; - signalClientReceiveCommands(connectionSlot,i,socketTriggered,event); - } - else { - slotsCompleted[i] = true; - } - } + if(connectionSlot->updateCompleted() == false) { + threadsDone = false; + break; + } + else { + // New lag check + bool clientLagExceeded = false; + if(connectionSlot->isConnected() == true) { + clientLagExceeded = clientLagCheck(connectionSlot); + } + // If the client has exceeded lag and the server wants + // to pause while they catch up, re-trigger the + // client reader thread + if(clientLagExceeded == true && pauseGameForLaggedClients == true) { + bool socketTriggered = (connectionSlot != NULL && connectionSlot->getSocket() != NULL ? socketTriggeredList[connectionSlot->getSocket()->getSocketId()] : false); + ConnectionSlotEvent &event = eventList[i]; + signalClientReceiveCommands(connectionSlot,i,socketTriggered,event); + } + else { + slotsCompleted[i] = true; + } + } } } - //sleep(0); + sleep(0); } // Step #3 dispatch network commands to the pending list so that they are done in proper order