🐞 fix(防加速): 添加校验参数
This commit is contained in:
@@ -449,10 +449,10 @@ export class ComBattleHandler {
|
||||
* @returns
|
||||
* @memberof ComBattleHandler
|
||||
*/
|
||||
async action(msg: {teamCode: string, bossHurts: Array<{hid: number, dataId: number, hurtHp: number}>, killed: number[], curRnd: number, timegap: number }, session: BackendSession) {
|
||||
async action(msg: {teamCode: string, bossHurts: Array<{hid: number, dataId: number, hurtHp: number}>, killed: number[], curRnd: number, timegap: number, roundTime: number }, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let sid = session.get('sid');
|
||||
let { teamCode, killed, bossHurts, curRnd, timegap = 0 } = msg;
|
||||
let { teamCode, killed, bossHurts, curRnd, timegap = 0, roundTime = 0 } = msg;
|
||||
let teamStatus = getComTeamByCode(teamCode);
|
||||
if (!teamStatus || !teamStatus.roleIds || teamStatus.roleIds.indexOf(roleId) === -1) {
|
||||
checkTeamStatusAndSend(teamCode, roleId, sid);
|
||||
@@ -473,7 +473,7 @@ export class ComBattleHandler {
|
||||
if(!roleSt.startActionTime || roleSt.startActionTime == 0) { // 第一次调用设置初始
|
||||
roleSt.startActionTime = nowSeconds();
|
||||
}
|
||||
if(timegap - (nowSeconds() - roleSt.startActionTime) > 5) { // 前后端误差超过5秒拦截
|
||||
if ((roundTime > 0 && roundTime < 200) || (timegap - (nowSeconds() - roleSt.startActionTime) > 5)) { // 前后端误差超过5秒拦截
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
isError: true,
|
||||
timegap: nowSeconds() - roleSt.startActionTime
|
||||
|
||||
@@ -245,14 +245,14 @@ export class CityActivityHandler {
|
||||
|
||||
|
||||
// 上报城门受到伤害
|
||||
async hitGate(msg: { cityId: number, code: string, damage: number, hid: number, round: number, timegap: number }, session: BackendSession) {
|
||||
async hitGate(msg: { cityId: number, code: string, damage: number, hid: number, round: number, timegap: number, roundTime: number }, session: BackendSession) {
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
const sid = session.get('sid');
|
||||
|
||||
let { cityId, code, damage, hid, round, timegap = 0 } = msg;
|
||||
let { cityId, code, damage, hid, round, timegap = 0, roundTime = 0 } = msg;
|
||||
let obj = getCityActivityObj();
|
||||
let { gateHp, maxHp } = await obj.getGateHpAndInc(serverId, cityId);
|
||||
if (gateHp <= 0) return resResult(STATUS.GATE_HP_IS_ZERO);
|
||||
@@ -262,7 +262,7 @@ export class CityActivityHandler {
|
||||
if(!member.startActionTime || member.startActionTime == 0) {
|
||||
member.startActionTime = nowSeconds();
|
||||
}
|
||||
if(timegap - (nowSeconds() - member.startActionTime) > 5) { // 前后端误差超过5秒拦截
|
||||
if ((roundTime > 0 && roundTime < 200) || (timegap - (nowSeconds() - member.startActionTime) > 5)) { // 前后端误差超过5秒拦截
|
||||
return resResult(STATUS.SUCCESS, {
|
||||
isError: true,
|
||||
timegap: nowSeconds() - member.startActionTime
|
||||
|
||||
@@ -558,10 +558,10 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
}
|
||||
case "comBattle.comBattleHandler.action":
|
||||
{
|
||||
let { teamCode, bossHurts, killed, curRnd, timegap = 0 } = msg;
|
||||
let { teamCode, bossHurts, killed, curRnd, timegap = 0, roundTime = 0 } = msg;
|
||||
if (!checkNaturalStrings(teamCode)) return false;
|
||||
if (!checkNumberArray(killed)) return false;
|
||||
if (!checkNaturalNumbers(curRnd, timegap)) return false;
|
||||
if (!checkNaturalNumbers(curRnd, timegap, roundTime)) return false;
|
||||
if (!checkArrayCanEmpty(bossHurts)) return false;
|
||||
for (let { hid, dataId, hurtHp } of bossHurts) {
|
||||
if (hid && !checkNaturalNumbers(hid)) return false;
|
||||
@@ -1082,10 +1082,8 @@ export function checkRouteParam(route: string, msg: any) {
|
||||
}
|
||||
case "guild.cityActivityHandler.hitGate":
|
||||
{
|
||||
let { cityId, code, damage, hid, round, timegap = 0 } = msg;
|
||||
console.log('###### timegap 1', timegap)
|
||||
if (!checkNaturalNumbers(cityId, damage, hid, round, timegap)) return false;
|
||||
console.log('###### timegap 2', timegap)
|
||||
let { cityId, code, damage, hid, round, timegap = 0, roundTime = 0 } = msg;
|
||||
if (!checkNaturalNumbers(cityId, damage, hid, round, timegap, roundTime)) return false;
|
||||
if (!checkNaturalStrings(code)) return false;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user