From 761177b22a59c3681d24a9a850ee0f6bb95bff7c Mon Sep 17 00:00:00 2001 From: NorthLan <6995syu@163.com> Date: Wed, 27 Apr 2022 11:01:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7id=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E6=B2=A1=E6=90=9E=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.yml | 2 +- game/command/manager.go | 2 +- game/msg_transfer/danmaku/cmd_parser_test.go | 3 +++ game/msg_transfer/danmaku/msg_to_push.go | 3 ++- game/msg_transfer/gift/msg_to_push.go | 1 + 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config.yml b/config.yml index 7b990e6..667a319 100644 --- a/config.yml +++ b/config.yml @@ -2,7 +2,7 @@ Server: Debug: false Listen: 0.0.0.0:8888 Command: - Keys: [ "j", "加入", "加入游戏", "s", "w", "c1", "c2", "c3", "c4", "r1", "r2", "r3", "m1", "m2", "m3" ] + Keys: [ "j", "加入", "加入游戏", "s", "w", "我在哪", "c1", "c2", "c3", "c4", "r1", "r2", "r3", "m1", "m2", "m3" ] UserCenterRpc: Etcd: Hosts: diff --git a/game/command/manager.go b/game/command/manager.go index 8c964e9..7d1c50b 100644 --- a/game/command/manager.go +++ b/game/command/manager.go @@ -23,7 +23,7 @@ func (m *Manager) Register(h HandlerFunc, cmd string, alias ...string) { m.handlers[cmd] = h // alias for _, s := range alias { - if _, ok := m.handlers[cmd]; ok { + if _, ok := m.handlers[s]; ok { continue } m.handlers[s] = h diff --git a/game/msg_transfer/danmaku/cmd_parser_test.go b/game/msg_transfer/danmaku/cmd_parser_test.go index 105ec02..915794c 100644 --- a/game/msg_transfer/danmaku/cmd_parser_test.go +++ b/game/msg_transfer/danmaku/cmd_parser_test.go @@ -23,6 +23,9 @@ func TestParse(t *testing.T) { "不服你咬我啊?", "红方前排速度m2b2", "c1c2c3c4c1c2c3c4", + "m2", + "b2", + "c2", } p := NewCMDParser([]string{"j", "c1", "c2", "c3", "c4", "b1", "b2", "b3", "s", "b2", "b3", "w", "m1", "m2", "m3", "加入", "加入游戏"}) diff --git a/game/msg_transfer/danmaku/msg_to_push.go b/game/msg_transfer/danmaku/msg_to_push.go index 8deda8b..2742dd4 100644 --- a/game/msg_transfer/danmaku/msg_to_push.go +++ b/game/msg_transfer/danmaku/msg_to_push.go @@ -38,7 +38,7 @@ func (h *MsgToPushHandler) Init(svc *svc.ServiceContext) { h.commandManager = command.NewManager() h.commandManager.Register(h.handleJoinGame, "j", "加入", "加入游戏") h.commandManager.Register(h.handleOutbreak, "s") - h.commandManager.Register(h.handleWai, "w") + h.commandManager.Register(h.handleWai, "w", "我在哪") h.commandManager.Register(h.handleCreateUnit, "c1", "c2", "c3", "c4") h.commandManager.Register(h.handleMove, "m1", "m2", "m3") h.commandManager.Register(h.handleMode, "r1", "r2", "r3") @@ -119,6 +119,7 @@ func (h *MsgToPushHandler) handleDanmaku(data []byte, msgKey string) { PUid: strconv.FormatInt(msgFromMq.Uid, 10), }) if err == nil { + pbUser.UId = rpcUser.User.Id pbUser.Avatar = rpcUser.User.PAvatar } else { logger.SLog.Info("rpc获取用户信息失败") diff --git a/game/msg_transfer/gift/msg_to_push.go b/game/msg_transfer/gift/msg_to_push.go index ff4818f..7e2ace7 100644 --- a/game/msg_transfer/gift/msg_to_push.go +++ b/game/msg_transfer/gift/msg_to_push.go @@ -59,6 +59,7 @@ func (h *MsgToPushHandler) handleGift(data []byte, msgKey string) { PUid: strconv.FormatInt(msgFromMq.Uid, 10), }) if err == nil { + pbUser.UId = rpcUser.User.Id pbUser.Avatar = rpcUser.User.PAvatar } else { logger.SLog.Error("rpc获取用户信息失败", err)