Skip to content

Commit 142163f

Browse files
fix a bug of index change (#1)
fix a bug that unexpectedly skipping to smelt some weapons because of index change.
1 parent bf3c997 commit 142163f

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

TLSmithingFasterMod/TLSmithingFasterCraftingCampaignBehaviorDoSmeltingPatch.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, I
3636
}
3737
}
3838
int item_num = itemRoster.GetItemNumber(itemRoster.GetItemAtIndex(i));
39-
for (int j = 0; j < item_num && !IsLocked && itemRoster.GetItemAtIndex(i).IsCraftedWeapon; j++)
39+
int j;
40+
for (j = 0; j < item_num && !IsLocked && itemRoster.GetItemAtIndex(i).IsCraftedWeapon; j++)
4041
{
4142
__instance.DoSmelting(hero, itemRoster.GetItemAtIndex(i));
4243
maxcounts--;
@@ -46,6 +47,11 @@ public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, I
4647
return;
4748
}
4849
}
50+
if (j == item_num)
51+
{
52+
i--;
53+
max_item_count--;
54+
}
4955
IsLocked = false;
5056
}
5157
TLSmithingFasterOperationCounts.Flag = false;
@@ -70,7 +76,8 @@ public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, I
7076
}
7177
}
7278
int item_num = itemRoster.GetItemNumber(itemRoster.GetItemAtIndex(i));
73-
for (int j = 0; j < item_num && !IsLocked && itemRoster.GetItemAtIndex(i).IsCraftedWeapon; j++)
79+
int j;
80+
for (j = 0; j < item_num && !IsLocked && itemRoster.GetItemAtIndex(i).IsCraftedWeapon; j++)
7481
{
7582
__instance.DoSmelting(hero, itemRoster.GetItemAtIndex(i));
7683
maxcounts--;
@@ -80,6 +87,11 @@ public static void Postfix(ref CraftingCampaignBehavior __instance, Hero hero, I
8087
return;
8188
}
8289
}
90+
if (j == item_num)
91+
{
92+
i--;
93+
max_item_count--;
94+
}
8395
IsLocked = false;
8496
}
8597
TLSmithingFasterOperationCounts.Flag = false;

0 commit comments

Comments
 (0)