• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeltyPlayer / MeltyTool / 21239091484

22 Jan 2026 06:55AM UTC coverage: 42.242% (-0.01%) from 42.255%
21239091484

push

github

MeltyPlayer
More fiddling w/ PLvPW.

6865 of 18402 branches covered (37.31%)

Branch coverage included in aggregate %.

0 of 41 new or added lines in 2 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

29415 of 67485 relevant lines covered (43.59%)

64421.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/FinModelUtility/Libraries/Level5/Level5/src/schema/Res.cs
1
using fin.io;
2
using fin.schema;
3

4
using level5.decompression;
5

6
using schema.binary;
7
using schema.binary.attributes;
8

9
namespace level5.schema;
10

11
public enum ResourceType {
12
  MATERIAL_1 = 220,
13
  MATERIAL_2 = 230,
14
  TEXTURE_DATA = 240,
15
  MATERIAL_DATA = 290,
16
  NULL = 9999,
17
}
18

19
public sealed class Resource {
20
  public sealed class Material {
21
    public string Name { get; set; }
×
22
    public int Index { get; set; } = -1;
×
23
    public string TexName { get; set; }
×
24
  }
25

26
  public string ModelName { get; set; }
×
27

28
  Dictionary<uint, string> ResourceNames { get; set; } =
×
29
    new Dictionary<uint, string>();
×
30

NEW
31
  Dictionary<uint, (ResourceType, string)> ResourceData { get; set; } = new();
×
32

UNCOV
33
  public List<string> TextureNames { get; } = [];
×
34

35
  public List<Material> Materials { get; } = [];
×
36

37
  public string GetResourceName(uint crc) {
×
38
    if (this.ResourceNames.ContainsKey(crc))
×
39
      return this.ResourceNames[crc];
×
40

41
    return "";
×
42
  }
×
43

NEW
44
  public (ResourceType, string)? GetResourceData(uint crc) {
×
NEW
45
    if (this.ResourceData.TryGetValue(crc, out (ResourceType, string) data)) {
×
NEW
46
      return data;
×
47
    }
48

NEW
49
    return null;
×
NEW
50
  }
×
51

52
  [Unknown]
53
  public Resource(IReadOnlyGenericFile file) {
×
54
    var data = file.ReadAllBytes();
×
55
    data = new Level5Decompressor().Decompress(data);
×
56
    using (var r = new SchemaBinaryReader(new MemoryStream(data),
×
57
                                          Endianness.LittleEndian)) {
×
58
      var magic = new string(r.ReadChars(6));
×
59
      if (magic != "CHRC00" && magic != "CHRN01")
×
60
        throw new FormatException("RES file is corrupt");
×
61

62
      // -----------------------
63
      var unknown0 = r.ReadInt16();
×
64
      var stringTableOffset = r.ReadInt16() << 2;
×
65
      var unknown1 = r.ReadInt16();
×
66
      var materialTableOffset = r.ReadInt16() << 2;
×
67
      var materialTableSectionCount = r.ReadInt16();
×
68
      var resourceNodeOffsets = r.ReadInt16() << 2;
×
69
      var resourceNodeCount = r.ReadInt16();
×
70

71
      r.Position = (uint)stringTableOffset;
×
72
      while (!r.Eof) {
×
73
        string mname = r.ReadStringNT(StringEncodingType.SHIFT_JIS);
×
74
        if (mname == "")
×
75
          break;
×
76
        if (!this.ResourceNames.ContainsKey(Crc32.Crc32C(mname)))
×
77
          this.ResourceNames.Add(Crc32.Crc32C(mname), mname);
×
78
      }
×
79

80
      r.Position = (uint)materialTableOffset;
×
81
      for (int i = 0; i < materialTableSectionCount; i++) {
×
82
        var offset = r.ReadInt16() << 2;
×
83
        var count = r.ReadInt16();
×
NEW
84
        var resourceType = (ResourceType) r.ReadInt16();
×
85
        var size = r.ReadInt16();
×
86

NEW
87
        if (resourceType == ResourceType.NULL)
×
88
          continue;
×
89

90
        var temp = r.Position;
×
91
        for (int j = 0; j < count; j++) {
×
92
          r.Position = (uint)(offset + j * size);
×
93
          var key = r.ReadUInt32();
×
94
          string resourceName = (this.ResourceNames.ContainsKey(key)
×
95
              ? this.ResourceNames[key]
×
96
              : key.ToString("X"));
×
97

NEW
98
          this.ResourceData[key] = (resourceType, resourceName);
×
99
          
100
          //Console.WriteLine(resourceName + " " + unknown.ToString("X") + " " + size.ToString("X"));
101

NEW
102
          if (resourceType is ResourceType.MATERIAL_1
×
NEW
103
                              or ResourceType.MATERIAL_2) {
×
104
            // TODO: Default libs
105
            ;
×
NEW
106
          } else if (resourceType == ResourceType.TEXTURE_DATA) {
×
107
            this.TextureNames.Add(resourceName);
×
NEW
108
          } else if (resourceType == ResourceType.MATERIAL_DATA) {
×
109
            Material mat = new Material();
×
110
            mat.Name = resourceName;
×
111
            r.Position += 12;
×
112
            key = r.ReadUInt32();
×
113
            resourceName = (this.ResourceNames.ContainsKey(key)
×
114
                ? this.ResourceNames[key]
×
115
                : key.ToString("X"));
×
116
            mat.TexName = resourceName;
×
117
            // Console.WriteLine(resourceName + " " + unknown.ToString("X") + " " + size.ToString("X"));
118
            this.Materials.Add(mat);
×
119
          } else {
×
120
            ;
×
121
          }
×
122
        }
×
123

124
        r.Position = temp;
×
125
      }
×
126

127
      r.Position = (uint)resourceNodeOffsets;
×
128
      for (int i = 0; i < resourceNodeCount; i++) {
×
129
        var offset = r.ReadInt16() << 2;
×
130
        var count = r.ReadInt16();
×
131
        var unknown = r.ReadInt16();
×
132
        var size = r.ReadInt16();
×
133

134
        if (unknown == 0x270F)
×
135
          continue;
×
136

137
        var temp = r.Position;
×
138
        r.Position = (uint)offset;
×
139
        for (int j = 0; j < count; j++) {
×
140
          var key = r.ReadUInt32();
×
141
          //Console.WriteLine((ResourceNames.ContainsKey(key) ? ResourceNames[key] : key.ToString("X")) + " " + unknown.ToString("X") + " " + size.ToString("X"));
142
          r.Position += (uint)(size - 4);
×
143
        }
×
144

145
        r.Position = temp;
×
146
      }
×
147
    }
×
148
  }
×
149
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc