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): put back the handicap hunks staged into the wrong place
Olcay Seyganae1535d3718f
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cppindex 878795e74..e19c35599 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -2097,6 +2097,10 @@ Weapon& Weapon::operator=(const Weapon& that)//-------------------------------------------------------------------------------------------------Weapon::~Weapon()+{+}++//-------------------------------------------------------------------------------------------------// Damage that takes health off. The rest read the amount as a count or a yes, or end something outright:// a Kill Garrisoned of 1 at half is nobody, and healing scales on the one healed. Sniper is here because// its one shot, one man is the unit; a suicide's own death is HUGE_DAMAGE_AMOUNT, past any bonus.@@ -2129,9 +2133,6 @@ static Bool lobbyHandicapScalesDamage( DamageType type )}}-{-}-//-------------------------------------------------------------------------------------------------void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraBonusFlags, WeaponBonus& bonus) const{@@ -2149,16 +2150,6 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraB}// a unit on a rank ladder takes its grade's rate of fire, damage and range instead of the global-- // The lobby's handicap. In the bonus, so a shell or a delayed hit carries it past its firer's death.- // A point defense laser only shoots missiles, 100 damage at 100 health: one hit, one missile at any p.- const Int MISSILES_ONLY = WEAPON_ANTI_PROJECTILE | WEAPON_ANTI_SMALL_MISSILE | WEAPON_ANTI_BALLISTIC_MISSILE;- if (lobbyHandicapScalesDamage(m_template->getDamageType()) && (m_template->getAntiMask() & ~MISSILES_ONLY) != 0)- {- const Real handicap = source->getOwnerHandicap();- if (handicap != 1.0f)- bonus.setField(WeaponBonus::DAMAGE, bonus.getField(WeaponBonus::DAMAGE) * handicap);- }// VETERAN, ELITE and HERO lines, and from the Veteran pin its side's own lines (China's horde)const ThingTemplate* sourceTemplate = source->getTemplate();const RankLadder* ladder = TheGlobalData->getRankLadder(sourceTemplate);@@ -2206,6 +2197,16 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraBconst WeaponBonusSet* extra = m_template->getExtraBonus();if (extra)extra->appendBonuses(flags, bonus);++ // The lobby's handicap. In the bonus, so a shell or a delayed hit carries it past its firer's death.+ // A point defense laser only shoots missiles, 100 damage at 100 health: one hit, one missile at any p.+ const Int MISSILES_ONLY = WEAPON_ANTI_PROJECTILE | WEAPON_ANTI_SMALL_MISSILE | WEAPON_ANTI_BALLISTIC_MISSILE;+ if (lobbyHandicapScalesDamage(m_template->getDamageType()) && (m_template->getAntiMask() & ~MISSILES_ONLY) != 0)+ {+ const Real handicap = source->getOwnerHandicap();+ if (handicap != 1.0f)+ bonus.setField(WeaponBonus::DAMAGE, bonus.getField(WeaponBonus::DAMAGE) * handicap);+ }}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex eab2da4f6..f6069607f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -1465,8 +1465,6 @@ static Bool executePower( const ScenarioAction &action, Player *player, const Co}if (obj->isDisabled())- DEBUG_LOG(("SCENARIO: frame %d power slot %d '%s' %s: logic frame %u, ready on %u\n", action.frame, action.slot,- action.selector.str(), power->getPowerName().str(), TheGameLogic->getFrame(), power->getReadyFrame()));{// the seat's whole grid, since one building that draws more than its plants make is the usual causeDEBUG_LOG(("SCENARIO: frame %d power: '%s' is disabled (underpowered %d: seat makes %d, draws %d)\n",@@ -1485,6 +1483,8 @@ static Bool executePower( const ScenarioAction &action, Player *player, const Cocontinue;power->doSpecialPowerAtLocation( &target, INVALID_ANGLE, COMMAND_FIRED_BY_SCRIPT );++fired;+ DEBUG_LOG(("SCENARIO: frame %d power slot %d '%s' %s: logic frame %u, ready on %u\n", action.frame, action.slot,+ action.selector.str(), power->getPowerName().str(), TheGameLogic->getFrame(), power->getReadyFrame()));}DEBUG_LOG(("SCENARIO: frame %d power slot %d '%s' fired %d at (%.0f,%.0f)\n",diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 91a96207a..007e26c04 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -21105,19 +21105,6 @@ TEST(debug_log_cut_keeps_the_head_and_the_last_whole_lines)CHECK( text.compare( text.size() - ending.size(), ending.size(), ending ) == 0 );}-// The replay's writer: appends and header patches through the queue leave the bytes the same calls-// made straight on the FILE did, the way RecorderClass makes them.-TEST(file_write_queue_writes_what_the_file_calls_wrote)-{- const std::string queued = (std::filesystem::temp_directory_path() / "zh_fwq_queued.bin").string();- const std::string direct = (std::filesystem::temp_directory_path() / "zh_fwq_direct.bin").string();-- FILE *d = fopen( direct.c_str(), "wb" );- FileWriteQueue queue;- FILE *q = fopen( queued.c_str(), "wb" );- queue.start( q );- const char head[] = "GENREP\0\0\0\0";- fwrite( head, 1, 10, d );#include "Common/MultiplayerSettings.h"#include "GameNetwork/LANAPICallbacks.h"@@ -21289,6 +21276,19 @@ TEST(handicap_rides_the_slot_entry_and_full_health_leaves_the_string_unchanged)TheWritableGlobalData = savedData;}+// The replay's writer: appends and header patches through the queue leave the bytes the same calls+// made straight on the FILE did, the way RecorderClass makes them.+TEST(file_write_queue_writes_what_the_file_calls_wrote)+{+ const std::string queued = (std::filesystem::temp_directory_path() / "zh_fwq_queued.bin").string();+ const std::string direct = (std::filesystem::temp_directory_path() / "zh_fwq_direct.bin").string();++ FILE *d = fopen( direct.c_str(), "wb" );+ FileWriteQueue queue;+ FILE *q = fopen( queued.c_str(), "wb" );+ queue.start( q );+ const char head[] = "GENREP\0\0\0\0";+ fwrite( head, 1, 10, d );queue.write( head, 10 );const UnsignedInt patch = 0x11223344;long end = ftell( d ); // a patch before the first flush, as logGameStart's