Is "uint32 bValue : 1;" in header file used to specify the number of replicated bits?

I’ve seen some declarations in header files such as such these as in GameMode.h:


UPROPERTY()
uint32 bUseSeamlessTravel : 1;

UPROPERTY()
uint32 bPauseable : 1;

UPROPERTY()
uint32 bStartPlayersAsSpectators : 1;

Notice the : 1. I noticed that the : 1 is only used for boolean values so I think its related to the number of relevant bits. Does anyone know if this is used to optimize replication? Is there documentation on this? Thanks. :slight_smile:

+1. Saw this same thing in ShooterGame Player Start.

/** Which team can start at this point */
UPROPERTY(EditInstanceOnly, Category=Team)
int32 SpawnTeam;

/** Whether players can start at this point */
UPROPERTY(EditInstanceOnly, Category=Team)
uint32 bNotForPlayers:1;

/** Whether bots can start at this point */
UPROPERTY(EditInstanceOnly, Category=Team)
uint32 bNotForBots:1;

That represent bitfield storage. It’s a memory optimisation basically specifying to use just one bit to represent the underlying value. Make no mistake, it doesn’t mean that just 1 bit of memory will be occupied, rather the data will be shared. In your case you have 3 uint32 so it would be 12 bytes. But since they use bitfields only 4 bytes will be allocated and 3 bits used. check this tutorial for further info C - Bit Fields

Cool! I didn’t know it was such a core feature to C. Thanks for the link. :slight_smile: