mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-21 19:11:06 +00:00
loop cleanup in SnapSectors
This commit is contained in:
parent
9203ca425e
commit
269bac76cd
1 changed files with 8 additions and 30 deletions
|
@ -206,36 +206,20 @@ void SetAbove(int nCurSector, int nAboveSector)
|
||||||
|
|
||||||
void SnapSectors(int nSectorA, int nSectorB, int b)
|
void SnapSectors(int nSectorA, int nSectorB, int b)
|
||||||
{
|
{
|
||||||
// edx - nSectorA
|
for(auto& wal1 : wallsofsector(nSectorA))
|
||||||
// eax - nSectorB
|
|
||||||
|
|
||||||
int nWallA = sector[nSectorA].wallptr;
|
|
||||||
int nWallB = sector[nSectorB].wallptr;
|
|
||||||
|
|
||||||
int num1 = sector[nSectorA].wallnum;
|
|
||||||
int num2 = sector[nSectorB].wallnum;
|
|
||||||
|
|
||||||
int nCount = 0;
|
|
||||||
|
|
||||||
while (num1 > nCount)
|
|
||||||
{
|
{
|
||||||
int dx = nWallB;
|
int bestx = 0x7FFFFFF;
|
||||||
|
|
||||||
int bestx = 0x7FFFFFF;
|
|
||||||
int besty = bestx;
|
int besty = bestx;
|
||||||
|
|
||||||
int x = wall[nWallA].x;
|
int x = wal1.x;
|
||||||
int y = wall[nWallA].y;
|
int y = wal1.y;
|
||||||
|
|
||||||
walltype* bestwall = nullptr;
|
walltype* bestwall = nullptr;
|
||||||
|
|
||||||
int nCount2 = 0;
|
for(auto& wal2 : wallsofsector(nSectorB))
|
||||||
|
|
||||||
while (nCount2 < num2)
|
|
||||||
{
|
{
|
||||||
auto wal = &wall[dx];
|
int thisx = x - wal2.x;
|
||||||
int thisx = x - wal->x;
|
int thisy = y - wal2.y;
|
||||||
int thisy = y - wal->y;
|
|
||||||
int thisdist = abs(thisx) + abs(thisy);
|
int thisdist = abs(thisx) + abs(thisy);
|
||||||
int bestdist = abs(bestx) + abs(besty);
|
int bestdist = abs(bestx) + abs(besty);
|
||||||
|
|
||||||
|
@ -243,17 +227,11 @@ void SnapSectors(int nSectorA, int nSectorB, int b)
|
||||||
{
|
{
|
||||||
bestx = thisx;
|
bestx = thisx;
|
||||||
besty = thisy;
|
besty = thisy;
|
||||||
bestwall = wal;
|
bestwall = &wal2;
|
||||||
}
|
}
|
||||||
|
|
||||||
dx++;
|
|
||||||
nCount2++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dragpoint(bestwall, bestwall->x + bestx, bestwall->y + besty);
|
dragpoint(bestwall, bestwall->x + bestx, bestwall->y + besty);
|
||||||
|
|
||||||
nCount++;
|
|
||||||
nWallA++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
|
|
Loading…
Reference in a new issue