Prioritize powered networks, fixes a glitch with tunnels connecting.
This commit is contained in:
@@ -28,6 +28,7 @@ public class Grid implements IGrid
|
||||
HashMap<Class<? extends IGridCache>, GridCacheWrapper> caches = new HashMap<Class<? extends IGridCache>, GridCacheWrapper>();
|
||||
|
||||
GridNode pivot;
|
||||
int isImportant; // how import is this network?
|
||||
|
||||
public Grid(GridNode center) {
|
||||
this.pivot = center;
|
||||
@@ -228,4 +229,10 @@ public class Grid implements IGrid
|
||||
}
|
||||
}
|
||||
|
||||
public void setImportantFlag(int i, boolean publicHasPower)
|
||||
{
|
||||
int flag = 1 << i;
|
||||
isImportant = (isImportant & ~flag) | (publicHasPower ? flag : 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
GridPropagator gp = new GridPropagator( a.getInternalGrid() );
|
||||
b.beginVisition( gp );
|
||||
}
|
||||
else if ( a.myGrid.size() > b.myGrid.size() )
|
||||
else if ( isNetworkABetter( a, b ) )
|
||||
{
|
||||
GridPropagator gp = new GridPropagator( a.getInternalGrid() );
|
||||
b.beginVisition( gp );
|
||||
@@ -82,6 +82,11 @@ public class GridConnection implements IGridConnection, IPathItem
|
||||
sideB.addConnection( this );
|
||||
}
|
||||
|
||||
private boolean isNetworkABetter(GridNode a, GridNode b)
|
||||
{
|
||||
return ((Grid) a.myGrid).isImportant > ((Grid) b.myGrid).isImportant || a.myGrid.size() > b.myGrid.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
|
||||
Vendored
+2
@@ -27,6 +27,7 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.events.MENetworkPowerStorage;
|
||||
import appeng.api.networking.pathing.IPathingGrid;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.me.Grid;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.me.energy.EnergyThreshold;
|
||||
import appeng.me.energy.EnergyWatcher;
|
||||
@@ -379,6 +380,7 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
return;
|
||||
|
||||
publicHasPower = newState;
|
||||
((Grid) myGrid).setImportantFlag( 0, publicHasPower );
|
||||
grid.postEvent( new MENetworkPowerStatusChange() );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user