数据校验

This commit is contained in:
meixiongfeng 2024-01-19 10:58:21 +08:00
parent 3d53840adb
commit c72dac2975
4 changed files with 45 additions and 9 deletions

View File

@ -58,7 +58,20 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.PlunderChallen
return return
} }
} }
if req.Pos >= int32(len(list.Line)) {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
if list.Line[req.Pos].Closetime == -1 { // 队列没解锁
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PlunderLineUnlock,
Title: pb.ErrorCode_PlunderLineUnlock.ToString(),
}
return
}
// 配置校验 // 配置校验
if conf, err = this.module.configure.getGamePlunderDataById(list.Source[req.Index]); err != nil { if conf, err = this.module.configure.getGamePlunderDataById(list.Source[req.Index]); err != nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{

View File

@ -38,9 +38,11 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PlunderCha
shipData *pb.ShipData // 船 shipData *pb.ShipData // 船
users []string users []string
update map[string]interface{} // update map[string]interface{} //
newShip map[string]*pb.ShipData
) )
update = make(map[string]interface{}) update = make(map[string]interface{})
changExp = make(map[string]int32, 0) changExp = make(map[string]int32, 0)
newShip = make(map[string]*pb.ShipData, 0)
if errdata = this.ChallengeOverCheck(session, req); errdata != nil { if errdata = this.ChallengeOverCheck(session, req); errdata != nil {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }
@ -76,6 +78,20 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PlunderCha
} }
return return
} }
if req.Pos >= int32(len(list.Line)) {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
}
return
}
if list.Line[req.Pos].Closetime == -1 { // 队列没解锁
errdata = &pb.ErrorData{
Code: pb.ErrorCode_PlunderLineUnlock,
Title: pb.ErrorCode_PlunderLineUnlock.ToString(),
}
return
}
// 校验通过 // 校验通过
errdata, isWin = this.module.battle.CheckBattleReport(session, req.Report) errdata, isWin = this.module.battle.CheckBattleReport(session, req.Report)
if errdata != nil { if errdata != nil {
@ -116,11 +132,13 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PlunderCha
} }
list.Count++ list.Count++
update["count"] = list.Count update["count"] = list.Count
list.Line[req.Index].Oid = _id
list.Line[req.Pos].Oid = _id
update["line"] = list.Line update["line"] = list.Line
list.Setout = append(list.Setout, req.Index) list.Setout = append(list.Setout, req.Index)
update["setout"] = list.Setout update["setout"] = list.Setout
// 广播用
newShip[_id] = shipData
this.module.modelPlunder.changePlunderData(session.GetUserId(), update) this.module.modelPlunder.changePlunderData(session.GetUserId(), update)
// 此处需要redis 锁 // 此处需要redis 锁
land.Ship[_id] = shipData // 一条新船 land.Ship[_id] = shipData // 一条新船
@ -130,7 +148,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PlunderCha
}) })
// 通知大家 // 通知大家
this.module.SendMsgToUsers(string(this.module.GetType()), "change", &pb.PlunderChangePush{ this.module.SendMsgToUsers(string(this.module.GetType()), "change", &pb.PlunderChangePush{
Ship: land.Ship, Ship: newShip,
}, users...) }, users...)
if battleConf.Carexe > 0 { if battleConf.Carexe > 0 {
var heroObjs []string var heroObjs []string
@ -162,7 +180,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.PlunderCha
} }
session.SendMsg(string(this.module.GetType()), "challengeover", &pb.PlunderChallengeOverResp{ session.SendMsg(string(this.module.GetType()), "challengeover", &pb.PlunderChallengeOverResp{
Line: list.Line, Line: list.Line,
Ship: map[string]*pb.ShipData{}, Ship: land.Ship,
Atno: atno, Atno: atno,
Heroexp: changExp, Heroexp: changExp,
}) })

View File

@ -22,8 +22,9 @@ func (this *apiComp) Reach(session comm.IUserSession, req *pb.PlunderReachReq) (
err error err error
list *pb.DBPlunder list *pb.DBPlunder
land *pb.DBPlunderLand // 岛屿数据 land *pb.DBPlunderLand // 岛屿数据
//changeShip map[string]*pb.ShipData // 变化的信息
) )
//changeShip = make(map[string]*pb.ShipData, 0)
if errdata = this.ReachCheck(session, req); errdata != nil { if errdata = this.ReachCheck(session, req); errdata != nil {
return // 参数校验失败直接返回 return // 参数校验失败直接返回
} }

View File

@ -473,6 +473,7 @@ const (
ErrorCode_TntegralDayMaxChallenge ErrorCode = 5301 // 当日挑战达上限 ErrorCode_TntegralDayMaxChallenge ErrorCode = 5301 // 当日挑战达上限
//plunder //plunder
ErrorCode_PlunderNotFoundShip ErrorCode = 5401 // pvp 没找到数据 ErrorCode_PlunderNotFoundShip ErrorCode = 5401 // pvp 没找到数据
ErrorCode_PlunderLineUnlock ErrorCode = 5402 // 队列没解锁
) )
// Enum value maps for ErrorCode. // Enum value maps for ErrorCode.
@ -881,6 +882,7 @@ var (
5212: "EntertainNoSkillCard", 5212: "EntertainNoSkillCard",
5301: "TntegralDayMaxChallenge", 5301: "TntegralDayMaxChallenge",
5401: "PlunderNotFoundShip", 5401: "PlunderNotFoundShip",
5402: "PlunderLineUnlock",
} }
ErrorCode_value = map[string]int32{ ErrorCode_value = map[string]int32{
"Success": 0, "Success": 0,
@ -1286,6 +1288,7 @@ var (
"EntertainNoSkillCard": 5212, "EntertainNoSkillCard": 5212,
"TntegralDayMaxChallenge": 5301, "TntegralDayMaxChallenge": 5301,
"PlunderNotFoundShip": 5401, "PlunderNotFoundShip": 5401,
"PlunderLineUnlock": 5402,
} }
) )
@ -1320,7 +1323,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{ var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0x94, 0x4b, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x6f, 0x2a, 0xac, 0x4b, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12,
0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10,
0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x45, 0x78, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e,
0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x10, 0x01, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76,
@ -1921,8 +1924,9 @@ var file_errorcode_proto_rawDesc = []byte{
0x12, 0x1c, 0x0a, 0x17, 0x54, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x79, 0x4d, 0x12, 0x1c, 0x0a, 0x17, 0x54, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x6c, 0x44, 0x61, 0x79, 0x4d,
0x61, 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x10, 0xb5, 0x29, 0x12, 0x18, 0x61, 0x78, 0x43, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x10, 0xb5, 0x29, 0x12, 0x18,
0x0a, 0x13, 0x50, 0x6c, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, 0x0a, 0x13, 0x50, 0x6c, 0x75, 0x6e, 0x64, 0x65, 0x72, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e,
0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x99, 0x2a, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x64, 0x53, 0x68, 0x69, 0x70, 0x10, 0x99, 0x2a, 0x12, 0x16, 0x0a, 0x11, 0x50, 0x6c, 0x75, 0x6e,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x64, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x65, 0x55, 0x6e, 0x6c, 0x6f, 0x63, 0x6b, 0x10, 0x9a, 0x2a,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (