Skip to content

Commit e687c8c

Browse files
committed
Added a missing value to FoxEntity that is required by Fox Engine.
1 parent af2ae60 commit e687c8c

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

FoxTool/Fox/FoxClass.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public class FoxClass : IXmlSerializable
88
{
99
public string Name { get; set; }
1010
public string Super { get; set; }
11-
public string TestUnknown { get; set; }
1211
public string Version { get; set; }
1312

1413
public XmlSchema GetSchema()
@@ -33,8 +32,7 @@ public void WriteXml(XmlWriter writer)
3332

3433
protected bool Equals(FoxClass other)
3534
{
36-
return string.Equals(Name, other.Name) && string.Equals(Super, other.Super) &&
37-
string.Equals(TestUnknown, other.TestUnknown);
35+
return string.Equals(Name, other.Name) && string.Equals(Super, other.Super);
3836
}
3937

4038
public override bool Equals(object obj)
@@ -51,7 +49,6 @@ public override int GetHashCode()
5149
{
5250
var hashCode = (Name != null ? Name.GetHashCode() : 0);
5351
hashCode = (hashCode*397) ^ (Super != null ? Super.GetHashCode() : 0);
54-
hashCode = (hashCode*397) ^ (TestUnknown != null ? TestUnknown.GetHashCode() : 0);
5552
return hashCode;
5653
}
5754
}

FoxTool/Fox/FoxEntity.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ public FoxEntity()
2525

2626
public ulong ClassNameHash { get; set; }
2727
public string ClassName { get; set; }
28-
public byte ClassId { get; set; }
28+
public short Unknown { get; set; }
2929
public short Version { get; set; }
30-
public byte SuperClassId { get; set; }
3130
public uint Address { get; set; }
3231

3332
public IEnumerable<FoxProperty> StaticProperties
@@ -48,10 +47,12 @@ public XmlSchema GetSchema()
4847
public void ReadXml(XmlReader reader)
4948
{
5049
ClassName = reader.GetAttribute("class");
50+
Version = short.Parse(reader.GetAttribute("classVersion"));
5151
string addr = reader.GetAttribute("addr");
5252
Address = addr.StartsWith("0x")
5353
? uint.Parse(addr.Substring(2, addr.Length - 2), NumberStyles.AllowHexSpecifier)
5454
: uint.Parse(addr);
55+
Unknown = short.Parse(reader.GetAttribute("unknown"));
5556

5657
var isEmptyElement = reader.IsEmptyElement;
5758
reader.ReadStartElement("entity");
@@ -91,7 +92,11 @@ public void ReadXml(XmlReader reader)
9192
public void WriteXml(XmlWriter writer)
9293
{
9394
writer.WriteAttributeString("class", ClassName);
95+
writer.WriteAttributeString("classVersion", Version.ToString());
9496
writer.WriteAttributeString("addr", String.Format("0x{0:X8}", Address));
97+
// TODO: Rename unknown1 attributes
98+
writer.WriteAttributeString("unknown", Unknown.ToString());
99+
95100

96101
writer.WriteStartElement("staticProperties");
97102
foreach (var staticProperty in StaticProperties)
@@ -123,8 +128,7 @@ private void Read(Stream input)
123128
{
124129
BinaryReader reader = new BinaryReader(input, Encoding.Default, true);
125130
short headerSize = reader.ReadInt16();
126-
ClassId = reader.ReadByte();
127-
SuperClassId = reader.ReadByte();
131+
Unknown = reader.ReadInt16();
128132
short padding1 = reader.ReadInt16();
129133
uint magicNumber1 = reader.ReadUInt32();
130134
Address = reader.ReadUInt32();
@@ -185,12 +189,12 @@ public void Write(Stream output)
185189
uint size = (uint) (endPosition - headerPosition);
186190
output.Position = headerPosition;
187191
writer.Write(HeaderSize);
188-
writer.Write(ClassId);
189-
writer.Write(SuperClassId);
192+
writer.Write(Unknown);
190193
writer.WriteZeros(2);
191194
writer.Write(MagicNumber);
192195
writer.Write(Address);
193-
writer.WriteZeros(14);
196+
writer.WriteZeros(12);
197+
writer.Write(Version);
194198
writer.Write(ClassNameHash);
195199
writer.Write(Convert.ToUInt16(StaticProperties.Count()));
196200
writer.Write(Convert.ToUInt16(DynamicProperties.Count()));

FoxTool/Fox/FoxFile.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ private void GenerateClasses()
151151
{
152152
Name = "Entity",
153153
Super = "",
154-
Version = "2",
155-
TestUnknown = ""
154+
Version = "2"
156155
};
157156
_classes.Add(entityClass);
158157

@@ -169,8 +168,7 @@ private void GenerateClasses()
169168
FoxClass foxClass = new FoxClass
170169
{
171170
Name = entity.ClassName,
172-
Version = entity.Version.ToString(),
173-
TestUnknown = entity.SuperClassId.ToString()
171+
Version = entity.Version.ToString()
174172
};
175173

176174
if (_classes.Contains(foxClass) == false)

FoxTool/Fox/Types/Values/FoxFilePtr.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public XmlSchema GetSchema()
7373

7474
public void WriteXml(XmlWriter writer)
7575
{
76-
if(FileName == null)
76+
if (FileName == null)
7777
FileNameHash.WriteXml(writer);
7878
else
7979
writer.WriteString(FileName);

FoxTool/Fox/Types/Values/FoxString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public XmlSchema GetSchema()
7272

7373
public void WriteXml(XmlWriter writer)
7474
{
75-
if(String == null)
75+
if (String == null)
7676
StringHash.WriteXml(writer);
7777
else
7878
writer.WriteString(String);

FoxTool/Hashing.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static ulong HashString(string text)
88
{
99
if (text == null) throw new ArgumentNullException("text");
1010
const ulong seed0 = 0x9ae16a3b2f90404f;
11-
ulong seed1 = text.Length > 0 ? (uint)((text[0]) << 16) + (uint)text.Length : 0;
11+
ulong seed1 = text.Length > 0 ? (uint) ((text[0]) << 16) + (uint) text.Length : 0;
1212
return CityHash.CityHash.CityHash64WithSeeds(text + "\0", seed0, seed1) & 0xFFFFFFFFFFFF;
1313
}
1414
}

0 commit comments

Comments
 (0)