diff --git a/server/matchserver/team/matchmgr.go b/server/matchserver/team/matchmgr.go index ff41d590..0e377fe7 100644 --- a/server/matchserver/team/matchmgr.go +++ b/server/matchserver/team/matchmgr.go @@ -3,9 +3,6 @@ package team import ( "q5" "f5" - /*"cs" - "main/common" - "mt"*/ ) type matchingInfo struct { @@ -14,6 +11,7 @@ type matchingInfo struct { entry q5.ListHead matchTimerWp *f5.TimerWp matchOk* matchingInfo + matchTick int64 } type matchMgr struct { @@ -38,6 +36,11 @@ func (this *matchMgr) addMatch(team *team) { m.team = team m.addTick = q5.GetTickCount() m.entry.Init(m) + m.matchTimerWp = f5.GetTimer().SetIntervalWp(1000, func (e int32, args* q5.Args) { + if e == q5.TIMER_EXEC_EVENT { + _matchMgr.execMatch(m) + } + }) this.teamUuidHash[team.GetTeamUuid()] = m this.mustBeZn(team.GetZnKey()).AddTail(&m.entry) } @@ -76,3 +79,24 @@ func (this *matchMgr) mustBeZn(key int64) *q5.ListHead { return l } } + +func (this *matchMgr) execMatch(m *matchingInfo) { + l := this.mustBeZn(m.team.GetZnKey()) + l.ForEach( + func (ele interface{}) bool { + if targetM, ok := ele.(*matchingInfo); ok { + if m != targetM && m.team.canMatch(targetM.team) { + m.matchOk = targetM + m.matchTick = q5.GetTickCount() + + targetM.matchOk = m + targetM.matchTick = q5.GetTickCount() + return false + } + } + return true + }) + if m.matchOk != nil { + + } +} diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 3877d6ec..377bc163 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -325,6 +325,13 @@ func (this *team) SendStateNotify() { this.broadcastMsg(this.stateNotifyMsg) } +func (this *team) canMatch(targetT *team) bool { + if this == targetT { + return false + } + return true +} + func newTeam() *team { t := new(team) t.state = constant.TEAM_STATE_INIT