diff --git a/src/modules/cars.ts b/src/modules/cars.ts index 94d5d0e..5367016 100644 --- a/src/modules/cars.ts +++ b/src/modules/cars.ts @@ -536,6 +536,8 @@ export default class CarModule extends Module { // Car update data data = { name: common.sanitizeInput(cars.name), + manufacturer: common.sanitizeInput(cars.manufacturer), + model: common.sanitizeInput(cars.model), visualModel: common.sanitizeInput(cars.visualModel), customColor: common.sanitizeInput(cars.customColor), wheel: common.sanitizeInput(cars.wheel), diff --git a/src/modules/resource.ts b/src/modules/resource.ts index f78571e..1c166cb 100644 --- a/src/modules/resource.ts +++ b/src/modules/resource.ts @@ -332,27 +332,28 @@ export default class ResourceModule extends Module { // Get the crown holder data let car_crown = await prisma.carCrown.findMany({ orderBy: { - area: 'asc' - } + area: 'asc' + }, + distinct: ['area'] }); // Crown holder data available if(car_crown.length !== 0) { - let counter = 0; + let counter = 0; // Loop GID_RUNAREA for(let i=0; i<19; i++) { - // 14 - 16 are dummy area, 17 is C1 Closed - if(i >= 14) + // After Kobe is Hiroshima then Fukuoka and the rest + if(i > 14) { i = 18; // GID_RUNAREA_HIROSHIMA } // Crown holder for certain area available - if(car_crown[counter].area === i){ - + if(car_crown[counter].area === i) + { // Get user's data let car = await prisma.car.findFirst({ where: { @@ -364,12 +365,6 @@ export default class ResourceModule extends Module { } }); - // If regionId is 0 or not set, game will crash after defeating the ghost - if(car!.regionId === 0) - { - car!.regionId = i + 1; // Change car region id - } - // Set the tunePower and tuneHandling used when capturing ghost crown car!.tunePower = car_crown[counter].tunePower; car!.tuneHandling = car_crown[counter].tuneHandling; @@ -394,48 +389,98 @@ export default class ResourceModule extends Module { } // Push the car data to the crown holder data - 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 - unlockAt: car_crown[counter].playedAt, - car: car! - - })); + // GID_RUNAREA_HIROSHIMA + if(car_crown[counter].area === 18) + { + let listCrown = wmsrv.wm.protobuf.Crown.create({ + carId: car_crown[counter].carId, + area: car_crown[counter].area, + unlockAt: car_crown[counter].playedAt, + car: car! + }); - if(counter < car_crown.length-1){ + // Push it after Kobe + list_crown.splice(11, 0, listCrown); + } + // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE + else + { + list_crown.push(wmsrv.wm.protobuf.Crown.create({ + carId: car_crown[counter].carId, + area: car_crown[counter].area, + unlockAt: car_crown[counter].playedAt, + car: car! + })); + } + + + if(counter < car_crown.length-1) + { counter++; } } // Crown holder for certain area not available - else{ - + else + { // Push the default data by the game to the crown holder data - list_crown.push(wmsrv.wm.protobuf.Crown.create({ - carId: i, - area: i, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA - unlockAt: 0, - })); + // GID_RUNAREA_HIROSHIMA + if(i === 18) + { + let listCrown = wmsrv.wm.protobuf.Crown.create({ + carId: 999999999-i, + area: i, + unlockAt: 0, + }); + + // Push it after Kobe + list_crown.splice(11, 0, listCrown); + } + // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE + else + { + list_crown.push(wmsrv.wm.protobuf.Crown.create({ + carId: 999999999-i, + area: i, + unlockAt: 0, + })); + } } } } // There is no user's crown holder data available - else{ - + else + { // Loop GID_RUNAREA - for(let i=0; i<19; i++) + for(let i=0; i<14; i++) { - // 14 - 16 are dummy area, 17 is C1 Closed - if(i >= 14) + // After Kobe is Hiroshima then Fukuoka and the rest + if(i > 14) { i = 18; // GID_RUNAREA_HIROSHIMA } // Push the default data by the game to the crown holder data - list_crown.push(wmsrv.wm.protobuf.Crown.create({ - carId: i, - area: i, // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE & GID_RUNAREA_HIROSHIMA - unlockAt: 0, - })); + // GID_RUNAREA_HIROSHIMA + if(i === 18) + { + let listCrown = wmsrv.wm.protobuf.Crown.create({ + carId: 999999999-i, + area: i, + unlockAt: 0, + }); + + // Push it after Kobe + list_crown.splice(11, 0, listCrown); + } + // GID_RUNAREA_C1 - GID_RUNAREA_TURNPIKE + else + { + list_crown.push(wmsrv.wm.protobuf.Crown.create({ + carId: 999999999-i, + area: i, + unlockAt: 0, + })); + } } }