Skip to content

Commit

Permalink
Changing naming of "Dedicated" client to "Headless"
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchangelWTF committed Jan 14, 2025
1 parent fbe942b commit c57c261
Show file tree
Hide file tree
Showing 33 changed files with 225 additions and 228 deletions.
15 changes: 7 additions & 8 deletions src/Fika.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ import { ImporterUtil } from "@spt/utils/ImporterUtil";
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
import { ICoreConfig } from "@spt/models/spt/config/ICoreConfig";
import { ConfigServer } from "@spt/servers/ConfigServer";
import { FikaClientController } from "./controllers/FikaClientController";
import { IFikaConfigBackground } from "./models/fika/config/IFikaConfigBackground";
import { IFikaConfigDedicated } from "./models/fika/config/IFikaConfigDedicated";
import { IFikaConfigHeadless } from "./models/fika/config/IFikaConfigHeadless";
import { IFikaConfigNatPunchServer } from "./models/fika/config/IFikaConfigNatPunchServer";
import { Overrider } from "./overrides/Overrider";
import { FikaClientService } from "./services/FikaClientService";
import { FikaPlayerRelationsCacheService } from "./services/cache/FikaPlayerRelationsCacheService";
import { FikaDedicatedProfileService } from "./services/dedicated/FikaDedicatedProfileService";
import { FikaHeadlessProfileService } from "./services/headless/FikaHeadlessProfileService";
import { FikaConfig } from "./utils/FikaConfig";
import { FikaServerTools } from "./utils/FikaServerTools";

@injectable()
export class Fika {
protected modPath: string;
protected natPunchServerConfig: IFikaConfigNatPunchServer;
protected dedicatedConfig: IFikaConfigDedicated;
protected headlessConfig: IFikaConfigHeadless;
protected backgroundConfig: IFikaConfigBackground;

constructor(
Expand All @@ -34,7 +33,7 @@ export class Fika {
@inject("FikaServerTools") protected fikaServerTools: FikaServerTools,
@inject("FikaConfig") protected fikaConfig: FikaConfig,
@inject("FikaClientService") protected fikaClientService: FikaClientService,
@inject("FikaDedicatedProfileService") protected fikaDedicatedProfileService: FikaDedicatedProfileService,
@inject("FikaHeadlessProfileService") protected fikaHeadlessProfileService: FikaHeadlessProfileService,
@inject("ImageRouter") protected imageRouter: ImageRouter,
@inject("ImporterUtil") protected importerUtil: ImporterUtil,
@inject("FikaPlayerRelationsCacheService") protected fikaPlayerRelationCacheServce: FikaPlayerRelationsCacheService,
Expand All @@ -46,7 +45,7 @@ export class Fika {
await this.fikaConfig.preInit();

this.natPunchServerConfig = this.fikaConfig.getConfig().natPunchServer;
this.dedicatedConfig = this.fikaConfig.getConfig().dedicated;
this.headlessConfig = this.fikaConfig.getConfig().headless;
this.backgroundConfig = this.fikaConfig.getConfig().background;

await this.fikaClientService.preInit();
Expand All @@ -58,8 +57,8 @@ export class Fika {
this.fikaServerTools.startService("NatPunchServer");
}

if (this.dedicatedConfig.profiles.amount > 0) {
this.fikaDedicatedProfileService.init();
if (this.headlessConfig.profiles.amount > 0) {
this.fikaHeadlessProfileService.init();
}

await this.addFikaClientLocales();
Expand Down
24 changes: 12 additions & 12 deletions src/callbacks/FikaRaidCallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { HttpResponseUtil } from "@spt/utils/HttpResponseUtil";
import { FikaRaidController } from "../controllers/FikaRaidController";
import { IFikaRaidServerIdRequestData } from "../models/fika/routes/raid/IFikaRaidServerIdRequestData";
import { IFikaRaidCreateRequestData } from "../models/fika/routes/raid/create/IFikaRaidCreateRequestData";
import { IStartDedicatedRequest } from "../models/fika/routes/raid/dedicated/IStartDedicatedRequest";
import { IStatusDedicatedRequest } from "../models/fika/routes/raid/dedicated/IStatusDedicatedRequest";
import { IStartHeadlessRequest } from "../models/fika/routes/raid/headless/IStartHeadlessRequest";
import { IStatusHeadlessRequest } from "../models/fika/routes/raid/headless/IStatusHeadlessRequest";
import { IFikaRaidJoinRequestData } from "../models/fika/routes/raid/join/IFikaRaidJoinRequestData";
import { IFikaRaidLeaveRequestData } from "../models/fika/routes/raid/leave/IFikaRaidLeaveRequestData";

Expand Down Expand Up @@ -48,22 +48,22 @@ export class FikaRaidCallbacks {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidGetSettings(info));
}

/** Handle /fika/raid/dedicated/start */
public handleRaidStartDedicated(_url: string, info: IStartDedicatedRequest, sessionID: string): string {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidStartDedicated(sessionID, info));
/** Handle /fika/raid/headless/start */
public handleRaidStartHeadless(_url: string, info: IStartHeadlessRequest, sessionID: string): string {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidStartHeadless(sessionID, info));
}

/** Handle /fika/raid/dedicated/status */
public handleRaidStatusDedicated(_url: string, info: IStatusDedicatedRequest, sessionID: string): string {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidStatusDedicated(sessionID, info));
/** Handle /fika/raid/headless/status */
public handleRaidStatusHeadless(_url: string, info: IStatusHeadlessRequest, sessionID: string): string {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidStatusHeadless(sessionID, info));
}

/** Handle /fika/raid/dedicated/getstatus */
public handleRaidGetStatusDedicated(_url: string, _info: any, _sessionID: string): string {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidGetStatusDedicated());
/** Handle /fika/raid/headless/getstatus */
public handleRaidGetStatusHeadless(_url: string, _info: any, _sessionID: string): string {
return this.httpResponseUtil.noBody(this.fikaRaidController.handleRaidGetStatusHeadless());
}

/** Handle /fika/raid/dedicated/registerPlayer */
/** Handle /fika/raid/registerPlayer */
public handleRaidRegisterPlayer(_url: string, info: IRegisterPlayerRequestData, sessionID: string): INullResponseData {
this.fikaRaidController.handleRaidRegisterPlayer(sessionID, info);

Expand Down
4 changes: 2 additions & 2 deletions src/controllers/FikaAchievementController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class FikaAchievementController {
) {
// empty
}
getAchievementStatistics(_sessionID: string): ICompletedAchievementsResponse {
public getAchievementStatistics(_sessionID: string): ICompletedAchievementsResponse {
const achievements = this.databaseService.getAchievements();
const stats: Record<string, number> = {};

Expand All @@ -21,7 +21,7 @@ export class FikaAchievementController {
for (const achievement of achievements) {
let percentage = 0;
for (const profile of profiles) {
if (profile.info?.password === "fika-dedicated") {
if (profile.info?.password === "fika-headless") {
continue;
}

Expand Down
98 changes: 49 additions & 49 deletions src/controllers/FikaRaidController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,35 @@ import { IRegisterPlayerRequestData } from "@spt/models/eft/inRaid/IRegisterPlay
import type { ILogger } from "@spt/models/spt/utils/ILogger";
import { DatabaseService } from "@spt/services/DatabaseService";

import { EDedicatedStatus } from "../models/enums/EDedicatedStatus";
import { EFikaMatchEndSessionMessage } from "../models/enums/EFikaMatchEndSessionMessages";
import { EFikaNotifications } from "../models/enums/EFikaNotifications";
import { EHeadlessStatus } from "../models/enums/EHeadlessStatus";
import { IFikaRaidServerIdRequestData } from "../models/fika/routes/raid/IFikaRaidServerIdRequestData";
import { IFikaRaidCreateRequestData } from "../models/fika/routes/raid/create/IFikaRaidCreateRequestData";
import { IFikaRaidCreateResponse } from "../models/fika/routes/raid/create/IFikaRaidCreateResponse";
import { IGetStatusDedicatedResponse } from "../models/fika/routes/raid/dedicated/IGetStatusDedicatedResponse";
import { IStartDedicatedRequest } from "../models/fika/routes/raid/dedicated/IStartDedicatedRequest";
import { IStartDedicatedResponse } from "../models/fika/routes/raid/dedicated/IStartDedicatedResponse";
import { IStatusDedicatedRequest } from "../models/fika/routes/raid/dedicated/IStatusDedicatedRequest";
import { IStatusDedicatedResponse } from "../models/fika/routes/raid/dedicated/IStatusDedicatedResponse";
import { IFikaRaidGethostResponse } from "../models/fika/routes/raid/gethost/IFikaRaidGethostResponse";
import { IFikaRaidSettingsResponse } from "../models/fika/routes/raid/getsettings/IFikaRaidSettingsResponse";
import { IGetStatusHeadlessResponse } from "../models/fika/routes/raid/headless/IGetStatusHeadlessResponse";
import { IStartHeadlessRequest } from "../models/fika/routes/raid/headless/IStartHeadlessRequest";
import { IStartHeadlessResponse } from "../models/fika/routes/raid/headless/IStartHeadlessResponse";
import { IStatusHeadlessRequest } from "../models/fika/routes/raid/headless/IStatusHeadlessRequest";
import { IStatusHeadlessResponse } from "../models/fika/routes/raid/headless/IStatusHeadlessResponse";
import { IFikaRaidJoinRequestData } from "../models/fika/routes/raid/join/IFikaRaidJoinRequestData";
import { IFikaRaidJoinResponse } from "../models/fika/routes/raid/join/IFikaRaidJoinResponse";
import { IFikaRaidLeaveRequestData } from "../models/fika/routes/raid/leave/IFikaRaidLeaveRequestData";
import { IStartRaidNotification } from "../models/fika/websocket/notifications/IStartRaidNotification";
import { FikaMatchService } from "../services/FikaMatchService";
import { FikaDedicatedRaidService } from "../services/dedicated/FikaDedicatedRaidService";
import { FikaDedicatedRaidWebSocket } from "../websockets/FikaDedicatedRaidWebSocket";
import { FikaHeadlessRaidService } from "../services/headless/FikaHeadlessRaidService";
import { FikaHeadlessRaidWebSocket } from "../websockets/FikaHeadlessRaidWebSocket";
import { FikaNotificationWebSocket } from "../websockets/FikaNotificationWebSocket";

@injectable()
export class FikaRaidController {
constructor(
@inject("DatabaseService") protected databaseService: DatabaseService,
@inject("FikaMatchService") protected fikaMatchService: FikaMatchService,
@inject("FikaDedicatedRaidService") protected fikaDedicatedRaidService: FikaDedicatedRaidService,
@inject("FikaDedicatedRaidWebSocket") protected fikaDedicatedRaidWebSocket: FikaDedicatedRaidWebSocket,
@inject("FikaHeadlessRaidService") protected fikaHeadlessRaidService: FikaHeadlessRaidService,
@inject("fikaHeadlessRaidWebSocket") protected fikaHeadlessRaidWebSocket: FikaHeadlessRaidWebSocket,
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
@inject("WinstonLogger") protected logger: ILogger,
@inject("InraidController") protected inraidController: InraidController,
Expand Down Expand Up @@ -106,7 +106,7 @@ export class FikaRaidController {
ips: match.ips,
port: match.port,
natPunch: match.natPunch,
isDedicated: match.isDedicated,
isHeadless: match.isHeadless,
};
}

Expand All @@ -128,95 +128,95 @@ export class FikaRaidController {
};
}

/** Handle /fika/raid/dedicated/start */
handleRaidStartDedicated(sessionID: string, info: IStartDedicatedRequest): IStartDedicatedResponse {
if (!this.fikaDedicatedRaidService.isDedicatedClientAvailable()) {
/** Handle /fika/raid/headless/start */
public handleRaidStartHeadless(sessionID: string, info: IStartHeadlessRequest): IStartHeadlessResponse {
if (!this.fikaHeadlessRaidService.isHeadlessClientAvailable()) {
return {
matchId: null,
error: "No dedicated clients available.",
error: "No headless clients available.",
};
}

if (sessionID in this.fikaDedicatedRaidService.dedicatedClients) {
if (sessionID in this.fikaHeadlessRaidService.headlessClients) {
return {
matchId: null,
error: "You are trying to connect to a dedicated client while having Fika.Dedicated installed. Please remove Fika.Dedicated from your client and try again.",
error: "You are trying to connect to a headless client while having Fika.Headless installed. Please remove Fika.Headless from your client and try again.",
};
}

let dedicatedClient: string | undefined = undefined;
let dedicatedClientWs: WebSocket | undefined = undefined;
let HeadlessClient: string | undefined = undefined;
let HeadlessClientWs: WebSocket | undefined = undefined;

for (const dedicatedSessionId in this.fikaDedicatedRaidService.dedicatedClients) {
const dedicatedClientInfo = this.fikaDedicatedRaidService.dedicatedClients[dedicatedSessionId];
for (const headlessSessionId in this.fikaHeadlessRaidService.headlessClients) {
const headlessClientInfo = this.fikaHeadlessRaidService.headlessClients[headlessSessionId];

if (dedicatedClientInfo.state != EDedicatedStatus.READY) {
if (headlessClientInfo.state != EHeadlessStatus.READY) {
continue;
}

dedicatedClientWs = this.fikaDedicatedRaidWebSocket.clientWebSockets[dedicatedSessionId];
HeadlessClientWs = this.fikaHeadlessRaidWebSocket.clientWebSockets[headlessSessionId];

if (!dedicatedClientWs || dedicatedClientWs.readyState == WebSocket.CLOSED) {
if (!HeadlessClientWs || HeadlessClientWs.readyState == WebSocket.CLOSED) {
continue;
}

dedicatedClient = dedicatedSessionId;
HeadlessClient = headlessSessionId;
break;
}

if (!dedicatedClient) {
if (!HeadlessClient) {
return {
matchId: null,
error: "No dedicated clients available at this time.",
error: "No headless client available at this time.",
};
}

const pmcDedicatedClientProfile: IPmcData = this.profileHelper.getPmcProfile(dedicatedClient);
const pmcHeadlessclientProfile: IPmcData = this.profileHelper.getPmcProfile(HeadlessClient);
const requesterProfile: IPmcData = this.profileHelper.getPmcProfile(sessionID);

this.logger.debug(`Dedicated: ${pmcDedicatedClientProfile.Info.Nickname} ${pmcDedicatedClientProfile.Info.Level} - Requester: ${requesterProfile.Info.Nickname} ${requesterProfile.Info.Level}`);
this.logger.debug(`Headless: ${pmcHeadlessclientProfile.Info.Nickname} ${pmcHeadlessclientProfile.Info.Level} - Requester: ${requesterProfile.Info.Nickname} ${requesterProfile.Info.Level}`);

//Set level of the dedicated profile to the person that has requested the raid to be started.
pmcDedicatedClientProfile.Info.Level = requesterProfile.Info.Level;
pmcDedicatedClientProfile.Info.Experience = requesterProfile.Info.Experience;
//Set level of the headless client profile to the person that has requested the raid to be started.
pmcHeadlessclientProfile.Info.Level = requesterProfile.Info.Level;
pmcHeadlessclientProfile.Info.Experience = requesterProfile.Info.Experience;

this.fikaDedicatedRaidService.requestedSessions[dedicatedClient] = sessionID;
this.fikaHeadlessRaidService.requestedSessions[HeadlessClient] = sessionID;

dedicatedClientWs.send(
HeadlessClientWs.send(
JSON.stringify({
type: "fikaDedicatedStartRaid",
type: "fikaHeadlessStartRaid",
...info,
}),
);

this.logger.info(`Sent WS fikaDedicatedStartRaid to ${dedicatedClient}`);
this.logger.info(`Sent WS fikaHeadlessStartRaid to ${HeadlessClient}`);

return {
// This really isn't required, I just want to make sure on the client
matchId: dedicatedClient,
matchId: HeadlessClient,
error: null,
};
}

/** Handle /fika/raid/dedicated/status */
public handleRaidStatusDedicated(sessionId: string, info: IStatusDedicatedRequest): IStatusDedicatedResponse {
/** Handle /fika/raid/headless/status */
public handleRaidStatusHeadless(sessionId: string, info: IStatusHeadlessRequest): IStatusHeadlessResponse {
// Temp fix because the enum gets deserialized as a string instead of an integer
switch (info.status.toString()) {
case "READY":
info.status = EDedicatedStatus.READY;
info.status = EHeadlessStatus.READY;
break;
case "IN_RAID":
info.status = EDedicatedStatus.IN_RAID;
info.status = EHeadlessStatus.IN_RAID;
break;
}

if (info.status == EDedicatedStatus.READY && !this.fikaDedicatedRaidService.isDedicatedClientAvailable()) {
if (this.fikaDedicatedRaidService.onDedicatedClientAvailable) {
this.fikaDedicatedRaidService.onDedicatedClientAvailable();
if (info.status == EHeadlessStatus.READY && !this.fikaHeadlessRaidService.isHeadlessClientAvailable()) {
if (this.fikaHeadlessRaidService.onHeadlessClientAvailable) {
this.fikaHeadlessRaidService.onHeadlessClientAvailable();
}
}

this.fikaDedicatedRaidService.dedicatedClients[sessionId] = {
this.fikaHeadlessRaidService.headlessClients[sessionId] = {
state: info.status,
lastPing: Date.now(),
};
Expand All @@ -227,14 +227,14 @@ export class FikaRaidController {
};
}

/** Handle /fika/raid/dedicated/getstatus */
public handleRaidGetStatusDedicated(): IGetStatusDedicatedResponse {
/** Handle /fika/raid/headless/getstatus */
public handleRaidGetStatusHeadless(): IGetStatusHeadlessResponse {
return {
available: this.fikaDedicatedRaidService.isDedicatedClientAvailable(),
available: this.fikaHeadlessRaidService.isHeadlessClientAvailable(),
};
}

/** Handle /fika/raid/dedicated/registerPlayer */
/** Handle /fika/raid/registerPlayer */
public handleRaidRegisterPlayer(sessionId: string, info: IRegisterPlayerRequestData): void {
this.inraidController.addPlayer(sessionId, info);
}
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/FikaSendItemController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class FikaSendItemController {
//Uninitialized profiles can cause this to error out, skip these.
if (!profile.characters?.pmc?.Info) continue;

if (profile.info.password === "fika-dedicated") continue;
if (profile.info.password === "fika-headless") continue;

const nickname = profile.characters.pmc.Info.Nickname;
if (!(nickname in result) && nickname !== sender.characters.pmc.Info.Nickname) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/FikaUpdateController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class FikaUpdateController {
* @param request
*/
public handleSethost(request: IFikaUpdateSethostRequestData): void {
this.fikaMatchService.setMatchHost(request.serverId, request.ips, request.port, request.natPunch, request.isDedicated);
this.fikaMatchService.setMatchHost(request.serverId, request.ips, request.port, request.natPunch, request.isHeadless);
}

/**
Expand Down
Loading

0 comments on commit c57c261

Please sign in to comment.