Skip to content

Commit 0972118

Browse files
committed
fix some bugs in Game & remove /p from docs
1 parent 1b9fce9 commit 0972118

File tree

6 files changed

+61
-61
lines changed

6 files changed

+61
-61
lines changed

src/main/java/bwapi/Game.java

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public List<Position> getNukeDots() {
454454
*
455455
* @param forceID The identifier for the Force object.
456456
*
457-
* @return {@link Force} object mapped to the given \p forceID. Returns null if the given identifier is invalid.
457+
* @return {@link Force} object mapped to the given forceID. Returns null if the given identifier is invalid.
458458
*/
459459
public Force getForce(final int forceID) {
460460
if (forceID < 0 || forceID >= forces.length) {
@@ -468,7 +468,7 @@ public Force getForce(final int forceID) {
468468
*
469469
* @param playerID The identifier for the {@link Player} object.
470470
*
471-
* @return {@link Player} object mapped to the given \p playerID. null if the given identifier is invalid.
471+
* @return {@link Player} object mapped to the given playerID. null if the given identifier is invalid.
472472
*/
473473
public Player getPlayer(final int playerID) {
474474
if (playerID < 0 || playerID >= players.length) {
@@ -482,7 +482,7 @@ public Player getPlayer(final int playerID) {
482482
*
483483
* @param unitID The identifier for the {@link Unit} object.
484484
*
485-
* @return {@link Unit} object mapped to the given \p unitID. null if the given identifier is invalid.
485+
* @return {@link Unit} object mapped to the given unitID. null if the given identifier is invalid.
486486
*/
487487
public Unit getUnit(final int unitID) {
488488
if (unitID < 0 || unitID >= units.length) {
@@ -496,7 +496,7 @@ public Unit getUnit(final int unitID) {
496496
*
497497
* @param regionID The identifier for the {@link Region} object.
498498
*
499-
* @return {@link Region} object mapped to the given \p regionID. Returns null if the given ID is invalid.
499+
* @return {@link Region} object mapped to the given regionID. Returns null if the given ID is invalid.
500500
*/
501501
public Region getRegion(final int regionID) {
502502
if (regionID < 0 || regionID >= regions.length) {
@@ -582,7 +582,7 @@ public Position getMousePosition() {
582582
*
583583
* @param button A {@link MouseButton} enum member indicating which button on the mouse to check.
584584
*
585-
* @return A boolean indicating the state of the given \p button. true if the button was pressed
585+
* @return A boolean indicating the state of the given button. true if the button was pressed
586586
* and false if it was not. Returns false always if {@link Flag#UserInput} is disabled.
587587
*
588588
* @see MouseButton
@@ -596,7 +596,7 @@ public boolean getMouseState(final MouseButton button) {
596596
*
597597
* @param key A {@link Key} enum member indicating which key on the keyboard to check.
598598
*
599-
* @return A boolean indicating the state of the given \p key. true if the key was pressed
599+
* @return A boolean indicating the state of the given key. true if the key was pressed
600600
* and false if it was not. Returns false always if {@link Flag#UserInput} is disabled.
601601
*
602602
* @see Key
@@ -655,7 +655,7 @@ public void pingMinimap(final Position p) {
655655
*
656656
* @param flag The {@link Flag} entry describing the flag's effects on BWAPI.
657657
*
658-
* @return true if the given \p flag is enabled, false if the flag is disabled.
658+
* @return true if the given flag is enabled, false if the flag is disabled.
659659
*
660660
* @see Flag
661661
*/
@@ -933,7 +933,7 @@ public int getGroundHeight(final int tileX, final int tileY) {
933933

934934
public int getGroundHeight(final TilePosition position) {
935935
if (!position.isValid(this)) {
936-
return -1;
936+
return 0;
937937
}
938938
return groundHeight[position.x][position.y];
939939
}
@@ -952,7 +952,7 @@ public boolean isBuildable(final int tileX, final int tileY) {
952952
* @param includeBuildings If this is true, then this function will also check if any visible structures are occupying the space. If this value is false, then it only checks the static map data for tile buildability. This value is false by default.
953953
*
954954
* @return boolean identifying if the given tile position is buildable (true) or not (false).
955-
* If \p includeBuildings was provided, then it will return false if a structure is currently
955+
* If includeBuildings was provided, then it will return false if a structure is currently
956956
* occupying the tile.
957957
*/
958958
public boolean isBuildable(final int tileX, final int tileY, final boolean includeBuildings) {
@@ -1121,10 +1121,10 @@ public boolean canBuildHere(final TilePosition position, final UnitType type) {
11211121
* the tiles' buildability and possible units obstructing the build location.
11221122
*
11231123
* If the type is an addon and a builer is provided, then the location of the addon will
1124-
* be placed 4 tiles to the right and 1 tile down from the given \p position. If the builder
1124+
* be placed 4 tiles to the right and 1 tile down from the given position. If the builder
11251125
* is not given, then the check for the addon will be conducted at position.
11261126
*
1127-
* If \p type is UnitType.Special_Start_Location, then the area for a resource depot
1127+
* If type is UnitType.Special_Start_Location, then the area for a resource depot
11281128
* (@Command_Center, @Hatchery, @Nexus) is checked as normal, but any potential obstructions
11291129
* (existing structures, creep, units, etc.) are ignored.
11301130
*
@@ -1261,10 +1261,10 @@ public boolean canMake(final UnitType type) {
12611261
* required units.
12621262
*
12631263
* @param type The {@link UnitType} to check.
1264-
* @param builder The Unit that will be used to build/train the provided unit \p type. If this value is null or excluded, then the builder will be excluded in the check.
1264+
* @param builder The Unit that will be used to build/train the provided unit type. If this value is null or excluded, then the builder will be excluded in the check.
12651265
*
1266-
* @return true indicating that the type can be made. If \p builder is provided, then it is
1267-
* only true if \p builder can make the \p type. Otherwise it will return false, indicating
1266+
* @return true indicating that the type can be made. If builder is provided, then it is
1267+
* only true if builder can make the type. Otherwise it will return false, indicating
12681268
* that the unit type can not be made.
12691269
*/
12701270
public boolean canMake(final UnitType type, final Unit builder) {
@@ -1391,11 +1391,11 @@ public boolean canResearch(final TechType type) {
13911391
* required units.
13921392
*
13931393
* @param type The {@link TechType} to check.
1394-
* @param unit The {@link Unit} that will be used to research the provided technology \p type. If this value is null or excluded, then the unit will be excluded in the check.
1394+
* @param unit The {@link Unit} that will be used to research the provided technology type. If this value is null or excluded, then the unit will be excluded in the check.
13951395
* @param checkCanIssueCommandType TODO fill this in
13961396
*
1397-
* @return true indicating that the type can be researched. If \p unit is provided, then it is
1398-
* only true if \p unit can research the \p type. Otherwise it will return false, indicating
1397+
* @return true indicating that the type can be researched. If unit is provided, then it is
1398+
* only true if unit can research the type. Otherwise it will return false, indicating
13991399
* that the technology can not be researched.
14001400
*/
14011401
public boolean canResearch(final TechType type, final Unit unit, final boolean checkCanIssueCommandType) {
@@ -1456,11 +1456,11 @@ public boolean canUpgrade(final UpgradeType type) {
14561456
* required units.
14571457
*
14581458
* @param type The {@link UpgradeType} to check.
1459-
* @param unit The {@link Unit} that will be used to upgrade the provided upgrade \p type. If this value is null or excluded, then the unit will be excluded in the check.
1459+
* @param unit The {@link Unit} that will be used to upgrade the provided upgrade type. If this value is null or excluded, then the unit will be excluded in the check.
14601460
* @param checkCanIssueCommandType TODO fill this in
14611461
*
1462-
* @return true indicating that the type can be upgraded. If \p unit is provided, then it is
1463-
* only true if \p unit can upgrade the \p type. Otherwise it will return false, indicating
1462+
* @return true indicating that the type can be upgraded. If unit is provided, then it is
1463+
* only true if unit can upgrade the type. Otherwise it will return false, indicating
14641464
* that the upgrade can not be upgraded.
14651465
*/
14661466
public boolean canUpgrade(final UpgradeType type, final Unit unit, final boolean checkCanIssueCommandType) {
@@ -1693,6 +1693,9 @@ public boolean issueCommand(final Collection<Unit> units, final UnitCommand comm
16931693
* @see #enableFlag
16941694
*/
16951695
public List<Unit> getSelectedUnits() {
1696+
if (!isFlagEnabled(Flag.UserInput)) {
1697+
return Collections.emptyList();
1698+
}
16961699
return IntStream.range(0, gameData.getSelectedUnitCount())
16971700
.mapToObj(i -> units[gameData.getSelectedUnits(i)])
16981701
.collect(Collectors.toList());
@@ -2228,6 +2231,8 @@ public boolean isLatComEnabled() {
22282231
* @see #isLatComEnabled
22292232
*/
22302233
public void setLatCom(final boolean isEnabled) {
2234+
//update shared memory
2235+
gameData.setHasLatCom(isEnabled);
22312236
addCommand(SetLatCom, isEnabled ? 1 : 0, 0);
22322237
}
22332238

@@ -2267,7 +2272,7 @@ public int getAPM(final boolean includeSelects) {
22672272
* @see #setLocalSpeed
22682273
*/
22692274
public void setFrameSkip(int frameSkip) {
2270-
addCommand(SetFrameSkip, frameSkip, 0);
2275+
addCommand(SetFrameSkip, Math.max(frameSkip, 1), 0);
22712276
}
22722277

22732278
/**
@@ -2281,7 +2286,7 @@ public void setFrameSkip(int frameSkip) {
22812286
* no other players are remaining in the game. This value is true by default.
22822287
*/
22832288
public boolean setAlliance(Player player, boolean allied, boolean alliedVictory) {
2284-
if (self() == null || isReplay() || player == self || player.equals(self())) {
2289+
if (self() == null || isReplay() || player == null || player.equals(self())) {
22852290
return false;
22862291
}
22872292

@@ -2310,12 +2315,11 @@ public boolean setAlliance(Player player) {
23102315
* value is true by default.
23112316
*/
23122317
public boolean setVision(Player player, boolean enabled) {
2313-
// Param check
2314-
if ( player == null) {
2318+
if (player == null) {
23152319
return false;
23162320
}
23172321

2318-
if ( !isReplay() && (self() == null || player.equals(self()))) {
2322+
if (!isReplay() && (self() == null || player.equals(self()))) {
23192323
return false;
23202324
}
23212325

@@ -2383,10 +2387,6 @@ public boolean setMap(final String mapFileName) {
23832387
return false;
23842388
}
23852389

2386-
if (!(new File(mapFileName).exists())) {
2387-
return false;
2388-
}
2389-
23902390
addCommand(CommandType.SetMap, client.addString(mapFileName), 0);
23912391
return true;
23922392
}
@@ -2439,7 +2439,7 @@ public boolean hasPath(final Position source, final Position destination) {
24392439
}
24402440

24412441
public void setTextSize() {
2442-
textSize = TextSize.Default;
2442+
setTextSize(TextSize.Default);
24432443
}
24442444

24452445
/**
@@ -2474,7 +2474,7 @@ public int elapsedTime() {
24742474
*
24752475
* @param level An integer representation of the aggressiveness for which commands are optimized. A lower level means less optimization, and a higher level means more optimization.
24762476
*
2477-
* The values for \p level are as follows:
2477+
* The values for level are as follows:
24782478
* - 0: No optimization.
24792479
* - 1: Some optimization.
24802480
* - Is not detected as a hack.
@@ -2627,10 +2627,10 @@ public TilePosition getBuildLocation(final UnitType type, final TilePosition des
26272627
*
26282628
* @param type A valid UnitType representing the unit type to accomodate space for.
26292629
* @param desiredPosition A valid TilePosition containing the desired placement position.
2630-
* @param maxRange The maximum distance (in tiles) to build from \p desiredPosition.
2630+
* @param maxRange The maximum distance (in tiles) to build from desiredPosition.
26312631
* @param creep A special boolean value that changes the behaviour of @Creep_Colony placement.
26322632
*
2633-
* @return A TilePosition containing the location that the structure should be constructed at. Returns {@link TilePosition#Invalid} If a build location could not be found within \p maxRange.
2633+
* @return A TilePosition containing the location that the structure should be constructed at. Returns {@link TilePosition#Invalid} If a build location could not be found within maxRange.
26342634
*/
26352635
public TilePosition getBuildLocation(final UnitType type, TilePosition desiredPosition, final int maxRange, final boolean creep) {
26362636
return BuildingPlacer.getBuildLocation(type, desiredPosition, maxRange, creep, this);
@@ -2665,12 +2665,12 @@ public int getDamageFrom(final UnitType fromType, final UnitType toType) {
26652665

26662666
/**
26672667
* Calculates the damage received for a given player. It can be understood
2668-
* as the damage from \p fromType to \p toType. Does not include shields in calculation.
2668+
* as the damage from fromType to toType. Does not include shields in calculation.
26692669
* Includes upgrades if players are provided.
26702670
*
26712671
* @param fromType The unit type that will be dealing the damage.
26722672
* @param toType The unit type that will be receiving the damage.
2673-
* @param fromPlayer The player owner of the given type that will be dealing the damage. If omitted, then no player will be used to calculate the upgrades for \p fromType.
2673+
* @param fromPlayer The player owner of the given type that will be dealing the damage. If omitted, then no player will be used to calculate the upgrades for fromType.
26742674
* @param toPlayer The player owner of the type that will be receiving the damage. If omitted, then this parameter will default to {@link #self}.
26752675
*
26762676
* @return The amount of damage that fromType would deal to toType.
@@ -2690,15 +2690,15 @@ public int getDamageTo(final UnitType toType, final UnitType fromType) {
26902690

26912691
/**
26922692
* Calculates the damage dealt for a given player. It can be understood as
2693-
* the damage to \p toType from \p fromType. Does not include shields in calculation.
2693+
* the damage to toType from fromType. Does not include shields in calculation.
26942694
* Includes upgrades if players are provided.
26952695
*
26962696
* This function is nearly the same as {@link #getDamageFrom}. The only difference is that
26972697
* the last parameter is intended to default to {@link #self}.
26982698
*
26992699
* @param toType The unit type that will be receiving the damage.
27002700
* @param fromType The unit type that will be dealing the damage.
2701-
* @param toPlayer The player owner of the type that will be receiving the damage. If omitted, then no player will be used to calculate the upgrades for \p toType.
2701+
* @param toPlayer The player owner of the type that will be receiving the damage. If omitted, then no player will be used to calculate the upgrades for toType.
27022702
* @param fromPlayer The player owner of the given type that will be dealing the damage. If omitted, then this parameter will default to {@link #self}).
27032703
*
27042704
* @return The amount of damage that fromType would deal to toType.

src/main/java/bwapi/Player.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ public Force getForce() {
111111
* Checks if this player is allied to the specified player.
112112
*
113113
* @param player The player to check alliance with.
114-
* Returns true if this player is allied with \p player, false if this player is not allied with \p player.
114+
* Returns true if this player is allied with player, false if this player is not allied with player.
115115
*
116116
* This function will also return false if this player is neutral or an observer, or
117-
* if \p player is neutral or an observer.
117+
* if player is neutral or an observer.
118118
*
119119
* @see #isEnemy
120120
*/
@@ -130,10 +130,10 @@ public boolean isAlly(final Player player) {
130130
*
131131
* @param player The player to check alliance with.
132132
*
133-
* @return true if this player is allied with \p player, false if this player is not allied with \p player .
133+
* @return true if this player is allied with player, false if this player is not allied with player .
134134
*
135135
* This function will also return false if this player is neutral or an observer, or if
136-
* \p player is neutral or an observer.
136+
* player is neutral or an observer.
137137
*
138138
* @see #isAlly
139139
*/
@@ -330,7 +330,7 @@ public int supplyTotal() {
330330
*
331331
* @param race The race to query the total supply for. If this is omitted, then the player's current race will be used.
332332
*
333-
* @return The total supply available for this player and the given \p race.
333+
* @return The total supply available for this player and the given race.
334334
*
335335
* @see #supplyUsed
336336
*/
@@ -347,7 +347,7 @@ public int supplyUsed() {
347347
*
348348
* @param race The race to query the used supply for. If this is omitted, then the player's current race will be used.
349349
*
350-
* @return The supply that is in use for this player and the given \p race.
350+
* @return The supply that is in use for this player and the given race.
351351
*
352352
* @see #supplyTotal
353353
*/
@@ -482,7 +482,7 @@ public int killedUnitCount(final UnitType unit) {
482482
*
483483
* @param upgrade The UpgradeType to query.
484484
*
485-
* @return The number of levels that the \p upgrade has been upgraded for this player.
485+
* @return The number of levels that the upgrade has been upgraded for this player.
486486
*
487487
* @see Unit#upgrade
488488
* @see #getMaxUpgradeLevel
@@ -496,7 +496,7 @@ public int getUpgradeLevel(final UpgradeType upgrade) {
496496
*
497497
* @param tech The {@link TechType} to query.
498498
*
499-
* @return true if the player has obtained the given \p tech, or false if they have not
499+
* @return true if the player has obtained the given tech, or false if they have not
500500
*
501501
* @see #isResearching
502502
* @see Unit#research
@@ -511,7 +511,7 @@ public boolean hasResearched(final TechType tech) {
511511
*
512512
* @param tech The {@link TechType} to query.
513513
*
514-
* @return true if the player is currently researching the \p tech, or false otherwise
514+
* @return true if the player is currently researching the tech, or false otherwise
515515
*
516516
* @see Unit#research
517517
* @see #hasResearched
@@ -525,7 +525,7 @@ public boolean isResearching(final TechType tech) {
525525
*
526526
* @param upgrade The upgrade type to query.
527527
*
528-
* @return true if the player is currently upgrading the given \p upgrade, false otherwise
528+
* @return true if the player is currently upgrading the given upgrade, false otherwise
529529
*
530530
* @see Unit#upgrade
531531
*/
@@ -790,7 +790,7 @@ public boolean isObserver() {
790790
*
791791
* @param upgrade The {@link UpgradeType} to retrieve the maximum upgrade level for.
792792
*
793-
* @return Maximum upgrade level of the given \p upgrade type.
793+
* @return Maximum upgrade level of the given upgrade type.
794794
*
795795
*/
796796
public int getMaxUpgradeLevel(final UpgradeType upgrade) {
@@ -803,7 +803,7 @@ public int getMaxUpgradeLevel(final UpgradeType upgrade) {
803803
*
804804
* @param tech The {@link TechType} to query.
805805
*
806-
* @return true if the \p tech type is available to the player for research.
806+
* @return true if the tech type is available to the player for research.
807807
*/
808808
public boolean isResearchAvailable(final TechType tech) {
809809
return playerData.isResearchAvailable(tech.id);
@@ -815,7 +815,7 @@ public boolean isResearchAvailable(final TechType tech) {
815815
*
816816
* @param unit The {@link UnitType} to check.
817817
*
818-
* @return true if the \p unit type is available to the player.
818+
* @return true if the unit type is available to the player.
819819
*/
820820
public boolean isUnitAvailable(final UnitType unit) {
821821
return playerData.isUnitAvailable(unit.id);

0 commit comments

Comments
 (0)