diff --git a/modules/battle/module.go b/modules/battle/module.go index bb945f6fa..b15bb81d8 100644 --- a/modules/battle/module.go +++ b/modules/battle/module.go @@ -165,8 +165,9 @@ func (this *Battle) CreatePveBattle(session comm.IUserSession, req *pb.BattlePVE } if req.Format == nil || req.Format.Format == nil || len(req.Format.Format) != 5 { errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Title: pb.ErrorCode_ReqParameterError.ToString(), + Code: pb.ErrorCode_ReqParameterError, + Title: pb.ErrorCode_ReqParameterError.ToString(), + Message: "Format data err!", } return } diff --git a/modules/dcolor/room.go b/modules/dcolor/room.go index 1495d3613..874a41d2a 100644 --- a/modules/dcolor/room.go +++ b/modules/dcolor/room.go @@ -27,7 +27,7 @@ func (this *Room) GameStart() (err error) { ServicePath: fmt.Sprintf("%s/%s", this.module.service.GetType(), this.module.service.GetId()), Room: this.data, Countdown: 60, - }); err != nil { + }, this.sessions...); err != nil { this.module.Errorln(err) } return @@ -45,7 +45,7 @@ func (this *Room) PlayerLoadEnd(uid string) (err error) { if err = this.Broadcast("gamestart", &pb.DColorGameStartPush{ Roomid: this.data.Rid, Side: 1, - }); err != nil { + }, this.sessions...); err != nil { this.module.Errorln(err) } } @@ -68,7 +68,7 @@ func (this *Room) PlayerHandle(uid string, handle *pb.DColorHandleReq) (err erro Roomid: this.data.Rid, Uid: uid, Handle: handleopt, - }); err != nil { + }, this.sessions...); err != nil { this.module.Errorln(err) } @@ -123,7 +123,7 @@ func (this *Room) PlayerHandle(uid string, handle *pb.DColorHandleReq) (err erro Winside: this.currside, RedIntegral: this.data.Red.Score, BlueIntegral: this.data.Blue.Score, - }); err != nil { + }, this.sessions...); err != nil { this.module.Errorln(err) } this.module.rooms.removeRoom(this.data.Rid) @@ -140,8 +140,9 @@ func (this *Room) PlayerHandle(uid string, handle *pb.DColorHandleReq) (err erro func (this *Room) PlayerOffline(uid string) (err error) { var ( - conf *cfg.GameGColorGetfractionData - tconf *cfg.GameGColortTmedecayData + conf *cfg.GameGColorGetfractionData + tconf *cfg.GameGColortTmedecayData + session comm.IUserSession ) endtime := int32(configure.Now().Sub(this.starttime).Seconds()) if conf, err = this.module.configure.getGameGColorGetfractionData(int32(this.data.Difficulty)+1, this.data.Repeat, 8); err != nil { @@ -154,9 +155,11 @@ func (this *Room) PlayerOffline(uid string) (err error) { } this.currside = 3 if uid == this.data.Blue.Info.Uid { + session = this.sessions[0] this.data.Red.Score = int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000))) this.data.Blue.Score = this.data.Red.Score / 2 } else { + session = this.sessions[1] this.data.Blue.Score = int32(math.Floor(float64(conf.Fraction) * float64(tconf.Pro) / float64(1000))) this.data.Red.Score = this.data.Red.Score / 2 } @@ -185,7 +188,7 @@ func (this *Room) PlayerOffline(uid string) (err error) { Winside: this.currside, RedIntegral: this.data.Red.Score, BlueIntegral: this.data.Blue.Score, - }); err != nil { + }, session); err != nil { this.module.Errorln(err) } this.module.rooms.removeRoom(this.data.Rid) @@ -218,8 +221,8 @@ func (this *Room) comparison(results []int32) (allright, halfpair int32) { return } -func (this *Room) Broadcast(stype string, msg proto.Message) (err error) { - if err = this.module.SendMsgToSession(string(this.module.GetType()), stype, msg, this.sessions...); err != nil { +func (this *Room) Broadcast(stype string, msg proto.Message, sessions ...comm.IUserSession) (err error) { + if err = this.module.SendMsgSyncToSession(string(this.module.GetType()), stype, msg, sessions...); err != nil { this.module.Errorln(err) } return diff --git a/modules/whackamole/api_info.go b/modules/whackamole/api_info.go index 8d2a5d005..0c992316b 100644 --- a/modules/whackamole/api_info.go +++ b/modules/whackamole/api_info.go @@ -28,6 +28,6 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.WhackamoleInfoReq) } return } - session.SendMsg(string(this.module.GetType()), "award", &pb.WhackamoleInfoResp{Info: info}) + session.SendMsg(string(this.module.GetType()), "info", &pb.WhackamoleInfoResp{Info: info}) return }