From 5551f3a8c5423ac8a2ee87125f17747ba93d0a26 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Mar 2017 11:48:36 +0100 Subject: [PATCH] - declared the sectorplanes in Sector as read only and marked all relevant functions in the planes themselves const. This is to block modification of the planes directly. For future-proofness with renderer changes everything that alters these values should go through he function interface. --- src/scripting/thingdef_data.cpp | 4 ++-- wadsrc/static/zscript/base.txt | 1 - wadsrc/static/zscript/mapdata.txt | 16 ++++++++-------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index c50b7f65b..a09134d58 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -858,8 +858,8 @@ void InitThingdef() // As a result, the size has to be set to something large and arbritrary because it can change between maps. This will need some serious improvement when things get cleaned up. sectorstruct->AddNativeField("lines", NewPointer(NewResizableArray(NewPointer(linestruct, false)), false), myoffsetof(sector_t, Lines), VARF_Native); - sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native); - sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native); + sectorstruct->AddNativeField("ceilingplane", secplanestruct, myoffsetof(sector_t, ceilingplane), VARF_Native | VARF_ReadOnly); + sectorstruct->AddNativeField("floorplane", secplanestruct, myoffsetof(sector_t, floorplane), VARF_Native | VARF_ReadOnly); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 2c1fb6661..a15b78de8 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -386,7 +386,6 @@ class Thinker : Object native play class ThinkerIterator : Object native { - native static ThinkerIterator Create(class type = "Actor", int statnum=Thinker.MAX_STATNUM+1); native Thinker Next(bool exact = false); native void Reinit(); diff --git a/wadsrc/static/zscript/mapdata.txt b/wadsrc/static/zscript/mapdata.txt index 4bbfb7097..3d18f9f5e 100644 --- a/wadsrc/static/zscript/mapdata.txt +++ b/wadsrc/static/zscript/mapdata.txt @@ -143,7 +143,7 @@ struct Line native play 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 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 @@ -177,15 +177,15 @@ struct SecPlane native play 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 bool isSlope() const; + native int PointOnSide(Vector3 pos) const; + native double ZatPoint (Vector2 v) const; + native double ZatPointDist(Vector2 v, double dist) const; + native bool isEqual(Secplane other) const; native void ChangeHeight(double hdiff); - native double GetChangedHeight(double hdiff); + native double GetChangedHeight(double hdiff) const; native double HeightDiff(double oldd, double newd = 0.0); - native double PointToDist(Vector2 xy, double z); + native double PointToDist(Vector2 xy, double z) const; } // This encapsulates all info Doom's original 'special' field contained - for saving and transferring.