review
This commit is contained in:
parent
481860d9bc
commit
da5bb97469
|
|
@ -520,7 +520,7 @@ func (this *CSInviteFriendOpHandler) Process(s *netlib.Session, packetid int, da
|
||||||
send(p)
|
send(p)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if !p.EnterScene(scene, true, pos) {
|
if !scene.PlayerEnter(p, pos, true) {
|
||||||
logger.Logger.Trace("CSInviteFriendHandler EnterScene fail")
|
logger.Logger.Trace("CSInviteFriendHandler EnterScene fail")
|
||||||
opRetCode = friend.OpResultCode_OPRC_Error //进入房间失败
|
opRetCode = friend.OpResultCode_OPRC_Error //进入房间失败
|
||||||
send(p)
|
send(p)
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ func (this *CSEnterRoomHandler) Process(s *netlib.Session, packetid int, data in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.EnterScene(scene, true, -1) {
|
if !scene.PlayerEnter(p, -1, true) {
|
||||||
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1940,7 +1940,7 @@ func (this *CSCreateRoomHandler) ProcessLocalGame(s *netlib.Session, packetid in
|
||||||
// try enter scene
|
// try enter scene
|
||||||
csp.scenes[scene.sceneId] = scene
|
csp.scenes[scene.sceneId] = scene
|
||||||
scene.csp = csp
|
scene.csp = csp
|
||||||
if !p.EnterScene(scene, true, -1) {
|
if !scene.PlayerEnter(p, -1, true) {
|
||||||
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2048,7 +2048,7 @@ func (this *CSCreateRoomHandler) ProcessThirteen(s *netlib.Session, packetid int
|
||||||
// try enter scene
|
// try enter scene
|
||||||
csp.scenes[scene.sceneId] = scene
|
csp.scenes[scene.sceneId] = scene
|
||||||
scene.csp = csp
|
scene.csp = csp
|
||||||
if !p.EnterScene(scene, true, -1) {
|
if !scene.PlayerEnter(p, -1, true) {
|
||||||
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,154 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/globalsign/mgo"
|
|
||||||
"mongo.games.com/game/common"
|
|
||||||
"mongo.games.com/game/model"
|
|
||||||
"mongo.games.com/game/proto"
|
|
||||||
"mongo.games.com/game/protocol/activity"
|
|
||||||
"mongo.games.com/game/protocol/server"
|
|
||||||
"mongo.games.com/game/srvdata"
|
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
var ActSignMgrSington = &ActSignMgr{
|
|
||||||
SignConfigs: make(map[int]*server.DB_ActSign),
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActSignMgr struct {
|
|
||||||
SignConfigs map[int]*server.DB_ActSign
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) Init() {
|
|
||||||
if this.SignConfigs == nil {
|
|
||||||
this.SignConfigs = make(map[int]*server.DB_ActSign)
|
|
||||||
}
|
|
||||||
for _, v := range srvdata.PBDB_ActSignMgr.Datas.GetArr() {
|
|
||||||
this.SignConfigs[int(v.Id)] = v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) GetConfig(id int) *server.DB_ActSign {
|
|
||||||
signConfig, ok := this.SignConfigs[id]
|
|
||||||
if ok {
|
|
||||||
return signConfig
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) OnPlayerLogin(player *Player) error {
|
|
||||||
return this.RefixedPlayerData(player)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) OnDayChanged(player *Player) error {
|
|
||||||
//跨天不需要
|
|
||||||
//this.RefixedPlayerData(player)
|
|
||||||
//this.SendSignDataToPlayer(player)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) RefixedPlayerData(player *Player) error {
|
|
||||||
if player.IsRob {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if player.SignData == nil {
|
|
||||||
player.SignData = &model.SignData{
|
|
||||||
SignIndex: 0,
|
|
||||||
LastSignTickets: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) SendSignDataToPlayer(player *Player) {
|
|
||||||
if player.IsRob {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
pack := &activity.SCSignData{}
|
|
||||||
//已经领取第几个
|
|
||||||
pack.SignCount = proto.Int(player.SignData.SignIndex)
|
|
||||||
if player.SignData.LastSignTickets != 0 {
|
|
||||||
lastSignTime := time.Unix(player.SignData.LastSignTickets, 0)
|
|
||||||
dayDiff := int32(common.DiffDay(time.Now(), lastSignTime))
|
|
||||||
if dayDiff == 0 {
|
|
||||||
pack.TodaySign = proto.Int32(1)
|
|
||||||
} else {
|
|
||||||
pack.TodaySign = proto.Int32(0)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
pack.TodaySign = proto.Int32(0)
|
|
||||||
}
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
player.SendToClient(int(activity.ActSignPacketID_PACKET_SCSignData), pack)
|
|
||||||
logger.Logger.Trace("SCSignData: ", pack)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *ActSignMgr) CanSign(player *Player, signIndex int) activity.OpResultCode_ActSign {
|
|
||||||
signConfig := this.GetConfig(signIndex)
|
|
||||||
if signConfig == nil {
|
|
||||||
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Error
|
|
||||||
}
|
|
||||||
|
|
||||||
if player.SignData.LastSignTickets != 0 {
|
|
||||||
lastSignTime := time.Unix(player.SignData.LastSignTickets, 0)
|
|
||||||
dayDiff := int32(common.DiffDay(time.Now(), lastSignTime))
|
|
||||||
if dayDiff == 0 {
|
|
||||||
if player.SignData.SignIndex == signIndex {
|
|
||||||
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Repeat
|
|
||||||
} else {
|
|
||||||
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Config_Day_Error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if player.SignData.SignIndex != (signIndex - 1) {
|
|
||||||
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Config_Day_Error
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if signIndex != 1 {
|
|
||||||
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Config_Day_Error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess
|
|
||||||
}
|
|
||||||
|
|
||||||
//func (this *ActSignMgr) Sign(player *Player, signIndex int, signType int32) activity.OpResultCode_ActSign {
|
|
||||||
// errCode := this.CanSign(player, signIndex)
|
|
||||||
// if errCode != activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess {
|
|
||||||
// return errCode
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// signConfig := this.GetConfig(signIndex)
|
|
||||||
// if signConfig == nil {
|
|
||||||
// return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Error
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// player.SignData.LastSignTickets = time.Now().Unix()
|
|
||||||
// player.SignData.SignIndex = signIndex
|
|
||||||
//
|
|
||||||
// logger.Logger.Info("签到成功: ", signConfig)
|
|
||||||
// grade := signConfig.Grade
|
|
||||||
// switch signType {
|
|
||||||
// case 0: //普通签到
|
|
||||||
// case 1: //双倍签到
|
|
||||||
// grade *= 2
|
|
||||||
// }
|
|
||||||
// switch signConfig.Type {
|
|
||||||
// case 1: //金币
|
|
||||||
// player.AddCoin(int64(grade), 0, common.GainWay_ActSign, strconv.Itoa(signIndex), time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
// case 2: //钻石
|
|
||||||
// player.AddDiamond(int64(grade), 0, common.GainWay_ActSign, strconv.Itoa(signIndex), time.Now().Format("2006-01-02 15:04:05"))
|
|
||||||
// case 3: //道具
|
|
||||||
// item := &Item{
|
|
||||||
// ItemId: signConfig.Item_Id,
|
|
||||||
// ItemNum: int64(grade),
|
|
||||||
// }
|
|
||||||
// BagMgrSingleton.AddItems(player, []*Item{item}, 0, common.GainWay_ActSign, strconv.Itoa(signIndex), time.Now().Format("2006-01-02 15:04:05"), 0, 0, false)
|
|
||||||
// }
|
|
||||||
// return activity.OpResultCode_ActSign_OPRC_Activity_Sign_Sucess
|
|
||||||
//}
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
mgo.SetStats(true)
|
|
||||||
}
|
|
||||||
|
|
@ -5,20 +5,20 @@ import (
|
||||||
|
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
gamehall_proto "mongo.games.com/game/protocol/gamehall"
|
gamehallproto "mongo.games.com/game/protocol/gamehall"
|
||||||
server_proto "mongo.games.com/game/protocol/server"
|
serverproto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CoinScenePool 房间池
|
// CoinScenePool 房间池
|
||||||
type CoinScenePool struct {
|
type CoinScenePool struct {
|
||||||
platform string // 平台id
|
platform string // 平台id
|
||||||
groupId int32 // 组id
|
groupId int32 // 组id
|
||||||
id int32 // 场次id
|
id int32 // 场次id
|
||||||
dbGameFree *server_proto.DB_GameFree // 场次配置
|
dbGameFree *serverproto.DB_GameFree // 场次配置
|
||||||
dbGameRule *server_proto.DB_GameRule // 场次配置
|
dbGameRule *serverproto.DB_GameRule // 场次配置
|
||||||
scenes map[int]*Scene // 所有房间,房间id
|
scenes map[int]*Scene // 所有房间,房间id
|
||||||
players map[int32]struct{} // 玩家id
|
players map[int32]struct{} // 玩家id
|
||||||
|
|
||||||
// 扩展数据
|
// 扩展数据
|
||||||
extraData interface{}
|
extraData interface{}
|
||||||
|
|
@ -26,7 +26,7 @@ type CoinScenePool struct {
|
||||||
policy ICoinScenePool
|
policy ICoinScenePool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCoinScenePool(platform string, groupId int32, dbGameFree *server_proto.DB_GameFree) *CoinScenePool {
|
func NewCoinScenePool(platform string, groupId int32, dbGameFree *serverproto.DB_GameFree) *CoinScenePool {
|
||||||
if dbGameFree == nil {
|
if dbGameFree == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -87,20 +87,20 @@ func (csp *CoinScenePool) CanInviteRob() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanEnter 检查入场条件
|
// CanEnter 检查入场条件
|
||||||
func (csp *CoinScenePool) CanEnter(p *Player) gamehall_proto.OpResultCode {
|
func (csp *CoinScenePool) CanEnter(p *Player) gamehallproto.OpResultCode {
|
||||||
if csp.dbGameFree == nil || p == nil {
|
if csp.dbGameFree == nil || p == nil {
|
||||||
return gamehall_proto.OpResultCode_OPRC_Error
|
return gamehallproto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测房间状态是否开启
|
//检测房间状态是否开启
|
||||||
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
||||||
if gps == nil || !gps.Status {
|
if gps == nil || !gps.Status {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
dbGameFree := csp.dbGameFree
|
dbGameFree := csp.dbGameFree
|
||||||
if dbGameFree == nil {
|
if dbGameFree == nil {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查游戏次数限制
|
//检查游戏次数限制
|
||||||
|
|
@ -109,7 +109,7 @@ func (csp *CoinScenePool) CanEnter(p *Player) gamehall_proto.OpResultCode {
|
||||||
if dbGameFree.GetPlayNumLimit() != 0 &&
|
if dbGameFree.GetPlayNumLimit() != 0 &&
|
||||||
todayData != nil &&
|
todayData != nil &&
|
||||||
todayData.GameTimes >= int64(dbGameFree.GetPlayNumLimit()) {
|
todayData.GameTimes >= int64(dbGameFree.GetPlayNumLimit()) {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomGameTimes
|
return gamehallproto.OpResultCode_OPRC_RoomGameTimes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,28 +117,30 @@ func (csp *CoinScenePool) CanEnter(p *Player) gamehall_proto.OpResultCode {
|
||||||
}
|
}
|
||||||
|
|
||||||
// CanAudienceEnter 检查观众入场条件
|
// CanAudienceEnter 检查观众入场条件
|
||||||
func (csp *CoinScenePool) CanAudienceEnter(p *Player) gamehall_proto.OpResultCode {
|
func (csp *CoinScenePool) CanAudienceEnter(p *Player) gamehallproto.OpResultCode {
|
||||||
if csp.dbGameFree == nil || p == nil {
|
if csp.dbGameFree == nil || p == nil {
|
||||||
return gamehall_proto.OpResultCode_OPRC_Error
|
return gamehallproto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
//检测房间状态是否开启
|
//检测房间状态是否开启
|
||||||
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
gps := PlatformMgrSingleton.GetGameFree(p.Platform, csp.id)
|
||||||
if gps == nil {
|
if gps == nil {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
dbGameFree := csp.dbGameFree
|
dbGameFree := csp.dbGameFree
|
||||||
if dbGameFree == nil {
|
if dbGameFree == nil {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomHadClosed
|
return gamehallproto.OpResultCode_OPRC_RoomHadClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
return csp.policy.CanAudienceEnter(csp, p)
|
return csp.policy.CanAudienceEnter(csp, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PlayerEnter 玩家进入房间池
|
// PlayerEnter 玩家进入房间池
|
||||||
func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32, ischangeroom bool) gamehall_proto.OpResultCode {
|
// exclude 排除的房间id
|
||||||
if ret := csp.CanEnter(p); ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
// isChangeRoom 是否换房
|
||||||
|
func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32, isChangeRoom bool) gamehallproto.OpResultCode {
|
||||||
|
if ret := csp.CanEnter(p); ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId,
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId,
|
||||||
p.Coin, ret, csp.dbGameFree.GetId())
|
p.Coin, ret, csp.dbGameFree.GetId())
|
||||||
return ret
|
return ret
|
||||||
|
|
@ -146,40 +148,42 @@ func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32,
|
||||||
|
|
||||||
if p.scene != nil {
|
if p.scene != nil {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
||||||
return gamehall_proto.OpResultCode_OPRC_Error
|
return gamehallproto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene *Scene
|
var scene *Scene
|
||||||
// 进入房间
|
// 进入房间
|
||||||
if roomId != 0 && (p.IsRob || p.GMLevel > 0 || csp.dbGameFree.GetCreateRoomNum() != 0) {
|
// 指定房间id进入,忽略排除exclude,只有机器人和进入预创建房间才允许
|
||||||
|
if roomId != 0 && (p.IsRob || csp.dbGameFree.GetCreateRoomNum() != 0) {
|
||||||
if s, ok := csp.scenes[int(roomId)]; ok {
|
if s, ok := csp.scenes[int(roomId)]; ok {
|
||||||
if s != nil && !s.deleting { //指定房间id进入,那么忽略掉排除id
|
if s != nil && !s.deleting { //指定房间id进入,那么忽略掉排除id
|
||||||
if s.IsFull() {
|
if s.IsFull() {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomIsFull
|
return gamehallproto.OpResultCode_OPRC_RoomIsFull
|
||||||
}
|
}
|
||||||
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
if sp, ok := s.sp.(*ScenePolicyData); ok {
|
||||||
if !s.starting || sp.EnterAfterStart {
|
if !s.starting || sp.EnterAfterStart {
|
||||||
scene = s
|
scene = s
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[!s.starting || sp.EnterAfterStart] snid:%v sceneid:%v starting:%v EnterAfterStart:%v", p.SnId, s.sceneId, s.starting, sp.EnterAfterStart)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter[!s.starting || sp.EnterAfterStart] snid:%v sceneid:%v starting:%v EnterAfterStart:%v", p.SnId, s.sceneId, s.starting, sp.EnterAfterStart)
|
||||||
return gamehall_proto.OpResultCode_OPRC_Error
|
return gamehallproto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter(robot:%v,roomid:%v, exclude:%v, ischangeroom:%v) no found scene", p.SnId, roomId, exclude, ischangeroom)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter(robot:%v,roomid:%v, exclude:%v, isChangeRoom:%v) no found scene", p.SnId, roomId, exclude, isChangeRoom)
|
||||||
return gamehall_proto.OpResultCode_OPRC_Error
|
return gamehallproto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
var ret gamehall_proto.OpResultCode
|
var ret gamehallproto.OpResultCode
|
||||||
ret, scene = csp.policy.PlayerEnter(csp, p, exclude, ischangeroom)
|
ret, scene = csp.policy.PlayerEnter(csp, p, exclude, isChangeRoom)
|
||||||
if ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
if ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 没有找到房间,创建新房间
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
scene = csp.policy.NewScene(csp, p)
|
scene = csp.policy.NewScene(csp, p)
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
|
|
@ -191,25 +195,25 @@ func (csp *CoinScenePool) PlayerEnter(p *Player, roomId int32, exclude []int32,
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
if p.EnterScene(scene, ischangeroom, -1) {
|
if scene.PlayerEnter(p, -1, isChangeRoom) {
|
||||||
csp.OnPlayerEnter(p, scene)
|
csp.OnPlayerEnter(p, scene)
|
||||||
return gamehall_proto.OpResultCode_OPRC_Sucess
|
return gamehallproto.OpResultCode_OPRC_Sucess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
||||||
return gamehall_proto.OpResultCode_OPRC_SceneServerMaintain
|
return gamehallproto.OpResultCode_OPRC_SceneServerMaintain
|
||||||
}
|
}
|
||||||
|
|
||||||
// AudienceEnter 观众入场
|
// AudienceEnter 观众入场
|
||||||
func (csp *CoinScenePool) AudienceEnter(p *Player, roomId int32, exclude []int32, ischangeroom bool) gamehall_proto.OpResultCode {
|
func (csp *CoinScenePool) AudienceEnter(p *Player, roomId int32, exclude []int32, ischangeroom bool) gamehallproto.OpResultCode {
|
||||||
if ret := csp.CanAudienceEnter(p); ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
if ret := csp.CanAudienceEnter(p); ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId, p.Coin, ret, csp.dbGameFree.GetId())
|
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter find snid:%v csp.CanEnter coin:%v ret:%v id:%v", p.SnId, p.Coin, ret, csp.dbGameFree.GetId())
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.scene != nil {
|
if p.scene != nil {
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
logger.Logger.Warnf("(csp *CoinScenePool) AudienceEnter[p.scene != nil] find snid:%v in scene:%v gameId:%v", p.SnId, p.scene.sceneId, p.scene.gameId)
|
||||||
return gamehall_proto.OpResultCode_OPRC_Error
|
return gamehallproto.OpResultCode_OPRC_Error
|
||||||
}
|
}
|
||||||
|
|
||||||
var scene *Scene
|
var scene *Scene
|
||||||
|
|
@ -224,29 +228,29 @@ func (csp *CoinScenePool) AudienceEnter(p *Player, roomId int32, exclude []int32
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
var ret gamehall_proto.OpResultCode
|
var ret gamehallproto.OpResultCode
|
||||||
ret, scene = csp.policy.AudienceEnter(csp, p, exclude, ischangeroom)
|
ret, scene = csp.policy.AudienceEnter(csp, p, exclude, ischangeroom)
|
||||||
if ret != gamehall_proto.OpResultCode_OPRC_Sucess {
|
if ret != gamehallproto.OpResultCode_OPRC_Sucess {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene == nil {
|
if scene == nil {
|
||||||
return gamehall_proto.OpResultCode_OPRC_NoFindDownTiceRoom
|
return gamehallproto.OpResultCode_OPRC_NoFindDownTiceRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
// 预创建房间检查观众数量
|
// 预创建房间检查观众数量
|
||||||
if scene.IsPreCreateScene() && scene.GetAudienceCnt() >= model.GameParamData.MaxAudienceNum {
|
if scene.IsPreCreateScene() && scene.GetAudienceCnt() >= model.GameParamData.MaxAudienceNum {
|
||||||
return gamehall_proto.OpResultCode_OPRC_RoomIsFull
|
return gamehallproto.OpResultCode_OPRC_RoomIsFull
|
||||||
}
|
}
|
||||||
if scene.AudienceEnter(p, ischangeroom) {
|
if scene.AudienceEnter(p, ischangeroom) {
|
||||||
csp.OnPlayerEnter(p, scene)
|
csp.OnPlayerEnter(p, scene)
|
||||||
return gamehall_proto.OpResultCode_OPRC_Sucess
|
return gamehallproto.OpResultCode_OPRC_Sucess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
logger.Logger.Warnf("(csp *CoinScenePool) PlayerEnter snid:%v not found scene", p.SnId)
|
||||||
return gamehall_proto.OpResultCode_OPRC_NoFindDownTiceRoom
|
return gamehallproto.OpResultCode_OPRC_NoFindDownTiceRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnPlayerEnter 玩家进入房间完成
|
// OnPlayerEnter 玩家进入房间完成
|
||||||
|
|
@ -431,7 +435,7 @@ func (csp *CoinScenePool) ListRoom(p *Player) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
pack := &gamehall_proto.SCCoinSceneListRoom{
|
pack := &gamehallproto.SCCoinSceneListRoom{
|
||||||
Id: csp.dbGameFree.Id,
|
Id: csp.dbGameFree.Id,
|
||||||
LimitCoin: csp.dbGameFree.LimitCoin,
|
LimitCoin: csp.dbGameFree.LimitCoin,
|
||||||
MaxCoinLimit: csp.dbGameFree.MaxCoinLimit,
|
MaxCoinLimit: csp.dbGameFree.MaxCoinLimit,
|
||||||
|
|
@ -442,7 +446,7 @@ func (csp *CoinScenePool) ListRoom(p *Player) bool {
|
||||||
|
|
||||||
maxPlayerNum := 0
|
maxPlayerNum := 0
|
||||||
for sceneId, s := range csp.scenes {
|
for sceneId, s := range csp.scenes {
|
||||||
data := &gamehall_proto.CoinSceneInfo{
|
data := &gamehallproto.CoinSceneInfo{
|
||||||
SceneId: proto.Int(sceneId),
|
SceneId: proto.Int(sceneId),
|
||||||
PlayerNum: proto.Int(len(s.players)),
|
PlayerNum: proto.Int(len(s.players)),
|
||||||
}
|
}
|
||||||
|
|
@ -451,7 +455,7 @@ func (csp *CoinScenePool) ListRoom(p *Player) bool {
|
||||||
}
|
}
|
||||||
pack.MaxPlayerNum = proto.Int(maxPlayerNum)
|
pack.MaxPlayerNum = proto.Int(maxPlayerNum)
|
||||||
proto.SetDefaults(pack)
|
proto.SetDefaults(pack)
|
||||||
p.SendToClient(int(gamehall_proto.CoinSceneGamePacketID_PACKET_SC_COINSCENE_LISTROOM), pack)
|
p.SendToClient(int(gamehallproto.CoinSceneGamePacketID_PACKET_SC_COINSCENE_LISTROOM), pack)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,6 @@ func NewPlayer(sid int64, pd *model.PlayerData, s *netlib.Session) *Player {
|
||||||
func (this *Player) init() bool {
|
func (this *Player) init() bool {
|
||||||
this.SetOnline()
|
this.SetOnline()
|
||||||
this.isNewbie = this.CreateTime == this.LastLoginTime
|
this.isNewbie = this.CreateTime == this.LastLoginTime
|
||||||
this.applyPos = -1
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2351,23 +2350,6 @@ func (this *Player) CreateLocalGameScene(sceneId, gameId, gameSite, sceneMode, p
|
||||||
return s, hall_proto.OpResultCode_Game_OPRC_Sucess_Game
|
return s, hall_proto.OpResultCode_Game_OPRC_Sucess_Game
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Player) EnterScene(s *Scene, ischangeroom bool, pos int) bool {
|
|
||||||
if s == nil {
|
|
||||||
logger.Logger.Tracef("(this *Player) EnterScene, s == nil %v", this.SnId)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
if s != nil {
|
|
||||||
this.applyPos = -1
|
|
||||||
if s.PlayerEnter(this, pos, ischangeroom) {
|
|
||||||
FirePlayerEnterScene(this, s)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Player) ReturnScene(isLoaded bool) *Scene {
|
func (this *Player) ReturnScene(isLoaded bool) *Scene {
|
||||||
logger.Logger.Tracef("(this *Player) ReturnScene %v", this.SnId)
|
logger.Logger.Tracef("(this *Player) ReturnScene %v", this.SnId)
|
||||||
if this.scene == nil {
|
if this.scene == nil {
|
||||||
|
|
|
||||||
|
|
@ -553,6 +553,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
||||||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_PLAYERENTER), msg)
|
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_PLAYERENTER), msg)
|
||||||
logger.Logger.Tracef("SSPacketID_PACKET_WG_PLAYERENTER Scene:%v ;PlayerEnter(%v, %v)", this.sceneId, p.SnId, pos)
|
logger.Logger.Tracef("SSPacketID_PACKET_WG_PLAYERENTER Scene:%v ;PlayerEnter(%v, %v)", this.sceneId, p.SnId, pos)
|
||||||
this.lastTime = time.Now()
|
this.lastTime = time.Now()
|
||||||
|
FirePlayerEnterScene(p, this)
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Warnf("(this *Scene:%v) PlayerEnter(%v, %v) Marshal player data error %v", this.sceneId, p.SnId, pos, err)
|
logger.Logger.Warnf("(this *Scene:%v) PlayerEnter(%v, %v) Marshal player data error %v", this.sceneId, p.SnId, pos, err)
|
||||||
|
|
@ -659,7 +660,6 @@ func (this *Scene) DelPlayer(p *Player) bool {
|
||||||
func (this *Scene) AudienceEnter(p *Player, ischangeroom bool) bool {
|
func (this *Scene) AudienceEnter(p *Player, ischangeroom bool) bool {
|
||||||
logger.Logger.Infof("(this *Scene:%v) AudienceEnter(%v) ", this.sceneId, p.SnId)
|
logger.Logger.Infof("(this *Scene:%v) AudienceEnter(%v) ", this.sceneId, p.SnId)
|
||||||
p.scene = this
|
p.scene = this
|
||||||
p.applyPos = -1
|
|
||||||
this.audiences[p.SnId] = p
|
this.audiences[p.SnId] = p
|
||||||
this.gameSess.AddPlayer(p)
|
this.gameSess.AddPlayer(p)
|
||||||
if this.IsHundredScene() {
|
if this.IsHundredScene() {
|
||||||
|
|
@ -744,7 +744,6 @@ func (this *Scene) DelAudience(p *Player) bool {
|
||||||
delete(this.gameCtx, p.SnId)
|
delete(this.gameCtx, p.SnId)
|
||||||
}
|
}
|
||||||
p.scene = nil
|
p.scene = nil
|
||||||
p.applyPos = -1
|
|
||||||
SceneMgrSingleton.OnPlayerLeaveScene(this, p)
|
SceneMgrSingleton.OnPlayerLeaveScene(this, p)
|
||||||
if this.IsHundredScene() {
|
if this.IsHundredScene() {
|
||||||
HundredSceneMgrSington.OnPlayerLeave(p)
|
HundredSceneMgrSington.OnPlayerLeave(p)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue