Fixed issue with error prone Grid Visitors.

Increased Channel update speed.
Renamed Controller Method.
This commit is contained in:
AlgorithmX2 2014-04-22 21:49:03 -05:00
parent fa307b467e
commit 021e924098
4 changed files with 17 additions and 20 deletions

View file

@ -24,7 +24,7 @@ public class GridConnection implements IGridConnection, IPathItem
private ForgeDirection fromAtoB; private ForgeDirection fromAtoB;
private GridNode sideB; private GridNode sideB;
byte visitorIterationNumber = Byte.MIN_VALUE; Object visitorIterationNumber = null;
public int channelData = 0; public int channelData = 0;

View file

@ -42,10 +42,7 @@ public class GridNode implements IGridNode, IPathItem
IGridBlock gridProxy; IGridBlock gridProxy;
Grid myGrid; Grid myGrid;
public static byte currentVisitorIterationNumber = Byte.MIN_VALUE; Object visitorIterationNumber = null;
public static byte currentChannelsIterationNumber = Byte.MIN_VALUE;
byte visitorIterationNumber = Byte.MIN_VALUE;
// connection criteria // connection criteria
AEColor myColor = AEColor.Transparent; AEColor myColor = AEColor.Transparent;
@ -152,12 +149,12 @@ public class GridNode implements IGridNode, IPathItem
@Override @Override
public void beginVisition(IGridVisitor g) public void beginVisition(IGridVisitor g)
{ {
currentVisitorIterationNumber++; Object tracker = new Object();
LinkedList<GridNode> nextRun = new LinkedList(); LinkedList<GridNode> nextRun = new LinkedList();
nextRun.add( this ); nextRun.add( this );
visitorIterationNumber = currentVisitorIterationNumber; visitorIterationNumber = tracker;
if ( g instanceof IGridConnecitonVisitor ) if ( g instanceof IGridConnecitonVisitor )
{ {
@ -173,7 +170,7 @@ public class GridNode implements IGridNode, IPathItem
nextRun = new LinkedList(); nextRun = new LinkedList();
for (GridNode n : thisRun) for (GridNode n : thisRun)
n.visitorConnection( g, nextRun, nextConn ); n.visitorConnection( tracker, g, nextRun, nextConn );
} }
} }
else else
@ -184,12 +181,12 @@ public class GridNode implements IGridNode, IPathItem
nextRun = new LinkedList(); nextRun = new LinkedList();
for (GridNode n : thisRun) for (GridNode n : thisRun)
n.visitorNode( g, nextRun ); n.visitorNode( tracker, g, nextRun );
} }
} }
} }
private void visitorConnection(IGridVisitor g, LinkedList<GridNode> nextRun, LinkedList<IGridConnection> nextConnections) private void visitorConnection(Object tracker, IGridVisitor g, LinkedList<GridNode> nextRun, LinkedList<IGridConnection> nextConnections)
{ {
if ( g.visitNode( this ) ) if ( g.visitNode( this ) )
{ {
@ -198,23 +195,23 @@ public class GridNode implements IGridNode, IPathItem
GridNode gn = (GridNode) gc.getOtherSide( this ); GridNode gn = (GridNode) gc.getOtherSide( this );
GridConnection gcc = (GridConnection) gc; GridConnection gcc = (GridConnection) gc;
if ( gcc.visitorIterationNumber != currentVisitorIterationNumber ) if ( gcc.visitorIterationNumber != tracker )
{ {
gcc.visitorIterationNumber = currentChannelsIterationNumber; gcc.visitorIterationNumber = tracker;
nextConnections.add( gc ); nextConnections.add( gc );
} }
if ( currentVisitorIterationNumber == gn.visitorIterationNumber ) if ( tracker == gn.visitorIterationNumber )
continue; continue;
gn.visitorIterationNumber = currentVisitorIterationNumber; gn.visitorIterationNumber = tracker;
nextRun.add( gn ); nextRun.add( gn );
} }
} }
} }
private void visitorNode(IGridVisitor g, LinkedList<GridNode> nextRun) private void visitorNode(Object tracker, IGridVisitor g, LinkedList<GridNode> nextRun)
{ {
if ( g.visitNode( this ) ) if ( g.visitNode( this ) )
{ {
@ -222,10 +219,10 @@ public class GridNode implements IGridNode, IPathItem
{ {
GridNode gn = (GridNode) gc.getOtherSide( this ); GridNode gn = (GridNode) gc.getOtherSide( this );
if ( currentVisitorIterationNumber == gn.visitorIterationNumber ) if ( tracker == gn.visitorIterationNumber )
continue; continue;
gn.visitorIterationNumber = currentVisitorIterationNumber; gn.visitorIterationNumber = tracker;
nextRun.add( gn ); nextRun.add( gn );
} }

View file

@ -84,7 +84,7 @@ public class PathGridCache implements IPathingGrid
used = 0; used = 0;
int nodes = myGrid.getNodes().size(); int nodes = myGrid.getNodes().size();
ticksUntilReady = 20 + (nodes / 10); ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
channelsByBlocks = nodes * used; channelsByBlocks = nodes * used;
channelPowerUsage = (double) channelsByBlocks / 128.0; channelPowerUsage = (double) channelsByBlocks / 128.0;
@ -98,7 +98,7 @@ public class PathGridCache implements IPathingGrid
else else
{ {
int nodes = myGrid.getNodes().size(); int nodes = myGrid.getNodes().size();
ticksUntilReady = 20 + (nodes / 10); ticksUntilReady = 20 + Math.max( 0, nodes / 100 - 20 );
closedList = new HashSet(); closedList = new HashSet();
semiOpen = new HashSet(); semiOpen = new HashSet();

View file

@ -83,7 +83,7 @@ public class TileController extends AENetworkPowerTile implements IAEPowerStorag
} }
@MENetworkEventSubscribe @MENetworkEventSubscribe
public void onPowerChange(MENetworkControllerChange status) public void onControllerChange(MENetworkControllerChange status)
{ {
updateMeta(); updateMeta();
} }