Skip to content
Snippets Groups Projects
Commit dabed0cd authored by Latapostrophe's avatar Latapostrophe
Browse files

Attempt to fix replay loading crash

parent 428dc42e
No related branches found
No related tags found
No related merge requests found
File added
......@@ -1247,7 +1247,7 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
return 0;
}
static UINT8 UnArchiveValueDemo(int TABLESINDEX)
static UINT8 UnArchiveValueDemo(int TABLESINDEX, char field[1024])
{
UINT8 type = READUINT8(demo_p);
switch (type)
......@@ -1299,7 +1299,12 @@ static UINT8 UnArchiveValueDemo(int TABLESINDEX)
LUA_PushUserdata(gL, &states[READUINT16(demo_p)], META_STATE);
break;
case ARCH_MOBJ:
LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(demo_p)), META_MOBJ);
demo_p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game.
if (field)
CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field);
else
CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n");
break;
case ARCH_PLAYER:
LUA_PushUserdata(gL, &players[READUINT8(demo_p)], META_PLAYER);
......@@ -1383,7 +1388,7 @@ static void UnArchiveExtVarsDemo(void *pointer)
{
READSTRING(demo_p, field);
CONS_Printf("%s\n", field);
UnArchiveValueDemo(TABLESINDEX);
UnArchiveValueDemo(TABLESINDEX, field);
lua_setfield(gL, -2, field);
}
......@@ -1452,9 +1457,9 @@ static void UnArchiveTablesDemo(void)
lua_rawgeti(gL, TABLESINDEX, i);
while (true)
{
if (UnArchiveValueDemo(TABLESINDEX) == 1) // read key
if (UnArchiveValueDemo(TABLESINDEX, NULL) == 1) // read key
break;
if (UnArchiveValueDemo(TABLESINDEX) == 2) // read value
if (UnArchiveValueDemo(TABLESINDEX, NULL) == 2) // read value
n++;
if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment