- another batch of direct native functions.

This commit is contained in:
Christoph Oelckers 2018-11-25 14:19:19 +01:00
parent 6628b34f4a
commit 8e8ee732f4
6 changed files with 159 additions and 82 deletions

View file

@ -735,7 +735,7 @@ void ProcessEDSector(sector_t *sec, int recordnum)
sec->terrainnum[sector_t::floor] = esec->floorterrain;
sec->terrainnum[sector_t::ceiling] = esec->ceilingterrain;
if (esec->colorSet) sec->SetColor(RPART(esec->color), GPART(esec->color), BPART(esec->color), 0);
if (esec->colorSet) sec->SetColor(esec->color, 0);
const uint32_t pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE;
for (int i = 0; i < 2; i++)

View file

@ -3886,7 +3886,7 @@ void FParser::SF_SetColor(void)
{
if (!DFraggleThinker::ActiveThinker->setcolormaterial)
{
level.sectors[i].SetColor(color.r, color.g, color.b, 0);
level.sectors[i].SetColor(color, 0);
}
else
{

View file

@ -2434,7 +2434,7 @@ FUNC(LS_Sector_SetColor)
int secnum;
while ((secnum = itr.Next()) >= 0)
{
level.sectors[secnum].SetColor(arg1, arg2, arg3, arg4);
level.sectors[secnum].SetColor(PalEntry(255, arg1, arg2, arg3), arg4);
}
return true;
@ -2447,7 +2447,7 @@ FUNC(LS_Sector_SetFade)
int secnum;
while ((secnum = itr.Next()) >= 0)
{
level.sectors[secnum].SetFade(arg1, arg2, arg3);
level.sectors[secnum].SetFade(PalEntry(255, arg1, arg2, arg3));
}
return true;
}

View file

@ -800,25 +800,27 @@ DEFINE_ACTION_FUNCTION(_Sector, FindLowestCeilingPoint)
//=====================================================================================
//
// 'color' is intentionally an int here
//
//=====================================================================================
void sector_t::SetColor(int r, int g, int b, int desat)
void SetColor(sector_t *sector, int color, int desat)
{
Colormap.LightColor = PalEntry(r, g, b);
Colormap.Desaturation = desat;
P_RecalculateAttachedLights(this);
sector->Colormap.LightColor = color;
sector->Colormap.Desaturation = desat;
P_RecalculateAttachedLights(sector);
}
//=====================================================================================
//
// 'color' is intentionally an int here
//
//=====================================================================================
void sector_t::SetFade(int r, int g, int b)
void SetFade(sector_t *sector, int color)
{
Colormap.FadeColor = PalEntry (r,g,b);
P_RecalculateAttachedLights(this);
sector->Colormap.FadeColor = color;
P_RecalculateAttachedLights(sector);
}
//=====================================================================================
@ -917,15 +919,15 @@ bool PlaneMoving(sector_t *sector, int pos)
//
//=====================================================================================
int sector_t::GetFloorLight () const
int GetFloorLight(const sector_t *sector)
{
if (GetFlags(sector_t::floor) & PLANEF_ABSLIGHTING)
if (sector->GetFlags(sector_t::floor) & PLANEF_ABSLIGHTING)
{
return GetPlaneLight(floor);
return sector->GetPlaneLight(sector_t::floor);
}
else
{
return ClampLight(lightlevel + GetPlaneLight(floor));
return sector->ClampLight(sector->lightlevel + sector->GetPlaneLight(sector_t::floor));
}
}
@ -934,15 +936,15 @@ int sector_t::GetFloorLight () const
//
//=====================================================================================
int sector_t::GetCeilingLight () const
int GetCeilingLight(const sector_t *sector)
{
if (GetFlags(ceiling) & PLANEF_ABSLIGHTING)
if (sector->GetFlags(sector_t::ceiling) & PLANEF_ABSLIGHTING)
{
return GetPlaneLight(ceiling);
return sector->GetPlaneLight(sector_t::ceiling);
}
else
{
return ClampLight(lightlevel + GetPlaneLight(ceiling));
return sector->ClampLight(sector->lightlevel + sector->GetPlaneLight(sector_t::ceiling));
}
}
@ -1020,14 +1022,14 @@ int GetTerrain(const sector_t *sector, int pos)
//
//=====================================================================================
void sector_t::CheckPortalPlane(int plane)
void CheckPortalPlane(sector_t *sector, int plane)
{
if (GetPortalType(plane) == PORTS_LINKEDPORTAL)
if (sector->GetPortalType(plane) == PORTS_LINKEDPORTAL)
{
double portalh = GetPortalPlaneZ(plane);
double planeh = GetPlaneTexZ(plane);
double portalh = sector->GetPortalPlaneZ(plane);
double planeh = sector->GetPlaneTexZ(plane);
int obstructed = PLANEF_OBSTRUCTED * (plane == sector_t::floor ? planeh > portalh : planeh < portalh);
planes[plane].Flags = (planes[plane].Flags & ~PLANEF_OBSTRUCTED) | obstructed;
sector->planes[plane].Flags = (sector->planes[plane].Flags & ~PLANEF_OBSTRUCTED) | obstructed;
}
}
@ -1320,11 +1322,11 @@ DEFINE_ACTION_FUNCTION(_Sector, NextLowestFloorAt)
//
//===========================================================================
void sector_t::AdjustFloorClip() const
void AdjustFloorClip(const sector_t *sector)
{
msecnode_t *node;
for (node = touching_thinglist; node; node = node->m_snext)
for (node = sector->touching_thinglist; node; node = node->m_snext)
{
if (node->m_thing->flags2 & MF2_FLOORCLIP)
{

View file

@ -638,12 +638,13 @@ public:
int Index() const;
void AdjustFloorClip () const;
void SetColor(int r, int g, int b, int desat);
void SetFade(int r, int g, int b);
void SetColor(PalEntry pe, int desat);
void SetFade(PalEntry pe);
void SetFogDensity(int dens);
void ClosestPoint(const DVector2 &pos, DVector2 &out) const;
int GetFloorLight () const;
int GetCeilingLight () const;
int GetFloorLight() const;
int GetCeilingLight() const;
sector_t *GetHeightSec() const
{
@ -1581,6 +1582,11 @@ inline sector_t *P_PointInSector(double X, double Y)
return P_PointInSubsector(X, Y)->sector;
}
inline sector_t *P_PointInSectorXY(double X, double Y) // This is for the benefit of unambiguously looking up this function's address
{
return P_PointInSubsector(X, Y)->sector;
}
inline bool FBoundingBox::inRange(const line_t *ld) const
{
return Left() < ld->bbox[BOXRIGHT] &&
@ -1614,6 +1620,11 @@ void GetSpecial(sector_t *self, secspecial_t *spec);
void SetSpecial(sector_t *self, const secspecial_t *spec);
int GetTerrain(const sector_t *, int pos);
void CheckPortalPlane(sector_t *sector, int plane);
void AdjustFloorClip(const sector_t *sector);
void SetColor(sector_t *sector, int color, int desat);
void SetFade(sector_t *sector, int color);
int GetFloorLight(const sector_t *);
int GetCeilingLight(const sector_t *);
inline void sector_t::RemoveForceField() { return ::RemoveForceField(this); }
@ -1623,6 +1634,11 @@ inline void sector_t::GetSpecial(secspecial_t *spec) { ::GetSpecial(this, spec);
inline void sector_t::SetSpecial(const secspecial_t *spec) { ::SetSpecial(this, spec); }
inline int sector_t::GetTerrain(int pos) const { return ::GetTerrain(this, pos); }
inline void sector_t::CheckPortalPlane(int plane) { return ::CheckPortalPlane(this, plane); }
inline void sector_t::AdjustFloorClip() const { ::AdjustFloorClip(this); }
inline void sector_t::SetColor(PalEntry pe, int desat) { ::SetColor(this, pe, desat); }
inline void sector_t::SetFade(PalEntry pe) { ::SetFade(this, pe); }
inline int sector_t::GetFloorLight() const { return ::GetFloorLight(this); }
inline int sector_t::GetCeilingLight() const { return ::GetCeilingLight(this); }
#endif

View file

@ -55,14 +55,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindModelCeilingSector, FindModelCeilingS
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, buz we need a guaranteed integer calling convention .
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);
@ -72,12 +64,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetColor, SetColor)
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);
@ -123,22 +109,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, PlaneMoving, PlaneMoving)
ACTION_RETURN_BOOL(PlaneMoving(self, 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);
@ -203,20 +179,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, AdjustFloorClip)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, AdjustFloorClip, AdjustFloorClip)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
self->AdjustFloorClip();
AdjustFloorClip(self);
return 0;
}
//===========================================================================
//
//
//
//===========================================================================
DEFINE_ACTION_FUNCTION(_Sector, PointInSector)
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, PointInSector, P_PointInSectorXY)
{
PARAM_PROLOGUE;
PARAM_FLOAT(x);
@ -224,7 +194,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
ACTION_RETURN_POINTER(P_PointInSector(x, y));
}
DEFINE_ACTION_FUNCTION(_Sector, SetXOffset)
static void SetXOffset(sector_t *self, int pos, double o)
{
self->SetXOffset(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXOffset, SetXOffset)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -233,7 +208,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, AddXOffset)
static void AddXOffset(sector_t *self, int pos, double o)
{
self->AddXOffset(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, AddXOffset, AddXOffset)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -242,14 +222,24 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, GetXOffset)
static double GetXOffset(sector_t *self, int pos)
{
return self->GetXOffset(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetXOffset, GetXOffset)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_FLOAT(self->GetXOffset(pos));
}
DEFINE_ACTION_FUNCTION(_Sector, SetYOffset)
static void SetYOffset(sector_t *self, int pos, double o)
{
self->SetYOffset(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetYOffset, SetYOffset)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -258,16 +248,26 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, AddYOffset)
static void AddYOffset(sector_t *self, int pos, double o)
{
self->AddYOffset(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, AddYOffset, AddYOffset)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
PARAM_FLOAT(o);
self->AddXOffset(pos, o);
self->AddYOffset(pos, o);
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, GetYOffset)
static double GetYOffset(sector_t *self, int pos)
{
return self->GetYOffset(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetYOffset, GetYOffset)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -275,7 +275,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
ACTION_RETURN_FLOAT(self->GetYOffset(pos, addbase));
}
DEFINE_ACTION_FUNCTION(_Sector, SetXScale)
static void SetXScale(sector_t *self, int pos, double o)
{
self->SetXScale(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetXScale, SetXScale)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -284,14 +289,23 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, GetXScale)
static double GetXScale(sector_t *self, int pos)
{
return self->GetXScale(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetXScale, GetXScale)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_FLOAT(self->GetXScale(pos));
}
static void SetYScale(sector_t *self, int pos, double o)
{
self->SetYScale(pos, o);
}
DEFINE_ACTION_FUNCTION(_Sector, SetYScale)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
@ -301,14 +315,24 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, GetYScale)
static double GetYScale(sector_t *self, int pos)
{
return self->GetYScale(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetYScale, GetYScale)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_FLOAT(self->GetYScale(pos));
}
DEFINE_ACTION_FUNCTION(_Sector, SetAngle)
static void SetAngle(sector_t *self, int pos, double o)
{
self->SetAngle(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetAngle, SetAngle)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -317,7 +341,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, GetAngle)
static double GetAngle(sector_t *self, int pos, bool addbase)
{
return self->GetAngle(pos, addbase).Degrees;
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetAngle, GetAngle)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -325,7 +354,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
ACTION_RETURN_FLOAT(self->GetAngle(pos, addbase).Degrees);
}
DEFINE_ACTION_FUNCTION(_Sector, SetBase)
static void SetBase(sector_t *self, int pos, double o, double a)
{
self->SetBase(pos, o, a);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetBase, SetBase)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -335,7 +369,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, SetAlpha)
static void SetAlpha(sector_t *self, int pos, double o)
{
self->SetAlpha(pos, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, SetAlpha, SetAlpha)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
@ -344,28 +383,48 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Sector, RemoveForceField, RemoveForceField)
return 0;
}
DEFINE_ACTION_FUNCTION(_Sector, GetAlpha)
static double GetAlpha(sector_t *self, int pos)
{
return self->GetAlpha(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetAlpha, GetAlpha)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_FLOAT(self->GetAlpha(pos));
}
DEFINE_ACTION_FUNCTION(_Sector, GetFlags)
static int GetFlags(sector_t *self, int pos)
{
return self->GetFlags(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetFlags, GetFlags)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_INT(self->GetFlags(pos));
}
DEFINE_ACTION_FUNCTION(_Sector, GetVisFlags)
static int GetVisFlags(sector_t *self, int pos)
{
return self->GetVisFlags(pos);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, GetVisFlags, GetVisFlags)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);
ACTION_RETURN_INT(self->GetVisFlags(pos));
}
DEFINE_ACTION_FUNCTION(_Sector, ChangeFlags)
static void ChangeFlags(sector_t *self, int pos, int a, int o)
{
self->ChangeFlags(pos, a, o);
}
DEFINE_ACTION_FUNCTION_NATIVE(_Sector, ChangeFlags, ChangeFlags)
{
PARAM_SELF_STRUCT_PROLOGUE(sector_t);
PARAM_INT(pos);