Skip to content

Commit 5b98a6f

Browse files
committed
fixed GuidMap using haxe5 Int64 map definition + fixed reload of by guid resolution
1 parent b1b4a8c commit 5b98a6f

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

cdb/Types.hx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -644,19 +644,19 @@ class IndexId<T,Kind> extends Index<T> {
644644

645645
}
646646

647-
#if hl
648-
abstract GuidMap<K,V>(hl.types.Int64Map) {
647+
#if haxe5
648+
abstract GuidMap<K,V>(Map<haxe.Int64,V>) {
649649
public inline function new() {
650-
this = new hl.types.Int64Map();
650+
this = new Map();
651651
}
652652
public inline function set( key : GuidInt<K>, value : V ) {
653653
this.set(key, value);
654654
}
655655
public inline function get( key : GuidInt<K> ) : V {
656656
return this.get(key);
657657
}
658-
public inline function exists( key : GuidInt<K> ) {
659-
return this.exists(key);
658+
public inline function keys() : Iterator<GuidInt<K>> {
659+
return cast this.keys();
660660
}
661661
}
662662
#else
@@ -666,7 +666,10 @@ class GuidMap<K,V> {
666666
public function set( key : GuidInt<K>, value : V ) {
667667
}
668668
public function get( key : GuidInt<K> ) : V {
669-
throw "Map<Int64> not implemented on this platform";
669+
throw "Map<Int64> requires haxe5";
670+
}
671+
public inline function keys() : Iterator<K> {
672+
return [].iterator();
670673
}
671674
}
672675
#end
@@ -710,6 +713,16 @@ class IndexGuid<T,Kind> extends IndexId<T,Kind> {
710713
}
711714
}
712715

716+
override function reload(data:Data) {
717+
var prev = byGUID;
718+
super.reload(data);
719+
if( prev == null ) return;
720+
for( id in byGUID.keys() ) {
721+
var oldObj = prev.get(id);
722+
if( oldObj != null ) byGUID.set(id, oldObj);
723+
}
724+
}
725+
713726
public dynamic function getDefault() : T {
714727
return null;
715728
}

0 commit comments

Comments
 (0)