When launcher requests profiles and the exp is null, fall back to 0 - Fixes profile killing launcher listing ability

Use properties without quotes
Update nullguard to use Nullish coalescing
This commit is contained in:
Dev 2023-10-19 11:37:07 +01:00
parent 14c0b73482
commit 2507837198

View File

@ -80,33 +80,33 @@ export class ProfileController
const pmc = profile.characters.pmc; const pmc = profile.characters.pmc;
// make sure character completed creation // make sure character completed creation
if (!(("Info" in pmc) && ("Level" in pmc.Info))) if (!((pmc?.Info?.Level)))
{ {
return { return {
"username": profile.info.username, username: profile.info.username,
"nickname": "unknown", nickname: "unknown",
"side": "unknown", side: "unknown",
"currlvl": 0, currlvl: 0,
"currexp": 0, currexp: 0,
"prevexp": 0, prevexp: 0,
"nextlvl": 0, nextlvl: 0,
"maxlvl": maxlvl, maxlvl: maxlvl,
"akiData": this.profileHelper.getDefaultAkiDataObject() akiData: this.profileHelper.getDefaultAkiDataObject()
}; };
} }
const currlvl = pmc.Info.Level; const currlvl = pmc.Info.Level;
const nextlvl = this.profileHelper.getExperience(currlvl + 1); const nextlvl = this.profileHelper.getExperience(currlvl + 1);
const result = { const result = {
"username": profile.info.username, username: profile.info.username,
"nickname": pmc.Info.Nickname, nickname: pmc.Info.Nickname,
"side": pmc.Info.Side, side: pmc.Info.Side,
"currlvl": pmc.Info.Level, currlvl: pmc.Info.Level,
"currexp": pmc.Info.Experience, currexp: pmc.Info.Experience ?? 0,
"prevexp": (currlvl === 0) ? 0 : this.profileHelper.getExperience(currlvl), prevexp: (currlvl === 0) ? 0 : this.profileHelper.getExperience(currlvl),
"nextlvl": nextlvl, nextlvl: nextlvl,
"maxlvl": maxlvl, maxlvl: maxlvl,
"akiData": profile.aki akiData: profile.aki
}; };
return result; return result;