上传任务对象池
This commit is contained in:
parent
5acf0521c4
commit
05e35cac0a
24
comm/pool.go
Normal file
24
comm/pool.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
package comm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go_dreamfactory/pb"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
var taskParamPool = &sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return &pb.AgentMessage{}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func GettaskParam(t TaskType, p ...int32) *TaskParam {
|
||||||
|
task := taskParamPool.Get().(*TaskParam)
|
||||||
|
task.TT = t
|
||||||
|
task.Params = append(task.Params, p...)
|
||||||
|
return task
|
||||||
|
}
|
||||||
|
|
||||||
|
func PuttaskParam(r *TaskParam) {
|
||||||
|
r.Params = r.Params[:0]
|
||||||
|
taskParamPool.Put(r)
|
||||||
|
}
|
@ -97,6 +97,7 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma
|
|||||||
configure *cfg.GameEquip
|
configure *cfg.GameEquip
|
||||||
add map[string]*pb.DB_Equipment
|
add map[string]*pb.DB_Equipment
|
||||||
uId string = session.GetUserId()
|
uId string = session.GetUserId()
|
||||||
|
tasks []*comm.TaskParam
|
||||||
)
|
)
|
||||||
if configure, err = this.module.configure.GetEquipmentConfigure(); err != nil {
|
if configure, err = this.module.configure.GetEquipmentConfigure(); err != nil {
|
||||||
return
|
return
|
||||||
@ -110,8 +111,8 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma
|
|||||||
return nil, err
|
return nil, err
|
||||||
} else {
|
} else {
|
||||||
//随机任务
|
//随机任务
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype50, 1, c.Star)
|
tasks = append(tasks, comm.GettaskParam(comm.Rtype50, 1, c.Star))
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype97, 1, c.Suittype, c.Star)
|
tasks = append(tasks, comm.GettaskParam(comm.Rtype97, 1, c.Suittype, c.Star))
|
||||||
unm := int32(1)
|
unm := int32(1)
|
||||||
if equipment.AdverbEntry != nil {
|
if equipment.AdverbEntry != nil {
|
||||||
unm += int32(len(equipment.AdverbEntry))
|
unm += int32(len(equipment.AdverbEntry))
|
||||||
@ -119,19 +120,24 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma
|
|||||||
if equipment.Adverbskill != nil {
|
if equipment.Adverbskill != nil {
|
||||||
unm += int32(len(equipment.Adverbskill))
|
unm += int32(len(equipment.Adverbskill))
|
||||||
}
|
}
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype99, 1, unm, c.Star)
|
tasks = append(tasks, comm.GettaskParam(comm.Rtype99, 1, unm, c.Star))
|
||||||
if c.Pos == 7 {
|
if c.Pos == 7 {
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype103, 1, c.Star)
|
tasks = append(tasks, comm.GettaskParam(comm.Rtype103, 1, c.Star))
|
||||||
} else if c.Pos == 6 {
|
} else if c.Pos == 6 {
|
||||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype101, 1, c.Star)
|
tasks = append(tasks, comm.GettaskParam(comm.Rtype101, 1, c.Star))
|
||||||
}
|
}
|
||||||
|
|
||||||
add[equipment.Id] = equipment
|
add[equipment.Id] = equipment
|
||||||
change = append(change, equipment)
|
change = append(change, equipment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//异步出发任务启动
|
||||||
|
if len(tasks) > 0 {
|
||||||
|
go this.module.ModuleRtask.TriggerTask(session.GetUserId(), tasks...)
|
||||||
|
}
|
||||||
|
|
||||||
if len(add) > 0 {
|
if len(add) > 0 {
|
||||||
var (
|
var (
|
||||||
model *db.DBModel
|
model *db.DBModel
|
||||||
@ -151,7 +157,6 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user