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.

feat(gameclient): captured superweapons join the superweapon bar

Olcay Seygan1a301c31acd8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 46e4ce6b9..62ea20920 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -641,6 +641,7 @@ found and fixed — EA's own, not port damage.**
- Pointing a worker at an ally's half-finished building no longer offers to finish it. The cursor promised to resume construction and the order it gave did nothing, because the check behind the cursor asked whether you were allied with whoever owned the site, and you are allied with yourself.
- Double-tapping 0 jumps the camera to that group.
- The mouse wheel no longer cancels a camera move already in progress.
+- A nuclear silo, a Scud Storm or a Particle Cannon you capture gets its button on the superweapon bar in the bottom right, next to your own. The bar only ever listed your own faction's powers, so a GLA player holding a Chinese silo had to find it on the map and select it to fire it.
- The end of a match no longer crashes on the score screen when paratroopers were still in the air over water. Clearing the battlefield dropped them one last time, they drowned, and the debris they left behind went looking for a player who had already been cleared away.
- Switching between fullscreen and windowed on Direct3D 9 no longer crashes. The graphics card can refuse a buffer for a moment while the screen changes, and the game wrote into the one it never got. It writes somewhere harmless now and asks again the next time it draws.
- Closing the window while the game is still loading closes the game. The close was turned into a message stamped with your player, and no player exists that early.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 85c6ef6b6..21bbc480f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -95,6 +95,8 @@ static Bool builderIsFree( AIUpdateInterface *ai, DozerAIInterface *dozer ); //
#include "GameNetwork/GameInfo.h"
+#include <algorithm>
+
#ifdef _INTERNAL
// for occasional debugging...
//#pragma optimize("", off)
@@ -6342,6 +6344,7 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
return;
// populate the button with commands defined
Int currentButton = 0;
+ std::vector<SpecialPowerType> shownPowerTypes;
const CommandButton *commandButton;
for( i = 0; i < m_currentlyUsedSpecialPowersButtons; i++ )
{
@@ -6522,6 +6525,9 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
}
}
+ if( commandButton->getSpecialPowerTemplate() )
+ shownPowerTypes.push_back( commandButton->getSpecialPowerTemplate()->getSpecialPowerType() );
+
// make sure the window is not hidden
m_specialPowerShortcutButtons[ currentButton ]->winHide( FALSE );
m_specialPowerShortcutButtonParents[ currentButton ]->winHide( FALSE );
@@ -6533,10 +6539,52 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
setControlCommand( m_specialPowerShortcutButtons[ currentButton ], commandButton );
GadgetButtonSetAltSound(m_specialPowerShortcutButtons[ currentButton ], "GUIGenShortcutClick");
currentButton++;
-
+
} // end else
} // end for i
+
+ //
+ // A superweapon the player took rather than built: a GLA player who captures a nuclear silo
+ // owns a power his own faction's shortcut set has no button for, so the silo could be fired
+ // only by finding it on the map and selecting it. Every other faction's shortcut set is asked
+ // for a button that fires a power this player now holds and nothing above has shown. Powers
+ // behind a science are left out: a general's power is bought, never captured.
+ //
+ for( Int t = 0; t < ThePlayerTemplateStore->getPlayerTemplateCount(); ++t )
+ {
+ const PlayerTemplate *otherFaction = ThePlayerTemplateStore->getNthPlayerTemplate( t );
+ if( otherFaction == player->getPlayerTemplate() || otherFaction->getSpecialPowerShortcutCommandSet().isEmpty() )
+ continue;
+ const CommandSet *otherSet = findCommandSet( otherFaction->getSpecialPowerShortcutCommandSet() );
+ if( otherSet == NULL )
+ continue;
+
+ for( Int b = 0; b < MAX_COMMANDS_PER_SET && currentButton < MAX_SPECIAL_POWER_SHORTCUTS; ++b )
+ {
+ const CommandButton *captured = otherSet->getCommandButton( b );
+ if( captured == NULL || !BitTest( captured->getOptions(), NEED_SPECIAL_POWER_SCIENCE ) )
+ continue;
+ const SpecialPowerTemplate *power = captured->getSpecialPowerTemplate();
+ if( power == NULL || power->getRequiredScience() != SCIENCE_INVALID )
+ continue;
+ const SpecialPowerType type = power->getSpecialPowerType();
+ if( std::find( shownPowerTypes.begin(), shownPowerTypes.end(), type ) != shownPowerTypes.end() )
+ continue;
+ if( player->findMostReadyShortcutSpecialPowerOfType( type ) == NULL )
+ continue;
+
+ shownPowerTypes.push_back( type );
+ m_specialPowerShortcutButtons[ currentButton ]->winHide( FALSE );
+ m_specialPowerShortcutButtonParents[ currentButton ]->winHide( FALSE );
+ m_specialPowerShortcutButtons[ currentButton ]->winEnable( TRUE );
+ m_specialPowerShortcutButtonParents[ currentButton ]->winEnable( TRUE );
+ setControlCommand( m_specialPowerShortcutButtons[ currentButton ], captured );
+ GadgetButtonSetAltSound( m_specialPowerShortcutButtons[ currentButton ], "GUIGenShortcutClick" );
+ currentButton++;
+ }
+ }
+
if(m_contextParent[ CP_MASTER ] && !m_contextParent[ CP_MASTER ]->winIsHidden() && m_specialPowerShortcutParent->winIsHidden())
{
showSpecialPowerShortcut();