parent
699596d022
commit
3526ef069f
|
@ -68,33 +68,30 @@ func init() {
|
|||
}))
|
||||
|
||||
//删除场景
|
||||
// 立刻删除,不管游戏是否结束
|
||||
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_DESTROYSCENE), netlib.PacketFactoryWrapper(func() interface{} {
|
||||
return &server.WGDestroyScene{}
|
||||
}))
|
||||
netlib.RegisterHandler(int(server.SSPacketID_PACKET_WG_DESTROYSCENE), netlib.HandlerWrapper(func(s *netlib.Session, packetid int, pack interface{}) error {
|
||||
logger.Logger.Trace("receive WGDestroyScene:", pack)
|
||||
if msg, ok := pack.(*server.WGDestroyScene); ok {
|
||||
sceneId := int(msg.GetSceneId())
|
||||
s := base.SceneMgrSington.GetScene(sceneId)
|
||||
if s != nil {
|
||||
if gameScene, ok := s.ExtraData.(base.GameScene); ok {
|
||||
gameScene.SceneDestroy(true)
|
||||
msg, ok := pack.(*server.WGDestroyScene)
|
||||
if !ok {
|
||||
return nil
|
||||
}
|
||||
if !msg.IsGrace {
|
||||
// 立刻删除,不管游戏是否结束
|
||||
for _, v := range msg.Ids {
|
||||
s := base.SceneMgrSington.GetScene(int(v))
|
||||
if s != nil {
|
||||
if gameScene, ok := s.ExtraData.(base.GameScene); ok {
|
||||
gameScene.SceneDestroy(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}))
|
||||
|
||||
//删除场景
|
||||
netlib.RegisterFactory(int(server.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), netlib.PacketFactoryWrapper(func() interface{} {
|
||||
return &server.WGGraceDestroyScene{}
|
||||
}))
|
||||
netlib.RegisterHandler(int(server.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), netlib.HandlerWrapper(func(s *netlib.Session, packetid int, pack interface{}) error {
|
||||
logger.Logger.Trace("receive WGGraceDestroyScene:", pack)
|
||||
if msg, ok := pack.(*server.WGGraceDestroyScene); ok {
|
||||
ids := msg.GetIds()
|
||||
for _, id := range ids {
|
||||
s := base.SceneMgrSington.GetScene(int(id))
|
||||
} else {
|
||||
// 游戏结束后删除房间
|
||||
for _, v := range msg.Ids {
|
||||
s := base.SceneMgrSington.GetScene(int(v))
|
||||
if s != nil {
|
||||
if s.IsHundredScene() || s.Gaming {
|
||||
s.SetGraceDestroy(true)
|
||||
|
@ -109,6 +106,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}))
|
||||
|
||||
|
|
|
@ -1046,8 +1046,8 @@ func (this *Scene) Destroy(force bool) {
|
|||
isCompleted := this.sp.IsCompleted(this) || this.completed
|
||||
SceneMgrSington.DestroyScene(this.SceneId)
|
||||
pack := &server.GWDestroyScene{
|
||||
SceneId: proto.Int(this.SceneId),
|
||||
IsCompleted: proto.Bool(isCompleted),
|
||||
SceneId: int64(this.SceneId),
|
||||
IsCompleted: isCompleted,
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
this.SendToWorld(int(server.SSPacketID_PACKET_GW_DESTROYSCENE), pack)
|
||||
|
|
|
@ -46,18 +46,8 @@ type GameParam struct {
|
|||
InvalidRobotAccRate int //每次更换过期机器人账号的比例,百分比
|
||||
InvalidRobotDay int //机器人过期的天数
|
||||
CreatePrivateSceneCnt int //每人可以创建私有房间数量
|
||||
PrivateSceneLogLimit int //私有房间日志上限
|
||||
PrivateSceneFreeDistroySec int //私有房间免费解散时间,默认600秒
|
||||
PrivateSceneDestroyTax int //私有房间提前解散税收,百分比
|
||||
NumOfGamesConfig []int32 //私人房间局数
|
||||
BacklogGameHorseRaceLamp int //游戏内公告储备多少条,超出丢弃
|
||||
IsRobFightTest bool //是否开启机器人自己对战功能
|
||||
BullFightCtrl0108 bool //牛牛是否使用新功能规则
|
||||
OpenPoolRec bool //是否打开水池数据记录
|
||||
CoinPoolMinOutRate int32 //水池最小出分
|
||||
CoinPoolMaxOutRate int32 //水池最大出分
|
||||
MaxRTP float64 //最大rtp
|
||||
AddRTP float64 //附加rtp
|
||||
PlayerWatchNum int32 //百人游戏允许围观的局数
|
||||
NotifyPlayerWatchNum int32 //百人游戏围观多少局的时候开始提示
|
||||
CgAddr string //后台cg工程地址
|
||||
|
@ -65,7 +55,6 @@ type GameParam struct {
|
|||
MaxAudienceNum int //最大观战人数
|
||||
IsFindRoomByGroup bool //查询房间列表时是否使用互通查询,默认是不使用
|
||||
NoOpTimes int32 //对战场允许托管的局数
|
||||
UseBevRobot bool //是否使用行为树机器人
|
||||
ClosePreCreateRoom bool //关闭予创建房间
|
||||
CloseQMThr bool //关闭全民三方流水计算
|
||||
ErrResetMongo bool //发生主从问题,是否重置连接
|
||||
|
@ -129,15 +118,6 @@ func InitGameParam() {
|
|||
if GameParamData.KickoutDefaultFreezeMinute == 0 {
|
||||
GameParamData.KickoutDefaultFreezeMinute = 5
|
||||
}
|
||||
|
||||
if GameParamData.MaxRTP <= 0.00001 {
|
||||
GameParamData.MaxRTP = 0.999999
|
||||
}
|
||||
|
||||
if GameParamData.AddRTP <= 0.00001 {
|
||||
GameParamData.AddRTP = 0.1
|
||||
}
|
||||
|
||||
mgo.SetDebug(GameParamData.MongoDebug)
|
||||
if GameParamData.RbAutoBalance {
|
||||
if GameParamData.RbAutoBalanceRate == 0 {
|
||||
|
@ -168,26 +148,6 @@ func InitGameParam() {
|
|||
if GameParamData.CreatePrivateSceneCnt == 0 {
|
||||
GameParamData.CreatePrivateSceneCnt = 20
|
||||
}
|
||||
if GameParamData.PrivateSceneLogLimit == 0 {
|
||||
GameParamData.PrivateSceneLogLimit = 7000
|
||||
}
|
||||
if GameParamData.PrivateSceneFreeDistroySec == 0 {
|
||||
GameParamData.PrivateSceneFreeDistroySec = 600
|
||||
}
|
||||
if GameParamData.PrivateSceneDestroyTax == 0 {
|
||||
GameParamData.PrivateSceneDestroyTax = 5
|
||||
}
|
||||
if len(GameParamData.NumOfGamesConfig) == 0 {
|
||||
GameParamData.NumOfGamesConfig = []int32{5, 10, 20, 50}
|
||||
}
|
||||
if GameParamData.CoinPoolMinOutRate == 0 {
|
||||
GameParamData.CoinPoolMinOutRate = 33
|
||||
}
|
||||
|
||||
if GameParamData.CoinPoolMaxOutRate == 0 {
|
||||
GameParamData.CoinPoolMaxOutRate = 66
|
||||
}
|
||||
|
||||
if GameParamData.PlayerWatchNum <= 2 {
|
||||
GameParamData.PlayerWatchNum = 20
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -42,7 +42,7 @@ enum SSPacketID {
|
|||
PACKET_WG_AUDIENCESIT = 1123;
|
||||
PACKET_WG_RECHARGE = 1124;
|
||||
PACKET_GW_SCENESTATE = 1125;
|
||||
PACKET_WG_GRACE_DESTROYSCENE = 1126;
|
||||
PACKET_WG_GRACE_DESTROYSCENE = 1126; // 废弃
|
||||
PACKET_GW_SCENEEND = 1127;
|
||||
PACKET_GW_FISHRECORD = 1128;
|
||||
PACKET_GW_PLAYERFORCELEAVE = 1129;
|
||||
|
@ -189,20 +189,16 @@ message WGCreateScene {
|
|||
|
||||
//PACKET_WG_DESTROYSCENE
|
||||
message WGDestroyScene {
|
||||
int32 SceneId = 1;
|
||||
bool IsCompleted = 2;
|
||||
repeated int64 Ids = 1;
|
||||
bool IsGrace = 2; // 游戏结束后删除
|
||||
}
|
||||
|
||||
//PACKET_GW_DESTROYSCENE
|
||||
message GWDestroyScene {
|
||||
int32 SceneId = 1;
|
||||
int64 SceneId = 1;
|
||||
bool IsCompleted = 2;
|
||||
}
|
||||
|
||||
//PACKET_WG_GRACE_DESTROYSCENE
|
||||
message WGGraceDestroyScene {
|
||||
repeated int32 Ids = 1;
|
||||
}
|
||||
message RebateTask {
|
||||
bool RebateSwitch = 1; //返利开关
|
||||
repeated string RebateGameCfg = 2; //已打开的游戏配置 gameid+gamemode
|
||||
|
|
|
@ -579,7 +579,7 @@ func (x *TMInfo) GetOnChannelName() []string {
|
|||
return nil
|
||||
}
|
||||
|
||||
//比赛场场次 激战人数刷新也走这个
|
||||
//比赛场场次
|
||||
//PACKET_TM_SCTMInfos
|
||||
type SCTMInfos struct {
|
||||
state protoimpl.MessageState
|
||||
|
|
|
@ -4025,7 +4025,7 @@ type GameMatchType struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Platform string `protobuf:"bytes,1,opt,name=Platform,proto3" json:"Platform,omitempty"`
|
||||
List []int32 `protobuf:"varint,2,rep,packed,name=List,proto3" json:"List,omitempty"`
|
||||
List []int32 `protobuf:"varint,2,rep,packed,name=List,proto3" json:"List,omitempty"` // 所有玩法类型 1.锦标赛 2.实物赛 3.vip比赛 4.话费赛
|
||||
}
|
||||
|
||||
func (x *GameMatchType) Reset() {
|
||||
|
|
|
@ -20,6 +20,13 @@ func init() {
|
|||
netlib.Register(int(gamehallproto.GameHallPacketID_PACKET_SC_QUITGAME), gamehallproto.SCQuitGame{}, SCQuitGame)
|
||||
}
|
||||
|
||||
func cleanRoomState(s *netlib.Session) {
|
||||
s.RemoveAttribute(SessionAttributeScene)
|
||||
s.RemoveAttribute(SessionAttributeSceneId)
|
||||
s.RemoveAttribute(SessionAttributeEnteringScene)
|
||||
s.RemoveAttribute(SessionAttributeEnteringMatchScene)
|
||||
}
|
||||
|
||||
func SCEnterRoom(s *netlib.Session, packid int, pack interface{}) error {
|
||||
logger.Logger.Trace("SCEnterRoom ", pack)
|
||||
msg, ok := pack.(*gamehallproto.SCEnterRoom)
|
||||
|
@ -44,10 +51,7 @@ func SCDestroyRoom(s *netlib.Session, packid int, pack interface{}) error {
|
|||
}
|
||||
|
||||
if msg.GetOpRetCode() == gamehallproto.OpResultCode_Game_OPRC_Sucess_Game {
|
||||
s.RemoveAttribute(SessionAttributeScene)
|
||||
s.RemoveAttribute(SessionAttributeSceneId)
|
||||
s.RemoveAttribute(SessionAttributeEnteringScene)
|
||||
s.RemoveAttribute(SessionAttributeEnteringMatchScene)
|
||||
cleanRoomState(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -72,10 +76,7 @@ func SCLeaveRoom(s *netlib.Session, packid int, pack interface{}) error {
|
|||
scene.DelPlayer(p.GetSnId())
|
||||
}
|
||||
}
|
||||
s.RemoveAttribute(SessionAttributeScene)
|
||||
s.RemoveAttribute(SessionAttributeSceneId)
|
||||
s.RemoveAttribute(SessionAttributeEnteringScene)
|
||||
s.RemoveAttribute(SessionAttributeEnteringMatchScene)
|
||||
cleanRoomState(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -118,10 +119,7 @@ func SCQuitGame(s *netlib.Session, packid int, pack interface{}) error {
|
|||
scene.DelPlayer(p.GetSnId())
|
||||
}
|
||||
}
|
||||
s.RemoveAttribute(SessionAttributeScene)
|
||||
s.RemoveAttribute(SessionAttributeSceneId)
|
||||
s.RemoveAttribute(SessionAttributeEnteringScene)
|
||||
s.RemoveAttribute(SessionAttributeEnteringMatchScene)
|
||||
cleanRoomState(s)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -1237,36 +1237,6 @@ func RefreshTransferThird2SystemTask(p *Player) {
|
|||
})
|
||||
}
|
||||
|
||||
type CSGetPrivateRoomHistoryPacketFactory struct {
|
||||
}
|
||||
type CSGetPrivateRoomHistoryHandler struct {
|
||||
}
|
||||
|
||||
func (this *CSGetPrivateRoomHistoryPacketFactory) CreatePacket() interface{} {
|
||||
pack := &gamehall.CSGetPrivateRoomHistory{}
|
||||
return pack
|
||||
}
|
||||
|
||||
func (this *CSGetPrivateRoomHistoryHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||
logger.Logger.Trace("CSGetPrivateRoomHistoryHandler Process recv ", data)
|
||||
if msg, ok := data.(*gamehall.CSGetPrivateRoomHistory); ok {
|
||||
p := PlayerMgrSington.GetPlayer(sid)
|
||||
if p == nil {
|
||||
logger.Logger.Warn("CSGetPrivateRoomHistoryHandler p == nil")
|
||||
return nil
|
||||
}
|
||||
|
||||
pps := PrivateSceneMgrSington.GetOrCreatePlayerPrivateScene(p)
|
||||
if pps == nil {
|
||||
logger.Logger.Warnf("CSGetPrivateRoomHistoryHandler PrivateSceneMgrSington.GetOrCreatePlayerPrivateScene(%v)", p.SnId)
|
||||
return nil
|
||||
}
|
||||
|
||||
pps.LoadLogs(p, msg.GetQueryTime())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CSQueryRoomInfoPacketFactory struct {
|
||||
}
|
||||
type CSQueryRoomInfoHandler struct {
|
||||
|
|
|
@ -260,7 +260,6 @@ func init() {
|
|||
scene.starting = msg.GetStart()
|
||||
scene.currRound = msg.GetCurrRound()
|
||||
scene.totalRound = msg.GetMaxRound()
|
||||
scene.lastTime = time.Now()
|
||||
if scene.starting {
|
||||
if scene.currRound == 1 {
|
||||
scene.startTime = time.Now()
|
||||
|
|
|
@ -8,13 +8,11 @@ import (
|
|||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/core/transact"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/proto"
|
||||
hall_proto "mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/game/protocol/server"
|
||||
server_proto "mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/game/srvdata"
|
||||
)
|
||||
|
@ -465,16 +463,15 @@ func (this *CoinSceneMgr) OnPlatformDestroy(p *Platform) {
|
|||
if p == nil {
|
||||
return
|
||||
}
|
||||
var ids []int
|
||||
if v, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
for _, csp := range v {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
for _, scene := range csp.scenes {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
// 房间中记录的有游服连接,广播的方式也可以
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
}
|
||||
}
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
|
||||
func (this *CoinSceneMgr) OnPlatformChangeDisabled(p *Platform, disabled bool) {
|
||||
|
@ -501,12 +498,11 @@ func (this *CoinSceneMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCfg *
|
|||
|
||||
if cps, ok := ss[newCfg.DbGameFree.Id]; ok {
|
||||
cps.dbGameFree = newCfg.DbGameFree
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
var ids []int
|
||||
for _, scene := range cps.scenes {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE),
|
||||
pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
this.TouchCreateRoom(p.IdStr, newCfg.DbGameFree.Id)
|
||||
}
|
||||
}
|
||||
|
@ -516,15 +512,15 @@ func (this *CoinSceneMgr) OnPlatformDestroyByGameFreeId(p *Platform, gameFreeId
|
|||
return
|
||||
}
|
||||
if csps, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
var ids []int
|
||||
for _, csp := range csps {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
for _, scene := range csp.scenes {
|
||||
if scene.dbGameFree.Id == gameFreeId {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
}
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -550,11 +546,11 @@ func (this *CoinSceneMgr) OnGameGroupUpdate(oldCfg, newCfg *webapi.GameConfigGro
|
|||
//TODO 预创建房间配置更新,unsupport group model
|
||||
cps.dbGameFree = newCfg.DbGameFree
|
||||
if needDestroy {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
var ids []int
|
||||
for _, scene := range cps.scenes {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,7 +349,7 @@ func (csp *CoinScenePool) OnPlayerLeave(s *Scene, p *Player) {
|
|||
// 玩家离开结算空房间的私人房
|
||||
if s.IsPrivateScene() {
|
||||
if s.IsEmpty() {
|
||||
s.ForceDelete(false)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ func (csp *CoinScenePool) OnPlayerLeave(s *Scene, p *Player) {
|
|||
}
|
||||
}
|
||||
if hasCnt > int(csp.dbGameFree.GetCreateRoomNum()) {
|
||||
s.ForceDelete(false)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,18 +2,18 @@ package main
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"time"
|
||||
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
gamehall_proto "mongo.games.com/game/protocol/gamehall"
|
||||
server_proto "mongo.games.com/game/protocol/server"
|
||||
"mongo.games.com/game/protocol/webapi"
|
||||
"mongo.games.com/game/srvdata"
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/core/module"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -555,11 +555,11 @@ func (this *HundredSceneMgr) OnPlatformDestroy(p *Platform) {
|
|||
return
|
||||
}
|
||||
if ss, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
var ids []int
|
||||
for _, scene := range ss {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -569,11 +569,11 @@ func (this *HundredSceneMgr) OnPlatformChangeIsolated(p *Platform, isolated bool
|
|||
this.OnPlatformCreate(p) //预创建场景
|
||||
} else {
|
||||
if ss, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
var ids []int
|
||||
for _, scene := range ss {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -585,11 +585,11 @@ func (this *HundredSceneMgr) OnPlatformChangeDisabled(p *Platform, disabled bool
|
|||
}
|
||||
if disabled {
|
||||
if ss, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
var ids []int
|
||||
for _, scene := range ss {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -600,25 +600,15 @@ func (this *HundredSceneMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCf
|
|||
}
|
||||
if oldCfg.GroupId != newCfg.GroupId || oldCfg.GroupId != 0 {
|
||||
if scenes, exist := this.scenesOfGroup[oldCfg.GroupId]; exist {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
if s, ok := scenes[newCfg.DbGameFree.Id]; ok {
|
||||
pack.Ids = append(pack.Ids, int32(s.sceneId))
|
||||
}
|
||||
if len(pack.Ids) > 0 {
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE),
|
||||
pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if scenes, exist := this.scenesOfPlatform[p.IdStr]; exist {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
if s, ok := scenes[newCfg.DbGameFree.Id]; ok {
|
||||
pack.Ids = append(pack.Ids, int32(s.sceneId))
|
||||
}
|
||||
if len(pack.Ids) > 0 {
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE),
|
||||
pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -639,9 +629,7 @@ func (this *HundredSceneMgr) OnGameGroupUpdate(oldCfg, newCfg *webapi.GameConfig
|
|||
needDestroy = true
|
||||
}
|
||||
if needDestroy {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
pack.Ids = append(pack.Ids, int32(s.sceneId))
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
SceneMgrSingleton.DoDelete([]int{s.sceneId}, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -726,13 +714,13 @@ func (this *HundredSceneMgr) OnPlatformDestroyByGameFreeId(p *Platform, gameFree
|
|||
return
|
||||
}
|
||||
if scenes, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
var ids []int
|
||||
for _, scene := range scenes {
|
||||
pack := &server_proto.WGGraceDestroyScene{}
|
||||
if scene.dbGameFree.Id == gameFreeId {
|
||||
pack.Ids = append(pack.Ids, int32(scene.sceneId))
|
||||
ids = append(ids, scene.sceneId)
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
}
|
||||
SceneMgrSingleton.DoDelete(ids, true)
|
||||
}
|
||||
}
|
||||
func init() {
|
||||
|
|
|
@ -177,7 +177,7 @@ func (ms *MatchSceneMgr) MatchStop(tm *TmMatch) {
|
|||
if SceneMgrSingleton.scenes != nil && tm != nil {
|
||||
for _, scene := range SceneMgrSingleton.scenes {
|
||||
if scene.IsMatchScene() && scene.matchId == tm.SortId {
|
||||
scene.ForceDelete(false)
|
||||
scene.DoDelete(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,334 +0,0 @@
|
|||
package main
|
||||
|
||||
//
|
||||
//import (
|
||||
// "mongo.games.com/game/common"
|
||||
// "mongo.games.com/game/proto"
|
||||
// "mongo.games.com/game/protocol/mngame"
|
||||
// server_proto "mongo.games.com/game/protocol/server"
|
||||
// webapi_proto "mongo.games.com/game/protocol/webapi"
|
||||
// "mongo.games.com/game/srvdata"
|
||||
// "mongo.games.com/goserver/core/logger"
|
||||
// "mongo.games.com/goserver/srvlib"
|
||||
// srvlibproto "mongo.games.com/goserver/srvlib/protocol"
|
||||
//)
|
||||
//
|
||||
//var MiniGameMgrSington = &MiniGameMgr{
|
||||
// //按平台管理
|
||||
// scenesOfPlatform: make(map[string]map[int32]*Scene),
|
||||
// //玩家当前打开的小游戏列表
|
||||
// playerGaming: make(map[int32]map[int32]*Scene),
|
||||
// matchAutoId: common.MiniGameSceneStartId,
|
||||
//}
|
||||
//
|
||||
//type MiniGameMgr struct {
|
||||
// BasePlayerListener
|
||||
// //按平台管理
|
||||
// scenesOfPlatform map[string]map[int32]*Scene
|
||||
// //玩家当前打开的小游戏列表
|
||||
// playerGaming map[int32]map[int32]*Scene
|
||||
// matchAutoId int
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) GenOneSceneId() int {
|
||||
// this.matchAutoId++
|
||||
// if this.matchAutoId > common.MiniGameSceneMaxId {
|
||||
// this.matchAutoId = common.MiniGameSceneStartId
|
||||
// }
|
||||
// return this.matchAutoId
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) PlayerEnter(p *Player, id int32) mngame.MNGameOpResultCode {
|
||||
// plt := p.GetPlatform()
|
||||
// s := this.GetScene(plt, id)
|
||||
// if s == nil {
|
||||
// return mngame.MNGameOpResultCode_MNGAME_OPRC_Error
|
||||
// }
|
||||
//
|
||||
// if !s.PlayerEnterMiniGame(p) {
|
||||
// return mngame.MNGameOpResultCode_MNGAME_OPRC_Error
|
||||
// }
|
||||
//
|
||||
// gamings, ok := this.playerGaming[p.SnId]
|
||||
// if !ok {
|
||||
// gamings = make(map[int32]*Scene)
|
||||
// this.playerGaming[p.SnId] = gamings
|
||||
// }
|
||||
// gamings[id] = s
|
||||
//
|
||||
// return mngame.MNGameOpResultCode_MNGAME_OPRC_Sucess
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) PlayerLeave(p *Player, id int32) mngame.MNGameOpResultCode {
|
||||
// plt := p.GetPlatform()
|
||||
// s := this.GetScene(plt, id)
|
||||
// if s == nil {
|
||||
// return mngame.MNGameOpResultCode_MNGAME_OPRC_Error
|
||||
// }
|
||||
//
|
||||
// if !s.PlayerLeaveMiniGame(p) {
|
||||
// return mngame.MNGameOpResultCode_MNGAME_OPRC_Error
|
||||
// }
|
||||
//
|
||||
// gamings, ok := this.playerGaming[p.SnId]
|
||||
// if ok {
|
||||
// delete(gamings, id)
|
||||
// }
|
||||
//
|
||||
// return mngame.MNGameOpResultCode_MNGAME_OPRC_Sucess
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) PlayerMsgDispatcher(p *Player, msg *mngame.CSMNGameDispatcher) {
|
||||
// plt := p.GetPlatform()
|
||||
// s := this.GetScene(plt, msg.GetId())
|
||||
// if s == nil {
|
||||
// logger.Logger.Errorf("MiniGameMgr.PlayerMsgDispatcher Can't find scene! plt:%v gameId:%v", plt, msg.GetId())
|
||||
// return
|
||||
// }
|
||||
//
|
||||
// //minigamesrv 重启容错
|
||||
// if !s.HasPlayer(p) {
|
||||
// this.PlayerEnter(p, msg.GetId())
|
||||
// }
|
||||
// s.RedirectMiniGameMsg(p, msg)
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) GetScene(p *Platform, id int32) *Scene {
|
||||
// scenes, ok := this.scenesOfPlatform[p.IdStr]
|
||||
// if !ok {
|
||||
// scenes = make(map[int32]*Scene)
|
||||
// this.scenesOfPlatform[p.IdStr] = scenes
|
||||
// }
|
||||
//
|
||||
// s, ok := scenes[id]
|
||||
// if !ok {
|
||||
// cfg := PlatformMgrSingleton.GetGameFree(p.IdStr, id)
|
||||
// if cfg != nil && cfg.Status && cfg.DbGameFree.GetGameType() == common.GameType_Mini {
|
||||
// s = this.CreateSceneByPlatform(p, cfg)
|
||||
// if s != nil {
|
||||
// scenes[cfg.DbGameFree.Id] = s
|
||||
// } else {
|
||||
// return nil
|
||||
// }
|
||||
// return s
|
||||
// } else {
|
||||
// return nil
|
||||
// }
|
||||
// } else {
|
||||
// return s
|
||||
// }
|
||||
// //return nil
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) CreateSceneByPlatform(p *Platform, cfg *webapi_proto.GameFree) *Scene {
|
||||
// sceneId := this.GenOneSceneId()
|
||||
// gameId := int(cfg.DbGameFree.GetGameId())
|
||||
// gs := GameSessMgrSington.GetMinLoadSess(gameId)
|
||||
// if gs == nil {
|
||||
// logger.Logger.Errorf("MiniGameMgr.CreateSceneByPlatform Get %v game min session failed.", gameId)
|
||||
// return nil
|
||||
// }
|
||||
// if gs != nil {
|
||||
// gameMode := cfg.DbGameFree.GetGameMode()
|
||||
// dbGameRule := srvdata.PBDB_GameRuleMgr.GetData(cfg.DbGameFree.GetGameRule())
|
||||
// params := dbGameRule.GetParams()
|
||||
// scene := SceneMgrSington.CreateScene(0, 0, sceneId, gameId, int(gameMode), common.SceneMode_Public, 1, -1, params,
|
||||
// gs, p, cfg.GroupId, cfg.DbGameFree, cfg.DbGameFree.Id)
|
||||
// if scene != nil {
|
||||
// scene.hallId = cfg.DbGameFree.Id
|
||||
// return scene
|
||||
// }
|
||||
// }
|
||||
// return nil
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlatformCreate(p *Platform) {
|
||||
// if p == nil {
|
||||
// return
|
||||
// }
|
||||
// scenes := make(map[int32]*Scene)
|
||||
// this.scenesOfPlatform[p.IdStr] = scenes
|
||||
//
|
||||
// gps := PlatformMgrSingleton.GetGameFrees(p.IdStr)
|
||||
// for _, v := range gps {
|
||||
// if v.Status && v.DbGameFree.GetGameType() == common.GameType_Mini {
|
||||
// s := this.CreateSceneByPlatform(p, v)
|
||||
// if s != nil {
|
||||
// scenes[v.DbGameFree.Id] = s
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlatformDestroy(p *Platform) {
|
||||
// if p == nil {
|
||||
// return
|
||||
// }
|
||||
// if scenes, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
// for _, s := range scenes {
|
||||
// pack := &server_proto.WGGraceDestroyScene{}
|
||||
// pack.Ids = append(pack.Ids, int32(s.sceneId))
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack)
|
||||
// }
|
||||
// delete(this.scenesOfPlatform, p.IdStr)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlatformChangeIsolated(p *Platform, isolated bool) {
|
||||
// if p == nil {
|
||||
// return
|
||||
// }
|
||||
// if !isolated {
|
||||
// this.OnPlatformDestroy(p)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlatformChangeDisabled(p *Platform, disabled bool) {
|
||||
// if p == nil {
|
||||
// return
|
||||
// }
|
||||
// if disabled {
|
||||
// this.OnPlatformDestroy(p)
|
||||
// } else {
|
||||
// this.OnPlatformCreate(p)
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlatformGameFreeUpdate(p *Platform, oldCfg, newCfg *webapi_proto.GameFree) {
|
||||
// if p == nil {
|
||||
// return
|
||||
// }
|
||||
// if scenes, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
// if oldCfg != nil {
|
||||
// if s, ok := scenes[oldCfg.DbGameFree.Id]; ok {
|
||||
// pack := &server_proto.WGGraceDestroyScene{}
|
||||
// pack.Ids = append(pack.Ids, int32(s.sceneId))
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack)
|
||||
// delete(scenes, oldCfg.DbGameFree.Id)
|
||||
// }
|
||||
// } else if newCfg != nil {
|
||||
// if newCfg.Status && newCfg.DbGameFree.GetGameType() == common.GameType_Mini {
|
||||
// s := this.CreateSceneByPlatform(p, newCfg)
|
||||
// if s != nil {
|
||||
// scenes[newCfg.DbGameFree.Id] = s
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnGameGroupUpdate(oldCfg, newCfg *webapi_proto.GameConfigGroup) {
|
||||
// //donothing
|
||||
//}
|
||||
//
|
||||
///*
|
||||
//获取platform下面对应的 player SnId所在的scene
|
||||
//*/
|
||||
//func (this *MiniGameMgr) GetAllSceneByPlayer(p *Player) map[int32]*Scene {
|
||||
// if gameingScenes, ok := this.playerGaming[p.SnId]; ok {
|
||||
// return gameingScenes
|
||||
// }
|
||||
// return nil
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlayerDropLine(p *Player) {
|
||||
// this.BasePlayerListener.OnPlayerDropLine(p)
|
||||
// if gamingScenes, ok := this.playerGaming[p.SnId]; ok {
|
||||
// for _, s := range gamingScenes {
|
||||
// pack := &server_proto.WGPlayerDropLine{
|
||||
// Id: proto.Int32(p.SnId),
|
||||
// SceneId: proto.Int(s.sceneId),
|
||||
// }
|
||||
// proto.SetDefaults(pack)
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERDROPLINE), pack)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlayerRehold(p *Player) {
|
||||
// this.BasePlayerListener.OnPlayerRehold(p)
|
||||
// var gateSid int64
|
||||
// if p.gateSess != nil {
|
||||
// if srvInfo, ok := p.gateSess.GetAttribute(srvlib.SessionAttributeServerInfo).(*srvlibproto.SSSrvRegiste); ok && srvInfo != nil {
|
||||
// sessionId := srvlib.NewSessionIdEx(srvInfo.GetAreaId(), srvInfo.GetType(), srvInfo.GetId(), 0)
|
||||
// gateSid = sessionId.Get()
|
||||
// }
|
||||
// }
|
||||
// if gamingScenes, ok := this.playerGaming[p.SnId]; ok {
|
||||
// for _, s := range gamingScenes {
|
||||
// pack := &server_proto.WGPlayerRehold{
|
||||
// Id: proto.Int32(p.SnId),
|
||||
// Sid: proto.Int64(p.sid),
|
||||
// SceneId: proto.Int(s.sceneId),
|
||||
// GateSid: proto.Int64(gateSid),
|
||||
// }
|
||||
// proto.SetDefaults(pack)
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERREHOLD), pack)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//func (this *MiniGameMgr) OnPlayerReturnScene(p *Player) {
|
||||
// this.BasePlayerListener.OnPlayerReturnScene(p)
|
||||
// if gameingScenes, ok := this.playerGaming[p.SnId]; ok {
|
||||
// for _, s := range gameingScenes {
|
||||
// pack := &server_proto.WGPlayerReturn{
|
||||
// PlayerId: p.SnId,
|
||||
// RoomId: int32(s.sceneId),
|
||||
// }
|
||||
// proto.SetDefaults(pack)
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_PLAYERRETURN), pack)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnDestroyScene(s *Scene) {
|
||||
//
|
||||
// if pltScenes, ok := this.scenesOfPlatform[s.limitPlatform.IdStr]; ok {
|
||||
// delete(pltScenes, s.dbGameFree.Id)
|
||||
// }
|
||||
//
|
||||
// for snid, _ := range s.players {
|
||||
// if scenes, ok := this.playerGaming[snid]; ok {
|
||||
// delete(scenes, s.dbGameFree.Id)
|
||||
// if len(scenes) == 0 {
|
||||
// delete(this.playerGaming, snid)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) ClrPlayerWhiteBlackState(p *Player) {
|
||||
// if gamings, ok := this.playerGaming[p.SnId]; ok {
|
||||
// for _, s := range gamings {
|
||||
// pack := &server_proto.WGSetPlayerBlackLevel{
|
||||
// SnId: proto.Int32(p.SnId),
|
||||
// SceneId: proto.Int32(int32(s.sceneId)),
|
||||
// ResetTotalCoin: proto.Bool(true),
|
||||
// }
|
||||
// proto.SetDefaults(pack)
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_GW_AUTORELIEVEWBLEVEL), pack)
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func (this *MiniGameMgr) OnPlatformDestroyByGameFreeId(p *Platform, gameFreeId int32) {
|
||||
// if p == nil {
|
||||
// return
|
||||
// }
|
||||
// if scenes, ok := this.scenesOfPlatform[p.IdStr]; ok {
|
||||
// for _, s := range scenes {
|
||||
// if s.dbGameFree.Id == gameFreeId {
|
||||
// pack := &server_proto.WGGraceDestroyScene{}
|
||||
// pack.Ids = append(pack.Ids, int32(s.sceneId))
|
||||
// s.SendToGame(int(server_proto.SSPacketID_PACKET_WG_GRACE_DESTROYSCENE), pack)
|
||||
// delete(scenes, gameFreeId)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//func init() {
|
||||
// RegistePlayerListener(MiniGameMgrSington)
|
||||
// PlatformMgrSingleton.RegisterObserver(MiniGameMgrSington)
|
||||
// PlatformGameGroupMgrSington.RegisterObserver(MiniGameMgrSington)
|
||||
//}
|
|
@ -1,276 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
"mongo.games.com/game/proto"
|
||||
hall_proto "mongo.games.com/game/protocol/gamehall"
|
||||
"mongo.games.com/goserver/core/basic"
|
||||
"mongo.games.com/goserver/core/task"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
PrivateSceneState_Deleting = iota //删除中
|
||||
PrivateSceneState_Deleted //已删除
|
||||
)
|
||||
|
||||
var PrivateSceneMgrSington = &PrivateSceneMgr{
|
||||
pps: make(map[int32]*PlayerPrivateScene),
|
||||
}
|
||||
|
||||
type PlayerPrivateScene struct {
|
||||
snid int32 // 玩家id
|
||||
creatorName string //创建人昵称
|
||||
platform string // 平台名称
|
||||
channel string // 渠道名称
|
||||
promoter string // 推广员
|
||||
packageTag string // 推广包标识
|
||||
scenes map[int]*Scene
|
||||
logsByDay map[int]*list.List
|
||||
dupLog map[string]struct{}
|
||||
loaded bool
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) AddScene(s *Scene) {
|
||||
pps.scenes[s.sceneId] = s
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) GetScene(sceneId int) *Scene {
|
||||
if s, exist := pps.scenes[sceneId]; exist {
|
||||
return s
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) GetCount() int {
|
||||
return len(pps.scenes)
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) CanDelete() bool {
|
||||
return !pps.loaded && len(pps.scenes) == 0
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) OnPlayerLogin(p *Player) {
|
||||
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) OnPlayerLogout(p *Player) {
|
||||
pps.logsByDay = nil
|
||||
pps.loaded = false
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) OnCreateScene(p *Player, s *Scene) {
|
||||
pps.scenes[s.sceneId] = s
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) LoadLogs(p *Player, yyyymmdd int32) {
|
||||
if !pps.loaded {
|
||||
var logs []*model.PrivateSceneLog
|
||||
var err error
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
logs, err = model.GetPrivateSceneLogBySnId(p.Platform, p.SnId, model.GameParamData.PrivateSceneLogLimit)
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||
if err == nil {
|
||||
pps.loaded = true
|
||||
pps.TidyLog(logs)
|
||||
pps.SendLogs(p, yyyymmdd)
|
||||
}
|
||||
}), "GetPrivateSceneLogBySnId").Start()
|
||||
} else {
|
||||
pps.SendLogs(p, yyyymmdd)
|
||||
}
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) TidyLog(logs []*model.PrivateSceneLog) {
|
||||
if pps.logsByDay == nil {
|
||||
pps.logsByDay = make(map[int]*list.List)
|
||||
}
|
||||
|
||||
for _, log := range logs {
|
||||
if _, exist := pps.dupLog[log.LogId.Hex()]; exist {
|
||||
continue
|
||||
}
|
||||
y, m, d := log.CreateTime.Date()
|
||||
day := y*10000 + int(m)*100 + d
|
||||
if lst, exist := pps.logsByDay[day]; exist {
|
||||
lst.PushBack(log)
|
||||
} else {
|
||||
lst = list.New()
|
||||
pps.logsByDay[day] = lst
|
||||
lst.PushBack(log)
|
||||
}
|
||||
}
|
||||
pps.dupLog = nil
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) SendLogs(p *Player, yyyymmdd int32) {
|
||||
pack := &hall_proto.SCGetPrivateRoomHistory{
|
||||
QueryTime: proto.Int32(yyyymmdd),
|
||||
}
|
||||
if logs, exist := pps.logsByDay[int(yyyymmdd)]; exist {
|
||||
for e := logs.Front(); e != nil; e = e.Next() {
|
||||
if log, ok := e.Value.(*model.PrivateSceneLog); ok {
|
||||
data := &hall_proto.PrivateRoomHistory{
|
||||
GameFreeId: proto.Int32(log.GameFreeId),
|
||||
RoomId: proto.Int32(log.SceneId),
|
||||
CreateTime: proto.Int32(int32(log.CreateTime.Unix())),
|
||||
DestroyTime: proto.Int32(int32(log.DestroyTime.Unix())),
|
||||
CreateFee: proto.Int32(log.CreateFee),
|
||||
}
|
||||
pack.Datas = append(pack.Datas, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
p.SendToClient(int(hall_proto.GameHallPacketID_PACKET_SC_GETPRIVATEROOMHISTORY), pack)
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) PushLog(log *model.PrivateSceneLog) {
|
||||
if log == nil {
|
||||
return
|
||||
}
|
||||
|
||||
y, m, d := log.CreateTime.Date()
|
||||
day := y*10000 + int(m)*100 + d
|
||||
if lst, exist := pps.logsByDay[day]; exist {
|
||||
lst.PushFront(log)
|
||||
} else {
|
||||
lst = list.New()
|
||||
pps.logsByDay[day] = lst
|
||||
lst.PushFront(log)
|
||||
}
|
||||
if !pps.loaded {
|
||||
pps.dupLog[log.LogId.Hex()] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
func (pps *PlayerPrivateScene) SendPrivateScenes(p *Player) {
|
||||
pack := &hall_proto.SCGetPrivateRoomList{}
|
||||
for sceneid, s := range pps.scenes {
|
||||
data := &hall_proto.PrivateRoomInfo{
|
||||
GameFreeId: proto.Int32(s.dbGameFree.GetId()),
|
||||
RoomId: proto.Int(sceneid),
|
||||
CurrRound: proto.Int32(s.currRound),
|
||||
MaxRound: proto.Int32(s.totalRound),
|
||||
CurrNum: proto.Int(len(s.players)),
|
||||
MaxPlayer: proto.Int(s.playerNum),
|
||||
CreateTs: proto.Int32(int32(s.createTime.Unix())),
|
||||
}
|
||||
pack.Datas = append(pack.Datas, data)
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
p.SendToClient(int(hall_proto.GameHallPacketID_PACKET_SC_GETPRIVATEROOMLIST), pack)
|
||||
}
|
||||
|
||||
type PrivateSceneMgr struct {
|
||||
pps map[int32]*PlayerPrivateScene
|
||||
}
|
||||
|
||||
func (psm *PrivateSceneMgr) GetOrCreatePlayerPrivateScene(p *Player) *PlayerPrivateScene {
|
||||
snid := p.SnId
|
||||
if pps, exist := psm.pps[snid]; exist {
|
||||
return pps
|
||||
}
|
||||
|
||||
pps := &PlayerPrivateScene{
|
||||
snid: snid,
|
||||
creatorName: p.Name,
|
||||
platform: p.Platform,
|
||||
channel: p.Channel,
|
||||
promoter: strconv.Itoa(int(p.PromoterTree)),
|
||||
packageTag: p.PackageID,
|
||||
scenes: make(map[int]*Scene),
|
||||
logsByDay: make(map[int]*list.List),
|
||||
dupLog: make(map[string]struct{}),
|
||||
}
|
||||
|
||||
psm.pps[snid] = pps
|
||||
return pps
|
||||
}
|
||||
|
||||
func (psm *PrivateSceneMgr) GetPlayerPrivateScene(snid int32) *PlayerPrivateScene {
|
||||
if pps, exist := psm.pps[snid]; exist {
|
||||
return pps
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (psm *PrivateSceneMgr) OnDestroyScene(scene *Scene) {
|
||||
if scene == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if !scene.IsPrivateScene() {
|
||||
return
|
||||
}
|
||||
|
||||
pps := psm.GetPlayerPrivateScene(scene.creator)
|
||||
if pps != nil {
|
||||
if pps.GetScene(scene.sceneId) == scene {
|
||||
delete(pps.scenes, scene.sceneId)
|
||||
var tax int32
|
||||
var returnCoin int32
|
||||
p := PlayerMgrSington.GetPlayerBySnId(scene.creator)
|
||||
|
||||
if scene.currRound == 0 && !scene.starting && scene.createFee > 0 { //未开始
|
||||
if scene.manualDelete && time.Now().Sub(scene.createTime) < time.Second*time.Duration(model.GameParamData.PrivateSceneFreeDistroySec) { //低于指定时间,要扣除部分费用
|
||||
tax = scene.createFee * int32(model.GameParamData.PrivateSceneDestroyTax) / 100
|
||||
returnCoin = scene.createFee - tax
|
||||
} else {
|
||||
returnCoin = scene.createFee
|
||||
}
|
||||
if returnCoin > 0 {
|
||||
if p != nil {
|
||||
var remark string
|
||||
if tax > 0 {
|
||||
remark = fmt.Sprintf("提前解散扣除费用%.02f", float32(tax)/100.0)
|
||||
}
|
||||
p.AddCoin(int64(returnCoin), 0, common.GainWay_PrivateSceneReturn, "", remark)
|
||||
} else {
|
||||
//TODO 发送邮件
|
||||
//sendClubMail_ClubCreateRoomRefund(scene.creator, scene.limitPlatform.Name, int32(scene.sceneId), int64(tax), int64(returnCoin))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if p != nil {
|
||||
pack := &hall_proto.SCDestroyPrivateRoom{
|
||||
OpRetCode: hall_proto.OpResultCode_Game_OPRC_Sucess_Game,
|
||||
RoomId: proto.Int(scene.sceneId),
|
||||
State: proto.Int(PrivateSceneState_Deleted),
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
p.SendToClient(int(hall_proto.GameHallPacketID_PACKET_SC_DESTROYPRIVATEROOM), pack)
|
||||
}
|
||||
|
||||
//写log
|
||||
log := model.NewPrivateSceneLog()
|
||||
if log != nil {
|
||||
log.SnId = pps.snid
|
||||
log.Platform = pps.platform
|
||||
log.Channel = pps.channel
|
||||
log.Promoter = pps.promoter
|
||||
log.GameFreeId = scene.dbGameFree.GetId()
|
||||
log.SceneId = int32(scene.sceneId)
|
||||
log.CreateTime = scene.createTime
|
||||
log.DestroyTime = time.Now()
|
||||
if returnCoin > 0 {
|
||||
log.CreateFee = tax
|
||||
} else {
|
||||
log.CreateFee = scene.createFee
|
||||
}
|
||||
//PrivateSceneLogChannelSington.Write(log)
|
||||
pps.PushLog(log)
|
||||
}
|
||||
|
||||
if pps.CanDelete() && p == nil {
|
||||
delete(psm.pps, scene.creator)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -92,7 +92,6 @@ type Scene struct {
|
|||
clubRoomPos int32 //
|
||||
clubRoomTax int32 //
|
||||
createFee int32 //创建房间的费用
|
||||
manualDelete bool //是否手动解散
|
||||
GameLog []int32 //游戏服务器同步的录单
|
||||
JackPotFund int64 //游戏服务器同步的奖池
|
||||
State int32 //当前游戏状态,后期放到ScenePolicy里去处理
|
||||
|
@ -503,6 +502,7 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
|||
enterTs: p.enterts.Unix(),
|
||||
totalConvertibleFlow: p.TotalConvertibleFlow,
|
||||
}
|
||||
this.lastTime = time.Now()
|
||||
}
|
||||
msg.TakeCoin = proto.Int64(takeCoin)
|
||||
msg.ExpectLeaveCoin = proto.Int64(leaveCoin)
|
||||
|
@ -552,7 +552,6 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
|||
proto.SetDefaults(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)
|
||||
this.lastTime = time.Now()
|
||||
FirePlayerEnterScene(p, this)
|
||||
return true
|
||||
} else {
|
||||
|
@ -603,8 +602,9 @@ func (this *Scene) PlayerLeave(p *Player, reason int) {
|
|||
|
||||
// 玩家最后所在游戏
|
||||
p.LastGameId = int(this.dbGameFree.GetGameId())
|
||||
|
||||
this.lastTime = time.Now()
|
||||
if !p.IsRob {
|
||||
this.lastTime = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Scene) DelPlayer(p *Player) bool {
|
||||
|
@ -701,6 +701,7 @@ func (this *Scene) AudienceEnter(p *Player, ischangeroom bool) bool {
|
|||
enterTs: p.enterts.Unix(),
|
||||
totalConvertibleFlow: p.TotalConvertibleFlow,
|
||||
}
|
||||
this.lastTime = time.Now()
|
||||
}
|
||||
|
||||
takeCoin := p.Coin
|
||||
|
@ -709,7 +710,6 @@ func (this *Scene) AudienceEnter(p *Player, ischangeroom bool) bool {
|
|||
proto.SetDefaults(msg)
|
||||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_AUDIENCEENTER), msg)
|
||||
p.enterts = time.Now()
|
||||
this.lastTime = time.Now()
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,9 @@ func (this *Scene) AudienceLeave(p *Player, reason int) {
|
|||
p.SendToClient(int(hallproto.GameHallPacketID_PACKET_SC_LEAVEROOM), pack)
|
||||
//观众直接从房间退出来
|
||||
this.DelAudience(p)
|
||||
this.lastTime = time.Now()
|
||||
if !p.IsRob {
|
||||
this.lastTime = time.Now()
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Scene) DelAudience(p *Player) bool {
|
||||
|
@ -808,12 +810,6 @@ func (this *Scene) AudienceSit(p *Player, pos int) bool {
|
|||
p.scene = this
|
||||
this.players[p.SnId] = p
|
||||
|
||||
//NpcServerAgentSington.OnPlayerEnterScene(this, p)
|
||||
if this.IsCoinScene() {
|
||||
//CoinSceneMgrSingleton.OnPlayerEnter(p, this.dbGameFree.GetId())
|
||||
} else if this.IsHallScene() {
|
||||
|
||||
}
|
||||
msg := &serverproto.WGAudienceSit{
|
||||
SnId: proto.Int32(p.SnId),
|
||||
SceneId: proto.Int(this.sceneId),
|
||||
|
@ -823,7 +819,9 @@ func (this *Scene) AudienceSit(p *Player, pos int) bool {
|
|||
msg.TakeCoin = proto.Int64(p.Coin)
|
||||
proto.SetDefaults(msg)
|
||||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_AUDIENCESIT), msg)
|
||||
this.lastTime = time.Now()
|
||||
if !p.IsRob {
|
||||
this.lastTime = time.Now()
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -935,23 +933,24 @@ func (this *Scene) BilledRoomCard(snid []int32) {
|
|||
|
||||
func (this *Scene) IsLongTimeInactive() bool {
|
||||
tNow := time.Now()
|
||||
//删除超过指定不活跃时间的房间
|
||||
if len(this.players) == 0 && tNow.Sub(this.lastTime) > time.Second*time.Duration(model.GameParamData.SceneMaxIdle) {
|
||||
// 房间没有真人,没有观众,长时间没有真人进出房间
|
||||
if this.GetTruePlayerCnt() == 0 && this.GetAudienceCnt() == 0 && tNow.Sub(this.lastTime) > time.Second*time.Duration(model.GameParamData.SceneMaxIdle) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *Scene) ForceDelete(isManual bool) {
|
||||
this.manualDelete = isManual
|
||||
this.deleting = true
|
||||
this.force = true
|
||||
pack := &serverproto.WGDestroyScene{
|
||||
SceneId: proto.Int(this.sceneId),
|
||||
func (this *Scene) DoDelete(isGrace bool) {
|
||||
if !isGrace {
|
||||
this.deleting = true
|
||||
this.force = true
|
||||
}
|
||||
pack := &serverproto.WGDestroyScene{
|
||||
Ids: []int64{int64(this.sceneId)},
|
||||
IsGrace: isGrace,
|
||||
}
|
||||
proto.SetDefaults(pack)
|
||||
this.SendToGame(int(serverproto.SSPacketID_PACKET_WG_DESTROYSCENE), pack)
|
||||
logger.Logger.Warnf("(this *Scene) ForceDelete() sceneid=%v", this.sceneId)
|
||||
logger.Logger.Tracef("WG_DESTROYSCENE: %v", pack)
|
||||
}
|
||||
|
||||
func (this *Scene) Shutdown() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"sort"
|
||||
|
||||
"mongo.games.com/goserver/core/logger"
|
||||
"mongo.games.com/goserver/srvlib"
|
||||
|
||||
"mongo.games.com/game/common"
|
||||
"mongo.games.com/game/model"
|
||||
|
@ -351,6 +352,26 @@ func (m *SceneMgr) OnPlayerLeaveScene(s *Scene, p *Player) {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *SceneMgr) DoDelete(sceneId []int, isGrace bool) {
|
||||
if len(sceneId) == 0 {
|
||||
return
|
||||
}
|
||||
var ids []int64
|
||||
for _, v := range sceneId {
|
||||
ids = append(ids, int64(v))
|
||||
s, ok := m.scenes[v]
|
||||
if !isGrace && ok && s != nil {
|
||||
s.deleting = true
|
||||
s.force = true
|
||||
}
|
||||
}
|
||||
pack := &serverproto.WGDestroyScene{
|
||||
Ids: ids,
|
||||
IsGrace: isGrace,
|
||||
}
|
||||
srvlib.ServerSessionMgrSington.Broadcast(int(serverproto.SSPacketID_PACKET_WG_DESTROYSCENE), pack, common.GetSelfAreaId(), srvlib.GameServerType)
|
||||
}
|
||||
|
||||
// GetThirdScene 获取三方游戏房间
|
||||
//func (m *SceneMgr) GetThirdScene(i webapi.IThirdPlatform) *Scene {
|
||||
// if i == nil {
|
||||
|
@ -393,18 +414,18 @@ func (m *SceneMgr) OnMiniTimer() {
|
|||
case s.IsCoinScene():
|
||||
if s.IsLongTimeInactive() {
|
||||
if s.dbGameFree.GetCreateRoomNum() == 0 {
|
||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene ForceDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||
s.ForceDelete(false)
|
||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene DoDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
if s.dbGameFree.GetCreateRoomNum() > 0 && s.csp != nil && s.csp.GetRoomNum() > int(s.dbGameFree.GetCreateRoomNum()) {
|
||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene ForceDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||
s.ForceDelete(false)
|
||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive CoinScene DoDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
case s.IsPrivateScene():
|
||||
if s.IsLongTimeInactive() {
|
||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive PrivateScene ForceDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||
s.ForceDelete(false)
|
||||
logger.Logger.Warnf("SceneMgr.DeleteLongTimeInactive PrivateScene DoDelete scene:%v IsLongTimeInactive", s.sceneId)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,9 +179,7 @@ func (spd *ScenePolicyData) OnPlayerLeave(s *Scene, p *Player) {
|
|||
|
||||
// 系统维护关闭事件
|
||||
func (spd *ScenePolicyData) OnShutdown(s *Scene) {
|
||||
if s.IsPrivateScene() {
|
||||
PrivateSceneMgrSington.OnDestroyScene(s)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 获得场景的匹配因子(值越大越优先选择)
|
||||
|
|
|
@ -2394,7 +2394,7 @@ func init() {
|
|||
if s != nil && !s.deleting && len(s.players) == 0 {
|
||||
logger.Logger.Warnf("WebService SpecailEmptySceneId destroyroom scene:%v", s.sceneId)
|
||||
s.TryForceDelectMatchInfo()
|
||||
s.ForceDelete(false)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
case 2: //删除所有未开始的房间
|
||||
|
@ -2405,7 +2405,7 @@ func init() {
|
|||
if s != nil && !s.deleting && !s.starting && !s.IsHundredScene() {
|
||||
logger.Logger.Warnf("WebService SpecailUnstartSceneId destroyroom scene:%v", s.sceneId)
|
||||
s.TryForceDelectMatchInfo()
|
||||
s.ForceDelete(false)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
default: //删除指定房间
|
||||
|
@ -2428,7 +2428,7 @@ func init() {
|
|||
}
|
||||
logger.Logger.Warnf("WebService destroyroom scene:%v", s.sceneId)
|
||||
s.TryForceDelectMatchInfo()
|
||||
s.ForceDelete(false)
|
||||
s.DoDelete(false)
|
||||
}
|
||||
}
|
||||
return common.ResponseTag_Ok, pack
|
||||
|
|
Loading…
Reference in New Issue