From dc16c1d44ea2ddd68249a26b4184f4f6e539d92f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Nov 2018 11:34:50 +0100 Subject: [PATCH] - moved VM thunks from p_sectors.cpp to a separate file and started adding direct native implementations. For a few larger functions I took them out of sector_t and made them global functions to avoid creating more unnecessary stubs. --- src/CMakeLists.txt | 1 + src/p_ceiling.cpp | 8 +- src/p_floor.cpp | 12 +- src/p_sectors.cpp | 861 +---------------------------------- src/r_defs.h | 10 +- src/scripting/vmthunks.cpp | 898 +++++++++++++++++++++++++++++++++++++ 6 files changed, 926 insertions(+), 864 deletions(-) create mode 100644 src/scripting/vmthunks.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c8e62c3a4..7d63575de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1149,6 +1149,7 @@ set (PCH_SOURCES r_data/models/models_ue1.cpp r_data/models/models_obj.cpp scripting/symbols.cpp + scripting/vmthunks.cpp scripting/types.cpp scripting/thingdef.cpp scripting/thingdef_data.cpp diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 02448f07c..c7f975302 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -368,13 +368,13 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t break; case DCeiling::ceilLowerByTexture: - targheight = sec->ceilingplane.ZatPoint (spot) - sec->FindShortestUpperAround (); + targheight = sec->ceilingplane.ZatPoint (spot) - FindShortestUpperAround (sec); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = -1; break; case DCeiling::ceilRaiseByTexture: - targheight = sec->ceilingplane.ZatPoint (spot) + sec->FindShortestUpperAround (); + targheight = sec->ceilingplane.ZatPoint (spot) + FindShortestUpperAround (sec); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_Direction = 1; break; @@ -420,8 +420,8 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t type == DCeiling::ceilRaiseToFloor || /*type == ceilLowerToHighest ||*/ type == DCeiling::ceilLowerToFloor) ? - sec->FindModelFloorSector (targheight) : - sec->FindModelCeilingSector (targheight); + FindModelFloorSector(sec, targheight) : + FindModelCeilingSector(sec, targheight); if (modelsec != NULL) { ceiling->m_Texture = modelsec->GetTexture(sector_t::ceiling); diff --git a/src/p_floor.cpp b/src/p_floor.cpp index f9d72c57a..305d75019 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -392,7 +392,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, case DFloor::floorLowerByTexture: floor->m_Direction = -1; - newheight = sec->CenterFloor() - sec->FindShortestTextureAround(); + newheight = sec->CenterFloor() - FindShortestTextureAround(sec); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); break; @@ -409,7 +409,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, // since the code is identical to what was here. (Oddly // enough, BOOM preserved the code here even though it // also had this function.) - newheight = sec->CenterFloor() + sec->FindShortestTextureAround(); + newheight = sec->CenterFloor() + FindShortestTextureAround(sec); floor->m_FloorDestDist = sec->floorplane.PointToDist(sec->centerspot, newheight); break; @@ -440,7 +440,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, //jff 5/23/98 use model subroutine to unify fixes and handling sector_t *modelsec; - modelsec = sec->FindModelFloorSector(newheight); + modelsec = FindModelFloorSector(sec, newheight); if (modelsec != NULL) { floor->m_Texture = modelsec->GetTexture(sector_t::floor); @@ -485,8 +485,8 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line, floortype == DFloor::floorLowerToLowestCeiling || floortype == DFloor::floorRaiseToCeiling || floortype == DFloor::floorLowerToCeiling) ? - sec->FindModelCeilingSector(-floor->m_FloorDestDist) : - sec->FindModelFloorSector(-floor->m_FloorDestDist); + FindModelCeilingSector(sec, -floor->m_FloorDestDist) : + FindModelFloorSector(sec, -floor->m_FloorDestDist); if (modelsec != NULL) { @@ -1126,7 +1126,7 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag) } break; case numChangeOnly: - secm = sec->FindModelFloorSector (sec->CenterFloor()); + secm = FindModelFloorSector(sec, sec->CenterFloor()); if (secm) { // if no model, no change sec->SetTexture(sector_t::floor, secm->GetTexture(sector_t::floor)); diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 1ed2c78d6..eef699dbe 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -571,11 +571,11 @@ static inline void CheckShortestTex (FTextureID texnum, double &minsize) } } -double sector_t::FindShortestTextureAround () const +double FindShortestTextureAround (sector_t *sec) { double minsize = FLT_MAX; - for (auto check : Lines) + for (auto check : sec->Lines) { if (check->flags & ML_TWOSIDED) { @@ -586,14 +586,6 @@ double sector_t::FindShortestTextureAround () const return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight(); } -DEFINE_ACTION_FUNCTION(_Sector, FindShortestTextureAround) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - double h = self->FindShortestTextureAround(); - ACTION_RETURN_FLOAT(h); -} - - // // P_FindShortestUpperAround() // @@ -604,11 +596,11 @@ DEFINE_ACTION_FUNCTION(_Sector, FindShortestTextureAround) // // jff 03/20/98 Add routine to find shortest upper texture // -double sector_t::FindShortestUpperAround () const +double FindShortestUpperAround (sector_t *sec) { double minsize = FLT_MAX; - for (auto check : Lines) + for (auto check : sec->Lines) { if (check->flags & ML_TWOSIDED) { @@ -619,13 +611,6 @@ double sector_t::FindShortestUpperAround () const return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight(); } -DEFINE_ACTION_FUNCTION(_Sector, FindShortestUpperAround) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - double h = self->FindShortestUpperAround(); - ACTION_RETURN_FLOAT(h); -} - // // P_FindModelFloorSector() // @@ -640,13 +625,13 @@ DEFINE_ACTION_FUNCTION(_Sector, FindShortestUpperAround) // jff 3/14/98 change first parameter to plain height to allow call // from routine not using floormove_t // -sector_t *sector_t::FindModelFloorSector (double floordestheight) const +sector_t *FindModelFloorSector (sector_t *sect, double floordestheight) { sector_t *sec; - for (auto check : Lines) + for (auto check : sect->Lines) { - sec = getNextSector (check, this); + sec = getNextSector (check, sect); if (sec != NULL && (sec->floorplane.ZatPoint(check->v1) == floordestheight || sec->floorplane.ZatPoint(check->v2) == floordestheight)) @@ -657,15 +642,6 @@ sector_t *sector_t::FindModelFloorSector (double floordestheight) const return NULL; } -DEFINE_ACTION_FUNCTION(_Sector, FindModelFloorSector) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_FLOAT(fdh); - auto h = self->FindModelFloorSector(fdh); - ACTION_RETURN_POINTER(h); -} - - // // P_FindModelCeilingSector() // @@ -681,13 +657,13 @@ DEFINE_ACTION_FUNCTION(_Sector, FindModelFloorSector) // jff 3/14/98 change first parameter to plain height to allow call // from routine not using ceiling_t // -sector_t *sector_t::FindModelCeilingSector (double floordestheight) const +sector_t *FindModelCeilingSector (sector_t *sect, double floordestheight) { sector_t *sec; - for (auto check : Lines) + for (auto check : sect->Lines) { - sec = getNextSector (check, this); + sec = getNextSector (check, sect); if (sec != NULL && (sec->ceilingplane.ZatPoint(check->v1) == floordestheight || sec->ceilingplane.ZatPoint(check->v2) == floordestheight)) @@ -698,14 +674,6 @@ sector_t *sector_t::FindModelCeilingSector (double floordestheight) const return NULL; } -DEFINE_ACTION_FUNCTION(_Sector, FindModelCeilingSector) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_FLOAT(fdh); - auto h = self->FindModelCeilingSector(fdh); - ACTION_RETURN_POINTER(h); -} - // // Find minimum light from an adjacent sector // @@ -842,17 +810,6 @@ void sector_t::SetColor(int r, int g, int b, int desat) P_RecalculateAttachedLights(this); } -DEFINE_ACTION_FUNCTION(_Sector, SetColor) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_COLOR(color); - PARAM_INT(desat); - self->Colormap.LightColor.SetRGB(color); - self->Colormap.Desaturation = desat; - P_RecalculateAttachedLights(self); - return 0; -} - //===================================================================================== // // @@ -864,33 +821,11 @@ void sector_t::SetFade(int r, int g, int b) P_RecalculateAttachedLights(this); } -DEFINE_ACTION_FUNCTION(_Sector, SetFade) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_COLOR(fade); - self->Colormap.FadeColor.SetRGB(fade); - P_RecalculateAttachedLights(self); - return 0; -} - //===================================================================================== // // //===================================================================================== -DEFINE_ACTION_FUNCTION(_Sector, SetSpecialColor) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(num); - PARAM_COLOR(color); - if (num >= 0 && num < 5) - { - color.a = 255; - self->SetSpecialColor(num, color); - } - return 0; -} - //===================================================================================== // // @@ -901,14 +836,6 @@ void sector_t::SetFogDensity(int dens) Colormap.FogDensity = dens; } -DEFINE_ACTION_FUNCTION(_Sector, SetFogDensity) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(dens); - self->Colormap.FogDensity = dens; - return 0; -} - //=========================================================================== // // sector_t :: ClosestPoint @@ -985,13 +912,6 @@ bool sector_t::PlaneMoving(int pos) return (ceilingdata != NULL || (planes[ceiling].Flags & PLANEF_BLOCKED)); } -DEFINE_ACTION_FUNCTION(_Sector, PlaneMoving) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_BOOL(self->PlaneMoving(pos)); -} - //===================================================================================== // // @@ -1009,12 +929,6 @@ int sector_t::GetFloorLight () const } } -DEFINE_ACTION_FUNCTION(_Sector, GetFloorLight) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - ACTION_RETURN_INT(self->GetFloorLight()); -} - //===================================================================================== // // @@ -1032,12 +946,6 @@ int sector_t::GetCeilingLight () const } } -DEFINE_ACTION_FUNCTION(_Sector, GetCeilingLight) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - ACTION_RETURN_INT(self->GetCeilingLight()); -} - //===================================================================================== // // @@ -1057,17 +965,6 @@ FSectorPortal *sector_t::ValidatePortal(int which) // //===================================================================================== -DEFINE_ACTION_FUNCTION(_Sector, GetHeightSec) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - ACTION_RETURN_POINTER(self->GetHeightSec()); -} - -//===================================================================================== -// -// -//===================================================================================== - void sector_t::GetSpecial(secspecial_t *spec) { spec->special = special; @@ -1078,14 +975,6 @@ void sector_t::GetSpecial(secspecial_t *spec) spec->Flags = Flags & SECF_SPECIALFLAGS; } -DEFINE_ACTION_FUNCTION(_Sector, GetSpecial) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_POINTER(spec, secspecial_t); - self->GetSpecial(spec); - return 0; -} - //===================================================================================== // // @@ -1101,15 +990,6 @@ void sector_t::SetSpecial(const secspecial_t *spec) Flags = (Flags & ~SECF_SPECIALFLAGS) | (spec->Flags & SECF_SPECIALFLAGS); } -DEFINE_ACTION_FUNCTION(_Sector, SetSpecial) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_POINTER(spec, secspecial_t); - self->SetSpecial(spec); - return 0; -} - - //===================================================================================== // // @@ -1125,14 +1005,6 @@ void sector_t::TransferSpecial(sector_t *model) Flags = (Flags&~SECF_SPECIALFLAGS) | (model->Flags & SECF_SPECIALFLAGS); } -DEFINE_ACTION_FUNCTION(_Sector, TransferSpecial) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_POINTER(spec, sector_t); - self->TransferSpecial(spec); - return 0; -} - //===================================================================================== // // @@ -1143,14 +1015,7 @@ int sector_t::GetTerrain(int pos) const return terrainnum[pos] >= 0 ? terrainnum[pos] : TerrainTypes[GetTexture(pos)]; } -DEFINE_ACTION_FUNCTION(_Sector, GetTerrain) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetTerrain(pos)); -} - -//===================================================================================== + //===================================================================================== // // //===================================================================================== @@ -1166,14 +1031,6 @@ void sector_t::CheckPortalPlane(int plane) } } -DEFINE_ACTION_FUNCTION(_Sector, CheckPortalPlane) -{ - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(plane); - self->CheckPortalPlane(plane); - return 0; -} - //=========================================================================== // // Finds the highest ceiling at the given position, all portals considered @@ -1457,13 +1314,6 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt) } } - DEFINE_ACTION_FUNCTION(_Sector, RemoveForceField) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - self->RemoveForceField(); - return 0; - } - //=========================================================================== // // phares 3/12/98: End of friction effects @@ -1483,14 +1333,6 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt) } } - DEFINE_ACTION_FUNCTION(_Sector, AdjustFloorClip) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - self->AdjustFloorClip(); - return 0; - } - - //========================================================================== // // Checks whether a sprite should be affected by a glow @@ -1662,594 +1504,6 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt) } } - //=========================================================================== - // - // - // - //=========================================================================== - - DEFINE_ACTION_FUNCTION(_Sector, PointInSector) - { - PARAM_PROLOGUE; - PARAM_FLOAT(x); - PARAM_FLOAT(y); - ACTION_RETURN_POINTER(P_PointInSector(x, y)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->SetXOffset(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, AddXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->AddXOffset(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetXOffset(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetYOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->SetXOffset(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, AddYOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->AddXOffset(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetYOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_BOOL(addbase); - ACTION_RETURN_FLOAT(self->GetYOffset(pos, addbase)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetXScale) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->SetXScale(pos, o); - return 0; - } - - - DEFINE_ACTION_FUNCTION(_Sector, GetXScale) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetXScale(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetYScale) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->SetYScale(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetYScale) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetYScale(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetAngle) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_ANGLE(o); - self->SetAngle(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetAngle) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_BOOL(addbase); - ACTION_RETURN_FLOAT(self->GetAngle(pos, addbase).Degrees); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetBase) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - PARAM_ANGLE(a); - self->SetBase(pos, o, a); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, SetAlpha) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->SetAlpha(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetAlpha) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetAlpha(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, GetFlags) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetFlags(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, GetVisFlags) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetVisFlags(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, ChangeFlags) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_INT(a); - PARAM_INT(o); - self->ChangeFlags(pos, a, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, SetPlaneLight) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_INT(o); - self->SetPlaneLight(pos, o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetPlaneLight) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetPlaneLight(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetTexture) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_INT(o); - PARAM_BOOL(adj); - self->SetTexture(pos, FSetTextureID(o), adj); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetTexture) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetTexture(pos).GetIndex()); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetPlaneTexZ) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - PARAM_BOOL(dirty); - self->SetPlaneTexZ(pos, o, true); // not setting 'dirty' here is a guaranteed cause for problems. - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetPlaneTexZ) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetPlaneTexZ(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetLightLevel) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(o); - self->SetLightLevel(o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, ChangeLightLevel) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(o); - self->ChangeLightLevel(o); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetLightLevel) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - ACTION_RETURN_INT(self->GetLightLevel()); - } - - DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksView) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_BOOL(self->PortalBlocksView(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksSight) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_BOOL(self->PortalBlocksSight(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksMovement) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_BOOL(self->PortalBlocksMovement(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksSound) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_BOOL(self->PortalBlocksSound(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, PortalIsLinked) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_BOOL(self->PortalIsLinked(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, ClearPortal) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - self->ClearPortal(pos); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetPortalPlaneZ) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetPortalPlaneZ(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, GetPortalDisplacement) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_VEC2(self->GetPortalDisplacement(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, GetPortalType) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetPortalType(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, GetOppositePortalGroup) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetOppositePortalGroup(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, CenterFloor) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - ACTION_RETURN_FLOAT(self->CenterFloor()); - } - - DEFINE_ACTION_FUNCTION(_Sector, CenterCeiling) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - ACTION_RETURN_FLOAT(self->CenterCeiling()); - } - - DEFINE_ACTION_FUNCTION(_Sector, Index) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - unsigned ndx = self->Index(); - if (ndx >= level.sectors.Size()) - { - // This qualifies as an array out of bounds exception. Normally it can only happen when a sector copy is concerned which scripts should not be able to create. - ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid sector"); - } - ACTION_RETURN_INT(ndx); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetEnvironmentID) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(envnum); - level.Zones[self->ZoneNumber].Environment = S_FindEnvironment(envnum); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, SetEnvironment) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_STRING(env); - level.Zones[self->ZoneNumber].Environment = S_FindEnvironment(env); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, GetGlowHeight) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_FLOAT(self->GetGlowHeight(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, GetGlowColor) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - ACTION_RETURN_INT(self->GetGlowColor(pos)); - } - - DEFINE_ACTION_FUNCTION(_Sector, SetGlowHeight) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_FLOAT(o); - self->SetGlowHeight(pos, float(o)); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Sector, SetGlowColor) - { - PARAM_SELF_STRUCT_PROLOGUE(sector_t); - PARAM_INT(pos); - PARAM_COLOR(o); - self->SetGlowColor(pos, o); - return 0; - } - - //=========================================================================== - // - // line_t exports - // - //=========================================================================== - - DEFINE_ACTION_FUNCTION(_Line, isLinePortal) - { - PARAM_SELF_STRUCT_PROLOGUE(line_t); - ACTION_RETURN_BOOL(self->isLinePortal()); - } - - DEFINE_ACTION_FUNCTION(_Line, isVisualPortal) - { - PARAM_SELF_STRUCT_PROLOGUE(line_t); - ACTION_RETURN_BOOL(self->isVisualPortal()); - } - - DEFINE_ACTION_FUNCTION(_Line, getPortalDestination) - { - PARAM_SELF_STRUCT_PROLOGUE(line_t); - ACTION_RETURN_POINTER(self->getPortalDestination()); - } - - DEFINE_ACTION_FUNCTION(_Line, getPortalAlignment) - { - PARAM_SELF_STRUCT_PROLOGUE(line_t); - ACTION_RETURN_INT(self->getPortalAlignment()); - } - - DEFINE_ACTION_FUNCTION(_Line, Index) - { - PARAM_SELF_STRUCT_PROLOGUE(line_t); - unsigned ndx = self->Index(); - if (ndx >= level.lines.Size()) - { - ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid line"); - } - ACTION_RETURN_INT(ndx); - } - - //=========================================================================== - // - // - // - //=========================================================================== - - DEFINE_ACTION_FUNCTION(_Side, GetTexture) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - ACTION_RETURN_INT(self->GetTexture(which).GetIndex()); - } - - DEFINE_ACTION_FUNCTION(_Side, SetTexture) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_INT(tex); - self->SetTexture(which, FSetTextureID(tex)); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, SetTextureXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->SetTextureXOffset(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, AddTextureXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->AddTextureXOffset(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, GetTextureXOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - ACTION_RETURN_FLOAT(self->GetTextureXOffset(which)); - } - - DEFINE_ACTION_FUNCTION(_Side, SetTextureYOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->SetTextureYOffset(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, AddTextureYOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->AddTextureYOffset(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, GetTextureYOffset) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - ACTION_RETURN_FLOAT(self->GetTextureYOffset(which)); - } - - DEFINE_ACTION_FUNCTION(_Side, SetTextureXScale) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->SetTextureXScale(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, MultiplyTextureXScale) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->MultiplyTextureXScale(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, GetTextureXScale) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - ACTION_RETURN_FLOAT(self->GetTextureXScale(which)); - } - - DEFINE_ACTION_FUNCTION(_Side, SetTextureYScale) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->SetTextureYScale(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, MultiplyTextureYScale) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - PARAM_FLOAT(ofs); - self->MultiplyTextureYScale(which, ofs); - return 0; - } - - DEFINE_ACTION_FUNCTION(_Side, GetTextureYScale) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(which); - ACTION_RETURN_FLOAT(self->GetTextureYScale(which)); - } - - DEFINE_ACTION_FUNCTION(_Side, V1) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - ACTION_RETURN_POINTER(self->V1()); - } - - DEFINE_ACTION_FUNCTION(_Side, V2) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - ACTION_RETURN_POINTER(self->V2()); - } - - DEFINE_ACTION_FUNCTION(_Side, Index) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - ACTION_RETURN_INT(self->Index()); - } - - //===================================================================================== -// -// -//===================================================================================== - - DEFINE_ACTION_FUNCTION(_Side, SetSpecialColor) - { - PARAM_SELF_STRUCT_PROLOGUE(side_t); - PARAM_INT(tier); - PARAM_INT(position); - PARAM_COLOR(color); - if (tier >= 0 && tier < 3 && position >= 0 && position < 2) - { - color.a = 255; - self->SetSpecialColor(tier, position, color); - } - return 0; - } - - - DEFINE_ACTION_FUNCTION(_Vertex, Index) - { - PARAM_SELF_STRUCT_PROLOGUE(vertex_t); - ACTION_RETURN_INT(self->Index()); - } - - //=========================================================================== // // @@ -2383,16 +1637,6 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags) } } -DEFINE_ACTION_FUNCTION(_TexMan, ReplaceTextures) -{ - PARAM_PROLOGUE; - PARAM_STRING(from); - PARAM_STRING(to); - PARAM_INT(flags); - P_ReplaceTextures(from, to, flags); - return 0; -} - //========================================================================== // // P_BuildPolyBSP @@ -2535,89 +1779,6 @@ void vertex_t::RecalcVertexHeights() dirty = false; } - - - -DEFINE_ACTION_FUNCTION(_Secplane, isSlope) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - ACTION_RETURN_BOOL(!self->normal.XY().isZero()); -} - -DEFINE_ACTION_FUNCTION(_Secplane, PointOnSide) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - ACTION_RETURN_INT(self->PointOnSide(DVector3(x, y, z))); -} - -DEFINE_ACTION_FUNCTION(_Secplane, ZatPoint) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - ACTION_RETURN_FLOAT(self->ZatPoint(x, y)); -} - -DEFINE_ACTION_FUNCTION(_Secplane, ZatPointDist) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(d); - ACTION_RETURN_FLOAT((d + self->normal.X*x + self->normal.Y*y) * self->negiC); -} - -DEFINE_ACTION_FUNCTION(_Secplane, isEqual) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_POINTER(other, secplane_t); - ACTION_RETURN_BOOL(*self == *other); -} - -DEFINE_ACTION_FUNCTION(_Secplane, ChangeHeight) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(hdiff); - self->ChangeHeight(hdiff); - return 0; -} - -DEFINE_ACTION_FUNCTION(_Secplane, GetChangedHeight) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(hdiff); - ACTION_RETURN_FLOAT(self->GetChangedHeight(hdiff)); -} - -DEFINE_ACTION_FUNCTION(_Secplane, HeightDiff) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(oldd); - PARAM_FLOAT(newd); - if (newd != 1e37) - { - ACTION_RETURN_FLOAT(self->HeightDiff(oldd)); - } - else - { - PARAM_FLOAT(newd); - ACTION_RETURN_FLOAT(self->HeightDiff(oldd, newd)); - } -} - -DEFINE_ACTION_FUNCTION(_Secplane, PointToDist) -{ - PARAM_SELF_STRUCT_PROLOGUE(secplane_t); - PARAM_FLOAT(x); - PARAM_FLOAT(y); - PARAM_FLOAT(z); - ACTION_RETURN_FLOAT(self->PointToDist(DVector2(x, y), z)); -} - - DEFINE_FIELD_X(Sector, sector_t, floorplane) DEFINE_FIELD_X(Sector, sector_t, ceilingplane) DEFINE_FIELD_X(Sector, sector_t, Colormap) diff --git a/src/r_defs.h b/src/r_defs.h index ad128c4dc..d21e5ffa4 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -630,10 +630,6 @@ public: double FindHighestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98 double FindNextLowestCeiling(vertex_t **v) const; // jff 2/04/98 double FindNextHighestCeiling(vertex_t **v) const; // jff 2/04/98 - double FindShortestTextureAround() const; // jff 2/04/98 - double FindShortestUpperAround() const; // jff 2/04/98 - sector_t *FindModelFloorSector(double floordestheight) const; // jff 2/04/98 - sector_t *FindModelCeilingSector(double floordestheight) const; // jff 2/04/98 int FindMinSurroundingLight (int max) const; sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH] double FindLowestCeilingPoint(vertex_t **v) const; @@ -1603,4 +1599,10 @@ inline void FColormap::CopyFrom3DLight(lightlist_t *light) } } + +double FindShortestTextureAround(sector_t *sector); // jff 2/04/98 +double FindShortestUpperAround(sector_t *sector); // jff 2/04/98 +sector_t *FindModelFloorSector(sector_t *sec, double floordestheight); // jff 2/04/98 +sector_t *FindModelCeilingSector(sector_t *sec, double floordestheight); // jff 2/04/98 + #endif diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp new file mode 100644 index 000000000..a3b85cc98 --- /dev/null +++ b/src/scripting/vmthunks.cpp @@ -0,0 +1,898 @@ +//----------------------------------------------------------------------------- +// +// Copyright 2016-2018 Christoph Oelckers +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//----------------------------------------------------------------------------- +// +// VM thunks for simple functions. +// +//----------------------------------------------------------------------------- + +#include "vm.h" +#include "r_defs.h" +#include "g_levellocals.h" +#include "s_sound.h" +#include "p_local.h" + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindShortestTextureAround, FindShortestTextureAround) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_FLOAT(FindShortestTextureAround(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindShortestUpperAround, FindShortestUpperAround) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_FLOAT(FindShortestUpperAround(self)); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindModelFloorSector, FindModelFloorSector) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_FLOAT(fdh); + auto h = FindModelFloorSector(self, fdh); + ACTION_RETURN_POINTER(h); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindModelCeilingSector, FindModelCeilingSector) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_FLOAT(fdh); + auto h = FindModelCeilingSector(self, fdh); + ACTION_RETURN_POINTER(h); +} + +// Note: Do not use struct types like PalEntry as argument types here! We never know what the compilers will do with them. +static void SetColor(sector_t *self, int color, int desat) +{ + self->Colormap.LightColor.SetRGB(color); + self->Colormap.Desaturation = desat; + P_RecalculateAttachedLights(self); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetColor, SetColor) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_COLOR(color); + PARAM_INT(desat); + SetColor(self, color, desat); + return 0; +} + +static void SetFade(sector_t *self, int fade) +{ + self->Colormap.FadeColor.SetRGB(fade); + P_RecalculateAttachedLights(self); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetFade, SetFade) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_COLOR(fade); + SetFade(self, fade); + return 0; +} + +static void SetSpecialColor(sector_t *self, int num, int _color) +{ + if (num >= 0 && num < 5) + { + PalEntry color = _color; + color.a = 255; + self->SetSpecialColor(num, color); + } +} +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetSpecialColor, SetSpecialColor) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(num); + PARAM_COLOR(color); + SetSpecialColor(self, num, color); + return 0; +} + +static void SetFogDensity(sector_t *self, int dens) +{ + self->Colormap.FogDensity = dens; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetFogDensity, SetFogDensity) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(dens); + self->Colormap.FogDensity = dens; + return 0; +} + +static int PlaneMoving(sector_t *self, int pos) +{ + return self->PlaneMoving(pos); +} + +DEFINE_ACTION_FUNCTION(_Sector, PlaneMoving) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_BOOL(self->PlaneMoving(pos)); +} + +static int GetFloorLight(sector_t *self) +{ + return self->GetFloorLight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetFloorLight, GetFloorLight) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_INT(self->GetFloorLight()); +} + +static int GetCeilingLight(sector_t *self) +{ + return self->GetCeilingLight(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetCeilingLight, GetCeilingLight) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_INT(self->GetCeilingLight()); +} + +static sector_t *GetHeightSec(sector_t *self) +{ + return self->GetHeightSec(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetHeightSec, GetHeightSec) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_POINTER(self->GetHeightSec()); +} + +static void GetSpecial(sector_t *self, secspecial_t *spec) +{ + self->GetSpecial(spec); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetSpecial, GetSpecial) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_POINTER(spec, secspecial_t); + self->GetSpecial(spec); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Sector, SetSpecial) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_POINTER(spec, secspecial_t); + self->SetSpecial(spec); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Sector, TransferSpecial) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_POINTER(spec, sector_t); + self->TransferSpecial(spec); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Sector, GetTerrain) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetTerrain(pos)); +} + +DEFINE_ACTION_FUNCTION(_Sector, CheckPortalPlane) +{ + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(plane); + self->CheckPortalPlane(plane); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Sector, RemoveForceField) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + self->RemoveForceField(); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, AdjustFloorClip) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + self->AdjustFloorClip(); + return 0; + } + + //=========================================================================== + // + // + // + //=========================================================================== + + DEFINE_ACTION_FUNCTION(_Sector, PointInSector) + { + PARAM_PROLOGUE; + PARAM_FLOAT(x); + PARAM_FLOAT(y); + ACTION_RETURN_POINTER(P_PointInSector(x, y)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetXOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->SetXOffset(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, AddXOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->AddXOffset(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetXOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetXOffset(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetYOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->SetXOffset(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, AddYOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->AddXOffset(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetYOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_BOOL(addbase); + ACTION_RETURN_FLOAT(self->GetYOffset(pos, addbase)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetXScale) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->SetXScale(pos, o); + return 0; + } + + + DEFINE_ACTION_FUNCTION(_Sector, GetXScale) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetXScale(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetYScale) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->SetYScale(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetYScale) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetYScale(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetAngle) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_ANGLE(o); + self->SetAngle(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetAngle) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_BOOL(addbase); + ACTION_RETURN_FLOAT(self->GetAngle(pos, addbase).Degrees); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetBase) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + PARAM_ANGLE(a); + self->SetBase(pos, o, a); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, SetAlpha) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->SetAlpha(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetAlpha) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetAlpha(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, GetFlags) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetFlags(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, GetVisFlags) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetVisFlags(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, ChangeFlags) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_INT(a); + PARAM_INT(o); + self->ChangeFlags(pos, a, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, SetPlaneLight) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_INT(o); + self->SetPlaneLight(pos, o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetPlaneLight) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetPlaneLight(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetTexture) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_INT(o); + PARAM_BOOL(adj); + self->SetTexture(pos, FSetTextureID(o), adj); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetTexture) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetTexture(pos).GetIndex()); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetPlaneTexZ) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + PARAM_BOOL(dirty); + self->SetPlaneTexZ(pos, o, true); // not setting 'dirty' here is a guaranteed cause for problems. + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetPlaneTexZ) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetPlaneTexZ(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetLightLevel) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(o); + self->SetLightLevel(o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, ChangeLightLevel) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(o); + self->ChangeLightLevel(o); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetLightLevel) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_INT(self->GetLightLevel()); + } + + DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksView) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_BOOL(self->PortalBlocksView(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksSight) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_BOOL(self->PortalBlocksSight(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksMovement) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_BOOL(self->PortalBlocksMovement(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, PortalBlocksSound) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_BOOL(self->PortalBlocksSound(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, PortalIsLinked) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_BOOL(self->PortalIsLinked(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, ClearPortal) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + self->ClearPortal(pos); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetPortalPlaneZ) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetPortalPlaneZ(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, GetPortalDisplacement) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_VEC2(self->GetPortalDisplacement(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, GetPortalType) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetPortalType(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, GetOppositePortalGroup) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetOppositePortalGroup(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, CenterFloor) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_FLOAT(self->CenterFloor()); + } + + DEFINE_ACTION_FUNCTION(_Sector, CenterCeiling) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + ACTION_RETURN_FLOAT(self->CenterCeiling()); + } + + DEFINE_ACTION_FUNCTION(_Sector, Index) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + unsigned ndx = self->Index(); + if (ndx >= level.sectors.Size()) + { + // This qualifies as an array out of bounds exception. Normally it can only happen when a sector copy is concerned which scripts should not be able to create. + ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid sector"); + } + ACTION_RETURN_INT(ndx); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetEnvironmentID) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(envnum); + level.Zones[self->ZoneNumber].Environment = S_FindEnvironment(envnum); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, SetEnvironment) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_STRING(env); + level.Zones[self->ZoneNumber].Environment = S_FindEnvironment(env); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, GetGlowHeight) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_FLOAT(self->GetGlowHeight(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, GetGlowColor) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + ACTION_RETURN_INT(self->GetGlowColor(pos)); + } + + DEFINE_ACTION_FUNCTION(_Sector, SetGlowHeight) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_FLOAT(o); + self->SetGlowHeight(pos, float(o)); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Sector, SetGlowColor) + { + PARAM_SELF_STRUCT_PROLOGUE(sector_t); + PARAM_INT(pos); + PARAM_COLOR(o); + self->SetGlowColor(pos, o); + return 0; + } + + //=========================================================================== + // + // line_t exports + // + //=========================================================================== + + DEFINE_ACTION_FUNCTION(_Line, isLinePortal) + { + PARAM_SELF_STRUCT_PROLOGUE(line_t); + ACTION_RETURN_BOOL(self->isLinePortal()); + } + + DEFINE_ACTION_FUNCTION(_Line, isVisualPortal) + { + PARAM_SELF_STRUCT_PROLOGUE(line_t); + ACTION_RETURN_BOOL(self->isVisualPortal()); + } + + DEFINE_ACTION_FUNCTION(_Line, getPortalDestination) + { + PARAM_SELF_STRUCT_PROLOGUE(line_t); + ACTION_RETURN_POINTER(self->getPortalDestination()); + } + + DEFINE_ACTION_FUNCTION(_Line, getPortalAlignment) + { + PARAM_SELF_STRUCT_PROLOGUE(line_t); + ACTION_RETURN_INT(self->getPortalAlignment()); + } + + DEFINE_ACTION_FUNCTION(_Line, Index) + { + PARAM_SELF_STRUCT_PROLOGUE(line_t); + unsigned ndx = self->Index(); + if (ndx >= level.lines.Size()) + { + ThrowAbortException(X_ARRAY_OUT_OF_BOUNDS, "Accessed invalid line"); + } + ACTION_RETURN_INT(ndx); + } + + //=========================================================================== + // + // + // + //=========================================================================== + + DEFINE_ACTION_FUNCTION(_Side, GetTexture) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + ACTION_RETURN_INT(self->GetTexture(which).GetIndex()); + } + + DEFINE_ACTION_FUNCTION(_Side, SetTexture) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_INT(tex); + self->SetTexture(which, FSetTextureID(tex)); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, SetTextureXOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->SetTextureXOffset(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, AddTextureXOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->AddTextureXOffset(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, GetTextureXOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + ACTION_RETURN_FLOAT(self->GetTextureXOffset(which)); + } + + DEFINE_ACTION_FUNCTION(_Side, SetTextureYOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->SetTextureYOffset(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, AddTextureYOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->AddTextureYOffset(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, GetTextureYOffset) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + ACTION_RETURN_FLOAT(self->GetTextureYOffset(which)); + } + + DEFINE_ACTION_FUNCTION(_Side, SetTextureXScale) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->SetTextureXScale(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, MultiplyTextureXScale) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->MultiplyTextureXScale(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, GetTextureXScale) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + ACTION_RETURN_FLOAT(self->GetTextureXScale(which)); + } + + DEFINE_ACTION_FUNCTION(_Side, SetTextureYScale) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->SetTextureYScale(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, MultiplyTextureYScale) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + PARAM_FLOAT(ofs); + self->MultiplyTextureYScale(which, ofs); + return 0; + } + + DEFINE_ACTION_FUNCTION(_Side, GetTextureYScale) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(which); + ACTION_RETURN_FLOAT(self->GetTextureYScale(which)); + } + + DEFINE_ACTION_FUNCTION(_Side, V1) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + ACTION_RETURN_POINTER(self->V1()); + } + + DEFINE_ACTION_FUNCTION(_Side, V2) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + ACTION_RETURN_POINTER(self->V2()); + } + + DEFINE_ACTION_FUNCTION(_Side, Index) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + ACTION_RETURN_INT(self->Index()); + } + + //===================================================================================== +// +// +//===================================================================================== + + DEFINE_ACTION_FUNCTION(_Side, SetSpecialColor) + { + PARAM_SELF_STRUCT_PROLOGUE(side_t); + PARAM_INT(tier); + PARAM_INT(position); + PARAM_COLOR(color); + if (tier >= 0 && tier < 3 && position >= 0 && position < 2) + { + color.a = 255; + self->SetSpecialColor(tier, position, color); + } + return 0; + } + + + DEFINE_ACTION_FUNCTION(_Vertex, Index) + { + PARAM_SELF_STRUCT_PROLOGUE(vertex_t); + ACTION_RETURN_INT(self->Index()); + } + +DEFINE_ACTION_FUNCTION(_TexMan, ReplaceTextures) +{ + PARAM_PROLOGUE; + PARAM_STRING(from); + PARAM_STRING(to); + PARAM_INT(flags); + P_ReplaceTextures(from, to, flags); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Secplane, isSlope) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + ACTION_RETURN_BOOL(!self->normal.XY().isZero()); +} + +DEFINE_ACTION_FUNCTION(_Secplane, PointOnSide) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + ACTION_RETURN_INT(self->PointOnSide(DVector3(x, y, z))); +} + +DEFINE_ACTION_FUNCTION(_Secplane, ZatPoint) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + ACTION_RETURN_FLOAT(self->ZatPoint(x, y)); +} + +DEFINE_ACTION_FUNCTION(_Secplane, ZatPointDist) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(d); + ACTION_RETURN_FLOAT((d + self->normal.X*x + self->normal.Y*y) * self->negiC); +} + +DEFINE_ACTION_FUNCTION(_Secplane, isEqual) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_POINTER(other, secplane_t); + ACTION_RETURN_BOOL(*self == *other); +} + +DEFINE_ACTION_FUNCTION(_Secplane, ChangeHeight) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(hdiff); + self->ChangeHeight(hdiff); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Secplane, GetChangedHeight) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(hdiff); + ACTION_RETURN_FLOAT(self->GetChangedHeight(hdiff)); +} + +DEFINE_ACTION_FUNCTION(_Secplane, HeightDiff) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(oldd); + PARAM_FLOAT(newd); + if (newd != 1e37) + { + ACTION_RETURN_FLOAT(self->HeightDiff(oldd)); + } + else + { + PARAM_FLOAT(newd); + ACTION_RETURN_FLOAT(self->HeightDiff(oldd, newd)); + } +} + +DEFINE_ACTION_FUNCTION(_Secplane, PointToDist) +{ + PARAM_SELF_STRUCT_PROLOGUE(secplane_t); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_FLOAT(z); + ACTION_RETURN_FLOAT(self->PointToDist(DVector2(x, y), z)); +} +