Skip to content

Commit 30c5ae5

Browse files
committed
e
1 parent 3b9409c commit 30c5ae5

File tree

3 files changed

+64
-8
lines changed

3 files changed

+64
-8
lines changed

source/archipelago/APGameState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ class APGameState
586586
}
587587
});
588588

589-
_ap.toggleDeathLink(slotData != null && Reflect.hasField(slotData, "deathLink") ? slotData.deathLink : ClientPrefs.data.deathlink);
589+
_ap.toggleDeathLink(slotData != null && Reflect.hasField(slotData, "deathLink") ? slotData?.deathLink? : ClientPrefs.data.deathlink);
590590

591591
_ap.onRetrieved.add(handleRetrievedPacket);
592592

source/yutautil/TypeUtils.hx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,62 @@ abstract DetailedException(ExceptionDetails) {
11831183
}
11841184
}
11851185

1186+
abstract HxVector<T>(haxe.ds.Vector<T>) {
1187+
public inline function new(value:Dynamic) {
1188+
if (value == null) throw 'HxVector cannot be constructed with null value';
1189+
if (Std.isOfType(value, Array)) {
1190+
var arr:Array<T> = cast value;
1191+
var vec = new haxe.ds.Vector<T>(arr.length);
1192+
for (i in 0...arr.length) vec[i] = arr[i];
1193+
this = vec;
1194+
} else {
1195+
this = cast value;
1196+
}
1197+
}
1198+
1199+
@:to
1200+
public inline function toVector():haxe.ds.Vector<T> {
1201+
return this;
1202+
}
1203+
1204+
@:to
1205+
public inline function toArray():Array<T> {
1206+
var arr = [];
1207+
for (i in 0...this.length) arr.push(this[i]);
1208+
return arr;
1209+
}
1210+
1211+
@:from
1212+
public static inline function fromVector<T>(value:haxe.ds.Vector<T>):HxVector<T> {
1213+
return new HxVector(value);
1214+
}
1215+
1216+
@:from
1217+
public static inline function fromArray<T>(value:Array<T>):HxVector<T> {
1218+
return new HxVector(value);
1219+
}
1220+
1221+
@:arrayAccess
1222+
public inline function arrayRead(idx:Int):T {
1223+
return this[idx];
1224+
}
1225+
1226+
@:arrayAccess
1227+
public inline function arrayWrite(idx:Int, value:T):T {
1228+
this[idx] = value;
1229+
return value;
1230+
}
1231+
1232+
public inline function iterator():Iterator<T> {
1233+
var i = 0;
1234+
var len = this.length;
1235+
return {
1236+
hasNext: function() return i < len,
1237+
next: function() return this[i++];
1238+
};
1239+
}
1240+
}
1241+
11861242
abstract ForceCasted<T>(Dynamic) {
11871243
public inline function new(value:Dynamic) {
11881244
this = value;

source/yutautil/modules/Container.hx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,32 @@ abstract Container<T>(Dynamic) {
1212
public function new() {
1313
this = [];
1414
}
15-
15+
@:from
1616
public function newFromArray(array:Array<T>):Container<T> {
1717
this = array;
1818
return this;
1919
}
20-
20+
@:from
2121
public function newFromMap(map:Map<String, T>):Container<T> {
2222
this = map;
2323
return this;
2424
}
25-
25+
@:from
2626
public function newFromDTable(table:DTable<T>):Container<T> {
2727
this = table;
2828
return this;
2929
}
30-
30+
@:from
3131
public function newFromHTable(table:HTable<T>):Container<T> {
3232
this = table;
3333
return this;
3434
}
35-
35+
@:from
3636
public function newFromFlxGroup(group:FlxGroup):Container<T> {
3737
this = group;
3838
return this;
3939
}
40-
40+
@:from
4141
public function newFromFlxTypedGroup(group:FlxTypedGroup<T>):Container<T> {
4242
this = group;
4343
return this;
@@ -72,7 +72,7 @@ abstract Container<T>(Dynamic) {
7272
throw "Unsupported container type";
7373
}
7474
}
75-
75+
@:arrayAccess
7676
public function get(index:Int):T {
7777
switch (this) {
7878
case a:Array<T>:

0 commit comments

Comments
 (0)