上传测试服代码
This commit is contained in:
parent
99267bfee3
commit
3b45e361bc
File diff suppressed because it is too large
Load Diff
@ -20,12 +20,14 @@ const (
|
||||
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Worldtask
|
||||
lock sync.RWMutex
|
||||
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) {
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
this.module = module.(*Worldtask)
|
||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||
gameWorldTask: cfg.NewGameWorldTask,
|
||||
gameWorldtaskBattle: cfg.NewGameWorldBattle,
|
||||
@ -38,6 +40,77 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
||||
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) {
|
||||
var (
|
||||
v interface{}
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var _ comm.IWorldtask = (*Worldtask)(nil)
|
||||
@ -37,7 +36,6 @@ func (this *Worldtask) Init(service core.IService, module core.IModule, options
|
||||
|
||||
func (this *Worldtask) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||
this.api = this.RegisterComp(new(apiComp)).(*apiComp)
|
||||
this.modelWorldtask = this.RegisterComp(new(ModelWorldtask)).(*ModelWorldtask)
|
||||
this.configure = this.RegisterComp(new(configureComp)).(*configureComp)
|
||||
@ -50,14 +48,7 @@ func (this *Worldtask) GetType() core.M_Modules {
|
||||
|
||||
func (this *Worldtask) Start() (err error) {
|
||||
err = this.ModuleBase.Start()
|
||||
if err = this.checkWorldtaskConf(); err != nil {
|
||||
return err
|
||||
}
|
||||
conf, err := this.configure.getWorldtaskCfg()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
this.configure.worldtaskConf = conf.GetDataMap()
|
||||
event.Register(comm.EventBuriedComplete, this.TCondFinishNotify)
|
||||
return
|
||||
}
|
||||
|
||||
@ -68,66 +59,6 @@ func (this *Worldtask) OpenCmdNotice(session comm.IUserSession, keys ...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) {
|
||||
this.Debug("世界任务完成条件通知", log.Field{Key: "uid", Value: uid}, log.Field{Key: "condIds", Value: conds})
|
||||
|
@ -238,7 +238,7 @@ func (this *WTask) fishtask(session comm.IUserSession, wtask *pb.DBWTask) {
|
||||
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()})
|
||||
return
|
||||
}
|
||||
@ -295,7 +295,7 @@ func (this *WTask) inquireActivations(session comm.IUserSession, wtask *pb.DBWTa
|
||||
if _, ok = activatMap[v.Key]; ok { //已在可接取列表中
|
||||
continue
|
||||
}
|
||||
if _, ok = acceptsMap[v.Key]; ok { //已在已接取任务列表中
|
||||
if _, ok = acceptsMap[v.Key]; v.LockAdd == 0 && ok { //已在已接取任务列表中 LockAdd 0 表示只能接取一次 1 表示可以重复接取
|
||||
continue
|
||||
}
|
||||
if _, ok = completeMap[v.Key]; ok { //已在完成列表中
|
||||
|
Loading…
Reference in New Issue
Block a user