Smash the typos
This commit is contained in:
parent
ea10da6f69
commit
c7bae7f448
|
@ -1 +1 @@
|
||||||
Subproject commit bbe2ad8e709a366faf34e6efac9aef37cb3d8013
|
Subproject commit 5dd2dd9d4cf50eeeb1b6d57d4770cbff82ebe935
|
|
@ -1,5 +1,24 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Applied Energistics 2.
|
||||||
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
||||||
|
*/
|
||||||
|
|
||||||
package appeng.services.helpers;
|
package appeng.services.helpers;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
@ -7,9 +26,9 @@ import java.nio.channels.FileChannel;
|
||||||
|
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
|
|
||||||
|
|
||||||
public class CompassRegion
|
public class CompassRegion
|
||||||
{
|
{
|
||||||
|
|
||||||
final int low_x;
|
final int low_x;
|
||||||
final int low_z;
|
final int low_z;
|
||||||
|
|
||||||
|
@ -17,31 +36,13 @@ public class CompassRegion
|
||||||
final int hi_z;
|
final int hi_z;
|
||||||
|
|
||||||
final int world;
|
final int world;
|
||||||
|
|
||||||
boolean hasFile = false;
|
|
||||||
final File rootFolder;
|
final File rootFolder;
|
||||||
|
boolean hasFile = false;
|
||||||
RandomAccessFile raf = null;
|
RandomAccessFile raf = null;
|
||||||
ByteBuffer buffer;
|
ByteBuffer buffer;
|
||||||
|
|
||||||
public void close()
|
public CompassRegion( int cx, int cz, int worldID, File rootFolder )
|
||||||
{
|
{
|
||||||
try
|
|
||||||
{
|
|
||||||
if ( hasFile )
|
|
||||||
{
|
|
||||||
buffer = null;
|
|
||||||
raf.close();
|
|
||||||
raf = null;
|
|
||||||
hasFile = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable t)
|
|
||||||
{
|
|
||||||
throw new CompassException( t );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CompassRegion(int cx, int cz, int worldID, File rootFolder) {
|
|
||||||
|
|
||||||
world = worldID;
|
world = worldID;
|
||||||
this.rootFolder = rootFolder;
|
this.rootFolder = rootFolder;
|
||||||
|
@ -58,7 +59,25 @@ public class CompassRegion
|
||||||
openFile( false );
|
openFile( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasBeacon(int cx, int cz)
|
public void close()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ( hasFile )
|
||||||
|
{
|
||||||
|
buffer = null;
|
||||||
|
raf.close();
|
||||||
|
raf = null;
|
||||||
|
hasFile = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( Throwable t )
|
||||||
|
{
|
||||||
|
throw new CompassException( t );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasBeacon( int cx, int cz )
|
||||||
{
|
{
|
||||||
if ( hasFile )
|
if ( hasFile )
|
||||||
{
|
{
|
||||||
|
@ -73,7 +92,7 @@ public class CompassRegion
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHasBeacon(int cx, int cz, int cdy, boolean hasBeacon)
|
public void setHasBeacon( int cx, int cz, int cdy, boolean hasBeacon )
|
||||||
{
|
{
|
||||||
cx &= 0x3FF;
|
cx &= 0x3FF;
|
||||||
cz &= 0x3FF;
|
cz &= 0x3FF;
|
||||||
|
@ -88,28 +107,28 @@ public class CompassRegion
|
||||||
if ( hasBeacon )
|
if ( hasBeacon )
|
||||||
val |= 1 << cdy;
|
val |= 1 << cdy;
|
||||||
else
|
else
|
||||||
val &= ~(1 << cdy);
|
val &= ~( 1 << cdy );
|
||||||
|
|
||||||
if ( originalVal != val )
|
if ( originalVal != val )
|
||||||
write( cx, cz, val );
|
write( cx, cz, val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void write(int cx, int cz, int val)
|
private void write( int cx, int cz, int val )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
buffer.put( cx + cz * 0x400, (byte) val );
|
buffer.put( cx + cz * 0x400, ( byte ) val );
|
||||||
// raf.seek( cx + cz * 0x400 );
|
// raf.seek( cx + cz * 0x400 );
|
||||||
// raf.writeByte( val );
|
// raf.writeByte( val );
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch ( Throwable t )
|
||||||
{
|
{
|
||||||
throw new CompassException( t );
|
throw new CompassException( t );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int read(int cx, int cz)
|
private int read( int cx, int cz )
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -117,17 +136,17 @@ public class CompassRegion
|
||||||
// raf.seek( cx + cz * 0x400 );
|
// raf.seek( cx + cz * 0x400 );
|
||||||
// return raf.readByte();
|
// return raf.readByte();
|
||||||
}
|
}
|
||||||
catch (IndexOutOfBoundsException outOfBounds)
|
catch ( IndexOutOfBoundsException outOfBounds )
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch ( Throwable t )
|
||||||
{
|
{
|
||||||
throw new CompassException( t );
|
throw new CompassException( t );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openFile(boolean create)
|
private void openFile( boolean create )
|
||||||
{
|
{
|
||||||
File fName = getFileName();
|
File fName = getFileName();
|
||||||
if ( hasFile )
|
if ( hasFile )
|
||||||
|
@ -142,7 +161,7 @@ public class CompassRegion
|
||||||
buffer = fc.map( FileChannel.MapMode.READ_WRITE, 0, 0x400 * 0x400 );// fc.size() );
|
buffer = fc.map( FileChannel.MapMode.READ_WRITE, 0, 0x400 * 0x400 );// fc.size() );
|
||||||
hasFile = true;
|
hasFile = true;
|
||||||
}
|
}
|
||||||
catch (Throwable t)
|
catch ( Throwable t )
|
||||||
{
|
{
|
||||||
throw new CompassException( t );
|
throw new CompassException( t );
|
||||||
}
|
}
|
||||||
|
@ -150,7 +169,7 @@ public class CompassRegion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean fileExists(File name)
|
private boolean fileExists( File name )
|
||||||
{
|
{
|
||||||
return name.exists() && name.isFile();
|
return name.exists() && name.isFile();
|
||||||
}
|
}
|
||||||
|
@ -163,10 +182,9 @@ public class CompassRegion
|
||||||
if ( !folderFile.exists() || !folderFile.isDirectory() )
|
if ( !folderFile.exists() || !folderFile.isDirectory() )
|
||||||
{
|
{
|
||||||
if ( !folderFile.mkdir() )
|
if ( !folderFile.mkdir() )
|
||||||
AELog.info( "Failed to created AE2/compass/" );
|
AELog.info( "Failed to create AE2/compass/" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return new File( folder + File.separatorChar + world + "_" + low_x + "_" + low_z + ".dat" );
|
return new File( folder + File.separatorChar + world + "_" + low_x + "_" + low_z + ".dat" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue