jgabaut/helapordo

[BUG] Specials menu displays the wrong selected move

Closed this issue · 3 comments

When I open the special move menu in a fight and I go over a special move, the screen on the right shows me the wrong infos. It seems like if I go over the Nth element the screen on the right shows me the Nth element that is shown in the menu that pops up when you have to learn a new special move

bug
example here

Thanks for pointing this out! In the screenshot, the description is the one for the 1st Special for Knight (wrong one).

I remember finding out about this and then forgetting. Alas, the issue is gonna keep it in my mind.

Can reproduce this easily.

  1. Learn any move that is not the first
  2. The right window will always show the description of the first one

Let's see where this stems from. Will update this post with links.

Edit: found it.

updateSelectedSpecialW(my_wins[0], my_menu, f);

This bit of code is related:

/* Prepare selection display window */
    my_wins[0] = newwin(18, 40, 4, 30);
    updateSelectedSpecialW(my_wins[0], my_menu, f);

    refresh();

    int picked = 0;
    ITEM *cur;

    while (!picked && (c = wgetch(my_menu_win)) != 'q') {
        switch (c) {
        case KEY_DOWN: {
            menu_driver(my_menu, REQ_DOWN_ITEM);
            cur = current_item(my_menu);
            //Update selected window
            wclear(my_wins[0]);
            wrefresh(my_wins[0]);
            updateSelectedSpecialW(my_wins[0], my_menu, f);
        }
        break;

I think since you never get to move the cursor without more than one special unlocked, it doesn't ever update and always shows the first one it landed on from this function:

void updateSelectedSpecialW(WINDOW *w, MENU *my_menu, Fighter *f)

Which should probably be investigated.

The right window should be started from the lowest special slot you have unlocked already.

In the end, it was a single typo that was never caught before.

The fix was merged with:

@gioninjo
Thanks a lot for helping me find this!
Looking forward to any more future contributions like this one. :)