forked from github/server
Merge pull request #680 from ennorehling/develop
Bug 2315, pdcurses 3.4
This commit is contained in:
commit
a1868ab00c
|
@ -21,9 +21,7 @@
|
||||||
"GiveRestriction": 3,
|
"GiveRestriction": 3,
|
||||||
"hunger.long": true,
|
"hunger.long": true,
|
||||||
"init_spells": 0,
|
"init_spells": 0,
|
||||||
"world.era": 2,
|
"game.era": 2,
|
||||||
"seed.population.min": 8,
|
|
||||||
"seed.population.max": 8,
|
|
||||||
"rules.reserve.twophase": true,
|
"rules.reserve.twophase": true,
|
||||||
"rules.give.max_men": -1,
|
"rules.give.max_men": -1,
|
||||||
"rules.check_overload": false,
|
"rules.check_overload": false,
|
||||||
|
|
|
@ -51,9 +51,7 @@
|
||||||
"recruit.allow_merge": true,
|
"recruit.allow_merge": true,
|
||||||
"study.expensivemigrants": true,
|
"study.expensivemigrants": true,
|
||||||
"study.speedup": 2,
|
"study.speedup": 2,
|
||||||
"world.era": 3,
|
"game.era": 3,
|
||||||
"seed.population.min": 8,
|
|
||||||
"seed.population.max": 8,
|
|
||||||
"rules.reserve.twophase": true,
|
"rules.reserve.twophase": true,
|
||||||
"rules.owners.force_leave": false,
|
"rules.owners.force_leave": false,
|
||||||
"rules.wage.function": 2,
|
"rules.wage.function": 2,
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
"keywords": {
|
"keywords": {
|
||||||
"en" : {
|
"en" : {
|
||||||
"grow": [ "GROW", "BREED", "PLANT" ],
|
"grow": [ "GROW", "BREED", "PLANT" ],
|
||||||
|
"promote": ["PROMOTE", "PROMOTION" ],
|
||||||
"combat": [ "COMBAT", "FIGHT" ]
|
"combat": [ "COMBAT", "FIGHT" ]
|
||||||
},
|
},
|
||||||
"de": {
|
"de": {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<item weight="200" score="200">
|
<item weight="200" score="200">
|
||||||
<construction skill="mining" minskill="8"/>
|
<construction skill="mining" minskill="8"/>
|
||||||
</item>
|
</item>
|
||||||
|
<modifier building="mine" type="skill" value="1"/>
|
||||||
<modifier type="require" building="mine"/>
|
<modifier type="require" building="mine"/>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
|
|
|
@ -1496,9 +1496,6 @@
|
||||||
<string name="prefix">
|
<string name="prefix">
|
||||||
<text locale="en">PREFIX</text>
|
<text locale="en">PREFIX</text>
|
||||||
</string>
|
</string>
|
||||||
<string name="promote">
|
|
||||||
<text locale="en">PROMOTION</text>
|
|
||||||
</string>
|
|
||||||
<string name="claim">
|
<string name="claim">
|
||||||
<text locale="en">CLAIM</text>
|
<text locale="en">CLAIM</text>
|
||||||
</string>
|
</string>
|
||||||
|
|
|
@ -3,5 +3,6 @@
|
||||||
<item weight="200" score="100">
|
<item weight="200" score="100">
|
||||||
<construction skill="mining" minskill="7"/>
|
<construction skill="mining" minskill="7"/>
|
||||||
</item>
|
</item>
|
||||||
|
<modifier building="mine" type="skill" value="1"/>
|
||||||
<modifier type="require" building="mine"/>
|
<modifier type="require" building="mine"/>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
|
@ -5,6 +5,10 @@ local function _test_create_ship(r)
|
||||||
return s
|
return s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function create_faction(race)
|
||||||
|
return faction.create(race, race .. '@eressea.de', "de")
|
||||||
|
end
|
||||||
|
|
||||||
local function one_unit(r, f)
|
local function one_unit(r, f)
|
||||||
local u = unit.create(f, r, 1)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("money", u.number * 100)
|
u:add_item("money", u.number * 100)
|
||||||
|
@ -17,8 +21,8 @@ local function two_units(r, f1, f2)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function two_factions()
|
local function two_factions()
|
||||||
local f1 = faction.create("human", "one@eressea.de", "de")
|
local f1 = create_faction('human')
|
||||||
local f2 = faction.create("elf", "two@eressea.de", "de")
|
local f2 = create_faction('elf')
|
||||||
return f1, f2
|
return f1, f2
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -44,7 +48,7 @@ end
|
||||||
|
|
||||||
function test_flags()
|
function test_flags()
|
||||||
local r = region.create(0, 0, "plain")
|
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 u = unit.create(f, r, 1)
|
||||||
local no = itoa36(f.id)
|
local no = itoa36(f.id)
|
||||||
local flags = 50332673
|
local flags = 50332673
|
||||||
|
@ -62,7 +66,7 @@ function test_elvenhorse_requires_riding_5()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
region.create(1, 0, "plain")
|
region.create(1, 0, "plain")
|
||||||
local goal = region.create(2, 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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("elvenhorse", 1)
|
u:add_item("elvenhorse", 1)
|
||||||
u:set_skill("riding", 6)-- halfling has -1 modifier
|
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 r = region.create(0, 0, "plain")
|
||||||
local goal = region.create(1, 0, "plain")
|
local goal = region.create(1, 0, "plain")
|
||||||
region.create(2, 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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("elvenhorse", 1)
|
u:add_item("elvenhorse", 1)
|
||||||
u:set_skill("riding", 5) -- halfling has -1 modifier
|
u:set_skill("riding", 5) -- halfling has -1 modifier
|
||||||
|
@ -96,7 +100,7 @@ end
|
||||||
|
|
||||||
function test_demon_food()
|
function test_demon_food()
|
||||||
local r = region.create(0, 0, "plain")
|
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 u = unit.create(f, r, 1)
|
||||||
local p = r:get_resource("peasant")
|
local p = r:get_resource("peasant")
|
||||||
r:set_resource("peasant", 2000)
|
r:set_resource("peasant", 2000)
|
||||||
|
@ -136,7 +140,7 @@ function test_plane()
|
||||||
local nx, ny = plane.normalize(pl, 4, 4)
|
local nx, ny = plane.normalize(pl, 4, 4)
|
||||||
assert_equal(nx, -3, "normalization failed")
|
assert_equal(nx, -3, "normalization failed")
|
||||||
assert_equal(ny, -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")
|
f.id = atoi36("tpla")
|
||||||
local r, x, y
|
local r, x, y
|
||||||
for x = -3, 3 do for y = -3, 3 do
|
for x = -3, 3 do for y = -3, 3 do
|
||||||
|
@ -155,7 +159,7 @@ end
|
||||||
|
|
||||||
function test_read_write()
|
function test_read_write()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r)
|
||||||
u.number = 2
|
u.number = 2
|
||||||
local fno = f.id
|
local fno = f.id
|
||||||
|
@ -184,7 +188,7 @@ end
|
||||||
function test_descriptions()
|
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 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 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 u = unit.create(f, r, 1)
|
||||||
local s = _test_create_ship(r)
|
local s = _test_create_ship(r)
|
||||||
local b = building.create(r, "castle")
|
local b = building.create(r, "castle")
|
||||||
|
@ -236,7 +240,7 @@ end
|
||||||
|
|
||||||
function test_faction()
|
function test_faction()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("human", "testfaction@eressea.de", "de")
|
local f = create_faction('human')
|
||||||
assert(f)
|
assert(f)
|
||||||
f.info = "Spazz"
|
f.info = "Spazz"
|
||||||
assert(f.info=="Spazz")
|
assert(f.info=="Spazz")
|
||||||
|
@ -259,7 +263,7 @@ end
|
||||||
|
|
||||||
function test_unit()
|
function test_unit()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r)
|
||||||
u.number = 20
|
u.number = 20
|
||||||
u.name = "Enno"
|
u.name = "Enno"
|
||||||
|
@ -292,7 +296,7 @@ end
|
||||||
|
|
||||||
function test_building()
|
function test_building()
|
||||||
local u
|
local u
|
||||||
local f = faction.create("human", "testbuilding@eressea.de", "de")
|
local f = create_faction('human')
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local b = building.create(r, "castle")
|
local b = building.create(r, "castle")
|
||||||
u = unit.create(f, r)
|
u = unit.create(f, r)
|
||||||
|
@ -318,7 +322,7 @@ end
|
||||||
|
|
||||||
function test_message()
|
function test_message()
|
||||||
local r = region.create(0, 0, "plain")
|
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 u = unit.create(f, r)
|
||||||
local msg = message.create("item_create_spell")
|
local msg = message.create("item_create_spell")
|
||||||
msg:set_unit("mage", u)
|
msg:set_unit("mage", u)
|
||||||
|
@ -346,7 +350,7 @@ function test_events()
|
||||||
plain = region.create(0, 0, "plain")
|
plain = region.create(0, 0, "plain")
|
||||||
skill = 8
|
skill = 8
|
||||||
|
|
||||||
f = faction.create("elf", "noreply2@eressea.de", "de")
|
f = create_faction('elf')
|
||||||
f.age = 20
|
f.age = 20
|
||||||
|
|
||||||
u = unit.create(f, plain)
|
u = unit.create(f, plain)
|
||||||
|
@ -356,7 +360,7 @@ function test_events()
|
||||||
u:add_order("NUMMER PARTEI test")
|
u:add_order("NUMMER PARTEI test")
|
||||||
u:add_handler("message", msg_handler)
|
u:add_handler("message", msg_handler)
|
||||||
msg = "BOTSCHAFT EINHEIT " .. itoa36(u.id) .. " Du~Elf~stinken"
|
msg = "BOTSCHAFT EINHEIT " .. itoa36(u.id) .. " Du~Elf~stinken"
|
||||||
f = faction.create("elf", "noreply3@eressea.de", "de")
|
f = create_faction('elf')
|
||||||
f.age = 20
|
f.age = 20
|
||||||
|
|
||||||
u = unit.create(f, plain)
|
u = unit.create(f, plain)
|
||||||
|
@ -371,7 +375,7 @@ end
|
||||||
|
|
||||||
function test_renumber_ship()
|
function test_renumber_ship()
|
||||||
local r = region.create(0, 0, "plain")
|
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 u = unit.create(f, r)
|
||||||
local s = ship.create(r, config.ships[1])
|
local s = ship.create(r, config.ships[1])
|
||||||
u.ship = s
|
u.ship = s
|
||||||
|
@ -386,7 +390,7 @@ end
|
||||||
|
|
||||||
function test_recruit2()
|
function test_recruit2()
|
||||||
local r = region.create(0, 0, "plain")
|
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 u = unit.create(f, r)
|
||||||
u.number = 1
|
u.number = 1
|
||||||
u:add_item("money", 2000)
|
u:add_item("money", 2000)
|
||||||
|
@ -401,7 +405,7 @@ end
|
||||||
function test_guard()
|
function test_guard()
|
||||||
region.create(1, 0, "plain")
|
region.create(1, 0, "plain")
|
||||||
local r = region.create(0, 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
|
f1.age = 20
|
||||||
local u1 = unit.create(f1, r, 10)
|
local u1 = unit.create(f1, r, 10)
|
||||||
u1:add_item("sword", 10)
|
u1:add_item("sword", 10)
|
||||||
|
@ -411,7 +415,7 @@ function test_guard()
|
||||||
u1:add_order("NACH O")
|
u1:add_order("NACH O")
|
||||||
u1.name="Kalle Pimp"
|
u1.name="Kalle Pimp"
|
||||||
|
|
||||||
local f2 = faction.create("human", "noreply6@eressea.de", "de")
|
local f2 = create_faction('human')
|
||||||
f2.age = 20
|
f2.age = 20
|
||||||
local u2 = unit.create(f2, r, 1)
|
local u2 = unit.create(f2, r, 1)
|
||||||
local u3 = unit.create(f2, r, 1)
|
local u3 = unit.create(f2, r, 1)
|
||||||
|
@ -429,7 +433,7 @@ end
|
||||||
|
|
||||||
function test_recruit()
|
function test_recruit()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r)
|
||||||
u.number = 1
|
u.number = 1
|
||||||
local n = 3
|
local n = 3
|
||||||
|
@ -445,7 +449,7 @@ end
|
||||||
|
|
||||||
function test_produce()
|
function test_produce()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r, 1)
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
local sword = config.get_resource('sword')
|
local sword = config.get_resource('sword')
|
||||||
|
@ -460,7 +464,7 @@ end
|
||||||
|
|
||||||
function test_work()
|
function test_work()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("money", u.number * 10) -- humans cost 10
|
u:add_item("money", u.number * 10) -- humans cost 10
|
||||||
u:set_skill("herbalism", 5)
|
u:set_skill("herbalism", 5)
|
||||||
|
@ -473,7 +477,7 @@ end
|
||||||
function test_upkeep()
|
function test_upkeep()
|
||||||
eressea.settings.set("rules.food.flags", "0")
|
eressea.settings.set("rules.food.flags", "0")
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r, 5)
|
||||||
u:add_item("money", u.number * 11)
|
u:add_item("money", u.number * 11)
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
|
@ -485,7 +489,7 @@ end
|
||||||
function test_id()
|
function test_id()
|
||||||
local r = region.create(0, 0, "plain")
|
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")
|
f.id = atoi36("42")
|
||||||
assert_not_equal(f, get_faction(42))
|
assert_not_equal(f, get_faction(42))
|
||||||
assert_equal(f, get_faction("42"))
|
assert_equal(f, get_faction("42"))
|
||||||
|
@ -521,7 +525,7 @@ function test_mallorn()
|
||||||
m:set_resource("tree", 100)
|
m:set_resource("tree", 100)
|
||||||
assert_equal(100, m:get_resource("tree"))
|
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)
|
local u1 = unit.create(f, r, 1)
|
||||||
u1:add_item("money", u1.number * 100)
|
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 pl = plane.create(1, 500, 500, 1001, 1001) -- astralraum
|
||||||
local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath
|
local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath
|
||||||
local r = region.create(1000, 1000, "plain")
|
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_not_equal(nil, r)
|
||||||
assert_equal(r.x, 1000)
|
assert_equal(r.x, 1000)
|
||||||
assert_equal(r.y, 1000)
|
assert_equal(r.y, 1000)
|
||||||
|
@ -604,8 +608,8 @@ end
|
||||||
|
|
||||||
function test_building_other()
|
function test_building_other()
|
||||||
local r = region.create(0,0, "plain")
|
local r = region.create(0,0, "plain")
|
||||||
local f1 = faction.create("human", "noreply17@eressea.de", "de")
|
local f1 = create_faction('human')
|
||||||
local f2 = faction.create("human", "noreply18@eressea.de", "de")
|
local f2 = create_faction('human')
|
||||||
local b = building.create(r, "castle")
|
local b = building.create(r, "castle")
|
||||||
b.size = 10
|
b.size = 10
|
||||||
local u1 = unit.create(f1, r, 3)
|
local u1 = unit.create(f1, r, 3)
|
||||||
|
@ -632,7 +636,7 @@ end
|
||||||
local function _test_create_laen()
|
local function _test_create_laen()
|
||||||
eressea.settings.set("rules.terraform.all", "1")
|
eressea.settings.set("rules.terraform.all", "1")
|
||||||
local r = region.create(0,0, "mountain")
|
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)
|
local u1 = unit.create(f1, r, 1)
|
||||||
r:set_resource("laen", 50)
|
r:set_resource("laen", 50)
|
||||||
return r, u1
|
return r, u1
|
||||||
|
@ -671,7 +675,7 @@ end
|
||||||
|
|
||||||
function test_mine()
|
function test_mine()
|
||||||
local r = region.create(0,0, "mountain")
|
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)
|
local u1 = unit.create(f1, r, 1)
|
||||||
|
|
||||||
u1:add_item("money", 1000)
|
u1:add_item("money", 1000)
|
||||||
|
@ -692,9 +696,9 @@ end
|
||||||
function test_guard_resources()
|
function test_guard_resources()
|
||||||
-- this is not quite http://bugs.eressea.de/view.php?id=1756
|
-- this is not quite http://bugs.eressea.de/view.php?id=1756
|
||||||
local r = region.create(0,0, "mountain")
|
local r = region.create(0,0, "mountain")
|
||||||
local f1 = faction.create("human", "noreply21@eressea.de", "de")
|
local f1 = create_faction('human')
|
||||||
f1.age=20
|
f1.age=20
|
||||||
local f2 = faction.create("human", "noreply22@eressea.de", "de")
|
local f2 = create_faction('human')
|
||||||
f2.age=20
|
f2.age=20
|
||||||
local u1 = unit.create(f1, r, 1)
|
local u1 = unit.create(f1, r, 1)
|
||||||
u1:add_item("money", 100)
|
u1:add_item("money", 100)
|
||||||
|
@ -722,7 +726,7 @@ end
|
||||||
|
|
||||||
function test_hero_hero_transfer()
|
function test_hero_hero_transfer()
|
||||||
local r = region.create(0,0, "mountain")
|
local r = region.create(0,0, "mountain")
|
||||||
local f = faction.create("human", "noreply23@eressea.de", "de")
|
local f = create_faction('human')
|
||||||
f.age=20
|
f.age=20
|
||||||
local UFL_HERO = 128
|
local UFL_HERO = 128
|
||||||
|
|
||||||
|
@ -743,7 +747,7 @@ end
|
||||||
|
|
||||||
function test_hero_normal_transfer()
|
function test_hero_normal_transfer()
|
||||||
local r = region.create(0,0, "mountain")
|
local r = region.create(0,0, "mountain")
|
||||||
local f = faction.create("human", "noreply24@eressea.de", "de")
|
local f = create_faction('human')
|
||||||
f.age=20
|
f.age=20
|
||||||
local UFL_HERO = 128
|
local UFL_HERO = 128
|
||||||
|
|
||||||
|
@ -762,7 +766,7 @@ end
|
||||||
|
|
||||||
function test_expensive_skills_cost_money()
|
function test_expensive_skills_cost_money()
|
||||||
local r = region.create(0,0, "mountain")
|
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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("money", 10000)
|
u:add_item("money", 10000)
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
|
@ -775,7 +779,7 @@ end
|
||||||
|
|
||||||
function test_food_is_consumed()
|
function test_food_is_consumed()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("money", 100)
|
u:add_item("money", 100)
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
|
@ -787,7 +791,7 @@ end
|
||||||
|
|
||||||
function test_food_can_override()
|
function test_food_can_override()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("money", 100)
|
u:add_item("money", 100)
|
||||||
u:clear_orders()
|
u:clear_orders()
|
||||||
|
@ -799,7 +803,7 @@ end
|
||||||
|
|
||||||
function test_swim_and_survive()
|
function test_swim_and_survive()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f = faction.create("human", "noreply28@eressea.de", "de")
|
local f = create_faction('human')
|
||||||
f.nam = "chaos"
|
f.nam = "chaos"
|
||||||
local u = unit.create(f, r, 1)
|
local u = unit.create(f, r, 1)
|
||||||
process_orders()
|
process_orders()
|
||||||
|
@ -813,7 +817,7 @@ end
|
||||||
|
|
||||||
function test_swim_and_die()
|
function test_swim_and_die()
|
||||||
local r = region.create(0, 0, "plain")
|
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 u = unit.create(f, r, 1)
|
||||||
local uid = u.id
|
local uid = u.id
|
||||||
process_orders()
|
process_orders()
|
||||||
|
@ -828,7 +832,7 @@ function test_ride_with_horse()
|
||||||
region.create(1, 0, "plain")
|
region.create(1, 0, "plain")
|
||||||
region.create(2, 0, "plain")
|
region.create(2, 0, "plain")
|
||||||
local r = region.create(0, 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)
|
local u = unit.create(f, r, 1)
|
||||||
u:add_item("horse", 1)
|
u:add_item("horse", 1)
|
||||||
local horse_cfg = config.get_resource("horse")
|
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(1, 0, "plain")
|
||||||
region.create(2, 0, "plain")
|
region.create(2, 0, "plain")
|
||||||
local r = region.create(0, 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 u = unit.create(f, r, 1)
|
||||||
local horse_cfg = config.get_resource("horse")
|
local horse_cfg = config.get_resource("horse")
|
||||||
local cart_cfg = config.get_resource("cart")
|
local cart_cfg = config.get_resource("cart")
|
||||||
|
@ -904,7 +908,7 @@ function test_walk_and_carry_the_cart()
|
||||||
region.create(1, 0, "plain")
|
region.create(1, 0, "plain")
|
||||||
local r = region.create(2, 0, "plain")
|
local r = region.create(2, 0, "plain")
|
||||||
local r = region.create(0, 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)
|
local u = unit.create(f, r, 10)
|
||||||
u:add_item("cart", 1)
|
u:add_item("cart", 1)
|
||||||
|
|
||||||
|
@ -925,7 +929,7 @@ end
|
||||||
|
|
||||||
function test_bug_1795_limit()
|
function test_bug_1795_limit()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u1 = one_unit(r,f)
|
||||||
u1:add_item("money", 100000000)
|
u1:add_item("money", 100000000)
|
||||||
u1:add_order("REKRUTIEREN 9999")
|
u1:add_order("REKRUTIEREN 9999")
|
||||||
|
@ -940,7 +944,7 @@ end
|
||||||
|
|
||||||
function test_bug_1795_demons()
|
function test_bug_1795_demons()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u1 = one_unit(r,f)
|
||||||
r:set_resource("peasant", 2000)
|
r:set_resource("peasant", 2000)
|
||||||
local peasants = r:get_resource("peasant")
|
local peasants = r:get_resource("peasant")
|
||||||
|
@ -966,7 +970,7 @@ end
|
||||||
|
|
||||||
function test_parser()
|
function test_parser()
|
||||||
local r = region.create(0, 0, "mountain")
|
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 u = unit.create(f, r, 1)
|
||||||
local filename = "orders.txt"
|
local filename = "orders.txt"
|
||||||
|
|
||||||
|
@ -991,7 +995,7 @@ end
|
||||||
|
|
||||||
function test_prefix()
|
function test_prefix()
|
||||||
local r0 = region.create(0, 0, "plain")
|
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)
|
local u1 = unit.create(f1, r0, 1)
|
||||||
|
|
||||||
set_order(u1, "PRAEFIX See")
|
set_order(u1, "PRAEFIX See")
|
||||||
|
@ -1018,7 +1022,7 @@ end
|
||||||
|
|
||||||
function test_recruit()
|
function test_recruit()
|
||||||
local r = region.create(0, 0, "plain")
|
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)
|
local u = unit.create(f, r, 1)
|
||||||
|
|
||||||
u:add_item("money", 1000)
|
u:add_item("money", 1000)
|
||||||
|
|
|
@ -10,10 +10,14 @@ function setup()
|
||||||
eressea.settings.set("rules.encounters", "0")
|
eressea.settings.set("rules.encounters", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function create_faction(race)
|
||||||
|
return faction.create(race, race .. '@eressea.de', "de")
|
||||||
|
end
|
||||||
|
|
||||||
local function _test_create_adamantium()
|
local function _test_create_adamantium()
|
||||||
eressea.settings.set("rules.terraform.all", "1")
|
eressea.settings.set("rules.terraform.all", "1")
|
||||||
local r = region.create(0,0, "mountain")
|
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)
|
local u1 = unit.create(f1, r, 1)
|
||||||
r:set_resource("adamantium", 50)
|
r:set_resource("adamantium", 50)
|
||||||
assert_equal(50, r:get_resource("adamantium"))
|
assert_equal(50, r:get_resource("adamantium"))
|
||||||
|
@ -24,20 +28,19 @@ function test_adamantium1()
|
||||||
local r, u1 = _test_create_adamantium()
|
local r, u1 = _test_create_adamantium()
|
||||||
|
|
||||||
u1:add_item("money", 1000)
|
u1:add_item("money", 1000)
|
||||||
u1:set_skill("mining", 8)
|
u1:set_skill("mining", 14)
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("MACHEN Adamantium")
|
u1:add_order("MACHEN Adamantium")
|
||||||
|
|
||||||
process_orders()
|
process_orders()
|
||||||
-- adamantium needs a mine, so nothing happens:
|
|
||||||
assert_equal(0, u1:get_item("adamantium"))
|
assert_equal(0, u1:get_item("adamantium"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_adamantium2()
|
function test_adamantium2()
|
||||||
local r, u1 = _test_create_adamantium()
|
local r, u1 = _test_create_adamantium()
|
||||||
u1.id = 42
|
|
||||||
u1:add_item("money", 1000)
|
u1:add_item("money", 1000)
|
||||||
u1:set_skill("mining", 8)
|
u1:set_skill("mining", 15)
|
||||||
u1:clear_orders()
|
u1:clear_orders()
|
||||||
u1:add_order("MACHEN Adamantium")
|
u1:add_order("MACHEN Adamantium")
|
||||||
|
|
||||||
|
@ -47,7 +50,7 @@ function test_adamantium2()
|
||||||
local adamantium = r:get_resource("adamantium")
|
local adamantium = r:get_resource("adamantium")
|
||||||
|
|
||||||
process_orders()
|
process_orders()
|
||||||
assert_equal(1, u1:get_item("adamantium"))
|
assert_equal(2, u1:get_item("adamantium"))
|
||||||
assert_equal(adamantium - 1, r:get_resource("adamantium"))
|
assert_equal(adamantium - 2, r:get_resource("adamantium"))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
require 'tests.e3.production'
|
||||||
require 'tests.e3.castles'
|
require 'tests.e3.castles'
|
||||||
require 'tests.e3.stealth'
|
require 'tests.e3.stealth'
|
||||||
require 'tests.e3.spells'
|
require 'tests.e3.spells'
|
||||||
|
|
|
@ -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
|
|
@ -16,6 +16,7 @@ function setup()
|
||||||
"attack" : "ATTACKIERE",
|
"attack" : "ATTACKIERE",
|
||||||
"maketemp" : "MACHETEMP",
|
"maketemp" : "MACHETEMP",
|
||||||
"end" : "ENDE",
|
"end" : "ENDE",
|
||||||
|
"use" : "BENUTZEN",
|
||||||
"recruit" : "REKRUTIERE"
|
"recruit" : "REKRUTIERE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,6 +20,18 @@ function setup()
|
||||||
eressea.settings.set("NewbieImmunity", "0")
|
eressea.settings.set("NewbieImmunity", "0")
|
||||||
end
|
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()
|
function test_learn()
|
||||||
u:add_order("LERNEN Hiebwaffen")
|
u:add_order("LERNEN Hiebwaffen")
|
||||||
_G.process_orders()
|
_G.process_orders()
|
||||||
|
|
|
@ -1100,10 +1100,10 @@ static char *cr_output_resource(char *buf, const resource_type *rtype,
|
||||||
{
|
{
|
||||||
const char *name, *tname;
|
const char *name, *tname;
|
||||||
assert(rtype);
|
assert(rtype);
|
||||||
name = resourcename(rtype, 1);
|
name = resourcename(rtype, NMF_PLURAL);
|
||||||
assert(name);
|
assert(name);
|
||||||
buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name));
|
buf += sprintf(buf, "RESOURCE %u\n", hashstring(rtype->_name));
|
||||||
tname = LOC(loc, rtype->_name);
|
tname = LOC(loc, name);
|
||||||
assert(tname);
|
assert(tname);
|
||||||
tname = translate(name, tname);
|
tname = translate(name, tname);
|
||||||
assert(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) {
|
for (n = 0; n < size; ++n) {
|
||||||
if (result[n].level >= 0 && result[n].number >= 0) {
|
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);
|
assert(name);
|
||||||
stream_printf(out, "%d;%s\n", result[n].number, crtag(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;
|
static int rc_cache;
|
||||||
|
|
||||||
if (era < 0) {
|
if (era < 0) {
|
||||||
era = config_get_int("world.era", 1);
|
era = config_get_int("game.era", 1);
|
||||||
}
|
}
|
||||||
if (F == NULL) {
|
if (F == NULL) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
#include <kernel/race.h>
|
#include <kernel/race.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
|
#include <kernel/resources.h>
|
||||||
#include <kernel/ship.h>
|
#include <kernel/ship.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
#include <kernel/spell.h>
|
#include <kernel/spell.h>
|
||||||
|
@ -52,8 +53,15 @@ static void test_cr_unit(CuTest *tc) {
|
||||||
|
|
||||||
static void setup_resources(void) {
|
static void setup_resources(void) {
|
||||||
struct locale *lang;
|
struct locale *lang;
|
||||||
|
item_type *itype;
|
||||||
|
|
||||||
test_setup();
|
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();
|
init_resources();
|
||||||
lang = get_or_create_locale("de"); /* CR tags are translated from this */
|
lang = get_or_create_locale("de"); /* CR tags are translated from this */
|
||||||
locale_setstring(lang, "money", "Silber");
|
locale_setstring(lang, "money", "Silber");
|
||||||
|
@ -62,6 +70,8 @@ static void setup_resources(void) {
|
||||||
locale_setstring(lang, "horse_p", "Pferde");
|
locale_setstring(lang, "horse_p", "Pferde");
|
||||||
locale_setstring(lang, "peasant", "Bauer");
|
locale_setstring(lang, "peasant", "Bauer");
|
||||||
locale_setstring(lang, "peasant_p", "Bauern");
|
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", "Blume");
|
||||||
locale_setstring(lang, "tree_p", "Blumen");
|
locale_setstring(lang, "tree_p", "Blumen");
|
||||||
locale_setstring(lang, "sapling", "Schoessling");
|
locale_setstring(lang, "sapling", "Schoessling");
|
||||||
|
@ -77,25 +87,31 @@ static void test_cr_resources(CuTest *tc) {
|
||||||
char line[1024];
|
char line[1024];
|
||||||
faction *f;
|
faction *f;
|
||||||
region *r;
|
region *r;
|
||||||
|
unit *u;
|
||||||
|
|
||||||
setup_resources();
|
setup_resources();
|
||||||
|
|
||||||
f = test_create_faction(0);
|
f = test_create_faction(0);
|
||||||
r = test_create_region(0, 0, 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->horses = 1;
|
||||||
r->land->peasants = 200;
|
r->land->peasants = 200;
|
||||||
r->land->money = 300;
|
r->land->money = 300;
|
||||||
rsettrees(r, 0, 1);
|
rsettrees(r, 0, 1);
|
||||||
rsettrees(r, 1, 2);
|
rsettrees(r, 1, 2);
|
||||||
rsettrees(r, 2, 3);
|
rsettrees(r, 2, 3);
|
||||||
|
region_setresource(r, get_resourcetype(R_STONE), 1);
|
||||||
|
|
||||||
mstream_init(&strm);
|
mstream_init(&strm);
|
||||||
cr_output_resources(&strm, f, r, false);
|
cr_output_resources(&strm, f, r, true);
|
||||||
strm.api->rewind(strm.handle);
|
strm.api->rewind(strm.handle);
|
||||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||||
CuAssertStrEquals(tc, "3;Baeume", line);
|
CuAssertStrEquals(tc, "3;Baeume", line);
|
||||||
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||||
CuAssertStrEquals(tc, "2;Schoesslinge", 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, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||||
CuAssertIntEquals(tc, 0, memcmp(line, "RESOURCE ", 9));
|
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)));
|
CuAssertIntEquals(tc, 0, strm.api->readln(strm.handle, line, sizeof(line)));
|
||||||
CuAssertStrEquals(tc, "1;number", 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);
|
mstream_done(&strm);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1170,7 +1170,6 @@ static allocate_function get_allocator(const struct resource_type *rtype)
|
||||||
void split_allocations(region * r)
|
void split_allocations(region * r)
|
||||||
{
|
{
|
||||||
allocation_list **p_alist = &allocations;
|
allocation_list **p_alist = &allocations;
|
||||||
freset(r, RF_SELECT);
|
|
||||||
while (*p_alist) {
|
while (*p_alist) {
|
||||||
allocation_list *alist = *p_alist;
|
allocation_list *alist = *p_alist;
|
||||||
const resource_type *rtype = alist->type;
|
const resource_type *rtype = alist->type;
|
||||||
|
@ -1178,7 +1177,6 @@ void split_allocations(region * r)
|
||||||
const item_type *itype = resource2item(rtype);
|
const item_type *itype = resource2item(rtype);
|
||||||
allocation **p_al = &alist->data;
|
allocation **p_al = &alist->data;
|
||||||
|
|
||||||
freset(r, RF_SELECT);
|
|
||||||
alloc(rtype, r, alist->data);
|
alloc(rtype, r, alist->data);
|
||||||
|
|
||||||
while (*p_al) {
|
while (*p_al) {
|
||||||
|
@ -1187,7 +1185,6 @@ void split_allocations(region * r)
|
||||||
assert(itype || !"not implemented for non-items");
|
assert(itype || !"not implemented for non-items");
|
||||||
i_change(&al->unit->items, itype, al->get);
|
i_change(&al->unit->items, itype, al->get);
|
||||||
produceexp(al->unit, itype->construction->skill, al->unit->number);
|
produceexp(al->unit, itype->construction->skill, al->unit->number);
|
||||||
fset(r, RF_SELECT);
|
|
||||||
}
|
}
|
||||||
if (al->want == INT_MAX)
|
if (al->want == INT_MAX)
|
||||||
al->want = al->get;
|
al->want = al->get;
|
||||||
|
|
|
@ -902,8 +902,8 @@ static void handlekey(state * st, int c)
|
||||||
new_players = read_newfactions(sbuffer);
|
new_players = read_newfactions(sbuffer);
|
||||||
}
|
}
|
||||||
cnormalize(&st->cursor, &nx, &ny);
|
cnormalize(&st->cursor, &nx, &ny);
|
||||||
minpop = config_get_int("seed.population.min", 8);
|
minpop = config_get_int("editor.population.min", 8);
|
||||||
maxpop = config_get_int("seed.population.max", minpop);
|
maxpop = config_get_int("editor.population.max", minpop);
|
||||||
if (maxpop > minpop) {
|
if (maxpop > minpop) {
|
||||||
n = rng_int() % (maxpop - minpop) + minpop;
|
n = rng_int() % (maxpop - minpop) + minpop;
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,16 +78,14 @@ variant v)
|
||||||
struct message *msg_feedback(const struct unit *u, struct order *ord,
|
struct message *msg_feedback(const struct unit *u, struct order *ord,
|
||||||
const char *name, const char *sig, ...)
|
const char *name, const char *sig, ...)
|
||||||
{
|
{
|
||||||
va_list marker;
|
|
||||||
const message_type *mtype = mt_find(name);
|
const message_type *mtype = mt_find(name);
|
||||||
char paramname[64];
|
|
||||||
const char *ic = sig;
|
|
||||||
variant args[16];
|
variant args[16];
|
||||||
variant var;
|
variant var;
|
||||||
memset(args, 0, sizeof(args));
|
memset(args, 0, sizeof(args));
|
||||||
|
|
||||||
if (ord == NULL)
|
if (ord && ord->_noerror) {
|
||||||
ord = u->thisorder;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mtype) {
|
if (!mtype) {
|
||||||
log_warning("trying to create message of unknown type \"%s\"\n", name);
|
log_warning("trying to create message of unknown type \"%s\"\n", name);
|
||||||
|
@ -106,10 +104,15 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
|
||||||
var.v = (void *)ord;
|
var.v = (void *)ord;
|
||||||
arg_set(args, mtype, "command", var);
|
arg_set(args, mtype, "command", var);
|
||||||
|
|
||||||
|
if (sig) {
|
||||||
|
const char *ic = sig;
|
||||||
|
va_list marker;
|
||||||
|
|
||||||
va_start(marker, sig);
|
va_start(marker, sig);
|
||||||
while (*ic && !isalnum(*ic))
|
while (*ic && !isalnum(*ic))
|
||||||
ic++;
|
ic++;
|
||||||
while (*ic) {
|
while (*ic) {
|
||||||
|
char paramname[64];
|
||||||
char *oc = paramname;
|
char *oc = paramname;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -140,7 +143,7 @@ struct message *msg_feedback(const struct unit *u, struct order *ord,
|
||||||
ic++;
|
ic++;
|
||||||
}
|
}
|
||||||
va_end(marker);
|
va_end(marker);
|
||||||
|
}
|
||||||
return msg_create(mtype, args);
|
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) {
|
message * msg_error(const unit * u, struct order *ord, int mno) {
|
||||||
static char msgname[20];
|
static char msgname[20];
|
||||||
|
|
||||||
if (fval(u->faction, FFL_NPC))
|
if (fval(u->faction, FFL_NPC)) {
|
||||||
return 0;
|
return NULL;
|
||||||
|
}
|
||||||
sprintf(msgname, "error%d", mno);
|
sprintf(msgname, "error%d", mno);
|
||||||
return msg_feedback(u, ord, msgname, "");
|
return msg_feedback(u, ord, msgname, "");
|
||||||
}
|
}
|
||||||
|
@ -259,7 +263,9 @@ message * cmistake(const unit * u, struct order *ord, int mno, int mtype)
|
||||||
message * result;
|
message * result;
|
||||||
UNUSED_ARG(mtype);
|
UNUSED_ARG(mtype);
|
||||||
result = msg_error(u, ord, mno);
|
result = msg_error(u, ord, mno);
|
||||||
|
if (result) {
|
||||||
ADDMSG(&u->faction->msgs, result);
|
ADDMSG(&u->faction->msgs, result);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,8 +273,10 @@ void syntax_error(const struct unit *u, struct order *ord)
|
||||||
{
|
{
|
||||||
message * result;
|
message * result;
|
||||||
result = msg_error(u, ord, 10);
|
result = msg_error(u, ord, 10);
|
||||||
|
if (result) {
|
||||||
ADDMSG(&u->faction->msgs, result);
|
ADDMSG(&u->faction->msgs, result);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void free_messagelist(mlist *msgs)
|
void free_messagelist(mlist *msgs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
#include <platform.h>
|
#include <platform.h>
|
||||||
#include "messages.h"
|
#include "messages.h"
|
||||||
|
|
||||||
|
#include "unit.h"
|
||||||
|
#include "order.h"
|
||||||
|
|
||||||
#include <CuTest.h>
|
#include <CuTest.h>
|
||||||
#include <tests.h>
|
#include <tests.h>
|
||||||
|
|
||||||
|
@ -68,11 +71,27 @@ static void test_merge_split(CuTest *tc) {
|
||||||
test_cleanup();
|
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 *get_messages_suite(void) {
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, test_missing_message);
|
SUITE_ADD_TEST(suite, test_missing_message);
|
||||||
SUITE_ADD_TEST(suite, test_merge_split);
|
SUITE_ADD_TEST(suite, test_merge_split);
|
||||||
SUITE_ADD_TEST(suite, test_message);
|
SUITE_ADD_TEST(suite, test_message);
|
||||||
|
SUITE_ADD_TEST(suite, test_noerror);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,6 +99,15 @@ char* get_command(const order *ord, char *sbuffer, size_t size) {
|
||||||
keyword_t kwd = ORD_KEYWORD(ord);
|
keyword_t kwd = ORD_KEYWORD(ord);
|
||||||
int bytes;
|
int bytes;
|
||||||
|
|
||||||
|
if (ord->_noerror) {
|
||||||
|
if (size > 0) {
|
||||||
|
*bufp++ = '!';
|
||||||
|
--size;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
WARN_STATIC_BUFFER();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ord->_persistent) {
|
if (ord->_persistent) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
*bufp++ = '@';
|
*bufp++ = '@';
|
||||||
|
@ -159,6 +168,7 @@ order *copy_order(const order * src)
|
||||||
order *ord = (order *)malloc(sizeof(order));
|
order *ord = (order *)malloc(sizeof(order));
|
||||||
ord->next = NULL;
|
ord->next = NULL;
|
||||||
ord->_persistent = src->_persistent;
|
ord->_persistent = src->_persistent;
|
||||||
|
ord->_noerror = src->_noerror;
|
||||||
ord->data = src->data;
|
ord->data = src->data;
|
||||||
++ord->data->_refcount;
|
++ord->data->_refcount;
|
||||||
return ord;
|
return ord;
|
||||||
|
@ -280,7 +290,7 @@ void close_orders(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static order *create_order_i(keyword_t kwd, const char *sptr, bool persistent,
|
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;
|
order *ord = NULL;
|
||||||
int lindex;
|
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 = (order *)malloc(sizeof(order));
|
||||||
ord->_persistent = persistent;
|
ord->_persistent = persistent;
|
||||||
|
ord->_noerror = noerror;
|
||||||
ord->next = NULL;
|
ord->next = NULL;
|
||||||
|
|
||||||
ord->data = create_data(kwd, sptr, lindex);
|
ord->data = create_data(kwd, sptr, lindex);
|
||||||
|
@ -373,7 +384,7 @@ order *create_order(keyword_t kwd, const struct locale * lang,
|
||||||
else {
|
else {
|
||||||
zBuffer[0] = 0;
|
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)
|
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) {
|
if (*s != 0) {
|
||||||
keyword_t kwd;
|
keyword_t kwd;
|
||||||
const char *sptr;
|
const char *sptr;
|
||||||
bool persistent = false;
|
bool persistent = false, noerror = false;
|
||||||
const char * p;
|
const char * p;
|
||||||
|
|
||||||
while (*s == '@') {
|
while (*s == '!' || *s=='@') {
|
||||||
persistent = true;
|
if (*s=='!') noerror = true;
|
||||||
|
else if (*s == '@') persistent = true;
|
||||||
++s;
|
++s;
|
||||||
}
|
}
|
||||||
sptr = s;
|
sptr = s;
|
||||||
|
@ -407,7 +419,7 @@ order *parse_order(const char *s, const struct locale * lang)
|
||||||
if (kwd != NOKEYWORD) {
|
if (kwd != NOKEYWORD) {
|
||||||
while (isspace(*(unsigned char *)sptr)) ++sptr;
|
while (isspace(*(unsigned char *)sptr)) ++sptr;
|
||||||
s = sptr;
|
s = sptr;
|
||||||
return create_order_i(kwd, s, persistent, lang);
|
return create_order_i(kwd, s, persistent, noerror, lang);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern "C" {
|
||||||
/* do not access this data: */
|
/* do not access this data: */
|
||||||
struct order_data *data;
|
struct order_data *data;
|
||||||
bool _persistent;
|
bool _persistent;
|
||||||
|
bool _noerror;
|
||||||
} order;
|
} order;
|
||||||
|
|
||||||
/* constructor */
|
/* constructor */
|
||||||
|
|
|
@ -14,14 +14,13 @@ static void test_create_order(CuTest *tc) {
|
||||||
order *ord;
|
order *ord;
|
||||||
struct locale * lang;
|
struct locale * lang;
|
||||||
|
|
||||||
test_cleanup();
|
test_setup();
|
||||||
lang = get_or_create_locale("en");
|
lang = test_create_locale();
|
||||||
|
|
||||||
locale_setstring(lang, "keyword::move", "MOVE");
|
|
||||||
ord = create_order(K_MOVE, lang, "NORTH");
|
ord = create_order(K_MOVE, lang, "NORTH");
|
||||||
CuAssertPtrNotNull(tc, ord);
|
CuAssertPtrNotNull(tc, ord);
|
||||||
CuAssertIntEquals(tc, K_MOVE, getkeyword(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));
|
CuAssertIntEquals(tc, K_MOVE, init_order(ord));
|
||||||
CuAssertStrEquals(tc, "NORTH", getstrtoken());
|
CuAssertStrEquals(tc, "NORTH", getstrtoken());
|
||||||
|
@ -34,19 +33,44 @@ static void test_parse_order(CuTest *tc) {
|
||||||
order *ord;
|
order *ord;
|
||||||
struct locale * lang;
|
struct locale * lang;
|
||||||
|
|
||||||
test_cleanup();
|
test_setup();
|
||||||
lang = get_or_create_locale("en");
|
lang = test_create_locale();
|
||||||
|
|
||||||
locale_setstring(lang, "keyword::move", "MOVE");
|
|
||||||
init_keyword(lang, K_MOVE, "MOVE");
|
|
||||||
ord = parse_order("MOVE NORTH", lang);
|
ord = parse_order("MOVE NORTH", lang);
|
||||||
CuAssertPtrNotNull(tc, ord);
|
CuAssertPtrNotNull(tc, ord);
|
||||||
|
CuAssertTrue(tc, !ord->_noerror);
|
||||||
|
CuAssertTrue(tc, !ord->_persistent);
|
||||||
CuAssertIntEquals(tc, K_MOVE, getkeyword(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));
|
CuAssertIntEquals(tc, K_MOVE, init_order(ord));
|
||||||
CuAssertStrEquals(tc, "NORTH", getstrtoken());
|
CuAssertStrEquals(tc, "NORTH", getstrtoken());
|
||||||
free_order(ord);
|
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();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +105,7 @@ static void test_parse_make_temp(CuTest *tc) {
|
||||||
lang = get_or_create_locale("en");
|
lang = get_or_create_locale("en");
|
||||||
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
locale_setstring(lang, keyword(K_MAKE), "MAKE");
|
||||||
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
|
locale_setstring(lang, keyword(K_MAKETEMP), "MAKETEMP");
|
||||||
locale_setstring(lang, "TEMP", "TEMP");
|
locale_setstring(lang, parameters[P_TEMP], "TEMP");
|
||||||
init_locale(lang);
|
init_locale(lang);
|
||||||
|
|
||||||
ord = parse_order("M T herp", lang);
|
ord = parse_order("M T herp", lang);
|
||||||
|
@ -156,9 +180,9 @@ static void test_replace_order(CuTest *tc) {
|
||||||
struct locale * lang;
|
struct locale * lang;
|
||||||
|
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
lang = get_or_create_locale("en");
|
lang = test_create_locale();
|
||||||
orig = create_order(K_MAKE, lang, 0);
|
orig = create_order(K_MAKE, lang, NULL);
|
||||||
repl = create_order(K_ALLY, lang, 0);
|
repl = create_order(K_ALLY, lang, NULL);
|
||||||
replace_order(&orders, orig, repl);
|
replace_order(&orders, orig, repl);
|
||||||
CuAssertPtrEquals(tc, 0, orders);
|
CuAssertPtrEquals(tc, 0, orders);
|
||||||
orders = orig;
|
orders = orig;
|
||||||
|
@ -171,6 +195,25 @@ static void test_replace_order(CuTest *tc) {
|
||||||
test_cleanup();
|
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 *get_order_suite(void)
|
||||||
{
|
{
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -183,5 +226,6 @@ CuSuite *get_order_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_replace_order);
|
SUITE_ADD_TEST(suite, test_replace_order);
|
||||||
SUITE_ADD_TEST(suite, test_skip_token);
|
SUITE_ADD_TEST(suite, test_skip_token);
|
||||||
SUITE_ADD_TEST(suite, test_getstrtoken);
|
SUITE_ADD_TEST(suite, test_getstrtoken);
|
||||||
|
SUITE_ADD_TEST(suite, test_get_command);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ static void load_inifile(void)
|
||||||
static const char * valid_keys[] = {
|
static const char * valid_keys[] = {
|
||||||
"game.id",
|
"game.id",
|
||||||
"game.name",
|
"game.name",
|
||||||
|
"game.start",
|
||||||
"game.locale",
|
"game.locale",
|
||||||
"game.verbose",
|
"game.verbose",
|
||||||
"game.report",
|
"game.report",
|
||||||
|
@ -82,9 +83,11 @@ static const char * valid_keys[] = {
|
||||||
"game.memcheck",
|
"game.memcheck",
|
||||||
"game.email",
|
"game.email",
|
||||||
"game.mailcmd",
|
"game.mailcmd",
|
||||||
|
"game.era",
|
||||||
"game.sender",
|
"game.sender",
|
||||||
"editor.color",
|
"editor.color",
|
||||||
"editor.codepage",
|
"editor.codepage",
|
||||||
|
"editor.population.",
|
||||||
"lua.",
|
"lua.",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
|
@ -493,18 +493,12 @@ static order *make_movement_order(unit * u, const region * target, int moves,
|
||||||
if (plan == NULL)
|
if (plan == NULL)
|
||||||
return 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]) {
|
while (position != moves && plan[position + 1]) {
|
||||||
region *prev = plan[position];
|
region *prev = plan[position];
|
||||||
region *next = plan[++position];
|
region *next = plan[++position];
|
||||||
direction_t dir = reldirection(prev, next);
|
direction_t dir = reldirection(prev, next);
|
||||||
assert(dir != NODIRECTION && dir != D_SPECIAL);
|
assert(dir != NODIRECTION && dir != D_SPECIAL);
|
||||||
if (size > 1) {
|
if (size > 1 && bufp != zOrder) {
|
||||||
*bufp++ = ' ';
|
*bufp++ = ' ';
|
||||||
--size;
|
--size;
|
||||||
}
|
}
|
||||||
|
@ -516,7 +510,7 @@ static order *make_movement_order(unit * u, const region * target, int moves,
|
||||||
}
|
}
|
||||||
|
|
||||||
*bufp = 0;
|
*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)
|
void random_growl(const unit *u, region *target, int rand)
|
||||||
|
|
|
@ -66,6 +66,8 @@ static attrib *mk_piracy(const faction * pirate, const faction * target,
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool validate_pirate(unit *u, order *ord) {
|
static bool validate_pirate(unit *u, order *ord) {
|
||||||
|
assert(u);
|
||||||
|
assert(ord);
|
||||||
if (fval(u_race(u), RCF_SWIM | RCF_FLY))
|
if (fval(u_race(u), RCF_SWIM | RCF_FLY))
|
||||||
return true;
|
return true;
|
||||||
if (!u->ship) {
|
if (!u->ship) {
|
||||||
|
@ -128,6 +130,7 @@ void piracy_cmd(unit * u)
|
||||||
int saff = 0;
|
int saff = 0;
|
||||||
int *il;
|
int *il;
|
||||||
|
|
||||||
|
assert(u->thisorder);
|
||||||
if (!validate_pirate(u, u->thisorder)) {
|
if (!validate_pirate(u, u->thisorder)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,6 +137,7 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
||||||
u_set_ship(u, test_create_ship(u->region, st_boat));
|
u_set_ship(u, test_create_ship(u->region, st_boat));
|
||||||
|
|
||||||
u2 = test_create_unit(u->faction, u->region);
|
u2 = test_create_unit(u->faction, u->region);
|
||||||
|
u2->thisorder = create_order(K_PIRACY, f->locale, "");
|
||||||
u_set_ship(u2, u->ship);
|
u_set_ship(u2, u->ship);
|
||||||
|
|
||||||
test_clear_messages(f);
|
test_clear_messages(f);
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef _LP64
|
||||||
|
#define _LP64 0 /* fix a warning in pdcurses 3.4 */
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef UNILIB_H
|
#ifndef UNILIB_H
|
||||||
#define UNILIB_H
|
#define UNILIB_H
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue