Skip to content
Snippets Groups Projects
Commit d159d9ea authored by dg's avatar dg
Browse files

*sshhh, as shadow we must be*

git-svn-id: http://svn.net-core.org/repos/t-engine4@4236 51575b47-30f0-44d4-a5cc-537603b46e54
parent 491f2331
No related branches found
Tags tome-beta32
No related merge requests found
......@@ -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
......
......@@ -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 {}))
......
......@@ -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
......
......@@ -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")
......@@ -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")
......
-- 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 = {
"",
},
}
-- 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 = {
"",
},
}
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment