Skip to content

Commit

Permalink
Make a change to prevent networks leaking on chunk unload.
Browse files Browse the repository at this point in the history
It seems to have fixed the broken pipe issue as well, please test.
  • Loading branch information
unpairedbracket committed Jul 21, 2015
1 parent 22282fc commit 53d8522
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void removeInvalidTransmitters()

for(IGridTransmitter invalid : invalidTransmitters)
{
if(!invalid.isOrphan())
if(!(invalid.isOrphan() && invalid.isValid()))
{
DynamicNetwork n = invalid.getTransmitterNetwork();

Expand Down Expand Up @@ -163,7 +163,7 @@ public <A, N extends DynamicNetwork<A, N>> DynamicNetwork<A, N> getNetworkFromOr
case 0:
if(MekanismAPI.debug)
{
logger.info("No networks found. Creating new network");
logger.info("No networks found. Creating new network for " + finder.connectedTransmitters.size() + " transmitters");
}

network = startOrphan.createEmptyNetwork();
Expand All @@ -172,7 +172,7 @@ public <A, N extends DynamicNetwork<A, N>> DynamicNetwork<A, N> getNetworkFromOr
case 1:
if(MekanismAPI.debug)
{
logger.info("Using single found network");
logger.info("Adding " + finder.connectedTransmitters.size() + " transmitters to single found network");
}

network = finder.networksFound.iterator().next();
Expand All @@ -181,7 +181,7 @@ public <A, N extends DynamicNetwork<A, N>> DynamicNetwork<A, N> getNetworkFromOr
default:
if(MekanismAPI.debug)
{
logger.info("Merging " + finder.networksFound.size() + " networks");
logger.info("Merging " + finder.networksFound.size() + " networks with " + finder.connectedTransmitters.size() + " new transmitters");
}

network = startOrphan.mergeNetworks(finder.networksFound);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public A getAcceptor(ForgeDirection side)
@Override
public boolean isValid()
{
return !(getPart().tile() == null || getPart().tile().isInvalid()) && coord().exists(world());
return getPart().tile() != null && !getPart().tile().isInvalid() && !getPart().unloaded && coord().exists(world());
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/mekanism/common/multipart/PartTransmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public abstract class PartTransmitter<A, N extends DynamicNetwork<A, N>> extends
{
public MultipartTransmitter<A, N> transmitterDelegate;

public boolean unloaded = true;

public PartTransmitter()
{
transmitterDelegate = new MultipartTransmitter<>(this);
Expand All @@ -36,6 +38,8 @@ public void onWorldJoin()
else {
MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile()));
}

unloaded = false;
}

public abstract N createNewNetwork();
Expand All @@ -46,6 +50,8 @@ public void onWorldJoin()
public void onChunkUnload()
{
super.onChunkUnload();

unloaded = true;

if(!world().isRemote)
{
Expand Down

0 comments on commit 53d8522

Please sign in to comment.