Skip to content

Commit 19b9cd9

Browse files
committed
bwem fixes for sparkle and neoaztec
1 parent 7cdfd09 commit 19b9cd9

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

src/main/java/bwem/Neutral.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
public abstract class Neutral {
2929
private final Unit bwapiUnit;
3030
private final Position pos;
31-
private final TilePosition topLeft;
31+
protected TilePosition topLeft;
3232
private final TilePosition tileSize;
3333
private final BWMap map;
3434
private Neutral nextStacked = null;
@@ -143,7 +143,7 @@ public Neutral getLastStacked() {
143143
}
144144

145145
private boolean isSameUnitTypeAs(Neutral neutral) {
146-
return this.getUnit().getClass().getName().equals(neutral.getUnit().getClass().getName());
146+
return this.getUnit().getType().equals(neutral.getUnit().getType());
147147
}
148148

149149
private void putOnTiles() {
@@ -159,6 +159,10 @@ private void putOnTiles() {
159159
deltaTile.addNeutral(this);
160160
} else {
161161
final Neutral topNeutral = deltaTile.getNeutral().getLastStacked();
162+
// https://github.com/N00byEdge/BWEM-community/issues/30#issuecomment-400840140
163+
if (!topNeutral.getTopLeft().equals(getTopLeft()) || !topNeutral.getBottomRight().equals(getBottomRight())) {
164+
continue;
165+
}
162166
if (this.equals(deltaTile.getNeutral())) {
163167
throw new IllegalStateException();
164168
} else if (this.equals(topNeutral)) {
@@ -176,7 +180,7 @@ private void putOnTiles() {
176180
// bwem_assert_plus(pTop->topLeft() == topLeft(), "stacked neutrals
177181
throw new IllegalStateException(
178182
"Stacked Neutral objects not aligned: top="
179-
+ topNeutral.toString()
183+
+ topNeutral.getTopLeft().toString()
180184
+ ", this="
181185
+ getTopLeft().toString());
182186
} else if (!(dx == 0 && dy == 0)) {

src/main/java/bwem/NeutralData.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import java.util.ArrayList;
1818
import java.util.List;
1919

20+
import static bwapi.UnitType.*;
21+
2022
public final class NeutralData {
2123
private final List<Mineral> minerals;
2224
private final List<Geyser> geysers;
@@ -46,16 +48,10 @@ public final class NeutralData {
4648
if (neutralUnit.getType().isBuilding()) {
4749
this.staticBuildings.add(new StaticBuilding(neutralUnit, map));
4850
}
51+
if ( neutralUnit.getType() == Special_Pit_Door || neutralUnit.getType() == Special_Right_Pit_Door) {
52+
this.staticBuildings.add(new StaticBuilding(neutralUnit, map));
53+
}
4954
}
50-
51-
// TODO: Add "Special_Pit_Door" and "Special_Right_Pit_Door" to static buildings list? See
52-
// mapImpl.cpp:238.
53-
// if (n->getType() == Special_Pit_Door)
54-
// m_StaticBuildings.push_back(make_unique<StaticBuilding>(n, this));
55-
// if (n->getType() == Special_Right_Pit_Door)
56-
// m_StaticBuildings.push_back(make_unique<StaticBuilding>(n, this));
57-
58-
////////////////////////////////////////////////////////////////////////
5955
}
6056

6157
public List<Mineral> getMinerals() {

src/main/java/bwem/StaticBuilding.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212

1313
package bwem;
1414

15+
import bwapi.TilePosition;
1516
import bwapi.Unit;
1617

18+
import static bwapi.UnitType.Special_Right_Pit_Door;
19+
1720
/**
1821
* StaticBuildings Correspond to the units in BWAPI::getStaticNeutralUnits() for which
1922
* getType().isSpecialBuilding. StaticBuilding also wrappers some special units like
@@ -22,11 +25,10 @@
2225
public class StaticBuilding extends Neutral {
2326
StaticBuilding(final Unit unit, final BWMap map) {
2427
super(unit, map);
25-
26-
// TODO
27-
// bwem_assert(Type().isSpecialBuilding() ||
28-
// (Type() == Special_Pit_Door) ||
29-
// Type() == Special_Right_Pit_Door);
28+
// https://github.com/N00byEdge/BWEM-community/blob/cf377c14a6fbad91d6bb4ce6c232a77cb22b500c/BWEM/src/neutral.cpp#L36
29+
if (unit.getType() == Special_Right_Pit_Door) {
30+
topLeft = topLeft.add(new TilePosition(1, 0));
31+
}
3032
}
3133

3234
@Override
@@ -41,6 +43,7 @@ public boolean equals(final Object object) {
4143
}
4244
}
4345

46+
4447
@Override
4548
public int hashCode() {
4649
return getUnit().hashCode();

0 commit comments

Comments
 (0)