Fixed Bug: #0641 - Redstone P2P Crash

Fixed an issue where tunnels would de-register if linked a certain way.
This commit is contained in:
AlgorithmX2
2014-07-14 23:47:07 -05:00
parent 675d068934
commit e1d3fdb8d7
3 changed files with 38 additions and 16 deletions
+10 -3
View File
@@ -62,8 +62,11 @@ public class P2PCache implements IGridCache
public void updateFreq(PartP2PTunnel t, long NewFreq) public void updateFreq(PartP2PTunnel t, long NewFreq)
{ {
outputs.remove( t.freq, t ); if ( outputs.containsValue( t ) )
inputs.remove( t.freq ); outputs.remove( t.freq, t );
if ( inputs.containsValue( t ) )
inputs.remove( t.freq );
t.freq = NewFreq; t.freq = NewFreq;
@@ -150,7 +153,11 @@ public class P2PCache implements IGridCache
if ( in == null ) if ( in == null )
return NullColl; return NullColl;
return inputs.get( freq ).getCollection( outputs.get( freq ) ); TunnelCollection<PartP2PTunnel> out = inputs.get( freq ).getCollection( outputs.get( freq ), c );
if ( out == null )
return NullColl;
return out;
} }
public PartP2PTunnel getInput(long freq) public PartP2PTunnel getInput(long freq)
+10
View File
@@ -34,4 +34,14 @@ public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
{ {
return !iterator().hasNext(); return !iterator().hasNext();
} }
public boolean matches(Class<? extends PartP2PTunnel> c)
{
return clz == c;
}
public Class<? extends PartP2PTunnel> getClz()
{
return clz;
}
} }
+18 -13
View File
@@ -201,19 +201,19 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
NBTTagCompound data = new NBTTagCompound(); NBTTagCompound data = new NBTTagCompound();
long newFreq = freq; long newFreq = freq;
boolean wasOutput = output;
output = false; output = false;
if ( output || freq == 0 ) if ( wasOutput || freq == 0 )
{
newFreq = System.currentTimeMillis(); newFreq = System.currentTimeMillis();
try
{ try
proxy.getP2P().updateFreq( this, newFreq ); {
} proxy.getP2P().updateFreq( this, newFreq );
catch (GridAccessException e) }
{ catch (GridAccessException e)
// :P {
} // :P
} }
onTunnelConfigChange(); onTunnelConfigChange();
@@ -243,10 +243,15 @@ public class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
return AEApi.instance().parts().partP2PTunnelME.stack( 1 ); return AEApi.instance().parts().partP2PTunnelME.stack( 1 );
} }
public TunnelCollection<T> getCollection(Collection<PartP2PTunnel> collection) public TunnelCollection<T> getCollection(Collection<PartP2PTunnel> collection, Class<? extends PartP2PTunnel> c)
{ {
type.setSource( collection ); if ( type.matches( c ) )
return type; {
type.setSource( collection );
return type;
}
return null;
} }
public T getInput() public T getInput()