Skip to content

Commit 4212989

Browse files
committed
Update v3.0.6.2
2 parents 3df03db + 98643f7 commit 4212989

File tree

17 files changed

+380
-109
lines changed

17 files changed

+380
-109
lines changed

xivModdingFramework/Cache/XivCache.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public static class XivCache
7777
private static GameInfo _gameInfo;
7878
private static DirectoryInfo _dbPath;
7979
private static DirectoryInfo _rootCachePath;
80-
public static readonly Version CacheVersion = new Version("1.0.3.3");
80+
public static readonly Version CacheVersion = new Version("1.0.3.4");
8181
private const string dbFileName = "mod_cache.db";
8282
private const string rootCacheFileName = "item_sets.db";
8383
private const string creationScript = "CreateCacheDB.sql";
@@ -981,15 +981,14 @@ private static async Task RebuildGearCache(ModTransaction tx)
981981
{
982982
foreach (var item in items)
983983
{
984-
var query = @"insert into items ( exd_id, primary_id, secondary_id, imc_variant, slot, slot_full, name, icon_id, is_weapon, root)
985-
values($exd_id, $primary_id, $secondary_id, $imc_variant, $slot, $slot_full, $name, $icon_id, $is_weapon, $root)";
984+
var query = @"insert into items ( exd_id, primary_id, secondary_id, imc_variant, slot, slot_full, name, icon_id, root)
985+
values($exd_id, $primary_id, $secondary_id, $imc_variant, $slot, $slot_full, $name, $icon_id, $root)";
986986
var root = item.GetRootInfo();
987987
using (var cmd = new SQLiteCommand(query, db))
988988
{
989989
cmd.Parameters.AddWithValue("exd_id", item.ExdID);
990990
cmd.Parameters.AddWithValue("primary_id", item.ModelInfo.PrimaryID);
991991
cmd.Parameters.AddWithValue("secondary_id", item.ModelInfo.SecondaryID);
992-
cmd.Parameters.AddWithValue("is_weapon", ((XivGearModelInfo)item.ModelInfo).IsWeapon);
993992
cmd.Parameters.AddWithValue("slot", item.GetItemSlotAbbreviation());
994993
cmd.Parameters.AddWithValue("slot_full", item.SecondaryCategory);
995994
cmd.Parameters.AddWithValue("imc_variant", item.ModelInfo.ImcSubsetID);
@@ -1361,7 +1360,7 @@ internal static XivCharacter MakeCharacter(CacheReader reader)
13611360
/// <returns></returns>
13621361
internal static XivGear MakeGear(CacheReader reader)
13631362
{
1364-
var primaryMi = new XivGearModelInfo();
1363+
var primaryMi = new XivModelInfo();
13651364

13661365
var item = new XivGear
13671366
{
@@ -1373,11 +1372,24 @@ internal static XivGear MakeGear(CacheReader reader)
13731372

13741373
item.Name = reader.GetString("name");
13751374
item.IconId = (uint)reader.GetInt32("icon_id");
1376-
//primaryMi.IsWeapon = reader.GetBoolean("is_weapon");
13771375
primaryMi.PrimaryID = reader.GetInt32("primary_id");
13781376
primaryMi.SecondaryID = reader.GetInt32("secondary_id");
13791377
primaryMi.ImcSubsetID = reader.GetInt32("imc_variant");
13801378

1379+
if (item.IsWeapon)
1380+
{
1381+
item.PrimaryCategory = XivStrings.Weapons;
1382+
var wt = item.WeaponType;
1383+
item.SecondaryCategory = wt.GetNiceName();
1384+
}
1385+
else if (item.SecondaryCategory == XivStrings.Earring
1386+
|| item.SecondaryCategory == XivStrings.Neck
1387+
|| item.SecondaryCategory == XivStrings.Wrists
1388+
|| item.SecondaryCategory == XivStrings.Rings)
1389+
{
1390+
item.PrimaryCategory = XivStrings.Accessories;
1391+
}
1392+
13811393
return item;
13821394
}
13831395

xivModdingFramework/Cache/XivDependencyRoot.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ public string GetMaterialPath(XivRace race = XivRace.All_Races, string suffix =
255255
}
256256

257257
var basePath = info.GetRootFolder();
258+
if (info.PrimaryType == XivItemType.weapon)
259+
{
260+
var wType = XivWeaponTypes.GetWeaponType(info.PrimaryId);
261+
if (Imc.ImcSharingWeaponTypes.Contains(wType))
262+
{
263+
var nInfo = info;
264+
nInfo.PrimaryId -= 50;
265+
basePath = nInfo.GetRootFolder();
266+
}
267+
}
258268

259269
if (UsesMaterialSets())
260270
{
@@ -1078,7 +1088,18 @@ public string GetRawImcFilePath()
10781088
{
10791089
var iPrefix = XivItemTypes.GetSystemPrefix((XivItemType)Info.SecondaryType);
10801090
var iId = Info.SecondaryId.ToString().PadLeft(4, '0');
1081-
imcPath = Info.GetRootFolder() + String.Format(ImcFileFormat, new string[] { iPrefix, iId });
1091+
1092+
var nInfo = Info;
1093+
if (Info.PrimaryType == XivItemType.weapon)
1094+
{
1095+
var wType = XivWeaponTypes.GetWeaponType(Info.PrimaryId);
1096+
if (Imc.ImcSharingWeaponTypes.Contains(wType))
1097+
{
1098+
nInfo.PrimaryId -= 50;
1099+
}
1100+
}
1101+
1102+
imcPath = nInfo.GetRootFolder() + String.Format(ImcFileFormat, new string[] { iPrefix, iId });
10821103
}
10831104
return imcPath;
10841105

xivModdingFramework/Exd/FileTypes/ExColumnExpectations.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ internal static class ExColumnExpectations
108108
var columnExpectations = new Dictionary<string, (int ColumnIndex, ExcelColumnDataType Type)>()
109109
{
110110
{ "Name", ( 9, ExcelColumnDataType.String ) },
111+
//{ "EquipType", ( 46, ExcelColumnDataType.UInt8 ) },
111112
{ "PrimaryInfo", ( 47, ExcelColumnDataType.UInt64 ) },
112113
{ "SecondaryInfo", ( 48, ExcelColumnDataType.UInt64 ) },
113114
{ "SlotNum", ( 17, ExcelColumnDataType.UInt8 ) },

xivModdingFramework/Helpers/IOUtil.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ public static void RecursiveDeleteDirectory(DirectoryInfo baseDir)
429429

430430
try
431431
{
432+
if (!baseDir.Exists)
433+
return;
432434
baseDir.Delete(true);
433435
}
434436
catch
@@ -872,6 +874,7 @@ private static int FloorPower2(int x)
872874

873875
public static async Task CompressWindowsDirectory(string dir)
874876
{
877+
if (!Directory.Exists(dir)) return;
875878
try
876879
{
877880
var wrappedDir = Regex.Replace(dir, @"(\\*)" + "\"", @"$1$1\" + "\"");

xivModdingFramework/Items/Categories/Gear.cs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ await Task.Run(() => Parallel.ForEach(itemDictionary, (item) =>
140140

141141
var icon = (ushort)row.GetColumnByName("Icon");
142142

143-
var primaryMi = new XivGearModelInfo();
144-
var secondaryMi = new XivGearModelInfo();
143+
var primaryMi = new XivModelInfo();
144+
var secondaryMi = new XivModelInfo();
145145
var xivGear = new XivGear
146146
{
147147
Name = name,
@@ -152,7 +152,6 @@ await Task.Run(() => Parallel.ForEach(itemDictionary, (item) =>
152152
};
153153

154154

155-
xivGear.EquipSlotCategory = slotNum;
156155
xivGear.SecondaryCategory = _slotNameDictionary.ContainsKey(slotNum) ? _slotNameDictionary[slotNum] : "Unknown";
157156

158157
// Model information is stored in a short-array format.
@@ -168,6 +167,7 @@ await Task.Run(() => Parallel.ForEach(itemDictionary, (item) =>
168167

169168
if (hasBodyId)
170169
{
170+
xivGear.PrimaryCategory = XivStrings.Weapons;
171171
primaryMi.SecondaryID = primaryQuad.Values[1];
172172
primaryMi.ImcSubsetID = primaryQuad.Values[2];
173173
secondaryMi.SecondaryID = secondaryQuad.Values[1];
@@ -177,6 +177,13 @@ await Task.Run(() => Parallel.ForEach(itemDictionary, (item) =>
177177
{
178178
primaryMi.ImcSubsetID = primaryQuad.Values[1];
179179
secondaryMi.ImcSubsetID = secondaryQuad.Values[1];
180+
if (xivGear.SecondaryCategory == XivStrings.Earring
181+
|| xivGear.SecondaryCategory == XivStrings.Neck
182+
|| xivGear.SecondaryCategory == XivStrings.Wrists
183+
|| xivGear.SecondaryCategory == XivStrings.Rings)
184+
{
185+
xivGear.PrimaryCategory = XivStrings.Accessories;
186+
}
180187
}
181188

182189
XivGear secondaryItem = null;
@@ -237,7 +244,7 @@ private List<XivGear> GetMissingGear()
237244
Name = "SmallClothes Body",
238245
PrimaryCategory = XivStrings.Gear,
239246
SecondaryCategory = _slotNameDictionary[4],
240-
ModelInfo = new XivGearModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0}
247+
ModelInfo = new XivModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0}
241248
};
242249

243250
xivGearList.Add(xivGear);
@@ -247,7 +254,7 @@ private List<XivGear> GetMissingGear()
247254
Name = "SmallClothes Hands",
248255
PrimaryCategory = XivStrings.Gear,
249256
SecondaryCategory = _slotNameDictionary[5],
250-
ModelInfo = new XivGearModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0 }
257+
ModelInfo = new XivModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0 }
251258
};
252259

253260
xivGearList.Add(xivGear);
@@ -257,7 +264,7 @@ private List<XivGear> GetMissingGear()
257264
Name = "SmallClothes Legs",
258265
PrimaryCategory = XivStrings.Gear,
259266
SecondaryCategory = _slotNameDictionary[7],
260-
ModelInfo = new XivGearModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0 }
267+
ModelInfo = new XivModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0 }
261268
};
262269

263270
xivGearList.Add(xivGear);
@@ -267,7 +274,7 @@ private List<XivGear> GetMissingGear()
267274
Name = "SmallClothes Feet",
268275
PrimaryCategory = XivStrings.Gear,
269276
SecondaryCategory = _slotNameDictionary[8],
270-
ModelInfo = new XivGearModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0 }
277+
ModelInfo = new XivModelInfo { PrimaryID = 0, ImcSubsetID = 1, SecondaryID = 0 }
271278
};
272279

273280
xivGearList.Add(xivGear);
@@ -277,7 +284,7 @@ private List<XivGear> GetMissingGear()
277284
Name = "SmallClothes Body (NPC)",
278285
PrimaryCategory = XivStrings.Gear,
279286
SecondaryCategory = _slotNameDictionary[4],
280-
ModelInfo = new XivGearModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
287+
ModelInfo = new XivModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
281288
};
282289

283290
xivGearList.Add(xivGear);
@@ -287,7 +294,7 @@ private List<XivGear> GetMissingGear()
287294
Name = "SmallClothes Hands (NPC)",
288295
PrimaryCategory = XivStrings.Gear,
289296
SecondaryCategory = _slotNameDictionary[5],
290-
ModelInfo = new XivGearModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
297+
ModelInfo = new XivModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
291298
};
292299

293300
xivGearList.Add(xivGear);
@@ -297,7 +304,7 @@ private List<XivGear> GetMissingGear()
297304
Name = "SmallClothes Legs (NPC)",
298305
PrimaryCategory = XivStrings.Gear,
299306
SecondaryCategory = _slotNameDictionary[7],
300-
ModelInfo = new XivGearModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
307+
ModelInfo = new XivModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
301308
};
302309

303310
xivGearList.Add(xivGear);
@@ -307,7 +314,7 @@ private List<XivGear> GetMissingGear()
307314
Name = "SmallClothes Feet (NPC)",
308315
PrimaryCategory = XivStrings.Gear,
309316
SecondaryCategory = _slotNameDictionary[8],
310-
ModelInfo = new XivGearModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
317+
ModelInfo = new XivModelInfo { PrimaryID = 9903, ImcSubsetID = 1, SecondaryID = 0 }
311318
};
312319

313320
xivGearList.Add(xivGear);
@@ -317,7 +324,7 @@ private List<XivGear> GetMissingGear()
317324
Name = "SmallClothes Feet 2 (NPC)",
318325
PrimaryCategory = XivStrings.Gear,
319326
SecondaryCategory = _slotNameDictionary[8],
320-
ModelInfo = new XivGearModelInfo { PrimaryID = 9901, ImcSubsetID = 1, SecondaryID = 0 }
327+
ModelInfo = new XivModelInfo { PrimaryID = 9901, ImcSubsetID = 1, SecondaryID = 0 }
321328
};
322329

323330
xivGearList.Add(xivGear);

xivModdingFramework/Items/DataContainers/XivGear.cs

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using System.Linq;
1919
using xivModdingFramework.Cache;
2020
using xivModdingFramework.General.Enums;
21+
using xivModdingFramework.Items.Enums;
2122
using xivModdingFramework.Items.Interfaces;
2223
using xivModdingFramework.Models.FileTypes;
2324
using xivModdingFramework.Resources;
@@ -82,10 +83,26 @@ public class XivGear : IItemModel
8283
/// </summary>
8384
public uint IconId { get; set; }
8485

85-
/// <summary>
86-
/// The gear EquipSlotCategory key
87-
/// </summary>
88-
public int EquipSlotCategory { get; set; }
86+
public bool IsWeapon
87+
{
88+
get
89+
{
90+
return this.ModelInfo != null && this.ModelInfo.SecondaryID > 0;
91+
}
92+
}
93+
94+
95+
public XivWeaponType WeaponType { get
96+
{
97+
if (ModelInfo == null) return XivWeaponType.Unknown;
98+
if (PrimaryCategory != XivStrings.Weapons) return XivWeaponType.Unknown;
99+
100+
var root = this.GetRoot();
101+
if(root == null) return XivWeaponType.Unknown;
102+
103+
return XivWeaponTypes.GetWeaponType(ModelInfo.PrimaryID);
104+
}
105+
}
89106

90107
/// <summary>
91108
/// The other item in this pair (main or offhand)
@@ -112,7 +129,7 @@ public string GetModlistItemCategory()
112129
internal static IItemModel FromDependencyRoot(XivDependencyRoot root, int imcSubset)
113130
{
114131
var item = new XivGear();
115-
item.ModelInfo = new XivGearModelInfo();
132+
item.ModelInfo = new XivModelInfo();
116133
item.ModelInfo.PrimaryID = root.Info.PrimaryId;
117134
if (root.Info.SecondaryId != null)
118135
{
@@ -121,15 +138,20 @@ internal static IItemModel FromDependencyRoot(XivDependencyRoot root, int imcSub
121138
item.ModelInfo.ImcSubsetID = imcSubset;
122139

123140
item.Name = root.Info.GetBaseFileName() + "_v" + imcSubset.ToString();
124-
item.PrimaryCategory = XivStrings.Gear;
125141

126142
if (root.Info.PrimaryType == Enums.XivItemType.weapon)
127143
{
128-
//((XivGearModelInfo)item.ModelInfo).IsWeapon = true;
129-
item.SecondaryCategory = XivStrings.Main_Hand;
144+
item.PrimaryCategory = XivStrings.Weapons;
145+
item.SecondaryCategory = item.WeaponType.GetNiceName();
146+
147+
} else if(root.Info.PrimaryType == XivItemType.accessory)
148+
{
149+
item.PrimaryCategory = XivStrings.Accessories;
150+
item.SecondaryCategory = Mdl.SlotAbbreviationDictionary.First(x => x.Value == root.Info.Slot).Key;
130151
}
131152
else
132153
{
154+
item.PrimaryCategory = XivStrings.Gear;
133155
item.SecondaryCategory = Mdl.SlotAbbreviationDictionary.First(x => x.Value == root.Info.Slot).Key;
134156
}
135157

@@ -140,7 +162,7 @@ internal static IItemModel FromDependencyRoot(XivDependencyRoot root, int imcSub
140162
public object Clone()
141163
{
142164
var copy = (XivGear)this.MemberwiseClone();
143-
copy.ModelInfo = (XivGearModelInfo)ModelInfo.Clone();
165+
copy.ModelInfo = (XivModelInfo)ModelInfo.Clone();
144166

145167
return copy;
146168
}
@@ -151,14 +173,6 @@ public int CompareTo(object obj)
151173
}
152174

153175
public override string ToString() => Name;
154-
}
155176

156-
public class XivGearModelInfo : XivModelInfo
157-
{
158-
public bool IsWeapon {
159-
get {
160-
return this.SecondaryID > 0;
161-
}
162-
}
163177
}
164178
}

0 commit comments

Comments
 (0)