- made adjustments for new savegame code.

This commit is contained in:
Christoph Oelckers 2016-09-24 01:47:44 +02:00
parent 6bfbe30b99
commit ee2766d00b
8 changed files with 70 additions and 57 deletions

View File

@ -69,6 +69,7 @@
#include "r_utility.h"
#include "portal.h"
#include "doomstat.h"
#include "serializer.h"
#include "gl/renderer/gl_renderer.h"
@ -154,24 +155,31 @@ static FRandom randLight;
//
//
//==========================================================================
void ADynamicLight::Serialize(FArchive &arc)
void ADynamicLight::Serialize(FSerializer &arc)
{
Super::Serialize (arc);
arc << lightflags << lighttype;
arc << m_tickCount << m_currentRadius;
arc << m_Radius[0] << m_Radius[1];
auto def = static_cast<ADynamicLight*>(GetDefault());
arc("lightflags", lightflags, def->lightflags)
("lighttype", lighttype, def->lighttype)
("tickcount", m_tickCount, def->m_tickCount)
("currentradius", m_currentRadius, def->m_currentRadius)
.Array("radius", m_Radius, def->m_Radius, 2);
if (lighttype == PulseLight) arc << m_lastUpdate << m_cycler;
if (arc.IsLoading())
{
// The default constructor which is used for creating objects before deserialization will not set this variable.
// It needs to be true for all placed lights.
visibletoplayer = true;
LinkLight();
}
if (lighttype == PulseLight)
arc("lastupdate", m_lastUpdate, def->m_lastUpdate)
("cycler", m_cycler, def->m_cycler);
}
void ADynamicLight::PostSerialize()
{
Super::PostSerialize();
// The default constructor which is used for creating objects before deserialization will not set this variable.
// It needs to be true for all placed lights.
visibletoplayer = true;
LinkLight();
}
//==========================================================================
//
// [TS]

View File

@ -32,7 +32,7 @@ EXTERN_CVAR(Bool, gl_lights)
EXTERN_CVAR(Bool, gl_attachedlights)
class ADynamicLight;
class FArchive;
class FSerializer;
@ -93,7 +93,8 @@ class ADynamicLight : public AActor
DECLARE_CLASS (ADynamicLight, AActor)
public:
virtual void Tick();
void Serialize(FArchive &arc);
void Serialize(FSerializer &arc);
void PostSerialize();
BYTE GetRed() const { return args[LIGHT_RED]; }
BYTE GetGreen() const { return args[LIGHT_GREEN]; }
BYTE GetBlue() const { return args[LIGHT_BLUE]; }

View File

@ -169,7 +169,7 @@ public:
void RenderScreenQuad();
void SetFixedColormap (player_t *player);
void WriteSavePic (player_t *player, FILE *file, int width, int height);
void WriteSavePic (player_t *player, FileWriter *file, int width, int height);
void EndDrawScene(sector_t * viewsector);
void UpdateCameraExposure();
void BloomScene();

View File

@ -43,6 +43,7 @@
#include "a_hexenglobal.h"
#include "p_local.h"
#include "gl/gl_functions.h"
#include "serializer.h"
#include "gl/dynlights/gl_lightbuffer.h"
#include "gl/system/gl_interface.h"
@ -921,7 +922,7 @@ void FGLRenderer::RenderView (player_t* player)
//
//===========================================================================
void FGLRenderer::WriteSavePic (player_t *player, FILE *file, int width, int height)
void FGLRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
{
GL_IRECT bounds;
@ -972,10 +973,10 @@ struct FGLInterface : public FRenderer
void PrecacheSprite(FTexture *tex, SpriteHits &hits);
void Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &actorhitlist) override;
void RenderView(player_t *player) override;
void WriteSavePic (player_t *player, FILE *file, int width, int height) override;
void WriteSavePic (player_t *player, FileWriter *file, int width, int height) override;
void StateChanged(AActor *actor) override;
void StartSerialize(FArchive &arc) override;
void EndSerialize(FArchive &arc) override;
void StartSerialize(FSerializer &arc) override;
void EndSerialize(FSerializer &arc) override;
void RenderTextureView (FCanvasTexture *self, AActor *viewpoint, int fov) override;
sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel, bool back) override;
void SetFogParams(int _fogdensity, PalEntry _outsidefogcolor, int _outsidefogdensity, int _skyfog) override;
@ -1195,20 +1196,22 @@ void FGLInterface::StateChanged(AActor *actor)
//
//===========================================================================
void FGLInterface::StartSerialize(FArchive &arc)
void FGLInterface::StartSerialize(FSerializer &arc)
{
gl_DeleteAllAttachedLights();
if (arc.BeginObject("glinfo"))
{
arc("fogdensity", fogdensity)
("outsidefogdensity", outsidefogdensity)
("skyfog", skyfog)
.EndObject();
}
}
void gl_SerializeGlobals(FArchive &arc)
{
arc << fogdensity << outsidefogdensity << skyfog;
}
void FGLInterface::EndSerialize(FArchive &arc)
void FGLInterface::EndSerialize(FSerializer &arc)
{
gl_RecreateAllAttachedLights();
if (arc.IsLoading()) gl_InitPortals();
if (arc.isReading()) gl_InitPortals();
}
//===========================================================================
@ -1244,7 +1247,7 @@ void FGLInterface::ClearBuffer(int color)
//
//===========================================================================
void FGLInterface::WriteSavePic (player_t *player, FILE *file, int width, int height)
void FGLInterface::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
{
GLRenderer->WriteSavePic(player, file, width, height);
}

View File

@ -36,7 +36,6 @@
#include "vectors.h"
#include "v_palette.h"
#include "templates.h"
#include "farchive.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h"

View File

@ -34,19 +34,30 @@
*/
#include <math.h>
#include "serializer.h"
#include "gl/utility/gl_cycler.h"
//==========================================================================
//
//
// This will never be called with a null-def, so don't bother with that case.
//
//==========================================================================
void FCycler::Serialize(FArchive & arc)
FSerializer &Serialize(FSerializer &arc, const char *key, FCycler &c, FCycler *def)
{
arc << m_start << m_end << m_current
<< m_time << m_cycle << m_increment << m_shouldCycle
<< m_cycleType;
if (arc.BeginObject(key))
{
arc("start", c.m_start, def->m_start)
("end", c.m_end, def->m_end)
("current", c.m_current, def->m_current)
("time", c.m_time, def->m_time)
("cycle", c.m_cycle, def->m_cycle)
("increment", c.m_increment, def->m_increment)
("shouldcycle", c.m_shouldCycle, def->m_shouldCycle)
.Enum("type", c.m_cycleType)
.EndObject();
}
return arc;
}
//==========================================================================

View File

@ -1,28 +1,24 @@
#ifndef __GL_CYCLER_H
#define __GL_CYCLER_H
#include "farchive.h"
class FSerializer;
typedef enum
enum CycleType
{
CYCLE_Linear,
CYCLE_Sin,
CYCLE_Cos,
CYCLE_SawTooth,
CYCLE_Square
} CycleType;
inline FArchive &operator<< (FArchive &arc, CycleType &type)
{
BYTE val = (BYTE)type;
arc << val;
type = (CycleType)val;
return arc;
}
CYCLE_Linear,
CYCLE_Sin,
CYCLE_Cos,
CYCLE_SawTooth,
CYCLE_Square
};
class FCycler;
FSerializer &Serialize(FSerializer &arc, const char *key, FCycler &c, FCycler *def);
class FCycler
{
friend FSerializer &Serialize(FSerializer &arc, const char *key, FCycler &c, FCycler *def);
public:
FCycler();
void Update(float diff);
@ -33,7 +29,6 @@ public:
inline operator float () const { return m_current; }
void Serialize(FArchive & arc);
protected:
float m_start, m_end, m_current;
float m_time, m_cycle;
@ -42,11 +37,5 @@ protected:
CycleType m_cycleType;
};
inline FArchive &operator<< (FArchive &arc, FCycler &type)
{
type.Serialize(arc);
return arc;
}
#endif

View File

@ -271,6 +271,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)
// GZDoom exclusive:
.Array("reflect", p.reflect, def->reflect, 2)
.EndObject();
if (arc.isReading() && !scroll.isZero())