Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAX_ definitions (or lack thereof) break progressive initializer for arrays #47

Open
Vince0789 opened this issue Jul 27, 2024 · 0 comments

Comments

@Vince0789
Copy link
Contributor

Consider following snippet:

static bool:gIsWeaponAllowed[MAX_WEAPONS] = {true, ...};

public OnGameModeInit()
{
    for (new i = 0; i < sizeof gIsWeaponAllowed; i++)
    {
        printf("%d: %d", i, gIsWeaponAllowed[WEAPON:i]);
    }
    return 1;
}

One would expect that all slots would be initialized to true, but only the first slot gets set.

[2024-07-27T18:24:52Z] [Info] 0: 1
[2024-07-27T18:24:52Z] [Info] 1: 0
[2024-07-27T18:24:52Z] [Info] 2: 0
...
[2024-07-27T18:24:52Z] [Info] 45: 0
[2024-07-27T18:24:52Z] [Info] 46: 0

Adding an additional

#define MAX_WEAPONS (WEAPON:47)

seems to remedy this problem and still allows the array to be indexed properly with the WEAPON_ definitions. This will probably need to be added for all tagged MAX_ definitions.

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

No branches or pull requests

1 participant