mirror of
https://github.com/glest/glest-source.git
synced 2025-08-28 10:19:55 +02:00
Added some more mutex guards around multi-player server side thread that processes incoming messages
This commit is contained in:
@@ -41,10 +41,13 @@ namespace Glest { namespace Game{
|
|||||||
// class MeshCallbackTeamColor
|
// class MeshCallbackTeamColor
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
|
bool MeshCallbackTeamColor::noTeamColors = false;
|
||||||
|
|
||||||
void MeshCallbackTeamColor::execute(const Mesh *mesh){
|
void MeshCallbackTeamColor::execute(const Mesh *mesh){
|
||||||
|
|
||||||
//team color
|
//team color
|
||||||
if(mesh->getCustomTexture() && teamTexture!=NULL){
|
if( mesh->getCustomTexture() && teamTexture != NULL &&
|
||||||
|
MeshCallbackTeamColor::noTeamColors == false) {
|
||||||
//texture 0
|
//texture 0
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
|
||||||
|
|
||||||
|
@@ -65,6 +65,8 @@ private:
|
|||||||
public:
|
public:
|
||||||
void setTeamTexture(const Texture *teamTexture) {this->teamTexture= teamTexture;}
|
void setTeamTexture(const Texture *teamTexture) {this->teamTexture= teamTexture;}
|
||||||
virtual void execute(const Mesh *mesh);
|
virtual void execute(const Mesh *mesh);
|
||||||
|
|
||||||
|
static bool noTeamColors;
|
||||||
};
|
};
|
||||||
|
|
||||||
//non shared classes
|
//non shared classes
|
||||||
|
@@ -346,6 +346,10 @@ int glestMain(int argc, char** argv){
|
|||||||
//showCursor(config.getBool("Windowed"));
|
//showCursor(config.getBool("Windowed"));
|
||||||
showCursor(false);
|
showCursor(false);
|
||||||
|
|
||||||
|
if(config.getBool("noTeamColors","false") == true) {
|
||||||
|
MeshCallbackTeamColor::noTeamColors = true;
|
||||||
|
}
|
||||||
|
|
||||||
program= new Program();
|
program= new Program();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@@ -87,7 +87,12 @@ public:
|
|||||||
void sendSwitchSetupRequest(string selectedFactionName, int8 currentFactionIndex, int8 toFactionIndex, int8 toTeam);
|
void sendSwitchSetupRequest(string selectedFactionName, int8 currentFactionIndex, int8 toFactionIndex, int8 toTeam);
|
||||||
virtual bool getConnectHasHandshaked() const { return gotIntro; }
|
virtual bool getConnectHasHandshaked() const { return gotIntro; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Mutex * getServerSynchAccessor() { return NULL; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void waitForMessage();
|
void waitForMessage();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -374,4 +374,8 @@ bool ConnectionSlot::hasValidSocketId() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mutex * ConnectionSlot::getServerSynchAccessor() {
|
||||||
|
return (serverInterface != NULL ? serverInterface->getServerSynchAccessor() : NULL);
|
||||||
|
}
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -65,6 +65,10 @@ public:
|
|||||||
|
|
||||||
bool hasValidSocketId();
|
bool hasValidSocketId();
|
||||||
virtual bool getConnectHasHandshaked() const { return gotIntro; }
|
virtual bool getConnectHasHandshaked() const { return gotIntro; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
Mutex * getServerSynchAccessor();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -121,11 +121,17 @@ GameNetworkInterface::GameNetworkInterface(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GameNetworkInterface::requestCommand(const NetworkCommand *networkCommand, bool insertAtStart) {
|
void GameNetworkInterface::requestCommand(const NetworkCommand *networkCommand, bool insertAtStart) {
|
||||||
|
Mutex *mutex = getServerSynchAccessor();
|
||||||
|
|
||||||
if(insertAtStart == false) {
|
if(insertAtStart == false) {
|
||||||
|
if(mutex != NULL) mutex->p();
|
||||||
requestedCommands.push_back(*networkCommand);
|
requestedCommands.push_back(*networkCommand);
|
||||||
|
if(mutex != NULL) mutex->v();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(mutex != NULL) mutex->p();
|
||||||
requestedCommands.insert(requestedCommands.begin(),*networkCommand);
|
requestedCommands.insert(requestedCommands.begin(),*networkCommand);
|
||||||
|
if(mutex != NULL) mutex->v();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -55,6 +55,8 @@ protected:
|
|||||||
static DisplayMessageFunction pCB_DisplayMessage;
|
static DisplayMessageFunction pCB_DisplayMessage;
|
||||||
void DisplayErrorMessage(string sErr, bool closeSocket=true);
|
void DisplayErrorMessage(string sErr, bool closeSocket=true);
|
||||||
|
|
||||||
|
virtual Mutex * getServerSynchAccessor() = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const int readyWaitTimeout;
|
static const int readyWaitTimeout;
|
||||||
GameSettings gameSettings;
|
GameSettings gameSettings;
|
||||||
|
@@ -123,7 +123,12 @@ public:
|
|||||||
virtual void slotUpdateTask(ConnectionSlotEvent *event);
|
virtual void slotUpdateTask(ConnectionSlotEvent *event);
|
||||||
bool hasClientConnection();
|
bool hasClientConnection();
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Mutex * getServerSynchAccessor() { return &serverSynchAccessor; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot= -1);
|
void broadcastMessage(const NetworkMessage* networkMessage, int excludeSlot= -1);
|
||||||
void broadcastMessageToConnectedClients(const NetworkMessage* networkMessage, int excludeSlot = -1);
|
void broadcastMessageToConnectedClients(const NetworkMessage* networkMessage, int excludeSlot = -1);
|
||||||
bool shouldDiscardNetworkMessage(NetworkMessageType networkMessageType,ConnectionSlot* connectionSlot);
|
bool shouldDiscardNetworkMessage(NetworkMessageType networkMessageType,ConnectionSlot* connectionSlot);
|
||||||
|
Reference in New Issue
Block a user