From e47b4507e4c0460dcc7f92b6f440c2f0d4832433 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Mar 2021 18:42:00 +0100 Subject: [PATCH] - 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. --- source/core/rendering/hw_entrypoint.cpp | 14 ++++++++++++++ source/core/rendering/render.h | 11 ++++++++--- source/core/savegamehelp.cpp | 4 +++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/source/core/rendering/hw_entrypoint.cpp b/source/core/rendering/hw_entrypoint.cpp index 1f27eb26f..0f074a3d1 100644 --- a/source/core/rendering/hw_entrypoint.cpp +++ b/source/core/rendering/hw_entrypoint.cpp @@ -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; +} diff --git a/source/core/rendering/render.h b/source/core/rendering/render.h index 721b33683..a47c8ec62 100644 --- a/source/core/rendering/render.h +++ b/source/core/rendering/render.h @@ -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 targets; }; +FSerializer& Serialize(FSerializer& arc, const char* key, PortalDesc& obj, PortalDesc* defval); + + extern TArray 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; diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 3c5b0ca71..5c506d2d5 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -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);