From fd60b30081d91163b85c9c5faf8d0b1860b24c82 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 7 Oct 2010 18:43:29 +0000 Subject: [PATCH] - updated announcement to use a safer compare and added announcement url to ini files --- mk/linux/glest.ini | 1 + source/glest_game/menu/menu_state_masterserver.cpp | 13 ++++++++----- .../include/platform/common/platform_common.h | 1 + .../sources/platform/common/platform_common.cpp | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index b446efb8..4e61947c 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -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 diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index 5ea6af1b..86c9783d 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -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; } diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index 6864b695..3108cda8 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -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); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 57c558cf..971310ad 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -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;