- changed Polyobject thinkers to operate on the actual polyobjects instead of indices
This also changes the action special interface to pass a Level parameter to the separate functions and makes a few other minor adjustments to the polyobject code.
This commit is contained in:
parent
65750bd7bf
commit
9f8dd66189
15 changed files with 331 additions and 348 deletions
130
src/p_saveg.cpp
130
src/p_saveg.cpp
|
|
@ -248,11 +248,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, secplane_t &p, secplan
|
|||
|
||||
FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t *def)
|
||||
{
|
||||
// save the Scroll data here because it's a lot easier to handle a default.
|
||||
// Just writing out the full array can massively inflate the archive for no gain.
|
||||
DVector2 scroll = { 0,0 }, nul = { 0,0 };
|
||||
if (arc.isWriting() && level.Scrolls.Size() > 0) scroll = level.Scrolls[p.sectornum];
|
||||
|
||||
if (arc.BeginObject(key))
|
||||
{
|
||||
arc("floorplane", p.floorplane, def->floorplane)
|
||||
|
|
@ -300,23 +295,12 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t
|
|||
("gravity", p.gravity, def->gravity)
|
||||
.Terrain("floorterrain", p.terrainnum[0], &def->terrainnum[0])
|
||||
.Terrain("ceilingterrain", p.terrainnum[1], &def->terrainnum[1])
|
||||
("scrolls", scroll, nul)
|
||||
("healthfloor", p.healthfloor, def->healthfloor)
|
||||
("healthceiling", p.healthceiling, def->healthceiling)
|
||||
("health3d", p.health3d, def->health3d)
|
||||
// GZDoom exclusive:
|
||||
.Array("reflect", p.reflect, def->reflect, 2, true)
|
||||
.EndObject();
|
||||
|
||||
if (arc.isReading() && !scroll.isZero())
|
||||
{
|
||||
if (level.Scrolls.Size() == 0)
|
||||
{
|
||||
level.Scrolls.Resize(level.sectors.Size());
|
||||
memset(&level.Scrolls[0], 0, sizeof(level.Scrolls[0])*level.Scrolls.Size());
|
||||
level.Scrolls[p.sectornum] = scroll;
|
||||
}
|
||||
}
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
|
@ -575,7 +559,7 @@ void P_SerializeSounds(FSerializer &arc)
|
|||
void CopyPlayer(player_t *dst, player_t *src, const char *name);
|
||||
static void ReadOnePlayer(FSerializer &arc, bool skipload);
|
||||
static void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayersNow, bool skipload);
|
||||
static void SpawnExtraPlayers();
|
||||
static void SpawnExtraPlayers(FLevelLocals *Level);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
|
@ -583,7 +567,7 @@ static void SpawnExtraPlayers();
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void P_SerializePlayers(FSerializer &arc, bool skipload)
|
||||
void P_SerializePlayers(FLevelLocals *Level, FSerializer &arc, bool skipload)
|
||||
{
|
||||
int numPlayers, numPlayersNow;
|
||||
int i;
|
||||
|
|
@ -640,7 +624,7 @@ void P_SerializePlayers(FSerializer &arc, bool skipload)
|
|||
}
|
||||
if (!skipload && numPlayersNow > numPlayers)
|
||||
{
|
||||
SpawnExtraPlayers();
|
||||
SpawnExtraPlayers(Level);
|
||||
}
|
||||
// Redo pitch limits, since the spawned player has them at 0.
|
||||
players[consoleplayer].SendPitchLimits();
|
||||
|
|
@ -891,7 +875,7 @@ void CopyPlayer(player_t *dst, player_t *src, const char *name)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static void SpawnExtraPlayers()
|
||||
static void SpawnExtraPlayers(FLevelLocals *Level)
|
||||
{
|
||||
// If there are more players now than there were in the savegame,
|
||||
// be sure to spawn the extra players.
|
||||
|
|
@ -907,7 +891,7 @@ static void SpawnExtraPlayers()
|
|||
if (playeringame[i] && players[i].mo == NULL)
|
||||
{
|
||||
players[i].playerstate = PST_ENTER;
|
||||
P_SpawnPlayer(&level.playerstarts[i], i, (level.flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0);
|
||||
P_SpawnPlayer(&Level->playerstarts[i], i, (level.flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -918,13 +902,13 @@ static void SpawnExtraPlayers()
|
|||
//
|
||||
//============================================================================
|
||||
|
||||
void G_SerializeLevel(FSerializer &arc, bool hubload)
|
||||
void G_SerializeLevel(FSerializer &arc, FLevelLocals *Level, bool hubload)
|
||||
{
|
||||
int i = level.totaltime;
|
||||
int i = Level->totaltime;
|
||||
|
||||
if (arc.isWriting())
|
||||
{
|
||||
arc.Array("checksum", level.md5, 16);
|
||||
arc.Array("checksum", Level->md5, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -933,11 +917,11 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
// deep down in the deserializer or just a crash if the few insufficient safeguards were not triggered.
|
||||
uint8_t chk[16] = { 0 };
|
||||
arc.Array("checksum", chk, 16);
|
||||
if (arc.GetSize("linedefs") != level.lines.Size() ||
|
||||
arc.GetSize("sidedefs") != level.sides.Size() ||
|
||||
arc.GetSize("sectors") != level.sectors.Size() ||
|
||||
arc.GetSize("polyobjs") != level.Polyobjects.Size() ||
|
||||
memcmp(chk, level.md5, 16))
|
||||
if (arc.GetSize("linedefs") != Level->lines.Size() ||
|
||||
arc.GetSize("sidedefs") != Level->sides.Size() ||
|
||||
arc.GetSize("sectors") != Level->sectors.Size() ||
|
||||
arc.GetSize("polyobjs") != Level->Polyobjects.Size() ||
|
||||
memcmp(chk, Level->md5, 16))
|
||||
{
|
||||
I_Error("Savegame is from a different level");
|
||||
}
|
||||
|
|
@ -953,55 +937,57 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
|
||||
arc("multiplayer", multiplayer);
|
||||
|
||||
arc("level.flags", level.flags)
|
||||
("level.flags2", level.flags2)
|
||||
("level.fadeto", level.fadeto)
|
||||
("level.found_secrets", level.found_secrets)
|
||||
("level.found_items", level.found_items)
|
||||
("level.killed_monsters", level.killed_monsters)
|
||||
("level.total_secrets", level.total_secrets)
|
||||
("level.total_items", level.total_items)
|
||||
("level.total_monsters", level.total_monsters)
|
||||
("level.gravity", level.gravity)
|
||||
("level.aircontrol", level.aircontrol)
|
||||
("level.teamdamage", level.teamdamage)
|
||||
("level.maptime", level.maptime)
|
||||
("level.totaltime", i)
|
||||
("level.skytexture1", level.skytexture1)
|
||||
("level.skytexture2", level.skytexture2)
|
||||
("level.fogdensity", level.fogdensity)
|
||||
("level.outsidefogdensity", level.outsidefogdensity)
|
||||
("level.skyfog", level.skyfog)
|
||||
("level.deathsequence", level.deathsequence)
|
||||
("level.bodyqueslot", level.bodyqueslot)
|
||||
("level.spawnindex", level.spawnindex)
|
||||
.Array("level.bodyque", level.bodyque, level.BODYQUESIZE)
|
||||
("level.corpsequeue", level.CorpseQueue)
|
||||
("level.spotstate", level.SpotState)
|
||||
("level.fragglethinker", level.FraggleScriptThinker)
|
||||
("level.acsthinker", level.ACSThinker);
|
||||
("level.impactdecalcount", level.ImpactDecalCount);
|
||||
arc("flags", Level->flags)
|
||||
("flags2", Level->flags2)
|
||||
("fadeto", Level->fadeto)
|
||||
("found_secrets", Level->found_secrets)
|
||||
("found_items", Level->found_items)
|
||||
("killed_monsters", Level->killed_monsters)
|
||||
("total_secrets", Level->total_secrets)
|
||||
("total_items", Level->total_items)
|
||||
("total_monsters", Level->total_monsters)
|
||||
("gravity", Level->gravity)
|
||||
("aircontrol", Level->aircontrol)
|
||||
("teamdamage", Level->teamdamage)
|
||||
("maptime", Level->maptime)
|
||||
("totaltime", i)
|
||||
("skytexture1", Level->skytexture1)
|
||||
("skytexture2", Level->skytexture2)
|
||||
("fogdensity", Level->fogdensity)
|
||||
("outsidefogdensity", Level->outsidefogdensity)
|
||||
("skyfog", Level->skyfog)
|
||||
("deathsequence", Level->deathsequence)
|
||||
("bodyqueslot", Level->bodyqueslot)
|
||||
("spawnindex", Level->spawnindex)
|
||||
.Array("bodyque", Level->bodyque, Level->BODYQUESIZE)
|
||||
("corpsequeue", Level->CorpseQueue)
|
||||
("spotstate", Level->SpotState)
|
||||
("fragglethinker", Level->FraggleScriptThinker)
|
||||
("acsthinker", Level->ACSThinker)
|
||||
("impactdecalcount", Level->ImpactDecalCount)
|
||||
("scrolls", Level->Scrolls);
|
||||
|
||||
|
||||
// Hub transitions must keep the current total time
|
||||
if (!hubload)
|
||||
level.totaltime = i;
|
||||
Level->totaltime = i;
|
||||
|
||||
if (arc.isReading())
|
||||
{
|
||||
sky1texture = level.skytexture1;
|
||||
sky2texture = level.skytexture2;
|
||||
sky1texture = Level->skytexture1;
|
||||
sky2texture = Level->skytexture2;
|
||||
R_InitSkyMap();
|
||||
G_AirControlChanged();
|
||||
}
|
||||
|
||||
level.Behaviors.SerializeModuleStates(arc);
|
||||
Level->Behaviors.SerializeModuleStates(arc);
|
||||
// The order here is important: First world state, then portal state, then thinkers, and last polyobjects.
|
||||
arc("linedefs", level.lines, level.loadlines);
|
||||
arc("sidedefs", level.sides, level.loadsides);
|
||||
arc("sectors", level.sectors, level.loadsectors);
|
||||
arc("zones", level.Zones);
|
||||
arc("lineportals", level.linePortals);
|
||||
arc("sectorportals", level.sectorPortals);
|
||||
arc("linedefs", Level->lines, Level->loadlines);
|
||||
arc("sidedefs", Level->sides, Level->loadsides);
|
||||
arc("sectors", Level->sectors, Level->loadsectors);
|
||||
arc("zones", Level->Zones);
|
||||
arc("lineportals", Level->linePortals);
|
||||
arc("sectorportals", Level->sectorPortals);
|
||||
if (arc.isReading()) P_FinalizePortals();
|
||||
|
||||
// [ZZ] serialize health groups
|
||||
|
|
@ -1009,18 +995,18 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
// [ZZ] serialize events
|
||||
E_SerializeEvents(arc);
|
||||
DThinker::SerializeThinkers(arc, hubload);
|
||||
arc("polyobjs", level.Polyobjects);
|
||||
arc("polyobjs", Level->Polyobjects);
|
||||
SerializeSubsectors(arc, "subsectors");
|
||||
StatusBar->SerializeMessages(arc);
|
||||
AM_SerializeMarkers(arc);
|
||||
FRemapTable::StaticSerializeTranslations(arc);
|
||||
level.canvasTextureInfo.Serialize(arc);
|
||||
P_SerializePlayers(arc, hubload);
|
||||
Level->canvasTextureInfo.Serialize(arc);
|
||||
P_SerializePlayers(Level, arc, hubload);
|
||||
P_SerializeSounds(arc);
|
||||
|
||||
if (arc.isReading())
|
||||
{
|
||||
for (auto &sec : level.sectors)
|
||||
for (auto &sec : Level->sectors)
|
||||
{
|
||||
P_Recalculate3DFloors(&sec);
|
||||
}
|
||||
|
|
@ -1033,5 +1019,5 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
}
|
||||
}
|
||||
AActor::RecreateAllAttachedLights();
|
||||
InitPortalGroups(&level);
|
||||
InitPortalGroups(Level);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue