diff --git a/gamesrv/clawdoll/action_clawdoll.go b/gamesrv/clawdoll/action_clawdoll.go index 58e3ca0..8f36d44 100644 --- a/gamesrv/clawdoll/action_clawdoll.go +++ b/gamesrv/clawdoll/action_clawdoll.go @@ -188,53 +188,6 @@ func (h *CSGetTokenHandler) Process(s *netlib.Session, packetid int, data interf } return nil } - -type CSDollConfigPacketFactory struct { -} - -type CSDollConfigHandler struct { -} - -func (f *CSDollConfigPacketFactory) CreatePacket() interface{} { - pack := &clawdoll.CSCLAWDOLLConfig{} - return pack -} - -func (h *CSDollConfigHandler) Process(s *netlib.Session, packetid int, data interface{}, sid int64) error { - logger.Logger.Tracef("CSDollConfigHandler") - if _, ok := data.(*clawdoll.CSCLAWDOLLConfig); ok { - p := base.PlayerMgrSington.GetPlayer(sid) - if p == nil { - logger.Logger.Warn("CSDollConfigHandler p == nil") - return nil - } - - scene := p.GetScene() - if scene == nil { - return nil - } - sceneEx, ok := scene.ExtraData.(*SceneEx) - if !ok { - return nil - } - - machineId := scene.GetDBGameFree().GetId() % 6080000 - machineInfo := sceneEx.GetMachineServerInfo(machineId, p.Platform) - if machineInfo == nil { - logger.Logger.Warn("CSDollConfigHandler machineId = %v not found", machineId) - return nil - } - pack := &clawdoll.SCCLAWDOLLConfig{ - IconAddr: machineInfo.IconAddr, - CostItemNum: machineInfo.CostItemNum, - ItemId: machineInfo.ItemId, - ItemNum: machineInfo.ItemNum, - GameId: scene.GetDBGameFree().GetId(), - } - p.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_DollConfig), pack) - } - return nil -} func init() { common.RegisterHandler(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_PLAYEROP), &CSPlayerOpHandler{}) netlib.RegisterFactory(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_PLAYEROP), &CSPlayerOpPacketFactory{}) @@ -242,7 +195,4 @@ func init() { //客户端请求token common.RegisterHandler(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_GETTOKEN), &CSGetTokenHandler{}) netlib.RegisterFactory(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_GETTOKEN), &CSGetTokenPacketFactory{}) - //客户端请求配置信息 - common.RegisterHandler(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_DollConfig), &CSDollConfigHandler{}) - netlib.RegisterFactory(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_DollConfig), &CSDollConfigPacketFactory{}) } diff --git a/protocol/clawdoll/clawdoll.pb.go b/protocol/clawdoll/clawdoll.pb.go index 4114f55..d801efb 100644 --- a/protocol/clawdoll/clawdoll.pb.go +++ b/protocol/clawdoll/clawdoll.pb.go @@ -1123,11 +1123,7 @@ type SCCLAWDOLLConfig struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IconAddr string `protobuf:"bytes,1,opt,name=IconAddr,proto3" json:"IconAddr,omitempty"` //图片地址 - CostItemNum int32 `protobuf:"varint,2,opt,name=CostItemNum,proto3" json:"CostItemNum,omitempty"` //消耗道具数量 - ItemId int32 `protobuf:"varint,3,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //获得道具ID - ItemNum int32 `protobuf:"varint,4,opt,name=ItemNum,proto3" json:"ItemNum,omitempty"` //获得道具数量 - GameId int32 `protobuf:"varint,5,opt,name=GameId,proto3" json:"GameId,omitempty"` + Info []*MachineInfo `protobuf:"bytes,1,rep,name=info,proto3" json:"info,omitempty"` } func (x *SCCLAWDOLLConfig) Reset() { @@ -1162,37 +1158,88 @@ func (*SCCLAWDOLLConfig) Descriptor() ([]byte, []int) { return file_clawdoll_proto_rawDescGZIP(), []int{14} } -func (x *SCCLAWDOLLConfig) GetIconAddr() string { +func (x *SCCLAWDOLLConfig) GetInfo() []*MachineInfo { + if x != nil { + return x.Info + } + return nil +} + +type MachineInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IconAddr string `protobuf:"bytes,1,opt,name=IconAddr,proto3" json:"IconAddr,omitempty"` //图片地址 + CostItemNum int32 `protobuf:"varint,2,opt,name=CostItemNum,proto3" json:"CostItemNum,omitempty"` //消耗道具数量 + ItemId int32 `protobuf:"varint,3,opt,name=ItemId,proto3" json:"ItemId,omitempty"` //获得道具ID + ItemNum int32 `protobuf:"varint,4,opt,name=ItemNum,proto3" json:"ItemNum,omitempty"` //获得道具数量 + MachineId int32 `protobuf:"varint,5,opt,name=MachineId,proto3" json:"MachineId,omitempty"` +} + +func (x *MachineInfo) Reset() { + *x = MachineInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_clawdoll_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MachineInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MachineInfo) ProtoMessage() {} + +func (x *MachineInfo) ProtoReflect() protoreflect.Message { + mi := &file_clawdoll_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MachineInfo.ProtoReflect.Descriptor instead. +func (*MachineInfo) Descriptor() ([]byte, []int) { + return file_clawdoll_proto_rawDescGZIP(), []int{15} +} + +func (x *MachineInfo) GetIconAddr() string { if x != nil { return x.IconAddr } return "" } -func (x *SCCLAWDOLLConfig) GetCostItemNum() int32 { +func (x *MachineInfo) GetCostItemNum() int32 { if x != nil { return x.CostItemNum } return 0 } -func (x *SCCLAWDOLLConfig) GetItemId() int32 { +func (x *MachineInfo) GetItemId() int32 { if x != nil { return x.ItemId } return 0 } -func (x *SCCLAWDOLLConfig) GetItemNum() int32 { +func (x *MachineInfo) GetItemNum() int32 { if x != nil { return x.ItemNum } return 0 } -func (x *SCCLAWDOLLConfig) GetGameId() int32 { +func (x *MachineInfo) GetMachineId() int32 { if x != nil { - return x.GameId + return x.MachineId } return 0 } @@ -1307,17 +1354,21 @@ var file_clawdoll_proto_rawDesc = []byte{ 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, 0x22, 0x12, 0x0a, 0x10, 0x43, 0x53, 0x43, 0x4c, - 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x9a, 0x01, 0x0a, - 0x10, 0x53, 0x43, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x43, 0x6f, 0x6e, 0x66, 0x69, - 0x67, 0x12, 0x1a, 0x0a, 0x08, 0x49, 0x63, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x49, 0x63, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x12, 0x20, 0x0a, - 0x0b, 0x43, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0b, 0x43, 0x6f, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x12, - 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, - 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, - 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x06, 0x47, 0x61, 0x6d, 0x65, 0x49, 0x64, 0x2a, 0xb3, 0x03, 0x0a, 0x10, 0x43, 0x4c, + 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x22, 0x3d, 0x0a, 0x10, + 0x53, 0x43, 0x43, 0x4c, 0x41, 0x57, 0x44, 0x4f, 0x4c, 0x4c, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x12, 0x29, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, + 0x2e, 0x63, 0x6c, 0x61, 0x77, 0x64, 0x6f, 0x6c, 0x6c, 0x2e, 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, + 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x9b, 0x01, 0x0a, 0x0b, + 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x49, + 0x63, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x49, + 0x63, 0x6f, 0x6e, 0x41, 0x64, 0x64, 0x72, 0x12, 0x20, 0x0a, 0x0b, 0x43, 0x6f, 0x73, 0x74, 0x49, + 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x43, 0x6f, + 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, + 0x6d, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, + 0x64, 0x12, 0x18, 0x0a, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x07, 0x49, 0x74, 0x65, 0x6d, 0x4e, 0x75, 0x6d, 0x12, 0x1c, 0x0a, 0x09, 0x4d, + 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, + 0x4d, 0x61, 0x63, 0x68, 0x69, 0x6e, 0x65, 0x49, 0x64, 0x2a, 0xb3, 0x03, 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, @@ -1370,7 +1421,7 @@ func file_clawdoll_proto_rawDescGZIP() []byte { } var file_clawdoll_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_clawdoll_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_clawdoll_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_clawdoll_proto_goTypes = []interface{}{ (CLAWDOLLPacketID)(0), // 0: clawdoll.CLAWDOLLPacketID (OpResultCode)(0), // 1: clawdoll.OpResultCode @@ -1389,17 +1440,19 @@ var file_clawdoll_proto_goTypes = []interface{}{ (*CLAWDOLLPlayerDigestInfo)(nil), // 14: clawdoll.CLAWDOLLPlayerDigestInfo (*CSCLAWDOLLConfig)(nil), // 15: clawdoll.CSCLAWDOLLConfig (*SCCLAWDOLLConfig)(nil), // 16: clawdoll.SCCLAWDOLLConfig + (*MachineInfo)(nil), // 17: clawdoll.MachineInfo } var file_clawdoll_proto_depIdxs = []int32{ 2, // 0: clawdoll.SCCLAWDOLLRoomInfo.Players:type_name -> clawdoll.CLAWDOLLPlayerData 1, // 1: clawdoll.SCCLAWDOLLOp.OpRetCode:type_name -> clawdoll.OpResultCode 14, // 2: clawdoll.SCCLAWDOLLPlayerEnter.Data:type_name -> clawdoll.CLAWDOLLPlayerDigestInfo 14, // 3: clawdoll.CLAWDOLLWaitPlayers.WaitPlayersInfo:type_name -> clawdoll.CLAWDOLLPlayerDigestInfo - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 17, // 4: clawdoll.SCCLAWDOLLConfig.info:type_name -> clawdoll.MachineInfo + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_clawdoll_proto_init() } @@ -1588,6 +1641,18 @@ func file_clawdoll_proto_init() { return nil } } + file_clawdoll_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MachineInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -1595,7 +1660,7 @@ func file_clawdoll_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_clawdoll_proto_rawDesc, NumEnums: 2, - NumMessages: 15, + NumMessages: 16, NumExtensions: 0, NumServices: 0, }, diff --git a/protocol/clawdoll/clawdoll.proto b/protocol/clawdoll/clawdoll.proto index d1e671b..2ddaf13 100644 --- a/protocol/clawdoll/clawdoll.proto +++ b/protocol/clawdoll/clawdoll.proto @@ -137,9 +137,12 @@ message CLAWDOLLPlayerDigestInfo { message CSCLAWDOLLConfig{ } message SCCLAWDOLLConfig{ + repeated MachineInfo info =1; +} +message MachineInfo{ string IconAddr =1; //图片地址 int32 CostItemNum = 2; //消耗道具数量 int32 ItemId = 3; //获得道具ID int32 ItemNum = 4;//获得道具数量 - int32 GameId = 5; + int32 MachineId = 5; } diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index f9d1bcf..fddcb7a 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "math/rand" + "mongo.games.com/game/protocol/clawdoll" "net/url" "regexp" "strconv" @@ -3204,6 +3205,34 @@ func CSClawdollItemLog(s *netlib.Session, packetId int, data interface{}, sid in return nil } +func CSCLAWDOLLConfig(s *netlib.Session, packetId int, data interface{}, sid int64) error { + logger.Logger.Tracef("CSDollConfigHandler") + if _, ok := data.(*clawdoll.CSCLAWDOLLConfig); ok { + p := PlayerMgrSington.GetPlayer(sid) + if p == nil { + logger.Logger.Warn("CSDollConfigHandler p == nil") + return nil + } + + machineInfo := PlatformMgrSingleton.GetConfig(p.Platform).MachineConfig + if machineInfo == nil { + return nil + } + pack := &clawdoll.SCCLAWDOLLConfig{} + for _, value := range machineInfo.Info { + info := &clawdoll.MachineInfo{ + IconAddr: value.IconAddr, + CostItemNum: value.CostItemNum, + ItemId: value.ItemId, + ItemNum: value.ItemNum, + MachineId: value.MachineId, + } + pack.Info = append(pack.Info, info) + } + p.SendToClient(int(clawdoll.CLAWDOLLPacketID_PACKET_SC_DollConfig), pack) + } + return nil +} func init() { // 用户信息 common.Register(int(player_proto.PlayerPacketID_PACKET_CS_PLAYERDATA), player_proto.CSPlayerData{}, CSPlayerData) @@ -3239,4 +3268,6 @@ func init() { common.Register(int(player_proto.PlayerPacketID_PACKET_CSUpdateAttribute), player_proto.CSUpdateAttribute{}, CSUpdateAttribute) //娃娃卡道具记录 common.Register(int(player_proto.PlayerPacketID_PACKET_CSClawdollItemLog), player_proto.CSClawdollItemLog{}, CSClawdollItemLog) + //客户端请求配置信息 + common.Register(int(clawdoll.CLAWDOLLPacketID_PACKET_CS_DollConfig), clawdoll.CSCLAWDOLLConfig{}, CSCLAWDOLLConfig) } diff --git a/worldsrv/etcd.go b/worldsrv/etcd.go index 606899b..a2419f9 100644 --- a/worldsrv/etcd.go +++ b/worldsrv/etcd.go @@ -97,6 +97,8 @@ func init() { etcd.Register(etcd.ETCDKEY_RoomConfig, webapi.RoomConfig{}, handlerEvent) // 竞技馆房间类型配置 etcd.Register(etcd.ETCDKEY_RoomType, webapi.RoomType{}, handlerEvent) + //娃娃机配置 + etcd.Register(etcd.ETCDKEY_MACHINE, webapi.MachineConfig{}, handlerEvent) } func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) { @@ -324,6 +326,8 @@ func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, e PlatformMgrSingleton.GetConfig(config.Platform).AwardLogConfig = config case *webapi.GuideConfig: PlatformMgrSingleton.GetConfig(config.Platform).GuideConfig = config + case *webapi.MachineConfig: + PlatformMgrSingleton.GetConfig(config.Platform).MachineConfig = config case *webapi.SpiritConfig: PlatformMgrSingleton.GetConfig(config.Platform).SpiritConfig = config if !isInit {