fix (?) item desync issues
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ aechannel=stable
|
|||||||
aebuild=7
|
aebuild=7
|
||||||
aegroup=appeng
|
aegroup=appeng
|
||||||
aebasename=appliedenergistics2
|
aebasename=appliedenergistics2
|
||||||
trousers=omni-fixes-v49f
|
trousers=omni-fixes-v49h
|
||||||
|
|
||||||
#########################################################
|
#########################################################
|
||||||
# Versions #
|
# Versions #
|
||||||
|
|||||||
+20
-32
@@ -19,7 +19,6 @@
|
|||||||
package appeng.me.cache;
|
package appeng.me.cache;
|
||||||
|
|
||||||
|
|
||||||
import javax.annotation.Nonnegative;
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
@@ -36,7 +35,6 @@ import appeng.api.storage.channels.IItemStorageChannel;
|
|||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.me.storage.ItemWatcher;
|
import appeng.me.storage.ItemWatcher;
|
||||||
import com.google.common.collect.Queues;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
|
||||||
@@ -47,9 +45,10 @@ import java.util.Map.Entry;
|
|||||||
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||||
{
|
{
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static final Set<NetworkMonitor<?>> NESTED_MONITORS = new HashSet<>();
|
private static final HashMap<IActionSource, Set<NetworkMonitor<?>>> src2MonitorsMap = new HashMap<>();
|
||||||
private static final HashMap<IActionSource, Set<NetworkMonitor<?>>> sourceSetHashMap = new HashMap<>();
|
private static final Set<IActionSource> nestingSources = new HashSet<>();
|
||||||
protected static boolean nested = false;
|
|
||||||
|
protected boolean wasNested = false;
|
||||||
protected boolean isNested = false;
|
protected boolean isNested = false;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@@ -63,8 +62,6 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
|
|
||||||
private boolean sendEvent = false;
|
private boolean sendEvent = false;
|
||||||
private boolean forceUpdate = false;
|
private boolean forceUpdate = false;
|
||||||
@Nonnegative
|
|
||||||
private int localDepthSemaphore = 0;
|
|
||||||
private long gridItemCount;
|
private long gridItemCount;
|
||||||
private long gridFluidCount;
|
private long gridFluidCount;
|
||||||
|
|
||||||
@@ -229,17 +226,20 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
|
|
||||||
protected void postChange( final boolean add, final Iterable<T> changes, final IActionSource src )
|
protected void postChange( final boolean add, final Iterable<T> changes, final IActionSource src )
|
||||||
{
|
{
|
||||||
|
src2MonitorsMap.putIfAbsent( src, new HashSet<>() );
|
||||||
if( sourceSetHashMap.get( src ) != null && sourceSetHashMap.get( src ).contains( this ) )
|
isNested = false;
|
||||||
|
if( nestingSources.contains( src ) )
|
||||||
{
|
{
|
||||||
NESTED_MONITORS.add( this );
|
forceUpdate = true;
|
||||||
nested = true;
|
}
|
||||||
|
if( !src2MonitorsMap.get( src ).add( this ) )
|
||||||
|
{
|
||||||
|
nestingSources.add( src );
|
||||||
|
forceUpdate = true;
|
||||||
|
src2MonitorsMap.get( src ).forEach( networkMonitor -> networkMonitor.isNested = true );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSetHashMap.putIfAbsent( src, new HashSet<>() );
|
|
||||||
sourceSetHashMap.get( src ).add( this );
|
|
||||||
|
|
||||||
this.sendEvent = true;
|
this.sendEvent = true;
|
||||||
|
|
||||||
for( final T change : changes )
|
for( final T change : changes )
|
||||||
@@ -282,28 +282,16 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
|
|
||||||
this.notifyListenersOfChange( changes, src );
|
this.notifyListenersOfChange( changes, src );
|
||||||
|
|
||||||
sourceSetHashMap.get( src ).remove( this );
|
src2MonitorsMap.get( src ).remove( this );
|
||||||
if( sourceSetHashMap.get( src ).isEmpty() )
|
if( src2MonitorsMap.get( src ).isEmpty() )
|
||||||
{
|
{
|
||||||
sourceSetHashMap.remove( src );
|
src2MonitorsMap.remove( src );
|
||||||
|
nestingSources.remove( src );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( sourceSetHashMap.isEmpty() )
|
if( isNested != wasNested || forceUpdate )
|
||||||
{
|
{
|
||||||
for( NetworkMonitor<?> nm : NESTED_MONITORS )
|
wasNested = isNested;
|
||||||
{
|
|
||||||
nm.setupForceUpdate();
|
|
||||||
}
|
|
||||||
nested = false;
|
|
||||||
NESTED_MONITORS.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setupForceUpdate()
|
|
||||||
{
|
|
||||||
if( nested != isNested )
|
|
||||||
{
|
|
||||||
isNested = nested;
|
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user