From f83444f3cceb7a59984a922d972b41b8301df812 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 14 Jan 2017 13:02:08 +0100 Subject: [PATCH] - exported the sound sequence interface to scripting. - split out the map data definitions from base.txt into their own file. --- src/s_sndseq.cpp | 107 +++++++- src/s_sndseq.h | 4 +- src/scripting/zscript/zcc_compile.cpp | 13 - wadsrc/static/zscript.txt | 2 + wadsrc/static/zscript/actor.txt | 4 + wadsrc/static/zscript/base.txt | 365 ------------------------- wadsrc/static/zscript/mapdata.txt | 369 ++++++++++++++++++++++++++ wadsrc/static/zscript/sounddata.txt | 18 ++ 8 files changed, 501 insertions(+), 381 deletions(-) create mode 100644 wadsrc/static/zscript/mapdata.txt create mode 100644 wadsrc/static/zscript/sounddata.txt diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index a8d2dc7d7..c8e1ef599 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -869,6 +869,16 @@ DSeqNode *SN_StartSequence (AActor *actor, int sequence, seqtype_t type, int mod return NULL; } +DEFINE_ACTION_FUNCTION(AActor, StartSoundSequenceID) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_INT(seq); + PARAM_INT(type); + PARAM_INT(modenum); + PARAM_BOOL_DEF(nostop); + ACTION_RETURN_POINTER(SN_StartSequence(self, seq, seqtype_t(type), modenum, nostop)); +} + DSeqNode *SN_StartSequence (sector_t *sector, int chan, int sequence, seqtype_t type, int modenum, bool nostop) { if (!nostop) @@ -882,6 +892,17 @@ DSeqNode *SN_StartSequence (sector_t *sector, int chan, int sequence, seqtype_t return NULL; } +DEFINE_ACTION_FUNCTION(_Sector, StartSoundSequenceID) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(chan); + PARAM_INT(seq); + PARAM_INT(type); + PARAM_INT(modenum); + PARAM_BOOL_DEF(nostop); + ACTION_RETURN_POINTER(SN_StartSequence(self, chan, seq, seqtype_t(type), modenum, nostop)); +} + DSeqNode *SN_StartSequence (FPolyObj *poly, int sequence, seqtype_t type, int modenum, bool nostop) { if (!nostop) @@ -921,6 +942,15 @@ DSeqNode *SN_StartSequence (AActor *actor, FName seqname, int modenum) return NULL; } +DEFINE_ACTION_FUNCTION(AActor, StartSoundSequence) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_NAME(seq); + PARAM_INT(modenum); + ACTION_RETURN_POINTER(SN_StartSequence(self, seq, modenum)); +} + + DSeqNode *SN_StartSequence (sector_t *sec, int chan, const char *seqname, int modenum) { int seqnum = FindSequence(seqname); @@ -941,6 +971,15 @@ DSeqNode *SN_StartSequence (sector_t *sec, int chan, FName seqname, int modenum) return NULL; } +DEFINE_ACTION_FUNCTION(_Sector, StartSoundSequence) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(chan); + PARAM_NAME(seq); + PARAM_INT(modenum); + ACTION_RETURN_POINTER(SN_StartSequence(self, chan, seq, modenum)); +} + DSeqNode *SN_StartSequence (FPolyObj *poly, const char *seqname, int modenum) { int seqnum = FindSequence(seqname); @@ -1001,6 +1040,13 @@ DSeqNode *SN_CheckSequence(sector_t *sector, int chan) return NULL; } +DEFINE_ACTION_FUNCTION(_Sector, CheckSoundSequence) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(chan); + ACTION_RETURN_POINTER(SN_CheckSequence(self, chan)); +} + //========================================================================== // // SN_StopSequence @@ -1012,6 +1058,13 @@ void SN_StopSequence (AActor *actor) SN_DoStop (actor); } +DEFINE_ACTION_FUNCTION(AActor, StopSoundSequence) +{ + PARAM_SELF_PROLOGUE(AActor); + SN_StopSequence(self); + return 0; +} + void SN_StopSequence (sector_t *sector, int chan) { DSeqNode *node = SN_CheckSequence(sector, chan); @@ -1021,6 +1074,15 @@ void SN_StopSequence (sector_t *sector, int chan) } } +DEFINE_ACTION_FUNCTION(_Sector, StopSoundSequence) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(chan); + SN_StopSequence(self, chan); + return 0; +} + + void SN_StopSequence (FPolyObj *poly) { SN_DoStop (poly); @@ -1090,6 +1152,13 @@ bool SN_IsMakingLoopingSound (sector_t *sector) return false; } +DEFINE_ACTION_FUNCTION(_Sector, IsMakingLoopingSound) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_BOOL(SN_IsMakingLoopingSound(self)); +} + + //========================================================================== // // SN_UpdateActiveSequences @@ -1325,6 +1394,15 @@ FName SN_GetSequenceSlot (int sequence, seqtype_t type) return NAME_None; } +DEFINE_ACTION_FUNCTION(DSeqNode, GetSequenceSlot) +{ + PARAM_PROLOGUE; + PARAM_INT(seq); + PARAM_INT(type); + ACTION_RETURN_INT(SN_GetSequenceSlot(seq, seqtype_t(type)).GetIndex()); +} + + //========================================================================== // // SN_MarkPrecacheSounds @@ -1351,6 +1429,16 @@ void SN_MarkPrecacheSounds(int sequence, seqtype_t type) } } +DEFINE_ACTION_FUNCTION(DSeqNode, MarkPrecacheSounds) +{ + PARAM_PROLOGUE; + PARAM_INT(seq); + PARAM_INT(type); + SN_MarkPrecacheSounds(seq, seqtype_t(type)); + return 0; +} + + //========================================================================== // // SN_ChangeNodeData @@ -1462,7 +1550,16 @@ bool SN_AreModesSame(int seqnum, seqtype_t type, int mode1, int mode2) return true; } -bool SN_AreModesSame(const char *name, int mode1, int mode2) +DEFINE_ACTION_FUNCTION(DSeqNode, AreModesSameID) +{ + PARAM_SELF_PROLOGUE(DSeqNode); + PARAM_INT(seqnum); + PARAM_INT(type); + PARAM_INT(mode); + ACTION_RETURN_BOOL(SN_AreModesSame(seqnum, seqtype_t(type), mode, self->GetModeNum())); +} + +bool SN_AreModesSame(FName name, int mode1, int mode2) { int seqnum = FindSequence(name); if (seqnum >= 0) @@ -1473,6 +1570,14 @@ bool SN_AreModesSame(const char *name, int mode1, int mode2) return true; } +DEFINE_ACTION_FUNCTION(DSeqNode, AreModesSame) +{ + PARAM_SELF_PROLOGUE(DSeqNode); + PARAM_NAME(seq); + PARAM_INT(mode); + ACTION_RETURN_BOOL(SN_AreModesSame(seq, mode, self->GetModeNum())); +} + //========================================================================== // // CCMD playsequence diff --git a/src/s_sndseq.h b/src/s_sndseq.h index 57e21caa1..a35fab026 100644 --- a/src/s_sndseq.h +++ b/src/s_sndseq.h @@ -20,7 +20,7 @@ class DSeqNode : public DObject DECLARE_CLASS (DSeqNode, DObject) HAS_OBJECT_POINTERS public: - void Serialize(FSerializer &arc); + void Serialize(FSerializer &arc) override; void StopAndDestroy (); void OnDestroy() override; void Tick (); @@ -91,7 +91,7 @@ void SN_StopSequence (AActor *mobj); void SN_StopSequence (sector_t *sector, int chan); void SN_StopSequence (FPolyObj *poly); bool SN_AreModesSame(int sequence, seqtype_t type, int mode1, int mode2); -bool SN_AreModesSame(const char *name, int mode1, int mode2); +bool SN_AreModesSame(FName name, int mode1, int mode2); void SN_UpdateActiveSequences (void); ptrdiff_t SN_GetSequenceOffset (int sequence, SDWORD *sequencePtr); void SN_DoStop (void *); diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 13a21eb88..817e28b24 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2306,19 +2306,6 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool unsigned vindex = ~0u; if (virtsym != nullptr) vindex = virtsym->Variants[0].Implementation->VirtualIndex; - if (vindex != ~0u || (varflags & VARF_Virtual)) - { - // Todo: Check if the declaration is legal. - - // First step: compare prototypes - if they do not match the virtual base method does not apply. - - // Second step: Check flags. Possible cases: - // 1. Base method is final: Error. - // 2. This method is override: Base virtual method must exist - // 3. This method is virtual but not override: Base may not have a virtual method with the same prototype. - } - - if (!(f->Flags & ZCC_Native)) { if (f->Body == nullptr) diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 199120f75..d18f42089 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -1,4 +1,6 @@ #include "zscript/base.txt" +#include "zscript/sounddata.txt" +#include "zscript/mapdata.txt" #include "zscript/dynarrays.txt" #include "zscript/constants.txt" #include "zscript/actor.txt" diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index b4c0395f1..9ad6db85c 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -420,6 +420,10 @@ class Actor : Thinker native native bool HitFriend(); native bool MonsterMove(); + native SeqNode StartSoundSequenceID (int sequence, int type, int modenum, bool nostop = false); + native SeqNode StartSoundSequence (Name seqname, int modenum); + native void StopSoundSequence(); + native void FindFloorCeiling(int flags = 0); native double, double GetFriction(); native bool, Actor TestMobjZ(bool quick = false); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 3a1576b0d..3c302cd6d 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -187,371 +187,6 @@ struct F3DFloor native { } -struct Vertex native -{ - native readonly Vector2 p; -} - -struct Side -{ - enum ETexpart - { - top=0, - mid=1, - bottom=2 - }; - - enum EWallFlags - { - WALLF_ABSLIGHTING = 1, // Light is absolute instead of relative - WALLF_NOAUTODECALS = 2, // Do not attach impact decals to this wall - WALLF_NOFAKECONTRAST = 4, // Don't do fake contrast for this wall in side_t::GetLightLevel - WALLF_SMOOTHLIGHTING = 8, // Similar to autocontrast but applies to all angles. - WALLF_CLIP_MIDTEX = 16, // Like the line counterpart, but only for this side. - WALLF_WRAP_MIDTEX = 32, // Like the line counterpart, but only for this side. - WALLF_POLYOBJ = 64, // This wall belongs to a polyobject. - WALLF_LIGHT_FOG = 128, // This wall's Light is used even in fog. - }; - - native Sector sector; // Sector the SideDef is facing. - //DBaseDecal* AttachedDecals; // [RH] Decals bound to the wall - native Line linedef; - native int16 Light; - native uint8 Flags; - - native TextureID GetTexture(int which); - native void SetTexture(int which, TextureID tex); - native void SetTextureXOffset(int which, double offset); - native double GetTextureXOffset(int which); - native void AddTextureXOffset(int which, double delta); - native void SetTextureYOffset(int which, double offset); - native double GetTextureYOffset(int which); - native void AddTextureYOffset(int which, double delta); - native void SetTextureXScale(int which, double scale); - native double GetTextureXScale(int which); - native void MultiplyTextureXScale(int which, double delta); - native void SetTextureYScale(int which, double scale); - native double GetTextureYScale(int which); - native void MultiplyTextureYScale(int which, double delta); - //native DInterpolation *SetInterpolation(int position); - //native void StopInterpolation(int position); - - native Vertex V1(); - native Vertex V2(); - - native int Index(); -}; - -struct Line native -{ - enum ELineFlags - { - ML_BLOCKING =0x00000001, // solid, is an obstacle - ML_BLOCKMONSTERS =0x00000002, // blocks monsters only - ML_TWOSIDED =0x00000004, // backside will not be present at all if not two sided - ML_DONTPEGTOP = 0x00000008, // upper texture unpegged - ML_DONTPEGBOTTOM = 0x00000010, // lower texture unpegged - ML_SECRET = 0x00000020, // don't map as two sided: IT'S A SECRET! - ML_SOUNDBLOCK = 0x00000040, // don't let sound cross two of these - ML_DONTDRAW = 0x00000080, // don't draw on the automap - ML_MAPPED = 0x00000100, // set if already drawn in automap - ML_REPEAT_SPECIAL = 0x00000200, // special is repeatable - ML_ADDTRANS = 0x00000400, // additive translucency (can only be set internally) - - // Extended flags - ML_MONSTERSCANACTIVATE = 0x00002000, // [RH] Monsters (as well as players) can activate the line - ML_BLOCK_PLAYERS = 0x00004000, - ML_BLOCKEVERYTHING = 0x00008000, // [RH] Line blocks everything - ML_ZONEBOUNDARY = 0x00010000, - ML_RAILING = 0x00020000, - ML_BLOCK_FLOATERS = 0x00040000, - ML_CLIP_MIDTEX = 0x00080000, // Automatic for every Strife line - ML_WRAP_MIDTEX = 0x00100000, - ML_3DMIDTEX = 0x00200000, - ML_CHECKSWITCHRANGE = 0x00400000, - ML_FIRSTSIDEONLY = 0x00800000, // activated only when crossed from front side - ML_BLOCKPROJECTILE = 0x01000000, - ML_BLOCKUSE = 0x02000000, // blocks all use actions through this line - ML_BLOCKSIGHT = 0x04000000, // blocks monster line of sight - ML_BLOCKHITSCAN = 0x08000000, // blocks hitscan attacks - ML_3DMIDTEX_IMPASS = 0x10000000, // [TP] if 3D midtex, behaves like a height-restricted ML_BLOCKING - }; - - - native readonly vertex v1, v2; // vertices, from v1 to v2 - native readonly Vector2 delta; // precalculated v2 - v1 for side checking - native uint flags; - native uint activation; // activation type - native int special; - native int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) - native double alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque) - //native Side sidedef[2]; - native readonly double bbox[4]; // bounding box, for the extent of the LineDef. - native readonly Sector frontsector, backsector; - native int validcount; // if == validcount, already checked - native int locknumber; // [Dusk] lock number for special - native readonly uint portalindex; - native readonly uint portaltransferred; - - native bool isLinePortal(); - native bool isVisualPortal(); - native Line getPortalDestination(); - native int getPortalAlignment(); - native int Index(); -} - -struct SecPlane native -{ - native Vector3 Normal; - native double D; - native double negiC; - - native bool isSlope(); - native int PointOnSide(Vector3 pos); - native double ZatPoint (Vector2 v); - native double ZatPointDist(Vector2 v, double dist); - native bool isEqual(Secplane other); - native void ChangeHeight(double hdiff); - native double GetChangedHeight(double hdiff); - native double HeightDiff(double oldd, double newd = 0.0); - native double PointToDist(Vector2 xy, double z); -} - -// This encapsulates all info Doom's original 'special' field contained - for saving and transferring. -struct SecSpecial -{ - Name damagetype; - int damageamount; - short special; - short damageinterval; - short leakydamage; - int Flags; -} - -struct Sector native -{ - //secplane_t floorplane, ceilingplane; // defined internally - //FDynamicColormap *ColorMap; - - native Actor SoundTarget; - - native int16 special; - native int16 lightlevel; - native int16 seqType; - - native int sky; - native Name SeqName; - - native readonly Vector2 centerspot; - native int validcount; - native Actor thinglist; - - native double friction, movefactor; - native int terrainnum[2]; - - // thinker_t for reversable actions - //SectorEffect floordata; - //SectorEffect ceilingdata; - //SectorEffect lightingdata; - - enum EPlane - { - floor, - ceiling - }; - - enum EInterpolationType - { - CeilingMove, - FloorMove, - CeilingScroll, - FloorScroll - }; - //Interpolation interpolations[4]; - - native uint8 soundtraversed; - native int8 stairlock; - native int prevsec; - native int nextsec; - - //TStaticPointedArray Lines; // this is defined internally to avoid exposing some overly complicated type to the parser - - native readonly Sector heightsec; - - native uint bottommap, midmap, topmap; - - //struct msecnode_t *touching_thinglist; - //struct msecnode_t *sectorportal_thinglist; - - native double gravity; - native Name damagetype; - native int damageamount; - native int16 damageinterval; - native int16 leakydamage; - - native readonly uint16 ZoneNumber; - - enum ESectorMoreFlags - { - SECMF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor - SECMF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes - SECMF_NOFAKELIGHT = 8, // heightsec does not change lighting - SECMF_IGNOREHEIGHTSEC= 16, // heightsec is only for triggering sector actions - SECMF_UNDERWATER = 32, // sector is underwater - SECMF_FORCEDUNDERWATER= 64, // sector is forced to be underwater - SECMF_UNDERWATERMASK = 32+64, - SECMF_DRAWN = 128, // sector has been drawn at least once - SECMF_HIDDEN = 256, // Do not draw on textured automap - } - native uint16 MoreFlags; - - enum ESectorFlags - { - SECF_SILENT = 1, // actors in sector make no noise - SECF_NOFALLINGDAMAGE= 2, // No falling damage in this sector - SECF_FLOORDROP = 4, // all actors standing on this floor will remain on it when it lowers very fast. - SECF_NORESPAWN = 8, // players can not respawn in this sector - SECF_FRICTION = 16, // sector has friction enabled - SECF_PUSH = 32, // pushers enabled - SECF_SILENTMOVE = 64, // Sector movement makes mo sound (Eternity got this so this may be useful for an extended cross-port standard.) - SECF_DMGTERRAINFX = 128, // spawns terrain splash when inflicting damage - SECF_ENDGODMODE = 256, // getting damaged by this sector ends god mode - SECF_ENDLEVEL = 512, // ends level when health goes below 10 - SECF_HAZARD = 1024, // Change to Strife's delayed damage handling. - - SECF_WASSECRET = 1 << 30, // a secret that was discovered - SECF_SECRET = 1 << 31, // a secret sector - - SECF_DAMAGEFLAGS = SECF_ENDGODMODE|SECF_ENDLEVEL|SECF_DMGTERRAINFX|SECF_HAZARD, - SECF_NOMODIFY = SECF_SECRET|SECF_WASSECRET, // not modifiable by Sector_ChangeFlags - SECF_SPECIALFLAGS = SECF_DAMAGEFLAGS|SECF_FRICTION|SECF_PUSH, // these flags originate from 'special and must be transferrable by floor thinkers - } - - enum EMoveResult - { - MOVE_OK, - MOVE_CRUSHED, - MOVE_PASTDEST - }; - - native uint Flags; - - native SectorAction SecActTarget; - - native readonly uint Portals[2]; - native readonly int PortalGroup; - - native readonly int sectornum; - - native int Index(); - - native double, Sector, F3DFloor NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0); - native double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0); - - native void RemoveForceField(); - native static Sector PointInSector(Vector2 pt); - native void SetColor(color c, int desat = 0); - native void SetFade(color c); - - native bool PlaneMoving(int pos); - native int GetFloorLight(); - native int GetCeilingLight(); - native Sector GetHeightSec(); - native void TransferSpecial(Sector model); - native void GetSpecial(out SecSpecial spec); - native void SetSpecial( SecSpecial spec); - native int GetTerrain(int pos); - native void CheckPortalPlane(int plane); - native double, Sector HighestCeilingAt(Vector2 a); - native double, Sector LowestFloorAt(Vector2 a); - native double, double GetFriction(int plane); - - native void SetXOffset(int pos, double o); - native void AddXOffset(int pos, double o); - native double GetXOffset(int pos); - native void SetYOffset(int pos, double o); - native void AddYOffset(int pos, double o); - native double GetYOffset(int pos, bool addbase = true); - native void SetXScale(int pos, double o); - native double GetXScale(int pos); - native void SetYScale(int pos, double o); - native double GetYScale(int pos); - native void SetAngle(int pos, double o); - native double GetAngle(int pos, bool addbase = true); - native void SetBase(int pos, double y, double o); - native void SetAlpha(int pos, double o); - native double GetAlpha(int pos); - native int GetFlags(int pos); - native int GetVisFlags(int pos); - native void ChangeFlags(int pos, int And, int Or); - native int GetPlaneLight(int pos); - native void SetPlaneLight(int pos, int level); - native TextureID GetTexture(int pos); - native void SetTexture(int pos, TextureID tex, bool floorclip = true); - native double GetPlaneTexZ(int pos); - native void SetPlaneTexZ(int pos, double val, bool dirtify = false); // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. - native void ChangeLightLevel(int newval); - native void SetLightLevel(int newval); - native int GetLightLevel(); - native void AdjustFloorClip(); - native bool IsLinked(Sector other, bool ceiling); - - native bool PortalBlocksView(int plane); - native bool PortalBlocksSight(int plane); - native bool PortalBlocksMovement(int plane); - native bool PortalBlocksSound(int plane); - native bool PortalIsLinked(int plane); - native void ClearPortal(int plane); - native double GetPortalPlaneZ(int plane); - native Vector2 GetPortalDisplacement(int plane); - native int GetPortalType(int plane); - native int GetOppositePortalGroup(int plane); - native double CenterFloor(); - native double CenterCeiling(); - native bool TriggerSectorActions(Actor thing, int activation); - - native int MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false); - native int MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush); - - native Sector NextSpecialSector(int type, Sector prev); - native double, Vertex FindLowestFloorSurrounding(); - native double, Vertex FindHighestFloorSurrounding(); - native double, Vertex FindNextHighestFloor(); - native double, Vertex FindNextLowestFloor(); - native double, Vertex FindLowestCeilingSurrounding(); - native double, Vertex FindHighestCeilingSurrounding(); - native double, Vertex FindNextLowestCeiling(); - native double, Vertex FindNextHighestCeiling(); - - native double FindShortestTextureAround(); - native double FindShortestUpperAround(); - native Sector FindModelFloorSector(double floordestheight); - native Sector FindModelCeilingSector(double floordestheight); - native int FindMinSurroundingLight(int max); - native double, Vertex FindLowestCeilingPoint(); - native double, Vertex FindHighestFloorPoint(); - - native void SetEnvironment(String env); - native void SetEnvironmentID(int envnum); - - bool isSecret() - { - return !!(Flags & SECF_SECRET); - } - - bool wasSecret() - { - return !!(Flags & SECF_WASSECRET); - } - - void ClearSecret() - { - Flags &= ~SECF_SECRET; - } - - -} - struct Wads { enum WadNamespace diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt new file mode 100644 index 000000000..9d352e5fb --- /dev/null +++ b/wadsrc/static/zscript/mapdata.txt @@ -0,0 +1,369 @@ + +struct Vertex native +{ + native readonly Vector2 p; +} + +struct Side +{ + enum ETexpart + { + top=0, + mid=1, + bottom=2 + }; + + enum EWallFlags + { + WALLF_ABSLIGHTING = 1, // Light is absolute instead of relative + WALLF_NOAUTODECALS = 2, // Do not attach impact decals to this wall + WALLF_NOFAKECONTRAST = 4, // Don't do fake contrast for this wall in side_t::GetLightLevel + WALLF_SMOOTHLIGHTING = 8, // Similar to autocontrast but applies to all angles. + WALLF_CLIP_MIDTEX = 16, // Like the line counterpart, but only for this side. + WALLF_WRAP_MIDTEX = 32, // Like the line counterpart, but only for this side. + WALLF_POLYOBJ = 64, // This wall belongs to a polyobject. + WALLF_LIGHT_FOG = 128, // This wall's Light is used even in fog. + }; + + native Sector sector; // Sector the SideDef is facing. + //DBaseDecal* AttachedDecals; // [RH] Decals bound to the wall + native Line linedef; + native int16 Light; + native uint8 Flags; + + native TextureID GetTexture(int which); + native void SetTexture(int which, TextureID tex); + native void SetTextureXOffset(int which, double offset); + native double GetTextureXOffset(int which); + native void AddTextureXOffset(int which, double delta); + native void SetTextureYOffset(int which, double offset); + native double GetTextureYOffset(int which); + native void AddTextureYOffset(int which, double delta); + native void SetTextureXScale(int which, double scale); + native double GetTextureXScale(int which); + native void MultiplyTextureXScale(int which, double delta); + native void SetTextureYScale(int which, double scale); + native double GetTextureYScale(int which); + native void MultiplyTextureYScale(int which, double delta); + //native DInterpolation *SetInterpolation(int position); + //native void StopInterpolation(int position); + + native Vertex V1(); + native Vertex V2(); + + native int Index(); +}; + +struct Line native +{ + enum ELineFlags + { + ML_BLOCKING =0x00000001, // solid, is an obstacle + ML_BLOCKMONSTERS =0x00000002, // blocks monsters only + ML_TWOSIDED =0x00000004, // backside will not be present at all if not two sided + ML_DONTPEGTOP = 0x00000008, // upper texture unpegged + ML_DONTPEGBOTTOM = 0x00000010, // lower texture unpegged + ML_SECRET = 0x00000020, // don't map as two sided: IT'S A SECRET! + ML_SOUNDBLOCK = 0x00000040, // don't let sound cross two of these + ML_DONTDRAW = 0x00000080, // don't draw on the automap + ML_MAPPED = 0x00000100, // set if already drawn in automap + ML_REPEAT_SPECIAL = 0x00000200, // special is repeatable + ML_ADDTRANS = 0x00000400, // additive translucency (can only be set internally) + + // Extended flags + ML_MONSTERSCANACTIVATE = 0x00002000, // [RH] Monsters (as well as players) can activate the line + ML_BLOCK_PLAYERS = 0x00004000, + ML_BLOCKEVERYTHING = 0x00008000, // [RH] Line blocks everything + ML_ZONEBOUNDARY = 0x00010000, + ML_RAILING = 0x00020000, + ML_BLOCK_FLOATERS = 0x00040000, + ML_CLIP_MIDTEX = 0x00080000, // Automatic for every Strife line + ML_WRAP_MIDTEX = 0x00100000, + ML_3DMIDTEX = 0x00200000, + ML_CHECKSWITCHRANGE = 0x00400000, + ML_FIRSTSIDEONLY = 0x00800000, // activated only when crossed from front side + ML_BLOCKPROJECTILE = 0x01000000, + ML_BLOCKUSE = 0x02000000, // blocks all use actions through this line + ML_BLOCKSIGHT = 0x04000000, // blocks monster line of sight + ML_BLOCKHITSCAN = 0x08000000, // blocks hitscan attacks + ML_3DMIDTEX_IMPASS = 0x10000000, // [TP] if 3D midtex, behaves like a height-restricted ML_BLOCKING + }; + + + native readonly vertex v1, v2; // vertices, from v1 to v2 + native readonly Vector2 delta; // precalculated v2 - v1 for side checking + native uint flags; + native uint activation; // activation type + native int special; + native int args[5]; // <--- hexen-style arguments (expanded to ZDoom's full width) + native double alpha; // <--- translucency (0=invisibile, FRACUNIT=opaque) + //native Side sidedef[2]; + native readonly double bbox[4]; // bounding box, for the extent of the LineDef. + native readonly Sector frontsector, backsector; + native int validcount; // if == validcount, already checked + native int locknumber; // [Dusk] lock number for special + native readonly uint portalindex; + native readonly uint portaltransferred; + + native bool isLinePortal(); + native bool isVisualPortal(); + native Line getPortalDestination(); + native int getPortalAlignment(); + native int Index(); +} + +struct SecPlane native +{ + native Vector3 Normal; + native double D; + native double negiC; + + native bool isSlope(); + native int PointOnSide(Vector3 pos); + native double ZatPoint (Vector2 v); + native double ZatPointDist(Vector2 v, double dist); + native bool isEqual(Secplane other); + native void ChangeHeight(double hdiff); + native double GetChangedHeight(double hdiff); + native double HeightDiff(double oldd, double newd = 0.0); + native double PointToDist(Vector2 xy, double z); +} + +// This encapsulates all info Doom's original 'special' field contained - for saving and transferring. +struct SecSpecial +{ + Name damagetype; + int damageamount; + short special; + short damageinterval; + short leakydamage; + int Flags; +} + +struct Sector native +{ + //secplane_t floorplane, ceilingplane; // defined internally + //FDynamicColormap *ColorMap; + + native Actor SoundTarget; + + native int16 special; + native int16 lightlevel; + native int16 seqType; + + native int sky; + native Name SeqName; + + native readonly Vector2 centerspot; + native int validcount; + native Actor thinglist; + + native double friction, movefactor; + native int terrainnum[2]; + + // thinker_t for reversable actions + //SectorEffect floordata; + //SectorEffect ceilingdata; + //SectorEffect lightingdata; + + enum EPlane + { + floor, + ceiling + }; + + enum EInterpolationType + { + CeilingMove, + FloorMove, + CeilingScroll, + FloorScroll + }; + //Interpolation interpolations[4]; + + native uint8 soundtraversed; + native int8 stairlock; + native int prevsec; + native int nextsec; + + //TStaticPointedArray Lines; // this is defined internally to avoid exposing some overly complicated type to the parser + + native readonly Sector heightsec; + + native uint bottommap, midmap, topmap; + + //struct msecnode_t *touching_thinglist; + //struct msecnode_t *sectorportal_thinglist; + + native double gravity; + native Name damagetype; + native int damageamount; + native int16 damageinterval; + native int16 leakydamage; + + native readonly uint16 ZoneNumber; + + enum ESectorMoreFlags + { + SECMF_FAKEFLOORONLY = 2, // when used as heightsec in R_FakeFlat, only copies floor + SECMF_CLIPFAKEPLANES = 4, // as a heightsec, clip planes to target sector's planes + SECMF_NOFAKELIGHT = 8, // heightsec does not change lighting + SECMF_IGNOREHEIGHTSEC= 16, // heightsec is only for triggering sector actions + SECMF_UNDERWATER = 32, // sector is underwater + SECMF_FORCEDUNDERWATER= 64, // sector is forced to be underwater + SECMF_UNDERWATERMASK = 32+64, + SECMF_DRAWN = 128, // sector has been drawn at least once + SECMF_HIDDEN = 256, // Do not draw on textured automap + } + native uint16 MoreFlags; + + enum ESectorFlags + { + SECF_SILENT = 1, // actors in sector make no noise + SECF_NOFALLINGDAMAGE= 2, // No falling damage in this sector + SECF_FLOORDROP = 4, // all actors standing on this floor will remain on it when it lowers very fast. + SECF_NORESPAWN = 8, // players can not respawn in this sector + SECF_FRICTION = 16, // sector has friction enabled + SECF_PUSH = 32, // pushers enabled + SECF_SILENTMOVE = 64, // Sector movement makes mo sound (Eternity got this so this may be useful for an extended cross-port standard.) + SECF_DMGTERRAINFX = 128, // spawns terrain splash when inflicting damage + SECF_ENDGODMODE = 256, // getting damaged by this sector ends god mode + SECF_ENDLEVEL = 512, // ends level when health goes below 10 + SECF_HAZARD = 1024, // Change to Strife's delayed damage handling. + + SECF_WASSECRET = 1 << 30, // a secret that was discovered + SECF_SECRET = 1 << 31, // a secret sector + + SECF_DAMAGEFLAGS = SECF_ENDGODMODE|SECF_ENDLEVEL|SECF_DMGTERRAINFX|SECF_HAZARD, + SECF_NOMODIFY = SECF_SECRET|SECF_WASSECRET, // not modifiable by Sector_ChangeFlags + SECF_SPECIALFLAGS = SECF_DAMAGEFLAGS|SECF_FRICTION|SECF_PUSH, // these flags originate from 'special and must be transferrable by floor thinkers + } + + enum EMoveResult + { + MOVE_OK, + MOVE_CRUSHED, + MOVE_PASTDEST + }; + + native uint Flags; + + native SectorAction SecActTarget; + + native readonly uint Portals[2]; + native readonly int PortalGroup; + + native readonly int sectornum; + + native int Index(); + + native double, Sector, F3DFloor NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0); + native double, Sector, F3DFloor NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0); + + native void RemoveForceField(); + native static Sector PointInSector(Vector2 pt); + native void SetColor(color c, int desat = 0); + native void SetFade(color c); + + native bool PlaneMoving(int pos); + native int GetFloorLight(); + native int GetCeilingLight(); + native Sector GetHeightSec(); + native void TransferSpecial(Sector model); + native void GetSpecial(out SecSpecial spec); + native void SetSpecial( SecSpecial spec); + native int GetTerrain(int pos); + native void CheckPortalPlane(int plane); + native double, Sector HighestCeilingAt(Vector2 a); + native double, Sector LowestFloorAt(Vector2 a); + native double, double GetFriction(int plane); + + native void SetXOffset(int pos, double o); + native void AddXOffset(int pos, double o); + native double GetXOffset(int pos); + native void SetYOffset(int pos, double o); + native void AddYOffset(int pos, double o); + native double GetYOffset(int pos, bool addbase = true); + native void SetXScale(int pos, double o); + native double GetXScale(int pos); + native void SetYScale(int pos, double o); + native double GetYScale(int pos); + native void SetAngle(int pos, double o); + native double GetAngle(int pos, bool addbase = true); + native void SetBase(int pos, double y, double o); + native void SetAlpha(int pos, double o); + native double GetAlpha(int pos); + native int GetFlags(int pos); + native int GetVisFlags(int pos); + native void ChangeFlags(int pos, int And, int Or); + native int GetPlaneLight(int pos); + native void SetPlaneLight(int pos, int level); + native TextureID GetTexture(int pos); + native void SetTexture(int pos, TextureID tex, bool floorclip = true); + native double GetPlaneTexZ(int pos); + native void SetPlaneTexZ(int pos, double val, bool dirtify = false); // This mainly gets used by init code. The only place where it must set the vertex to dirty is the interpolation code. + native void ChangeLightLevel(int newval); + native void SetLightLevel(int newval); + native int GetLightLevel(); + native void AdjustFloorClip(); + native bool IsLinked(Sector other, bool ceiling); + + native bool PortalBlocksView(int plane); + native bool PortalBlocksSight(int plane); + native bool PortalBlocksMovement(int plane); + native bool PortalBlocksSound(int plane); + native bool PortalIsLinked(int plane); + native void ClearPortal(int plane); + native double GetPortalPlaneZ(int plane); + native Vector2 GetPortalDisplacement(int plane); + native int GetPortalType(int plane); + native int GetOppositePortalGroup(int plane); + native double CenterFloor(); + native double CenterCeiling(); + native bool TriggerSectorActions(Actor thing, int activation); + + native int MoveFloor(double speed, double dest, int crush, int direction, bool hexencrush, bool instant = false); + native int MoveCeiling(double speed, double dest, int crush, int direction, bool hexencrush); + + native Sector NextSpecialSector(int type, Sector prev); + native double, Vertex FindLowestFloorSurrounding(); + native double, Vertex FindHighestFloorSurrounding(); + native double, Vertex FindNextHighestFloor(); + native double, Vertex FindNextLowestFloor(); + native double, Vertex FindLowestCeilingSurrounding(); + native double, Vertex FindHighestCeilingSurrounding(); + native double, Vertex FindNextLowestCeiling(); + native double, Vertex FindNextHighestCeiling(); + + native double FindShortestTextureAround(); + native double FindShortestUpperAround(); + native Sector FindModelFloorSector(double floordestheight); + native Sector FindModelCeilingSector(double floordestheight); + native int FindMinSurroundingLight(int max); + native double, Vertex FindLowestCeilingPoint(); + native double, Vertex FindHighestFloorPoint(); + + native void SetEnvironment(String env); + native void SetEnvironmentID(int envnum); + + native SeqNode StartSoundSequenceID (int chan, int sequence, int type, int modenum, bool nostop = false); + native SeqNode StartSoundSequence (int chan, Name seqname, int modenum); + native SeqNode CheckSoundSequence (int chan); + native void StopSoundSequence(int chan); + native bool IsMakingLoopingSound (); + + bool isSecret() + { + return !!(Flags & SECF_SECRET); + } + + bool wasSecret() + { + return !!(Flags & SECF_WASSECRET); + } + + void ClearSecret() + { + Flags &= ~SECF_SECRET; + } +} diff --git a/wadsrc/static/zscript/sounddata.txt b/wadsrc/static/zscript/sounddata.txt new file mode 100644 index 000000000..3aff17c4c --- /dev/null +++ b/wadsrc/static/zscript/sounddata.txt @@ -0,0 +1,18 @@ + +class SeqNode native +{ + enum ESeqType + { + PLATFORM, + DOOR, + ENVIRONMENT, + NUMSEQTYPES, + NOTRANS + }; + + native bool AreModesSameID(int sequence, int type, int mode1); + native bool AreModesSame(Name name, int mode1); + native static Name GetSequenceSlot (int sequence, int type); + native static void MarkPrecacheSounds(int sequence, int type); +} +