forked from github/server
Merge pull request #533 from ennorehling/develop
fix duplicate market effect
This commit is contained in:
commit
42703de217
|
@ -6,7 +6,7 @@ eressea.log.debug("rules for game E3")
|
||||||
return {
|
return {
|
||||||
require('eressea'),
|
require('eressea'),
|
||||||
require('eressea.xmasitems'),
|
require('eressea.xmasitems'),
|
||||||
require('eressea.markets'),
|
-- require('eressea.markets'),
|
||||||
require('eressea.frost'),
|
require('eressea.frost'),
|
||||||
require('eressea.ents')
|
require('eressea.ents')
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ eressea.log.debug("rules for game E4")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
require('eressea'),
|
require('eressea'),
|
||||||
require('eressea.markets'),
|
-- require('eressea.markets'),
|
||||||
require('eressea.frost'),
|
require('eressea.frost'),
|
||||||
require('eressea.ents')
|
require('eressea.ents')
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,14 @@ module("tests.e3.e3features", package.seeall, lunit.testcase)
|
||||||
|
|
||||||
local settings
|
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)
|
local function set_rule(key, value)
|
||||||
if value==nil then
|
if value==nil then
|
||||||
eressea.settings.set(key, settings[key])
|
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
|
-- 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()
|
local r, u, b, herbnames, luxurynames, herbtable, luxurytable = market_fixture()
|
||||||
|
|
||||||
|
process_markets()
|
||||||
eressea.process.markets()
|
|
||||||
|
|
||||||
test_items(u, herbtable, 10)
|
test_items(u, herbtable, 10)
|
||||||
test_items(u, luxurytable, 5)
|
test_items(u, luxurytable, 5)
|
||||||
|
@ -421,8 +428,7 @@ function test_multiple_markets()
|
||||||
reset_items(u2)
|
reset_items(u2)
|
||||||
u2.building = b2
|
u2.building = b2
|
||||||
|
|
||||||
|
process_markets()
|
||||||
eressea.process.markets()
|
|
||||||
for _, i in pairs(luxurytable) do
|
for _, i in pairs(luxurytable) do
|
||||||
assert_equal(5, u1:get_item(i)+u2:get_item(i), "not enough " .. i )
|
assert_equal(5, u1:get_item(i)+u2:get_item(i), "not enough " .. i )
|
||||||
end
|
end
|
||||||
|
@ -432,7 +438,6 @@ function test_multiple_markets()
|
||||||
assert_equal(5, u1:get_item('silk')) -- uncontested
|
assert_equal(5, u1:get_item('silk')) -- uncontested
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function test_market()
|
function test_market()
|
||||||
local r = region.create(0, 0, "plain")
|
local r = region.create(0, 0, "plain")
|
||||||
local f1 = faction.create("market2@eressea.de", "human", "de")
|
local f1 = faction.create("market2@eressea.de", "human", "de")
|
||||||
|
@ -469,7 +474,7 @@ function test_market()
|
||||||
end
|
end
|
||||||
reset_items()
|
reset_items()
|
||||||
b.size = 1
|
b.size = 1
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
|
|
||||||
assert_equal(0, u1:get_item("h0"))
|
assert_equal(0, u1:get_item("h0"))
|
||||||
b.size = 10
|
b.size = 10
|
||||||
|
@ -477,38 +482,38 @@ function test_market()
|
||||||
|
|
||||||
reset_items()
|
reset_items()
|
||||||
r:set_resource("peasant", 2100)
|
r:set_resource("peasant", 2100)
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
|
|
||||||
assert_equal(5, u1:get_item("h0"))
|
assert_equal(5, u1:get_item("h0"))
|
||||||
assert_equal(3, u1:get_item("balm"))
|
assert_equal(3, u1:get_item("balm"))
|
||||||
|
|
||||||
reset_items()
|
reset_items()
|
||||||
r:set_resource("peasant", 1049)
|
r:set_resource("peasant", 1049)
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
assert_equal(2, u1:get_item("h0"))
|
assert_equal(2, u1:get_item("h0"))
|
||||||
assert_equal(1, u1:get_item("balm"))
|
assert_equal(1, u1:get_item("balm"))
|
||||||
|
|
||||||
reset_items()
|
reset_items()
|
||||||
r:set_resource("peasant", 550)
|
r:set_resource("peasant", 550)
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
assert_equal(2, u1:get_item("h0"))
|
assert_equal(2, u1:get_item("h0"))
|
||||||
assert_equal(1, u1:get_item("balm"))
|
assert_equal(1, u1:get_item("balm"))
|
||||||
|
|
||||||
reset_items()
|
reset_items()
|
||||||
r:set_resource("peasant", 549)
|
r:set_resource("peasant", 549)
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
assert_equal(1, u1:get_item("h0"))
|
assert_equal(1, u1:get_item("h0"))
|
||||||
assert_equal(1, u1:get_item("balm"))
|
assert_equal(1, u1:get_item("balm"))
|
||||||
|
|
||||||
reset_items()
|
reset_items()
|
||||||
r:set_resource("peasant", 50)
|
r:set_resource("peasant", 50)
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
assert_equal(1, u1:get_item("h0"))
|
assert_equal(1, u1:get_item("h0"))
|
||||||
assert_equal(1, u1:get_item("balm"))
|
assert_equal(1, u1:get_item("balm"))
|
||||||
|
|
||||||
reset_items()
|
reset_items()
|
||||||
r:set_resource("peasant", 49)
|
r:set_resource("peasant", 49)
|
||||||
eressea.process.markets()
|
process_markets()
|
||||||
assert_equal(0, u1:get_item("h0"))
|
assert_equal(0, u1:get_item("h0"))
|
||||||
r:set_resource("peasant", 1050)
|
r:set_resource("peasant", 1050)
|
||||||
|
|
||||||
|
|
|
@ -1543,21 +1543,21 @@ int write_reports(faction * f, time_t ltime)
|
||||||
log_debug("Reports for %s:", factionname(f));
|
log_debug("Reports for %s:", factionname(f));
|
||||||
for (rtype = report_types; rtype != NULL; rtype = rtype->next) {
|
for (rtype = report_types; rtype != NULL; rtype = rtype->next) {
|
||||||
if (f->options & rtype->flag) {
|
if (f->options & rtype->flag) {
|
||||||
int error;
|
int error = 0;
|
||||||
do {
|
do {
|
||||||
char filename[32];
|
char filename[32];
|
||||||
char path[MAX_PATH];
|
char path[MAX_PATH];
|
||||||
sprintf(filename, "%d-%s.%s", turn, factionid(f),
|
sprintf(filename, "%d-%s.%s", turn, factionid(f),
|
||||||
rtype->extension);
|
rtype->extension);
|
||||||
join_path(reportpath(), filename, path, sizeof(path));
|
join_path(reportpath(), filename, path, sizeof(path));
|
||||||
error = 0;
|
errno = 0;
|
||||||
if (rtype->write(path, &ctx, encoding) == 0) {
|
if (rtype->write(path, &ctx, encoding) == 0) {
|
||||||
gotit = true;
|
gotit = true;
|
||||||
}
|
}
|
||||||
if (errno) {
|
if (errno) {
|
||||||
char zText[64];
|
char zText[64];
|
||||||
log_warning("retrying, error %d during %s report for faction %s", error, rtype->extension, factionname(f));
|
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 / 1000);
|
sprintf(zText, "waiting %u seconds before we retry", backup);
|
||||||
perror(zText);
|
perror(zText);
|
||||||
_sleep(backup);
|
_sleep(backup);
|
||||||
if (backup < maxbackup) {
|
if (backup < maxbackup) {
|
||||||
|
|
Loading…
Reference in New Issue