1
0
mirror of https://github.com/shiroikitsu8/Bayshore_6r_legacy.git synced 2025-02-26 22:28:59 +01:00

fix if value is 0 will not update to db

This commit is contained in:
ghkkk090 2022-08-20 21:44:17 +07:00
parent aed96ce32b
commit 8d7b3909f6
4 changed files with 57 additions and 52 deletions

View File

@ -530,24 +530,24 @@ export default class CarModule extends Module {
{ {
// Car update data // Car update data
data = { data = {
customColor: cars.customColor || undefined, customColor: common.sanitizeInput(cars.customColor),
wheel: cars.wheel || undefined, wheel: common.sanitizeInput(cars.wheel),
wheelColor: cars.wheelColor || undefined, wheelColor: common.sanitizeInput(cars.wheelColor),
aero: cars.aero || undefined, aero: common.sanitizeInput(cars.aero),
bonnet: cars.bonnet || undefined, bonnet: common.sanitizeInput(cars.bonnet),
wing: cars.wing || undefined, wing: common.sanitizeInput(cars.wing),
mirror: cars.mirror || undefined, mirror: common.sanitizeInput(cars.mirror),
neon: cars.neon || undefined, neon: common.sanitizeInput(cars.neon),
trunk: cars.trunk || undefined, trunk: common.sanitizeInput(cars.trunk),
plate: cars.plate || undefined, plate: common.sanitizeInput(cars.plate),
plateColor: cars.plateColor || undefined, plateColor: common.sanitizeInput(cars.plateColor),
plateNumber: cars.plateNumber || undefined, plateNumber: common.sanitizeInput(cars.plateNumber),
windowSticker: cars.windowSticker || undefined, windowSticker: common.sanitizeInput(cars.windowSticker),
windowDecoration: cars.windowDecoration || undefined, windowDecoration: common.sanitizeInput(cars.windowDecoration),
rivalMarker: cars.rivalMarker || undefined, rivalMarker: common.sanitizeInput(cars.rivalMarker),
aura: cars.aura || undefined, aura: common.sanitizeInput(cars.aura),
auraMotif: cars.auraMotif || undefined, auraMotif: common.sanitizeInput(cars.auraMotif),
rgStamp: body?.rgStamp! || undefined, rgStamp: common.sanitizeInput(body.rgStamp),
} }
// Update the car info // Update the car info
@ -634,12 +634,12 @@ export default class CarModule extends Module {
if (gtWing) if (gtWing)
{ {
let dataGTWing : any = { let dataGTWing : any = {
pillar: gtWing.pillar || undefined, pillar: common.sanitizeInput(gtWing.pillar),
pillarMaterial: gtWing.pillarMaterial || undefined, pillarMaterial: common.sanitizeInput(gtWing.pillarMaterial),
mainWing: gtWing.mainWing || undefined, mainWing: common.sanitizeInput(gtWing.mainWing),
mainWingColor: gtWing.mainWingColor || undefined, mainWingColor: common.sanitizeInput(gtWing.mainWingColor),
wingTip: gtWing.wingTip || undefined, wingTip: common.sanitizeInput(gtWing.wingTip),
material: gtWing.material || undefined, material: common.sanitizeInput(gtWing.material),
} }
await prisma.carGTWing.update({ await prisma.carGTWing.update({

View File

@ -41,4 +41,8 @@ export function getBigIntFromLong(n: Long)
// Return the finished value // Return the finished value
return Number(bigInt); return Number(bigInt);
}
export function sanitizeInput(value: any){
return (value == null || value == undefined) ? undefined : value;
} }

View File

@ -3,8 +3,10 @@ import { prisma } from "../..";
// Import Proto // Import Proto
import { wm } from "../../wmmt/wm.proto"; import { wm } from "../../wmmt/wm.proto";
import wmproto from "../../wmmt/wm.proto"; import wmproto from "../../wmmt/wm.proto";
import * as ghost_history from "../games/games_util/ghost_history";
// Import Util
import * as common from "../../util/common";
import * as ghost_history from "../games/games_util/ghost_history";
// Save ghost battle result // Save ghost battle result
export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any) export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequest, car: any)
@ -34,10 +36,10 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
{ {
// Ghost update data // Ghost update data
dataGhost = { dataGhost = {
rgRegionMapScore: ghostResult.rgRegionMapScore || undefined, rgRegionMapScore: common.sanitizeInput(ghostResult.rgRegionMapScore),
rgPlayCount: ghostResult.rgPlayCount || undefined, rgPlayCount: common.sanitizeInput(ghostResult.rgPlayCount),
dressupLevel: ghostResult.dressupLevel || undefined, dressupLevel: common.sanitizeInput(ghostResult.dressupLevel),
dressupPoint: ghostResult.dressupPoint || undefined, dressupPoint: common.sanitizeInput(ghostResult.dressupPoint),
} }
} }
@ -62,18 +64,18 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
// Car update data // Car update data
dataCar = { dataCar = {
wheel: cars.wheel || undefined, wheel: common.sanitizeInput(cars.wheel),
wheelColor: cars.wheelColor || undefined, wheelColor: common.sanitizeInput(cars.wheelColor),
aero: cars.aero || undefined, aero: common.sanitizeInput(cars.aero),
bonnet: cars.bonnet || undefined, bonnet: common.sanitizeInput(cars.bonnet),
wing: cars.wing || undefined, wing: common.sanitizeInput(cars.wing),
mirror: cars.mirror || undefined, mirror: common.sanitizeInput(cars.mirror),
neon: cars.neon || undefined, neon: common.sanitizeInput(cars.neon),
trunk: cars.trunk || undefined, trunk: common.sanitizeInput(cars.trunk),
plate: cars.plate || undefined, plate: common.sanitizeInput(cars.plate),
plateColor: cars.plateColor || undefined, plateColor: common.sanitizeInput(cars.plateColor),
plateNumber: cars.plateNumber || undefined, plateNumber: common.sanitizeInput(cars.plateNumber),
ghostLevel: cars.ghostLevel || undefined, ghostLevel: common.sanitizeInput(cars.ghostLevel),
} }
} }
@ -205,9 +207,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
// Ghost Crown update data // Ghost Crown update data
dataCrown = { dataCrown = {
carId: carId, carId: carId,
playedAt: body.playedAt || undefined, playedAt: common.sanitizeInput(body.playedAt),
tunePower: body.car?.tunePower || undefined, tunePower: common.sanitizeInput(body.car?.tunePower),
tuneHandling: body.car?.tuneHandling || undefined, tuneHandling: common.sanitizeInput(body.car?.tuneHandling),
} }
// Get the area id and ramp id // Get the area id and ramp id

View File

@ -23,12 +23,12 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
{ {
// Story update data // Story update data
let data : any = { let data : any = {
stClearDivCount: storyResult.stClearDivCount || undefined, stClearDivCount: common.sanitizeInput(storyResult.stClearDivCount),
stPlayCount: storyResult.stPlayCount || undefined, stPlayCount: common.sanitizeInput(storyResult.stPlayCount),
stClearCount: storyResult.stClearCount || undefined, stClearCount: common.sanitizeInput(storyResult.stClearCount),
stConsecutiveWins: storyResult.stConsecutiveWins || undefined, stConsecutiveWins: common.sanitizeInput(storyResult.stConsecutiveWins),
tuningPoints: storyResult.tuningPoint || 0, tuningPoints: common.sanitizeInput(storyResult.tuningPoint),
stCompleted100Episodes: storyResult.stCompleted_100Episodes || undefined, stCompleted100Episodes: common.sanitizeInput(storyResult.stCompleted_100Episodes),
} }
// If the current consecutive wins is greater than the previous max // If the current consecutive wins is greater than the previous max
@ -53,8 +53,7 @@ export async function saveStoryResult(body: wm.protobuf.SaveGameResultRequest, c
} }
// Check if clearBits is not null, and not lose the story // Check if clearBits is not null, and not lose the story
if (storyResult.stClearBits !== null && storyResult.stClearBits !== undefined if (common.sanitizeInput(storyResult.stClearBits) && data.stLoseBits === 0)
&& data.stLoseBits === 0)
{ {
data.stClearBits = storyResult.stClearBits; data.stClearBits = storyResult.stClearBits;
} }