This commit is contained in:
aozhiwei 2024-03-19 17:18:35 +08:00
parent 00bbfab6ef
commit dfc6b52498
2 changed files with 34 additions and 3 deletions

View File

@ -3,9 +3,6 @@ package team
import ( import (
"q5" "q5"
"f5" "f5"
/*"cs"
"main/common"
"mt"*/
) )
type matchingInfo struct { type matchingInfo struct {
@ -14,6 +11,7 @@ type matchingInfo struct {
entry q5.ListHead entry q5.ListHead
matchTimerWp *f5.TimerWp matchTimerWp *f5.TimerWp
matchOk* matchingInfo matchOk* matchingInfo
matchTick int64
} }
type matchMgr struct { type matchMgr struct {
@ -38,6 +36,11 @@ func (this *matchMgr) addMatch(team *team) {
m.team = team m.team = team
m.addTick = q5.GetTickCount() m.addTick = q5.GetTickCount()
m.entry.Init(m) 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.teamUuidHash[team.GetTeamUuid()] = m
this.mustBeZn(team.GetZnKey()).AddTail(&m.entry) this.mustBeZn(team.GetZnKey()).AddTail(&m.entry)
} }
@ -76,3 +79,24 @@ func (this *matchMgr) mustBeZn(key int64) *q5.ListHead {
return l 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 {
}
}

View File

@ -325,6 +325,13 @@ func (this *team) SendStateNotify() {
this.broadcastMsg(this.stateNotifyMsg) this.broadcastMsg(this.stateNotifyMsg)
} }
func (this *team) canMatch(targetT *team) bool {
if this == targetT {
return false
}
return true
}
func newTeam() *team { func newTeam() *team {
t := new(team) t := new(team)
t.state = constant.TEAM_STATE_INIT t.state = constant.TEAM_STATE_INIT