From 84fb776d1c75f9af008e36292cf01c6b5a0db111 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Wed, 25 Jun 2014 13:15:37 +0200 Subject: [PATCH 1/8] Fixed a bug that crasehed the server when Stonegolems created a new building and the whole unite was consumed during this process (could not enter the new building as no one was left in the unit) --- src/kernel/build.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/kernel/build.c b/src/kernel/build.c index 86b390755..79b7d7567 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -774,7 +774,8 @@ build_building(unit * u, const building_type * btype, int want, order * ord) fset(b, BLD_MAINTAINED); /* Die Einheit befindet sich automatisch im Inneren der neuen Burg. */ - if (leave(u, false)) { + /* Check if unit still have member, as stonegolems are destroyed during construction*/ + if (leave(u, false) && u->number >> 0) { u_set_building(u, b); assert(building_owner(b)==u); } From fa9ac186d7fad58aad55233104f93dc5caf568c6 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Wed, 25 Jun 2014 13:20:00 +0200 Subject: [PATCH 2/8] Test a bug that crasehed the server when Stonegolems created a new building and the whole unite was consumed during this process (could not enter the new building as no one was left in the unit) --- scripts/tests/eressea.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/tests/eressea.lua b/scripts/tests/eressea.lua index 87a493e5e..e2825d973 100644 --- a/scripts/tests/eressea.lua +++ b/scripts/tests/eressea.lua @@ -306,3 +306,32 @@ function test_block_movement_aots() assert_equal(r1, u21.region, "unit with amulet should stop me") assert_equal(r2, u22.region, "nobody should see me") end + +function test_stonegolems() + local r0 = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "stonegolem", "de") + local u1 = unit.create(f1, r0, 1) + local u2 = unit.create(f1, r0, 2) + local c1 = building.create(r0, "castle") + + c1.size = 226 + + u1:set_skill("building", 1) + u2:set_skill("building", 1) + +-- test that no server crash occur + u1:clear_orders() + u1:add_order("Mache Burg") + process_orders() + assert_equal(0 ,u1.number, "There shoud be no Stone Golems") +-- end test server crash + +-- test that Stone Golems build for four stones + u2:clear_orders() + u2:add_order("MACHE 4 BURG " .. itoa36(c1.id)) + process_orders() + assert_equal(230, c1.size, "resulting size should be 230") + assert_equal(1 ,u2.number, "There shoud be one Stone Golems") +-- end test Stone Golems four stones +end + From 0400bcafadf40754c5abddd9317636db643d285a Mon Sep 17 00:00:00 2001 From: TomBraun Date: Wed, 25 Jun 2014 13:22:42 +0200 Subject: [PATCH 3/8] Iron and Stone golems now use the corect number of stones / iron. 0001946: Eisengolems stellen keine Waren her http://bugs.eressea.de/view.php?id=1921 --- src/kernel/item.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index 729a94679..016efcc16 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -110,14 +110,14 @@ static int res_changeitem(unit * u, const resource_type * rtype, int delta) if (delta % GOLEM_STONE != 0) --reduce; scale_number(u, u->number + reduce); - num = u->number; + num = u->number * GOLEM_STONE; } else if (rtype == get_resourcetype(R_IRON) && u_race(u) == new_race[RC_IRONGOLEM] && delta <= 0) { int reduce = delta / GOLEM_IRON; if (delta % GOLEM_IRON != 0) --reduce; scale_number(u, u->number + reduce); - num = u->number; + num = u->number * GOLEM_IRON; } else { const item_type *itype = resource2item(rtype); item *i; From d4fdddbc2710dbf27816fc616407952522f17394 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Wed, 25 Jun 2014 13:24:06 +0200 Subject: [PATCH 4/8] Iron golems can now create dwarfen only items (makes irongolems usable for dwarfs) --- src/kernel/item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/item.c b/src/kernel/item.c index 016efcc16..b3c1f1fe1 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -753,7 +753,7 @@ mod_elves_only(const unit * u, const region * r, skill_t sk, int value) static int mod_dwarves_only(const unit * u, const region * r, skill_t sk, int value) { - if (u_race(u) == new_race[RC_DWARF]) + if (u_race(u) == new_race[RC_DWARF] || (u_race(u)->flags & RCF_IRONGOLEM)) return value; unused_arg(r); return -118; From 50ff812bb82633cc02139b174f881ae1688ab920 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Wed, 25 Jun 2014 13:26:34 +0200 Subject: [PATCH 5/8] Add test Iron Golems now use the corect number of iron. Test also Iron Golems can now create dwarfen only items (makes irongolems usable for dwarfs) --- scripts/tests/e3a.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index c94fa54db..93ad00721 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -693,3 +693,22 @@ function disabled_test_bug_1738_build_castle_e3() -- does not have the needed minimum skill. assert_equal(c.size, 250) end + +function test_golem_use_four_iron() + + local r0 = region.create(0, 0, "plain") + local f1 = faction.create("noreply@eressea.de", "irongolem", "de") + local u1 = unit.create(f1, r0, 3) + u1:set_skill("weaponsmithing", 1) + u1:set_skill("armorer", 1) + u1:clear_orders() + u1:add_order("Mache 4 Turmschild") + + process_orders() + + assert_equal(4 ,u1:get_item("towershield"), "I shoud have 4 towershields") + assert_equal(2 ,u1.number, "There shoud be 2 Irongolems left") + + +end + From 99da4de9ad34f288ecc4b395194204796754fb80 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Thu, 26 Jun 2014 07:20:59 +0200 Subject: [PATCH 6/8] Define "pf_generic cast = 0" and "pf_generic fumble = 0" early Visual Studio 2013 express don't compile without errors if this definition comes to late. --- src/kernel/xmlreader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 4cc8ba358..9935604db 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1487,6 +1487,8 @@ static int parse_spells(xmlDocPtr doc) xmlXPathObjectPtr spells; char zText[32]; strcpy(zText, "fumble_"); + pf_generic cast = 0; + pf_generic fumble = 0; /* reading eressea/spells/spell */ spells = xmlXPathEvalExpression(BAD_CAST "/eressea/spells/spell", xpath); @@ -1555,8 +1557,6 @@ static int parse_spells(xmlDocPtr doc) sp->sptyp |= modes[k]; /* reading eressea/spells/spell/function */ - pf_generic cast = 0; - pf_generic fumble = 0; xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "function", xpath); From 6ced596b1339acac04ab5de88be34a2563232ad7 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Thu, 26 Jun 2014 14:59:54 +0200 Subject: [PATCH 7/8] Chang "git submodule update --init" with "clone --recursive" --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 252f3c349..6952de5f6 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,8 @@ Eressea depends on a number of external libraries. On a recent Debian-based Linu This repository relies heavily on the use of submodules, and it pulls in most of the code from those. The build system being used is cmake, which can create Makefiles on Unix, or Visual Studio project files on Windows. Here's how you clone and build the source on Ubuntu: - git clone git://github.com/eressea/server.git + git clone --recursive git://github.com/eressea/server.git cd server - git submodule update --init ./configure -If you got this far and all went well, you have built a server (it is linked from the `game` subdirectory), and it will have passed some basic functionality tests. \ No newline at end of file +If you got this far and all went well, you have built a server (it is linked from the `game` subdirectory), and it will have passed some basic functionality tests. From c31c436cc7d978a8f32cc43df1f315634c8cf6a8 Mon Sep 17 00:00:00 2001 From: TomBraun Date: Sat, 28 Jun 2014 20:45:17 +0200 Subject: [PATCH 8/8] change u->number >> 0 to u->number>0 --- src/kernel/build.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel/build.c b/src/kernel/build.c index 79b7d7567..74072358d 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -775,7 +775,7 @@ build_building(unit * u, const building_type * btype, int want, order * ord) /* Die Einheit befindet sich automatisch im Inneren der neuen Burg. */ /* Check if unit still have member, as stonegolems are destroyed during construction*/ - if (leave(u, false) && u->number >> 0) { + if (leave(u, false) && u->number>0) { u_set_building(u, b); assert(building_owner(b)==u); }