tanghai 3 лет назад
Родитель
Сommit
76586a8955

+ 1 - 1
Apps/App/Program.cs

@@ -37,7 +37,7 @@ namespace ET
 
 				Options.Instance = options;
 
-				Log.ILog = new NLogger(Game.Options.AppType.ToString());
+				Game.ILog = new NLogger(Game.Options.AppType.ToString());
 				LogManager.Configuration.Variables["appIdFormat"] = $"{Game.Options.Process:000000}";
 				
 				Log.Console($"app start: {Game.Scene.Id} options: {JsonHelper.ToJson(Game.Options)} ");

+ 3 - 1
Apps/Core/Apps.Core.csproj

@@ -3,19 +3,21 @@
     <PropertyGroup>
         <TargetFramework>net6.0</TargetFramework>
         <ImplicitUsings>enable</ImplicitUsings>
-        <Nullable>enable</Nullable>
+        <Nullable>disable</Nullable>
     </PropertyGroup>
 
     <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
       <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
       <DefineConstants>TRACE;APPS</DefineConstants>
       <OutputPath>..\..\Bin\</OutputPath>
+      <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     </PropertyGroup>
 
     <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
       <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
       <DefineConstants>TRACE;APPS</DefineConstants>
       <OutputPath>..\..\Bin\</OutputPath>
+      <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     </PropertyGroup>
     
     <ItemGroup>

+ 0 - 0
Apps/Model/Module/NetworkTCP/AMRpcHandler.cs → Apps/Model/Module/MessageInner/AMRpcHandler.cs


+ 2 - 8
Apps/Model/Module/RobotCase/RobotLog.cs

@@ -1,26 +1,20 @@
-using DnsClient.Internal;
-
 namespace ET
 {
 	public static class RobotLog
 	{
-		private static readonly ILog logger = new NLogger("RobotConsole");
-		
 		public static void Debug(string msg)
 		{
 			Log.Info(msg);
-			logger.Info(msg);
 		}
 		
 		public static void Debug(string msg, params object[] args)
 		{
-			Log.Info(msg);
-			logger.Info(msg, args);
+			Log.Info(msg, args);
 		}
 
 		public static void Console(string msg)
 		{
-			logger.Info(msg);
+			Log.Console(msg);
 		}
 	}
 }

+ 1 - 1
Apps/Model/Server/AOI/AOIManagerComponent.cs

@@ -4,6 +4,6 @@
     [ComponentOf(typeof(Scene))]
     public class AOIManagerComponent: Entity, IAwake
     {
-        public static int CellSize = 10 * 1000;
+        public const int CellSize = 10 * 1000;
     }
 }

+ 1 - 1
Apps/Tool/Program.cs

@@ -34,7 +34,7 @@ namespace ET
 
                 Options.Instance = options;
 
-                Log.ILog = new NLogger(Game.Options.AppType.ToString());
+                Game.ILog = new NLogger(Game.Options.AppType.ToString());
                 LogManager.Configuration.Variables["appIdFormat"] = $"{Game.Options.Process:000000}";
 				
                 Log.Info($"server start........................ {Game.Scene.Id}");

+ 2 - 0
Unity/Assets/Core/Entity/Game.cs

@@ -33,6 +33,8 @@ namespace ET
 
         public static List<Action> FrameFinishCallback = new List<Action>();
 
+        public static ILog ILog { get; set; }
+
         public static void Update()
         {
             ThreadSynchronizationContext.Update();

+ 15 - 23
Unity/Assets/Core/Log/Log.cs

@@ -1,18 +1,10 @@
 using System;
 using System.Diagnostics;
-using System.IO;
-using System.Net;
-
-#if APPS
-using NLog;
-#endif
 
 namespace ET
 {
     public static class Log
     {
-        public static ILog ILog { get; set; }
-        
         private const int TraceLevel = 1;
         private const int DebugLevel = 2;
         private const int InfoLevel = 3;
@@ -34,7 +26,7 @@ namespace ET
                 return;
             }
             StackTrace st = new StackTrace(1, true);
-            ILog.Trace($"{msg}\n{st}");
+            Game.ILog.Trace($"{msg}\n{st}");
         }
 
         public static void Debug(string msg)
@@ -43,7 +35,7 @@ namespace ET
             {
                 return;
             }
-            ILog.Debug(msg);
+            Game.ILog.Debug(msg);
         }
 
         public static void Info(string msg)
@@ -52,7 +44,7 @@ namespace ET
             {
                 return;
             }
-            ILog.Info(msg);
+            Game.ILog.Info(msg);
         }
 
         public static void TraceInfo(string msg)
@@ -62,7 +54,7 @@ namespace ET
                 return;
             }
             StackTrace st = new StackTrace(1, true);
-            ILog.Trace($"{msg}\n{st}");
+            Game.ILog.Trace($"{msg}\n{st}");
         }
 
         public static void Warning(string msg)
@@ -72,24 +64,24 @@ namespace ET
                 return;
             }
 
-            ILog.Warning(msg);
+            Game.ILog.Warning(msg);
         }
 
         public static void Error(string msg)
         {
             StackTrace st = new StackTrace(1, true);
-            ILog.Error($"{msg}\n{st}");
+            Game.ILog.Error($"{msg}\n{st}");
         }
 
         public static void Error(Exception e)
         {
             if (e.Data.Contains("StackTrace"))
             {
-                ILog.Error($"{e.Data["StackTrace"]}\n{e}");
+                Game.ILog.Error($"{e.Data["StackTrace"]}\n{e}");
                 return;
             }
             string str = e.ToString();
-            ILog.Error(str);
+            Game.ILog.Error(str);
         }
 
         public static void Trace(string message, params object[] args)
@@ -99,7 +91,7 @@ namespace ET
                 return;
             }
             StackTrace st = new StackTrace(1, true);
-            ILog.Trace($"{string.Format(message, args)}\n{st}");
+            Game.ILog.Trace($"{string.Format(message, args)}\n{st}");
         }
 
         public static void Warning(string message, params object[] args)
@@ -108,7 +100,7 @@ namespace ET
             {
                 return;
             }
-            ILog.Warning(string.Format(message, args));
+            Game.ILog.Warning(string.Format(message, args));
         }
 
         public static void Info(string message, params object[] args)
@@ -117,7 +109,7 @@ namespace ET
             {
                 return;
             }
-            ILog.Info(string.Format(message, args));
+            Game.ILog.Info(string.Format(message, args));
         }
 
         public static void Debug(string message, params object[] args)
@@ -126,7 +118,7 @@ namespace ET
             {
                 return;
             }
-            ILog.Debug(string.Format(message, args));
+            Game.ILog.Debug(string.Format(message, args));
 
         }
 
@@ -134,7 +126,7 @@ namespace ET
         {
             StackTrace st = new StackTrace(1, true);
             string s = string.Format(message, args) + '\n' + st;
-            ILog.Error(s);
+            Game.ILog.Error(s);
         }
         
         public static void Console(string message)
@@ -143,7 +135,7 @@ namespace ET
             {
                 System.Console.WriteLine(message);
             }
-            ILog.Debug(message);
+            Game.ILog.Debug(message);
         }
         
         public static void Console(string message, params object[] args)
@@ -153,7 +145,7 @@ namespace ET
             {
                 System.Console.WriteLine(s);
             }
-            ILog.Debug(s);
+            Game.ILog.Debug(s);
         }
     }
 }

+ 1 - 1
Unity/Assets/Mono/MonoBehaviour/Init.cs

@@ -31,7 +31,7 @@ namespace ET
 
 			ETTask.ExceptionHandler += Log.Error;
 
-			Log.ILog = new UnityLogger();
+			Game.ILog = new UnityLogger();
 
 			Options.Instance = new Options();
 

+ 0 - 55
Unity/Codes/Model/Module/Message/MessagePackHelper.cs

@@ -1,55 +0,0 @@
-using System;
-using System.IO;
-
-namespace ET
-{
-    /*
-    public static class MessagePackHelper
-    {
-        static MessagePackHelper()
-        {
-            UnityTypeBindings.Register();
-        }
-
-        public static void Init()
-        {
-        }
-        
-        public static object FromBytes(Type type, byte[] bytes, int index, int count)
-        {
-            ReadOnlyMemory<byte> memory = new ReadOnlyMemory<byte>(bytes, index, count);
-            return MessagePack.MessagePackSerializer.Deserialize(type, memory);
-        }
-        
-        public static byte[] ToBytes(object message)
-        {
-            return MessagePack.MessagePackSerializer.Serialize(message);
-        }
-        
-        public static void ToStream(object message, MemoryStream stream)
-        {
-            MessagePack.MessagePackSerializer.Serialize(stream, message);
-        }
-
-        public static object FromStream(Type type, MemoryStream stream)
-        {
-            return MessagePack.MessagePackSerializer.Deserialize(type, stream);
-        }
-        
-        public static string ToJson(object message)
-        {
-            return LitJson.JsonMapper.ToJson(message);
-        }
-        
-        public static object FromJson(Type type, string json)
-        {
-            return LitJson.JsonMapper.ToObject(json, type);
-        }
-        
-        public static T FromJson<T>(string json)
-        {
-            return LitJson.JsonMapper.ToObject<T>(json);
-        }
-    }
-    */
-}

+ 2 - 2
Unity/Codes/Model/Module/Message/OpcodeHelper.cs

@@ -37,7 +37,7 @@ namespace ET
                 return;
             }
             
-            Log.ILog.Debug("zone: {0} {1}", zone, message);
+            Game.ILog.Debug("zone: {0} {1}", zone, message);
         }
         
         public static void LogMsg(ushort opcode, long actorId, object message)
@@ -47,7 +47,7 @@ namespace ET
                 return;
             }
             
-            Log.ILog.Debug("actorId: {0} {1}", actorId, message);
+            Game.ILog.Debug("actorId: {0} {1}", actorId, message);
         }
     }
 }

+ 1 - 1
Unity/Codes/Model/Module/Recast/PathfindingComponent.cs

@@ -8,7 +8,7 @@ namespace ET
     [ComponentOf(typeof(Unit))]
     public class PathfindingComponent: Entity, IAwake<string>, IDestroy
     {
-        public static int FindRandomNavPosMaxRadius = 15000;  // 随机找寻路点的最大半径
+        public const int FindRandomNavPosMaxRadius = 15000;  // 随机找寻路点的最大半径
         
         public static float[] extents = {15, 10, 15};