Merge branch 'develop' into release
This commit is contained in:
commit
0e84e74049
|
@ -38,142 +38,148 @@ 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 {
|
||||||
if msg, ok := pack.(*serverproto.GWPlayerLeave); ok {
|
logger.Logger.Trace("receive GWPlayerLeave:", pack)
|
||||||
logger.Logger.Trace("receive GWPlayerLeave:", msg.GetPlayerId())
|
msg, ok := pack.(*serverproto.GWPlayerLeave)
|
||||||
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()))
|
if !ok {
|
||||||
if scene != nil {
|
return nil
|
||||||
p := PlayerMgrSington.GetPlayerBySnId(msg.GetPlayerId())
|
}
|
||||||
if p != nil {
|
|
||||||
data := msg.GetPlayerData()
|
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()), true)
|
||||||
if len(data) != 0 {
|
if scene == nil {
|
||||||
logger.Logger.Trace("GWPlayerLeave p.UnmarshalData(data)")
|
logger.Logger.Warnf("玩家离开房间,房间没找到 %v", pack)
|
||||||
p.UnmarshalData(data, scene)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
p := PlayerMgrSington.GetPlayerBySnId(msg.GetPlayerId())
|
||||||
case scene.IsCoinScene():
|
if p == nil {
|
||||||
if !CoinSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
|
logger.Logger.Warnf("玩家离开房间,玩家信息没找到 %v", pack)
|
||||||
logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [coinscene]",
|
return nil
|
||||||
p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
|
}
|
||||||
}
|
|
||||||
case scene.IsHundredScene():
|
data := msg.GetPlayerData()
|
||||||
if !HundredSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
|
if len(data) != 0 {
|
||||||
logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [hundredcene]",
|
logger.Logger.Trace("GWPlayerLeave p.UnmarshalData(data)")
|
||||||
p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
|
p.UnmarshalData(data, scene)
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
scene.PlayerLeave(p, int(msg.GetReason()))
|
switch {
|
||||||
}
|
case scene.IsCoinScene():
|
||||||
|
if !CoinSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
|
||||||
if p.scene != nil {
|
logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [coinscene]",
|
||||||
logger.Logger.Errorf("after GWPlayerLeave found snid:%v sceneid:%v gameid:%v modeid:%v",
|
p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
|
||||||
p.SnId, p.scene.sceneId, p.scene.gameId, p.scene.gameMode)
|
}
|
||||||
}
|
case scene.IsHundredScene():
|
||||||
|
if !HundredSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason())) {
|
||||||
if scene.IsMatchScene() {
|
logger.Logger.Warnf("GWPlayerLeave snid:%v sceneid:%v gameid:%v modeid:%v [hundredcene]",
|
||||||
//结算积分
|
p.SnId, scene.sceneId, scene.gameId, scene.gameMode)
|
||||||
if !p.IsRob {
|
}
|
||||||
TournamentMgr.UpdateMatchInfo(p, msg.MatchId, int32(msg.GetReturnCoin()), int32(msg.GetCurIsWin()), msg.GetMatchRobotGrades())
|
default:
|
||||||
} else {
|
scene.PlayerLeave(p, int(msg.GetReason()))
|
||||||
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 {
|
|
||||||
RankMgrSingleton.UpdateRobotSeason(p.Platform, p.SnId, scene.dbGameFree.GetRankType(),
|
if scene.IsMatchScene() {
|
||||||
msg.GetRankScore()[scene.dbGameFree.GetRankType()], p.Name, p.Sex, p.HeadUrl, p.Coin, p.PlayerData.GetRoleId())
|
//结算积分
|
||||||
} else {
|
if !p.IsRob {
|
||||||
if model.GameParamData.TestRankMatchAward {
|
TournamentMgr.UpdateMatchInfo(p, msg.MatchId, int32(msg.GetReturnCoin()), int32(msg.GetCurIsWin()), msg.GetMatchRobotGrades())
|
||||||
if RankMgrSingleton.playerSeasons[p.SnId] != nil {
|
} else {
|
||||||
if RankMgrSingleton.playerSeasons[p.SnId].RankType == nil {
|
p.matchCtx = 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() {
|
||||||
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].LastScore = 7500
|
if p.IsRob {
|
||||||
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Score = 7500
|
RankMgrSingleton.UpdateRobotSeason(p.Platform, p.SnId, scene.dbGameFree.GetRankType(),
|
||||||
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Awards = nil
|
msg.GetRankScore()[scene.dbGameFree.GetRankType()], p.Name, p.Sex, p.HeadUrl, p.Coin, p.PlayerData.GetRoleId())
|
||||||
}
|
} else {
|
||||||
RankMgrSingleton.UpdatePlayerSeason(p.SnId, map[int32]int64{1: 10000})
|
if model.GameParamData.TestRankMatchAward {
|
||||||
} else {
|
if RankMgrSingleton.playerSeasons[p.SnId] != nil {
|
||||||
RankMgrSingleton.UpdatePlayerSeason(p.SnId, msg.GetRankScore())
|
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{}
|
||||||
//更新玩家等级排行榜
|
}
|
||||||
LogChannelSingleton.WriteLog(&model.PlayerLevelInfo{
|
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].LastScore = 7500
|
||||||
SnId: p.SnId,
|
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Score = 7500
|
||||||
Name: p.Name,
|
RankMgrSingleton.playerSeasons[p.SnId].RankType[1].Awards = nil
|
||||||
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 {
|
||||||
logger.Logger.Tracef("GWPlayerLeave LocalRobotIdMgrSington %v", msg.GetPlayerId())
|
RankMgrSingleton.UpdatePlayerSeason(p.SnId, msg.GetRankScore())
|
||||||
//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
|
||||||
|
|
|
@ -102,8 +102,14 @@ func (m *SceneMgr) GetPlatformBySceneId(sceneId int) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetScene 获取房间对象
|
// GetScene 获取房间对象
|
||||||
func (m *SceneMgr) GetScene(sceneId int) *Scene {
|
// 默认是不包含删除中的房间
|
||||||
if s, exist := m.scenes[sceneId]; exist && !s.deleting {
|
// hasDeleting true 包含删除中的房间
|
||||||
|
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
|
||||||
|
|
Loading…
Reference in New Issue