Re-enabled the lua type filter again
This commit is contained in:
@@ -43,29 +43,7 @@ require("DefaultLib/Utils/String")
|
|||||||
require("DefaultLib/Utils/Util")
|
require("DefaultLib/Utils/Util")
|
||||||
require("DefaultLib/Utils/SteamApi")
|
require("DefaultLib/Utils/SteamApi")
|
||||||
|
|
||||||
if false then
|
require("PostSetup")
|
||||||
LuaUserData.RegisterType = function (typeName)
|
|
||||||
local descriptor = Descriptors[typeName]
|
|
||||||
|
|
||||||
if descriptor == nil then
|
|
||||||
error("Type '" .. typeName .. "' can't be registered", 2)
|
|
||||||
else
|
|
||||||
return descriptor
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local originalCreateStatic = LuaUserData.CreateStatic
|
|
||||||
LuaUserData.CreateStatic = function (typeName, addCallMethod)
|
|
||||||
local descriptor = Descriptors[typeName]
|
|
||||||
|
|
||||||
if descriptor == nil then
|
|
||||||
error("Unable to create static reference to type " .. typeName, 2)
|
|
||||||
end
|
|
||||||
|
|
||||||
return originalCreateStatic(typeName, addCallMethod)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
LuaSetup = nil
|
LuaSetup = nil
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
if CSActive then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local function IsAllowed(typeName)
|
||||||
|
if string.startsWith(typeName, "Barotrauma.Lua") or string.startsWith(typeName, "Barotrauma.Cs") or string.startsWith(typeName, "Barotrauma.LuaCs") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
if string.startsWith(typeName, "System.Collections") then return true end
|
||||||
|
|
||||||
|
if string.startsWith(typeName, "Microsoft.Xna") then return true end
|
||||||
|
|
||||||
|
if string.startsWith(typeName, "Barotrauma.IO") then return false end
|
||||||
|
|
||||||
|
if string.startsWith(typeName, "Barotrauma.ToolBox") then return false end
|
||||||
|
if string.startsWith(typeName, "Barotrauma.SaveUtil") then return false end
|
||||||
|
|
||||||
|
if string.startsWith(typeName, "Barotrauma.") then return true end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
local originalRegisterType = LuaUserData.RegisterType
|
||||||
|
LuaUserData.RegisterType = function (typeName)
|
||||||
|
if not IsAllowed(typeName) then
|
||||||
|
error("Couldn't register type " .. typeName .. ".", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local success, result = pcall(originalRegisterType, typeName)
|
||||||
|
|
||||||
|
if not success then
|
||||||
|
error(result, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
local originalCreateStatic = LuaUserData.CreateStatic
|
||||||
|
LuaUserData.CreateStatic = function (typeName, addCallMethod)
|
||||||
|
if not IsAllowed(typeName) then
|
||||||
|
error("Couldn't register type " .. typeName .. ".", 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
local success, result = pcall(originalCreateStatic, typeName, addCallMethod)
|
||||||
|
|
||||||
|
if not success then
|
||||||
|
error(result, 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user