Skip to content

Commit

Permalink
Merge pull request #397 from runejs/kat/dialogue-fix
Browse files Browse the repository at this point in the history
Fixing a bug causing dialogue to crash and fail
  • Loading branch information
Promises authored Jun 29, 2023
2 parents 39978a0 + 8305229 commit 0196052
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
4 changes: 0 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 8 additions & 9 deletions src/engine/world/actor/dialogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,14 @@ function parseDialogueTree(player: Player, npcParticipants: NpcParticipant[], di
}

dialogueDetails = dialogueAction(npc);

if (npc === -1) {
throw new Error('No npc found for dialogue action.');
}
} else {
dialogueDetails = dialogueAction(player);
}

// TODO (Jameskmonger) not sure if this check is needed, added it when getting TypeScript types into strict mode
if (npc === -1) {
throw new Error('No npc found for dialogue action.');
}

const emote = dialogueDetails[0] as Emote;
const text = carryoverDialogue.join(' ') + dialogueDetails[1] as string;
carryoverDialogue = [];
Expand Down Expand Up @@ -582,10 +581,10 @@ async function runDialogueAction(player: Player, dialogueAction: string | Dialog

if (dialogueAction.type === 'NPC') {
npcId = (dialogueAction as NpcDialogueAction).npcId;
}
// TODO (Jameskmonger) not sure if this check is needed, added it when getting TypeScript types into strict mode
if (npcId === -1) {
throw new Error('No npc found for dialogue action.');

if (npcId === -1) {
throw new Error('No npc found for dialogue action.');
}
}

const actorDialogueAction = dialogueAction as ActorDialogueAction;
Expand Down

0 comments on commit 0196052

Please sign in to comment.