forked from github/server
bug 2292: set mailcmd from eressea.ini
this fixes https://bugs.eressea.de/view.php?id=2292
This commit is contained in:
parent
45854851ae
commit
4502141c5b
|
@ -833,17 +833,21 @@ const char * game_name(void)
|
|||
return param ? param : global.gamename;
|
||||
}
|
||||
|
||||
const char * game_name_upper(void)
|
||||
const char * game_mailcmd(void)
|
||||
{
|
||||
const char *param = config_get("game.mailcmd");
|
||||
if (!param) {
|
||||
static char result[32]; /* FIXME: static result */
|
||||
char *r = result;
|
||||
const char *param = game_name();
|
||||
const char *c = param;
|
||||
while (*c && (result+sizeof(result))>r) {
|
||||
*r++ = (char)toupper(*c++);
|
||||
const char *c;
|
||||
param = game_name();
|
||||
for (c = param; *c && (result + sizeof(result)) > r; ++c) {
|
||||
*r++ = (char)toupper(*c);
|
||||
}
|
||||
*r = '\0';
|
||||
return result;
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
int game_id(void) {
|
||||
|
|
|
@ -51,7 +51,7 @@ extern "C" {
|
|||
param_t getparam(const struct locale *lang);
|
||||
|
||||
const char * game_name(void);
|
||||
const char * game_name_upper(void);
|
||||
const char * game_mailcmd(void);
|
||||
int game_id(void);
|
||||
/* returns a value between [0..xpct_2], generated with two dice */
|
||||
|
||||
|
|
|
@ -245,7 +245,6 @@ static void test_config_inifile(CuTest *tc) {
|
|||
config_set_from(ini);
|
||||
CuAssertStrEquals(tc, "Eressea", config_get("game.name"));
|
||||
CuAssertStrEquals(tc, "Eressea", game_name());
|
||||
CuAssertStrEquals(tc, "ERESSEA", game_name_upper());
|
||||
CuAssertIntEquals(tc, 42, game_id());
|
||||
iniparser_freedict(ini);
|
||||
test_cleanup();
|
||||
|
@ -274,6 +273,18 @@ static void test_findparam(CuTest *tc) {
|
|||
test_cleanup();
|
||||
}
|
||||
|
||||
static void test_game_mailcmd(CuTest *tc) {
|
||||
test_setup();
|
||||
CuAssertStrEquals(tc, "Eressea", game_name());
|
||||
CuAssertStrEquals(tc, "ERESSEA", game_mailcmd());
|
||||
config_set("game.name", "Hodor");
|
||||
CuAssertStrEquals(tc, "Hodor", game_name());
|
||||
CuAssertStrEquals(tc, "HODOR", game_mailcmd());
|
||||
config_set("game.mailcmd", "ERESSEA");
|
||||
CuAssertStrEquals(tc, "ERESSEA", game_mailcmd());
|
||||
test_cleanup();
|
||||
}
|
||||
|
||||
CuSuite *get_config_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -287,6 +298,7 @@ CuSuite *get_config_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_getunit);
|
||||
SUITE_ADD_TEST(suite, test_read_unitid);
|
||||
SUITE_ADD_TEST(suite, test_default_order);
|
||||
SUITE_ADD_TEST(suite, test_game_mailcmd);
|
||||
SUITE_ADD_TEST(suite, test_rules);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -1945,7 +1945,7 @@ static void eval_regions(struct opstack **stack, const void *userdata)
|
|||
const char *get_mailcmd(const struct locale *loc)
|
||||
{
|
||||
static char result[64]; /* FIXME: static return buffer */
|
||||
snprintf(result, sizeof(result), "%s %d %s", game_name_upper(), game_id(), LOC(loc, "mailcmd"));
|
||||
snprintf(result, sizeof(result), "%s %d %s", game_mailcmd(), game_id(), LOC(loc, "mailcmd"));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue