Răsfoiți Sursa

fixed marking bug

ncannasse 9 ani în urmă
părinte
comite
0fbd2b6e8f
2 a modificat fișierele cu 19 adăugiri și 2 ștergeri
  1. 1 1
      hxd/net/Macros.hx
  2. 18 1
      hxd/net/NetworkHost.hx

+ 1 - 1
hxd/net/Macros.hx

@@ -838,7 +838,7 @@ class Macros {
 				@:noCompletion public var __bits : Int = 0;
 				@:noCompletion public var __next : hxd.net.NetworkSerializable;
 				@:noCompletion public inline function networkSetBit( b : Int ) {
-					if( __host != null && (__bits != 0 || @:privateAccess __host.mark(this)) )
+					if( __host != null && (__next != null || @:privateAccess __host.mark(this)) )
 						__bits |= 1 << b;
 				}
 				public var enableReplication(get, set) : Bool;

+ 18 - 1
hxd/net/NetworkHost.hx

@@ -386,6 +386,22 @@ class NetworkHost {
 		ctx.addAnyRef(o);
 		if( checkEOM ) ctx.addByte(EOM);
 	}
+	
+	function unmark( o : NetworkSerializable ) {
+		if( o.__next == null )
+			return;
+		var prev = null;
+		var h = markHead;
+		while( h != o ) {
+			prev = h;
+			h = h.__next;
+		}
+		if( prev == null )
+			markHead = o.__next;
+		else
+			prev.__next = o.__next;
+		o.__next = null;
+	}
 
 	function unregister( o : NetworkSerializable ) {
 		if( o.__host == null )
@@ -397,7 +413,8 @@ class NetworkHost {
 		}
 		flushProps(); // send changes
 		o.__host = null;
-		o.__bits = 0;
+		o.__bits = 0;		
+		unmark(o);
 		if( logger != null )
 			logger("Unregister " + o+"#"+o.__uid);
 		ctx.addByte(UNREG);