From 29fc0fe6c3205147372eb78edff5687d6fa8974c Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 9 Jan 2015 20:41:48 +0100 Subject: [PATCH 1/7] preview build script checks for a branch to build from (in build/.preview) fix int to bool conversions --- s/cron/previews.sh | 16 ++++++++++------ src/kernel/order.c | 6 ++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/s/cron/previews.sh b/s/cron/previews.sh index 7c9f8bb95..6e30c75c5 100755 --- a/s/cron/previews.sh +++ b/s/cron/previews.sh @@ -1,9 +1,13 @@ #!/bin/sh -[ -z $ERESSEA ] && ERESSEA=$HOME/eressea -SRC=$ERESSEA/git -$SRC/s/preview build master -$SRC/s/preview version +[ -z ${ERESSEA} ] && ERESSEA=~/eressea +branch="master" +if [ -e ${ERESSEA}/build/.preview ]; then + branch=`cat ${ERESSEA}/build/.preview` +fi +SRC=${ERESSEA}/git +${SRC}/s/preview build ${branch} +${SRC}/s/preview version for game in 2 3 4 ; do - $SRC/s/preview -g $game run && \ - $SRC/s/preview -g $game send + ${SRC}/s/preview -g ${game} run && \ + ${SRC}/s/preview -g ${game} send done diff --git a/src/kernel/order.c b/src/kernel/order.c index 165769807..83171ddfe 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -472,7 +472,6 @@ bool is_exclusive(const order * ord) bool is_long(const order * ord) { keyword_t kwd = ORD_KEYWORD(ord); - bool result = false; switch (kwd) { case K_CAST: @@ -499,9 +498,9 @@ bool is_long(const order * ord) return true; default: - result = false; + break; } - return result; + return false; } /** @@ -529,7 +528,6 @@ bool is_persistent(const order * ord) default: return persist || is_repeated(ord); } - } char *write_order(const order * ord, char *buffer, size_t size) From e6538439fb845bfb5135135d06ae11b5ef5fb41d Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Mon, 12 Jan 2015 20:01:12 +0100 Subject: [PATCH 2/7] mallorn spell used wrong error message --- src/spells.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spells.c b/src/spells.c index 9474a69cc..73be7f187 100644 --- a/src/spells.c +++ b/src/spells.c @@ -1044,11 +1044,11 @@ static int sp_mallorn(castorder * co) unit *mage = co->magician.u; if (!fval(r->terrain, LAND_REGION)) { - cmistake(mage, co->order, 290, MSG_MAGIC); + cmistake(mage, co->order, 186, MSG_MAGIC); return 0; } if (fval(r, RF_MALLORN)) { - cmistake(mage, co->order, 291, MSG_MAGIC); + cmistake(mage, co->order, 191, MSG_MAGIC); return 0; } From 9142b79614697e35b89b9bbe161fc2909cd2745b Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Tue, 13 Jan 2015 11:18:13 +0100 Subject: [PATCH 3/7] fixed message (bug #1506) --- res/core/messages.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/core/messages.xml b/res/core/messages.xml index cbc5dd780..d983fe455 100644 --- a/res/core/messages.xml +++ b/res/core/messages.xml @@ -5858,8 +5858,8 @@ - "$unit($unit) in $region($region): '$order($command)' - Laen kann nur in einem Bergwerk abgebaut werden." - "$unit($unit) in $region($region): '$order($command)' - Laen can be excavated only in a mine." + "$unit($unit) in $region($region): '$order($command)' - Dieses Metall kann nur in einem Bergwerk abgebaut werden." + "$unit($unit) in $region($region): '$order($command)' - This metal can be excavated only in a mine." From 468882f974fb0e5bebdd01e20992324f3d583949 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Jan 2015 07:46:42 +0100 Subject: [PATCH 4/7] 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]); From 6fb23af66a2b2e14ceb88132a9686f1644189098 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 14 Jan 2015 17:49:48 +0100 Subject: [PATCH 5/7] test that ships are encumbered by money. define money in XML, not just in code. --- res/core/common/items.xml | 4 ++++ scripts/tests/e3/rules.lua | 19 +++++++++++++++++++ src/kernel/item.c | 1 - src/kernel/item.test.c | 22 ++++++++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index d867a3126..c8910e695 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -1,6 +1,10 @@ + + + + diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 5350df169..57c19522d 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -729,6 +729,25 @@ function test_silver_weight_stops_movement() assert_equal(r2, u1.region) end +function test_silver_weight_stops_ship() + local r1 = region.create(1, 1, "ocean") + local r2 = region.create(2, 1, "ocean") + region.create(3, 1, "ocean") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r1, 1) + u1:set_skill("sailing", 3) + local s1 = ship.create(r1, "canoe") + u1.ship = s1 + u1:clear_orders() + u1:add_order("NACH OST") + u1:add_item("money", 2000) + 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 1592d1a93..b09ea1b67 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -960,7 +960,6 @@ 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]); diff --git a/src/kernel/item.test.c b/src/kernel/item.test.c index dcb7ca878..981edf641 100644 --- a/src/kernel/item.test.c +++ b/src/kernel/item.test.c @@ -143,6 +143,27 @@ static void test_fix_demand(CuTest *tc) { test_cleanup(); } +static void test_core_resources(CuTest *tc) { + resource_type * rtype; + test_cleanup(); + init_resources(); + CuAssertPtrNotNull(tc, rtype = rt_find("money")); + CuAssertPtrNotNull(tc, rtype->itype); + CuAssertPtrNotNull(tc, rtype->uchange); + CuAssertPtrNotNull(tc, rtype->itype->give); + CuAssertPtrNotNull(tc, rtype = rt_find("peasant")); + CuAssertPtrEquals(tc, 0, rtype->itype); + CuAssertPtrNotNull(tc, rtype = rt_find("person")); + CuAssertPtrEquals(tc, 0, rtype->itype); + CuAssertPtrNotNull(tc, rtype = rt_find("permaura")); + CuAssertPtrEquals(tc, 0, rtype->itype); + CuAssertPtrNotNull(tc, rtype = rt_find("hp")); + CuAssertPtrEquals(tc, 0, rtype->itype); + CuAssertPtrNotNull(tc, rtype = rt_find("aura")); + CuAssertPtrEquals(tc, 0, rtype->itype); + test_cleanup(); +} + CuSuite *get_item_suite(void) { CuSuite *suite = CuSuiteNew(); @@ -153,5 +174,6 @@ CuSuite *get_item_suite(void) SUITE_ADD_TEST(suite, test_finditemtype); SUITE_ADD_TEST(suite, test_findresourcetype); SUITE_ADD_TEST(suite, test_fix_demand); + SUITE_ADD_TEST(suite, test_core_resources); return suite; } From c7b28e7b39d6c6f2e823b6d152c5b7ebfd939a8b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 26 Jan 2015 07:17:19 +0100 Subject: [PATCH 6/7] disable ORIGIN at the source, prevent gcc warnings. --- src/laws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laws.c b/src/laws.c index 0c01f0471..36171ed2b 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4318,7 +4318,7 @@ void init_processor(void) p += 10; add_proc_order(p, K_QUIT, &quit_cmd, 0, NULL); - add_proc_order(p, K_URSPRUNG, &origin_cmd, 0, NULL); + // add_proc_order(p, K_URSPRUNG, &origin_cmd, 0, NULL); add_proc_order(p, K_ALLY, &ally_cmd, 0, NULL); add_proc_order(p, K_PREFIX, &prefix_cmd, 0, NULL); add_proc_order(p, K_SETSTEALTH, &setstealth_cmd, 0, NULL); From 7527e6e90372fe78cf0b0f615c68f8059c82758a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 29 Jan 2015 16:56:21 +0100 Subject: [PATCH 7/7] disable silver weight for the initial rollout of version 3.4 two weeks after launch, revert this commit --- res/core/common/items.xml | 2 +- scripts/tests/e3/rules.lua | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index c8910e695..9508653e7 100644 --- a/res/core/common/items.xml +++ b/res/core/common/items.xml @@ -2,7 +2,7 @@ - + diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 57c19522d..193551ea9 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -712,7 +712,7 @@ function test_golem_use_four_iron() assert_equal(4, u1:get_item("towershield")) end -function test_silver_weight_stops_movement() +function skip_test_silver_weight_stops_movement() local r1 = region.create(1, 1, "plain") local r2 = region.create(2, 1, "plain") region.create(3, 1, "plain") @@ -729,7 +729,7 @@ function test_silver_weight_stops_movement() assert_equal(r2, u1.region) end -function test_silver_weight_stops_ship() +function skip_test_silver_weight_stops_ship() local r1 = region.create(1, 1, "ocean") local r2 = region.create(2, 1, "ocean") region.create(3, 1, "ocean") @@ -770,3 +770,12 @@ function test_building_owner_can_enter_ship() assert_equal(s1, u1.ship) assert_equal(null, u1.building, "owner of the building can not go into a ship") end + +function test_weightless_silver() + local r1 = region.create(1, 2, "plain") + local f1 = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f1, r1, 1) + assert_equal(1000, u1.weight) + u1:add_item("money", 540) + assert_equal(1000, u1.weight) +end