Skip to content

Commit

Permalink
A bug to detect the end of the String, Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcussacana committed Jun 14, 2017
1 parent b00bf86 commit a3771ce
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions AutomataTranslator/BIN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class MRubyStringEditor {
byte[] Script;
int StringStartPos;
int StringEndPos;
public int StringTableLength { get { return StringEndPos - StringStartPos; } }
public int StringTableLength => StringEndPos - StringStartPos;
RiteHdr Hdr;
public bool AssertLength = true;
public MRubyStringEditor(byte[] Script) {
Expand All @@ -36,20 +36,24 @@ public class MRubyStringEditor {
StringStartPos = (Hdr.Unk2DataLength * 4) + 0x84 + 0x08;//0x84 = Relative Offset; 0x8 = ??
Reader.BaseStream.Position = StringStartPos;
List<string> Strings = new List<string>();
long LastStr = 0;
while (true) {
LastStr = Reader.BaseStream.Position + 3;
string String = ReadString(Reader.BaseStream);
if (String == string.Empty || String.Contains("_")) {
if (String == string.Empty || String.Contains("_") || String.Contains("\x0")) {
long Pos = Reader.BaseStream.Position;
bool Result = false;
try {
string tmp = ReadString(Reader.BaseStream);
if (!(tmp == string.Empty || tmp.Contains("_")))
if (!(tmp == string.Empty || tmp.Contains("_") || String.Contains("\x0")))
Result = true;
}
catch { }
Reader.BaseStream.Position = Pos;
if (!Result)
if (!Result) {
Reader.BaseStream.Position = LastStr;
break;
}
}
Strings.Add(String);
}
Expand Down

0 comments on commit a3771ce

Please sign in to comment.