1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2024-11-28 17:30:51 +01:00

Merge pull request #23 from ghkkk090/master

fix window sticker string
This commit is contained in:
Luna 2022-08-13 20:39:53 +01:00 committed by GitHub
commit f57f55c643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 // Error handling if windowStickerString and windowStickerFont is undefined or null
let wsString = ""; // User is registering bannapass from terminal unit first instead of driver unit
// Default value for windowStickerString and windowStickerFont
let wsString = '';
let wsFont = 0; let wsFont = 0;
// No car data // user.cars found
if(user.cars.length <= 0) if(user.cars)
{ {
wsString = ''; // User atleast have 1 car
wsFont = 0; if(user.cars[0]?.windowStickerString !== null &&
} user.cars[0]?.windowStickerString !== undefined &&
// There is car data user.cars[0]?.windowStickerString !== '')
else {
{ wsString = user.cars[0].windowStickerString;
// User atleast have cars wsFont = user.cars[0].windowStickerFont;
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 = '';
wsFont = 0;
} }
// else{} User don't have a car... returning default windowStickerString and windowStickerFont value
} }
let msg = { let msg = {
@ -1915,7 +1909,7 @@ export default class GameModule extends Module {
if (body.car?.windowStickerString !== null && body.car?.windowStickerString !== undefined) { if (body.car?.windowStickerString !== null && body.car?.windowStickerString !== undefined) {
saveEx.windowStickerString = body.car?.windowStickerString!; saveEx.windowStickerString = body.car?.windowStickerString!;
} else { } else {
saveEx.windowStickerString = ''; saveEx.windowStickerString = car?.windowStickerString;
} }
if (body.car?.windowStickerFont !== null && body.car?.windowStickerFont !== undefined) { if (body.car?.windowStickerFont !== null && body.car?.windowStickerFont !== undefined) {
saveEx.windowStickerFont = body.car?.windowStickerFont!; saveEx.windowStickerFont = body.car?.windowStickerFont!;
@ -2244,6 +2238,30 @@ export default class GameModule extends Module {
lastPlayedAt: date, 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) // Additional car values (for basic / full tune)
let additionalInsert = { let additionalInsert = {
@ -2322,7 +2340,8 @@ export default class GameModule extends Module {
carId: car.carId, carId: car.carId,
car, car,
...carInsert, ...carInsert,
...additionalInsert ...additionalInsert,
...additionalWindowStickerInsert
} }
let resp = wm.wm.protobuf.CreateCarResponse.encode(msg); let resp = wm.wm.protobuf.CreateCarResponse.encode(msg);
let end = resp.finish(); let end = resp.finish();
@ -2891,7 +2910,7 @@ export default class GameModule extends Module {
let lists_binaryByCar let lists_binaryByCar
if(ghost_trails?.trendBinaryByCar !== null && ghost_trails?.trendBinaryByCar !== undefined){ if(ghost_trails?.trendBinaryByCar !== null && ghost_trails?.trendBinaryByCar !== undefined){
lists_binaryByArea = wm.wm.protobuf.BinaryData.create({ lists_binaryByCar = wm.wm.protobuf.BinaryData.create({
data: ghost_trails!.trendBinaryByCar!, data: ghost_trails!.trendBinaryByCar!,
mergeSerial: ghost_trails!.byCarMergeSerial! mergeSerial: ghost_trails!.byCarMergeSerial!
}); });
@ -2899,7 +2918,7 @@ export default class GameModule extends Module {
let lists_binaryByUser let lists_binaryByUser
if(ghost_trails?.trendBinaryByUser !== null && ghost_trails?.trendBinaryByUser !== undefined){ if(ghost_trails?.trendBinaryByUser !== null && ghost_trails?.trendBinaryByUser !== undefined){
lists_binaryByArea = wm.wm.protobuf.BinaryData.create({ lists_binaryByUser = wm.wm.protobuf.BinaryData.create({
data: ghost_trails!.trendBinaryByUser!, data: ghost_trails!.trendBinaryByUser!,
mergeSerial: ghost_trails!.byUserMergeSerial! mergeSerial: ghost_trails!.byUserMergeSerial!
}); });