- another batch.

This commit is contained in:
Christoph Oelckers 2016-09-19 19:58:04 +02:00
parent e89d072abc
commit a5000ead4c
11 changed files with 89 additions and 108 deletions

View file

@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit)
bool isdefault = false;
// shoot a cube at current target
targ = state->GetNextInList(PClass::FindClass("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain));
targ = state->GetNextInList(PClass::FindActor("BossTarget"), G_SkillProperty(SKILLP_EasyBossBrain));
if (targ != NULL)
{

View file

@ -148,7 +148,7 @@ void P_DSparilTeleport (AActor *actor)
DSpotState *state = DSpotState::GetSpotState();
if (state == NULL) return;
spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->X(), actor->Y(), 128, 0);
spot = state->GetSpotWithMinMaxDistance(PClass::FindActor("BossSpot"), actor->X(), actor->Y(), 128, 0);
if (spot == NULL) return;
prev = actor->Pos();

View file

@ -11,7 +11,7 @@
#include "p_enemy.h"
#include "statnums.h"
#include "templates.h"
#include "farchive.h"
#include "serializer.h"
#include "r_data/r_translate.h"
static FRandom pr_freezedeath ("FreezeDeath");
@ -361,7 +361,7 @@ class DCorpsePointer : public DThinker
public:
DCorpsePointer (AActor *ptr);
void Destroy ();
void Serialize(FArchive &arc);
void Serialize(FSerializer &arc);
TObjPtr<AActor> Corpse;
DWORD Count; // Only the first corpse pointer's count is valid.
private:
@ -435,10 +435,11 @@ void DCorpsePointer::Destroy ()
Super::Destroy ();
}
void DCorpsePointer::Serialize(FArchive &arc)
void DCorpsePointer::Serialize(FSerializer &arc)
{
Super::Serialize(arc);
arc << Corpse << Count;
arc("corpse", Corpse)
("count", Count);
}

View file

@ -1,7 +1,7 @@
#include "a_sharedglobal.h"
#include "g_level.h"
#include "d_player.h"
#include "farchive.h"
#include "serializer.h"
IMPLEMENT_POINTY_CLASS (DFlashFader)
DECLARE_POINTER (ForWho)
@ -26,13 +26,13 @@ void DFlashFader::Destroy ()
Super::Destroy();
}
void DFlashFader::Serialize(FArchive &arc)
void DFlashFader::Serialize(FSerializer &arc)
{
Super::Serialize (arc);
arc << TotalTics << StartTic << ForWho;
for (int i = 1; i >= 0; --i)
for (int j = 3; j >= 0; --j)
arc << Blends[i][j];
arc("totaltics", TotalTics)
("starttic", StartTic)
("forwho", ForWho)
.Array("blends", Blends[0], 8);
}
void DFlashFader::Tick ()

View file

@ -9,7 +9,7 @@
#include "r_sky.h"
#include "g_level.h"
#include "r_state.h"
#include "farchive.h"
#include "serializer.h"
static FRandom pr_lightning ("Lightning");
@ -19,44 +19,24 @@ DLightningThinker::DLightningThinker ()
: DThinker (STAT_LIGHTNING)
{
Stopped = false;
LightningLightLevels = NULL;
LightningFlashCount = 0;
NextLightningFlash = ((pr_lightning()&15)+5)*35; // don't flash at level start
LightningLightLevels = new short[numsectors];
clearbufshort(LightningLightLevels, numsectors, SHRT_MAX);
LightningLightLevels.Resize(numsectors);
clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
}
DLightningThinker::~DLightningThinker ()
{
if (LightningLightLevels != NULL)
{
delete[] LightningLightLevels;
}
}
void DLightningThinker::Serialize(FArchive &arc)
void DLightningThinker::Serialize(FSerializer &arc)
{
int i;
short *lights;
Super::Serialize (arc);
arc << Stopped << NextLightningFlash << LightningFlashCount;
if (arc.IsLoading ())
{
if (LightningLightLevels != NULL)
{
delete[] LightningLightLevels;
}
LightningLightLevels = new short[numsectors];
}
lights = LightningLightLevels;
for (i = numsectors; i > 0; ++lights, --i)
{
arc << *lights;
}
arc("stopped", Stopped)
("next", NextLightningFlash)
("count", LightningFlashCount)
("levels", LightningLightLevels);
}
void DLightningThinker::Tick ()
@ -107,7 +87,7 @@ void DLightningThinker::LightningFlash ()
tempSec->SetLightLevel(LightningLightLevels[j]);
}
}
clearbufshort(LightningLightLevels, numsectors, SHRT_MAX);
clearbufshort(&LightningLightLevels[0], numsectors, SHRT_MAX);
level.flags &= ~LEVEL_SWAPSKIES;
}
return;

View file

@ -13,7 +13,7 @@ class DLightningThinker : public DThinker
public:
DLightningThinker ();
~DLightningThinker ();
void Serialize(FArchive &arc);
void Serialize(FSerializer &arc);
void Tick ();
void ForceLightning (int mode);
void TerminateLightning();
@ -24,7 +24,7 @@ protected:
int NextLightningFlash;
int LightningFlashCount;
bool Stopped;
short *LightningLightLevels;
TArray<short> LightningLightLevels;
};
void P_StartLightning ();

View file

@ -8,7 +8,7 @@
#include "s_sound.h"
#include "a_sharedglobal.h"
#include "statnums.h"
#include "farchive.h"
#include "serializer.h"
#include "d_player.h"
#include "r_utility.h"
@ -64,15 +64,23 @@ DEarthquake::DEarthquake(AActor *center, int intensityX, int intensityY, int int
//
//==========================================================================
void DEarthquake::Serialize(FArchive &arc)
void DEarthquake::Serialize(FSerializer &arc)
{
Super::Serialize (arc);
arc << m_Spot << m_Intensity << m_Countdown
<< m_TremorRadius << m_DamageRadius
<< m_QuakeSFX << m_Flags << m_CountdownStart
<< m_WaveSpeed
<< m_Falloff << m_Highpoint << m_MiniCount
<< m_RollIntensity << m_RollWave;
arc("spot", m_Spot)
("intensity", m_Intensity)
("countdown", m_Countdown)
("tremorradius", m_TremorRadius)
("damageradius", m_DamageRadius)
("quakesfx", m_QuakeSFX)
("quakeflags", m_Flags)
("countdownstart", m_CountdownStart)
("wavespeed", m_WaveSpeed)
("falloff", m_Falloff)
("highpoint", m_Highpoint)
("minicount", m_MiniCount)
("rollintensity", m_RollIntensity)
("rollwave", m_RollWave);
}
//==========================================================================

View file

@ -122,7 +122,7 @@ public:
float r2, float g2, float b2, float a2,
float time, AActor *who);
void Destroy ();
void Serialize(FArchive &arc);
void Serialize(FSerializer &arc);
void Tick ();
AActor *WhoFor() { return ForWho; }
void Cancel ();
@ -165,7 +165,7 @@ public:
int damrad, int tremrad, FSoundID quakesfx, int flags,
double waveSpeedX, double waveSpeedY, double waveSpeedZ, int falloff, int highpoint, double rollIntensity, double rollWave);
void Serialize(FArchive &arc);
void Serialize(FSerializer &arc);
void Tick ();
TObjPtr<AActor> m_Spot;
double m_TremorRadius, m_DamageRadius;

View file

@ -39,7 +39,7 @@
#include "i_system.h"
#include "thingdef/thingdef.h"
#include "doomstat.h"
#include "farchive.h"
#include "serializer.h"
#include "a_pickups.h"
static FRandom pr_spot ("SpecialSpot");
@ -58,7 +58,7 @@ TObjPtr<DSpotState> DSpotState::SpotState;
struct FSpotList
{
const PClass *Type;
PClassActor *Type;
TArray<ASpecialSpot*> Spots;
unsigned Index;
int SkipCount;
@ -68,7 +68,7 @@ struct FSpotList
{
}
FSpotList(const PClass *type)
FSpotList(PClassActor *type)
{
Type = type;
Index = 0;
@ -82,17 +82,6 @@ struct FSpotList
//
//----------------------------------------------------------------------------
void Serialize(FArchive &arc)
{
arc << Type << Spots << Index << SkipCount << numcalls;
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
bool Add(ASpecialSpot *newspot)
{
for(unsigned i = 0; i < Spots.Size(); i++)
@ -194,6 +183,26 @@ struct FSpotList
//
//----------------------------------------------------------------------------
FSerializer &Serialize(FSerializer &arc, const char *key, FSpotList &list, FSpotList *def)
{
if (arc.BeginObject(key))
{
arc("type", list.Type)
("spots", list.Spots)
("index", list.Index)
("skipcount", list.SkipCount)
("numcalls", list.numcalls)
.EndObject();
}
return arc;
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
DSpotState::DSpotState ()
: DThinker (STAT_INFO)
{
@ -215,10 +224,6 @@ DSpotState::DSpotState ()
void DSpotState::Destroy ()
{
for(unsigned i = 0; i < SpotLists.Size(); i++)
{
delete SpotLists[i];
}
SpotLists.Clear();
SpotLists.ShrinkToFit();
@ -254,13 +259,13 @@ DSpotState *DSpotState::GetSpotState(bool create)
//
//----------------------------------------------------------------------------
FSpotList *DSpotState::FindSpotList(const PClass *type)
FSpotList *DSpotState::FindSpotList(PClassActor *type)
{
for(unsigned i = 0; i < SpotLists.Size(); i++)
{
if (SpotLists[i]->Type == type) return SpotLists[i];
if (SpotLists[i].Type == type) return &SpotLists[i];
}
return SpotLists[SpotLists.Push(new FSpotList(type))];
return &SpotLists[SpotLists.Push(FSpotList(type))];
}
//----------------------------------------------------------------------------
@ -295,27 +300,10 @@ bool DSpotState::RemoveSpot(ASpecialSpot *spot)
//
//----------------------------------------------------------------------------
void DSpotState::Serialize(FArchive &arc)
void DSpotState::Serialize(FSerializer &arc)
{
Super::Serialize(arc);
if (arc.IsStoring())
{
arc.WriteCount(SpotLists.Size());
for(unsigned i = 0; i < SpotLists.Size(); i++)
{
SpotLists[i]->Serialize(arc);
}
}
else
{
unsigned c = arc.ReadCount();
SpotLists.Resize(c);
for(unsigned i = 0; i < SpotLists.Size(); i++)
{
SpotLists[i] = new FSpotList;
SpotLists[i]->Serialize(arc);
}
}
arc("spots", SpotLists);
}
//----------------------------------------------------------------------------
@ -324,7 +312,7 @@ void DSpotState::Serialize(FArchive &arc)
//
//----------------------------------------------------------------------------
ASpecialSpot *DSpotState::GetNextInList(const PClass *type, int skipcounter)
ASpecialSpot *DSpotState::GetNextInList(PClassActor *type, int skipcounter)
{
FSpotList *list = FindSpotList(type);
if (list != NULL) return list->GetNextInList(skipcounter);
@ -337,7 +325,7 @@ ASpecialSpot *DSpotState::GetNextInList(const PClass *type, int skipcounter)
//
//----------------------------------------------------------------------------
ASpecialSpot *DSpotState::GetSpotWithMinMaxDistance(const PClass *type, double x, double y, double mindist, double maxdist)
ASpecialSpot *DSpotState::GetSpotWithMinMaxDistance(PClassActor *type, double x, double y, double mindist, double maxdist)
{
FSpotList *list = FindSpotList(type);
if (list != NULL) return list->GetSpotWithMinMaxDistance(x, y, mindist, maxdist);
@ -350,7 +338,7 @@ ASpecialSpot *DSpotState::GetSpotWithMinMaxDistance(const PClass *type, double x
//
//----------------------------------------------------------------------------
ASpecialSpot *DSpotState::GetRandomSpot(const PClass *type, bool onlyonce)
ASpecialSpot *DSpotState::GetRandomSpot(PClassActor *type, bool onlyonce)
{
FSpotList *list = FindSpotList(type);
if (list != NULL) return list->GetRandomSpot(onlyonce);

View file

@ -22,7 +22,7 @@ class DSpotState : public DThinker
{
DECLARE_CLASS(DSpotState, DThinker)
static TObjPtr<DSpotState> SpotState;
TArray<FSpotList *> SpotLists;
TArray<FSpotList> SpotLists;
public:
@ -31,13 +31,13 @@ public:
void Destroy ();
void Tick ();
static DSpotState *GetSpotState(bool create = true);
FSpotList *FindSpotList(const PClass *type);
FSpotList *FindSpotList(PClassActor *type);
bool AddSpot(ASpecialSpot *spot);
bool RemoveSpot(ASpecialSpot *spot);
void Serialize(FArchive &arc);
ASpecialSpot *GetNextInList(const PClass *type, int skipcounter);
ASpecialSpot *GetSpotWithMinMaxDistance(const PClass *type, double x, double y, double mindist, double maxdist);
ASpecialSpot *GetRandomSpot(const PClass *type, bool onlyonce = false);
void Serialize(FSerializer &arc);
ASpecialSpot *GetNextInList(PClassActor *type, int skipcounter);
ASpecialSpot *GetSpotWithMinMaxDistance(PClassActor *type, double x, double y, double mindist, double maxdist);
ASpecialSpot *GetRandomSpot(PClassActor *type, bool onlyonce = false);
};

View file

@ -1055,12 +1055,16 @@ double sector_t::NextLowestFloorAt(double x, double y, double z, int flags, doub
FSerializer &Serialize(FSerializer &arc, const char *key, secspecial_t &spec, secspecial_t *def)
{
arc("special", spec.special)
("damageamount", spec.damageamount)
("damagetype", spec.damagetype)
("damageinterval", spec.damageinterval)
("leakydamage", spec.leakydamage)
("flags", spec.Flags);
if (arc.BeginObject(key))
{
arc("special", spec.special)
("damageamount", spec.damageamount)
("damagetype", spec.damagetype)
("damageinterval", spec.damageinterval)
("leakydamage", spec.leakydamage)
("flags", spec.Flags)
.EndObject();
}
return arc;
}