- 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; angle = self->angle;
fixedvec3 pos = self->Vec3Offset( fixed_t xo = (pr_fp2.Random2() << 9);
(pr_fp2.Random2() << 9), fixed_t yo = (pr_fp2.Random2() << 9);
(pr_fp2.Random2() << 9), fixedvec3 pos = self->Vec3Offset(xo, yo,
26*FRACUNIT + finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] - self->floorclip); 26*FRACUNIT + finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] - self->floorclip);
slope = finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] + (FRACUNIT/10); slope = finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] + (FRACUNIT/10);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -262,10 +262,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks)
i = (pr_freeze.Random2()) % (numChunks/4); i = (pr_freeze.Random2()) % (numChunks/4);
for (i = MAX (24, numChunks + i); i >= 0; i--) for (i = MAX (24, numChunks + i); i >= 0; i--)
{ {
mo = Spawn("IceChunk", self->Vec3Offset( fixed_t xo = (((pr_freeze() - 128)*self->radius) >> 7);
(((pr_freeze()-128)*self->radius)>>7), fixed_t yo = (((pr_freeze() - 128)*self->radius) >> 7);
(((pr_freeze()-128)*self->radius)>>7), fixed_t zo = (pr_freeze()*self->height / 255);
(pr_freeze()*self->height/255)), ALLOW_REPLACE); mo = Spawn("IceChunk", self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo) if (mo)
{ {
mo->SetState (mo->SpawnState + (pr_freeze()%3)); 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; const PClass *dtype = NULL;
AActor *mo; 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]; char fmt[8];
mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6); 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) 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) if (!p)
break; break;
fixedvec3 pos = actor->Vec3Offset(
((M_Random()-128)<<9) * (actor->radius>>FRACBITS), fixed_t xo = ((M_Random() - 128) << 9) * (actor->radius >> FRACBITS);
((M_Random()-128)<<9) * (actor->radius>>FRACBITS), fixed_t yo = ((M_Random() - 128) << 9) * (actor->radius >> FRACBITS);
(M_Random()<<8) * (actor->height>>FRACBITS)); fixed_t zo = (M_Random() << 8) * (actor->height >> FRACBITS);
fixedvec3 pos = actor->Vec3Offset(xo, yo, zo);
p->x = pos.x; p->x = pos.x;
p->y = pos.y; p->y = pos.y;
p->z = pos.z; p->z = pos.z;

View file

@ -3297,10 +3297,9 @@ void AActor::Tick ()
{ {
smokecounter = 0; smokecounter = 0;
angle_t moveangle = R_PointToAngle2(0,0,velx,vely); angle_t moveangle = R_PointToAngle2(0,0,velx,vely);
AActor * th = Spawn("GrenadeSmokeTrail", Vec3Offset( fixed_t xo = -FixedMul(finecosine[(moveangle) >> ANGLETOFINESHIFT], radius * 2) + (pr_rockettrail() << 10);
- FixedMul (finecosine[(moveangle)>>ANGLETOFINESHIFT], radius*2) + (pr_rockettrail()<<10), fixed_t yo = -FixedMul(finesine[(moveangle) >> ANGLETOFINESHIFT], radius * 2) + (pr_rockettrail() << 10);
- 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);
- (height>>3) * (velz>>16) + (2*height)/3), ALLOW_REPLACE);
if (th) if (th)
{ {
th->tics -= pr_rockettrail()&3; th->tics -= pr_rockettrail()&3;
@ -5266,10 +5265,10 @@ void P_RipperBlood (AActor *mo, AActor *bleeder)
PalEntry bloodcolor = bleeder->GetBloodColor(); PalEntry bloodcolor = bleeder->GetBloodColor();
const PClass *bloodcls = bleeder->GetBloodType(); const PClass *bloodcls = bleeder->GetBloodType();
fixedvec3 pos = mo->Vec3Offset( fixed_t xo = (pr_ripperblood.Random2() << 12);
(pr_ripperblood.Random2 () << 12), fixed_t yo = (pr_ripperblood.Random2() << 12);
(pr_ripperblood.Random2 () << 12), fixed_t zo = (pr_ripperblood.Random2() << 12);
(pr_ripperblood.Random2 () << 12)); fixedvec3 pos = mo->Vec3Offset(xo, yo, zo);
int bloodtype = cl_bloodtype; 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++) for (i = 0; i < GetDefaultByType(debris)->health; i++)
{ {
mo = Spawn(debris, self->Vec3Offset( fixed_t xo = ((pr_spawndebris() - 128) << 12);
((pr_spawndebris()-128)<<12), fixed_t yo = ((pr_spawndebris() - 128) << 12);
((pr_spawndebris()-128)<<12), fixed_t zo = (pr_spawndebris()*self->height / 256 + self->GetBobOffset());
(pr_spawndebris()*self->height/256+self->GetBobOffset())), ALLOW_REPLACE); mo = Spawn(debris, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo) if (mo)
{ {
if (transfer_translation) if (transfer_translation)
@ -2924,10 +2924,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst)
i = (pr_burst.Random2()) % (numChunks/4); i = (pr_burst.Random2()) % (numChunks/4);
for (i = MAX (24, numChunks + i); i >= 0; i--) for (i = MAX (24, numChunks + i); i >= 0; i--)
{ {
mo = Spawn(chunk, self->Vec3Offset( fixed_t xo = (((pr_burst() - 128)*self->radius) >> 7);
(((pr_burst()-128)*self->radius)>>7), fixed_t yo = (((pr_burst() - 128)*self->radius) >> 7);
(((pr_burst()-128)*self->radius)>>7), fixed_t zo = (pr_burst()*self->height / 255 + self->GetBobOffset());
(pr_burst()*self->height/255 + self->GetBobOffset())), ALLOW_REPLACE); mo = Spawn(chunk, self->Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
if (mo) if (mo)
{ {