修复空指针异常

This commit is contained in:
sk 2024-05-29 09:17:14 +08:00
parent b9c1b85193
commit 9177d20d5e
2 changed files with 84 additions and 83 deletions

View File

@ -1106,88 +1106,89 @@ func (this *TienLenSceneData) SendHandCardOdds() {
// 前两局不能天胡,之后根据概率给一次天胡,至少天胡一次 // 前两局不能天胡,之后根据概率给一次天胡,至少天胡一次
noviceTianHu := false noviceTianHu := false
noviceCtrl := false noviceCtrl := false
config := srvdata.PBDB_NewPlayerMgr.GetData(int32(this.GameId)) //config := srvdata.PBDB_NewPlayerMgr.GetData(int32(this.GameId))
if config != nil && config.GetTianHuRate() > 0 && len(this.testPokers) == 0 { // 启用新手天胡体验 //if config != nil && config.GetTianHuRate() > 0 && len(this.testPokers) == 0 { // 启用新手天胡体验
rand.Shuffle(len(novicePlayers), func(i, j int) { // rand.Shuffle(len(novicePlayers), func(i, j int) {
novicePlayers[i], novicePlayers[j] = novicePlayers[j], novicePlayers[i] // novicePlayers[i], novicePlayers[j] = novicePlayers[j], novicePlayers[i]
}) // })
keyNovice := common.GetKeyNoviceGameId(this.GameId) // keyNovice := common.GetKeyNoviceGameId(this.GameId)
for _, v := range novicePlayers { // for _, v := range novicePlayers {
data, ok := v.GDatas[keyNovice] // data, ok := v.GDatas[keyNovice]
if !ok { // if !ok {
data = &model.PlayerGameInfo{FirstTime: time.Now()} // data = &model.PlayerGameInfo{FirstTime: time.Now()}
v.GDatas[keyNovice] = data // v.GDatas[keyNovice] = data
} // }
// 前两局不能天胡 // // 前两局不能天胡
if data.Statics.GameTimes < 2 { // if data.Statics.GameTimes < 2 {
continue // continue
} // }
if int(config.GetTianHuRate()) > this.RandInt(1000) { // if int(config.GetTianHuRate()) > this.RandInt(1000) {
var allcs []int32 // var allcs []int32
for i := 0; i < 52; i++ { // for i := 0; i < 52; i++ {
allcs = append(allcs, int32(i)) // allcs = append(allcs, int32(i))
} // }
rand.Shuffle(len(allcs), func(i, j int) { // rand.Shuffle(len(allcs), func(i, j int) {
allcs[i], allcs[j] = allcs[j], allcs[i] // allcs[i], allcs[j] = allcs[j], allcs[i]
}) // })
cs, _ := rule.GetTianHu() // cs, _ := rule.GetTianHu()
allcs = common.DelSliceIn32s(allcs, cs) // allcs = common.DelSliceIn32s(allcs, cs)
for _, seat := range this.seats { // for _, seat := range this.seats {
if seat != nil && seat.IsGameing() { // if seat != nil && seat.IsGameing() {
if seat != v { // if seat != v {
f1(seat, allcs[:13]) // f1(seat, allcs[:13])
allcs = allcs[13:] // allcs = allcs[13:]
} else { // } else {
f1(seat, cs) // f1(seat, cs)
} // }
} // }
} // }
v.TestLog = append(v.TestLog, fmt.Sprintf("新手天胡体验,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes)) // v.TestLog = append(v.TestLog, fmt.Sprintf("新手天胡体验,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
logger.Logger.Tracef("新手天胡体验,玩家:%d 发天胡", v.SnId) // logger.Logger.Tracef("新手天胡体验,玩家:%d 发天胡", v.SnId)
noviceTianHu = true // noviceTianHu = true
noviceCtrl = true // noviceCtrl = true
} // }
} // }
if !noviceTianHu { // if !noviceTianHu {
// 没有新手玩家天胡,随机一个非新手玩家,如果没有天胡过,给一次天胡 // // 没有新手玩家天胡,随机一个非新手玩家,如果没有天胡过,给一次天胡
rand.Shuffle(len(notNoviceRealPlayers), func(i, j int) { // rand.Shuffle(len(notNoviceRealPlayers), func(i, j int) {
notNoviceRealPlayers[i], notNoviceRealPlayers[j] = notNoviceRealPlayers[j], notNoviceRealPlayers[i] // notNoviceRealPlayers[i], notNoviceRealPlayers[j] = notNoviceRealPlayers[j], notNoviceRealPlayers[i]
}) // })
for _, v := range notNoviceRealPlayers { // for _, v := range notNoviceRealPlayers {
data, ok := v.GDatas[keyNovice] // data, ok := v.GDatas[keyNovice]
if !ok { // if !ok {
data = &model.PlayerGameInfo{FirstTime: time.Now()} // data = &model.PlayerGameInfo{FirstTime: time.Now()}
v.GDatas[keyNovice] = data // v.GDatas[keyNovice] = data
} // }
//
if data.Statics.GetInt(rule.StaticsTianHuTimes) == 0 { // if data.Statics.GetInt(rule.StaticsTianHuTimes) == 0 {
var allcs []int32 // var allcs []int32
for i := 0; i < 52; i++ { // for i := 0; i < 52; i++ {
allcs = append(allcs, int32(i)) // allcs = append(allcs, int32(i))
} // }
rand.Shuffle(len(allcs), func(i, j int) { // rand.Shuffle(len(allcs), func(i, j int) {
allcs[i], allcs[j] = allcs[j], allcs[i] // allcs[i], allcs[j] = allcs[j], allcs[i]
}) // })
cs, _ := rule.GetTianHu() // cs, _ := rule.GetTianHu()
allcs = common.DelSliceIn32s(allcs, cs) // allcs = common.DelSliceIn32s(allcs, cs)
for _, seat := range this.seats { // for _, seat := range this.seats {
if seat != nil && seat.IsGameing() { // if seat != nil && seat.IsGameing() {
if seat != v { // if seat != v {
f1(seat, allcs[:13]) // f1(seat, allcs[:13])
allcs = allcs[13:] // allcs = allcs[13:]
} else { // } else {
f1(seat, cs) // f1(seat, cs)
} // }
} // }
} // }
v.TestLog = append(v.TestLog, fmt.Sprintf("新手阶段没有天胡过,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes)) // v.TestLog = append(v.TestLog, fmt.Sprintf("新手阶段没有天胡过,玩家:%d 发天胡 num:%v", v.SnId, data.Statics.GameTimes))
logger.Logger.Tracef("新手阶段没有天胡过,玩家:%v 发天胡", v.SnId) // logger.Logger.Tracef("新手阶段没有天胡过,玩家:%v 发天胡", v.SnId)
noviceCtrl = true // noviceCtrl = true
} // }
} // }
} // }
} //}
// 全局配置
gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig gameConfig := base.ConfigMgrInst.GetConfig(this.Platform).GameConfig
// testPokers 用于测试 // testPokers 用于测试

View File

@ -454,7 +454,7 @@ func (this *CSPigBankGetInfoHandler) Process(s *netlib.Session, packetid int, da
if _, ok := data.(*welfare.CSPigbankGetInfo); ok { if _, ok := data.(*welfare.CSPigbankGetInfo); ok {
p := PlayerMgrSington.GetPlayer(sid) p := PlayerMgrSington.GetPlayer(sid)
if p == nil { if p == nil {
logger.Logger.Warnf("CSPigBankGetInfoHandler p == nil p.SnId = %v", p.SnId) logger.Logger.Warnf("CSPigBankGetInfoHandler p == nil")
return nil return nil
} }
WelfareMgrSington.PigbankGetInfo(p) WelfareMgrSington.PigbankGetInfo(p)
@ -479,7 +479,7 @@ func (this *CSPigBankTakeCoinHandler) Process(s *netlib.Session, packetid int, d
if _, ok := data.(*welfare.CSPigbankTakeCoin); ok { if _, ok := data.(*welfare.CSPigbankTakeCoin); ok {
p := PlayerMgrSington.GetPlayer(sid) p := PlayerMgrSington.GetPlayer(sid)
if p == nil { if p == nil {
logger.Logger.Warnf("CSPigBankTakeCoinHandler p == nil p.SnId = %v", p.SnId) logger.Logger.Warnf("CSPigBankTakeCoinHandler p == nil")
return nil return nil
} }
WelfareMgrSington.PigbankTakeCoin(p) WelfareMgrSington.PigbankTakeCoin(p)