diff --git a/configure b/configure index 930b90d45..220805263 100755 --- a/configure +++ b/configure @@ -1,12 +1,6 @@ #!/bin/sh git submodule update --init -MACHINE=`uname -m` -[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" -[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" -[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" -[ -z "$JOBS" ] && JOBS=$(nproc) -BIN_DIR="build-$MACHINE-$CC-Debug" DISTCC=`which distcc` if [ ! -z "$DISTCC" ] ; then JOBS=`distcc -j` @@ -19,8 +13,6 @@ fi fi echo "Building with $CC and $JOBS jobs" -mkdir -p $BIN_DIR -cd $BIN_DIR -CC="$CC" ../s/cmake-init +CC="$CC" s/cmake-init make -j$JOBS make test diff --git a/src/bind_config.c b/src/bind_config.c index 19e99ec77..e0930481f 100644 --- a/src/bind_config.c +++ b/src/bind_config.c @@ -36,8 +36,9 @@ int config_parse(const char *json) int line; char buffer[10]; const char *xp = json, *lp, *ep = cJSON_GetErrorPtr(); - for (line=0,lp=xp;xp && xp=ep) break; } xp = (ep > json + 10) ? ep - 10 : json; strncpy(buffer, xp, sizeof(buffer)); diff --git a/src/kernel/config.c b/src/kernel/config.c index 5aaf90801..4d0fcacfa 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -1161,21 +1161,24 @@ int findoption(const char *s, const struct locale *lang) param_t findparam(const char *s, const struct locale * lang) { - param_t result = NOPARAM; - char buffer[64]; - char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), s); - - if (str && *str) { - int i; - const void * match; - void **tokens = get_translations(lang, UT_PARAMS); - critbit_tree *cb = (critbit_tree *)*tokens; - if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { - cb_get_kv(match, &i, sizeof(int)); - result = (param_t)i; + param_t result = NOPARAM; + char buffer[64]; + char * str = transliterate(buffer, sizeof(buffer)-sizeof(int), s); + + if (str && *str) { + int i; + const void * match; + void **tokens = get_translations(lang, UT_PARAMS); + critbit_tree *cb = (critbit_tree *)*tokens; + if (!cb) { + log_error_n("no parameters defined in locale %s", locale_name(lang)); + } + else if (cb_find_prefix(cb, str, strlen(str), &match, 1, 0)) { + cb_get_kv(match, &i, sizeof(int)); + result = (param_t)i; + } } - } - return result; + return result; } param_t findparam_ex(const char *s, const struct locale * lang) diff --git a/tests/init.lua b/tests/init.lua index 032bf94ec..e54c2229f 100644 --- a/tests/init.lua +++ b/tests/init.lua @@ -7,3 +7,4 @@ require "tests.ships" require "tests.study" require "tests.movement" require "tests.castles" +require "tests.spells" diff --git a/tests/spells.lua b/tests/spells.lua new file mode 100644 index 000000000..0c6333569 --- /dev/null +++ b/tests/spells.lua @@ -0,0 +1,47 @@ +require "lunit" + +module("tests.spells", package.seeall, lunit.testcase) + +function setup() + eressea.game.reset() + eressea.settings.set("nmr.removenewbie", "0") + eressea.settings.set("nmr.timeout", "0") + conf = [[{ + "races": { + "human" : {} + }, + "terrains" : { + "plain": { "flags" : [ "land", "walk", "sail" ] } + }, + "spells" : { + "resist_magic" : { + "index" : 97, + "parameters" : "u+" + } + }, + "keywords" : { + "de" : { + "cast" : "ZAUBERE" + } + }, + "strings" : { + "de" : { + "harbour" : "Hafen" + } + } + }]] + + eressea.config.reset() + assert(eressea.config.parse(conf)==0) +end + +function test_antimagic_visibility() + local r = region.create(0, 0, "plain") + local f1 = faction.create("test@example.com", "human", "de") + local mage = unit.create(f1, r, 1) + local target = unit.create(f1, r, 1) + mage:set_skill("magic", 10) + mage:add_spell("resist_magic") + mage:add_order("ZAUBERE Antimagie " .. target.id) + process_orders() +end