Exemplo n.º 1
0
  private Object read(
      DataInput objBuffer,
      Type propertyType,
      boolean array,
      UnrealPackageReadOnly.ExportEntry arrayInner,
      String structName,
      UnrealPackageReadOnly up)
      throws IOException {
    switch (propertyType) {
      case NONE:
        return null;
      case BYTE:
        return objBuffer.readUnsignedByte();
      case INT:
        return objBuffer.readInt();
      case BOOL:
        return array;
      case FLOAT:
        return objBuffer.readFloat();
      case OBJECT:
        return objBuffer.readCompactInt();
      case NAME:
        return objBuffer.readCompactInt();
      case ARRAY:
        int arraySize = objBuffer.readCompactInt();
        List<Object> arrayList = new ArrayList<>(arraySize);

        String a = arrayInner.getObjectClass().getObjectName().getName();
        Property f = unrealClassLoader.getProperty(arrayInner.getObjectFullName());

        array = false;
        arrayInner = null;
        structName = null;
        propertyType = Type.valueOf(a.replace("Property", "").toUpperCase());
        if (propertyType == Type.STRUCT) {
          StructProperty structProperty = (StructProperty) f;
          structName = structProperty.getStructType().getObjectFullName();
        }
        if (propertyType == Type.ARRAY) {
          array = true;
          ArrayProperty arrayProperty = (ArrayProperty) f;
          arrayInner = (UnrealPackageReadOnly.ExportEntry) arrayProperty.getInner();
        }

        for (int i = 0; i < arraySize; i++) {
          arrayList.add(read(objBuffer, propertyType, array, arrayInner, structName, up));
        }
        return arrayList;
      case STRUCT:
        return readStruct(objBuffer, structName, up);
        /*case VECTOR:
            return readStruct(objBuffer, "Vector", up);
        case ROTATOR:
            return readStruct(objBuffer, "Rotator", up);*/
      case STR:
        return objBuffer.readLine();
      default:
        throw new IllegalStateException("Unk type(" + structName + "): " + propertyType);
    }
  }
Exemplo n.º 2
0
 private static int readPropertySize(int sizeType, DataInput dataInput) throws IOException {
   switch (sizeType) {
     case 0:
       return 1;
     case 1:
       return 2;
     case 2:
       return 4;
     case 3:
       return 12;
     case 4:
       return 16;
     case 5:
       return dataInput.readUnsignedByte();
     case 6:
       return dataInput.readUnsignedShort();
     case 7:
       return dataInput.readInt();
     default:
       throw new IllegalArgumentException();
   }
 }
Exemplo n.º 3
0
  public List<L2Property> readStructBin(
      DataInput objBuffer, String structName, UnrealPackageReadOnly up) throws UnrealException {
    List<Property> properties = unrealClassLoader.getStructProperties(structName);

    try {
      switch (structName) {
        case "Core.Object.Vector":
          {
            L2Property x = new L2Property(properties.get(0), up);
            x.putAt(0, objBuffer.readFloat());
            L2Property y = new L2Property(properties.get(1), up);
            y.putAt(0, objBuffer.readFloat());
            L2Property z = new L2Property(properties.get(2), up);
            z.putAt(0, objBuffer.readFloat());
            return Arrays.asList(x, y, z);
          }
        case "Core.Object.Rotator":
          {
            L2Property pitch = new L2Property(properties.get(0), up);
            pitch.putAt(0, objBuffer.readInt());
            L2Property yaw = new L2Property(properties.get(1), up);
            yaw.putAt(0, objBuffer.readInt());
            L2Property roll = new L2Property(properties.get(2), up);
            roll.putAt(0, objBuffer.readInt());
            return Arrays.asList(pitch, yaw, roll);
          }
        case "Core.Object.Color":
          {
            L2Property b = new L2Property(properties.get(0), up);
            b.putAt(0, objBuffer.readUnsignedByte());
            L2Property g = new L2Property(properties.get(1), up);
            g.putAt(0, objBuffer.readUnsignedByte());
            L2Property r = new L2Property(properties.get(2), up);
            r.putAt(0, objBuffer.readUnsignedByte());
            L2Property a = new L2Property(properties.get(3), up);
            a.putAt(0, objBuffer.readUnsignedByte());
            return Arrays.asList(b, g, r, a);
          }
        case "Fire.FireTexture.Spark":
          {
            L2Property type = new L2Property(properties.get(0), up);
            type.putAt(0, objBuffer.readUnsignedByte());
            L2Property heat = new L2Property(properties.get(1), up);
            heat.putAt(0, objBuffer.readUnsignedByte());
            L2Property x = new L2Property(properties.get(2), up);
            x.putAt(0, objBuffer.readUnsignedByte());
            L2Property y = new L2Property(properties.get(3), up);
            y.putAt(0, objBuffer.readUnsignedByte());
            L2Property byteA = new L2Property(properties.get(4), up);
            byteA.putAt(0, objBuffer.readUnsignedByte());
            L2Property byteB = new L2Property(properties.get(5), up);
            byteB.putAt(0, objBuffer.readUnsignedByte());
            L2Property byteC = new L2Property(properties.get(6), up);
            byteC.putAt(0, objBuffer.readUnsignedByte());
            L2Property byteD = new L2Property(properties.get(7), up);
            byteD.putAt(0, objBuffer.readUnsignedByte());
            return Arrays.asList(type, heat, x, y, byteA, byteB, byteC, byteD);
          }
        default:
          throw new UnsupportedOperationException("Not implemented"); // TODO
      }
    } catch (IOException e) {
      throw new UnrealException(e);
    }
  }