add debug warning for unknown argument keywords

"weapon asault" will now print a warning to console.
This commit is contained in:
ac-stef
2015-03-24 02:06:19 +01:00
parent 7b607a6c43
commit b4b1c0bf91
2 changed files with 11 additions and 3 deletions
+6 -3
View File
@@ -463,6 +463,11 @@ char *parseword(const char *&p, int arg, int &infix) // pa
char *conc(const char **w, int n, bool space)
{
if(n < 0)
{ // auto-determine number of strings
n = 0;
while(w[n] && w[n][0]) n++;
}
int len = space ? max(n-1, 0) : 0;
loopj(n) len += (int)strlen(w[j]);
char *r = newstring("", len);
@@ -1745,9 +1750,7 @@ void listoptions(char *s)
const char *optionnames[] = { "entities", "ents", "weapons", "teamnames", "teamnames-abbrv", "punctuations", "crosshairnames", "" };
const char **optionlists[] = { optionnames, entnames + 1, entnames + 1, gunnames, teamnames, teamnames_s, punctnames, crosshairnames };
const char **listp = optionlists[getlistindex(s, optionnames, true, -1) + 1];
int num = 0;
while(listp[num] && listp[num][0]) num++;
commandret = conc(listp, num, true);
commandret = conc(listp, -1, true);
}
COMMAND(listoptions, "s");
+5
View File
@@ -432,6 +432,11 @@ int getlistindex(const char *key, const char *list[], bool acceptnumeric, int de
int i = (int)strtol(key, NULL, 0);
if(i >= 0 && i < max) return i;
}
#if !defined(STANDALONE) && defined(_DEBUG)
char *opts = conc(list, -1, true);
if(*key) clientlogf("warning: unknown token \"%s\" (not in list [%s])", key, opts);
delstring(opts);
#endif
return deflt;
}