Fix profile ids being prepended with pmc/scav killing game load

This commit is contained in:
Dev 2023-12-27 22:01:30 +00:00
parent 8bd4a31c1e
commit db296499e9
8 changed files with 71 additions and 32 deletions

View File

@ -29,7 +29,7 @@ export class CustomizationCallbacks
public getSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetSuitsResponse> public getSuits(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData<IGetSuitsResponse>
{ {
const result: IGetSuitsResponse = { const result: IGetSuitsResponse = {
_id: `pmc${sessionID}`, _id: sessionID,
suites: this.saveServer.getProfile(sessionID).suits, suites: this.saveServer.getProfile(sessionID).suits,
}; };
return this.httpResponse.getBody(result); return this.httpResponse.getBody(result);

View File

@ -138,24 +138,7 @@ export class ProfileCallbacks
sessionID: string, sessionID: string,
): IGetBodyResponseData<GetProfileStatusResponseData> ): IGetBodyResponseData<GetProfileStatusResponseData>
{ {
const response: GetProfileStatusResponseData = { return this.httpResponse.getBody(this.profileController.getProfileStatus(sessionID));
maxPveCountExceeded: false,
profiles: [{
profileid: `scav${sessionID}`,
profileToken: null,
status: "Free",
sid: "",
ip: "",
port: 0,
version: "live",
location: "bigmap",
raidMode: "Online",
mode: "deathmatch",
shortId: "xxx1x1",
}, { profileid: `pmc${sessionID}`, profileToken: null, status: "Free", sid: "", ip: "", port: 0 }],
};
return this.httpResponse.getBody(response);
} }
/** /**

View File

@ -434,7 +434,7 @@ export class GameController
lang: "en", lang: "en",
aid: profile.aid, aid: profile.aid,
taxonomy: 6, taxonomy: 6,
activeProfileId: `pmc${sessionID}`, activeProfileId: sessionID,
backend: { backend: {
Lobby: this.httpServerHelper.getBackendUrl(), Lobby: this.httpServerHelper.getBackendUrl(),
Trading: this.httpServerHelper.getBackendUrl(), Trading: this.httpServerHelper.getBackendUrl(),

View File

@ -17,6 +17,8 @@ import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { SaveServer } from "@spt-aki/servers/SaveServer"; import { SaveServer } from "@spt-aki/servers/SaveServer";
import { LocalisationService } from "@spt-aki/services/LocalisationService"; import { LocalisationService } from "@spt-aki/services/LocalisationService";
import { HashUtil } from "@spt-aki/utils/HashUtil"; import { HashUtil } from "@spt-aki/utils/HashUtil";
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
@injectable() @injectable()
export class LauncherController export class LauncherController
@ -26,6 +28,8 @@ export class LauncherController
constructor( constructor(
@inject("WinstonLogger") protected logger: ILogger, @inject("WinstonLogger") protected logger: ILogger,
@inject("HashUtil") protected hashUtil: HashUtil, @inject("HashUtil") protected hashUtil: HashUtil,
@inject("TimeUtil") protected timeUtil: TimeUtil,
@inject("RandomUtil") protected randomUtil: RandomUtil,
@inject("SaveServer") protected saveServer: SaveServer, @inject("SaveServer") protected saveServer: SaveServer,
@inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper, @inject("HttpServerHelper") protected httpServerHelper: HttpServerHelper,
@inject("ProfileHelper") protected profileHelper: ProfileHelper, @inject("ProfileHelper") protected profileHelper: ProfileHelper,
@ -110,9 +114,11 @@ export class LauncherController
protected createAccount(info: IRegisterData): string protected createAccount(info: IRegisterData): string
{ {
const sessionID = this.hashUtil.generate(); const profileId = this.generateProfileId();
const scavId = this.generateProfileId();
const newProfileDetails: Info = { const newProfileDetails: Info = {
id: sessionID, id: profileId,
scavId: scavId,
aid: this.hashUtil.generateAccountId(), aid: this.hashUtil.generateAccountId(),
username: info.username, username: info.username,
password: info.password, password: info.password,
@ -121,10 +127,25 @@ export class LauncherController
}; };
this.saveServer.createProfile(newProfileDetails); this.saveServer.createProfile(newProfileDetails);
this.saveServer.loadProfile(sessionID); this.saveServer.loadProfile(profileId);
this.saveServer.saveProfile(sessionID); this.saveServer.saveProfile(profileId);
return sessionID; return profileId;
}
protected generateProfileId(): string
{
const timestamp = this.timeUtil.getTimestamp();
return this.formatID(timestamp, timestamp * this.randomUtil.getInt(1, 1000000));
}
protected formatID(timeStamp: number, counter: number): string
{
const timeStampStr = timeStamp.toString(16).padStart(8, '0');
const counterStr = counter.toString(16).padStart(16, '0');
return timeStampStr.toLowerCase() + counterStr.toLowerCase();
} }
public changeUsername(info: IChangeRequestData): string public changeUsername(info: IChangeRequestData): string

View File

@ -10,6 +10,7 @@ import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { TemplateSide } from "@spt-aki/models/eft/common/tables/IProfileTemplate"; import { TemplateSide } from "@spt-aki/models/eft/common/tables/IProfileTemplate";
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse"; import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
import { IMiniProfile } from "@spt-aki/models/eft/launcher/IMiniProfile"; import { IMiniProfile } from "@spt-aki/models/eft/launcher/IMiniProfile";
import { GetProfileStatusResponseData } from "@spt-aki/models/eft/profile/GetProfileStatusResponseData";
import { IAkiProfile, Inraid, Vitality } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IAkiProfile, Inraid, Vitality } from "@spt-aki/models/eft/profile/IAkiProfile";
import { IProfileChangeNicknameRequestData } from "@spt-aki/models/eft/profile/IProfileChangeNicknameRequestData"; import { IProfileChangeNicknameRequestData } from "@spt-aki/models/eft/profile/IProfileChangeNicknameRequestData";
import { IProfileChangeVoiceRequestData } from "@spt-aki/models/eft/profile/IProfileChangeVoiceRequestData"; import { IProfileChangeVoiceRequestData } from "@spt-aki/models/eft/profile/IProfileChangeVoiceRequestData";
@ -133,9 +134,9 @@ export class ProfileController
this.deleteProfileBySessionId(sessionID); this.deleteProfileBySessionId(sessionID);
// PMC // PMC
pmcData._id = `pmc${sessionID}`; pmcData._id = account.id;
pmcData.aid = account.aid; pmcData.aid = account.aid;
pmcData.savage = `scav${sessionID}`; pmcData.savage = account.scavId;
pmcData.sessionId = sessionID; pmcData.sessionId = sessionID;
pmcData.Info.Nickname = info.nickname; pmcData.Info.Nickname = info.nickname;
pmcData.Info.LowerNickname = info.nickname.toLowerCase(); pmcData.Info.LowerNickname = info.nickname.toLowerCase();
@ -356,4 +357,30 @@ export class ProfileController
{ {
return [{ _id: this.hashUtil.generate(), Info: { Level: 1, Side: "Bear", Nickname: info.nickname } }]; return [{ _id: this.hashUtil.generate(), Info: { Level: 1, Side: "Bear", Nickname: info.nickname } }];
} }
/**
* Handle client/profile/status
*/
public getProfileStatus(sessionId: string): GetProfileStatusResponseData
{
const account = this.saveServer.getProfile(sessionId).info;
const response: GetProfileStatusResponseData = {
maxPveCountExceeded: false,
profiles: [{
profileid: account.scavId,
profileToken: null,
status: "Free",
sid: "",
ip: "",
port: 0,
version: "live",
location: "bigmap",
raidMode: "Online",
mode: "deathmatch",
shortId: "xxx1x1",
}, { profileid: account.id, profileToken: null, status: "Free", sid: "", ip: "", port: 0 }],
};
return response;
}
} }

View File

@ -29,7 +29,9 @@ export class TraderPurchaseData
export interface Info export interface Info
{ {
/** main profile id */
id: string; id: string;
scavId: string;
aid: number; aid: number;
username: string; username: string;
password: string; password: string;

View File

@ -50,7 +50,7 @@ export class HttpRouter
// TODO: Temporary hack to change ItemEventRouter response sessionID binding to what client expects // TODO: Temporary hack to change ItemEventRouter response sessionID binding to what client expects
if (wrapper.output?.includes("\"profileChanges\":{")) if (wrapper.output?.includes("\"profileChanges\":{"))
{ {
wrapper.output = wrapper.output.replace(sessionID, `pmc${sessionID}`); wrapper.output = wrapper.output.replace(sessionID, sessionID);
} }
return wrapper.output; return wrapper.output;

View File

@ -1,6 +1,7 @@
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { ICreateGroupRequestData } from "@spt-aki/models/eft/match/ICreateGroupRequestData"; import { ICreateGroupRequestData } from "@spt-aki/models/eft/match/ICreateGroupRequestData";
import { SaveServer } from "@spt-aki/servers/SaveServer";
import { TimeUtil } from "@spt-aki/utils/TimeUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil";
@injectable() @injectable()
@ -8,16 +9,21 @@ export class MatchLocationService
{ {
protected locations = {}; protected locations = {};
constructor(@inject("TimeUtil") protected timeUtil: TimeUtil) constructor(
@inject("TimeUtil") protected timeUtil: TimeUtil,
@inject("SaveServer") protected saveServer: SaveServer,
)
{} {}
public createGroup(sessionID: string, info: ICreateGroupRequestData): any public createGroup(sessionID: string, info: ICreateGroupRequestData): any
{ {
const account = this.saveServer.getProfile(sessionID).info;
const groupID = "test"; const groupID = "test";
this.locations[info.location].groups[groupID] = { this.locations[info.location].groups[groupID] = {
_id: groupID, _id: groupID,
owner: `pmc${sessionID}`, owner: account.id,
location: info.location, location: info.location,
gameVersion: "live", gameVersion: "live",
region: "EUR", region: "EUR",
@ -26,10 +32,10 @@ export class MatchLocationService
timeShift: "CURR", timeShift: "CURR",
dt: this.timeUtil.getTimestamp(), dt: this.timeUtil.getTimestamp(),
players: [{ players: [{
_id: `pmc${sessionID}`, _id: account.id,
region: "EUR", region: "EUR",
ip: "127.0.0.1", ip: "127.0.0.1",
savageId: `scav${sessionID}`, savageId: account.scavId,
accessKeyId: "", accessKeyId: "",
}], }],
customDataCenter: [], customDataCenter: [],