Skip to content

Fix "Double continuation" warning when using an item during NPC interaction - #3496

Open
Streusel wants to merge 1 commit into
HerculesWS:masterfrom
Streusel:fix/item-npc-double-continuation-3471
Open

Streusel wants to merge 1 commit into
HerculesWS:masterfrom
Streusel:fix/item-npc-double-continuation-3471

Conversation

@Streusel

Copy link
Copy Markdown
Member

Pull Request Prelude

Changes Proposed

With item_enabled_npc set to allow item usage during NPC interaction, using an item that opens a dialog of its own while an NPC conversation is already open printed a Double continuation warning and silently discarded the conversation the player was in:

[Warning]: Unable to restore stack! Double continuation!
[Debug]: Previous script (lost):
[Debug]: Source (NPC): Bulletin Board#09 at prontera (148,49)
[Debug]: Current script:
[Debug]: Source (NPC): FAKE_NPC (invisible/not on a map)

pc_useitem() ran the item script while the player was still attached to the NPC's script. script_attach_state() therefore backed the NPC's state up into the item script's bk_st. When the item script then paused to show its own dialog, run_script_main() reached the st->state != END && st->rid != 0 branch, found st->bk_st set, emitted the warning and called script_free_state() on the backup. That freed state was the NPC conversation.

The player is now detached from the running script before the item script executes, and reattached to it once the item script is done, so no backup chain is ever created. Whatever state the item script leaves pending is discarded, because it may not take over a conversation that is already in progress. When no NPC script is attached, which is the ordinary case, the added code is inert.

The fix is a port of the equivalent rAthena change for the same bug. The upstream commit is reproduced in full in the commit message, as done previously for other ported changes in this repository.

Testing

Reproduction from the issue report, in pre-renewal with item_enabled_npc: 0x3:

  1. talk to an NPC that opens a dialog, such as a Bulletin Board;
  2. while the dialog is open, use an item that opens a dialog of its own, such as a Kafra Card;
  3. the warning no longer appears and the NPC dialog remains usable.

Issues addressed: #3471

@kyeme

kyeme commented Sep 18, 2026

Copy link
Copy Markdown

I tested this PR and found another issue.

While talking to an NPC with an active dialog, I tried to use a Kafra_Card. After doing so, the following debug message appears in the console:

[Debug]: npc_scriptcont: Shion#nv1 (sd->npc_id=110010076) is not FAKE_NPC (id=110010601).

After this happens, my character becomes stuck.

I also tested the same scenario on rAthena, and the same issue occurs there.

@Streusel
Streusel force-pushed the fix/item-npc-double-continuation-3471 branch from b7d5356 to daf8e99 Compare September 18, 2026 23:54
@Streusel

Copy link
Copy Markdown
Member Author

Welp, thanks for the report.
Could you retest both cases when you get a chance? An item with no window of its own, such as a Blessing Scroll, should leave the NPC dialog usable, and a Kafra Card should open its window normally without locking you up.

@kyeme

kyeme commented Sep 19, 2026

Copy link
Copy Markdown

Welp, thanks for the report. Could you retest both cases when you get a chance? An item with no window of its own, such as a Blessing Scroll, should leave the NPC dialog usable, and a Kafra Card should open its window normally without locking you up.

It's working now. The Kafra_Card can be used while an NPC dialog is active. The previous dialog is canceled, and the Kafra Storage opens correctly.

However, the Blessing Scroll cannot be used while an NPC dialog is active. I'm not sure if this is the intended behavior, since I'm unable to test it on an official Pre-Renewal server because I don't have access to one.

@Streusel

Copy link
Copy Markdown
Member Author

Great. As for the blessing scroll we'll have to wait for more info and address it when it comes to that.

@hemagx

hemagx commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@skyleo may you be able to confirm the blessing scroll?

@hemagx hemagx added this to the Release v2026.09 milestone Sep 19, 2026
@kyeme

kyeme commented Sep 19, 2026

Copy link
Copy Markdown

@Streusel
I found another bug scenario while testing this PR again.

Scenario

  1. Talk to an NPC that opens a menu.
  2. While the NPC menu is still active, use an item that also opens a menu, such as DUN_TELE_SCROLL1.
  3. The DUN_TELE_SCROLL1 menu does not appear.
  4. Instead, the character is automatically warped immediately.

It seems that using an item with its own menu while an NPC menu is already active causes the item script to continue with a menu selection automatically instead of waiting for the player to select an option.

9-20-2026.6-49-57.AM.mp4

@Streusel

Copy link
Copy Markdown
Member Author

@kyeme Do you have an example of this in official? Is the NPC menu supposed to be dismissed? What's the expected behaviour? Other than the menu obviously being accessible.

@kyeme

kyeme commented Sep 21, 2026

Copy link
Copy Markdown
dun_tele_scroll.mp4

If the NPC dialog does not have a menu shown, I can use the Dungeon Teleport Scroll normally.

The issue only happens when the NPC dialog currently has a menu/selection shown. If I use DUN_TELE_SCROLL1 while that NPC menu is open, the scroll automatically warps the character instead of showing its own menu/selection.

So it seems this case is specifically related to using an item with its own menu while an NPC menu is already active.

I'm not sure what the correct official pre-renewal behavior should be, since I don't currently have access to a pre-renewal Aegis server to verify it.

For comparison, on the official Renewal server I tested, usable items cannot be used at all while interacting with an NPC, so I can't use Renewal behavior to confirm how this should work in pre-renewal.

…action

With item_enabled_npc allowing item usage while an NPC dialog is open, using an item attached a second script to the player. The NPC's script was backed up into the item script's bk_st and then reported as a lost "Double continuation", discarding the conversation the player was in.

The player is now detached from the running script before the item script is executed, and reattached to it afterwards, so an item that does not open a window of its own leaves the conversation intact.

Detaching the script is not enough on its own, because the answer a menu() or input() is waiting for is kept in the session data rather than in the script state. An item script that opened a menu of its own found that pending answer already set and read it as its own, returning a selection the player never made for it, so a dungeon teleport scroll used while an NPC menu was open warped the player immediately instead of asking where to go. The pending answer is now saved and cleared before the item script runs, and handed back only when the previous script is reattached.

An item script that does pause to show its own window is a different case: by that point the client is already displaying that window, so the previous conversation can no longer be resumed and its script is released instead. Restoring it there would leave the client showing one dialog while the server expects another, which locks the player out of both.

Based on rathena commit:

commit 3c93e30
Author: Lemongrass3110 <lemongrass@kstp.at>
Date:   Wed Oct 29 18:36:28 2025 +0000

    Fixed an issue with item_enabled_npc (#9606)

    Fixes #8625

    Thanks to @thanna

Fixes HerculesWS#3471
@kyeme

kyeme commented Sep 21, 2026

Copy link
Copy Markdown

Tested the new PR, and it's working now. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants