Compare commits
3 Commits
cd321a3f55
...
18e3e5cd7d
Author | SHA1 | Date |
---|---|---|
|
18e3e5cd7d | |
|
71655d8126 | |
|
00b0e01000 |
|
@ -853,3 +853,9 @@ const (
|
||||||
On = 1 // 开启
|
On = 1 // 开启
|
||||||
Off = 2 // 关闭
|
Off = 2 // 关闭
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DataConfigAll = 0 // 全部配置
|
||||||
|
DataConfigSprite = 1 // 精灵配置
|
||||||
|
DataConfigMatchAudience = 2 // 赛事观战开关
|
||||||
|
)
|
||||||
|
|
|
@ -699,7 +699,7 @@ func (this *Scene) AudienceLeave(p *Player, reason int) {
|
||||||
//当前状态不能离场
|
//当前状态不能离场
|
||||||
if !this.CanChangeCoinScene(p) {
|
if !this.CanChangeCoinScene(p) {
|
||||||
pack := &gamehall.SCLeaveRoom{
|
pack := &gamehall.SCLeaveRoom{
|
||||||
OpRetCode: (gamehall.OpResultCode_Game(p.OpCode)), //protocol.OpResultCode_OPRC_Hundred_YouHadBetCannotLeave,
|
OpRetCode: gamehall.OpResultCode_Game(p.OpCode), //protocol.OpResultCode_OPRC_Hundred_YouHadBetCannotLeave,
|
||||||
RoomId: proto.Int(this.SceneId),
|
RoomId: proto.Int(this.SceneId),
|
||||||
}
|
}
|
||||||
proto.SetDefaults(pack)
|
proto.SetDefaults(pack)
|
||||||
|
|
|
@ -517,7 +517,7 @@ func TienLenCreateRoomInfoPacket(s *base.Scene, p *base.Player, sceneEx *TienLen
|
||||||
//手牌
|
//手牌
|
||||||
for j := int32(0); j < rule.HandCardNum; j++ {
|
for j := int32(0); j < rule.HandCardNum; j++ {
|
||||||
if nowPlayer.cards[j] != rule.InvalideCard {
|
if nowPlayer.cards[j] != rule.InvalideCard {
|
||||||
if s.GetSceneState().GetState() == rule.TienLenSceneStateBilled { //结算状态显示用
|
if s.GetSceneState().GetState() == rule.TienLenSceneStateBilled || p.IsMarkFlag(base.PlayerState_Audience) { //结算状态显示用
|
||||||
pd1.Cards = append(pd1.Cards, nowPlayer.cards[j])
|
pd1.Cards = append(pd1.Cards, nowPlayer.cards[j])
|
||||||
} else {
|
} else {
|
||||||
pd1.Cards = append(pd1.Cards, rule.InvalideCard)
|
pd1.Cards = append(pd1.Cards, rule.InvalideCard)
|
||||||
|
|
|
@ -135,7 +135,7 @@ type AllConfig struct {
|
||||||
*webapi.AwardLogConfig
|
*webapi.AwardLogConfig
|
||||||
// 新手引导配置
|
// 新手引导配置
|
||||||
*webapi.GuideConfig
|
*webapi.GuideConfig
|
||||||
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表
|
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表 key: 玩家id
|
||||||
// 小精灵配置
|
// 小精灵配置
|
||||||
*webapi.SpiritConfig
|
*webapi.SpiritConfig
|
||||||
}
|
}
|
||||||
|
|
|
@ -10903,7 +10903,7 @@ type Config struct {
|
||||||
|
|
||||||
// Tp 类型:
|
// Tp 类型:
|
||||||
// 1:小精灵快捷入口 On开关 Value地址
|
// 1:小精灵快捷入口 On开关 Value地址
|
||||||
// 2: ...
|
// 2:比赛观战开关 On开关
|
||||||
// ...
|
// ...
|
||||||
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"`
|
Tp int32 `protobuf:"varint,1,opt,name=Tp,proto3" json:"Tp,omitempty"`
|
||||||
On bool `protobuf:"varint,2,opt,name=On,proto3" json:"On,omitempty"`
|
On bool `protobuf:"varint,2,opt,name=On,proto3" json:"On,omitempty"`
|
||||||
|
|
|
@ -1351,7 +1351,7 @@ message SCGuideConfig{
|
||||||
message Config{
|
message Config{
|
||||||
// Tp 类型:
|
// Tp 类型:
|
||||||
// 1:小精灵快捷入口 On开关 Value地址
|
// 1:小精灵快捷入口 On开关 Value地址
|
||||||
// 2: ...
|
// 2:比赛观战开关 On开关
|
||||||
// ...
|
// ...
|
||||||
int32 Tp = 1;
|
int32 Tp = 1;
|
||||||
bool On = 2;
|
bool On = 2;
|
||||||
|
|
2
public
2
public
|
@ -1 +1 @@
|
||||||
Subproject commit 5436469c04056f83ab69b52b7cdeb5d21832fa94
|
Subproject commit e754bb123f44b0f524ec9dd6d67a1e9d2803a7c5
|
|
@ -183,94 +183,6 @@ failed:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type CSAudienceEnterRoomHandler struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *CSAudienceEnterRoomHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
|
||||||
logger.Logger.Trace("CSAudienceEnterRoomHandler Process recv ", data)
|
|
||||||
if msg, ok := data.(*gamehall.CSEnterRoom); ok {
|
|
||||||
p := PlayerMgrSington.GetPlayer(sid)
|
|
||||||
if p == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var code = gamehall.OpResultCode_Game_OPRC_Sucess_Game
|
|
||||||
var sp ScenePolicy
|
|
||||||
var dbGameFree *server.DB_GameFree
|
|
||||||
var cfg *webapiproto.GameFree
|
|
||||||
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()))
|
|
||||||
if scene == nil {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
|
||||||
logger.Logger.Trace("CSAudienceEnterRoomHandler scene == nil")
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
if !scene.CanAudience() {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
|
||||||
logger.Logger.Tracef("CSAudienceEnterRoomHandler scene.CanAudience() %v", scene.sceneId)
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
|
|
||||||
if scene.IsMatchScene() && !PlatformMgrSingleton.IsMatchAudience(p.Platform, p.SnId) {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
|
||||||
logger.Logger.Tracef("CSAudienceEnterRoomHandler scene.IsMatchAudience() %v", scene.sceneId)
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
if p.scene != nil {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_CannotWatchReasonInOther_Game
|
|
||||||
logger.Logger.Trace("CSAudienceEnterRoomHandler p.scene != nil")
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
cfg = PlatformMgrSingleton.GetGameFree(p.Platform, scene.dbGameFree.Id)
|
|
||||||
if cfg != nil && (cfg.GroupId != scene.groupId || cfg.GroupId == 0) {
|
|
||||||
if scene.limitPlatform != nil {
|
|
||||||
if scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.IdStr {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
|
||||||
logger.Logger.Tracef("CSEnterRoomHandler ScenePolicy(gameid:%v mode:%v) scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.Name", scene.gameId, scene.gameMode)
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//if !scene.starting {
|
|
||||||
// code = gamehall.OpResultCode_Game_OPRC_CannotWatchReasonRoomNotStart_Game
|
|
||||||
// logger.Logger.Trace("CSAudienceEnterRoomHandler !scene.starting")
|
|
||||||
// goto failed
|
|
||||||
//}
|
|
||||||
if scene.deleting {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
|
||||||
logger.Logger.Trace("CSAudienceEnterRoomHandler scene is deleting")
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
if scene.closed {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game
|
|
||||||
logger.Logger.Trace("CSAudienceEnterRoomHandler scene is closed")
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
//if scene.IsCoinScene() || scene.IsHundredScene() {
|
|
||||||
// code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
|
||||||
// logger.Logger.Trace("CSAudienceEnterRoomHandler scene is IsCoinScene IsHundredScene")
|
|
||||||
// goto failed
|
|
||||||
//}
|
|
||||||
|
|
||||||
sp = GetScenePolicy(scene.gameId, scene.gameMode)
|
|
||||||
if sp == nil {
|
|
||||||
code = gamehall.OpResultCode_Game_OPRC_GameNotExist_Game
|
|
||||||
logger.Logger.Tracef("CSAudienceEnterRoomHandler ScenePolicy(gameid:%v mode:%v) not registe", scene.gameId, scene.gameMode)
|
|
||||||
goto failed
|
|
||||||
}
|
|
||||||
dbGameFree = scene.dbGameFree
|
|
||||||
code = gamehall.OpResultCode_Game(CoinSceneMgrSingleton.AudienceEnter(p, dbGameFree.GetId(), msg.GetRoomId(), nil, true))
|
|
||||||
|
|
||||||
failed:
|
|
||||||
if code != gamehall.OpResultCode_Game_OPRC_Sucess_Game {
|
|
||||||
resp := &gamehall.SCEnterRoom{
|
|
||||||
OpRetCode: code,
|
|
||||||
}
|
|
||||||
proto.SetDefaults(resp)
|
|
||||||
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_ENTERROOM), resp)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type CSReturnRoomPacketFactory struct {
|
type CSReturnRoomPacketFactory struct {
|
||||||
}
|
}
|
||||||
type CSReturnRoomHandler struct {
|
type CSReturnRoomHandler struct {
|
||||||
|
@ -1235,10 +1147,95 @@ func (this *CSRecordAndNoticeHandler) Process(s *netlib.Session, packetid int, d
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CSAudienceEnterRoomHandler(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSAudienceEnterRoomHandler Process recv ", data)
|
||||||
|
msg, ok := data.(*gamehall.CSEnterRoom)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var code = gamehall.OpResultCode_Game_OPRC_Error_Game
|
||||||
|
var sp ScenePolicy
|
||||||
|
var cfg *webapiproto.GameFree
|
||||||
|
|
||||||
|
// 房间是否存在
|
||||||
|
scene := SceneMgrSingleton.GetScene(int(msg.GetRoomId()))
|
||||||
|
if scene == nil {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
||||||
|
logger.Logger.Trace("CSAudienceEnterRoomHandler scene == nil")
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 房间是否正在销毁
|
||||||
|
if scene.deleting {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
||||||
|
logger.Logger.Trace("CSAudienceEnterRoomHandler scene is deleting")
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 房间是否已经关闭
|
||||||
|
if scene.closed {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_RoomHadClosed_Game
|
||||||
|
logger.Logger.Trace("CSAudienceEnterRoomHandler scene is closed")
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 玩家没有在房间中
|
||||||
|
if p.scene != nil {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_CannotWatchReasonInOther_Game
|
||||||
|
logger.Logger.Trace("CSAudienceEnterRoomHandler p.scene != nil")
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 房间是否可以观战
|
||||||
|
if !scene.CanAudience() {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
||||||
|
logger.Logger.Tracef("CSAudienceEnterRoomHandler scene.CanAudience() %v", scene.sceneId)
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 比赛场白名单观众
|
||||||
|
if scene.IsMatchScene() && !PlatformMgrSingleton.IsMatchAudience(p.Platform, p.SnId) {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
||||||
|
logger.Logger.Tracef("CSAudienceEnterRoomHandler scene.IsMatchAudience() %v", scene.sceneId)
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 是不是相同平台
|
||||||
|
cfg = PlatformMgrSingleton.GetGameFree(p.Platform, scene.dbGameFree.Id)
|
||||||
|
if cfg == nil || (scene.limitPlatform != nil && scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.IdStr) {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_RoomNotExist_Game
|
||||||
|
logger.Logger.Tracef("CSEnterRoomHandler ScenePolicy(gameid:%v mode:%v) scene.limitPlatform.Isolated && p.Platform != scene.limitPlatform.Name", scene.gameId, scene.gameMode)
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
// 游戏规则是否存在
|
||||||
|
sp = GetScenePolicy(scene.gameId, scene.gameMode)
|
||||||
|
if sp == nil {
|
||||||
|
code = gamehall.OpResultCode_Game_OPRC_GameNotExist_Game
|
||||||
|
logger.Logger.Tracef("CSAudienceEnterRoomHandler ScenePolicy(gameid:%v mode:%v) not registe", scene.gameId, scene.gameMode)
|
||||||
|
goto failed
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case scene.IsCoinScene():
|
||||||
|
code = gamehall.OpResultCode_Game(CoinSceneMgrSingleton.AudienceEnter(p, cfg.GetDbGameFree().GetId(), msg.GetRoomId(), nil, true))
|
||||||
|
case scene.IsHundredScene():
|
||||||
|
|
||||||
|
case scene.IsMatchScene():
|
||||||
|
code = gamehall.OpResultCode_Game(MatchSceneMgrSingleton.AudienceEnter(p, cfg.GetDbGameFree().GetId(), int(msg.GetRoomId()), nil, true))
|
||||||
|
}
|
||||||
|
|
||||||
|
failed:
|
||||||
|
if code != gamehall.OpResultCode_Game_OPRC_Sucess_Game {
|
||||||
|
resp := &gamehall.SCEnterRoom{
|
||||||
|
OpRetCode: code,
|
||||||
|
}
|
||||||
|
p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SC_ENTERROOM), resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 观众进入房间
|
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_AUDIENCE_ENTERROOM), &CSAudienceEnterRoomHandler{})
|
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_AUDIENCE_ENTERROOM), &CSEnterRoomPacketFactory{})
|
|
||||||
// 返回房间
|
// 返回房间
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomHandler{})
|
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomPacketFactory{})
|
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_RETURNROOM), &CSReturnRoomPacketFactory{})
|
||||||
|
@ -1266,4 +1263,7 @@ func init() {
|
||||||
//我的游戏信息及平台公告
|
//我的游戏信息及平台公告
|
||||||
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_COMNOTICE), &CSRecordAndNoticeHandler{})
|
common.RegisterHandler(int(gamehall.GameHallPacketID_PACKET_CS_COMNOTICE), &CSRecordAndNoticeHandler{})
|
||||||
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_COMNOTICE), &CSRecordAndNoticePacketFactory{})
|
netlib.RegisterFactory(int(gamehall.GameHallPacketID_PACKET_CS_COMNOTICE), &CSRecordAndNoticePacketFactory{})
|
||||||
|
|
||||||
|
// 观众进入房间
|
||||||
|
common.Register(int(gamehall.GameHallPacketID_PACKET_CS_AUDIENCE_ENTERROOM), &gamehall.CSEnterRoom{}, CSAudienceEnterRoomHandler)
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,8 +253,11 @@ func init() {
|
||||||
p.GameCoinTs = gameCoinTs
|
p.GameCoinTs = gameCoinTs
|
||||||
p.dirty = true
|
p.dirty = true
|
||||||
}
|
}
|
||||||
|
if scene.IsMatchScene() {
|
||||||
|
scene.AudienceLeave(p, int(msg.GetReason()))
|
||||||
|
} else {
|
||||||
CoinSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason()))
|
CoinSceneMgrSingleton.PlayerLeave(p, int(msg.GetReason()))
|
||||||
|
}
|
||||||
|
|
||||||
//变化金币
|
//变化金币
|
||||||
p.dirty = true
|
p.dirty = true
|
||||||
|
@ -639,7 +642,7 @@ func init() {
|
||||||
if msg, ok := pack.(*serverproto.GWChangeSceneEvent); ok {
|
if msg, ok := pack.(*serverproto.GWChangeSceneEvent); ok {
|
||||||
scene := SceneMgrSingleton.GetScene(int(msg.GetSceneId()))
|
scene := SceneMgrSingleton.GetScene(int(msg.GetSceneId()))
|
||||||
if scene != nil {
|
if scene != nil {
|
||||||
scene.PlayerTryChange()
|
//scene.PlayerTryChange()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -199,17 +199,25 @@ func CSRoomList(s *netlib.Session, packetId int, data interface{}, sid int64) er
|
||||||
if v.matchCtx == nil {
|
if v.matchCtx == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(v.matchCtx.copySnid)
|
||||||
|
|
||||||
d := &tournament.MatchPlayer{
|
d := &tournament.MatchPlayer{
|
||||||
SnId: v.matchCtx.copySnid,
|
SnId: v.matchCtx.copySnid,
|
||||||
Name: v.Name,
|
Name: p.GetName(),
|
||||||
HeadUrl: v.HeadUrl,
|
|
||||||
UseRoleId: v.matchCtx.copyRoleId,
|
UseRoleId: v.matchCtx.copyRoleId,
|
||||||
UseSkinId: v.matchCtx.copySkinId,
|
UseSkinId: v.matchCtx.copySkinId,
|
||||||
Rank: v.matchCtx.rank,
|
Rank: TournamentMgr.GetRank(tm.SortId, v.matchCtx.copySnid),
|
||||||
Score: v.matchCtx.grade,
|
Score: v.matchCtx.grade,
|
||||||
}
|
}
|
||||||
room.Players = append(room.Players, d)
|
room.Players = append(room.Players, d)
|
||||||
}
|
}
|
||||||
|
sort.Slice(room.Players, func(i, j int) bool {
|
||||||
|
if room.Players[i].Rank == room.Players[j].Rank {
|
||||||
|
return room.Players[i].SnId < room.Players[j].SnId
|
||||||
|
}
|
||||||
|
return room.Players[i].Rank < room.Players[j].Rank
|
||||||
|
})
|
||||||
pack.List = append(pack.List, room)
|
pack.List = append(pack.List, room)
|
||||||
}
|
}
|
||||||
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCRoomList), pack)
|
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCRoomList), pack)
|
||||||
|
|
|
@ -330,7 +330,7 @@ func (csp *CoinScenePool) onPlayerLeave(s *Scene, p *Player) {
|
||||||
// 玩家离开结算空房间的私人房
|
// 玩家离开结算空房间的私人房
|
||||||
if s.IsPrivateScene() {
|
if s.IsPrivateScene() {
|
||||||
if s.IsEmpty() {
|
if s.IsEmpty() {
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ func (csp *CoinScenePool) onPlayerLeave(s *Scene, p *Player) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if hasCnt > int(csp.dbGameFree.GetCreateRoomNum()) {
|
if hasCnt > int(csp.dbGameFree.GetCreateRoomNum()) {
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -323,15 +323,7 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e
|
||||||
case *webapi.SpiritConfig:
|
case *webapi.SpiritConfig:
|
||||||
PlatformMgrSingleton.GetConfig(config.Platform).SpiritConfig = config
|
PlatformMgrSingleton.GetConfig(config.Platform).SpiritConfig = config
|
||||||
if !isInit {
|
if !isInit {
|
||||||
PlayerMgrSington.BroadcastMessageToPlatform(config.Platform, int(playerproto.PlayerPacketID_PACKET_SCDataConfig), &playerproto.SCDataConfig{
|
PlayerMgrSington.BroadcastDataConfigToPlatform(config.Platform, common.DataConfigSprite)
|
||||||
Cfg: []*playerproto.Config{
|
|
||||||
{
|
|
||||||
Tp: 1,
|
|
||||||
On: config.GetOn() == 1,
|
|
||||||
Value: config.GetUrl(),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
||||||
|
@ -404,8 +396,20 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case clientv3.EventTypePut:
|
case clientv3.EventTypePut:
|
||||||
PlatformMgrSingleton.AddMatchAudience(config)
|
PlatformMgrSingleton.AddMatchAudience(config)
|
||||||
|
if !isInit {
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(config.GetSnId())
|
||||||
|
if p != nil {
|
||||||
|
p.SCDataConfig(common.DataConfigMatchAudience)
|
||||||
|
}
|
||||||
|
}
|
||||||
case clientv3.EventTypeDelete:
|
case clientv3.EventTypeDelete:
|
||||||
PlatformMgrSingleton.DelMatchAudience(config)
|
PlatformMgrSingleton.DelMatchAudience(config)
|
||||||
|
if !isInit {
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(config.GetSnId())
|
||||||
|
if p != nil {
|
||||||
|
p.SCDataConfig(common.DataConfigMatchAudience)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -80,9 +80,6 @@ func (this *GameSession) GetSrvId() int32 {
|
||||||
// 关闭其上的所有场景
|
// 关闭其上的所有场景
|
||||||
func (this *GameSession) CloseAllScene() {
|
func (this *GameSession) CloseAllScene() {
|
||||||
for sceneId, scene := range this.scenes {
|
for sceneId, scene := range this.scenes {
|
||||||
if scene.IsMiniGameScene() {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
scDestroyRoom := &gamehall_proto.SCDestroyRoom{
|
scDestroyRoom := &gamehall_proto.SCDestroyRoom{
|
||||||
RoomId: proto.Int(sceneId),
|
RoomId: proto.Int(sceneId),
|
||||||
OpRetCode: gamehall_proto.OpResultCode_Game_OPRC_Sucess_Game,
|
OpRetCode: gamehall_proto.OpResultCode_Game_OPRC_Sucess_Game,
|
||||||
|
@ -92,7 +89,6 @@ func (this *GameSession) CloseAllScene() {
|
||||||
scene.Broadcast(int(gamehall_proto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
scene.Broadcast(int(gamehall_proto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
||||||
SceneMgrSingleton.DestroyScene(sceneId, true)
|
SceneMgrSingleton.DestroyScene(sceneId, true)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.scenes = nil
|
this.scenes = nil
|
||||||
this.players = nil
|
this.players = nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -392,7 +392,7 @@ func (this *HundredSceneMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCf
|
||||||
}
|
}
|
||||||
if scenes, exist := this.scenesOfPlatform[p.IdStr]; exist {
|
if scenes, exist := this.scenesOfPlatform[p.IdStr]; exist {
|
||||||
if s, ok := scenes[newCfg.DbGameFree.Id]; ok {
|
if s, ok := scenes[newCfg.DbGameFree.Id]; ok {
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
|
hallproto "mongo.games.com/game/protocol/gamehall"
|
||||||
"mongo.games.com/game/protocol/server"
|
"mongo.games.com/game/protocol/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -172,11 +173,22 @@ func (ms *MatchSceneMgr) OnDestroyScene(sceneId int) {
|
||||||
delete(ms.scenes, sceneId)
|
delete(ms.scenes, sceneId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ms *MatchSceneMgr) AudienceEnter(p *Player, id int32, roomId int, exclude []int32, ischangeroom bool) hallproto.OpResultCode {
|
||||||
|
scene, ok := ms.scenes[roomId]
|
||||||
|
if !ok {
|
||||||
|
return hallproto.OpResultCode_OPRC_RoomHadClosed
|
||||||
|
}
|
||||||
|
if !scene.AudienceEnter(p, ischangeroom) {
|
||||||
|
return hallproto.OpResultCode_OPRC_RoomHadClosed
|
||||||
|
}
|
||||||
|
return hallproto.OpResultCode_OPRC_Sucess
|
||||||
|
}
|
||||||
|
|
||||||
func (ms *MatchSceneMgr) MatchStop(tm *TmMatch) {
|
func (ms *MatchSceneMgr) MatchStop(tm *TmMatch) {
|
||||||
if SceneMgrSingleton.scenes != nil && tm != nil {
|
if SceneMgrSingleton.scenes != nil && tm != nil {
|
||||||
for _, scene := range SceneMgrSingleton.scenes {
|
for _, scene := range SceneMgrSingleton.scenes {
|
||||||
if scene.IsMatchScene() && scene.matchId == tm.SortId {
|
if scene.IsMatchScene() && scene.matchId == tm.SortId {
|
||||||
scene.DoDelete(false)
|
scene.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1662,7 +1662,7 @@ func (this *Player) OnLogouted() {
|
||||||
this.Save(true)
|
this.Save(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Player) MarshalData(gameid int) (d []byte, e error) {
|
func (this *Player) MarshalData() (d []byte, e error) {
|
||||||
d, e = netlib.Gob.Marshal(this.PlayerData)
|
d, e = netlib.Gob.Marshal(this.PlayerData)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3101,8 +3101,8 @@ func (this *Player) SendPlayerInfo() {
|
||||||
this.SCItems()
|
this.SCItems()
|
||||||
// 引导配置
|
// 引导配置
|
||||||
this.SCGuide()
|
this.SCGuide()
|
||||||
// 小精灵配置
|
// 其它配置
|
||||||
this.SCSpirit()
|
this.SCDataConfig(common.DataConfigAll)
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (this *Player) SendJackpotInfo() {
|
//func (this *Player) SendJackpotInfo() {
|
||||||
|
@ -4951,20 +4951,66 @@ func (this *Player) SCGuide() {
|
||||||
logger.Logger.Tracef("SCGuideConfig: %v", pack)
|
logger.Logger.Tracef("SCGuideConfig: %v", pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Player) SCSpirit() {
|
// DataConfigFuncMap 配置查询方法
|
||||||
cfg := PlatformMgrSingleton.GetConfig(this.Platform).SpiritConfig
|
var DataConfigFuncMap = map[int]func(platform string, p *Player) *playerproto.Config{
|
||||||
|
common.DataConfigSprite: func(platform string, p *Player) *playerproto.Config {
|
||||||
|
cfg := PlatformMgrSingleton.GetConfig(platform).SpiritConfig
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
return
|
return nil
|
||||||
}
|
}
|
||||||
pack := &playerproto.SCDataConfig{
|
return &playerproto.Config{
|
||||||
Cfg: []*playerproto.Config{
|
Tp: common.DataConfigSprite,
|
||||||
{
|
|
||||||
Tp: 1,
|
|
||||||
On: cfg.On == 1,
|
On: cfg.On == 1,
|
||||||
Value: cfg.Url,
|
Value: cfg.Url,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
common.DataConfigMatchAudience: func(platform string, p *Player) *playerproto.Config {
|
||||||
|
if p == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cfg := PlatformMgrSingleton.GetConfig(platform).MatchAudience
|
||||||
|
if cfg == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
d, ok := cfg[p.GetSnId()]
|
||||||
|
if !ok || d == nil {
|
||||||
|
return &playerproto.Config{
|
||||||
|
Tp: common.DataConfigMatchAudience,
|
||||||
|
On: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return &playerproto.Config{
|
||||||
|
Tp: common.DataConfigMatchAudience,
|
||||||
|
On: true,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SCDataConfig 通知配置
|
||||||
|
// tp 类型 0所有 1小精灵 2比赛观众开关
|
||||||
|
func (this *Player) SCDataConfig(tp int) {
|
||||||
|
if this == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
pack := &playerproto.SCDataConfig{}
|
||||||
|
if tp == common.DataConfigAll {
|
||||||
|
for _, f := range DataConfigFuncMap {
|
||||||
|
d := f(this.Platform, this)
|
||||||
|
if d != nil {
|
||||||
|
pack.Cfg = append(pack.Cfg, d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
f, ok := DataConfigFuncMap[tp]
|
||||||
|
if ok {
|
||||||
|
d := f(this.Platform, this)
|
||||||
|
if d != nil {
|
||||||
|
pack.Cfg = append(pack.Cfg, d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(pack.Cfg) > 0 {
|
||||||
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCDataConfig), pack)
|
this.SendToClient(int(playerproto.PlayerPacketID_PACKET_SCDataConfig), pack)
|
||||||
logger.Logger.Tracef("SCDataConfig: %v", pack)
|
logger.Logger.Tracef("SCDataConfig: %v", pack)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
|
playerproto "mongo.games.com/game/protocol/player"
|
||||||
serverproto "mongo.games.com/game/protocol/server"
|
serverproto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/worldsrv/internal"
|
"mongo.games.com/game/worldsrv/internal"
|
||||||
)
|
)
|
||||||
|
@ -328,6 +329,21 @@ func (this *PlayerMgr) BroadcastMessageToPlatform(platform string, packetid int,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *PlayerMgr) BroadcastDataConfigToPlatform(platform string, tp int) {
|
||||||
|
packetId := int(playerproto.PlayerPacketID_PACKET_SCDataConfig)
|
||||||
|
pack := &playerproto.SCDataConfig{}
|
||||||
|
f, ok := DataConfigFuncMap[tp]
|
||||||
|
if ok {
|
||||||
|
d := f(platform, nil)
|
||||||
|
if d != nil {
|
||||||
|
pack.Cfg = append(pack.Cfg, d)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(pack.Cfg) > 0 {
|
||||||
|
this.BroadcastMessageToPlatform(platform, packetId, pack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *PlayerMgr) BroadcastMessageToPlatformByFunc(platform string, packetid int, rawpack interface{}, f func(p *Player) bool) {
|
func (this *PlayerMgr) BroadcastMessageToPlatformByFunc(platform string, packetid int, rawpack interface{}, f func(p *Player) bool) {
|
||||||
if platform == "" {
|
if platform == "" {
|
||||||
this.BroadcastMessage(packetid, rawpack)
|
this.BroadcastMessage(packetid, rawpack)
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"mongo.games.com/game/proto"
|
"mongo.games.com/game/proto"
|
||||||
hallproto "mongo.games.com/game/protocol/gamehall"
|
hallproto "mongo.games.com/game/protocol/gamehall"
|
||||||
playerproto "mongo.games.com/game/protocol/player"
|
|
||||||
serverproto "mongo.games.com/game/protocol/server"
|
serverproto "mongo.games.com/game/protocol/server"
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
@ -50,11 +49,11 @@ type PlayerGameCtx struct {
|
||||||
type Scene struct {
|
type Scene struct {
|
||||||
sceneId int //场景id
|
sceneId int //场景id
|
||||||
gameId int //游戏id
|
gameId int //游戏id
|
||||||
gameMode int //游戏模式
|
gameMode int //游戏模式(玩法)
|
||||||
sceneMode int //房间模式,参考common.SceneMode_XXX
|
sceneMode int //房间模式,参考common.SceneMode_XXX
|
||||||
params []int64 //场景参数
|
params []int64 //场景参数
|
||||||
paramsEx []int32 //其他扩展参数
|
paramsEx []int32 //其他扩展参数
|
||||||
playerNum int //人数
|
playerNum int //房间最大人数
|
||||||
robotNum int //机器人数量
|
robotNum int //机器人数量
|
||||||
robotLimit int //最大限制机器人数量
|
robotLimit int //最大限制机器人数量
|
||||||
preInviteRobNum int //准备邀请机器人的数量
|
preInviteRobNum int //准备邀请机器人的数量
|
||||||
|
@ -145,7 +144,7 @@ func NewScene(agentor, creator int32, id, gameId, gameMode, sceneMode int, clycl
|
||||||
s.playerNum = int(sp.GetPlayerNum(s))
|
s.playerNum = int(sp.GetPlayerNum(s))
|
||||||
s.lastTime = s.createTime
|
s.lastTime = s.createTime
|
||||||
|
|
||||||
if s.IsHallScene() || s.IsCoinScene() {
|
if s.IsCoinScene() {
|
||||||
code := SceneMgrSingleton.AllocReplayCode()
|
code := SceneMgrSingleton.AllocReplayCode()
|
||||||
s.replayCode = code
|
s.replayCode = code
|
||||||
}
|
}
|
||||||
|
@ -228,6 +227,13 @@ func (this *Scene) RobotIsLimit() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Scene) GetPlayerGameCtx(snid int32) *PlayerGameCtx {
|
||||||
|
if ctx, exist := this.gameCtx[snid]; exist {
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
||||||
logger.Logger.Infof("(this *Scene:%v) PlayerEnter(%v, %v) ", this.sceneId, p.SnId, pos)
|
logger.Logger.Infof("(this *Scene:%v) PlayerEnter(%v, %v) ", this.sceneId, p.SnId, pos)
|
||||||
|
|
||||||
|
@ -273,15 +279,6 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
||||||
this.players[p.SnId] = p
|
this.players[p.SnId] = p
|
||||||
this.gameSess.AddPlayer(p)
|
this.gameSess.AddPlayer(p)
|
||||||
|
|
||||||
switch {
|
|
||||||
case this.IsCoinScene():
|
|
||||||
|
|
||||||
case this.IsHundredScene():
|
|
||||||
|
|
||||||
case this.IsMatchScene():
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果正在等待比赛,退赛
|
// 如果正在等待比赛,退赛
|
||||||
if !this.IsMatchScene() {
|
if !this.IsMatchScene() {
|
||||||
isWaiting, tmid := TournamentMgr.IsMatchWaiting(p.Platform, p.SnId)
|
isWaiting, tmid := TournamentMgr.IsMatchWaiting(p.Platform, p.SnId)
|
||||||
|
@ -458,8 +455,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
||||||
logger.Logger.Tracef("(this *Scene) PlayerEnter(%v) robot(%v) robotlimit(%v)", name, this.robotNum, this.robotLimit)
|
logger.Logger.Tracef("(this *Scene) PlayerEnter(%v) robot(%v) robotlimit(%v)", name, this.robotNum, this.robotLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo:send add msg to gamesrv
|
data, err := p.MarshalData()
|
||||||
data, err := p.MarshalData(this.gameId)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
var gateSid int64
|
var gateSid int64
|
||||||
if p.gateSess != nil {
|
if p.gateSess != nil {
|
||||||
|
@ -563,110 +559,19 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExePMCmd(s *netlib.Session, cmd string) {
|
|
||||||
CSPMCmd := &playerproto.CSPMCmd{
|
|
||||||
Cmd: proto.String(cmd),
|
|
||||||
}
|
|
||||||
proto.SetDefaults(CSPMCmd)
|
|
||||||
logger.Logger.Trace("CSPMCmd:", CSPMCmd)
|
|
||||||
s.Send(int(playerproto.PlayerPacketID_PACKET_CS_PMCMD), CSPMCmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Scene) GetPlayerGameCtx(snid int32) *PlayerGameCtx {
|
|
||||||
if ctx, exist := this.gameCtx[snid]; exist {
|
|
||||||
return ctx
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Scene) PlayerLeave(p *Player, reason int) {
|
|
||||||
logger.Logger.Infof("(this *Scene:%v) PlayerLeave(%v, %v) ", this.sceneId, p.SnId, reason)
|
|
||||||
//if !this.IsMatchScene() {
|
|
||||||
//pack := &hall_proto.SCLeaveRoom{
|
|
||||||
// Reason: proto.Int(reason),
|
|
||||||
// OpRetCode: hall_proto.OpResultCode_Game_OPRC_Sucess_Game,
|
|
||||||
// Mode: proto.Int(0),
|
|
||||||
// RoomId: proto.Int(this.sceneId),
|
|
||||||
//}
|
|
||||||
//proto.SetDefaults(pack)
|
|
||||||
//p.SendToClient(int(hall_proto.GameHallPacketID_PACKET_SC_LEAVEROOM), pack)
|
|
||||||
pack := &hallproto.SCQuitGame{
|
|
||||||
Id: int32(this.dbGameFree.Id),
|
|
||||||
Reason: proto.Int(reason),
|
|
||||||
}
|
|
||||||
pack.OpCode = hallproto.OpResultCode_Game_OPRC_Sucess_Game
|
|
||||||
proto.SetDefaults(pack)
|
|
||||||
p.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_QUITGAME), pack)
|
|
||||||
//}
|
|
||||||
|
|
||||||
//其他人直接从房间退出来
|
|
||||||
this.DelPlayer(p)
|
|
||||||
|
|
||||||
// 玩家最后所在游戏
|
|
||||||
p.LastGameId = int(this.dbGameFree.GetGameId())
|
|
||||||
if !p.IsRob {
|
|
||||||
this.lastTime = time.Now()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Scene) DelPlayer(p *Player) bool {
|
|
||||||
if p.scene != this {
|
|
||||||
inroomid := 0
|
|
||||||
if p.scene != nil {
|
|
||||||
inroomid = p.scene.sceneId
|
|
||||||
}
|
|
||||||
logger.Logger.Warnf("(this *Scene) DelPlayer found player:%v in room:%v but room:%v", p.SnId, inroomid, this.sceneId)
|
|
||||||
}
|
|
||||||
if this.gameSess != nil {
|
|
||||||
this.gameSess.DelPlayer(p)
|
|
||||||
}
|
|
||||||
delete(this.players, p.SnId)
|
|
||||||
if !p.IsRob {
|
|
||||||
delete(this.gameCtx, p.SnId)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.scene = nil
|
|
||||||
SceneMgrSingleton.OnPlayerLeaveScene(this, p)
|
|
||||||
|
|
||||||
switch {
|
|
||||||
case this.IsHundredScene():
|
|
||||||
//case this.IsHallScene():
|
|
||||||
// PlatformMgrSingleton.OnPlayerLeaveScene(this, p)
|
|
||||||
// for i := 0; i < this.playerNum; i++ {
|
|
||||||
// if this.seats[i] == p {
|
|
||||||
// p.pos = -1
|
|
||||||
// this.seats[i] = nil
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
case this.IsCoinScene() || this.IsMatchScene():
|
|
||||||
for i := 0; i < this.playerNum; i++ {
|
|
||||||
if this.seats[i] == p {
|
|
||||||
p.pos = -1
|
|
||||||
this.seats[i] = nil
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.IsRob {
|
|
||||||
this.robotNum--
|
|
||||||
name := this.GetSceneName()
|
|
||||||
logger.Logger.Tracef("(this *Scene) PlayerLeave(%v) robot(%v) robotlimit(%v)", name, this.robotNum, this.robotLimit)
|
|
||||||
}
|
|
||||||
//from gameserver, so don't need send msg
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
||||||
|
takeCoin := p.Coin
|
||||||
|
p.takeCoin = takeCoin
|
||||||
this.audiences[p.SnId] = p
|
this.audiences[p.SnId] = p
|
||||||
this.gameSess.AddPlayer(p)
|
this.gameSess.AddPlayer(p)
|
||||||
|
|
||||||
//todo:send add msg to gamesrv
|
data, err := p.MarshalData()
|
||||||
data, err := p.MarshalData(this.gameId)
|
if err != nil {
|
||||||
if err == nil {
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var gateSid int64
|
var gateSid int64
|
||||||
if p.gateSess != nil {
|
if p.gateSess != nil {
|
||||||
if srvInfo, ok := p.gateSess.GetAttribute(srvlib.SessionAttributeServerInfo).(*srvlibproto.SSSrvRegiste); ok && srvInfo != nil {
|
if srvInfo, ok := p.gateSess.GetAttribute(srvlib.SessionAttributeServerInfo).(*srvlibproto.SSSrvRegiste); ok && srvInfo != nil {
|
||||||
|
@ -674,47 +579,91 @@ func (this *Scene) AudienceEnter(p *Player, ischangeroom bool) bool {
|
||||||
gateSid = sessionId.Get()
|
gateSid = sessionId.Get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isQuMin := false
|
|
||||||
//if !p.IsRob {
|
|
||||||
// pt := PlatformMgrSingleton.GetPackageTag(p.PackageID)
|
|
||||||
// if pt != nil && pt.SpreadTag == 1 {
|
|
||||||
// isQuMin = true
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
msg := &serverproto.WGPlayerEnter{
|
msg := &serverproto.WGPlayerEnter{
|
||||||
Sid: proto.Int64(p.sid),
|
Sid: proto.Int64(p.sid),
|
||||||
SnId: proto.Int32(p.SnId),
|
SnId: proto.Int32(p.SnId),
|
||||||
GateSid: proto.Int64(gateSid),
|
GateSid: proto.Int64(gateSid),
|
||||||
SceneId: proto.Int(this.sceneId),
|
SceneId: proto.Int(this.sceneId),
|
||||||
PlayerData: data,
|
PlayerData: data,
|
||||||
|
TakeCoin: takeCoin,
|
||||||
IsLoaded: proto.Bool(ischangeroom),
|
IsLoaded: proto.Bool(ischangeroom),
|
||||||
IsQM: proto.Bool(isQuMin),
|
IsQM: false,
|
||||||
IParams: p.MarshalIParam(),
|
IParams: p.MarshalIParam(),
|
||||||
SParams: p.MarshalSParam(),
|
SParams: p.MarshalSParam(),
|
||||||
CParams: p.MarshalCParam(),
|
CParams: p.MarshalCParam(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if !p.IsRob { //保存下进入时的环境
|
if !p.IsRob { //保存下进入时的环境
|
||||||
|
p.enterts = time.Now()
|
||||||
this.gameCtx[p.SnId] = &PlayerGameCtx{
|
this.gameCtx[p.SnId] = &PlayerGameCtx{
|
||||||
takeCoin: p.takeCoin,
|
takeCoin: p.takeCoin,
|
||||||
enterTs: p.enterts.Unix(),
|
enterTs: p.enterts.Unix(),
|
||||||
totalConvertibleFlow: p.TotalConvertibleFlow,
|
|
||||||
}
|
}
|
||||||
this.lastTime = time.Now()
|
this.lastTime = time.Now()
|
||||||
}
|
}
|
||||||
|
|
||||||
takeCoin := p.Coin
|
|
||||||
p.takeCoin = takeCoin
|
|
||||||
msg.TakeCoin = proto.Int64(takeCoin)
|
|
||||||
proto.SetDefaults(msg)
|
|
||||||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_AUDIENCEENTER), msg)
|
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_AUDIENCEENTER), msg)
|
||||||
p.enterts = time.Now()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
func (this *Scene) DelPlayer(p *Player) bool {
|
||||||
|
if p.scene != this {
|
||||||
|
roomId := 0
|
||||||
|
if p.scene != nil {
|
||||||
|
roomId = p.scene.sceneId
|
||||||
|
}
|
||||||
|
logger.Logger.Errorf("DelPlayer found player:%v in room:%v but room:%v", p.SnId, roomId, this.sceneId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if this.gameSess != nil {
|
||||||
|
this.gameSess.DelPlayer(p)
|
||||||
|
}
|
||||||
|
// 玩家离开游戏
|
||||||
|
if _, ok := this.players[p.SnId]; ok {
|
||||||
|
delete(this.players, p.SnId)
|
||||||
|
if p.IsRobot() {
|
||||||
|
this.robotNum--
|
||||||
|
}
|
||||||
|
// 记录玩家最近玩游戏的房间
|
||||||
|
SceneMgrSingleton.OnPlayerLeaveScene(this, p)
|
||||||
|
// 玩家最后所在游戏
|
||||||
|
p.LastGameId = int(this.dbGameFree.GetGameId())
|
||||||
|
}
|
||||||
|
// 观众离开游戏
|
||||||
|
if _, ok := this.audiences[p.SnId]; ok {
|
||||||
|
delete(this.audiences, p.SnId)
|
||||||
|
}
|
||||||
|
for k, v := range this.seats {
|
||||||
|
if v != nil && v.SnId == p.SnId {
|
||||||
|
p.pos = -1
|
||||||
|
this.seats[k] = nil
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !p.IsRob {
|
||||||
|
delete(this.gameCtx, p.SnId)
|
||||||
|
}
|
||||||
|
p.scene = nil
|
||||||
|
if !p.IsRob {
|
||||||
|
this.lastTime = time.Now()
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// PlayerLeave 玩家离开
|
||||||
|
func (this *Scene) PlayerLeave(p *Player, reason int) {
|
||||||
|
logger.Logger.Infof("(this *Scene:%v) PlayerLeave(%v, %v) ", this.sceneId, p.SnId, reason)
|
||||||
|
pack := &hallproto.SCQuitGame{
|
||||||
|
Id: this.dbGameFree.Id,
|
||||||
|
Reason: proto.Int(reason),
|
||||||
|
}
|
||||||
|
pack.OpCode = hallproto.OpResultCode_Game_OPRC_Sucess_Game
|
||||||
|
p.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_QUITGAME), pack)
|
||||||
|
logger.Logger.Tracef("SCQuitGame: %v, %v", p.SnId, pack)
|
||||||
|
this.DelPlayer(p)
|
||||||
|
}
|
||||||
|
|
||||||
|
// AudienceLeave 观众离开
|
||||||
func (this *Scene) AudienceLeave(p *Player, reason int) {
|
func (this *Scene) AudienceLeave(p *Player, reason int) {
|
||||||
logger.Logger.Infof("(this *Scene:%v) AudienceLeave(%v, %v) ", this.sceneId, p.SnId, reason)
|
logger.Logger.Infof("(this *Scene:%v) AudienceLeave(%v, %v) ", this.sceneId, p.SnId, reason)
|
||||||
pack := &hallproto.SCLeaveRoom{
|
pack := &hallproto.SCLeaveRoom{
|
||||||
|
@ -723,97 +672,25 @@ func (this *Scene) AudienceLeave(p *Player, reason int) {
|
||||||
Mode: proto.Int(0),
|
Mode: proto.Int(0),
|
||||||
RoomId: proto.Int(this.sceneId),
|
RoomId: proto.Int(this.sceneId),
|
||||||
}
|
}
|
||||||
proto.SetDefaults(pack)
|
|
||||||
p.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_LEAVEROOM), pack)
|
p.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_LEAVEROOM), pack)
|
||||||
//观众直接从房间退出来
|
logger.Logger.Tracef("AudienceLeave SCLeaveRoom: %v, %v", p.SnId, pack)
|
||||||
this.DelAudience(p)
|
this.DelPlayer(p)
|
||||||
if !p.IsRob {
|
|
||||||
this.lastTime = time.Now()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) DelAudience(p *Player) bool {
|
// AudienceSit 观众坐下
|
||||||
logger.Logger.Infof("(this *Scene:%v) DelAudience(%v) ", this.sceneId, p.SnId)
|
|
||||||
if p.scene != this {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if this.gameSess != nil {
|
|
||||||
this.gameSess.DelPlayer(p)
|
|
||||||
}
|
|
||||||
delete(this.audiences, p.SnId)
|
|
||||||
if !p.IsRob {
|
|
||||||
delete(this.gameCtx, p.SnId)
|
|
||||||
}
|
|
||||||
p.scene = nil
|
|
||||||
SceneMgrSingleton.OnPlayerLeaveScene(this, p)
|
|
||||||
//from gameserver, so don't need send msg
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
//观众坐下
|
|
||||||
//func (this *Scene) AudienceSit(p *Player, pos int) bool {
|
|
||||||
// logger.Logger.Infof("(this *Scene:%v) AudienceSit(%v, %v, %v) ", this.sceneId, p.SnId, pos)
|
|
||||||
// if _, exist := this.audiences[p.SnId]; exist {
|
|
||||||
// if pos == -1 && !this.IsHundredScene() { //自动匹配;百人场没座位概念
|
|
||||||
// for i := 0; i < this.playerNum; i++ {
|
|
||||||
// if this.seats[i] == nil {
|
|
||||||
// pos = i
|
|
||||||
// break
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if pos != -1 || this.IsHundredScene() {
|
|
||||||
// if !this.IsHundredScene() {
|
|
||||||
// if this.seats[pos] != nil {
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
// p.pos = pos
|
|
||||||
// p.applyPos = -1
|
|
||||||
// this.seats[pos] = p
|
|
||||||
// }
|
|
||||||
// delete(this.audiences, p.SnId)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// p.scene = this
|
|
||||||
// this.players[p.SnId] = p
|
|
||||||
//
|
|
||||||
// NpcServerAgentSington.OnPlayerEnterScene(this, p)
|
|
||||||
// if this.IsCoinScene() {
|
|
||||||
// CoinSceneMgrSingleton.OnPlayerEnter(p, int32(this.sceneId))
|
|
||||||
// } else if this.IsHallScene() {
|
|
||||||
// PlatformMgrSingleton.OnPlayerEnterScene(this, p)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// msg := &protocol.WGAudienceSit{
|
|
||||||
// SnId: proto.Int32(p.SnId),
|
|
||||||
// SceneId: proto.Int(this.sceneId),
|
|
||||||
// Pos: proto.Int(pos),
|
|
||||||
// }
|
|
||||||
// p.takeCoin = p.Coin
|
|
||||||
// msg.TakeCoin = proto.Int64(p.Coin)
|
|
||||||
// proto.SetDefaults(msg)
|
|
||||||
// this.SendToGame(int(protocol.MmoPacketID_PACKET_WG_AUDIENCESIT), msg)
|
|
||||||
// this.lastTime = time.Now()
|
|
||||||
// return true
|
|
||||||
// }
|
|
||||||
// return false
|
|
||||||
//}
|
|
||||||
|
|
||||||
func (this *Scene) AudienceSit(p *Player, pos int) bool {
|
func (this *Scene) AudienceSit(p *Player, pos int) bool {
|
||||||
logger.Logger.Infof("(this *Scene:%v) AudienceSit(%v, %v, %v) ", this.sceneId, p.SnId, pos, this.dbGameFree.GetId())
|
logger.Logger.Infof("(this *Scene:%v) AudienceSit(%v, %v, %v) ", this.sceneId, p.SnId, pos, this.dbGameFree.GetId())
|
||||||
if _, exist := this.audiences[p.SnId]; exist {
|
if _, exist := this.audiences[p.SnId]; exist {
|
||||||
delete(this.audiences, p.SnId)
|
delete(this.audiences, p.SnId)
|
||||||
p.scene = this
|
p.scene = this
|
||||||
|
p.takeCoin = p.Coin
|
||||||
this.players[p.SnId] = p
|
this.players[p.SnId] = p
|
||||||
|
|
||||||
msg := &serverproto.WGAudienceSit{
|
msg := &serverproto.WGAudienceSit{
|
||||||
SnId: proto.Int32(p.SnId),
|
SnId: proto.Int32(p.SnId),
|
||||||
|
TakeCoin: p.Coin,
|
||||||
SceneId: proto.Int(this.sceneId),
|
SceneId: proto.Int(this.sceneId),
|
||||||
Pos: proto.Int(pos),
|
Pos: proto.Int(pos),
|
||||||
}
|
}
|
||||||
p.takeCoin = p.Coin
|
|
||||||
msg.TakeCoin = proto.Int64(p.Coin)
|
|
||||||
proto.SetDefaults(msg)
|
|
||||||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_AUDIENCESIT), msg)
|
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_AUDIENCESIT), msg)
|
||||||
if !p.IsRob {
|
if !p.IsRob {
|
||||||
this.lastTime = time.Now()
|
this.lastTime = time.Now()
|
||||||
|
@ -871,6 +748,8 @@ func (this *Scene) GetAudienceCnt() int {
|
||||||
return len(this.audiences)
|
return len(this.audiences)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsFull 是否满人
|
||||||
|
// 不包含观众
|
||||||
func (this *Scene) IsFull() bool {
|
func (this *Scene) IsFull() bool {
|
||||||
return this.GetPlayerCnt() >= this.playerNum
|
return this.GetPlayerCnt() >= this.playerNum
|
||||||
}
|
}
|
||||||
|
@ -883,23 +762,24 @@ func (this *Scene) AllIsRobot() bool {
|
||||||
return len(this.players) == this.robotNum
|
return len(this.players) == this.robotNum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OnClose 房间销毁
|
||||||
func (this *Scene) OnClose() {
|
func (this *Scene) OnClose() {
|
||||||
scDestroyRoom := &hallproto.SCDestroyRoom{
|
scDestroyRoom := &hallproto.SCDestroyRoom{
|
||||||
RoomId: proto.Int(this.sceneId),
|
RoomId: proto.Int(this.sceneId),
|
||||||
OpRetCode: hallproto.OpResultCode_Game_OPRC_Sucess_Game,
|
OpRetCode: hallproto.OpResultCode_Game_OPRC_Sucess_Game,
|
||||||
IsForce: proto.Int(1),
|
IsForce: proto.Int(1),
|
||||||
}
|
}
|
||||||
proto.SetDefaults(scDestroyRoom)
|
|
||||||
this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0)
|
||||||
|
|
||||||
|
this.deleting = true
|
||||||
this.closed = true
|
this.closed = true
|
||||||
this.sp.OnStop(this)
|
this.sp.OnStop(this)
|
||||||
//NpcServerAgentSington.OnSceneClose(this)
|
|
||||||
for _, p := range this.players {
|
for _, p := range this.players {
|
||||||
this.DelPlayer(p)
|
this.DelPlayer(p)
|
||||||
}
|
}
|
||||||
for _, p := range this.audiences {
|
for _, p := range this.audiences {
|
||||||
this.DelAudience(p)
|
this.DelPlayer(p)
|
||||||
}
|
}
|
||||||
this.players = nil
|
this.players = nil
|
||||||
this.audiences = nil
|
this.audiences = nil
|
||||||
|
@ -913,17 +793,13 @@ func (this *Scene) SendToGame(packetId int, pack interface{}) bool {
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
func (this *Scene) SendToClient(packetid int, rawpack interface{}, excludeId int32) {
|
|
||||||
for snid, value := range this.players {
|
func (this *Scene) SendToClient(packetId int, pack interface{}, excludeId int32) {
|
||||||
if snid == excludeId {
|
for v, value := range this.players {
|
||||||
|
if v == excludeId {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
value.SendToClient(packetid, rawpack)
|
value.SendToClient(packetId, pack)
|
||||||
}
|
|
||||||
}
|
|
||||||
func (this *Scene) BilledRoomCard(snid []int32) {
|
|
||||||
if this.sp != nil {
|
|
||||||
this.sp.BilledRoomCard(this, snid)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,7 +812,7 @@ func (this *Scene) IsLongTimeInactive() bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) DoDelete(isGrace bool) {
|
func (this *Scene) SendGameDelete(isGrace bool) {
|
||||||
if !isGrace {
|
if !isGrace {
|
||||||
this.deleting = true
|
this.deleting = true
|
||||||
this.force = true
|
this.force = true
|
||||||
|
@ -949,46 +825,32 @@ func (this *Scene) DoDelete(isGrace bool) {
|
||||||
logger.Logger.Tracef("WG_DESTROYSCENE: %v", pack)
|
logger.Logger.Tracef("WG_DESTROYSCENE: %v", pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) Shutdown() {
|
// IsMatchScene 比赛场
|
||||||
if this.hadCost && this.sp != nil {
|
|
||||||
this.sp.OnShutdown(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 小游戏场
|
|
||||||
func (this *Scene) IsMiniGameScene() bool {
|
|
||||||
return this.sceneId >= common.MiniGameSceneStartId && this.sceneId < common.MiniGameSceneMaxId
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比赛场
|
|
||||||
func (this *Scene) IsMatchScene() bool {
|
func (this *Scene) IsMatchScene() bool {
|
||||||
return this.sceneId >= common.MatchSceneStartId && this.sceneId < common.MatchSceneMaxId
|
return this.sceneId >= common.MatchSceneStartId && this.sceneId < common.MatchSceneMaxId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 大厅场
|
// IsCoinScene 金币场
|
||||||
func (this *Scene) IsHallScene() bool {
|
|
||||||
return this.sceneId >= common.HallSceneStartId && this.sceneId < common.HallSceneMaxId
|
|
||||||
}
|
|
||||||
|
|
||||||
// 金币场
|
|
||||||
func (this *Scene) IsCoinScene() bool {
|
func (this *Scene) IsCoinScene() bool {
|
||||||
return this.sceneId >= common.CoinSceneStartId && this.sceneId < common.CoinSceneMaxId
|
return this.sceneId >= common.CoinSceneStartId && this.sceneId < common.CoinSceneMaxId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 百人场
|
// IsHundredScene 百人场
|
||||||
func (this *Scene) IsHundredScene() bool {
|
func (this *Scene) IsHundredScene() bool {
|
||||||
return this.sceneId >= common.HundredSceneStartId && this.sceneId < common.HundredSceneMaxId
|
return this.sceneId >= common.HundredSceneStartId && this.sceneId < common.HundredSceneMaxId
|
||||||
}
|
}
|
||||||
|
|
||||||
// 私人房间
|
// IsPrivateScene 私人房间
|
||||||
func (this *Scene) IsPrivateScene() bool {
|
func (this *Scene) IsPrivateScene() bool {
|
||||||
return this.sceneId >= common.PrivateSceneStartId && this.sceneId < common.PrivateSceneMaxId || this.sceneMode == common.SceneMode_Private
|
return this.sceneId >= common.PrivateSceneStartId && this.sceneId < common.PrivateSceneMaxId || this.sceneMode == common.SceneMode_Private
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsSceneMode 房间模式
|
||||||
func (this *Scene) IsSceneMode(mode int) bool {
|
func (this *Scene) IsSceneMode(mode int) bool {
|
||||||
return this.sceneMode == mode
|
return this.sceneMode == mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsRankMatch 排位赛
|
||||||
func (this *Scene) IsRankMatch() bool {
|
func (this *Scene) IsRankMatch() bool {
|
||||||
if this.dbGameFree == nil {
|
if this.dbGameFree == nil {
|
||||||
return false
|
return false
|
||||||
|
@ -996,6 +858,7 @@ func (this *Scene) IsRankMatch() bool {
|
||||||
return this.dbGameFree.RankType > 0
|
return this.dbGameFree.RankType > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsTestScene 试玩场
|
||||||
func (this *Scene) IsTestScene() bool {
|
func (this *Scene) IsTestScene() bool {
|
||||||
if this.dbGameFree != nil {
|
if this.dbGameFree != nil {
|
||||||
return this.dbGameFree.GetSceneType() == -1
|
return this.dbGameFree.GetSceneType() == -1
|
||||||
|
@ -1010,6 +873,9 @@ func (this *Scene) IsTestScene() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) GetSceneName() string {
|
func (this *Scene) GetSceneName() string {
|
||||||
|
if this.dbGameFree != nil {
|
||||||
|
return this.dbGameFree.GetName() + this.dbGameFree.GetTitle()
|
||||||
|
}
|
||||||
if len(this.paramsEx) > 0 {
|
if len(this.paramsEx) > 0 {
|
||||||
dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(this.paramsEx[0])
|
dbGameFree := srvdata.PBDB_GameFreeMgr.GetData(this.paramsEx[0])
|
||||||
if dbGameFree != nil {
|
if dbGameFree != nil {
|
||||||
|
@ -1020,6 +886,21 @@ func (this *Scene) GetSceneName() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) RandRobotCnt() {
|
func (this *Scene) RandRobotCnt() {
|
||||||
|
if this.dbGameFree != nil {
|
||||||
|
numrng := this.dbGameFree.GetRobotNumRng()
|
||||||
|
if len(numrng) >= 2 {
|
||||||
|
if numrng[1] == numrng[0] {
|
||||||
|
this.robotLimit = int(numrng[0])
|
||||||
|
} else {
|
||||||
|
if numrng[1] < numrng[0] {
|
||||||
|
numrng[1], numrng[0] = numrng[0], numrng[1]
|
||||||
|
}
|
||||||
|
this.robotLimit = int(numrng[1]) //int(numrng[0] + rand.Int31n(numrng[1]-numrng[0]) + 1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(this.paramsEx) > 0 {
|
if len(this.paramsEx) > 0 {
|
||||||
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.paramsEx[0])
|
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.paramsEx[0])
|
||||||
if gps != nil {
|
if gps != nil {
|
||||||
|
@ -1045,7 +926,7 @@ func (this *Scene) RandRobotCnt() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) isPlatform(platform string) bool {
|
func (this *Scene) IsPlatform(platform string) bool {
|
||||||
if platform == "0" || platform == this.limitPlatform.IdStr {
|
if platform == "0" || platform == this.limitPlatform.IdStr {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -1106,31 +987,7 @@ func (this *Scene) GetTruePlayerCnt() int {
|
||||||
return len(this.players) - this.robotNum
|
return len(this.players) - this.robotNum
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) GetPlayerType(gameid, gamefreeid int32) (types []int32) {
|
func (this *Scene) Broadcast(packetId int, msg rawproto.Message, excludeSid int64) {
|
||||||
for _, p := range this.players {
|
|
||||||
t := int32(0)
|
|
||||||
if p.IsRob {
|
|
||||||
t = common.PlayerType_Rob
|
|
||||||
} else if p.WBLevel < 0 {
|
|
||||||
t = common.PlayerType_Black
|
|
||||||
} else if p.WBLevel > 0 {
|
|
||||||
t = common.PlayerType_White
|
|
||||||
} else {
|
|
||||||
pt := p.CheckType(gameid, gamefreeid)
|
|
||||||
if pt != nil {
|
|
||||||
t = pt.GetId()
|
|
||||||
} else {
|
|
||||||
t = common.PlayerType_Undefine
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !common.InSliceInt32(types, t) {
|
|
||||||
types = append(types, t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Scene) Broadcast(packetid int, msg rawproto.Message, excludeSid int64) {
|
|
||||||
mgs := make(map[*netlib.Session][]*srvlibproto.MCSessionUnion)
|
mgs := make(map[*netlib.Session][]*srvlibproto.MCSessionUnion)
|
||||||
for _, p := range this.players {
|
for _, p := range this.players {
|
||||||
if p != nil {
|
if p != nil {
|
||||||
|
@ -1159,7 +1016,7 @@ func (this *Scene) Broadcast(packetid int, msg rawproto.Message, excludeSid int6
|
||||||
|
|
||||||
for gateSess, v := range mgs {
|
for gateSess, v := range mgs {
|
||||||
if gateSess != nil && len(v) != 0 {
|
if gateSess != nil && len(v) != 0 {
|
||||||
pack, err := common.CreateMulticastPacket(packetid, msg, v...)
|
pack, err := common.CreateMulticastPacket(packetId, msg, v...)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
proto.SetDefaults(pack)
|
proto.SetDefaults(pack)
|
||||||
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
gateSess.Send(int(srvlibproto.SrvlibPacketID_PACKET_SS_MULTICAST), pack)
|
||||||
|
@ -1171,12 +1028,11 @@ func (this *Scene) Broadcast(packetid int, msg rawproto.Message, excludeSid int6
|
||||||
func (this *Scene) HasSameIp(ip string) bool {
|
func (this *Scene) HasSameIp(ip string) bool {
|
||||||
for _, p := range this.players {
|
for _, p := range this.players {
|
||||||
if !p.IsRob {
|
if !p.IsRob {
|
||||||
if p.GMLevel == 0 && p.Ip == ip {
|
if p.Ip == ip {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1184,45 +1040,6 @@ func (this *Scene) IsPreCreateScene() bool {
|
||||||
return this.dbGameFree.GetCreateRoomNum() > 0
|
return this.dbGameFree.GetCreateRoomNum() > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) PlayerTryChange() {
|
|
||||||
var member []*Player
|
|
||||||
var player *Player
|
|
||||||
for _, value := range this.players {
|
|
||||||
if !value.IsRob {
|
|
||||||
member = append(member, value)
|
|
||||||
player = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(member) <= 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
gameFreeId := this.dbGameFree.GetId()
|
|
||||||
gameConfig := PlatformMgrSingleton.GetGameFree(player.Platform, gameFreeId)
|
|
||||||
if gameConfig != nil && gameConfig.DbGameFree.GetMatchMode() == 1 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for i := 0; i < len(member)-1; i++ {
|
|
||||||
p := member[i]
|
|
||||||
other := member[i+1:]
|
|
||||||
if this.dbGameFree.GetSamePlaceLimit() > 0 && sceneLimitMgr.LimitSamePlaceBySnid(other, p,
|
|
||||||
this.dbGameFree.GetGameId(), this.dbGameFree.GetSamePlaceLimit()) {
|
|
||||||
if p.scene.IsPrivateScene() {
|
|
||||||
//if ClubSceneMgrSington.PlayerInChanging(p) {
|
|
||||||
// continue
|
|
||||||
//}
|
|
||||||
//ClubSceneMgrSington.PlayerTryChange(p, gameFreeId, []int32{int32(this.sceneId)}, false)
|
|
||||||
} else {
|
|
||||||
if CoinSceneMgrSingleton.PlayerInChanging(p) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
excludeSceneIds := p.lastSceneId[gameFreeId]
|
|
||||||
CoinSceneMgrSingleton.PlayerTryChange(p, gameFreeId, excludeSceneIds, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this *Scene) GetParamEx(idx int) int32 {
|
func (this *Scene) GetParamEx(idx int) int32 {
|
||||||
if idx < 0 || idx > len(this.paramsEx) {
|
if idx < 0 || idx > len(this.paramsEx) {
|
||||||
return -1
|
return -1
|
||||||
|
@ -1238,7 +1055,7 @@ func (this *Scene) SetParamEx(idx int, val int32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) TryForceDelectMatchInfo() {
|
func (this *Scene) TryForceDeleteMatchInfo() {
|
||||||
if !this.IsMatchScene() {
|
if !this.IsMatchScene() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -435,18 +435,18 @@ func (m *SceneMgr) OnMiniTimer() {
|
||||||
case s.IsCoinScene():
|
case s.IsCoinScene():
|
||||||
if s.IsLongTimeInactive() {
|
if s.IsLongTimeInactive() {
|
||||||
if s.dbGameFree.GetCreateRoomNum() == 0 {
|
if s.dbGameFree.GetCreateRoomNum() == 0 {
|
||||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene DoDelete scene:%v IsLongTimeInactive", s.sceneId)
|
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene SendGameDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
if s.dbGameFree.GetCreateRoomNum() > 0 && s.csp != nil && s.csp.GetRoomNum() > int(s.dbGameFree.GetCreateRoomNum()) {
|
if s.dbGameFree.GetCreateRoomNum() > 0 && s.csp != nil && s.csp.GetRoomNum() > int(s.dbGameFree.GetCreateRoomNum()) {
|
||||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene DoDelete scene:%v IsLongTimeInactive", s.sceneId)
|
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene SendGameDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case s.IsPrivateScene():
|
case s.IsPrivateScene():
|
||||||
if s.IsLongTimeInactive() {
|
if s.IsLongTimeInactive() {
|
||||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive PrivateScene DoDelete scene:%v IsLongTimeInactive", s.sceneId)
|
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive PrivateScene SendGameDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,10 @@ import (
|
||||||
"mongo.games.com/game/srvdata"
|
"mongo.games.com/game/srvdata"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getSortId() int64 {
|
||||||
|
return time.Now().UnixMilli()
|
||||||
|
}
|
||||||
|
|
||||||
type TmPlayer struct {
|
type TmPlayer struct {
|
||||||
SnId int32
|
SnId int32
|
||||||
seq int // 报名序号(第几个报名的)
|
seq int // 报名序号(第几个报名的)
|
||||||
|
@ -30,6 +34,7 @@ type TmGradeInfo struct {
|
||||||
copyLv int32
|
copyLv int32
|
||||||
copyRoleId int32
|
copyRoleId int32
|
||||||
CopySkinId int32
|
CopySkinId int32
|
||||||
|
rank int32
|
||||||
}
|
}
|
||||||
|
|
||||||
type TmMatch struct {
|
type TmMatch struct {
|
||||||
|
@ -48,7 +53,7 @@ type TmMatch struct {
|
||||||
|
|
||||||
func NewTmMatch(platform string, match *webapi_proto.GameMatchDate, players map[int32]*TmPlayer) *TmMatch {
|
func NewTmMatch(platform string, match *webapi_proto.GameMatchDate, players map[int32]*TmPlayer) *TmMatch {
|
||||||
ret := &TmMatch{
|
ret := &TmMatch{
|
||||||
SortId: time.Now().UnixNano(),
|
SortId: getSortId(),
|
||||||
TMId: match.Id,
|
TMId: match.Id,
|
||||||
TmPlayer: make(map[int32]*TmPlayer),
|
TmPlayer: make(map[int32]*TmPlayer),
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
|
@ -307,6 +312,7 @@ func (tm *TmMatch) RobotGradesDecline(round int) {
|
||||||
copyLv: info.copyLv,
|
copyLv: info.copyLv,
|
||||||
copyRoleId: info.copyRoleId,
|
copyRoleId: info.copyRoleId,
|
||||||
CopySkinId: info.CopySkinId,
|
CopySkinId: info.CopySkinId,
|
||||||
|
rank: info.rank,
|
||||||
}
|
}
|
||||||
tm.robotGrades[lastRound][i] = gradeInfo
|
tm.robotGrades[lastRound][i] = gradeInfo
|
||||||
if info.copySnid != 0 {
|
if info.copySnid != 0 {
|
||||||
|
|
|
@ -154,8 +154,8 @@ func (this *Tournament) addFinalPlayer(sortId int64, p *PerRankInfo) {
|
||||||
this.finalPerRank[sortId] = append(this.finalPerRank[sortId], p)
|
this.finalPerRank[sortId] = append(this.finalPerRank[sortId], p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询一场比赛某轮的历史数据
|
// GetRoundPlayer 查询一场比赛某轮的历史数据
|
||||||
func (this *Tournament) getRoundPlayer(sortId int64, round int32) *PlayerRoundInfo {
|
func (this *Tournament) GetRoundPlayer(sortId int64, round int32) *PlayerRoundInfo {
|
||||||
_, ok := this.roundPlayers[sortId]
|
_, ok := this.roundPlayers[sortId]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil
|
return nil
|
||||||
|
@ -923,6 +923,59 @@ func (this *Tournament) getRank(sortId int64, round, snid int32, isFinals bool)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRank 获取排名
|
||||||
|
func (this *Tournament) GetRank(sortId int64, snid int32) int32 {
|
||||||
|
tm := this.GetTm(sortId)
|
||||||
|
if tm == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
round := this.GetRound(sortId)
|
||||||
|
useRobot := this.IsRobotOn(tm.gmd)
|
||||||
|
|
||||||
|
robotRankFunc := func(n int, snid int32) int32 {
|
||||||
|
rank := int32(0)
|
||||||
|
for _, v := range tm.robotGrades[n] {
|
||||||
|
if v.copySnid == snid {
|
||||||
|
return v.rank
|
||||||
|
}
|
||||||
|
if v.copySnid == 0 {
|
||||||
|
rank = v.rank
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rank
|
||||||
|
}
|
||||||
|
|
||||||
|
playerRankFunc := func(n int, snid int32) int32 {
|
||||||
|
d := this.GetRoundPlayer(sortId, int32(n))
|
||||||
|
if d != nil {
|
||||||
|
for _, v := range d.players {
|
||||||
|
if v.p.SnId == snid {
|
||||||
|
return v.rank
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d = this.GetRoundPlayer(sortId, int32(n-1))
|
||||||
|
if d != nil {
|
||||||
|
for _, v := range d.players {
|
||||||
|
if v.p.SnId == snid {
|
||||||
|
return v.rank
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
if round <= 1 {
|
||||||
|
return 0
|
||||||
|
} else {
|
||||||
|
if useRobot {
|
||||||
|
return robotRankFunc(int(round-1), snid)
|
||||||
|
} else {
|
||||||
|
return playerRankFunc(int(round-1), snid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// UpdateMatchInfo 玩家比赛结束 更新积分
|
// UpdateMatchInfo 玩家比赛结束 更新积分
|
||||||
func (this *Tournament) UpdateMatchInfo(p *Player, sortId int64, grade, isWin int32, matchRobotGrades map[int32]int32) {
|
func (this *Tournament) UpdateMatchInfo(p *Player, sortId int64, grade, isWin int32, matchRobotGrades map[int32]int32) {
|
||||||
logger.Logger.Tracef("UpdateMatchInfo: sortId:%v, grade:%v, isWin: %v, matchRobotGrades:%v", sortId, grade, isWin, matchRobotGrades)
|
logger.Logger.Tracef("UpdateMatchInfo: sortId:%v, grade:%v, isWin: %v, matchRobotGrades:%v", sortId, grade, isWin, matchRobotGrades)
|
||||||
|
@ -999,7 +1052,7 @@ func (this *Tournament) stopMatch(matchId int32, sortId int64) (isOver bool) {
|
||||||
// 开启机器人时使用
|
// 开启机器人时使用
|
||||||
func (this *Tournament) NextRoundStartSingle(sortId int64, playerCtx *PlayerMatchContext, matchRobotGrades map[int32]int32) {
|
func (this *Tournament) NextRoundStartSingle(sortId int64, playerCtx *PlayerMatchContext, matchRobotGrades map[int32]int32) {
|
||||||
logger.Logger.Tracef("NextRoundStartSingle 当前第 %v 轮", playerCtx.round)
|
logger.Logger.Tracef("NextRoundStartSingle 当前第 %v 轮", playerCtx.round)
|
||||||
info := this.getRoundPlayer(sortId, playerCtx.round)
|
info := this.GetRoundPlayer(sortId, playerCtx.round)
|
||||||
if info == nil {
|
if info == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1042,11 +1095,24 @@ func (this *Tournament) NextRoundStartSingle(sortId int64, playerCtx *PlayerMatc
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Slice(arr, func(i, j int) bool {
|
sort.Slice(arr, func(i, j int) bool {
|
||||||
|
if arr[i].grade == arr[j].grade { // 真人在前
|
||||||
|
if arr[i].copySnid == 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if arr[j].copySnid == 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
return arr[i].grade > arr[j].grade
|
return arr[i].grade > arr[j].grade
|
||||||
})
|
})
|
||||||
|
for k, v := range arr {
|
||||||
|
v.rank = int32(k + 1)
|
||||||
|
}
|
||||||
|
playerCtx.tm.robotGrades[int(round)] = arr
|
||||||
|
|
||||||
for _, info := range arr {
|
for _, info := range arr {
|
||||||
logger.Logger.Tracef("NextRoundStart_Single 本轮积分排名 Snid:%v Grade:%v copyLv:%v copyRoleId:%v", info.copySnid, info.grade, info.copyLv, info.copyRoleId)
|
logger.Logger.Tracef("NextRoundStart_Single 本轮积分排名 round:%v Snid:%v Grade:%v copyLv:%v copyRoleId:%v rank:%v",
|
||||||
|
playerCtx.round, info.copySnid, info.grade, info.copyLv, info.copyRoleId, info.rank)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取排名
|
// 获取排名
|
||||||
|
@ -1117,7 +1183,7 @@ func (this *Tournament) NextRoundStartSingle(sortId int64, playerCtx *PlayerMatc
|
||||||
// 关闭机器时使用
|
// 关闭机器时使用
|
||||||
func (this *Tournament) NextRoundStart(sortId int64, playerCtx *PlayerMatchContext) {
|
func (this *Tournament) NextRoundStart(sortId int64, playerCtx *PlayerMatchContext) {
|
||||||
logger.Logger.Tracef("NextRoundStart 当前第 %v 轮", playerCtx.round)
|
logger.Logger.Tracef("NextRoundStart 当前第 %v 轮", playerCtx.round)
|
||||||
info := this.getRoundPlayer(sortId, playerCtx.round)
|
info := this.GetRoundPlayer(sortId, playerCtx.round)
|
||||||
if info == nil {
|
if info == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1224,7 @@ func (this *Tournament) NextRoundStart(sortId int64, playerCtx *PlayerMatchConte
|
||||||
info.players = info.players[len(ps):]
|
info.players = info.players[len(ps):]
|
||||||
|
|
||||||
willOut := false
|
willOut := false
|
||||||
if promotionNum1 == this.getRoundPlayer(sortId, playerCtx.round-1).num {
|
if promotionNum1 == this.GetRoundPlayer(sortId, playerCtx.round-1).num {
|
||||||
// 最后一个人打完了,确定要淘汰的人
|
// 最后一个人打完了,确定要淘汰的人
|
||||||
willOut = true
|
willOut = true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1747,24 +1747,24 @@ func init() {
|
||||||
switch msg.DestroyType {
|
switch msg.DestroyType {
|
||||||
case 1: //删除所有空房间
|
case 1: //删除所有空房间
|
||||||
for _, s := range SceneMgrSingleton.scenes {
|
for _, s := range SceneMgrSingleton.scenes {
|
||||||
if !s.isPlatform(platform) {
|
if !s.IsPlatform(platform) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if s != nil && !s.deleting && len(s.players) == 0 {
|
if s != nil && !s.deleting && len(s.players) == 0 {
|
||||||
logger.Logger.Warnf("WebService SpecailEmptySceneId destroyroom scene:%v", s.sceneId)
|
logger.Logger.Warnf("WebService SpecailEmptySceneId destroyroom scene:%v", s.sceneId)
|
||||||
s.TryForceDelectMatchInfo()
|
s.TryForceDeleteMatchInfo()
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 2: //删除所有未开始的房间
|
case 2: //删除所有未开始的房间
|
||||||
for _, s := range SceneMgrSingleton.scenes {
|
for _, s := range SceneMgrSingleton.scenes {
|
||||||
if !s.isPlatform(platform) {
|
if !s.IsPlatform(platform) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if s != nil && !s.deleting && !s.starting && !s.IsHundredScene() {
|
if s != nil && !s.deleting && !s.starting && !s.IsHundredScene() {
|
||||||
logger.Logger.Warnf("WebService SpecailUnstartSceneId destroyroom scene:%v", s.sceneId)
|
logger.Logger.Warnf("WebService SpecailUnstartSceneId destroyroom scene:%v", s.sceneId)
|
||||||
s.TryForceDelectMatchInfo()
|
s.TryForceDeleteMatchInfo()
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default: //删除指定房间
|
default: //删除指定房间
|
||||||
|
@ -1780,14 +1780,14 @@ func init() {
|
||||||
pack.Msg = "the sceneid is nil"
|
pack.Msg = "the sceneid is nil"
|
||||||
return common.ResponseTag_NoFindRoom, pack
|
return common.ResponseTag_NoFindRoom, pack
|
||||||
}
|
}
|
||||||
if !s.isPlatform(platform) {
|
if !s.IsPlatform(platform) {
|
||||||
pack.Tag = webapiproto.TagCode_FAILED
|
pack.Tag = webapiproto.TagCode_FAILED
|
||||||
pack.Msg = "the sceneid is not ower platform"
|
pack.Msg = "the sceneid is not ower platform"
|
||||||
return common.ResponseTag_NoFindRoom, pack
|
return common.ResponseTag_NoFindRoom, pack
|
||||||
}
|
}
|
||||||
logger.Logger.Warnf("WebService destroyroom scene:%v", s.sceneId)
|
logger.Logger.Warnf("WebService destroyroom scene:%v", s.sceneId)
|
||||||
s.TryForceDelectMatchInfo()
|
s.TryForceDeleteMatchInfo()
|
||||||
s.DoDelete(false)
|
s.SendGameDelete(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return common.ResponseTag_Ok, pack
|
return common.ResponseTag_Ok, pack
|
||||||
|
|
Loading…
Reference in New Issue