Print actors list on desync [squashed]

This commit is contained in:
Paul Chote
2010-04-13 12:30:20 +12:00
committed by Chris Forbes
parent 21ee783521
commit 30a16ca4bd

View File

@@ -23,6 +23,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Traits;
namespace OpenRA.Network namespace OpenRA.Network
{ {
@@ -116,17 +117,22 @@ namespace OpenRA.Network
if( syncForFrame.TryGetValue( frame, out existingSync ) ) if( syncForFrame.TryGetValue( frame, out existingSync ) )
{ {
if( packet.Length != existingSync.Length ) if( packet.Length != existingSync.Length )
{
DumpActors();
OutOfSync( frame ); OutOfSync( frame );
}
else else
{ {
for( int i = 0 ; i < packet.Length ; i++ ) for( int i = 0 ; i < packet.Length ; i++ )
{ {
if( packet[ i ] != existingSync[ i ] ) if( packet[ i ] != existingSync[ i ] )
{ {
DumpActors();
if ( i < SyncHeaderSize ) if ( i < SyncHeaderSize )
OutOfSync(frame, "Tick"); OutOfSync(frame, "Tick");
else else
OutOfSync( frame , (i - SyncHeaderSize) / 4); OutOfSync( frame , (i - SyncHeaderSize) / 4);
} }
} }
} }
@@ -135,6 +141,17 @@ namespace OpenRA.Network
syncForFrame.Add( frame, packet ); syncForFrame.Add( frame, packet );
} }
static void DumpActors()
{
Log.Write( "Actors:" );
foreach( var a in Game.world.Actors )
Log.Write( "\t {0} {1} {2} ({3})", a.ActorID, a.Info.Name, ( a.Owner == null ) ? "null" : a.Owner.InternalName, Sync.CalculateSyncHash( a ) );
Log.Write( "Tick Actors:" );
foreach( var a in Game.world.Queries.WithTraitMultiple<ITick>() )
Log.Write( "\t {0} {1} {2} {3} ({4})", a.Actor.ActorID, a.Actor.Info.Name, ( a.Actor.Owner == null ) ? "null" : a.Actor.Owner.InternalName, a.Trait.GetType().Name, Sync.CalculateSyncHash( a.Trait ) );
}
void OutOfSync( int frame , int index) void OutOfSync( int frame , int index)
{ {
var frameData = clientQuitTimes var frameData = clientQuitTimes