diff --git a/game/engines/default/engine/Birther.lua b/game/engines/default/engine/Birther.lua index c3bd715aa93d859066d69b2e62e2405b428c287e..7e863559fdf046f0043cfe35fda2b0cb3ac3508e 100644 --- a/game/engines/default/engine/Birther.lua +++ b/game/engines/default/engine/Birther.lua @@ -33,16 +33,16 @@ _M.step_names = {} --- Defines birth descriptors -- Static! function _M:loadDefinition(file) - local f, err = loadfile(file) - if not f and err then error(err) os.exit() end - setfenv(f, setmetatable({ + local f, err = util.loadfilemods(file, setmetatable({ ActorTalents = require("engine.interface.ActorTalents"), newBirthDescriptor = function(t) self:newBirthDescriptor(t) end, setAuto = function(type, v) self.birth_auto[type] = v end, setStepNames = function(names) self.step_names = names end, load = function(f) self:loadDefinition(f) end }, {__index=_G})) - f() + if not f and err then error(err) os.exit() end + local ok, err = pcall(f) + if not ok and err then error(err) end end --- Defines one birth descriptor @@ -50,6 +50,7 @@ end function _M:newBirthDescriptor(t) assert(t.name, "no birth name") assert(t.type, "no birth type") + print("==============**************************", t.name) t.short_name = t.short_name or t.name t.short_name = t.short_name:upper():gsub("[ ]", "_") t.display_name = t.display_name or t.name diff --git a/game/engines/default/engine/Module.lua b/game/engines/default/engine/Module.lua index bb33da825474c52f2a7c94d6665003bd50675d86..8fd5510ae95483cc784125ba235d45c5431dacae 100644 --- a/game/engines/default/engine/Module.lua +++ b/game/engines/default/engine/Module.lua @@ -375,15 +375,19 @@ function _M:instanciate(mod, name, new_game, no_reboot) end end local t = core.game.getTime() - fp("/mod") - fp("/data") - fp("/engine") - table.sort(md5s) - local fmd5 = md5.sumhexa(table.concat(md5s)) - print("[MODULE LOADER] module MD5", fmd5, "computed in ", core.game.getTime() - t) - local hash_valid, hash_err - if mod.short_name ~= "boot" then - hash_valid, hash_err = profile:checkModuleHash(mod.version_name, fmd5) + if config.settings.cheat then + hash_valid, hash_err = false, "cheat mode skipping validation" + else + fp("/mod") + fp("/data") + fp("/engine") + table.sort(md5s) + local fmd5 = md5.sumhexa(table.concat(md5s)) + print("[MODULE LOADER] module MD5", fmd5, "computed in ", core.game.getTime() - t) + local hash_valid, hash_err + if mod.short_name ~= "boot" then + hash_valid, hash_err = profile:checkModuleHash(mod.version_name, fmd5) + end end profile:addStatFields(unpack(mod.profile_stats_fields or {})) diff --git a/game/engines/default/engine/utils.lua b/game/engines/default/engine/utils.lua index 2c76f0428d264281a4595a229da885d550d329af..27ed743a1a24afa771ffd32e2678c216c8cc246f 100644 --- a/game/engines/default/engine/utils.lua +++ b/game/engines/default/engine/utils.lua @@ -970,6 +970,31 @@ function util.getval(val, ...) end end +function util.loadfilemods(file, env) + -- Base loader + local prev, err = loadfile(file) + if err then error(err) end + setfenv(prev, env) + + for i, addon in ipairs(fs.list("/mod/addons/")) do + local fn = "/mod/addons/"..addon.."/superload/"..file + if fs.exists(fn) then + local f, err = loadfile(fn) + if err then error(err) end + local base = prev + setfenv(f, setmetatable({ + loadPrevious = function() + local ok, err = pcall(base, bname) + if not ok and err then error(err) end + end + }, {__index=env})) + print("Loaded mod", f, fn) + prev = f + end + end + return prev +end + function core.fov.circle_grids(x, y, radius, block) if not x or not y then return {} end if radius == 0 then return {[x]={[y]=true}} end diff --git a/game/loader/init.lua b/game/loader/init.lua index 8b6d714d2dc7efe207bec972bb46f955e02f3935..7419946ad2b743fe29a4bf2f0e696cb7ebd99607 100644 --- a/game/loader/init.lua +++ b/game/loader/init.lua @@ -133,5 +133,38 @@ load(...) fs.umount(homepath) + +-- [[ +local te4_loader = function(name) + local bname = name + + -- Base loader + local prev = loadfile("/"..bname:gsub("%.", "/")..".lua") + + name = name:gsub("%.", "/") + for i, addon in ipairs(fs.list("/mod/addons/")) do + local fn = "/mod/addons/"..addon.."/superload/"..name..".lua" + if fs.exists(fn) then + local f = loadfile(fn) + local base = prev + setfenv(f, setmetatable({ + loadPrevious = function() + print("FROM ", fn, "loading previous!") + base(bname) + return package.loaded[bname] + end + }, {__index=_G})) + prev = f + end + end + return prev +end + +table.insert(package.loaders, 2, te4_loader) +--table.insert(package.loaders, 2, function(name) return loadfile("/"..name:gsub("%.", "/")..".lua") end ) +--]] + + + -- RUN engine RUN !! dofile("/engine/init.lua") diff --git a/game/modules/tome/data/birth/descriptors.lua b/game/modules/tome/data/birth/descriptors.lua index b18760d2460ca2788ed658945f33d46fd8655626..43d2f65465832daa6e705e551829b3e3ca390baf 100644 --- a/game/modules/tome/data/birth/descriptors.lua +++ b/game/modules/tome/data/birth/descriptors.lua @@ -247,9 +247,6 @@ load("/data/birth/races/elf.lua") load("/data/birth/races/halfling.lua") load("/data/birth/races/dwarf.lua") load("/data/birth/races/yeek.lua") -load("/data/birth/races/orc.lua") -load("/data/birth/races/troll.lua") ---load("/data/birth/races/spider.lua") load("/data/birth/races/undead.lua") load("/data/birth/races/construct.lua") diff --git a/game/modules/tome/data/birth/races/orc.lua b/game/modules/tome/data/birth/races/orc.lua deleted file mode 100644 index 7892eb1ba83da862a4adcc33d7ec703b6729b1be..0000000000000000000000000000000000000000 --- a/game/modules/tome/data/birth/races/orc.lua +++ /dev/null @@ -1,75 +0,0 @@ --- ToME - Tales of Maj'Eyal --- Copyright (C) 2009, 2010, 2011 Nicolas Casalini --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see <http://www.gnu.org/licenses/>. --- --- Nicolas Casalini "DarkGod" --- darkgod@te4.org - ---------------------------------------------------------- --- Orcs -- ---------------------------------------------------------- -newBirthDescriptor{ - type = "race", - name = "Orc", - desc = { - "", - }, - descriptor_choices = - { - subrace = - { - __ALL__ = "disallow", - ["Orc"] = "allow", - }, - sex = - { - __ALL__ = "disallow", - Male = "allow", - }, - class = - { - Mage = "disallow", - }, - }, - inc_stats = { str=4, con=1, wil=2, mag=-2, dex=-2 }, - talents = { - [ActorTalents.T_ORC_FURY]=1, - }, - copy = { - moddable_tile = "orc", - faction = "orc-pride", - type = "humanoid", subtype="orc", - default_wilderness = {"playerpop", "allied"}, - starting_zone = "wilderness", - starting_quest = "start-allied", - starting_intro = "orc", - life_rating=12, - resolvers.inscription("INFUSION:_REGENERATION", {cooldown=10, dur=5, heal=60}), - resolvers.inscription("INFUSION:_WILD", {cooldown=12, what={poison=true}, dur=4, power=14}), - }, - experience = 1.3, -} - --------------------------------------------------------- --- Orcs -- --------------------------------------------------------- -newBirthDescriptor -{ - type = "subrace", - name = "Orc", - desc = { - "", - }, -} diff --git a/game/modules/tome/data/birth/races/troll.lua b/game/modules/tome/data/birth/races/troll.lua deleted file mode 100644 index 44932c85e702ac19f503601245ec1741ddd67af1..0000000000000000000000000000000000000000 --- a/game/modules/tome/data/birth/races/troll.lua +++ /dev/null @@ -1,70 +0,0 @@ --- ToME - Tales of Maj'Eyal --- Copyright (C) 2009, 2010, 2011 Nicolas Casalini --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see <http://www.gnu.org/licenses/>. --- --- Nicolas Casalini "DarkGod" --- darkgod@te4.org - ---------------------------------------------------------- --- Trolls -- ---------------------------------------------------------- -newBirthDescriptor{ - type = "race", - name = "Troll", - desc = { - "", - }, - descriptor_choices = - { - subrace = - { - __ALL__ = "disallow", - ["Olog-hai"] = "allow", - }, - sex = - { - __ALL__ = "disallow", - Male = "allow", - }, - }, - inc_stats = { str=4, con=3, wil=3, mag=-2, dex=-2 }, - talents = { --- [ActorTalents.T_DWARF_RESILIENCE]=1, - }, - copy = { - faction = "orc-pride", - type = "humanoid", subtype="troll", - default_wilderness = {"playerpop", "allied"}, - starting_zone = "trollmire", - starting_quest = "start-dunadan", - starting_intro = "dwarf", - life_rating=10, - resolvers.inscription("INFUSION:_REGENERATION", {cooldown=10, dur=5, heal=60}), - resolvers.inscription("INFUSION:_WILD", {cooldown=12, what={poison=true}, dur=4, power=14}), - }, - experience = 1.1, -} - ---------------------------------------------------------- --- Dwarves -- ---------------------------------------------------------- -newBirthDescriptor -{ - type = "subrace", - name = "Olog-hai", - desc = { - "", - }, -} diff --git a/game/modules/tome/data/birth/worlds.lua b/game/modules/tome/data/birth/worlds.lua index 28025868341dc3aadf3b900b0042d3e6796f11da..b8a79d473d2ac697be55bea5f1422b23f4aee8a4 100644 --- a/game/modules/tome/data/birth/worlds.lua +++ b/game/modules/tome/data/birth/worlds.lua @@ -158,27 +158,6 @@ newBirthDescriptor{ }, } -newBirthDescriptor{ - type = "world", - name = "Orcs", - display_name = "Orcs: The Rise to Power", - locked = function() return profile.mod.allow_build.campaign_orc and true or "hide" end, - locked_desc = "", - desc = - { - "Baston!", - }, - descriptor_choices = - { - race = - { - __ALL__ = "disallow", - Orc = "allow", --- Spider = function() return profile.mod.allow_build.spider and "allow" or "disallow" end, - }, - }, -} - newBirthDescriptor{ type = "world", name = "Spydre",