forked from github/server
Merge branch 'master' of github.com:eressea/core
This commit is contained in:
commit
f6b5728b49
129 changed files with 2368 additions and 2165 deletions
res/de
scripts/tests
src
CMakeLists.txt
attributes
bindings
CMakeLists.txtbind_building.cbind_faction.cbind_gmtool.cbind_hashtable.cbind_message.cbind_process.cbind_process.hbind_region.cbind_ship.cbind_sqlite.cbind_storage.cbind_unit.cbindings.chelpers.cprocess.pkg
gamecode
archetype.hcreport.ceconomy.ceconomy.hgive.claws.claws.hmonster.cmonster.hrandenc.creport.cspy.cstudy.cstudy.hsummary.csummary.hxmlreport.c
gmtool.cgmtool.hgmtool_structs.hitems
kernel
alliance.calliance.hally.cally.hally_test.cbattle.cbattle.hbattle_test.cbuild.cbuild.hbuilding.cconfig.cconfig.hconnection.cconnection.hcurse.ccurse.hfaction.cfaction.hgroup.cgroup.hitem.citem.hmagic.cmagic.hmove.cmove.hmove_test.corder.corder.hpathfinder.cpathfinder.hplane.cplane.hpool.cpool.hrace.crace.hregion.cregion.hreports.creports.hresources.csave.cship.cskill.cskill.hsqlite.cteleport.cteleport.htypes.hunit.c
|
@ -2200,9 +2200,6 @@
|
|||
<string name="LERNEN">
|
||||
<text locale="de">LERNEN</text>
|
||||
</string>
|
||||
<string name="LIEFERE">
|
||||
<text locale="de">LIEFERE</text>
|
||||
</string>
|
||||
<string name="MACHEN">
|
||||
<text locale="de">MACHEN</text>
|
||||
</string>
|
||||
|
@ -6980,6 +6977,81 @@
|
|||
<text locale="en">guards the region</text>
|
||||
</string>
|
||||
|
||||
<string name="unit_hungers">
|
||||
<text locale="de">hungert</text>
|
||||
<text locale="en">hungry</text>
|
||||
</string>
|
||||
|
||||
<string name="smod_far">
|
||||
<text locale="de">Fernzauber</text>
|
||||
<text locale="en">far</text>
|
||||
</string>
|
||||
|
||||
<string name="smod_sea">
|
||||
<text locale="de">Seezauber</text>
|
||||
<text locale="en">sea</text>
|
||||
</string>
|
||||
|
||||
<string name="smod_ship">
|
||||
<text locale="de">Schiffszauber</text>
|
||||
<text locale="en">ship</text>
|
||||
</string>
|
||||
|
||||
<string name="smod_nofamiliar">
|
||||
<text locale="de">Magier exklusiv</text>
|
||||
<text locale="en">magicians only</text>
|
||||
</string>
|
||||
|
||||
<string name="smod_none">
|
||||
<text locale="de">Keine</text>
|
||||
<text locale="en">none</text>
|
||||
</string>
|
||||
|
||||
<string name="faction_help_one">
|
||||
<text locale="de">Wir helfen der Partei</text>
|
||||
<text locale="en">We are helping the faction</text>
|
||||
</string>
|
||||
|
||||
<string name="faction_help_many">
|
||||
<text locale="de">Wir helfen den Parteien</text>
|
||||
<text locale="en">We are helping the factions</text>
|
||||
</string>
|
||||
|
||||
<string name="group_help_one">
|
||||
<text locale="de">hilft der Partei</text>
|
||||
<text locale="en">is helping the faction</text>
|
||||
</string>
|
||||
|
||||
<string name="group_help_many">
|
||||
<text locale="de">hilft den Parteien</text>
|
||||
<text locale="en">is helping the factions</text>
|
||||
</string>
|
||||
|
||||
<string name="has_moved_one">
|
||||
<text locale="de">hat die Region durchquert</text>
|
||||
<text locale="en">has traveled through the region</text>
|
||||
</string>
|
||||
|
||||
<string name="has_moved_many">
|
||||
<text locale="de">haben die Region durchquert</text>
|
||||
<text locale="en">have traveled through the region</text>
|
||||
</string>
|
||||
|
||||
<string name="see_travel">
|
||||
<text locale="de">durchgereist</text>
|
||||
<text locale="en">travel</text>
|
||||
</string>
|
||||
|
||||
<string name="see_neighbour">
|
||||
<text locale="de">benachbart</text>
|
||||
<text locale="en">neighbour</text>
|
||||
</string>
|
||||
|
||||
<string name="see_lighthouse">
|
||||
<text locale="de">vom Turm erblickt</text>
|
||||
<text locale="en">from lighthouse</text>
|
||||
</string>
|
||||
|
||||
<string name="list_and">
|
||||
<text locale="de"> und </text>
|
||||
<text locale="en"> and </text>
|
||||
|
|
|
@ -23,10 +23,36 @@ function test_process()
|
|||
assert_equal("function", _G.type(eressea.process.set_prefix))
|
||||
assert_equal("function", _G.type(eressea.process.set_stealth))
|
||||
assert_equal("function", _G.type(eressea.process.set_status))
|
||||
assert_equal("function", _G.type(eressea.process.set_description))
|
||||
assert_equal("function", _G.type(eressea.process.set_name))
|
||||
assert_equal("function", _G.type(eressea.process.set_group))
|
||||
assert_equal("function", _G.type(eressea.process.set_origin))
|
||||
assert_equal("function", _G.type(eressea.process.quit))
|
||||
assert_equal("function", _G.type(eressea.process.study))
|
||||
assert_equal("function", _G.type(eressea.process.movement))
|
||||
assert_equal("function", _G.type(eressea.process.use))
|
||||
assert_equal("function", _G.type(eressea.process.battle))
|
||||
assert_equal("function", _G.type(eressea.process.siege))
|
||||
assert_equal("function", _G.type(eressea.process.leave))
|
||||
assert_equal("function", _G.type(eressea.process.promote))
|
||||
assert_equal("function", _G.type(eressea.process.renumber))
|
||||
assert_equal("function", _G.type(eressea.process.restack))
|
||||
assert_equal("function", _G.type(eressea.process.set_spells))
|
||||
assert_equal("function", _G.type(eressea.process.set_help))
|
||||
assert_equal("function", _G.type(eressea.process.contact))
|
||||
assert_equal("function", _G.type(eressea.process.enter))
|
||||
assert_equal("function", _G.type(eressea.process.magic))
|
||||
assert_equal("function", _G.type(eressea.process.give_control))
|
||||
assert_equal("function", _G.type(eressea.process.regeneration))
|
||||
assert_equal("function", _G.type(eressea.process.guard_on))
|
||||
assert_equal("function", _G.type(eressea.process.guard_off))
|
||||
assert_equal("function", _G.type(eressea.process.explain))
|
||||
assert_equal("function", _G.type(eressea.process.messages))
|
||||
assert_equal("function", _G.type(eressea.process.reserve))
|
||||
assert_equal("function", _G.type(eressea.process.claim))
|
||||
assert_equal("function", _G.type(eressea.process.follow))
|
||||
assert_equal("function", _G.type(eressea.process.alliance))
|
||||
assert_equal("function", _G.type(eressea.process.idle))
|
||||
assert_equal("function", _G.type(eressea.process.set_default))
|
||||
end
|
||||
|
||||
function test_settings()
|
||||
|
|
|
@ -44,18 +44,7 @@ function setup()
|
|||
eressea.settings.set("nmr.timeout", "0")
|
||||
eressea.settings.set("NewbieImmunity", "0")
|
||||
eressea.settings.set("rules.economy.food", "4")
|
||||
end
|
||||
|
||||
function DISABLE_test_eventbus_fire()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u = unit.create(f, r)
|
||||
|
||||
function compare_f(u, event, f)
|
||||
assert_equal(u.faction, f)
|
||||
end
|
||||
eventbus.register(u, "weird", compare_f)
|
||||
eventbus.fire(u, "weird", f)
|
||||
eressea.settings.set("rules.encounters", "0")
|
||||
end
|
||||
|
||||
function test_fleeing_units_can_be_transported()
|
||||
|
@ -579,6 +568,73 @@ function test_config()
|
|||
assert_not_equal(nil, config.locales)
|
||||
end
|
||||
|
||||
local function _test_create_laen()
|
||||
local r = region.create(0,0, "mountain")
|
||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = unit.create(f1, r, 1)
|
||||
|
||||
-- TODO this is a stupid way to create a laen region
|
||||
for i = 1, 10000 do
|
||||
r = region.create(i,0, "mountain")
|
||||
if r:get_resource("laen") > 2 then
|
||||
break
|
||||
end
|
||||
end
|
||||
assert(r:get_resource("laen")>2, "could not run test properly, please try again")
|
||||
|
||||
return r, u1
|
||||
end
|
||||
|
||||
function test_laen1()
|
||||
local r, u1 = _test_create_laen()
|
||||
|
||||
u1:add_item("money", 1000)
|
||||
u1:set_skill("mining", 14)
|
||||
u1:clear_orders()
|
||||
u1:add_order("MACHEN Laen")
|
||||
|
||||
process_orders()
|
||||
assert_equal(0, u1:get_item("laen"))
|
||||
end
|
||||
|
||||
function test_laen2()
|
||||
local r, u1 = _test_create_laen()
|
||||
|
||||
u1:add_item("money", 1000)
|
||||
u1:set_skill("mining", 15)
|
||||
u1:clear_orders()
|
||||
u1:add_order("MACHEN Laen")
|
||||
|
||||
local b = building.create(r, "mine")
|
||||
b.size = 10
|
||||
u1.building = b
|
||||
local laen = r:get_resource("laen")
|
||||
|
||||
process_orders()
|
||||
assert_equal(2, u1:get_item("laen"))
|
||||
assert_equal(laen - 2, r:get_resource("laen"))
|
||||
end
|
||||
|
||||
function test_mine()
|
||||
local r = region.create(0,0, "mountain")
|
||||
local f1 = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = unit.create(f1, r, 1)
|
||||
|
||||
u1:add_item("money", 1000)
|
||||
u1:set_skill("mining", 1)
|
||||
u1:clear_orders()
|
||||
u1:add_order("MACHEN Eisen")
|
||||
|
||||
local b = building.create(r, "mine")
|
||||
b.size = 10
|
||||
u1.building = b
|
||||
local iron = r:get_resource("iron")
|
||||
|
||||
process_orders()
|
||||
assert_equal(2, u1:get_item("iron")) -- skill +1
|
||||
assert_equal(iron - 1, r:get_resource("iron")) -- only 1/2 is taken away
|
||||
end
|
||||
|
||||
function test_guard_resources()
|
||||
-- this is not quite http://bugs.eressea.de/view.php?id=1756
|
||||
local r = region.create(0,0, "mountain")
|
||||
|
@ -601,12 +657,13 @@ function test_guard_resources()
|
|||
|
||||
process_orders()
|
||||
local iron = u2:get_item("iron")
|
||||
assert_true(iron > 0)
|
||||
process_orders()
|
||||
assert_equal(iron, u2:get_item("iron"))
|
||||
end
|
||||
|
||||
local function is_flag_set(flags, flag)
|
||||
return math.mod(flags, flag*2) - math.mod(flags, flag) == flag;
|
||||
return math.fmod(flags, flag*2) - math.fmod(flags, flag) == flag;
|
||||
end
|
||||
|
||||
function test_hero_hero_transfer()
|
||||
|
@ -815,7 +872,7 @@ end
|
|||
local function find_in_report(f, pattern, extension)
|
||||
extension = extension or "nr"
|
||||
local filename = config.reportpath .. "/" .. get_turn() .. "-" .. itoa36(f.id) .. "." .. extension
|
||||
local report = io.open(filename, 'rt');
|
||||
local report = io.open(filename, 'r');
|
||||
assert_not_nil(report)
|
||||
t = report:read("*all")
|
||||
report:close()
|
||||
|
@ -897,6 +954,8 @@ function setup()
|
|||
eressea.free_game()
|
||||
eressea.write_game("free.dat")
|
||||
eressea.settings.set("rules.economy.food", "4") -- FOOD_IS_FREE
|
||||
eressea.settings.set("rules.encounters", "0")
|
||||
eressea.settings.set("rules.move.owner_leave", "0")
|
||||
end
|
||||
|
||||
function test_parser()
|
||||
|
@ -905,7 +964,7 @@ function test_parser()
|
|||
local u = unit.create(f, r, 1)
|
||||
local filename = config.basepath .. "/data/orders.txt"
|
||||
|
||||
local file = io.open(filename, "w+")
|
||||
local file = io.open(filename, "w")
|
||||
assert_not_nil(file)
|
||||
file:write('ERESSEA ' .. itoa36(f.id) .. ' "' .. f.password .. '"\n')
|
||||
file:write('EINHEIT ' .. itoa36(u.id) .. "\n")
|
||||
|
@ -968,7 +1027,7 @@ function test_bug_1814()
|
|||
local u = unit.create(f, r, 1)
|
||||
local filename = config.basepath .. "/data/1814.txt"
|
||||
|
||||
local file = io.open(filename, "w+")
|
||||
local file = io.open(filename, "w")
|
||||
file:write('ERESSEA ' .. itoa36(f.id) .. ' "' .. f.password .. '"\n')
|
||||
file:write('EINHEIT ' .. itoa36(u.id) .. "\n")
|
||||
file:write("; parse error follows: '\n")
|
||||
|
@ -989,11 +1048,11 @@ function test_bug_1679()
|
|||
local u = unit.create(f, r, 1)
|
||||
local filename = config.basepath .. "/data/1679.txt"
|
||||
|
||||
local file = io.open(filename, "w+")
|
||||
local file = io.open(filename, "w")
|
||||
file:write('ERESSEA ' .. itoa36(f.id) .. ' "' .. f.password .. '"\n')
|
||||
file:write('EINHEIT ' .. itoa36(u.id) .. "\n")
|
||||
file:write("NACH W\n")
|
||||
file:write("ARBEITEN\n")
|
||||
file:write("NACH W\n")
|
||||
file:close()
|
||||
|
||||
eressea.read_orders(filename)
|
||||
|
@ -1001,7 +1060,7 @@ function test_bug_1679()
|
|||
init_reports()
|
||||
write_report(f)
|
||||
assert_true(find_in_report(f, "Die Einheit kann keine weiteren langen Befehle", "cr"))
|
||||
assert_true(find_in_report(f, "entdeckt, dass es keinen Weg nach Westen gibt"))
|
||||
assert_false(find_in_report(f, "entdeckt, dass es keinen Weg nach Westen gibt"))
|
||||
end
|
||||
|
||||
function test_building_unique0()
|
||||
|
@ -1144,7 +1203,12 @@ function test_bug_1875_use_help()
|
|||
|
||||
assert_equal(0, u:get_item("peasantblood"))
|
||||
assert_equal(0, r:get_resource("peasant"))
|
||||
assert_equal(0, r:get_resource("peasant"))
|
||||
assert_equal(0, u2:get_potion("peasantblood")) -- first unit helps this unit
|
||||
if 98~=u:get_potion("peasantblood") then
|
||||
print(get_turn(), f, u)
|
||||
write_reports()
|
||||
end
|
||||
assert_equal(98, u:get_potion("peasantblood")) -- unit uses one peasantblood effect
|
||||
end
|
||||
|
||||
|
@ -1176,3 +1240,97 @@ function test_bug_1875_use_own_first()
|
|||
assert_equal(99, u:get_potion("peasantblood")) -- unit uses one peasantblood effect
|
||||
assert_equal(99, u2:get_potion("peasantblood")) -- u2 uses its own effect before u's
|
||||
end
|
||||
|
||||
|
||||
function test_bug_1879_follow_unit()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local r1 = region.create(1, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1, u2 = two_units(r, f, f)
|
||||
u1:clear_orders()
|
||||
u1:set_skill("magic", 10)
|
||||
u1:add_order("ZAUBERE STUFE 1 Kleine Flüche")
|
||||
u1:add_order("FOLGEN EINHEIT " .. itoa36(u2.id))
|
||||
u2:clear_orders()
|
||||
u2:add_order("NACH o")
|
||||
process_orders()
|
||||
assert_equal(u1.region.id, r1.id)
|
||||
assert_equal(u2.region.id, r1.id)
|
||||
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
|
||||
|
||||
function test_bug_1795_limit()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "human", "de")
|
||||
local u1 = one_unit(r,f)
|
||||
u1:add_item("money", 100000000)
|
||||
u1:add_order("REKRUTIEREN 9999")
|
||||
r:set_resource("peasant", 2000) -- no fractional growth!
|
||||
local peasants = r:get_resource("peasant")
|
||||
local limit,frac = math.modf(peasants/40) -- one day this should be a parameter
|
||||
local growth = peasants * 0.001
|
||||
|
||||
process_orders()
|
||||
|
||||
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
|
||||
assert_equal(peasants+growth-limit, r:get_resource("peasant"))
|
||||
end
|
||||
|
||||
function test_bug_1795_demons()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local f = faction.create("noreply@eressea.de", "demon", "de")
|
||||
local u1 = one_unit(r,f)
|
||||
r:set_resource("peasant", 2000)
|
||||
local peasants = r:get_resource("peasant")
|
||||
local limit,frac = math.modf(peasants/40)
|
||||
local growth = peasants * 0.001
|
||||
|
||||
u1:add_item("money", 100000000)
|
||||
u1:add_order("REKRUTIEREN 9999")
|
||||
|
||||
process_orders()
|
||||
|
||||
assert_equal(limit+1, u1.number, u1.number .. "!=" .. (limit+1))
|
||||
assert_equal(peasants+growth, r:get_resource("peasant"))
|
||||
end
|
||||
|
|
|
@ -2,6 +2,8 @@ require "lunit"
|
|||
|
||||
local _G = _G
|
||||
local eressea = eressea
|
||||
local default_ship = config.ships[1]
|
||||
local default_building = config.buildings[1]
|
||||
|
||||
module("tests.orders", lunit.testcase)
|
||||
|
||||
|
@ -12,7 +14,7 @@ function setup()
|
|||
r = _G.region.create(0, 0, "mountain")
|
||||
f = _G.faction.create("noreply@eressea.de", "human", "de")
|
||||
u = _G.unit.create(f, r, 1)
|
||||
u:clear_orders()
|
||||
u:clear_orders()
|
||||
eressea.settings.set("rules.economy.food", "4")
|
||||
eressea.settings.set("nmr.removenewbie", "0")
|
||||
eressea.settings.set("nmr.timeout", "0")
|
||||
|
@ -20,88 +22,245 @@ function setup()
|
|||
end
|
||||
|
||||
function test_learn()
|
||||
u:add_order("LERNEN Hiebwaffen")
|
||||
_G.process_orders()
|
||||
assert_not_equal(0, u:get_skill("melee"))
|
||||
u:add_order("LERNEN Hiebwaffen")
|
||||
_G.process_orders()
|
||||
assert_not_equal(0, u:get_skill("melee"))
|
||||
end
|
||||
|
||||
function test_give()
|
||||
local u2 = _G.unit.create(f, r, 1)
|
||||
u:add_item("money", 10)
|
||||
u:add_order("GIB " .. u2.id .. "5 SILBER")
|
||||
_G.process_orders()
|
||||
assert_not_equal(5, u:get_item("money"))
|
||||
assert_not_equal(5, u2:get_item("money"))
|
||||
local u2 = _G.unit.create(f, r, 1)
|
||||
u:add_item("money", 10)
|
||||
u:add_order("GIB " .. u2.id .. "5 SILBER")
|
||||
_G.process_orders()
|
||||
assert_not_equal(5, u:get_item("money"))
|
||||
assert_not_equal(5, u2:get_item("money"))
|
||||
end
|
||||
|
||||
function test_make_temp()
|
||||
u:add_order("MACHE TEMP 123 'Herpderp'")
|
||||
u:add_order("// this comment will be copied")
|
||||
u:add_order("ENDE")
|
||||
eressea.process.make_temp()
|
||||
u:add_order("MACHE TEMP 123 'Herpderp'")
|
||||
u:add_order("// this comment will be copied")
|
||||
u:add_order("ENDE")
|
||||
eressea.process.make_temp()
|
||||
|
||||
for x in f.units do
|
||||
if x.name == 'Herpderp' then u=x end
|
||||
end
|
||||
assert_equal('Herpderp', u.name)
|
||||
assert_equal(0, u.number)
|
||||
local c = 0
|
||||
for o in u.orders do
|
||||
assert_equal('// this comment will be copied', o)
|
||||
c = c + 1
|
||||
end
|
||||
assert_equal(1, c)
|
||||
for x in f.units do
|
||||
if x.name == 'Herpderp' then u=x end
|
||||
end
|
||||
assert_equal('Herpderp', u.name)
|
||||
assert_equal(0, u.number)
|
||||
local c = 0
|
||||
for o in u.orders do
|
||||
assert_equal('// this comment will be copied', o)
|
||||
c = c + 1
|
||||
end
|
||||
assert_equal(1, c)
|
||||
end
|
||||
|
||||
function test_give_temp()
|
||||
u.number = 2
|
||||
u:add_order("GIB TEMP 123 1 PERSON")
|
||||
u:add_order("MACHE TEMP 123 'Herpderp'")
|
||||
u:add_order("ENDE")
|
||||
_G.process_orders()
|
||||
assert_equal(1, u.number)
|
||||
u.number = 2
|
||||
u:add_order("GIB TEMP 123 1 PERSON")
|
||||
u:add_order("MACHE TEMP 123 'Herpderp'")
|
||||
u:add_order("ENDE")
|
||||
_G.process_orders()
|
||||
assert_equal(1, u.number)
|
||||
|
||||
for x in f.units do
|
||||
if x.name == 'Herpderp' then u=x end
|
||||
end
|
||||
assert_equal('Herpderp', u.name)
|
||||
assert_equal(1, u.number)
|
||||
for x in f.units do
|
||||
if x.name == 'Herpderp' then u=x end
|
||||
end
|
||||
assert_equal('Herpderp', u.name)
|
||||
assert_equal(1, u.number)
|
||||
end
|
||||
|
||||
function test_process_settings()
|
||||
f.options = 0
|
||||
u:add_order("EMAIL herp@derp.com")
|
||||
u:add_order("BANNER 'Herpderp'")
|
||||
u:add_order("PASSWORT 'HerpDerp'")
|
||||
u:add_order("OPTION AUSWERTUNG")
|
||||
eressea.process.settings()
|
||||
assert_equal("herp@derp.com", f.email)
|
||||
assert_equal("Herpderp", f.info)
|
||||
assert_equal("HerpDerp", f.password)
|
||||
assert_equal(1, f.options)
|
||||
f.options = 0
|
||||
u:add_order("EMAIL herp@derp.com")
|
||||
u:add_order("BANNER 'Herpderp'")
|
||||
u:add_order("PASSWORT 'HerpDerp'")
|
||||
u:add_order("OPTION AUSWERTUNG")
|
||||
eressea.process.settings()
|
||||
assert_equal("herp@derp.com", f.email)
|
||||
assert_equal("Herpderp", f.info)
|
||||
assert_equal("HerpDerp", f.password)
|
||||
assert_equal(1, f.options)
|
||||
end
|
||||
|
||||
function test_process_group()
|
||||
u:add_order("GRUPPE herp")
|
||||
eressea.process.set_group()
|
||||
assert_equal('herp', u.group)
|
||||
u:add_order("GRUPPE herp")
|
||||
eressea.process.set_group()
|
||||
assert_equal('herp', u.group)
|
||||
end
|
||||
|
||||
function test_process_origin()
|
||||
u:add_order("URSPRUNG 1 2")
|
||||
eressea.process.set_origin()
|
||||
x, y = u.faction:get_origin()
|
||||
assert_equal(1, x)
|
||||
assert_equal(2, y)
|
||||
u:add_order("URSPRUNG 1 2")
|
||||
eressea.process.set_origin()
|
||||
x, y = u.faction:get_origin()
|
||||
assert_equal(1, x)
|
||||
assert_equal(2, y)
|
||||
end
|
||||
|
||||
function test_process_quit()
|
||||
fno = f.id
|
||||
u:add_order("STIRB '" .. u.faction.password .. "'")
|
||||
assert_not_equal(nil, _G.get_faction(fno))
|
||||
eressea.process.quit()
|
||||
eressea.write_game('test.dat')
|
||||
eressea.free_game()
|
||||
eressea.read_game('test.dat')
|
||||
assert_equal(nil, _G.get_faction(fno))
|
||||
fno = f.id
|
||||
u:add_order("STIRB '" .. u.faction.password .. "'")
|
||||
assert_not_equal(nil, _G.get_faction(fno))
|
||||
eressea.process.quit()
|
||||
eressea.write_game('test.dat')
|
||||
eressea.free_game()
|
||||
eressea.read_game('test.dat')
|
||||
assert_equal(nil, _G.get_faction(fno))
|
||||
end
|
||||
|
||||
function test_process_make()
|
||||
u.region:set_resource('tree', 100)
|
||||
u:set_skill('forestry', 1)
|
||||
u:add_order('MACHE HOLZ')
|
||||
eressea.process.produce()
|
||||
assert_equal(1, u:get_item('log'))
|
||||
end
|
||||
|
||||
function test_process_study()
|
||||
u:add_order("LERNEN Holzfaellen")
|
||||
eressea.process.update_long_order()
|
||||
eressea.process.study()
|
||||
x, y = u.faction:get_origin()
|
||||
assert_equal(1, u:get_skill('forestry'))
|
||||
end
|
||||
|
||||
function test_process_teach()
|
||||
eressea.settings.set("study.random_progress", "0")
|
||||
u:set_skill('forestry', 3)
|
||||
u2 = _G.unit.create(f, r, 10)
|
||||
u2:clear_orders()
|
||||
u2:set_skill('forestry', 1)
|
||||
u2:add_order("LERNEN Holzfaellen")
|
||||
u:add_order("LEHREN " .. _G.itoa36(u2.id))
|
||||
eressea.process.update_long_order()
|
||||
eressea.process.study()
|
||||
assert_equal(2, u2:get_skill('forestry'))
|
||||
end
|
||||
|
||||
function test_process_move()
|
||||
r2 = _G.region.create(1, 0, 'plain')
|
||||
u:add_order('NACH O')
|
||||
assert_not_equal(r2.id, u.region.id)
|
||||
eressea.process.update_long_order()
|
||||
eressea.process.movement()
|
||||
assert_equal(r2, u.region)
|
||||
end
|
||||
|
||||
function test_process_leave()
|
||||
r2 = _G.region.create(1, 0, 'plain')
|
||||
b = _G.building.create(r, default_building)
|
||||
u.building = b
|
||||
assert_equal(b, u.building)
|
||||
u:add_order('VERLASSEN')
|
||||
eressea.process.leave()
|
||||
assert_not_equal(b, u.building)
|
||||
end
|
||||
|
||||
function test_process_name_unit()
|
||||
u:add_order("BENENNE EINHEIT 'Weasel'")
|
||||
u:add_order("BESCHREIBE EINHEIT 'Juanita'")
|
||||
eressea.process.set_name()
|
||||
assert_equal('Weasel', u.name)
|
||||
assert_equal('Juanita', u.info)
|
||||
end
|
||||
|
||||
function test_process_name_faction()
|
||||
u:add_order("BENENNE PARTEI 'Herpderp'")
|
||||
eressea.process.set_name()
|
||||
assert_equal('Herpderp', f.name)
|
||||
end
|
||||
|
||||
function test_process_name_building()
|
||||
u:add_order("BENENNE GEBAEUDE 'Herpderp'")
|
||||
u.building = _G.building.create(r, default_building)
|
||||
eressea.process.set_name()
|
||||
assert_equal('Herpderp', u.building.name)
|
||||
end
|
||||
|
||||
function test_process_name_ship()
|
||||
u:add_order("BENENNE SCHIFF 'Herpderp'")
|
||||
u.ship = _G.ship.create(r, default_ship)
|
||||
eressea.process.set_name()
|
||||
assert_equal('Herpderp', u.ship.name)
|
||||
end
|
||||
|
||||
function test_process_renumber()
|
||||
u:add_order("NUMMER EINHEIT 'ii'")
|
||||
eressea.process.renumber()
|
||||
assert_equal(666, u.id)
|
||||
end
|
||||
|
||||
function test_process_enter()
|
||||
b = _G.building.create(r, default_building)
|
||||
u:add_order("BETRETEN GEBAEUDE " .. _G.itoa36(b.id))
|
||||
eressea.process.enter(1)
|
||||
assert_equal(b, u.building)
|
||||
end
|
||||
|
||||
function test_process_restack()
|
||||
eressea.process.restack()
|
||||
end
|
||||
|
||||
function test_process_setspells()
|
||||
eressea.process.set_spells()
|
||||
end
|
||||
|
||||
function test_process_help()
|
||||
eressea.process.set_help()
|
||||
end
|
||||
|
||||
function test_process_contact()
|
||||
eressea.process.contact()
|
||||
end
|
||||
|
||||
function test_process_battle()
|
||||
eressea.process.battle()
|
||||
end
|
||||
|
||||
function test_process_magic()
|
||||
eressea.process.magic()
|
||||
end
|
||||
|
||||
function test_process_give_control()
|
||||
eressea.process.give_control()
|
||||
end
|
||||
|
||||
function test_process_regeneration()
|
||||
eressea.process.regeneration()
|
||||
end
|
||||
|
||||
function test_process_guard_on()
|
||||
eressea.process.guard_on()
|
||||
end
|
||||
|
||||
function test_process_guard_off()
|
||||
eressea.process.guard_off()
|
||||
end
|
||||
|
||||
function test_process_explain()
|
||||
eressea.process.explain()
|
||||
end
|
||||
|
||||
function test_process_messages()
|
||||
eressea.process.messages()
|
||||
end
|
||||
|
||||
function test_process_reserve()
|
||||
eressea.process.reserve()
|
||||
end
|
||||
|
||||
function test_process_claim()
|
||||
eressea.process.claim()
|
||||
end
|
||||
|
||||
function test_process_follow()
|
||||
eressea.process.follow()
|
||||
end
|
||||
|
||||
function test_process_idle()
|
||||
eressea.process.idle()
|
||||
end
|
||||
|
||||
function test_process_set_default()
|
||||
eressea.process.set_default()
|
||||
end
|
||||
|
|
|
@ -3,6 +3,7 @@ project (eressea C)
|
|||
|
||||
IF(CMAKE_COMPILER_IS_GNUCC)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Werror -Wno-unknown-pragmas -Wstrict-prototypes -Wpointer-arith -Wno-char-subscripts -Wno-long-long")
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -DHAVE__BOOL")
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCC)
|
||||
MESSAGE(STATUS "Unknown compiler ${CMAKE_C_COMPILER_ID}")
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
@ -12,14 +13,13 @@ set (ERESSEA_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "Eressea Cor
|
|||
|
||||
add_subdirectory(bindings)
|
||||
|
||||
find_package (Lua51 REQUIRED)
|
||||
find_package (Lua 5 REQUIRED)
|
||||
find_package (ToLua REQUIRED)
|
||||
find_package (LibXml2 REQUIRED)
|
||||
find_package (Curses REQUIRED)
|
||||
find_package (SQLite3 REQUIRED)
|
||||
|
||||
set (ERESSEA_LIBRARIES
|
||||
${BSON_LIBRARIES}
|
||||
${CUTEST_LIBRARIES}
|
||||
${CRITBIT_LIBRARIES}
|
||||
${QUICKLIST_LIBRARIES}
|
||||
|
@ -40,7 +40,6 @@ include_directories (${CUTEST_INCLUDE_DIR})
|
|||
include_directories (${LUA_INCLUDE_DIR})
|
||||
include_directories (${TOLUA_INCLUDE_DIR})
|
||||
include_directories (${LIBXML2_INCLUDE_DIR})
|
||||
include_directories (${BSON_INCLUDE_DIR})
|
||||
include_directories (${INIPARSER_INCLUDE_DIR})
|
||||
|
||||
FILE (GLOB_RECURSE LIB_HDR *.h)
|
||||
|
@ -51,6 +50,7 @@ set (TEST_SRC
|
|||
gamecode/economy_test.c
|
||||
gamecode/laws_test.c
|
||||
gamecode/market_test.c
|
||||
kernel/ally_test.c
|
||||
kernel/battle_test.c
|
||||
kernel/building_test.c
|
||||
kernel/curse_test.c
|
||||
|
@ -117,6 +117,7 @@ set (LIB_SRC
|
|||
items/xerewards.c
|
||||
kernel/alchemy.c
|
||||
kernel/alliance.c
|
||||
kernel/ally.c
|
||||
kernel/battle.c
|
||||
kernel/binarystore.c
|
||||
kernel/build.c
|
||||
|
@ -162,7 +163,6 @@ set (LIB_SRC
|
|||
modules/score.c
|
||||
modules/weather.c
|
||||
modules/wormhole.c
|
||||
modules/xecmd.c
|
||||
modules/xmas.c
|
||||
triggers/changefaction.c
|
||||
triggers/changerace.c
|
||||
|
@ -184,7 +184,6 @@ set (LIB_SRC
|
|||
util/console.c
|
||||
util/crmessage.c
|
||||
util/dice.c
|
||||
util/eventbus.c
|
||||
util/event.c
|
||||
util/filereader.c
|
||||
util/functions.c
|
||||
|
|
|
@ -48,7 +48,7 @@ attrib_type at_moved = {
|
|||
"moved", NULL, NULL, age_moved, write_moved, read_moved
|
||||
};
|
||||
|
||||
boolean get_moved(attrib ** alist)
|
||||
bool get_moved(attrib ** alist)
|
||||
{
|
||||
return a_find(*alist, &at_moved) ? true : false;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ extern "C" {
|
|||
struct attrib;
|
||||
struct attrib_type;
|
||||
|
||||
extern boolean get_moved(struct attrib **alist);
|
||||
extern bool get_moved(struct attrib **alist);
|
||||
extern void set_moved(struct attrib **alist);
|
||||
|
||||
extern struct attrib_type at_moved;
|
||||
|
|
|
@ -42,7 +42,7 @@ attrib_type at_movement = {
|
|||
"movement", NULL, NULL, NULL, write_movement, read_movement
|
||||
};
|
||||
|
||||
boolean get_movement(attrib * const *alist, int type)
|
||||
bool get_movement(attrib * const *alist, int type)
|
||||
{
|
||||
const attrib *a = a_findc(*alist, &at_movement);
|
||||
if (a == NULL)
|
||||
|
|
|
@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern boolean get_movement(struct attrib *const *alist, int type);
|
||||
extern bool get_movement(struct attrib *const *alist, int type);
|
||||
extern void set_movement(struct attrib **alist, int type);
|
||||
|
||||
extern struct attrib_type at_movement;
|
||||
|
|
|
@ -9,7 +9,7 @@ ENDIF(CMAKE_COMPILER_IS_GNUCC)
|
|||
|
||||
set (BINDINGS_LIBRARY ${PROJECT_NAME} CACHE INTERNAL "Eressea Lua Bindings")
|
||||
|
||||
find_package (Lua51 REQUIRED)
|
||||
find_package (Lua 5 REQUIRED)
|
||||
find_package (ToLua REQUIRED)
|
||||
find_package (LibXml2 REQUIRED)
|
||||
find_package (Curses REQUIRED)
|
||||
|
@ -23,7 +23,6 @@ include_directories (${CUTEST_INCLUDE_DIR})
|
|||
include_directories (${LUA_INCLUDE_DIR})
|
||||
include_directories (${TOLUA_INCLUDE_DIR})
|
||||
include_directories (${LIBXML2_INCLUDE_DIR})
|
||||
include_directories (${BSON_INCLUDE_DIR})
|
||||
include_directories (${INIPARSER_INCLUDE_DIR})
|
||||
|
||||
FILE (GLOB_RECURSE LIB_HDR *.h)
|
||||
|
|
|
@ -21,7 +21,6 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
#include <util/language.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
int tolua_buildinglist_next(lua_State * L)
|
||||
|
|
|
@ -29,7 +29,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/log.h>
|
||||
#include <quicklist.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
int tolua_factionlist_next(lua_State * L)
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <modules/autoseed.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
static int tolua_run_mapper(lua_State * L)
|
||||
|
|
|
@ -23,7 +23,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/variant.h>
|
||||
#include <util/attrib.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <util/message.h>
|
||||
|
||||
/* lua includes */
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -2,20 +2,83 @@
|
|||
|
||||
#include <platform.h>
|
||||
#include <kernel/types.h>
|
||||
#include <kernel/alliance.h>
|
||||
#include <kernel/config.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/battle.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/terrain.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/move.h>
|
||||
#include <gamecode/economy.h>
|
||||
#include <gamecode/laws.h>
|
||||
#include <gamecode/market.h>
|
||||
#include <gamecode/study.h>
|
||||
|
||||
#define PROC_LAND_REGION 0x0001
|
||||
#define PROC_LONG_ORDER 0x0002
|
||||
|
||||
static void process_cmd(keyword_t kwd, int (*callback)(unit *, order *), int flags)
|
||||
{
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
unit * u;
|
||||
|
||||
/* look for shortcuts */
|
||||
if (flags&PROC_LAND_REGION) {
|
||||
/* only execute when we are on solid terrain */
|
||||
while (r && (r->terrain->flags&LAND_REGION)==0) {
|
||||
r = r->next;
|
||||
}
|
||||
if (!r) break;
|
||||
}
|
||||
|
||||
for (u=r->units; u; u=u->next) {
|
||||
if (flags & PROC_LONG_ORDER) {
|
||||
if (kwd == get_keyword(u->thisorder)) {
|
||||
callback(u, u->thisorder);
|
||||
}
|
||||
} else {
|
||||
order * ord;
|
||||
for (ord=u->orders; ord; ord=ord->next) {
|
||||
if (kwd == get_keyword(ord)) {
|
||||
callback(u, ord);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_produce(void) {
|
||||
struct region *r;
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit * u;
|
||||
for (u=r->units; u; u=u->next) {
|
||||
order * ord;
|
||||
for (ord=u->orders; ord; ord=ord->next) {
|
||||
if (K_MAKE == get_keyword(ord)) {
|
||||
make_cmd(u, ord);
|
||||
}
|
||||
}
|
||||
}
|
||||
produce(r);
|
||||
split_allocations(r);
|
||||
}
|
||||
}
|
||||
|
||||
void process_battle(void) {
|
||||
struct region *r;
|
||||
for (r = regions; r; r = r->next) {
|
||||
do_battle(r);
|
||||
}
|
||||
}
|
||||
|
||||
void process_siege(void) {
|
||||
process_cmd(K_BESIEGE, siege_cmd, PROC_LAND_REGION);
|
||||
}
|
||||
|
||||
void process_update_long_order(void) {
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
|
@ -59,51 +122,173 @@ void process_settings(void) {
|
|||
}
|
||||
}
|
||||
|
||||
static void process_cmd(keyword_t kwd, int (*callback)(unit *, order *))
|
||||
{
|
||||
void process_ally(void) {
|
||||
process_cmd(K_ALLY, ally_cmd, 0);
|
||||
}
|
||||
|
||||
void process_prefix(void) {
|
||||
process_cmd(K_PREFIX, prefix_cmd, 0);
|
||||
}
|
||||
|
||||
void process_setstealth(void) {
|
||||
process_cmd(K_SETSTEALTH, setstealth_cmd, 0);
|
||||
}
|
||||
|
||||
void process_status(void) {
|
||||
process_cmd(K_STATUS, status_cmd, 0);
|
||||
}
|
||||
|
||||
void process_name(void) {
|
||||
process_cmd(K_NAME, name_cmd, 0);
|
||||
process_cmd(K_DISPLAY, display_cmd, 0);
|
||||
}
|
||||
|
||||
void process_group(void) {
|
||||
process_cmd(K_GROUP, group_cmd, 0);
|
||||
}
|
||||
|
||||
void process_origin(void) {
|
||||
process_cmd(K_URSPRUNG, origin_cmd, 0);
|
||||
}
|
||||
|
||||
void process_quit(void) {
|
||||
process_cmd(K_QUIT, quit_cmd, 0);
|
||||
quit();
|
||||
}
|
||||
|
||||
void process_study(void) {
|
||||
process_cmd(K_TEACH, teach_cmd, PROC_LONG_ORDER);
|
||||
process_cmd(K_STUDY, learn_cmd, PROC_LONG_ORDER);
|
||||
}
|
||||
|
||||
void process_movement(void) {
|
||||
region * r;
|
||||
|
||||
movement();
|
||||
for (r=regions; r; r=r->next) {
|
||||
if (r->ships) {
|
||||
sinkships(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_use(void) {
|
||||
process_cmd(K_USE, use_cmd, 0);
|
||||
}
|
||||
|
||||
void process_leave(void) {
|
||||
process_cmd(K_LEAVE, leave_cmd, 0);
|
||||
}
|
||||
|
||||
void process_promote(void) {
|
||||
process_cmd(K_PROMOTION, promotion_cmd, 0);
|
||||
}
|
||||
|
||||
void process_renumber(void) {
|
||||
process_cmd(K_NUMBER, renumber_cmd, 0);
|
||||
renumber_factions();
|
||||
}
|
||||
|
||||
void process_restack(void) {
|
||||
restack_units();
|
||||
}
|
||||
|
||||
void process_setspells(void) {
|
||||
process_cmd(K_COMBATSPELL, combatspell_cmd, 0);
|
||||
}
|
||||
|
||||
void process_sethelp(void) {
|
||||
process_cmd(K_ALLY, ally_cmd, 0);
|
||||
}
|
||||
|
||||
void process_contact(void) {
|
||||
process_cmd(K_CONTACT, contact_cmd, 0);
|
||||
}
|
||||
|
||||
void process_magic(void) {
|
||||
magic();
|
||||
}
|
||||
|
||||
void process_give_control(void) {
|
||||
process_cmd(K_CONTACT, give_control_cmd, 0);
|
||||
}
|
||||
|
||||
void process_guard_on(void) {
|
||||
process_cmd(K_GUARD, guard_on_cmd, PROC_LAND_REGION);
|
||||
}
|
||||
|
||||
void process_explain(void) {
|
||||
process_cmd(K_RESHOW, reshow_cmd, 0);
|
||||
}
|
||||
|
||||
void process_reserve(void) {
|
||||
process_cmd(K_RESERVE, reserve_cmd, 0);
|
||||
}
|
||||
|
||||
void process_claim(void) {
|
||||
process_cmd(K_CLAIM, claim_cmd, 0);
|
||||
}
|
||||
|
||||
void process_follow(void) {
|
||||
struct region *r;
|
||||
for (r = regions; r; r = r->next) {
|
||||
unit * u;
|
||||
for (u=r->units; u; u=u->next) {
|
||||
follow_unit(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void process_messages(void) {
|
||||
process_cmd(K_MAIL, mail_cmd, 0);
|
||||
}
|
||||
|
||||
void process_guard_off(void) {
|
||||
process_cmd(K_GUARD, guard_off_cmd, PROC_LAND_REGION);
|
||||
}
|
||||
|
||||
void process_regeneration(void) {
|
||||
monthly_healing();
|
||||
regenerate_aura();
|
||||
}
|
||||
|
||||
void process_enter(int final) {
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
do_enter(r, final);
|
||||
}
|
||||
}
|
||||
|
||||
void process_maintenance(void) {
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
unit * u;
|
||||
for (u=r->units; u; u=u->next) {
|
||||
order * ord;
|
||||
for (ord=u->orders; ord; ord=ord->next) {
|
||||
if (kwd == get_keyword(ord)) {
|
||||
callback(u, ord);
|
||||
keyword_t kwd = get_keyword(ord);
|
||||
if (kwd==K_PAY) {
|
||||
pay_cmd(u, ord);
|
||||
}
|
||||
}
|
||||
}
|
||||
maintain_buildings(r, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void process_ally(void) {
|
||||
process_cmd(K_ALLY, ally_cmd);
|
||||
void process_alliance(void) {
|
||||
alliance_cmd();
|
||||
}
|
||||
|
||||
void process_prefix(void) {
|
||||
process_cmd(K_PREFIX, prefix_cmd);
|
||||
void process_idle(void) {
|
||||
region * r;
|
||||
for (r=regions; r; r=r->next) {
|
||||
auto_work(r);
|
||||
}
|
||||
}
|
||||
|
||||
void process_setstealth(void) {
|
||||
process_cmd(K_SETSTEALTH, setstealth_cmd);
|
||||
}
|
||||
|
||||
void process_status(void) {
|
||||
process_cmd(K_STATUS, status_cmd);
|
||||
}
|
||||
|
||||
void process_display(void) {
|
||||
process_cmd(K_DISPLAY, display_cmd);
|
||||
}
|
||||
|
||||
void process_group(void) {
|
||||
process_cmd(K_GROUP, group_cmd);
|
||||
}
|
||||
|
||||
void process_origin(void) {
|
||||
process_cmd(K_URSPRUNG, origin_cmd);
|
||||
}
|
||||
|
||||
void process_quit(void) {
|
||||
process_cmd(K_QUIT, quit_cmd);
|
||||
quit();
|
||||
void process_set_default(void) {
|
||||
if (!global.disabled[K_DEFAULT]) {
|
||||
defaultorders();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,10 +14,37 @@ void process_ally(void);
|
|||
void process_prefix(void);
|
||||
void process_setstealth(void);
|
||||
void process_status(void);
|
||||
void process_display(void);
|
||||
void process_name(void);
|
||||
void process_group(void);
|
||||
void process_origin(void);
|
||||
void process_quit(void);
|
||||
void process_study(void);
|
||||
void process_movement(void);
|
||||
void process_use(void);
|
||||
void process_battle(void);
|
||||
void process_siege(void);
|
||||
void process_leave(void);
|
||||
void process_maintenance(void);
|
||||
void process_promote(void);
|
||||
void process_renumber(void);
|
||||
void process_restack(void);
|
||||
void process_setspells(void);
|
||||
void process_sethelp(void);
|
||||
void process_contact(void);
|
||||
void process_enter(int final);
|
||||
void process_magic(void);
|
||||
void process_give_control(void);
|
||||
void process_regeneration(void);
|
||||
void process_guard_on(void);
|
||||
void process_guard_off(void);
|
||||
void process_explain(void);
|
||||
void process_messages(void);
|
||||
void process_reserve(void);
|
||||
void process_claim(void);
|
||||
void process_follow(void);
|
||||
void process_alliance(void);
|
||||
void process_idle(void);
|
||||
void process_set_default(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/language.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -22,7 +22,6 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
#include <util/language.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
int tolua_shiplist_next(lua_State * L)
|
||||
|
|
|
@ -16,12 +16,11 @@ without prior permission by the authors of Eressea.
|
|||
#include "bindings.h"
|
||||
|
||||
#include <sqlite3.h>
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
#define LTYPE_DB TOLUA_CAST "db"
|
||||
|
||||
extern int db_update_factions(sqlite3 * db, boolean force);
|
||||
extern int db_update_factions(sqlite3 * db, bool force);
|
||||
static int tolua_db_update_factions(lua_State * L)
|
||||
{
|
||||
sqlite3 *db = (sqlite3 *) tolua_tousertype(L, 1, 0);
|
||||
|
@ -29,7 +28,7 @@ static int tolua_db_update_factions(lua_State * L)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern int db_update_scores(sqlite3 * db, boolean force);
|
||||
extern int db_update_scores(sqlite3 * db, bool force);
|
||||
static int tolua_db_update_scores(lua_State * L)
|
||||
{
|
||||
sqlite3 *db = (sqlite3 *) tolua_tousertype(L, 1, 0);
|
||||
|
|
|
@ -22,7 +22,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
static int tolua_storage_create(lua_State * L)
|
||||
|
|
|
@ -51,7 +51,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/log.h>
|
||||
#include <quicklist.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
|
|
@ -62,7 +62,6 @@ without prior permission by the authors of Eressea.
|
|||
#include <util/attrib.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/console.h>
|
||||
#include <util/eventbus.h>
|
||||
#include <util/language.h>
|
||||
#include <util/lists.h>
|
||||
#include <util/log.h>
|
||||
|
@ -1007,63 +1006,6 @@ typedef struct event_args {
|
|||
const char *sendertype;
|
||||
} event_args;
|
||||
|
||||
static void args_free(void *udata)
|
||||
{
|
||||
free(udata);
|
||||
}
|
||||
|
||||
static void event_cb(void *sender, const char *event, void *udata)
|
||||
{
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
event_args *args = (event_args *) udata;
|
||||
int nargs = 2;
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, args->hfunction);
|
||||
if (sender && args->sendertype) {
|
||||
tolua_pushusertype(L, sender, TOLUA_CAST args->sendertype);
|
||||
} else {
|
||||
lua_pushnil(L);
|
||||
}
|
||||
tolua_pushstring(L, event);
|
||||
if (args->hargs) {
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, args->hfunction);
|
||||
++nargs;
|
||||
}
|
||||
lua_pcall(L, nargs, 0, 0);
|
||||
}
|
||||
|
||||
/* arguments:
|
||||
* 1: sender (usertype)
|
||||
* 2: event (string)
|
||||
* 3: handler (function)
|
||||
* 4: arguments (any, *optional*)
|
||||
**/
|
||||
static int tolua_eventbus_register(lua_State * L)
|
||||
{
|
||||
void *sender = tolua_tousertype(L, 1, 0);
|
||||
const char *event = tolua_tostring(L, 2, 0);
|
||||
event_args *args = (event_args *)malloc(sizeof(event_args));
|
||||
args->sendertype = sender ? tolua_typename(L, 1) : NULL;
|
||||
lua_pushvalue(L, 3);
|
||||
args->hfunction = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
if (lua_type(L, 4) != LUA_TNONE) {
|
||||
lua_pushvalue(L, 4);
|
||||
args->hargs = luaL_ref(L, LUA_REGISTRYINDEX);
|
||||
} else {
|
||||
args->hargs = 0;
|
||||
}
|
||||
eventbus_register(sender, event, &event_cb, &args_free, args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_eventbus_fire(lua_State * L)
|
||||
{
|
||||
void *sender = tolua_tousertype(L, 1, 0);
|
||||
const char *event = tolua_tostring(L, 2, 0);
|
||||
void *args = NULL;
|
||||
eventbus_fire(sender, event, args);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_report_unit(lua_State * L)
|
||||
{
|
||||
char buffer[512];
|
||||
|
@ -1145,12 +1087,6 @@ int tolua_bindings_open(lua_State * L)
|
|||
#endif
|
||||
tolua_variable(L, TOLUA_CAST "text", tolua_get_spell_text, 0);
|
||||
} tolua_endmodule(L);
|
||||
tolua_module(L, TOLUA_CAST "eventbus", 1);
|
||||
tolua_beginmodule(L, TOLUA_CAST "eventbus");
|
||||
{
|
||||
tolua_function(L, TOLUA_CAST "register", &tolua_eventbus_register);
|
||||
tolua_function(L, TOLUA_CAST "fire", &tolua_eventbus_fire);
|
||||
} tolua_endmodule(L);
|
||||
tolua_module(L, TOLUA_CAST "report", 1);
|
||||
tolua_beginmodule(L, TOLUA_CAST "report");
|
||||
{
|
||||
|
@ -1224,34 +1160,9 @@ int tolua_bindings_open(lua_State * L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static const struct {
|
||||
const char *name;
|
||||
int (*func) (lua_State *);
|
||||
} lualibs[] = {
|
||||
{
|
||||
"", luaopen_base}, {
|
||||
LUA_TABLIBNAME, luaopen_table}, {
|
||||
LUA_IOLIBNAME, luaopen_io}, {
|
||||
LUA_STRLIBNAME, luaopen_string}, {
|
||||
LUA_MATHLIBNAME, luaopen_math}, {
|
||||
LUA_LOADLIBNAME, luaopen_package}, {
|
||||
LUA_DBLIBNAME, luaopen_debug},
|
||||
#if LUA_VERSION_NUM>=501
|
||||
{
|
||||
LUA_OSLIBNAME, luaopen_os},
|
||||
#endif
|
||||
{
|
||||
NULL, NULL}
|
||||
};
|
||||
|
||||
static void openlibs(lua_State * L)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; lualibs[i].func; ++i) {
|
||||
lua_pushcfunction(L, lualibs[i].func);
|
||||
lua_pushstring(L, lualibs[i].name);
|
||||
lua_call(L, 1, 0);
|
||||
}
|
||||
luaL_openlibs(L);
|
||||
}
|
||||
|
||||
void lua_done(lua_State * L) {
|
||||
|
@ -1259,7 +1170,7 @@ void lua_done(lua_State * L) {
|
|||
}
|
||||
|
||||
lua_State *lua_init(void) {
|
||||
lua_State *L = lua_open();
|
||||
lua_State *L = luaL_newstate();
|
||||
|
||||
openlibs(L);
|
||||
#ifdef BINDINGS_TOLUA
|
||||
|
@ -1286,7 +1197,7 @@ lua_State *lua_init(void) {
|
|||
|
||||
int eressea_run(lua_State *L, const char *luafile, const char *entry_point)
|
||||
{
|
||||
int err;
|
||||
int err = 0;
|
||||
|
||||
global.vm_state = L;
|
||||
/* run the main script */
|
||||
|
@ -1303,14 +1214,16 @@ int eressea_run(lua_State *L, const char *luafile, const char *entry_point)
|
|||
}
|
||||
if (entry_point) {
|
||||
lua_getglobal(L, entry_point);
|
||||
err = lua_pcall(L, 0, 1, 0);
|
||||
if (err != 0) {
|
||||
log_lua_error(L);
|
||||
abort();
|
||||
if (lua_isfunction(L, -1)) {
|
||||
log_debug("calling entry-point: %s\n", entry_point);
|
||||
err = lua_pcall(L, 0, 1, 0);
|
||||
if (err != 0) {
|
||||
log_lua_error(L);
|
||||
}
|
||||
return err;
|
||||
} else {
|
||||
log_error("unknown entry-point: %s\n", entry_point);
|
||||
}
|
||||
} else {
|
||||
err = lua_console(L);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
return lua_console(L);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
#include <gamecode/archetype.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <tolua.h>
|
||||
#include <lua.h>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
|
@ -48,8 +48,7 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o
|
|||
strlcpy(fname, iname, sizeof(fname));
|
||||
strlcat(fname, "_give", sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, s, TOLUA_CAST "unit");
|
||||
tolua_pushusertype(L, d, TOLUA_CAST "unit");
|
||||
|
@ -81,8 +80,7 @@ static int limit_resource(const region * r, const resource_type * rtype)
|
|||
strlcpy(fname, rtype->_name[0], sizeof(fname));
|
||||
strlcat(fname, "_limit", sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
|
||||
|
||||
|
@ -111,8 +109,7 @@ produce_resource(region * r, const resource_type * rtype, int norders)
|
|||
strlcpy(fname, rtype->_name[0], sizeof(fname));
|
||||
strlcat(fname, "_produce", sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
|
||||
tolua_pushnumber(L, (lua_Number) norders);
|
||||
|
@ -140,8 +137,7 @@ static int lc_age(struct attrib *a)
|
|||
if (fname != NULL) {
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
|
||||
if (fparam) {
|
||||
|
@ -201,8 +197,7 @@ static int lua_callspell(castorder * co)
|
|||
fname = fbuf;
|
||||
}
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
int nparam = 4;
|
||||
tolua_pushusertype(L, r, TOLUA_CAST "region");
|
||||
|
@ -254,8 +249,7 @@ static int lua_initfamiliar(unit * u)
|
|||
strlcpy(fname, "initfamiliar_", sizeof(fname));
|
||||
strlcat(fname, u->race->_name[0], sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, u, TOLUA_CAST "unit");
|
||||
|
||||
|
@ -290,8 +284,7 @@ lua_changeresource(unit * u, const struct resource_type *rtype, int delta)
|
|||
strlcpy(fname, rtype->_name[0], sizeof(fname));
|
||||
strlcat(fname, "_changeresource", sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, u, TOLUA_CAST "unit");
|
||||
tolua_pushnumber(L, (lua_Number) delta);
|
||||
|
@ -321,8 +314,7 @@ static int lua_getresource(unit * u, const struct resource_type *rtype)
|
|||
strlcpy(fname, rtype->_name[0], sizeof(fname));
|
||||
strlcat(fname, "_getresource", sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, u, TOLUA_CAST "unit");
|
||||
|
||||
|
@ -342,17 +334,16 @@ static int lua_getresource(unit * u, const struct resource_type *rtype)
|
|||
return result;
|
||||
}
|
||||
|
||||
static boolean lua_canuse_item(const unit * u, const struct item_type *itype)
|
||||
static bool lua_canuse_item(const unit * u, const struct item_type *itype)
|
||||
{
|
||||
static int function_exists = 1;
|
||||
boolean result = true;
|
||||
bool result = true;
|
||||
|
||||
if (function_exists) {
|
||||
lua_State *L = (lua_State *) global.vm_state;
|
||||
const char *fname = "item_canuse";
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
tolua_pushstring(L, itype->rtype->_name[0]);
|
||||
|
@ -381,8 +372,7 @@ lua_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
const char *fname = "wage";
|
||||
int result = -1;
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)r, TOLUA_CAST "region");
|
||||
tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction");
|
||||
|
@ -413,8 +403,7 @@ static void lua_agebuilding(building * b)
|
|||
strlcpy(fname, "age_", sizeof(fname));
|
||||
strlcat(fname, b->type->_name, sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
|
||||
|
||||
|
@ -435,8 +424,7 @@ static int lua_building_protection(building * b, unit * u)
|
|||
const char *fname = "building_protection";
|
||||
int result = 0;
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
|
@ -462,8 +450,7 @@ static double lua_building_taxes(building * b, int level)
|
|||
const char *fname = "building_taxes";
|
||||
double result = 0.0F;
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)b, TOLUA_CAST "building");
|
||||
tolua_pushnumber(L, level);
|
||||
|
@ -489,8 +476,7 @@ static int lua_maintenance(const unit * u)
|
|||
const char *fname = "maintenance";
|
||||
int result = -1;
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
|
||||
|
@ -519,8 +505,7 @@ static int lua_equipmentcallback(const struct equipment *eq, unit * u)
|
|||
strlcpy(fname, "equip_", sizeof(fname));
|
||||
strlcat(fname, eq->name, sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
|
||||
|
@ -551,8 +536,7 @@ lua_useitem(struct unit *u, const struct item_type *itype, int amount,
|
|||
strlcpy(fname, "use_", sizeof(fname));
|
||||
strlcat(fname, itype->rtype->_name[0], sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
tolua_pushnumber(L, (lua_Number) amount);
|
||||
|
@ -582,8 +566,7 @@ static int lua_recruit(struct unit *u, const struct archetype *arch, int amount)
|
|||
strlcpy(fname, "recruit_", sizeof(fname));
|
||||
strlcat(fname, arch->name[0], sizeof(fname));
|
||||
|
||||
lua_pushstring(L, fname);
|
||||
lua_rawget(L, LUA_GLOBALSINDEX);
|
||||
lua_getglobal(L, fname);
|
||||
if (lua_isfunction(L, -1)) {
|
||||
tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit");
|
||||
tolua_pushnumber(L, (lua_Number) amount);
|
||||
|
|
|
@ -4,16 +4,43 @@ module eressea {
|
|||
module process {
|
||||
void process_update_long_order @ update_long_order(void);
|
||||
void process_markets @ markets(void); /* operate the e3 markets */
|
||||
void process_produce @ produce(void); /* BUY/SELL/ENTERTAIN/WORK/TAX/STEAL/SPY/SABOTAGE/PLANT/BREED/RESEARCH */
|
||||
void process_produce @ produce(void); /* MAKE+BUY/SELL/ENTERTAIN/WORK/TAX/STEAL/SPY/SABOTAGE/PLANT/BREED/RESEARCH */
|
||||
void process_make_temp @ make_temp(void); /* MAKE TEMP */
|
||||
void process_settings @ settings(void); /* EMAIL/PASSWORD/BANNER/OPTION */
|
||||
void process_ally @ set_allies(void); /* HELP */
|
||||
void process_prefix @ set_prefix(void); /* PREFIX */
|
||||
void process_setstealth @ set_stealth(void); /* STEALTH */
|
||||
void process_status @ set_status(void); /* STATUS */
|
||||
void process_display @ set_description(void); /* DESCRIBE */
|
||||
void process_name @ set_name(void); /* NAME/DISPLAY */
|
||||
void process_group @ set_group(void); /* GROUP */
|
||||
void process_origin @ set_origin(void); /* ORIGIN */
|
||||
void process_quit @ quit(void); /* QUIT */
|
||||
void process_study @ study(void); /* LEARN/TEACH */
|
||||
void process_movement @ movement(void); /* MOVE/FOLLOW/ROUTE */
|
||||
void process_use @ use(void); /* USE */
|
||||
void process_battle @ battle(void); /* ATTACK */
|
||||
void process_siege @ siege(void); /* SIEGE */
|
||||
void process_leave @ leave(void); /* LEAVE */
|
||||
void process_maintenance @ maintenance(void); /* PAY */
|
||||
void process_promote @ promote(void); /* PROMOTE */
|
||||
void process_renumber @ renumber(void); /* RENUMBER */
|
||||
void process_restack @ restack(void); /* SORT */
|
||||
void process_setspells @ set_spells(void); /* COMBATSPELL */
|
||||
void process_sethelp @ set_help(void); /* HELP */
|
||||
void process_contact @ contact(void); /* CONTACT */
|
||||
void process_enter @ enter(int message); /* ENTER */
|
||||
void process_magic @ magic(void); /* CAST */
|
||||
void process_give_control @ give_control(void); /* GIVE CONTROL */
|
||||
void process_regeneration @ regeneration(void); /* regen health & aura */
|
||||
void process_guard_on @ guard_on(void); /* GUARD */
|
||||
void process_guard_off @ guard_off(void); /* GUARD NOT */
|
||||
void process_explain @ explain(void); /* SHOW */
|
||||
void process_messages @ messages(void); /* MESSAGE */
|
||||
void process_reserve @ reserve(void); /* RESERVE */
|
||||
void process_claim @ claim(void); /* CLAIM */
|
||||
void process_follow @ follow(void); /* FOLLOW */
|
||||
void process_alliance @ alliance(void); /* FOLLOW */
|
||||
void process_idle @ idle(void); /* work.auto */
|
||||
void process_set_default @ set_default(void); /* work.auto */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct rule {
|
||||
boolean allow;
|
||||
bool allow;
|
||||
char *property;
|
||||
char *value;
|
||||
} rule;
|
||||
|
|
|
@ -33,6 +33,7 @@ without prior permission by the authors of Eressea.
|
|||
/* kernel includes */
|
||||
#include <kernel/alchemy.h>
|
||||
#include <kernel/alliance.h>
|
||||
#include <kernel/ally.h>
|
||||
#include <kernel/connection.h>
|
||||
#include <kernel/building.h>
|
||||
#include <kernel/curse.h>
|
||||
|
@ -80,7 +81,7 @@ without prior permission by the authors of Eressea.
|
|||
|
||||
/* imports */
|
||||
extern int verbosity;
|
||||
boolean opt_cr_absolute_coords = false;
|
||||
bool opt_cr_absolute_coords = false;
|
||||
|
||||
/* globals */
|
||||
#define C_REPORT_VERSION 66
|
||||
|
@ -177,7 +178,7 @@ static void print_items(FILE * F, item * items, const struct locale *lang)
|
|||
static void
|
||||
cr_output_curses(FILE * F, const faction * viewer, const void *obj, objtype_t typ)
|
||||
{
|
||||
boolean header = false;
|
||||
bool header = false;
|
||||
attrib *a = NULL;
|
||||
int self = 0;
|
||||
region *r;
|
||||
|
@ -508,7 +509,7 @@ static void render_messages(FILE * F, faction * f, message_list * msgs)
|
|||
struct mlist *m = msgs->begin;
|
||||
while (m) {
|
||||
char crbuffer[BUFFERSIZE]; /* gross, wegen spionage-messages :-( */
|
||||
boolean printed = false;
|
||||
bool printed = false;
|
||||
const struct message_type *mtype = m->msg->type;
|
||||
unsigned int hash = mtype->key;
|
||||
#ifdef RENDER_CRMESSAGES
|
||||
|
@ -637,7 +638,7 @@ cr_output_ship(FILE * F, const ship * sh, const unit * u, int fcaptain,
|
|||
|
||||
static void
|
||||
fwriteorder(FILE * F, const struct order *ord, const struct locale *lang,
|
||||
boolean escape)
|
||||
bool escape)
|
||||
{
|
||||
char ebuf[1024];
|
||||
char obuf[1024];
|
||||
|
@ -690,9 +691,9 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
|
|||
const char *pzTmp;
|
||||
skill *sv;
|
||||
const attrib *a_fshidden = NULL;
|
||||
boolean itemcloak = false;
|
||||
bool itemcloak = false;
|
||||
static const curse_type *itemcloak_ct = 0;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
item result[MAX_INVENTORY];
|
||||
|
||||
if (fval(u->race, RCF_INVISIBLE))
|
||||
|
@ -1096,7 +1097,7 @@ cr_borders(seen_region ** seen, const region * r, const faction * f,
|
|||
}
|
||||
b = get_borders(r, r2);
|
||||
while (b) {
|
||||
boolean cs = b->type->fvisible(b, f, r);
|
||||
bool cs = b->type->fvisible(b, f, r);
|
||||
|
||||
if (!cs) {
|
||||
cs = b->type->rvisible(b, r);
|
||||
|
@ -1352,7 +1353,7 @@ static void cr_output_region(FILE * F, report_context * ctx, seen_region * sr)
|
|||
/* describe both passed and inhabited regions */
|
||||
show_active_spells(r);
|
||||
if (fval(r, RF_TRAVELUNIT)) {
|
||||
boolean seeunits = false, seeships = false;
|
||||
bool seeunits = false, seeships = false;
|
||||
const attrib *ru;
|
||||
/* show units pulled through region */
|
||||
for (ru = a_find(r->attribs, &at_travelunit);
|
||||
|
|
|
@ -89,7 +89,7 @@ typedef struct request {
|
|||
int qty;
|
||||
int no;
|
||||
union {
|
||||
boolean goblin; /* stealing */
|
||||
bool goblin; /* stealing */
|
||||
const struct luxury_type *ltype; /* trading */
|
||||
} type;
|
||||
} request;
|
||||
|
@ -215,6 +215,9 @@ typedef struct recruitment {
|
|||
int total, assigned;
|
||||
} recruitment;
|
||||
|
||||
/** Creates a list of recruitment structs, one for each faction. Adds every quantifyable request
|
||||
* to the faction's struct and to total.
|
||||
*/
|
||||
static recruitment *select_recruitment(request ** rop,
|
||||
int (*quantify) (const struct race *, int), int *total)
|
||||
{
|
||||
|
@ -292,14 +295,14 @@ static int any_recruiters(const struct race *rc, int qty)
|
|||
return (int)(qty * 2 * rc->recruit_multi);
|
||||
}
|
||||
|
||||
static int peasant_recruiters(const struct race *rc, int qty)
|
||||
/*static int peasant_recruiters(const struct race *rc, int qty)
|
||||
{
|
||||
if (rc->ec_flags & ECF_REC_ETHEREAL)
|
||||
return -1;
|
||||
if (rc->ec_flags & ECF_REC_HORSES)
|
||||
return -1;
|
||||
return (int)(qty * 2 * rc->recruit_multi);
|
||||
}
|
||||
}*/
|
||||
|
||||
static int horse_recruiters(const struct race *rc, int qty)
|
||||
{
|
||||
|
@ -315,10 +318,12 @@ static int do_recruiting(recruitment * recruits, int available)
|
|||
recruitment *rec;
|
||||
int recruited = 0;
|
||||
|
||||
/* try to assign recruits to factions fairly */
|
||||
while (available > 0) {
|
||||
int n = 0;
|
||||
int rest, mintotal = INT_MAX;
|
||||
|
||||
/* find smallest request */
|
||||
for (rec = recruits; rec != NULL; rec = rec->next) {
|
||||
int want = rec->total - rec->assigned;
|
||||
if (want > 0) {
|
||||
|
@ -334,6 +339,8 @@ static int do_recruiting(recruitment * recruits, int available)
|
|||
}
|
||||
rest = available - mintotal * n;
|
||||
|
||||
/* assign size of smallest request for everyone if possible; in the end roll dice to assign
|
||||
* small rest */
|
||||
for (rec = recruits; rec != NULL; rec = rec->next) {
|
||||
int want = rec->total - rec->assigned;
|
||||
|
||||
|
@ -350,6 +357,7 @@ static int do_recruiting(recruitment * recruits, int available)
|
|||
}
|
||||
}
|
||||
|
||||
/* do actual recruiting */
|
||||
for (rec = recruits; rec != NULL; rec = rec->next) {
|
||||
request *req;
|
||||
int get = rec->assigned;
|
||||
|
@ -365,8 +373,6 @@ static int do_recruiting(recruitment * recruits, int available)
|
|||
int afford = get_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
|
||||
number * rc->recruitcost) / rc->recruitcost;
|
||||
number = MIN(number, afford);
|
||||
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
|
||||
rc->recruitcost * number);
|
||||
}
|
||||
if (u->number + number > UNIT_MAXSIZE) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, req->ord, "error_unit_size",
|
||||
|
@ -374,6 +380,10 @@ static int do_recruiting(recruitment * recruits, int available)
|
|||
number = UNIT_MAXSIZE - u->number;
|
||||
assert(number >= 0);
|
||||
}
|
||||
if (rc->recruitcost) {
|
||||
use_pooled(u, oldresourcetype[R_SILVER], GET_DEFAULT,
|
||||
rc->recruitcost * number);
|
||||
}
|
||||
add_recruits(u, number, req->qty);
|
||||
dec = (int)(number * multi);
|
||||
if ((rc->ec_flags & ECF_REC_ETHEREAL) == 0) {
|
||||
|
@ -392,7 +402,7 @@ static void feedback_give_not_allowed(unit * u, order * ord)
|
|||
""));
|
||||
}
|
||||
|
||||
static boolean check_give(unit * u, unit * u2, const item_type * itype,
|
||||
static bool check_give(unit * u, unit * u2, const item_type * itype,
|
||||
int mask)
|
||||
{
|
||||
if (u2) {
|
||||
|
@ -449,7 +459,7 @@ static void expandrecruit(region * r, request * recruitorders)
|
|||
}
|
||||
|
||||
/* peasant limited: */
|
||||
recruits = select_recruitment(&recruitorders, peasant_recruiters, &orc_total);
|
||||
recruits = select_recruitment(&recruitorders, any_recruiters, &orc_total);
|
||||
if (recruits) {
|
||||
int orc_recruited, orc_peasants = rpeasants(r) * 2;
|
||||
int orc_frac = orc_peasants / RECRUITFRACTION; /* anzahl orks. 2 ork = 1 bauer */
|
||||
|
@ -464,10 +474,10 @@ static void expandrecruit(region * r, request * recruitorders)
|
|||
/* no limit: */
|
||||
recruits = select_recruitment(&recruitorders, any_recruiters, &orc_total);
|
||||
if (recruits) {
|
||||
int recruited, peasants = rpeasants(r);
|
||||
int recruited, peasants = rpeasants(r) * 2;
|
||||
recruited = do_recruiting(recruits, INT_MAX);
|
||||
if (recruited > 0) {
|
||||
rsetpeasants(r, peasants - recruited / 2);
|
||||
rsetpeasants(r, (peasants - recruited) / 2);
|
||||
}
|
||||
free_recruitments(recruits);
|
||||
}
|
||||
|
@ -537,7 +547,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders)
|
|||
get_gamedate(turn, &date);
|
||||
if (date.season == 0 && r->terrain != newterrain(T_DESERT)) {
|
||||
#ifdef INSECT_POTION
|
||||
boolean usepotion = false;
|
||||
bool usepotion = false;
|
||||
unit *u2;
|
||||
|
||||
for (u2 = r->units; u2; u2 = u2->next)
|
||||
|
@ -769,7 +779,7 @@ static void give_cmd(unit * u, order * ord)
|
|||
}
|
||||
|
||||
else if (p == P_HERBS) {
|
||||
boolean given = false;
|
||||
bool given = false;
|
||||
if (!(u->race->ec_flags & GIVEITEM) && u2 != NULL) {
|
||||
ADDMSG(&u->faction->msgs,
|
||||
msg_feedback(u, ord, "race_nogive", "race", u->race));
|
||||
|
@ -996,12 +1006,12 @@ void add_spende(faction * f1, faction * f2, int amount, region * r)
|
|||
r->donations = sp;
|
||||
}
|
||||
|
||||
static boolean maintain(building * b, boolean first)
|
||||
static bool maintain(building * b, bool first)
|
||||
/* first==false -> take money from wherever you can */
|
||||
{
|
||||
int c;
|
||||
region *r = b->region;
|
||||
boolean paid = true, work = first;
|
||||
bool paid = true, work = first;
|
||||
unit *u;
|
||||
if (fval(b, BLD_MAINTAINED) || b->type == NULL || b->type->maintenance == NULL
|
||||
|| is_cursed(b->attribs, C_NOCOST, 0)) {
|
||||
|
@ -1111,12 +1121,12 @@ static boolean maintain(building * b, boolean first)
|
|||
return true;
|
||||
}
|
||||
|
||||
void maintain_buildings(region * r, boolean crash)
|
||||
void maintain_buildings(region * r, bool crash)
|
||||
{
|
||||
building **bp = &r->buildings;
|
||||
while (*bp) {
|
||||
building *b = *bp;
|
||||
boolean maintained = maintain(b, !crash);
|
||||
bool maintained = maintain(b, !crash);
|
||||
|
||||
/* the second time, send a message */
|
||||
if (crash) {
|
||||
|
@ -1141,7 +1151,7 @@ void maintain_buildings(region * r, boolean crash)
|
|||
|
||||
static int recruit_archetype(unit * u, order * ord)
|
||||
{
|
||||
boolean merge = (u->number > 0);
|
||||
bool merge = (u->number > 0);
|
||||
int want;
|
||||
const char *s;
|
||||
|
||||
|
@ -1178,7 +1188,7 @@ static int recruit_archetype(unit * u, order * ord)
|
|||
*/
|
||||
int k;
|
||||
for (k = 0; arch->rules[k].property; ++k) {
|
||||
boolean match = false;
|
||||
bool match = false;
|
||||
if (arch->rules[k].value[0] == '*')
|
||||
match = true;
|
||||
else if (strcmp(arch->rules[k].property, "race") == 0) {
|
||||
|
@ -1296,7 +1306,7 @@ void economics(region * r)
|
|||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
order *ord;
|
||||
boolean destroyed = false;
|
||||
bool destroyed = false;
|
||||
if (u->number > 0) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
keyword_t kwd = get_keyword(ord);
|
||||
|
@ -1306,7 +1316,7 @@ void economics(region * r)
|
|||
ord = NULL;
|
||||
destroyed = true;
|
||||
}
|
||||
} else if (kwd == K_GIVE || kwd == K_LIEFERE) {
|
||||
} else if (kwd == K_GIVE) {
|
||||
give_cmd(u, ord);
|
||||
} else if (kwd == K_FORGET) {
|
||||
forget_cmd(u, ord);
|
||||
|
@ -1421,7 +1431,7 @@ typedef struct allocation_list {
|
|||
|
||||
static allocation_list *allocations;
|
||||
|
||||
static boolean can_guard(const unit * guard, const unit * u)
|
||||
static bool can_guard(const unit * guard, const unit * u)
|
||||
{
|
||||
if (fval(guard, UFL_ISNEW))
|
||||
return false;
|
||||
|
@ -1612,7 +1622,7 @@ leveled_allocation(const resource_type * rtype, region * r, allocation * alist)
|
|||
const item_type *itype = resource2item(rtype);
|
||||
rawmaterial *rm = rm_get(r, rtype);
|
||||
int need;
|
||||
boolean first = true;
|
||||
bool first = true;
|
||||
|
||||
if (rm != NULL) {
|
||||
do {
|
||||
|
@ -2373,9 +2383,9 @@ static void expandselling(region * r, request * sellorders, int limit)
|
|||
}
|
||||
}
|
||||
|
||||
static boolean sell(unit * u, request ** sellorders, struct order *ord)
|
||||
static bool sell(unit * u, request ** sellorders, struct order *ord)
|
||||
{
|
||||
boolean unlimited = true;
|
||||
bool unlimited = true;
|
||||
const item_type *itype;
|
||||
const luxury_type *ltype = NULL;
|
||||
int n;
|
||||
|
@ -2904,7 +2914,7 @@ static int max_skill(region * r, faction * f, skill_t sk)
|
|||
static void steal_cmd(unit * u, struct order *ord, request ** stealorders)
|
||||
{
|
||||
int n, i, id;
|
||||
boolean goblin = false;
|
||||
bool goblin = false;
|
||||
request *o;
|
||||
unit *u2 = NULL;
|
||||
region *r = u->region;
|
||||
|
@ -3342,7 +3352,7 @@ void produce(struct region *r)
|
|||
unit *u;
|
||||
int todo;
|
||||
static int rule_autowork = -1;
|
||||
boolean limited = true;
|
||||
bool limited = true;
|
||||
request *nextworker = workers;
|
||||
assert(r);
|
||||
|
||||
|
@ -3378,7 +3388,7 @@ void produce(struct region *r)
|
|||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
order *ord;
|
||||
boolean trader = false;
|
||||
bool trader = false;
|
||||
|
||||
if (u->race == new_race[RC_SPELL] || fval(u, UFL_LONGACTION))
|
||||
continue;
|
||||
|
|
|
@ -48,7 +48,7 @@ extern "C" {
|
|||
|
||||
enum { IC_WORK, IC_ENTERTAIN, IC_TAX, IC_TRADE, IC_TRADETAX, IC_STEAL,
|
||||
IC_MAGIC };
|
||||
void maintain_buildings(struct region *r, boolean crash);
|
||||
void maintain_buildings(struct region *r, bool crash);
|
||||
extern void add_spende(struct faction *f1, struct faction *f2, int betrag,
|
||||
struct region *r);
|
||||
extern int make_cmd(struct unit *u, struct order *ord);
|
||||
|
|
|
@ -87,7 +87,7 @@ add_give(unit * u, unit * u2, int given, int received,
|
|||
}
|
||||
}
|
||||
|
||||
static boolean limited_give(const item_type * type)
|
||||
static bool limited_give(const item_type * type)
|
||||
{
|
||||
/* trade only money 2:1, if at all */
|
||||
return (type == i_silver);
|
||||
|
@ -288,7 +288,7 @@ void give_men(int n, unit * u, unit * u2, struct order *ord)
|
|||
if (u2) {
|
||||
if (u2->number != 0 && recruit_archetypes()) {
|
||||
/* must have same set of skills */
|
||||
boolean okay = false;
|
||||
bool okay = false;
|
||||
if (u->skill_size == u2->skill_size) {
|
||||
int i;
|
||||
for (i = 0; i != u->skill_size; ++i) {
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,9 +34,10 @@ extern "C" {
|
|||
const char *s, struct unit *receiver);
|
||||
int init_data(const char *filename, const char *catalog);
|
||||
|
||||
boolean renamed_building(const struct building * b);
|
||||
bool renamed_building(const struct building * b);
|
||||
int rename_building(struct unit * u, struct order * ord, struct building * b, const char *name);
|
||||
void get_food(struct region * r);
|
||||
extern int can_contact(const struct region *r, const struct unit *u, const struct unit *u2);
|
||||
|
||||
/* eressea-specific. put somewhere else, please. */
|
||||
void processorders(void);
|
||||
|
@ -45,9 +46,19 @@ extern "C" {
|
|||
extern int dropouts[2];
|
||||
extern int *age;
|
||||
|
||||
extern int enter_building(struct unit *u, struct order *ord, int id, int report);
|
||||
extern int enter_ship(struct unit *u, struct order *ord, int id, int report);
|
||||
|
||||
extern void new_units(void);
|
||||
extern void defaultorders(void);
|
||||
extern void quit(void);
|
||||
extern void update_long_order(struct unit * u);
|
||||
extern void monthly_healing(void);
|
||||
extern void renumber_factions(void);
|
||||
extern void restack_units(void);
|
||||
extern void update_long_order(struct unit *u);
|
||||
extern void sinkships(struct region * r);
|
||||
extern void do_enter(struct region *r, bool is_final_attempt);
|
||||
|
||||
extern int password_cmd(struct unit *u, struct order *ord);
|
||||
extern int banner_cmd(struct unit *u, struct order *ord);
|
||||
extern int email_cmd(struct unit *u, struct order *ord);
|
||||
|
@ -61,7 +72,22 @@ extern "C" {
|
|||
extern int origin_cmd(struct unit *u, struct order *ord);
|
||||
extern int quit_cmd(struct unit *u, struct order *ord);
|
||||
extern int name_cmd(struct unit *u, struct order *ord);
|
||||
|
||||
extern int use_cmd(struct unit *u, struct order *ord);
|
||||
extern int siege_cmd(struct unit *u, struct order *ord);
|
||||
extern int leave_cmd(struct unit *u, struct order *ord);
|
||||
extern int pay_cmd(struct unit *u, struct order *ord);
|
||||
extern int promotion_cmd(struct unit *u, struct order *ord);
|
||||
extern int renumber_cmd(struct unit *u, struct order *ord);
|
||||
extern int combatspell_cmd(struct unit *u, struct order *ord);
|
||||
extern int contact_cmd(struct unit *u, struct order *ord);
|
||||
extern int guard_on_cmd(struct unit *u, struct order *ord);
|
||||
extern int guard_off_cmd(struct unit *u, struct order *ord);
|
||||
extern int reshow_cmd(struct unit *u, struct order *ord);
|
||||
extern int mail_cmd(struct unit *u, struct order *ord);
|
||||
extern int reserve_cmd(struct unit *u, struct order *ord);
|
||||
extern int claim_cmd(struct unit *u, struct order *ord);
|
||||
extern int follow_cmd(struct unit *u, struct order *ord);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -70,7 +70,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#define MAXILLUSION_TEXTS 3
|
||||
|
||||
boolean monster_is_waiting(const unit * u)
|
||||
bool monster_is_waiting(const unit * u)
|
||||
{
|
||||
if (fval(u, UFL_ISNEW | UFL_MOVED))
|
||||
return true;
|
||||
|
|
|
@ -23,7 +23,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
void monster_kills_peasants(struct unit *u);
|
||||
boolean monster_is_waiting(const struct unit *u);
|
||||
bool monster_is_waiting(const struct unit *u);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ static void dissolve_units(void)
|
|||
static int improve_all(faction * f, skill_t sk, int by_weeks)
|
||||
{
|
||||
unit *u;
|
||||
boolean ret = by_weeks;
|
||||
bool ret = by_weeks;
|
||||
|
||||
for (u = f->units; u; u = u->nextF) {
|
||||
if (has_skill(u, sk)) {
|
||||
|
@ -596,7 +596,7 @@ static int nb_armor(const unit * u, int index)
|
|||
}
|
||||
|
||||
static int
|
||||
damage_unit(unit * u, const char *dam, boolean physical, boolean magic)
|
||||
damage_unit(unit * u, const char *dam, bool physical, bool magic)
|
||||
{
|
||||
int *hp = malloc(u->number * sizeof(int));
|
||||
int h;
|
||||
|
@ -980,7 +980,7 @@ void create_icebergs(void)
|
|||
|
||||
for (r = regions; r; r = r->next) {
|
||||
if (r->terrain == newterrain(T_ICEBERG_SLEEP) && chance(0.05)) {
|
||||
boolean has_ocean_neighbour = false;
|
||||
bool has_ocean_neighbour = false;
|
||||
direction_t dir;
|
||||
region *rc;
|
||||
unit *u;
|
||||
|
@ -1062,7 +1062,7 @@ static void orc_growth(void)
|
|||
for (r = regions; r; r = r->next) {
|
||||
unit *u;
|
||||
for (u = r->units; u; u = u->next) {
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
static const curse_type *ct_orcish = 0;
|
||||
curse *c = 0;
|
||||
if (!init) {
|
||||
|
|
|
@ -38,6 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
/* kernel includes */
|
||||
#include <kernel/alchemy.h>
|
||||
#include <kernel/ally.h>
|
||||
#include <kernel/connection.h>
|
||||
#include <kernel/build.h>
|
||||
#include <kernel/building.h>
|
||||
|
@ -134,7 +135,7 @@ void rnl(FILE * F)
|
|||
fputc('\n', F);
|
||||
}
|
||||
|
||||
static void centre(FILE * F, const char *s, boolean breaking)
|
||||
static void centre(FILE * F, const char *s, bool breaking)
|
||||
{
|
||||
/* Bei Namen die genau 80 Zeichen lang sind, kann es hier Probleme
|
||||
* geben. Seltsamerweise wird i dann auf MAXINT oder aehnlich
|
||||
|
@ -217,12 +218,25 @@ rparagraph(FILE * F, const char *str, ptrdiff_t indent, int hanging_indent,
|
|||
} while (*begin);
|
||||
}
|
||||
|
||||
static size_t write_spell_modifier(spell * sp, int flag, const char * str, bool cont, char * bufp, size_t size) {
|
||||
if (sp->sptyp & flag) {
|
||||
size_t bytes = 0;
|
||||
if (cont) {
|
||||
bytes = strlcpy(bufp, ", ", size);
|
||||
} else {
|
||||
bytes = strlcpy(bufp, " ", size);
|
||||
}
|
||||
bytes += strlcpy(bufp+bytes, str, size-bytes);
|
||||
return bytes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
||||
{
|
||||
int bytes, k, itemanz, costtyp;
|
||||
int dh = 0;
|
||||
char buf[4096];
|
||||
char *bufp = buf;
|
||||
char *startp, *bufp = buf;
|
||||
size_t size = sizeof(buf) - 1;
|
||||
spell * sp = sbe->sp;
|
||||
const char *params = sp->parameter;
|
||||
|
@ -296,52 +310,29 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
|
|||
bytes = (int)strlcpy(buf, LOC(lang, "nr_spell_modifiers"), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
if (sp->sptyp & FARCASTING) {
|
||||
bytes = (int)strlcpy(bufp, " Fernzauber", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
dh = 1;
|
||||
|
||||
startp = bufp;
|
||||
bytes = (int)write_spell_modifier(sp, FARCASTING, LOC(lang, "smod_far"), startp!=bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
if (sp->sptyp & OCEANCASTABLE) {
|
||||
if (dh == 1) {
|
||||
bytes = (int)strlcpy(bufp, ",", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes = (int)write_spell_modifier(sp, OCEANCASTABLE, LOC(lang, "smod_sea"), startp!=bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)write_spell_modifier(sp, ONSHIPCAST, LOC(lang, "smod_ship"), startp!=bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_nofamiliar"), startp!=bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
if (startp==bufp) {
|
||||
bytes = (int)write_spell_modifier(sp, NOTFAMILIARCAST, LOC(lang, "smod_none"), startp!=bufp, bufp, size);
|
||||
if (bytes && wrptr(&bufp, &size, bytes) != 0) {
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)strlcpy(bufp, " Seezauber", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
dh = 1;
|
||||
}
|
||||
if (sp->sptyp & ONSHIPCAST) {
|
||||
if (dh == 1) {
|
||||
bytes = (int)strlcpy(bufp, ",", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)strlcpy(bufp, " Schiffszauber", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
dh = 1;
|
||||
}
|
||||
if (sp->sptyp & NOTFAMILIARCAST) {
|
||||
if (dh == 1) {
|
||||
bytes = (int)strlcpy(bufp, ", k", size);
|
||||
} else {
|
||||
bytes = (int)strlcpy(bufp, " K", size);
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
bytes =
|
||||
(int)strlcpy(bufp, "ann nicht vom Vertrauten gezaubert werden", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
dh = 1;
|
||||
}
|
||||
if (dh == 0) {
|
||||
bytes = (int)strlcpy(bufp, " Keine", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
*bufp = 0;
|
||||
rparagraph(F, buf, 0, 0, 0);
|
||||
|
@ -698,7 +689,7 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
attrib *a_otherfaction;
|
||||
char marker;
|
||||
int dh;
|
||||
boolean isbattle = (boolean) (mode == see_battle);
|
||||
bool isbattle = (bool) (mode == see_battle);
|
||||
char buf[8192];
|
||||
|
||||
if (fval(u->race, RCF_INVISIBLE))
|
||||
|
@ -735,7 +726,7 @@ nr_unit(FILE * F, const faction * f, const unit * u, int indent, int mode)
|
|||
|
||||
static void
|
||||
rp_messages(FILE * F, message_list * msgs, faction * viewer, int indent,
|
||||
boolean categorized)
|
||||
bool categorized)
|
||||
{
|
||||
nrsection *section;
|
||||
if (!msgs)
|
||||
|
@ -866,9 +857,9 @@ static void prices(FILE * F, const region * r, const faction * f)
|
|||
|
||||
}
|
||||
|
||||
boolean see_border(const connection * b, const faction * f, const region * r)
|
||||
bool see_border(const connection * b, const faction * f, const region * r)
|
||||
{
|
||||
boolean cs = b->type->fvisible(b, f, r);
|
||||
bool cs = b->type->fvisible(b, f, r);
|
||||
if (!cs) {
|
||||
cs = b->type->rvisible(b, r);
|
||||
if (!cs) {
|
||||
|
@ -890,7 +881,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
{
|
||||
const region *r = sr->r;
|
||||
int n;
|
||||
boolean dh;
|
||||
bool dh;
|
||||
direction_t d;
|
||||
int trees;
|
||||
int saplings;
|
||||
|
@ -899,12 +890,12 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
struct edge {
|
||||
struct edge *next;
|
||||
char *name;
|
||||
boolean transparent;
|
||||
boolean block;
|
||||
boolean exist[MAXDIRECTIONS];
|
||||
bool transparent;
|
||||
bool block;
|
||||
bool exist[MAXDIRECTIONS];
|
||||
direction_t lastd;
|
||||
} *edges = NULL, *e;
|
||||
boolean see[MAXDIRECTIONS];
|
||||
bool see[MAXDIRECTIONS];
|
||||
char buf[8192];
|
||||
char *bufp = buf;
|
||||
size_t size = sizeof(buf);
|
||||
|
@ -919,7 +910,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
continue;
|
||||
for (b = get_borders(r, r2); b;) {
|
||||
struct edge *e = edges;
|
||||
boolean transparent = b->type->transparent(b, f);
|
||||
bool transparent = b->type->transparent(b, f);
|
||||
const char *name = b->type->name(b, r, f, GF_DETAILED | GF_ARTICLE);
|
||||
|
||||
if (!transparent)
|
||||
|
@ -948,11 +939,11 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
WARN_STATIC_BUFFER();
|
||||
|
||||
if (sr->mode == see_travel) {
|
||||
bytes = (int)strlcpy(bufp, " (durchgereist)", size);
|
||||
bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel"));
|
||||
} else if (sr->mode == see_neighbour) {
|
||||
bytes = (int)strlcpy(bufp, " (benachbart)", size);
|
||||
bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
|
||||
} else if (sr->mode == see_lighthouse) {
|
||||
bytes = (int)strlcpy(bufp, " (vom Turm erblickt)", size);
|
||||
bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse"));
|
||||
} else {
|
||||
bytes = 0;
|
||||
}
|
||||
|
@ -1235,7 +1226,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
|
|||
if (edges)
|
||||
rnl(F);
|
||||
for (e = edges; e; e = e->next) {
|
||||
boolean first = true;
|
||||
bool first = true;
|
||||
bufp = buf;
|
||||
size = sizeof(buf) - 1;
|
||||
for (d = 0; d != MAXDIRECTIONS; ++d) {
|
||||
|
@ -1440,9 +1431,9 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
|
|||
}
|
||||
/* TODO: finish localization */
|
||||
if (maxtravel == 1) {
|
||||
bytes = (int)strlcpy(bufp, " hat die Region durchquert.", size);
|
||||
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_one"));
|
||||
} else {
|
||||
bytes = (int)strlcpy(bufp, " haben die Region durchquert.", size);
|
||||
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_many"));
|
||||
}
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
|
@ -1455,7 +1446,7 @@ static int buildingmaintenance(const building * b, const resource_type * rtype)
|
|||
{
|
||||
const building_type *bt = b->type;
|
||||
int c, cost = 0;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
static const curse_type *nocost_ct;
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
@ -1735,9 +1726,9 @@ static void allies(FILE * F, const faction * f)
|
|||
int bytes;
|
||||
size_t size = sizeof(buf);
|
||||
if (!f->allies->next) {
|
||||
bytes = (int)strlcpy(buf, "Wir helfen der Partei ", size);
|
||||
bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_one"));
|
||||
} else {
|
||||
bytes = (int)strlcpy(buf, "Wir helfen den Parteien ", size);
|
||||
bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_many"));
|
||||
}
|
||||
size -= bytes;
|
||||
show_allies(f, f->allies, buf + bytes, size);
|
||||
|
@ -1750,9 +1741,9 @@ static void allies(FILE * F, const faction * f)
|
|||
int bytes;
|
||||
size_t size = sizeof(buf);
|
||||
if (!g->allies->next) {
|
||||
bytes = snprintf(buf, size, "%s hilft der Partei ", g->name);
|
||||
bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_one"));
|
||||
} else {
|
||||
bytes = snprintf(buf, size, "%s hilft den Parteien ", g->name);
|
||||
bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_many"));
|
||||
}
|
||||
size -= bytes;
|
||||
show_allies(f, g->allies, buf + bytes, size);
|
||||
|
@ -1775,7 +1766,7 @@ static void guards(FILE * F, const region * r, const faction * see)
|
|||
unit *u;
|
||||
int i;
|
||||
|
||||
boolean tarned = false;
|
||||
bool tarned = false;
|
||||
/* Bewachung */
|
||||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
|
@ -2579,7 +2570,7 @@ static void add_find(faction * f, unit * u, faction * f2)
|
|||
static void update_find(void)
|
||||
{
|
||||
region *r;
|
||||
static boolean initial = true;
|
||||
static bool initial = true;
|
||||
|
||||
if (initial)
|
||||
for (r = regions; r; r = r->next) {
|
||||
|
@ -2601,10 +2592,10 @@ static void update_find(void)
|
|||
initial = false;
|
||||
}
|
||||
|
||||
boolean kann_finden(faction * f1, faction * f2)
|
||||
bool kann_finden(faction * f1, faction * f2)
|
||||
{
|
||||
update_find();
|
||||
return (boolean) (can_find(f1, f2) != NULL);
|
||||
return (bool) (can_find(f1, f2) != NULL);
|
||||
}
|
||||
|
||||
/******* end summary ******/
|
||||
|
|
|
@ -19,15 +19,16 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <platform.h>
|
||||
#include <kernel/config.h>
|
||||
#include "spy.h"
|
||||
#include "laws.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include <kernel/build.h>
|
||||
#include <kernel/reports.h>
|
||||
#include <kernel/item.h>
|
||||
#include <kernel/faction.h>
|
||||
#include <kernel/magic.h>
|
||||
#include <kernel/message.h>
|
||||
#include <kernel/move.h>
|
||||
#include <kernel/order.h>
|
||||
#include <kernel/race.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
|
|
|
@ -87,7 +87,7 @@ magic_t getmagicskill(const struct locale * lang)
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
/* Vertraute und Kröten sind keine Migranten */
|
||||
boolean is_migrant(unit * u)
|
||||
bool is_migrant(unit * u)
|
||||
{
|
||||
if (u->race == u->faction->race)
|
||||
return false;
|
||||
|
@ -103,7 +103,7 @@ boolean is_migrant(unit * u)
|
|||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
boolean magic_lowskill(unit * u)
|
||||
bool magic_lowskill(unit * u)
|
||||
{
|
||||
return (u->race == new_race[RC_TOAD]) ? true : false;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ static int study_days(unit * student, skill_t sk)
|
|||
|
||||
static int
|
||||
teach_unit(unit * teacher, unit * student, int nteaching, skill_t sk,
|
||||
boolean report, int *academy)
|
||||
bool report, int *academy)
|
||||
{
|
||||
teaching_info *teach = NULL;
|
||||
attrib *a;
|
||||
|
@ -393,7 +393,7 @@ int teach_cmd(unit * u, struct order *ord)
|
|||
|
||||
while (!parser_end()) {
|
||||
unit *u2 = getunit(r, u->faction);
|
||||
boolean feedback;
|
||||
bool feedback;
|
||||
++count;
|
||||
|
||||
/* Falls die Unit nicht gefunden wird, Fehler melden */
|
||||
|
@ -763,7 +763,7 @@ int learn_cmd(unit * u, order * ord)
|
|||
while (teach->teachers[index] && index != MAXTEACHERS) {
|
||||
unit *teacher = teach->teachers[index++];
|
||||
if (teacher->faction != u->faction) {
|
||||
boolean feedback = alliedunit(u, teacher->faction, HELP_GUARD);
|
||||
bool feedback = alliedunit(u, teacher->faction, HELP_GUARD);
|
||||
if (feedback) {
|
||||
ADDMSG(&teacher->faction->msgs, msg_message("teach_teacher",
|
||||
"teacher student skill level", teacher, u, sk,
|
||||
|
|
|
@ -27,7 +27,7 @@ extern "C" {
|
|||
extern int learn_cmd(struct unit *u, struct order *ord);
|
||||
|
||||
extern magic_t getmagicskill(const struct locale *lang);
|
||||
extern boolean is_migrant(struct unit *u);
|
||||
extern bool is_migrant(struct unit *u);
|
||||
extern int study_cost(struct unit *u, skill_t talent);
|
||||
|
||||
#define MAXTEACHERS 4
|
||||
|
|
|
@ -132,7 +132,7 @@ static void writeturn(void)
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
void report_summary(summary * s, summary * o, boolean full)
|
||||
void report_summary(summary * s, summary * o, bool full)
|
||||
{
|
||||
FILE *F = NULL;
|
||||
int i, newplayers = 0;
|
||||
|
|
|
@ -17,7 +17,7 @@ extern "C" {
|
|||
|
||||
struct summary;
|
||||
extern void report_summary(struct summary *n, struct summary *o,
|
||||
boolean full);
|
||||
bool full);
|
||||
extern struct summary *make_summary(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -31,6 +31,7 @@ without prior permission by the authors of Eressea.
|
|||
/* kernel includes */
|
||||
#include <kernel/alchemy.h>
|
||||
#include <kernel/alliance.h>
|
||||
#include <kernel/ally.h>
|
||||
#include <kernel/connection.h>
|
||||
#include <kernel/curse.h>
|
||||
#include <kernel/building.h>
|
||||
|
@ -213,10 +214,10 @@ static xmlNodePtr xml_unit(report_context * ctx, unit * u, int mode)
|
|||
xml_context *xct = (xml_context *) ctx->userdata;
|
||||
xmlNodePtr node = xmlNewNode(xct->ns_atl, BAD_CAST "unit");
|
||||
static const curse_type *itemcloak_ct = 0;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
xmlNodePtr child;
|
||||
const char *str, *rcname, *rcillusion;
|
||||
boolean disclosure = (ctx->f == u->faction || omniscient(ctx->f));
|
||||
bool disclosure = (ctx->f == u->faction || omniscient(ctx->f));
|
||||
|
||||
/* TODO: hitpoints, aura, combatspells, curses */
|
||||
|
||||
|
@ -391,7 +392,7 @@ static xmlNodePtr xml_unit(report_context * ctx, unit * u, int mode)
|
|||
if (disclosure) {
|
||||
show = u->items;
|
||||
} else {
|
||||
boolean see_items = (mode >= see_unit);
|
||||
bool see_items = (mode >= see_unit);
|
||||
if (see_items) {
|
||||
if (itemcloak_ct && curse_active(get_curse(u->attribs, itemcloak_ct))) {
|
||||
see_items = false;
|
||||
|
|
|
@ -356,7 +356,7 @@ static void paint_status(window * wnd, const state * st)
|
|||
wclrtoeol(win);
|
||||
}
|
||||
|
||||
static boolean handle_info_region(window * wnd, state * st, int c)
|
||||
static bool handle_info_region(window * wnd, state * st, int c)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ curses_readline(struct lua_State *L, char *buffer, size_t size,
|
|||
return buffer[0] != 0;
|
||||
}
|
||||
|
||||
void seed_players(const char *filename, boolean new_island)
|
||||
void seed_players(const char *filename, bool new_island)
|
||||
{
|
||||
newfaction *players = read_newfactions(filename);
|
||||
if (players != NULL) {
|
||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
|||
void state_close(struct state *);
|
||||
|
||||
void make_block(int x, int y, int radius, const struct terrain_type *terrain);
|
||||
void seed_players(const char *filename, boolean new_island);
|
||||
void seed_players(const char *filename, bool new_island);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -70,13 +70,13 @@ extern "C" {
|
|||
} state;
|
||||
|
||||
typedef struct window {
|
||||
boolean(*handlekey) (struct window * win, struct state * st, int key);
|
||||
bool(*handlekey) (struct window * win, struct state * st, int key);
|
||||
void (*paint) (struct window * win, const struct state * st);
|
||||
|
||||
WINDOW *handle;
|
||||
struct window *next;
|
||||
struct window *prev;
|
||||
boolean initialized;
|
||||
bool initialized;
|
||||
int update;
|
||||
} window;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ use_phoenixcompass(struct unit *u, const struct item_type *itype,
|
|||
region *r;
|
||||
unit *closest_phoenix = NULL;
|
||||
int closest_phoenix_distance = INT_MAX;
|
||||
boolean confusion = false;
|
||||
bool confusion = false;
|
||||
direction_t direction;
|
||||
unit *u2;
|
||||
direction_t closest_neighbour_direction = 0;
|
||||
|
|
|
@ -38,7 +38,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
/* damage types */
|
||||
|
||||
static boolean
|
||||
static bool
|
||||
attack_firesword(const troop * at, const struct weapon_type *wtype,
|
||||
int *casualties)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ attack_firesword(const troop * at, const struct weapon_type *wtype,
|
|||
|
||||
#define CATAPULT_ATTACKS 6
|
||||
|
||||
static boolean
|
||||
static bool
|
||||
attack_catapult(const troop * at, const struct weapon_type *wtype,
|
||||
int *casualties)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,7 @@ use_skillpotion(struct unit *u, const struct item_type *itype, int amount,
|
|||
while (sv != u->skills + u->skill_size) {
|
||||
int i;
|
||||
for (i = 0; i != 3; ++i)
|
||||
learn_skill(u, sv->id, 1.0);
|
||||
learn_skill(u, (skill_t)sv->id, 1.0);
|
||||
++sv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -452,7 +452,7 @@ int victorycondition(const alliance * al, const char *name)
|
|||
const struct item_type *itype = it_find(*igem);
|
||||
quicklist *flist = al->members;
|
||||
int qi;
|
||||
boolean found = false;
|
||||
bool found = false;
|
||||
|
||||
assert(itype != NULL);
|
||||
for (qi = 0; flist && !found; ql_advance(&flist, &qi, 1)) {
|
||||
|
|
|
@ -40,6 +40,8 @@ extern "C" {
|
|||
|
||||
#define ALF_NON_ALLIED (1<<0) /* this alliance is just a default for a non-allied faction */
|
||||
|
||||
#define ALLY_ENEMY (1<<0)
|
||||
|
||||
typedef struct alliance {
|
||||
struct alliance *next;
|
||||
struct faction *_leader;
|
||||
|
@ -47,6 +49,7 @@ extern "C" {
|
|||
unsigned int flags;
|
||||
int id;
|
||||
char *name;
|
||||
struct ally *allies;
|
||||
} alliance;
|
||||
|
||||
extern alliance *alliances;
|
||||
|
|
39
src/kernel/ally.c
Normal file
39
src/kernel/ally.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include "types.h"
|
||||
#include "ally.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
ally * ally_find(ally *al, const struct faction *f) {
|
||||
for (;al;al=al->next) {
|
||||
if (al->faction==f) return al;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ally * ally_add(ally **al_p, struct faction *f) {
|
||||
ally * al;
|
||||
while (*al_p) {
|
||||
al = *al_p;
|
||||
if (al->faction==f) return al;
|
||||
al_p = &al->next;
|
||||
}
|
||||
al = (ally *)malloc(sizeof(ally));
|
||||
al->faction = f;
|
||||
al->status = 0;
|
||||
al->next = 0;
|
||||
*al_p = al;
|
||||
return al;
|
||||
}
|
||||
|
||||
void ally_remove(ally **al_p, struct faction *f) {
|
||||
ally * al;
|
||||
while (*al_p) {
|
||||
al = *al_p;
|
||||
if (al->faction==f) {
|
||||
*al_p = al->next;
|
||||
free(al);
|
||||
break;
|
||||
}
|
||||
al_p = &al->next;
|
||||
}
|
||||
}
|
40
src/kernel/ally.h
Normal file
40
src/kernel/ally.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
||||
Katja Zedel <katze@felidae.kn-bremen.de
|
||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
**/
|
||||
|
||||
#ifndef ALLY_H
|
||||
#define ALLY_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ally {
|
||||
struct ally *next;
|
||||
struct faction *faction;
|
||||
int status;
|
||||
} ally;
|
||||
|
||||
ally * ally_find(ally *al, const struct faction *f);
|
||||
ally * ally_add(ally **al_p, struct faction *f);
|
||||
void ally_remove(ally **al_p, struct faction *f);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
27
src/kernel/ally_test.c
Normal file
27
src/kernel/ally_test.c
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <platform.h>
|
||||
#include "types.h"
|
||||
#include "ally.h"
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
||||
static void test_ally(CuTest * tc)
|
||||
{
|
||||
ally * al = 0;
|
||||
struct faction * f1 = test_create_faction(0);
|
||||
|
||||
ally_add(&al, f1);
|
||||
CuAssertPtrNotNull(tc, al);
|
||||
CuAssertPtrEquals(tc, f1, ally_find(al, f1)->faction);
|
||||
|
||||
ally_remove(&al, f1);
|
||||
CuAssertPtrEquals(tc, 0, al);
|
||||
CuAssertPtrEquals(tc, 0, ally_find(al, f1));
|
||||
}
|
||||
|
||||
CuSuite *get_ally_suite(void)
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_ally);
|
||||
return suite;
|
||||
}
|
|
@ -175,35 +175,6 @@ static int army_index(side * s)
|
|||
return s->index;
|
||||
}
|
||||
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
region *fleeregion(const unit * u)
|
||||
{
|
||||
region *r = u->region;
|
||||
region *neighbours[MAXDIRECTIONS];
|
||||
int c = 0;
|
||||
direction_t i;
|
||||
|
||||
if (u->ship && !fval(r->terrain, SEA_REGION))
|
||||
return NULL;
|
||||
|
||||
if (u->ship && !(u->race->flags & RCF_SWIM) && !(u->race->flags & RCF_FLY)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = 0; i != MAXDIRECTIONS; ++i) {
|
||||
region *r2 = rconnect(r, i);
|
||||
if (r2) {
|
||||
if (can_survive(u, r2) && !move_blocked(u, r, r2))
|
||||
neighbours[c++] = r2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!c)
|
||||
return NULL;
|
||||
return neighbours[rng_int() % c];
|
||||
}
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
|
||||
static char *sidename(side * s)
|
||||
{
|
||||
#define SIDENAMEBUFLEN 256
|
||||
|
@ -215,7 +186,7 @@ static char *sidename(side * s)
|
|||
return sidename_buf[bufno++];
|
||||
}
|
||||
|
||||
static const char *sideabkz(side * s, boolean truename)
|
||||
static const char *sideabkz(side * s, bool truename)
|
||||
{
|
||||
static char sideabkz_buf[8]; /* STATIC_RESULT: used for return, not across calls */
|
||||
const faction *f = (s->stealthfaction
|
||||
|
@ -235,7 +206,7 @@ static void message_faction(battle * b, faction * f, struct message *m)
|
|||
region *r = b->region;
|
||||
|
||||
if (f->battles == NULL || f->battles->r != r) {
|
||||
struct bmsg *bm = calloc(1, sizeof(struct bmsg));
|
||||
struct bmsg *bm = (struct bmsg *)calloc(1, sizeof(struct bmsg));
|
||||
bm->next = f->battles;
|
||||
f->battles = bm;
|
||||
bm->r = r;
|
||||
|
@ -243,7 +214,7 @@ static void message_faction(battle * b, faction * f, struct message *m)
|
|||
add_message(&f->battles->msgs, m);
|
||||
}
|
||||
|
||||
int armedmen(const unit * u, boolean siege_weapons)
|
||||
int armedmen(const unit * u, bool siege_weapons)
|
||||
{
|
||||
item *itm;
|
||||
int n = 0;
|
||||
|
@ -302,7 +273,7 @@ static void fbattlerecord(battle * b, faction * f, const char *s)
|
|||
#define enemy(as, ds) (as->relations[ds->index]&E_ENEMY)
|
||||
#define friendly(as, ds) (as->relations[ds->index]&E_FRIEND)
|
||||
|
||||
static boolean set_enemy(side * as, side * ds, boolean attacking)
|
||||
static bool set_enemy(side * as, side * ds, bool attacking)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i != MAXSIDES; ++i) {
|
||||
|
@ -395,11 +366,11 @@ fighter *select_corpse(battle * b, fighter * af)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean helping(const side * as, const side * ds)
|
||||
bool helping(const side * as, const side * ds)
|
||||
{
|
||||
if (as->faction == ds->faction)
|
||||
return true;
|
||||
return (boolean) (!enemy(as, ds) && allysf(as, ds->faction));
|
||||
return (bool) (!enemy(as, ds) && allysf(as, ds->faction));
|
||||
}
|
||||
|
||||
int statusrow(int status)
|
||||
|
@ -443,7 +414,7 @@ static double hpflee(int status)
|
|||
|
||||
static int get_row(const side * s, int row, const side * vs)
|
||||
{
|
||||
boolean counted[MAXSIDES];
|
||||
bool counted[MAXSIDES];
|
||||
int enemyfront = 0;
|
||||
int line, result;
|
||||
int retreat = 0;
|
||||
|
@ -508,7 +479,6 @@ int get_unitrow(const fighter * af, const side * vs)
|
|||
break;
|
||||
return FIGHT_ROW + (row - i);
|
||||
} else {
|
||||
#ifdef FASTROW
|
||||
battle *b = vs->battle;
|
||||
if (row != b->rowcache.row || b->alive != b->rowcache.alive
|
||||
|| af->side != b->rowcache.as || vs != b->rowcache.vs) {
|
||||
|
@ -526,9 +496,6 @@ int get_unitrow(const fighter * af, const side * vs)
|
|||
}
|
||||
#endif
|
||||
return b->rowcache.result;
|
||||
#else
|
||||
return get_row(af->side, row, vs);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -538,14 +505,6 @@ static void reportcasualties(battle * b, fighter * fig, int dead)
|
|||
region *r = NULL;
|
||||
if (fig->alive == fig->unit->number)
|
||||
return;
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
if (fig->run.region == NULL) {
|
||||
fig->run.region = fleeregion(fig->unit);
|
||||
if (fig->run.region == NULL)
|
||||
fig->run.region = b->region;
|
||||
}
|
||||
r = fig->run.region;
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
m = msg_message("casualties", "unit runto run alive fallen",
|
||||
fig->unit, r, fig->run.number, fig->alive, dead);
|
||||
message_all(b, m);
|
||||
|
@ -601,7 +560,7 @@ contest(int skdiff, const troop dt, const armor_type * ar,
|
|||
}
|
||||
}
|
||||
|
||||
static boolean is_riding(const troop t)
|
||||
static bool is_riding(const troop t)
|
||||
{
|
||||
if (t.fighter->building != NULL)
|
||||
return false;
|
||||
|
@ -610,7 +569,7 @@ static boolean is_riding(const troop t)
|
|||
return false;
|
||||
}
|
||||
|
||||
static weapon *preferred_weapon(const troop t, boolean attacking)
|
||||
static weapon *preferred_weapon(const troop t, bool attacking)
|
||||
{
|
||||
weapon *missile = t.fighter->person[t.index].missile;
|
||||
weapon *melee = t.fighter->person[t.index].melee;
|
||||
|
@ -627,8 +586,8 @@ static weapon *preferred_weapon(const troop t, boolean attacking)
|
|||
return melee;
|
||||
}
|
||||
|
||||
static weapon *select_weapon(const troop t, boolean attacking,
|
||||
boolean ismissile)
|
||||
static weapon *select_weapon(const troop t, bool attacking,
|
||||
bool ismissile)
|
||||
/* select the primary weapon for this trooper */
|
||||
{
|
||||
if (attacking) {
|
||||
|
@ -645,7 +604,7 @@ static weapon *select_weapon(const troop t, boolean attacking,
|
|||
return preferred_weapon(t, attacking);
|
||||
}
|
||||
|
||||
static boolean i_canuse(const unit * u, const item_type * itype)
|
||||
static bool i_canuse(const unit * u, const item_type * itype)
|
||||
{
|
||||
if (itype->canuse) {
|
||||
return itype->canuse(u, itype);
|
||||
|
@ -654,7 +613,7 @@ static boolean i_canuse(const unit * u, const item_type * itype)
|
|||
}
|
||||
|
||||
static int
|
||||
weapon_skill(const weapon_type * wtype, const unit * u, boolean attacking)
|
||||
weapon_skill(const weapon_type * wtype, const unit * u, bool attacking)
|
||||
/* the 'pure' skill when using this weapon to attack or defend.
|
||||
* only undiscriminate modifiers (not affected by troops or enemies)
|
||||
* are taken into account, e.g. no horses, magic, etc. */
|
||||
|
@ -770,8 +729,8 @@ static int CavalryBonus(const unit * u, troop enemy, int type)
|
|||
}
|
||||
|
||||
static int
|
||||
weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking,
|
||||
boolean missile)
|
||||
weapon_effskill(troop t, troop enemy, const weapon * w, bool attacking,
|
||||
bool missile)
|
||||
/* effektiver Waffenskill während des Kampfes */
|
||||
{
|
||||
/* In dieser Runde alle die Modifier berechnen, die fig durch die
|
||||
|
@ -851,7 +810,7 @@ weapon_effskill(troop t, troop enemy, const weapon * w, boolean attacking,
|
|||
return skill;
|
||||
}
|
||||
|
||||
static const armor_type *select_armor(troop t, boolean shield)
|
||||
static const armor_type *select_armor(troop t, bool shield)
|
||||
{
|
||||
unsigned int type = shield ? ATF_SHIELD : 0;
|
||||
unit *u = t.fighter->unit;
|
||||
|
@ -899,7 +858,7 @@ int select_magicarmor(troop t)
|
|||
}
|
||||
|
||||
/* Sind side ds und Magier des meffect verbündet, dann return 1*/
|
||||
boolean meffect_protection(battle * b, meffect * s, side * ds)
|
||||
bool meffect_protection(battle * b, meffect * s, side * ds)
|
||||
{
|
||||
if (!s->magician->alive)
|
||||
return false;
|
||||
|
@ -913,7 +872,7 @@ boolean meffect_protection(battle * b, meffect * s, side * ds)
|
|||
}
|
||||
|
||||
/* Sind side as und Magier des meffect verfeindet, dann return 1*/
|
||||
boolean meffect_blocked(battle * b, meffect * s, side * as)
|
||||
bool meffect_blocked(battle * b, meffect * s, side * as)
|
||||
{
|
||||
if (!s->magician->alive)
|
||||
return false;
|
||||
|
@ -973,12 +932,8 @@ void remove_troop(troop dt)
|
|||
fighter *df = dt.fighter;
|
||||
struct person p = df->person[dt.index];
|
||||
battle *b = df->side->battle;
|
||||
#ifdef FASTCOUNT
|
||||
b->fast.alive = -1; /* invalidate cached value */
|
||||
#endif
|
||||
#ifdef FASTROW
|
||||
b->rowcache.alive = -1; /* invalidate cached value */
|
||||
#endif
|
||||
++df->removed;
|
||||
++df->side->removed;
|
||||
df->person[dt.index] = df->person[df->alive - df->removed];
|
||||
|
@ -1096,8 +1051,8 @@ static int natural_armor(unit * du)
|
|||
return an;
|
||||
}
|
||||
|
||||
boolean
|
||||
terminate(troop dt, troop at, int type, const char *damage, boolean missile)
|
||||
bool
|
||||
terminate(troop dt, troop at, int type, const char *damage, bool missile)
|
||||
{
|
||||
item **pitm;
|
||||
fighter *df = dt.fighter;
|
||||
|
@ -1121,13 +1076,11 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
|
|||
const weapon *weapon;
|
||||
|
||||
int rda, sk = 0, sd;
|
||||
boolean magic = false;
|
||||
bool magic = false;
|
||||
int da = dice_rand(damage);
|
||||
|
||||
assert(du->number > 0);
|
||||
#ifdef SHOW_KILLS
|
||||
++at.fighter->hits;
|
||||
#endif
|
||||
|
||||
switch (type) {
|
||||
case AT_STANDARD:
|
||||
|
@ -1364,9 +1317,7 @@ terminate(troop dt, troop at, int type, const char *damage, boolean missile)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
#ifdef SHOW_KILLS
|
||||
++at.fighter->kills;
|
||||
#endif
|
||||
|
||||
if (bdebug) {
|
||||
fprintf(bdebug, "Damage %d, armor %d, type %d: %d -> %d HP, tot.\n",
|
||||
|
@ -1468,7 +1419,6 @@ int
|
|||
count_enemies(battle * b, const fighter * af, int minrow, int maxrow,
|
||||
int select)
|
||||
{
|
||||
#ifdef FASTCOUNT
|
||||
int sr = statusrow(af->status);
|
||||
side *as = af->side;
|
||||
|
||||
|
@ -1497,12 +1447,9 @@ count_enemies(battle * b, const fighter * af, int minrow, int maxrow,
|
|||
b->fast.maxrow = maxrow;
|
||||
memset(b->fast.enemies, -1, sizeof(b->fast.enemies));
|
||||
}
|
||||
#endif
|
||||
if (maxrow >= FIRST_ROW) {
|
||||
int i = count_enemies_i(b, af, minrow, maxrow, select);
|
||||
#ifdef FASTCOUNT
|
||||
b->fast.enemies[select] = i;
|
||||
#endif
|
||||
return i;
|
||||
}
|
||||
return 0;
|
||||
|
@ -1788,14 +1735,6 @@ void do_combatmagic(battle * b, combatmagic_t was)
|
|||
}
|
||||
}
|
||||
|
||||
static void combat_action(fighter * af)
|
||||
{
|
||||
#ifndef SIMPLE_COMBAT
|
||||
af->action_counter++;
|
||||
af->side->bf->lastturn = af->side->battle->turn;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int cast_combatspell(troop at, const spell * sp, int level, double force)
|
||||
{
|
||||
castorder co;
|
||||
|
@ -1806,7 +1745,6 @@ static int cast_combatspell(troop at, const spell * sp, int level, double force)
|
|||
free_castorder(&co);
|
||||
if (level > 0) {
|
||||
pay_spell(at.fighter->unit, sp, level, 1);
|
||||
combat_action(at.fighter);
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
@ -1926,7 +1864,7 @@ int skilldiff(troop at, troop dt, int dist)
|
|||
}
|
||||
|
||||
if (df->building) {
|
||||
boolean init = false;
|
||||
bool init = false;
|
||||
static const curse_type *strongwall_ct, *magicwalls_ct;
|
||||
if (!init) {
|
||||
strongwall_ct = ct_find("strongwall");
|
||||
|
@ -1996,7 +1934,7 @@ int getreload(troop at)
|
|||
|
||||
static void
|
||||
debug_hit(troop at, const weapon * awp, troop dt, const weapon * dwp,
|
||||
int skdiff, int dist, boolean success)
|
||||
int skdiff, int dist, bool success)
|
||||
{
|
||||
fprintf(bdebug, "%.4s/%d [%6s/%d] %s %.4s/%d [%6s/%d] with %d, distance %d\n",
|
||||
unitid(at.fighter->unit), at.index,
|
||||
|
@ -2174,8 +2112,8 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
if (getreload(ta)) {
|
||||
ta.fighter->person[ta.index].reload--;
|
||||
} else {
|
||||
boolean standard_attack = true;
|
||||
boolean reload = false;
|
||||
bool standard_attack = true;
|
||||
bool reload = false;
|
||||
/* spezialattacken der waffe nur, wenn erste attacke in der runde.
|
||||
* sonst helden mit feuerschwertern zu mächtig */
|
||||
if (numattack == 0 && wp && wp->type->attack) {
|
||||
|
@ -2186,11 +2124,10 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
af->catmsg += dead;
|
||||
if (!standard_attack && af->person[ta.index].last_action < b->turn) {
|
||||
af->person[ta.index].last_action = b->turn;
|
||||
combat_action(af);
|
||||
}
|
||||
}
|
||||
if (standard_attack) {
|
||||
boolean missile = false;
|
||||
bool missile = false;
|
||||
if (wp && fval(wp->type, WTF_MISSILE))
|
||||
missile = true;
|
||||
if (missile) {
|
||||
|
@ -2202,7 +2139,6 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
return;
|
||||
if (ta.fighter->person[ta.index].last_action < b->turn) {
|
||||
ta.fighter->person[ta.index].last_action = b->turn;
|
||||
combat_action(ta.fighter);
|
||||
}
|
||||
reload = true;
|
||||
if (hits(ta, td, wp)) {
|
||||
|
@ -2235,7 +2171,6 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
return;
|
||||
if (ta.fighter->person[ta.index].last_action < b->turn) {
|
||||
ta.fighter->person[ta.index].last_action = b->turn;
|
||||
combat_action(ta.fighter);
|
||||
}
|
||||
if (hits(ta, td, NULL)) {
|
||||
terminate(td, ta, a->type, a->data.dice, false);
|
||||
|
@ -2247,7 +2182,6 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
return;
|
||||
if (ta.fighter->person[ta.index].last_action < b->turn) {
|
||||
ta.fighter->person[ta.index].last_action = b->turn;
|
||||
combat_action(ta.fighter);
|
||||
}
|
||||
if (hits(ta, td, NULL)) {
|
||||
int c = dice_rand(a->data.dice);
|
||||
|
@ -2267,7 +2201,6 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
return;
|
||||
if (ta.fighter->person[ta.index].last_action < b->turn) {
|
||||
ta.fighter->person[ta.index].last_action = b->turn;
|
||||
combat_action(ta.fighter);
|
||||
}
|
||||
if (hits(ta, td, NULL)) {
|
||||
drain_exp(td.fighter->unit, dice_rand(a->data.dice));
|
||||
|
@ -2279,7 +2212,6 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
return;
|
||||
if (ta.fighter->person[ta.index].last_action < b->turn) {
|
||||
ta.fighter->person[ta.index].last_action = b->turn;
|
||||
combat_action(ta.fighter);
|
||||
}
|
||||
if (hits(ta, td, NULL)) {
|
||||
dazzle(b, &td);
|
||||
|
@ -2291,7 +2223,6 @@ static void attack(battle * b, troop ta, const att * a, int numattack)
|
|||
return;
|
||||
if (ta.fighter->person[ta.index].last_action < b->turn) {
|
||||
ta.fighter->person[ta.index].last_action = b->turn;
|
||||
combat_action(ta.fighter);
|
||||
}
|
||||
if (td.fighter->unit->ship) {
|
||||
/* FIXME should use damage_ship here? */
|
||||
|
@ -2453,7 +2384,6 @@ side *make_side(battle * b, const faction * f, const group * g,
|
|||
side *s1 = b->sides + b->nsides;
|
||||
bfaction *bf;
|
||||
|
||||
#ifdef SIMPLE_COMBAT
|
||||
if (fval(b->region->terrain, SEA_REGION)) {
|
||||
/* every fight in an ocean is short */
|
||||
flags |= SIDE_HASGUARDS;
|
||||
|
@ -2468,7 +2398,6 @@ side *make_side(battle * b, const faction * f, const group * g,
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
s1->battle = b;
|
||||
s1->group = g;
|
||||
|
@ -2631,23 +2560,7 @@ static void loot_items(fighter * corpse)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
static void loot_fleeing(fighter * fig, unit * runner)
|
||||
{
|
||||
/* TODO: Vernünftig fixen */
|
||||
runner->items = NULL;
|
||||
assert(runner->items == NULL);
|
||||
runner->items = fig->run.items;
|
||||
fig->run.items = NULL;
|
||||
}
|
||||
|
||||
static void merge_fleeloot(fighter * fig, unit * u)
|
||||
{
|
||||
i_merge(&u->items, &fig->run.items);
|
||||
}
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
|
||||
static boolean seematrix(const faction * f, const side * s)
|
||||
static bool seematrix(const faction * f, const side * s)
|
||||
{
|
||||
if (f == s->faction)
|
||||
return true;
|
||||
|
@ -2713,7 +2626,7 @@ static void aftermath(battle * b)
|
|||
side *s;
|
||||
int dead_players = 0;
|
||||
bfaction *bf;
|
||||
boolean ships_damaged = (boolean) (b->turn + (b->has_tactics_turn ? 1 : 0) > 2); /* only used for ship damage! */
|
||||
bool ships_damaged = (bool) (b->turn + (b->has_tactics_turn ? 1 : 0) > 2); /* only used for ship damage! */
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *df;
|
||||
|
@ -2743,7 +2656,6 @@ static void aftermath(battle * b)
|
|||
if (playerrace(df->unit->race)) {
|
||||
s->casualties += dead;
|
||||
}
|
||||
#ifdef SHOW_KILLS
|
||||
if (df->hits + df->kills) {
|
||||
struct message *m =
|
||||
msg_message("killsandhits", "unit hits kills", du, df->hits,
|
||||
|
@ -2751,7 +2663,6 @@ static void aftermath(battle * b)
|
|||
message_faction(b, du->faction, m);
|
||||
msg_release(m);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2761,23 +2672,10 @@ static void aftermath(battle * b)
|
|||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
int snumber = 0;
|
||||
fighter *df;
|
||||
boolean relevant = false; /* Kampf relevant für diese Partei? */
|
||||
#ifdef SIMPLE_COMBAT
|
||||
if (fval(s, SIDE_HASGUARDS) == 0)
|
||||
bool relevant = false; /* Kampf relevant für diese Partei? */
|
||||
if (!fval(s, SIDE_HASGUARDS)) {
|
||||
relevant = true;
|
||||
#else
|
||||
if (s->bf->lastturn > 1) {
|
||||
relevant = true;
|
||||
} else if (s->bf->lastturn == 1 && b->has_tactics_turn) {
|
||||
side *stac;
|
||||
for (stac = b->sides; stac; stac = stac->next) {
|
||||
if (stac->leader.value == b->max_tactics && helping(stac, s)) {
|
||||
relevant = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
s->flee = 0;
|
||||
|
||||
for (df = s->fighters; df; df = df->next) {
|
||||
|
@ -2792,13 +2690,11 @@ static void aftermath(battle * b)
|
|||
}
|
||||
}
|
||||
snumber += du->number;
|
||||
#ifdef SIMPLE_COMBAT
|
||||
if (relevant) {
|
||||
int flags = UFL_LONGACTION | UFL_NOTMOVING;
|
||||
#ifdef SIMPLE_ESCAPE
|
||||
if (du->status == ST_FLEE)
|
||||
if (du->status == ST_FLEE) {
|
||||
flags -= UFL_NOTMOVING;
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
}
|
||||
fset(du, flags);
|
||||
}
|
||||
if (sum_hp + df->run.hp < du->hp) {
|
||||
|
@ -2807,17 +2703,6 @@ static void aftermath(battle * b)
|
|||
if (sh)
|
||||
fset(sh, SF_DAMAGED);
|
||||
}
|
||||
#else
|
||||
if (relevant) {
|
||||
fset(du, UFL_NOTMOVING); /* unit cannot move this round */
|
||||
if (df->action_counter >= du->number) {
|
||||
ship *sh = du->ship ? du->ship : leftship(du);
|
||||
if (sh)
|
||||
fset(sh, SF_DAMAGED);
|
||||
fset(du, UFL_LONGACTION);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (df->alive == du->number) {
|
||||
du->hp = sum_hp;
|
||||
|
@ -2830,18 +2715,9 @@ static void aftermath(battle * b)
|
|||
/* Zuerst dürfen die Feinde plündern, die mitgenommenen Items
|
||||
* stehen in fig->run.items. Dann werden die Fliehenden auf
|
||||
* die leere (tote) alte Einheit gemapt */
|
||||
#ifdef SIMPLE_ESCAPE
|
||||
if (!fval(df, FIG_NOLOOT)) {
|
||||
loot_items(df);
|
||||
}
|
||||
#else
|
||||
if (fval(df, FIG_NOLOOT)) {
|
||||
merge_fleeloot(df, du);
|
||||
} else {
|
||||
loot_items(df);
|
||||
loot_fleeing(df, du);
|
||||
}
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
scale_number(du, df->run.number);
|
||||
du->hp = df->run.hp;
|
||||
setguard(du, GUARD_NONE);
|
||||
|
@ -2850,13 +2726,6 @@ static void aftermath(battle * b)
|
|||
if (!fval(r->terrain, SEA_REGION)) {
|
||||
leave(du, true); /* even region owners have to flee */
|
||||
}
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
if (df->run.region) {
|
||||
run_to(du, df->run.region);
|
||||
df->run.region = du->region;
|
||||
}
|
||||
fset(du, UFL_LONGACTION | UFL_NOTMOVING);
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
fset(du, UFL_FLEEING);
|
||||
} else {
|
||||
/* nur teilweise geflohene Einheiten mergen sich wieder */
|
||||
|
@ -2865,9 +2734,6 @@ static void aftermath(battle * b)
|
|||
s->size[statusrow(df->status)] += df->run.number;
|
||||
s->alive += df->run.number;
|
||||
sum_hp += df->run.hp;
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
merge_fleeloot(df, du);
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
df->run.number = 0;
|
||||
df->run.hp = 0;
|
||||
/* df->run.region = NULL; */
|
||||
|
@ -2882,9 +2748,6 @@ static void aftermath(battle * b)
|
|||
/* alle sind tot, niemand geflohen. Einheit auflösen */
|
||||
df->run.number = 0;
|
||||
df->run.hp = 0;
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
df->run.region = NULL;
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
|
||||
/* Report the casualties */
|
||||
reportcasualties(b, df, dead);
|
||||
|
@ -3057,7 +2920,7 @@ static void print_fighters(battle * b, const side * s)
|
|||
}
|
||||
}
|
||||
|
||||
boolean is_attacker(const fighter * fig)
|
||||
bool is_attacker(const fighter * fig)
|
||||
{
|
||||
return fval(fig, FIG_ATTACKER) != 0;
|
||||
}
|
||||
|
@ -3076,7 +2939,7 @@ static void print_header(battle * b)
|
|||
message *m;
|
||||
faction *f = bf->faction;
|
||||
const char *lastf = NULL;
|
||||
boolean first = false;
|
||||
bool first = false;
|
||||
side *s;
|
||||
char *bufp = zText;
|
||||
size_t size = sizeof(zText) - 1;
|
||||
|
@ -3266,7 +3129,7 @@ static void print_stats(battle * b)
|
|||
}
|
||||
}
|
||||
|
||||
static int weapon_weight(const weapon * w, boolean missile)
|
||||
static int weapon_weight(const weapon * w, bool missile)
|
||||
{
|
||||
if (missile == i2b(fval(w->type, WTF_MISSILE))) {
|
||||
return w->attackskill + w->defenseskill;
|
||||
|
@ -3274,7 +3137,46 @@ static int weapon_weight(const weapon * w, boolean missile)
|
|||
return 0;
|
||||
}
|
||||
|
||||
fighter *make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
||||
side * get_side(battle * b, const struct unit * u)
|
||||
{
|
||||
side * s;
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
if (s->faction==u->faction) {
|
||||
fighter * fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
if (fig->unit==u) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
side * find_side(battle * b, const faction * f, const group * g, int flags, const faction * stealthfaction)
|
||||
{
|
||||
side * s;
|
||||
static int rule_anon_battle = -1;
|
||||
|
||||
if (rule_anon_battle < 0) {
|
||||
rule_anon_battle = get_param_int(global.parameters, "rules.stealth.anon_battle", 1);
|
||||
}
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
if (s->faction == f && s->group == g) {
|
||||
int s1flags = flags | SIDE_HASGUARDS;
|
||||
int s2flags = s->flags | SIDE_HASGUARDS;
|
||||
if (rule_anon_battle && s->stealthfaction != stealthfaction) {
|
||||
continue;
|
||||
}
|
||||
if (s1flags == s2flags) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
fighter *make_fighter(battle * b, unit * u, side * s1, bool attack)
|
||||
{
|
||||
#define WMAX 20
|
||||
weapon weapons[WMAX];
|
||||
|
@ -3284,26 +3186,18 @@ fighter *make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
region *r = b->region;
|
||||
item *itm;
|
||||
fighter *fig = NULL;
|
||||
int i, tactics = eff_skill(u, SK_TACTICS, r);
|
||||
side *s2;
|
||||
int h;
|
||||
int h, i, tactics = eff_skill(u, SK_TACTICS, r);
|
||||
int berserk;
|
||||
int strongmen;
|
||||
int speeded = 0, speed = 1;
|
||||
boolean pr_aid = false;
|
||||
bool pr_aid = false;
|
||||
int rest;
|
||||
const group *g = NULL;
|
||||
const attrib *a = a_find(u->attribs, &at_otherfaction);
|
||||
const faction *stealthfaction = a ? get_otherfaction(a) : NULL;
|
||||
unsigned int flags = 0;
|
||||
static int rule_anon_battle = -1;
|
||||
|
||||
assert(u->number);
|
||||
|
||||
if (rule_anon_battle < 0) {
|
||||
rule_anon_battle =
|
||||
get_param_int(global.parameters, "rules.stealth.anon_battle", 1);
|
||||
}
|
||||
if (fval(u, UFL_ANON_FACTION) != 0)
|
||||
flags |= SIDE_STEALTH;
|
||||
if (!(AllianceAuto() & HELP_FIGHT) && fval(u, UFL_GROUP)) {
|
||||
|
@ -3317,25 +3211,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
return NULL;
|
||||
}
|
||||
if (s1 == NULL) {
|
||||
for (s2 = b->sides; s2 != b->sides + b->nsides; ++s2) {
|
||||
if (s2->faction == u->faction && s2->group == g) {
|
||||
#ifdef SIMPLE_COMBAT
|
||||
int s1flags = flags | SIDE_HASGUARDS;
|
||||
int s2flags = s2->flags | SIDE_HASGUARDS;
|
||||
#else
|
||||
int s1flags = flags;
|
||||
int s2flags = s2->flags;
|
||||
#endif
|
||||
if (rule_anon_battle && s2->stealthfaction != stealthfaction) {
|
||||
continue;
|
||||
}
|
||||
if (s1flags == s2flags) {
|
||||
s1 = s2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s1 = find_side(b, u->faction, g, flags, stealthfaction);
|
||||
/* aliances are moved out of make_fighter and will be handled later */
|
||||
if (!s1) {
|
||||
s1 = make_side(b, u->faction, g, flags, stealthfaction);
|
||||
|
@ -3345,7 +3221,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
/* Zu diesem Zeitpunkt ist attacked noch 0, da die Einheit für noch
|
||||
* keinen Kampf ausgewählt wurde (sonst würde ein fighter existieren) */
|
||||
}
|
||||
fig = calloc(1, sizeof(struct fighter));
|
||||
fig = (struct fighter*)calloc(1, sizeof(struct fighter));
|
||||
|
||||
fig->next = s1->fighters;
|
||||
s1->fighters = fig;
|
||||
|
@ -3370,7 +3246,7 @@ fighter *make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
fig->catmsg = -1;
|
||||
|
||||
/* Freigeben nicht vergessen! */
|
||||
fig->person = calloc(fig->alive, sizeof(struct person));
|
||||
fig->person = (struct person*)calloc(fig->alive, sizeof(struct person));
|
||||
|
||||
h = u->hp / u->number;
|
||||
assert(h);
|
||||
|
@ -3601,7 +3477,24 @@ fighter *make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
return fig;
|
||||
}
|
||||
|
||||
static int join_battle(battle * b, unit * u, boolean attack, fighter ** cp)
|
||||
fighter * get_fighter(battle * b, const struct unit * u)
|
||||
{
|
||||
side * s;
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fig;
|
||||
if (s->faction == u->faction) {
|
||||
for (fig = s->fighters; fig; fig = fig->next) {
|
||||
if (fig->unit == u) {
|
||||
return fig;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int join_battle(battle * b, unit * u, bool attack, fighter ** cp)
|
||||
{
|
||||
side *s;
|
||||
fighter *c = NULL;
|
||||
|
@ -3684,7 +3577,7 @@ battle *make_battle(region * r)
|
|||
else {
|
||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||
fwrite(utf8_bom, 1, 3, bdebug);
|
||||
fprintf(bdebug, "In %s findet ein Kampf stattactics:\n", rname(r,
|
||||
fprintf(bdebug, "In %s findet ein Kampf statt:\n", rname(r,
|
||||
default_locale));
|
||||
}
|
||||
obs_count++;
|
||||
|
@ -3742,7 +3635,6 @@ static void free_fighter(fighter * fig)
|
|||
|
||||
static void free_battle(battle * b)
|
||||
{
|
||||
side *s;
|
||||
int max_fac_no = 0;
|
||||
|
||||
if (bdebug) {
|
||||
|
@ -3757,19 +3649,11 @@ static void free_battle(battle * b)
|
|||
free(bf);
|
||||
}
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
fnext = fig->next;
|
||||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
free_side(s);
|
||||
}
|
||||
ql_free(b->leaders);
|
||||
ql_foreach(b->meffects, free);
|
||||
ql_free(b->meffects);
|
||||
|
||||
battle_free(b);
|
||||
}
|
||||
|
||||
static int *get_alive(side * s)
|
||||
|
@ -3792,8 +3676,8 @@ static int *get_alive(side * s)
|
|||
static int battle_report(battle * b)
|
||||
{
|
||||
side *s, *s2;
|
||||
boolean cont = false;
|
||||
boolean komma;
|
||||
bool cont = false;
|
||||
bool komma;
|
||||
bfaction *bf;
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
|
@ -4010,53 +3894,6 @@ static void flee(const troop dt)
|
|||
fighter *fig = dt.fighter;
|
||||
unit *u = fig->unit;
|
||||
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
int carry = personcapacity(u) - u->race->weight;
|
||||
int money;
|
||||
|
||||
item **ip = &u->items;
|
||||
|
||||
while (*ip) {
|
||||
item *itm = *ip;
|
||||
const item_type *itype = itm->type;
|
||||
int keep = 0;
|
||||
|
||||
if (fval(itype, ITF_ANIMAL)) {
|
||||
/* Regeländerung: Man muß das Tier nicht reiten können,
|
||||
* um es vom Schlachtfeld mitzunehmen, ist ja nur
|
||||
* eine Region weit. * */
|
||||
keep = MIN(1, itm->number);
|
||||
/* da ist das weight des tiers mit drin */
|
||||
carry += itype->capacity - itype->weight;
|
||||
} else if (itm->type->weight <= 0) {
|
||||
/* if it doesn'tactics weigh anything, it won'tactics slow us down */
|
||||
keep = itm->number;
|
||||
}
|
||||
/* jeder troop nimmt seinen eigenen Teil der Sachen mit */
|
||||
if (keep > 0) {
|
||||
if (itm->number == keep) {
|
||||
i_add(&fig->run.items, i_remove(ip, itm));
|
||||
} else {
|
||||
item *run_itm = i_new(itype, keep);
|
||||
i_add(&fig->run.items, run_itm);
|
||||
i_change(ip, itype, -keep);
|
||||
}
|
||||
}
|
||||
if (*ip == itm)
|
||||
ip = &itm->next;
|
||||
}
|
||||
|
||||
/* we will take money with us */
|
||||
money = get_money(u);
|
||||
/* nur ganzgeflohene/resttote Einheiten verlassen die Region */
|
||||
if (money > carry)
|
||||
money = carry;
|
||||
if (money > 0) {
|
||||
i_change(&u->items, i_silver, -money);
|
||||
i_change(&fig->run.items, i_silver, +money);
|
||||
}
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
|
||||
fig->run.hp += fig->person[dt.index].hp;
|
||||
++fig->run.number;
|
||||
|
||||
|
@ -4065,11 +3902,11 @@ static void flee(const troop dt)
|
|||
kill_troop(dt);
|
||||
}
|
||||
|
||||
static boolean init_battle(region * r, battle ** bp)
|
||||
static bool start_battle(region * r, battle ** bp)
|
||||
{
|
||||
battle *b = NULL;
|
||||
unit *u;
|
||||
boolean fighting = false;
|
||||
bool fighting = false;
|
||||
|
||||
/* list_foreach geht nicht, wegen flucht */
|
||||
for (u = r->units; u != NULL; u = u->next) {
|
||||
|
@ -4079,7 +3916,7 @@ static boolean init_battle(region * r, battle ** bp)
|
|||
order *ord;
|
||||
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
static const curse_type *peace_ct, *slave_ct, *calm_ct;
|
||||
|
||||
if (!init) {
|
||||
|
@ -4178,7 +4015,7 @@ static boolean init_battle(region * r, battle ** bp)
|
|||
|
||||
if (calm_ct) {
|
||||
attrib *a = a_find(u->attribs, &at_curse);
|
||||
boolean calm = false;
|
||||
bool calm = false;
|
||||
while (a && a->type == &at_curse) {
|
||||
curse *c = (curse *) a->data.v;
|
||||
if (c->type == calm_ct
|
||||
|
@ -4280,7 +4117,7 @@ static void battle_stats(FILE * F, battle * b)
|
|||
}
|
||||
stat = *slist;
|
||||
if (stat == NULL || stat->wtype != wtype || stat->level != level) {
|
||||
stat = calloc(1, sizeof(stat_info));
|
||||
stat = (stat_info*)calloc(1, sizeof(stat_info));
|
||||
stat->wtype = wtype;
|
||||
stat->level = level;
|
||||
stat->next = *slist;
|
||||
|
@ -4378,12 +4215,6 @@ static void battle_flee(battle * b)
|
|||
}
|
||||
|
||||
dt.fighter = fig;
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
if (!fig->run.region)
|
||||
fig->run.region = fleeregion(u);
|
||||
if (!fig->run.region)
|
||||
continue;
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
dt.index = fig->alive - fig->removed;
|
||||
while (s->size[SUM_ROW] && dt.index != 0) {
|
||||
double ispaniced = 0.0;
|
||||
|
@ -4434,7 +4265,7 @@ static void battle_flee(battle * b)
|
|||
void do_battle(region * r)
|
||||
{
|
||||
battle *b = NULL;
|
||||
boolean fighting = false;
|
||||
bool fighting = false;
|
||||
ship *sh;
|
||||
static int init_rules = 0;
|
||||
|
||||
|
@ -4446,7 +4277,7 @@ void do_battle(region * r)
|
|||
msg_separator = msg_message("battle::section", "");
|
||||
}
|
||||
|
||||
fighting = init_battle(r, &b);
|
||||
fighting = start_battle(r, &b);
|
||||
|
||||
if (b == NULL)
|
||||
return;
|
||||
|
@ -4513,3 +4344,26 @@ void do_battle(region * r)
|
|||
free(b);
|
||||
}
|
||||
}
|
||||
|
||||
void battle_init(battle * b) {
|
||||
assert(b);
|
||||
memset(b, 0, sizeof(battle));
|
||||
}
|
||||
|
||||
void battle_free(battle * b) {
|
||||
side *s;
|
||||
|
||||
assert(b);
|
||||
|
||||
for (s = b->sides; s != b->sides + b->nsides; ++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
fnext = fig->next;
|
||||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
free_side(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SHOW_KILLS
|
||||
#undef SMALL_BATTLE_MESSAGES
|
||||
|
||||
/** more defines **/
|
||||
#define FS_ENEMY 1
|
||||
#define FS_HELP 2
|
||||
|
@ -49,10 +46,7 @@ extern "C" {
|
|||
struct bfaction *next;
|
||||
struct side *sides;
|
||||
struct faction *faction;
|
||||
#ifndef SIMPLE_COMBAT
|
||||
int lastturn; /* last time this struct faction was involved in combat */
|
||||
#endif
|
||||
boolean attacker;
|
||||
bool attacker;
|
||||
} bfaction;
|
||||
|
||||
typedef struct tactics {
|
||||
|
@ -61,9 +55,7 @@ extern "C" {
|
|||
} tactics;
|
||||
|
||||
#define SIDE_STEALTH 1<<0
|
||||
#ifdef SIMPLE_COMBAT
|
||||
#define SIDE_HASGUARDS 1<<1
|
||||
#endif
|
||||
typedef struct side {
|
||||
struct side *nextF; /* next army of same faction */
|
||||
struct battle *battle;
|
||||
|
@ -102,15 +94,10 @@ extern "C" {
|
|||
struct quicklist *meffects;
|
||||
int max_tactics;
|
||||
int turn;
|
||||
boolean has_tactics_turn;
|
||||
bool has_tactics_turn;
|
||||
int keeploot;
|
||||
boolean reelarrow;
|
||||
bool reelarrow;
|
||||
int alive;
|
||||
#ifdef SMALL_BATTLE_MESSAGES
|
||||
boolean small;
|
||||
#endif
|
||||
#define FASTROW
|
||||
#ifdef FASTROW
|
||||
struct {
|
||||
const struct side *as;
|
||||
const struct side *vs;
|
||||
|
@ -118,9 +105,6 @@ extern "C" {
|
|||
int row;
|
||||
int result;
|
||||
} rowcache;
|
||||
#endif
|
||||
#define FASTCOUNT
|
||||
#ifdef FASTCOUNT
|
||||
struct {
|
||||
struct side *side;
|
||||
int status;
|
||||
|
@ -128,7 +112,6 @@ extern "C" {
|
|||
int minrow, maxrow;
|
||||
int enemies[8];
|
||||
} fast;
|
||||
#endif
|
||||
} battle;
|
||||
|
||||
typedef struct weapon {
|
||||
|
@ -198,18 +181,9 @@ extern "C" {
|
|||
struct {
|
||||
int number; /* number of people who fled */
|
||||
int hp; /* accumulated hp of fleeing people */
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
struct region *region; /* destination of fleeing people */
|
||||
struct item *items; /* items they take */
|
||||
#endif /* SIMPLE_ESCAPE */
|
||||
} run;
|
||||
#ifndef SIMPLE_COMBAT
|
||||
int action_counter; /* number of active actions the struct unit did in the fight */
|
||||
#endif /* SIMPLE_COMBAT */
|
||||
#ifdef SHOW_KILLS
|
||||
int kills;
|
||||
int hits;
|
||||
#endif
|
||||
} fighter;
|
||||
|
||||
/* schilde */
|
||||
|
@ -231,6 +205,14 @@ extern "C" {
|
|||
|
||||
extern const troop no_troop;
|
||||
|
||||
/* BEGIN battle interface */
|
||||
void battle_init(battle * b);
|
||||
void battle_free(battle * b);
|
||||
side * find_side(battle * b, const struct faction * f, const struct group * g, int flags, const struct faction * stealthfaction);
|
||||
side * get_side(battle * b, const struct unit * u);
|
||||
fighter * get_fighter(battle * b, const struct unit * u);
|
||||
/* END battle interface */
|
||||
|
||||
extern void do_battle(struct region *r);
|
||||
|
||||
/* for combat spells and special attacks */
|
||||
|
@ -244,8 +226,8 @@ extern "C" {
|
|||
|
||||
extern int count_enemies(struct battle *b, const struct fighter *af,
|
||||
int minrow, int maxrow, int select);
|
||||
extern boolean terminate(troop dt, troop at, int type, const char *damage,
|
||||
boolean missile);
|
||||
extern bool terminate(troop dt, troop at, int type, const char *damage,
|
||||
bool missile);
|
||||
extern void message_all(battle * b, struct message *m);
|
||||
extern int hits(troop at, troop dt, weapon * awp);
|
||||
extern void damage_building(struct battle *b, struct building *bldg,
|
||||
|
@ -255,21 +237,18 @@ extern "C" {
|
|||
extern int count_allies(const struct side *as, int minrow, int maxrow,
|
||||
int select, int allytype);
|
||||
extern int get_unitrow(const struct fighter *af, const struct side *vs);
|
||||
extern boolean helping(const struct side *as, const struct side *ds);
|
||||
extern bool helping(const struct side *as, const struct side *ds);
|
||||
extern void rmfighter(fighter * df, int i);
|
||||
#ifndef SIMPLE_ESCAPE
|
||||
extern struct region *fleeregion(const struct unit *u);
|
||||
#endif
|
||||
extern struct fighter *select_corpse(struct battle *b, struct fighter *af);
|
||||
extern int statusrow(int status);
|
||||
extern void drain_exp(struct unit *u, int d);
|
||||
extern void kill_troop(troop dt);
|
||||
extern void remove_troop(troop dt); /* not the same as the badly named rmtroop */
|
||||
extern boolean is_attacker(const fighter * fig);
|
||||
extern bool is_attacker(const fighter * fig);
|
||||
|
||||
extern struct battle *make_battle(struct region * r);
|
||||
extern fighter *make_fighter(struct battle *b, struct unit *u, side * s,
|
||||
boolean attack);
|
||||
bool attack);
|
||||
extern struct side *make_side(struct battle * b, const struct faction * f,
|
||||
const struct group * g, unsigned int flags,
|
||||
const struct faction * stealthfaction);
|
||||
|
|
|
@ -8,8 +8,9 @@
|
|||
#include "region.h"
|
||||
#include "skill.h"
|
||||
#include "unit.h"
|
||||
#include "tests.h"
|
||||
|
||||
#include <CuTest.h>
|
||||
#include "tests.h"
|
||||
|
||||
static void test_make_fighter(CuTest * tc)
|
||||
{
|
||||
|
|
|
@ -69,99 +69,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
/* Name, MaxGroesse, MinBauTalent, Kapazitaet, {Eisen, Holz, Stein, BauSilber,
|
||||
* Laen, Mallorn}, UnterSilber, UnterSpezialTyp, UnterSpezial */
|
||||
|
||||
static boolean CheckOverload(void)
|
||||
{
|
||||
static int value = -1;
|
||||
if (value < 0) {
|
||||
value = get_param_int(global.parameters, "rules.check_overload", 0);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/* test if the unit can slip through a siege undetected.
|
||||
* returns 0 if siege is successful, or 1 if the building is either
|
||||
* not besieged or the unit can slip through the siege due to better stealth.
|
||||
*/
|
||||
static int slipthru(const region * r, const unit * u, const building * b)
|
||||
{
|
||||
unit *u2;
|
||||
int n, o;
|
||||
|
||||
/* b ist die burg, in die man hinein oder aus der man heraus will. */
|
||||
if (b == NULL || b->besieged < b->size * SIEGEFACTOR) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* u wird am hinein- oder herausschluepfen gehindert, wenn STEALTH <=
|
||||
* OBSERVATION +2 der belagerer u2 ist */
|
||||
n = eff_skill(u, SK_STEALTH, r);
|
||||
|
||||
for (u2 = r->units; u2; u2 = u2->next) {
|
||||
if (usiege(u2) == b) {
|
||||
|
||||
if (invisible(u, u2) >= u->number)
|
||||
continue;
|
||||
|
||||
o = eff_skill(u2, SK_PERCEPTION, r);
|
||||
|
||||
if (o + 2 >= n) {
|
||||
return 0; /* entdeckt! */
|
||||
}
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int can_contact(const region * r, const unit * u, const unit * u2)
|
||||
{
|
||||
|
||||
/* hier geht es nur um die belagerung von burgen */
|
||||
|
||||
if (u->building == u2->building) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* unit u is trying to contact u2 - unasked for contact. wenn u oder u2
|
||||
* nicht in einer burg ist, oder die burg nicht belagert ist, ist
|
||||
* slipthru () == 1. ansonsten ist es nur 1, wenn man die belagerer */
|
||||
|
||||
if (slipthru(u->region, u, u->building) && slipthru(u->region, u2, u2->building)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (alliedunit(u, u2->faction, HELP_GIVE));
|
||||
}
|
||||
|
||||
static void contact_cmd(unit * u, order * ord, int final)
|
||||
{
|
||||
/* unit u kontaktiert unit u2. Dies setzt den contact einfach auf 1 -
|
||||
* ein richtiger toggle ist (noch?) nicht noetig. die region als
|
||||
* parameter ist nur deswegen wichtig, weil er an getunit ()
|
||||
* weitergegeben wird. dies wird fuer das auffinden von tempunits in
|
||||
* getnewunit () verwendet! */
|
||||
unit *u2;
|
||||
region *r = u->region;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
u2 = getunitg(r, u->faction);
|
||||
|
||||
if (u2 != NULL) {
|
||||
if (!can_contact(r, u, u2)) {
|
||||
if (final)
|
||||
cmistake(u, u->thisorder, 23, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
usetcontact(u, u2);
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
struct building *getbuilding(const struct region *r)
|
||||
{
|
||||
building *b = findbuilding(getid());
|
||||
|
@ -182,102 +89,6 @@ ship *getship(const struct region * r)
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void siege_cmd(unit * u, order * ord)
|
||||
{
|
||||
region *r = u->region;
|
||||
building *b;
|
||||
int d, pooled;
|
||||
int bewaffnete, katapultiere = 0;
|
||||
static boolean init = false;
|
||||
static const curse_type *magicwalls_ct;
|
||||
static item_type *it_catapultammo = NULL;
|
||||
static item_type *it_catapult = NULL;
|
||||
if (!init) {
|
||||
init = true;
|
||||
magicwalls_ct = ct_find("magicwalls");
|
||||
it_catapultammo = it_find("catapultammo");
|
||||
it_catapult = it_find("catapult");
|
||||
}
|
||||
/* gibt es ueberhaupt Burgen? */
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
b = getbuilding(r);
|
||||
|
||||
if (!b) {
|
||||
cmistake(u, ord, 31, MSG_BATTLE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerrace(u->race)) {
|
||||
/* keine Drachen, Illusionen, Untote etc */
|
||||
cmistake(u, ord, 166, MSG_BATTLE);
|
||||
return;
|
||||
}
|
||||
/* schaden durch katapulte */
|
||||
|
||||
d = i_get(u->items, it_catapult);
|
||||
d = MIN(u->number, d);
|
||||
pooled = get_pooled(u, it_catapultammo->rtype, GET_DEFAULT, d);
|
||||
d = MIN(pooled, d);
|
||||
if (eff_skill(u, SK_CATAPULT, r) >= 1) {
|
||||
katapultiere = d;
|
||||
d *= eff_skill(u, SK_CATAPULT, r);
|
||||
} else {
|
||||
d = 0;
|
||||
}
|
||||
|
||||
bewaffnete = armedmen(u, true);
|
||||
if (d == 0 && bewaffnete == 0) {
|
||||
/* abbruch, falls unbewaffnet oder unfaehig, katapulte zu benutzen */
|
||||
cmistake(u, ord, 80, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_guard(u, GUARD_TRAVELTHRU)) {
|
||||
/* abbruch, wenn die einheit nicht vorher die region bewacht - als
|
||||
* warnung fuer alle anderen! */
|
||||
cmistake(u, ord, 81, MSG_EVENT);
|
||||
return;
|
||||
}
|
||||
/* einheit und burg markieren - spart zeit beim behandeln der einheiten
|
||||
* in der burg, falls die burg auch markiert ist und nicht alle
|
||||
* einheiten wieder abgesucht werden muessen! */
|
||||
|
||||
usetsiege(u, b);
|
||||
b->besieged += MAX(bewaffnete, katapultiere);
|
||||
|
||||
/* definitiver schaden eingeschraenkt */
|
||||
|
||||
d = MIN(d, b->size - 1);
|
||||
|
||||
/* meldung, schaden anrichten */
|
||||
if (d && !curse_active(get_curse(b->attribs, magicwalls_ct))) {
|
||||
b->size -= d;
|
||||
use_pooled(u, it_catapultammo->rtype,
|
||||
GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, d);
|
||||
/* send message to the entire region */
|
||||
ADDMSG(&r->msgs, msg_message("siege_catapults",
|
||||
"unit building destruction", u, b, d));
|
||||
} else {
|
||||
/* send message to the entire region */
|
||||
ADDMSG(&r->msgs, msg_message("siege", "unit building", u, b));
|
||||
}
|
||||
}
|
||||
|
||||
void do_siege(region * r)
|
||||
{
|
||||
if (fval(r->terrain, LAND_REGION)) {
|
||||
unit *u;
|
||||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (get_keyword(u->thisorder) == K_BESIEGE) {
|
||||
siege_cmd(u, u->thisorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static void destroy_road(unit * u, int nmax, struct order *ord)
|
||||
|
@ -1152,246 +963,3 @@ void continue_ship(region * r, unit * u, int want)
|
|||
build_ship(u, sh, want);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static boolean mayenter(region * r, unit * u, building * b)
|
||||
{
|
||||
unit *u2;
|
||||
if (fval(b, BLD_UNGUARDED))
|
||||
return true;
|
||||
u2 = building_owner(b);
|
||||
|
||||
if (u2 == NULL || ucontact(u2, u)
|
||||
|| alliedunit(u2, u->faction, HELP_GUARD))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int mayboard(const unit * u, ship * sh)
|
||||
{
|
||||
unit *u2 = ship_owner(sh);
|
||||
|
||||
return (!u2 || ucontact(u2, u) || alliedunit(u2, u->faction, HELP_GUARD));
|
||||
}
|
||||
|
||||
int leave_cmd(unit * u, struct order *ord)
|
||||
{
|
||||
region *r = u->region;
|
||||
|
||||
if (fval(u, UFL_ENTER)) {
|
||||
/* if we just entered this round, then we don't leave again */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (fval(r->terrain, SEA_REGION) && u->ship) {
|
||||
if (!fval(u->race, RCF_SWIM)) {
|
||||
cmistake(u, ord, 11, MSG_MOVE);
|
||||
return 0;
|
||||
}
|
||||
if (has_horses(u)) {
|
||||
cmistake(u, ord, 231, MSG_MOVE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (!slipthru(r, u, u->building)) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "entrance_besieged",
|
||||
"building", u->building));
|
||||
} else {
|
||||
leave(u, true);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static boolean enter_ship(unit * u, struct order *ord, int id, boolean report)
|
||||
{
|
||||
region *r = u->region;
|
||||
ship *sh;
|
||||
|
||||
/* Muß abgefangen werden, sonst könnten Schwimmer an
|
||||
* Bord von Schiffen an Land gelangen. */
|
||||
if (!fval(u->race, RCF_CANSAIL) || (!fval(u->race, RCF_WALK)
|
||||
&& !fval(u->race, RCF_FLY))) {
|
||||
cmistake(u, ord, 233, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
|
||||
sh = findship(id);
|
||||
if (sh == NULL || sh->region != r) {
|
||||
if (report)
|
||||
cmistake(u, ord, 20, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
if (sh == u->ship)
|
||||
return true;
|
||||
if (!mayboard(u, sh)) {
|
||||
if (report)
|
||||
cmistake(u, ord, 34, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
if (CheckOverload()) {
|
||||
int sweight, scabins;
|
||||
int mweight = shipcapacity(sh);
|
||||
int mcabins = sh->type->cabins;
|
||||
|
||||
if (mweight > 0) {
|
||||
getshipweight(sh, &sweight, &scabins);
|
||||
sweight += weight(u);
|
||||
if (mcabins) {
|
||||
int pweight = u->number * u->race->weight;
|
||||
/* weight goes into number of cabins, not cargo */
|
||||
scabins += pweight;
|
||||
sweight -= pweight;
|
||||
}
|
||||
|
||||
if (sweight > mweight || (mcabins && (scabins > mcabins))) {
|
||||
if (report)
|
||||
cmistake(u, ord, 34, MSG_MOVE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (leave(u, false)) {
|
||||
u_set_ship(u, sh);
|
||||
fset(u, UFL_ENTER);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean enter_building(unit * u, order * ord, int id, boolean report)
|
||||
{
|
||||
region *r = u->region;
|
||||
building *b;
|
||||
|
||||
/* Schwimmer können keine Gebäude betreten, außer diese sind
|
||||
* auf dem Ozean */
|
||||
if (!fval(u->race, RCF_WALK) && !fval(u->race, RCF_FLY)) {
|
||||
if (!fval(r->terrain, SEA_REGION)) {
|
||||
if (report) {
|
||||
cmistake(u, ord, 232, MSG_MOVE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
b = findbuilding(id);
|
||||
if (b == NULL || b->region != r) {
|
||||
if (report) {
|
||||
cmistake(u, ord, 6, MSG_MOVE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!mayenter(r, u, b)) {
|
||||
if (report) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "entrance_denied",
|
||||
"building", b));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (!slipthru(r, u, b)) {
|
||||
if (report) {
|
||||
ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "entrance_besieged",
|
||||
"building", b));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (leave(u, false)) {
|
||||
fset(u, UFL_ENTER);
|
||||
u_set_building(u, b);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void do_misc(region * r, int is_final_attempt)
|
||||
{
|
||||
unit **uptr, *uc;
|
||||
|
||||
for (uc = r->units; uc; uc = uc->next) {
|
||||
order *ord;
|
||||
for (ord = uc->orders; ord; ord = ord->next) {
|
||||
keyword_t kwd = get_keyword(ord);
|
||||
if (kwd == K_CONTACT) {
|
||||
contact_cmd(uc, ord, is_final_attempt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uptr = &r->units; *uptr;) {
|
||||
unit *u = *uptr;
|
||||
order **ordp = &u->orders;
|
||||
|
||||
while (*ordp) {
|
||||
order *ord = *ordp;
|
||||
if (get_keyword(ord) == K_ENTER) {
|
||||
param_t p;
|
||||
int id;
|
||||
unit *ulast = NULL;
|
||||
const char * s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
p = findparam_ex(s, u->faction->locale);
|
||||
id = getid();
|
||||
|
||||
switch (p) {
|
||||
case P_BUILDING:
|
||||
case P_GEBAEUDE:
|
||||
if (u->building && u->building->no == id)
|
||||
break;
|
||||
if (enter_building(u, ord, id, is_final_attempt)) {
|
||||
unit *ub;
|
||||
for (ub = u; ub; ub = ub->next) {
|
||||
if (ub->building == u->building) {
|
||||
ulast = ub;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case P_SHIP:
|
||||
if (u->ship && u->ship->no == id)
|
||||
break;
|
||||
if (enter_ship(u, ord, id, is_final_attempt)) {
|
||||
unit *ub;
|
||||
ulast = u;
|
||||
for (ub = u; ub; ub = ub->next) {
|
||||
if (ub->ship == u->ship) {
|
||||
ulast = ub;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (is_final_attempt) {
|
||||
cmistake(u, ord, 79, MSG_MOVE);
|
||||
}
|
||||
}
|
||||
if (ulast != NULL) {
|
||||
/* Wenn wir hier angekommen sind, war der Befehl
|
||||
* erfolgreich und wir löschen ihn, damit er im
|
||||
* zweiten Versuch nicht nochmal ausgeführt wird. */
|
||||
*ordp = ord->next;
|
||||
ord->next = NULL;
|
||||
free_order(ord);
|
||||
|
||||
if (ulast != u) {
|
||||
/* put u behind ulast so it's the last unit in the building */
|
||||
*uptr = u->next;
|
||||
u->next = ulast->next;
|
||||
ulast->next = u;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (*ordp == ord)
|
||||
ordp = &ord->next;
|
||||
}
|
||||
if (*uptr == u)
|
||||
uptr = &u->next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,10 +64,6 @@ extern "C" {
|
|||
extern int destroy_cmd(struct unit *u, struct order *ord);
|
||||
extern int leave_cmd(struct unit *u, struct order *ord);
|
||||
|
||||
extern int can_contact(const struct region *r, const struct unit *u,
|
||||
const struct unit *u2);
|
||||
|
||||
void do_siege(struct region *r);
|
||||
void build_road(struct region *r, struct unit *u, int size, direction_t d);
|
||||
void create_ship(struct region *r, struct unit *u,
|
||||
const struct ship_type *newtype, int size, struct order *ord);
|
||||
|
@ -76,8 +72,6 @@ extern "C" {
|
|||
struct building *getbuilding(const struct region *r);
|
||||
struct ship *getship(const struct region *r);
|
||||
|
||||
void do_misc(struct region *r, int is_final_attempt);
|
||||
|
||||
void reportevent(struct region *r, char *s);
|
||||
|
||||
void shash(struct ship *sh);
|
||||
|
|
|
@ -180,7 +180,7 @@ const char *buildingtype(const building_type * btype, const building * b,
|
|||
int bsize)
|
||||
{
|
||||
const char *s = NULL;
|
||||
static boolean init_generic = false;
|
||||
static bool init_generic = false;
|
||||
static const struct building_type *bt_generic;
|
||||
|
||||
if (!init_generic) {
|
||||
|
@ -451,7 +451,7 @@ building *new_building(const struct building_type * btype, region * r,
|
|||
{
|
||||
building **bptr = &r->buildings;
|
||||
building *b = (building *) calloc(1, sizeof(building));
|
||||
static boolean init_lighthouse = false;
|
||||
static bool init_lighthouse = false;
|
||||
static const struct building_type *bt_lighthouse = 0;
|
||||
const char *bname = 0;
|
||||
char buffer[32];
|
||||
|
@ -501,7 +501,7 @@ void remove_building(building ** blist, building * b)
|
|||
{
|
||||
unit *u;
|
||||
static const struct building_type *bt_caravan, *bt_dam, *bt_tunnel;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
|
|
@ -25,6 +25,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
/* kernel includes */
|
||||
#include "alliance.h"
|
||||
#include "ally.h"
|
||||
#include "alchemy.h"
|
||||
#include "battle.h"
|
||||
#include "connection.h"
|
||||
|
@ -95,22 +96,10 @@ struct settings global = {
|
|||
FILE *logfile;
|
||||
FILE *updatelog;
|
||||
const struct race *new_race[MAXRACES];
|
||||
boolean sqlpatch = false;
|
||||
boolean battledebug = false;
|
||||
bool sqlpatch = false;
|
||||
bool battledebug = false;
|
||||
int turn = 0;
|
||||
|
||||
#if XECMD_MODULE
|
||||
attrib_type at_xontormiaexpress = {
|
||||
"xontormiaexpress",
|
||||
DEFAULT_INIT,
|
||||
DEFAULT_FINALIZE,
|
||||
DEFAULT_AGE,
|
||||
a_writeint,
|
||||
a_readint,
|
||||
ATF_UNIQUE
|
||||
};
|
||||
#endif
|
||||
|
||||
int NewbieImmunity(void)
|
||||
{
|
||||
static int value = -1;
|
||||
|
@ -122,7 +111,7 @@ int NewbieImmunity(void)
|
|||
return value;
|
||||
}
|
||||
|
||||
boolean IsImmune(const faction * f)
|
||||
bool IsImmune(const faction * f)
|
||||
{
|
||||
return !fval(f, FFL_NPC) && f->age < NewbieImmunity();
|
||||
}
|
||||
|
@ -155,7 +144,7 @@ static int ally_flag(const char *s, int help_mask)
|
|||
return 0;
|
||||
}
|
||||
|
||||
boolean ExpensiveMigrants(void)
|
||||
bool ExpensiveMigrants(void)
|
||||
{
|
||||
static int value = -1;
|
||||
static int gamecookie = -1;
|
||||
|
@ -411,8 +400,6 @@ const char *keywords[MAXKEYWORDS] = {
|
|||
"ENDE",
|
||||
"FAHREN",
|
||||
"NUMMER",
|
||||
"KRIEG",
|
||||
"FRIEDEN",
|
||||
"FOLGEN",
|
||||
"FORSCHEN",
|
||||
"GIB",
|
||||
|
@ -423,7 +410,6 @@ const char *keywords[MAXKEYWORDS] = {
|
|||
"KONTAKTIEREN",
|
||||
"LEHREN",
|
||||
"LERNEN",
|
||||
"LIEFERE",
|
||||
"MACHEN",
|
||||
"NACH",
|
||||
"PASSWORT",
|
||||
|
@ -449,18 +435,12 @@ const char *keywords[MAXKEYWORDS] = {
|
|||
"URSPRUNG",
|
||||
"EMAIL",
|
||||
"PIRATERIE",
|
||||
"NEUSTART",
|
||||
"GRUPPE",
|
||||
"OPFERE",
|
||||
"BETEN",
|
||||
"SORTIEREN",
|
||||
"JIHAD",
|
||||
"GM",
|
||||
"INFO",
|
||||
"PRAEFIX",
|
||||
"PFLANZEN",
|
||||
"WERWESEN",
|
||||
"XONTORMIA",
|
||||
"ALLIANZ",
|
||||
"BEANSPRUCHEN",
|
||||
"PROMOTION",
|
||||
|
@ -637,7 +617,7 @@ int shipspeed(const ship * sh, const unit * u)
|
|||
{
|
||||
double k = sh->type->range;
|
||||
static const curse_type *stormwind_ct, *nodrift_ct;
|
||||
static boolean init;
|
||||
static bool init;
|
||||
attrib *a;
|
||||
curse *c;
|
||||
|
||||
|
@ -849,7 +829,7 @@ int eff_stealth(const unit * u, const region * r)
|
|||
return e;
|
||||
}
|
||||
|
||||
boolean unit_has_cursed_item(unit * u)
|
||||
bool unit_has_cursed_item(unit * u)
|
||||
{
|
||||
item *itm = u->items;
|
||||
while (itm) {
|
||||
|
@ -875,7 +855,7 @@ static void init_gms(void)
|
|||
static int
|
||||
autoalliance(const plane * pl, const faction * sf, const faction * f2)
|
||||
{
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
if (!init) {
|
||||
init_gms();
|
||||
init = true;
|
||||
|
@ -979,7 +959,7 @@ int alliedunit(const unit * u, const faction * f2, int mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
boolean
|
||||
bool
|
||||
seefaction(const faction * f, const region * r, const unit * u, int modifier)
|
||||
{
|
||||
if (((f == u->faction) || !fval(u, UFL_ANON_FACTION))
|
||||
|
@ -988,7 +968,7 @@ seefaction(const faction * f, const region * r, const unit * u, int modifier)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean
|
||||
bool
|
||||
cansee(const faction * f, const region * r, const unit * u, int modifier)
|
||||
/* r kann != u->region sein, wenn es um durchreisen geht */
|
||||
/* und es muss niemand aus f in der region sein, wenn sie vom Turm
|
||||
|
@ -997,7 +977,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
|
|||
int stealth, rings;
|
||||
unit *u2 = r->units;
|
||||
static const item_type *itype_grail;
|
||||
static boolean init;
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
@ -1057,7 +1037,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean cansee_unit(const unit * u, const unit * target, int modifier)
|
||||
bool cansee_unit(const unit * u, const unit * target, int modifier)
|
||||
/* target->region kann != u->region sein, wenn es um durchreisen geht */
|
||||
{
|
||||
if (fval(target->race, RCF_INVISIBLE) || target->number == 0)
|
||||
|
@ -1093,7 +1073,7 @@ boolean cansee_unit(const unit * u, const unit * target, int modifier)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean
|
||||
bool
|
||||
cansee_durchgezogen(const faction * f, const region * r, const unit * u,
|
||||
int modifier)
|
||||
/* r kann != u->region sein, wenn es um durchreisen geht */
|
||||
|
@ -1164,7 +1144,7 @@ static attrib_type at_lighthouse = {
|
|||
*/
|
||||
void update_lighthouse(building * lh)
|
||||
{
|
||||
static boolean init_lighthouse = false;
|
||||
static bool init_lighthouse = false;
|
||||
static const struct building_type *bt_lighthouse = 0;
|
||||
|
||||
if (!init_lighthouse) {
|
||||
|
@ -1269,14 +1249,8 @@ int count_maxmigrants(const faction * f)
|
|||
return migrants;
|
||||
}
|
||||
|
||||
void init_tokens(const struct order *ord)
|
||||
{
|
||||
char *cmd = getcommand(ord);
|
||||
init_tokens_str(cmd, cmd);
|
||||
}
|
||||
|
||||
void
|
||||
parse(keyword_t kword, int (*dofun) (unit *, struct order *), boolean thisorder)
|
||||
parse(keyword_t kword, int (*dofun) (unit *, struct order *), bool thisorder)
|
||||
{
|
||||
region *r;
|
||||
|
||||
|
@ -1423,13 +1397,13 @@ param_t findparam_ex(const char *s, const struct locale * lang)
|
|||
return (result == P_BUILDING) ? P_GEBAEUDE : result;
|
||||
}
|
||||
|
||||
int isparam(const char *s, const struct locale * lang, param_t param)
|
||||
bool isparam(const char *s, const struct locale * lang, param_t param)
|
||||
{
|
||||
if (s[0]>'@') {
|
||||
param_t p = (param==P_GEBAEUDE) ? findparam_ex(s, lang) : findparam(s, lang);
|
||||
return p==param;
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
param_t getparam(const struct locale * lang)
|
||||
|
@ -1522,7 +1496,7 @@ int read_unitid(const faction * f, const region * r)
|
|||
}
|
||||
|
||||
/* exported symbol */
|
||||
boolean getunitpeasants;
|
||||
bool getunitpeasants;
|
||||
unit *getunitg(const region * r, const faction * f)
|
||||
{
|
||||
int n = read_unitid(f, r);
|
||||
|
@ -1585,7 +1559,7 @@ void freestrlist(strlist * s)
|
|||
|
||||
/* - Meldungen und Fehler ------------------------------------------------- */
|
||||
|
||||
boolean lomem = false;
|
||||
bool lomem = false;
|
||||
|
||||
/* - Namen der Strukturen -------------------------------------- */
|
||||
typedef char name[OBJECTIDSIZE + 1];
|
||||
|
@ -1635,7 +1609,7 @@ char *cstring(const char *s)
|
|||
}
|
||||
|
||||
building *largestbuilding(const region * r, cmp_building_cb cmp_gt,
|
||||
boolean imaginary)
|
||||
bool imaginary)
|
||||
{
|
||||
building *b, *best = NULL;
|
||||
|
||||
|
@ -1740,9 +1714,9 @@ unit *createunit(region * r, faction * f, int number, const struct race * rc)
|
|||
return create_unit(r, f, number, rc, 0, NULL, NULL);
|
||||
}
|
||||
|
||||
boolean idle(faction * f)
|
||||
bool idle(faction * f)
|
||||
{
|
||||
return (boolean) (f ? false : true);
|
||||
return (bool) (f ? false : true);
|
||||
}
|
||||
|
||||
int maxworkingpeasants(const struct region *r)
|
||||
|
@ -1785,7 +1759,7 @@ int lighthouse_range(const building * b, const faction * f)
|
|||
return d;
|
||||
}
|
||||
|
||||
boolean check_leuchtturm(region * r, faction * f)
|
||||
bool check_leuchtturm(region * r, faction * f)
|
||||
{
|
||||
attrib *a;
|
||||
|
||||
|
@ -1973,6 +1947,11 @@ direction_t finddirection(const char *s, const struct locale *lang)
|
|||
return NODIRECTION;
|
||||
}
|
||||
|
||||
direction_t getdirection(const struct locale * lang)
|
||||
{
|
||||
return finddirection(getstrtoken(), lang);
|
||||
}
|
||||
|
||||
static void init_translations(const struct locale *lang, int ut, const char * (*string_cb)(int i), int maxstrings)
|
||||
{
|
||||
char buffer[256];
|
||||
|
@ -2384,7 +2363,7 @@ void remove_empty_units(void)
|
|||
}
|
||||
}
|
||||
|
||||
boolean faction_id_is_unused(int id)
|
||||
bool faction_id_is_unused(int id)
|
||||
{
|
||||
return findfaction(id) == NULL;
|
||||
}
|
||||
|
@ -2481,7 +2460,7 @@ int lifestyle(const unit * u)
|
|||
return need;
|
||||
}
|
||||
|
||||
boolean has_horses(const struct unit * u)
|
||||
bool has_horses(const struct unit * u)
|
||||
{
|
||||
item *itm = u->items;
|
||||
for (; itm; itm = itm->next) {
|
||||
|
@ -2491,7 +2470,7 @@ boolean has_horses(const struct unit * u)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean hunger(int number, unit * u)
|
||||
bool hunger(int number, unit * u)
|
||||
{
|
||||
region *r = u->region;
|
||||
int dead = 0, hpsub = 0;
|
||||
|
@ -2540,7 +2519,7 @@ boolean hunger(int number, unit * u)
|
|||
return (dead || hpsub);
|
||||
}
|
||||
|
||||
void plagues(region * r, boolean ismagic)
|
||||
void plagues(region * r, bool ismagic)
|
||||
{
|
||||
int peasants;
|
||||
int i;
|
||||
|
@ -2604,7 +2583,7 @@ int cmp_wage(const struct building *b, const building * a)
|
|||
return -1;
|
||||
}
|
||||
|
||||
boolean is_owner_building(const struct building * b)
|
||||
bool is_owner_building(const struct building * b)
|
||||
{
|
||||
region *r = b->region;
|
||||
if (b->type->taxes && r->land && r->land->ownership) {
|
||||
|
@ -2774,7 +2753,7 @@ default_wage(const region * r, const faction * f, const race * rc, int in_turn)
|
|||
attrib *a;
|
||||
const building_type *artsculpture_type = bt_find("artsculpture");
|
||||
static const curse_type *drought_ct, *blessedharvest_ct;
|
||||
static boolean init;
|
||||
static bool init;
|
||||
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
@ -2915,7 +2894,7 @@ int movewhere(const unit * u, const char *token, region * r, region ** resultp)
|
|||
return E_MOVE_OK;
|
||||
}
|
||||
|
||||
boolean move_blocked(const unit * u, const region * r, const region * r2)
|
||||
bool move_blocked(const unit * u, const region * r, const region * r2)
|
||||
{
|
||||
connection *b;
|
||||
curse *c;
|
||||
|
@ -2964,7 +2943,7 @@ int lovar(double xpct_x2)
|
|||
return (rng_int() % n + rng_int() % n) / 1000;
|
||||
}
|
||||
|
||||
boolean has_limited_skills(const struct unit * u)
|
||||
bool has_limited_skills(const struct unit * u)
|
||||
{
|
||||
if (has_skill(u, SK_MAGIC) || has_skill(u, SK_ALCHEMY) ||
|
||||
has_skill(u, SK_TACTICS) || has_skill(u, SK_HERBALISM) ||
|
||||
|
@ -3022,9 +3001,8 @@ void attrib_init(void)
|
|||
register_function((pf_generic) & minimum_wage, "minimum_wage");
|
||||
|
||||
at_register(&at_germs);
|
||||
#if XECMD_MODULE
|
||||
at_register(&at_xontormiaexpress); /* required for old datafiles */
|
||||
#endif
|
||||
|
||||
at_deprecate("xontormiaexpress", a_readint); /* required for old datafiles */
|
||||
at_register(&at_speedup);
|
||||
at_register(&at_building_action);
|
||||
}
|
||||
|
|
|
@ -111,13 +111,7 @@ extern "C" {
|
|||
|
||||
extern int shipspeed(const struct ship *sh, const struct unit *u);
|
||||
|
||||
#define i2b(i) ((boolean)((i)?(true):(false)))
|
||||
|
||||
typedef struct ally {
|
||||
struct ally *next;
|
||||
struct faction *faction;
|
||||
int status;
|
||||
} ally;
|
||||
#define i2b(i) ((bool)((i)?(true):(false)))
|
||||
|
||||
void remove_empty_units_in_region(struct region *r);
|
||||
void remove_empty_units(void);
|
||||
|
@ -136,10 +130,10 @@ extern "C" {
|
|||
extern int verbosity;
|
||||
|
||||
/* parteinummern */
|
||||
extern boolean faction_id_is_unused(int);
|
||||
extern bool faction_id_is_unused(int);
|
||||
|
||||
/* leuchtturm */
|
||||
extern boolean check_leuchtturm(struct region *r, struct faction *f);
|
||||
extern bool check_leuchtturm(struct region *r, struct faction *f);
|
||||
extern void update_lighthouse(struct building *lh);
|
||||
extern int lighthouse_range(const struct building *b,
|
||||
const struct faction *f);
|
||||
|
@ -159,22 +153,23 @@ extern "C" {
|
|||
|
||||
void addstrlist(strlist ** SP, const char *s);
|
||||
|
||||
int armedmen(const struct unit *u, boolean siege_weapons);
|
||||
int armedmen(const struct unit *u, bool siege_weapons);
|
||||
|
||||
unsigned int atoip(const char *s);
|
||||
unsigned int getuint(void);
|
||||
int getint(void);
|
||||
|
||||
direction_t getdirection(const struct locale *);
|
||||
|
||||
extern const char *igetstrtoken(const char *s);
|
||||
|
||||
extern void init_tokens(const struct order *ord); /* initialize token parsing */
|
||||
extern skill_t findskill(const char *s, const struct locale *lang);
|
||||
|
||||
extern keyword_t findkeyword(const char *s, const struct locale *lang);
|
||||
|
||||
param_t findparam(const char *s, const struct locale *lang);
|
||||
param_t findparam_ex(const char *s, const struct locale * lang);
|
||||
int isparam(const char *s, const struct locale * lang, param_t param);
|
||||
bool isparam(const char *s, const struct locale * lang, param_t param);
|
||||
param_t getparam(const struct locale *lang);
|
||||
|
||||
extern int getid(void);
|
||||
|
@ -188,13 +183,13 @@ extern "C" {
|
|||
#define factionid(x) itoa36((x)->no)
|
||||
#define curseid(x) itoa36((x)->no)
|
||||
|
||||
extern boolean cansee(const struct faction *f, const struct region *r,
|
||||
extern bool cansee(const struct faction *f, const struct region *r,
|
||||
const struct unit *u, int modifier);
|
||||
boolean cansee_durchgezogen(const struct faction *f, const struct region *r,
|
||||
bool cansee_durchgezogen(const struct faction *f, const struct region *r,
|
||||
const struct unit *u, int modifier);
|
||||
extern boolean cansee_unit(const struct unit *u, const struct unit *target,
|
||||
extern bool cansee_unit(const struct unit *u, const struct unit *target,
|
||||
int modifier);
|
||||
boolean seefaction(const struct faction *f, const struct region *r,
|
||||
bool seefaction(const struct faction *f, const struct region *r,
|
||||
const struct unit *u, int modifier);
|
||||
extern int effskill(const struct unit *u, skill_t sk);
|
||||
|
||||
|
@ -210,7 +205,7 @@ extern "C" {
|
|||
extern struct unit *createunit(struct region *r, struct faction *f,
|
||||
int number, const struct race *rc);
|
||||
extern void create_unitid(struct unit *u, int id);
|
||||
extern boolean getunitpeasants;
|
||||
extern bool getunitpeasants;
|
||||
extern struct unit *getunitg(const struct region *r, const struct faction *f);
|
||||
extern struct unit *getunit(const struct region *r, const struct faction *f);
|
||||
|
||||
|
@ -242,7 +237,7 @@ extern "C" {
|
|||
typedef int (*cmp_building_cb) (const struct building * b,
|
||||
const struct building * a);
|
||||
struct building *largestbuilding(const struct region *r, cmp_building_cb,
|
||||
boolean imaginary);
|
||||
bool imaginary);
|
||||
int cmp_wage(const struct building *b, const struct building *bother);
|
||||
int cmp_taxes(const struct building *b, const struct building *bother);
|
||||
int cmp_current_owner(const struct building *b,
|
||||
|
@ -265,7 +260,7 @@ extern "C" {
|
|||
extern int count_migrants(const struct faction *f);
|
||||
extern int count_maxmigrants(const struct faction *f);
|
||||
|
||||
extern boolean has_limited_skills(const struct unit *u);
|
||||
extern bool has_limited_skills(const struct unit *u);
|
||||
extern const struct race *findrace(const char *, const struct locale *);
|
||||
|
||||
int eff_stealth(const struct unit *u, const struct region *r);
|
||||
|
@ -273,7 +268,7 @@ extern "C" {
|
|||
|
||||
int check_option(struct faction *f, int option);
|
||||
extern void parse(keyword_t kword, int (*dofun) (struct unit *,
|
||||
struct order *), boolean thisorder);
|
||||
struct order *), bool thisorder);
|
||||
|
||||
/* Anzahl Personen in einer Einheit festlegen. NUR (!) mit dieser Routine,
|
||||
* sonst großes Unglück. Durch asserts an ein paar Stellen abgesichert. */
|
||||
|
@ -293,8 +288,8 @@ extern "C" {
|
|||
void fhash(struct faction *f);
|
||||
void funhash(struct faction *f);
|
||||
|
||||
boolean idle(struct faction *f);
|
||||
boolean unit_has_cursed_item(struct unit *u);
|
||||
bool idle(struct faction *f);
|
||||
bool unit_has_cursed_item(struct unit *u);
|
||||
|
||||
/* simple garbage collection: */
|
||||
void *gc_add(void *p);
|
||||
|
@ -344,18 +339,18 @@ extern "C" {
|
|||
*/
|
||||
unsigned int guard_flags(const struct unit *u);
|
||||
|
||||
extern boolean hunger(int number, struct unit *u);
|
||||
extern bool hunger(int number, struct unit *u);
|
||||
extern int lifestyle(const struct unit *);
|
||||
extern int besieged(const struct unit *u);
|
||||
extern int maxworkingpeasants(const struct region *r);
|
||||
extern boolean has_horses(const struct unit *u);
|
||||
extern bool has_horses(const struct unit *u);
|
||||
extern int markets_module(void);
|
||||
extern int wage(const struct region *r, const struct faction *f,
|
||||
const struct race *rc, int in_turn);
|
||||
extern int maintenance_cost(const struct unit *u);
|
||||
extern struct message *movement_error(struct unit *u, const char *token,
|
||||
struct order *ord, int error_code);
|
||||
extern boolean move_blocked(const struct unit *u, const struct region *src,
|
||||
extern bool move_blocked(const struct unit *u, const struct region *src,
|
||||
const struct region *dest);
|
||||
extern void add_income(struct unit *u, int type, int want, int qty);
|
||||
|
||||
|
@ -392,7 +387,7 @@ extern "C" {
|
|||
const char *gamename;
|
||||
struct attrib *attribs;
|
||||
unsigned int data_turn;
|
||||
boolean disabled[MAXKEYWORDS];
|
||||
bool disabled[MAXKEYWORDS];
|
||||
struct param *parameters;
|
||||
void *vm_state;
|
||||
float producexpchance;
|
||||
|
@ -409,9 +404,9 @@ extern "C" {
|
|||
|
||||
extern int produceexp(struct unit *u, skill_t sk, int n);
|
||||
|
||||
extern boolean battledebug;
|
||||
extern boolean sqlpatch;
|
||||
extern boolean lomem; /* save memory */
|
||||
extern bool battledebug;
|
||||
extern bool sqlpatch;
|
||||
extern bool lomem; /* save memory */
|
||||
|
||||
extern const char *dbrace(const struct race *rc);
|
||||
|
||||
|
@ -421,19 +416,19 @@ extern "C" {
|
|||
extern float get_param_flt(const struct param *p, const char *name,
|
||||
float def);
|
||||
|
||||
extern boolean ExpensiveMigrants(void);
|
||||
extern bool ExpensiveMigrants(void);
|
||||
extern int NMRTimeout(void);
|
||||
extern int LongHunger(const struct unit *u);
|
||||
extern int SkillCap(skill_t sk);
|
||||
extern int NewbieImmunity(void);
|
||||
extern boolean IsImmune(const struct faction *f);
|
||||
extern bool IsImmune(const struct faction *f);
|
||||
extern int AllianceAuto(void); /* flags that allied factions get automatically */
|
||||
extern int AllianceRestricted(void); /* flags restricted to allied factions */
|
||||
extern int HelpMask(void); /* flags restricted to allied factions */
|
||||
extern struct order *default_order(const struct locale *lang);
|
||||
extern int entertainmoney(const struct region *r);
|
||||
|
||||
extern void plagues(struct region *r, boolean ismagic);
|
||||
extern void plagues(struct region *r, bool ismagic);
|
||||
typedef struct helpmode {
|
||||
const char *name;
|
||||
int status;
|
||||
|
@ -458,10 +453,6 @@ extern "C" {
|
|||
# define count_unit(u) 1
|
||||
#endif
|
||||
|
||||
#if XECMD_MODULE
|
||||
extern struct attrib_type at_xontormiaexpress;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -224,21 +224,21 @@ void b_write(const connection * b, storage * store)
|
|||
}
|
||||
}
|
||||
|
||||
boolean b_transparent(const connection * b, const struct faction *f)
|
||||
bool b_transparent(const connection * b, const struct faction *f)
|
||||
{
|
||||
unused(b);
|
||||
unused(f);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean b_opaque(const connection * b, const struct faction * f)
|
||||
bool b_opaque(const connection * b, const struct faction * f)
|
||||
{
|
||||
unused(b);
|
||||
unused(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean b_blockall(const connection * b, const unit * u, const region * r)
|
||||
bool b_blockall(const connection * b, const unit * u, const region * r)
|
||||
{
|
||||
unused(u);
|
||||
unused(r);
|
||||
|
@ -246,7 +246,7 @@ boolean b_blockall(const connection * b, const unit * u, const region * r)
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean b_blocknone(const connection * b, const unit * u, const region * r)
|
||||
bool b_blocknone(const connection * b, const unit * u, const region * r)
|
||||
{
|
||||
unused(u);
|
||||
unused(r);
|
||||
|
@ -254,12 +254,12 @@ boolean b_blocknone(const connection * b, const unit * u, const region * r)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean b_rvisible(const connection * b, const region * r)
|
||||
bool b_rvisible(const connection * b, const region * r)
|
||||
{
|
||||
return (boolean) (b->to == r || b->from == r);
|
||||
return (bool) (b->to == r || b->from == r);
|
||||
}
|
||||
|
||||
boolean b_fvisible(const connection * b, const struct faction * f,
|
||||
bool b_fvisible(const connection * b, const struct faction * f,
|
||||
const region * r)
|
||||
{
|
||||
unused(r);
|
||||
|
@ -268,21 +268,21 @@ boolean b_fvisible(const connection * b, const struct faction * f,
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean b_uvisible(const connection * b, const unit * u)
|
||||
bool b_uvisible(const connection * b, const unit * u)
|
||||
{
|
||||
unused(u);
|
||||
unused(b);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean b_rinvisible(const connection * b, const region * r)
|
||||
bool b_rinvisible(const connection * b, const region * r)
|
||||
{
|
||||
unused(r);
|
||||
unused(b);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean b_finvisible(const connection * b, const struct faction * f,
|
||||
bool b_finvisible(const connection * b, const struct faction * f,
|
||||
const region * r)
|
||||
{
|
||||
unused(r);
|
||||
|
@ -291,7 +291,7 @@ boolean b_finvisible(const connection * b, const struct faction * f,
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean b_uinvisible(const connection * b, const unit * u)
|
||||
bool b_uinvisible(const connection * b, const unit * u)
|
||||
{
|
||||
unused(u);
|
||||
unused(b);
|
||||
|
@ -399,14 +399,14 @@ static const char *b_namefogwall(const connection * b, const region * r,
|
|||
return LOC(f->locale, mkname("border", "fogwall"));
|
||||
}
|
||||
|
||||
static boolean
|
||||
static bool
|
||||
b_blockfogwall(const connection * b, const unit * u, const region * r)
|
||||
{
|
||||
unused(b);
|
||||
unused(r);
|
||||
if (!u)
|
||||
return true;
|
||||
return (boolean) (effskill(u, SK_PERCEPTION) > 4); /* Das ist die alte Nebelwand */
|
||||
return (bool) (effskill(u, SK_PERCEPTION) > 4); /* Das ist die alte Nebelwand */
|
||||
}
|
||||
|
||||
/** Legacy type used in old Eressea games, no longer in use. */
|
||||
|
@ -458,7 +458,7 @@ border_type bt_illusionwall = {
|
|||
* special quest door
|
||||
***/
|
||||
|
||||
boolean b_blockquestportal(const connection * b, const unit * u,
|
||||
bool b_blockquestportal(const connection * b, const unit * u,
|
||||
const region * r)
|
||||
{
|
||||
if (b->data.i > 0)
|
||||
|
@ -558,14 +558,14 @@ static void b_writeroad(const connection * b, storage * store)
|
|||
store->w_int(store, b->data.sa[1]);
|
||||
}
|
||||
|
||||
static boolean b_validroad(const connection * b)
|
||||
static bool b_validroad(const connection * b)
|
||||
{
|
||||
if (b->data.sa[0] == SHRT_MAX)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean b_rvisibleroad(const connection * b, const region * r)
|
||||
static bool b_rvisibleroad(const connection * b, const region * r)
|
||||
{
|
||||
int x = b->data.i;
|
||||
x = (r == b->from) ? b->data.sa[0] : b->data.sa[1];
|
||||
|
|
|
@ -39,7 +39,7 @@ extern "C" {
|
|||
typedef struct border_type {
|
||||
const char *__name; /* internal use only */
|
||||
variant_type datatype;
|
||||
boolean(*transparent) (const connection *, const struct faction *);
|
||||
bool(*transparent) (const connection *, const struct faction *);
|
||||
/* is it possible to see through this? */
|
||||
void (*init) (connection *);
|
||||
/* constructor: initialize the connection. allocate extra memory if needed */
|
||||
|
@ -47,7 +47,7 @@ extern "C" {
|
|||
/* destructor: remove all extra memory for destruction */
|
||||
void (*read) (connection *, struct storage *);
|
||||
void (*write) (const connection *, struct storage *);
|
||||
boolean(*block) (const connection *, const struct unit *,
|
||||
bool(*block) (const connection *, const struct unit *,
|
||||
const struct region * r);
|
||||
/* return true if it blocks movement of u from
|
||||
* r to the opposite struct region.
|
||||
|
@ -59,11 +59,11 @@ extern "C" {
|
|||
* may depend on the struct faction, for example "a wall" may
|
||||
* turn out to be "an illusionary wall"
|
||||
*/
|
||||
boolean(*rvisible) (const connection *, const struct region *);
|
||||
bool(*rvisible) (const connection *, const struct region *);
|
||||
/* is it visible to everyone in r ?
|
||||
* if not, it may still be fvisible() for some f.
|
||||
*/
|
||||
boolean(*fvisible) (const connection *, const struct faction *,
|
||||
bool(*fvisible) (const connection *, const struct faction *,
|
||||
const struct region *);
|
||||
/* is it visible to units of f in r?
|
||||
* the function shall not check for
|
||||
|
@ -73,16 +73,16 @@ extern "C" {
|
|||
* the reporting function will have to assure).
|
||||
* if not true, it may still be uvisible() for some u.
|
||||
*/
|
||||
boolean(*uvisible) (const connection *, const struct unit *);
|
||||
bool(*uvisible) (const connection *, const struct unit *);
|
||||
/* is it visible to u ?
|
||||
* a doorway may only be visible to a struct unit with perception > 5
|
||||
*/
|
||||
boolean(*valid) (const connection *);
|
||||
bool(*valid) (const connection *);
|
||||
/* is the connection in a valid state,
|
||||
* or should it be erased at the end of this turn to save space?
|
||||
*/
|
||||
struct region *(*move) (const connection *, struct unit * u,
|
||||
struct region * from, struct region * to, boolean routing);
|
||||
struct region * from, struct region * to, bool routing);
|
||||
/* executed when the units traverses this connection */
|
||||
int (*age) (struct connection *);
|
||||
/* return 0 if connection needs to be removed. >0 if still aging, <0 if not aging */
|
||||
|
@ -112,20 +112,20 @@ extern "C" {
|
|||
/* provide default implementations for some member functions: */
|
||||
extern void b_read(connection * b, struct storage *store);
|
||||
extern void b_write(const connection * b, struct storage *store);
|
||||
extern boolean b_blockall(const connection *, const struct unit *,
|
||||
extern bool b_blockall(const connection *, const struct unit *,
|
||||
const struct region *);
|
||||
extern boolean b_blocknone(const connection *, const struct unit *,
|
||||
extern bool b_blocknone(const connection *, const struct unit *,
|
||||
const struct region *);
|
||||
extern boolean b_rvisible(const connection *, const struct region *r);
|
||||
extern boolean b_fvisible(const connection *, const struct faction *f,
|
||||
extern bool b_rvisible(const connection *, const struct region *r);
|
||||
extern bool b_fvisible(const connection *, const struct faction *f,
|
||||
const struct region *);
|
||||
extern boolean b_uvisible(const connection *, const struct unit *u);
|
||||
extern boolean b_rinvisible(const connection *, const struct region *r);
|
||||
extern boolean b_finvisible(const connection *, const struct faction *f,
|
||||
extern bool b_uvisible(const connection *, const struct unit *u);
|
||||
extern bool b_rinvisible(const connection *, const struct region *r);
|
||||
extern bool b_finvisible(const connection *, const struct faction *f,
|
||||
const struct region *);
|
||||
extern boolean b_uinvisible(const connection *, const struct unit *u);
|
||||
extern boolean b_transparent(const connection *, const struct faction *);
|
||||
extern boolean b_opaque(const connection *, const struct faction *); /* !transparent */
|
||||
extern bool b_uinvisible(const connection *, const struct unit *u);
|
||||
extern bool b_transparent(const connection *, const struct faction *);
|
||||
extern bool b_opaque(const connection *, const struct faction *); /* !transparent */
|
||||
|
||||
extern border_type bt_fogwall;
|
||||
extern border_type bt_noway;
|
||||
|
|
|
@ -322,7 +322,7 @@ const curse_type *ct_find(const char *c)
|
|||
* einen pointer auf die struct zurück.
|
||||
*/
|
||||
|
||||
boolean cmp_curse(const attrib * a, const void *data)
|
||||
bool cmp_curse(const attrib * a, const void *data)
|
||||
{
|
||||
const curse *c = (const curse *)data;
|
||||
if (a->type->flags & ATF_CURSE) {
|
||||
|
@ -332,7 +332,7 @@ boolean cmp_curse(const attrib * a, const void *data)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean cmp_cursetype(const attrib * a, const void *data)
|
||||
bool cmp_cursetype(const attrib * a, const void *data)
|
||||
{
|
||||
const curse_type *ct = (const curse_type *)data;
|
||||
if (a->type->flags & ATF_CURSE) {
|
||||
|
@ -343,7 +343,7 @@ boolean cmp_cursetype(const attrib * a, const void *data)
|
|||
}
|
||||
|
||||
curse *get_cursex(attrib * ap, const curse_type * ctype, variant data,
|
||||
boolean(*compare) (const curse *, variant))
|
||||
bool(*compare) (const curse *, variant))
|
||||
{
|
||||
attrib *a = a_select(ap, ctype, cmp_cursetype);
|
||||
while (a) {
|
||||
|
@ -585,7 +585,7 @@ static void do_transfer_curse(curse * c, unit * u, unit * u2, int n)
|
|||
{
|
||||
int cursedmen = 0;
|
||||
int men = get_cursedmen(u, c);
|
||||
boolean dogive = false;
|
||||
bool dogive = false;
|
||||
const curse_type *ct = c->type;
|
||||
|
||||
switch ((ct->flags | c->flags) & CURSE_SPREADMASK) {
|
||||
|
@ -642,7 +642,7 @@ void transfer_curse(unit * u, unit * u2, int n)
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
boolean curse_active(const curse * c)
|
||||
bool curse_active(const curse * c)
|
||||
{
|
||||
if (!c)
|
||||
return false;
|
||||
|
@ -654,7 +654,7 @@ boolean curse_active(const curse * c)
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean is_cursed_internal(attrib * ap, const curse_type * ct)
|
||||
bool is_cursed_internal(attrib * ap, const curse_type * ct)
|
||||
{
|
||||
curse *c = get_curse(ap, ct);
|
||||
|
||||
|
@ -664,7 +664,7 @@ boolean is_cursed_internal(attrib * ap, const curse_type * ct)
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean is_cursed_with(const attrib * ap, const curse * c)
|
||||
bool is_cursed_with(const attrib * ap, const curse * c)
|
||||
{
|
||||
const attrib *a = ap;
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ extern "C" {
|
|||
|
||||
extern void destroy_curse(curse * c);
|
||||
|
||||
boolean is_cursed_internal(struct attrib *ap, const curse_type * ctype);
|
||||
bool is_cursed_internal(struct attrib *ap, const curse_type * ctype);
|
||||
/* ignoriert CURSE_ISNEW */
|
||||
|
||||
extern void remove_curse(struct attrib **ap, const struct curse *c);
|
||||
|
@ -281,7 +281,7 @@ extern "C" {
|
|||
* */
|
||||
|
||||
extern struct curse *get_cursex(struct attrib *ap, const curse_type * ctype,
|
||||
variant data, boolean(*compare) (const struct curse *, variant));
|
||||
variant data, bool(*compare) (const struct curse *, variant));
|
||||
/* gibt pointer auf die erste curse-struct zurück, deren Typ ctype ist,
|
||||
* und für die compare() true liefert, oder einen NULL-pointer.
|
||||
* */
|
||||
|
@ -303,15 +303,15 @@ extern "C" {
|
|||
extern void curse_done(struct attrib *a);
|
||||
extern int curse_age(struct attrib *a);
|
||||
|
||||
extern boolean cmp_curse(const struct attrib *a, const void *data);
|
||||
extern boolean cmp_cursetype(const struct attrib *a, const void *data);
|
||||
extern bool cmp_curse(const struct attrib *a, const void *data);
|
||||
extern bool cmp_cursetype(const struct attrib *a, const void *data);
|
||||
|
||||
extern double destr_curse(struct curse *c, int cast_level, double force);
|
||||
|
||||
extern int resolve_curse(variant data, void *address);
|
||||
extern boolean is_cursed_with(const struct attrib *ap, const struct curse *c);
|
||||
extern bool is_cursed_with(const struct attrib *ap, const struct curse *c);
|
||||
|
||||
extern boolean curse_active(const struct curse *c);
|
||||
extern bool curse_active(const struct curse *c);
|
||||
/* gibt true, wenn der Curse nicht NULL oder inaktiv ist */
|
||||
|
||||
/*** COMPATIBILITY MACROS. DO NOT USE FOR NEW CODE, REPLACE IN OLD CODE: */
|
||||
|
|
|
@ -21,6 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "faction.h"
|
||||
|
||||
#include "alliance.h"
|
||||
#include "ally.h"
|
||||
#include "equipment.h"
|
||||
#include "group.h"
|
||||
#include "item.h"
|
||||
|
@ -258,7 +259,7 @@ unit *addplayer(region * r, faction * f)
|
|||
return u;
|
||||
}
|
||||
|
||||
boolean checkpasswd(const faction * f, const char *passwd, boolean shortp)
|
||||
bool checkpasswd(const faction * f, const char *passwd, bool shortp)
|
||||
{
|
||||
if (unicode_utf8_strcasecmp(f->passw, passwd) == 0)
|
||||
return true;
|
||||
|
@ -490,14 +491,14 @@ void faction_setpassword(faction * f, const char *passw)
|
|||
f->passw = strdup(itoa36(rng_int()));
|
||||
}
|
||||
|
||||
boolean valid_race(const struct faction *f, const struct race *rc)
|
||||
bool valid_race(const struct faction *f, const struct race *rc)
|
||||
{
|
||||
if (f->race == rc)
|
||||
return true;
|
||||
else {
|
||||
const char *str = get_param(f->race->parameters, "other_race");
|
||||
if (str)
|
||||
return (boolean) (rc_find(str) == rc);
|
||||
return (bool) (rc_find(str) == rc);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ extern "C" {
|
|||
int no_units;
|
||||
struct ally *allies;
|
||||
struct group *groups;
|
||||
boolean alive; /* enno: sollte ein flag werden */
|
||||
bool alive; /* enno: sollte ein flag werden */
|
||||
int nregions;
|
||||
int money;
|
||||
#if SCORE_MODULE
|
||||
|
@ -118,14 +118,14 @@ extern "C" {
|
|||
extern struct unit *addplayer(struct region *r, faction * f);
|
||||
extern struct faction *addfaction(const char *email, const char *password,
|
||||
const struct race *frace, const struct locale *loc, int subscription);
|
||||
extern boolean checkpasswd(const faction * f, const char *passwd,
|
||||
boolean shortp);
|
||||
extern bool checkpasswd(const faction * f, const char *passwd,
|
||||
bool shortp);
|
||||
extern void destroyfaction(faction * f);
|
||||
|
||||
extern void set_alliance(struct faction *a, struct faction *b, int status);
|
||||
extern int get_alliance(const struct faction *a, const struct faction *b);
|
||||
|
||||
extern struct alliance *f_get_alliance(const struct faction *a);
|
||||
extern struct alliance *f_get_alliance(const struct faction *f);
|
||||
|
||||
extern void write_faction_reference(const struct faction *f,
|
||||
struct storage *store);
|
||||
|
@ -150,7 +150,7 @@ extern "C" {
|
|||
|
||||
const char *faction_getpassword(const struct faction *self);
|
||||
void faction_setpassword(struct faction *self, const char *password);
|
||||
boolean valid_race(const struct faction *f, const struct race *rc);
|
||||
bool valid_race(const struct faction *f, const struct race *rc);
|
||||
|
||||
struct spellbook * faction_get_spellbook(struct faction *f);
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -21,9 +21,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "group.h"
|
||||
|
||||
/* kernel includes */
|
||||
#include "unit.h"
|
||||
#include "ally.h"
|
||||
#include "faction.h"
|
||||
#include "save.h"
|
||||
#include "unit.h"
|
||||
#include "version.h"
|
||||
|
||||
/* attrib includes */
|
||||
|
@ -175,7 +176,7 @@ void set_group(struct unit *u, struct group *g)
|
|||
}
|
||||
}
|
||||
|
||||
boolean join_group(unit * u, const char *name)
|
||||
bool join_group(unit * u, const char *name)
|
||||
{
|
||||
group *g = NULL;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ extern "C" {
|
|||
} group;
|
||||
|
||||
extern struct attrib_type at_group; /* attribute for units assigned to a group */
|
||||
extern boolean join_group(struct unit *u, const char *name);
|
||||
extern bool join_group(struct unit *u, const char *name);
|
||||
extern void set_group(struct unit *u, struct group *g);
|
||||
extern struct group * get_group(const struct unit *u);
|
||||
extern void free_group(struct group *g);
|
||||
|
|
|
@ -684,7 +684,7 @@ typedef struct t_item {
|
|||
const char *name;
|
||||
/* [0]: Einzahl für eigene; [1]: Mehrzahl für eigene;
|
||||
* [2]: Einzahl für Fremde; [3]: Mehrzahl für Fremde */
|
||||
boolean is_resource;
|
||||
bool is_resource;
|
||||
skill_t skill;
|
||||
int minskill;
|
||||
int gewicht;
|
||||
|
|
|
@ -132,7 +132,7 @@ extern "C" {
|
|||
int capacity;
|
||||
struct construction *construction;
|
||||
/* --- functions --- */
|
||||
boolean(*canuse) (const struct unit * user,
|
||||
bool(*canuse) (const struct unit * user,
|
||||
const struct item_type * itype);
|
||||
int (*use) (struct unit * user, const struct item_type * itype, int amount,
|
||||
struct order * ord);
|
||||
|
@ -220,7 +220,7 @@ extern "C" {
|
|||
int reload; /* time to reload this weapon */
|
||||
weapon_mod *modifiers;
|
||||
/* --- functions --- */
|
||||
boolean(*attack) (const struct troop *, const struct weapon_type *,
|
||||
bool(*attack) (const struct troop *, const struct weapon_type *,
|
||||
int *deaths);
|
||||
} weapon_type;
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ attrib_type at_mage = {
|
|||
ATF_UNIQUE
|
||||
};
|
||||
|
||||
boolean is_mage(const unit * u)
|
||||
bool is_mage(const unit * u)
|
||||
{
|
||||
return i2b(get_mage(u) != NULL);
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ attrib_type at_seenspell = {
|
|||
|
||||
#define MAXSPELLS 256
|
||||
|
||||
static boolean already_seen(const faction * f, const spell * sp)
|
||||
static bool already_seen(const faction * f, const spell * sp)
|
||||
{
|
||||
attrib *a;
|
||||
|
||||
|
@ -912,7 +912,7 @@ void pay_spell(unit * u, const spell * sp, int cast_level, int range)
|
|||
* aber dann immer noch nicht können, vieleicht ist seine Stufe derzeit
|
||||
* nicht ausreichend oder die Komponenten fehlen.
|
||||
*/
|
||||
boolean knowsspell(const region * r, const unit * u, const spell * sp)
|
||||
bool knowsspell(const region * r, const unit * u, const spell * sp)
|
||||
{
|
||||
/* Ist überhaupt ein gültiger Spruch angegeben? */
|
||||
if (!sp || sp->id == 0) {
|
||||
|
@ -929,7 +929,7 @@ boolean knowsspell(const region * r, const unit * u, const spell * sp)
|
|||
* und sonstige Gegenstaende sein.
|
||||
*/
|
||||
|
||||
boolean
|
||||
bool
|
||||
cancast(unit * u, const spell * sp, int level, int range, struct order * ord)
|
||||
{
|
||||
int k;
|
||||
|
@ -1178,7 +1178,7 @@ double magic_resistance(unit * target)
|
|||
* true zurück
|
||||
*/
|
||||
|
||||
boolean
|
||||
bool
|
||||
target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus)
|
||||
{
|
||||
double probability = 0.0;
|
||||
|
@ -1244,9 +1244,9 @@ target_resists_magic(unit * magician, void *obj, int objtyp, int t_bonus)
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
boolean is_magic_resistant(unit * magician, unit * target, int resist_bonus)
|
||||
bool is_magic_resistant(unit * magician, unit * target, int resist_bonus)
|
||||
{
|
||||
return (boolean) target_resists_magic(magician, target, TYP_UNIT,
|
||||
return (bool) target_resists_magic(magician, target, TYP_UNIT,
|
||||
resist_bonus);
|
||||
}
|
||||
|
||||
|
@ -1261,7 +1261,7 @@ boolean is_magic_resistant(unit * magician, unit * target, int resist_bonus)
|
|||
* eben) bis zu etwa 1% bei doppelt so gut wie notwendig
|
||||
*/
|
||||
|
||||
boolean fumble(region * r, unit * u, const spell * sp, int cast_grade)
|
||||
bool fumble(region * r, unit * u, const spell * sp, int cast_grade)
|
||||
{
|
||||
/* X ergibt Zahl zwischen 1 und 0, je kleiner, desto besser der Magier.
|
||||
* 0,5*40-20=0, dh wenn der Magier doppelt so gut ist, wie der Spruch
|
||||
|
@ -1445,7 +1445,7 @@ static double regeneration(unit * u)
|
|||
return aura;
|
||||
}
|
||||
|
||||
void regeneration_magiepunkte(void)
|
||||
void regenerate_aura(void)
|
||||
{
|
||||
region *r;
|
||||
unit *u;
|
||||
|
@ -1500,7 +1500,7 @@ void regeneration_magiepunkte(void)
|
|||
}
|
||||
}
|
||||
|
||||
static boolean
|
||||
static bool
|
||||
verify_ship(region * r, unit * mage, const spell * sp, spllprm * spobj,
|
||||
order * ord)
|
||||
{
|
||||
|
@ -1523,7 +1523,7 @@ verify_ship(region * r, unit * mage, const spell * sp, spllprm * spobj,
|
|||
return true;
|
||||
}
|
||||
|
||||
static boolean
|
||||
static bool
|
||||
verify_building(region * r, unit * mage, const spell * sp, spllprm * spobj,
|
||||
order * ord)
|
||||
{
|
||||
|
@ -1564,7 +1564,7 @@ message *msg_unitnotfound(const struct unit * mage, struct order * ord,
|
|||
"unit region command id", mage, mage->region, ord, uid);
|
||||
}
|
||||
|
||||
static boolean
|
||||
static bool
|
||||
verify_unit(region * r, unit * mage, const spell * sp, spllprm * spobj,
|
||||
order * ord)
|
||||
{
|
||||
|
@ -1907,7 +1907,7 @@ addparam_unit(const char *const param[], spllprm ** spobjp, const unit * u,
|
|||
static spellparameter *add_spellparameter(region * target_r, unit * u,
|
||||
const char *syntax, const char *const param[], int size, struct order *ord)
|
||||
{
|
||||
boolean fail = false;
|
||||
bool fail = false;
|
||||
int i = 0;
|
||||
int p = 0;
|
||||
const char *c;
|
||||
|
@ -2116,7 +2116,7 @@ typedef struct familiar_data {
|
|||
unit *familiar;
|
||||
} famililar_data;
|
||||
|
||||
boolean is_familiar(const unit * u)
|
||||
bool is_familiar(const unit * u)
|
||||
{
|
||||
attrib *a = a_find(u->attribs, &at_familiarmage);
|
||||
return i2b(a != NULL);
|
||||
|
@ -2200,7 +2200,7 @@ void remove_familiar(unit * mage)
|
|||
}
|
||||
}
|
||||
|
||||
boolean create_newfamiliar(unit * mage, unit * familiar)
|
||||
bool create_newfamiliar(unit * mage, unit * familiar)
|
||||
{
|
||||
/* if the skill modifier for the mage does not yet exist, add it */
|
||||
attrib *a;
|
||||
|
@ -2461,7 +2461,7 @@ unit *get_clone_mage(const unit * u)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static boolean is_moving_ship(const region * r, ship * sh)
|
||||
static bool is_moving_ship(const region * r, ship * sh)
|
||||
{
|
||||
const unit *u = ship_owner(sh);
|
||||
|
||||
|
@ -2743,13 +2743,15 @@ void magic(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
if (get_keyword(ord) == K_CAST) {
|
||||
castorder *co = cast_cmd(u, ord);
|
||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||
if (co) {
|
||||
const spell *sp = co->sp;
|
||||
add_castorder(&spellranks[sp->rank], co);
|
||||
if (u->thisorder != NULL) {
|
||||
for (ord = u->orders; ord; ord = ord->next) {
|
||||
if (get_keyword(ord) == K_CAST) {
|
||||
castorder *co = cast_cmd(u, ord);
|
||||
fset(u, UFL_LONGACTION | UFL_NOTMOVING);
|
||||
if (co) {
|
||||
const spell *sp = co->sp;
|
||||
add_castorder(&spellranks[sp->rank], co);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2767,7 +2769,7 @@ void magic(void)
|
|||
for (co = spellranks[rank].begin; co; co = co->next) {
|
||||
order *ord = co->order;
|
||||
int invalid, resist, success, cast_level = co->level;
|
||||
boolean fumbled = false;
|
||||
bool fumbled = false;
|
||||
unit *u = co->magician.u;
|
||||
const spell *sp = co->sp;
|
||||
region *target_r = co_get_region(co);
|
||||
|
|
|
@ -192,7 +192,7 @@ typedef struct sc_mage {
|
|||
|
||||
void magic(void);
|
||||
|
||||
void regeneration_magiepunkte(void);
|
||||
void regenerate_aura(void);
|
||||
|
||||
extern struct attrib_type at_seenspell;
|
||||
extern struct attrib_type at_mage;
|
||||
|
@ -228,9 +228,9 @@ typedef struct sc_mage {
|
|||
* und initialisiert den Magiertypus mit mtyp. */
|
||||
sc_mage *get_mage(const struct unit *u);
|
||||
/* gibt u->mage zurück, bei nicht-Magiern *NULL */
|
||||
boolean is_mage(const struct unit *u);
|
||||
bool is_mage(const struct unit *u);
|
||||
/* gibt true, wenn u->mage gesetzt. */
|
||||
boolean is_familiar(const struct unit *u);
|
||||
bool is_familiar(const struct unit *u);
|
||||
/* gibt true, wenn eine Familiar-Relation besteht. */
|
||||
|
||||
/* Sprüche */
|
||||
|
@ -253,7 +253,7 @@ typedef struct sc_mage {
|
|||
/* fügt alle Zauber des Magiegebietes der Einheit, deren Stufe kleiner
|
||||
* als das aktuelle Magietalent ist, in die Spruchliste der Einheit
|
||||
* ein */
|
||||
boolean knowsspell(const struct region *r, const struct unit *u,
|
||||
bool knowsspell(const struct region *r, const struct unit *u,
|
||||
const struct spell * sp);
|
||||
/* prüft, ob die Einheit diesen Spruch gerade beherrscht, dh
|
||||
* mindestens die erforderliche Stufe hat. Hier können auch Abfragen
|
||||
|
@ -277,7 +277,7 @@ typedef struct sc_mage {
|
|||
extern double spellpower(struct region *r, struct unit *u, const struct spell * sp,
|
||||
int cast_level, struct order *ord);
|
||||
/* ermittelt die Stärke eines Spruchs */
|
||||
boolean fumble(struct region *r, struct unit *u, const struct spell * sp,
|
||||
bool fumble(struct region *r, struct unit *u, const struct spell * sp,
|
||||
int cast_level);
|
||||
/* true, wenn der Zauber misslingt, bei false gelingt der Zauber */
|
||||
|
||||
|
@ -304,7 +304,7 @@ typedef struct sc_mage {
|
|||
/* gibt die für diesen Spruch derzeit notwendigen Magiepunkte auf der
|
||||
* geringstmöglichen Stufe zurück, schon um den Faktor der bereits
|
||||
* zuvor gezauberten Sprüche erhöht */
|
||||
boolean cancast(struct unit *u, const struct spell * spruch, int eff_stufe,
|
||||
bool cancast(struct unit *u, const struct spell * spruch, int eff_stufe,
|
||||
int distance, struct order *ord);
|
||||
/* true, wenn Einheit alle Komponenten des Zaubers (incl. MP) für die
|
||||
* geringstmögliche Stufe hat und den Spruch beherrscht */
|
||||
|
@ -317,13 +317,13 @@ typedef struct sc_mage {
|
|||
/* ermittelt die effektive Stufe des Zaubers. Dabei ist cast_level
|
||||
* die gewünschte maximale Stufe (im Normalfall Stufe des Magiers,
|
||||
* bei Farcasting Stufe*2^Entfernung) */
|
||||
boolean is_magic_resistant(struct unit *magician, struct unit *target, int
|
||||
bool is_magic_resistant(struct unit *magician, struct unit *target, int
|
||||
resist_bonus);
|
||||
/* Mapperfunktion für target_resists_magic() vom Typ struct unit. */
|
||||
extern double magic_resistance(struct unit *target);
|
||||
/* gibt die Chance an, mit der einem Zauber widerstanden wird. Je
|
||||
* größer, desto resistenter ist da Opfer */
|
||||
boolean target_resists_magic(struct unit *magician, void *obj, int objtyp,
|
||||
bool target_resists_magic(struct unit *magician, void *obj, int objtyp,
|
||||
int resist_bonus);
|
||||
/* gibt false zurück, wenn der Zauber gelingt, true, wenn das Ziel
|
||||
* widersteht */
|
||||
|
@ -339,7 +339,7 @@ typedef struct sc_mage {
|
|||
extern struct attrib_type at_familiar;
|
||||
extern struct attrib_type at_familiarmage;
|
||||
extern void remove_familiar(struct unit *mage);
|
||||
extern boolean create_newfamiliar(struct unit *mage, struct unit *familiar);
|
||||
extern bool create_newfamiliar(struct unit *mage, struct unit *familiar);
|
||||
extern void create_newclone(struct unit *mage, struct unit *familiar);
|
||||
extern struct unit *has_clone(struct unit *mage);
|
||||
|
||||
|
|
|
@ -176,18 +176,11 @@ attrib_type at_speedup = {
|
|||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
direction_t getdirection(const struct locale * lang)
|
||||
{
|
||||
return finddirection(getstrtoken(), lang);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------- */
|
||||
|
||||
static attrib_type at_driveweight = {
|
||||
"driveweight", NULL, NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
static boolean entrance_allowed(const struct unit *u, const struct region *r)
|
||||
static bool entrance_allowed(const struct unit *u, const struct region *r)
|
||||
{
|
||||
#ifdef REGIONOWNERS
|
||||
faction *owner = region_get_owner(r);
|
||||
|
@ -372,7 +365,7 @@ static int canwalk(unit * u)
|
|||
return E_CANWALK_TOOHEAVY;
|
||||
}
|
||||
|
||||
boolean canfly(unit * u)
|
||||
bool canfly(unit * u)
|
||||
{
|
||||
if (get_item(u, I_PEGASUS) >= u->number && effskill(u, SK_RIDING) >= 4)
|
||||
return true;
|
||||
|
@ -386,7 +379,7 @@ boolean canfly(unit * u)
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean canswim(unit * u)
|
||||
bool canswim(unit * u)
|
||||
{
|
||||
if (get_item(u, I_DOLPHIN) >= u->number && effskill(u, SK_RIDING) >= 4)
|
||||
return true;
|
||||
|
@ -448,7 +441,7 @@ static int canride(unit * u)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static boolean cansail(const region * r, ship * sh)
|
||||
static bool cansail(const region * r, ship * sh)
|
||||
{
|
||||
/* sonst ist construction:: size nicht ship_type::maxsize */
|
||||
assert(!sh->type->construction
|
||||
|
@ -584,7 +577,7 @@ ship *move_ship(ship * sh, region * from, region * to, region_list * route)
|
|||
{
|
||||
unit **iunit = &from->units;
|
||||
unit **ulist = &to->units;
|
||||
boolean trail = (route == NULL);
|
||||
bool trail = (route == NULL);
|
||||
|
||||
if (from != to) {
|
||||
translist(&from->ships, &to->ships, sh);
|
||||
|
@ -619,7 +612,7 @@ ship *move_ship(ship * sh, region * from, region * to, region_list * route)
|
|||
return sh;
|
||||
}
|
||||
|
||||
static boolean is_freezing(const unit * u)
|
||||
static bool is_freezing(const unit * u)
|
||||
{
|
||||
if (u->race != new_race[RC_INSECT])
|
||||
return false;
|
||||
|
@ -628,12 +621,7 @@ static boolean is_freezing(const unit * u)
|
|||
return true;
|
||||
}
|
||||
|
||||
#define SA_HARBOUR 1
|
||||
#define SA_COAST 1
|
||||
#define SA_NO_INSECT -1
|
||||
#define SA_NO_COAST -2
|
||||
|
||||
static int is_ship_allowed(struct ship *sh, const region * r)
|
||||
int check_ship_allowed(struct ship *sh, const region * r)
|
||||
{
|
||||
int c = 0;
|
||||
static const building_type *bt_harbour = NULL;
|
||||
|
@ -641,7 +629,7 @@ static int is_ship_allowed(struct ship *sh, const region * r)
|
|||
if (bt_harbour == NULL)
|
||||
bt_harbour = bt_find("harbour");
|
||||
|
||||
if (r_insectstalled(r)) {
|
||||
if (sh->region && r_insectstalled(r)) {
|
||||
/* insekten dürfen nicht hier rein. haben wir welche? */
|
||||
unit *u;
|
||||
|
||||
|
@ -661,7 +649,7 @@ static int is_ship_allowed(struct ship *sh, const region * r)
|
|||
}
|
||||
}
|
||||
|
||||
if (buildingtype_exists(r, bt_harbour, true))
|
||||
if (bt_harbour && buildingtype_exists(r, bt_harbour, true))
|
||||
return SA_HARBOUR;
|
||||
for (c = 0; sh->type->coasts[c] != NULL; ++c) {
|
||||
if (sh->type->coasts[c] == r->terrain)
|
||||
|
@ -671,7 +659,7 @@ static int is_ship_allowed(struct ship *sh, const region * r)
|
|||
return SA_NO_COAST;
|
||||
}
|
||||
|
||||
static boolean flying_ship(const ship * sh)
|
||||
static bool flying_ship(const ship * sh)
|
||||
{
|
||||
if (sh->type->flags & SFL_FLY)
|
||||
return true;
|
||||
|
@ -704,7 +692,7 @@ static float damage_drift(void)
|
|||
static void drifting_ships(region * r)
|
||||
{
|
||||
direction_t d;
|
||||
if (get_param_int(global.parameters, "rules.ship.drifting", 1)==0) return;
|
||||
bool drift = get_param_int(global.parameters, "rules.ship.drifting", 1)!=0;
|
||||
|
||||
if (fval(r->terrain, SEA_REGION)) {
|
||||
ship **shp = &r->ships;
|
||||
|
@ -721,7 +709,7 @@ static void drifting_ships(region * r)
|
|||
}
|
||||
|
||||
/* Schiff schon abgetrieben oder durch Zauber geschützt? */
|
||||
if (fval(sh, SF_DRIFTED) || is_cursed(sh->attribs, C_SHIP_NODRIFT, 0)) {
|
||||
if (!drift || fval(sh, SF_DRIFTED) || is_cursed(sh->attribs, C_SHIP_NODRIFT, 0)) {
|
||||
shp = &sh->next;
|
||||
continue;
|
||||
}
|
||||
|
@ -753,7 +741,7 @@ static void drifting_ships(region * r)
|
|||
region *rn;
|
||||
dir = (direction_t) ((d + d_offset) % MAXDIRECTIONS);
|
||||
rn = rconnect(r, dir);
|
||||
if (rn != NULL && fval(rn->terrain, SAIL_INTO) && is_ship_allowed(sh, rn) > 0) {
|
||||
if (rn != NULL && fval(rn->terrain, SAIL_INTO) && check_ship_allowed(sh, rn) > 0) {
|
||||
rnext = rn;
|
||||
if (!fval(rnext->terrain, SEA_REGION))
|
||||
break;
|
||||
|
@ -804,9 +792,9 @@ static void drifting_ships(region * r)
|
|||
}
|
||||
}
|
||||
|
||||
static boolean present(region * r, unit * u)
|
||||
static bool present(region * r, unit * u)
|
||||
{
|
||||
return (boolean) (u && u->region == r);
|
||||
return (bool) (u && u->region == r);
|
||||
}
|
||||
|
||||
static void caught_target(region * r, unit * u)
|
||||
|
@ -837,7 +825,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r)
|
|||
{
|
||||
unit *u;
|
||||
int perception = 0;
|
||||
boolean contact = false;
|
||||
bool contact = false;
|
||||
unit *guard = NULL;
|
||||
|
||||
if (fval(reisender->race, RCF_ILLUSIONARY))
|
||||
|
@ -871,7 +859,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static boolean is_guardian_u(const unit * guard, unit * u, unsigned int mask)
|
||||
static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask)
|
||||
{
|
||||
if (guard->faction == u->faction)
|
||||
return false;
|
||||
|
@ -887,7 +875,7 @@ static boolean is_guardian_u(const unit * guard, unit * u, unsigned int mask)
|
|||
return true;
|
||||
}
|
||||
|
||||
static boolean is_guardian_r(const unit * guard)
|
||||
static bool is_guardian_r(const unit * guard)
|
||||
{
|
||||
if (guard->number == 0)
|
||||
return false;
|
||||
|
@ -912,7 +900,7 @@ static boolean is_guardian_r(const unit * guard)
|
|||
return true;
|
||||
}
|
||||
|
||||
boolean is_guard(const struct unit * u, int mask)
|
||||
bool is_guard(const struct unit * u, int mask)
|
||||
{
|
||||
return is_guardian_r(u) && (getguard(u) & mask) != 0;
|
||||
}
|
||||
|
@ -1011,8 +999,8 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
|||
char neworder[2048];
|
||||
const char *token;
|
||||
direction_t d = NODIRECTION;
|
||||
boolean paused = false;
|
||||
boolean pause;
|
||||
bool paused = false;
|
||||
bool pause;
|
||||
order *norder;
|
||||
size_t size = sizeof(tail) - 1;
|
||||
|
||||
|
@ -1086,7 +1074,7 @@ static void cycle_route(order * ord, unit * u, int gereist)
|
|||
free_order(norder);
|
||||
}
|
||||
|
||||
static boolean transport(unit * ut, unit * u)
|
||||
static bool transport(unit * ut, unit * u)
|
||||
{
|
||||
order *ord;
|
||||
|
||||
|
@ -1106,7 +1094,7 @@ static boolean transport(unit * ut, unit * u)
|
|||
return false;
|
||||
}
|
||||
|
||||
static boolean can_move(const unit * u)
|
||||
static bool can_move(const unit * u)
|
||||
{
|
||||
if (u->race->flags & RCF_CANNOTMOVE)
|
||||
return false;
|
||||
|
@ -1185,7 +1173,7 @@ static void init_transportation(void)
|
|||
}
|
||||
}
|
||||
|
||||
static boolean roadto(const region * r, direction_t dir)
|
||||
static bool roadto(const region * r, direction_t dir)
|
||||
{
|
||||
/* wenn es hier genug strassen gibt, und verbunden ist, und es dort
|
||||
* genug strassen gibt, dann existiert eine strasse in diese richtung */
|
||||
|
@ -1329,7 +1317,7 @@ static int movement_speed(unit * u)
|
|||
{
|
||||
int mp;
|
||||
static const curse_type *speed_ct;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
double dk = u->race->speed;
|
||||
|
||||
assert(u->number);
|
||||
|
@ -1428,7 +1416,7 @@ static const region_list *travel_route(unit * u,
|
|||
region *current = u->region;
|
||||
const region_list *iroute = route_begin;
|
||||
int steps = 0;
|
||||
boolean landing = false; /* aquarians have landed */
|
||||
bool landing = false; /* aquarians have landed */
|
||||
|
||||
while (iroute && iroute != route_end) {
|
||||
region *next = iroute->data;
|
||||
|
@ -1586,7 +1574,7 @@ static const region_list *travel_route(unit * u,
|
|||
return iroute;
|
||||
}
|
||||
|
||||
static boolean ship_ready(const region * r, unit * u)
|
||||
static bool ship_ready(const region * r, unit * u)
|
||||
{
|
||||
if (!u->ship || u!=ship_owner(u->ship)) {
|
||||
cmistake(u, u->thisorder, 146, MSG_MOVE);
|
||||
|
@ -1633,8 +1621,8 @@ unit *owner_buildingtyp(const region * r, const building_type * bt)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean
|
||||
buildingtype_exists(const region * r, const building_type * bt, boolean working)
|
||||
bool
|
||||
buildingtype_exists(const region * r, const building_type * bt, bool working)
|
||||
{
|
||||
building *b;
|
||||
|
||||
|
@ -1648,7 +1636,7 @@ buildingtype_exists(const region * r, const building_type * bt, boolean working)
|
|||
|
||||
/* Prüft, ob Ablegen von einer Küste in eine der erlaubten Richtungen erfolgt. */
|
||||
|
||||
static boolean check_takeoff(ship * sh, region * from, region * to)
|
||||
static bool check_takeoff(ship * sh, region * from, region * to)
|
||||
{
|
||||
if (!fval(from->terrain, SEA_REGION) && sh->coast != NODIRECTION) {
|
||||
direction_t coast = sh->coast;
|
||||
|
@ -1667,7 +1655,7 @@ static boolean check_takeoff(ship * sh, region * from, region * to)
|
|||
}
|
||||
|
||||
static void
|
||||
sail(unit * u, order * ord, boolean move_on_land, region_list ** routep)
|
||||
sail(unit * u, order * ord, bool move_on_land, region_list ** routep)
|
||||
{
|
||||
region *starting_point = u->region;
|
||||
region *current_point, *last_point;
|
||||
|
@ -1732,9 +1720,12 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep)
|
|||
int reason;
|
||||
|
||||
if (gamecookie != global.cookie) {
|
||||
gamedate date;
|
||||
get_gamedate(turn, &date);
|
||||
stormyness = storms[date.month] * 5;
|
||||
bool storms_enabled = get_param_int(global.parameters, "rules.ship.storms", 1)!=0;
|
||||
if (storms_enabled) {
|
||||
gamedate date;
|
||||
get_gamedate(turn, &date);
|
||||
stormyness = storms[date.month] * 5;
|
||||
}
|
||||
gamecookie = global.cookie;
|
||||
}
|
||||
|
||||
|
@ -1747,7 +1738,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep)
|
|||
&& fval(current_point->terrain, SEA_REGION)) {
|
||||
if (!is_cursed(sh->attribs, C_SHIP_NODRIFT, 0)) {
|
||||
region *rnext = NULL;
|
||||
boolean storm = true;
|
||||
bool storm = true;
|
||||
int d_offset = rng_int() % MAXDIRECTIONS;
|
||||
direction_t d;
|
||||
/* Sturm nur, wenn nächste Region Hochsee ist. */
|
||||
|
@ -1816,7 +1807,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep)
|
|||
}
|
||||
}
|
||||
|
||||
reason = is_ship_allowed(sh, next_point);
|
||||
reason = check_ship_allowed(sh, next_point);
|
||||
if (reason<0) {
|
||||
/* for some reason or another, we aren't allowed in there.. */
|
||||
if (check_leuchtturm(current_point, NULL) || reason == SA_NO_INSECT) {
|
||||
|
@ -2035,7 +2026,7 @@ static const region_list *travel_i(unit * u, const region_list * route_begin,
|
|||
} else if (!can_move(ut)) {
|
||||
cmistake(u, ord, 99, MSG_MOVE);
|
||||
} else {
|
||||
boolean found = false;
|
||||
bool found = false;
|
||||
|
||||
if (!fval(ut, UFL_NOTMOVING) && !LongHunger(ut)) {
|
||||
init_tokens(ut->thisorder);
|
||||
|
@ -2150,7 +2141,7 @@ static void travel(unit * u, region_list ** routep)
|
|||
|
||||
}
|
||||
|
||||
static void move(unit * u, boolean move_on_land)
|
||||
static void move(unit * u, bool move_on_land)
|
||||
{
|
||||
region_list *route = NULL;
|
||||
|
||||
|
@ -2556,7 +2547,7 @@ void movement(void)
|
|||
region *r = regions;
|
||||
while (r != NULL) {
|
||||
unit **up = &r->units;
|
||||
boolean repeat = false;
|
||||
bool repeat = false;
|
||||
|
||||
while (*up) {
|
||||
unit *u = *up;
|
||||
|
@ -2676,7 +2667,7 @@ void follow_unit(unit * u)
|
|||
|
||||
if (a && !fval(u, UFL_MOVED | UFL_NOTMOVING)) {
|
||||
unit *u2 = a->data.v;
|
||||
boolean follow = false;
|
||||
bool follow = false;
|
||||
|
||||
if (!u2 || u2->region != r || !cansee(u->faction, r, u2, 0)) {
|
||||
return;
|
||||
|
@ -2706,12 +2697,13 @@ void follow_unit(unit * u)
|
|||
attrib *a2 = a_find(u2->attribs, &at_follow);
|
||||
if (a2 != NULL) {
|
||||
unit *u3 = a2->data.v;
|
||||
follow = (u3 && u2->region == u2->region);
|
||||
follow = (u3 && u2->region == u3->region);
|
||||
}
|
||||
}
|
||||
if (follow) {
|
||||
fset(u, UFL_FOLLOWING);
|
||||
fset(u2, UFL_FOLLOWED);
|
||||
/* FOLLOW unit on a (potentially) moving unit prevents long orders */
|
||||
set_order(&u->thisorder, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,27 +47,32 @@ extern "C" {
|
|||
** pferde, macht nur noch 100, aber samt eigenem gewicht (40) macht also 140. */
|
||||
|
||||
int personcapacity(const struct unit *u);
|
||||
direction_t getdirection(const struct locale *);
|
||||
void movement(void);
|
||||
void run_to(struct unit *u, struct region *to);
|
||||
struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask);
|
||||
boolean is_guard(const struct unit *u, int mask);
|
||||
bool is_guard(const struct unit *u, int mask);
|
||||
int enoughsailors(const struct ship *sh, const struct region *r);
|
||||
boolean canswim(struct unit *u);
|
||||
boolean canfly(struct unit *u);
|
||||
bool canswim(struct unit *u);
|
||||
bool canfly(struct unit *u);
|
||||
struct unit *get_captain(const struct ship *sh);
|
||||
void travelthru(const struct unit *u, struct region *r);
|
||||
struct ship *move_ship(struct ship *sh, struct region *from,
|
||||
struct region *to, struct region_list *route);
|
||||
int walkingcapacity(const struct unit *u);
|
||||
void follow_unit(struct unit *u);
|
||||
boolean buildingtype_exists(const struct region *r,
|
||||
const struct building_type *bt, boolean working);
|
||||
bool buildingtype_exists(const struct region *r,
|
||||
const struct building_type *bt, bool working);
|
||||
struct unit *owner_buildingtyp(const struct region *r,
|
||||
const struct building_type *bt);
|
||||
|
||||
extern struct attrib_type at_speedup;
|
||||
|
||||
#define SA_HARBOUR 2
|
||||
#define SA_COAST 1
|
||||
#define SA_NO_INSECT -1
|
||||
#define SA_NO_COAST -2
|
||||
|
||||
extern int check_ship_allowed(struct ship *sh, const struct region * r);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -4,12 +4,57 @@
|
|||
#include <kernel/building.h>
|
||||
#include <kernel/move.h>
|
||||
#include <kernel/region.h>
|
||||
#include <kernel/ship.h>
|
||||
#include <kernel/terrain.h>
|
||||
|
||||
#include <util/language.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
||||
static void test_ship_not_allowed_in_coast(CuTest * tc)
|
||||
{
|
||||
region *r;
|
||||
ship * sh;
|
||||
terrain_type * ttype;
|
||||
ship_type * stype;
|
||||
const char * names[] = { "derp", "derp_p" };
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
ttype = test_create_terrain("glacier", LAND_REGION|ARCTIC_REGION|WALK_INTO|SAIL_INTO);
|
||||
stype = test_create_shiptype(names);
|
||||
stype->coasts = (const struct terrain_type **)calloc(2, sizeof(const struct terrain_type *));
|
||||
|
||||
r = test_create_region(0, 0, ttype);
|
||||
sh = test_create_ship(0, stype);
|
||||
|
||||
CuAssertIntEquals(tc, SA_NO_COAST, check_ship_allowed(sh, r));
|
||||
stype->coasts[0] = ttype;
|
||||
CuAssertIntEquals(tc, SA_COAST, check_ship_allowed(sh, r));
|
||||
}
|
||||
|
||||
static void test_ship_allowed_with_harbor(CuTest * tc)
|
||||
{
|
||||
region *r;
|
||||
ship * sh;
|
||||
terrain_type * ttype;
|
||||
building_type * btype;
|
||||
|
||||
test_cleanup();
|
||||
test_create_world();
|
||||
|
||||
ttype = test_create_terrain("glacier", LAND_REGION|ARCTIC_REGION|WALK_INTO|SAIL_INTO);
|
||||
btype = test_create_buildingtype("harbour");
|
||||
|
||||
r = test_create_region(0, 0, ttype);
|
||||
sh = test_create_ship(0, 0);
|
||||
|
||||
test_create_building(r, btype);
|
||||
CuAssertIntEquals(tc, SA_HARBOUR, check_ship_allowed(sh, r));
|
||||
}
|
||||
|
||||
static void test_building_type_exists(CuTest * tc)
|
||||
{
|
||||
region *r;
|
||||
|
@ -35,5 +80,7 @@ CuSuite *get_move_suite(void)
|
|||
{
|
||||
CuSuite *suite = CuSuiteNew();
|
||||
SUITE_ADD_TEST(suite, test_building_type_exists);
|
||||
SUITE_ADD_TEST(suite, test_ship_not_allowed_in_coast);
|
||||
SUITE_ADD_TEST(suite, test_ship_allowed_with_harbor);
|
||||
return suite;
|
||||
}
|
||||
|
|
|
@ -260,10 +260,6 @@ static order *create_order_i(keyword_t kwd, const char *sptr, int persistent,
|
|||
case K_KOMMENTAR:
|
||||
case NOKEYWORD:
|
||||
return NULL;
|
||||
case K_LIEFERE:
|
||||
kwd = K_GIVE;
|
||||
persistent = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -373,7 +369,7 @@ order *parse_order(const char *s, const struct locale * lang)
|
|||
* \return true if the order is long
|
||||
* \sa is_exclusive(), is_repeated(), is_persistent()
|
||||
*/
|
||||
int is_repeated(const order * ord)
|
||||
bool is_repeated(const order * ord)
|
||||
{
|
||||
keyword_t kwd = ORD_KEYWORD(ord);
|
||||
const struct locale *lang = ORD_LOCALE(ord);
|
||||
|
@ -439,7 +435,7 @@ int is_repeated(const order * ord)
|
|||
* \return true if the order is long
|
||||
* \sa is_exclusive(), is_repeated(), is_persistent()
|
||||
*/
|
||||
int is_exclusive(const order * ord)
|
||||
bool is_exclusive(const order * ord)
|
||||
{
|
||||
keyword_t kwd = ORD_KEYWORD(ord);
|
||||
const struct locale *lang = ORD_LOCALE(ord);
|
||||
|
@ -447,8 +443,6 @@ int is_exclusive(const order * ord)
|
|||
|
||||
switch (kwd) {
|
||||
case K_MOVE:
|
||||
case K_WEREWOLF:
|
||||
/* these should not become persistent */
|
||||
case K_ROUTE:
|
||||
case K_DRIVE:
|
||||
case K_WORK:
|
||||
|
@ -502,18 +496,17 @@ int is_exclusive(const order * ord)
|
|||
* \return true if the order is long
|
||||
* \sa is_exclusive(), is_repeated(), is_persistent()
|
||||
*/
|
||||
int is_long(const order * ord)
|
||||
bool is_long(const order * ord)
|
||||
{
|
||||
keyword_t kwd = ORD_KEYWORD(ord);
|
||||
const struct locale *lang = ORD_LOCALE(ord);
|
||||
int result = 0;
|
||||
bool result = false;
|
||||
|
||||
switch (kwd) {
|
||||
case K_CAST:
|
||||
case K_BUY:
|
||||
case K_SELL:
|
||||
case K_MOVE:
|
||||
case K_WEREWOLF:
|
||||
case K_ROUTE:
|
||||
case K_DRIVE:
|
||||
case K_WORK:
|
||||
|
@ -553,7 +546,7 @@ int is_long(const order * ord)
|
|||
parser_popstate();
|
||||
break;
|
||||
default:
|
||||
result = 0;
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -567,19 +560,17 @@ int is_long(const order * ord)
|
|||
* \return true if the order is persistent
|
||||
* \sa is_exclusive(), is_repeated(), is_persistent()
|
||||
*/
|
||||
int is_persistent(const order * ord)
|
||||
bool is_persistent(const order * ord)
|
||||
{
|
||||
keyword_t kwd = ORD_KEYWORD(ord);
|
||||
int persist = ord->_persistent != 0;
|
||||
switch (kwd) {
|
||||
case K_MOVE:
|
||||
case K_WEREWOLF:
|
||||
case NOKEYWORD:
|
||||
/* lang, aber niemals persistent! */
|
||||
return false;
|
||||
|
||||
case K_KOMMENTAR:
|
||||
case K_LIEFERE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -610,3 +601,9 @@ void push_order(order ** ordp, order * ord)
|
|||
ordp = &(*ordp)->next;
|
||||
*ordp = ord;
|
||||
}
|
||||
|
||||
void init_tokens(const struct order *ord)
|
||||
{
|
||||
char *cmd = getcommand(ord);
|
||||
init_tokens_str(cmd, cmd);
|
||||
}
|
||||
|
|
|
@ -51,12 +51,13 @@ extern "C" {
|
|||
extern keyword_t get_keyword(const order * ord);
|
||||
extern void set_order(order ** destp, order * src);
|
||||
extern char *getcommand(const order * ord);
|
||||
extern int is_persistent(const order * ord);
|
||||
extern int is_exclusive(const order * ord);
|
||||
extern int is_repeated(const order * ord);
|
||||
extern int is_long(const order * ord);
|
||||
extern bool is_persistent(const order * ord);
|
||||
extern bool is_exclusive(const order * ord);
|
||||
extern bool is_repeated(const order * ord);
|
||||
extern bool is_long(const order * ord);
|
||||
|
||||
extern char *write_order(const order * ord, char *buffer, size_t size);
|
||||
extern void init_tokens(const struct order *ord); /* initialize token parsing */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -28,21 +28,21 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
boolean allowed_swim(const region * src, const region * r)
|
||||
bool allowed_swim(const region * src, const region * r)
|
||||
{
|
||||
if (fval(r->terrain, SWIM_INTO))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean allowed_walk(const region * src, const region * r)
|
||||
bool allowed_walk(const region * src, const region * r)
|
||||
{
|
||||
if (fval(r->terrain, WALK_INTO))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean allowed_fly(const region * src, const region * r)
|
||||
bool allowed_fly(const region * src, const region * r)
|
||||
{
|
||||
if (fval(r->terrain, FLY_INTO))
|
||||
return true;
|
||||
|
@ -100,7 +100,7 @@ static void free_nodes(node * root)
|
|||
}
|
||||
|
||||
struct quicklist *regions_in_range(struct region *start, int maxdist,
|
||||
boolean(*allowed) (const struct region *, const struct region *))
|
||||
bool(*allowed) (const struct region *, const struct region *))
|
||||
{
|
||||
quicklist * rlist = NULL;
|
||||
node *root = new_node(start, 0, NULL);
|
||||
|
@ -140,14 +140,14 @@ struct quicklist *regions_in_range(struct region *start, int maxdist,
|
|||
}
|
||||
|
||||
static region **internal_path_find(region * start, const region * target,
|
||||
int maxlen, boolean(*allowed) (const region *, const region *))
|
||||
int maxlen, bool(*allowed) (const region *, const region *))
|
||||
{
|
||||
static region *path[MAXDEPTH + 2]; /* STATIC_RETURN: used for return, not across calls */
|
||||
direction_t d;
|
||||
node *root = new_node(start, 0, NULL);
|
||||
node **end = &root->next;
|
||||
node *n = root;
|
||||
boolean found = false;
|
||||
bool found = false;
|
||||
assert(maxlen <= MAXDEPTH);
|
||||
fset(start, RF_MARK);
|
||||
|
||||
|
@ -190,9 +190,9 @@ static region **internal_path_find(region * start, const region * target,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean
|
||||
bool
|
||||
path_exists(region * start, const region * target, int maxlen,
|
||||
boolean(*allowed) (const region *, const region *))
|
||||
bool(*allowed) (const region *, const region *))
|
||||
{
|
||||
assert((!fval(start, RF_MARK) && !fval(target, RF_MARK))
|
||||
|| !"Some Algorithm did not clear its RF_MARKs!");
|
||||
|
@ -204,7 +204,7 @@ path_exists(region * start, const region * target, int maxlen,
|
|||
}
|
||||
|
||||
region **path_find(region * start, const region * target, int maxlen,
|
||||
boolean(*allowed) (const region *, const region *))
|
||||
bool(*allowed) (const region *, const region *))
|
||||
{
|
||||
assert((!fval(start, RF_MARK) && !fval(target, RF_MARK))
|
||||
|| !"Did you call path_init()?");
|
||||
|
|
|
@ -29,18 +29,18 @@ extern "C" {
|
|||
|
||||
extern struct region **path_find(struct region *start,
|
||||
const struct region *target, int maxlen,
|
||||
boolean(*allowed) (const struct region *, const struct region *));
|
||||
extern boolean path_exists(struct region *start, const struct region *target,
|
||||
int maxlen, boolean(*allowed) (const struct region *,
|
||||
bool(*allowed) (const struct region *, const struct region *));
|
||||
extern bool path_exists(struct region *start, const struct region *target,
|
||||
int maxlen, bool(*allowed) (const struct region *,
|
||||
const struct region *));
|
||||
extern boolean allowed_swim(const struct region *src,
|
||||
extern bool allowed_swim(const struct region *src,
|
||||
const struct region *target);
|
||||
extern boolean allowed_fly(const struct region *src,
|
||||
extern bool allowed_fly(const struct region *src,
|
||||
const struct region *target);
|
||||
extern boolean allowed_walk(const struct region *src,
|
||||
extern bool allowed_walk(const struct region *src,
|
||||
const struct region *target);
|
||||
extern struct quicklist *regions_in_range(struct region *src, int maxdist,
|
||||
boolean(*allowed) (const struct region *, const struct region *));
|
||||
bool(*allowed) (const struct region *, const struct region *));
|
||||
|
||||
extern void pathfinder_cleanup(void);
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ int read_plane_reference(plane ** pp, struct storage *store)
|
|||
return AT_READ_OK;
|
||||
}
|
||||
|
||||
boolean is_watcher(const struct plane * p, const struct faction * f)
|
||||
bool is_watcher(const struct plane * p, const struct faction * f)
|
||||
{
|
||||
struct watcher *w;
|
||||
if (!p)
|
||||
|
|
|
@ -73,7 +73,7 @@ extern "C" {
|
|||
struct plane *get_homeplane(void);
|
||||
extern int rel_to_abs(const struct plane *pl, const struct faction *f,
|
||||
int rel, unsigned char index);
|
||||
extern boolean is_watcher(const struct plane *p, const struct faction *f);
|
||||
extern bool is_watcher(const struct plane *p, const struct faction *f);
|
||||
extern int resolve_plane(variant data, void *addr);
|
||||
extern void write_plane_reference(const plane * p, struct storage *store);
|
||||
extern int read_plane_reference(plane ** pp, struct storage *store);
|
||||
|
|
|
@ -96,7 +96,7 @@ int change_resource(unit * u, const resource_type * rtype, int change)
|
|||
|
||||
int get_reservation(const unit * u, const resource_type * rtype)
|
||||
{
|
||||
struct reservation *res = u->reservations;
|
||||
reservation *res = u->reservations;
|
||||
|
||||
if (rtype == oldresourcetype[R_STONE] && (u->race->flags & RCF_STONEGOLEM))
|
||||
return (u->number * GOLEM_STONE);
|
||||
|
@ -111,7 +111,7 @@ int get_reservation(const unit * u, const resource_type * rtype)
|
|||
|
||||
int change_reservation(unit * u, const resource_type * rtype, int value)
|
||||
{
|
||||
struct reservation *res, **rp = &u->reservations;
|
||||
reservation *res, **rp = &u->reservations;
|
||||
|
||||
if (!value)
|
||||
return 0;
|
||||
|
@ -120,7 +120,7 @@ int change_reservation(unit * u, const resource_type * rtype, int value)
|
|||
rp = &(*rp)->next;
|
||||
res = *rp;
|
||||
if (!res) {
|
||||
*rp = res = calloc(sizeof(struct reservation), 1);
|
||||
*rp = res = calloc(sizeof(reservation), 1);
|
||||
res->type = rtype;
|
||||
res->value = value;
|
||||
} else if (res && res->value + value <= 0) {
|
||||
|
@ -133,9 +133,9 @@ int change_reservation(unit * u, const resource_type * rtype, int value)
|
|||
return res->value;
|
||||
}
|
||||
|
||||
static int new_set_resvalue(unit * u, const resource_type * rtype, int value)
|
||||
int set_resvalue(unit * u, const resource_type * rtype, int value)
|
||||
{
|
||||
struct reservation *res, **rp = &u->reservations;
|
||||
reservation *res, **rp = &u->reservations;
|
||||
|
||||
while (*rp && (*rp)->type != rtype)
|
||||
rp = &(*rp)->next;
|
||||
|
@ -143,7 +143,7 @@ static int new_set_resvalue(unit * u, const resource_type * rtype, int value)
|
|||
if (!res) {
|
||||
if (!value)
|
||||
return 0;
|
||||
*rp = res = calloc(sizeof(struct reservation), 1);
|
||||
*rp = res = calloc(sizeof(reservation), 1);
|
||||
res->type = rtype;
|
||||
res->value = value;
|
||||
} else if (res && value <= 0) {
|
||||
|
@ -253,34 +253,3 @@ use_pooled(unit * u, const resource_type * rtype, unsigned int mode, int count)
|
|||
}
|
||||
return count - use;
|
||||
}
|
||||
|
||||
int reserve_cmd(unit * u, struct order *ord)
|
||||
{
|
||||
if (u->number > 0 && (urace(u)->ec_flags & GETITEM)) {
|
||||
int use, count;
|
||||
const resource_type *rtype;
|
||||
const char *s;
|
||||
|
||||
init_tokens(ord);
|
||||
skip_token();
|
||||
s = getstrtoken();
|
||||
count = atoip((const char *)s);
|
||||
|
||||
if (count == 0 && findparam(s, u->faction->locale) == P_EACH) {
|
||||
count = getint() * u->number;
|
||||
}
|
||||
|
||||
rtype = findresourcetype(getstrtoken(), u->faction->locale);
|
||||
if (rtype == NULL)
|
||||
return 0;
|
||||
|
||||
new_set_resvalue(u, rtype, 0); /* make sure the pool is empty */
|
||||
use = use_pooled(u, rtype, GET_DEFAULT, count);
|
||||
if (use) {
|
||||
new_set_resvalue(u, rtype, use);
|
||||
change_resource(u, rtype, use);
|
||||
return use;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -54,11 +54,7 @@ extern "C" {
|
|||
int change_reservation(struct unit *u, const struct resource_type *res,
|
||||
int value);
|
||||
|
||||
int reserve_cmd(struct unit *u, struct order *ord);
|
||||
|
||||
/** init_pool
|
||||
* initialisiert den regionalen Pool.
|
||||
*/
|
||||
int set_resvalue(struct unit * u, const struct resource_type * rtype, int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ race *rc_find(const char *name)
|
|||
}
|
||||
|
||||
/** dragon movement **/
|
||||
boolean allowed_dragon(const region * src, const region * target)
|
||||
bool allowed_dragon(const region * src, const region * target)
|
||||
{
|
||||
if (fval(src->terrain, ARCTIC_REGION) && fval(target->terrain, SEA_REGION))
|
||||
return false;
|
||||
|
@ -187,7 +187,7 @@ void set_show_item(faction * f, item_t i)
|
|||
a->data.v = (void *)olditemtype[i];
|
||||
}
|
||||
|
||||
boolean r_insectstalled(const region * r)
|
||||
bool r_insectstalled(const region * r)
|
||||
{
|
||||
return fval(r->terrain, ARCTIC_REGION);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ extern "C" {
|
|||
struct att attack[10];
|
||||
char bonus[MAXSKILLS];
|
||||
signed char *study_speed; /* study-speed-bonus in points/turn (0=30 Tage) */
|
||||
boolean __remove_me_nonplayer;
|
||||
bool __remove_me_nonplayer;
|
||||
int flags;
|
||||
int battle_flags;
|
||||
int ec_flags;
|
||||
|
@ -89,7 +89,7 @@ extern "C" {
|
|||
const char *(*generate_name) (const struct unit *);
|
||||
const char *(*describe) (const struct unit *, const struct locale *);
|
||||
void (*age) (struct unit * u);
|
||||
boolean(*move_allowed) (const struct region *, const struct region *);
|
||||
bool(*move_allowed) (const struct region *, const struct region *);
|
||||
struct item *(*itemdrop) (const struct race *, int size);
|
||||
void (*init_familiar) (struct unit *);
|
||||
|
||||
|
@ -176,10 +176,10 @@ extern "C" {
|
|||
#define humanoidrace(rc) (fval((rc), RCF_UNDEAD) || (rc)==new_race[RC_DRACOID] || playerrace(rc))
|
||||
#define illusionaryrace(rc) (fval(rc, RCF_ILLUSIONARY))
|
||||
|
||||
extern boolean allowed_dragon(const struct region *src,
|
||||
extern bool allowed_dragon(const struct region *src,
|
||||
const struct region *target);
|
||||
|
||||
extern boolean r_insectstalled(const struct region *r);
|
||||
extern bool r_insectstalled(const struct region *r);
|
||||
|
||||
extern void add_raceprefix(const char *);
|
||||
extern char **race_prefixes;
|
||||
|
|
|
@ -431,7 +431,7 @@ static int hash_requests;
|
|||
static int hash_misses;
|
||||
#endif
|
||||
|
||||
boolean pnormalize(int *x, int *y, const plane * pl)
|
||||
bool pnormalize(int *x, int *y, const plane * pl)
|
||||
{
|
||||
if (pl) {
|
||||
if (x) {
|
||||
|
@ -628,13 +628,13 @@ int distance(const region * r1, const region * r2)
|
|||
static direction_t
|
||||
koor_reldirection(int ax, int ay, int bx, int by, const struct plane *pl)
|
||||
{
|
||||
direction_t dir;
|
||||
int dir;
|
||||
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
|
||||
int x = ax + delta_x[dir];
|
||||
int y = ay + delta_y[dir];
|
||||
pnormalize(&x, &y, pl);
|
||||
if (bx == x && by == y)
|
||||
return dir;
|
||||
return (direction_t)dir;
|
||||
}
|
||||
return NODIRECTION;
|
||||
}
|
||||
|
@ -806,7 +806,7 @@ short rroad(const region * r, direction_t d)
|
|||
return (r == b->from) ? b->data.sa[0] : b->data.sa[1];
|
||||
}
|
||||
|
||||
boolean r_isforest(const region * r)
|
||||
bool r_isforest(const region * r)
|
||||
{
|
||||
if (fval(r->terrain, FOREST_REGION)) {
|
||||
/* needs to be covered with at leas 48% trees */
|
||||
|
@ -817,17 +817,17 @@ boolean r_isforest(const region * r)
|
|||
return false;
|
||||
}
|
||||
|
||||
int is_coastregion(region * r)
|
||||
bool is_coastregion(region * r)
|
||||
{
|
||||
direction_t i;
|
||||
int res = 0;
|
||||
|
||||
for (i = 0; i < MAXDIRECTIONS; i++) {
|
||||
for (i = 0; !res && i < MAXDIRECTIONS; i++) {
|
||||
region *rn = rconnect(r, i);
|
||||
if (rn && fval(rn->terrain, SEA_REGION))
|
||||
res++;
|
||||
}
|
||||
return res;
|
||||
return res!=0;
|
||||
}
|
||||
|
||||
int rpeasants(const region * r)
|
||||
|
@ -1593,9 +1593,9 @@ void region_set_morale(region * r, int morale, int turn)
|
|||
|
||||
void get_neighbours(const region * r, region ** list)
|
||||
{
|
||||
direction_t dir;
|
||||
int dir;
|
||||
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
|
||||
list[dir] = rconnect(r, dir);
|
||||
list[dir] = rconnect(r, (direction_t)dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1607,7 +1607,7 @@ int owner_change(const region * r)
|
|||
return -1;
|
||||
}
|
||||
|
||||
boolean is_mourning(const region * r, int in_turn)
|
||||
bool is_mourning(const region * r, int in_turn)
|
||||
{
|
||||
int change = owner_change(r);
|
||||
return (change == in_turn - 1
|
||||
|
|
|
@ -157,7 +157,7 @@ extern "C" {
|
|||
typedef struct spec_direction {
|
||||
int x, y;
|
||||
int duration;
|
||||
boolean active;
|
||||
bool active;
|
||||
char *desc;
|
||||
char *keyword;
|
||||
} spec_direction;
|
||||
|
@ -210,7 +210,7 @@ extern "C" {
|
|||
short rroad(const struct region *r, direction_t d);
|
||||
void rsetroad(struct region *r, direction_t d, short value);
|
||||
|
||||
int is_coastregion(struct region *r);
|
||||
bool is_coastregion(struct region *r);
|
||||
|
||||
int rtrees(const struct region *r, int ageclass);
|
||||
enum {
|
||||
|
@ -236,7 +236,7 @@ extern "C" {
|
|||
#define rherbs(r) ((r)->land?(r)->land->herbs:0)
|
||||
#define rsetherbs(r, value) if ((r)->land) ((r)->land->herbs=(short)(value))
|
||||
|
||||
boolean r_isforest(const struct region *r);
|
||||
bool r_isforest(const struct region *r);
|
||||
|
||||
#define rterrain(r) (oldterrain((r)->terrain))
|
||||
#define rsetterrain(r, t) ((r)->terrain = newterrain(t))
|
||||
|
@ -255,7 +255,7 @@ extern "C" {
|
|||
struct region *new_region(int x, int y, struct plane *pl, unsigned int uid);
|
||||
void remove_region(region ** rlist, region * r);
|
||||
void terraform_region(struct region *r, const struct terrain_type *terrain);
|
||||
boolean pnormalize(int *x, int *y, const struct plane *pl);
|
||||
bool pnormalize(int *x, int *y, const struct plane *pl);
|
||||
|
||||
extern const int delta_x[MAXDIRECTIONS];
|
||||
extern const int delta_y[MAXDIRECTIONS];
|
||||
|
@ -295,7 +295,7 @@ extern "C" {
|
|||
void region_setresource(struct region *r, const struct resource_type *rtype,
|
||||
int value);
|
||||
int owner_change(const region * r);
|
||||
boolean is_mourning(const region * r, int in_turn);
|
||||
bool is_mourning(const region * r, int in_turn);
|
||||
const struct item_type *r_luxury(struct region *r);
|
||||
void get_neighbours(const struct region *r, struct region **list);
|
||||
|
||||
|
|
|
@ -69,9 +69,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <attributes/otherfaction.h>
|
||||
#include <attributes/racename.h>
|
||||
|
||||
boolean nocr = false;
|
||||
boolean nonr = false;
|
||||
boolean noreports = false;
|
||||
bool nocr = false;
|
||||
bool nonr = false;
|
||||
bool noreports = false;
|
||||
|
||||
const char *visibility[] = {
|
||||
"none",
|
||||
|
@ -141,7 +141,7 @@ const char *hp_status(const unit * u)
|
|||
|
||||
void
|
||||
report_item(const unit * owner, const item * i, const faction * viewer,
|
||||
const char **name, const char **basename, int *number, boolean singular)
|
||||
const char **name, const char **basename, int *number, bool singular)
|
||||
{
|
||||
assert(!owner || owner->number);
|
||||
if (owner && owner->faction == viewer) {
|
||||
|
@ -379,7 +379,7 @@ report_resources(const seen_region * sr, resource_report * result, int size,
|
|||
int horses = rhorses(r);
|
||||
int trees = rtrees(r, 2);
|
||||
int saplings = rtrees(r, 1);
|
||||
boolean mallorn = fval(r, RF_MALLORN) != 0;
|
||||
bool mallorn = fval(r, RF_MALLORN) != 0;
|
||||
|
||||
if (money) {
|
||||
if (n >= size)
|
||||
|
@ -457,16 +457,16 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
|
|||
int getarnt = fval(u, UFL_ANON_FACTION);
|
||||
const char *pzTmp, *str;
|
||||
building *b;
|
||||
boolean isbattle = (boolean) (mode == see_battle);
|
||||
bool isbattle = (bool) (mode == see_battle);
|
||||
int telepath_see = 0;
|
||||
attrib *a_fshidden = NULL;
|
||||
item *itm;
|
||||
item *show;
|
||||
faction *fv = visible_faction(f, u);
|
||||
char *bufp = buf;
|
||||
boolean itemcloak = false;
|
||||
bool itemcloak = false;
|
||||
static const curse_type *itemcloak_ct = 0;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
int bytes;
|
||||
item result[MAX_INVENTORY];
|
||||
|
||||
|
@ -620,10 +620,12 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
|
|||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
if (fval(u, UFL_HUNGER)) {
|
||||
if (c)
|
||||
bytes = (int)strlcpy(bufp, ", hungert", size);
|
||||
else
|
||||
bytes = (int)strlcpy(bufp, "hungert", size);
|
||||
if (c) {
|
||||
bytes = (int)strlcpy(bufp, ", ", size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
bytes = (int)strlcpy(bufp, LOC(f->locale, "unit_hungers"), size);
|
||||
if (wrptr(&bufp, &size, bytes) != 0)
|
||||
WARN_STATIC_BUFFER();
|
||||
}
|
||||
|
@ -774,7 +776,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
|
|||
}
|
||||
}
|
||||
if (!isbattle) {
|
||||
boolean printed = 0;
|
||||
bool printed = 0;
|
||||
order *ord;;
|
||||
for (ord = u->old_orders; ord; ord = ord->next) {
|
||||
if (is_repeated(ord)) {
|
||||
|
@ -1095,7 +1097,7 @@ static void get_addresses(report_context * ctx)
|
|||
while (u != NULL) {
|
||||
if (u->faction != ctx->f) {
|
||||
faction *sf = visible_faction(ctx->f, u);
|
||||
boolean ballied = sf && sf != ctx->f && sf != lastf
|
||||
bool ballied = sf && sf != ctx->f && sf != lastf
|
||||
&& !fval(u, UFL_ANON_FACTION) && cansee(ctx->f, r, u, stealthmod);
|
||||
if (ballied || ALLIED(ctx->f, sf)) {
|
||||
ql_set_insert(&flist, sf);
|
||||
|
@ -1208,9 +1210,9 @@ static void get_seen_interval(report_context * ctx)
|
|||
link_seen(ctx->seen, ctx->first, ctx->last);
|
||||
}
|
||||
|
||||
boolean
|
||||
bool
|
||||
add_seen(struct seen_region *seehash[], struct region *r, unsigned char mode,
|
||||
boolean dis)
|
||||
bool dis)
|
||||
{
|
||||
seen_region *find = find_seen(seehash, r);
|
||||
if (find == NULL) {
|
||||
|
@ -1590,7 +1592,7 @@ static seen_region **prepare_report(faction * f)
|
|||
int write_reports(faction * f, time_t ltime)
|
||||
{
|
||||
int backup = 1, maxbackup = 128;
|
||||
boolean gotit = false;
|
||||
bool gotit = false;
|
||||
struct report_context ctx;
|
||||
const char *encoding = "UTF-8";
|
||||
|
||||
|
@ -2321,7 +2323,7 @@ int report_action(region * r, unit * actor, message * msg, int flags)
|
|||
if (view) {
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (!fval(u->faction, FFL_SELECT)) {
|
||||
boolean show = u->faction == actor->faction;
|
||||
bool show = u->faction == actor->faction;
|
||||
fset(u->faction, FFL_SELECT);
|
||||
if (view == ACTION_CANSEE) {
|
||||
/* Bei Fernzaubern sieht nur die eigene Partei den Magier */
|
||||
|
|
|
@ -33,12 +33,12 @@ extern "C" {
|
|||
|
||||
extern const char *directions[];
|
||||
extern const char *coasts[];
|
||||
extern boolean nonr;
|
||||
extern boolean nocr;
|
||||
extern boolean noreports;
|
||||
extern bool nonr;
|
||||
extern bool nocr;
|
||||
extern bool noreports;
|
||||
|
||||
/* kann_finden speedups */
|
||||
extern boolean kann_finden(struct faction *f1, struct faction *f2);
|
||||
extern bool kann_finden(struct faction *f1, struct faction *f2);
|
||||
extern struct unit *can_find(struct faction *, struct faction *);
|
||||
|
||||
/* funktionen zum schreiben eines reports */
|
||||
|
@ -77,13 +77,13 @@ extern "C" {
|
|||
struct seen_region *next;
|
||||
struct region *r;
|
||||
unsigned char mode;
|
||||
boolean disbelieves;
|
||||
bool disbelieves;
|
||||
} seen_region;
|
||||
|
||||
extern struct seen_region *find_seen(struct seen_region *seehash[],
|
||||
const struct region *r);
|
||||
extern boolean add_seen(struct seen_region *seehash[], struct region *r,
|
||||
unsigned char mode, boolean dis);
|
||||
extern bool add_seen(struct seen_region *seehash[], struct region *r,
|
||||
unsigned char mode, bool dis);
|
||||
extern struct seen_region **seen_init(void);
|
||||
extern void seen_done(struct seen_region *seehash[]);
|
||||
extern void free_seen(void);
|
||||
|
@ -137,7 +137,7 @@ extern "C" {
|
|||
const struct unit *owner, const struct faction *viewer);
|
||||
void report_item(const struct unit *owner, const struct item *i,
|
||||
const struct faction *viewer, const char **name, const char **basename,
|
||||
int *number, boolean singular);
|
||||
int *number, bool singular);
|
||||
void report_building(const struct building *b, const char **btype,
|
||||
const char **billusion);
|
||||
void report_race(const struct unit *u, const char **rcname,
|
||||
|
|
|
@ -118,7 +118,7 @@ static void terraform_default(struct rawmaterial *res, const region * r)
|
|||
}
|
||||
|
||||
#ifdef RANDOM_CHANGE
|
||||
static void resource_random_change(int *pvalue, boolean used)
|
||||
static void resource_random_change(int *pvalue, bool used)
|
||||
{
|
||||
int split = 5;
|
||||
int rnd = rng_int() % 100;
|
||||
|
|
|
@ -22,6 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
|
||||
#include "alchemy.h"
|
||||
#include "alliance.h"
|
||||
#include "ally.h"
|
||||
#include "connection.h"
|
||||
#include "building.h"
|
||||
#include "faction.h"
|
||||
|
@ -132,7 +133,7 @@ FILE *cfopen(const char *filename, const char *mode)
|
|||
int freadstr(FILE * F, int encoding, char *start, size_t size)
|
||||
{
|
||||
char *str = start;
|
||||
boolean quote = false;
|
||||
bool quote = false;
|
||||
for (;;) {
|
||||
int c = fgetc(F);
|
||||
|
||||
|
@ -298,7 +299,7 @@ static unit *unitorders(FILE * F, int enc, struct faction *f)
|
|||
stok = parse_token(&stok);
|
||||
|
||||
if (stok) {
|
||||
boolean quit = false;
|
||||
bool quit = false;
|
||||
param_t param = findparam(stok, u->faction->locale);
|
||||
switch (param) {
|
||||
case P_UNIT:
|
||||
|
|
|
@ -171,7 +171,6 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
|||
const char *sname = 0;
|
||||
|
||||
assert(stype);
|
||||
assert(r);
|
||||
sh->no = newcontainerid();
|
||||
sh->coast = NODIRECTION;
|
||||
sh->type = stype;
|
||||
|
@ -188,7 +187,9 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
|||
slprintf(buffer, sizeof(buffer), "%s %s", sname, shipid(sh));
|
||||
sh->name = strdup(buffer);
|
||||
shash(sh);
|
||||
addlist(&r->ships, sh);
|
||||
if (r) {
|
||||
addlist(&r->ships, sh);
|
||||
}
|
||||
return sh;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ const char *skillnames[MAXSKILLS] = {
|
|||
"unarmed"
|
||||
};
|
||||
|
||||
boolean skill_enabled[MAXSKILLS];
|
||||
bool skill_enabled[MAXSKILLS];
|
||||
|
||||
const char *skillname(skill_t sk, const struct locale *lang)
|
||||
{
|
||||
|
@ -83,7 +83,7 @@ const char *skillname(skill_t sk, const struct locale *lang)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void enable_skill(const char *skname, boolean value)
|
||||
void enable_skill(const char *skname, bool value)
|
||||
{
|
||||
skill_t sk;
|
||||
for (sk = 0; sk != MAXSKILLS; ++sk) {
|
||||
|
@ -260,7 +260,7 @@ int level(int days)
|
|||
{
|
||||
int i;
|
||||
static int ldays[64];
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
if (!init) {
|
||||
init = true;
|
||||
for (i = 0; i != 64; ++i)
|
||||
|
|
|
@ -48,7 +48,7 @@ extern "C" {
|
|||
|
||||
extern const char *skillname(skill_t, const struct locale *);
|
||||
extern skill_t sk_find(const char *name);
|
||||
extern void enable_skill(const char *name, boolean value);
|
||||
extern void enable_skill(const char *name, bool value);
|
||||
extern int level_days(int level);
|
||||
extern int level(int days);
|
||||
|
||||
|
@ -60,7 +60,7 @@ extern "C" {
|
|||
extern void sk_set(skill * sv, int level);
|
||||
|
||||
extern const char *skillnames[];
|
||||
extern boolean skill_enabled[];
|
||||
extern bool skill_enabled[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -73,9 +73,9 @@ typedef struct db_faction {
|
|||
|
||||
static int
|
||||
db_update_email(sqlite3 * db, const faction * f, const db_faction * dbstate,
|
||||
boolean force, /* [OUT] */ sqlite3_uint64 * id_email)
|
||||
bool force, /* [OUT] */ sqlite3_uint64 * id_email)
|
||||
{
|
||||
boolean update = force;
|
||||
bool update = force;
|
||||
int res = SQLITE_OK;
|
||||
char email_lc[MAX_EMAIL_LENGTH];
|
||||
|
||||
|
@ -129,7 +129,7 @@ db_update_email(sqlite3 * db, const faction * f, const db_faction * dbstate,
|
|||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
int db_update_factions(sqlite3 * db, boolean force)
|
||||
int db_update_factions(sqlite3 * db, bool force)
|
||||
{
|
||||
int game_id = 6;
|
||||
const char sql_select[] =
|
||||
|
@ -172,7 +172,7 @@ int db_update_factions(sqlite3 * db, boolean force)
|
|||
int i;
|
||||
char passwd_md5[MD5_LENGTH_0];
|
||||
sqlite3_uint64 id_email;
|
||||
boolean update = force;
|
||||
bool update = force;
|
||||
db_faction dbstate;
|
||||
const char *no_b36;
|
||||
|
||||
|
@ -241,7 +241,7 @@ int db_update_factions(sqlite3 * db, boolean force)
|
|||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
int db_update_scores(sqlite3 * db, boolean force)
|
||||
int db_update_scores(sqlite3 * db, bool force)
|
||||
{
|
||||
const char *sql_ins =
|
||||
"INSERT OR FAIL INTO score (value,faction_id,turn) VALUES (?,?,?)";
|
||||
|
|
|
@ -61,7 +61,7 @@ static region *tpregion(const region * r)
|
|||
return rt;
|
||||
}
|
||||
|
||||
region_list *astralregions(const region * r, boolean(*valid) (const region *))
|
||||
region_list *astralregions(const region * r, bool(*valid) (const region *))
|
||||
{
|
||||
region_list *rlist = NULL;
|
||||
int x, y;
|
||||
|
@ -116,7 +116,7 @@ region *r_astral_to_standard(const region * r)
|
|||
}
|
||||
|
||||
region_list *all_in_range(const region * r, int n,
|
||||
boolean(*valid) (const region *))
|
||||
bool(*valid) (const region *))
|
||||
{
|
||||
int x, y;
|
||||
region_list *rlist = NULL;
|
||||
|
@ -171,7 +171,7 @@ plane *get_normalplane(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean is_astral(const region * r)
|
||||
bool is_astral(const region * r)
|
||||
{
|
||||
plane *pl = get_astralplane();
|
||||
return (pl && rplane(r) == pl);
|
||||
|
@ -227,7 +227,7 @@ void create_teleport_plane(void)
|
|||
}
|
||||
}
|
||||
|
||||
boolean inhabitable(const region * r)
|
||||
bool inhabitable(const region * r)
|
||||
{
|
||||
return fval(r->terrain, LAND_REGION);
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ extern "C" {
|
|||
struct region *r_standard_to_astral(const struct region *r);
|
||||
struct region *r_astral_to_standard(const struct region *);
|
||||
extern struct region_list *astralregions(const struct region *rastral,
|
||||
boolean(*valid) (const struct region *));
|
||||
bool(*valid) (const struct region *));
|
||||
extern struct region_list *all_in_range(const struct region *r, int n,
|
||||
boolean(*valid) (const struct region *));
|
||||
extern boolean inhabitable(const struct region *r);
|
||||
extern boolean is_astral(const struct region *r);
|
||||
bool(*valid) (const struct region *));
|
||||
extern bool inhabitable(const struct region *r);
|
||||
extern bool is_astral(const struct region *r);
|
||||
extern struct plane *get_astralplane(void);
|
||||
extern struct plane *get_normalplane(void);
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ typedef short item_t;
|
|||
|
||||
struct attrib;
|
||||
struct attrib_type;
|
||||
struct ally;
|
||||
struct building;
|
||||
struct building_type;
|
||||
struct curse;
|
||||
|
@ -90,8 +91,6 @@ typedef enum {
|
|||
K_END,
|
||||
K_DRIVE,
|
||||
K_NUMBER,
|
||||
K_WAR,
|
||||
K_PEACE,
|
||||
K_FOLLOW,
|
||||
K_RESEARCH,
|
||||
K_GIVE,
|
||||
|
@ -102,7 +101,6 @@ typedef enum {
|
|||
K_CONTACT,
|
||||
K_TEACH,
|
||||
K_STUDY,
|
||||
K_LIEFERE,
|
||||
K_MAKE,
|
||||
K_MOVE,
|
||||
K_PASSWORD,
|
||||
|
@ -128,18 +126,12 @@ typedef enum {
|
|||
K_URSPRUNG,
|
||||
K_EMAIL,
|
||||
K_PIRACY,
|
||||
K_RESTART,
|
||||
K_GROUP,
|
||||
K_SACRIFICE,
|
||||
K_PRAY,
|
||||
K_SORT,
|
||||
K_SETJIHAD,
|
||||
K_GM, /* perform GM commands */
|
||||
K_INFO, /* set player-info */
|
||||
K_PREFIX,
|
||||
K_PLANT,
|
||||
K_WEREWOLF,
|
||||
K_XE,
|
||||
K_ALLIANCE,
|
||||
K_CLAIM,
|
||||
K_PROMOTION,
|
||||
|
@ -402,10 +394,6 @@ typedef enum {
|
|||
/* ------------------------------------------------------------- */
|
||||
/* Prototypen */
|
||||
|
||||
#define ALLIED_TAX 1
|
||||
#define ALLIED_NOBLOCK 2
|
||||
#define ALLIED_HELP 4
|
||||
|
||||
/* alle vierstelligen zahlen: */
|
||||
#define MAX_UNIT_NR (36*36*36*36-1)
|
||||
#define MAX_CONTAINER_NR (36*36*36*36-1)
|
||||
|
|
|
@ -612,7 +612,7 @@ void usetcontact(unit * u, const unit * u2)
|
|||
a_add(&u->attribs, a_new(&at_contact))->data.v = (void *)u2;
|
||||
}
|
||||
|
||||
boolean ucontact(const unit * u, const unit * u2)
|
||||
bool ucontact(const unit * u, const unit * u2)
|
||||
/* Prüft, ob u den Kontaktiere-Befehl zu u2 gesetzt hat. */
|
||||
{
|
||||
attrib *ru;
|
||||
|
@ -820,23 +820,27 @@ void leave_building(unit * u)
|
|||
}
|
||||
}
|
||||
|
||||
boolean can_leave(unit * u)
|
||||
bool can_leave(unit * u)
|
||||
{
|
||||
static int gamecookie = -1;
|
||||
static int rule_leave = -1;
|
||||
|
||||
if (!u->building) {
|
||||
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);
|
||||
}
|
||||
|
||||
if (rule_leave && u->building && u == building_owner(u->building)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean leave(unit * u, boolean force)
|
||||
bool leave(unit * u, bool force)
|
||||
{
|
||||
if (!force) {
|
||||
if (!can_leave(u)) {
|
||||
|
@ -856,7 +860,7 @@ const struct race *urace(const struct unit *u)
|
|||
return u->race;
|
||||
}
|
||||
|
||||
boolean can_survive(const unit * u, const region * r)
|
||||
bool can_survive(const unit * u, const region * r)
|
||||
{
|
||||
if ((fval(r->terrain, WALK_INTO) && (u->race->flags & RCF_WALK))
|
||||
|| (fval(r->terrain, SWIM_INTO) && (u->race->flags & RCF_SWIM))
|
||||
|
@ -891,7 +895,7 @@ void move_unit(unit * u, region * r, unit ** ulist)
|
|||
if (u->ship || u->building) {
|
||||
/* can_leave must be checked in travel_i */
|
||||
#ifndef NDEBUG
|
||||
boolean result = leave(u, false);
|
||||
bool result = leave(u, false);
|
||||
assert(result);
|
||||
#else
|
||||
leave(u, false);
|
||||
|
@ -1117,7 +1121,7 @@ void set_number(unit * u, int count)
|
|||
u->number = (unsigned short)count;
|
||||
}
|
||||
|
||||
boolean learn_skill(unit * u, skill_t sk, double chance)
|
||||
bool learn_skill(unit * u, skill_t sk, double chance)
|
||||
{
|
||||
skill *sv = u->skills;
|
||||
if (chance < 1.0 && rng_int() % 10000 >= chance * 10000)
|
||||
|
@ -1183,7 +1187,7 @@ skill *get_skill(const unit * u, skill_t sk)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
boolean has_skill(const unit * u, skill_t sk)
|
||||
bool has_skill(const unit * u, skill_t sk)
|
||||
{
|
||||
skill *sv = u->skills;
|
||||
while (sv != u->skills + u->skill_size) {
|
||||
|
@ -1224,7 +1228,7 @@ static int item_modification(const unit * u, skill_t sk, int val)
|
|||
static int att_modification(const unit * u, skill_t sk)
|
||||
{
|
||||
double result = 0;
|
||||
static boolean init = false;
|
||||
static bool init = false;
|
||||
static const curse_type *skillmod_ct, *gbdream_ct, *worse_ct;
|
||||
curse *c;
|
||||
|
||||
|
@ -1283,7 +1287,7 @@ static int att_modification(const unit * u, skill_t sk)
|
|||
|
||||
int
|
||||
get_modifier(const unit * u, skill_t sk, int level, const region * r,
|
||||
boolean noitem)
|
||||
bool noitem)
|
||||
{
|
||||
int bskill = level;
|
||||
int skill = bskill;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue