From 252c15cbc41fa7e962998663b5fb50a88fc6d7dc Mon Sep 17 00:00:00 2001 From: louis Date: Mon, 19 Jan 2015 09:41:49 +0100 Subject: [PATCH] fixed bug that custom int tokens were not considered in conditions --- HISTORY | 2 +- libtemplate/parameter.c | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/HISTORY b/HISTORY index 749dc97..a947af5 100644 --- a/HISTORY +++ b/HISTORY @@ -159,4 +159,4 @@ Version 0.1.4 - added "empty" operator additionally to "isset" to check in a condition if a string token is set - added token {nummenuitem} for plugin menu lists - +- fixed bug that custom int tokens were not considered in conditions diff --git a/libtemplate/parameter.c b/libtemplate/parameter.c index b191d17..83597c8 100644 --- a/libtemplate/parameter.c +++ b/libtemplate/parameter.c @@ -342,20 +342,24 @@ int cConditionalParameter::EvaluateParameter(string token, map < string, int > * map < string, int >::iterator hitGlobals = globals->intVars.find(token); if (hitGlobals != globals->intVars.end()) { return hitGlobals->second; - } else { - //then check tokens - if (intTokens) { - map < string, int >::iterator hit = intTokens->find(token); - if (hit != intTokens->end()) { - return hit->second; - } + } + //then check custom tokens + map < string, int >::iterator hitCustomTokens = globals->customIntTokens.find(token); + if (hitCustomTokens != globals->customIntTokens.end()) { + return hitCustomTokens->second; + } + //then check tokens + if (intTokens) { + map < string, int >::iterator hit = intTokens->find(token); + if (hit != intTokens->end()) { + return hit->second; } - if (stringTokens) { - map < string, string >::iterator hit = stringTokens->find(token); - if (hit != stringTokens->end()) { - string value = hit->second; - return atoi(value.c_str()); - } + } + if (stringTokens) { + map < string, string >::iterator hit = stringTokens->find(token); + if (hit != stringTokens->end()) { + string value = hit->second; + return atoi(value.c_str()); } } return 0;