diff --git a/src/modules/ghost/functions.ts b/src/modules/ghost/functions.ts index 9f5f68f..1bc67ba 100644 --- a/src/modules/ghost/functions.ts +++ b/src/modules/ghost/functions.ts @@ -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)) { diff --git a/src/modules/resource/crown_list.ts b/src/modules/resource/crown_list.ts index ccbe38c..e782ed4 100644 --- a/src/modules/resource/crown_list.ts +++ b/src/modules/resource/crown_list.ts @@ -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) diff --git a/src/modules/users.ts b/src/modules/users.ts index 0a1333a..bb80143 100644 --- a/src/modules/users.ts +++ b/src/modules/users.ts @@ -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,