From 7cbd23c26bac38ef83eaeeb7dbd87c7100112389 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Aug 2016 20:50:27 +0200 Subject: [PATCH 1/2] fix error detection during report writing --- src/reports.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/reports.c b/src/reports.c index 379b35429..48a01d9a8 100644 --- a/src/reports.c +++ b/src/reports.c @@ -1543,21 +1543,21 @@ int write_reports(faction * f, time_t ltime) log_debug("Reports for %s:", factionname(f)); for (rtype = report_types; rtype != NULL; rtype = rtype->next) { if (f->options & rtype->flag) { - int error; + int error = 0; do { char filename[32]; char path[MAX_PATH]; sprintf(filename, "%d-%s.%s", turn, factionid(f), rtype->extension); join_path(reportpath(), filename, path, sizeof(path)); - error = 0; + errno = 0; if (rtype->write(path, &ctx, encoding) == 0) { gotit = true; } if (errno) { char zText[64]; - log_warning("retrying, error %d during %s report for faction %s", error, rtype->extension, factionname(f)); - sprintf(zText, "waiting %u seconds before we retry", backup / 1000); + log_warning("retrying, error %d during %s report for faction %s", errno, rtype->extension, factionname(f)); + sprintf(zText, "waiting %u seconds before we retry", backup); perror(zText); _sleep(backup); if (backup < maxbackup) { From 6aebb12fd5d19ee759e2aa0ea1fc1a13ee0e3197 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Aug 2016 21:51:31 +0200 Subject: [PATCH 2/2] Fix duplicate market effect. https://bugs.eressea.de/view.php?id=2225 The Lua markets module is wrong, so the C code is being used. Disable the Lua module for now, either fix or delete it later? --- scripts/eressea/e3/init.lua | 2 +- scripts/eressea/e4/init.lua | 2 +- scripts/tests/e3/rules.lua | 31 ++++++++++++++++++------------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/eressea/e3/init.lua b/scripts/eressea/e3/init.lua index 9acda1093..e376eaadc 100644 --- a/scripts/eressea/e3/init.lua +++ b/scripts/eressea/e3/init.lua @@ -6,7 +6,7 @@ eressea.log.debug("rules for game E3") return { require('eressea'), require('eressea.xmasitems'), - require('eressea.markets'), + -- require('eressea.markets'), require('eressea.frost'), require('eressea.ents') } diff --git a/scripts/eressea/e4/init.lua b/scripts/eressea/e4/init.lua index e5e617c55..32c0b8498 100644 --- a/scripts/eressea/e4/init.lua +++ b/scripts/eressea/e4/init.lua @@ -5,7 +5,7 @@ eressea.log.debug("rules for game E4") return { require('eressea'), - require('eressea.markets'), + -- require('eressea.markets'), require('eressea.frost'), require('eressea.ents') } diff --git a/scripts/tests/e3/rules.lua b/scripts/tests/e3/rules.lua index 323103e73..2cba83f21 100644 --- a/scripts/tests/e3/rules.lua +++ b/scripts/tests/e3/rules.lua @@ -4,6 +4,14 @@ module("tests.e3.e3features", package.seeall, lunit.testcase) local settings +-- use the C implementation in market.c, because the Lua +-- module is wrong (https://bugs.eressea.de/view.php?id=2225) +local function process_markets() + -- markets = require("eressea.markets") + -- markets.update() + eressea.process.markets() +end + local function set_rule(key, value) if value==nil then eressea.settings.set(key, settings[key]) @@ -403,8 +411,7 @@ function test_market_regions() -- if i am the only trader around, i should be getting all the herbs from all 7 regions local r, u, b, herbnames, luxurynames, herbtable, luxurytable = market_fixture() - - eressea.process.markets() + process_markets() test_items(u, herbtable, 10) test_items(u, luxurytable, 5) @@ -420,9 +427,8 @@ function test_multiple_markets() b2.working = true reset_items(u2) u2.building = b2 - - eressea.process.markets() + process_markets() for _, i in pairs(luxurytable) do assert_equal(5, u1:get_item(i)+u2:get_item(i), "not enough " .. i ) end @@ -432,12 +438,11 @@ function test_multiple_markets() assert_equal(5, u1:get_item('silk')) -- uncontested end - function test_market() local r = region.create(0, 0, "plain") local f1 = faction.create("market2@eressea.de", "human", "de") local u1 = unit.create(f1, r, 1) - + local b = building.create(r, "market") eressea.settings.set("rules.peasants.growth", "0") @@ -469,7 +474,7 @@ function test_market() end reset_items() b.size = 1 - eressea.process.markets() + process_markets() assert_equal(0, u1:get_item("h0")) b.size = 10 @@ -477,38 +482,38 @@ function test_market() reset_items() r:set_resource("peasant", 2100) - eressea.process.markets() + process_markets() assert_equal(5, u1:get_item("h0")) assert_equal(3, u1:get_item("balm")) reset_items() r:set_resource("peasant", 1049) - eressea.process.markets() + process_markets() assert_equal(2, u1:get_item("h0")) assert_equal(1, u1:get_item("balm")) reset_items() r:set_resource("peasant", 550) - eressea.process.markets() + process_markets() assert_equal(2, u1:get_item("h0")) assert_equal(1, u1:get_item("balm")) reset_items() r:set_resource("peasant", 549) - eressea.process.markets() + process_markets() assert_equal(1, u1:get_item("h0")) assert_equal(1, u1:get_item("balm")) reset_items() r:set_resource("peasant", 50) - eressea.process.markets() + process_markets() assert_equal(1, u1:get_item("h0")) assert_equal(1, u1:get_item("balm")) reset_items() r:set_resource("peasant", 49) - eressea.process.markets() + process_markets() assert_equal(0, u1:get_item("h0")) r:set_resource("peasant", 1050)