From a31448bf03dc0c420063de0a0fff8f88eb7ebc0e Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Mon, 22 May 2023 16:54:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=A2=AB=E5=BF=BD=E7=95=A5=E7=9A=84?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/world.go | 2 +- server/options.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/game/world.go b/game/world.go index 3755559..ba2a811 100644 --- a/game/world.go +++ b/game/world.go @@ -51,7 +51,7 @@ type World[PlayerID comparable, P Player[PlayerID]] interface { // RegWorldResetEvent 世界被重置后将立即执行被注册的事件处理函数 RegWorldResetEvent(handle WorldResetEventHandle[PlayerID, P]) OnWorldResetEvent() - // RegWorldReleaseEvent 直接被释放前将立即执行被注册的事件处理函数,此刻世界仍然可用 + // RegWorldReleaseEvent 世界被释放前将立即执行被注册的事件处理函数,此刻世界仍然可用 RegWorldReleaseEvent(handle WorldReleaseEventHandle[PlayerID, P]) OnWorldReleaseEvent() // RegPlayerJoinWorldEvent 玩家进入世界时将立即执行被注册的事件处理函数 diff --git a/server/options.go b/server/options.go index d8d3845..440fa3f 100644 --- a/server/options.go +++ b/server/options.go @@ -63,7 +63,7 @@ func WithCross(crossName string, serverId int64, cross Cross) Option { func WithTLS(certFile, keyFile string) Option { return func(srv *Server) { switch srv.network { - case NetworkHttp, NetworkWebsocket, NetworkTcp, NetworkTcp4, NetworkTcp6: + case NetworkHttp, NetworkWebsocket: srv.certFile = certFile srv.keyFile = keyFile } From 2c0c33e59482f2fa95ebed9e9fe4a0ba0a1ac33b Mon Sep 17 00:00:00 2001 From: kercylan98 Date: Tue, 23 May 2023 11:13:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=B8=8B=E4=B8=80?= =?UTF-8?q?=E4=B8=AAN=E7=A7=92=E5=9C=A8=E5=A4=9A=E5=B0=91=E7=A7=92?= =?UTF-8?q?=E4=B9=8B=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/times/calc.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 utils/times/calc.go diff --git a/utils/times/calc.go b/utils/times/calc.go new file mode 100644 index 0000000..83d6a87 --- /dev/null +++ b/utils/times/calc.go @@ -0,0 +1,19 @@ +package times + +import ( + "time" +) + +// CalcNextSec 计算下一个N秒在多少秒之后 +func CalcNextSec(sec int) int { + now := time.Now().Unix() + next := now + int64(sec) - now%int64(sec) + return int(next - now) +} + +// CalcNextSecWithTime 计算下一个N秒在多少秒之后 +func CalcNextSecWithTime(t time.Time, sec int) int { + now := t.Unix() + next := now + int64(sec) - now%int64(sec) + return int(next - now) +}