From e125a4967091988714eea45d9f26e1af2c86cd49 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Sun, 4 Feb 2024 11:54:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=8C=B9=E9=85=8D=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E6=97=A5=E5=BF=97=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/matchpool/pool.go | 16 +++++++++++----- services/comp_match.go | 8 +++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/modules/matchpool/pool.go b/modules/matchpool/pool.go index 8d84ec39d..93e7bf94a 100644 --- a/modules/matchpool/pool.go +++ b/modules/matchpool/pool.go @@ -28,12 +28,18 @@ type MPool struct { func (this *MPool) join(req *pb.JoinMatchPoolReq) { this.lock.Lock() - player := &MatchPlayer{ - Uid: req.Uid, - Time: 0, - Data: req.Data, + if player, ok := this.Players[req.Uid]; ok { + player.Dan = req.Dan + player.Data = req.Data + } else { + player := &MatchPlayer{ + Uid: req.Uid, + Dan: req.Dan, + Time: 0, + Data: req.Data, + } + this.Players[req.Uid] = player } - this.Players[req.Uid] = player this.lock.Unlock() } diff --git a/services/comp_match.go b/services/comp_match.go index 9ae26c085..bb178b376 100644 --- a/services/comp_match.go +++ b/services/comp_match.go @@ -5,6 +5,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/lego/core/cbase" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" "google.golang.org/protobuf/proto" @@ -67,12 +68,17 @@ func (this *SCompMatch) SuccMatchNotice(ctx context.Context, args *pb.SuccMatchN for k, v := range args.Players { if msg, err = v.UnmarshalNew(); err != nil { + log.Errorf("[RPC:SuccMatchNotice] UnmarshalNew err:%s", err.Error()) return } player[k] = msg } //执行处理流 - err = msghandle(player) + if err = msghandle(player); err != nil { + log.Errorf("[RPC:SuccMatchNotice] msghandle err:%s", err.Error()) + } + } else { + log.Errorf("[RPC:SuccMatchNotice] on found args:%s", args.String()) } return nil }