- 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) void dragpoint(walltype* startwall, const DVector2& pos)
{ {
vertexscan(startwall, [&](walltype* wal) vertexscan(startwall, [&](walltype* wal)

View file

@ -256,7 +256,6 @@ EClose IsCloseToWall(const DVector2& vect, walltype* wal, double walldist);
void checkRotatedWalls(); void checkRotatedWalls();
bool sectorsConnected(int sect1, int sect2); bool sectorsConnected(int sect1, int sect2);
[[deprecated]] void dragpoint(walltype* wal, int newx, int newy);
void dragpoint(walltype* wal, const DVector2& pos); void dragpoint(walltype* wal, const DVector2& pos);
int32_t inside(double x, double y, const sectortype* sect); int32_t inside(double x, double y, const sectortype* sect);
int insidePoly(double x, double y, const DVector2* points, int count); 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; } bool twoSided() const { return nextsector >= 0; }
double Length(); double Length();
void calcLength(); // this is deliberately not inlined and stored in a file where it can't be found at compile time. 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) void move(const DVector2& vec)
{ {
pos = vec; pos = vec;
@ -609,14 +608,6 @@ inline void walltype::moved()
sectorp()->dirty = EDirty::AllDirty; 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() inline double walltype::Length()
{ {
if ((lengthflags & 1) || (point2Wall()->lengthflags & 2)) 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) void wall_move(walltype* wal, double x, double y)
{ {
if (!wal) ThrowAbortException(X_READ_NIL, nullptr); if (!wal) ThrowAbortException(X_READ_NIL, nullptr);
wal->movexy(x, y); wal->move(DVector2(x, y));
} }
DEFINE_ACTION_FUNCTION_NATIVE(_walltype, move, wall_move) 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_SELF_STRUCT_PROLOGUE(walltype);
PARAM_FLOAT(x); PARAM_FLOAT(x);
PARAM_FLOAT(y); PARAM_FLOAT(y);
self->movexy(x, y); self->move(DVector2(x, y));
return 0; return 0;
} }

View file

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

View file

@ -589,6 +589,11 @@ static double LongSeek(double* pZVal, double a2, double a3, double a4)
return v4; 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) if (cx == 1)
{ {
auto pWall = SlideData[nSlide].pWall1; auto pWall = SlideData[nSlide].pWall1;
double x = pWall->pos.X; auto wlPos = pWall->pos;
double y = pWall->pos.Y; 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); if (nSeek.isZero())
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)
{ {
clipstate = clipmask; clipstate = clipmask;
} }
pWall = SlideData[nSlide].pStartWall; pWall = SlideData[nSlide].pStartWall;
wlPos = pWall->pos + nSeek;
x = pWall->pos.X + nSeekA; dragpoint(pWall, wlPos);
y = pWall->pos.Y + nSeekB;
dragpoint(SlideData[nSlide].pStartWall, x, y);
pWall = SlideData[nSlide].pWall3; 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; if (nSeek.isZero())
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) {
clipstate++; clipstate++;
} }
pWall = SlideData[nSlide].pWall2; pWall = SlideData[nSlide].pWall2;
wlPos = pWall->pos + nSeek;
x = pWall->pos.X + nSeekC; dragpoint(pWall, wlPos);
y = pWall->pos.Y + nSeekD;
dragpoint(SlideData[nSlide].pWall2, x, y);
} }
else if (cx == 0) // right branch else if (cx == 0) // right branch
{ {
auto pWall = SlideData[nSlide].pStartWall; auto pWall = SlideData[nSlide].pStartWall;
double x = pWall->pos.X; auto wlPos = pWall->pos;
double y = pWall->pos.Y; 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); if (nSeek.isZero())
int nSeekB = LongSeek(&y, SlideData[nSlide].pos[0].Y, 1.25, 1.25); {
dragpoint(SlideData[nSlide].pStartWall, x, y);
if (nSeekA == 0 && nSeekB == 0) {
clipstate = clipmask; clipstate = clipmask;
} }
pWall = SlideData[nSlide].pWall1; pWall = SlideData[nSlide].pWall1;
wlPos = pWall->pos + nSeek;
y = pWall->pos.Y + nSeekB; dragpoint(pWall, wlPos);
x = pWall->pos.X + nSeekA;
dragpoint(SlideData[nSlide].pWall1, x, y);
pWall = SlideData[nSlide].pWall2; 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; if (nSeek.isZero())
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) {
clipstate++; clipstate++;
} }
pWall = SlideData[nSlide].pWall3; pWall = SlideData[nSlide].pWall3;
wlPos = pWall->pos + nSeek;
y = pWall->pos.Y + nSeekD; dragpoint(pWall, wlPos);
x = pWall->pos.X + nSeekC;
dragpoint(SlideData[nSlide].pWall3, x, y);
} }
// loc_21A51: // loc_21A51:

View file

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