- cleaned up lobby message processing
This commit is contained in:
parent
2e99f69ef1
commit
a2f013c51a
|
@ -433,15 +433,22 @@ void ClientInterface::updateLobby() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nmtLaunch:
|
case nmtLaunch:
|
||||||
|
case nmtBroadCastSetup:
|
||||||
{
|
{
|
||||||
NetworkMessageLaunch networkMessageLaunch;
|
NetworkMessageLaunch networkMessageLaunch;
|
||||||
|
|
||||||
if(receiveMessage(&networkMessageLaunch)) {
|
if(receiveMessage(&networkMessageLaunch)) {
|
||||||
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got nmtLaunch\n",__FILE__,__FUNCTION__,__LINE__);
|
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 {
|
else {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Lined: %d] got networkMessageLaunch.getMessageType() = %d\n",__FILE__,__FUNCTION__,__LINE__,networkMessageLaunch.getMessageType());
|
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);
|
networkMessageLaunch.buildGameSettings(&gameSettings);
|
||||||
|
@ -462,35 +469,9 @@ void ClientInterface::updateLobby() {
|
||||||
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
if(networkMessageLaunch.getMessageType() == nmtLaunch) {
|
||||||
launchGame= true;
|
launchGame= true;
|
||||||
}
|
}
|
||||||
}
|
else if(networkMessageLaunch.getMessageType() == nmtBroadCastSetup) {
|
||||||
}
|
gameSettingsReceived=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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
gameSettingsReceived=true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -783,6 +783,18 @@ bool ServerInterface::shouldDiscardNetworkMessage(NetworkMessageType networkMess
|
||||||
|
|
||||||
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex());
|
ChatMsgInfo msg(netMsg.getText().c_str(),netMsg.getSender().c_str(),netMsg.getTeamIndex());
|
||||||
this->addChatInfo(msg);
|
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;
|
break;
|
||||||
case nmtSynchNetworkGameData:
|
case nmtSynchNetworkGameData:
|
||||||
|
|
Loading…
Reference in New Issue