0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Implemented updated endpoint for applying clothing to a players character

Fixed dogtag customisation choice not being saved to the correct parameter

Removed dead endpoint
This commit is contained in:
Chomp 2024-12-30 16:55:32 +00:00
parent 502f08c414
commit d5f9c1f253
3 changed files with 44 additions and 45 deletions

View File

@ -42,17 +42,6 @@ export class CustomizationCallbacks {
return this.httpResponse.getBody(this.customizationController.getTraderSuits(traderID, sessionID));
}
/**
* Handle CustomizationWear event
*/
public wearClothing(
pmcData: IPmcData,
body: IWearClothingRequestData,
sessionID: string,
): IItemEventRouterResponse {
return this.customizationController.wearClothing(pmcData, body, sessionID);
}
/**
* Handle CustomizationBuy event
*/

View File

@ -7,13 +7,14 @@ import type {
IBuyClothingRequestData,
IPaymentItemForClothing,
} from "@spt/models/eft/customization/IBuyClothingRequestData";
import type { ICustomizationSetRequest } from "@spt/models/eft/customization/ICustomizationSetRequest";
import type { IWearClothingRequestData } from "@spt/models/eft/customization/IWearClothingRequestData";
import type {
CustomizationSetOption,
ICustomizationSetRequest,
} from "@spt/models/eft/customization/ICustomizationSetRequest";
import type { IHideoutCustomisation } from "@spt/models/eft/hideout/IHideoutCustomisation";
import type { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
import { ISptProfile } from "@spt/models/eft/profile/ISptProfile";
import { GameEditions } from "@spt/models/enums/GameEditions";
import { ItemTpl } from "@spt/models/enums/ItemTpl";
import type { ILogger } from "@spt/models/spt/utils/ILogger";
import { EventOutputHolder } from "@spt/routers/EventOutputHolder";
import { SaveServer } from "@spt/servers/SaveServer";
@ -63,34 +64,6 @@ export class CustomizationController {
return matchedSuits;
}
/**
* Handle CustomizationWear event
* Equip one to many clothing items to player
*/
public wearClothing(
pmcData: IPmcData,
wearClothingRequest: IWearClothingRequestData,
sessionID: string,
): IItemEventRouterResponse {
for (const suitId of wearClothingRequest.suites) {
// Find desired clothing item in db
const dbSuit = this.databaseService.getCustomization()[suitId];
// Legs
if (dbSuit._parent === this.clothingIds.lowerParentId) {
pmcData.Customization.Feet = dbSuit._props.Feet;
}
// Torso
if (dbSuit._parent === this.clothingIds.upperParentId) {
pmcData.Customization.Body = dbSuit._props.Body;
pmcData.Customization.Hands = dbSuit._props.Hands;
}
}
return this.eventOutputHolder.getOutput(sessionID);
}
/**
* Handle CustomizationBuy event
* Purchase/unlock a clothing item from a trader
@ -350,9 +323,48 @@ export class CustomizationController {
pmcData: IPmcData,
): IItemEventRouterResponse {
for (const customisation of request.customizations) {
pmcData.Customization[customisation.type] = customisation.id;
switch (customisation.type) {
case "dogTag":
pmcData.Customization.DogTag = customisation.id;
break;
case "suite":
this.applyClothingItemToProfile(customisation, pmcData);
break;
default:
this.logger.error(`Unhandled customisation type: ${customisation.type}`);
break;
}
}
return this.eventOutputHolder.getOutput(sessionId);
}
/**
* Applies a purchsed suit to the players doll
* @param customisation Suit to apply to profile
* @param pmcData Profile to update
*/
protected applyClothingItemToProfile(customisation: CustomizationSetOption, pmcData: IPmcData): void {
const dbSuit = this.databaseService.getCustomization()[customisation.id];
if (!dbSuit) {
this.logger.error(
`Unable to find suit customisation id: ${customisation.id}, cannot apply clothing to player profile: ${pmcData._id}`,
);
return;
}
// Body
if (dbSuit._parent === this.clothingIds.upperParentId) {
pmcData.Customization.Body = dbSuit._props.Body;
pmcData.Customization.Hands = dbSuit._props.Hands;
return;
}
// Feet
if (dbSuit._parent === this.clothingIds.lowerParentId) {
pmcData.Customization.Feet = dbSuit._props.Feet;
}
}
}

View File

@ -27,8 +27,6 @@ export class CustomizationItemEventRouter extends ItemEventRouterDefinition {
sessionID: string,
): Promise<IItemEventRouterResponse> {
switch (url) {
case "CustomizationWear":
return this.customizationCallbacks.wearClothing(pmcData, body, sessionID);
case "CustomizationBuy":
return this.customizationCallbacks.buyClothing(pmcData, body, sessionID);
case "CustomizationSet":