p2p fixes

This commit is contained in:
PrototypeTrousers
2022-09-09 12:47:19 -03:00
parent 6e6f8d33cd
commit 6277058167
2 changed files with 28 additions and 9 deletions
@@ -133,24 +133,42 @@ public class PartP2PFEPower extends PartP2PTunnel<PartP2PFEPower>
}
final int amountPerOutput = maxReceive / outputTunnels;
int overflow = amountPerOutput == 0 ? maxReceive : maxReceive % amountPerOutput;
int overflow = 0;
if (outputs.isEmpty())
{
for ( PartP2PFEPower o : PartP2PFEPower.this.getOutputs())
for( PartP2PFEPower o : PartP2PFEPower.this.getOutputs() )
outputs.add( o );
}
while ( !outputs.isEmpty() ) {
while( !outputs.isEmpty() )
{
PartP2PFEPower target = outputs.poll();
final IEnergyStorage output = target.getAttachedEnergyStorage();
final int toSend = amountPerOutput + overflow;
final int received = output.receiveEnergy( toSend, simulate );
final int received = output.receiveEnergy( amountPerOutput, simulate );
overflow = toSend - received;
overflow += amountPerOutput - received;
total += received;
}
if( overflow > 0 )
{
for( PartP2PFEPower o : PartP2PFEPower.this.getOutputs() )
outputs.add( o );
while( !outputs.isEmpty() )
{
PartP2PFEPower target = outputs.poll();
final IEnergyStorage output = target.getAttachedEnergyStorage();
final int received = output.receiveEnergy( overflow, simulate );
overflow -= received;
total += received;
if( overflow == 0 )
{
outputs.clear();
break;
}
}
}
if( !simulate )
{
PartP2PFEPower.this.queueTunnelDrain( PowerUnits.RF, total );
@@ -164,6 +164,7 @@ public class PartP2PGTCEPower extends PartP2PTunnel<PartP2PGTCEPower>
if( amperage >= amperesUsed )
{
outputs.clear();
break;
}
}