Skip to content

Commit

Permalink
Update ClothingLoader.cs
Browse files Browse the repository at this point in the history
Fixing dictionary errors caused by missing mods by skipping associated key rather than overwriting it
  • Loading branch information
jalil49 committed Mar 5, 2021
1 parent 7c552ed commit 1750744
Showing 1 changed file with 37 additions and 18 deletions.
55 changes: 37 additions & 18 deletions src/ClothingLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,18 @@ private static void Generalized(int outfitnum)
//{
// ExpandedOutfit.Logger.LogDebug($"Overwriting Accessory (ID:{chaControl.chaFile.coordinate[outfitnum].accessory.parts[i].id}) at {i + 1} with default head accessory");
//}
chaControl.chaFile.coordinate[outfitnum].accessory.parts[ACCpostion] = import.Dequeue();
if (Subimport.Peek() != null)
{
Temp.Add(ACCpostion, Subimport.Dequeue());
}
else
if (!Temp.ContainsKey(ACCpostion))
{
Subimport.Dequeue();
chaControl.chaFile.coordinate[outfitnum].accessory.parts[ACCpostion] = import.Dequeue();

if (Subimport.Peek() != null)
{
Temp.Add(ACCpostion, Subimport.Dequeue());
}
else
{
Subimport.Dequeue();
}
}
}
}
Expand All @@ -151,7 +155,31 @@ private static void Generalized(int outfitnum)
Empty = data.nowAccessories[ACCpostion].type == 120;
if (Empty) //120 is empty/default
{
data.nowAccessories[ACCpostion] = import.Dequeue();
if (!Temp.ContainsKey(ACCpostion))
{
data.nowAccessories[ACCpostion] = import.Dequeue();
if (Subimport.Peek() != null)
{
Temp.Add(ACCpostion, Subimport.Dequeue());
}
else
{
Subimport.Dequeue();
}
}
}
}
bool print = true;
while (import.Count != 0)
{
if (print)
{
print = false;
ExpandedOutfit.Logger.LogDebug(chaControl.fileParam.fullname + $" Ran out of space for accessories, Making {import.Count} space(s) at least (due to potential keys already existing just in case)");
}
if (!Temp.ContainsKey(ACCpostion))
{
data.nowAccessories.Add(import.Dequeue());
if (Subimport.Peek() != null)
{
Temp.Add(ACCpostion, Subimport.Dequeue());
Expand All @@ -161,18 +189,9 @@ private static void Generalized(int outfitnum)
Subimport.Dequeue();
}
}
}
while (import.Count != 0)
{
//ExpandedOutfit.Logger.logdebug(chaControl.fileParam.fullname + " Ran out of space for accessory, adding a space");
data.nowAccessories.Add(import.Dequeue());
if (Subimport.Peek() != null)
{
Temp.Add(ACCpostion, Subimport.Dequeue());
}
else
{
Subimport.Dequeue();
data.nowAccessories.Add(new ChaFileAccessory.PartsInfo());
}
data.infoAccessory.Add(null);
data.objAccessory.Add(null);
Expand Down

0 comments on commit 1750744

Please sign in to comment.