diff --git a/src/modules/game.ts b/src/modules/game.ts index b854e5f..80e5adb 100644 --- a/src/modules/game.ts +++ b/src/modules/game.ts @@ -1175,31 +1175,25 @@ 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 = ""; + // Error handling if windowStickerString and windowStickerFont is undefined or null + // User is registering bannapass from terminal unit first instead of driver unit + // Default value for windowStickerString and windowStickerFont + let wsString = 'WANGAN'; let wsFont = 0; - // No car data - if(user.cars.length <= 0) + // user.cars found + if(user.cars) { - 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; + // User atleast have 1 car + 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{} User don't have a car... returning default windowStickerString and windowStickerFont value } let msg = { @@ -1915,7 +1909,7 @@ export default class GameModule extends Module { if (body.car?.windowStickerString !== null && body.car?.windowStickerString !== undefined) { saveEx.windowStickerString = body.car?.windowStickerString!; } else { - saveEx.windowStickerString = 'WANGAN'; + saveEx.windowStickerString = car?.windowStickerString; } if (body.car?.windowStickerFont !== null && body.car?.windowStickerFont !== undefined) { saveEx.windowStickerFont = body.car?.windowStickerFont!; @@ -2243,6 +2237,30 @@ export default class GameModule extends Module { regionId: body.car.regionId!, lastPlayedAt: date, }; + + let checkWindowSticker = await prisma.car.findFirst({ + where: { + userId: body.userId + }, + select: { + windowStickerString: true, + windowStickerFont: true + } + }); + + // Check if user have more than one cars + let additionalWindowStickerInsert = { + + } + + // If more than one cars + if(checkWindowSticker) + { + additionalWindowStickerInsert = { + windowStickerString: checkWindowSticker.windowStickerString, + windowStickerFont: checkWindowSticker.windowStickerFont, + } + } // Additional car values (for basic / full tune) let additionalInsert = { @@ -2322,7 +2340,8 @@ export default class GameModule extends Module { carId: car.carId, car, ...carInsert, - ...additionalInsert + ...additionalInsert, + ...additionalWindowStickerInsert } let resp = wm.wm.protobuf.CreateCarResponse.encode(msg); let end = resp.finish();