上传测试服代码

This commit is contained in:
liwei 2023-07-06 17:21:09 +08:00
parent 99267bfee3
commit 3b45e361bc
4 changed files with 278 additions and 742 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,12 +20,14 @@ const (
type configureComp struct { type configureComp struct {
modules.MCompConfigure modules.MCompConfigure
module *Worldtask
lock sync.RWMutex lock sync.RWMutex
worldtaskConf map[int32]*cfg.GameWorldTaskData //key 条件ID worldtaskConf map[int32]*cfg.GameWorldTaskData //key 条件ID
} }
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options) err = this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Worldtask)
err = this.LoadMultiConfigure(map[string]interface{}{ err = this.LoadMultiConfigure(map[string]interface{}{
gameWorldTask: cfg.NewGameWorldTask, gameWorldTask: cfg.NewGameWorldTask,
gameWorldtaskBattle: cfg.NewGameWorldBattle, gameWorldtaskBattle: cfg.NewGameWorldBattle,
@ -38,6 +40,77 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
return return
} }
func (this *configureComp) Start() (err error) {
err = this.MCompConfigure.Start()
this.checkWorldtaskConf()
conf, err := this.getWorldtaskCfg()
if err != nil {
return err
}
this.worldtaskConf = conf.GetDataMap()
return
}
// 配置文件校验
func (this *configureComp) checkWorldtaskConf() (err error) {
worldtaskConf, err := this.getWorldtaskCfg()
if err != nil {
return err
}
buriedCondConf, err := this.getBuriedCondCfg()
if err != nil {
return err
}
for _, data := range worldtaskConf.GetDataList() {
// 检查 lock
if data.Lock < 1 {
this.module.Errorf("taskId:%v lock:%v可能存在问题", data.Key, data.Lock)
}
//检查group
if data.Group <= 0 {
this.module.Errorf("taskId:%v group:%v可能存在问题", data.Key, data.Group)
}
//检查des
if data.Des < 1 || data.Des > 5 {
// errs = append(errs, fmt.Sprintf("taskId:%v des:%v可能存在问题", data.Key, data.Des))
this.module.Errorf("taskId:%v des:%v可能存在问题", data.Key, data.Des)
}
// 检查completetask 是否有效
for _, condId := range data.Completetask {
if condId > 0 {
if _, ok := buriedCondConf.GetDataMap()[condId]; !ok {
this.module.Errorf("taskId:%v completetask:%v可能是无效的ID", data.Key, condId)
// errs = append(errs, fmt.Sprintf("taskId:%v completetask:%v可能是无效的ID", data.Key, condId))
}
}
}
//检查NPC
if data.Npc > 0 {
if _, err := this.getNPCById(data.Npc); err != nil {
this.module.Errorf("npcId:%v 可能无效,检查world_task表字段Npc值是否存在于buried/rdtasknpc", data.Npc)
// errs = append(errs, fmt.Sprintf("npcId:%v 可能无效,检查world_task表字段Npc值是否存在于buried/rdtasknpc", data.Npc))
}
}
if data.DeliverNpc > 0 {
if _, err := this.getNPCById(data.Npc); err != nil {
this.module.Errorf("npcId:%v 可能无效,检查world_task表字段deliver_npc值是否存在于buried/rdtasknpc", data.Npc)
// errs = append(errs, fmt.Sprintf("npcId:%v 可能无效,检查world_task表字段deliver_npc值是否存在于buried/rdtasknpc", data.Npc))
}
}
}
for _, data := range buriedCondConf.GetDataList() {
if data.NPC > 0 {
if _, err := this.getNPCById(data.NPC); err != nil {
this.module.Errorf("npcId:%v 可能无效,检查buried_condi表字段NPC值是否存在于buried/rdtasknpc", data.NPC)
}
}
}
return
}
func (this *configureComp) getWorldtaskCfg() (data *cfg.GameWorldTask, err error) { func (this *configureComp) getWorldtaskCfg() (data *cfg.GameWorldTask, err error) {
var ( var (
v interface{} v interface{}

View File

@ -11,7 +11,6 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"strings"
) )
var _ comm.IWorldtask = (*Worldtask)(nil) var _ comm.IWorldtask = (*Worldtask)(nil)
@ -37,7 +36,6 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options
func (this *Worldtask) OnInstallComp() { func (this *Worldtask) OnInstallComp() {
this.ModuleBase.OnInstallComp() this.ModuleBase.OnInstallComp()
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
this.api = this.RegisterComp(new(apiComp)).(*apiComp) this.api = this.RegisterComp(new(apiComp)).(*apiComp)
this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask) this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask)
this.configure = this.RegisterComp(new(configureComp)).(*configureComp) this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
@ -50,14 +48,7 @@ func (this *Worldtask) GetType() core.M_Modules {
func (this *Worldtask) Start() (err error) { func (this *Worldtask) Start() (err error) {
err = this.ModuleBase.Start() err = this.ModuleBase.Start()
if err = this.checkWorldtaskConf(); err != nil { event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
return err
}
conf, err := this.configure.getWorldtaskCfg()
if err != nil {
return err
}
this.configure.worldtaskConf = conf.GetDataMap()
return return
} }
@ -68,66 +59,6 @@ func (this *Worldtask) OpenCmdNotice(session comm.IUserSession, keys ...string)
var errs []string var errs []string
// 配置文件校验
func (this *Worldtask) checkWorldtaskConf() (err error) {
worldtaskConf, err := this.configure.getWorldtaskCfg()
if err != nil {
return err
}
buriedCondConf, err := this.configure.getBuriedCondCfg()
if err != nil {
return err
}
for _, data := range worldtaskConf.GetDataList() {
// 检查 lock
if data.Lock < 1 {
errs = append(errs, fmt.Sprintf("taskId:%v lock:%v可能存在问题", data.Key, data.Lock))
}
//检查group
if data.Group <= 0 {
errs = append(errs, fmt.Sprintf("taskId:%v group:%v可能存在问题", data.Key, data.Group))
}
//检查des
if data.Des < 1 || data.Des > 5 {
errs = append(errs, fmt.Sprintf("taskId:%v des:%v可能存在问题", data.Key, data.Des))
}
// 检查completetask 是否有效
for _, condId := range data.Completetask {
if condId > 0 {
if _, ok := buriedCondConf.GetDataMap()[condId]; !ok {
errs = append(errs, fmt.Sprintf("taskId:%v completetask:%v可能是无效的ID", data.Key, condId))
}
}
}
//检查NPC
if data.Npc > 0 {
if _, err := this.configure.getNPCById(data.Npc); err != nil {
errs = append(errs, fmt.Sprintf("npcId:%v 可能无效,检查world_task表字段Npc值是否存在于buried/rdtasknpc", data.Npc))
}
}
if data.DeliverNpc > 0 {
if _, err := this.configure.getNPCById(data.Npc); err != nil {
errs = append(errs, fmt.Sprintf("npcId:%v 可能无效,检查world_task表字段deliver_npc值是否存在于buried/rdtasknpc", data.Npc))
}
}
}
for _, data := range buriedCondConf.GetDataList() {
if data.NPC > 0 {
if _, err := this.configure.getNPCById(data.NPC); err != nil {
errs = append(errs, fmt.Sprintf("npcId:%v 可能无效,检查buried_condi表字段NPC值是否存在于buried/rdtasknpc", data.NPC))
}
}
}
if len(errs) > 0 {
return fmt.Errorf("%s", strings.Join(errs, "|"))
}
this.Debug("check worldtask conf completed")
return
}
// 完成条件通知 // 完成条件通知
func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) { func (this *Worldtask) TCondFinishNotify(uid string, conds []*pb.ConIProgress) {
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condIds", Value: conds}) this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condIds", Value: conds})

View File

@ -238,7 +238,7 @@ func (this *WTask) fishtask(session comm.IUserSession, wtask *pb.DBWTask) {
opencmd = append(opencmd, k) opencmd = append(opencmd, k)
} }
} }
if user = this.ModuleUser.GetUser(session.GetUserId()); user != nil { if user = this.ModuleUser.GetUser(session.GetUserId()); user == nil {
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: session.GetUserId()}) this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: session.GetUserId()})
return return
} }
@ -295,7 +295,7 @@ func (this *WTask) inquireActivations(session comm.IUserSession, wtask *pb.DBWTa
if _, ok = activatMap[v.Key]; ok { //已在可接取列表中 if _, ok = activatMap[v.Key]; ok { //已在可接取列表中
continue continue
} }
if _, ok = acceptsMap[v.Key]; ok { //已在已接取任务列表中 if _, ok = acceptsMap[v.Key]; v.LockAdd == 0 && ok { //已在已接取任务列表中 LockAdd 0 表示只能接取一次 1 表示可以重复接取
continue continue
} }
if _, ok = completeMap[v.Key]; ok { //已在完成列表中 if _, ok = completeMap[v.Key]; ok { //已在完成列表中