@@ -717,6 +717,20 @@ const FieldParse CommandSet::m_commandSetFieldParseTable[] =
717717 { " 16" , CommandSet::parseCommandButton, (void *)15 , offsetof ( CommandSet, m_command ) },
718718 { " 17" , CommandSet::parseCommandButton, (void *)16 , offsetof ( CommandSet, m_command ) },
719719 { " 18" , CommandSet::parseCommandButton, (void *)17 , offsetof ( CommandSet, m_command ) },
720+ { " 19" , CommandSet::parseCommandButton, (void *)18 , offsetof ( CommandSet, m_command ) },
721+ { " 20" , CommandSet::parseCommandButton, (void *)19 , offsetof ( CommandSet, m_command ) },
722+ { " 21" , CommandSet::parseCommandButton, (void *)20 , offsetof ( CommandSet, m_command ) },
723+ { " 22" , CommandSet::parseCommandButton, (void *)21 , offsetof ( CommandSet, m_command ) },
724+ { " 23" , CommandSet::parseCommandButton, (void *)22 , offsetof ( CommandSet, m_command ) },
725+ { " 24" , CommandSet::parseCommandButton, (void *)23 , offsetof ( CommandSet, m_command ) },
726+ { " 25" , CommandSet::parseCommandButton, (void *)24 , offsetof ( CommandSet, m_command ) },
727+ { " 26" , CommandSet::parseCommandButton, (void *)25 , offsetof ( CommandSet, m_command ) },
728+ { " 27" , CommandSet::parseCommandButton, (void *)26 , offsetof ( CommandSet, m_command ) },
729+ { " 28" , CommandSet::parseCommandButton, (void *)27 , offsetof ( CommandSet, m_command ) },
730+ { " 29" , CommandSet::parseCommandButton, (void *)28 , offsetof ( CommandSet, m_command ) },
731+ { " 30" , CommandSet::parseCommandButton, (void *)29 , offsetof ( CommandSet, m_command ) },
732+ { " 31" , CommandSet::parseCommandButton, (void *)30 , offsetof ( CommandSet, m_command ) },
733+ { " 32" , CommandSet::parseCommandButton, (void *)31 , offsetof ( CommandSet, m_command ) },
720734 { NULL , NULL , NULL , 0 } // keep this last
721735
722736};
@@ -3263,14 +3277,18 @@ void ControlBar::initSpecialPowershortcutBar( Player *player)
32633277 id = TheNameKeyGenerator->nameToKey ( windowName.str () );
32643278 m_specialPowerShortcutButtons[ i ] =
32653279 TheWindowManager->winGetWindowFromId ( m_specialPowerShortcutParent, id );
3266- m_specialPowerShortcutButtons[ i ]->winSetStatus ( WIN_STATUS_USE_OVERLAY_STATES );
3267- // Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
3268- m_specialPowerShortcutButtons[ i ]->winSetStatus ( WIN_STATUS_SHORTCUT_BUTTON );
32693280
3270- windowName.format ( parentName, i+1 );
3271- id = TheNameKeyGenerator->nameToKey ( windowName.str () );
3272- m_specialPowerShortcutButtonParents[ i ] =
3273- TheWindowManager->winGetWindowFromId ( m_specialPowerShortcutParent, id );
3281+ if (m_specialPowerShortcutButtons[i] != nullptr ) {
3282+
3283+ m_specialPowerShortcutButtons[i]->winSetStatus (WIN_STATUS_USE_OVERLAY_STATES);
3284+ // Oh god... this is a total hack for shortcut buttons to handle rendering text top left corner...
3285+ m_specialPowerShortcutButtons[i]->winSetStatus (WIN_STATUS_SHORTCUT_BUTTON);
3286+
3287+ windowName.format (parentName, i + 1 );
3288+ id = TheNameKeyGenerator->nameToKey (windowName.str ());
3289+ m_specialPowerShortcutButtonParents[i] =
3290+ TheWindowManager->winGetWindowFromId (m_specialPowerShortcutParent, id);
3291+ }
32743292 } // end for i
32753293
32763294}
@@ -3480,16 +3498,18 @@ void ControlBar::populateSpecialPowerShortcut( Player *player)
34803498 }
34813499 }
34823500
3483- // make sure the window is not hidden
3484- m_specialPowerShortcutButtons[ currentButton ]->winHide ( FALSE );
3485- m_specialPowerShortcutButtonParents[ currentButton ]->winHide ( FALSE );
3486- // enable by default
3487- m_specialPowerShortcutButtons[ currentButton ]->winEnable ( TRUE );
3488- m_specialPowerShortcutButtonParents[ currentButton ]->winEnable ( TRUE );
3489-
3490- // populate the visible button with data from the command button
3491- setControlCommand ( m_specialPowerShortcutButtons[ currentButton ], commandButton );
3492- GadgetButtonSetAltSound (m_specialPowerShortcutButtons[ currentButton ], " GUIGenShortcutClick" );
3501+ if (m_specialPowerShortcutButtons[currentButton] != nullptr ) {
3502+ // make sure the window is not hidden
3503+ m_specialPowerShortcutButtons[currentButton]->winHide (FALSE );
3504+ m_specialPowerShortcutButtonParents[currentButton]->winHide (FALSE );
3505+ // enable by default
3506+ m_specialPowerShortcutButtons[currentButton]->winEnable (TRUE );
3507+ m_specialPowerShortcutButtonParents[currentButton]->winEnable (TRUE );
3508+
3509+ // populate the visible button with data from the command button
3510+ setControlCommand (m_specialPowerShortcutButtons[currentButton], commandButton);
3511+ GadgetButtonSetAltSound (m_specialPowerShortcutButtons[currentButton], " GUIGenShortcutClick" );
3512+ }
34933513 currentButton++;
34943514
34953515 } // end else
@@ -3512,7 +3532,7 @@ Bool ControlBar::hasAnyShortcutSelection() const
35123532 const CommandButton *command;
35133533
35143534 win = m_specialPowerShortcutButtons[ i ];
3515- if ( win->winIsHidden () == TRUE )
3535+ if ( win == nullptr || win ->winIsHidden () == TRUE )
35163536 continue ;
35173537
35183538 // get the command from the control
@@ -3574,7 +3594,7 @@ void ControlBar::updateSpecialPowerShortcut( void )
35743594 // get the window
35753595 win = m_specialPowerShortcutButtons[ i ];
35763596
3577- if ( win->winIsHidden () == TRUE )
3597+ if ( win== nullptr || win ->winIsHidden () == TRUE )
35783598 continue ;
35793599 // get the command from the control
35803600 command = (const CommandButton *)GadgetButtonGetData (win);
@@ -3667,7 +3687,7 @@ void ControlBar::drawSpecialPowerShortcutMultiplierText()
36673687 // get the window
36683688 win = m_specialPowerShortcutButtons[ i ];
36693689
3670- if ( win->winIsHidden () == TRUE )
3690+ if ( win == nullptr || win ->winIsHidden () == TRUE )
36713691 continue ;
36723692 // get the command from the control
36733693 command = (const CommandButton *)GadgetButtonGetData (win);
@@ -3746,7 +3766,7 @@ void ControlBar::showSpecialPowerShortcut( void )
37463766 Bool dontAnimate = TRUE ;
37473767 for ( Int i = 0 ; i < m_currentlyUsedSpecialPowersButtons; ++i )
37483768 {
3749- if (m_specialPowerShortcutButtons[i]->winGetUserData ())
3769+ if (m_specialPowerShortcutButtons[i] == nullptr || m_specialPowerShortcutButtons[i] ->winGetUserData ())
37503770 {
37513771 dontAnimate = FALSE ;
37523772 break ;
0 commit comments