From 33380d1bf8ae20930cf78300b7828fccc8e6eb3a Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 5 Sep 2024 16:02:50 +0800 Subject: [PATCH 01/23] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/transact/trascate_gamesrv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gamesrv/transact/trascate_gamesrv.go b/gamesrv/transact/trascate_gamesrv.go index 1cdca9d..a56fc1a 100644 --- a/gamesrv/transact/trascate_gamesrv.go +++ b/gamesrv/transact/trascate_gamesrv.go @@ -106,7 +106,7 @@ func init() { if err != nil { pack.Tag = webapiproto.TagCode_FAILED pack.Msg = "数据序列化失败" - return common.ResponseTag_ParamError, pack + return common.ResponseTag_Ok, pack } pack.Tag = webapiproto.TagCode_SUCCESS @@ -114,7 +114,7 @@ func init() { if scene == nil || scene.ExtraData == nil { pack.Tag = webapiproto.TagCode_NotFound pack.Msg = "房间没找到" - return common.ResponseTag_NoFindRoom, pack + return common.ResponseTag_Ok, pack } switch d := scene.ExtraData.(type) { From c4bea18f9f6cbd3d75142a9770e2cdcb258cc89a Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 5 Sep 2024 18:31:04 +0800 Subject: [PATCH 02/23] =?UTF-8?q?=E9=81=93=E5=85=B7=E4=BA=A4=E6=98=93?= =?UTF-8?q?=E5=B8=82=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/constant.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/constant.go b/common/constant.go index c43faf4..ba96eb7 100644 --- a/common/constant.go +++ b/common/constant.go @@ -316,6 +316,7 @@ const ( GainWayVipGift9 = 105 //vip等级礼包 GainWayRoomCost = 106 //房费消耗 GainWayRoomGain = 107 //房卡场获得 + GainWayItemShop = 108 // 交易市场道具交易 ) // 后台选择 金币变化类型 的充值 类型id号起始 From fccb385f79e0a289ec7cde9701302ecf4e700168 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Thu, 5 Sep 2024 18:47:21 +0800 Subject: [PATCH 03/23] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E9=A6=86=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E9=85=8D=E7=BD=AE=E5=8C=85=E7=B1=BB=E5=9E=8B=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/config.go | 9 +++++++-- worldsrv/action_game.go | 6 +++++- worldsrv/playernotify.go | 35 ++++++++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/model/config.go b/model/config.go index e569e0c..622469d 100644 --- a/model/config.go +++ b/model/config.go @@ -1,12 +1,13 @@ package model import ( - "mongo.games.com/game/protocol/gamehall" + "slices" "strconv" "mongo.games.com/goserver/core/logger" "mongo.games.com/game/common" + "mongo.games.com/game/protocol/gamehall" "mongo.games.com/game/protocol/shop" "mongo.games.com/game/protocol/webapi" ) @@ -425,7 +426,7 @@ func (cm *ConfigMgr) DelRoomConfig(plt string, id int32) { delete(cm.GetConfig(plt).RoomConfig, id) } -func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig { +func (cm *ConfigMgr) GetRoomConfig(plt string, lastChannel string) *gamehall.SCRoomConfig { pack := &gamehall.SCRoomConfig{} for _, v := range cm.GetConfig(plt).RoomType { if v.GetOn() != common.On { @@ -436,6 +437,10 @@ func (cm *ConfigMgr) GetRoomConfig(plt string) *gamehall.SCRoomConfig { if vv.GetOn() != common.On { continue } + if lastChannel != "" && !slices.Contains(vv.GetOnChannelName(), lastChannel) { + continue + } + var cost, reward []*gamehall.ItemInfo for _, item := range vv.GetCost() { cost = append(cost, &gamehall.ItemInfo{ diff --git a/worldsrv/action_game.go b/worldsrv/action_game.go index 7785ce8..61e09b8 100644 --- a/worldsrv/action_game.go +++ b/worldsrv/action_game.go @@ -1168,7 +1168,7 @@ func CSRoomConfigHandler(s *netlib.Session, packetId int, data interface{}, sid return nil } - pack := PlatformMgrSingleton.GetRoomConfig(p.Platform) + pack := PlatformMgrSingleton.GetRoomConfig(p.Platform, p.LastChannel) p.SendToClient(int(gamehall.GameHallPacketID_PACKET_SCRoomConfig), pack) logger.Logger.Tracef("SCRoomConfig: %v", pack) return nil @@ -1202,6 +1202,10 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{ send() return nil } + if !slices.Contains(cfg.GetOnChannelName(), p.LastChannel) { + send() + return nil + } // 场次 if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) { send() diff --git a/worldsrv/playernotify.go b/worldsrv/playernotify.go index e944769..29f2829 100644 --- a/worldsrv/playernotify.go +++ b/worldsrv/playernotify.go @@ -1,11 +1,13 @@ package main import ( + "slices" "time" "mongo.games.com/goserver/core/logger" "mongo.games.com/game/common" + "mongo.games.com/game/protocol/gamehall" ) func init() { @@ -76,7 +78,34 @@ func (p *PlayerNotify) GetPlayers(tp common.NotifyType) []int32 { // SendToClient 发送消息给客户端 // tp 消息类型 func (p *PlayerNotify) SendToClient(tp common.NotifyType, packetId int, pack interface{}) { - ids := p.GetPlayers(tp) - PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack) - logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids) + switch tp { + case common.NotifyPrivateRoomList: + d := pack.(*gamehall.SCGetPrivateRoomList) + if len(d.GetDatas()) == 0 { + return + } + scene := SceneMgrSingleton.GetScene(int(d.GetDatas()[0].GetRoomId())) + if scene == nil { + return + } + roomConfigId := d.GetDatas()[0].GetRoomConfigId() + cfg := PlatformMgrSingleton.GetConfig(scene.limitPlatform.IdStr).RoomConfig[roomConfigId] + if cfg == nil { + return + } + + var ids []int32 + for _, v := range p.GetPlayers(tp) { + player := PlayerMgrSington.GetPlayerBySnId(v) + if player == nil { + continue + } + if slices.Contains(cfg.GetOnChannelName(), player.LastChannel) { + ids = append(ids, v) + } + } + + PlayerMgrSington.BroadcastMessageToTarget(ids, packetId, pack) + logger.Logger.Tracef("PlayerNotify SendToClient tp:%v ids:%v", tp, ids) + } } From 8f59f4d03acf37db5e2df8464a684f3c2205d016 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 09:41:41 +0800 Subject: [PATCH 04/23] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E6=8A=93?= =?UTF-8?q?=E5=8F=96=E5=90=8E=E7=BB=93=E6=9E=9C=E9=80=9A=E7=9F=A5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamerule/clawdoll/constants.go | 4 ++++ gamesrv/clawdoll/action_clawdoll.go | 24 +++++++++++++++++++++--- gamesrv/clawdoll/player_clawdoll.go | 24 +++++++++++++++++++++++- gamesrv/clawdoll/scenepolicy_clawdoll.go | 12 +----------- 4 files changed, 49 insertions(+), 15 deletions(-) diff --git a/gamerule/clawdoll/constants.go b/gamerule/clawdoll/constants.go index e855368..8c0386f 100644 --- a/gamerule/clawdoll/constants.go +++ b/gamerule/clawdoll/constants.go @@ -71,3 +71,7 @@ const ( Zego_ForbidRTCStream = iota + 1 Zego_ResumeRTCStream = iota + 1 ) + +const ( + ClawDoorItemID = 40003 +) diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index bd83ddc..9affeb7 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -2,6 +2,7 @@ package clawdoll import ( "mongo.games.com/game/common" + rule "mongo.games.com/game/gamerule/clawdoll" "mongo.games.com/game/gamesrv/base" "mongo.games.com/game/protocol/clawdoll" "mongo.games.com/game/protocol/machine" @@ -52,10 +53,20 @@ func (h *CSPlayerOpHandler) Process(s *netlib.Session, packetid int, data interf func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data interface{}) error { logger.Logger.Tracef("收到返回上分结果!!!!!!!!!!") if msg, ok := data.(*machine.MSDollMachineoPerateResult); ok { - p := base.PlayerMgrSington.GetPlayerBySnId(msg.GetSnid()) if p == nil { - logger.Logger.Warn("CSGetTokenHandler p == nil") + logger.Logger.Warn("MSDollMachineoCoinResultHandler p == nil") + return nil + } + + s := p.GetScene() + if s == nil { + logger.Logger.Warn("MSDollMachineoCoinResultHandler p.scene == nil") + return nil + } + + sceneEx, ok := s.ExtraData.(*SceneEx) + if !ok { return nil } @@ -68,10 +79,17 @@ func MSDollMachineoCoinResultHandler(session *netlib.Session, packetId int, data } case 2: if msg.Result == 1 { - + // 获得娃娃卡 + logger.Logger.Tracef("下抓成功!!!!!!!!!!!!snid = ", msg.Snid) } else { logger.Logger.Tracef("下抓失败!!!!!!!!!!!!snid = ", msg.Snid) } + + s.ChangeSceneState(rule.ClawDollSceneStateBilled) + sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) + + ClawdollBroadcastRoomState(s) + ClawdollSendPlayerInfo(s) } } return nil diff --git a/gamesrv/clawdoll/player_clawdoll.go b/gamesrv/clawdoll/player_clawdoll.go index 2fb434e..3dd7af7 100644 --- a/gamesrv/clawdoll/player_clawdoll.go +++ b/gamesrv/clawdoll/player_clawdoll.go @@ -1,7 +1,9 @@ package clawdoll import ( + rule "mongo.games.com/game/gamerule/clawdoll" "mongo.games.com/game/gamesrv/base" + "mongo.games.com/game/srvdata" "mongo.games.com/goserver/core/logger" ) @@ -37,11 +39,18 @@ func (this *PlayerEx) CanOp(sceneEx *SceneEx) bool { // 能否投币 func (this *PlayerEx) CanPayCoin() bool { + + itemID := int32(rule.ClawDoorItemID) + itemData := srvdata.GameItemMgr.Get(this.Platform, itemID) + if itemData == nil { + return false + } + return true } // 投币消耗 -func (this *PlayerEx) CostPlayCoin() bool { +func (this *PlayerEx) CostPlayCoin(count int32) bool { return true } @@ -106,3 +115,16 @@ func (this *PlayerEx) GetClawState() int32 { func (this *PlayerEx) SetClawState(state int32) { this.clawDollState = state } + +func (this *PlayerEx) GetItemCount(itemID int32) int64 { + itemData := srvdata.GameItemMgr.Get(this.Platform, itemID) + if itemData != nil { + v, ok := this.Items[itemID] + if ok { + return v + } else { + return 0 + } + } + return 0 +} diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index f00ad1f..664e238 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -67,6 +67,7 @@ func (this *PolicyClawdoll) OnTick(s *base.Scene) { sceneEx, ok := s.ExtraData.(*SceneEx) if ok { if sceneEx.machineId == 0 { + //machineId := s.DBGameFree.GetId() % 6080000 sceneEx.machineId = action.GetFreeDollMachineId() } if sceneEx.machineId != 0 { @@ -666,12 +667,6 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para //1-弱力抓 2 -强力抓 sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), grapType) - s.ChangeSceneState(rule.ClawDollSceneStateBilled) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) - case rule.ClawDollPlayerOpMove: if !sceneEx.CheckMoveOp(playerEx) { @@ -702,11 +697,6 @@ func (this *PlayGame) OnTick(s *base.Scene) { logger.Logger.Trace("PlayGame OnTick TimeOutPlayGrab SnId", sceneEx.playingSnid, " machineId:", sceneEx.machineId) } - s.ChangeSceneState(rule.ClawDollSceneStateBilled) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) return } } From 9963ef130ae66f4707afa64c2156ca8c9497f599 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 09:43:14 +0800 Subject: [PATCH 05/23] public --- public | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public b/public index 06da9b3..00b9fce 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit 06da9b31abec96f3936877d7d73069e9852781ff +Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 From 40966b52cbb2048918c3c1e6c812a8554f1c1220 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 09:50:19 +0800 Subject: [PATCH 06/23] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E9=A6=86=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/action_game.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/worldsrv/action_game.go b/worldsrv/action_game.go index 61e09b8..de81b77 100644 --- a/worldsrv/action_game.go +++ b/worldsrv/action_game.go @@ -1206,18 +1206,32 @@ func CSCreatePrivateRoomHandler(s *netlib.Session, packetId int, data interface{ send() return nil } + + f := func(param []int32) []int32 { + if len(param) == 0 { + return nil + } + if param[0] == 0 { + return param[1:] + } + if param[0] > 0 && int(param[0]) < len(param) { + return []int32{param[param[0]]} + } + return nil + } + // 场次 - if !slices.Contains(cfg.GetGameFreeId(), msg.GetGameFreeId()) { + if !slices.Contains(f(cfg.GetGameFreeId()), msg.GetGameFreeId()) { send() return nil } // 局数 - if !slices.Contains(cfg.GetRound(), msg.GetRound()) { + if !slices.Contains(f(cfg.GetRound()), msg.GetRound()) { send() return nil } // 玩家数量 - if !slices.Contains(cfg.GetPlayerNum(), msg.GetPlayerNum()) { + if !slices.Contains(f(cfg.GetPlayerNum()), msg.GetPlayerNum()) { send() return nil } From 979645567ef02272136d678fc1e30c0a75c8bae9 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 10:08:29 +0800 Subject: [PATCH 07/23] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/clawdoll/scenepolicy_clawdoll.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index f00ad1f..b9ad90d 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -67,7 +67,8 @@ func (this *PolicyClawdoll) OnTick(s *base.Scene) { sceneEx, ok := s.ExtraData.(*SceneEx) if ok { if sceneEx.machineId == 0 { - sceneEx.machineId = action.GetFreeDollMachineId() + machineId := s.DBGameFree.GetId() % 6080000 + sceneEx.machineId = action.GetFreeDollMachineId(machineId) } if sceneEx.machineId != 0 { machineStatus := action.GetDollMachineStatus(sceneEx.machineId) From 32e8b2f22e021e6b4ba7335c4b9553942abeb6a6 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 10:01:10 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E6=88=BF=E5=8D=A1=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=8A=A0=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/config.go | 2 +- worldsrv/shopmgr.go | 57 ++++++++++++++------------------------------- 2 files changed, 19 insertions(+), 40 deletions(-) diff --git a/model/config.go b/model/config.go index 622469d..568775e 100644 --- a/model/config.go +++ b/model/config.go @@ -77,7 +77,7 @@ func (this *ShopInfo) GetItems() []ItemInfo { if this.ItemId > 0 { ret = append(ret, ItemInfo{ ItemId: this.ItemId, - ItemNum: this.Amount, + ItemNum: this.AmountFinal, }) } for _, v := range this.AddItemInfo { diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index a296bee..1fdf0d2 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -44,14 +44,15 @@ const ( // page类型 const ( - ShopPageCoin = 1 //金币页面 - ShopPageDiamond = 2 //钻石页面 - ShopPageItem = 3 //道具页面 - ShopPageVip = 4 //VIP页面 - ShopPagePrivilege = 5 //VIP特权礼包 - ShopPageGift = 7 //礼包页面 - ShopPageDiamondBank = 8 //钻石存储罐 - ShopPagePermit = 9 //赛季通行证 + ShopPageCoin = 1 //金币页面 + ShopPageDiamond = 2 //钻石页面 + ShopPageItem = 3 //道具页面 + ShopPageVip = 4 //VIP页面 + ShopPagePrivilege = 5 //VIP特权礼包 + ShopPageGift = 7 //礼包页面 + ShopPageDiamondBank = 8 //钻石存储罐 + ShopPagePermit = 9 //赛季通行证 + ShopPageFangKa = 10 //房卡页面 ShopPagePhoneScore = 61 //手机积分商城 ShopPagePhoneScoreGoogle = 62 @@ -646,6 +647,7 @@ func (this *ShopMgr) GetAmountFinal(p *Player, shopId, vipShopId int32) int64 { } } default: + addTotal += addNormal } return addTotal } @@ -1197,37 +1199,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, var amount [ShopTypeItem]int32 var dbShop *model.DbShop if shopInfo, ok := data.(*model.ShopInfo); ok { - // 目前现金只能买钻石 - var addTotal = int64(shopInfo.Amount) - added := rand.Int31n(shopInfo.AddArea[1]-shopInfo.AddArea[0]+1) + shopInfo.AddArea[0] costNum := rand.Int31n(shopInfo.CostArea[1]-shopInfo.CostArea[0]+1) + shopInfo.CostArea[0] - /* if shopInfo.Page == ShopPageVip { - //暂时这样修改 VIP礼包没有现金支付 - shopData := p.GetVipShopData(shopInfo.Id, 0) - if shopData != nil { - added = shopData.AddArea - costNum = shopData.CostArea - } - }*/ - vipAdded := int32(0) - if shopInfo.Page == ShopPageDiamond { - //vip加成 - vipAdded = VipMgrSington.GetVipDiamondExtra(p.Platform, p.VIP) - logger.Logger.Tracef("商城钻石购买,vip加成 vipAdded = %v", vipAdded) - } - - if added > 0 || vipAdded > 0 { - addTotal = shopInfo.Amount + int64((float64(shopInfo.Amount)*float64(added+vipAdded))/100.0) - } - - // 首充翻倍 - if shopInfo.FirstSwitch { - if !slices.Contains(p.ShopID, int(shopInfo.Id)) { - addTotal *= 2 - } - } - - amount[ShopTypeDiamond-1] = int32(addTotal) var itemInfo []model.ItemInfo var webItemInfo []*webapi_proto.ItemInfo for _, info := range shopInfo.GetItems() { @@ -1241,6 +1213,13 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, }) } + switch shopInfo.Type { + case ShopTypeDiamond: + amount[ShopTypeDiamond-1] = int32(shopInfo.AmountFinal) + default: + + } + dbShop = this.NewDbShop(p, shopInfo.Page, amount[:], ShopConsumeMoney, costNum, common.GainWay_ShopBuy, itemInfo, shopInfo.Id, shopInfo.Name, 0, remark, []int32{}) err := model.InsertDbShopLog(dbShop) @@ -1249,7 +1228,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, return nil } return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, shopInfo.Id, p.Platform, p.PackageID, p.DeviceOS, - p.DeviceId, shopInfo.Name, [ShopTypeItem]int32{0, int32(addTotal), 0}, costNum, webItemInfo, "", p.Channel, p.ChannelId) + p.DeviceId, shopInfo.Name, [ShopTypeItem]int32{0, int32(shopInfo.AmountFinal), 0}, costNum, webItemInfo, "", p.Channel, p.ChannelId) } else if cdata, ok := data.(*ExchangeShopInfo); ok { var info *shop.ExchangeType From 82aee49eda530476a5b91535af3aa0a2ae22031e Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Fri, 6 Sep 2024 11:24:35 +0800 Subject: [PATCH 09/23] =?UTF-8?q?=E7=94=9F=E6=88=90token=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index afa8cd6..da5749b 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -10,6 +10,7 @@ import ( "mongo.games.com/goserver/core/logger" "mongo.games.com/goserver/core/netlib" "mongo.games.com/goserver/core/timer" + "strconv" "sync" "time" ) @@ -290,7 +291,7 @@ func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{}) var payload string = "" //生成token - token, err := token04.GenerateToken04(appId, string(userId), serverSecret, effectiveTimeInSeconds, payload) + token, err := token04.GenerateToken04(appId, strconv.Itoa(int(userId)), serverSecret, effectiveTimeInSeconds, payload) if err != nil { logger.Logger.Error(err) return err From 3ac3f2dea115d524e074782feb42a6c51bfa3fe0 Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 11:57:45 +0800 Subject: [PATCH 10/23] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E8=A7=86=E9=A2=91token=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/clawdoll/action_clawdoll.go | 22 ++-- gamesrv/clawdoll/scenepolicy_clawdoll.go | 24 +++-- protocol/clawdoll/clawdoll.pb.go | 122 ++++++++++++----------- protocol/clawdoll/clawdoll.proto | 1 + 4 files changed, 100 insertions(+), 69 deletions(-) diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index 9affeb7..e77acb9 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -1,6 +1,7 @@ package clawdoll import ( + "github.com/zegoim/zego_server_assistant/token/go/src/token04" "mongo.games.com/game/common" rule "mongo.games.com/game/gamerule/clawdoll" "mongo.games.com/game/gamesrv/base" @@ -115,8 +116,6 @@ func (h *CSGetTokenHandler) Process(s *netlib.Session, packetid int, data interf logger.Logger.Warn("CSGetTokenHandler p == nil") return nil } - pack := &machine.SMGetToken{} - pack.Snid = p.SnId scene := p.GetScene() if scene == nil { @@ -130,16 +129,27 @@ func (h *CSGetTokenHandler) Process(s *netlib.Session, packetid int, data interf machineId := scene.GetDBGameFree().GetId() % 6080000 machineInfo := sceneEx.GetMachineServerInfo(machineId, p.Platform) if machineInfo == nil { + logger.Logger.Warn("CSGetTokenHandler machineId = %v not found", machineId) return nil } logger.Logger.Tracef("获取娃娃机 appId = %v, serverSecret = %v, streamId = %v", machineInfo.AppId, machineInfo.ServerSecret, machineInfo.StreamId) - pack.ServerSecret = machineInfo.ServerSecret - pack.AppId = machineInfo.AppId - pack.StreamId = machineInfo.StreamId + //生成token + token, err := token04.GenerateToken04(uint32(machineInfo.AppId), string(p.SnId), machineInfo.ServerSecret, 7200, "") + if err != nil { + logger.Logger.Error(err) + return err + } + logger.Logger.Trace(token) - sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMGetToken), pack) + pack := &clawdoll.SCCLAWDOLLSendToken{ + LogicId: scene.DBGameFree.GetId(), + Appid: machineInfo.AppId, + Token: token, + StreamId: machineInfo.StreamId, + } + p.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_SENDTOKEN), pack) } return nil } diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index 664e238..3462e5e 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -1,9 +1,9 @@ package clawdoll import ( + "github.com/zegoim/zego_server_assistant/token/go/src/token04" "mongo.games.com/game/gamesrv/action" "mongo.games.com/game/protocol/clawdoll" - "mongo.games.com/game/protocol/machine" "time" "mongo.games.com/goserver/core" @@ -279,21 +279,31 @@ func (this *PolicyClawdoll) SendGetVideoToken(s *base.Scene, p *base.Player, sce logger.Logger.Warn("ClawdollGetVideoToken p == nil") return } - pack := &machine.SMGetToken{} - pack.Snid = p.SnId machineId := s.DBGameFree.GetId() % 6080000 machineinfo := sceneEx.GetMachineServerInfo(machineId, p.Platform) if machineinfo == nil { + logger.Logger.Warn("CSGetTokenHandler machineId = %v not found", machineId) return } logger.Logger.Tracef("获取娃娃机 appId = %v, serverSecret = %v, streamId = %v", machineinfo.AppId, machineinfo.ServerSecret, machineinfo.StreamId) - pack.ServerSecret = machineinfo.ServerSecret - pack.AppId = machineinfo.AppId - pack.StreamId = machineinfo.StreamId - sceneEx.SendToMachine(int(machine.DollMachinePacketID_PACKET_SMGetToken), pack) + //生成token + token, err := token04.GenerateToken04(uint32(machineinfo.AppId), string(p.SnId), machineinfo.ServerSecret, 3600, "") + if err != nil { + logger.Logger.Error(err) + return + } + logger.Logger.Trace(token) + + pack := &clawdoll.SCCLAWDOLLSendToken{ + LogicId: s.DBGameFree.GetId(), + Appid: machineinfo.AppId, + Token: token, + StreamId: machineinfo.StreamId, + } + p.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_SENDTOKEN), pack) } // 广播房间状态 diff --git a/protocol/clawdoll/clawdoll.pb.go b/protocol/clawdoll/clawdoll.pb.go index 7f6bfba..3143e31 100644 --- a/protocol/clawdoll/clawdoll.pb.go +++ b/protocol/clawdoll/clawdoll.pb.go @@ -885,6 +885,7 @@ type SCCLAWDOLLSendToken struct { Appid int64 `protobuf:"varint,2,opt,name=Appid,proto3" json:"Appid,omitempty"` Token string `protobuf:"bytes,3,opt,name=Token,proto3" json:"Token,omitempty"` StreamId string `protobuf:"bytes,4,opt,name=StreamId,proto3" json:"StreamId,omitempty"` + AppSign string `protobuf:"bytes,5,opt,name=AppSign,proto3" json:"AppSign,omitempty"` } func (x *SCCLAWDOLLSendToken) Reset() { @@ -947,6 +948,13 @@ func (x *SCCLAWDOLLSendToken) GetStreamId() string { return "" } +func (x *SCCLAWDOLLSendToken) GetAppSign() string { + if x != nil { + return x.AppSign + } + return "" +} + type CLAWDOLLWaitPlayers struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1161,62 +1169,64 @@ var file_clawdoll_proto_rawDesc = []byte{ 0x61, 0x79, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x22, 0x14, 0x0a, 0x12, 0x43, 0x53, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x47, 0x65, 0x74, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x22, 0x77, 0x0a, 0x13, 0x53, 0x43, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, - 0x4c, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x4c, 0x6f, - 0x67, 0x69, 0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x4c, 0x6f, 0x67, - 0x69, 0x63, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x6f, - 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, 0x6e, - 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x22, 0x63, 0x0a, 0x13, - 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x73, 0x12, 0x4c, 0x0a, 0x0f, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, - 0x72, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, - 0x6c, 0x61, 0x77, 0x64, 0x6f, 0x6c, 0x6c, 0x2e, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, - 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x0f, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x49, 0x6e, 0x66, - 0x6f, 0x22, 0x84, 0x01, 0x0a, 0x18, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x50, 0x6c, - 0x61, 0x79, 0x65, 0x72, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, - 0x0a, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, - 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x48, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x04, 0x48, 0x65, 0x61, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x48, 0x65, 0x61, 0x64, 0x55, 0x72, - 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x48, 0x65, 0x61, 0x64, 0x55, 0x72, 0x6c, - 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x04, 0x53, 0x74, 0x61, 0x74, 0x2a, 0xfd, 0x02, 0x0a, 0x10, 0x43, 0x4c, 0x41, - 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x44, 0x12, 0x0f, 0x0a, - 0x0b, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x17, - 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x52, 0x4f, 0x4f, 0x4d, - 0x49, 0x4e, 0x46, 0x4f, 0x10, 0xe1, 0x2b, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, - 0x54, 0x5f, 0x43, 0x53, 0x5f, 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x4f, 0x50, 0x10, 0xe2, 0x2b, - 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x4c, - 0x41, 0x59, 0x45, 0x52, 0x4f, 0x50, 0x10, 0xe3, 0x2b, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x41, 0x43, - 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x52, 0x4f, 0x4f, 0x4d, 0x53, 0x54, 0x41, 0x54, 0x45, - 0x10, 0xe4, 0x2b, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, - 0x5f, 0x47, 0x41, 0x4d, 0x45, 0x42, 0x49, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0xe5, 0x2b, 0x12, 0x1a, - 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x6c, 0x61, 0x79, - 0x65, 0x72, 0x45, 0x6e, 0x74, 0x65, 0x72, 0x10, 0xe6, 0x2b, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, - 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4c, 0x65, - 0x61, 0x76, 0x65, 0x10, 0xe7, 0x2b, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, - 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0xe8, - 0x2b, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, 0x53, 0x5f, 0x47, - 0x45, 0x54, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x10, 0xe9, 0x2b, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x41, - 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x53, 0x45, 0x4e, 0x44, 0x54, 0x4f, 0x4b, 0x45, - 0x4e, 0x10, 0xea, 0x2b, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, - 0x53, 0x5f, 0x57, 0x41, 0x49, 0x54, 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x53, 0x10, 0xeb, 0x2b, - 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x57, 0x41, - 0x49, 0x54, 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x53, 0x10, 0xec, 0x2b, 0x12, 0x1a, 0x0a, 0x15, - 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x4c, 0x41, 0x59, 0x49, 0x4e, - 0x47, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0xed, 0x2b, 0x2a, 0x64, 0x0a, 0x0c, 0x4f, 0x70, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x4f, 0x50, 0x52, 0x43, - 0x5f, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, - 0x52, 0x43, 0x5f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4f, 0x50, - 0x52, 0x43, 0x5f, 0x43, 0x6f, 0x69, 0x6e, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, - 0x10, 0x02, 0x12, 0x1a, 0x0a, 0x16, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x6f, 0x73, 0x41, 0x6c, - 0x52, 0x65, 0x61, 0x64, 0x79, 0x50, 0x6c, 0x61, 0x79, 0x69, 0x6e, 0x67, 0x10, 0x03, 0x42, 0x28, - 0x5a, 0x26, 0x6d, 0x6f, 0x6e, 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x67, 0x61, 0x6d, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, - 0x63, 0x6c, 0x61, 0x77, 0x64, 0x6f, 0x6c, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6b, 0x65, 0x6e, 0x22, 0x91, 0x01, 0x0a, 0x13, 0x53, 0x43, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, + 0x4c, 0x4c, 0x53, 0x65, 0x6e, 0x64, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x4c, + 0x6f, 0x67, 0x69, 0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x4c, 0x6f, + 0x67, 0x69, 0x63, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x41, 0x70, 0x70, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x41, 0x70, 0x70, 0x53, 0x69, 0x67, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x41, 0x70, 0x70, 0x53, 0x69, 0x67, 0x6e, 0x22, 0x63, 0x0a, 0x13, 0x43, 0x4c, 0x41, 0x57, 0x44, + 0x4f, 0x4c, 0x4c, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x12, 0x4c, + 0x0a, 0x0f, 0x57, 0x61, 0x69, 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x49, 0x6e, 0x66, + 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6c, 0x61, 0x77, 0x64, 0x6f, + 0x6c, 0x6c, 0x2e, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x50, 0x6c, 0x61, 0x79, 0x65, + 0x72, 0x44, 0x69, 0x67, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x57, 0x61, 0x69, + 0x74, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x73, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0x84, 0x01, 0x0a, + 0x18, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x44, + 0x69, 0x67, 0x65, 0x73, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x53, 0x6e, 0x49, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, 0x6e, 0x49, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x48, 0x65, 0x61, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x48, 0x65, 0x61, + 0x64, 0x12, 0x18, 0x0a, 0x07, 0x48, 0x65, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x48, 0x65, 0x61, 0x64, 0x55, 0x72, 0x6c, 0x12, 0x12, 0x0a, 0x04, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x12, + 0x12, 0x0a, 0x04, 0x53, 0x74, 0x61, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x53, + 0x74, 0x61, 0x74, 0x2a, 0xfd, 0x02, 0x0a, 0x10, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, + 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x49, 0x44, 0x12, 0x0f, 0x0a, 0x0b, 0x50, 0x41, 0x43, 0x4b, + 0x45, 0x54, 0x5f, 0x5a, 0x45, 0x52, 0x4f, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x52, 0x4f, 0x4f, 0x4d, 0x49, 0x4e, 0x46, 0x4f, 0x10, + 0xe1, 0x2b, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, 0x53, 0x5f, + 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x4f, 0x50, 0x10, 0xe2, 0x2b, 0x12, 0x17, 0x0a, 0x12, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x4f, + 0x50, 0x10, 0xe3, 0x2b, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, + 0x43, 0x5f, 0x52, 0x4f, 0x4f, 0x4d, 0x53, 0x54, 0x41, 0x54, 0x45, 0x10, 0xe4, 0x2b, 0x12, 0x19, + 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x47, 0x41, 0x4d, 0x45, + 0x42, 0x49, 0x4c, 0x4c, 0x45, 0x44, 0x10, 0xe5, 0x2b, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, + 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x45, 0x6e, 0x74, + 0x65, 0x72, 0x10, 0xe6, 0x2b, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, + 0x53, 0x43, 0x5f, 0x50, 0x6c, 0x61, 0x79, 0x65, 0x72, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x10, 0xe7, + 0x2b, 0x12, 0x19, 0x0a, 0x14, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, + 0x4c, 0x41, 0x59, 0x45, 0x52, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0xe8, 0x2b, 0x12, 0x17, 0x0a, 0x12, + 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, 0x53, 0x5f, 0x47, 0x45, 0x54, 0x54, 0x4f, 0x4b, + 0x45, 0x4e, 0x10, 0xe9, 0x2b, 0x12, 0x18, 0x0a, 0x13, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, + 0x53, 0x43, 0x5f, 0x53, 0x45, 0x4e, 0x44, 0x54, 0x4f, 0x4b, 0x45, 0x4e, 0x10, 0xea, 0x2b, 0x12, + 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x43, 0x53, 0x5f, 0x57, 0x41, 0x49, + 0x54, 0x50, 0x4c, 0x41, 0x59, 0x45, 0x52, 0x53, 0x10, 0xeb, 0x2b, 0x12, 0x1a, 0x0a, 0x15, 0x50, + 0x41, 0x43, 0x4b, 0x45, 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x57, 0x41, 0x49, 0x54, 0x50, 0x4c, 0x41, + 0x59, 0x45, 0x52, 0x53, 0x10, 0xec, 0x2b, 0x12, 0x1a, 0x0a, 0x15, 0x50, 0x41, 0x43, 0x4b, 0x45, + 0x54, 0x5f, 0x53, 0x43, 0x5f, 0x50, 0x4c, 0x41, 0x59, 0x49, 0x4e, 0x47, 0x49, 0x4e, 0x46, 0x4f, + 0x10, 0xed, 0x2b, 0x2a, 0x64, 0x0a, 0x0c, 0x4f, 0x70, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x53, 0x75, 0x63, 0x63, + 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x0e, 0x0a, 0x0a, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x45, 0x72, + 0x72, 0x6f, 0x72, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x43, 0x6f, + 0x69, 0x6e, 0x4e, 0x6f, 0x74, 0x45, 0x6e, 0x6f, 0x75, 0x67, 0x68, 0x10, 0x02, 0x12, 0x1a, 0x0a, + 0x16, 0x4f, 0x50, 0x52, 0x43, 0x5f, 0x50, 0x6f, 0x73, 0x41, 0x6c, 0x52, 0x65, 0x61, 0x64, 0x79, + 0x50, 0x6c, 0x61, 0x79, 0x69, 0x6e, 0x67, 0x10, 0x03, 0x42, 0x28, 0x5a, 0x26, 0x6d, 0x6f, 0x6e, + 0x67, 0x6f, 0x2e, 0x67, 0x61, 0x6d, 0x65, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x61, 0x6d, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x6f, 0x6c, 0x2f, 0x63, 0x6c, 0x61, 0x77, 0x64, + 0x6f, 0x6c, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/protocol/clawdoll/clawdoll.proto b/protocol/clawdoll/clawdoll.proto index b8dd5c9..ffc7cd9 100644 --- a/protocol/clawdoll/clawdoll.proto +++ b/protocol/clawdoll/clawdoll.proto @@ -118,6 +118,7 @@ message SCCLAWDOLLSendToken { int64 Appid = 2; string Token = 3; string StreamId = 4; + string AppSign = 5; } message CLAWDOLLWaitPlayers { From fc2db94c86a881d40a0b6707f9e4001a977b4c21 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 14:00:34 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E9=A6=86=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/DB_PropExchange.dat | Bin 384 -> 384 bytes data/DB_Task.dat | Bin 5299 -> 5299 bytes model/config.go | 25 ++++++++++++++++++------- public | 2 +- worldsrv/scene.go | 1 - worldsrv/scenemgr.go | 1 + 6 files changed, 20 insertions(+), 9 deletions(-) diff --git a/data/DB_PropExchange.dat b/data/DB_PropExchange.dat index eab78e7297231cf3a52b2e8368d3632ac62bb02e..79f8787d87dd629e44daad01b4faae3b91f55cf3 100644 GIT binary patch literal 384 zcmd-w<6snElw#w!+{O&1uR!UmQ2H8_z7C?5I5-yevI!h$vE|a^U;?YZ0hPZArEfv$ z+i2>;IUweP#ew#rtH){|P#w&C6!$4{g5A-u_7MwLEC&nNAuxx+42D?*(+INw>=7h` ZVGh0nbvQTxl-M~I0X_PKnTvt85CCSnJT(9S literal 384 zcmd-w<6snElw#w!(#8y?uR`f-Q2IKQz6_$3I5-yevI!h$vE|a^U;?YZ0hPZArEfv$ z+i2>;IUweP%^|`*{N{3k-O;f25eru=2MgFCFbBgl-hny2i-EQf0Au1jH2?qr diff --git a/data/DB_Task.dat b/data/DB_Task.dat index ec74cdafd8493c72f3f5010721a7e2cc12d529f8..7f781343a7cc7a11712f89c0ca1f3edb0dfa161a 100644 GIT binary patch delta 226 zcmdn2xmk09p&$px!d^Ck1&8Fk*f^E|S*#nK)-nmQaV!F|8NHygy={DEH|X!9bVgG8V< NH*{8QHV|lL0RXb^Hf{g_ diff --git a/model/config.go b/model/config.go index 568775e..4ba254c 100644 --- a/model/config.go +++ b/model/config.go @@ -406,7 +406,19 @@ func (cm *ConfigMgr) UpdateRoomConfig(data *webapi.RoomConfig) { if d == nil { d = make([]*webapi.RoomConfig, 0) } - d = append(d, data) + + has := false + for k, v := range d { + if v.GetId() == data.GetId() { + d[k] = data + has = true + break + } + } + if !has { + d = append(d, data) + } + cm.GetConfig(data.GetPlatform()).RoomTypeMap[data.GetRoomType()] = d } @@ -414,12 +426,11 @@ func (cm *ConfigMgr) DelRoomConfig(plt string, id int32) { d := cm.GetConfig(plt).RoomConfig[id] if d != nil { b := cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()] - if b != nil { - for i, v := range b { - if v.GetId() == id { - b = append(b[:i], b[i+1:]...) - cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()] = b - } + for i, v := range b { + if v.GetId() == id { + b = append(b[:i], b[i+1:]...) + cm.GetConfig(plt).RoomTypeMap[d.GetRoomType()] = b + break } } } diff --git a/public b/public index 00b9fce..9d35521 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 +Subproject commit 9d355215710228e4481fc6334f6e14b902a03e95 diff --git a/worldsrv/scene.go b/worldsrv/scene.go index 093a35e..a8fcd80 100644 --- a/worldsrv/scene.go +++ b/worldsrv/scene.go @@ -141,7 +141,6 @@ func NewScene(args *CreateSceneParam) *Scene { if s.CustomParam == nil { s.CustomParam = new(serverproto.CustomParam) } - s.sp.OnStart(s) return s } diff --git a/worldsrv/scenemgr.go b/worldsrv/scenemgr.go index 185f3f5..439a945 100644 --- a/worldsrv/scenemgr.go +++ b/worldsrv/scenemgr.go @@ -413,6 +413,7 @@ func (m *SceneMgr) CreateScene(args *CreateSceneParam) *Scene { return nil } m.scenes[args.RoomId] = s + s.sp.OnStart(s) // 添加到游戏服记录中 args.GS.AddScene(&AddSceneParam{ S: s, From 63387ba9b4a611bef315c1e67113739deb798e2e Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 14:46:30 +0800 Subject: [PATCH 12/23] =?UTF-8?q?=E5=95=86=E5=9F=8E=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E6=88=BF=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/scene.go | 2 +- worldsrv/shopmgr.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/worldsrv/scene.go b/worldsrv/scene.go index a8fcd80..2ff2a09 100644 --- a/worldsrv/scene.go +++ b/worldsrv/scene.go @@ -682,9 +682,9 @@ func (this *Scene) OnClose() { } this.Broadcast(int(hallproto.GameHallPacketID_PACKET_SC_DESTROYROOM), scDestroyRoom, 0) + this.sp.OnStop(this) this.deleting = true this.closed = true - this.sp.OnStop(this) for _, p := range this.players { this.DelPlayer(p) diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index 1fdf0d2..40bd5de 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -1228,7 +1228,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, return nil } return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, shopInfo.Id, p.Platform, p.PackageID, p.DeviceOS, - p.DeviceId, shopInfo.Name, [ShopTypeItem]int32{0, int32(shopInfo.AmountFinal), 0}, costNum, webItemInfo, "", p.Channel, p.ChannelId) + p.DeviceId, shopInfo.Name, amount, costNum, webItemInfo, "", p.Channel, p.ChannelId) } else if cdata, ok := data.(*ExchangeShopInfo); ok { var info *shop.ExchangeType From 4bd2cee327429669f9752a90bd8873c7b7592bbd Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 14:49:51 +0800 Subject: [PATCH 13/23] public --- public | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public b/public index 9d35521..00b9fce 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit 9d355215710228e4481fc6334f6e14b902a03e95 +Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 From 09dc4f45882d498a5aa95a4c93b683bad67a92f3 Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Fri, 6 Sep 2024 14:55:44 +0800 Subject: [PATCH 14/23] public --- public | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public b/public index 00b9fce..d789cca 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 +Subproject commit d789cca81a36ddbaf30e5414b6c4fe530e0631f6 From 98a834b357030e7089bde36c50781fc3c4b65e61 Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Fri, 6 Sep 2024 14:56:40 +0800 Subject: [PATCH 15/23] public --- public | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public b/public index 00b9fce..d789cca 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 +Subproject commit d789cca81a36ddbaf30e5414b6c4fe530e0631f6 From 8a19cd642f49f96fc111d6ce75ddc4a163fed0eb Mon Sep 17 00:00:00 2001 From: kxdd Date: Fri, 6 Sep 2024 15:36:59 +0800 Subject: [PATCH 16/23] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=9C=BA=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=8A=B6=E6=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/clawdoll/scenepolicy_clawdoll.go | 11 ----------- public | 2 +- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/gamesrv/clawdoll/scenepolicy_clawdoll.go b/gamesrv/clawdoll/scenepolicy_clawdoll.go index 36886fa..f60bbfa 100644 --- a/gamesrv/clawdoll/scenepolicy_clawdoll.go +++ b/gamesrv/clawdoll/scenepolicy_clawdoll.go @@ -677,12 +677,6 @@ func (this *PlayGame) OnPlayerOp(s *base.Scene, p *base.Player, opcode int, para //1-弱力抓 2 -强力抓 sceneEx.OnPlayerSMGrabOp(p.SnId, int32(sceneEx.machineId), grapType) - s.ChangeSceneState(rule.ClawDollSceneStateBilled) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) - case rule.ClawDollPlayerOpMove: if !sceneEx.CheckMoveOp(playerEx) { @@ -713,11 +707,6 @@ func (this *PlayGame) OnTick(s *base.Scene) { logger.Logger.Trace("PlayGame OnTick TimeOutPlayGrab SnId", sceneEx.playingSnid, " machineId:", sceneEx.machineId) } - s.ChangeSceneState(rule.ClawDollSceneStateBilled) - sceneEx.SetPlayingState(int32(rule.ClawDollSceneStateBilled)) - - ClawdollBroadcastRoomState(s) - ClawdollSendPlayerInfo(s) return } } diff --git a/public b/public index d789cca..00b9fce 160000 --- a/public +++ b/public @@ -1 +1 @@ -Subproject commit d789cca81a36ddbaf30e5414b6c4fe530e0631f6 +Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 From c20f0fa69cac02c61765550b040679c327a53562 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 15:39:30 +0800 Subject: [PATCH 17/23] =?UTF-8?q?=E5=95=86=E5=9F=8E=E8=B4=AD=E4=B9=B0?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/shopmgr.go | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index 40bd5de..5f34e9b 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -63,9 +63,14 @@ const ( const ( ShopTypeCoin = iota + 1 // 金币 ShopTypeDiamond // 钻石 - ShopTypeItem // 道具 - ShopTypeFangKa // 房卡 - ShopTypeMax +) + +// 商品参数类型 +const ( + ShopParamCoin = iota // 金币 + ShopParamDiamond // 钻石 + ShopParamUnKnown // 未定义 + ShopParamMax // 参数数量 ) // 兑换商品状态 @@ -139,7 +144,7 @@ func (this *ShopMgr) GetShopInfoProto(si *model.ShopInfo, p *Player, vipShopId i } added := int32(rand.Intn(int(si.AddArea[1])-int(si.AddArea[0])+1) + int(si.AddArea[0])) consumptionAmount := int32(rand.Intn(int(si.CostArea[1])-int(si.CostArea[0])+1) + int(si.CostArea[0])) - amount := int64(si.Amount) + amount := si.Amount isBuy := false if si.Page == ShopPageVip { shopData := p.GetVipShopData(si.Id, vipShopId) @@ -705,7 +710,7 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po }) } - amount := [3]int32{} // 获得含义:金币,钻石,经验 + amount := [ShopParamMax]int32{} // 获得含义:金币,钻石,经验 if shopInfo.Page == ShopPageVip { if p.VipShopData[vipShopId] == nil { logger.Logger.Errorf("GainShop 没有找到vip商品 shopId:%v vipShopId:%v snid:%v", shopInfo.Id, vipShopId, p.SnId) @@ -720,7 +725,7 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po switch shopInfo.Type { case ShopTypeCoin: - amount[0] = int32(addTotal) + amount[ShopParamCoin] = int32(addTotal) p.AddCoin(addTotal, 0, common.GainWay_Shop_Buy, "system", shopName) if shopInfo.Ad > 0 { //观看广告 if !p.IsRob { @@ -737,7 +742,7 @@ func (this *ShopMgr) GainShop(shopInfo *model.ShopInfo, p *Player, vipShopId, po case ShopTypeDiamond: //增加钻石 - amount[1] = int32(addTotal) + amount[ShopParamDiamond] = int32(addTotal) p.AddDiamond(addTotal, 0, common.GainWay_Shop_Buy, "system", shopName) if shopInfo.Ad > 0 { //观看广告 if !p.IsRob { @@ -904,7 +909,7 @@ func (this *ShopMgr) Exchange(p *Player, goodsId int32, username, mobile, commen if err := proto.Unmarshal(buff, as); err != nil { logger.Logger.Errorf("API_CreateExchange err: %v %v", err, as.Tag) } - var amount [ShopTypeItem]int32 + var amount [ShopParamMax]int32 //保存db dbShop := this.NewDbShop(p, 0, amount[:], ExchangeConsumeCash, info.Cash*num, common.GainWay_ShopBuy, itemInfo, cdata.Id, cdata.Name, 0, "", []int32{}) @@ -1196,7 +1201,7 @@ func (this *ShopMgr) NewDbShop(p *Player, pageId int32, amount []int32, consume, func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, remark string) { //三方购买 task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - var amount [ShopTypeItem]int32 + var amount [ShopParamMax]int32 var dbShop *model.DbShop if shopInfo, ok := data.(*model.ShopInfo); ok { costNum := rand.Int31n(shopInfo.CostArea[1]-shopInfo.CostArea[0]+1) + shopInfo.CostArea[0] @@ -1215,7 +1220,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, switch shopInfo.Type { case ShopTypeDiamond: - amount[ShopTypeDiamond-1] = int32(shopInfo.AmountFinal) + amount[ShopParamDiamond] = int32(shopInfo.AmountFinal) default: } @@ -1253,14 +1258,14 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, //兑换 充值订单 logger.Logger.Infof("客户端请求兑换 创建支付订单!AppId = %v,SnId = %v,Id = %v,dbShop.LogId.Hex() = %v,cash = %v", common.GetAppId(), p.SnId, cdata.Id, dbShop.LogId.Hex(), info.Cash*cdata.ExchangeNum) return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, cdata.Id, p.Platform, p.PackageID, p.DeviceOS, - p.DeviceId, cdata.Name, [ShopTypeItem]int32{0, 0, 0}, info.Cash*cdata.ExchangeNum, nil, orderId, p.Channel, p.ChannelId) + p.DeviceId, cdata.Name, amount, info.Cash*cdata.ExchangeNum, nil, orderId, p.Channel, p.ChannelId) } else if bbd, ok := data.(*webapi_proto.BlindBoxData); ok { - if bbd.Type == 1 { + if bbd.Type == ShopTypeCoin { //金币 - amount[0] = bbd.Grade - } else if bbd.Type == 2 { + amount[ShopParamCoin] = bbd.Grade + } else if bbd.Type == ShopTypeDiamond { //钻石 - amount[1] = bbd.Grade + amount[ShopParamDiamond] = bbd.Grade } dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, nil, 0, "", 0, remark, []int32{bbd.Id}) err := model.InsertDbShopLog(dbShop) @@ -1274,9 +1279,9 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, var items []model.ItemInfo for _, it := range wfs.Item { if it.Type == 1 { - amount[0] = it.Grade + amount[ShopParamCoin] = it.Grade } else if it.Type == 2 { - amount[1] = it.Grade + amount[ShopParamDiamond] = it.Grade } else if it.Type == 3 { items = append(items, model.ItemInfo{ ItemId: it.Item_Id, From b4bab0de1eea56a93536bfbd9b40984cfed1049c Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 15:58:06 +0800 Subject: [PATCH 18/23] =?UTF-8?q?=E5=88=A0=E9=99=A4public=E5=AD=90?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitmodules | 3 --- README.md | 21 --------------------- public | 1 - shell/update_public.bat | 10 +++++----- 4 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 .gitmodules delete mode 160000 public diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index e7c37df..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "public"] - path = public - url = git@git.pogorockgames.com:mango-games/server/public.git diff --git a/README.md b/README.md index 432863b..f5b2aeb 100644 --- a/README.md +++ b/README.md @@ -2,27 +2,6 @@ 游戏业务代码 -### 子仓库 - public子仓库本项目本身并没有使用,只是用来暴露部分公共代码,供其他项目使用。 - 例如: - 1.客户端同步通信协议 - 2.客户端同步游戏配置 - -#### 初始化子仓库 -``` -git submodule update --init --recursive -``` - -#### 更新子仓库 -``` -git submodule update --remote -``` - -#### 更新并提交子仓库代码 -``` -update_public.sh -``` - ### 脚本 #### gen_data.bat xlsx文件转换为json,dat文件,生成pbdata.proto,生成srvdata包 diff --git a/public b/public deleted file mode 160000 index 00b9fce..0000000 --- a/public +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 00b9fce886af5b6a926aa804d3cad33be9ea0793 diff --git a/shell/update_public.bat b/shell/update_public.bat index a81133b..376fa0b 100644 --- a/shell/update_public.bat +++ b/shell/update_public.bat @@ -1,11 +1,11 @@ -if exist ".\public" ( - cd .\public +if exist "..\public" ( + cd ..\public git checkout main git pull - xcopy ..\data .\data /s /e /y - xcopy ..\protocol .\protocol /s /e /y - xcopy ..\xlsx .\xlsx /s /e /y + xcopy ..\game\data .\data /s /e /y + xcopy ..\game\protocol .\protocol /s /e /y + xcopy ..\game\xlsx .\xlsx /s /e /y git add . git commit -m "update" From 5bdf3d78df250cedf6660ec3b00c9943b4d32124 Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 16:23:57 +0800 Subject: [PATCH 19/23] =?UTF-8?q?=E5=95=86=E5=BA=97=E8=B4=AD=E4=B9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/shopmgr.go | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/worldsrv/shopmgr.go b/worldsrv/shopmgr.go index 5f34e9b..75333b9 100644 --- a/worldsrv/shopmgr.go +++ b/worldsrv/shopmgr.go @@ -63,6 +63,7 @@ const ( const ( ShopTypeCoin = iota + 1 // 金币 ShopTypeDiamond // 钻石 + SHopTypeItem // 道具 ) // 商品参数类型 @@ -1267,26 +1268,45 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, //钻石 amount[ShopParamDiamond] = bbd.Grade } - dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, nil, 0, "", 0, remark, []int32{bbd.Id}) + + var itemInfo []model.ItemInfo + var webItemInfo []*webapi_proto.ItemInfo + for _, info := range shopInfo.GetItems() { + itemInfo = append(itemInfo, model.ItemInfo{ + ItemId: info.ItemId, + ItemNum: info.ItemNum, + }) + webItemInfo = append(webItemInfo, &webapi_proto.ItemInfo{ + ItemId: info.ItemId, + ItemNum: info.ItemNum, + }) + } + + dbShop = this.NewDbShop(p, 0, amount[:], ShopConsumeMoney, int32(bbd.Price2), common.GainWay_ActBlindBox, itemInfo, 0, "", 0, remark, []int32{bbd.Id}) err := model.InsertDbShopLog(dbShop) if err != nil { logger.Logger.Errorf("model.InsertDbShopLog err:", err) return nil } return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS, - p.DeviceId, bbd.Name, amount, int32(bbd.Price2), nil, "", p.Channel, p.ChannelId) + p.DeviceId, bbd.Name, amount, int32(bbd.Price2), webItemInfo, "", p.Channel, p.ChannelId) } else if wfs, ok := data.(*webapi_proto.WelfareSpree); ok { var items []model.ItemInfo + var webItemInfo []*webapi_proto.ItemInfo for _, it := range wfs.Item { - if it.Type == 1 { + if it.Type == ShopTypeCoin { amount[ShopParamCoin] = it.Grade - } else if it.Type == 2 { + } else if it.Type == ShopTypeDiamond { amount[ShopParamDiamond] = it.Grade - } else if it.Type == 3 { + } else if it.Type == SHopTypeItem { items = append(items, model.ItemInfo{ ItemId: it.Item_Id, ItemNum: int64(it.Grade), }) + webItemInfo = append(webItemInfo, &webapi_proto.ItemInfo{ + ItemId: it.GetItem_Id(), + ItemNum: int64(it.GetGrade()), + }) } } var gainWay int32 = common.GainWay_ActFirstPay @@ -1300,7 +1320,7 @@ func (this *ShopMgr) SendAPICreateOrder(p *Player, ConfigPayId int32, data any, return nil } return webapi.API_CreateOrder(common.GetAppId(), dbShop.LogId.Hex(), ConfigPayId, p.SnId, 0, p.Platform, p.PackageID, p.DeviceOS, - p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), nil, "", p.Channel, p.ChannelId) + p.DeviceId, "FirstRecharge", amount, int32(wfs.Price2), webItemInfo, "", p.Channel, p.ChannelId) } return nil }), task.CompleteNotifyWrapper(func(retdata interface{}, t task.Task) { From 67a85f6535f6411a0fccb77e9d034d65943e135c Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 17:28:10 +0800 Subject: [PATCH 20/23] =?UTF-8?q?=E7=AB=9E=E6=8A=80=E6=88=BF=E9=97=B4?= =?UTF-8?q?=E6=B2=A1=E4=BA=BA=E8=A7=A3=E6=95=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gamesrv/action/action_game.go | 37 -------------------------- gamesrv/tienlen/scenepolicy_tienlen.go | 6 ++--- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/gamesrv/action/action_game.go b/gamesrv/action/action_game.go index 344fa6e..8148257 100644 --- a/gamesrv/action/action_game.go +++ b/gamesrv/action/action_game.go @@ -13,43 +13,6 @@ import ( "mongo.games.com/game/srvdata" ) -type CSDestroyRoomPacketFactory struct { -} -type CSDestroyRoomHandler struct { -} - -func (this *CSDestroyRoomPacketFactory) CreatePacket() interface{} { - pack := &gamehall.CSDestroyRoom{} - return pack -} - -func (this *CSDestroyRoomHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error { - logger.Logger.Trace("CSDestroyRoomHandler Process recv ", data) - p := base.PlayerMgrSington.GetPlayer(sid) - if p == nil { - logger.Logger.Warn("CSDestroyRoomHandler p == nil") - return nil - } - scene := p.GetScene() - if scene == nil { - logger.Logger.Warn("CSDestroyRoomHandler p.GetScene() == nil") - return nil - } - if !scene.HasPlayer(p) { - return nil - } - if scene.Creator != p.SnId { - logger.Logger.Warn("CSDestroyRoomHandler s.creator != p.AccountId") - return nil - } - // 房卡场开始后不能解散 - if scene.IsCustom() && scene.NumOfGames > 0 { - return nil - } - scene.Destroy(true) - return nil -} - type CSLeaveRoomPacketFactory struct { } type CSLeaveRoomHandler struct { diff --git a/gamesrv/tienlen/scenepolicy_tienlen.go b/gamesrv/tienlen/scenepolicy_tienlen.go index 46bf98c..6a90360 100644 --- a/gamesrv/tienlen/scenepolicy_tienlen.go +++ b/gamesrv/tienlen/scenepolicy_tienlen.go @@ -148,6 +148,9 @@ func (this *ScenePolicyTienLen) OnPlayerLeave(s *base.Scene, p *base.Player, rea } sceneEx.OnPlayerLeave(p, reason) s.FirePlayerEvent(p, base.PlayerEventLeave, []int64{int64(reason)}) + if s.IsCustom() && len(s.Players) == 0 { + s.Destroy(true) + } } // 玩家掉线 @@ -603,9 +606,6 @@ func (this *SceneBaseStateTienLen) OnTick(s *base.Scene) { s.RandRobotCnt() s.SetTimerRandomRobot(s.GetRobotTime()) } - if s.IsCustom() && len(s.Players) == 0 { - s.Destroy(true) - } } // 发送玩家操作情况 From 892a61aa470e1af3b2e40f1c77c29d3bcabf2bca Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Fri, 6 Sep 2024 17:30:28 +0800 Subject: [PATCH 21/23] log --- machine/action/action_server.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index da5749b..759543c 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -201,7 +201,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid Result: 0, TypeId: 2, }) - logger.Logger.Trace("没有抓到礼品!!!!!!!!snid = ", snid, "num = ", num) + fmt.Println("没有抓到礼品!!!!!!!!snid = ", snid, "num = ", num) return } if bytes.Contains(part, instruction1) && num != 1 { @@ -209,7 +209,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid //回应数据 _, err = conn.Write([]byte{0xAA, 0x04, 0x01, 0x50, 0x09, 0x5c, 0xdd}) if err != nil { - logger.Logger.Error("Failed to read response from server:", err) + fmt.Println("Failed to read response from server:", err) return } session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ @@ -218,7 +218,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid Result: 1, TypeId: 2, }) - logger.Logger.Trace("抓到礼品了!!!!!!!!snid = ", snid, "num = ", num) + fmt.Println("抓到礼品了!!!!!!!!snid = ", snid, "num = ", num) return } //上分成功 @@ -231,6 +231,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid Result: 1, TypeId: 1, }) + fmt.Println("上分成功!!!!!!!!!!snid = ", snid, "num = ", num) } //上分失败 coinData = []byte{0xAA, 0x04, 0x02, 0x03, 0x00} @@ -242,6 +243,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid Result: 0, TypeId: 1, }) + fmt.Println("上分失败!!!!!!!!!!snid = ", snid, "num = ", num) } } } @@ -254,7 +256,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid // 与游戏服务器连接成功,向游戏服务器推送所有娃娃机连接 func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interface{}) error { - logger.Logger.Trace("与游戏服务器连接成功") + fmt.Println("与游戏服务器连接成功") //开始向游戏服务器发送娃娃机连接信息 msg := &machine.MSDollMachineList{} for i, _ := range machinedoll.MachineMgr.ConnMap { @@ -263,7 +265,7 @@ func SMGameLinkSucceedHandler(session *netlib.Session, packetId int, data interf msg.Data = append(msg.Data, info) } session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineList), msg) - logger.Logger.Tracef("向游戏服务器发送娃娃机连接信息:%v", msg) + fmt.Println("向游戏服务器发送娃娃机连接信息:%v", msg) return nil } @@ -304,7 +306,7 @@ func SMGetTokenHandler(session *netlib.Session, packetId int, data interface{}) info.StreamId = msg.StreamId session.Send(int(machine.DollMachinePacketID_PACKET_MSSendToken), info) - logger.Logger.Tracef("向游戏服务器发送娃娃机token:%v", info) + fmt.Println("向游戏服务器发送娃娃机token:%v", info) return nil } From 7889c982eafed6e8660a03acc687c42a596e69bb Mon Sep 17 00:00:00 2001 From: by <123456@qq.com> Date: Fri, 6 Sep 2024 18:06:40 +0800 Subject: [PATCH 22/23] =?UTF-8?q?=E5=A8=83=E5=A8=83=E6=A9=9F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/action/action_server.go | 12 ++++++------ machine/machinedoll/machinemgr.go | 4 +--- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/machine/action/action_server.go b/machine/action/action_server.go index 759543c..ea70d6b 100644 --- a/machine/action/action_server.go +++ b/machine/action/action_server.go @@ -195,13 +195,13 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid //fmt.Println("Failed to read response from server:", err) return } - session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ + fmt.Println("没有抓到礼品!!!!!!!!snid = ", snid, "num = ", num) + machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ Snid: snid, Id: id, Result: 0, TypeId: 2, }) - fmt.Println("没有抓到礼品!!!!!!!!snid = ", snid, "num = ", num) return } if bytes.Contains(part, instruction1) && num != 1 { @@ -212,20 +212,20 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid fmt.Println("Failed to read response from server:", err) return } - session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ + fmt.Println("抓到礼品了!!!!!!!!snid = ", snid, "num = ", num) + machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ Snid: snid, Id: id, Result: 1, TypeId: 2, }) - fmt.Println("抓到礼品了!!!!!!!!snid = ", snid, "num = ", num) return } //上分成功 coinData := []byte{0xAA, 0x04, 0x02, 0x03, 0x01} if bytes.Contains(part, coinData) { //返回消息 - session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ + machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ Snid: snid, Id: id, Result: 1, @@ -237,7 +237,7 @@ func DollMachineGrabResult(session *netlib.Session, conn *machinedoll.Conn, snid coinData = []byte{0xAA, 0x04, 0x02, 0x03, 0x00} if bytes.Contains(part, coinData) { //返回消息 - session.Send(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ + machinedoll.SendToGameServer(int(machine.DollMachinePacketID_PACKET_MSDollMachineoPerateResult), &machine.MSDollMachineoPerateResult{ Snid: snid, Id: id, Result: 0, diff --git a/machine/machinedoll/machinemgr.go b/machine/machinedoll/machinemgr.go index 3fc997e..bbad9ff 100644 --- a/machine/machinedoll/machinemgr.go +++ b/machine/machinedoll/machinemgr.go @@ -152,9 +152,7 @@ func (this *MachineManager) UpdateToGameServer(conn *Conn, status int32) { } func SendToGameServer(pid int, msg interface{}) { - if GameConn == nil { - GameConn = srvlib.ServerSessionMgrSington.GetSession(1, 7, 701) - } + GameConn = srvlib.ServerSessionMgrSington.GetSession(1, 7, 777) if GameConn != nil { GameConn.Send(pid, msg) } else { From 4da55c95880b3525a8597bc6c5a22008edf0073f Mon Sep 17 00:00:00 2001 From: sk <123456@qq.com> Date: Fri, 6 Sep 2024 18:33:28 +0800 Subject: [PATCH 23/23] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E4=B8=AD=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E5=AE=9E=E6=97=B6=E9=87=91=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- worldsrv/action_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldsrv/action_server.go b/worldsrv/action_server.go index bf0779f..441578d 100644 --- a/worldsrv/action_server.go +++ b/worldsrv/action_server.go @@ -513,7 +513,7 @@ func init() { } } - if !scene.IsMatchScene() { // 比赛没金币是积分 + if !scene.IsMatchScene() && !scene.IsCustom() { // 比赛没金币是积分 player.Coin = playerBet.GetCoin() player.GameCoinTs = playerBet.GetGameCoinTs() player.GameTax += playerBet.GetTax()