Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preserve client loadout on lobby join #43

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/classes/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ export class Handler {
console.error("Unknown discover type", request.body.bitsToDiscover);
case DiscoverTypes.INITIAL_LOAD:
try {
const [userSaveGame, serverInfo] = await Promise.all([Handler.getUserSaveGame(id), Handler.getGeneralServerInfo()]);
const [userSaveGame, serverInfo] = await Promise.all([Handler.getUserSaveGame(request.body.accountIdToDiscover ?? id), Handler.getGeneralServerInfo()]);
// TODO when we actually implement the bitsToDiscoverFlag PROPERLY we should remove this
if (request.body.accountIdToDiscover != null) {
delete userSaveGame.data.playerSettingsData;
}
userSaveGame.data.DDT_SpecificLoadoutsBit = userSaveGame.data.DDT_AllLoadoutsBit;
// End of the TODO remove in the future block
return response.send(deepmerge(userSaveGame, serverInfo));
} catch (e) {
const str = String(e);
Expand Down Expand Up @@ -373,7 +379,7 @@ export class Handler {

/**
* Get info that's general for the whole server, not of an specific user
* */
* */
static async getGeneralServerInfo(): Promise<Partial<SaveGameResponse>> {
const collection = db.collection<ServerInfo>(Collections.SERVER_INFO);
const event = (await collection.findOneAsync({})).currentEvent;
Expand Down
1 change: 1 addition & 0 deletions src/types/save-game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface SaveData {
DDT_AllPlayerSlotsBit?: DDTAllPlayerSlotsBit;
/**Character-related info */
DDT_AllLoadoutsBit?: DDTAllLoadoutsBit;
DDT_SpecificLoadoutsBit?: Partial<DDTAllLoadoutsBit>;
DDT_AllWeaponsBit?: DDTAllWeaponsBit;
DDT_AllInventoryItemsBit?: DDTAllInventoryItemsBit[];
DDT_AllUnclaimedChestsBit?: any[];
Expand Down
4 changes: 3 additions & 1 deletion src/types/vhs-the-game-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ export interface LoginData {
}

export interface DiscoverRequest {
/** Account ID we need to get info from. Empty if the logged user one */
accountIdToDiscover?: string;
/** Some kind of ID to know what information we're requesting */
bitsToDiscover?: DiscoverTypes;
bitsToDiscover: DiscoverTypes;
/** ID-like, not the same as the LoginRequest, not the same across requests (nonce?) */
idpk?: string;
journeyGuid?: string;
Expand Down