mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Fix archiving with tables that contain tables as keys
This commit is contained in:
parent
911b462212
commit
cb26e55260
1 changed files with 10 additions and 2 deletions
|
@ -1443,8 +1443,11 @@ static void ArchiveTables(void)
|
||||||
{
|
{
|
||||||
// Write key
|
// Write key
|
||||||
e = ArchiveValue(TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
|
e = ArchiveValue(TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
|
||||||
if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
|
if (e == 1)
|
||||||
|
n++; // the table contained a new table we'll have to archive. :(
|
||||||
|
else if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
|
||||||
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
|
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
|
||||||
|
|
||||||
// Write value
|
// Write value
|
||||||
e = ArchiveValue(TABLESINDEX, -1);
|
e = ArchiveValue(TABLESINDEX, -1);
|
||||||
if (e == 1)
|
if (e == 1)
|
||||||
|
@ -1659,10 +1662,15 @@ static void UnArchiveTables(void)
|
||||||
lua_rawgeti(gL, TABLESINDEX, i);
|
lua_rawgeti(gL, TABLESINDEX, i);
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (UnArchiveValue(TABLESINDEX) == 1) // read key
|
UINT8 e = UnArchiveValue(TABLESINDEX); // read key
|
||||||
|
if (e == 1) // End of table
|
||||||
break;
|
break;
|
||||||
|
else if (e == 2) // Key contains a new table
|
||||||
|
n++;
|
||||||
|
|
||||||
if (UnArchiveValue(TABLESINDEX) == 2) // read value
|
if (UnArchiveValue(TABLESINDEX) == 2) // read value
|
||||||
n++;
|
n++;
|
||||||
|
|
||||||
if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
|
if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i);
|
CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i);
|
||||||
|
|
Loading…
Reference in a new issue