-2

I was looking through the code from a Pokemon pearl de-compilation and every item in the game was put in a struct but with the item name in brackets followed by its' properties. What is this way of using structs called ?

 [ITEM_MASTER_BALL] =
    {
        .name = _("MASTER BALL"),
        .itemId = ITEM_MASTER_BALL,
        .price = 0,
        .description = sMasterBallDesc,
        .pocket = POCKET_POKE_BALLS,
        .type = ITEM_MASTER_BALL - FIRST_BALL,
        .battleUsage = ITEM_B_USE_OTHER,
        .battleUseFunc = ItemUseInBattle_PokeBall,
        .secondaryId = ITEM_MASTER_BALL - FIRST_BALL,
    },

1 Answers1

0

Edit: As the person replying to my comment pointed out. Is is a designated initializer in the form like int a[6] = {[4] = 29, [2] = 15 }; where you cut out part of the code so we only see the equivalent of "[4] = 29,"

Your array is also a struct array rather than int.

ITEM_MASTER_BALL is probably an enum to a specific position within that array.

Thank you so much Eric for removing my confusing regarding this code snip :)

l_t_m_f
  • 11
  • 1
  • The code shown in the question is a designated initializer in a list of initializers. – Eric Postpischil Oct 05 '22 at 03:21
  • Ah yes, I see now. Makes sense but without the surrounding context I wasn't seeing it and gave some misinformation. I have adapted my reply to include your input. Thanks :) – l_t_m_f Oct 05 '22 at 21:43