From 8ea43d327b8802ac42b1ffa61f92cf45fc35ae3c Mon Sep 17 00:00:00 2001 From: Alessandro Proto Date: Sun, 8 Jan 2023 00:50:12 +0100 Subject: [PATCH] Cleanup --- Capy64/BIOS/Bios.cs | 8 ++++---- Capy64/LuaRuntime/Extensions/Utils.cs | 7 +++---- Capy64/LuaRuntime/Sandbox.cs | 4 ---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Capy64/BIOS/Bios.cs b/Capy64/BIOS/Bios.cs index 8325d43..a55232a 100644 --- a/Capy64/BIOS/Bios.cs +++ b/Capy64/BIOS/Bios.cs @@ -23,9 +23,9 @@ namespace Capy64.BIOS; public class Bios : IPlugin { private static IGame _game; - private EventEmitter _eventEmitter; + private readonly EventEmitter _eventEmitter; private RuntimeInputEvents _runtimeInputEvents; - private Drawing _drawing; + private readonly Drawing _drawing; private static bool CloseRuntime = false; private static bool OpenBios = false; @@ -132,7 +132,7 @@ public class Bios : IPlugin } } - private void InitLuaPlugins() + private static void InitLuaPlugins() { var allPlugins = new List(_game.NativePlugins); allPlugins.AddRange(_game.Plugins); @@ -142,7 +142,7 @@ public class Bios : IPlugin } } - public void InstallOS(bool force = false) + public static void InstallOS(bool force = false) { var installedFilePath = Path.Combine(FileSystem.BasePath, ".installed"); if (!File.Exists(installedFilePath) || force) diff --git a/Capy64/LuaRuntime/Extensions/Utils.cs b/Capy64/LuaRuntime/Extensions/Utils.cs index 1c5d558..93ae50b 100644 --- a/Capy64/LuaRuntime/Extensions/Utils.cs +++ b/Capy64/LuaRuntime/Extensions/Utils.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Threading.Tasks; namespace Capy64.LuaRuntime.Extensions; - public static class Utils { public static void PushArray(this Lua state, object obj) @@ -25,10 +24,10 @@ public static class Utils } state.SetTop(-1); } - +#nullable enable public static int PushValue(this Lua state, object? obj) { - var type = obj.GetType(); + var type = obj?.GetType(); switch (obj) { case string str: @@ -74,7 +73,7 @@ public static class Utils break; default: - if (type.IsArray) + if (type is not null && type.IsArray) { state.PushArray(obj); } diff --git a/Capy64/LuaRuntime/Sandbox.cs b/Capy64/LuaRuntime/Sandbox.cs index 84b3223..8aa7bce 100644 --- a/Capy64/LuaRuntime/Sandbox.cs +++ b/Capy64/LuaRuntime/Sandbox.cs @@ -14,10 +14,6 @@ namespace Capy64.LuaRuntime; internal class Sandbox { - private struct CallData - { - public int Delta; - } internal static void OpenLibraries(Lua L) { L.OpenBase();