Improve Crash Report for Ticking GridNodes.
This commit is contained in:
parent
6b89d27562
commit
a1fcdcda80
3 changed files with 77 additions and 34 deletions
82
me/cache/TickManagerCache.java
vendored
82
me/cache/TickManagerCache.java
vendored
|
@ -3,6 +3,9 @@ package appeng.me.cache;
|
|||
import java.util.HashMap;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.util.ReportedException;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
|
@ -52,45 +55,56 @@ public class TickManagerCache implements ITickManager
|
|||
@Override
|
||||
public void onUpdateTick()
|
||||
{
|
||||
currentTick++;
|
||||
while (!upcomingTicks.isEmpty())
|
||||
TickTracker tt = null;
|
||||
try
|
||||
{
|
||||
TickTracker tt = upcomingTicks.peek();
|
||||
int diff = (int) (currentTick - tt.lastTick);
|
||||
if ( diff >= tt.current_rate )
|
||||
currentTick++;
|
||||
while (!upcomingTicks.isEmpty())
|
||||
{
|
||||
// remove tt..
|
||||
upcomingTicks.poll();
|
||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
|
||||
switch (mod)
|
||||
tt = upcomingTicks.peek();
|
||||
int diff = (int) (currentTick - tt.lastTick);
|
||||
if ( diff >= tt.current_rate )
|
||||
{
|
||||
case FASTER:
|
||||
tt.setRate( tt.current_rate - 2 );
|
||||
break;
|
||||
case IDLE:
|
||||
tt.setRate( tt.request.maxTickRate );
|
||||
break;
|
||||
case SAME:
|
||||
break;
|
||||
case SLEEP:
|
||||
sleepDevice( tt.node );
|
||||
break;
|
||||
case SLOWER:
|
||||
tt.setRate( tt.current_rate + 1 );
|
||||
break;
|
||||
case URGENT:
|
||||
tt.setRate( 0 );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// remove tt..
|
||||
upcomingTicks.poll();
|
||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
|
||||
switch (mod)
|
||||
{
|
||||
case FASTER:
|
||||
tt.setRate( tt.current_rate - 2 );
|
||||
break;
|
||||
case IDLE:
|
||||
tt.setRate( tt.request.maxTickRate );
|
||||
break;
|
||||
case SAME:
|
||||
break;
|
||||
case SLEEP:
|
||||
sleepDevice( tt.node );
|
||||
break;
|
||||
case SLOWER:
|
||||
tt.setRate( tt.current_rate + 1 );
|
||||
break;
|
||||
case URGENT:
|
||||
tt.setRate( 0 );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ( awake.containsKey( tt.node ) )
|
||||
addToQueue( tt );
|
||||
}
|
||||
|
||||
if ( awake.containsKey( tt.node ) )
|
||||
addToQueue( tt );
|
||||
else
|
||||
return; // done!
|
||||
}
|
||||
else
|
||||
return; // done!
|
||||
}
|
||||
catch( Throwable t )
|
||||
{
|
||||
CrashReport crashreport = CrashReport.makeCrashReport(t, "Ticking GridNode");
|
||||
CrashReportCategory crashreportcategory = crashreport.makeCategory( tt.gt.getClass().getSimpleName() + " being ticked." );
|
||||
tt.addEntityCrashInfo(crashreportcategory);
|
||||
throw new ReportedException(crashreport);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
23
me/cache/helpers/TickTracker.java
vendored
23
me/cache/helpers/TickTracker.java
vendored
|
@ -1,9 +1,12 @@
|
|||
package appeng.me.cache.helpers;
|
||||
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.parts.AEBasePart;
|
||||
|
||||
public class TickTracker implements Comparable<TickTracker>
|
||||
{
|
||||
|
@ -50,4 +53,24 @@ public class TickTracker implements Comparable<TickTracker>
|
|||
int ts_nextTick = (int) ((t.lastTick - host.getCurrentTick()) + t.current_rate);
|
||||
return nextTick - ts_nextTick;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||
{
|
||||
if ( gt instanceof AEBasePart )
|
||||
{
|
||||
AEBasePart part = (AEBasePart)gt;
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", current_rate );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", request.minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", request.maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", gt.getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", node.getConnectedSides() );
|
||||
|
||||
DimensionalCoord dc = node.getGridBlock().getLocation();
|
||||
if ( dc != null )
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -507,4 +508,9 @@ public class AEBasePart implements IPart, IGridProxyable, IActionHost, IUpgradea
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Part Side", side );
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue