Skip to content

Commit c6a05ef

Browse files
committed
Merge branch 'gmd_rework'
2 parents 20d90f0 + 6c02e72 commit c6a05ef

File tree

10 files changed

+199
-223
lines changed

10 files changed

+199
-223
lines changed

Cirilla.Core.Test/Tests/GMDTests.cs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System.Linq;
12
using Cirilla.Core.Models;
23
using Microsoft.VisualStudio.TestTools.UnitTesting;
34

@@ -27,7 +28,6 @@ public void Load__item_eng()
2728
[TestMethod]
2829
public void Load__armor_eng()
2930
{
30-
// StringCount > actual number of strings
3131
GMD gmd = new GMD(Utility.GetFullPath(@"chunk0/common/text/steam/armor_eng.gmd"));
3232
}
3333

@@ -37,7 +37,7 @@ public void Load__action_trial_eng()
3737
// Uses skipInvalidMessages
3838
GMD gmd = new GMD(Utility.GetFullPath(@"chunk0/common/text/action_trial_eng.gmd"));
3939

40-
Assert.AreEqual(gmd.Strings[3], "©CAPCOM CO., LTD. ALL RIGHTS RESERVED.");
40+
//Assert.AreEqual(gmd.Entries[3].Value, "©CAPCOM CO., LTD. ALL RIGHTS RESERVED.");
4141
}
4242

4343
[TestMethod]
@@ -46,7 +46,19 @@ public void Load__action_trial_ara()
4646
// Uses skipInvalidMessages and weird workaround (see Models/GMD.cs)
4747
GMD gmd = new GMD(Utility.GetFullPath(@"chunk0/common/text/action_trial_ara.gmd"));
4848

49-
Assert.AreEqual(gmd.Strings[3], "©CAPCOM CO., LTD. ALL RIGHTS RESERVED.");
49+
//Assert.AreEqual(gmd.Entries[3].Value, "©CAPCOM CO., LTD. ALL RIGHTS RESERVED.");
50+
}
51+
52+
[TestMethod]
53+
public void Load__cm_facility_eng()
54+
{
55+
GMD gmd = new GMD(Utility.GetFullPath(@"chunk0/common/text/cm_facility_eng.gmd"));
56+
}
57+
58+
[TestMethod]
59+
public void Load__cm_facility_kor()
60+
{
61+
GMD gmd = new GMD(Utility.GetFullPath(@"chunk0/common/text/cm_facility_kor.gmd"));
5062
}
5163

5264
[TestMethod]
@@ -66,7 +78,7 @@ public void Rebuild__em_names_eng()
6678
public void Rebuild__q00503_eng()
6779
{
6880
string origPath = Utility.GetFullPath(@"chunk0/common/text/quest/q00503_eng.gmd");
69-
string rebuildPath = "rebuild__q00503_eng";
81+
string rebuildPath = "rebuild__q00503_eng.gmd";
7082

7183
GMD gmd = new GMD(origPath);
7284
gmd.Save(rebuildPath);
@@ -98,8 +110,8 @@ public void Rebuild__action_trial_eng()
98110
GMD gmd = new GMD(origPath);
99111
gmd.Save(rebuildPath);
100112

101-
//if (!Utility.CheckFilesAreSame(origPath, rebuildPath))
102-
// Assert.Fail("Hash doesn't match!");
113+
if (!Utility.CheckFilesAreSame(origPath, rebuildPath))
114+
Assert.Fail("Hash doesn't match!");
103115
}
104116

105117
[TestMethod]
@@ -111,8 +123,8 @@ public void Rebuild__wep_series_eng()
111123
GMD gmd = new GMD(origPath);
112124
gmd.Save(rebuildPath);
113125

114-
//if (!Utility.CheckFilesAreSame(origPath, rebuildPath))
115-
// Assert.Fail("Hash doesn't match!");
126+
if (!Utility.CheckFilesAreSame(origPath, rebuildPath))
127+
Assert.Fail("Hash doesn't match!");
116128
}
117129

118130
[TestMethod]
@@ -144,24 +156,25 @@ public void AddString__q00503_eng()
144156
Assert.IsTrue(oldGmd.Header.KeyBlockSize < newGmd.Header.KeyBlockSize);
145157
Assert.IsTrue(oldGmd.Header.StringCount < newGmd.Header.StringCount);
146158
Assert.IsTrue(oldGmd.Header.StringBlockSize < newGmd.Header.StringBlockSize);
147-
Assert.IsTrue(newGmd.Strings.Contains("New string text...."));
159+
Assert.IsNotNull(newGmd.Entries.FirstOrDefault(x => x.Value == "New string text...."));
148160
}
149161

150162
[TestMethod]
151-
public void RemoveString__w_sword_eng()
163+
public void ReaddString__w_sword_eng()
152164
{
165+
// This won't display correctly in game, because the string order DOES matter
166+
153167
string origPath = Utility.GetFullPath(@"chunk0/common/text/steam/w_sword_eng.gmd");
154168
string newPath = "removestring__w_sword_eng.gmd";
155169
string readdPath = "readdstring__w_sword_eng.gmd";
156170

157171
GMD gmd = new GMD(origPath);
158-
int idx = gmd.Keys.IndexOf("WP_WSWD_044_NAME");
159172
gmd.RemoveString("WP_WSWD_044_NAME");
160173
gmd.Save(newPath);
161174

162175
GMD newGmd = new GMD(newPath);
163176

164-
newGmd.AddString("WP_WSWD_044_NAME", "My new string", idx);
177+
newGmd.AddString("WP_WSWD_044_NAME", "My new string");
165178
newGmd.Save(readdPath);
166179
}
167180
}

Cirilla.Core/Cirilla.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<Version>0.0.4.1</Version>
5+
<Version>0.0.5</Version>
66
<Authors>Fusion86</Authors>
77
<Company />
88
</PropertyGroup>

Cirilla.Core/Enums/EmLanguage.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
using System;
2-
3-
namespace Cirilla.Core.Enums
1+
namespace Cirilla.Core.Enums
42
{
5-
public enum EmLanguage : UInt32
3+
public enum EmLanguage : int
64
{
75
Japanese = 0,
86
English = 1,

Cirilla.Core/Extensions/BinaryReaderExtensions.cs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ public static T ReadStruct<T>(this BinaryReader br)
2525
}
2626

2727
/// <summary>
28-
/// Read zero terminated string (skips zeros in front of it)
28+
/// Read zero terminated string (skips zeros in front of it).
29+
/// Leaves BaseStream.Position += stringLength + 1 (for szString terminator)
2930
/// </summary>
3031
/// <param name="br"></param>
3132
/// <param name="encoding"></param>
3233
/// <returns></returns>
3334
public static string ReadStringZero(this BinaryReader br, Encoding encoding)
3435
{
3536
byte b;
36-
int skippedZeros = 0;
3737
List<byte> szBytes = new List<byte>();
3838

3939
while (br.BaseStream.Position != br.BaseStream.Length)
@@ -42,26 +42,15 @@ public static string ReadStringZero(this BinaryReader br, Encoding encoding)
4242

4343
if (b == 0)
4444
{
45-
// Stop if we found a \0 **AND** we already have read some text.
46-
// This is because a string could have empty space in front of it.
47-
// While this is 'undocumented behaviour' it works in-game.
48-
if (szBytes.Count > 0)
49-
break;
50-
else
51-
skippedZeros++;
45+
break;
5246
}
5347
else
5448
{
5549
szBytes.Add(b);
5650
}
5751
}
5852

59-
string str = encoding.GetString(szBytes.ToArray());
60-
61-
if (skippedZeros != 0)
62-
Logger.Warn($"Skipped {skippedZeros} zeros in front of string '{str}'");
63-
64-
return str;
53+
return encoding.GetString(szBytes.ToArray());
6554
}
6655
}
6756
}

0 commit comments

Comments
 (0)