- keep evaluation order of Random() calls defined.

This commit is contained in:
Christoph Oelckers 2016-01-20 09:25:30 +01:00
parent 7ea3e49332
commit e9b23cf833
15 changed files with 77 additions and 83 deletions

View File

@ -1294,9 +1294,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2)
}
angle = self->angle;
fixedvec3 pos = self->Vec3Offset(
(pr_fp2.Random2() << 9),
(pr_fp2.Random2() << 9),
fixed_t xo = (pr_fp2.Random2() << 9);
fixed_t yo = (pr_fp2.Random2() << 9);
fixedvec3 pos = self->Vec3Offset(xo, yo,
26*FRACUNIT + finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] - self->floorclip);
slope = finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] + (FRACUNIT/10);

View File

@ -23,10 +23,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_DripBlood)
{
AActor *mo;
fixedvec3 pos = self->Vec3Offset(
(pr_dripblood.Random2 () << 11),
(pr_dripblood.Random2 () << 11), 0);
mo = Spawn ("Blood", pos, ALLOW_REPLACE);
fixed_t xo = (pr_dripblood.Random2() << 11);
fixed_t yo = (pr_dripblood.Random2() << 11);
mo = Spawn ("Blood", self->Vec3Offset(xo, yo, 0), ALLOW_REPLACE);
mo->velx = pr_dripblood.Random2 () << 10;
mo->vely = pr_dripblood.Random2 () << 10;
mo->gravity = FRACUNIT/8;

View File

@ -193,11 +193,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur)
self->SetState (self->FindState ("Blur"));
return;
}
fixedvec3 pos = self->Vec3Offset(
(pr_pain.Random2()<<12),
(pr_pain.Random2()<<12),
(pr_pain.Random2()<<11));
mo = Spawn ("BishopPainBlur", pos, ALLOW_REPLACE);
fixed_t xo = (pr_pain.Random2() << 12);
fixed_t yo = (pr_pain.Random2() << 12);
fixed_t zo = (pr_pain.Random2() << 11);
mo = Spawn ("BishopPainBlur", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->angle = self->angle;

View File

@ -252,12 +252,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFX2)
delay = 16+(pr_dragonfx2()>>3);
for (i = 1+(pr_dragonfx2()&3); i; i--)
{
fixedvec3 pos = self->Vec3Offset(
((pr_dragonfx2()-128)<<14),
((pr_dragonfx2()-128)<<14),
((pr_dragonfx2()-128)<<12));
fixed_t xo = ((pr_dragonfx2() - 128) << 14);
fixed_t yo = ((pr_dragonfx2() - 128) << 14);
fixed_t zo = ((pr_dragonfx2() - 128) << 12);
mo = Spawn ("DragonExplosion", pos, ALLOW_REPLACE);
mo = Spawn ("DragonExplosion", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->tics = delay+(pr_dragonfx2()&3)*i*2;

View File

@ -112,11 +112,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordFlames)
for (i = 1+(pr_fswordflame()&3); i; i--)
{
fixedvec3 pos = self->Vec3Offset(
((pr_fswordflame()-128)<<12),
((pr_fswordflame()-128)<<12),
((pr_fswordflame()-128)<<11));
Spawn ("FSwordFlame", pos, ALLOW_REPLACE);
fixed_t xo = ((pr_fswordflame() - 128) << 12);
fixed_t yo = ((pr_fswordflame() - 128) << 12);
fixed_t zo = ((pr_fswordflame() - 128) << 11);
Spawn ("FSwordFlame", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
}
}

View File

@ -54,11 +54,10 @@ void A_FiredSpawnRock (AActor *actor)
break;
}
fixedvec3 pos = actor->Vec3Offset(
((pr_firedemonrock() - 128) << 12),
((pr_firedemonrock() - 128) << 12),
( pr_firedemonrock() << 11));
mo = Spawn (rtype, pos, ALLOW_REPLACE);
fixed_t xo = ((pr_firedemonrock() - 128) << 12);
fixed_t yo = ((pr_firedemonrock() - 128) << 12);
fixed_t zo = (pr_firedemonrock() << 11);
mo = Spawn (rtype, actor->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->target = actor;

View File

@ -197,11 +197,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn)
for (i = (pr_leaf()&3)+1; i; i--)
{
fixed_t xo = (pr_leaf.Random2() << 14);
fixed_t yo = (pr_leaf.Random2() << 14);
fixed_t zo = (pr_leaf() << 14);
mo = Spawn (pr_leaf()&1 ? PClass::FindClass ("Leaf1") : PClass::FindClass ("Leaf2"),
self->Vec3Offset(
(pr_leaf.Random2()<<14),
(pr_leaf.Random2()<<14),
(pr_leaf()<<14)), ALLOW_REPLACE);
self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
P_ThrustMobj (mo, self->angle, (pr_leaf()<<9)+3*FRACUNIT);
@ -278,10 +279,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode)
for (i = 0; i < 10; i++)
{
mo = Spawn ("ZArmorChunk", self->Vec3Offset(
((pr_soaexplode()-128)<<12),
((pr_soaexplode()-128)<<12),
(pr_soaexplode()*self->height/256)), ALLOW_REPLACE);
fixed_t xo = ((pr_soaexplode() - 128) << 12);
fixed_t yo = ((pr_soaexplode() - 128) << 12);
fixed_t zo = (pr_soaexplode()*self->height / 256);
mo = Spawn ("ZArmorChunk", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->SetState (mo->SpawnState + i);

View File

@ -228,11 +228,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap)
{
deltaZ = -10*FRACUNIT;
}
mo = Spawn(lightning,
self->Vec3Offset(
((pr_zap() - 128)*self->radius / 256),
((pr_zap() - 128)*self->radius / 256),
deltaZ), ALLOW_REPLACE);
fixed_t xo = ((pr_zap() - 128)*self->radius / 256);
fixed_t yo = ((pr_zap() - 128)*self->radius / 256);
mo = Spawn(lightning, self->Vec3Offset(xo, yo, deltaZ), ALLOW_REPLACE);
if (mo)
{
mo->lastenemy = self;

View File

@ -147,12 +147,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3)
while (numdropped-- > 0)
{
fixedvec3 pos = self->Vec3Offset(
(pr_wraithfx3()-128)<<11,
(pr_wraithfx3()-128)<<11,
(pr_wraithfx3()<<10));
fixed_t xo = (pr_wraithfx3() - 128) << 11;
fixed_t yo = (pr_wraithfx3() - 128) << 11;
fixed_t zo = pr_wraithfx3() << 10;
mo = Spawn ("WraithFX3", pos, ALLOW_REPLACE);
mo = Spawn ("WraithFX3", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->floorz = self->floorz;
@ -199,12 +198,11 @@ void A_WraithFX4 (AActor *self)
if (spawn4)
{
fixedvec3 pos = self->Vec3Offset(
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()<<10));
fixed_t xo = (pr_wraithfx4() - 128) << 12;
fixed_t yo = (pr_wraithfx4() - 128) << 12;
fixed_t zo = (pr_wraithfx4() << 10);
mo = Spawn ("WraithFX4", pos, ALLOW_REPLACE);
mo = Spawn ("WraithFX4", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->floorz = self->floorz;
@ -214,12 +212,11 @@ void A_WraithFX4 (AActor *self)
}
if (spawn5)
{
fixedvec3 pos = self->Vec3Offset(
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()-128)<<12,
(pr_wraithfx4()<<10));
fixed_t xo = (pr_wraithfx4() - 128) << 11;
fixed_t yo = (pr_wraithfx4() - 128) << 11;
fixed_t zo = (pr_wraithfx4()<<10);
mo = Spawn ("WraithFX5", pos, ALLOW_REPLACE);
mo = Spawn ("WraithFX5", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->floorz = self->floorz;

View File

@ -262,10 +262,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
i = (pr_freeze.Random2()) % (numChunks/4);
for (i = MAX (24, numChunks + i); i >= 0; i--)
{
mo = Spawn("IceChunk", self->Vec3Offset(
(((pr_freeze()-128)*self->radius)>>7),
(((pr_freeze()-128)*self->radius)>>7),
(pr_freeze()*self->height/255)), ALLOW_REPLACE);
fixed_t xo = (((pr_freeze() - 128)*self->radius) >> 7);
fixed_t yo = (((pr_freeze() - 128)*self->radius) >> 7);
fixed_t zo = (pr_freeze()*self->height / 255);
mo = Spawn("IceChunk", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
mo->SetState (mo->SpawnState + (pr_freeze()%3));

View File

@ -34,7 +34,8 @@ void P_SpawnDirt (AActor *actor, fixed_t radius)
const PClass *dtype = NULL;
AActor *mo;
fixedvec3 pos = actor->Vec3Angle(radius, pr_dirt() << 24, (pr_dirt() << 9) + FRACUNIT);
fixed_t zo = (pr_dirt() << 9) + FRACUNIT;
fixedvec3 pos = actor->Vec3Angle(radius, pr_dirt() << 24, zo);
char fmt[8];
mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6);

View File

@ -18,9 +18,10 @@ extern const PClass *QuestItemClasses[31];
DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud)
{
fixedvec3 pos = self->Vec3Offset((pr_bang4cloud.Random2() & 3) * 10240, (pr_bang4cloud.Random2() & 3) * 10240, 0);
fixed_t xo = (pr_bang4cloud.Random2() & 3) * 10240;
fixed_t yo = (pr_bang4cloud.Random2() & 3) * 10240;
Spawn("Bang4Cloud", pos, ALLOW_REPLACE);
Spawn("Bang4Cloud", self->Vec3Offset(xo, yo, 0), ALLOW_REPLACE);
}
// -------------------------------------------------------------------

View File

@ -843,10 +843,11 @@ void P_DisconnectEffect (AActor *actor)
if (!p)
break;
fixedvec3 pos = actor->Vec3Offset(
((M_Random()-128)<<9) * (actor->radius>>FRACBITS),
((M_Random()-128)<<9) * (actor->radius>>FRACBITS),
(M_Random()<<8) * (actor->height>>FRACBITS));
fixed_t xo = ((M_Random() - 128) << 9) * (actor->radius >> FRACBITS);
fixed_t yo = ((M_Random() - 128) << 9) * (actor->radius >> FRACBITS);
fixed_t zo = (M_Random() << 8) * (actor->height >> FRACBITS);
fixedvec3 pos = actor->Vec3Offset(xo, yo, zo);
p->x = pos.x;
p->y = pos.y;
p->z = pos.z;

View File

@ -3297,10 +3297,9 @@ void AActor::Tick ()
{
smokecounter = 0;
angle_t moveangle = R_PointToAngle2(0,0,velx,vely);
AActor * th = Spawn("GrenadeSmokeTrail", Vec3Offset(
- FixedMul (finecosine[(moveangle)>>ANGLETOFINESHIFT], radius*2) + (pr_rockettrail()<<10),
- FixedMul (finesine[(moveangle)>>ANGLETOFINESHIFT], radius*2) + (pr_rockettrail()<<10),
- (height>>3) * (velz>>16) + (2*height)/3), ALLOW_REPLACE);
fixed_t xo = -FixedMul(finecosine[(moveangle) >> ANGLETOFINESHIFT], radius * 2) + (pr_rockettrail() << 10);
fixed_t yo = -FixedMul(finesine[(moveangle) >> ANGLETOFINESHIFT], radius * 2) + (pr_rockettrail() << 10);
AActor * th = Spawn("GrenadeSmokeTrail", Vec3Offset(xo, yo, - (height>>3) * (velz>>16) + (2*height)/3), ALLOW_REPLACE);
if (th)
{
th->tics -= pr_rockettrail()&3;
@ -5266,10 +5265,10 @@ void P_RipperBlood (AActor *mo, AActor *bleeder)
PalEntry bloodcolor = bleeder->GetBloodColor();
const PClass *bloodcls = bleeder->GetBloodType();
fixedvec3 pos = mo->Vec3Offset(
(pr_ripperblood.Random2 () << 12),
(pr_ripperblood.Random2 () << 12),
(pr_ripperblood.Random2 () << 12));
fixed_t xo = (pr_ripperblood.Random2() << 12);
fixed_t yo = (pr_ripperblood.Random2() << 12);
fixed_t zo = (pr_ripperblood.Random2() << 12);
fixedvec3 pos = mo->Vec3Offset(xo, yo, zo);
int bloodtype = cl_bloodtype;

View File

@ -2606,10 +2606,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris)
for (i = 0; i < GetDefaultByType(debris)->health; i++)
{
mo = Spawn(debris, self->Vec3Offset(
((pr_spawndebris()-128)<<12),
((pr_spawndebris()-128)<<12),
(pr_spawndebris()*self->height/256+self->GetBobOffset())), ALLOW_REPLACE);
fixed_t xo = ((pr_spawndebris() - 128) << 12);
fixed_t yo = ((pr_spawndebris() - 128) << 12);
fixed_t zo = (pr_spawndebris()*self->height / 256 + self->GetBobOffset());
mo = Spawn(debris, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{
if (transfer_translation)
@ -2924,10 +2924,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst)
i = (pr_burst.Random2()) % (numChunks/4);
for (i = MAX (24, numChunks + i); i >= 0; i--)
{
mo = Spawn(chunk, self->Vec3Offset(
(((pr_burst()-128)*self->radius)>>7),
(((pr_burst()-128)*self->radius)>>7),
(pr_burst()*self->height/255 + self->GetBobOffset())), ALLOW_REPLACE);
fixed_t xo = (((pr_burst() - 128)*self->radius) >> 7);
fixed_t yo = (((pr_burst() - 128)*self->radius) >> 7);
fixed_t zo = (pr_burst()*self->height / 255 + self->GetBobOffset());
mo = Spawn(chunk, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo)
{