---------------------------------------------- CHANGE RACE -----------------------------------------------
| 57 | } |
| 58 | //---------------------------------------------- CHANGE RACE ----------------------------------------------- |
| 59 | void GameImpl::_changeRace(int slot, BWAPI::Race race) |
| 60 | { |
| 61 | if ( race == Races::Unknown || race == Races::None ) |
| 62 | return; |
| 63 | |
| 64 | // Obtain the single player dialog |
| 65 | BW::dialog *custom = BW::FindDialogGlobal("Create"); |
| 66 | if ( custom ) |
| 67 | { |
| 68 | slot = Util::clamp(slot, 0, 7); |
| 69 | // Apply the single player change |
| 70 | BW::dialog *slotCtrl = custom->findIndex((short)(28 + slot)); // 28 is the CtrlID of the first slot |
| 71 | if ( slotCtrl && (int)slotCtrl->getSelectedValue() != race ) |
| 72 | slotCtrl->setSelectedByValue(race); |
| 73 | return; |
| 74 | } |
| 75 | |
| 76 | // Obtain the multi-player dialog |
| 77 | custom = BW::FindDialogGlobal("Chat"); |
| 78 | if ( !custom ) // return if not found |
| 79 | return; |
| 80 | |
| 81 | // Obtain the countdown control |
| 82 | BW::dialog *countdown = custom->findIndex(24); |
| 83 | if ( !countdown ) // return if not found |
| 84 | return; |
| 85 | |
| 86 | // Obtain the countdown control's text |
| 87 | const char *txt = countdown->getText(); |
| 88 | if ( txt && txt[0] && txt[0] < '2' ) |
| 89 | return; // return if the countdown is less than 2 |
| 90 | |
| 91 | // Send the change race command for multi-player |
| 92 | QUEUE_COMMAND(BW::Orders::RequestChangeRace, slot, race); |
| 93 | } |
| 94 | } |
| 95 |
nothing calls this directly
no test coverage detected