1
0
mirror of synced 2025-02-02 12:47:21 +01:00

Merge pull request #70 from shiroikitsu8/master

fix bug, and block connection outside mt6, detect force finish
This commit is contained in:
Luna Nightshade 2023-04-06 14:21:58 +01:00 committed by GitHub
commit 7c739600f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 350 additions and 123 deletions

View File

@ -13,6 +13,7 @@
"scratchType": 0, "scratchType": 0,
"giveMeterReward": 0, "giveMeterReward": 0,
"newCardsBanned": 0, "newCardsBanned": 0,
"revisionCheck": 1,
"enableScreenshot": 0 "enableScreenshot": 0
} }
} }

View File

@ -0,0 +1,21 @@
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
-- AlterTable
ALTER TABLE "FileList" ALTER COLUMN "filePath" DROP DEFAULT;
-- CreateTable
CREATE TABLE "CarCrownDetect" (
"id" SERIAL NOT NULL,
"carId" INTEGER NOT NULL,
"status" TEXT NOT NULL DEFAULT '',
"area" INTEGER,
"ramp" INTEGER,
"path" INTEGER,
"trail" BYTEA,
"playedAt" INTEGER,
"tunePower" INTEGER,
"tuneHandling" INTEGER,
CONSTRAINT "CarCrownDetect_pkey" PRIMARY KEY ("id")
);

View File

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "Car" ALTER COLUMN "stLoseBits" SET DEFAULT 0;
-- AlterTable
ALTER TABLE "CarCrownDetect" ADD COLUMN "opponentCarId" INTEGER;

View File

@ -446,5 +446,19 @@ model FileList {
sha1sum String sha1sum String
notBefore Int notBefore Int
notAfter Int notAfter Int
filePath String @default("") filePath String
}
model CarCrownDetect {
id Int @id @default(autoincrement())
carId Int
status String @default("")
area Int?
ramp Int?
path Int?
trail Bytes?
playedAt Int?
tunePower Int?
tuneHandling Int?
opponentCarId Int?
} }

View File

@ -54,6 +54,11 @@ export interface GameOptions {
// and prevent new card registration // and prevent new card registration
newCardsBanned: number; // 1 is on, 0 is off newCardsBanned: number; // 1 is on, 0 is off
// revision check
// set this option to 1 will block not matched revision
// and from connecting to the server
revisionCheck: number; // 1 is on, 0 is off
// revision check // revision check
// set this option to 1 to enable screenshot feature // set this option to 1 to enable screenshot feature
enableScreenshot: number; // 1 is on, 0 is off enableScreenshot: number; // 1 is on, 0 is off

View File

@ -9,6 +9,7 @@ import * as wm from "../wmmt/wm.proto";
// Import Util // Import Util
import * as common from "./util/common"; import * as common from "./util/common";
import * as carFunctions from "./cars/functions"; import * as carFunctions from "./cars/functions";
import * as terminal from "./terminal/check_car";
export default class CarModule extends Module { export default class CarModule extends Module {
@ -81,7 +82,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.LoadCarResponse.encode(msg); let message = wm.wm.protobuf.LoadCarResponse.encode(msg);
// Send the response // Send the response
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -94,6 +95,7 @@ export default class CarModule extends Module {
// Create the Car // Create the Car
let createCar = await carFunctions.createCar(body); let createCar = await carFunctions.createCar(body);
let tune = createCar.tune; let tune = createCar.tune;
let itemId = createCar.itemId;
let carInsert = createCar.carInsert; let carInsert = createCar.carInsert;
// Check if user's other car have unique window sticker // Check if user's other car have unique window sticker
@ -105,7 +107,7 @@ export default class CarModule extends Module {
let additionalInsert = getCarTune.additionalInsert; let additionalInsert = getCarTune.additionalInsert;
// Check created car and item used // Check created car and item used
let checkCreatedCars = await carFunctions.checkCreatedCar(body, carInsert); let checkCreatedCars = await carFunctions.checkCreatedCar(body, carInsert, itemId);
if(checkCreatedCars.cheated === true) if(checkCreatedCars.cheated === true)
{ {
let msg = { let msg = {
@ -119,20 +121,41 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.CreateCarResponse.encode(msg); let message = wm.wm.protobuf.CreateCarResponse.encode(msg);
// Send the response // Send the response
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return; return;
} }
// Generate blank car settings object
let settings = await prisma.carSettings.create({
data: {}
});
// Generate blank car state object
let state = await prisma.carState.create({
data: {}
});
let gtWing = await prisma.carGTWing.create({
data: {}
});
// Insert the car into the database // Insert the car into the database
let car = await prisma.car.create({ let car = await prisma.car.create({
data: { data: {
...carInsert, ...carInsert,
...additionalInsert, ...additionalInsert,
...additionalWindowStickerInsert ...additionalWindowStickerInsert,
carSettingsDbId: settings.dbId,
carStateDbId: state.dbId,
carGTWingDbId: gtWing.dbId,
} }
}); });
// Check if created car is from terminal scratch car
await terminal.checkScratchCar(body.userId, body.car.visualModel!)
// Get the user's current car order // Get the user's current car order
let carOrder = createCar.user.carOrder; let carOrder = createCar.user.carOrder;
await carFunctions.carOrder(carOrder, car, createCar.user.id); await carFunctions.carOrder(carOrder, car, createCar.user.id);
@ -160,7 +183,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.CreateCarResponse.encode(msg); let message = wm.wm.protobuf.CreateCarResponse.encode(msg);
// Send the response // Send the response
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -226,7 +249,7 @@ export default class CarModule extends Module {
let message = wm.wm.protobuf.UpdateCarResponse.encode(msg); let message = wm.wm.protobuf.UpdateCarResponse.encode(msg);
// Send the response // Send the response
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -17,6 +17,7 @@ export async function createCarWithItem(userItemId: number)
} }
}); });
let tune = 0; let tune = 0;
let itemId = item.itemId;
console.log('Item deleted!'); console.log('Item deleted!');
@ -80,7 +81,7 @@ export async function createCarWithItem(userItemId: number)
} }
break; break;
} }
console.log(`Item category was ${item.category} and item game ID was ${item.itemId}`); console.log(`Item category was ${item.category} and item game ID was ${itemId}`);
return { tune } return { tune, itemId }
} }

View File

@ -10,7 +10,6 @@ import * as wmproto from "../../wmmt/wm.proto";
// Import Util // Import Util
import * as common from "../util/common"; import * as common from "../util/common";
import * as car_tune from "./car_tune"; import * as car_tune from "./car_tune";
import * as terminal from "../terminal/check_car";
// Get Car Data // Get Car Data
@ -287,20 +286,6 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
// User not found, terminate // User not found, terminate
if (!user) throw new Error(); if (!user) throw new Error();
// Generate blank car settings object
let settings = await prisma.carSettings.create({
data: {}
});
// Generate blank car state object
let state = await prisma.carState.create({
data: {}
});
let gtWing = await prisma.carGTWing.create({
data: {}
});
// Sets if full tune is used or not // Sets if full tune is used or not
// let fullyTuned = false; // let fullyTuned = false;
@ -308,6 +293,7 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
// 1: Basic Tune (600 HP) // 1: Basic Tune (600 HP)
// 2: Fully Tuned (840 HP) // 2: Fully Tuned (840 HP)
let tune = 0; let tune = 0;
let itemId = 0;
// If a user item has been used // If a user item has been used
if (body.userItemId) if (body.userItemId)
@ -315,6 +301,7 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
let carUtilFunctions = await car_tune.createCarWithItem(body.userItemId); let carUtilFunctions = await car_tune.createCarWithItem(body.userItemId);
tune = carUtilFunctions.tune; tune = carUtilFunctions.tune;
itemId = carUtilFunctions.itemId;
} }
// Other cases, may occur if item is not detected as 'used' // Other cases, may occur if item is not detected as 'used'
// User item not used, but car has 740 HP by default // User item not used, but car has 740 HP by default
@ -322,9 +309,6 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
{ {
// Car is fully tuned // Car is fully tuned
tune = 2; tune = 2;
// Check if created car is from terminal scratch car
await terminal.checkScratchCar(body.userId, body.car.visualModel!)
} }
// User item not used, but car has 600 HP by default // User item not used, but car has 600 HP by default
else if (body.car && body.car.tunePower == 10 && body.car.tuneHandling == 10) else if (body.car && body.car.tunePower == 10 && body.car.tuneHandling == 10)
@ -392,15 +376,12 @@ export async function createCar(body: wm.protobuf.CreateCarRequest)
level: body.car.level!, level: body.car.level!,
tunePower: body.car.tunePower!, tunePower: body.car.tunePower!,
tuneHandling: body.car.tuneHandling!, tuneHandling: body.car.tuneHandling!,
carSettingsDbId: settings.dbId,
carStateDbId: state.dbId,
carGTWingDbId: gtWing.dbId,
regionId: random, regionId: random,
lastPlayedAt: date, lastPlayedAt: date,
lastPlayedPlaceId: 1, // Server Default lastPlayedPlaceId: 1, // Server Default
}; };
return { carInsert, tune, user } return { carInsert, tune, user, itemId }
} }
@ -670,7 +651,7 @@ export async function updateCarCustomWing(body: wm.protobuf.UpdateCarRequest)
// Remove Used Ticket // Remove Used Ticket
export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any) export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: any, itemId: number)
{ {
let cheated: boolean = false; let cheated: boolean = false;
@ -698,7 +679,6 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
137, // NDERC 137, // NDERC
138, // UF31 138, // UF31
139, // GS130 139, // GS130
143, // 928GT
]; ];
let carVisualModelWithoutItem = [ let carVisualModelWithoutItem = [
@ -719,10 +699,6 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
125, // P400S 125, // P400S
126, // DIABLO 126, // DIABLO
133, // PS13 133, // PS13
137, // NDERC
138, // UF31
139, // GS130
143, // 928GT
]; ];
// Check if user item id is not set and its a special car // Check if user item id is not set and its a special car
@ -747,16 +723,15 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
} }
} }
// Get the item id
let item = await prisma.userItem.findFirst({
where: {
userItemId: body.userItemId
}
});
let itemId = item?.itemId || -1;
// Check if user item id is set and its a special car created from ticket // Check if user item id is set and its a special car created from ticket
if(car.visualModel === 130) if(car.visualModel === 122)
{
if(itemId < 7 || itemId > 15)
{
cheated = true;
}
}
else if(car.visualModel === 130)
{ {
if(itemId < 22 || itemId > 27) if(itemId < 22 || itemId > 27)
{ {
@ -770,13 +745,6 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
cheated = true; cheated = true;
} }
} }
else if(car.visualModel === 122)
{
if(itemId < 7 || itemId > 15)
{
cheated = true;
}
}
else if(car.visualModel === 137) else if(car.visualModel === 137)
{ {
if(itemId !== 37) if(itemId !== 37)
@ -786,14 +754,14 @@ export async function checkCreatedCar(body: wm.protobuf.CreateCarRequest, car: a
} }
else if(car.visualModel === 138) else if(car.visualModel === 138)
{ {
if(itemId !== 38) if(itemId !== 39)
{ {
cheated = true; cheated = true;
} }
} }
else if(car.visualModel === 139) else if(car.visualModel === 139)
{ {
if(itemId !== 39) if(itemId !== 38)
{ {
cheated = true; cheated = true;
} }

View File

@ -158,7 +158,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.SaveGameResultResponse.encode(msg); let message = wm.wm.protobuf.SaveGameResultResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -207,7 +207,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.LoadGameHistoryResponse.encode(msg); let message = wm.wm.protobuf.LoadGameHistoryResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -223,7 +223,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.SaveChargeResponse.encode(msg); let message = wm.wm.protobuf.SaveChargeResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -236,6 +236,108 @@ export default class GameModule extends Module {
// Perform the save screenshot request for the car // Perform the save screenshot request for the car
await gameFunction.saveScreenshot(body); await gameFunction.saveScreenshot(body);
// Check retire crown
let getCarCrown = await prisma.carCrownDetect.findFirst({
where:{
carId: body.carId
}
});
if(getCarCrown)
{
if(getCarCrown.status === 'retire')
{
await prisma.carCrownDetect.delete({
where:{
id: getCarCrown.id
}
});
}
else if(getCarCrown.status === 'finish')
{
let timestamp = body.playedAt - body.timestamp;
if(timestamp <= 120)
{
console.log('Crown Force Finish Detected');
// Update the user status
await prisma.carCrownDetect.update({
where:{
id: getCarCrown.id
},
data:{
status: 'forcefinish'
}
});
// Restore the old crown
await prisma.carCrown.update({
where:{
area: getCarCrown.area!
},
data:{
carId: getCarCrown.opponentCarId!,
area: getCarCrown.area!,
ramp: getCarCrown.ramp!,
path: getCarCrown.path!,
playedAt: getCarCrown.playedAt!,
tunePower: getCarCrown.tunePower!,
tuneHandling: getCarCrown.tuneHandling!,
}
});
await prisma.ghostTrail.updateMany({
where:{
area: getCarCrown.area!,
crownBattle: true
},
data:{
carId: getCarCrown.opponentCarId!,
area: getCarCrown.area!,
ramp: getCarCrown.ramp!,
path: getCarCrown.path!,
playedAt: getCarCrown.playedAt!,
tunePower: getCarCrown.tunePower!,
tuneHandling: getCarCrown.tuneHandling!,
trail: getCarCrown.trail!
}
});
// Banned the user
let getUserId = await prisma.car.findFirst({
where:{
carId: body.carId
},
select:{
userId: true
}
})
if(getUserId)
{
await prisma.user.update({
where:{
id: getUserId.userId
},
data:{
userBanned: true
}
});
}
}
else
{
await prisma.carCrownDetect.delete({
where:{
id: getCarCrown.id
}
});
}
}
}
// Response data // Response data
let msg = { let msg = {
error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS, error: wm.wm.protobuf.ErrorCode.ERR_SUCCESS,
@ -245,7 +347,7 @@ export default class GameModule extends Module {
let message = wm.wm.protobuf.SaveScreenshotResponse.encode(msg); let message = wm.wm.protobuf.SaveScreenshotResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -200,6 +200,9 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
// Declare data // Declare data
let dataCrown : any; let dataCrown : any;
let area = 0;
let ramp = 0;
let path = 0;
// ghostResultCrown is set // ghostResultCrown is set
if (ghostResultCrown) if (ghostResultCrown)
@ -219,9 +222,6 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
} }
// Get the area id and ramp id // Get the area id and ramp id
let area = 0;
let ramp = 0;
let path = 0;
if(body.rgResult?.path) if(body.rgResult?.path)
{ {
if(body.rgResult?.path >= 0 && body.rgResult?.path <= 9){ // GID_PATH_C1 if(body.rgResult?.path >= 0 && body.rgResult?.path <= 9){ // GID_PATH_C1
@ -289,20 +289,33 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
} }
// Get the available crown holder data // Get the available crown holder data
let carCrowns = await prisma.carCrown.count({ let carCrowns = await prisma.carCrown.findFirst({
where: { where: {
area: area area: area
} }
}); });
// Crown holder data available // Crown holder data available
if(carCrowns !== 0) if(carCrowns)
{ {
// Crown Finish Status
await prisma.carCrownDetect.create({
data:{
carId: body.carId,
status: 'finish',
area: carCrowns.area,
ramp: carCrowns.ramp,
path: carCrowns.path,
playedAt: carCrowns.playedAt,
tunePower: carCrowns.tunePower,
tuneHandling: carCrowns.tuneHandling
}
});
// Update it to the new one // Update it to the new one
let areaVal = Number(area);
await prisma.carCrown.update({ await prisma.carCrown.update({
where: { where: {
area: areaVal dbId: carCrowns.dbId
}, },
data: { data: {
...dataCrown, ...dataCrown,
@ -536,7 +549,6 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
// Retiring Ghost Battle // Retiring Ghost Battle
else if(body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_REGION || else if(body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_REGION ||
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_BY_LEVEL || body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_BY_LEVEL ||
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_CROWN_MATCH ||
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_STAMP_MATCH || body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_STAMP_MATCH ||
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_HISTORY || body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_FROM_HISTORY ||
body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_SHOP || body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SEARCH_BY_SHOP ||
@ -659,6 +671,19 @@ export async function saveGhostBattleResult(body: wm.protobuf.SaveGameResultRequ
} }
}); });
} }
// Retiring Crown Mode
else if(body.rgResult!.selectionMethod === wmproto.wm.protobuf.GhostSelectionMethod.GHOST_SELECT_CROWN_MATCH)
{
console.log('Crown Ghost Mode Found but Retiring');
// Crown Finish Status
await prisma.carCrownDetect.create({
data:{
carId: body.carId,
status: 'retire'
}
});
}
// Return the value to 'BASE_PATH/src/modules/game.ts' // Return the value to 'BASE_PATH/src/modules/game.ts'
return { ghostModePlay, updateNewTrail, OCMModePlay } return { ghostModePlay, updateNewTrail, OCMModePlay }

View File

@ -64,11 +64,31 @@ export default class GhostModule extends Module {
stampReturnStats: car?.stampSheet || null, stampReturnStats: car?.stampSheet || null,
}; };
let getUserId = await prisma.user.findFirst({
where:{
id: car!.userId
}
});
if(getUserId)
{
if(getUserId.userBanned === false)
{
// Encode the response // Encode the response
let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg); let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}
}
else
{
// Encode the response
let message = wm.wm.protobuf.LoadGhostBattleInfoResponse.encode(msg);
// Send the response to the client
common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}
}) })
@ -97,7 +117,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadStampTargetResponse.encode(msg); let message = wm.wm.protobuf.LoadStampTargetResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -174,7 +194,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.SearchCarsByLevelResponse.encode(msg); let message = wm.wm.protobuf.SearchCarsByLevelResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -266,7 +286,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadGhostDriveDataResponse.encode(msg); let message = wm.wm.protobuf.LoadGhostDriveDataResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -328,7 +348,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.RegisterGhostTrailResponse.encode(msg); let message = wm.wm.protobuf.RegisterGhostTrailResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -390,7 +410,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.GhostTrail.encode(msg); let message = wm.wm.protobuf.GhostTrail.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -496,7 +516,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadPathsAndTuningsResponse.encode(msg); let message = wm.wm.protobuf.LoadPathsAndTuningsResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -515,7 +535,7 @@ export default class GhostModule extends Module {
let message = wmsrv.wm.protobuf.LockCrownResponse.encode(msg); let message = wmsrv.wm.protobuf.LockCrownResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -218,6 +218,16 @@ export async function saveCrownGhostTrail(body: wm.protobuf.RegisterGhostTrailRe
console.log('Crown Trail history found'); console.log('Crown Trail history found');
console.log('Updating crown trail to the newest trail'); console.log('Updating crown trail to the newest trail');
await prisma.carCrownDetect.updateMany({
where:{
carId: ghostResult.car.carId!
},
data: {
trail: gtCount.trail,
opponentCarId: gtCount.carId
}
})
// Update the data // Update the data
await prisma.ghostTrail.update({ await prisma.ghostTrail.update({
where: { where: {

View File

@ -378,7 +378,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.LoadGhostCompetitionInfoResponse.encode(msg); let message = wm.wm.protobuf.LoadGhostCompetitionInfoResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -699,7 +699,7 @@ export default class GhostModule extends Module {
let message = wm.wm.protobuf.GhostCompetitionTarget.encode(msg); let message = wm.wm.protobuf.GhostCompetitionTarget.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -76,7 +76,7 @@ export default class ResourceModule extends Module {
let message = wm.wm.protobuf.PlaceList.encode({places}); let message = wm.wm.protobuf.PlaceList.encode({places});
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
// Get Ranking data for attract screen (TA, Ghost, VS) // Get Ranking data for attract screen (TA, Ghost, VS)
@ -103,7 +103,7 @@ export default class ResourceModule extends Module {
let message = wmsrv.wm.protobuf.Ranking.encode({lists}); let message = wmsrv.wm.protobuf.Ranking.encode({lists});
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -123,7 +123,7 @@ export default class ResourceModule extends Module {
let message = wmsrv.wm.protobuf.CrownList.encode( {crowns} ); let message = wmsrv.wm.protobuf.CrownList.encode( {crowns} );
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -184,7 +184,7 @@ export default class ResourceModule extends Module {
let message = wm.wm.protobuf.FileList.encode(msg); let message = wm.wm.protobuf.FileList.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -206,7 +206,7 @@ export default class ResourceModule extends Module {
let message = wmsrv.wm.protobuf.GhostList.encode(msg); let message = wmsrv.wm.protobuf.GhostList.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -49,7 +49,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.RegisterSystemInfoResponse.encode(msg); let message = wm.wm.protobuf.RegisterSystemInfoResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -70,7 +70,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg); let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -89,7 +89,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.PingResponse.encode(ping); let message = wm.wm.protobuf.PingResponse.encode(ping);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -110,7 +110,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.RegisterSystemStatsResponse.encode(msg); let message = wm.wm.protobuf.RegisterSystemStatsResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -135,7 +135,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.UpdateEventModeSerialResponse.encode(msg); let message = wm.wm.protobuf.UpdateEventModeSerialResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -156,7 +156,7 @@ export default class StartupModule extends Module {
let message = wm.wm.protobuf.SubmitClientLogResponse.encode(msg); let message = wm.wm.protobuf.SubmitClientLogResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -36,7 +36,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadTerminalInformationResponse.encode(msg); let message = wm.wm.protobuf.LoadTerminalInformationResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -91,7 +91,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg); let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -148,7 +148,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg); let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -177,7 +177,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg); let message = wm.wm.protobuf.LoadBookmarksResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -300,7 +300,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.CarSummary.encode(msg); let message = wm.wm.protobuf.CarSummary.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -360,7 +360,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.SaveTerminalResultResponse.encode(msg); let message = wm.wm.protobuf.SaveTerminalResultResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -440,7 +440,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadScratchInformationResponse.encode(msg); let message = wm.wm.protobuf.LoadScratchInformationResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -469,7 +469,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.TurnScratchSheetResponse.encode(msg); let message = wm.wm.protobuf.TurnScratchSheetResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -598,7 +598,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.SaveScratchSheetResponse.encode(msg); let message = wm.wm.protobuf.SaveScratchSheetResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -1033,7 +1033,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.encode(msg); let message = wm.wm.protobuf.LoadGhostCompetitionRankingResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -1098,7 +1098,7 @@ export default class TerminalModule extends Module {
let message = wm.wm.protobuf.RegisterOpponentGhostResponse.encode(msg); let message = wm.wm.protobuf.RegisterOpponentGhostResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -1144,7 +1144,7 @@ export default class TerminalModule extends Module {
}); });
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -1163,7 +1163,7 @@ export default class TerminalModule extends Module {
let message = wmsrv.wm.protobuf.LoadUnreceivedUserItemsResponse.encode(msg); let message = wmsrv.wm.protobuf.LoadUnreceivedUserItemsResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -1181,7 +1181,7 @@ export default class TerminalModule extends Module {
let message = wmsrv.wm.protobuf.CheckItemReceivableCarsResponse.encode(msg); let message = wmsrv.wm.protobuf.CheckItemReceivableCarsResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
*/ */
} }

View File

@ -60,7 +60,7 @@ export default class TimeAttackModule extends Module {
let message = wm.wm.protobuf.LoadTimeAttackRecordResponse.encode(msg); let message = wm.wm.protobuf.LoadTimeAttackRecordResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return; return;
} }
@ -83,7 +83,7 @@ export default class TimeAttackModule extends Module {
let message = wm.wm.protobuf.LoadTimeAttackRecordResponse.encode(msg); let message = wm.wm.protobuf.LoadTimeAttackRecordResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
} }
} }

View File

@ -68,7 +68,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg); let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return; return;
} }
@ -93,7 +93,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg); let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return; return;
} }
@ -199,7 +199,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg); let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
return; return;
} }
@ -587,7 +587,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadUserResponse.encode(msg); let message = wm.wm.protobuf.LoadUserResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -643,7 +643,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.CreateUserResponse.encode(msg); let message = wm.wm.protobuf.CreateUserResponse.encode(msg);
// Send response to client // Send response to client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -694,7 +694,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.LoadDriveInformationResponse.encode(msg); let message = wm.wm.protobuf.LoadDriveInformationResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -710,7 +710,7 @@ export default class UserModule extends Module {
let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg); let message = wm.wm.protobuf.UpdateUserSessionResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
@ -730,7 +730,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.StartTransferResponse.encode(msg); let message = wmsrv.wm.protobuf.StartTransferResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -749,7 +749,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.GrantCarRightResponse.encode(msg); let message = wmsrv.wm.protobuf.GrantCarRightResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -768,7 +768,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.AskAccessCodeResponse.encode(msg); let message = wmsrv.wm.protobuf.AskAccessCodeResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -787,7 +787,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.ParticipateInInviteFriendCampaignResponse.encode(msg); let message = wmsrv.wm.protobuf.ParticipateInInviteFriendCampaignResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}); });
@ -805,7 +805,7 @@ export default class UserModule extends Module {
let message = wmsrv.wm.protobuf.ConsumeUserItemResponse.encode(msg); let message = wmsrv.wm.protobuf.ConsumeUserItemResponse.encode(msg);
// Send the response to the client // Send the response to the client
common.sendResponse(message, res); common.sendResponse(message, res, req.rawHeaders[5], req.rawHeaders[7]);
}) })
*/ */
} }

View File

@ -1,11 +1,12 @@
import { Response } from "express"; import { Response } from "express";
import Long from "long";
import { Writer } from "protobufjs"; import { Writer } from "protobufjs";
import { Config } from "../../config";
import Long from "long";
// sendResponse(message, res): Void // sendResponse(message, res): Void
// Sends the server response to the client // Sends the server response to the client
export function sendResponse(message: Writer, res: Response) export function sendResponse(message: Writer, res: Response, rawHeaders: string, rawHeaders2: string)
{ {
// Get the end of the message // Get the end of the message
let end = message.finish(); let end = message.finish();
@ -17,9 +18,40 @@ export function sendResponse(message: Writer, res: Response)
.header('Content-Length', end.length.toString()) .header('Content-Length', end.length.toString())
.status(200); .status(200);
// Revision Check
let revisionCheck = Config.getConfig().gameOptions.revisionCheck || 1;
// Revision Check is enabled
if(revisionCheck === 1)
{
// Get the Revision
let getProtobufRev;
if(rawHeaders.includes('application/x-protobuf')) // application/x-protobuf; revision=number_here
{
getProtobufRev = rawHeaders.split('; ');
}
else
{
getProtobufRev = rawHeaders2.split('; ');
}
let protobufRev = getProtobufRev[1].split('='); // array 0 = content type, array 1 = protobuf revision
// Connect to the server if the Revision is match
if(protobufRev[1] === "8053")
{
// Send the response to the client // Send the response to the client
r.send(Buffer.from(end)); r.send(Buffer.from(end));
} }
// else{} Prevent connecting to the server
}
// Just send it
else
{
// Send the response to the client
r.send(Buffer.from(end));
}
}
// getBigIntFromLong(n: Long): BigInt // getBigIntFromLong(n: Long): BigInt