mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 22:51:50 +00:00
- floatify SE18 handler.
To store floars in temp_data without relying on map format conventions, the FixedTo functions were extended to allow custom precision.
This commit is contained in:
parent
1131eeb443
commit
9275c14c9c
4 changed files with 32 additions and 23 deletions
|
@ -15,24 +15,28 @@ __forceinline constexpr int64_t DivScaleL(int64_t a, int64_t b, int shift) { ret
|
|||
|
||||
#include "xs_Float.h"
|
||||
|
||||
template<int b = 16>
|
||||
inline fixed_t FloatToFixed(double f)
|
||||
{
|
||||
return xs_Fix<16>::ToFix(f);
|
||||
return xs_Fix<b>::ToFix(f);
|
||||
}
|
||||
|
||||
template<int b = 16>
|
||||
inline constexpr fixed_t IntToFixed(int32_t f)
|
||||
{
|
||||
return f << FRACBITS;
|
||||
return f << b;
|
||||
}
|
||||
|
||||
template<int b = 16>
|
||||
inline constexpr double FixedToFloat(fixed_t f)
|
||||
{
|
||||
return f * (1/65536.);
|
||||
return f * (1. / (1 << b));
|
||||
}
|
||||
|
||||
template<int b = 16>
|
||||
inline constexpr int32_t FixedToInt(fixed_t f)
|
||||
{
|
||||
return (f + FRACUNIT/2) >> FRACBITS;
|
||||
return (f + (1 << (b-1))) >> b;
|
||||
}
|
||||
|
||||
inline unsigned FloatToAngle(double f)
|
||||
|
|
|
@ -3927,41 +3927,44 @@ void handle_se18(DDukeActor *actor, bool morecheck)
|
|||
{
|
||||
auto sc = actor->sector();
|
||||
|
||||
double extra = sc->extra * zmaptoworld;
|
||||
double goal = FixedToFloat<8>(actor->temp_data[1]);
|
||||
if (actor->temp_data[0])
|
||||
{
|
||||
double extra = sc->extra * zmaptoworld;
|
||||
if (actor->spr.pal)
|
||||
{
|
||||
if (actor->int_ang() == 512)
|
||||
if (actor->spr.intangle == 512)
|
||||
{
|
||||
sc->add_int_ceilingz(-sc->extra);
|
||||
if (sc->int_ceilingz() <= actor->temp_data[1])
|
||||
sc->addceilingz(-extra);
|
||||
if (sc->ceilingz <= goal)
|
||||
{
|
||||
sc->set_int_ceilingz(actor->temp_data[1]);
|
||||
sc->setceilingz(goal);
|
||||
deletesprite(actor);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sc->add_int_floorz(sc->extra);
|
||||
sc->addfloorz(extra);
|
||||
if (morecheck)
|
||||
{
|
||||
DukeSectIterator it(actor->sector());
|
||||
while (auto a2 = it.Next())
|
||||
{
|
||||
if (a2->isPlayer() && a2->GetOwner())
|
||||
{
|
||||
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.Z += extra;
|
||||
}
|
||||
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
|
||||
{
|
||||
a2->add_int_z(sc->extra);
|
||||
a2->spr.pos.Z += extra;
|
||||
a2->floorz = sc->floorz;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sc->int_floorz() >= actor->temp_data[1])
|
||||
if (sc->floorz >= goal)
|
||||
{
|
||||
sc->set_int_floorz(actor->temp_data[1]);
|
||||
sc->setfloorz(goal);
|
||||
deletesprite(actor);
|
||||
return;
|
||||
}
|
||||
|
@ -3969,10 +3972,10 @@ void handle_se18(DDukeActor *actor, bool morecheck)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (actor->int_ang() == 512)
|
||||
if (actor->spr.intangle == 512)
|
||||
{
|
||||
sc->add_int_ceilingz(sc->extra);
|
||||
if (sc->int_ceilingz() >= actor->int_pos().Z)
|
||||
sc->addceilingz(extra);
|
||||
if (sc->ceilingz >= actor->spr.pos.Z)
|
||||
{
|
||||
sc->setceilingz(actor->spr.pos.Z);
|
||||
deletesprite(actor);
|
||||
|
@ -3981,22 +3984,24 @@ void handle_se18(DDukeActor *actor, bool morecheck)
|
|||
}
|
||||
else
|
||||
{
|
||||
sc->add_int_floorz(-sc->extra);
|
||||
sc->addfloorz(-extra);
|
||||
if (morecheck)
|
||||
{
|
||||
DukeSectIterator it(actor->sector());
|
||||
while (auto a2 = it.Next())
|
||||
{
|
||||
if (a2->isPlayer() && a2->GetOwner())
|
||||
{
|
||||
if (ps[a2->PlayerIndex()].on_ground == 1) ps[a2->PlayerIndex()].pos.Z -= extra;
|
||||
}
|
||||
if (a2->spr.zvel == 0 && a2->spr.statnum != STAT_EFFECTOR && a2->spr.statnum != STAT_PROJECTILE)
|
||||
{
|
||||
a2->add_int_z(-sc->extra);
|
||||
a2->spr.pos.Z -= extra;
|
||||
a2->floorz = sc->floorz;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sc->int_floorz() <= actor->int_pos().Z)
|
||||
if (sc->floorz <= actor->spr.pos.Z)
|
||||
{
|
||||
sc->setfloorz(actor->spr.pos.Z);
|
||||
deletesprite(actor);
|
||||
|
|
|
@ -523,7 +523,7 @@ bool activatewarpelevators(DDukeActor* actor, int d) //Parm = sectoreffectornum
|
|||
if (act2->spr.hitag == actor->spr.hitag)
|
||||
{
|
||||
act2->temp_data[0] = d;
|
||||
act2->temp_data[1] = d; //Make all check warp
|
||||
if (act2->spr.lotag == SE_17_WARP_ELEVATOR) act2->temp_data[1] = d; //Make all check warp (only SE17, in SE18 this is a coordinate)
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -638,15 +638,15 @@ void spawneffector(DDukeActor* actor, TArray<DDukeActor*>* actors)
|
|||
break;
|
||||
case SE_18_INCREMENTAL_SECTOR_RISE_FALL:
|
||||
|
||||
if (actor->int_ang() == 512)
|
||||
if (actor->spr.intangle == 512)
|
||||
{
|
||||
actor->temp_data[1] = sectp->int_ceilingz();
|
||||
actor->temp_data[1] = FloatToFixed<8>(sectp->ceilingz);
|
||||
if (actor->spr.pal)
|
||||
sectp->setceilingz(actor->spr.pos.Z);
|
||||
}
|
||||
else
|
||||
{
|
||||
actor->temp_data[1] = sectp->int_floorz();
|
||||
actor->temp_data[1] = FloatToFixed<8>(sectp->floorz);
|
||||
if (actor->spr.pal)
|
||||
sectp->setfloorz(actor->spr.pos.Z);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue