forked from github/server
add message if implicit leave of building owner fails (see bug #1870)
This commit is contained in:
parent
f286c51862
commit
69a51c4b2c
|
@ -955,6 +955,7 @@ function setup()
|
||||||
eressea.write_game("free.dat")
|
eressea.write_game("free.dat")
|
||||||
eressea.settings.set("rules.economy.food", "4") -- FOOD_IS_FREE
|
eressea.settings.set("rules.economy.food", "4") -- FOOD_IS_FREE
|
||||||
eressea.settings.set("rules.encounters", "0")
|
eressea.settings.set("rules.encounters", "0")
|
||||||
|
eressea.settings.set("rules.move.owner_leave", "0")
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_parser()
|
function test_parser()
|
||||||
|
@ -1257,3 +1258,44 @@ function test_bug_1879_follow_unit()
|
||||||
assert_equal(u2.region.id, r1.id)
|
assert_equal(u2.region.id, r1.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function test_bug_1870_leave_enter_e2()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
local u1, u2 = two_units(r, f, f)
|
||||||
|
local mine = building.create(r, "mine")
|
||||||
|
mine.size = 10
|
||||||
|
u1.building = mine
|
||||||
|
|
||||||
|
local b = building.create(r, "castle")
|
||||||
|
b.size = 10
|
||||||
|
u2.building = b
|
||||||
|
|
||||||
|
u1:clear_orders()
|
||||||
|
u1:add_order("LERNEN Burgenbau ")
|
||||||
|
u1:add_order("BETRETEN BURG " .. itoa36(b.id))
|
||||||
|
|
||||||
|
eressea.settings.set("rules.move.owner_leave", "0")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(u1.building.id, b.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
function test_bug_1870_leave_enter_e3()
|
||||||
|
local r = region.create(0, 0, "plain")
|
||||||
|
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||||
|
local u1, u2 = two_units(r, f, f)
|
||||||
|
local mine = building.create(r, "mine")
|
||||||
|
mine.size = 10
|
||||||
|
u1.building = mine
|
||||||
|
|
||||||
|
local b = building.create(r, "castle")
|
||||||
|
b.size = 10
|
||||||
|
u2.building = b
|
||||||
|
|
||||||
|
u1:clear_orders()
|
||||||
|
u1:add_order("LERNEN Burgenbau ")
|
||||||
|
u1:add_order("BETRETEN BURG " .. itoa36(b.id))
|
||||||
|
|
||||||
|
eressea.settings.set("rules.move.owner_leave", "1")
|
||||||
|
process_orders()
|
||||||
|
assert_equal(u1.building.id, mine.id)
|
||||||
|
end
|
||||||
|
|
|
@ -1261,9 +1261,11 @@ int enter_ship(unit * u, struct order *ord, int id, int report)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (leave(u, 0)) {
|
if (leave(u, false)) {
|
||||||
u_set_ship(u, sh);
|
u_set_ship(u, sh);
|
||||||
fset(u, UFL_ENTER);
|
fset(u, UFL_ENTER);
|
||||||
|
} else if (report) {
|
||||||
|
cmistake(u, ord, 150, MSG_MOVE);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1310,6 +1312,8 @@ int enter_building(unit * u, order * ord, int id, int report)
|
||||||
fset(u, UFL_ENTER);
|
fset(u, UFL_ENTER);
|
||||||
u_set_building(u, b);
|
u_set_building(u, b);
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (report) {
|
||||||
|
cmistake(u, ord, 150, MSG_MOVE);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -822,14 +822,18 @@ void leave_building(unit * u)
|
||||||
|
|
||||||
bool can_leave(unit * u)
|
bool can_leave(unit * u)
|
||||||
{
|
{
|
||||||
|
static int gamecookie = -1;
|
||||||
static int rule_leave = -1;
|
static int rule_leave = -1;
|
||||||
|
|
||||||
if (!u->building) {
|
if (!u->building) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (rule_leave < 0) {
|
|
||||||
|
if (rule_leave < 0 || gamecookie != global.cookie) {
|
||||||
|
gamecookie = global.cookie;
|
||||||
rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
|
rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rule_leave && u->building && u == building_owner(u->building)) {
|
if (rule_leave && u->building && u == building_owner(u->building)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue