- improved RANDOM_P2F interface.

This commit is contained in:
Christoph Oelckers 2022-10-11 22:09:15 +02:00
parent f77ecbed32
commit 2a8dd6b955
2 changed files with 2 additions and 2 deletions

View file

@ -115,7 +115,7 @@ inline int RANDOM(void)
return randomseed;
}
int RANDOM_P2(int pwr_of_2) { return (RANDOM() & (pwr_of_2 - 1)); }
double RANDOM_P2F(int pwr_of_2) { return (RANDOM() & (pwr_of_2 - 1)) * maptoworld; }
double RANDOM_P2F(int pwr_of_2, int shift) { return (RANDOM() & ((pwr_of_2 << shift) - 1)) * (1./(1 << shift)); }
DAngle RANDOM_ANGLE() { return DAngle::fromBuild(RANDOM_P2(2048)); }
//

View file

@ -844,7 +844,7 @@ void SectorExp(DSWActor* actor, sectortype* sectp, double zh)
auto mid = SectorMidPoint(sectp);
// randomize the explosions
actor->spr.angle = DAngle::fromBuild(RANDOM_P2(256) - 128);
actor->spr.pos = { mid.X + RANDOM_P2F(256) - 16, mid.Y + RANDOM_P2F(1024) - 64, zh };
actor->spr.pos = { mid.X + RANDOM_P2F(16, 4) - 16, mid.Y + RANDOM_P2F(64, 4) - 64, zh };
// setup vars needed by SectorExp
ChangeActorSect(actor, sectp);