1
0
mirror of synced 2025-01-22 11:23:40 +01:00

Merge pull request #68 from shiroikitsu8/master

fix terminal ocm ranking, blocking some car reg
This commit is contained in:
Luna Nightshade 2023-03-26 12:01:15 -07:00 committed by GitHub
commit b5ae13335a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 177 additions and 7 deletions

View File

@ -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: {

View File

@ -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<allCarVisualModel.length; i++)
{
if(!(body.userItemId) && car.visualModel === allCarVisualModel[i])
{
cheated = true;
return { cheated }
}
}
// Check if user item id is set and its a special car cannot be created from ticket
for(let i=0; i<carVisualModelWithoutItem.length; i++)
{
if(body.userItemId && car.visualModel === carVisualModelWithoutItem[i])
{
cheated = true;
return { cheated }
}
}
// Get the item id
let item = await prisma.userItem.findFirst({
where: {
userItemId: body.userItemId
}
});
let itemId = item?.itemId || -1;
// Check if user item id is set and its a special car created from ticket
if(car.visualModel === 130)
{
if(itemId < 22 || itemId > 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 }
}

View File

@ -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;