From 76cce7f2399ef3b60ee53ce55a72da3454308b16 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 2 Mar 2015 23:12:02 +0100 Subject: [PATCH 1/5] fix terrible code to avoid gcc 4.9 warning --- src/kernel/region.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/kernel/region.c b/src/kernel/region.c index 7f5d65ef6..807fb3d76 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -611,8 +611,8 @@ int rpeasants(const region * r) void rsetpeasants(region * r, int value) { - ((r)->land ? ((r)->land->peasants = - (value)) : (assert((value) >= 0), (value)), 0); + if (r->land) r->land->peasants = value; + else assert(value>=0); } int rmoney(const region * r) @@ -634,8 +634,8 @@ int rhorses(const region * r) void rsetmoney(region * r, int value) { - ((r)->land ? ((r)->land->money = - (value)) : (assert((value) >= 0), (value)), 0); + if (r->land) r->land->money = value; + else assert(value >= 0); } void r_setdemand(region * r, const luxury_type * ltype, int value) From cad154ac59a71cf9d2ae8cc2b17081c6d3c60818 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Mar 2015 13:56:31 +0100 Subject: [PATCH 2/5] re-enable silver weight Conflicts: scripts/tests/e3/rules.lua scripts/tests/faction.lua --- res/core/common/items.xml | 2 +- scripts/tests/e3/rules.lua | 33 ++++++++++++++++++++++++--------- scripts/tests/faction.lua | 3 ++- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/res/core/common/items.xml b/res/core/common/items.xml index 9508653e7..c8910e695 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 193551ea9..62bbd8758 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 skip_test_silver_weight_stops_movement() +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") @@ -729,7 +729,7 @@ function skip_test_silver_weight_stops_movement() assert_equal(r2, u1.region) end -function skip_test_silver_weight_stops_ship() +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") @@ -771,11 +771,26 @@ function test_building_owner_can_enter_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) +function test_only_building_owner_can_set_not_paid() + local r = region.create(0, 0, "plain") + local f = faction.create("noreply@eressea.de", "human", "de") + local u1 = unit.create(f, r, 1) + local u2 = unit.create(f, r, 1) + local mine = building.create(r, "mine") + mine.size = 2 + u1:add_item("money", 500) + u1.building = mine + u2.building = mine + u1:clear_orders() + u2:clear_orders() +-- Test that Bezahle nicht is working + u1:add_order("Bezahle nicht") + process_orders() + assert_equal(500, u1:get_item("money")) + u1:clear_orders() +-- Test that bug fix 0001976 is working +-- Bezahle nicht is not working + u2:add_order("Bezahle nicht") + process_orders() + assert_equal(0, u1:get_item("money")) end diff --git a/scripts/tests/faction.lua b/scripts/tests/faction.lua index a6a07a6e1..b4c0179d3 100644 --- a/scripts/tests/faction.lua +++ b/scripts/tests/faction.lua @@ -10,7 +10,8 @@ function setup() }]] eressea.config.reset() assert(eressea.config.parse(conf)==0) - f = faction.create("faction@eressea.de", "human", "de") + f = faction.create("faction@eressea.de", "human", "de") + assert(f~=nil) end function test_faction_flags() From eb282eecb1ea1dd4ac2bd13cae280948c59b8374 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 4 Mar 2015 22:19:11 +0100 Subject: [PATCH 3/5] fix keyword-buffer overflow --- src/kernel/config.h | 1 - src/keyword.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/kernel/config.h b/src/kernel/config.h index a10186e6d..caffedb9e 100644 --- a/src/kernel/config.h +++ b/src/kernel/config.h @@ -81,7 +81,6 @@ extern "C" { #define ORDERSIZE (DISPLAYSIZE*2) /* max. length of an order */ #define NAMESIZE 128 /* max. Länge eines Namens, incl trailing 0 */ #define IDSIZE 16 /* max. Länge einer no (als String), incl trailing 0 */ -#define KEYWORDSIZE 16 /* max. Länge eines Keyword, incl trailing 0 */ #define OBJECTIDSIZE (NAMESIZE+5+IDSIZE) /* max. Länge der Strings, die * von struct unitname, etc. zurückgegeben werden. ohne die 0 */ diff --git a/src/keyword.c b/src/keyword.c index fde981bb9..1ffdc4c3c 100644 --- a/src/keyword.c +++ b/src/keyword.c @@ -12,7 +12,7 @@ const char * keyword(keyword_t kwd) { - static char result[KEYWORDSIZE]; // FIXME: static return value + static char result[32]; // FIXME: static return value if (!result[0]) { strcpy(result, "keyword::"); } From 0b3190605a9df0b433cad7527323814f20f7a386 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Mar 2015 14:13:29 +0100 Subject: [PATCH 4/5] increase build number: silver weight enabled again, fix keyword crash --- src/buildno.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/buildno.h b/src/buildno.h index be62c19a5..1bf7abd91 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 4 -#define VERSION_BUILD 5 +#define VERSION_BUILD 6 From 3e1ae5e0f2587f3153a37a4387ef3f1e15a1a93a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 19 Apr 2015 08:13:40 +0200 Subject: [PATCH 5/5] allow reading of JSON_REPORT_VERSION from future source release --- src/buildno.h | 2 +- src/kernel/save.c | 2 +- src/kernel/version.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/buildno.h b/src/buildno.h index 1bf7abd91..551e0a9a3 100644 --- a/src/buildno.h +++ b/src/buildno.h @@ -1,3 +1,3 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 4 -#define VERSION_BUILD 6 +#define VERSION_BUILD 7 diff --git a/src/kernel/save.c b/src/kernel/save.c index db9999148..6b6be28e4 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -1382,7 +1382,7 @@ int readgame(const char *filename, int backup) assert(stream_version == STREAM_VERSION || !"unsupported data format"); } assert(gdata.version >= MIN_VERSION || !"unsupported data format"); - assert(gdata.version <= RELEASE_VERSION || !"unsupported data format"); + assert(gdata.version <= MAX_VERSION || !"unsupported data format"); gdata.encoding = enc_gamedata; fstream_init(&strm, F); diff --git a/src/kernel/version.h b/src/kernel/version.h index 516893437..a59c6013a 100644 --- a/src/kernel/version.h +++ b/src/kernel/version.h @@ -30,6 +30,7 @@ #define AUTO_RACENAME_VERSION 345 /* NPC units with name==NULL will automatically get their race for a name */ #define MIN_VERSION INTPAK_VERSION /* minimal datafile we support */ +#define MAX_VERSION 346 #define RELEASE_VERSION AUTO_RACENAME_VERSION /* current datafile */ #define STREAM_VERSION 2 /* internal encoding of binary files */