Fix command card crashes

This commit is contained in:
Retera 2020-11-16 23:49:43 -05:00
parent 9f80e62ead
commit d4595c5abc

View File

@ -927,15 +927,17 @@ public class MeleeUI implements CUnitStateListener, CommandButtonListener, Comma
final boolean autoCastActive, final boolean menuButton) { final boolean autoCastActive, final boolean menuButton) {
int x = Math.max(0, Math.min(COMMAND_CARD_WIDTH - 1, buttonPositionX)); int x = Math.max(0, Math.min(COMMAND_CARD_WIDTH - 1, buttonPositionX));
int y = Math.max(0, Math.min(COMMAND_CARD_HEIGHT - 1, buttonPositionY)); int y = Math.max(0, Math.min(COMMAND_CARD_HEIGHT - 1, buttonPositionY));
while (this.commandCard[y][x].isVisible() && (y < COMMAND_CARD_HEIGHT) && (x < COMMAND_CARD_WIDTH)) { while ((x < COMMAND_CARD_WIDTH) && (y < COMMAND_CARD_HEIGHT) && this.commandCard[y][x].isVisible()) {
x++; x++;
if (x >= COMMAND_CARD_WIDTH) { if (x >= COMMAND_CARD_WIDTH) {
x = 0; x = 0;
y++; y++;
} }
} }
this.commandCard[y][x].setCommandButtonData(icon, abilityHandleId, orderId, autoCastId, active, autoCastActive, if((x < COMMAND_CARD_WIDTH) && (y < COMMAND_CARD_HEIGHT)) {
menuButton); this.commandCard[y][x].setCommandButtonData(icon, abilityHandleId, orderId, autoCastId, active, autoCastActive,
menuButton);
}
} }
public void resize(final Rectangle viewport) { public void resize(final Rectangle viewport) {