Skip to content

Commit

Permalink
[HaCreator] fix initialisation errors with MapleStoryU String,wz (TOD…
Browse files Browse the repository at this point in the history
…O: Mintable item handling)
  • Loading branch information
lastbattle committed Nov 24, 2024
1 parent 58dc5a2 commit 17639be
Showing 1 changed file with 38 additions and 26 deletions.
64 changes: 38 additions & 26 deletions HaCreator/GUI/Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,7 @@ public void ExtractStringFile(bool bIsBetaMapleStory)
{
// In non-beta, process each item within the category
eqpCategorySubProp.WzProperties
.Cast<WzSubProperty>()
//.Cast<WzSubProperty>()
.ToList()
.ForEach(itemProp => ExtractStringFile_ProcessEquipmentItem(
itemProp,
Expand All @@ -1104,22 +1104,28 @@ public void ExtractStringFile(bool bIsBetaMapleStory)
else
stringInsImg = ((WzImage)Program.WzManager.FindWzImageByName("string", "Ins.img")).WzProperties;

foreach (WzSubProperty insItemImg in stringInsImg) // String.wz/Ins.img/3010000
foreach (WzImageProperty insItemImage in stringInsImg) // String.wz/Ins.img/3010000
{
string itemId = insItemImg.Name;
const string itemCategory = "Ins";
string itemName = (insItemImg["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (insItemImg["desc"] as WzStringProperty)?.Value ?? "NO DESC";
if (insItemImage is WzSubProperty insItemSubProp)
{
string itemId = insItemSubProp.Name;
const string itemCategory = "Ins";
string itemName = (insItemSubProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (insItemSubProp["desc"] as WzStringProperty)?.Value ?? "NO DESC";

int intName = 0;
int.TryParse(itemId, out intName);
int intName = 0;
int.TryParse(itemId, out intName);

if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(itemCategory, itemName, itemDesc);
else
if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(itemCategory, itemName, itemDesc);
else
{
string error = string.Format("[Initialization] Duplicate [Ins] item name in String.wz. ItemId='{0}', Category={1}", itemId, insItemSubProp.Name);
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
}
} else
{
string error = string.Format("[Initialization] Duplicate [Ins] item name in String.wz. ItemId='{0}', Category={1}", itemId, insItemImg.Name);
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
// TOOD: Handle MapleStoryU related items
}
}

Expand Down Expand Up @@ -1245,23 +1251,29 @@ private void ExtractStringFile_ProcessEtcItem(WzSubProperty itemProp, string par
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
}
}
private void ExtractStringFile_ProcessEquipmentItem(WzSubProperty itemProp, string category)
private void ExtractStringFile_ProcessEquipmentItem(WzImageProperty itemImageProp, string category)
{
string itemId = itemProp.Name;
string itemName = (itemProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (itemProp["desc"] as WzStringProperty)?.Value ?? "NO DESC";

if (int.TryParse(itemId, out int intName))
if (itemImageProp is WzSubProperty itemProp)
{
if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
{
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(category, itemName, itemDesc);
}
else
string itemId = itemProp.Name;
string itemName = (itemProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (itemProp["desc"] as WzStringProperty)?.Value ?? "NO DESC";

if (int.TryParse(itemId, out int intName))
{
string error = $"[Initialization] Duplicate [Equip] item name in String.wz. ItemId='{itemId}', Category={category}";
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
{
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(category, itemName, itemDesc);
}
else
{
string error = $"[Initialization] Duplicate [Equip] item name in String.wz. ItemId='{itemId}', Category={category}";
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
}
}
} else
{
// TODO: Handle MapleStoryU related equipments
}
}

Expand Down

1 comment on commit 17639be

@lastbattle
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

^^

Please sign in to comment.