From 468882f974fb0e5bebdd01e20992324f3d583949 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Jan 2015 07:46:42 +0100 Subject: [PATCH] test that money has weight, add weight in init_resources (TODO: use the config files). --- scripts/tests/e3/rules.lua | 17 +++++++++++++++++ src/kernel/item.c | 1 + 2 files changed, 18 insertions(+) diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 07fbb1a60..5350df169 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -712,6 +712,23 @@ function test_golem_use_four_iron() assert_equal(4, u1:get_item("towershield")) end +function test_silver_weight_stops_movement() + local r1 = region.create(1, 1, "plain") + local r2 = region.create(2, 1, "plain") + region.create(3, 1, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r1, 1) + u1:clear_orders() + u1:add_order("NACH OST") + u1:add_item("money", 540) + assert_equal(1540, u1.weight) + process_orders() + assert_equal(r2, u1.region) + u1:add_item("money", 1) + process_orders() + assert_equal(r2, u1.region) +end + function test_building_owner_can_enter_ship() local r1 = region.create(1, 2, "plain") local f1 = faction.create("noreply@eressea.de", "human", "de") diff --git a/src/kernel/item.c b/src/kernel/item.c index b09ea1b67..1592d1a93 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -960,6 +960,7 @@ void init_resources(void) rtype->uchange = res_changeitem; rtype->itype = it_get_or_create(rtype); rtype->itype->give = give_money; + rtype->itype->weight = 1; // R_PERMAURA rtype = rt_get_or_create(resourcenames[R_PERMAURA]);