reading and writing the NPC flag was broken, because flags were a fully loaded unsigned int. making it an int instead, and adding a test.

fixing a bad test in which shadowmasters were deserting to faction null (causing a crash).
This commit is contained in:
Enno Rehling 2014-05-05 19:11:40 -07:00
parent ce347a95c9
commit 86bc4e7aef
5 changed files with 81 additions and 63 deletions

View File

@ -30,8 +30,8 @@ local function two_units(r, f1, f2)
end end
local function two_factions() local function two_factions()
local f1 = faction.create("noreply@eressea.de", "human", "de") local f1 = faction.create("one@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "elf", "de") local f2 = faction.create("two@eressea.de", "elf", "de")
return f1, f2 return f1, f2
end end
@ -47,11 +47,26 @@ function setup()
eressea.settings.set("rules.peasants.growth", "1") eressea.settings.set("rules.peasants.growth", "1")
end end
function test_flags()
local r = region.create(0, 0, "plain")
local f = faction.create("flags@eressea.de", "halfling", "de")
local u = unit.create(f, r, 1)
local no = itoa36(f.id)
local flags = 587203585
f.flags = flags
eressea.write_game("test.dat")
eressea.free_game()
eressea.read_game("test.dat")
f = get_faction(no)
assert_equal(flags, f.flags)
end
function test_elvenhorse_requires_riding_5() function test_elvenhorse_requires_riding_5()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
region.create(1, 0, "plain") region.create(1, 0, "plain")
local goal = region.create(2, 0, "plain") local goal = region.create(2, 0, "plain")
local f = faction.create("noreply@eressea.de", "halfling", "de") local f = faction.create("riding@eressea.de", "halfling", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("elvenhorse", 1) u:add_item("elvenhorse", 1)
u:set_skill("riding", 6)-- halfling has -1 modifier u:set_skill("riding", 6)-- halfling has -1 modifier
@ -65,7 +80,7 @@ function test_cannot_ride_elvenhorse_without_enough_skill()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local goal = region.create(1, 0, "plain") local goal = region.create(1, 0, "plain")
region.create(2, 0, "plain") region.create(2, 0, "plain")
local f = faction.create("noreply@eressea.de", "halfling", "de") local f = faction.create("elvenhorse@eressea.de", "halfling", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("elvenhorse", 1) u:add_item("elvenhorse", 1)
u:set_skill("riding", 5) -- halfling has -1 modifier u:set_skill("riding", 5) -- halfling has -1 modifier
@ -85,7 +100,7 @@ end
function test_demon_food() function test_demon_food()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "demon", "de") local f = faction.create("demonfood@eressea.de", "demon", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
local p = r:get_resource("peasant") local p = r:get_resource("peasant")
r:set_resource("peasant", 2000) r:set_resource("peasant", 2000)
@ -125,7 +140,7 @@ function test_plane()
local nx, ny = plane.normalize(pl, 4, 4) local nx, ny = plane.normalize(pl, 4, 4)
assert_equal(nx, -3, "normalization failed") assert_equal(nx, -3, "normalization failed")
assert_equal(ny, -3, "normalization failed") assert_equal(ny, -3, "normalization failed")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("plan@eressea.de", "human", "de")
f.id = atoi36("tpla") f.id = atoi36("tpla")
local r, x, y local r, x, y
for x = -3, 3 do for y = -3, 3 do for x = -3, 3 do for y = -3, 3 do
@ -144,7 +159,7 @@ end
function test_read_write() function test_read_write()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("readwrite@eressea.de", "human", "de")
local u = unit.create(f, r) local u = unit.create(f, r)
u.number = 2 u.number = 2
local fno = f.id local fno = f.id
@ -173,7 +188,7 @@ end
function test_descriptions() function test_descriptions()
local info = "Descriptions can be very long. Bug 1984 behauptet, dass es Probleme gibt mit Beschreibungen die laenger als 120 Zeichen sind. This description is longer than 120 characters." local info = "Descriptions can be very long. Bug 1984 behauptet, dass es Probleme gibt mit Beschreibungen die laenger als 120 Zeichen sind. This description is longer than 120 characters."
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("descriptions@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
local s = _test_create_ship(r) local s = _test_create_ship(r)
local b = building.create(r, "castle") local b = building.create(r, "castle")
@ -224,7 +239,7 @@ end
function test_faction() function test_faction()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("testfaction@eressea.de", "human", "de")
assert(f) assert(f)
f.info = "Spazz" f.info = "Spazz"
assert(f.info=="Spazz") assert(f.info=="Spazz")
@ -247,7 +262,7 @@ end
function test_unit() function test_unit()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("testunit@eressea.de", "human", "de")
local u = unit.create(f, r) local u = unit.create(f, r)
u.number = 20 u.number = 20
u.name = "Enno" u.name = "Enno"
@ -280,7 +295,7 @@ end
function test_building() function test_building()
local u local u
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("testbuilding@eressea.de", "human", "de")
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local b = building.create(r, "castle") local b = building.create(r, "castle")
u = unit.create(f, r) u = unit.create(f, r)
@ -306,7 +321,7 @@ end
function test_message() function test_message()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("testmessage@eressea.de", "human", "de")
local u = unit.create(f, r) local u = unit.create(f, r)
local msg = message.create("item_create_spell") local msg = message.create("item_create_spell")
msg:set_unit("mage", u) msg:set_unit("mage", u)
@ -319,7 +334,7 @@ function test_message()
end end
function test_hashtable() function test_hashtable()
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply1@eressea.de", "human", "de")
f.objects:set("enno", "smart guy") f.objects:set("enno", "smart guy")
f.objects:set("age", 10) f.objects:set("age", 10)
assert(f.objects:get("jesus") == nil) assert(f.objects:get("jesus") == nil)
@ -345,7 +360,7 @@ function test_events()
plain = region.create(0, 0, "plain") plain = region.create(0, 0, "plain")
skill = 8 skill = 8
f = faction.create("noreply@eressea.de", "elf", "de") f = faction.create("noreply2@eressea.de", "elf", "de")
f.age = 20 f.age = 20
u = unit.create(f, plain) u = unit.create(f, plain)
@ -355,7 +370,7 @@ function test_events()
u:add_order("NUMMER PARTEI test") u:add_order("NUMMER PARTEI test")
u:add_handler("message", msg_handler) u:add_handler("message", msg_handler)
msg = "BOTSCHAFT EINHEIT " .. itoa36(u.id) .. " Du~Elf~stinken" msg = "BOTSCHAFT EINHEIT " .. itoa36(u.id) .. " Du~Elf~stinken"
f = faction.create("noreply@eressea.de", "elf", "de") f = faction.create("noreply3@eressea.de", "elf", "de")
f.age = 20 f.age = 20
u = unit.create(f, plain) u = unit.create(f, plain)
@ -370,7 +385,7 @@ end
function test_recruit2() function test_recruit2()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply4@eressea.de", "human", "de")
local u = unit.create(f, r) local u = unit.create(f, r)
u.number = 1 u.number = 1
u:add_item("money", 2000) u:add_item("money", 2000)
@ -385,7 +400,7 @@ end
function test_guard() function test_guard()
region.create(1, 0, "plain") region.create(1, 0, "plain")
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de") local f1 = faction.create("noreply5@eressea.de", "human", "de")
f1.age = 20 f1.age = 20
local u1 = unit.create(f1, r, 10) local u1 = unit.create(f1, r, 10)
u1:add_item("sword", 10) u1:add_item("sword", 10)
@ -395,7 +410,7 @@ function test_guard()
u1:add_order("NACH O") u1:add_order("NACH O")
u1.name="Kalle Pimp" u1.name="Kalle Pimp"
local f2 = faction.create("noreply@eressea.de", "human", "de") local f2 = faction.create("noreply6@eressea.de", "human", "de")
f2.age = 20 f2.age = 20
local u2 = unit.create(f2, r, 1) local u2 = unit.create(f2, r, 1)
local u3 = unit.create(f2, r, 1) local u3 = unit.create(f2, r, 1)
@ -413,7 +428,7 @@ end
function test_recruit() function test_recruit()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply7@eressea.de", "human", "de")
local u = unit.create(f, r) local u = unit.create(f, r)
u.number = 1 u.number = 1
local n = 3 local n = 3
@ -430,7 +445,7 @@ end
function test_produce() function test_produce()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply8@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:clear_orders() u:clear_orders()
local sword = config.get_resource('sword') local sword = config.get_resource('sword')
@ -445,7 +460,7 @@ end
function test_work() function test_work()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply9@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("money", u.number * 10) -- humans cost 10 u:add_item("money", u.number * 10) -- humans cost 10
u:set_skill("herbalism", 5) u:set_skill("herbalism", 5)
@ -458,7 +473,7 @@ end
function test_upkeep() function test_upkeep()
eressea.settings.set("rules.economy.food", "0") eressea.settings.set("rules.economy.food", "0")
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply10@eressea.de", "human", "de")
local u = unit.create(f, r, 5) local u = unit.create(f, r, 5)
u:add_item("money", u.number * 11) u:add_item("money", u.number * 11)
u:clear_orders() u:clear_orders()
@ -470,7 +485,7 @@ end
function test_id() function test_id()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply11@eressea.de", "human", "de")
f.id = atoi36("42") f.id = atoi36("42")
assert(get_faction(42)~=f) assert(get_faction(42)~=f)
assert(get_faction("42")==f) assert(get_faction("42")==f)
@ -498,7 +513,7 @@ end
function test_herbalism() function test_herbalism()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply12@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("money", u.number * 100) u:add_item("money", u.number * 100)
u:set_skill("herbalism", 5) u:set_skill("herbalism", 5)
@ -517,7 +532,7 @@ function test_mallorn()
m:set_resource("tree", 100) m:set_resource("tree", 100)
assert(m:get_resource("tree")==100) assert(m:get_resource("tree")==100)
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply13@eressea.de", "human", "de")
local u1 = unit.create(f, r, 1) local u1 = unit.create(f, r, 1)
u1:add_item("money", u1.number * 100) u1:add_item("money", u1.number * 100)
@ -554,7 +569,7 @@ function test_coordinate_translation()
local pl = plane.create(1, 500, 500, 1001, 1001) -- astralraum local pl = plane.create(1, 500, 500, 1001, 1001) -- astralraum
local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath local pe = plane.create(1, -8761, 3620, 23, 23) -- eternath
local r = region.create(1000, 1000, "plain") local r = region.create(1000, 1000, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply14@eressea.de", "human", "de")
assert_not_equal(nil, r) assert_not_equal(nil, r)
assert_equal(r.x, 1000) assert_equal(r.x, 1000)
assert_equal(r.y, 1000) assert_equal(r.y, 1000)
@ -600,7 +615,7 @@ end
function test_store_unit() function test_store_unit()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply15@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
local fid = f.id local fid = f.id
u:add_item("money", u.number * 100) u:add_item("money", u.number * 100)
@ -612,7 +627,7 @@ function test_store_unit()
eressea.free_game() eressea.free_game()
-- recreate world: -- recreate world:
r = region.create(0, 0, "plain") r = region.create(0, 0, "plain")
f = faction.create("noreply@eressea.de", "human", "de") f = faction.create("noreply16@eressea.de", "human", "de")
f.id = fid f.id = fid
store = storage.create(filename, "rb") store = storage.create(filename, "rb")
assert_not_nil(store) assert_not_nil(store)
@ -624,8 +639,8 @@ end
function test_building_other() function test_building_other()
local r = region.create(0,0, "plain") local r = region.create(0,0, "plain")
local f1 = faction.create("noreply@eressea.de", "human", "de") local f1 = faction.create("noreply17@eressea.de", "human", "de")
local f2 = faction.create("noreply@eressea.de", "human", "de") local f2 = faction.create("noreply18@eressea.de", "human", "de")
local b = building.create(r, "castle") local b = building.create(r, "castle")
b.size = 10 b.size = 10
local u1 = unit.create(f1, r, 3) local u1 = unit.create(f1, r, 3)
@ -650,7 +665,7 @@ end
local function _test_create_laen() local function _test_create_laen()
eressea.settings.set("rules.terraform.all", "1") eressea.settings.set("rules.terraform.all", "1")
local r = region.create(0,0, "mountain") local r = region.create(0,0, "mountain")
local f1 = faction.create("noreply@eressea.de", "human", "de") local f1 = faction.create("noreply19@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1) local u1 = unit.create(f1, r, 1)
r:set_resource("laen", 50) r:set_resource("laen", 50)
return r, u1 return r, u1
@ -691,7 +706,7 @@ end
function test_mine() function test_mine()
local r = region.create(0,0, "mountain") local r = region.create(0,0, "mountain")
local f1 = faction.create("noreply@eressea.de", "human", "de") local f1 = faction.create("noreply20@eressea.de", "human", "de")
local u1 = unit.create(f1, r, 1) local u1 = unit.create(f1, r, 1)
u1:add_item("money", 1000) u1:add_item("money", 1000)
@ -712,9 +727,9 @@ end
function test_guard_resources() function test_guard_resources()
-- this is not quite http://bugs.eressea.de/view.php?id=1756 -- this is not quite http://bugs.eressea.de/view.php?id=1756
local r = region.create(0,0, "mountain") local r = region.create(0,0, "mountain")
local f1 = faction.create("noreply@eressea.de", "human", "de") local f1 = faction.create("noreply21@eressea.de", "human", "de")
f1.age=20 f1.age=20
local f2 = faction.create("noreply@eressea.de", "human", "de") local f2 = faction.create("noreply22@eressea.de", "human", "de")
f2.age=20 f2.age=20
local u1 = unit.create(f1, r, 1) local u1 = unit.create(f1, r, 1)
u1:add_item("money", 100) u1:add_item("money", 100)
@ -742,7 +757,7 @@ end
function test_hero_hero_transfer() function test_hero_hero_transfer()
local r = region.create(0,0, "mountain") local r = region.create(0,0, "mountain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply23@eressea.de", "human", "de")
f.age=20 f.age=20
local UFL_HERO = 128 local UFL_HERO = 128
@ -763,7 +778,7 @@ end
function test_hero_normal_transfer() function test_hero_normal_transfer()
local r = region.create(0,0, "mountain") local r = region.create(0,0, "mountain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply24@eressea.de", "human", "de")
f.age=20 f.age=20
local UFL_HERO = 128 local UFL_HERO = 128
@ -782,7 +797,7 @@ end
function test_expensive_skills_cost_money() function test_expensive_skills_cost_money()
local r = region.create(0,0, "mountain") local r = region.create(0,0, "mountain")
local f = faction.create("noreply@eressea.de", "elf", "de") local f = faction.create("noreply25@eressea.de", "elf", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("money", 10000) u:add_item("money", 10000)
u:clear_orders() u:clear_orders()
@ -794,7 +809,7 @@ end
function test_food_is_consumed() function test_food_is_consumed()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply26@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("money", 100) u:add_item("money", 100)
u:clear_orders() u:clear_orders()
@ -806,7 +821,7 @@ end
function test_food_can_override() function test_food_can_override()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply27@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("money", 100) u:add_item("money", 100)
u:clear_orders() u:clear_orders()
@ -818,7 +833,7 @@ end
function test_swim_and_survive() function test_swim_and_survive()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply28@eressea.de", "human", "de")
f.nam = "chaos" f.nam = "chaos"
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
process_orders() process_orders()
@ -832,7 +847,7 @@ end
function test_swim_and_die() function test_swim_and_die()
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply29@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
local uid = u.id local uid = u.id
process_orders() process_orders()
@ -847,7 +862,7 @@ function test_ride_with_horse()
region.create(1, 0, "plain") region.create(1, 0, "plain")
region.create(2, 0, "plain") region.create(2, 0, "plain")
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply30@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
u:add_item("horse", 1) u:add_item("horse", 1)
local horse_cfg = config.get_resource("horse") local horse_cfg = config.get_resource("horse")
@ -870,7 +885,7 @@ function test_ride_with_horses_and_cart()
region.create(1, 0, "plain") region.create(1, 0, "plain")
region.create(2, 0, "plain") region.create(2, 0, "plain")
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply31@eressea.de", "human", "de")
local u = unit.create(f, r, 1) local u = unit.create(f, r, 1)
local horse_cfg = config.get_resource("horse") local horse_cfg = config.get_resource("horse")
local cart_cfg = config.get_resource("cart") local cart_cfg = config.get_resource("cart")
@ -923,7 +938,7 @@ function test_walk_and_carry_the_cart()
region.create(1, 0, "plain") region.create(1, 0, "plain")
local r = region.create(2, 0, "plain") local r = region.create(2, 0, "plain")
local r = region.create(0, 0, "plain") local r = region.create(0, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de") local f = faction.create("noreply32@eressea.de", "human", "de")
local u = unit.create(f, r, 10) local u = unit.create(f, r, 10)
u:add_item("cart", 1) u:add_item("cart", 1)

View File

@ -1218,7 +1218,6 @@ int eressea_run(lua_State *L, const char *luafile)
err = lua_pcall(L, 1, 1, -3); err = lua_pcall(L, 1, 1, -3);
if (err != 0) { if (err != 0) {
log_lua_error(L); log_lua_error(L);
abort();
} else { } else {
if (lua_isnumber(L, -1)) { if (lua_isnumber(L, -1)) {
err = (int)lua_tonumber(L, -1); err = (int)lua_tonumber(L, -1);

View File

@ -44,12 +44,12 @@ extern "C" {
* (FFL_SELECT muss man vorher initialisieren, * (FFL_SELECT muss man vorher initialisieren,
* FL_MARK hinterher löschen) */ * FL_MARK hinterher löschen) */
#define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */ #define FFL_NOIDLEOUT (1<<24) /* Partei stirbt nicht an NMRs */
#define FFL_NPC (1<<25) /* eine Partei mit Monstern */
#define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */ #define FFL_DBENTRY (1<<28) /* Partei ist in Datenbank eingetragen */
#define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */ #define FFL_NOTIMEOUT (1<<29) /* ignore MaxAge() */
#define FFL_GM (1<<30) /* eine Partei mit Sonderrechten */ #define FFL_GM (1<<30) /* eine Partei mit Sonderrechten */
#define FFL_NPC (1<<31) /* eine Partei mit Monstern */
#define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_GM|FFL_NPC|FFL_NOTIMEOUT|FFL_DBENTRY|FFL_NOTIMEOUT) #define FFL_SAVEMASK (FFL_DEFENDER|FFL_NEWID|FFL_GM|FFL_NPC|FFL_NOTIMEOUT|FFL_DBENTRY|FFL_NOIDLEOUT)
struct faction *get_monsters(void); struct faction *get_monsters(void);
#define is_monsters(f) ((f)->flags&FFL_NPC) #define is_monsters(f) ((f)->flags&FFL_NPC)
@ -65,7 +65,7 @@ extern "C" {
#endif #endif
int no; int no;
int subscription; int subscription;
unsigned int flags; int flags;
char *name; char *name;
char *banner; char *banner;
char *email; char *email;

View File

@ -1266,8 +1266,9 @@ faction *readfaction(struct gamedata * data)
READ_INT(data->store, &n); READ_INT(data->store, &n);
} }
READ_UINT(data->store, &f->flags); READ_INT(data->store, &f->flags);
if (f->no == 0) { assert((f->flags&FFL_SAVEMASK) == f->flags);
if (f->no==0 || f->no==666) {
f->flags |= FFL_NPC; f->flags |= FFL_NPC;
} }

View File

@ -1209,6 +1209,7 @@ static void rotting_herbs(void)
void randomevents(void) void randomevents(void)
{ {
region *r; region *r;
faction *monsters = get_monsters();
icebergs(); icebergs();
godcurse(); godcurse();
@ -1290,21 +1291,23 @@ void randomevents(void)
} }
/* monster-einheiten desertieren */ /* monster-einheiten desertieren */
for (r = regions; r; r = r->next) { if (monsters) {
unit *u; for (r = regions; r; r = r->next) {
unit *u;
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
if (u->faction && !is_monsters(u->faction) if (u->faction && !is_monsters(u->faction)
&& (u_race(u)->flags & RCF_DESERT)) { && (u_race(u)->flags & RCF_DESERT)) {
if (fval(u, UFL_ISNEW)) if (fval(u, UFL_ISNEW))
continue; continue;
if (rng_int() % 100 < 5) { if (rng_int() % 100 < 5) {
ADDMSG(&u->faction->msgs, msg_message("desertion", ADDMSG(&u->faction->msgs, msg_message("desertion",
"unit region", u, r)); "unit region", u, r));
u_setfaction(u, get_monsters()); u_setfaction(u, monsters);
} }
}
}
} }
}
} }
/* Chaos */ /* Chaos */