diff --git a/game/live_logic/logic.go b/game/live_logic/logic.go index 06d22fc..2b3a924 100644 --- a/game/live_logic/logic.go +++ b/game/live_logic/logic.go @@ -66,12 +66,24 @@ func (l *LiveGameLogic) RegisterNobilityHandler(h NobilityHandlerFunc) { // HandleDanmaku 弹幕数据处理 // pushCommonMsg 非弹幕数据是否转发 func (l *LiveGameLogic) HandleDanmaku(pushCommonMsg bool, user *pbCommon.PbUser, dm *pbMq.MqDanmaku) { - cmdStruct := l.CmdParser.Parse(dm.Msg) - if cmdStruct.IsCMD { - for _, m := range cmdStruct.Matches { - l.handleCMD(dm.LiveRoomId, dm.MsgId, m.Prefix, m.Content, user) + if l.CmdParser != nil { + cmdStruct := l.CmdParser.Parse(dm.Msg) + if cmdStruct.IsCMD { + for _, m := range cmdStruct.Matches { + l.handleCMD(dm.LiveRoomId, dm.MsgId, m.Prefix, m.Content, user) + } + } else if pushCommonMsg { + room, err := manager.GameManager.RoomByLiveRoomId(dm.LiveRoomId) + if err != nil { + return + } + // 发送正常的非命令弹幕消息 + room.Broadcast(pb.PushDanmaku, &pbCommon.DanmakuMsg{ + User: user, + Content: dm.Msg, + }) } - } else if pushCommonMsg { + } else { room, err := manager.GameManager.RoomByLiveRoomId(dm.LiveRoomId) if err != nil { return diff --git a/game/live_logic/manager.go b/game/live_logic/manager.go index 22fd5b3..e56a2cd 100644 --- a/game/live_logic/manager.go +++ b/game/live_logic/manager.go @@ -29,6 +29,7 @@ func InitLiveManager(svcCtx *svc.ServiceContext) { LiveManager.RegisterLogic(NewZhgLiveGameLogic(svcCtx)) LiveManager.RegisterLogic(NewZhghzLiveGameLogic().LiveGameLogic) LiveManager.RegisterLogic(NewZhgzdLiveGameLogic(svcCtx)) + LiveManager.RegisterLogic(NewTestLiveGameLogic(svcCtx)) } func newManager() *Manager { diff --git a/game/live_logic/test_handler.go b/game/live_logic/test_handler.go new file mode 100644 index 0000000..0389d15 --- /dev/null +++ b/game/live_logic/test_handler.go @@ -0,0 +1,19 @@ +package live_logic + +import ( + pbRoom "dcg/game/pb/room" + "dcg/game/svc" +) + +type TestGameLogic struct { + svcCtx *svc.ServiceContext + *LiveGameLogic +} + +func NewTestLiveGameLogic(svcCtx *svc.ServiceContext) *LiveGameLogic { + resp := &TestGameLogic{ + svcCtx: svcCtx, + LiveGameLogic: NewLiveGameLogic(pbRoom.GameType_ZHG, nil), + } + return resp.LiveGameLogic +}