diff --git a/bin/json/game_worldtask.json b/bin/json/game_worldtask.json index 4d51e84d2..50da7ab9b 100644 --- a/bin/json/game_worldtask.json +++ b/bin/json/game_worldtask.json @@ -634,7 +634,7 @@ 406 ], "completetask": 0, - "auto_accept": 1, + "auto_accept": 0, "overtips": 1, "reword": [], "module": [] @@ -747,7 +747,7 @@ }, "npc": [ "bossfight_pt_02", - "新手引导-波比-右屏圣树1", + "3新手引导-波比-正常待机-中轴城", "901" ], "receivenpc": [ @@ -787,7 +787,7 @@ }, "npc": [ "bossfight_pt_02", - "新手引导-波比-右屏圣树2", + "3新手引导-波比-正常待机-中轴城", "901" ], "receivenpc": [ @@ -993,7 +993,7 @@ }, "npc": [ "bossfight_pt_02", - "新手引导-波比-右屏圣树3", + "3新手引导-波比-正常待机-中轴城", "901" ], "receivenpc": [ @@ -1033,7 +1033,7 @@ }, "npc": [ "bossfight_pt_02", - "新手引导-波比-右屏圣树3", + "3新手引导-波比-正常待机-中轴城", "901" ], "receivenpc": [ diff --git a/cmd/v2/FyneApp.toml b/cmd/v2/FyneApp.toml index 0e8f9b054..3059a2a98 100644 --- a/cmd/v2/FyneApp.toml +++ b/cmd/v2/FyneApp.toml @@ -4,5 +4,5 @@ Website = "http://legu.cc" Icon = "app.png" Name = "RobotGUI" ID = "cc.legu.app" - Version = "1.2.10" - Build = 40 + Version = "1.2.11" + Build = 41 diff --git a/cmd/v2/lib/storage/config.go b/cmd/v2/lib/storage/config.go index e52e626ee..a61e783f8 100644 --- a/cmd/v2/lib/storage/config.go +++ b/cmd/v2/lib/storage/config.go @@ -41,6 +41,12 @@ type Config struct { MgoDB *MgoDB `json:"mgoDB,omitempty"` //MongoDB配置 ServiceDBInfo *pb.ServiceDBInfo `json:"serviceDBInfo,omitempty"` // JsonDir string `json:"jsonDir,omitempty"` //json配置目录 + PingConf *PingConf `json:"pingConf,omitempty"` //ping配置 +} + +type PingConf struct { + Host string + Ports string } type MgoDB struct { diff --git a/cmd/v2/ui/tool_ping.go b/cmd/v2/ui/tool_ping.go index 9e4cccd40..d32523261 100644 --- a/cmd/v2/ui/tool_ping.go +++ b/cmd/v2/ui/tool_ping.go @@ -3,6 +3,7 @@ package ui import ( "fmt" "go_dreamfactory/cmd/v2/lib/common" + os_storage "go_dreamfactory/cmd/v2/lib/storage" "go_dreamfactory/cmd/v2/service" "go_dreamfactory/cmd/v2/service/observer" "net" @@ -37,17 +38,56 @@ func (this *appPing) LazyInit(ptService service.PttService, obs observer.Observe targetHost := widget.NewEntry() targetHost.PlaceHolder = "目标主机Ip" + //load + storage, _ := os_storage.NewOSStorage() + conf, err := storage.LoadConfig() + if err != nil { + return err + } portEntry := widget.NewMultiLineEntry() portEntry.Text = "20,21,22,80,1521,2379,2380,3306,6379,8080,8020,8500,9000,9090,13306,50070,27019,10013,8300,8301,8600,10012,10011" + saveBtn := widget.NewButton("保存配置", func() { + pingConf := &os_storage.PingConf{ + Host: targetHost.Text, + Ports: portEntry.Text, + } + conf.PingConf = pingConf + if err := storage.StoreConfig(conf); err != nil { + logrus.WithField("err", err).Debug("保存配置") + return + } + }) + form := widget.NewForm( widget.NewFormItem("主机", targetHost), - widget.NewFormItem("端口", portEntry), + widget.NewFormItem("端口", container.NewBorder(nil, nil, nil, saveBtn, portEntry)), ) + + if conf.PingConf != nil { + targetHost.SetText(conf.PingConf.Host) + portEntry.SetText(conf.PingConf.Ports) + } // result result := widget.NewMultiLineEntry() result.Disable() + //初始化端口对应说明字典 + portDesc := map[int]string{ + 7891: "websocket", + 10013: "MongoDB", + 10011: "Redis", + 10012: "Consul", + 9567: "gateway", + 9568: "mainte", + 9569: "worker", + 9897: "battle", + 8001: "cross_mainte", + 9570: "cross_worker", + 8000: "web", + 9571: "cross_web", + } + form.OnSubmit = func() { result.Text = "" if portEntry.Text == "" { @@ -87,13 +127,17 @@ func (this *appPing) LazyInit(ptService service.PttService, obs observer.Observe this.ping(ip.String(), ports) for p := range this.resultCh { - msgs = append(msgs, fmt.Sprintf("端口:%d %s", p.port, p.err)) + desc, ok := portDesc[p.port] + if !ok { + desc = "未知" + } + msgs = append(msgs, fmt.Sprintf("%s 端口:%d %s", desc, p.port, p.err)) result.Text = strings.Join(msgs, "\n") result.Refresh() } - } form.Items[1].HintText = "多个端口使用英文,号分隔" + form.SubmitText = "Ping" result.OnChanged = func(s string) { result.Refresh() diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index ef6f7f6e0..7c8c2aa54 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -56,7 +56,6 @@ type Agent struct { closeSignal chan bool state int32 //状态 0 关闭 1 运行 2 关闭中 wg sync.WaitGroup - hlock sync.RWMutex protoMsg map[string]int64 } @@ -97,32 +96,27 @@ locp: code, err = this.secAuth(msg) if err == nil { this.gateway.Debugf("----------2 agent:%s uId:%s MainType:%s SubType:%s ", this.sessionId, this.uId, msg.MainType, msg.SubType) - if this.uId != "" { - key := this.uId + msg.MainType + msg.SubType // 加锁 - if v, ok := this.protoMsg[key]; ok { - if v != 0 && configure.Now().Unix()-v < 2 { - // 返回错误码 - this.hlock.Lock() - this.protoMsg[key] = configure.Now().Unix() - this.hlock.Unlock() - data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ - ReqMainType: msg.MainType, - ReqSubType: msg.SubType, - Arg: msg.Data, - Code: pb.ErrorCode_InsufficientPermissions}) - err = this.WriteMsg(&pb.UserMessage{ - MainType: comm.MainTypeNotify, - SubType: comm.SubTypeErrorNotify, - Data: data, - }) - continue - } - } - this.hlock.Lock() - this.protoMsg[key] = configure.Now().Unix() - this.hlock.Unlock() + key := msg.MainType + msg.SubType // 加锁 + if v, ok := this.protoMsg[key]; ok { + if v != 0 && configure.Now().Unix()-v < 2 { + // 返回错误码 + this.protoMsg[key] = configure.Now().Unix() + data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ + ReqMainType: msg.MainType, + ReqSubType: msg.SubType, + Arg: msg.Data, + Code: pb.ErrorCode_InsufficientPermissions}) + err = this.WriteMsg(&pb.UserMessage{ + MainType: comm.MainTypeNotify, + SubType: comm.SubTypeErrorNotify, + Data: data, + }) + continue + } } + this.protoMsg[key] = configure.Now().Unix() + if err := this.messageDistribution(msg); err != nil { this.gateway.Errorf("messageDistribution err:%v", err) go this.Close() @@ -372,14 +366,9 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) { log.Field{Key: "req", Value: fmt.Sprintf("%s:%s %v", req.MainType, req.SubType, req.Message.String())}, log.Field{Key: "reply", Value: reply.String()}, ) - - if this.uId != "" { - key := this.uId + msg.MainType + msg.SubType - this.hlock.Lock() - if v, ok := this.protoMsg[key]; ok && v != 0 { // 发送消息 协议解锁 - v = 0 - } - this.hlock.Unlock() + key := msg.MainType + msg.SubType + if v, ok := this.protoMsg[key]; ok && v != 0 { // 发送消息 协议解锁 + v = 0 } if reply.Code != pb.ErrorCode_Success { data, _ := anypb.New(&pb.NotifyErrorNotifyPush{ diff --git a/modules/sociaty/module.go b/modules/sociaty/module.go index 9ae791ad9..418e459a8 100644 --- a/modules/sociaty/module.go +++ b/modules/sociaty/module.go @@ -130,7 +130,7 @@ func (this *Sociaty) MembersBySociatyId(sociatyId string) (list []*pb.SociatyMem return this.modelSociaty.members(sociaty) } -//公会 +// 公会 func (this *Sociaty) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]bool) { reddot = make(map[comm.ReddotType]bool) sociaty := this.modelSociaty.getUserSociaty(session.GetUserId()) @@ -192,7 +192,7 @@ type SociatyUpdateParam struct { Update map[string]interface{} } -//跨服更新数据 +// 跨服更新数据 func (this *Sociaty) RpcUpdateSociaty(ctx context.Context, req *SociatyUpdateParam, reply *pb.DBSociaty) error { return this.modelSociaty.ChangeList(comm.RDS_EMPTY, req.SociatyId, req.Update) } @@ -308,3 +308,23 @@ func (this *Sociaty) RpcGetUserTask(ctx context.Context, p *pb.RPCGeneralReqA2, reply.LastUpdateTime = dt.LastUpdateTime return nil } + +// 创建公会3.10 +func (this *Sociaty) CreateSociaty(uid, sociatyName string) error { + //创建公会 + sociaty := &pb.DBSociaty{ + Creater: uid, + Name: sociatyName, + Icon: "wp_icon_10015", + ApplyLv: 1, + } + + //会长 + sociaty.Members = append(sociaty.Members, &pb.SociatyMember{ + Uid: uid, + Job: pb.SociatyJob_PRESIDENT, //创建人是会长 + Ctime: configure.Now().Unix(), + }) + + return this.modelSociaty.create(sociaty) +} diff --git a/modules/user/api_create.go b/modules/user/api_create.go index 81c1244ba..698085003 100644 --- a/modules/user/api_create.go +++ b/modules/user/api_create.go @@ -23,7 +23,7 @@ func (this *apiComp) CreateCheck(session comm.IUserSession, req *pb.UserCreateRe return } -//创角 +// 创角 func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (code pb.ErrorCode, data proto.Message) { if code = this.CreateCheck(session, req); code != pb.ErrorCode_Success { return @@ -96,6 +96,9 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.UserCreateReq) (c //初始化用户设置 // this.module.modelSetting.InitSetting(session.GetUserId()) + //初始化公会 date3.10 + this.module.CrossCreateSociaty(uid, req.NickName) + if err := session.SendMsg(string(this.module.GetType()), UserSubTypeCreate, &pb.UserCreateResp{IsSucc: true}); err != nil { code = pb.ErrorCode_SystemError } diff --git a/modules/user/module.go b/modules/user/module.go index eb0941fdb..1e9dc9211 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -9,6 +9,7 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" "go_dreamfactory/sys/db" "go_dreamfactory/utils" "strings" @@ -24,6 +25,7 @@ import ( "github.com/pkg/errors" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/mongo" ) @@ -36,6 +38,9 @@ const ( Rpc_GetCrossUserSession string = "Rpc_GetCrossUserSession" // 搜索用户 Rpc_QueryUser = "Rpc_QueryUser" + + //创建公会 + Rpc_CreateSociaty string = "Rpc_CreateSociaty" ) var _ comm.IUser = (*User)(nil) @@ -78,6 +83,8 @@ func (this *User) Start() (err error) { this.service.RegisterFunctionName(Rpc_GetCrossUser, this.RpcGetCrossUser) this.service.RegisterFunctionName(Rpc_GetCrossUserSession, this.RpcGetCrossUserSession) this.service.RegisterFunctionName(Rpc_QueryUser, this.RpcQueryUser) + //date 3.10 + this.service.RegisterFunctionName(Rpc_CreateSociaty, this.RpcCreateSociaty) this.globalConf = this.configure.GetGlobalConf() if this.globalConf == nil { err = errors.New("global config not found") @@ -237,6 +244,45 @@ func (this *User) CrossUserSession(uid string) *pb.CacheUser { return cacheUser } +// 跨服创建玩家公会 date 3.10 +func (this *User) CrossCreateSociaty(uid, sociatyName string) *pb.EmptyResp { + this.service.AcrossClusterRpcCall(context.Background(), this.GetCrossTag(), + comm.Service_Worker, Rpc_CreateSociaty, &pb.RPCGeneralReqA2{Param1: uid, Param2: sociatyName}, &pb.EmptyResp{}) + return nil +} + +// date 3.10 +func (this *User) RpcCreateSociaty(ctx context.Context, req *pb.RPCGeneralReqA2, reply *pb.EmptyResp) error { + conn, err := db.Local() + if err != nil { + return err + } + model := db.NewDBModel(comm.TableSociaty, 0, conn) + + sociaty := &pb.DBSociaty{} + _id := primitive.NewObjectID().Hex() + sociaty.Creater = req.Param1 + sociaty.Name = req.Param2 + sociaty.Icon = "wp_icon_10015" + sociaty.ApplyLv = 1 + sociaty.Id = _id + sociaty.Ctime = configure.Now().Unix() + sociaty.Lv = 1 //默认1级 + + sociaty.Members = append(sociaty.Members, &pb.SociatyMember{ + Uid: req.Param1, + Job: pb.SociatyJob_PRESIDENT, + Ctime: configure.Now().Unix(), + }) + + if err := model.AddList(comm.RDS_EMPTY, sociaty.Id, sociaty); err != nil { + if err != mongo.ErrNoDocuments { + return err + } + } + return nil +} + // 跨服搜索用户 func (this *User) CrossSearchUser(nickName string) ([]*pb.DBUser, error) { name := strings.TrimSpace(nickName)