From 78758b33c921548c6a5379b62cbd6ffdc87f6162 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sat, 30 Dec 2023 11:18:14 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E6=96=B9=E6=B3=95=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/equipment/module.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/equipment/module.go b/modules/equipment/module.go index 93cc483b7..8d8a88d32 100644 --- a/modules/equipment/module.go +++ b/modules/equipment/module.go @@ -1,6 +1,7 @@ package equipment import ( + "crypto/rand" "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/core" @@ -10,8 +11,7 @@ import ( cfg "go_dreamfactory/sys/configure/structs" "go_dreamfactory/sys/db" "math" - "math/rand" - "time" + "math/big" "github.com/go-redis/redis/v8" ) @@ -622,8 +622,10 @@ func (this *Equipment) GetForgeEquip(session comm.IUserSession, suiteId int32, p } return } - r := rand.New(rand.NewSource(time.Now().Unix())) - index := r.Perm(len(lvs))[0] + // 随机方法修改 + n, _ := rand.Int(rand.Reader, big.NewInt(int64(len(lvs)))) + index := n.Int64() //rand.New(rand.NewSource(time.Now().Unix())) + //index := r.Perm(len(lvs))[0] if eruip, err = this.modelEquipment.newEquipment(session.GetUserId(), lvs[index], dyweight, isepic); err == nil { errdata = this.AddEquipment(session, eruip) // this.equipmentsChangePush(session, []*pb.DB_Equipment{eruip})