bunch of fixes that include fixing lua networking, script loading and client side lua installation
This commit is contained in:
@@ -690,6 +690,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
ServerPacketHeader header = (ServerPacketHeader)inc.ReadByte();
|
||||
|
||||
GameMain.Lua.networking.NetMessageReceived(inc, header);
|
||||
|
||||
if (roundInitStatus != RoundInitStatus.Started &&
|
||||
roundInitStatus != RoundInitStatus.NotStarted &&
|
||||
roundInitStatus != RoundInitStatus.Error &&
|
||||
|
||||
@@ -1277,24 +1277,25 @@ namespace Barotrauma
|
||||
{
|
||||
"Barotrauma.dll", "Barotrauma.deps.json",
|
||||
"0harmony.dll", "Mono.Cecil.dll",
|
||||
"Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb",
|
||||
"Mono.Cecil.Rocks", "MonoMod.Common.dll",
|
||||
"Mono.Cecil.Mdb.dll", "Mono.Cecil.Pdb.dll",
|
||||
"Mono.Cecil.Rocks.dll", "MonoMod.Common.dll",
|
||||
"MoonSharp.Interpreter.dll",
|
||||
"mscordaccore_amd64_amd64_4.700.22.11601",
|
||||
"mscordaccore_amd64_amd64_4.700.22.11601.dll",
|
||||
};
|
||||
|
||||
|
||||
File.Move("Barotrauma.dll", "Barotrauma.dll.old", true);
|
||||
File.Move("Barotrauma.deps.json", "Barotrauma.deps.json.old", true);
|
||||
|
||||
foreach (string file in filesToMove)
|
||||
{
|
||||
File.Move(Path.Combine(path, "Binary", file), file, true);
|
||||
File.Copy(Path.Combine(path, "Binary", file), file, true);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
GameMain.Lua.PrintError("You seem to already have Client Side Lua installed, if you are trying to reinstall, make sure uninstall it first (mainmenu button located top left).");
|
||||
// GameMain.Lua.PrintError("You seem to already have Client Side Lua installed, if you are trying to reinstall, make sure uninstall it first (mainmenu button located top left).");
|
||||
|
||||
GameMain.Lua.HandleLuaException(e);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,13 @@ local CreateStatic = function (typeName, addCallMethod)
|
||||
if addCallMethod then
|
||||
debug.setmetatable(staticUserdata, {
|
||||
__call = function(obj, ...)
|
||||
return staticUserdata.__new(...)
|
||||
local success, result = pcall(staticUserdata.__new, ...)
|
||||
|
||||
if not success then
|
||||
error(result, 2)
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
})
|
||||
end
|
||||
@@ -50,13 +56,16 @@ defaultLib["InputType"] = CreateStatic("Barotrauma.InputType")
|
||||
|
||||
defaultLib["ContentPackageManager"] = CreateStatic("Barotrauma.ContentPackageManager")
|
||||
defaultLib["GameSettings"] = CreateStatic("Barotrauma.GameSettings")
|
||||
defaultLib["RichString"] = CreateStatic("Barotrauma.RichString", true)
|
||||
defaultLib["Identifier"] = CreateStatic("Barotrauma.Identifier", true)
|
||||
defaultLib["ContentPackage"] = CreateStatic("Barotrauma.ContentPackage", true)
|
||||
defaultLib["WayPoint"] = CreateStatic("Barotrauma.WayPoint", true)
|
||||
defaultLib["Submarine"] = CreateStatic("Barotrauma.Submarine", true)
|
||||
defaultLib["Client"] = CreateStatic("Barotrauma.Networking.Client", true)
|
||||
defaultLib["Character"] = CreateStatic("Barotrauma.Character")
|
||||
defaultLib["CharacterPrefab"] = CreateStatic("Barotrauma.CharacterPrefab")
|
||||
defaultLib["CharacterInfo"] = CreateStatic("Barotrauma.CharacterInfo", true)
|
||||
defaultLib["CharacterInfoPrefab"] = CreateStatic("Barotrauma.CharacterInfoPrefab")
|
||||
defaultLib["Item"] = CreateStatic("Barotrauma.Item", true)
|
||||
defaultLib["ItemPrefab"] = CreateStatic("Barotrauma.ItemPrefab", true)
|
||||
defaultLib["FactionPrefab"] = CreateStatic("Barotrauma.FactionPrefab", true)
|
||||
@@ -131,6 +140,7 @@ elseif CLIENT then
|
||||
|
||||
defaultLib["GUI"] = {
|
||||
GUI = CreateStatic("Barotrauma.GUI", true),
|
||||
GUIStyle = CreateStatic("Barotrauma.GUIStyle", true),
|
||||
RectTransform = CreateStatic("Barotrauma.RectTransform", true),
|
||||
LayoutGroup = CreateStatic("Barotrauma.GUILayoutGroup", true),
|
||||
Button = CreateStatic("Barotrauma.GUIButton", true),
|
||||
|
||||
@@ -25,11 +25,24 @@ RegisterBarotrauma("LuaFloat")
|
||||
RegisterBarotrauma("Level+InterestingPosition")
|
||||
|
||||
RegisterBarotrauma("Identifier")
|
||||
|
||||
RegisterBarotrauma("LocalizedString")
|
||||
RegisterBarotrauma("TagLString")
|
||||
RegisterBarotrauma("RichString")
|
||||
|
||||
RegisterBarotrauma("Job")
|
||||
RegisterBarotrauma("JobPrefab")
|
||||
RegisterBarotrauma("Level")
|
||||
RegisterBarotrauma("WayPoint")
|
||||
|
||||
RegisterBarotrauma("Character")
|
||||
RegisterBarotrauma("CharacterPrefab")
|
||||
RegisterBarotrauma("CharacterInfo")
|
||||
RegisterBarotrauma("CharacterInfoPrefab")
|
||||
RegisterBarotrauma("CharacterHealth")
|
||||
RegisterBarotrauma("CharacterHealth+LimbHealth")
|
||||
RegisterBarotrauma("CharacterInventory")
|
||||
|
||||
RegisterBarotrauma("Item")
|
||||
RegisterBarotrauma("Submarine")
|
||||
RegisterBarotrauma("Networking.Client")
|
||||
@@ -38,12 +51,10 @@ RegisterBarotrauma("Networking.LidgrenConnection")
|
||||
RegisterBarotrauma("Networking.SteamP2PConnection")
|
||||
RegisterBarotrauma("AfflictionPrefab")
|
||||
RegisterBarotrauma("Affliction")
|
||||
RegisterBarotrauma("CharacterHealth")
|
||||
RegisterBarotrauma("AnimController")
|
||||
RegisterBarotrauma("Limb")
|
||||
RegisterBarotrauma("Ragdoll")
|
||||
RegisterBarotrauma("Networking.ChatMessage")
|
||||
RegisterBarotrauma("CharacterHealth+LimbHealth")
|
||||
RegisterBarotrauma("AttackResult")
|
||||
RegisterBarotrauma("Attack")
|
||||
RegisterBarotrauma("Entity")
|
||||
@@ -73,7 +84,6 @@ RegisterBarotrauma("Networking.ServerSettings")
|
||||
RegisterBarotrauma("Networking.ServerSettings+SavedClientPermission")
|
||||
RegisterBarotrauma("Inventory")
|
||||
RegisterBarotrauma("ItemInventory")
|
||||
RegisterBarotrauma("CharacterInventory")
|
||||
RegisterBarotrauma("Inventory+ItemSlot")
|
||||
RegisterBarotrauma("FireSource")
|
||||
|
||||
@@ -199,7 +209,6 @@ RegisterBarotrauma("Pair`2[[Barotrauma.JobPrefab],[System.Int32]]")
|
||||
|
||||
RegisterBarotrauma("Range`1[System.Single]")
|
||||
|
||||
RegisterBarotrauma("CharacterInfo")
|
||||
RegisterBarotrauma("Items.Components.Signal")
|
||||
RegisterBarotrauma("SubmarineInfo")
|
||||
|
||||
@@ -241,6 +250,7 @@ Register("Microsoft.Xna.Framework.Input.KeyboardState")
|
||||
|
||||
RegisterBarotrauma("Sprite")
|
||||
RegisterBarotrauma("GUI")
|
||||
RegisterBarotrauma("GUIStyle")
|
||||
RegisterBarotrauma("GUILayoutGroup")
|
||||
RegisterBarotrauma("GUITextBox")
|
||||
RegisterBarotrauma("GUITextBlock")
|
||||
|
||||
@@ -23,46 +23,87 @@ require("DefaultHook")
|
||||
|
||||
-- Execute Mods
|
||||
|
||||
local allPackages = ContentPackageManager.AllPackages
|
||||
local localPackages = ContentPackageManager.LocalPackages
|
||||
local enabledPackages = ContentPackageManager.EnabledPackages.All
|
||||
|
||||
local function endsWith(str, suffix)
|
||||
return str:sub(-string.len(suffix)) == suffix
|
||||
end
|
||||
|
||||
local function executeProtected(s)
|
||||
print(s)
|
||||
dofile(s)
|
||||
local function getFileName(file)
|
||||
return file:match("^.+/(.+)$")
|
||||
end
|
||||
|
||||
local function runFolder(folder)
|
||||
local function getPath(str)
|
||||
local sep = "/"
|
||||
return str:match("(.*"..sep..")")
|
||||
end
|
||||
|
||||
|
||||
local function executeProtected(s, folder)
|
||||
loadfile(s)(folder)
|
||||
end
|
||||
|
||||
local function runFolder(folder, rootFolder, package)
|
||||
local search = File.DirSearch(folder)
|
||||
for i = 1, #search, 1 do
|
||||
local s = search[i]:gsub("\\", "/")
|
||||
|
||||
if endsWith(s, ".lua") then
|
||||
executeProtected(s)
|
||||
executeProtected(s, rootFolder)
|
||||
print(string.format("%s: Executing %s", package.Name, getFileName(s)))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
if SERVER then
|
||||
|
||||
for package in enabledPackages do
|
||||
if package then
|
||||
local d = package.Path:gsub("\\", "/")
|
||||
d = d:gsub("/filelist.xml", "")
|
||||
|
||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
||||
for package in enabledPackages do
|
||||
if package then
|
||||
local d = package.Path:gsub("\\", "/")
|
||||
d = d:gsub("/filelist.xml", "")
|
||||
|
||||
if File.DirectoryExists(d .. "/Lua/Autorun") then
|
||||
runFolder(d .. "/Lua/Autorun")
|
||||
end
|
||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
||||
|
||||
if File.DirectoryExists(d .. "/Lua/Autorun") then
|
||||
runFolder(d .. "/Lua/Autorun", d, package)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- we don't want to execute workshop ForcedAutorun if we have a local Package
|
||||
local executedLocalPackages = {}
|
||||
|
||||
for package in localPackages do
|
||||
if package then
|
||||
local d = package.Path:gsub("\\", "/")
|
||||
d = d:gsub("/filelist.xml", "")
|
||||
|
||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
||||
|
||||
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
|
||||
runFolder(d .. "/Lua/ForcedAutorun", d, package)
|
||||
|
||||
executedLocalPackages[package.Name] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for package in allPackages do
|
||||
if package and executedLocalPackages[package.Name] == nil then
|
||||
local d = package.Path:gsub("\\", "/")
|
||||
d = d:gsub("/filelist.xml", "")
|
||||
|
||||
table.insert(modulePaths, (d .. "/Lua/?.lua"))
|
||||
|
||||
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
|
||||
runFolder(d .. "/Lua/ForcedAutorun", d, package)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
setmodulepaths(modulePaths)
|
||||
|
||||
Hook.Add("stop", "luaSetup.stop", function ()
|
||||
|
||||
@@ -85,8 +85,8 @@ namespace Barotrauma.Networking
|
||||
EVENTACTION,
|
||||
CREW, //anything related to managing bots in multiplayer
|
||||
MEDICAL, //medical clinic
|
||||
READY_CHECK, //start, end and update a ready check
|
||||
MONEY,
|
||||
READY_CHECK, //start, end and update a ready check
|
||||
|
||||
LUA_NET_MESSAGE
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user