In handmade.cpp
| internal uint32
AddEntity(game_state *GameState)
{
uint32 EntityIndex = GameState->EntityCount++;
Assert(GameState->EntityCount < ArrayCount(GameState->Entities));
entity *Entity = &GameState->Entities[EntityIndex];
*Entity = {};
return(EntityIndex);
}
|
If I'm not mistaken, every time we add a new entity we are supposed to zero the struct values to zero, with:
But in my case it is not really working: if I break after that line, the Entity structure pointed has still values != 0, which cause an additional fake player to be drawn.
This happen in my own version of the code, so I might have missed something, but my question is: is using the empty braces supposed to work, in order to zero a struct after declaration?
I have found examples where it is used in the same line where we declare the struct, but none where it is used afterwards.
If I use a memset to zero, instead of the braces, it works.