Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): shell paths keep retail steps, mod tracers fly flat

Olcay Seyganed6d48c6c2c4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5133736b5..4993a11e9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,7 @@ found and fixed — EA's own, not port damage.**
- Normal speed is now the fastest a skirmish or a mission runs. The game speed choice in the skirmish lobby offers x0.5, x0.75 and x1, and x1 is 60 steps a second; the x1.5 and x2 it used to have are gone. A lobby left on one of them, or a saved game made at one, comes back at x1, and the speed console command and a mission's own script stay between half speed and normal as well. Replays still play as fast as you ask, and network games are untouched.
- Replays and saved games from earlier versions will not load in this one. A player on an earlier version cannot join a match with a player on this version, whichever of them hosts, so a LAN party needs everyone on the same build.
- Guns fire at their 2003 rate again. After a shot the game goes back to aiming for a step before it can fire again, which at 30 steps put a 100 millisecond Quad Cannon on a shot every 0.133 seconds; at 60 the same loop fired it every 0.100, a third faster. Shot delays and reloads are rounded to the old step and a gun's next shot is held to the old rhythm, so every weapon fires on the frames it did in 2003. A turret with no turning speed in its data rose twice as fast as it should, aircraft weighed their thrust against gravity at half strength, and a unit hit on the step before still counted as untouched for stealth. All three keep EA's timing now.
+- Mod guns shoot straight again. Shockwave Chaos and other mods give their machine guns and autocannons a shell that arcs 300 high but flies so fast that the 30-step game only ever put it at the muzzle and on the target. At 60 steps the shell stopped partway up that arc, so in Chaos a Humvee's autocannon round went 200 into the air before coming down on a tank 100 away. A shell now passes through the points it passed through in 2003 and flies straight between them, so mod rounds hit straight and the original game's shells fly the same arcs.
## Zero Hour on a Mac, on Linux and on the Steam Deck
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
index 7bbebcd9c..c4503954c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp
@@ -479,14 +479,40 @@ Bool DumbProjectileBehavior::calcFlightPath(Bool recalcNumSegments)
// With four control points, we have a curve. We will decide how many frames we want to take to get to the target,
// and fill our vector with those curve points.
+ //
+ // The curve is sampled where a retail (30 Hz) frame put the shell, and the frames in between fly the
+ // straight line to the next sample, so a path looks and lasts as it did. Sampled at every frame, a
+ // fast shot met points of the curve retail never visited: mods give an instant tracer FirstHeight 300
+ // and WeaponSpeed 9999, which retail sampled at its two ends only, and at 60 Hz the third of four
+ // samples flew it 200 into the air.
BezierSegment flightCurve( controlPoints );
+ Int retailSegments;
if (recalcNumSegments)
{
Real flightDistance = flightCurve.getApproximateLength();
- m_flightPathSegments = floatToIntAsMsvc( (float)ceil( flightDistance / m_flightPathSpeed ) );
+ retailSegments = floatToIntAsMsvc( (float)ceil( flightDistance / (m_flightPathSpeed * LOGICFRAMES_PER_RETAIL_FRAME) ) );
+ }
+ else
+ {
+ retailSegments = m_flightPathSegments > 1 ? (m_flightPathSegments - 1) / LOGICFRAMES_PER_RETAIL_FRAME + 1 : m_flightPathSegments;
+ }
+ VecCoord3D retailPath;
+ flightCurve.getSegmentPoints( retailSegments, &retailPath );
+ m_flightPathSegments = retailSegments > 1 ? (retailSegments - 1) * LOGICFRAMES_PER_RETAIL_FRAME + 1 : retailSegments;
+ m_flightPath.resize( m_flightPathSegments );
+ for (Int i = 0; i < m_flightPathSegments; ++i)
+ {
+ Int sample = i / LOGICFRAMES_PER_RETAIL_FRAME;
+ Int between = i % LOGICFRAMES_PER_RETAIL_FRAME;
+ m_flightPath[i] = retailPath[sample];
+ if (between != 0)
+ {
+ Real t = (Real)between / LOGICFRAMES_PER_RETAIL_FRAME;
+ m_flightPath[i].x += t * (retailPath[sample + 1].x - retailPath[sample].x);
+ m_flightPath[i].y += t * (retailPath[sample + 1].y - retailPath[sample].y);
+ m_flightPath[i].z += t * (retailPath[sample + 1].z - retailPath[sample].z);
+ }
}
- flightCurve.getSegmentPoints( m_flightPathSegments, &m_flightPath );
- DEBUG_ASSERTCRASH(m_flightPathSegments == m_flightPath.size(), ("m_flightPathSegments mismatch"));
#if defined(_DEBUG) || defined(_INTERNAL)
if( TheGlobalData->m_debugProjectilePath )