forked from github/server
allow a maxnmr setting in eressea.ini to override the nmr.timeout rule.
This commit is contained in:
parent
ed46a24f58
commit
9ba255e269
3 changed files with 26 additions and 2 deletions
10
src/laws.c
10
src/laws.c
|
@ -141,7 +141,15 @@ bool IsImmune(const faction * f)
|
|||
|
||||
int NMRTimeout(void)
|
||||
{
|
||||
return config_get_int("nmr.timeout", 0);
|
||||
int nmr_timeout = config_get_int("nmr.timeout", 0);
|
||||
int ini_timeout = config_get_int("game.maxnmr", 0);
|
||||
if (nmr_timeout > 0) {
|
||||
if (ini_timeout > nmr_timeout) {
|
||||
return nmr_timeout;
|
||||
}
|
||||
return (ini_timeout > 0) ? ini_timeout : nmr_timeout;
|
||||
}
|
||||
return ini_timeout;
|
||||
}
|
||||
|
||||
bool LongHunger(const struct unit *u)
|
||||
|
|
|
@ -1745,6 +1745,20 @@ static void test_cansee_sphere(CuTest *tc) {
|
|||
test_teardown();
|
||||
}
|
||||
|
||||
static void test_nmr_timeout(CuTest *tc) {
|
||||
test_setup();
|
||||
CuAssertIntEquals(tc, 0, NMRTimeout());
|
||||
config_set_int("nmr.timeout", 5);
|
||||
CuAssertIntEquals(tc, 5, NMRTimeout());
|
||||
config_set_int("game.maxnmr", 4);
|
||||
CuAssertIntEquals(tc, 4, NMRTimeout());
|
||||
config_set("nmr.timeout", NULL);
|
||||
CuAssertIntEquals(tc, 4, NMRTimeout());
|
||||
config_set("game.maxnmr", NULL);
|
||||
CuAssertIntEquals(tc, 0, NMRTimeout());
|
||||
test_teardown();
|
||||
}
|
||||
|
||||
CuSuite *get_laws_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
|
@ -1816,6 +1830,7 @@ CuSuite *get_laws_suite(void)
|
|||
SUITE_ADD_TEST(suite, test_cansee);
|
||||
SUITE_ADD_TEST(suite, test_cansee_ring);
|
||||
SUITE_ADD_TEST(suite, test_cansee_sphere);
|
||||
SUITE_ADD_TEST(suite, test_nmr_timeout);
|
||||
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ static void load_inifile(void)
|
|||
static const char * valid_keys[] = {
|
||||
"game.id",
|
||||
"game.deadlog",
|
||||
"game.maxnmr",
|
||||
"game.name",
|
||||
"game.start",
|
||||
"game.locale",
|
||||
|
@ -257,7 +258,7 @@ static int parse_args(int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BACKTRACE)
|
||||
#ifdef HAVE_BACKTRACE
|
||||
#include <execinfo.h>
|
||||
#include <signal.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue