Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
fb3128d11a
|
@ -51,7 +51,7 @@ type World[PlayerID comparable, P Player[PlayerID]] interface {
|
||||||
// RegWorldResetEvent 世界被重置后将立即执行被注册的事件处理函数
|
// RegWorldResetEvent 世界被重置后将立即执行被注册的事件处理函数
|
||||||
RegWorldResetEvent(handle WorldResetEventHandle[PlayerID, P])
|
RegWorldResetEvent(handle WorldResetEventHandle[PlayerID, P])
|
||||||
OnWorldResetEvent()
|
OnWorldResetEvent()
|
||||||
// RegWorldReleaseEvent 直接被释放前将立即执行被注册的事件处理函数,此刻世界仍然可用
|
// RegWorldReleaseEvent 世界被释放前将立即执行被注册的事件处理函数,此刻世界仍然可用
|
||||||
RegWorldReleaseEvent(handle WorldReleaseEventHandle[PlayerID, P])
|
RegWorldReleaseEvent(handle WorldReleaseEventHandle[PlayerID, P])
|
||||||
OnWorldReleaseEvent()
|
OnWorldReleaseEvent()
|
||||||
// RegPlayerJoinWorldEvent 玩家进入世界时将立即执行被注册的事件处理函数
|
// RegPlayerJoinWorldEvent 玩家进入世界时将立即执行被注册的事件处理函数
|
||||||
|
|
|
@ -63,7 +63,7 @@ func WithCross(crossName string, serverId int64, cross Cross) Option {
|
||||||
func WithTLS(certFile, keyFile string) Option {
|
func WithTLS(certFile, keyFile string) Option {
|
||||||
return func(srv *Server) {
|
return func(srv *Server) {
|
||||||
switch srv.network {
|
switch srv.network {
|
||||||
case NetworkHttp, NetworkWebsocket, NetworkTcp, NetworkTcp4, NetworkTcp6:
|
case NetworkHttp, NetworkWebsocket:
|
||||||
srv.certFile = certFile
|
srv.certFile = certFile
|
||||||
srv.keyFile = keyFile
|
srv.keyFile = keyFile
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
Loading…
Reference in New Issue