- updated announcement to use a safer compare and added announcement url to ini files

This commit is contained in:
Mark Vejvoda 2010-10-07 18:43:29 +00:00
parent e400f449d6
commit fd60b30081
4 changed files with 14 additions and 5 deletions

View File

@ -4,6 +4,7 @@ AiRedir=false
AllowDownloadDataSynch=false
AllowGameDataSynchCheck=false
AllowRotateUnits=true
AnnouncementURL=http://megaglest.pepper.freeit.org/announcement.txt
AutoMaxFullScreen=false
AutoTest=false
CheckGlCaps=true

View File

@ -461,11 +461,14 @@ void MenuStateMasterserver::updateServerInfo() {
clearServerLines();
safeMutex.ReleaseLock(true);
if(!announcementLoaded)
{
std::string announcementTxt = SystemFlags::getHTTP(Config::getInstance().getString("AnnouncementURL","http://megaglest.pepper.freeit.org/announcement.txt"));
if(announcementTxt.substr (0,31)=="Announcement from Masterserver:")
announcementLabel.setText(announcementTxt);
if(announcementLoaded == false) {
string announcementURL = Config::getInstance().getString("AnnouncementURL","http://megaglest.pepper.freeit.org/announcement.txt");
if(announcementURL != "") {
std::string announcementTxt = SystemFlags::getHTTP(announcementURL);
if(StartsWith(announcementTxt,"Announcement from Masterserver:") == true) {
announcementLabel.setText(announcementTxt);
}
}
announcementLoaded=true;
}

View File

@ -121,6 +121,7 @@ void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight);
bool changeVideoMode(int resH, int resW, int colorBits, int refreshFrequency);
void restoreVideoMode(bool exitingApp=false);
bool StartsWith(const std::string &str, const std::string &key);
bool EndsWith(const string &str, const string& key);
string replaceAll(string& context, const string& from, const string& to);

View File

@ -304,6 +304,10 @@ bool isdir(const char *path)
return ret;
}
bool StartsWith(const std::string &str, const std::string &key) {
return str.find(key) == 0;
}
bool EndsWith(const string &str, const string& key)
{
bool result = false;