diff --git a/conf/e2/config.json b/conf/e2/config.json
index f9f9b2df0..46ee01497 100644
--- a/conf/e2/config.json
+++ b/conf/e2/config.json
@@ -21,9 +21,7 @@
"GiveRestriction": 3,
"hunger.long": true,
"init_spells": 0,
- "world.era": 2,
- "seed.population.min": 8,
- "seed.population.max": 8,
+ "game.era": 2,
"rules.reserve.twophase": true,
"rules.give.max_men": -1,
"rules.check_overload": false,
diff --git a/conf/e3/config.json b/conf/e3/config.json
index a42961e03..beb45f35d 100644
--- a/conf/e3/config.json
+++ b/conf/e3/config.json
@@ -51,9 +51,7 @@
"recruit.allow_merge": true,
"study.expensivemigrants": true,
"study.speedup": 2,
- "world.era": 3,
- "seed.population.min": 8,
- "seed.population.max": 8,
+ "game.era": 3,
"rules.reserve.twophase": true,
"rules.owners.force_leave": false,
"rules.wage.function": 2,
diff --git a/conf/keywords.json b/conf/keywords.json
index 7117217d7..4c9fa905d 100644
--- a/conf/keywords.json
+++ b/conf/keywords.json
@@ -2,6 +2,7 @@
"keywords": {
"en" : {
"grow": [ "GROW", "BREED", "PLANT" ],
+ "promote": ["PROMOTE", "PROMOTION" ],
"combat": [ "COMBAT", "FIGHT" ]
},
"de": {
diff --git a/res/adamantium.xml b/res/adamantium.xml
index 77e138f77..e1f0643e2 100644
--- a/res/adamantium.xml
+++ b/res/adamantium.xml
@@ -5,7 +5,8 @@
-
-
+
+
diff --git a/res/core/en/strings.xml b/res/core/en/strings.xml
index 14b2b817d..dbc4dc611 100644
--- a/res/core/en/strings.xml
+++ b/res/core/en/strings.xml
@@ -1496,9 +1496,6 @@
PREFIX
-
- PROMOTION
-
CLAIM
diff --git a/res/core/resources/laen.xml b/res/core/resources/laen.xml
index 4099f5ca9..e584fe485 100644
--- a/res/core/resources/laen.xml
+++ b/res/core/resources/laen.xml
@@ -3,5 +3,6 @@
-
-
+
+
diff --git a/scripts/tests/common.lua b/scripts/tests/common.lua
index dc449903d..08a7ca94f 100644
--- a/scripts/tests/common.lua
+++ b/scripts/tests/common.lua
@@ -5,6 +5,10 @@ local function _test_create_ship(r)
return s
end
+local function create_faction(race)
+ return faction.create(race, race .. '@eressea.de', "de")
+end
+
local function one_unit(r, f)
local u = unit.create(f, r, 1)
u:add_item("money", u.number * 100)
@@ -17,8 +21,8 @@ local function two_units(r, f1, f2)
end
local function two_factions()
- local f1 = faction.create("human", "one@eressea.de", "de")
- local f2 = faction.create("elf", "two@eressea.de", "de")
+ local f1 = create_faction('human')
+ local f2 = create_faction('elf')
return f1, f2
end
@@ -44,7 +48,7 @@ end
function test_flags()
local r = region.create(0, 0, "plain")
- local f = faction.create("halfling", "flags@eressea.de", "de")
+ local f = create_faction('halfling')
local u = unit.create(f, r, 1)
local no = itoa36(f.id)
local flags = 50332673
@@ -62,7 +66,7 @@ function test_elvenhorse_requires_riding_5()
local r = region.create(0, 0, "plain")
region.create(1, 0, "plain")
local goal = region.create(2, 0, "plain")
- local f = faction.create("halfling", "riding@eressea.de", "de")
+ local f = create_faction('halfling')
local u = unit.create(f, r, 1)
u:add_item("elvenhorse", 1)
u:set_skill("riding", 6)-- halfling has -1 modifier
@@ -76,7 +80,7 @@ function test_cannot_ride_elvenhorse_without_enough_skill()
local r = region.create(0, 0, "plain")
local goal = region.create(1, 0, "plain")
region.create(2, 0, "plain")
- local f = faction.create("halfling", "elvenhorse@eressea.de", "de")
+ local f = create_faction('halfling')
local u = unit.create(f, r, 1)
u:add_item("elvenhorse", 1)
u:set_skill("riding", 5) -- halfling has -1 modifier
@@ -96,7 +100,7 @@ end
function test_demon_food()
local r = region.create(0, 0, "plain")
- local f = faction.create("demon", "demonfood@eressea.de", "de")
+ local f = create_faction('demon')
local u = unit.create(f, r, 1)
local p = r:get_resource("peasant")
r:set_resource("peasant", 2000)
@@ -136,7 +140,7 @@ function test_plane()
local nx, ny = plane.normalize(pl, 4, 4)
assert_equal(nx, -3, "normalization failed")
assert_equal(ny, -3, "normalization failed")
- local f = faction.create("human", "plan@eressea.de", "de")
+ local f = create_faction('human')
f.id = atoi36("tpla")
local r, x, y
for x = -3, 3 do for y = -3, 3 do
@@ -155,7 +159,7 @@ end
function test_read_write()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "readwrite@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r)
u.number = 2
local fno = f.id
@@ -184,7 +188,7 @@ end
function test_descriptions()
local info = "Descriptions can be very long. Bug 1984 behauptet, dass es Probleme gibt mit Beschreibungen die laenger als 120 Zeichen sind. This description is longer than 120 characters."
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "descriptions@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
local s = _test_create_ship(r)
local b = building.create(r, "castle")
@@ -236,7 +240,7 @@ end
function test_faction()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "testfaction@eressea.de", "de")
+ local f = create_faction('human')
assert(f)
f.info = "Spazz"
assert(f.info=="Spazz")
@@ -259,7 +263,7 @@ end
function test_unit()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "testunit@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r)
u.number = 20
u.name = "Enno"
@@ -292,7 +296,7 @@ end
function test_building()
local u
- local f = faction.create("human", "testbuilding@eressea.de", "de")
+ local f = create_faction('human')
local r = region.create(0, 0, "plain")
local b = building.create(r, "castle")
u = unit.create(f, r)
@@ -318,7 +322,7 @@ end
function test_message()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "testmessage@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r)
local msg = message.create("item_create_spell")
msg:set_unit("mage", u)
@@ -346,7 +350,7 @@ function test_events()
plain = region.create(0, 0, "plain")
skill = 8
- f = faction.create("elf", "noreply2@eressea.de", "de")
+ f = create_faction('elf')
f.age = 20
u = unit.create(f, plain)
@@ -356,7 +360,7 @@ function test_events()
u:add_order("NUMMER PARTEI test")
u:add_handler("message", msg_handler)
msg = "BOTSCHAFT EINHEIT " .. itoa36(u.id) .. " Du~Elf~stinken"
- f = faction.create("elf", "noreply3@eressea.de", "de")
+ f = create_faction('elf')
f.age = 20
u = unit.create(f, plain)
@@ -371,7 +375,7 @@ end
function test_renumber_ship()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply4@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r)
local s = ship.create(r, config.ships[1])
u.ship = s
@@ -386,7 +390,7 @@ end
function test_recruit2()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply4@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r)
u.number = 1
u:add_item("money", 2000)
@@ -401,7 +405,7 @@ end
function test_guard()
region.create(1, 0, "plain")
local r = region.create(0, 0, "plain")
- local f1 = faction.create("human", "noreply5@eressea.de", "de")
+ local f1 = create_faction('human')
f1.age = 20
local u1 = unit.create(f1, r, 10)
u1:add_item("sword", 10)
@@ -411,7 +415,7 @@ function test_guard()
u1:add_order("NACH O")
u1.name="Kalle Pimp"
- local f2 = faction.create("human", "noreply6@eressea.de", "de")
+ local f2 = create_faction('human')
f2.age = 20
local u2 = unit.create(f2, r, 1)
local u3 = unit.create(f2, r, 1)
@@ -429,7 +433,7 @@ end
function test_recruit()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply7@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r)
u.number = 1
local n = 3
@@ -445,7 +449,7 @@ end
function test_produce()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply8@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
u:clear_orders()
local sword = config.get_resource('sword')
@@ -460,7 +464,7 @@ end
function test_work()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply9@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
u:add_item("money", u.number * 10) -- humans cost 10
u:set_skill("herbalism", 5)
@@ -473,7 +477,7 @@ end
function test_upkeep()
eressea.settings.set("rules.food.flags", "0")
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply10@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 5)
u:add_item("money", u.number * 11)
u:clear_orders()
@@ -485,7 +489,7 @@ end
function test_id()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply11@eressea.de", "de")
+ local f = create_faction('human')
f.id = atoi36("42")
assert_not_equal(f, get_faction(42))
assert_equal(f, get_faction("42"))
@@ -521,7 +525,7 @@ function test_mallorn()
m:set_resource("tree", 100)
assert_equal(100, m:get_resource("tree"))
- local f = faction.create("human", "noreply13@eressea.de", "de")
+ local f = create_faction('human')
local u1 = unit.create(f, r, 1)
u1:add_item("money", u1.number * 100)
@@ -558,7 +562,7 @@ function test_coordinate_translation()
local pl = plane.create(1, 500, 500, 1001, 1001) -- astralraum
local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath
local r = region.create(1000, 1000, "plain")
- local f = faction.create("human", "noreply14@eressea.de", "de")
+ local f = create_faction('human')
assert_not_equal(nil, r)
assert_equal(r.x, 1000)
assert_equal(r.y, 1000)
@@ -604,8 +608,8 @@ end
function test_building_other()
local r = region.create(0,0, "plain")
- local f1 = faction.create("human", "noreply17@eressea.de", "de")
- local f2 = faction.create("human", "noreply18@eressea.de", "de")
+ local f1 = create_faction('human')
+ local f2 = create_faction('human')
local b = building.create(r, "castle")
b.size = 10
local u1 = unit.create(f1, r, 3)
@@ -632,7 +636,7 @@ end
local function _test_create_laen()
eressea.settings.set("rules.terraform.all", "1")
local r = region.create(0,0, "mountain")
- local f1 = faction.create("human", "noreply19@eressea.de", "de")
+ local f1 = create_faction('human')
local u1 = unit.create(f1, r, 1)
r:set_resource("laen", 50)
return r, u1
@@ -671,7 +675,7 @@ end
function test_mine()
local r = region.create(0,0, "mountain")
- local f1 = faction.create("human", "noreply20@eressea.de", "de")
+ local f1 = create_faction('human')
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 1000)
@@ -692,9 +696,9 @@ end
function test_guard_resources()
-- this is not quite http://bugs.eressea.de/view.php?id=1756
local r = region.create(0,0, "mountain")
- local f1 = faction.create("human", "noreply21@eressea.de", "de")
+ local f1 = create_faction('human')
f1.age=20
- local f2 = faction.create("human", "noreply22@eressea.de", "de")
+ local f2 = create_faction('human')
f2.age=20
local u1 = unit.create(f1, r, 1)
u1:add_item("money", 100)
@@ -722,7 +726,7 @@ end
function test_hero_hero_transfer()
local r = region.create(0,0, "mountain")
- local f = faction.create("human", "noreply23@eressea.de", "de")
+ local f = create_faction('human')
f.age=20
local UFL_HERO = 128
@@ -743,7 +747,7 @@ end
function test_hero_normal_transfer()
local r = region.create(0,0, "mountain")
- local f = faction.create("human", "noreply24@eressea.de", "de")
+ local f = create_faction('human')
f.age=20
local UFL_HERO = 128
@@ -762,7 +766,7 @@ end
function test_expensive_skills_cost_money()
local r = region.create(0,0, "mountain")
- local f = faction.create("elf", "noreply25@eressea.de", "de")
+ local f = create_faction('elf')
local u = unit.create(f, r, 1)
u:add_item("money", 10000)
u:clear_orders()
@@ -775,7 +779,7 @@ end
function test_food_is_consumed()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply26@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
u:add_item("money", 100)
u:clear_orders()
@@ -787,7 +791,7 @@ end
function test_food_can_override()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply27@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
u:add_item("money", 100)
u:clear_orders()
@@ -799,7 +803,7 @@ end
function test_swim_and_survive()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply28@eressea.de", "de")
+ local f = create_faction('human')
f.nam = "chaos"
local u = unit.create(f, r, 1)
process_orders()
@@ -813,7 +817,7 @@ end
function test_swim_and_die()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply29@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
local uid = u.id
process_orders()
@@ -828,7 +832,7 @@ function test_ride_with_horse()
region.create(1, 0, "plain")
region.create(2, 0, "plain")
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply30@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
u:add_item("horse", 1)
local horse_cfg = config.get_resource("horse")
@@ -851,7 +855,7 @@ function test_ride_with_horses_and_cart()
region.create(1, 0, "plain")
region.create(2, 0, "plain")
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply31@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
local horse_cfg = config.get_resource("horse")
local cart_cfg = config.get_resource("cart")
@@ -904,7 +908,7 @@ function test_walk_and_carry_the_cart()
region.create(1, 0, "plain")
local r = region.create(2, 0, "plain")
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply32@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 10)
u:add_item("cart", 1)
@@ -925,7 +929,7 @@ end
function test_bug_1795_limit()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply@eressea.de", "de")
+ local f = create_faction('human')
local u1 = one_unit(r,f)
u1:add_item("money", 100000000)
u1:add_order("REKRUTIEREN 9999")
@@ -940,7 +944,7 @@ end
function test_bug_1795_demons()
local r = region.create(0, 0, "plain")
- local f = faction.create("demon", "noreply@eressea.de", "de")
+ local f = create_faction('demon')
local u1 = one_unit(r,f)
r:set_resource("peasant", 2000)
local peasants = r:get_resource("peasant")
@@ -966,7 +970,7 @@ end
function test_parser()
local r = region.create(0, 0, "mountain")
- local f = faction.create("human", "noreply@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
local filename = "orders.txt"
@@ -991,7 +995,7 @@ end
function test_prefix()
local r0 = region.create(0, 0, "plain")
- local f1 = faction.create("human", "noreply@eressea.de", "de")
+ local f1 = create_faction('human')
local u1 = unit.create(f1, r0, 1)
set_order(u1, "PRAEFIX See")
@@ -1018,7 +1022,7 @@ end
function test_recruit()
local r = region.create(0, 0, "plain")
- local f = faction.create("human", "noreply@eressea.de", "de")
+ local f = create_faction('human')
local u = unit.create(f, r, 1)
u:add_item("money", 1000)
diff --git a/scripts/tests/e2/adamantium.lua b/scripts/tests/e2/adamantium.lua
index 8cb703f33..de9a2312f 100644
--- a/scripts/tests/e2/adamantium.lua
+++ b/scripts/tests/e2/adamantium.lua
@@ -10,10 +10,14 @@ function setup()
eressea.settings.set("rules.encounters", "0")
end
+local function create_faction(race)
+ return faction.create(race, race .. '@eressea.de', "de")
+end
+
local function _test_create_adamantium()
eressea.settings.set("rules.terraform.all", "1")
local r = region.create(0,0, "mountain")
- local f1 = faction.create("human", "noreply19@eressea.de", "de")
+ local f1 = create_faction('human')
local u1 = unit.create(f1, r, 1)
r:set_resource("adamantium", 50)
assert_equal(50, r:get_resource("adamantium"))
@@ -22,22 +26,21 @@ end
function test_adamantium1()
local r, u1 = _test_create_adamantium()
-
+
u1:add_item("money", 1000)
- u1:set_skill("mining", 8)
+ u1:set_skill("mining", 14)
u1:clear_orders()
u1:add_order("MACHEN Adamantium")
process_orders()
- -- adamantium needs a mine, so nothing happens:
assert_equal(0, u1:get_item("adamantium"))
end
function test_adamantium2()
local r, u1 = _test_create_adamantium()
- u1.id = 42
+
u1:add_item("money", 1000)
- u1:set_skill("mining", 8)
+ u1:set_skill("mining", 15)
u1:clear_orders()
u1:add_order("MACHEN Adamantium")
@@ -47,7 +50,7 @@ function test_adamantium2()
local adamantium = r:get_resource("adamantium")
process_orders()
- assert_equal(1, u1:get_item("adamantium"))
- assert_equal(adamantium - 1, r:get_resource("adamantium"))
+ assert_equal(2, u1:get_item("adamantium"))
+ assert_equal(adamantium - 2, r:get_resource("adamantium"))
end
diff --git a/scripts/tests/e3/init.lua b/scripts/tests/e3/init.lua
index 06e05e1ae..146d8733d 100644
--- a/scripts/tests/e3/init.lua
+++ b/scripts/tests/e3/init.lua
@@ -1,3 +1,4 @@
+require 'tests.e3.production'
require 'tests.e3.castles'
require 'tests.e3.stealth'
require 'tests.e3.spells'
diff --git a/scripts/tests/e3/production.lua b/scripts/tests/e3/production.lua
new file mode 100644
index 000000000..9cffe056a
--- /dev/null
+++ b/scripts/tests/e3/production.lua
@@ -0,0 +1,179 @@
+require "lunit"
+
+module("tests.e3.production", package.seeall, lunit.testcase )
+
+function setup()
+ eressea.game.reset()
+ eressea.settings.set("rules.food.flags", "4") -- food is free
+ eressea.settings.set("NewbieImmunity", "0")
+end
+
+local function create_faction(race)
+ return faction.create(race, race .. '@eressea.de', "de")
+end
+
+function test_laen_needs_mine()
+ -- some resources require a building
+ -- i.e. you cannot create laen without a mine
+ local r = region.create(0, 0, "mountain")
+ local f = create_faction('human')
+ local u = unit.create(f, r, 1)
+
+ turn_begin()
+ r:set_resource('laen', 100)
+ u:add_order("MACHE Laen")
+ u:set_skill('mining', 7)
+ turn_process()
+ assert_equal(0, u:get_item('laen'))
+ assert_equal(100, r:get_resource('laen'))
+ assert_equal(1, f:count_msg_type("error104")) -- requires building
+
+ u.building = building.create(u.region, "mine")
+ u.building.working = true
+ u.building.size = 10
+ turn_process()
+ assert_equal(1, u:get_item('laen'))
+ assert_equal(99, r:get_resource('laen'))
+
+ turn_end()
+end
+
+function test_mine_laen_bonus()
+ -- some buildings grant a bonus on the production skill
+ -- i.e. a mine adds +1 to mining
+ local r = region.create(0, 0, 'mountain')
+ local f = create_faction('human')
+ local u = unit.create(f, r, 1)
+
+ turn_begin()
+ r:set_resource('laen', 100)
+ assert_equal(100, r:get_resource('laen'))
+ u:add_order("MACHE Laen")
+ u:set_skill('mining', 6)
+ u.building = building.create(u.region, "mine")
+ u.building.working = true
+ u.building.size = 10
+ u.number = 2
+ turn_process() -- T6 is not enough for laen
+ assert_equal(0, u:get_item('laen'))
+ assert_equal(100, r:get_resource('laen'))
+ assert_equal(1, f:count_msg_type("manufacture_skills"))
+
+ u:set_skill('mining', 13)
+ turn_process() -- T13 is enough, the +1 produces one extra Laen
+ assert_equal(4, u:get_item('laen')) -- FAIL (3)
+ assert_equal(96, r:get_resource('laen'))
+
+ turn_end()
+end
+
+function test_mine_iron_bonus()
+ -- some buildings grant a bonus on the production skill
+ -- i.e. a mine adds +1 to mining iron
+ --
+ local r = region.create(0, 0, 'mountain')
+ local f = create_faction('human')
+ local u = unit.create(f, r, 1)
+
+ turn_begin()
+ r:set_resource('iron', 100)
+ assert_equal(100, r:get_resource('iron'))
+ u:add_order("MACHE Eisen")
+ u:set_skill('mining', 1)
+ u.building = building.create(u.region, "mine")
+ u.building.working = false
+ u.building.size = 10
+ u.number = 2
+ turn_process() -- iron can be made without a working mine
+ assert_equal(2, u:get_item('iron'))
+ assert_equal(98, r:get_resource('iron'))
+
+ u.building.working = true
+ turn_process()
+ assert_equal(6, u:get_item('iron'))
+ assert_equal(96, r:get_resource('iron'))
+
+ turn_end()
+end
+
+function test_quarry_bonus()
+ -- a quarry grants +1 to quarrying, and saves 50% stone
+ --
+ local r = region.create(0, 0, 'mountain')
+ local f = create_faction('human')
+ local u = unit.create(f, r, 1)
+
+ turn_begin()
+ r:set_resource('stone', 100)
+ assert_equal(100, r:get_resource('stone'))
+ u:add_order("MACHE Stein")
+ u:set_skill('quarrying', 1)
+ u.number = 2
+ u.building = building.create(u.region, 'quarry')
+ u.building.working = false
+ u.building.size = 10
+ turn_process()
+ assert_equal(2, u:get_item('stone'))
+ assert_equal(98, r:get_resource('stone'))
+
+ u.building.working = true
+ turn_process()
+ assert_equal(6, u:get_item('stone'))
+ assert_equal(96, r:get_resource('stone'))
+
+ turn_end()
+end
+
+function test_smithy_bonus_iron()
+-- a smithy adds +1 to weaponsmithing, and saves 50% iron
+ local r = region.create(0, 0, 'mountain')
+ local f = create_faction('human')
+ local u = unit.create(f, r, 1)
+
+ turn_begin()
+ u.building = building.create(u.region, 'smithy')
+ u.building.working = false
+ u.building.size = 10
+ u:set_skill('weaponsmithing', 5) -- needs 3
+ u:add_item('iron', 100)
+ u:add_order("MACHE Schwert")
+ turn_process() -- building disabled
+ assert_equal(1, u:get_item('sword'))
+ assert_equal(99, u:get_item('iron'))
+
+ u.building.working = true
+ turn_process() -- building active
+ assert_equal(3, u:get_item('sword'))
+ assert_equal(98, u:get_item('iron'))
+
+ turn_end()
+end
+
+function test_smithy_bonus_mixed()
+-- a smithy adds +1 to weaponsmithing, and saves 50% iron
+-- it does not save any other resource, though.
+ local r = region.create(0, 0, 'mountain')
+ local f = create_faction('human')
+ local u = unit.create(f, r, 1)
+
+ turn_begin()
+ u.building = building.create(u.region, 'smithy')
+ u.building.working = false
+ u.building.size = 10
+ u:set_skill('weaponsmithing', 5) -- needs 3
+ u:add_item('iron', 100)
+ u:add_item('log', 100)
+ u:add_order("MACHE Kriegsaxt")
+ turn_process() -- building disabled
+ assert_equal(1, u:get_item('axe'))
+ assert_equal(99, u:get_item('iron'))
+ assert_equal(99, u:get_item('log'))
+
+ u.building.working = true
+ turn_process() -- building active
+ assert_equal(3, u:get_item('axe'))
+ assert_equal(98, u:get_item('iron'))
+ assert_equal(97, u:get_item('log'))
+
+ turn_end()
+end
diff --git a/scripts/tests/laws.lua b/scripts/tests/laws.lua
index 8b64ffb7f..3a724a440 100644
--- a/scripts/tests/laws.lua
+++ b/scripts/tests/laws.lua
@@ -16,6 +16,7 @@ function setup()
"attack" : "ATTACKIERE",
"maketemp" : "MACHETEMP",
"end" : "ENDE",
+ "use" : "BENUTZEN",
"recruit" : "REKRUTIERE"
}
},
diff --git a/scripts/tests/orders.lua b/scripts/tests/orders.lua
index d88a59293..af0919640 100644
--- a/scripts/tests/orders.lua
+++ b/scripts/tests/orders.lua
@@ -20,6 +20,18 @@ function setup()
eressea.settings.set("NewbieImmunity", "0")
end
+function test_no_errors()
+ turn_begin()
+ u:add_order("!BENUTZEN 23 Yanxspirit")
+ turn_process()
+ assert_equal(0, f:count_msg_type('error43'))
+ u:clear_orders()
+ u:add_order("BENUTZEN 23 Yanxspirit")
+ turn_process()
+ assert_equal(1, f:count_msg_type('error43'))
+ turn_end()
+end
+
function test_learn()
u:add_order("LERNEN Hiebwaffen")
_G.process_orders()
diff --git a/src/bind_unit.c b/src/bind_unit.c
old mode 100755
new mode 100644
diff --git a/src/creport.c b/src/creport.c
index 14e6e8faa..4dfacad2c 100644
--- a/src/creport.c
+++ b/src/creport.c
@@ -1100,10 +1100,10 @@ static char *cr_output_resource(char *buf, const resource_type *rtype,
{
const char *name, *tname;
assert(rtype);
- name = resourcename(rtype, 1);
+ name = resourcename(rtype, NMF_PLURAL);
assert(name);
buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name));
- tname = LOC(loc, rtype->_name);
+ tname = LOC(loc, name);
assert(tname);
tname = translate(name, tname);
assert(tname);
@@ -1188,7 +1188,7 @@ void cr_output_resources(stream *out, const faction * f, const region *r, bool s
}
for (n = 0; n < size; ++n) {
if (result[n].level >= 0 && result[n].number >= 0) {
- const char * name = resourcename(result[n].rtype, result[n].number != 1);
+ const char * name = resourcename(result[n].rtype, 1);
assert(name);
stream_printf(out, "%d;%s\n", result[n].number, crtag(name));
}
@@ -1501,7 +1501,7 @@ report_computer(const char *filename, report_context * ctx, const char *bom)
static int rc_cache;
if (era < 0) {
- era = config_get_int("world.era", 1);
+ era = config_get_int("game.era", 1);
}
if (F == NULL) {
perror(filename);
diff --git a/src/creport.test.c b/src/creport.test.c
index 46e6e6967..e87de235e 100644
--- a/src/creport.test.c
+++ b/src/creport.test.c
@@ -11,6 +11,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -52,8 +53,15 @@ static void test_cr_unit(CuTest *tc) {
static void setup_resources(void) {
struct locale *lang;
+ item_type *itype;
test_setup();
+ itype = it_get_or_create(rt_get_or_create("stone"));
+ itype->rtype->flags = RTF_LIMITED | RTF_POOLED;
+ itype->construction = calloc(1, sizeof(construction));
+ itype->construction->skill = SK_QUARRYING;
+ itype->construction->minskill = 1;
+ rmt_create(itype->rtype);
init_resources();
lang = get_or_create_locale("de"); /* CR tags are translated from this */
locale_setstring(lang, "money", "Silber");
@@ -62,6 +70,8 @@ static void setup_resources(void) {
locale_setstring(lang, "horse_p", "Pferde");
locale_setstring(lang, "peasant", "Bauer");
locale_setstring(lang, "peasant_p", "Bauern");
+ locale_setstring(lang, "stone", "Stein");
+ locale_setstring(lang, "stone_p", "Steine");
locale_setstring(lang, "tree", "Blume");
locale_setstring(lang, "tree_p", "Blumen");
locale_setstring(lang, "sapling", "Schoessling");
@@ -77,25 +87,31 @@ static void test_cr_resources(CuTest *tc) {
char line[1024];
faction *f;
region *r;
-
+ unit *u;
+
setup_resources();
f = test_create_faction(0);
r = test_create_region(0, 0, 0);
+ u = test_create_unit(f, r);
+ set_level(u, SK_QUARRYING, 1);
r->land->horses = 1;
r->land->peasants = 200;
r->land->money = 300;
rsettrees(r, 0, 1);
rsettrees(r, 1, 2);
rsettrees(r, 2, 3);
+ region_setresource(r, get_resourcetype(R_STONE), 1);
mstream_init(&strm);
- cr_output_resources(&strm, f, r, false);
+ cr_output_resources(&strm, f, r, true);
strm.api->rewind(strm.handle);
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
CuAssertStrEquals(tc, "3;Baeume", line);
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
CuAssertStrEquals(tc, "2;Schoesslinge", line);
+ CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
+ CuAssertStrEquals(tc, "1;Steine", line);
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
@@ -132,6 +148,15 @@ static void test_cr_resources(CuTest *tc) {
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
CuAssertStrEquals(tc, "1;number", line);
+ CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
+ CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
+ CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
+ CuAssertStrEquals(tc, "\"Steine\";type", line);
+ CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
+ CuAssertStrEquals(tc, "1;skill", line);
+ CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
+ CuAssertStrEquals(tc, "1;number", line);
+
mstream_done(&strm);
test_cleanup();
}
diff --git a/src/economy.c b/src/economy.c
index ce174dd09..e3a6dc18d 100644
--- a/src/economy.c
+++ b/src/economy.c
@@ -1170,7 +1170,6 @@ static allocate_function get_allocator(const struct resource_type *rtype)
void split_allocations(region * r)
{
allocation_list **p_alist = &allocations;
- freset(r, RF_SELECT);
while (*p_alist) {
allocation_list *alist = *p_alist;
const resource_type *rtype = alist->type;
@@ -1178,7 +1177,6 @@ void split_allocations(region * r)
const item_type *itype = resource2item(rtype);
allocation **p_al = &alist->data;
- freset(r, RF_SELECT);
alloc(rtype, r, alist->data);
while (*p_al) {
@@ -1187,7 +1185,6 @@ void split_allocations(region * r)
assert(itype || !"not implemented for non-items");
i_change(&al->unit->items, itype, al->get);
produceexp(al->unit, itype->construction->skill, al->unit->number);
- fset(r, RF_SELECT);
}
if (al->want == INT_MAX)
al->want = al->get;
diff --git a/src/gmtool.c b/src/gmtool.c
index 148aafe6d..674e139f7 100644
--- a/src/gmtool.c
+++ b/src/gmtool.c
@@ -902,8 +902,8 @@ static void handlekey(state * st, int c)
new_players = read_newfactions(sbuffer);
}
cnormalize(&st->cursor, &nx, &ny);
- minpop = config_get_int("seed.population.min", 8);
- maxpop = config_get_int("seed.population.max", minpop);
+ minpop = config_get_int("editor.population.min", 8);
+ maxpop = config_get_int("editor.population.max", minpop);
if (maxpop > minpop) {
n = rng_int() % (maxpop - minpop) + minpop;
}
diff --git a/src/kernel/messages.c b/src/kernel/messages.c
index f74e9c0d7..d3cd4f99b 100644
--- a/src/kernel/messages.c
+++ b/src/kernel/messages.c
@@ -78,16 +78,14 @@ variant v)
struct message *msg_feedback(const struct unit *u, struct order *ord,
const char *name, const char *sig, ...)
{
- va_list marker;
const message_type *mtype = mt_find(name);
- char paramname[64];
- const char *ic = sig;
variant args[16];
variant var;
memset(args, 0, sizeof(args));
- if (ord == NULL)
- ord = u->thisorder;
+ if (ord && ord->_noerror) {
+ return NULL;
+ }
if (!mtype) {
log_warning("trying to create message of unknown type \"%s\"\n", name);
@@ -106,41 +104,46 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
var.v = (void *)ord;
arg_set(args, mtype, "command", var);
- va_start(marker, sig);
- while (*ic && !isalnum(*ic))
- ic++;
- while (*ic) {
- char *oc = paramname;
- int i;
+ if (sig) {
+ const char *ic = sig;
+ va_list marker;
- while (isalnum(*ic))
- *oc++ = *ic++;
- *oc = '\0';
-
- for (i = 0; i != mtype->nparameters; ++i) {
- if (!strcmp(paramname, mtype->pnames[i]))
- break;
- }
- if (i != mtype->nparameters) {
- if (mtype->types[i]->vtype == VAR_VOIDPTR) {
- args[i].v = va_arg(marker, void *);
- }
- else if (mtype->types[i]->vtype == VAR_INT) {
- args[i].i = va_arg(marker, int);
- }
- else {
- assert(!"unknown variant type");
- }
- }
- else {
- log_error("invalid parameter %s for message type %s\n", paramname, mtype->name);
- assert(!"program aborted.");
- }
+ va_start(marker, sig);
while (*ic && !isalnum(*ic))
ic++;
- }
- va_end(marker);
+ while (*ic) {
+ char paramname[64];
+ char *oc = paramname;
+ int i;
+ while (isalnum(*ic))
+ *oc++ = *ic++;
+ *oc = '\0';
+
+ for (i = 0; i != mtype->nparameters; ++i) {
+ if (!strcmp(paramname, mtype->pnames[i]))
+ break;
+ }
+ if (i != mtype->nparameters) {
+ if (mtype->types[i]->vtype == VAR_VOIDPTR) {
+ args[i].v = va_arg(marker, void *);
+ }
+ else if (mtype->types[i]->vtype == VAR_INT) {
+ args[i].i = va_arg(marker, int);
+ }
+ else {
+ assert(!"unknown variant type");
+ }
+ }
+ else {
+ log_error("invalid parameter %s for message type %s\n", paramname, mtype->name);
+ assert(!"program aborted.");
+ }
+ while (*ic && !isalnum(*ic))
+ ic++;
+ }
+ va_end(marker);
+ }
return msg_create(mtype, args);
}
@@ -248,8 +251,9 @@ void addmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
message * msg_error(const unit * u, struct order *ord, int mno) {
static char msgname[20];
- if (fval(u->faction, FFL_NPC))
- return 0;
+ if (fval(u->faction, FFL_NPC)) {
+ return NULL;
+ }
sprintf(msgname, "error%d", mno);
return msg_feedback(u, ord, msgname, "");
}
@@ -259,7 +263,9 @@ message * cmistake(const unit * u, struct order *ord, int mno, int mtype)
message * result;
UNUSED_ARG(mtype);
result = msg_error(u, ord, mno);
- ADDMSG(&u->faction->msgs, result);
+ if (result) {
+ ADDMSG(&u->faction->msgs, result);
+ }
return result;
}
@@ -267,7 +273,9 @@ void syntax_error(const struct unit *u, struct order *ord)
{
message * result;
result = msg_error(u, ord, 10);
- ADDMSG(&u->faction->msgs, result);
+ if (result) {
+ ADDMSG(&u->faction->msgs, result);
+ }
}
void free_messagelist(mlist *msgs)
diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c
index 7b0f2dd5e..cd301756d 100644
--- a/src/kernel/messages.test.c
+++ b/src/kernel/messages.test.c
@@ -1,6 +1,9 @@
#include
#include "messages.h"
+#include "unit.h"
+#include "order.h"
+
#include
#include
@@ -68,11 +71,27 @@ static void test_merge_split(CuTest *tc) {
test_cleanup();
}
+static void test_noerror(CuTest *tc) {
+ unit *u;
+ struct locale *lang;
+
+ test_setup();
+ lang = test_create_locale();
+ u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
+ u->thisorder = parse_order("!@move", lang);
+ CuAssertTrue(tc, u->thisorder->_persistent);
+ CuAssertTrue(tc, u->thisorder->_noerror);
+ CuAssertPtrEquals(tc, NULL, msg_error(u, u->thisorder, 100));
+ CuAssertPtrEquals(tc, NULL, msg_feedback(u, u->thisorder, "error_unit_not_found", NULL));
+ test_cleanup();
+}
+
CuSuite *get_messages_suite(void) {
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_missing_message);
SUITE_ADD_TEST(suite, test_merge_split);
SUITE_ADD_TEST(suite, test_message);
+ SUITE_ADD_TEST(suite, test_noerror);
return suite;
}
diff --git a/src/kernel/order.c b/src/kernel/order.c
index 776190b67..9e7a45991 100644
--- a/src/kernel/order.c
+++ b/src/kernel/order.c
@@ -99,6 +99,15 @@ char* get_command(const order *ord, char *sbuffer, size_t size) {
keyword_t kwd = ORD_KEYWORD(ord);
int bytes;
+ if (ord->_noerror) {
+ if (size > 0) {
+ *bufp++ = '!';
+ --size;
+ }
+ else {
+ WARN_STATIC_BUFFER();
+ }
+ }
if (ord->_persistent) {
if (size > 0) {
*bufp++ = '@';
@@ -159,6 +168,7 @@ order *copy_order(const order * src)
order *ord = (order *)malloc(sizeof(order));
ord->next = NULL;
ord->_persistent = src->_persistent;
+ ord->_noerror = src->_noerror;
ord->data = src->data;
++ord->data->_refcount;
return ord;
@@ -280,7 +290,7 @@ void close_orders(void) {
}
static order *create_order_i(keyword_t kwd, const char *sptr, bool persistent,
- const struct locale *lang)
+ bool noerror, const struct locale *lang)
{
order *ord = NULL;
int lindex;
@@ -313,6 +323,7 @@ static order *create_order_i(keyword_t kwd, const char *sptr, bool persistent,
ord = (order *)malloc(sizeof(order));
ord->_persistent = persistent;
+ ord->_noerror = noerror;
ord->next = NULL;
ord->data = create_data(kwd, sptr, lindex);
@@ -373,7 +384,7 @@ order *create_order(keyword_t kwd, const struct locale * lang,
else {
zBuffer[0] = 0;
}
- return create_order_i(kwd, zBuffer, false, lang);
+ return create_order_i(kwd, zBuffer, false, false, lang);
}
order *parse_order(const char *s, const struct locale * lang)
@@ -386,11 +397,12 @@ order *parse_order(const char *s, const struct locale * lang)
if (*s != 0) {
keyword_t kwd;
const char *sptr;
- bool persistent = false;
+ bool persistent = false, noerror = false;
const char * p;
- while (*s == '@') {
- persistent = true;
+ while (*s == '!' || *s=='@') {
+ if (*s=='!') noerror = true;
+ else if (*s == '@') persistent = true;
++s;
}
sptr = s;
@@ -407,7 +419,7 @@ order *parse_order(const char *s, const struct locale * lang)
if (kwd != NOKEYWORD) {
while (isspace(*(unsigned char *)sptr)) ++sptr;
s = sptr;
- return create_order_i(kwd, s, persistent, lang);
+ return create_order_i(kwd, s, persistent, noerror, lang);
}
}
return NULL;
diff --git a/src/kernel/order.h b/src/kernel/order.h
index 7f4b00a5e..bf4d02982 100644
--- a/src/kernel/order.h
+++ b/src/kernel/order.h
@@ -37,6 +37,7 @@ extern "C" {
/* do not access this data: */
struct order_data *data;
bool _persistent;
+ bool _noerror;
} order;
/* constructor */
diff --git a/src/kernel/order.test.c b/src/kernel/order.test.c
index f5eb51c6f..876d75b1e 100644
--- a/src/kernel/order.test.c
+++ b/src/kernel/order.test.c
@@ -14,14 +14,13 @@ static void test_create_order(CuTest *tc) {
order *ord;
struct locale * lang;
- test_cleanup();
- lang = get_or_create_locale("en");
+ test_setup();
+ lang = test_create_locale();
- locale_setstring(lang, "keyword::move", "MOVE");
ord = create_order(K_MOVE, lang, "NORTH");
CuAssertPtrNotNull(tc, ord);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
- CuAssertStrEquals(tc, "MOVE NORTH", get_command(ord, cmd, sizeof(cmd)));
+ CuAssertStrEquals(tc, "move NORTH", get_command(ord, cmd, sizeof(cmd)));
CuAssertIntEquals(tc, K_MOVE, init_order(ord));
CuAssertStrEquals(tc, "NORTH", getstrtoken());
@@ -34,19 +33,44 @@ static void test_parse_order(CuTest *tc) {
order *ord;
struct locale * lang;
- test_cleanup();
- lang = get_or_create_locale("en");
+ test_setup();
+ lang = test_create_locale();
- locale_setstring(lang, "keyword::move", "MOVE");
- init_keyword(lang, K_MOVE, "MOVE");
ord = parse_order("MOVE NORTH", lang);
CuAssertPtrNotNull(tc, ord);
+ CuAssertTrue(tc, !ord->_noerror);
+ CuAssertTrue(tc, !ord->_persistent);
CuAssertIntEquals(tc, K_MOVE, getkeyword(ord));
- CuAssertStrEquals(tc, "MOVE NORTH", get_command(ord, cmd, sizeof(cmd)));
+ CuAssertStrEquals(tc, "move NORTH", get_command(ord, cmd, sizeof(cmd)));
CuAssertIntEquals(tc, K_MOVE, init_order(ord));
CuAssertStrEquals(tc, "NORTH", getstrtoken());
free_order(ord);
+
+ ord = parse_order("!MOVE NORTH", lang);
+ CuAssertPtrNotNull(tc, ord);
+ CuAssertTrue(tc, ord->_noerror);
+ CuAssertTrue(tc, !ord->_persistent);
+ free_order(ord);
+
+ ord = parse_order("@MOVE NORTH", lang);
+ CuAssertPtrNotNull(tc, ord);
+ CuAssertTrue(tc, !ord->_noerror);
+ CuAssertTrue(tc, ord->_persistent);
+ free_order(ord);
+
+ ord = parse_order("@!MOVE NORTH", lang);
+ CuAssertPtrNotNull(tc, ord);
+ CuAssertTrue(tc, ord->_noerror);
+ CuAssertTrue(tc, ord->_persistent);
+ free_order(ord);
+
+ ord = parse_order("!@MOVE NORTH", lang);
+ CuAssertPtrNotNull(tc, ord);
+ CuAssertTrue(tc, ord->_noerror);
+ CuAssertTrue(tc, ord->_persistent);
+ free_order(ord);
+
test_cleanup();
}
@@ -81,7 +105,7 @@ static void test_parse_make_temp(CuTest *tc) {
lang = get_or_create_locale("en");
locale_setstring(lang, keyword(K_MAKE), "MAKE");
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
- locale_setstring(lang, "TEMP", "TEMP");
+ locale_setstring(lang, parameters[P_TEMP], "TEMP");
init_locale(lang);
ord = parse_order("M T herp", lang);
@@ -156,9 +180,9 @@ static void test_replace_order(CuTest *tc) {
struct locale * lang;
test_cleanup();
- lang = get_or_create_locale("en");
- orig = create_order(K_MAKE, lang, 0);
- repl = create_order(K_ALLY, lang, 0);
+ lang = test_create_locale();
+ orig = create_order(K_MAKE, lang, NULL);
+ repl = create_order(K_ALLY, lang, NULL);
replace_order(&orders, orig, repl);
CuAssertPtrEquals(tc, 0, orders);
orders = orig;
@@ -171,6 +195,25 @@ static void test_replace_order(CuTest *tc) {
test_cleanup();
}
+static void test_get_command(CuTest *tc) {
+ struct locale * lang;
+ order *ord;
+ char buf[64];
+
+ test_setup();
+ lang = test_create_locale();
+ ord = create_order(K_MAKE, lang, "iron");
+ CuAssertStrEquals(tc, "make iron", get_command(ord, buf, sizeof(buf)));
+ ord->_noerror = true;
+ CuAssertStrEquals(tc, "!make iron", get_command(ord, buf, sizeof(buf)));
+ ord->_persistent = true;
+ CuAssertStrEquals(tc, "!@make iron", get_command(ord, buf, sizeof(buf)));
+ ord->_noerror = false;
+ CuAssertStrEquals(tc, "@make iron", get_command(ord, buf, sizeof(buf)));
+ free_order(ord);
+ test_cleanup();
+}
+
CuSuite *get_order_suite(void)
{
CuSuite *suite = CuSuiteNew();
@@ -183,5 +226,6 @@ CuSuite *get_order_suite(void)
SUITE_ADD_TEST(suite, test_replace_order);
SUITE_ADD_TEST(suite, test_skip_token);
SUITE_ADD_TEST(suite, test_getstrtoken);
+ SUITE_ADD_TEST(suite, test_get_command);
return suite;
}
diff --git a/src/main.c b/src/main.c
index a9a8339d4..e67982108 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,6 +75,7 @@ static void load_inifile(void)
static const char * valid_keys[] = {
"game.id",
"game.name",
+ "game.start",
"game.locale",
"game.verbose",
"game.report",
@@ -82,9 +83,11 @@ static const char * valid_keys[] = {
"game.memcheck",
"game.email",
"game.mailcmd",
+ "game.era",
"game.sender",
"editor.color",
"editor.codepage",
+ "editor.population.",
"lua.",
NULL
};
diff --git a/src/monsters.c b/src/monsters.c
index 0d9857024..4edaeedea 100644
--- a/src/monsters.c
+++ b/src/monsters.c
@@ -493,18 +493,12 @@ static order *make_movement_order(unit * u, const region * target, int moves,
if (plan == NULL)
return NULL;
- bytes =
- (int)strlcpy(bufp,
- (const char *)LOC(u->faction->locale, keyword(K_MOVE)), size);
- if (wrptr(&bufp, &size, bytes) != 0)
- WARN_STATIC_BUFFER();
-
while (position != moves && plan[position + 1]) {
region *prev = plan[position];
region *next = plan[++position];
direction_t dir = reldirection(prev, next);
assert(dir != NODIRECTION && dir != D_SPECIAL);
- if (size > 1) {
+ if (size > 1 && bufp != zOrder) {
*bufp++ = ' ';
--size;
}
@@ -516,7 +510,7 @@ static order *make_movement_order(unit * u, const region * target, int moves,
}
*bufp = 0;
- return parse_order(zOrder, u->faction->locale);
+ return create_order(K_MOVE, u->faction->locale, zOrder);
}
void random_growl(const unit *u, region *target, int rand)
diff --git a/src/piracy.c b/src/piracy.c
index 80b1dd47a..3025d484c 100644
--- a/src/piracy.c
+++ b/src/piracy.c
@@ -66,6 +66,8 @@ static attrib *mk_piracy(const faction * pirate, const faction * target,
}
static bool validate_pirate(unit *u, order *ord) {
+ assert(u);
+ assert(ord);
if (fval(u_race(u), RCF_SWIM | RCF_FLY))
return true;
if (!u->ship) {
@@ -128,6 +130,7 @@ void piracy_cmd(unit * u)
int saff = 0;
int *il;
+ assert(u->thisorder);
if (!validate_pirate(u, u->thisorder)) {
return;
}
diff --git a/src/piracy.test.c b/src/piracy.test.c
index 40e66af18..33860e03f 100644
--- a/src/piracy.test.c
+++ b/src/piracy.test.c
@@ -137,6 +137,7 @@ static void test_piracy_cmd_errors(CuTest * tc) {
u_set_ship(u, test_create_ship(u->region, st_boat));
u2 = test_create_unit(u->faction, u->region);
+ u2->thisorder = create_order(K_PIRACY, f->locale, "");
u_set_ship(u2, u->ship);
test_clear_messages(f);
diff --git a/src/platform.h b/src/platform.h
index 6ccbb8d6d..104ff28d7 100644
--- a/src/platform.h
+++ b/src/platform.h
@@ -1,5 +1,9 @@
#pragma once
+#ifndef _LP64
+#define _LP64 0 /* fix a warning in pdcurses 3.4 */
+#endif
+
#ifndef UNILIB_H
#define UNILIB_H