Merge branch 'master' of github.com:ennorehling/eressea

This commit is contained in:
Enno Rehling 2020-01-26 09:12:47 +01:00
commit 9e41f6b0ba
6 changed files with 65 additions and 27 deletions

View File

@ -5519,7 +5519,7 @@ msgstr "aquarians"
msgctxt "iteminfo" msgctxt "iteminfo"
msgid "fairyboot" msgid "fairyboot"
msgstr "These leather boots are embroidere with unicorn hair and allow their wearer to walk at twice his normal speed." msgstr "These leather boots are embroidered with unicorn hair and allow their wearer to walk at twice his normal speed."
msgctxt "spell" msgctxt "spell"
msgid "skillmod" msgid "skillmod"

View File

@ -29,6 +29,25 @@ function test_castle_names()
assert_equal("citadel", b:get_typename(6250)) assert_equal("citadel", b:get_typename(6250))
end end
function test_build_tunnel_limited()
-- bug 2221
local r = region.create(0, 0, "plain")
local b = building.create(r, "tunnel")
local f = faction.create('human')
local u = unit.create(f, r, 2)
u:set_skill('building', 6, true)
u:add_item('stone', 22)
u:add_item('log', 10)
u:add_item('iron', 2)
u:add_item('money', 700)
u.building = b
u.name = 'Xolgrim'
u:add_order('MACHE 2 BURG ' .. itoa36(b.id))
b.size = 99
process_orders()
assert_equal(100, b.size)
end
function test_build_castle_one_stage() function test_build_castle_one_stage()
local r = region.create(0, 0, 'plain') local r = region.create(0, 0, 'plain')
local f = faction.create('human') local f = faction.create('human')

View File

@ -1,3 +1,6 @@
require 'tests.e2.buildings'
require 'tests.e2.allies'
require 'tests.e2.quit'
require 'tests.e2.movement' require 'tests.e2.movement'
require 'tests.e2.carts' require 'tests.e2.carts'
require 'tests.e2.quit' require 'tests.e2.quit'
@ -5,7 +8,6 @@ require 'tests.e2.astral'
require 'tests.e2.spells' require 'tests.e2.spells'
require 'tests.e2.e2features' require 'tests.e2.e2features'
require 'tests.e2.insects' require 'tests.e2.insects'
require 'tests.e2.buildings'
require 'tests.e2.production' require 'tests.e2.production'
require 'tests.e2.adamantium' require 'tests.e2.adamantium'
require 'tests.e2.undead' require 'tests.e2.undead'

View File

@ -1495,7 +1495,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
bool unlimited = true; bool unlimited = true;
const item_type *itype; const item_type *itype;
const luxury_type *ltype; const luxury_type *ltype;
int n, i; int n, k;
region *r = u->region; region *r = u->region;
const char *s; const char *s;
keyword_t kwd; keyword_t kwd;
@ -1546,8 +1546,9 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
} }
/* Ein Haendler kann nur 10 Gueter pro Talentpunkt verkaufen. */ /* Ein Haendler kann nur 10 Gueter pro Talentpunkt verkaufen. */
i = u->number * 10 * effskill(u, SK_TRADE, NULL); /* Ein Haendler kann nur 10 Gueter pro Talentpunkt handeln. */
if (n > i) n = i; k = u->number * 10 * effskill(u, SK_TRADE, NULL);
if (n > k) n = k;
if (!n) { if (!n) {
cmistake(u, ord, 54, MSG_COMMERCE); cmistake(u, ord, 54, MSG_COMMERCE);
@ -1563,7 +1564,7 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
else { else {
attrib *a; attrib *a;
econ_request *o; econ_request *o;
int k, available; int available;
if (!r->land || !r_demand(r, ltype)) { if (!r->land || !r_demand(r, ltype)) {
cmistake(u, ord, 263, MSG_COMMERCE); cmistake(u, ord, 263, MSG_COMMERCE);
@ -1594,9 +1595,6 @@ static bool sell(unit * u, econ_request ** sellorders, struct order *ord)
* produktion, wo fuer jedes produkt einzeln eine obere limite * produktion, wo fuer jedes produkt einzeln eine obere limite
* existiert, so dass man arrays von orders machen kann. */ * existiert, so dass man arrays von orders machen kann. */
/* Ein Haendler kann nur 10 Gueter pro Talentpunkt handeln. */
k = u->number * 10 * effskill(u, SK_TRADE, NULL);
/* hat der Haendler bereits gehandelt, muss die Menge der bereits /* hat der Haendler bereits gehandelt, muss die Menge der bereits
* verkauften/gekauften Gueter abgezogen werden */ * verkauften/gekauften Gueter abgezogen werden */
a = a_find(u->attribs, &at_trades); a = a_find(u->attribs, &at_trades);

View File

@ -209,7 +209,7 @@ static void setup_terrains(CuTest *tc) {
static region *setup_trade_region(CuTest *tc, const struct terrain_type *terrain) { static region *setup_trade_region(CuTest *tc, const struct terrain_type *terrain) {
region *r; region *r;
item_type *it_luxury; item_type *it_luxury;
struct locale * lang = default_locale; struct locale * lang = test_create_locale();
new_luxurytype(it_luxury = test_create_itemtype("balm"), 5); new_luxurytype(it_luxury = test_create_itemtype("balm"), 5);
locale_setstring(lang, it_luxury->rtype->_name, it_luxury->rtype->_name); locale_setstring(lang, it_luxury->rtype->_name, it_luxury->rtype->_name);
@ -233,6 +233,36 @@ static unit *setup_trade_unit(CuTest *tc, region *r, const struct race *rc) {
return u; return u;
} }
static void test_trade_limits(CuTest *tc) {
region *r;
unit *u;
building *b;
const item_type *it_jewel, *it_balm;
test_setup();
setup_production();
setup_terrains(tc);
init_terrains();
r = setup_trade_region(tc, NULL);
b = test_create_building(r, test_create_buildingtype("castle"));
b->size = 2;
rsetpeasants(r, TRADE_FRACTION * 20);
it_jewel = it_find("jewel");
u = test_create_unit(test_create_faction(NULL), r);
set_level(u, SK_TRADE, 1);
i_change(&u->items, it_find("money"), 500);
unit_addorder(u, create_order(K_BUY, u->faction->locale, "5 %s",
LOC(u->faction->locale, resourcename(it_jewel->rtype, 0))));
it_balm = it_find("balm");
i_change(&u->items, it_balm, 10);
unit_addorder(u, create_order(K_SELL, u->faction->locale, "10 %s",
LOC(u->faction->locale, resourcename(it_balm->rtype, 0))));
produce(r);
CuAssertIntEquals(tc, 5, i_get(u->items, it_jewel));
CuAssertIntEquals(tc, 5, i_get(u->items, it_balm));
test_teardown();
}
static void test_trade_needs_castle(CuTest *tc) { static void test_trade_needs_castle(CuTest *tc) {
/* Handeln ist nur in Regionen mit Burgen möglich. */ /* Handeln ist nur in Regionen mit Burgen möglich. */
race *rc; race *rc;
@ -837,6 +867,7 @@ CuSuite *get_economy_suite(void)
SUITE_ADD_TEST(suite, test_heroes_dont_recruit); SUITE_ADD_TEST(suite, test_heroes_dont_recruit);
SUITE_ADD_TEST(suite, test_tax_cmd); SUITE_ADD_TEST(suite, test_tax_cmd);
SUITE_ADD_TEST(suite, test_buy_cmd); SUITE_ADD_TEST(suite, test_buy_cmd);
SUITE_ADD_TEST(suite, test_trade_limits);
SUITE_ADD_TEST(suite, test_trade_needs_castle); SUITE_ADD_TEST(suite, test_trade_needs_castle);
SUITE_ADD_TEST(suite, test_trade_insect); SUITE_ADD_TEST(suite, test_trade_insect);
SUITE_ADD_TEST(suite, test_maintain_buildings); SUITE_ADD_TEST(suite, test_maintain_buildings);

View File

@ -810,25 +810,13 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
} }
built = b->size; built = b->size;
} }
if (n <= 0 || n == INT_MAX) {
if (b == NULL) { if (btype->maxsize > 0) {
if (btype->maxsize > 0) { int remain = btype->maxsize - built;
n = btype->maxsize - built; if (remain < n) {
} n = remain;
else {
n = INT_MAX;
}
}
else {
if (b->type->maxsize > 0) {
n = b->type->maxsize - built;
}
else {
n = INT_MAX;
}
} }
} }
built = build_stages(u, btype, built, n, basesk, &skills); built = build_stages(u, btype, built, n, basesk, &skills);
if (built < 0) { if (built < 0) {