Skip to content

Round of fixes for jbwapi (2) - #107

Merged
JasperGeurtz merged 1 commit into
developfrom
bwapi-4.4.0-fixes
Nov 8, 2026
Merged

JasperGeurtz merged 1 commit into
developfrom
bwapi-4.4.0-fixes

Conversation

@JasperGeurtz

@JasperGeurtz JasperGeurtz commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes discrepancies in jbwapi found by Gemini

  • CommandTemp:
    • Subtract gas cost instead of adding it when handling Upgrade commands.
    • Fix ArrayIndexOutOfBoundsException in Cancel_Train_Slot when shifting a full 5-slot training queue, and use Unit.getTrainingQueueAt.
  • Unit:
    • Fix canBuildAddon(UnitType) calling canBuildAddon(type, false) instead of canBuildAddon(false) before checking canMake(type, this).
    • Fix canAttackGrouped(Position, ...) checking canAttackUnitGrouped instead of only canAttackMoveGrouped.
    • Fix isTargetable() to require isVisible(game.self()) when CompleteMapInformation is disabled.
    • Fix canTargetUnit(Unit) to pass checkCommandibility = true by default (matching C++ BWAPI canTargetUnit(targetUnit, true)).
    • Fix isVisible() to fall back to checking visibility for any player (0..8) when game.self() == null (e.g. in replays) and validate player ID bounds (0..11).
    • Match C++ BWAPI special-case redirects in build(type, TilePosition.None) (trains Carrier/Reaver ammo), train(UnitType.None) (cancels morph/construction/addon), and useTech(tech, null) (redirects to targetless useTech(tech)).
  • Bullet:
    • Fix isVisible() to fall back to checking visibility for any player (0..8) when game.self() == null and validate player ID bounds (0..11).
  • Player:
    • Fix isEnemy(Player) to delegate to playerData.isEnemy(player.getID()) instead of !playerData.isAlly(...).
    • Fix isNeutral() to delegate to playerData.isNeutral() instead of comparing equals(game.neutral()).
    • Fix supplyTotal() and supplyUsed() to sum across Zerg/Terran/Protoss (0..2), default Race.None to getRace(), and return 0 for invalid races (Race.Unknown).
  • Region:
    • Fix updateNeighbours() accessibility check to compare getRegionGroupID() == neighbor.getRegionGroupID() instead of isHigherGround().
  • Game:
    • Refresh allies(), enemies(), and observers() on every frame (excluding defeated/left players) instead of only at game start.
    • Fix drawEllipseScreen passing CoordinateType.Mouse instead of CoordinateType.Screen.
  • BuildingPlacer:
    • Copy PlacementReserve before clearing unwalkable tiles in ReserveDefault instead of mutating the shared static array in place.
  • UnitCommand:
    • Include UnitCommandType.Repair in isQueued().

@JasperGeurtz
JasperGeurtz force-pushed the bwapi-4.4.0-fixes branch 2 times, most recently from 94aec78 to 080fe7d Compare November 7, 2026 19:38
- CommandTemp: subtract gas cost on Upgrade; fix Cancel_Train_Slot queue shift OOB
- Unit: fix canBuildAddon(UnitType) overload call, canAttackGrouped(Position) check, isTargetable visibility check, canTargetUnit(Unit) default checkCommandibility, isVisible replay fallback/bounds check, and build/train/useTech special-case redirects
- Bullet: fix isVisible replay fallback and player ID bounds check
- Player: fix isEnemy/isNeutral delegation to PlayerData and supplyTotal/supplyUsed Race.None and bounds checks
- Region: fix updateNeighbours accessibility check to compare regionGroupID
- Game: refresh allies/enemies/observers each frame and fix drawEllipseScreen coordinate type
- BuildingPlacer: avoid mutating original PlacementReserve in ReserveDefault
- UnitCommand: include Repair in isQueued
- Add unit tests for all BWAPI 4.4.0 alignment fixes
@JasperGeurtz
JasperGeurtz merged commit 68871f1 into develop Nov 8, 2026
19 of 21 checks passed
@JasperGeurtz
JasperGeurtz deleted the bwapi-4.4.0-fixes branch November 8, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant