jgabaut / helapordo

A roguelike terminal game, using ncurses.
https://jgabaut.github.io/helapordo-docs
GNU General Public License v3.0
14 stars 0 forks source link

[BUG] Specials menu displays the wrong selected move #81

Closed gioninjo closed 5 months ago

gioninjo commented 6 months ago

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

gioninjo commented 6 months ago

bug example here

jgabaut commented 6 months ago

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.

https://github.com/jgabaut/helapordo/blob/e85dfa46959134321d126e984fd4a608c9d40e02/src/build-nc/game_curses.c#L3488

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:

https://github.com/jgabaut/helapordo/blob/e85dfa46959134321d126e984fd4a608c9d40e02/src/build-nc/game_curses.c#L2093

Which should probably be investigated.

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

jgabaut commented 5 months ago

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. :)