savegame fixes (#1376)

* restore function pointer reading

There seems to be a check for NULL somewhere.

* remove saveg_compat checks in write function, formatting
This commit is contained in:
Roman Fomin 2024-01-06 17:40:03 +07:00 committed by GitHub
parent dd4e2b55b6
commit 63e625e295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -264,8 +264,7 @@ static void saveg_read_thinker_t(thinker_t *str)
str->next = saveg_readp(); str->next = saveg_readp();
// think_t function; // think_t function;
saveg_readp(); str->function.v = (actionf_v)saveg_readp();
str->function.v = NULL;
// struct thinker_s* cnext; // struct thinker_s* cnext;
str->cnext = saveg_readp(); str->cnext = saveg_readp();
@ -583,11 +582,8 @@ static void saveg_write_mobj_t(mobj_t *str)
// int flags; // int flags;
saveg_write32(str->flags); saveg_write32(str->flags);
if (saveg_compat > saveg_woof510)
{
// [Woof!]: mbf21: int flags2; // [Woof!]: mbf21: int flags2;
saveg_write32(str->flags2); saveg_write32(str->flags2);
}
// int intflags; // int intflags;
saveg_write32(str->intflags); saveg_write32(str->intflags);
@ -667,12 +663,9 @@ static void saveg_write_mobj_t(mobj_t *str)
// [Woof!]: int oldangle; // [Woof!]: int oldangle;
saveg_write32(str->oldangle); saveg_write32(str->oldangle);
if (saveg_compat > saveg_woof510)
{
// [Woof!]: int bloodcolor; // [Woof!]: int bloodcolor;
saveg_write32(str->bloodcolor); saveg_write32(str->bloodcolor);
} }
}
// //
// ticcmd_t // ticcmd_t
@ -767,7 +760,6 @@ static void saveg_read_pspdef_t(pspdef_t *str)
static void saveg_write_pspdef_t(pspdef_t *str) static void saveg_write_pspdef_t(pspdef_t *str)
{ {
// state_t* state;
if (str->state) if (str->state)
{ {
saveg_write32(str->state - states); saveg_write32(str->state - states);
@ -1204,7 +1196,7 @@ static void saveg_write_ceiling_t(ceiling_t *str)
static void saveg_read_vldoor_t(vldoor_t *str) static void saveg_read_vldoor_t(vldoor_t *str)
{ {
int sector; int sector, line;
// thinker_t thinker; // thinker_t thinker;
saveg_read_thinker_t(&str->thinker); saveg_read_thinker_t(&str->thinker);
@ -1232,7 +1224,16 @@ static void saveg_read_vldoor_t(vldoor_t *str)
str->topcountdown = saveg_read32(); str->topcountdown = saveg_read32();
// line_t *line; // line_t *line;
str->line = saveg_readp(); //jff 1/31/98 unarchive line remembered by door as well
line = saveg_read32();
if (line == -1)
{
str->line = NULL;
}
else
{
str->line = &lines[line];
}
// int lighttag; // int lighttag;
str->lighttag = saveg_read32(); str->lighttag = saveg_read32();
@ -1267,9 +1268,13 @@ static void saveg_write_vldoor_t(vldoor_t *str)
// line_t *line; // line_t *line;
//jff 1/31/98 archive line remembered by door as well //jff 1/31/98 archive line remembered by door as well
if (str->line) if (str->line)
{
saveg_write32(str->line - lines); saveg_write32(str->line - lines);
}
else else
{
saveg_write32(-1); saveg_write32(-1);
}
// int lighttag; // int lighttag;
saveg_write32(str->lighttag); saveg_write32(str->lighttag);
@ -2593,10 +2598,6 @@ void P_UnArchiveSpecials (void)
{ {
vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL); vldoor_t *door = Z_Malloc (sizeof(*door), PU_LEVEL, NULL);
saveg_read_vldoor_t(door); saveg_read_vldoor_t(door);
//jff 1/31/98 unarchive line remembered by door as well
door->line = (intptr_t)door->line!=-1? &lines[(size_t)door->line] : NULL;
door->sector->ceilingdata = door; //jff 2/22/98 door->sector->ceilingdata = door; //jff 2/22/98
door->thinker.function.p1 = (actionf_p1)T_VerticalDoor; door->thinker.function.p1 = (actionf_p1)T_VerticalDoor;
P_AddThinker (&door->thinker); P_AddThinker (&door->thinker);