mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
Implemented loading/saving of line/sector health and health groups in savegames
This commit is contained in:
parent
40c56bad09
commit
a6cdcab128
5 changed files with 71 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
#include "p_local.h"
|
||||
#include "p_maputl.h"
|
||||
#include "c_cvars.h"
|
||||
#include "serializer.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -530,3 +531,50 @@ bool P_CheckSectorVulnerable(sector_t* sector, int part)
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
FSerializer &Serialize(FSerializer &arc, const char *key, FHealthGroup& g, FHealthGroup *def)
|
||||
{
|
||||
if (arc.BeginObject(key))
|
||||
{
|
||||
arc("id", g.id)
|
||||
("health", g.health)
|
||||
.EndObject();
|
||||
}
|
||||
return arc;
|
||||
}
|
||||
|
||||
void P_SerializeHealthGroups(FSerializer& arc)
|
||||
{
|
||||
// todo : stuff
|
||||
if (arc.BeginArray("healthgroups"))
|
||||
{
|
||||
if (arc.isReading())
|
||||
{
|
||||
TArray<FHealthGroup> readGroups;
|
||||
int sz = arc.ArraySize();
|
||||
for (int i = 0; i < sz; i++)
|
||||
{
|
||||
FHealthGroup grp;
|
||||
arc(nullptr, grp);
|
||||
FHealthGroup* existinggrp = P_GetHealthGroup(grp.id);
|
||||
if (!existinggrp)
|
||||
continue;
|
||||
existinggrp->health = grp.health;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TMap<int, FHealthGroup>::ConstIterator it(level.healthGroups);
|
||||
TMap<int, FHealthGroup>::ConstPair* pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
FHealthGroup grp = pair->Value;
|
||||
arc(nullptr, grp);
|
||||
}
|
||||
}
|
||||
|
||||
arc.EndArray();
|
||||
}
|
||||
}
|
|
@ -35,3 +35,5 @@ void P_GeometryRadiusAttack(AActor* bombspot, AActor* bombsource, int bombdamage
|
|||
|
||||
bool P_CheckLinedefVulnerable(line_t* line, int side, int part = -1);
|
||||
bool P_CheckSectorVulnerable(sector_t* sector, int part);
|
||||
|
||||
void P_SerializeHealthGroups(FSerializer& arc);
|
|
@ -56,6 +56,7 @@
|
|||
#include "serializer.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "events.h"
|
||||
#include "p_destructible.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -74,6 +75,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, line_t &line, line_t *
|
|||
.Args("args", line.args, def->args, line.special)
|
||||
("portalindex", line.portalindex, def->portalindex)
|
||||
("locknumber", line.locknumber, def->locknumber)
|
||||
("health", line.health, def->health)
|
||||
// Unless the map loader is changed the sidedef references will not change between map loads so there's no need to save them.
|
||||
//.Array("sides", line.sidedef, 2)
|
||||
.EndObject();
|
||||
|
@ -293,6 +295,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sector_t &p, sector_t
|
|||
.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)
|
||||
// GZDoom exclusive:
|
||||
.Array("reflect", p.reflect, def->reflect, 2, true)
|
||||
.EndObject();
|
||||
|
@ -991,6 +995,8 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
arc("sectorportals", level.sectorPortals);
|
||||
if (arc.isReading()) P_FinalizePortals();
|
||||
|
||||
// [ZZ] serialize health groups
|
||||
P_SerializeHealthGroups(arc);
|
||||
// [ZZ] serialize events
|
||||
E_SerializeEvents(arc);
|
||||
DThinker::SerializeThinkers(arc, hubload);
|
||||
|
|
|
@ -2652,6 +2652,10 @@ DEFINE_FIELD_X(Sector, sector_t, damageamount)
|
|||
DEFINE_FIELD_X(Sector, sector_t, damageinterval)
|
||||
DEFINE_FIELD_X(Sector, sector_t, leakydamage)
|
||||
DEFINE_FIELD_X(Sector, sector_t, ZoneNumber)
|
||||
DEFINE_FIELD_X(Sector, sector_t, healthceiling)
|
||||
DEFINE_FIELD_X(Sector, sector_t, healthfloor)
|
||||
DEFINE_FIELD_X(Sector, sector_t, healthceilinggroup)
|
||||
DEFINE_FIELD_X(Sector, sector_t, healthfloorgroup)
|
||||
DEFINE_FIELD_X(Sector, sector_t, MoreFlags)
|
||||
DEFINE_FIELD_X(Sector, sector_t, Flags)
|
||||
DEFINE_FIELD_X(Sector, sector_t, SecActTarget)
|
||||
|
@ -2675,6 +2679,8 @@ DEFINE_FIELD_X(Line, line_t, validcount)
|
|||
DEFINE_FIELD_X(Line, line_t, locknumber)
|
||||
DEFINE_FIELD_X(Line, line_t, portalindex)
|
||||
DEFINE_FIELD_X(Line, line_t, portaltransferred)
|
||||
DEFINE_FIELD_X(Line, line_t, health)
|
||||
DEFINE_FIELD_X(Line, line_t, healthgroup)
|
||||
|
||||
DEFINE_FIELD_X(Side, side_t, sector)
|
||||
DEFINE_FIELD_X(Side, side_t, linedef)
|
||||
|
|
|
@ -157,6 +157,9 @@ struct Line native play
|
|||
native readonly uint portalindex;
|
||||
native readonly uint portaltransferred;
|
||||
|
||||
native readonly int health;
|
||||
native readonly int healthgroup;
|
||||
|
||||
native bool isLinePortal();
|
||||
native bool isVisualPortal();
|
||||
native Line getPortalDestination();
|
||||
|
@ -287,6 +290,11 @@ struct Sector native play
|
|||
|
||||
native readonly uint16 ZoneNumber;
|
||||
|
||||
native readonly int healthceiling;
|
||||
native readonly int healthfloor;
|
||||
native readonly int healthceilinggroup;
|
||||
native readonly int healthfloorgroup;
|
||||
|
||||
enum ESectorMoreFlags
|
||||
{
|
||||
SECMF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor
|
||||
|
|
Loading…
Reference in a new issue