Fix possible infinite loop

This commit is contained in:
Aidan Brady 2013-11-29 17:37:00 -05:00
parent 2e86b2a471
commit cd62f593fa

View file

@ -269,21 +269,31 @@ public final class CableUtils
double remains = totalToSend%outputtingSides.size(); double remains = totalToSend%outputtingSides.size();
double splitSend = (totalToSend-remains)/outputtingSides.size(); double splitSend = (totalToSend-remains)/outputtingSides.size();
List<ForgeDirection> toRemove = new ArrayList<ForgeDirection>();
for(ForgeDirection side : outputtingSides) for(ForgeDirection side : outputtingSides)
{ {
TileEntity tileEntity = Object3D.get(emitter).getFromSide(side).getTileEntity(emitter.worldObj); TileEntity tileEntity = Object3D.get(emitter).getFromSide(side).getTileEntity(emitter.worldObj);
double toSend = splitSend+remains; double toSend = splitSend+remains;
remains = 0; remains = 0;
double prev = totalToSend;
totalToSend -= (toSend - emit_do_do(emitter, tileEntity, side, toSend)); totalToSend -= (toSend - emit_do_do(emitter, tileEntity, side, toSend));
if(prev-totalToSend == 0)
{
toRemove.add(side);
}
}
for(ForgeDirection side : toRemove)
{
outputtingSides.remove(side);
} }
return totalToSend; return totalToSend;
} }
/**
* @return rejects
*/
private static double emit_do_do(TileEntityElectricBlock from, TileEntity tileEntity, ForgeDirection side, double sendingEnergy) private static double emit_do_do(TileEntityElectricBlock from, TileEntity tileEntity, ForgeDirection side, double sendingEnergy)
{ {
if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY)) if(TransmissionType.checkTransmissionType(tileEntity, TransmissionType.ENERGY))