Skip to content

Commit

Permalink
fix: showing null loc names in viewport options
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraviolet-jordan committed Jan 29, 2024
1 parent 5bccfb7 commit a781072
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 56 deletions.
93 changes: 48 additions & 45 deletions src/js/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6685,59 +6685,62 @@ class Client extends GameShell {

if (entityType === 2 && this.scene && this.scene.getInfo(this.currentLevel, x, z, bitset) >= 0) {
const loc: LocType = LocType.get(typeId);
if (this.objSelected === 1) {
this.menuOption[this.menuSize] = 'Use ' + this.objSelectedName + ' with @cya@' + loc.name;
this.menuAction[this.menuSize] = 450;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
} else if (this.spellSelected !== 1) {
if (loc.ops) {
for (let op: number = 4; op >= 0; op--) {
if (loc.ops[op]) {
this.menuOption[this.menuSize] = loc.ops[op] + ' @cya@' + loc.name;
if (op === 0) {
this.menuAction[this.menuSize] = 285;
}
// loc.name check is custom but think we need it
if (loc.name) {
if (this.objSelected === 1) {
this.menuOption[this.menuSize] = 'Use ' + this.objSelectedName + ' with @cya@' + loc.name;
this.menuAction[this.menuSize] = 450;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
} else if (this.spellSelected !== 1) {
if (loc.ops) {
for (let op: number = 4; op >= 0; op--) {
if (loc.ops[op]) {
this.menuOption[this.menuSize] = loc.ops[op] + ' @cya@' + loc.name;
if (op === 0) {
this.menuAction[this.menuSize] = 285;
}

if (op === 1) {
this.menuAction[this.menuSize] = 504;
}
if (op === 1) {
this.menuAction[this.menuSize] = 504;
}

if (op === 2) {
this.menuAction[this.menuSize] = 364;
}
if (op === 2) {
this.menuAction[this.menuSize] = 364;
}

if (op === 3) {
this.menuAction[this.menuSize] = 581;
}
if (op === 3) {
this.menuAction[this.menuSize] = 581;
}

if (op === 4) {
this.menuAction[this.menuSize] = 1501;
}
if (op === 4) {
this.menuAction[this.menuSize] = 1501;
}

this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
}
}
}
}

this.menuOption[this.menuSize] = 'Examine @cya@' + loc.name;
this.menuAction[this.menuSize] = 1175;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
} else if ((this.activeSpellFlags & 0x4) === 4) {
this.menuOption[this.menuSize] = this.spellCaption + ' @cya@' + loc.name;
this.menuAction[this.menuSize] = 55;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
this.menuOption[this.menuSize] = 'Examine @cya@' + loc.name;
this.menuAction[this.menuSize] = 1175;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
} else if ((this.activeSpellFlags & 0x4) === 4) {
this.menuOption[this.menuSize] = this.spellCaption + ' @cya@' + loc.name;
this.menuAction[this.menuSize] = 55;
this.menuParamA[this.menuSize] = bitset;
this.menuParamB[this.menuSize] = x;
this.menuParamC[this.menuSize] = z;
this.menuSize++;
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/js/jagex2/config/LocType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class LocType extends ConfigType {
walloff: number = 16;
ambient: number = 0;
contrast: number = 0;
ops: (string | null)[] = [];
ops: (string | null)[] | null = null;
mapfunction: number = -1;
mapscene: number = -1;
mirror: boolean = false;
Expand Down Expand Up @@ -159,9 +159,12 @@ export default class LocType extends ConfigType {
} else if (code === 39) {
this.contrast = dat.g1b;
} else if (code >= 30 && code < 35) {
this.ops[code - 30] = dat.gjstr;
if (!this.ops) {
this.ops = new Array(5).fill(null);
}

if (this.ops[code - 30] === 'hidden') {
this.ops[code - 30] = dat.gjstr;
if (this.ops[code - 30]?.toLowerCase() === 'hidden') {
this.ops[code - 30] = null;
}
} else if (code === 40) {
Expand Down
9 changes: 6 additions & 3 deletions src/js/jagex2/config/NpcType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default class NpcType extends ConfigType {
hasalpha: boolean = false;
recol_s: Uint16Array | null = null;
recol_d: Uint16Array | null = null;
ops: (string | null)[] = [];
ops: (string | null)[] | null = null;
code90: number = -1;
code91: number = -1;
code92: number = -1;
Expand Down Expand Up @@ -109,9 +109,12 @@ export default class NpcType extends ConfigType {
this.walkanim_r = dat.g2;
this.walkanim_l = dat.g2;
} else if (code >= 30 && code < 40) {
this.ops[code - 30] = dat.gjstr;
if (!this.ops) {
this.ops = new Array(5).fill(null);
}

if (this.ops[code - 30] === 'hidden') {
this.ops[code - 30] = dat.gjstr;
if (this.ops[code - 30]?.toLowerCase() === 'hidden') {
this.ops[code - 30] = null;
}
} else if (code === 40) {
Expand Down
10 changes: 5 additions & 5 deletions src/js/jagex2/config/ObjType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default class ObjType extends ConfigType {
if (!this.membersWorld && obj.members) {
obj.name = 'Members Object';
obj.desc = "Login to a members' server to use this object.";
obj.ops = [];
obj.iops = [];
obj.ops = null;
obj.iops = null;
}

return obj;
Expand Down Expand Up @@ -205,7 +205,7 @@ export default class ObjType extends ConfigType {
cost: number = 1;
members: boolean = false;
ops: (string | null)[] | null = null;
iops: string[] | null = null;
iops: (string | null)[] | null = null;
manwear: number = -1;
manwear2: number = -1;
manwearOffsetY: number = 0;
Expand Down Expand Up @@ -268,11 +268,11 @@ export default class ObjType extends ConfigType {
this.womanwear2 = dat.g2;
} else if (code >= 30 && code < 35) {
if (!this.ops) {
this.ops = new Array(5);
this.ops = new Array(5).fill(null);
}

this.ops[code - 30] = dat.gjstr;
if (this.ops[code - 30] === 'hidden') {
if (this.ops[code - 30]?.toLowerCase() === 'hidden') {
this.ops[code - 30] = null;
}
} else if (code >= 35 && code < 40) {
Expand Down

0 comments on commit a781072

Please sign in to comment.