- updated client connection screen to NOT crash if client does not have the tech selected on the server

This commit is contained in:
Mark Vejvoda
2010-06-03 06:03:41 +00:00
parent e85a269738
commit 1b000376d4
3 changed files with 29 additions and 16 deletions

View File

@@ -506,7 +506,7 @@ void MenuStateConnectedGame::update()
if(currentFactionName != gameSettings->getTech()) if(currentFactionName != gameSettings->getTech())
{ {
currentFactionName = gameSettings->getTech(); currentFactionName = gameSettings->getTech();
hasFactions = loadFactions(gameSettings); hasFactions = loadFactions(gameSettings,false);
} }
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d\n",__FILE__,__FUNCTION__,__LINE__,hasFactions); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] hasFactions = %d\n",__FILE__,__FUNCTION__,__LINE__,hasFactions);
@@ -606,8 +606,7 @@ void MenuStateConnectedGame::update()
} }
bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings, bool errorOnNoFactions){
bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings){
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__);
vector<string> results; vector<string> results;
@@ -618,7 +617,7 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings){
for(int idx = 0; idx < techPaths.size(); idx++) { for(int idx = 0; idx < techPaths.size(); idx++) {
string &techPath = techPaths[idx]; string &techPath = techPaths[idx];
findAll(techPath + "/" + gameSettings->getTech() + "/factions/*.", results, false, false); findAll(techPath + "/" + gameSettings->getTech() + "xx/factions/*.", results, false, false);
if(results.size() > 0) { if(results.size() > 0) {
break; break;
} }
@@ -630,8 +629,20 @@ bool MenuStateConnectedGame::loadFactions(const GameSettings *gameSettings){
NetworkManager &networkManager= NetworkManager::getInstance(); NetworkManager &networkManager= NetworkManager::getInstance();
ClientInterface* clientInterface= networkManager.getClientInterface(); ClientInterface* clientInterface= networkManager.getClientInterface();
if(clientInterface->getAllowGameDataSynchCheck() == false) { if(clientInterface->getAllowGameDataSynchCheck() == false) {
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]"); if(errorOnNoFactions == true) {
throw runtime_error("(2)There are no factions for the tech tree [" + gameSettings->getTech() + "]");
}
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (2)There are no factions for the tech tree [%s]\n",__FILE__,__FUNCTION__,__LINE__,gameSettings->getTech().c_str());
} }
results.push_back("***missing***");
factionFiles = results;
for(int i=0; i<GameConstants::maxPlayers; ++i){
listBoxFactions[i].setItems(results);
}
char szMsg[1024]="";
sprintf(szMsg,"Player: %s is missing the techtree: %s",Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()).c_str(),gameSettings->getTech().c_str());
clientInterface->sendTextMessage(szMsg,-1);
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__);
} }

View File

@@ -87,7 +87,7 @@ private:
bool hasNetworkGameSettings(); bool hasNetworkGameSettings();
void reloadFactions(); void reloadFactions();
bool loadFactions(const GameSettings *gameSettings); bool loadFactions(const GameSettings *gameSettings,bool errorOnNoFactions);
void returnToJoinMenu(); void returnToJoinMenu();
}; };

View File

@@ -99,16 +99,18 @@ bool NetworkMessage::receive(Socket* socket, void* data, int dataSize)
void NetworkMessage::send(Socket* socket, const void* data, int dataSize) const void NetworkMessage::send(Socket* socket, const void* data, int dataSize) const
{ {
if(socket != NULL && socket->send(data, dataSize)!=dataSize) if(socket != NULL) {
{ int sendResult = socket->send(data, dataSize);
if(socket != NULL && socket->getSocketId() > 0) if(sendResult != dataSize) {
{ if(socket != NULL && socket->getSocketId() > 0) {
throw runtime_error("Error sending NetworkMessage"); char szBuf[1024]="";
} sprintf(szBuf,"Error sending NetworkMessage, sendResult = %d, dataSize = %d",sendResult,dataSize);
else throw runtime_error(szBuf);
{ }
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d socket has been disconnected\n",__FILE__,__FUNCTION__,__LINE__); else {
} SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d socket has been disconnected\n",__FILE__,__FUNCTION__,__LINE__);
}
}
} }
} }