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. diff --git a/scripts/tests/e3a.lua b/scripts/tests/e3a.lua index c94fa54db..a656c50a4 100644 --- a/scripts/tests/e3a.lua +++ b/scripts/tests/e3a.lua @@ -693,3 +693,20 @@ 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", "dwarf", "de") + local u1 = unit.create(f1, r0, 3) + u1.race = "irongolem" + u1:set_skill("weaponsmithing", 1) + u1:set_skill("armorer", 1) + u1:clear_orders() + u1:add_order("Mache 4 Turmschild") + + process_orders() + + assert_equal(2, u1.number) + assert_equal(4, u1:get_item("towershield")) +end + 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 + diff --git a/src/kernel/build.c b/src/kernel/build.c index 380a1af3c..7988293ef 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -777,13 +777,12 @@ build_building(unit * u, const building_type * btype, int id, int want, order * /* Die Einheit befindet sich automatisch im Inneren der neuen Burg. */ if (u->number && leave(u, false)) { - u_set_building(u, b); - assert(building_owner(b)==u); + u_set_building(u, b); } #ifdef WDW_PYRAMID if (b->type == bt_find("pyramid") && f_get_alliance(u->faction) != NULL) { - attrib *a = a_add(&b->attribs, a_new(&at_alliance)); - a->data.i = u->faction->alliance->id; + attrib *a = a_add(&b->attribs, a_new(&at_alliance)); + a->data.i = u->faction->alliance->id; } #endif } diff --git a/src/kernel/item.c b/src/kernel/item.c index 815ef0a2d..e8879ae00 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -109,14 +109,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) == get_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; @@ -711,10 +711,11 @@ 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) == get_race(RC_DWARF)) + unused_arg(r); + if (u->faction->race == get_race(RC_DWARF)) { return value; - unused_arg(r); - return -118; + } + return -118; } static int heal(unit * user, int effect) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index bdfc429bb..0a2679ac0 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1441,6 +1441,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); @@ -1509,8 +1511,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);