From c60e329935ded857f635401bdf3812ec8d8ff422 Mon Sep 17 00:00:00 2001 From: Shiroi Kitsu <108461408+shiroikitsu8@users.noreply.github.com> Date: Sun, 26 Mar 2023 22:34:19 +0700 Subject: [PATCH] fix terminal ocm ranking, blocking some car reg --- src/modules/cars.ts | 20 +++++ src/modules/cars/functions.ts | 138 ++++++++++++++++++++++++++++++++++ src/modules/terminal.ts | 26 +++++-- 3 files changed, 177 insertions(+), 7 deletions(-) diff --git a/src/modules/cars.ts b/src/modules/cars.ts index dfbad24..60d6fc0 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -104,6 +104,26 @@ export default class CarModule extends Module { let getCarTune = await carFunctions.getCarTune(tune, carInsert); let additionalInsert = getCarTune.additionalInsert; + // Check created car and item used + let checkCreatedCars = await carFunctions.checkCreatedCar(body, carInsert); + if(checkCreatedCars.cheated === true) + { + let msg = { + error: wm.wm.protobuf.ErrorCode.ERR_FORBIDDEN, + carId: -1, + userId: -1, + rgStamp: -1 + } + + // Generate the load car response message + let message = wm.wm.protobuf.CreateCarResponse.encode(msg); + + // Send the response + common.sendResponse(message, res); + + return; + } + // Insert the car into the database let car = await prisma.car.create({ data: { diff --git a/src/modules/cars/functions.ts b/src/modules/cars/functions.ts index 3de7a16..093cb62 100644 --- a/src/modules/cars/functions.ts +++ b/src/modules/cars/functions.ts @@ -666,4 +666,142 @@ export async function updateCarCustomWing(body: wm.protobuf.UpdateCarRequest) }); } } +} + + +// Remove Used Ticket +export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any) +{ + let cheated: boolean = false; + + let allCarVisualModel = [ + 1, // ZR1T + 3, // CAMARO_MAT + 38, // Z31ANIV + 44, // R964 + 45, // R997 + 46, // RKC + 80, // MF10_MAT + 93, // R991 + 99, // MXG + 100, // E89P + 102, // CAMAROT + 103, // R127P + 116, // ND5RC + 120, // RCT + 122, // R60 + 125, // P400S + 126, // DIABLO + 130, // JW5 + 131, // AP2 + 133, // PS13 + 137, // NDERC + 138, // UF31 + 139, // GS130 + 143, // 928GT + ]; + + let carVisualModelWithoutItem = [ + 1, // ZR1T + 3, // CAMARO_MAT + 38, // Z31ANIV + 44, // R964 + 45, // R997 + 46, // RKC + 80, // MF10_MAT + 93, // R991 + 99, // MXG + 100, // E89P + 102, // CAMAROT + 103, // R127P + 116, // ND5RC + 120, // RCT + 125, // P400S + 126, // DIABLO + 133, // PS13 + 137, // NDERC + 138, // UF31 + 139, // GS130 + 143, // 928GT + ]; + + // Check if user item id is not set and its a special car + for(let i=0; i 27) + { + cheated = true; + } + } + else if(car.visualModel === 131) + { + if(itemId < 28 || itemId > 36) + { + cheated = true; + } + } + else if(car.visualModel === 122) + { + if(itemId < 7 || itemId > 15) + { + cheated = true; + } + } + else if(car.visualModel === 137) + { + if(itemId !== 37) + { + cheated = true; + } + } + else if(car.visualModel === 138) + { + if(itemId !== 38) + { + cheated = true; + } + } + else if(car.visualModel === 139) + { + if(itemId !== 39) + { + cheated = true; + } + } + else if(car.visualModel > 144) + { + cheated = true; + } + + return { cheated } } \ No newline at end of file diff --git a/src/modules/terminal.ts b/src/modules/terminal.ts index 673510b..dea37d2 100644 --- a/src/modules/terminal.ts +++ b/src/modules/terminal.ts @@ -688,10 +688,16 @@ export default class TerminalModule extends Module { car: true }, distinct: ["carId"], - take: 50 - }) + take: 100 + }); - numOfParticipants = ocmParticipant.length; + let numOfParticipantsLength = [{ count: 0 }]; + + numOfParticipantsLength = await prisma.$queryRaw` + select count(*) as "count" from + "OCMTally" where "competitionId" = ${body.competitionId}`; + + numOfParticipants = Number(numOfParticipantsLength[0].count); periodId = 0; let ranking = 0; @@ -822,7 +828,7 @@ export default class TerminalModule extends Module { car: true }, distinct: ["carId"], - }) + }); numOfParticipants = ocmParticipant.length; periodId = 0; @@ -879,10 +885,16 @@ export default class TerminalModule extends Module { car: true }, distinct: ["carId"], - take: 10 - }) + take: 25 + }); - numOfParticipants = ocmParticipant.length; + let numOfParticipantsLength = [{ count: 0 }]; + + numOfParticipantsLength = await prisma.$queryRaw` + select count(*) as "count" from + "OCMTally" where "competitionId" = ${body.competitionId}`; + + numOfParticipants = Number(numOfParticipantsLength[0].count); periodId = 0; let ranking = 0;