diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.Statistics.cs b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.Statistics.cs index a1e3c1ec..17b8fb4a 100644 --- a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.Statistics.cs +++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/AxiProjectTools.Statistics.cs @@ -438,7 +438,8 @@ public class AxiProjectToolsStatistics : EditorWindow int DirtyCount = 0; foreach (var node in cache.nodes) { - GameObject targetNodePathObj = GetNodeByLink(cache.FullPath, node.link, out string errStr); + string errStr; + GameObject targetNodePathObj = GetNodeByLink(cache.FullPath, node.link, out errStr); if (targetNodePathObj == null) { errLog.Add(errStr); diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/GenCode.cs b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/GenCode.cs new file mode 100644 index 00000000..da300e01 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/GenCode.cs @@ -0,0 +1,69 @@ +#if UNITY_EDITOR +using AxibugEmuOnline.Client.Network; +using Google.Protobuf; +using System; +using System.Collections; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using UnityEditor; + +public static class GenCode +{ + const string TEMPLATE = @" +namespace [NAMESPACE] +{ + public sealed partial class [CLASSNAME] : IResetable + { + public void Reset() + {[RESETCODE] + } + } +} +"; + [MenuItem("项目工具/生成Protobuff Reset代码文件")] + public static void GenResetCode() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("using AxibugEmuOnline.Client.Network;"); + + var msgInterfaceType = typeof(IMessage); + var protoMsgTypes = typeof(NetMsg).Assembly.GetExportedTypes().Where(t => msgInterfaceType.IsAssignableFrom(t)).ToArray(); + var flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.GetProperty; + foreach (var msgType in protoMsgTypes) + { + if (msgType.IsAbstract) continue; + + var props = msgType.GetProperties(flag); + StringBuilder resetCodeSB = new StringBuilder(); + foreach (var prop in props) + { + resetCodeSB.AppendLine(); + if (prop.PropertyType.IsValueType) + resetCodeSB.Append($"\t\t\t{prop.Name} = default;"); + else if (typeof(IBufferMessage).IsAssignableFrom(prop.PropertyType)) + resetCodeSB.Append($"\t\t\t{prop.Name}?.Reset();"); + else if (typeof(IList).IsAssignableFrom(prop.PropertyType)) + resetCodeSB.Append($"\t\t\t{prop.Name}?.Clear();"); + else if (typeof(string) == prop.PropertyType) + resetCodeSB.Append($"\t\t\t{prop.Name} = string.Empty;"); + else if (typeof(ByteString) == prop.PropertyType) + resetCodeSB.Append($"\t\t\t{prop.Name} = Google.Protobuf.ByteString.Empty;"); + else throw new Exception($"Not Impl Reset Op {msgType}.{prop.Name} : {prop.PropertyType}"); + } + var code = TEMPLATE + .Replace("[NAMESPACE]", msgType.Namespace) + .Replace("[CLASSNAME]", msgType.Name) + .Replace("[RESETCODE]", resetCodeSB.ToString()); + + + sb.AppendLine(code); + } + + File.WriteAllText("Assets/Script/AppMain/Network/ProtobufferMsgPool.g.cs", sb.ToString()); + + AssetDatabase.Refresh(); + } +} +#endif \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/GenCode.cs.meta b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/GenCode.cs.meta new file mode 100644 index 00000000..28a92248 --- /dev/null +++ b/AxibugEmuOnline.Client/Assets/AxiProjectTools/Editors/GenCode.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 896973cf744f927409f700f4e9151a82 \ No newline at end of file diff --git a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/FrameProfiler.cs b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/FrameProfiler.cs index cb9a180c..aa85efa3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/FrameProfiler.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/AxiReplay/FrameProfiler.cs @@ -53,7 +53,8 @@ namespace AxiReplay void CalcCacheCount() { double deltaMax = 0; - while (m_timePoints.TryRead(out double delta)) + double delta; + while (m_timePoints.TryRead(out delta)) { deltaMax = Math.Max(deltaMax, delta); } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/AxiMemory.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/AxiMemory.cs index 159b9fa8..a32d7f94 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/AxiMemory.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/AxiMemory.cs @@ -16,28 +16,33 @@ namespace Essgee.Utilities public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (uint*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (short*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (ushort*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (int*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (byte*)intptr; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/ColecoVision.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/ColecoVision.cs index b700e3be..8ddb9fff 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/ColecoVision.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/Emulation/Machines/ColecoVision.cs @@ -186,7 +186,8 @@ namespace Essgee.Emulation.Machines //var (type, bootstrapRomData) = CartridgeLoader.Load(configuration.BiosRom, "ColecoVision BIOS"); //直接加载BootStrap - GameMetadataHandler.instance.gameMetaReources.GetDatBytes("Bootstrap/[BIOS] ColecoVision (USA, Europe).col", out byte[] bootstrapRomData); + byte[] bootstrapRomData; + GameMetadataHandler.instance.gameMetaReources.GetDatBytes("Bootstrap/[BIOS] ColecoVision (USA, Europe).col", out bootstrapRomData); bios = new ColecoCartridge(bootstrapRomData.Length, 0); bios.LoadRom(bootstrapRomData); } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/ObjectPoolAuto.cs b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/ObjectPoolAuto.cs index c55fd88c..4b8fb1f3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/ObjectPoolAuto.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Essgee.Unity/ObjectPoolAuto.cs @@ -159,7 +159,8 @@ internal static class ObjectPoolAuto public static T GetCachedResult(Func function) { var method = function.Method; - if (!Cache.Results.TryGetValue(method, out var result)) + KeyValuePair, T> result; + if (!Cache.Results.TryGetValue(method, out result)) { result = new KeyValuePair, T>(function, function()); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/IngameDebugConsole/Scripts/InputFieldWarningsFixer.cs b/AxibugEmuOnline.Client/Assets/Plugins/IngameDebugConsole/Scripts/InputFieldWarningsFixer.cs index 27b2f0d6..a3fec150 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/IngameDebugConsole/Scripts/InputFieldWarningsFixer.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/IngameDebugConsole/Scripts/InputFieldWarningsFixer.cs @@ -18,7 +18,9 @@ namespace IngameDebugConsole protected void OnValidate() { - if( preventFontCallback != null && TryGetComponent( out InputField inputField ) ) + InputField inputField; + + if ( preventFontCallback != null && TryGetComponent( out inputField ) ) { preventFontCallback.SetValue( inputField, true ); UnityEditor.EditorApplication.delayCall += () => preventFontCallback.SetValue( inputField, false ); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/ObjectPoolAuto.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/ObjectPoolAuto.cs index 56dd3a31..f551b4b3 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/ObjectPoolAuto.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/ObjectPoolAuto.cs @@ -151,7 +151,8 @@ namespace MAME.Core public static T GetCachedResult(Func function) { var method = function.Method; - if (!Cache.Results.TryGetValue(method, out var result)) + KeyValuePair, T> result; + if (!Cache.Results.TryGetValue(method, out result)) { result = new KeyValuePair, T>(function, function()); diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs index 181c3d78..3704a1f9 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Memory.cs @@ -420,28 +420,33 @@ namespace MAME.Core public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (uint*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (short*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (ushort*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (int*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (byte*)intptr; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mouse.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mouse.cs index aeaade3c..8358d079 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mouse.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/Mouse.cs @@ -15,7 +15,8 @@ namespace MAME.Core public static void Update() { int X, Y; - iMouse.MouseXY(out X, out Y, out byte[] MouseButtons); + byte[] MouseButtons; + iMouse.MouseXY(out X, out Y, out MouseButtons); deltaX = X - oldX; deltaY = Y - oldY; oldX = X; diff --git a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/RomInfo.cs b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/RomInfo.cs index 3cff492f..5fc8d3fd 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/RomInfo.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/Mame.Core/emu/RomInfo.cs @@ -21,7 +21,8 @@ namespace MAME.Core } public static RomInfo GetRomByName(string s1) { - if (!dictName2Rom.TryGetValue(s1, out RomInfo info)) + RomInfo info; + if (!dictName2Rom.TryGetValue(s1, out info)) return null; return info; } diff --git a/AxibugEmuOnline.Client/Assets/Plugins/StoicGooseUnity/AxiMemory.cs b/AxibugEmuOnline.Client/Assets/Plugins/StoicGooseUnity/AxiMemory.cs index ea12178c..8a47884e 100644 --- a/AxibugEmuOnline.Client/Assets/Plugins/StoicGooseUnity/AxiMemory.cs +++ b/AxibugEmuOnline.Client/Assets/Plugins/StoicGooseUnity/AxiMemory.cs @@ -21,28 +21,33 @@ namespace StoicGooseUnity public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref uint* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (uint*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref short* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (short*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref ushort* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (ushort*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref int* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (int*)intptr; } public static void GetObjectPtr(this object srcObj, ref GCHandle handle, ref byte* ptr) { - GetObjectPtr(srcObj, ref handle, out IntPtr intptr); + IntPtr intptr; + GetObjectPtr(srcObj, ref handle, out intptr); ptr = (byte*)intptr; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiPlayerPrefs/AxiPlayerPrefsFileBase.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiPlayerPrefs/AxiPlayerPrefsFileBase.cs index c2ed6ed5..53462598 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiPlayerPrefs/AxiPlayerPrefsFileBase.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/AxiPlayerPrefs/AxiPlayerPrefsFileBase.cs @@ -83,23 +83,26 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs public float GetFloat(string key, float defaultValue) { - AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool IsNew); + bool IsNew; + AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out IsNew); if (IsNew) kv.floatval = defaultValue; return kv.floatval; } public int GetInt(string key, int defaultValue) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool IsNew); + { + bool IsNew; + AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out IsNew); if (IsNew) kv.intval = defaultValue; return kv.intval; } public string GetString(string key, string defaultValue) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool IsNew); + { + bool IsNew; + AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out IsNew); if (IsNew) kv.strval = defaultValue; return kv.strval; @@ -107,29 +110,33 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs public float GetFloat(string key) { - AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out bool _); + bool val; + AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out val); if (kv != null) return kv.floatval; return default(float); } public int GetInt(string key) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out bool _); + { + bool val; + AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out val); if (kv != null) return kv.intval; return default(int); } public string GetString(string key) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out bool _); + { + bool val; + AxiPlayerPrefsKeyValye kv = GetByKey(key, false, out val); if (kv != null) return kv.strval; return string.Empty; } public void SetInt(string key, int value) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool _); + { + bool val; + AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out val); if (kv.intval == value) return; kv.intval = value; @@ -137,8 +144,9 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs } public void SetString(string key, string value) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool _); + { + bool val; + AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out val); if (string.Equals(kv.strval, value)) return; kv.strval = value; @@ -146,8 +154,9 @@ public abstract class AxiPlayerPrefsFileBase : IAxiPlayerPrefs } public void SetFloat(string key, float value) - { - AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out bool _); + { + bool val; + AxiPlayerPrefsKeyValye kv = GetByKey(key, true, out val); if (kv.floatval == value) return; kv.floatval = value; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs index 515c1cd0..3b0e7330 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Common/ObjectPoolAuto.cs @@ -162,7 +162,8 @@ namespace AxibugEmuOnline.Client.Common public static T GetCachedResult(Func function) { var method = function.Method; - if (!Cache.Results.TryGetValue(method, out var result)) + KeyValuePair, T> result; + if (!Cache.Results.TryGetValue(method, out result)) { result = new KeyValuePair, T>(function, function()); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/EmuCore.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/EmuCore.cs index 2014c0a1..55779b19 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/EmuCore.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/EmuCore.cs @@ -88,7 +88,8 @@ namespace AxibugEmuOnline.Client bool TryPushEmulatorFrame() { - if (SampleInputData(out var inputData)) + INPUTDATA inputData; + if (SampleInputData(out inputData)) { if (IsNetPlay) SendLocalInput(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/Handle/DatabaseHandler.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/Handle/DatabaseHandler.cs index 26779e16..7224f0f7 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/Handle/DatabaseHandler.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Emulator/StoicGooseEmulator/Handle/DatabaseHandler.cs @@ -14,7 +14,8 @@ public sealed class DatabaseHandler { { string wsc = "Bandai - WonderSwan Color.dat"; - GetDatBytes(wsc, out byte[] loadedData); + byte[] loadedData; + GetDatBytes(wsc, out loadedData); using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData)) { var root = new XmlRootAttribute("datafile") { IsNullable = true }; @@ -26,7 +27,8 @@ public sealed class DatabaseHandler { string ws = "Bandai - WonderSwan.dat"; - GetDatBytes(ws, out byte[] loadedData); + byte[] loadedData; + GetDatBytes(ws, out loadedData); using (System.IO.MemoryStream stream = new System.IO.MemoryStream(loadedData)) { var root = new XmlRootAttribute("datafile") { IsNullable = true }; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppLogin.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppLogin.cs index 64f22168..3af7c49a 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppLogin.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppLogin.cs @@ -68,7 +68,7 @@ namespace AxibugEmuOnline.Client.Manager } public void RecvLoginMsg(Protobuf_Login_RESP msg) - { + { if (msg.Status == LoginResultStatus.Ok) { App.log.Info("登录成功"); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterChainEffect.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterChainEffect.cs index 0807fb89..01f4cf5e 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterChainEffect.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/Filter/FilterChainEffect.cs @@ -78,7 +78,8 @@ public abstract class FilterChainEffect : FilterEffect { var existoutput = m_passOutputTexNames[index]; var existoutputSize = m_passOutputTexSizes[index]; - if (m_outputCaches.TryGetValue(existoutput, out var passOutput)) + RenderTexture passOutput; + if (m_outputCaches.TryGetValue(existoutput, out passOutput)) { if (pass.Mat.HasTexture(existoutput)) pass.Mat.SetTexture(existoutput, passOutput); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/KeyMapperSetting.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/KeyMapperSetting.cs index 6afc72c7..01dc93ff 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/KeyMapperSetting.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/KeyMapperSetting.cs @@ -28,13 +28,15 @@ namespace AxibugEmuOnline.Client.Settings public T GetBinder() where T : InternalEmuCoreBinder { - m_bindersByType.TryGetValue(typeof(T), out var binder); + InternalEmuCoreBinder binder; + m_bindersByType.TryGetValue(typeof(T), out binder); return binder as T; } public T GetBinder(RomPlatformType romType) where T : InternalEmuCoreBinder { - m_binders.TryGetValue(romType, out var binder); + InternalEmuCoreBinder binder; + m_binders.TryGetValue(romType, out binder); return binder as T; } } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/Model/EmuCoreBinder.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/Model/EmuCoreBinder.cs index 3ad6b597..483e1776 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/Model/EmuCoreBinder.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppSettings/KeyMapperSetting/Model/EmuCoreBinder.cs @@ -258,12 +258,14 @@ public abstract class EmuCoreBinder : InternalEmuCoreBinder, public void SetBinding(T emuBtn, InputControl_C key, int settingSlot) { var device = key.Device; - m_registedDevices.TryGetValue(device.GetType(), out var inputDevice); + InputDevice_D inputDevice; + m_registedDevices.TryGetValue(device.GetType(), out inputDevice); Debug.Assert(inputDevice == device); var setting = m_mapSetting[inputDevice]; - if (!setting.TryGetValue(emuBtn, out var settingList)) + List settingList; + if (!setting.TryGetValue(emuBtn, out settingList)) { settingList = new List(); setting[emuBtn] = settingList; @@ -277,10 +279,12 @@ public abstract class EmuCoreBinder : InternalEmuCoreBinder, public InputControl_C GetBinding(T emuBtn, InputDevice_D device, int settingSlot) { - m_mapSetting.TryGetValue(device, out var mapSetting); + MapSetting mapSetting; + m_mapSetting.TryGetValue(device, out mapSetting); if (mapSetting == null) return null; - mapSetting.TryGetValue(emuBtn, out var settingList); + List settingList; + mapSetting.TryGetValue(emuBtn, out settingList); if (settingList == null || settingSlot >= settingList.Count) return null; return settingList[settingSlot]; @@ -293,7 +297,8 @@ public abstract class EmuCoreBinder : InternalEmuCoreBinder, foreach (var mapSettings in m_mapSetting.Values) { - mapSettings.TryGetValue(emuBtn, out var bindControls); + List bindControls; + mapSettings.TryGetValue(emuBtn, out bindControls); if (bindControls != null) { m_caches.AddRange(bindControls); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/DualWayDictionary.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/DualWayDictionary.cs index 3ab06251..491218c5 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/DualWayDictionary.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/DualWayDictionary.cs @@ -28,7 +28,8 @@ namespace AxibugEmuOnline.Client.InputDevices get => _forward[key]; set { - if (_forward.TryGetValue(key, out var oldValue)) + TValue oldValue; + if (_forward.TryGetValue(key, out oldValue)) _reverse.Remove(oldValue); _forward[key] = value; _reverse[value] = key; @@ -78,7 +79,11 @@ namespace AxibugEmuOnline.Client.InputDevices } public bool Contains(object key) => key is TKey k && _forward.ContainsKey(k); - public bool Contains(KeyValuePair item) => _forward.TryGetValue(item.Key, out var v) && v.Equals(item.Value); + public bool Contains(KeyValuePair item) + { + TValue v; + return _forward.TryGetValue(item.Key, out v) && v.Equals(item.Value); + } public bool ContainsKey(TKey key) => _forward.ContainsKey(key); public void CopyTo(KeyValuePair[] array, int arrayIndex) @@ -93,7 +98,8 @@ namespace AxibugEmuOnline.Client.InputDevices public bool Remove(TKey key) { - if (!_forward.Remove(key, out var value)) return false; + TValue value; + if (!_forward.Remove(key, out value)) return false; _reverse.Remove(value); return true; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputResolver.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputResolver.cs index 42d438b4..acd456b6 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputResolver.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputResolver.cs @@ -40,7 +40,8 @@ namespace AxibugEmuOnline.Client.InputDevices private void AxiScreenGamepad_OnGamepadDisactive(AxiScreenGamepad sender) { - if (m_devices.TryGetValue(sender, out var device)) + ScreenGamepad_D device; + if (m_devices.TryGetValue(sender, out device)) { m_devices.Remove(sender); RaiseDeviceLost(device); @@ -76,7 +77,8 @@ namespace AxibugEmuOnline.Client.InputDevices { if (device is ScreenGamepad_D) { - return m_devices.TryGetKey(device as ScreenGamepad_D, out var _); + AxiScreenGamepad val; + return m_devices.TryGetKey(device as ScreenGamepad_D, out val); } else { @@ -168,7 +170,8 @@ namespace AxibugEmuOnline.Client.InputDevices { if (inputDevice is ScreenGamepad_D) { - m_devices.TryGetKey(inputDevice as ScreenGamepad_D, out var realDeviceScript); + AxiScreenGamepad realDeviceScript; + m_devices.TryGetKey(inputDevice as ScreenGamepad_D, out realDeviceScript); return $"{realDeviceScript.GetType().Name}_{realDeviceScript.GetHashCode()}"; } else return OnGetDeviceName(inputDevice); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputSystemResolver.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputSystemResolver.cs index f5bfefd8..43af0188 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputSystemResolver.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/InputDevicesManager/InputResolver/InputSystemResolver.cs @@ -108,7 +108,8 @@ On-Screen Keyboard:这个是真正的屏幕软键盘。 private void RemoveDevice(InputDevice ipdev) { - if (m_devices.TryGetValue(ipdev, out var device)) + InputDevice_D device; + if (m_devices.TryGetValue(ipdev, out device)) { RemoveDeviceMapper(device); RaiseDeviceLost(device); @@ -118,7 +119,8 @@ On-Screen Keyboard:这个是真正的屏幕软键盘。 private T GetInputSystemDevice(InputDevice_D device) where T : InputDevice { - m_devices.TryGetKey(device, out var ipDev); + InputDevice ipDev; + m_devices.TryGetKey(device, out ipDev); return ipDev as T; } @@ -132,7 +134,8 @@ On-Screen Keyboard:这个是真正的屏幕软键盘。 protected override bool OnCheckOnline(InputDevice_D device) { - return m_devices.TryGetKey(device, out var _); + InputDevice val; + return m_devices.TryGetKey(device, out val); } private void IP_onDeviceChange(InputDevice device, InputDeviceChange changeType) @@ -171,7 +174,8 @@ On-Screen Keyboard:这个是真正的屏幕软键盘。 { var device_d = key.Device; var mapper = m_deviceMapper[device_d]; - mapper.TryGetValue(key, out InputControl inputBtn); + InputControl inputBtn; + mapper.TryGetValue(key, out inputBtn); if (inputBtn != null) return inputBtn; else diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/FileDownloader.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/FileDownloader.cs index 068a018f..18052ef6 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/FileDownloader.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/RomLib/FileDownloader.cs @@ -11,7 +11,8 @@ namespace AxibugEmuOnline.Client Dictionary> m_completeCallback = new Dictionary>(); public void BeginDownload(string url, Action callback) { - if (m_downloadingTasks.TryGetValue(url, out var downloadProxy)) return; + AxiHttpProxy.SendDownLoadProxy downloadProxy; + if (m_downloadingTasks.TryGetValue(url, out downloadProxy)) return; m_completeCallback[url] = callback; var downloadRequest = AxiHttpProxy.GetDownLoad($"{App.httpAPI.WebHost}/{url}"); @@ -20,7 +21,8 @@ namespace AxibugEmuOnline.Client public float? GetDownloadProgress(string url) { - m_downloadingTasks.TryGetValue(url, out var proxy); + AxiHttpProxy.SendDownLoadProxy proxy; + m_downloadingTasks.TryGetValue(url, out proxy); if (proxy == null) return null; return Mathf.Clamp01(proxy.downloadHandler.downLoadPr); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs index 91cbc4d5..76c1c8a7 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFile.cs @@ -275,13 +275,14 @@ namespace AxibugEmuOnline.Client private static void Add(SyncingFiles file) { - if (!m_syncFiles.TryGetValue(file.platform, out var mapper)) + Dictionary> mapper; + if (!m_syncFiles.TryGetValue(file.platform, out mapper)) { mapper = new Dictionary>(); m_syncFiles.Add(file.platform, mapper); } - - if (!mapper.TryGetValue(file.romID, out var syncingTables)) + HashSet syncingTables; + if (!mapper.TryGetValue(file.romID, out syncingTables)) { syncingTables = new HashSet(); mapper[file.romID] = syncingTables; @@ -296,12 +297,15 @@ namespace AxibugEmuOnline.Client public static void Remove(SaveFile savFile) { SyncingFiles file = new SyncingFiles { romID = savFile.RomID, platform = savFile.EmuPlatform, slotIndex = savFile.SlotIndex }; - if (!m_syncFiles.TryGetValue(file.platform, out var mapper)) + + Dictionary> mapper; + if (!m_syncFiles.TryGetValue(file.platform, out mapper)) { return; } - if (!mapper.TryGetValue(savFile.RomID, out var syncingTables)) + HashSet syncingTables; + if (!mapper.TryGetValue(savFile.RomID, out syncingTables)) { return; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFileSyncStates/UploadingState.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFileSyncStates/UploadingState.cs index 224db995..c7f27d98 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFileSyncStates/UploadingState.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SaveFileSyncStates/UploadingState.cs @@ -15,7 +15,8 @@ namespace AxibugEmuOnline.Client FSM.ChangeState(); return; } - Host.GetSavData(out byte[] savData, out byte[] screenData); + byte[] savData, screenData; + Host.GetSavData(out savData, out screenData); Host.CloudAPI.SendUpLoadGameSav(Host.RomID, Host.SlotIndex, Host.Sequecen, savData, screenData); Host.SetSavingFlag(); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SimpleSFM.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SimpleSFM.cs index b59fa540..cf986517 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SimpleSFM.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/SaveSlotManager/SimpleSFM.cs @@ -100,7 +100,8 @@ namespace AxibugEmuOnline.Client.Tools public T GetState() where T : State, new() { - m_states.TryGetValue(typeof(T), out var value); + State value; + m_states.TryGetValue(typeof(T), out value); return value as T; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs index 1283c426..943a7218 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/MonoCom/AudioMgr.cs @@ -201,7 +201,8 @@ namespace AxibugEmuOnline.Client public void BeginRecordGameAudio() { - App.emu.Core.GetAudioParams(out int frequency, out int channels); + int frequency, channels; + App.emu.Core.GetAudioParams(out frequency, out channels); BeginRecording(frequency, channels); } @@ -275,7 +276,8 @@ namespace AxibugEmuOnline.Client this.SourceSampleRate = SourceSampleRate; this.AxiAudioPullHandle = audiohandle; NeedsResampling = SourceSampleRate != AudioSettings.outputSampleRate; - AudioSettings.GetDSPBufferSize(out int bufferLength, out int numBuffers); + int bufferLength, numBuffers; + AudioSettings.GetDSPBufferSize(out bufferLength, out numBuffers); } } class WaveHeader diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs index 3fc882f7..febaaab2 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/NetMsg.cs @@ -62,8 +62,10 @@ namespace AxibugEmuOnline.Client.Network public void UnregisterCMD(int cmd, Action callback) where T : IMessage { - if (delegateWrappers.TryGetValue(typeof(T), out var wrapperDict) && - wrapperDict.TryGetValue(callback, out var wrappedCallback)) + Dictionary> wrapperDict; + Action wrappedCallback; + if (delegateWrappers.TryGetValue(typeof(T), out wrapperDict) && + wrapperDict.TryGetValue(callback, out wrappedCallback)) { InterUnregisterCMD(cmd, wrappedCallback); wrapperDict.Remove(callback); @@ -242,7 +244,8 @@ namespace AxibugEmuOnline.Client.Network } private static Type GetTypeByCmd(int cmd) { - if (cmd2MsgTypeDict.TryGetValue(cmd, out var type)) return type; + Type type; + if (cmd2MsgTypeDict.TryGetValue(cmd, out type)) return type; return null; } @@ -251,7 +254,8 @@ namespace AxibugEmuOnline.Client.Network /// private HashSet> GetNetEventDicList(int cmd) { - if (netEventDic.TryGetValue(cmd, out var tempList) && tempList != null) + HashSet> tempList; + if (netEventDic.TryGetValue(cmd, out tempList) && tempList != null) return tempList; return null; } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/ProtobufferMsgPool.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/ProtobufferMsgPool.cs index 6075fc72..72c42287 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/ProtobufferMsgPool.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Network/ProtobufferMsgPool.cs @@ -2,6 +2,7 @@ using Google.Protobuf; using System; using System.Collections.Generic; +using UnityEditor.Search; namespace AxibugEmuOnline.Client.Network { @@ -11,7 +12,8 @@ namespace AxibugEmuOnline.Client.Network public IMessage Get(Type msgType) { - if (!_pool.TryGetValue(msgType, out var queue)) + Queue queue; + if (!_pool.TryGetValue(msgType, out queue)) { queue = new Queue(); _pool[msgType] = queue; @@ -36,7 +38,8 @@ namespace AxibugEmuOnline.Client.Network if (msg is IResetable resetableMsg) { var msgType = msg.GetType(); - if (!_pool.TryGetValue(msgType, out var queue)) + Queue queue; + if (!_pool.TryGetValue(msgType, out queue)) { queue = new Queue(); _pool[msgType] = queue; diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateMenu.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateMenu.cs index 74e97dbd..bd967485 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateMenu.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI_SaveStateMenu.cs @@ -120,7 +120,8 @@ namespace AxibugEmuOnline.Client public override void OnExcute(OptionUI optionUI, ref bool cancelHide) { cancelHide = true; - m_savFile.GetSavData(out byte[] savData, out var _); + byte[] data, savData; + m_savFile.GetSavData(out savData, out data); if (savData != null) { m_ingameUI.Core.LoadStateFromBytes(savData); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs index 0ee28d76..65b4c9d4 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI.cs @@ -330,7 +330,8 @@ namespace AxibugEmuOnline.Client private void CreateRuntimeMenuItem(InternalOptionMenu menuData) { - m_menuUI_templates.TryGetValue(menuData.MenuUITemplateType, out var template); + OptionUI_MenuItem template; + m_menuUI_templates.TryGetValue(menuData.MenuUITemplateType, out template); if (template == null) { throw new NotImplementedException($"{menuData.GetType().Name}指定的MenuUI类型实例未在OptionUI中找到"); diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_SavSlotItem.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_SavSlotItem.cs index 8035d21c..92b99911 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_SavSlotItem.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/OptionUI/OptionUI_SavSlotItem.cs @@ -79,7 +79,8 @@ namespace AxibugEmuOnline.Client { var savTime = MenuData.SavFile.GetSavTimeUTC().ToLocalTime(); UI_SavTime.text = $"{savTime.Year}/{savTime.Month:00}/{savTime.Day:00}\n{savTime.Hour}:{savTime.Minute}:{savTime.Second}"; - MenuData.SavFile.GetSavData(out byte[] _, out byte[] screenShotData); + byte[] _tempdata, screenShotData; + MenuData.SavFile.GetSavData(out _tempdata, out screenShotData); if (!m_screenTex) m_screenTex = new Texture2D(1, 1);