From 9c37582534047c30df11531a523630773c5edca7 Mon Sep 17 00:00:00 2001 From: Afevis Date: Mon, 3 Mar 2025 11:00:57 -0700 Subject: [PATCH 1/5] Backports zh 1.03 scud storm exploit fix --- .../GameClient/MessageStream/SelectionXlat.cpp | 12 ++++++++++++ .../GameEngine/Source/GameLogic/AI/AIStates.cpp | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp index aa60a4139d..78391434a3 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp @@ -1105,6 +1105,18 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa else { + // =================== Community Fix Start ================= + // Backported Zero Hour 1.03 scud storm exploit fix // + Drawable *draw = TheInGameUI->getFirstSelectedDrawable(); + if( draw && draw->isKindOf( KINDOF_STRUCTURE ) ) + { + //Kris: Jan 12, 2005 + //Can't select other units if you have a structure selected. So deselect the structure to prevent + //group force attack exploit. + TheInGameUI->deselectAllDrawables(); + } + // =================== Community Fix End ================= + // no need to send two messages for selecting the same group. TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_ADD_TEAM0 + group)); Player *player = ThePlayerList->getLocalPlayer(); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index b5c71fbba5..ed07f7afac 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5263,6 +5263,19 @@ StateReturnType AIAttackState::onEnter() if (m_attackParameters && m_attackParameters->shouldExit(getMachine())) return STATE_SUCCESS; + + // =================== Community Fix Start ================= + // Backported Zero Hour 1.03 scud storm exploit fix // + //Kris: Jan 12, 2005 + //Don't allow units under construction to attack! The selection/action manager system was responsible for preventing this + //from ever happening, but failed in two cases which I fixed. This is an extra check to mitigate cheats. + if( source->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) ) + { + return STATE_FAILURE; + } + // =================== Community Fix End ================= + + // if all of our weapons are out of ammo, can't attack. // (this can happen for units which never auto-reload, like the Raptor) if (source->isOutOfAmmo() && !source->isKindOf(KINDOF_PROJECTILE)) From 0d1965d6f21f5c142e6e518e4a8c7d25261cd982 Mon Sep 17 00:00:00 2001 From: Afevis Date: Tue, 4 Mar 2025 03:04:38 -0700 Subject: [PATCH 2/5] updated comment --- .../Source/GameClient/MessageStream/SelectionXlat.cpp | 4 +--- Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp index 78391434a3..41faff0ffb 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp @@ -1105,8 +1105,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa else { - // =================== Community Fix Start ================= - // Backported Zero Hour 1.03 scud storm exploit fix // + // TheSuperHackers @bugfix @ShizCalev 04/04/2025 - Backported Zero Hour 1.03 scud storm exploit fix Drawable *draw = TheInGameUI->getFirstSelectedDrawable(); if( draw && draw->isKindOf( KINDOF_STRUCTURE ) ) { @@ -1115,7 +1114,6 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa //group force attack exploit. TheInGameUI->deselectAllDrawables(); } - // =================== Community Fix End ================= // no need to send two messages for selecting the same group. TheMessageStream->appendMessage((GameMessage::Type)(GameMessage::MSG_ADD_TEAM0 + group)); diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index ed07f7afac..1d92a9c714 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5264,8 +5264,7 @@ StateReturnType AIAttackState::onEnter() return STATE_SUCCESS; - // =================== Community Fix Start ================= - // Backported Zero Hour 1.03 scud storm exploit fix // + // TheSuperHackers @bugfix @ShizCalev 04/04/2025 - Backported Zero Hour 1.03 scud storm exploit fix //Kris: Jan 12, 2005 //Don't allow units under construction to attack! The selection/action manager system was responsible for preventing this //from ever happening, but failed in two cases which I fixed. This is an extra check to mitigate cheats. @@ -5273,7 +5272,6 @@ StateReturnType AIAttackState::onEnter() { return STATE_FAILURE; } - // =================== Community Fix End ================= // if all of our weapons are out of ammo, can't attack. From 49f40f5840c2e6e04ba689546199066958a0ad5c Mon Sep 17 00:00:00 2001 From: Afevis Date: Tue, 4 Mar 2025 03:24:12 -0700 Subject: [PATCH 3/5] Update AIStates.cpp --- Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 1d92a9c714..2476fb71db 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5264,7 +5264,7 @@ StateReturnType AIAttackState::onEnter() return STATE_SUCCESS; - // TheSuperHackers @bugfix @ShizCalev 04/04/2025 - Backported Zero Hour 1.03 scud storm exploit fix + // TheSuperHackers @bugfix @ShizCalev 04/04/2025 - Backported Zero Hour 1.03 scud storm exploit fix - pr #334 //Kris: Jan 12, 2005 //Don't allow units under construction to attack! The selection/action manager system was responsible for preventing this //from ever happening, but failed in two cases which I fixed. This is an extra check to mitigate cheats. From d160c905713446fe82a521d667bd6287af24fbdd Mon Sep 17 00:00:00 2001 From: Afevis Date: Wed, 2 Jul 2025 16:05:11 -0600 Subject: [PATCH 4/5] Apply suggestions from code review --- .../GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp | 1 - Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 1 - 2 files changed, 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp index 41faff0ffb..45e7bd8c21 100644 --- a/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp +++ b/Generals/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp @@ -1105,7 +1105,6 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa else { - // TheSuperHackers @bugfix @ShizCalev 04/04/2025 - Backported Zero Hour 1.03 scud storm exploit fix Drawable *draw = TheInGameUI->getFirstSelectedDrawable(); if( draw && draw->isKindOf( KINDOF_STRUCTURE ) ) { diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 2476fb71db..9074db62d8 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5264,7 +5264,6 @@ StateReturnType AIAttackState::onEnter() return STATE_SUCCESS; - // TheSuperHackers @bugfix @ShizCalev 04/04/2025 - Backported Zero Hour 1.03 scud storm exploit fix - pr #334 //Kris: Jan 12, 2005 //Don't allow units under construction to attack! The selection/action manager system was responsible for preventing this //from ever happening, but failed in two cases which I fixed. This is an extra check to mitigate cheats. From 2ab4b8511a914f41c7726d1ab4e95aa174e6562b Mon Sep 17 00:00:00 2001 From: Afevis Date: Fri, 11 Jul 2025 16:29:59 -0600 Subject: [PATCH 5/5] Apply suggestions from code review --- Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp index 9074db62d8..d1ea15ec71 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp @@ -5271,8 +5271,6 @@ StateReturnType AIAttackState::onEnter() { return STATE_FAILURE; } - - // if all of our weapons are out of ammo, can't attack. // (this can happen for units which never auto-reload, like the Raptor) if (source->isOutOfAmmo() && !source->isKindOf(KINDOF_PROJECTILE))