From 4643ac4b683fff89164f7a1cfa0cd1a15797fb28 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Tue, 24 Feb 2009 20:33:57 -0700 Subject: Fix handling of next and close packets If we aren't talking with the NPC that they originate from, just send off the next dialog packet, as empty dialogs don't help. This prevents problems with ivisible NPCs that just send close (which was ignored by older clients anyways). --- src/net/npchandler.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/net/npchandler.cpp b/src/net/npchandler.cpp index a6dc216b..5ae2ac2e 100644 --- a/src/net/npchandler.cpp +++ b/src/net/npchandler.cpp @@ -54,6 +54,7 @@ NPCHandler::NPCHandler() void NPCHandler::handleMessage(MessageIn *msg) { int id; + NPC *temporaryNPC; switch (msg->getId()) { @@ -78,15 +79,24 @@ void NPCHandler::handleMessage(MessageIn *msg) case SMSG_NPC_CLOSE: id = msg->readInt32(); - current_npc = dynamic_cast(beingManager->findBeing(id)); - npcTextDialog->showCloseButton(); + temporaryNPC = dynamic_cast(beingManager->findBeing(id)); + // If we're talking to that NPC, show the close button + if (temporaryNPC == current_npc) + npcTextDialog->showCloseButton(); + // Otherwise, move on as an empty dialog doesn't help + else + temporaryNPC->nextDialog(); break; case SMSG_NPC_NEXT: - // Next button in NPC dialog, currently unused id = msg->readInt32(); - current_npc = dynamic_cast(beingManager->findBeing(id)); - npcTextDialog->showNextButton(); + temporaryNPC = dynamic_cast(beingManager->findBeing(id)); + // If we're talking to that NPC, show the next button + if (temporaryNPC == current_npc) + npcTextDialog->showNextButton(); + else + // Otherwise, move on as an empty dialog doesn't help + temporaryNPC->nextDialog(); break; case SMSG_NPC_INT_INPUT: -- cgit v1.2.3-70-g09d2