mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 19:29:47 +02:00
added some safety checks if user does not have masterserver setup properly
This commit is contained in:
@@ -138,8 +138,11 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
|||||||
labelTitle.init(330, 700);
|
labelTitle.init(330, 700);
|
||||||
labelTitle.setText(lang.get("AvailableServers"));
|
labelTitle.setText(lang.get("AvailableServers"));
|
||||||
|
|
||||||
|
if(Config::getInstance().getString("Masterserver","") == "") {
|
||||||
|
labelTitle.setText("*** " + lang.get("AvailableServers"));
|
||||||
|
}
|
||||||
|
|
||||||
// bottom
|
// bottom
|
||||||
|
|
||||||
buttonReturn.init(50, 70, 150);
|
buttonReturn.init(50, 70, 150);
|
||||||
buttonCreateGame.init(300, 70, 150);
|
buttonCreateGame.init(300, 70, 150);
|
||||||
buttonRefresh.init(550, 70, 150);
|
buttonRefresh.init(550, 70, 150);
|
||||||
@@ -277,44 +280,53 @@ void MenuStateMasterserver::simpleTask() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MenuStateMasterserver::updateServerInfo() {
|
void MenuStateMasterserver::updateServerInfo() {
|
||||||
needUpdateFromServer = false;
|
try {
|
||||||
//MasterServerInfos masterServerInfos;
|
needUpdateFromServer = false;
|
||||||
clearServerLines();
|
//MasterServerInfos masterServerInfos;
|
||||||
|
clearServerLines();
|
||||||
|
|
||||||
std::string serverInfo = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver")+"showServersForGlest.php");
|
if(Config::getInstance().getString("Masterserver","") != "") {
|
||||||
|
std::string serverInfo = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver")+"showServersForGlest.php");
|
||||||
|
|
||||||
std::vector<std::string> serverList;
|
std::vector<std::string> serverList;
|
||||||
Tokenize(serverInfo,serverList,"\n");
|
Tokenize(serverInfo,serverList,"\n");
|
||||||
for(int i=0; i < serverList.size(); i++) {
|
for(int i=0; i < serverList.size(); i++) {
|
||||||
string &server = serverList[i];
|
string &server = serverList[i];
|
||||||
std::vector<std::string> serverEntities;
|
std::vector<std::string> serverEntities;
|
||||||
Tokenize(server,serverEntities,"|");
|
Tokenize(server,serverEntities,"|");
|
||||||
|
|
||||||
const int MIN_FIELDS_EXPECTED = 11;
|
const int MIN_FIELDS_EXPECTED = 11;
|
||||||
if(serverEntities.size() >= MIN_FIELDS_EXPECTED) {
|
if(serverEntities.size() >= MIN_FIELDS_EXPECTED) {
|
||||||
MasterServerInfo *masterServerInfo=new MasterServerInfo();
|
MasterServerInfo *masterServerInfo=new MasterServerInfo();
|
||||||
|
|
||||||
//general info:
|
//general info:
|
||||||
masterServerInfo->setGlestVersion(serverEntities[0]);
|
masterServerInfo->setGlestVersion(serverEntities[0]);
|
||||||
masterServerInfo->setPlatform(serverEntities[1]);
|
masterServerInfo->setPlatform(serverEntities[1]);
|
||||||
masterServerInfo->setBinaryCompileDate(serverEntities[2]);
|
masterServerInfo->setBinaryCompileDate(serverEntities[2]);
|
||||||
|
|
||||||
//game info:
|
//game info:
|
||||||
masterServerInfo->setServerTitle(serverEntities[3]);
|
masterServerInfo->setServerTitle(serverEntities[3]);
|
||||||
masterServerInfo->setIpAddress(serverEntities[4]);
|
masterServerInfo->setIpAddress(serverEntities[4]);
|
||||||
|
|
||||||
//game setup info:
|
//game setup info:
|
||||||
masterServerInfo->setTech(serverEntities[5]);
|
masterServerInfo->setTech(serverEntities[5]);
|
||||||
masterServerInfo->setMap(serverEntities[6]);
|
masterServerInfo->setMap(serverEntities[6]);
|
||||||
masterServerInfo->setTileset(serverEntities[7]);
|
masterServerInfo->setTileset(serverEntities[7]);
|
||||||
masterServerInfo->setActiveSlots(strToInt(serverEntities[8]));
|
masterServerInfo->setActiveSlots(strToInt(serverEntities[8]));
|
||||||
masterServerInfo->setNetworkSlots(strToInt(serverEntities[9]));
|
masterServerInfo->setNetworkSlots(strToInt(serverEntities[9]));
|
||||||
masterServerInfo->setConnectedClients(strToInt(serverEntities[10]));
|
masterServerInfo->setConnectedClients(strToInt(serverEntities[10]));
|
||||||
|
|
||||||
serverLines.push_back(new ServerLine( masterServerInfo, i));
|
serverLines.push_back(new ServerLine( masterServerInfo, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
//masterServerInfos.push_back(masterServerInfo);
|
||||||
//masterServerInfos.push_back(masterServerInfo);
|
}
|
||||||
|
catch(const exception &e){
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Line: %d, error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what());
|
||||||
|
|
||||||
|
throw runtime_error(e.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user