Basic reformat, hit once, hope never again
This commit is contained in:
@@ -44,24 +44,21 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
{
|
||||
|
||||
private static final MENetworkChannelsChanged EVENT = new MENetworkChannelsChanged();
|
||||
|
||||
public int channelData = 0;
|
||||
Object visitorIterationNumber = null;
|
||||
private GridNode sideA;
|
||||
private ForgeDirection fromAtoB;
|
||||
private GridNode sideB;
|
||||
|
||||
Object visitorIterationNumber = null;
|
||||
|
||||
public int channelData = 0;
|
||||
|
||||
public GridConnection( IGridNode aNode, IGridNode bNode, ForgeDirection fromAtoB ) throws FailedConnection
|
||||
{
|
||||
|
||||
GridNode a = ( GridNode ) aNode;
|
||||
GridNode b = ( GridNode ) bNode;
|
||||
GridNode a = (GridNode) aNode;
|
||||
GridNode b = (GridNode) bNode;
|
||||
|
||||
if ( Platform.securityCheck( a, b ) )
|
||||
if( Platform.securityCheck( a, b ) )
|
||||
{
|
||||
if ( AEConfig.instance.isFeatureEnabled( AEFeature.LogSecurityAudits ) )
|
||||
if( AEConfig.instance.isFeatureEnabled( AEFeature.LogSecurityAudits ) )
|
||||
{
|
||||
final DimensionalCoord aCoordinates = a.getGridBlock().getLocation();
|
||||
final DimensionalCoord bCoordinates = b.getGridBlock().getLocation();
|
||||
@@ -73,10 +70,10 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
throw new FailedConnection();
|
||||
}
|
||||
|
||||
if ( a == null || b == null )
|
||||
if( a == null || b == null )
|
||||
throw new GridException( "Connection Forged Between null entities." );
|
||||
|
||||
if ( a.hasConnection( b ) || b.hasConnection( a ) )
|
||||
if( a.hasConnection( b ) || b.hasConnection( a ) )
|
||||
{
|
||||
final String aCoords = a.getGridBlock().getLocation().toString();
|
||||
final String bCoords = b.getGridBlock().getLocation().toString();
|
||||
@@ -87,23 +84,23 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
this.fromAtoB = fromAtoB;
|
||||
this.sideB = b;
|
||||
|
||||
if ( b.getMyGrid() == null )
|
||||
if( b.getMyGrid() == null )
|
||||
{
|
||||
b.setGrid( a.getInternalGrid() );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( a.getMyGrid() == null )
|
||||
if( a.getMyGrid() == null )
|
||||
{
|
||||
GridPropagator gp = new GridPropagator( b.getInternalGrid() );
|
||||
a.beginVisit( gp );
|
||||
}
|
||||
else if ( b.getMyGrid() == null )
|
||||
else if( b.getMyGrid() == null )
|
||||
{
|
||||
GridPropagator gp = new GridPropagator( a.getInternalGrid() );
|
||||
b.beginVisit( gp );
|
||||
}
|
||||
else if ( this.isNetworkABetter( a, b ) )
|
||||
else if( this.isNetworkABetter( a, b ) )
|
||||
{
|
||||
GridPropagator gp = new GridPropagator( a.getInternalGrid() );
|
||||
b.beginVisit( gp );
|
||||
@@ -128,6 +125,29 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
return a.getMyGrid().getPriority() > b.getMyGrid().getPriority() || a.getMyGrid().size() > b.getMyGrid().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getOtherSide( IGridNode gridNode )
|
||||
{
|
||||
if( gridNode == this.sideA )
|
||||
return this.sideB;
|
||||
if( gridNode == this.sideB )
|
||||
return this.sideA;
|
||||
|
||||
throw new GridException( "Invalid Side of Connection" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection( IGridNode side )
|
||||
{
|
||||
if( this.fromAtoB == ForgeDirection.UNKNOWN )
|
||||
return this.fromAtoB;
|
||||
|
||||
if( this.sideA == side )
|
||||
return this.fromAtoB;
|
||||
else
|
||||
return this.fromAtoB.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
@@ -148,74 +168,28 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
return this.sideA;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForgeDirection getDirection( IGridNode side )
|
||||
{
|
||||
if ( this.fromAtoB == ForgeDirection.UNKNOWN )
|
||||
return this.fromAtoB;
|
||||
|
||||
if ( this.sideA == side )
|
||||
return this.fromAtoB;
|
||||
else
|
||||
return this.fromAtoB.getOpposite();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode b()
|
||||
{
|
||||
return this.sideB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode getOtherSide( IGridNode gridNode )
|
||||
{
|
||||
if ( gridNode == this.sideA )
|
||||
return this.sideB;
|
||||
if ( gridNode == this.sideB )
|
||||
return this.sideA;
|
||||
|
||||
throw new GridException( "Invalid Side of Connection" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasDirection()
|
||||
{
|
||||
return this.fromAtoB != ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReadOnlyCollection<IPathItem> getPossibleOptions()
|
||||
{
|
||||
return new ReadOnlyCollection<IPathItem>( Arrays.asList( ( IPathItem ) this.a(), ( IPathItem ) this.b() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementChannelCount( int usedChannels )
|
||||
{
|
||||
this.channelData += usedChannels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSupportMoreChannels()
|
||||
{
|
||||
return this.getLastUsedChannels() < 32; // max, PERIOD.
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUsedChannels()
|
||||
{
|
||||
return ( this.channelData >> 8 ) & 0xff;
|
||||
}
|
||||
|
||||
public int getLastUsedChannels()
|
||||
{
|
||||
return this.channelData & 0xff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPathItem getControllerRoute()
|
||||
{
|
||||
if ( this.sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) )
|
||||
if( this.sideA.getFlags().contains( GridFlags.CANNOT_CARRY ) )
|
||||
return null;
|
||||
return this.sideA;
|
||||
}
|
||||
@@ -223,10 +197,10 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
@Override
|
||||
public void setControllerRoute( IPathItem fast, boolean zeroOut )
|
||||
{
|
||||
if ( zeroOut )
|
||||
if( zeroOut )
|
||||
this.channelData &= ~0xff;
|
||||
|
||||
if ( this.sideB == fast )
|
||||
if( this.sideB == fast )
|
||||
{
|
||||
GridNode tmp = this.sideA;
|
||||
this.sideA = this.sideB;
|
||||
@@ -236,19 +210,21 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeChannels()
|
||||
public boolean canSupportMoreChannels()
|
||||
{
|
||||
if ( this.getUsedChannels() != this.getLastUsedChannels() )
|
||||
{
|
||||
this.channelData &= 0xff;
|
||||
this.channelData |= this.channelData << 8;
|
||||
return this.getLastUsedChannels() < 32; // max, PERIOD.
|
||||
}
|
||||
|
||||
if ( this.sideA.getInternalGrid() != null )
|
||||
this.sideA.getInternalGrid().postEventTo( this.sideA, EVENT );
|
||||
@Override
|
||||
public IReadOnlyCollection<IPathItem> getPossibleOptions()
|
||||
{
|
||||
return new ReadOnlyCollection<IPathItem>( Arrays.asList( (IPathItem) this.a(), (IPathItem) this.b() ) );
|
||||
}
|
||||
|
||||
if ( this.sideB.getInternalGrid() != null )
|
||||
this.sideB.getInternalGrid().postEventTo( this.sideB, EVENT );
|
||||
}
|
||||
@Override
|
||||
public void incrementChannelCount( int usedChannels )
|
||||
{
|
||||
this.channelData += usedChannels;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,4 +233,24 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
return EnumSet.noneOf( GridFlags.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finalizeChannels()
|
||||
{
|
||||
if( this.getUsedChannels() != this.getLastUsedChannels() )
|
||||
{
|
||||
this.channelData &= 0xff;
|
||||
this.channelData |= this.channelData << 8;
|
||||
|
||||
if( this.sideA.getInternalGrid() != null )
|
||||
this.sideA.getInternalGrid().postEventTo( this.sideA, EVENT );
|
||||
|
||||
if( this.sideB.getInternalGrid() != null )
|
||||
this.sideB.getInternalGrid().postEventTo( this.sideB, EVENT );
|
||||
}
|
||||
}
|
||||
|
||||
public int getLastUsedChannels()
|
||||
{
|
||||
return this.channelData & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user