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
fix(gameengine): clear the power sabotage stamp when a new game starts
Olcay Seyganba1eea6ab8b0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 04e675c2a..c94e896d7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -163,6 +163,11 @@ map. Ctrl+A is still everything at once.- **Loading a save remembers what your guards were guarding.** The guard order was written to thefile one slot too far and overwrote the position it was guarding, so units restored from a savecould come back watching the wrong place.+- **A power sabotage does not follow you into the next game.** Shutting a base's power down set a+ timer, and nothing cleared that timer when the match ended. Start another game without quitting to+ the desktop and the player who had been sabotaged began the new map blacked out — no radar, no+ defences, nothing building — for the first sixteen minutes of it, and only on the machines that+ had watched the sabotage happen.- **Two machines playing the same match drift apart less.** Defeating a player, playing a secondmap without restarting, and the fingerprint the game uses to notice that two players have stoppedagreeing — all three had bugs that made one side quietly diverge from the other, and thediff --git a/GeneralsMD/Code/GameEngine/Include/Common/Energy.h b/GeneralsMD/Code/GameEngine/Include/Common/Energy.hindex 56acaf769..055de37e2 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/Energy.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/Energy.h@@ -73,6 +73,12 @@ public:{m_energyProduction = 0;m_energyConsumption = 0;+ // The Player objects are a fixed array that is reused for every game, and init() is what a+ // new game gets instead of a fresh constructor. EA reset the two counters here but not the+ // sabotage stamp, so a player who was power sabotaged in one game started the next one with+ // a stamp that is still in the future of a frame counter that has gone back to zero - no+ // power at all, on the machines that saw the sabotage and nowhere else.+ m_powerSabotagedTillFrame = 0;m_owner = owner;}diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 92d46e9d2..7b3370a23 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -35,6 +35,7 @@#include "GameNetwork/KeepAliveSchedule.h"#include "GameNetwork/CushionMetrics.h"#include "GameNetwork/LinkSimulation.h"+#include "Common/Energy.h"#include <float.h>#include "GameClient/Water.h"#include "GameLogic/Module/PhysicsUpdate.h"@@ -2605,6 +2606,26 @@ TEST(linksim_the_modulation_has_the_period_it_says_it_has)CHECK( (c > d ? c - d : d - c) <= 1u );}+// ---------------------------------------------------------------------------------------------+// Per-game state that a reused Player has to give back.+// ---------------------------------------------------------------------------------------------++TEST(energy_a_new_game_does_not_inherit_the_last_games_sabotage)+{+ Energy e;++ // a sabotage that runs to frame 30000 of the game that is being left+ e.setPowerSabotagedTillFrame( 30000 );+ CHECK_EQ( e.getPowerSabotagedTillFrame(), 30000u );++ // the Player array is reused, so the next game gets init() rather than a constructor. EA left+ // the stamp behind: the new game's frame counter starts at 0, so 30000 is still in the future+ // and that player produced no power at all until frame 30000 - on the machines that saw the+ // sabotage, and nowhere else.+ e.init( NULL );+ CHECK_EQ( e.getPowerSabotagedTillFrame(), 0u );+}+// ---------------------------------------------------------------------------------------------// The cushion, and the self-slug it drives (MULTIPLAYER 3.3). Two type defects met in the// middle here: an unsigned frame subtraction that could wrap, and an Int sentinel returned