| 524 | int lastHotkey; |
| 525 | DWORD lastHotkeyTime; |
| 526 | void __fastcall CommandFilter(BYTE *buffer, DWORD length) |
| 527 | { |
| 528 | if ( !buffer || !length ) |
| 529 | return; |
| 530 | |
| 531 | // Filter commands using BWAPI rules |
| 532 | if ( BWAPI::BroodwarImpl.isFlagEnabled(BWAPI::Flag::UserInput) || |
| 533 | !BWAPI::BroodwarImpl.onStartCalled || |
| 534 | buffer[0] <= 0x0B || |
| 535 | (buffer[0] >= 0x0F && buffer[0] <= 0x12) || |
| 536 | (length >= 3 && buffer[0] == 0x13 && buffer[1] == 1) || // Hotkey (select only) |
| 537 | (buffer[0] >= 0x37 && buffer[0] <= 0x59) || |
| 538 | buffer[0] >= 0x5B ) |
| 539 | { |
| 540 | // Custom select code |
| 541 | if ( buffer[0] == 0x09 || |
| 542 | buffer[0] == 0x0A || |
| 543 | buffer[0] == 0x0B || |
| 544 | (length >= 3 && buffer[0] == 0x13 && buffer[1] == 1) ) // Select Units |
| 545 | { |
| 546 | // Do our own center view on hotkeys, since BWAPI introduces a bug that destroys this |
| 547 | if ( length >= 3 && buffer[0] == 0x13 && buffer[1] == 1 ) // Recall Hotkey |
| 548 | { |
| 549 | DWORD thisHotkeyTime = GetTickCount(); |
| 550 | if ( lastHotkey == buffer[2] && (thisHotkeyTime - lastHotkeyTime) < 800 ) |
| 551 | { |
| 552 | // do center view here |
| 553 | BWAPI::BroodwarImpl.moveToSelectedUnits(); |
| 554 | lastHotkeyTime = 0; |
| 555 | lastHotkey = -1; |
| 556 | } |
| 557 | else |
| 558 | { |
| 559 | lastHotkeyTime = thisHotkeyTime; |
| 560 | lastHotkey = buffer[2]; |
| 561 | } |
| 562 | } |
| 563 | BWAPI::BroodwarImpl.wantSelectionUpdate = true; |
| 564 | return; |
| 565 | } // selections |
| 566 | |
| 567 | if ( buffer[0] == 0x0C || |
| 568 | (buffer[0] == 0x13 && !(buffer[1] & 1)) || |
| 569 | buffer[0] == 0x14 || |
| 570 | buffer[0] == 0x15 || |
| 571 | (buffer[0] >= 0x18 && buffer[0] <= 0x36) || |
| 572 | buffer[0] == 0x5A ) |
| 573 | { |
| 574 | //reload the unit selection states (so that the user doesn't notice any changes in selected units in the Starcraft GUI. |
| 575 | BW::Orders::Select sel(BW::BWDATA::ClientSelectionCount, const_cast<const BW::CUnit**>(BW::BWDATA::ClientSelectionGroup.data())); |
| 576 | QueueGameCommand(&sel, sel.size()); |
| 577 | } // user select |
| 578 | QueueGameCommand(buffer, length); |
| 579 | } |
| 580 | } |
nothing calls this directly
no test coverage detected