比赛场优化
This commit is contained in:
parent
622d622194
commit
c628f8876f
|
@ -560,6 +560,7 @@ func (this *Tournament) IsGaming(snId int32) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMatchWaiting 判断是否在匹配中,已报名
|
// IsMatchWaiting 判断是否在匹配中,已报名
|
||||||
|
// 返回 是否匹配中,比赛配置id
|
||||||
func (this *Tournament) IsMatchWaiting(platform string, snId int32) (bool, int32) {
|
func (this *Tournament) IsMatchWaiting(platform string, snId int32) (bool, int32) {
|
||||||
// 未使用机器人
|
// 未使用机器人
|
||||||
for k, v := range this.signupPlayers[platform] {
|
for k, v := range this.signupPlayers[platform] {
|
||||||
|
@ -845,22 +846,36 @@ func (this *Tournament) Quit(platform string, snid int32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForceQuit 强制退赛
|
// ForceQuit 强制退赛,异常时才使用
|
||||||
func (this *Tournament) ForceQuit(platform string, snId int32) {
|
func (this *Tournament) ForceQuit(platform string, snId int32) {
|
||||||
logger.Logger.Tracef("TournamentMgr.ForceQuit: snId:%d", snId)
|
logger.Logger.Tracef("TournamentMgr.ForceQuit: snId:%d", snId)
|
||||||
|
if snId <= 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
this.Quit(platform, snId)
|
this.Quit(platform, snId)
|
||||||
|
|
||||||
var info *PlayerMatchContext
|
p := PlayerMgrSington.GetPlayerBySnId(snId)
|
||||||
var ok bool
|
if p != nil {
|
||||||
for _, v := range this.players {
|
if p.matchCtx != nil && p.matchCtx.tm != nil {
|
||||||
info, ok = v[snId]
|
this.StopMatch(p.matchCtx.tm.TMId, p.matchCtx.tm.SortId)
|
||||||
if ok {
|
return
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if info != nil && info.tm != nil {
|
|
||||||
this.StopMatch(info.tm.TMId, info.tm.SortId)
|
for _, v := range this.matches {
|
||||||
MatchSceneMgrSingleton.MatchStop(info.tm)
|
for _, vv := range v {
|
||||||
|
if vv != nil && vv.TmPlayer[snId] != nil {
|
||||||
|
this.StopMatch(vv.TMId, vv.SortId)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range this.players {
|
||||||
|
if info, ok := v[snId]; ok && info != nil && info.tm != nil {
|
||||||
|
this.StopMatch(info.tm.TMId, info.tm.SortId)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,7 +1104,7 @@ func (this *Tournament) GetRank(sortId int64, snid int32) int32 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Tournament) stopMatch(matchId int32, sortId int64) (isOver bool) {
|
func (this *Tournament) CanStopMatch(matchId int32, sortId int64) (isOver bool) {
|
||||||
if this.players[sortId] != nil {
|
if this.players[sortId] != nil {
|
||||||
hasReal := false
|
hasReal := false
|
||||||
for snId, context := range this.players[sortId] {
|
for snId, context := range this.players[sortId] {
|
||||||
|
@ -1101,7 +1116,7 @@ func (this *Tournament) stopMatch(matchId int32, sortId int64) (isOver bool) {
|
||||||
//没有真人比赛解散
|
//没有真人比赛解散
|
||||||
if !hasReal {
|
if !hasReal {
|
||||||
isOver = true
|
isOver = true
|
||||||
logger.Logger.Trace("没有真人比赛解散")
|
logger.Logger.Tracef("没有真人比赛解散 matchId:%v sortId:%v", matchId, sortId)
|
||||||
this.StopMatch(matchId, sortId)
|
this.StopMatch(matchId, sortId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1352,10 +1367,9 @@ func (this *Tournament) NextRoundStart(sortId int64, playerCtx *PlayerMatchConte
|
||||||
for _, v := range info.players {
|
for _, v := range info.players {
|
||||||
logger.Logger.Tracef("淘汰 %+v", *v)
|
logger.Logger.Tracef("淘汰 %+v", *v)
|
||||||
this.sendPromotionInfo(v, sortId, TaoTai, true, false) //淘汰
|
this.sendPromotionInfo(v, sortId, TaoTai, true, false) //淘汰
|
||||||
|
|
||||||
//真人被淘汰,如果剩下的都是机器人,比赛解散
|
//真人被淘汰,如果剩下的都是机器人,比赛解散
|
||||||
if !v.p.IsRob {
|
if !v.p.IsRob {
|
||||||
isOver = this.stopMatch(playerCtx.tm.TMId, sortId)
|
isOver = this.CanStopMatch(playerCtx.tm.TMId, sortId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1502,7 +1516,7 @@ func (this *Tournament) sendPromotionInfo(mc *PlayerMatchContext, sortId int64,
|
||||||
delete(this.players[sortId], mc.p.SnId)
|
delete(this.players[sortId], mc.p.SnId)
|
||||||
//真人被淘汰,如果剩下的都是机器人,比赛解散
|
//真人被淘汰,如果剩下的都是机器人,比赛解散
|
||||||
if !mc.p.IsRob {
|
if !mc.p.IsRob {
|
||||||
this.stopMatch(mc.tm.TMId, sortId)
|
this.CanStopMatch(mc.tm.TMId, sortId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2039,7 +2053,7 @@ func (this *Tournament) OnHourTimer() {
|
||||||
for _, v := range this.matches {
|
for _, v := range this.matches {
|
||||||
for _, vv := range v {
|
for _, vv := range v {
|
||||||
if vv != nil && (now.Sub(vv.RoundTime).Hours() >= 1 || now.Sub(vv.StartTime).Hours() > 5) {
|
if vv != nil && (now.Sub(vv.RoundTime).Hours() >= 1 || now.Sub(vv.StartTime).Hours() > 5) {
|
||||||
logger.Logger.Errorf("比赛异常 %v", vv)
|
logger.Logger.Errorf("比赛异常,长时间未结束 %v", vv)
|
||||||
this.StopMatch(vv.TMId, vv.SortId)
|
this.StopMatch(vv.TMId, vv.SortId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2049,7 +2063,7 @@ func (this *Tournament) OnHourTimer() {
|
||||||
if _, ok := tm[sortId]; !ok {
|
if _, ok := tm[sortId]; !ok {
|
||||||
for _, v := range this.players[sortId] {
|
for _, v := range this.players[sortId] {
|
||||||
if v != nil {
|
if v != nil {
|
||||||
logger.Logger.Errorf("比赛异常 %v", v.tm)
|
logger.Logger.Errorf("比赛异常,比赛已经不存在了 %v", v.tm)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue