Avoid uninitialized reads when saving game
player_info::cloak_time is only defined if the player is cloaked. player_info::invulnerable_time is only defined if the player is invulnerable. In both cases, the game save code tried to read the ::*_time variable even when it was undefined. Modify the saving code to check player flags before reading the associated timer.
This commit is contained in:
parent
fe50c0a20a
commit
a7ec4ccd63
|
@ -493,11 +493,11 @@ static void state_player_to_player_rw(const fix pl_shields, const player *pl, pl
|
|||
pl_rw->score = pl_info.mission.score;
|
||||
pl_rw->time_level = pl->time_level;
|
||||
pl_rw->time_total = pl->time_total;
|
||||
if (pl_info.cloak_time - GameTime64 < F1_0*(-18000))
|
||||
if (!(pl_info.powerup_flags & PLAYER_FLAGS_CLOAKED) || pl_info.cloak_time - GameTime64 < F1_0*(-18000))
|
||||
pl_rw->cloak_time = F1_0*(-18000);
|
||||
else
|
||||
pl_rw->cloak_time = pl_info.cloak_time - GameTime64;
|
||||
if (pl_info.invulnerable_time - GameTime64 < F1_0*(-18000))
|
||||
if (!(pl_info.powerup_flags & PLAYER_FLAGS_INVULNERABLE) || pl_info.invulnerable_time - GameTime64 < F1_0*(-18000))
|
||||
pl_rw->invulnerable_time = F1_0*(-18000);
|
||||
else
|
||||
pl_rw->invulnerable_time = pl_info.invulnerable_time - GameTime64;
|
||||
|
|
Loading…
Reference in a new issue