- added generic level post-processing script class

It was extracted from LevelCompatibility class, and native code was moved accordingly
(original patch by _mental_)

# Conflicts:
#	src/compatibility.cpp
This commit is contained in:
drfrag 2019-11-13 13:42:42 +01:00
parent 033f0ca43e
commit 91859bc6fa
6 changed files with 116 additions and 108 deletions

View file

@ -341,20 +341,20 @@ FName CheckCompatibility(MapData *map)
//==========================================================================
//
// SetCompatibilityParams
// PostProcessLevel
//
//==========================================================================
class DLevelCompatibility : public DObject
class DLevelPostProcessor : public DObject
{
DECLARE_ABSTRACT_CLASS(DLevelCompatibility, DObject)
DECLARE_ABSTRACT_CLASS(DLevelPostProcessor, DObject)
};
IMPLEMENT_CLASS(DLevelCompatibility, true, false);
IMPLEMENT_CLASS(DLevelPostProcessor, true, false);
void SetCompatibilityParams(FName checksum)
void PostProcessLevel(FName checksum)
{
auto lc = Create<DLevelCompatibility>();
auto lc = Create<DLevelPostProcessor>();
if (sv_njnoautolevelcompat)
{
@ -364,7 +364,7 @@ void SetCompatibilityParams(FName checksum)
for (auto cls : PClass::AllClasses)
{
if (cls->IsDescendantOf(RUNTIME_CLASS(DLevelCompatibility)))
if (cls->IsDescendantOf(RUNTIME_CLASS(DLevelPostProcessor)))
{
PFunction *const func = dyn_cast<PFunction>(cls->FindSymbol("Apply", false));
if (func == nullptr)
@ -386,9 +386,9 @@ void SetCompatibilityParams(FName checksum)
}
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, OffsetSectorPlane)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, OffsetSectorPlane)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(sector);
PARAM_INT(planeval);
PARAM_FLOAT(delta);
@ -403,17 +403,17 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, OffsetSectorPlane)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearSectorTags)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, ClearSectorTags)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(sector);
tagManager.RemoveSectorTags(sector);
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddSectorTag)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, AddSectorTag)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(sector);
PARAM_INT(tag);
@ -424,17 +424,17 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddSectorTag)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, ClearLineIDs)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, ClearLineIDs)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(line);
tagManager.RemoveLineIDs(line);
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddLineID)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, AddLineID)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(line);
PARAM_INT(tag);
@ -445,9 +445,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, AddLineID)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingSkills)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetThingSkills)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(thing);
PARAM_INT(skillmask);
@ -458,9 +458,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingSkills)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingXY)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetThingXY)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(thing);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
@ -474,9 +474,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingXY)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingZ)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetThingZ)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(thing);
PARAM_FLOAT(z);
@ -487,9 +487,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingZ)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingFlags)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetThingFlags)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_INT(thing);
PARAM_INT(flags);
@ -500,9 +500,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetThingFlags)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetVertex)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetVertex)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_UINT(vertex);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
@ -515,9 +515,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetVertex)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetLineSectorRef)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, SetLineSectorRef)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_UINT(lineidx);
PARAM_UINT(sideidx);
PARAM_UINT(sectoridx);
@ -536,9 +536,9 @@ DEFINE_ACTION_FUNCTION(DLevelCompatibility, SetLineSectorRef)
return 0;
}
DEFINE_ACTION_FUNCTION(DLevelCompatibility, GetDefaultActor)
DEFINE_ACTION_FUNCTION(DLevelPostProcessor, GetDefaultActor)
{
PARAM_SELF_PROLOGUE(DLevelCompatibility);
PARAM_SELF_PROLOGUE(DLevelPostProcessor);
PARAM_NAME(actorclass);
ACTION_RETURN_OBJECT(GetDefaultByName(actorclass));
}

View file

@ -37,6 +37,6 @@ extern TMap<FMD5Holder, FCompatValues, FMD5HashTraits> BCompatMap;
void ParseCompatibility();
FName CheckCompatibility(MapData *map);
void SetCompatibilityParams(FName);
void PostProcessLevel(FName checksum);
#endif

View file

@ -3427,7 +3427,7 @@ void P_SetupLevel(const char *lumpname, int position, bool newGame)
times[0].Unclock();
}
SetCompatibilityParams(checksum);
PostProcessLevel(checksum);
times[6].Clock();
P_LoopSidedefs(true);

View file

@ -6,6 +6,7 @@ version "3.8"
#include "zscript/constants.zs"
#include "zscript/events.zs"
#include "zscript/destructible.zs"
#include "zscript/level_postprocessor.zs"
#include "zscript/level_compatibility.zs"
#include "zscript/actors/actor.zs"

View file

@ -1,5 +1,5 @@
class LevelCompatibility native play
class LevelCompatibility : LevelPostProcessor
{
protected void Apply(Name checksum, String mapname)
{
@ -1448,77 +1448,4 @@ class LevelCompatibility native play
}
}
}
protected native void ClearSectorTags(int sector);
protected native void AddSectorTag(int sector, int tag);
protected native void ClearLineIDs(int line);
protected native void AddLineID(int line, int tag);
protected native void OffsetSectorPlane(int sector, int plane, double offset);
protected native void SetThingSkills(int thing, int skills);
protected native void SetThingXY(int thing, double x, double y);
protected native void SetThingZ(int thing, double z);
protected native void SetThingFlags(int thing, int flags);
protected native void SetVertex(uint vertex, double x, double y);
protected native void SetLineSectorRef(uint line, uint side, uint sector);
protected native Actor GetDefaultActor(Name actorclass);
protected void SetWallTexture(int line, int side, int texpart, String texture)
{
SetWallTextureID(line, side, texpart, TexMan.CheckForTexture(texture, TexMan.Type_Wall));
}
protected void SetWallTextureID(int line, int side, int texpart, TextureID texture)
{
level.Lines[line].sidedef[side].SetTexture(texpart, texture);
}
protected void SetLineFlags(int line, int setflags, int clearflags = 0)
{
level.Lines[line].flags = (level.Lines[line].flags & ~clearflags) | setflags;
}
protected void SetLineActivation(int line, int acttype)
{
level.Lines[line].activation = acttype;
}
protected void ClearLineSpecial(int line)
{
level.Lines[line].special = 0;
}
protected void SetLineSpecial(int line, int special, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0, int arg5 = 0)
{
level.Lines[line].special = special;
level.Lines[line].args[0] = arg1;
level.Lines[line].args[1] = arg2;
level.Lines[line].args[2] = arg3;
level.Lines[line].args[3] = arg4;
level.Lines[line].args[4] = arg5;
}
protected void SetSectorSpecial(int sectornum, int special)
{
level.sectors[sectornum].special = special;
}
protected void SetSectorTextureID(int sectornum, int plane, TextureID texture)
{
level.sectors[sectornum].SetTexture(plane, texture);
}
protected void SetSectorTexture(int sectornum, int plane, String texture)
{
SetSectorTextureID(sectornum, plane, TexMan.CheckForTexture(texture, TexMan.Type_Flat));
}
protected void SetSectorLight(int sectornum, int newval)
{
level.sectors[sectornum].SetLightLevel(newval);
}
protected void SetWallYScale(int line, int side, int texpart, double scale)
{
level.lines[line].sidedef[side].SetTextureYScale(texpart, scale);
}
}

View file

@ -0,0 +1,80 @@
class LevelPostProcessor native play
{
protected void Apply(Name checksum, String mapname)
{
}
protected native void ClearSectorTags(int sector);
protected native void AddSectorTag(int sector, int tag);
protected native void ClearLineIDs(int line);
protected native void AddLineID(int line, int tag);
protected native void OffsetSectorPlane(int sector, int plane, double offset);
protected native void SetThingSkills(int thing, int skills);
protected native void SetThingXY(int thing, double x, double y);
protected native void SetThingZ(int thing, double z);
protected native void SetThingFlags(int thing, int flags);
protected native void SetVertex(uint vertex, double x, double y);
protected native void SetLineSectorRef(uint line, uint side, uint sector);
protected native Actor GetDefaultActor(Name actorclass);
protected void SetWallTexture(int line, int side, int texpart, String texture)
{
SetWallTextureID(line, side, texpart, TexMan.CheckForTexture(texture, TexMan.Type_Wall));
}
protected void SetWallTextureID(int line, int side, int texpart, TextureID texture)
{
level.Lines[line].sidedef[side].SetTexture(texpart, texture);
}
protected void SetLineFlags(int line, int setflags, int clearflags = 0)
{
level.Lines[line].flags = (level.Lines[line].flags & ~clearflags) | setflags;
}
protected void SetLineActivation(int line, int acttype)
{
level.Lines[line].activation = acttype;
}
protected void ClearLineSpecial(int line)
{
level.Lines[line].special = 0;
}
protected void SetLineSpecial(int line, int special, int arg1 = 0, int arg2 = 0, int arg3 = 0, int arg4 = 0, int arg5 = 0)
{
level.Lines[line].special = special;
level.Lines[line].args[0] = arg1;
level.Lines[line].args[1] = arg2;
level.Lines[line].args[2] = arg3;
level.Lines[line].args[3] = arg4;
level.Lines[line].args[4] = arg5;
}
protected void SetSectorSpecial(int sectornum, int special)
{
level.sectors[sectornum].special = special;
}
protected void SetSectorTextureID(int sectornum, int plane, TextureID texture)
{
level.sectors[sectornum].SetTexture(plane, texture);
}
protected void SetSectorTexture(int sectornum, int plane, String texture)
{
SetSectorTextureID(sectornum, plane, TexMan.CheckForTexture(texture, TexMan.Type_Flat));
}
protected void SetSectorLight(int sectornum, int newval)
{
level.sectors[sectornum].SetLightLevel(newval);
}
protected void SetWallYScale(int line, int side, int texpart, double scale)
{
level.lines[line].sidedef[side].SetTextureYScale(texpart, scale);
}
}