Skip to content

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

@Vince0789

Description

@Vince0789

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions