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.

fix(gameclient): a build queue belongs to one building, not a selection

Olcay Seygan344274e7ac83
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
index 68a5c2dc2..ba2871814 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp
@@ -2356,6 +2356,11 @@ Bool ControlBar::cancelLastQueuedUnit( const ThingTemplate *thing )
if( thing == NULL )
return FALSE;
+ // with several producers selected there is no one queue on the bar to take from, and the
+ // buttons show no queue either, so there is nothing here to cancel
+ if( m_currContext == CB_CONTEXT_MULTI_SELECT )
+ return FALSE;
+
//
// Look across every selected producer, not just the representative one. A shift-click spreads
// a batch over all the selected factories, so cancelling only ever on the representative left
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
index 9a94eb2d3..13d06be30 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
@@ -704,17 +704,31 @@ void ControlBar::updateContextCommand( void )
//
if( command->getCommandType() == GUI_COMMAND_UNIT_BUILD && pu )
{
- Int queued = 0;
- for( const ProductionEntry *p = pu->firstProduction(); p; p = pu->nextProduction( p ) )
- if( p->getProductionType() == PRODUCTION_UNIT &&
- p->getProductionObject() == command->getThingTemplate() )
- queued++;
- GadgetButtonSetCount( win, queued );
-
- const ProductionEntry *first = pu->firstProduction();
- if( first && first->getProductionType() == PRODUCTION_UNIT &&
- first->getProductionObject() == command->getThingTemplate() )
- GadgetButtonDrawClock( win, first->getPercentComplete(), BuildClockColor );
+ //
+ // a queue belongs to one building. With several producers selected the bar shows the
+ // representative's queue, which is a lie about the rest of the selection, so the badge
+ // and the radial fill stay off (and right-click cancel is refused, see
+ // ControlBar::cancelLastQueuedUnit). The clock clears itself after each draw; the
+ // count badge does not, so put it back to zero.
+ //
+ if( m_currContext == CB_CONTEXT_MULTI_SELECT )
+ {
+ GadgetButtonSetCount( win, 0 );
+ }
+ else
+ {
+ Int queued = 0;
+ for( const ProductionEntry *p = pu->firstProduction(); p; p = pu->nextProduction( p ) )
+ if( p->getProductionType() == PRODUCTION_UNIT &&
+ p->getProductionObject() == command->getThingTemplate() )
+ queued++;
+ GadgetButtonSetCount( win, queued );
+
+ const ProductionEntry *first = pu->firstProduction();
+ if( first && first->getProductionType() == PRODUCTION_UNIT &&
+ first->getProductionObject() == command->getThingTemplate() )
+ GadgetButtonDrawClock( win, first->getPercentComplete(), BuildClockColor );
+ }
}
// a structure outside the armed chord group greys out until the chord resolves