diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 37823cc0..c9408935 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -149,16 +149,7 @@ func (this *team) getMainTeam() *team { } func (this *team) onMatchOk(startTime int64) { - this.state = constant.TEAM_STATE_STARTED - this.startTime = startTime - this.stateNotifyMsg.State = proto.Int32(this.state) - this.genStartGameInfo() - this.SendStateNotify() - f5.GetTimer().SetInterval(1000, func(e int32, args *q5.Args) { - if e == q5.TIMER_EXEC_EVENT { - this.SendStateNotify() - } - }) + this.doStartGame(startTime) } func (this *team) CanStartGame(hum common.Player) bool { @@ -184,20 +175,24 @@ func (this *team) StartGame() { _matchMgr.addMatch(this) this.SendStateNotify() } else { - this.state = constant.TEAM_STATE_STARTED - this.startTime = f5.GetApp().GetNowSeconds() - this.stateNotifyMsg.State = proto.Int32(this.state) - this.genStartGameInfo() - this.SendStateNotify() - f5.GetTimer().SetInterval(1000, func(e int32, args *q5.Args) { - if e == q5.TIMER_EXEC_EVENT { - this.SendStateNotify() - } - }) + this.doStartGame(f5.GetApp().GetNowSeconds()) } } } +func (this *team) doStartGame(startTime int64) { + this.state = constant.TEAM_STATE_STARTED + this.startTime = startTime + this.stateNotifyMsg.State = proto.Int32(this.state) + this.genStartGameInfo() + this.SendStateNotify() + f5.GetTimer().SetInterval(1000, func(e int32, args *q5.Args) { + if e == q5.TIMER_EXEC_EVENT { + this.SendStateNotify() + } + }) +} + func (this *team) GetMemberNum() int32 { return int32(len(this.memberIdHash)) }