From 4dea9d9da7acecb3cf9cf0487b7040a5288c67ce Mon Sep 17 00:00:00 2001
From: BobSong <605277374@qq.com>
Date: Sun, 18 Jan 2026 20:20:33 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8F=92=E6=A7=BD=E6=B8=85?=
=?UTF-8?q?=E7=90=86=E5=90=8E=E7=9A=84bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Entity/EntityTimeOutComponent.cs | 42 ++---
.../Handler/C2A_LoginRequestHandler.cs | 14 +-
Hotfix/EntityHelper.cs | 96 +++++------
Hotfix/EntityTimeOutComponentSystem.cs | 158 +++++++++---------
.../Handler/C2Game_GetItemsRequestHandler.cs | 2 +-
.../PlayerItemContainerComponentSystem.cs | 6 +
.../Components/PlayerManageComponentSystem.cs | 2 +-
Hotfix/Game/Player/Helper/PlayerHelper.cs | 14 +-
8 files changed, 170 insertions(+), 164 deletions(-)
diff --git a/Entity/EntityTimeOutComponent.cs b/Entity/EntityTimeOutComponent.cs
index 3cfd390..09d5253 100644
--- a/Entity/EntityTimeOutComponent.cs
+++ b/Entity/EntityTimeOutComponent.cs
@@ -1,21 +1,21 @@
-using Fantasy.Entitas;
-
-namespace NB;
-
-public class EntityTimeOutComponent : Entity
-{
- ///
- /// 主要是用于检测每次请求的间隔,这里存放是下一次能正常通信时间
- ///
- public long NextTime;
-
- ///
- /// 用来设置检查的间隔时间
- ///
- public int Interval;
-
- ///
- /// 用于记录时间计划任务的ID,后面可以通过这个ID随时取消这个任务
- ///
- public long TimerId;
-}
\ No newline at end of file
+// using Fantasy.Entitas;
+//
+// namespace NB;
+//
+// public class EntityTimeOutComponent : Entity
+// {
+// ///
+// /// 主要是用于检测每次请求的间隔,这里存放是下一次能正常通信时间
+// ///
+// public long NextTime;
+//
+// ///
+// /// 用来设置检查的间隔时间
+// ///
+// public int Interval;
+//
+// ///
+// /// 用于记录时间计划任务的ID,后面可以通过这个ID随时取消这个任务
+// ///
+// public long TimerId;
+// }
\ No newline at end of file
diff --git a/Hotfix/Authentication/Handler/C2A_LoginRequestHandler.cs b/Hotfix/Authentication/Handler/C2A_LoginRequestHandler.cs
index fa6f84f..fd7b4d0 100644
--- a/Hotfix/Authentication/Handler/C2A_LoginRequestHandler.cs
+++ b/Hotfix/Authentication/Handler/C2A_LoginRequestHandler.cs
@@ -13,14 +13,14 @@ public class C2A_LoginRequestHandler : MessageRPC();
-
- if (sessionTimeOutComponent == null)
- {
- sessionTimeOutComponent = entity.AddComponent();
- sessionTimeOutComponent.SetInterval(interval);
- return true;
- }
-
- return sessionTimeOutComponent.CheckInterval();
- }
-
- public static void SetTimeout(this Entity entity, int timeout = 3000, Func? task = null)
- {
- var sessionTimeOutComponent = entity.GetComponent();
-
- if (sessionTimeOutComponent == null)
- {
- sessionTimeOutComponent = entity.AddComponent();
- }
-
- sessionTimeOutComponent.TimeOut(timeout, task);
- }
-
- public static bool IsTimeOutComponent(this Entity entity)
- {
- return entity.GetComponent() != null;
- }
-
- public static void CancelTimeout(this Entity entity)
- {
- entity.RemoveComponent();
- }
-}
\ No newline at end of file
+// using System;
+// using NB.Authentication;
+// using Fantasy;
+// using Fantasy.Async;
+// using Fantasy.Entitas;
+// using Fantasy.Network;
+// // ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
+//
+// namespace NB;
+//
+// public static class EntityHelper
+// {
+// public static bool CheckInterval(this Entity entity, int interval)
+// {
+// var sessionTimeOutComponent = entity.GetComponent();
+//
+// if (sessionTimeOutComponent == null)
+// {
+// sessionTimeOutComponent = entity.AddComponent();
+// sessionTimeOutComponent.SetInterval(interval);
+// return true;
+// }
+//
+// return sessionTimeOutComponent.CheckInterval();
+// }
+//
+// public static void SetTimeout(this Entity entity, int timeout = 3000, Func? task = null)
+// {
+// var sessionTimeOutComponent = entity.GetComponent();
+//
+// if (sessionTimeOutComponent == null)
+// {
+// sessionTimeOutComponent = entity.AddComponent();
+// }
+//
+// sessionTimeOutComponent.TimeOut(timeout, task);
+// }
+//
+// public static bool IsTimeOutComponent(this Entity entity)
+// {
+// return entity.GetComponent() != null;
+// }
+//
+// public static void CancelTimeout(this Entity entity)
+// {
+// entity.RemoveComponent();
+// }
+// }
\ No newline at end of file
diff --git a/Hotfix/EntityTimeOutComponentSystem.cs b/Hotfix/EntityTimeOutComponentSystem.cs
index 9d1de78..16dcf51 100644
--- a/Hotfix/EntityTimeOutComponentSystem.cs
+++ b/Hotfix/EntityTimeOutComponentSystem.cs
@@ -1,79 +1,79 @@
-using System;
-using Fantasy;
-using Fantasy.Async;
-using Fantasy.Entitas.Interface;
-using Fantasy.Helper;
-
-namespace NB.Authentication;
-
-public sealed class EntityTimeOutComponentDestroySystem : DestroySystem
-{
- protected override void Destroy(EntityTimeOutComponent self)
- {
- if (self.TimerId != 0)
- {
- self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
- }
-
- self.NextTime = 0;
- self.Interval = 0;
- }
-}
-
-public static class EntityTimeOutComponentSystem
-{
- public static void SetInterval(this EntityTimeOutComponent self, int interval)
- {
- if (interval <= 0)
- {
- throw new ArgumentException("interval must be greater than 0", nameof(interval));
- }
-
- self.Interval = interval;
- self.NextTime = TimeHelper.Now + interval;
- }
-
- public static bool CheckInterval(this EntityTimeOutComponent self)
- {
- if (self.NextTime > TimeHelper.Now)
- {
- Log.Warning("当前连接请求的间隔过小");
- return false;
- }
-
- self.NextTime = TimeHelper.Now + self.Interval;
- return true;
- }
-
- public static void TimeOut(this EntityTimeOutComponent self, int timeout, Func? task = null)
- {
- var scene = self.Scene;
- var parentRunTimeId = self.Parent.RuntimeId;
-
- if (self.TimerId != 0)
- {
- self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
- }
-
- self.TimerId =
- scene.TimerComponent.Net.OnceTimer(timeout, () => { self.Handler(parentRunTimeId, task).Coroutine(); });
- }
-
- private static async FTask Handler(this EntityTimeOutComponent self, long parentRunTimeId, Func? task = null)
- {
- var selfParent = self.Parent;
-
- if (selfParent == null || parentRunTimeId != selfParent.RuntimeId)
- {
- return;
- }
-
- if (task != null)
- {
- await task();
- }
-
- self.TimerId = 0;
- selfParent.Dispose();
- }
-}
\ No newline at end of file
+// using System;
+// using Fantasy;
+// using Fantasy.Async;
+// using Fantasy.Entitas.Interface;
+// using Fantasy.Helper;
+//
+// namespace NB.Authentication;
+//
+// public sealed class EntityTimeOutComponentDestroySystem : DestroySystem
+// {
+// protected override void Destroy(EntityTimeOutComponent self)
+// {
+// if (self.TimerId != 0)
+// {
+// self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
+// }
+//
+// self.NextTime = 0;
+// self.Interval = 0;
+// }
+// }
+//
+// public static class EntityTimeOutComponentSystem
+// {
+// public static void SetInterval(this EntityTimeOutComponent self, int interval)
+// {
+// if (interval <= 0)
+// {
+// throw new ArgumentException("interval must be greater than 0", nameof(interval));
+// }
+//
+// self.Interval = interval;
+// self.NextTime = TimeHelper.Now + interval;
+// }
+//
+// public static bool CheckInterval(this EntityTimeOutComponent self)
+// {
+// if (self.NextTime > TimeHelper.Now)
+// {
+// Log.Warning("当前连接请求的间隔过小");
+// return false;
+// }
+//
+// self.NextTime = TimeHelper.Now + self.Interval;
+// return true;
+// }
+//
+// public static void TimeOut(this EntityTimeOutComponent self, int timeout, Func? task = null)
+// {
+// var scene = self.Scene;
+// var parentRunTimeId = self.Parent.RuntimeId;
+//
+// if (self.TimerId != 0)
+// {
+// self.Scene.TimerComponent.Net.Remove(ref self.TimerId);
+// }
+//
+// self.TimerId =
+// scene.TimerComponent.Net.OnceTimer(timeout, () => { self.Handler(parentRunTimeId, task).Coroutine(); });
+// }
+//
+// private static async FTask Handler(this EntityTimeOutComponent self, long parentRunTimeId, Func? task = null)
+// {
+// var selfParent = self.Parent;
+//
+// if (selfParent == null || parentRunTimeId != selfParent.RuntimeId)
+// {
+// return;
+// }
+//
+// if (task != null)
+// {
+// await task();
+// }
+//
+// self.TimerId = 0;
+// selfParent.Dispose();
+// }
+// }
\ No newline at end of file
diff --git a/Hotfix/Game/Handler/C2Game_GetItemsRequestHandler.cs b/Hotfix/Game/Handler/C2Game_GetItemsRequestHandler.cs
index f240e35..311d91c 100644
--- a/Hotfix/Game/Handler/C2Game_GetItemsRequestHandler.cs
+++ b/Hotfix/Game/Handler/C2Game_GetItemsRequestHandler.cs
@@ -13,7 +13,7 @@ public class C2Game_GetItemsRequestHandler : AddressRPC();
response.Items = itemContainer.GetItemInfos();
response.Rigs = itemContainer.GetRigInfos();
- response.Slots = itemContainer.Slots;
+ response.Slots = itemContainer.GetSlots();
await FTask.CompletedTask;
}
}
\ No newline at end of file
diff --git a/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs b/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs
index f959814..4d66edb 100644
--- a/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs
+++ b/Hotfix/Game/Item/PlayerItemContainerComponentSystem.cs
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using System.Linq;
using Fantasy;
using Fantasy.Async;
using Fantasy.Entitas.Interface;
@@ -161,5 +162,10 @@ public static class PlayerItemContainerComponentSystem
return ret;
}
+ public static List GetSlots(this PlayerItemContainerComponent self)
+ {
+ return self.Slots.ToList();
+ }
+
#endregion
}
\ No newline at end of file
diff --git a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs
index ee070b5..6f9030c 100644
--- a/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs
+++ b/Hotfix/Game/Player/Components/PlayerManageComponentSystem.cs
@@ -79,7 +79,7 @@ public static class PlayerManageComponentSystem
{
Log.Debug("检测到当前账号已经在缓存中了");
// 如果有延迟下线的计划任务,那就先取消一下。
- account.CancelTimeout();
+ // account.CancelTimeout();
// 如果在Gate的缓存中已经存在了该账号那只能以下几种可能:
// 1、同一客户端发送了重复登录的请求数据。
// 2、客户端经历的断线然后又重新连接到这个服务器上了(断线重连)。
diff --git a/Hotfix/Game/Player/Helper/PlayerHelper.cs b/Hotfix/Game/Player/Helper/PlayerHelper.cs
index d5ce77d..935eb84 100644
--- a/Hotfix/Game/Player/Helper/PlayerHelper.cs
+++ b/Hotfix/Game/Player/Helper/PlayerHelper.cs
@@ -92,12 +92,12 @@ public static class PlayerHelper
return;
}
- // 如果不存在定时任务的组件,那就添加并设置定时任务
- if (account.IsTimeOutComponent())
- {
- // 如果已经存在了,那就表示当然已经有一个延时断开的任务了,那就不需要重复添加了
- return;
- }
+ // // 如果不存在定时任务的组件,那就添加并设置定时任务
+ // if (account.IsTimeOutComponent())
+ // {
+ // // 如果已经存在了,那就表示当然已经有一个延时断开的任务了,那就不需要重复添加了
+ // return;
+ // }
// 立即下线处理
if (timeOut <= 0)
@@ -108,7 +108,7 @@ public static class PlayerHelper
}
// 设置延迟下线
- account.SetTimeout(timeOut, account.Disconnect);
+ // account.SetTimeout(timeOut, account.Disconnect);
}
#endregion