- cleaned up lobby message processing

This commit is contained in:
Mark Vejvoda 2010-08-27 20:09:55 +00:00
parent 2e99f69ef1
commit a2f013c51a
2 changed files with 22 additions and 29 deletions

View File

@ -433,15 +433,22 @@ void ClientInterface::updateLobby() {
break;
case nmtLaunch:
case nmtBroadCastSetup:
{
NetworkMessageLaunch networkMessageLaunch;
if(receiveMessage(&networkMessageLaunch)) {
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",__FILE__,__FUNCTION__,__LINE__);
}
else if(networkMessageLaunch.getMessageType() == nmtBroadCastSetup) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtBroadCastSetup\n",__FILE__,__FUNCTION__,__LINE__);
}
else {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got networkMessageLaunch.getMessageType() = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
char szBuf[1024]="";
snprintf(szBuf,1023,"In [%s::%s Line: %d] Invalid networkMessageLaunch.getMessageType() = %d",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
throw runtime_error(szBuf);
}
networkMessageLaunch.buildGameSettings(&gameSettings);
@ -462,35 +469,9 @@ void ClientInterface::updateLobby() {
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
launchGame= true;
}
}
}
break;
case nmtBroadCastSetup:
{
NetworkMessageLaunch networkMessageLaunch;
if(receiveMessage(&networkMessageLaunch))
{
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] got NetworkMessageLaunch\n",__FILE__,__FUNCTION__);
networkMessageLaunch.buildGameSettings(&gameSettings);
//replace server player by network
for(int i= 0; i<gameSettings.getFactionCount(); ++i)
{
//replace by network
if(gameSettings.getFactionControl(i)==ctHuman)
{
gameSettings.setFactionControl(i, ctNetwork);
}
//set the faction index
if(gameSettings.getStartLocationIndex(i)==playerIndex)
{
gameSettings.setThisFactionIndex(i);
}
else if(networkMessageLaunch.getMessageType() == nmtBroadCastSetup) {
gameSettingsReceived=true;
}
gameSettingsReceived=true;
}
}
break;

View File

@ -783,6 +783,18 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex());
this->addChatInfo(msg);
string newChatText = msg.chatText.c_str();
string newChatSender = msg.chatSender.c_str();
int newChatTeamIndex = msg.chatTeamIndex;
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 about to broadcast nmtText chatText [%s] chatSender [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
NetworkMessageText networkMessageText(newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
broadcastMessage(&networkMessageText, connectionSlot->getPlayerIndex());
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] after broadcast nmtText chatText [%s] chatSender [%s] chatTeamIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,newChatText.c_str(),newChatSender.c_str(),newChatTeamIndex);
}
break;
case nmtSynchNetworkGameData: