prevent crashing if ghost region id is not between 1 and 47
This commit is contained in:
parent
0852317ae6
commit
639871025d
@ -37,6 +37,12 @@ export async function getOpponentHistory(carId: number)
|
|||||||
take: 10
|
take: 10
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Error handling if regionId is below 1 or above 47
|
||||||
|
if(car!.regionId < 1 || car!.regionId > 47)
|
||||||
|
{
|
||||||
|
car!.regionId = Math.floor(Math.random() * 10) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
opponentHistory.push(wmproto.wm.protobuf.Car.create({
|
opponentHistory.push(wmproto.wm.protobuf.Car.create({
|
||||||
...car!
|
...car!
|
||||||
}))
|
}))
|
||||||
@ -74,7 +80,13 @@ export async function getStampTarget(carId: number)
|
|||||||
gtWing: true,
|
gtWing: true,
|
||||||
lastPlayedPlace: true
|
lastPlayedPlace: true
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// Error handling if regionId is below 1 or above 47
|
||||||
|
if(carTarget!.regionId < 1 || carTarget!.regionId > 47)
|
||||||
|
{
|
||||||
|
carTarget!.regionId = Math.floor(Math.random() * 10) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
stampTarget.push(
|
stampTarget.push(
|
||||||
wmproto.wm.protobuf.StampTargetCar.create({
|
wmproto.wm.protobuf.StampTargetCar.create({
|
||||||
@ -144,6 +156,12 @@ export async function getChallengers(carId: number)
|
|||||||
result = Math.abs(getChallengers[i].result);
|
result = Math.abs(getChallengers[i].result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error handling if regionId is below 1 or above 47
|
||||||
|
if(carTarget!.regionId < 1 || carTarget!.regionId > 47)
|
||||||
|
{
|
||||||
|
carTarget!.regionId = Math.floor(Math.random() * 10) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
challengers.push(
|
challengers.push(
|
||||||
wmproto.wm.protobuf.ChallengerCar.create({
|
wmproto.wm.protobuf.ChallengerCar.create({
|
||||||
car: carTarget!,
|
car: carTarget!,
|
||||||
@ -214,6 +232,12 @@ export async function getGhostCar(car: any, area: number, ramp: number, path: nu
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Error handling if regionId is below 1 or above 47
|
||||||
|
if(car!.regionId < 1 || car!.regionId > 47)
|
||||||
|
{
|
||||||
|
car!.regionId = Math.floor(Math.random() * 10) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
// Push user's car data without ghost trail
|
// Push user's car data without ghost trail
|
||||||
if(!(ghost_trails))
|
if(!(ghost_trails))
|
||||||
{
|
{
|
||||||
|
@ -70,6 +70,12 @@ export async function getCrownList()
|
|||||||
car_crown[counter].playedAt = 1674579600;
|
car_crown[counter].playedAt = 1674579600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Error handling if regionId is below 1 or above 47
|
||||||
|
if(car!.regionId < 1 || car!.regionId > 47)
|
||||||
|
{
|
||||||
|
car!.regionId = Math.floor(Math.random() * 10) + 10;
|
||||||
|
}
|
||||||
|
|
||||||
// Push the car data to the crown holder data
|
// Push the car data to the crown holder data
|
||||||
// GID_RUNAREA_HIROSHIMA
|
// GID_RUNAREA_HIROSHIMA
|
||||||
if(car_crown[counter].area === 18)
|
if(car_crown[counter].area === 18)
|
||||||
|
@ -60,7 +60,7 @@ export default class UserModule extends Module {
|
|||||||
if (!body.cardChipId || !body.accessCode)
|
if (!body.cardChipId || !body.accessCode)
|
||||||
{
|
{
|
||||||
let msg = {
|
let msg = {
|
||||||
error: wm.wm.protobuf.ErrorCode.ERR_ID_BANNED,
|
error: wm.wm.protobuf.ErrorCode.ERR_USER_SUCCEEDED,
|
||||||
numOfOwnedCars: 0,
|
numOfOwnedCars: 0,
|
||||||
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
||||||
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED
|
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED
|
||||||
@ -81,6 +81,25 @@ export default class UserModule extends Module {
|
|||||||
// New card registration is allowed
|
// New card registration is allowed
|
||||||
if (newCardsBanned === 0)
|
if (newCardsBanned === 0)
|
||||||
{
|
{
|
||||||
|
let checkUser = await prisma.user.findFirst({
|
||||||
|
where:{
|
||||||
|
chipId: body.cardChipId
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(checkUser)
|
||||||
|
{
|
||||||
|
msg.error = wm.wm.protobuf.ErrorCode.ERR_USER_LOCKED;
|
||||||
|
|
||||||
|
// Encode the response
|
||||||
|
let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
|
||||||
|
|
||||||
|
// Send the response to the client
|
||||||
|
common.sendResponse(message, res);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let user = await prisma.user.create({
|
let user = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
chipId: body.cardChipId,
|
chipId: body.cardChipId,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user