Compare commits

..

No commits in common. "0e84e7404974c94b7546f7d641afe36454fa8f1b" and "79915a49e114c895458cc443a398837cf2204029" have entirely different histories.

2 changed files with 135 additions and 147 deletions

View File

@ -38,148 +38,142 @@ func init() {
return &serverproto.GWPlayerLeave{} return &serverproto.GWPlayerLeave{}
})) }))
netlib.RegisterHandler(int(serverproto.SSPacketID_PACKET_GW_PLAYERLEAVE), netlib.HandlerWrapper(func(s *netlib.Session, packetid int, pack interface{}) error { netlib.RegisterHandler(int(serverproto.SSPacketID_PACKET_GW_PLAYERLEAVE), netlib.HandlerWrapper(func(s *netlib.Session, packetid int, pack interface{}) error {
logger.Logger.Trace("receive GWPlayerLeave:", pack) if msg, ok := pack.(*serverproto.GWPlayerLeave); ok {
msg, ok := pack.(*serverproto.GWPlayerLeave) logger.Logger.Trace("receive GWPlayerLeave:", msg.GetPlayerId())
if !ok { scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()))
return nil if scene != nil {
} p := PlayerMgrSington.GetPlayerBySnId(msg.GetPlayerId())
if p != nil {
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()), true) data := msg.GetPlayerData()
if scene == nil { if len(data) != 0 {
logger.Logger.Warnf("玩家离开房间,房间没找到 %v", pack) logger.Logger.Trace("GWPlayerLeave p.UnmarshalData(data)")
return nil p.UnmarshalData(data, scene)
} }
p := PlayerMgrSington.GetPlayerBySnId(msg.GetPlayerId()) switch {
if p == nil { case scene.IsCoinScene():
logger.Logger.Warnf("玩家离开房间,玩家信息没找到 %v", pack) if !CoinSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
return nil logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [coinscene]",
} p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
}
data := msg.GetPlayerData() case scene.IsHundredScene():
if len(data) != 0 { if !HundredSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
logger.Logger.Trace("GWPlayerLeave p.UnmarshalData(data)") logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [hundredcene]",
p.UnmarshalData(data, scene) p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
} }
default:
switch { scene.PlayerLeave(p, int(msg.GetReason()))
case scene.IsCoinScene(): }
if !CoinSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [coinscene]", if p.scene != nil {
p.SnId, scene.sceneId, scene.gameId, scene.gameMode) logger.Logger.Errorf("after GWPlayerLeave found snid:%v sceneid:%v gameid:%v modeid:%v",
} p.SnId, p.scene.sceneId, p.scene.gameId, p.scene.gameMode)
case scene.IsHundredScene(): }
if !HundredSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [hundredcene]", if scene.IsMatchScene() {
p.SnId, scene.sceneId, scene.gameId, scene.gameMode) //结算积分
} if !p.IsRob {
default: TournamentMgr.UpdateMatchInfo(p, msg.MatchId, int32(msg.GetReturnCoin()), int32(msg.GetCurIsWin()), msg.GetMatchRobotGrades())
scene.PlayerLeave(p, int(msg.GetReason())) } else {
} p.matchCtx = nil
}
if p.scene != nil { }
logger.Logger.Errorf("after GWPlayerLeave found snid:%v sceneid:%v gameid:%v modeid:%v",
p.SnId, p.scene.sceneId, p.scene.gameId, p.scene.gameMode) // 同步排位积分
} if scene.IsRankMatch() {
if p.IsRob {
if scene.IsMatchScene() { RankMgrSingleton.UpdateRobotSeason(p.Platform, p.SnId, scene.dbGameFree.GetRankType(),
//结算积分 msg.GetRankScore()[scene.dbGameFree.GetRankType()], p.Name, p.Sex, p.HeadUrl, p.Coin, p.PlayerData.GetRoleId())
if !p.IsRob { } else {
TournamentMgr.UpdateMatchInfo(p, msg.MatchId, int32(msg.GetReturnCoin()), int32(msg.GetCurIsWin()), msg.GetMatchRobotGrades()) if model.GameParamData.TestRankMatchAward {
} else { if RankMgrSingleton.playerSeasons[p.SnId] != nil {
p.matchCtx = nil if RankMgrSingleton.playerSeasons[p.SnId].RankType == nil {
} RankMgrSingleton.playerSeasons[p.SnId].RankType = make(map[int32]*model.PlayerRankInfo)
} }
if RankMgrSingleton.playerSeasons[p.SnId].RankType[1] == nil {
// 同步排位积分 RankMgrSingleton.playerSeasons[p.SnId].RankType[1] = &model.PlayerRankInfo{}
if scene.IsRankMatch() { }
if p.IsRob { RankMgrSingleton.playerSeasons[p.SnId].RankType[1].LastScore = 7500
RankMgrSingleton.UpdateRobotSeason(p.Platform, p.SnId, scene.dbGameFree.GetRankType(), RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Score = 7500
msg.GetRankScore()[scene.dbGameFree.GetRankType()], p.Name, p.Sex, p.HeadUrl, p.Coin, p.PlayerData.GetRoleId()) RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Awards = nil
} else { }
if model.GameParamData.TestRankMatchAward { RankMgrSingleton.UpdatePlayerSeason(p.SnId, map[int32]int64{1: 10000})
if RankMgrSingleton.playerSeasons[p.SnId] != nil { } else {
if RankMgrSingleton.playerSeasons[p.SnId].RankType == nil { RankMgrSingleton.UpdatePlayerSeason(p.SnId, msg.GetRankScore())
RankMgrSingleton.playerSeasons[p.SnId].RankType = make(map[int32]*model.PlayerRankInfo) }
}
if RankMgrSingleton.playerSeasons[p.SnId].RankType[1] == nil { }
RankMgrSingleton.playerSeasons[p.SnId].RankType[1] = &model.PlayerRankInfo{} }
} //更新玩家等级排行榜
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].LastScore = 7500 LogChannelSingleton.WriteLog(&model.PlayerLevelInfo{
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Score = 7500 SnId: p.SnId,
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Awards = nil Name: p.Name,
Level: p.Level,
Exp: p.Exp,
ModId: p.PlayerData.GetRoleId(),
Platform: p.Platform,
})
//比赛场不处理下面的内容
if !scene.IsMatchScene() && !scene.IsCustom() {
// 破产检测
sdata := srvdata.PBDB_GameSubsidyMgr.GetData(GameSubsidyid)
if sdata != nil {
if !p.IsRob && p.takeCoin > msg.GetReturnCoin() && p.takeCoin >= int64(sdata.LimitNum) && msg.GetReturnCoin() < int64(sdata.LimitNum) {
CostCoin := p.takeCoin - msg.GetReturnCoin()
logger.Logger.Infof("NewBankruptLogEx: snid:%v GetReturnCoin:%v coin:%v CostCoin:%v", p.SnId, msg.GetReturnCoin(), p.takeCoin, CostCoin)
log := model.NewBankruptLogEx(p.SnId, scene.dbGameFree.GetId(), p.CreateTime.Unix(), CostCoin, p.Platform, p.Channel, scene.gameId)
if log != nil {
LogChannelSingleton.WriteLog(log)
}
}
}
// 破产检测
oldCoin := p.Coin
//带回金币
if p.Coin != msg.GetReturnCoin() {
p.Coin = msg.GetReturnCoin()
if p.Coin < 0 {
p.Coin = 0
}
p.dirty = true
}
logger.Logger.Infof("SSPacketID_PACKET_GW_PLAYERLEAVE: snid:%v oldcoin:%v coin:%v", p.SnId, oldCoin, p.Coin)
p.diffData.Coin = -1 //强制更新金币
p.diffData.TotalConvertibleFlow = -1 //强制更新流水
p.SendDiffData() //只是把差异发给前端
gameCoinTs := msg.GetGameCoinTs()
if !p.IsRob && !scene.IsTestScene() {
//对账点同步
if p.GameCoinTs < gameCoinTs {
p.GameCoinTs = gameCoinTs
p.dirty = true
}
//破产统计
//if int(msg.GetReason()) == common.PlayerLeaveReason_Bekickout {
// if len(scene.paramsEx) > 0 {
// gameIdEx := scene.paramsEx[0]
// gps := PlatformMgrSingleton.GetGameFree(scene.limitPlatform.IdStr, scene.paramsEx[0])
// if gps != nil {
// lowLimit := gps.DbGameFree.GetLowerThanKick()
// if lowLimit != 0 && p.Coin+p.SafeBoxCoin < int64(lowLimit) {
// p.ReportBankRuptcy(int32(scene.gameId), int32(scene.gameMode), gameIdEx)
// }
// }
// }
//}
}
} }
RankMgrSingleton.UpdatePlayerSeason(p.SnId, map[int32]int64{1: 10000})
} else { } else {
RankMgrSingleton.UpdatePlayerSeason(p.SnId, msg.GetRankScore()) logger.Logger.Tracef("GWPlayerLeave LocalRobotIdMgrSington %v", msg.GetPlayerId())
//LocalRobotIdMgrSington.FreeId(msg.GetPlayerId())
} }
}
}
//更新玩家等级排行榜
LogChannelSingleton.WriteLog(&model.PlayerLevelInfo{
SnId: p.SnId,
Name: p.Name,
Level: p.Level,
Exp: p.Exp,
ModId: p.PlayerData.GetRoleId(),
Platform: p.Platform,
})
//比赛场不处理下面的内容
if !scene.IsMatchScene() && !scene.IsCustom() {
// 破产检测
sdata := srvdata.PBDB_GameSubsidyMgr.GetData(GameSubsidyid)
if sdata != nil {
if !p.IsRob && p.takeCoin > msg.GetReturnCoin() && p.takeCoin >= int64(sdata.LimitNum) && msg.GetReturnCoin() < int64(sdata.LimitNum) {
CostCoin := p.takeCoin - msg.GetReturnCoin()
logger.Logger.Infof("NewBankruptLogEx: snid:%v GetReturnCoin:%v coin:%v CostCoin:%v", p.SnId, msg.GetReturnCoin(), p.takeCoin, CostCoin)
log := model.NewBankruptLogEx(p.SnId, scene.dbGameFree.GetId(), p.CreateTime.Unix(), CostCoin, p.Platform, p.Channel, scene.gameId)
if log != nil {
LogChannelSingleton.WriteLog(log)
}
}
}
// 破产检测
oldCoin := p.Coin
//带回金币
if p.Coin != msg.GetReturnCoin() {
p.Coin = msg.GetReturnCoin()
if p.Coin < 0 {
p.Coin = 0
}
p.dirty = true
}
logger.Logger.Infof("SSPacketID_PACKET_GW_PLAYERLEAVE: snid:%v oldcoin:%v coin:%v", p.SnId, oldCoin, p.Coin)
p.diffData.Coin = -1 //强制更新金币
p.diffData.TotalConvertibleFlow = -1 //强制更新流水
p.SendDiffData() //只是把差异发给前端
gameCoinTs := msg.GetGameCoinTs()
if !p.IsRob && !scene.IsTestScene() {
//对账点同步
if p.GameCoinTs < gameCoinTs {
p.GameCoinTs = gameCoinTs
p.dirty = true
}
//破产统计
//if int(msg.GetReason()) == common.PlayerLeaveReason_Bekickout {
// if len(scene.paramsEx) > 0 {
// gameIdEx := scene.paramsEx[0]
// gps := PlatformMgrSingleton.GetGameFree(scene.limitPlatform.IdStr, scene.paramsEx[0])
// if gps != nil {
// lowLimit := gps.DbGameFree.GetLowerThanKick()
// if lowLimit != 0 && p.Coin+p.SafeBoxCoin < int64(lowLimit) {
// p.ReportBankRuptcy(int32(scene.gameId), int32(scene.gameMode), gameIdEx)
// }
// }
// }
//}
} }
} }
return nil return nil

View File

@ -102,14 +102,8 @@ func (m *SceneMgr) GetPlatformBySceneId(sceneId int) string {
} }
// GetScene 获取房间对象 // GetScene 获取房间对象
// 默认是不包含删除中的房间 func (m *SceneMgr) GetScene(sceneId int) *Scene {
// hasDeleting true 包含删除中的房间 if s, exist := m.scenes[sceneId]; exist && !s.deleting {
func (m *SceneMgr) GetScene(sceneId int, hasDeleting ...bool) *Scene {
has := false
if len(hasDeleting) > 0 {
has = hasDeleting[0]
}
if s, exist := m.scenes[sceneId]; exist && (has || !s.deleting) {
return s return s
} }
return nil return nil