pret/pokeheartgold

Decide on usage of comma operator + alignment of bitfields.

Closed this issue ยท 4 comments

e.g. (from pokeplatinum)

typedef struct SideConditions {
    u32 reflectBattlerId        :2,
        reflectTurns            :3,
        lightScreenBattlerId    :2,
        lightScreenTurns        :3,
        mistBattlerId           :2,
        mistTurns               :3,
        safeguardBattlerId      :2,
        safeguardTurns          :3,
        followMeActive          :1,
        followMeBattlerId       :2,
        knockedOffItemBattlers  :6,
        padding00_1D            :3;

    u32 spikesLayers        :2,
        toxicSpikesLayers   :2,
        padding04_04        :28;
} SideConditions;

vs.

typedef struct SideConditions {
    u32 reflectBattlerId:2;
    u32 reflectTurns:3;
    u32 lightScreenBattlerId:2;
    u32 lightScreenTurns:3;
    u32 mistBattlerId:2;
    u32 mistTurns:3;
    u32 safeguardBattlerId:2;
    u32 safeguardTurns:3;
    u32 followMeActive:1;
    u32 followMeBattlerId:2;
    u32 knockedOffItemBattlers:6;
    u32 padding00_1D:3;

    u32 spikesLayers:2;
    u32 toxicSpikesLayers:2;
    u32 padding04_04:28;
} SideConditions;

TODO: write up a grep

Personal preference: the first has much more readable field names at-a-glance and clearly communicates how the values map in memory.

I also agree with the first, but I know @red031000 does disagree

top is quite ugly imo, bottom is better

Bottom except spaces around the :