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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): run logic on its own thread by default
Olcay Seygan3fedc7d914b0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex e746859a6..43f9bf7af 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -91,6 +91,7 @@ found and fixed — EA's own, not port damage.**- The match plays at the speed it always did. Every speed, delay, reload and build time in the game's data was converted to the shorter step, so a Crusader still fires every two seconds. The balance is the one you know.- Mission timers keep EA's clock. A map's countdown still ticks 30 times a second, because the missions read a running timer's number and act on it: the second American mission declares victory when its "Win" timer drops below 1700, and on the first 60-step builds that came after 38 seconds instead of 10. The cutscene cues, the random music pick in the campaigns and the generals' challenges, the shell map's camera loop and the lightning on Eastern Everglades and Rocky Rampage were off the same way, 30 maps in all, and run on their original timing again. Custom maps get the same.- Normal speed is 60 steps a second. Turbo mode, the one other speed a match can have, runs 120 of the same steps a second (see Turbo mode above). Replays still play as fast as you ask.+- The battle's arithmetic now runs on a thread of its own, beside the drawing. The game used to work out a step and then draw, one after the other, so a heavy step stalled the picture. Now the screen keeps drawing while the next step is worked out, and it pays most in the late game, where the steps are heaviest. In a late 4-player match, uncapped, frames slower than 16.7 ms (one 60 Hz refresh) fell from 23% to 0.8%, the slowest one frame in a hundred fell from 24.0 to 16.5 ms live and from 16.0-16.5 to 10.6-12.5 ms in a replay, and the average frame went from 15.2 to 11.8 ms. The battle still takes 60 steps a second, no more and no fewer. Network games keep each step in step with the other machines as before and do not overlap yet. If you want the old one-after-the-other loop back, start the game with `-logicthread 0`.- Replays and games saved in the middle of a match from earlier versions will not load in this one. The "Mission Start" saves a campaign makes between missions do, and every campaign mission can be picked from the campaign menu. 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. A shell fired point blank, close enough to arrive in one step, used to fly to the corner of the map and explode there, a bug since 2003; it hits its target now.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h b/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.hindex 72526f34a..a03d91b5c 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/LogicThread.h@@ -38,9 +38,10 @@ class Drawable;class Player;/**- * `-logicthread 0` (the default) runs the tick on the main thread, as it always ran.- * `-logicthread 1` hands every tick to a dedicated thread and waits for it: nothing overlaps- * yet, so nothing can race, and any code that cares which thread it is on shows itself.+ * `-logicthread 0` runs the tick on the main thread, as it always ran.+ * `-logicthread 1`, the default, hands every tick to a dedicated thread; outside a network game+ * the render draws beside it (phases 3 and 4), reading only the copies taken at the sync point.+ * `-logicthread 2` adds jitter to the tick to shake out races.** The census counts calls into the client made from the logic thread, one count per channel* of LOGIC-THREAD.md section 1's table. Each count is an entry point phase 2 has to turn intodiff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cppindex 796c1b6b7..495cd93a1 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/LogicThread.cpp@@ -425,8 +425,10 @@ void LogicThread::takeOverlapTimes( Real &tickMS, Real &waitMS )//-------------------------------------------------------------------------------------------------void LogicThread::init( void ){- char value[ 32 ];- if( !findEarlyCommandLineValue( L"-logicthread", value, sizeof(value) ) || atoi( value ) == 0 )+ // 1 unless the command line asks otherwise; -logicthread 0 keeps the tick on the main thread+ char value[ 32 ] = "1";+ findEarlyCommandLineValue( L"-logicthread", value, sizeof(value) );+ if( atoi( value ) == 0 )return;s_enabled = TRUE;