Skip to content

Commit 532a5b0

Browse files
committed
Fix crash when patching ModifyTooltip
1 parent 19da926 commit 532a5b0

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

ModLocalizer/Patcher.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,10 @@ void ApplyItemsInternal(ItemTranslation translation, TranslationEmitter emitter)
140140
}
141141
else if (ins.OpCode.Equals(OpCodes.Call) && ins.Operand is MemberRef n && n.Name.Equals("Concat")) // for thorium mod
142142
{
143-
int index2 = index, reversedListIndex = 0, argumentCount = 0;
143+
int index2 = index, argumentCount = 0;
144144
var total = n.MethodSig.Params.Count + 1;
145145

146-
var reversedList = translation.ModifyTooltips.GetRange(index, translation.ModifyTooltips.Count - index);
147-
reversedList.Reverse();
148-
146+
// get ldstr instructions we need to change their operand
149147
var ldstrList = new List<Instruction>();
150148
while (--index2 > 0 && argumentCount < total)
151149
{
@@ -160,10 +158,11 @@ void ApplyItemsInternal(ItemTranslation translation, TranslationEmitter emitter)
160158
ldstrList.Add(ins);
161159
}
162160
}
161+
ldstrList.Reverse();
163162

164163
foreach (var ldstrInstruction in ldstrList)
165164
{
166-
ldstrInstruction.Operand = reversedList[reversedListIndex++];
165+
ldstrInstruction.Operand = translation.ModifyTooltips[listIndex++];
167166
index++;
168167
}
169168
}
@@ -409,8 +408,8 @@ void ApplyCustomTranslationsInternal(IList<CustomTranslation> translations, Tran
409408
var ins = inst[index];
410409

411410
if (!ins.OpCode.Equals(OpCodes.Call) ||
412-
!(ins.Operand is IMethod m) ||
413-
!string.Equals(m.Name.ToString(), "CreateTranslation"))
411+
!(ins.Operand is IMethod m) ||
412+
!string.Equals(m.Name.ToString(), "CreateTranslation"))
414413
continue;
415414

416415
if (!(ins = inst[++index]).IsStloc())

ModLocalizer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414

1515
[assembly: Guid("613f981d-c5dd-43d1-b0ff-057169a647c4")]
1616

17-
[assembly: AssemblyVersion("0.10.0.0")]
18-
[assembly: AssemblyFileVersion("0.10.0.0")]
17+
[assembly: AssemblyVersion("0.10.1.0")]
18+
[assembly: AssemblyFileVersion("0.10.1.0")]

0 commit comments

Comments
 (0)