From 7a4d7e3bc440b8bc7948a994a81ff53c6cad8b9f Mon Sep 17 00:00:00 2001 From: zicodxx Date: Fri, 23 Sep 2011 19:48:45 +0200 Subject: [PATCH] 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 --- CHANGELOG.txt | 4 ++++ main/state.c | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5a1e20535..c58687cbd 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -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 diff --git a/main/state.c b/main/state.c index 9ec11ffb6..a09797de3 100644 --- a/main/state.c +++ b/main/state.c @@ -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 {