forked from github/server
small fixes (morale < 0)
This commit is contained in:
parent
79c4ea0efe
commit
090c6665f0
|
@ -646,7 +646,8 @@ give_control(unit * u, unit * u2)
|
|||
int morale = region_get_morale(r);
|
||||
region_set_owner(r, u2->faction, turn);
|
||||
if (morale>0) {
|
||||
region_set_morale(r, morale-MORALE_TRANSFER, turn);
|
||||
morale = MAX(0, morale-MORALE_TRANSFER);
|
||||
region_set_morale(r, morale, turn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1532,7 +1532,11 @@ region_getname(const region * r) {
|
|||
|
||||
int region_get_morale(const region * r)
|
||||
{
|
||||
return r->land?r->land->morale:-1;
|
||||
if (r->land) {
|
||||
assert(r->land->morale>=0 && r->land->morale<=MORALE_MAX);
|
||||
return r->land->morale;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void region_set_morale(region * r, int morale, int turn)
|
||||
|
@ -1542,6 +1546,7 @@ void region_set_morale(region * r, int morale, int turn)
|
|||
if (turn>=0 && r->land->ownership) {
|
||||
r->land->ownership->morale_turn = turn;
|
||||
}
|
||||
assert(r->land->morale>=0 && r->land->morale<=MORALE_MAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1062,6 +1062,7 @@ readregion(struct storage * store, int x, int y)
|
|||
}
|
||||
if (store->version>=REGIONOWNER_VERSION) {
|
||||
r->land->morale = (short)store->r_int(store);
|
||||
if (r->land->morale<0) r->land->morale = 0;
|
||||
read_owner(store, &r->land->ownership);
|
||||
if (r->land->ownership && r->land->ownership->owner) {
|
||||
faction * owner = r->land->ownership->owner;
|
||||
|
|
|
@ -7,7 +7,7 @@ function mark_multi(f)
|
|||
if u.building~=nil then
|
||||
local found = False
|
||||
for u2 in u.region.units do
|
||||
if u2.faction~=u.faction then
|
||||
if u2.faction.id~=u.faction.id then
|
||||
found = true
|
||||
break
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ local locales = { "de", "en" }
|
|||
local confirmed_multis = {
|
||||
}
|
||||
local suspected_multis = {
|
||||
"odin"
|
||||
}
|
||||
|
||||
function num_oceans(r)
|
||||
|
@ -72,10 +73,11 @@ function kill_multis(multis)
|
|||
end
|
||||
|
||||
function mark_multis(multis)
|
||||
if multi~=nil and multis~=nil then
|
||||
if multis~=nil then
|
||||
for idx, fno in ipairs(multis) do
|
||||
local f = get_faction(fno)
|
||||
if f~=nil and f.email~="doppelspieler@eressea.de" then
|
||||
print("* multi-player " .. tostring(f))
|
||||
mark_multi(f)
|
||||
end
|
||||
end
|
||||
|
@ -147,7 +149,7 @@ end
|
|||
|
||||
function process(orders)
|
||||
-- initialize starting equipment for new players
|
||||
|
||||
print(orders)
|
||||
if open_game(get_turn())~=0 then
|
||||
print("could not read game")
|
||||
return -1
|
||||
|
@ -156,6 +158,8 @@ function process(orders)
|
|||
|
||||
-- kill multi-players (external script)
|
||||
-- loadscript("eressea/multis.lua")
|
||||
kill_multis(confirmed_multis)
|
||||
mark_multis(suspected_multis)
|
||||
|
||||
-- run the turn:
|
||||
if read_orders(orders) ~= 0 then
|
||||
|
@ -163,7 +167,6 @@ function process(orders)
|
|||
return -1
|
||||
end
|
||||
|
||||
kill_multis(confirmed_multis)
|
||||
-- plan_monsters()
|
||||
local mon = get_faction(666)
|
||||
if mon ~= nil then
|
||||
|
@ -192,7 +195,6 @@ function process(orders)
|
|||
-- spawn_ents()
|
||||
|
||||
kill_nonstarters()
|
||||
mark_multis(suspected_multis)
|
||||
-- post-turn updates:
|
||||
update_guards()
|
||||
update_scores()
|
||||
|
|
Loading…
Reference in New Issue