(EXE Modding) Making an "extern INT32" thing be considered integers when compiling?

Status
Not open for further replies.
(EXE Modding) Making an "extern INT32" thing be considered integers when compiling?

I'm working on an EXE modification, where I want to check a struct thingie through the "case" of a "switch (variable)".
However, when I try to compile it, even though it can only ever contain integer numbers in-game, the compiler complains about it, saying "case label does not be reduce to an integer amount".
Is there any way to get around this correctly? See the spoiler for code snippets.

g_input.h:
Code:
-

typedef enum
{
    mc_null = 0, // A key/button mapped to mc_null has no effect
    mc_up,
    mc_down,
    mc_right,
    mc_left,
    mc_confirm,
    mc_cancel,
    mc_clear,
    mc_openmenu,
    num_menucontrols
} menucontrols_e;

-

extern INT32 gamecontrolmenu[num_menucontrols][2]; // Menu navigation

-
g_input.c:
Code:
-

INT32 gamecontrolmenu[num_menucontrols][2]; // Menu navigation

-
m_menu.c:
Code:
-

    else if (ev->type == ev_keydown)
    {
        ch = ev->data1;

        // R.I.P. "remap virtual keys" for joysticks 5/2/1998 - Some day in September/2016
        // But hey, we got user-customizable controls instead, which supports joysticks too!
        switch (ch)
        {
            case KEY_LSHIFT:
            case KEY_RSHIFT:
                shiftdown = true;
                break; //return false;
            case gamecontrolmenu[mc_confirm][0]:
            case gamecontrolmenu[mc_confirm][1]:
                ch = KEY_ENTER;
                break;

            // Escape and Backspace must be done on a case-by-case basis, so they're not here

            case gamecontrolmenu[mc_up][0]:
            case gamecontrolmenu[mc_up][1]:
                ch = KEY_UPARROW;
                break;
            case gamecontrolmenu[mc_down][0]:
            case gamecontrolmenu[mc_down][1]:
                ch = KEY_DOWNARROW;
                break;
            case gamecontrolmenu[mc_left][0]:
            case gamecontrolmenu[mc_left][1]:
                ch = KEY_LEFTARROW;
                break;
            case gamecontrolmenu[mc_right][0]:
            case gamecontrolmenu[mc_right][1]:
                ch = KEY_RIGHTARROW;
                break;
        }
    }

-
The compiling errors point at the start of the "gamecontrolmenu[mc_thing][X]" things in m_menu.c. I have tried laying them out as "(gamecontrolmenu[mc_thing][X])" too, which didn't fix it.
Edit: If you saw the previous edit, sorry, false alarm, not fixed.
 
Last edited:
I don't think you can use your gamecontrolmenu array as a switch case thing like that. You may be better off using if statements for them like "if (ch == gamecontrolmenu[mc_confirm][0] || ch == gamecontrolmenu[mc_confirm][1])", then "else if (ch == gamecontrolmenu[mc_down][0] || ch == gamecontrolmenu[mc_down][1])" etc and do the switch case thing otherwise?
 
It may be tough to pull off if I understand you correctly (there are 15 occurences of this stuff in m_menu.c besides the snippet shown), but not too tough. Alright, I'll try that when I get around to working more on it. Thank you, though. (But it'd still be nice with a potential way to use the switch case thing (without adding many or few extra temporary variables and such).)
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top