diff --git a/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/rtti/HFWTypeReader.java b/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/rtti/HFWTypeReader.java index 18ade0a7..e1ac57d2 100644 --- a/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/rtti/HFWTypeReader.java +++ b/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/rtti/HFWTypeReader.java @@ -18,7 +18,7 @@ import static com.shade.decima.game.hfw.rtti.HorizonForbiddenWest.RTTIRefObject; public class HFWTypeReader extends AbstractTypeReader { - public record ObjectInfo(@NotNull RTTIRefObject object, @NotNull ClassTypeInfo info) {} + public record ObjectInfo(@NotNull ClassTypeInfo type, @NotNull RTTIRefObject object) {} @NotNull public static T readCompound(@NotNull Class cls, @NotNull BinaryReader reader, @NotNull TypeFactory factory) throws IOException { @@ -43,7 +43,7 @@ public ObjectInfo readObject(@NotNull BinaryReader reader, @NotNull TypeFactory throw new IllegalStateException("Expected RTTIRefObject, got " + type.name()); } - return new ObjectInfo(refObject, type); + return new ObjectInfo(type, refObject); } @NotNull diff --git a/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/ObjectStreamingSystem.java b/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/ObjectStreamingSystem.java index 1fcd0fde..ed24899f 100644 --- a/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/ObjectStreamingSystem.java +++ b/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/ObjectStreamingSystem.java @@ -1,11 +1,10 @@ package com.shade.decima.game.hfw.storage; +import com.shade.decima.game.hfw.rtti.HorizonForbiddenWest.StreamingDataSource; import com.shade.util.NotNull; import java.io.IOException; -import static com.shade.decima.game.hfw.rtti.HorizonForbiddenWest.StreamingDataSourceLocator; - public final class ObjectStreamingSystem { /** * Represents the result of reading a link from the link table. @@ -27,8 +26,13 @@ public ObjectStreamingSystem(@NotNull StorageReadDevice device, @NotNull Streami } @NotNull - public byte[] getDataSourceData(@NotNull StreamingDataSourceLocator locator, int offset, int length) throws IOException { - return getFileData((int) (locator.data() & 0xffffff), Math.addExact(locator.data() >>> 24, offset), length); + public byte[] getDataSourceData(@NotNull StreamingDataSource dataSource) throws IOException { + return getDataSourceData(dataSource, dataSource.offset(), dataSource.length()); + } + + @NotNull + public byte[] getDataSourceData(@NotNull StreamingDataSource dataSource, int offset, int length) throws IOException { + return getFileData((int) (dataSource.locator() & 0xffffff), Math.addExact(dataSource.locator() >>> 24, offset), length); } @NotNull diff --git a/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/StreamingObjectReader.java b/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/StreamingObjectReader.java index 25c606d6..320ac494 100644 --- a/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/StreamingObjectReader.java +++ b/modules/decima-game-horizon-forbidden-west/src/main/java/com/shade/decima/game/hfw/storage/StreamingObjectReader.java @@ -113,7 +113,7 @@ public GroupInfo readGroup(int id, @NotNull List groups) throws IOExc for (int i = 0; i < group.numObjects(); i++) { var type = graph.types().get(group.typeStart() + objects.size()); var object = (RTTIRefObject) type.newInstance(); - objects.add(new ObjectInfo(object, type)); + objects.add(new ObjectInfo(type, object)); } var result = new GroupInfo(group, objects); @@ -132,7 +132,7 @@ public GroupInfo readGroup(int id, @NotNull List groups) throws IOExc var object = objects.get(j++); if (DEBUG) { - log.debug("{}Reading \033[33m{}\033[0m at offset \033[34m{}\033[0m in \033[33m{}\033[0m", " ".repeat(depth), object.info(), span.offset() + reader.position(), getSpanFile(span)); + log.debug("{}Reading \033[33m{}\033[0m at offset \033[34m{}\033[0m in \033[33m{}\033[0m", " ".repeat(depth), object.type(), span.offset() + reader.position(), getSpanFile(span)); } fillCompound(object, reader); @@ -146,7 +146,7 @@ public GroupInfo readGroup(int id, @NotNull List groups) throws IOExc private void fillCompound(@NotNull ObjectInfo info, @NotNull BinaryReader reader) throws IOException { var object = info.object(); - for (ClassAttrInfo attr : info.info().serializableAttrs()) { + for (ClassAttrInfo attr : info.type().serializableAttrs()) { attr.set(object, read(attr.type().get(), reader, factory)); } if (object instanceof ExtraBinaryDataHolder holder) { @@ -227,7 +227,7 @@ private void resolveLink(@NotNull PointerTypeInfo info, @NotNull Ref ref) { linkIndex, linkGroup, group.group.groupID(), - object.info(), + object.type(), matches ? "\033[32mtrue\033[0m" : "\033[31mfalse\033[0m" ); }