mirror of
https://github.com/glest/glest-source.git
synced 2025-08-29 10:49:48 +02:00
- added queued broadcast message ability and tried to fix tomreyn's fuzzer program issue
This commit is contained in:
@@ -1347,7 +1347,13 @@ void MenuStateCustomGame::render() {
|
|||||||
catch(const std::exception &ex) {
|
catch(const std::exception &ex) {
|
||||||
char szBuf[4096]="";
|
char szBuf[4096]="";
|
||||||
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||||
throw runtime_error(szBuf);
|
//throw runtime_error(szBuf);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugError,szBuf);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf);
|
||||||
|
//throw runtime_error(szBuf);!!!
|
||||||
|
showGeneralError=true;
|
||||||
|
generalErrorToShow = ex.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1950,8 +1956,11 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
|
|||||||
|
|
||||||
ServerInterface *serverInterface= NetworkManager::getInstance().getServerInterface(false);
|
ServerInterface *serverInterface= NetworkManager::getInstance().getServerInterface(false);
|
||||||
if(serverInterface != NULL) {
|
if(serverInterface != NULL) {
|
||||||
NetworkMessagePing msg(GameConstants::networkPingInterval,time(NULL));
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
serverInterface->broadcastPing(&msg);
|
NetworkMessagePing *msg = new NetworkMessagePing(GameConstants::networkPingInterval,time(NULL));
|
||||||
|
//serverInterface->broadcastPing(&msg);
|
||||||
|
serverInterface->queueBroadcastMessage(msg);
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
@@ -605,6 +605,7 @@ void ServerInterface::update() {
|
|||||||
validateConnectedClients();
|
validateConnectedClients();
|
||||||
|
|
||||||
processTextMessageQueue();
|
processTextMessageQueue();
|
||||||
|
processBroadCastMessageQueue();
|
||||||
|
|
||||||
std::map<PLATFORM_SOCKET,bool> socketTriggeredList;
|
std::map<PLATFORM_SOCKET,bool> socketTriggeredList;
|
||||||
//update all slots
|
//update all slots
|
||||||
@@ -1099,10 +1100,34 @@ void ServerInterface::waitUntilReady(Checksum* checksum) {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s] END\n",__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s] END\n",__FUNCTION__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerInterface::processBroadCastMessageQueue() {
|
||||||
|
MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,intToStr(__LINE__));
|
||||||
|
if(broadcastMessageQueue.size() > 0) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] broadcastMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,broadcastMessageQueue.size());
|
||||||
|
for(int i = 0; i < broadcastMessageQueue.size(); ++i) {
|
||||||
|
pair<const NetworkMessage *,int> &item = broadcastMessageQueue[i];
|
||||||
|
if(item.first != NULL) {
|
||||||
|
this->broadcastMessage(item.first,item.second);
|
||||||
|
delete item.first;
|
||||||
|
}
|
||||||
|
item.first = NULL;
|
||||||
|
}
|
||||||
|
broadcastMessageQueue.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ServerInterface::queueBroadcastMessage(const NetworkMessage *networkMessage, int excludeSlot) {
|
||||||
|
MutexSafeWrapper safeMutexSlot(&broadcastMessageQueueThreadAccessor,intToStr(__LINE__));
|
||||||
|
pair<const NetworkMessage *,int> item;
|
||||||
|
item.first = networkMessage;
|
||||||
|
item.second = excludeSlot;
|
||||||
|
broadcastMessageQueue.push_back(item);
|
||||||
|
}
|
||||||
|
|
||||||
void ServerInterface::processTextMessageQueue() {
|
void ServerInterface::processTextMessageQueue() {
|
||||||
MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,intToStr(__LINE__));
|
MutexSafeWrapper safeMutexSlot(&textMessageQueueThreadAccessor,intToStr(__LINE__));
|
||||||
if(textMessageQueue.size() > 0) {
|
if(textMessageQueue.size() > 0) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] textMessageQueue.size() = %d\n",__FILE__,__FUNCTION__,__LINE__,textMessageQueue.size());
|
||||||
for(int i = 0; i < textMessageQueue.size(); ++i) {
|
for(int i = 0; i < textMessageQueue.size(); ++i) {
|
||||||
TextMessageQueue &item = textMessageQueue[i];
|
TextMessageQueue &item = textMessageQueue[i];
|
||||||
sendTextMessage(item.text, item.teamIndex, item.echoLocal);
|
sendTextMessage(item.text, item.teamIndex, item.echoLocal);
|
||||||
|
@@ -67,6 +67,9 @@ private:
|
|||||||
Mutex textMessageQueueThreadAccessor;
|
Mutex textMessageQueueThreadAccessor;
|
||||||
vector<TextMessageQueue> textMessageQueue;
|
vector<TextMessageQueue> textMessageQueue;
|
||||||
|
|
||||||
|
Mutex broadcastMessageQueueThreadAccessor;
|
||||||
|
vector<pair<const NetworkMessage *,int> > broadcastMessageQueue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerInterface();
|
ServerInterface();
|
||||||
virtual ~ServerInterface();
|
virtual ~ServerInterface();
|
||||||
@@ -84,7 +87,6 @@ public:
|
|||||||
// message sending
|
// message sending
|
||||||
virtual void sendTextMessage(const string &text, int teamIndex, bool echoLocal=false);
|
virtual void sendTextMessage(const string &text, int teamIndex, bool echoLocal=false);
|
||||||
void sendTextMessage(const string &text, int teamIndex, bool echoLocal, int lockedSlotIndex);
|
void sendTextMessage(const string &text, int teamIndex, bool echoLocal, int lockedSlotIndex);
|
||||||
|
|
||||||
void queueTextMessage(const string &text, int teamIndex, bool echoLocal=false);
|
void queueTextMessage(const string &text, int teamIndex, bool echoLocal=false);
|
||||||
|
|
||||||
virtual void quitGame(bool userManuallyQuit);
|
virtual void quitGame(bool userManuallyQuit);
|
||||||
@@ -125,6 +127,8 @@ public:
|
|||||||
this->broadcastMessage(networkMessage,excludeSlot);
|
this->broadcastMessage(networkMessage,excludeSlot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void queueBroadcastMessage(const NetworkMessage *networkMessage, int excludeSlot=-1);
|
||||||
|
|
||||||
virtual string getHumanPlayerName(int index=-1);
|
virtual string getHumanPlayerName(int index=-1);
|
||||||
virtual int getHumanPlayerIndex() const;
|
virtual int getHumanPlayerIndex() const;
|
||||||
|
|
||||||
@@ -152,6 +156,7 @@ private:
|
|||||||
int64 getNextEventId();
|
int64 getNextEventId();
|
||||||
|
|
||||||
void processTextMessageQueue();
|
void processTextMessageQueue();
|
||||||
|
void processBroadCastMessageQueue();
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
Reference in New Issue
Block a user