When restoring Coop players and make turn them into ghosts perform a check if this player is actually a valid player so we do not just blindly use any object number from a possibly uninitialized player structure

This commit is contained in:
zicodxx 2011-09-23 19:48:45 +02:00
parent 8f483e690b
commit 7a4d7e3bc4
2 changed files with 10 additions and 4 deletions

View file

@ -1,5 +1,9 @@
D1X-Rebirth Changelog
20110923
--------
main/state.c: When restoring Coop players and make turn them into ghosts perform a check if this player is actually a valid player so we do not just blindly use any object number from a possibly uninitialized player structure
20110921
--------
main/net_udp.c: Streamlined joining, rejoining, disconnecting players and timeouts, getting rid of unwanted rejoin messages and let host remove a player for good without rejoining it via pdata packet to really get rid of lossy or unwanted players; Care for rollover of pkt_num of stored mdata packets

View file

@ -1032,7 +1032,7 @@ int state_save_all_sub(char *filename, char *desc)
// Save Coop Info
if (Game_mode & GM_MULTI_COOP)
{
for (i = 0; i < MAX_PLAYERS; i++)
for (i = 0; i < MAX_PLAYERS; i++) // I know, I know we only allow 4 players in coop. I screwed that up. But if we ever allow 8 players in coop, who's gonna laugh then?
{
player_rw *pl_rw;
MALLOC(pl_rw, player_rw, 1);
@ -1402,9 +1402,11 @@ RetryObjectLoading:
// make all (previous) player objects to ghosts
obj = &Objects[restore_players[i].objnum];
obj->type = OBJ_GHOST;
multi_reset_player_object(obj);
if (restore_players[i].connected == CONNECT_PLAYING && obj->type == OBJ_PLAYER)
{
obj->type = OBJ_GHOST;
multi_reset_player_object(obj);
}
}
for (i = 0; i < MAX_PLAYERS; i++) // copy restored players to the current slots
{