mirror of
https://github.com/shiroikitsu8/Bayshore_6r_legacy.git
synced 2024-11-30 18:24:39 +01:00
Merge pull request #61 from shiroikitsu8/master
prevent crashing if ghost region id is not between 1 and 47
This commit is contained in:
commit
9395f1f4f0
@ -37,6 +37,12 @@ export async function getOpponentHistory(carId: number)
|
||||
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({
|
||||
...car!
|
||||
}))
|
||||
@ -74,7 +80,13 @@ export async function getStampTarget(carId: number)
|
||||
gtWing: 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(
|
||||
wmproto.wm.protobuf.StampTargetCar.create({
|
||||
@ -144,6 +156,12 @@ export async function getChallengers(carId: number)
|
||||
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(
|
||||
wmproto.wm.protobuf.ChallengerCar.create({
|
||||
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
|
||||
if(!(ghost_trails))
|
||||
{
|
||||
|
@ -70,6 +70,12 @@ export async function getCrownList()
|
||||
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
|
||||
// GID_RUNAREA_HIROSHIMA
|
||||
if(car_crown[counter].area === 18)
|
||||
|
@ -60,7 +60,7 @@ export default class UserModule extends Module {
|
||||
if (!body.cardChipId || !body.accessCode)
|
||||
{
|
||||
let msg = {
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_ID_BANNED,
|
||||
error: wm.wm.protobuf.ErrorCode.ERR_USER_SUCCEEDED,
|
||||
numOfOwnedCars: 0,
|
||||
spappState: wm.wm.protobuf.SmartphoneAppState.SPAPP_UNREGISTERED,
|
||||
transferState: wm.wm.protobuf.TransferState.NOT_REGISTERED
|
||||
@ -81,6 +81,25 @@ export default class UserModule extends Module {
|
||||
// New card registration is allowed
|
||||
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({
|
||||
data: {
|
||||
chipId: body.cardChipId,
|
||||
|
Loading…
Reference in New Issue
Block a user