From bcdcc1cc47d392417e54d230b95c6201808adfe5 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Sun, 29 Sep 2024 09:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=AF=94=E8=B5=9B=E5=9C=BAid?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/id.go | 9 +++++++++ worldsrv/tmmatch.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 common/id.go diff --git a/common/id.go b/common/id.go new file mode 100644 index 0000000..2673f16 --- /dev/null +++ b/common/id.go @@ -0,0 +1,9 @@ +package common + +import "github.com/bwmarrin/snowflake" + +var IdNode, _ = snowflake.NewNode(int64(GetSelfSrvId())) + +func GetId() int64 { + return IdNode.Generate().Int64() +} diff --git a/worldsrv/tmmatch.go b/worldsrv/tmmatch.go index bc23dc5..ab10cd3 100644 --- a/worldsrv/tmmatch.go +++ b/worldsrv/tmmatch.go @@ -20,7 +20,7 @@ import ( ) func getSortId() int64 { - return time.Now().UnixMilli() + return common.GetId() } type TmPlayer struct {