mirror of
https://github.com/glest/glest-source.git
synced 2025-09-30 17:39:02 +02:00
- added the ability to remove cell markers
This commit is contained in:
@@ -1133,6 +1133,45 @@ void ServerInterface::dispatchPendingMarkCellMessages(std::vector <string> &erro
|
||||
}
|
||||
}
|
||||
|
||||
void ServerInterface::dispatchPendingUnMarkCellMessages(std::vector <string> &errorMsgList) {
|
||||
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
|
||||
MutexSafeWrapper safeMutexSlot(slotAccessorMutexes[i],CODE_AT_LINE_X(i));
|
||||
ConnectionSlot* connectionSlot= slots[i];
|
||||
if(connectionSlot != NULL &&
|
||||
connectionSlot->getUnMarkedCellList(false).empty() == false) {
|
||||
try {
|
||||
std::vector<UnMarkedCell> chatText = connectionSlot->getUnMarkedCellList(true);
|
||||
for(int chatIdx = 0;
|
||||
exitServer == false && slots[i] != NULL &&
|
||||
chatIdx < chatText.size(); chatIdx++) {
|
||||
connectionSlot= slots[i];
|
||||
if(connectionSlot != NULL) {
|
||||
UnMarkedCell msg(chatText[chatIdx]);
|
||||
this->addUnMarkedCell(msg);
|
||||
|
||||
NetworkMessageUnMarkCell networkMessageMarkCell(msg.getTargetPos(),msg.getFactionIndex());
|
||||
broadcastMessage(&networkMessageMarkCell, connectionSlot->getPlayerIndex(),i);
|
||||
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex);
|
||||
}
|
||||
}
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] i = %d\n",__FILE__,__FUNCTION__,__LINE__,i);
|
||||
// Its possible that the slot is disconnected here
|
||||
// so check the original pointer again
|
||||
if(slots[i] != NULL) {
|
||||
slots[i]->clearUnMarkedCellList();
|
||||
}
|
||||
}
|
||||
catch(const exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] error detected [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
errorMsgList.push_back(ex.what());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ServerInterface::update() {
|
||||
Chrono chrono;
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) chrono.start();
|
||||
@@ -1206,6 +1245,7 @@ void ServerInterface::update() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
dispatchPendingMarkCellMessages(errorMsgList);
|
||||
dispatchPendingUnMarkCellMessages(errorMsgList);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
|
||||
}
|
||||
@@ -1386,17 +1426,6 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
||||
|
||||
this->addMarkedCell(msg);
|
||||
|
||||
// string newChatText = msg.chatText.c_str();
|
||||
// //string newChatSender = msg.chatSender.c_str();
|
||||
// int newChatTeamIndex = msg.chatTeamIndex;
|
||||
// int newChatPlayerIndex = msg.chatPlayerIndex;
|
||||
// string newChatLanguage = msg.targetLanguage.c_str();
|
||||
//
|
||||
// if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatTeamIndex = %d, newChatPlayerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex);
|
||||
//
|
||||
// NetworkMessageText networkMessageText(newChatText.c_str(),newChatTeamIndex,newChatPlayerIndex,newChatLanguage);
|
||||
// broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex());
|
||||
|
||||
NetworkMessageMarkCell networkMessageMarkCellBroadcast(
|
||||
networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex(),
|
||||
@@ -1408,6 +1437,27 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
||||
}
|
||||
break;
|
||||
|
||||
case nmtUnMarkCell:
|
||||
{
|
||||
discard = true;
|
||||
NetworkMessageUnMarkCell networkMessageMarkCell;
|
||||
connectionSlot->receiveMessage(&networkMessageMarkCell);
|
||||
|
||||
UnMarkedCell msg(networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex());
|
||||
|
||||
this->addUnMarkedCell(msg);
|
||||
|
||||
NetworkMessageUnMarkCell networkMessageMarkCellBroadcast(
|
||||
networkMessageMarkCell.getTarget(),
|
||||
networkMessageMarkCell.getFactionIndex());
|
||||
broadcastMessage(&networkMessageMarkCellBroadcast, connectionSlot->getPlayerIndex());
|
||||
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtMarkCell chatText [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatTeamIndex);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case nmtSynchNetworkGameData:
|
||||
{
|
||||
discard = true;
|
||||
@@ -1763,6 +1813,20 @@ void ServerInterface::sendMarkCellMessage(Vec2i targetPos, int factionIndex, str
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ServerInterface::sendUnMarkCellMessage(Vec2i targetPos, int factionIndex) {
|
||||
sendUnMarkCellMessage(targetPos, factionIndex, -1);
|
||||
}
|
||||
|
||||
void ServerInterface::sendUnMarkCellMessage(Vec2i targetPos, int factionIndex, int lockedSlotIndex) {
|
||||
//printf("Line: %d text [%s] echoLocal = %d\n",__LINE__,text.c_str(),echoLocal);
|
||||
//assert(text.length() > 0);
|
||||
|
||||
//if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] text [%s] teamIndex = %d, echoLocal = %d, lockedSlotIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,text.c_str(),teamIndex,echoLocal,lockedSlotIndex);
|
||||
NetworkMessageUnMarkCell networkMessageMarkCell(targetPos,factionIndex);
|
||||
broadcastMessage(&networkMessageMarkCell, -1, lockedSlotIndex);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void ServerInterface::quitGame(bool userManuallyQuit) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
NetworkMessageQuit networkMessageQuit;
|
||||
|
Reference in New Issue
Block a user