@@ -935,10 +935,7 @@ final public boolean isWalkable(final int walkX, final int walkY) {
935935 }
936936
937937 final public boolean isWalkable (final WalkPosition position ) {
938- if (!position .isValid (this )) {
939- return false ;
940- }
941- return walkable [position .x ][position .y ];
938+ return position .isValid (this ) && walkable [position .x ][position .y ];
942939 }
943940
944941 /**
@@ -955,15 +952,12 @@ final public boolean isWalkable(final WalkPosition position) {
955952 * - 5: Very high ground doodad
956953 * .
957954 */
958- public int getGroundHeight (final int tileX , final int tileY ) {
959- return getGroundHeight ( new TilePosition ( tileX , tileY )) ;
955+ final public int getGroundHeight (final int tileX , final int tileY ) {
956+ return isValidTile ( tileX , tileY ) ? groundHeight [ tileX ][ tileY ] : 0 ;
960957 }
961958
962- public int getGroundHeight (final TilePosition position ) {
963- if (!position .isValid (this )) {
964- return 0 ;
965- }
966- return groundHeight [position .x ][position .y ];
959+ final public int getGroundHeight (final TilePosition position ) {
960+ return getGroundHeight (position .x , position .y );
967961 }
968962
969963 final public boolean isBuildable (final int tileX , final int tileY ) {
@@ -1077,23 +1071,23 @@ final public boolean hasPowerPrecise(final Position position, final UnitType uni
10771071 return hasPowerPrecise (position .x , position .y , unitType );
10781072 }
10791073
1080- final public boolean hasPower (final int tileX , final int tileY ) {
1081- return hasPower (new TilePosition ( tileX , tileY ) );
1074+ final public boolean hasPower (final TilePosition position ) {
1075+ return hasPower (position . x , position . y );
10821076 }
10831077
1084- final public boolean hasPower (final int tileX , final int tileY , final UnitType unitType ) {
1085- return hasPower (new TilePosition ( tileX , tileY ), unitType );
1078+ final public boolean hasPower (final int tileX , final int tileY ) {
1079+ return hasPower (tileX , tileY , UnitType . None );
10861080 }
10871081
1088- final public boolean hasPower (final TilePosition position ) {
1089- return hasPower (position .x , position .y , UnitType . None );
1082+ final public boolean hasPower (final TilePosition position , final UnitType unitType ) {
1083+ return hasPower (position .x , position .y , unitType );
10901084 }
10911085
1092- final public boolean hasPower (final TilePosition position , final UnitType unitType ) {
1086+ final public boolean hasPower (final int tileX , final int tileY , final UnitType unitType ) {
10931087 if (unitType .id >= 0 && unitType .id < UnitType .None .id ) {
1094- return hasPowerPrecise (position . x * 32 + unitType .tileWidth () * 16 , position . y * 32 + unitType .tileHeight () * 16 , unitType );
1088+ return hasPowerPrecise (tileX * 32 + unitType .tileWidth () * 16 , tileY * 32 + unitType .tileHeight () * 16 , unitType );
10951089 }
1096- return hasPowerPrecise (position . x * 32 , position . y * 32 , UnitType .None );
1090+ return hasPowerPrecise (tileY * 32 , tileY * 32 , UnitType .None );
10971091 }
10981092
10991093 final public boolean hasPower (final int tileX , final int tileY , final int tileWidth , final int tileHeight ) {
0 commit comments