- a few random wrapper removals in Duke

This commit is contained in:
Christoph Oelckers 2022-09-03 17:43:39 +02:00
parent 6b0b8f944c
commit 4df1578064
3 changed files with 13 additions and 8 deletions

View file

@ -188,6 +188,11 @@ inline int32_t krand(void)
return ((uint32_t) randomseed)>>16;
}
inline double krandf(double span)
{
return (krand() & 0x7fff) * span / 32767;
}
inline int32_t ksqrt(uint64_t num)
{
return int(sqrt(double(num)));

View file

@ -3457,7 +3457,7 @@ void handle_se10(DDukeActor* actor, const int* specialtags)
auto sc = actor->sector();
int sh = actor->spr.hitag;
if ((sc->lotag & 0xff) == 27 || (sc->int_floorz() > sc->int_ceilingz() && (sc->lotag & 0xff) != 23) || sc->lotag == 32791 - 65536)
if ((sc->lotag & 0xff) == 27 || (sc->floorz > sc->ceilingz && (sc->lotag & 0xff) != 23) || sc->lotag == 32791 - 65536)
{
int j = 1;
@ -4508,7 +4508,7 @@ void handle_se35(DDukeActor *actor, int SMALLSMOKE, int EXPLOSION2)
{
auto sc = actor->sector();
if (sc->int_ceilingz() > actor->int_pos().Z)
if (sc->ceilingz > actor->spr.pos.Z)
for (int j = 0; j < 8; j++)
{
actor->add_int_ang(krand() & 511);
@ -4598,7 +4598,7 @@ void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2)
}
else actor->temp_data[0]++;
int x = sc->int_floorz() - sc->int_ceilingz();
double x = sc->floorz - sc->ceilingz;
if (rnd(64))
{
@ -4606,7 +4606,7 @@ void handle_se130(DDukeActor *actor, int countmax, int EXPLOSION2)
if (k)
{
k->spr.xrepeat = k->spr.yrepeat = 2 + (krand() & 7);
k->set_int_z(sc->int_floorz() - (krand() % x));
k->spr.pos.Z = sc->floorz + krandf(x);
k->add_int_ang(256 - (krand() % 511));
k->set_int_xvel(krand() & 127);
ssp(k, CLIPMASK0);

View file

@ -222,14 +222,14 @@ bool ifsquished(DDukeActor* actor, int p)
return false;
auto sectp = actor->sector();
int floorceildist = sectp->int_floorz() - sectp->int_ceilingz();
double floorceildist = sectp->floorz - sectp->ceilingz;
if (sectp->lotag != ST_23_SWINGING_DOOR)
{
if (actor->spr.pal == 1)
squishme = floorceildist < (32 << 8) && (sectp->lotag & 32768) == 0;
squishme = floorceildist < 32 && (sectp->lotag & 32768) == 0;
else
squishme = floorceildist < (12 << 8);
squishme = floorceildist < 12;
}
if (squishme)
@ -267,7 +267,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h
while (auto dasectp = search.GetNext())
{
if (((dasectp->int_ceilingz() - actor->int_pos().Z) >> 8) < r)
if (((dasectp->int_ceilingz() - actor->int_pos().Z) >> 8) < r) // what value range is this supposed to be?
{
auto wal = dasectp->firstWall();
int d = abs(wal->wall_int_pos().X - actor->int_pos().X) + abs(wal->wall_int_pos().Y - actor->int_pos().Y);