Added support for news messages to be filtered for addons

that are not installed. Syntax: "addons_id not installed".
Fixed ticket #127.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8788 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2011-05-31 06:58:11 +00:00
parent 2a1fa5bf29
commit e151f35825

View File

@ -270,6 +270,8 @@ bool NewsManager::conditionFulfilled(const std::string &cond)
cond_list[i].c_str());
continue;
}
// Check for stkversion comparisons
// ================================
if(cond[0]=="stkversion")
{
int news_version = versionToInt(cond[2]);
@ -292,6 +294,23 @@ bool NewsManager::conditionFulfilled(const std::string &cond)
printf("Invalid comparison in condition '%s' - assumed true.\n",
cond_list[i].c_str());
}
// Check for addons not installed
// ==============================
else if(cond[1]=="not" && cond[2]=="installed")
{
// The addons_manager can not be access, since it's
// being initialised after the news manager. So a simple
// test is made to see if the directory exists. It is
// necessary to check for karts and tracks separately,
// since it's not possible to know if the addons is
// a kart or a track.
const std::string dir=file_manager->getAddonsDir();
if(file_manager->fileExists(dir+"/karts/"+cond[0]))
continue;
if(file_manager->fileExists(dir+"/tracks/"+cond[0]))
continue;
return false;
}
else
{
printf("Invalid condition '%s' - assumed to be true.\n",