- Remove old integer dragpoint() interface that was used by floats in lots of places.

* Cannot wait until all the narrowing warnings can be re-enabled...
This commit is contained in:
Mitchell Richters 2022-09-30 13:31:02 +10:00 committed by Christoph Oelckers
parent 5cc9774873
commit 9dd27ee3a2
7 changed files with 47 additions and 99 deletions

View file

@ -408,15 +408,6 @@ bool sectorsConnected(int sect1, int sect2)
//
//==========================================================================
void dragpoint(walltype* startwall, int newx, int newy)
{
vertexscan(startwall, [&](walltype* wal)
{
wal->movexy(newx, newy);
wal->sectorp()->exflags |= SECTOREX_DRAGGED;
});
}
void dragpoint(walltype* startwall, const DVector2& pos)
{
vertexscan(startwall, [&](walltype* wal)

View file

@ -256,7 +256,6 @@ EClose IsCloseToWall(const DVector2& vect, walltype* wal, double walldist);
void checkRotatedWalls();
bool sectorsConnected(int sect1, int sect2);
[[deprecated]] void dragpoint(walltype* wal, int newx, int newy);
void dragpoint(walltype* wal, const DVector2& pos);
int32_t inside(double x, double y, const sectortype* sect);
int insidePoly(double x, double y, const DVector2* points, int count);

View file

@ -421,7 +421,6 @@ struct walltype
bool twoSided() const { return nextsector >= 0; }
double Length();
void calcLength(); // this is deliberately not inlined and stored in a file where it can't be found at compile time.
void movexy(int newx, int newy);
void move(const DVector2& vec)
{
pos = vec;
@ -609,14 +608,6 @@ inline void walltype::moved()
sectorp()->dirty = EDirty::AllDirty;
}
inline void walltype::movexy(int newx, int newy)
{
pos.X = newx * inttoworld;
pos.Y = newy * inttoworld;
lengthflags = 3;
sectorp()->dirty = EDirty::AllDirty;
}
inline double walltype::Length()
{
if ((lengthflags & 1) || (point2Wall()->lengthflags & 2))

View file

@ -485,7 +485,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, length, wall_length)
void wall_move(walltype* wal, double x, double y)
{
if (!wal) ThrowAbortException(X_READ_NIL, nullptr);
wal->movexy(x, y);
wal->move(DVector2(x, y));
}
DEFINE_ACTION_FUNCTION_NATIVE(_walltype, move, wall_move)
@ -493,7 +493,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_walltype, move, wall_move)
PARAM_SELF_STRUCT_PROLOGUE(walltype);
PARAM_FLOAT(x);
PARAM_FLOAT(y);
self->movexy(x, y);
self->move(DVector2(x, y));
return 0;
}

View file

@ -229,30 +229,23 @@ void SnapSectors(sectortype* pSectorA, sectortype* pSectorB, int b)
{
for(auto& wal1 : wallsofsector(pSectorA))
{
int bestx = 0x7FFFFFF;
int besty = bestx;
double x = wal1.pos.X;
int y = wal1.pos.Y;
DVector2 bestxy = { 0x7FFFFFF, 0x7FFFFFF };
DVector2 w1pos = wal1.pos;
walltype* bestwall = nullptr;
for(auto& wal2 : wallsofsector(pSectorB))
{
double thisx = x - wal2.pos.X;
double thisy = y - wal2.pos.Y;
double thisdist = abs(thisx) + abs(thisy);
double bestdist = abs(bestx) + abs(besty);
DVector2 thisxy = w1pos - wal2.pos;
if (thisdist < bestdist)
if (thisxy.Sum() < bestxy.Sum())
{
bestx = thisx;
besty = thisy;
bestxy = thisxy;
bestwall = &wal2;
}
}
dragpoint(bestwall, bestwall->pos.X + bestx, bestwall->pos.Y + besty);
dragpoint(bestwall, bestwall->pos + bestxy);
}
if (b) {

View file

@ -589,6 +589,11 @@ static double LongSeek(double* pZVal, double a2, double a3, double a4)
return v4;
}
static inline DVector2 LongSeek(DVector2& pZVals, const DVector2& a2, double a3, double a4)
{
return DVector2(LongSeek(&pZVals.X, a2.X, a3, a4), LongSeek(&pZVals.Y, a2.Y, a3, a4));
}
//---------------------------------------------------------------------------
//
//
@ -1126,90 +1131,63 @@ void AISlide::Tick(RunListEvent* ev)
if (cx == 1)
{
auto pWall = SlideData[nSlide].pWall1;
double x = pWall->pos.X;
double y = pWall->pos.Y;
auto wlPos = pWall->pos;
auto nSeek = LongSeek(wlPos, SlideData[nSlide].pos[4], 1.25, 1.25);
dragpoint(pWall, wlPos);
movesprite(SlideData[nSlide].pActor, nSeek, 0, 0, CLIPMASK1);
double nSeekA = LongSeek(&x, SlideData[nSlide].pos[4].X, 1.25, 1.25);
double nSeekB = LongSeek(&y, SlideData[nSlide].pos[4].Y, 1.25, 1.25);
dragpoint(SlideData[nSlide].pWall1, x, y);
movesprite(SlideData[nSlide].pActor, DVector2(nSeekA, nSeekB), 0, 0, CLIPMASK1);
if (nSeekA == 0 && nSeekB == 0)
if (nSeek.isZero())
{
clipstate = clipmask;
}
pWall = SlideData[nSlide].pStartWall;
x = pWall->pos.X + nSeekA;
y = pWall->pos.Y + nSeekB;
dragpoint(SlideData[nSlide].pStartWall, x, y);
wlPos = pWall->pos + nSeek;
dragpoint(pWall, wlPos);
pWall = SlideData[nSlide].pWall3;
wlPos = pWall->pos;
nSeek = LongSeek(wlPos, SlideData[nSlide].pos[5], 1.25, 1.25);
dragpoint(pWall, wlPos);
x = pWall->pos.X;
y = pWall->pos.Y;
int nSeekC = LongSeek(&x, SlideData[nSlide].pos[5].X, 1.25, 1.25);
int nSeekD = LongSeek(&y, SlideData[nSlide].pos[5].Y, 1.25, 1.25);
dragpoint(SlideData[nSlide].pWall3, x, y);
if (nSeekC == 0 && nSeekD == 0) {
if (nSeek.isZero())
{
clipstate++;
}
pWall = SlideData[nSlide].pWall2;
x = pWall->pos.X + nSeekC;
y = pWall->pos.Y + nSeekD;
dragpoint(SlideData[nSlide].pWall2, x, y);
wlPos = pWall->pos + nSeek;
dragpoint(pWall, wlPos);
}
else if (cx == 0) // right branch
{
auto pWall = SlideData[nSlide].pStartWall;
double x = pWall->pos.X;
double y = pWall->pos.Y;
auto wlPos = pWall->pos;
auto nSeek = LongSeek(wlPos, SlideData[nSlide].pos[0], 1.25, 1.25);
dragpoint(pWall, wlPos);
int nSeekA = LongSeek(&x, SlideData[nSlide].pos[0].X, 1.25, 1.25);
int nSeekB = LongSeek(&y, SlideData[nSlide].pos[0].Y, 1.25, 1.25);
dragpoint(SlideData[nSlide].pStartWall, x, y);
if (nSeekA == 0 && nSeekB == 0) {
if (nSeek.isZero())
{
clipstate = clipmask;
}
pWall = SlideData[nSlide].pWall1;
y = pWall->pos.Y + nSeekB;
x = pWall->pos.X + nSeekA;
dragpoint(SlideData[nSlide].pWall1, x, y);
wlPos = pWall->pos + nSeek;
dragpoint(pWall, wlPos);
pWall = SlideData[nSlide].pWall2;
wlPos = pWall->pos;
nSeek = LongSeek(wlPos, SlideData[nSlide].pos[1], 1.25, 1.25);
dragpoint(pWall, wlPos);
x = pWall->pos.X;
y = pWall->pos.Y;
int nSeekC = LongSeek(&x, SlideData[nSlide].pos[1].X, 1.25, 1.25);
int nSeekD = LongSeek(&y, SlideData[nSlide].pos[1].Y, 1.25, 1.25);
dragpoint(SlideData[nSlide].pWall2, x, y);
if (nSeekC == 0 && nSeekD == 0) {
if (nSeek.isZero())
{
clipstate++;
}
pWall = SlideData[nSlide].pWall3;
y = pWall->pos.Y + nSeekD;
x = pWall->pos.X + nSeekC;
dragpoint(SlideData[nSlide].pWall3, x, y);
wlPos = pWall->pos + nSeek;
dragpoint(pWall, wlPos);
}
// loc_21A51:

View file

@ -2625,28 +2625,24 @@ void DoSineWaveFloor(void)
void DoSineWaveWall(void)
{
SINE_WALL *sw;
double New;
short sw_num;
for (sw_num = 0; sw_num < MAX_SINE_WALL; sw_num++)
for (short sw_num = 0; sw_num < MAX_SINE_WALL; sw_num++)
{
for (sw = &SineWall[sw_num][0]; sw->wallp != nullptr && sw < &SineWall[sw_num][MAX_SINE_WALL_POINTS]; sw++)
for (SINE_WALL* sw = &SineWall[sw_num][0]; sw->wallp != nullptr && sw < &SineWall[sw_num][MAX_SINE_WALL_POINTS]; sw++)
{
auto wal = sw->wallp;
DVector2 newpos = wal->pos;
// move through the sintable
sw->sintable_ndx = NORM_ANGLE(sw->sintable_ndx + (synctics << sw->speed_shift));
if (!sw->type)
{
New = sw->origXY + sw->Range * BobVal(sw->sintable_ndx);
dragpoint(wal, DVector2(wal->pos.X, New));
newpos.Y = sw->origXY + sw->Range * BobVal(sw->sintable_ndx);
}
else
{
New = sw->origXY + sw->Range * BobVal(sw->sintable_ndx);
dragpoint(wal, DVector2(New, wal->pos.Y));
newpos.X = sw->origXY + sw->Range * BobVal(sw->sintable_ndx);
}
dragpoint(wal, newpos);
}
}
}