提交道具背包优化

This commit is contained in:
liwei1dao 2022-07-15 20:08:03 +08:00
parent 840bc4c986
commit 9e699cc116

View File

@ -17,16 +17,16 @@ func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.ItemsGetlis
///获取用户道具 ///获取用户道具
func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq) (code pb.ErrorCode, data proto.Message) { func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq) (code pb.ErrorCode, data proto.Message) {
var ( var (
err error err error
items []*pb.DB_UserItemData items []*pb.DB_UserItemData
nt int64 nt int64
tempgrids []*pb.DB_UserItemData // tempgrids []*pb.DB_UserItemData
grids []*pb.DB_UserItemData grids []*pb.DB_UserItemData
modifys []*pb.DB_UserItemData modifys []*pb.DB_UserItemData
dels []*pb.DB_UserItemData dels []*pb.DB_UserItemData
) )
defer func() { defer func() {
session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: grids}) session.SendMsg(string(this.module.GetType()), "getlist", &pb.ItemsGetlistResp{Grids: items})
if code == pb.ErrorCode_Success { if code == pb.ErrorCode_Success {
go func() { //异步处理修改数据 go func() { //异步处理修改数据
if len(modifys) > 0 { if len(modifys) > 0 {
@ -44,12 +44,12 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
code = pb.ErrorCode_CacheReadError code = pb.ErrorCode_CacheReadError
return return
} else { } else {
tempgrids = this.module.configure.GetPackItemByType(items, req.IType) // tempgrids = this.module.configure.GetPackItemByType(items, req.IType)
modifys = make([]*pb.DB_UserItemData, 0, len(tempgrids)) modifys = make([]*pb.DB_UserItemData, 0, len(items))
dels = make([]*pb.DB_UserItemData, 0, len(tempgrids)) dels = make([]*pb.DB_UserItemData, 0, len(items))
grids = make([]*pb.DB_UserItemData, 0, len(items)) grids = make([]*pb.DB_UserItemData, 0, len(items))
nt = time.Now().Unix() nt = time.Now().Unix()
for _, v := range tempgrids { for _, v := range items {
if v.ETime > 0 && v.ETime < nt { //已经过期 if v.ETime > 0 && v.ETime < nt { //已经过期
dels = append(dels, v) dels = append(dels, v)
} else { } else {