- Exhumed: floatified most of CreatePushBlock

This commit is contained in:
Christoph Oelckers 2022-08-30 22:16:18 +02:00
parent 32dab95c8d
commit 70d0b2ea93

View file

@ -775,52 +775,45 @@ void CreatePushBlock(sectortype* pSector)
{ {
int nBlock = GrabPushBlock(); int nBlock = GrabPushBlock();
int xSum = 0; double xSumm = 0;
int ySum = 0; double ySumm = 0;
for (auto& wal : wallsofsector(pSector)) for (auto& wal : wallsofsector(pSector))
{ {
xSum += wal.wall_int_pos().X; xSumm += wal.pos.X;
ySum += wal.wall_int_pos().Y; ySumm += wal.pos.Y;
} }
int xAvg = xSum / pSector->wallnum; double xAvgg = xSumm / pSector->wallnum;
int yAvg = ySum / pSector->wallnum; double yAvgg = ySumm / pSector->wallnum;
sBlockInfo[nBlock].x = xAvg; sBlockInfo[nBlock].x = xAvgg * worldtoint;
sBlockInfo[nBlock].y = yAvg; sBlockInfo[nBlock].y = yAvgg * worldtoint;
auto pActor = insertActor(pSector, 0); auto pActor = insertActor(pSector, 0);
sBlockInfo[nBlock].pActor = pActor; sBlockInfo[nBlock].pActor = pActor;
pActor->set_int_pos({ xAvg, yAvg, pSector->int_floorz() - 256 }); pActor->spr.pos = { xAvgg, yAvgg, pSector->floorz- 1 };
pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE; pActor->spr.cstat = CSTAT_SPRITE_INVISIBLE;
int var_28 = 0; double mindist = 0;
for (auto& wal : wallsofsector(pSector)) for (auto& wal : wallsofsector(pSector))
{ {
uint32_t xDiff = abs(xAvg - wal.wall_int_pos().X); double xDiff = abs(xAvgg - wal.pos.X);
uint32_t yDiff = abs(yAvg - wal.wall_int_pos().Y); double yDiff = abs(yAvgg - wal.pos.Y);
uint32_t sqrtNum = xDiff * xDiff + yDiff * yDiff; double nSqrt = g_sqrt(xDiff * xDiff + yDiff * yDiff);
if (sqrtNum > INT_MAX) if (nSqrt > mindist) {
{ mindist = nSqrt;
DPrintf(DMSG_WARNING, "%s %d: overflow\n", __func__, __LINE__);
sqrtNum = INT_MAX;
}
int nSqrt = ksqrt(sqrtNum);
if (nSqrt > var_28) {
var_28 = nSqrt;
} }
} }
sBlockInfo[nBlock].field_8 = var_28; sBlockInfo[nBlock].field_8 = mindist * worldtoint;
pActor->spr.clipdist = (var_28 & 0xFF) << 2; pActor->spr.clipdist = (int(mindist * worldtoint) & 0xFF) << 2;
pSector->extra = nBlock; pSector->extra = nBlock;
} }