From d417f733e5b00c54233c36d8b61b69f14d5ba996 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:24:55 -0400 Subject: [PATCH 1/2] Colormap netsync: Handle unaccounted dummy colormaps properly --- src/p_saveg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index b98a34436..c0f98d88b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -682,6 +682,20 @@ static void P_NetUnArchiveColormaps(void) exc_next = R_CreateDefaultColormap(false); } + // if we still have a valid net_colormap after iterating up to num_net_colormaps, + // some sector had a colormap index higher than num_net_colormaps. We done goofed or $$$ was corrupted. + // In any case, add them to the colormap list too so that at least the sectors' colormap + // addresses are valid and accounted properly + if (exc_next) + { + existing_exc = R_GetDefaultColormap(); + for (exc = exc_next; exc; exc = exc->next) + { + exc->colormap = existing_exc->colormap; // all our dummies are default values + R_AddColormapToList(exc); + } + } + // Don't need these anymore num_net_colormaps = 0; net_colormaps = NULL; From 69a4906911aa206ac0dffc10a5b5536e692edbb7 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Mon, 17 Sep 2018 10:38:09 -0400 Subject: [PATCH 2/2] 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 (;;)