Przeglądaj źródła

【BUG】解决一些登录过程中的报错

johnclot69 1 rok temu
rodzic
commit
b5e0e4fc41

+ 8 - 0
DotNet/App/Properties/launchSettings.json

@@ -0,0 +1,8 @@
+{
+  "profiles": {
+    "DotNet.App": {
+      "commandName": "Project",
+      "commandLineArgs": "--AppType=Server"
+    }
+  }
+}

+ 10 - 4
DotNet/Hotfix/Helper/MapHelper.cs

@@ -137,13 +137,13 @@ namespace ET.Server
             Map map = null;
 
             // 角色身上绑定的场景信息
-            PlayerMapInfo mapData = player.GetComponent<PlayerTempDataComponent>().MapData;
+            PlayerMapInfo playerMapInfo = player.GetComponent<PlayerTempDataComponent>().MapData;
 
             // 执行普通场景逻辑
-            MapConfig prop = MapConfigCategory.Instance.Get(mapData.mapId);
+            MapConfig prop = MapConfigCategory.Instance.Get(playerMapInfo.mapId);
             if (prop != null)
             {
-                map = player.DomainScene().GetComponent<GameMapComponent>().Get(mapData.mapInstanceId);
+                map = player.DomainScene().GetComponent<GameMapComponent>().Get(playerMapInfo.mapInstanceId);
             }
 
             if (map != null)
@@ -151,11 +151,16 @@ namespace ET.Server
                 return map;
             }
 
+            if (map == null)
+            {
+                playerMapInfo.mapId = 10098;
+            }
+
             // 创建一个场景
             JObject jsonObject = new JObject();
             jsonObject.Add("id", player.GetId());
             jsonObject.Add("logicServerId", player.GetLogicServerId());
-            jsonObject.Add("areaId", mapData.mapId);
+            jsonObject.Add("areaId", playerMapInfo.mapId);
             map = CreateMap(player, jsonObject, false);
 
             return map;
@@ -205,6 +210,7 @@ namespace ET.Server
             if (resCode == 0)
             {
                 jsonObject.Add("instanceId", instanceId);
+                jsonObject.Add("areaId", mapId);
                 return CreaLocalMap(player, prop, jsonObject, instanceId, mapId, player.GetLogicServerId().ToString());
             }
 

+ 3 - 3
DotNet/Hotfix/Module/Http/HttpComponentSystem.cs

@@ -14,7 +14,7 @@ namespace ET.Server
                 try
                 {
                     self.Load();
-                
+
                     self.Listener = new HttpListener();
 
                     foreach (string s in address.Split(';'))
@@ -55,7 +55,7 @@ namespace ET.Server
                 self.Listener.Close();
             }
         }
-        
+
         public static void Load(this HttpComponent self)
         {
             self.dispatcher = new Dictionary<string, IHttpHandler>();
@@ -89,7 +89,7 @@ namespace ET.Server
                 self.dispatcher.Add(httpHandlerAttribute.Path, ihttpHandler);
             }
         }
-        
+
         public static async ETTask Accept(this HttpComponent self)
         {
             long instanceId = self.InstanceId;

+ 2 - 0
DotNet/Hotfix/Scenes/Game/Handler/C2G_BindPlayerHandler.cs

@@ -86,6 +86,8 @@ namespace ET.Server
             player ??= scene.GetComponent<GamePlayerComponent>()
                     .AddChildWithId<WNPlayer, Session, PlayerInfo>(playerInfo.Id, session, playerInfo);
 
+            await player.GetComponent<PlayerTempDataComponent>().InitFromDB(player);
+
             session.AddComponent<MailBoxComponent, MailboxType>(MailboxType.GateSession);
 
             session.GetComponent<SessionPlayerComponent>().PlayerId = request.PlayerId;

+ 8 - 2
DotNet/Hotfix/Scenes/Game/Player/PlayerTempDataComponentSystem.cs

@@ -12,7 +12,6 @@ namespace ET.Server
         /// <param name="player"></param>
         protected override void Awake(PlayerTempDataComponent self, WNPlayer player)
         {
-            self?.Init(player);
         }
     }
 
@@ -31,15 +30,22 @@ namespace ET.Server
     [FriendOf(typeof (PlayerTempDataComponent))]
     public static class PlayerTempDataComponentSystem
     {
-        public static async ETTask Init(this PlayerTempDataComponent self, WNPlayer player)
+        public static async ETTask InitFromDB(this PlayerTempDataComponent self, WNPlayer player)
         {
             self.Player = player;
+
             List<PlayerMapInfo> list = await DBManagerComponent.Instance.GetZoneDB(self.DomainZone())
                     .Query<PlayerMapInfo>(p => p.Id == player.GetId());
             if (list is { Count: > 0 })
             {
                 self.MapData = list[0];
             }
+            else
+            {
+                PlayerMapInfo info = new PlayerMapInfo();
+                info.mapId = 10098;
+                self.MapData = info;
+            }
         }
 
         public static async ETTask Save(this PlayerTempDataComponent self)

+ 1 - 0
Unity/Assets/Scripts/Core/Module/CoroutineLock/CoroutineLockType.cs

@@ -12,6 +12,7 @@ namespace ET
         public const int ResourcesLoader = 7;
         public const int Login = 8;
         public const int CreatePlayer = 9;
+        public const int InitPlayerTempDataComponent = 10;
 
         public const int Max = 100; // 这个必须最大
     }