- serialize the sector portal offset table.

Due to where this happens, the init code for these portals cannot be run when loading a savegame so it has to be saved.
This commit is contained in:
Christoph Oelckers 2021-03-24 18:42:00 +01:00
parent 1297e4ed02
commit e47b4507e4
3 changed files with 25 additions and 4 deletions

View file

@ -313,3 +313,17 @@ void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sect
RenderViewpoint(r_viewpoint, nullptr, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, false, false);
All.Unclock();
}
FSerializer& Serialize(FSerializer& arc, const char* key, PortalDesc& obj, PortalDesc* defval)
{
if (arc.BeginObject(key))
{
arc("type", obj.type)
("dx", obj.dx)
("dy", obj.dy)
("dz", obj.dz)
("targets", obj.targets)
.EndObject();
}
return arc;
}

View file

@ -1,6 +1,8 @@
#pragma once
#include "build.h"
class FSerializer;
void render_drawrooms(spritetype* playersprite, const vec3_t& position, int sectnum, fixed_t q16angle, fixed_t q16horizon, float rollang);
struct PortalDesc
@ -10,6 +12,9 @@ struct PortalDesc
TArray<int> targets;
};
FSerializer& Serialize(FSerializer& arc, const char* key, PortalDesc& obj, PortalDesc* defval);
extern TArray<PortalDesc> allPortals;
inline void portalClear()
@ -28,10 +33,10 @@ inline int portalAdd(int type, int target, int dx = 0, int dy = 0, int dz = 0)
return allPortals.Size() - 1;
}
// merges portals in adjoining sectors. AFAIK the only one of this kind is in Blood's E4M9, which with the original code is very glitchy.
// merges portals in adjoining sectors.
inline void mergePortals()
{
Printf("Have %d portals\n", allPortals.Size());
//Printf("Have %d portals\n", allPortals.Size());
bool didsomething = true;
while (didsomething)
{
@ -56,7 +61,7 @@ inline void mergePortals()
pt2.type = -1;
for (int n = 0; n < numsectors; n++)
{
Printf("Merged %d and %d\n", i, j);
//Printf("Merged %d and %d\n", i, j);
if (sector[n].portalnum == j) sector[n].portalnum = i;
didsomething = true;
break;

View file

@ -57,6 +57,7 @@
#include "razemenu.h"
#include "interpolate.h"
#include "gamefuncs.h"
#include "render.h"
sectortype sectorbackup[MAXSECTORS];
@ -649,7 +650,8 @@ void SerializeMap(FSerializer& arc)
("parallaxys", parallaxyscale_override)
("pskybits", pskybits_override)
("numsprites", Numsprites)
("gamesetinput", gamesetinput);
("gamesetinput", gamesetinput)
("allportals", allPortals);
SerializeInterpolations(arc);