Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/ZDoom/gzdoom into gzdoom_…
Browse files Browse the repository at this point in the history
…unstable
nashmuhandes committed Jan 30, 2025
2 parents 8ab04dd + 3adddd6 commit 8946aba
Showing 9 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/common/engine/m_random.h
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@

#include <stdio.h>
#include "basics.h"
#include "tarray.h"
#include "sfmt/SFMTObj.h"

class FSerializer;
2 changes: 2 additions & 0 deletions src/playsim/actor.h
Original file line number Diff line number Diff line change
@@ -549,6 +549,8 @@ enum ActorBounceFlag
BOUNCE_BounceOnUnrips = 1<<16, // projectile bounces on actors with DONTRIP
BOUNCE_NotOnSky = 1<<17, // Don't bounce on sky floors / ceilings / walls
BOUNCE_DEH = 1<<18, // Flag was set through Dehacked.
BOUNCE_KeepAngle = 1<<19, // Don't change yaw when bouncing off a surface.
BOUNCE_ModifyPitch = 1<<20, // Change pitch when bouncing off a surface.

BOUNCE_TypeMask = BOUNCE_Walls | BOUNCE_Floors | BOUNCE_Ceilings | BOUNCE_Actors | BOUNCE_AutoOff | BOUNCE_HereticType | BOUNCE_MBF,

5 changes: 5 additions & 0 deletions src/playsim/p_acs.cpp
Original file line number Diff line number Diff line change
@@ -10337,6 +10337,11 @@ int DLevelScript::RunScript()
}
}

// There are several or more p-codes that can trigger a division or modulus of zero.
// Reset the active behavior back to the original if this happens.
if (state == SCRIPT_DivideBy0 || state == SCRIPT_ModulusBy0)
activeBehavior = savedActiveBehavior;

if (runaway != 0 && InModuleScriptNumber >= 0)
{
auto scriptptr = activeBehavior->GetScriptPtr(InModuleScriptNumber);
1 change: 1 addition & 0 deletions src/playsim/p_effect.h
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ enum EParticleFlags
SPF_NOFACECAMERA = 1 << 12,
SPF_ROLLCENTER = 1 << 13,
SPF_STRETCHPIXELS = 1 << 14,
SPF_ALLOWSHADERS = 1 << 15,
};

class DVisualThinker;
12 changes: 9 additions & 3 deletions src/playsim/p_map.cpp
Original file line number Diff line number Diff line change
@@ -3653,7 +3653,8 @@ bool FSlide::BounceWall(AActor *mo)
}
moveangle = mo->Vel.Angle();
deltaangle = (lineangle * 2) - moveangle;
mo->Angles.Yaw = deltaangle;
if (!(mo->BounceFlags & BOUNCE_KeepAngle))
mo->Angles.Yaw = deltaangle;

movelen = mo->Vel.XY().Length() * GetWallBounceFactor(mo);

@@ -3751,8 +3752,10 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
DAngle angle = BlockingMobj->AngleTo(mo) + DAngle::fromDeg((pr_bounce() % 16) - 8);
double speed = mo->VelXYToSpeed() * GetWallBounceFactor(mo); // [GZ] was 0.75, using wallbouncefactor seems more consistent
if (fabs(speed) < EQUAL_EPSILON) speed = 0;
mo->Angles.Yaw = angle;
mo->VelFromAngle(speed);
if (!(mo->BounceFlags & BOUNCE_KeepAngle))
mo->Angles.Yaw = angle;
mo->Vel.X = speed * angle.Cos();
mo->Vel.Y = speed * angle.Sin();
mo->PlayBounceSound(true, 1.0);
}
else
@@ -3781,6 +3784,9 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop)
mo->Vel *= mo->bouncefactor;
}

if (mo->BounceFlags & BOUNCE_ModifyPitch)
mo->Angles.Pitch = -VecToAngle(mo->Vel.XY().Length(), mo->Vel.Z);

mo->PlayBounceSound(true, 1.0);
if (mo->BounceFlags & BOUNCE_MBF) // Bring it to rest below a certain speed
{
9 changes: 7 additions & 2 deletions src/playsim/p_mobj.cpp
Original file line number Diff line number Diff line change
@@ -1824,7 +1824,8 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
if (BounceFlags & (BOUNCE_HereticType | BOUNCE_MBF))
{
Vel -= norm * dot;
AngleFromVel();
if (!(BounceFlags & BOUNCE_KeepAngle))
AngleFromVel();
if (!(BounceFlags & BOUNCE_MBF)) // Heretic projectiles die, MBF projectiles don't.
{
flags |= MF_INBOUNCE;
@@ -1838,9 +1839,13 @@ bool AActor::FloorBounceMissile (secplane_t &plane, bool is3DFloor)
{
// The reflected velocity keeps only about 70% of its original speed
Vel = (Vel - norm * dot) * bouncefactor;
AngleFromVel();
if (!(BounceFlags & BOUNCE_KeepAngle))
AngleFromVel();
}

if (BounceFlags & BOUNCE_ModifyPitch)
Angles.Pitch = -VecToAngle(Vel.XY().Length(), Vel.Z);

PlayBounceSound(true, 1.0);

// Set bounce state
2 changes: 1 addition & 1 deletion src/rendering/hwrenderer/scene/hw_sprites.cpp
Original file line number Diff line number Diff line change
@@ -1501,7 +1501,7 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, FRenderState& state, particle_t *
foglevel = (uint8_t)clamp<short>(sector->lightlevel, 0, 255);

trans = particle->alpha;
OverrideShader = 0;
OverrideShader = (particle->flags & SPF_ALLOWSHADERS) ? -1 : 0;
modelframe = nullptr;
texture = nullptr;
topclip = LARGE_VALUE;
2 changes: 2 additions & 0 deletions src/scripting/thingdef_data.cpp
Original file line number Diff line number Diff line change
@@ -407,6 +407,8 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG2(BOUNCE_NotOnShootables, DONTBOUNCEONSHOOTABLES, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_BounceOnUnrips, BOUNCEONUNRIPPABLES, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_NotOnSky, DONTBOUNCEONSKY, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_KeepAngle, KEEPBOUNCEANGLE, AActor, BounceFlags),
DEFINE_FLAG2(BOUNCE_ModifyPitch, BOUNCEMODIFIESPITCH, AActor, BounceFlags),

DEFINE_FLAG2(OF_Transient, NOSAVEGAME, AActor, ObjectFlags),

1 change: 1 addition & 0 deletions wadsrc/static/zscript/constants.zs
Original file line number Diff line number Diff line change
@@ -723,6 +723,7 @@ enum EParticleFlags
SPF_NOFACECAMERA = 1 << 12,
SPF_ROLLCENTER = 1 << 13,
SPF_STRETCHPIXELS = 1 << 14,
SPF_ALLOWSHADERS = 1 << 15,

SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
};

0 comments on commit 8946aba

Please sign in to comment.