diff --git a/s/runtests b/s/runtests index 7b55cda78..ea192b98b 100755 --- a/s/runtests +++ b/s/runtests @@ -19,4 +19,5 @@ $ROOT/$BIN_DIR/eressea/test_eressea cd $ROOT [ -e eressea.ini ] || ln -sf conf/eressea.ini $ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests.lua +$ROOT/$BIN_DIR/eressea/eressea -v0 scripts/run-tests-e3.lua cd $OLDWPD diff --git a/scripts/run-tests-e3.lua b/scripts/run-tests-e3.lua new file mode 100644 index 000000000..3e5ecdcb2 --- /dev/null +++ b/scripts/run-tests-e3.lua @@ -0,0 +1,19 @@ +-- new tests 2014-06-11 + +path = 'scripts' +if config.source_dir ~= nil then + path = config.source_dir .. '/' .. path +end +package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' + +config.rules = 'e3' + +require 'eressea' +require 'eressea.path' +require 'eressea.xmlconf' +require 'tests.e3' +require 'lunit' + +eressea.settings.set("rules.alliances", "0") +rules = require('eressea.' .. config.rules) +lunit.main() diff --git a/scripts/tests/e3/castles.lua b/scripts/tests/e3/castles.lua index c8c1bc83b..1aa2bb17c 100644 --- a/scripts/tests/e3/castles.lua +++ b/scripts/tests/e3/castles.lua @@ -3,25 +3,25 @@ require "lunit" module("tests.e3.castles", package.seeall, lunit.testcase ) function setup() - eressea.free_game() + eressea.game.reset() end function test_small_castles() - local r = region.create(0, 0, "plain") - local f1 = faction.create("noreply@eressea.de", "human", "de") - local u1 = unit.create(f1, r, 1) - local f2 = faction.create("noreply@eressea.de", "halfling", "de") - local u2 = unit.create(f2, r, 1) - u1:add_item("money", 10000) + local r = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 1) + local f2 = faction.create("noreply@eressea.de", "halfling", "de") + local u2 = unit.create(f2, r, 1) + u1:add_item("money", 10000) - local b = building.create(r, "castle") - u2.building = b - u1.building = b + local b = building.create(r, "castle") + u2.building = b + u1.building = b - b.owner = u2 - assert_equal("site", b:get_typename(7)) - assert_equal("fortification", b:get_typename(8)) - b.owner = u1 - assert_equal("site", b:get_typename(9)) - assert_equal("fortification", b:get_typename(10)) + b.owner = u2 + assert_equal("site", b:get_typename(7)) + assert_equal("fortification", b:get_typename(8)) + b.owner = u1 + assert_equal("site", b:get_typename(9)) + assert_equal("fortification", b:get_typename(10)) end diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua new file mode 100644 index 000000000..03d5ded81 --- /dev/null +++ b/scripts/tests/e3/init.lua @@ -0,0 +1,3 @@ +require 'tests.e3.castles' +require 'tests.e3.stealth' +require 'tests.e3.spells' diff --git a/scripts/tests/e3/spells.lua b/scripts/tests/e3/spells.lua index a96607a96..21a743646 100644 --- a/scripts/tests/e3/spells.lua +++ b/scripts/tests/e3/spells.lua @@ -3,7 +3,7 @@ require "lunit" module("tests.e3.spells", package.seeall, lunit.testcase) function setup() - eressea.free_game() + eressea.game.reset() eressea.settings.set("magic.fumble.enable", "0") eressea.settings.set("nmr.removenewbie", "0") eressea.settings.set("nmr.timeout", "0") @@ -11,7 +11,6 @@ function setup() end function test_blessedharvest_lasts_n_turn() - eressea.free_game() local r = region.create(0, 0, "plain") local f = faction.create("noreply@eressea.de", "halfling", "de") local u = unit.create(f, r) diff --git a/scripts/tests/e3/stealth.lua b/scripts/tests/e3/stealth.lua index a5f8cdcb5..687e2bfe4 100644 --- a/scripts/tests/e3/stealth.lua +++ b/scripts/tests/e3/stealth.lua @@ -6,20 +6,20 @@ local f local u function setup() - eressea.free_game() - eressea.settings.set("rules.economy.food", "4") + eressea.game.reset() + eressea.settings.set("rules.economy.food", "4") - local r = region.create(0,0, "plain") - f = faction.create("stealthy@eressea.de", "human", "de") - u = unit.create(f, r, 1) - f = faction.create("stealth@eressea.de", "human", "de") + local r = region.create(0,0, "plain") + f = faction.create("stealth1@eressea.de", "human", "de") + u = unit.create(f, r, 1) + f = faction.create("stealth2@eressea.de", "human", "de") end function test_stealth_faction_on() u:clear_orders() - u:add_order("TARNEN PARTEI") + u:add_order("TARNE PARTEI") - eressea.settings.set("rules.stealth.faction", 1) + eressea.settings.set("rules.stealth.faction", 1) process_orders() assert_not_match("Partei", report.report_unit(u, f)) assert_match("anonym", report.report_unit(u, f)) @@ -27,9 +27,9 @@ end function test_stealth_faction_off() u:clear_orders() - u:add_order("TARNEN PARTEI") + u:add_order("TARNE PARTEI") - eressea.settings.set("rules.stealth.faction", 0) + eressea.settings.set("rules.stealth.faction", 0) process_orders() assert_match("Partei", report.report_unit(u, f)) assert_not_match("anonym", report.report_unit(u, f)) diff --git a/src/bindings.c b/src/bindings.c index 87eab4c34..6021339fd 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -514,6 +514,7 @@ static void reset_game(void) for (f = factions; f; f = f->next) { f->flags &= FFL_SAVEMASK; } + init_locales(); } static int tolua_process_orders(lua_State * L) diff --git a/src/spy.c b/src/spy.c index 5b96849c5..5531eb684 100644 --- a/src/spy.c +++ b/src/spy.c @@ -210,12 +210,13 @@ void set_factionstealth(unit * u, faction * f) int setstealth_cmd(unit * u, struct order *ord) { + char token[64]; const char *s; int level, rule; const race *trace; init_order(ord); - s = getstrtoken(); + s = gettoken(token, sizeof(token)); /* Tarne ohne Parameter: Setzt maximale Tarnung */ @@ -286,7 +287,7 @@ int setstealth_cmd(unit * u, struct order *ord) /* TARNE PARTEI is disabled */ break; } - s = getstrtoken(); + s = gettoken(token, sizeof(token)); if (rule & 1) { if (!s || *s == 0) { fset(u, UFL_ANON_FACTION); @@ -299,13 +300,13 @@ int setstealth_cmd(unit * u, struct order *ord) } if (rule & 2) { if (get_keyword(s, u->faction->locale) == K_NUMBER) { - const char *s2 = getstrtoken(); + s = gettoken(token, sizeof(token)); int nr = -1; - if (s2) { - nr = atoi36(s2); + if (s) { + nr = atoi36(s); } - if (!s2 || *s2 == 0 || nr == u->faction->no) { + if (!s || *s == 0 || nr == u->faction->no) { a_removeall(&u->attribs, &at_otherfaction); break; }