Do not consider system gamearrays for updating from demos.

This generally fixes demo playback. Before, tilesizx[]/tilesizy[] were written
into twice as many bytes as needed. Now, don't do that at all.

git-svn-id: https://svn.eduke32.com/eduke32@4191 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-12-06 18:56:39 +00:00
parent 9a397a01c1
commit a5f0610b38
3 changed files with 15 additions and 3 deletions

View file

@ -62,7 +62,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# define BYTEVERSION_JF 288
#else
// Non-Lua build
# define BYTEVERSION_JF 288
# define BYTEVERSION_JF 291
#endif
#define BYTEVERSION_13 27

View file

@ -1447,6 +1447,7 @@ static void Gv_AddSystemVars(void)
Gv_NewVar("rendmode", 0, GAMEVAR_READONLY | GAMEVAR_SYSTEM);
# endif
// SYSTEM_GAMEARRAY
Gv_NewArray("tilesizx", (void *)tilesizx, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
Gv_NewArray("tilesizy", (void *)tilesizy, MAXTILES, GAMEARRAY_READONLY|GAMEARRAY_OFSHORT);
#endif

View file

@ -1076,13 +1076,16 @@ static uint8_t *svdiff;
static void sv_makevarspec()
{
static char *magic = "blK:vars";
int32_t i, j, numsavedvars=0, per;
int32_t i, j, numsavedvars=0, numsavedarrays=0, per;
for (i=0; i<g_gameVarCount; i++)
numsavedvars += (aGameVars[i].dwFlags&SV_SKIPMASK) ? 0 : 1;
for (i=0; i<g_gameArrayCount; i++)
numsavedarrays += !(aGameArrays[i].dwFlags & GAMEARRAY_READONLY); // SYSTEM_GAMEARRAY
Bfree(svgm_vars);
svgm_vars = (dataspec_t *)Bmalloc((numsavedvars+g_gameArrayCount+2)*sizeof(dataspec_t));
svgm_vars = (dataspec_t *)Bmalloc((numsavedvars+numsavedarrays+2)*sizeof(dataspec_t));
if (svgm_vars == NULL)
G_GameExit("OUT OF MEMORY in sv_makevarspec()\n");
@ -1108,6 +1111,12 @@ static void sv_makevarspec()
for (i=0; i<g_gameArrayCount; i++)
{
// We must not update read-only SYSTEM_GAMEARRAY gamearrays: besides
// being questionable by itself, sizeof(...) may be e.g. 4 whereas the
// actual element type is int16_t (such as tilesizx[]/tilesizy[]).
if (aGameArrays[i].dwFlags & GAMEARRAY_READONLY)
continue;
svgm_vars[j].flags = 0;
svgm_vars[j].ptr = aGameArrays[i].plValues;
svgm_vars[j].size = sizeof(aGameArrays[0].plValues[0]);
@ -1116,6 +1125,8 @@ static void sv_makevarspec()
}
svgm_vars[j].flags = DS_END;
svgm_vars[j].ptr = NULL;
svgm_vars[j].size = svgm_vars[j].cnt = 0;
}
#endif