1
This commit is contained in:
parent
00bbfab6ef
commit
dfc6b52498
@ -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 {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user