diff --git a/src/p_setup.c b/src/p_setup.c index 1090ca0a9..662f0b5d9 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2901,6 +2901,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) //Patch_FreeTag(PU_PATCH_ROTATED); // we keep those ty! Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); + Y_VoteClear(); + #if defined (WALLSPLATS) || defined (FLOORSPLATS) // clear the splats from previous level R_ClearLevelSplats(); diff --git a/src/y_inter.c b/src/y_inter.c index 6257a6818..7eee526f4 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1576,6 +1576,22 @@ void Y_EndVote(void) voteendtic = -1; } +// +// Y_VoteClear +// Resets patches to prevent dangling pointers +// +void Y_VoteClear(void) +{ + VoteScreen.bgpatch = NULL; + VoteScreen.widebgpatch = NULL; + + for (size_t i = 0; i < sizeof(VoteScreen.cursor)/sizeof(VoteScreen.cursor[0]); ++i) + VoteScreen.cursor[i] = NULL; + + VoteScreen.randomlvl = NULL; + VoteScreen.rubyicon = NULL; +} + // // Y_SetupVoteFinish // diff --git a/src/y_inter.h b/src/y_inter.h index 31dc96694..401461db7 100644 --- a/src/y_inter.h +++ b/src/y_inter.h @@ -22,6 +22,7 @@ void Y_StartVote(void); void Y_EndVote(void); void Y_SetupVoteFinish(SINT8 pick, SINT8 level); void Y_VoteScreenCheck(void); +void Y_VoteClear(void); typedef struct {