From 69a4906911aa206ac0dffc10a5b5536e692edbb7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:38:09 -0400 Subject: [PATCH] Colormap netsync: Count ffloors for colormap loading upper limit --- src/p_saveg.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/p_saveg.c b/src/p_saveg.c index c0f98d88b..b8af7cff6 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -480,6 +480,7 @@ static void P_NetUnArchivePlayers(void) static extracolormap_t *net_colormaps = NULL; static UINT32 num_net_colormaps = 0; +static UINT32 num_ffloors = 0; // for loading // Copypasta from r_data.c AddColormapToList // But also check for equality and return the matching index @@ -536,7 +537,9 @@ static extracolormap_t *GetNetColormapFromList(UINT32 index) // LET'S HOPE that index is a sane value, because we create up to [index] // entries in net_colormaps. At this point, we don't know // what the total colormap count is - if (index >= numsectors*3) // if every sector had a unique colormap change AND a fade thinker which has two colormap entries + if (index >= numsectors*3 + num_ffloors) + // if every sector had a unique colormap change AND a fade color thinker which has two colormap entries + // AND every ffloor had a fade FOF thinker with one colormap entry I_Error("Colormap %d from server is too high for sectors %d", index, (UINT32)numsectors); // our index doesn't exist, so just make the entry @@ -564,6 +567,7 @@ static void ClearNetColormaps(void) Z_Free(exc); } num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -597,6 +601,7 @@ static void P_NetArchiveColormaps(void) } num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -698,6 +703,7 @@ static void P_NetUnArchiveColormaps(void) // Don't need these anymore num_net_colormaps = 0; + num_ffloors = 0; net_colormaps = NULL; } @@ -1031,6 +1037,14 @@ static void P_NetUnArchiveWorld(void) // initialize colormap vars because paranoia ClearNetColormaps(); + // count the level's ffloors so that colormap loading can have an upper limit + for (i = 0; i < numsectors; i++) + { + ffloor_t *rover; + for (rover = sectors[i].ffloors; rover; rover = rover->next) + num_ffloors++; + } + get = save_p; for (;;)