diff --git a/src/modules/game.ts b/src/modules/game.ts index e18a6c3..b854e5f 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -1175,16 +1175,32 @@ export default class GameModule extends Module { } }) + // Error handling if windowStickerString is undefined if user registering bannapass from terminal first instead of driver unit let wsString = ""; let wsFont = 0; - if(user.cars[0].windowStickerString !== null && user.cars[0].windowStickerString !== undefined && user.cars[0].windowStickerString !== ''){ - wsString = user.cars[0].windowStickerString; - wsFont = user.cars[0].windowStickerFont; - } - else{ + + // No car data + if(user.cars.length <= 0) + { wsString = 'WANGAN'; wsFont = 0; } + // There is car data + else + { + // User atleast have cars + if(user.cars){ + if(user.cars[0]?.windowStickerString !== null && user.cars[0]?.windowStickerString !== undefined && user.cars[0]?.windowStickerString !== ''){ + wsString = user.cars[0].windowStickerString; + wsFont = user.cars[0].windowStickerFont; + } + } + // User don't have car yet + else{ + wsString = 'WANGAN'; + wsFont = 0; + } + } let msg = { error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, @@ -1961,15 +1977,19 @@ export default class GameModule extends Module { } }) - if(userData!.windowStickerString !== saveEx.windowStickerString){ - await prisma.car.updateMany({ - where: { - userId: userData!.userId - }, - data: { - windowStickerString: saveEx.windowStickerString - } - }) + if (body.car?.windowStickerString !== null && body.car?.windowStickerString !== undefined) + { + if(userData!.windowStickerString !== saveEx.windowStickerString) + { + await prisma.car.updateMany({ + where: { + userId: userData!.userId + }, + data: { + windowStickerString: saveEx.windowStickerString + } + }) + } } // Get car item @@ -2328,6 +2348,13 @@ export default class GameModule extends Module { } }); + // Error handling if ghostLevel accidentally set to 0 or more than 10 + if(car!.ghostLevel < 1){ + car!.ghostLevel = 1; + } + else if(car!.ghostLevel > 11){ + car!.ghostLevel = 10; + } // This is fucking terrible let longLoseBits = Long.fromString(car!.stLoseBits.toString()); @@ -2961,7 +2988,15 @@ export default class GameModule extends Module { playedAt: 'desc' } }); - playedAt = time!.playedAt - 172800; + + if(time!.playedAt !== 0 && time!.playedAt >= 1659805200) + { + playedAt = time!.playedAt - 172800; + } + else if(time!.playedAt === 0 || time!.playedAt < 1659805200) + { + playedAt = 1659805200; + } ghostTrail = ghost_trails!.trail; } else{ diff --git a/src/modules/startup.ts b/src/modules/startup.ts index 44efc18..76a083a 100644 --- a/src/modules/startup.ts +++ b/src/modules/startup.ts @@ -302,8 +302,26 @@ export default class StartupModule extends Module { } car!.tunePower = car_crown[counter].tunePower; car!.tuneHandling = car_crown[counter].tuneHandling; - car!.lastPlayedAt = car_crown[counter].playedAt - 172800; - car_crown[counter].playedAt = car_crown[counter].playedAt - 172800; + + // Error handling if played At value is current date + if(car_crown[counter].playedAt !== 0 && car_crown[counter].playedAt >= 1659805200) + { + // Acquired crown timestamp - 1 day + car!.lastPlayedAt = car_crown[counter].playedAt - 172800; + + // Acquired crown timestamp - 1 day + car_crown[counter].playedAt = car_crown[counter].playedAt - 172800; + } + // Error handling if played At value is 0 + else if(car_crown[counter].playedAt === 0 || car_crown[counter].playedAt < 1659805200) + { + // Acquired crown timestamp become 7 August 2022 + car!.lastPlayedAt = 1659805200; + + // Acquired crown timestamp become 7 August 2022 + car_crown[counter].playedAt = 1659805200; + } + list_crown.push(wmsrv.wm.protobuf.Crown.create({ carId: car_crown[counter].carId, area: car_crown[counter].area, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA