diff --git a/dist/Data/Scripts/Source/SKI_FavoritesManager.psc b/dist/Data/Scripts/Source/SKI_FavoritesManager.psc index 8c499bc56..233b8a524 100644 --- a/dist/Data/Scripts/Source/SKI_FavoritesManager.psc +++ b/dist/Data/Scripts/Source/SKI_FavoritesManager.psc @@ -11,9 +11,11 @@ import Math ; 2: - Added check for vampire lord ; ; 3: - Less eagerly clearing of invalid entries +; +; 4: - EDC - Added repeat find to InvalidateItem() int function GetVersion() - return 3 + return 4 endFunction @@ -221,6 +223,11 @@ event OnVersionUpdate(int a_version) _itemInvalidFlags1 = new bool[128] _itemInvalidFlags2 = new bool[128] endIf + + ; Version 4 + if (a_version >= 4 && CurrentVersion < 4) + Debug.Trace(self + ": Updating to script version 4") + endIf endEvent @@ -804,7 +811,8 @@ bool function ProcessItem(Form a_item, int a_itemType, bool a_allowDeferring = t ; It's two-handed and both hands are free elseIf (weaponType > 4 && !_usedRightHand && !_usedLeftHand) - if (a_item == PlayerREF.GetEquippedObject(0) && a_itemId != PlayerREF.GetEquippedItemId(0)) + ; EDC - Changed this line from GetEquippedItemId(0) to GetEquippedItemId(1) since two-handed weapons don't seem to appear in left hand + if (a_item == PlayerREF.GetEquippedObject(0) && a_itemId != PlayerREF.GetEquippedItemId(1)) UnequipHand(0) endIf PlayerREF.EquipItemById(itemWeapon, a_itemId, equipSlot = 0, equipSound = _silenceEquipSounds) @@ -960,41 +968,74 @@ bool function ProcessItem(Form a_item, int a_itemType, bool a_allowDeferring = t endFunction function InvalidateItem(int a_itemId, bool redrawIcon = false) + ;EDC - Version 3 implementation only invalidates the first appearance of an itemID. Any subsequent + ; use in other groups is missed. + ; This version recursively searches for additional items beyond the first int index ; GroupData - index = _itemIds1.Find(a_itemId) - if (index != -1) - _itemInvalidFlags1[index] = true - endIf - - index = _itemIds2.Find(a_itemId) - if (index != -1) - _itemInvalidFlags2[index] = true - endIf + index = 0 + while index < 128 + index = _itemIds1.Find(a_itemId, index) + if (index != -1) + _itemInvalidFlags1[index] = true + index += 1 + else + index = 128 + endIf + endWhile + index = 0 + while index < 128 + index = _itemIds2.Find(a_itemId, index) + if (index != -1) + _itemInvalidFlags2[index] = true + index += 1 + else + index = 128 + endIf + endWhile + ; Main hand - index = _groupMainHandItemIds.Find(a_itemId) - if (index != -1) - _groupMainHandItems[index] = none - _groupMainHandItemIds[index] = 0 - endIf + index = 0 + while index < 8 + index = _groupMainHandItemIds.Find(a_itemId, index) + if (index != -1) + _groupMainHandItems[index] = none + _groupMainHandItemIds[index] = 0 + index += 1 + else + index = 8 + endIf + endWhile ; Off hand - index = _groupOffHandItemIds.Find(a_itemId) - if (index != -1) - _groupOffHandItems[index] = none - _groupOffHandItemIds[index] = 0 - endIf + index = 0 + while index < 8 + index = _groupOffHandItemIds.Find(a_itemId, index) + if (index != -1) + _groupOffHandItems[index] = none + _groupOffHandItemIds[index] = 0 + index += 1 + else + index = 8 + endIf + endWhile ; Icon - index = _groupIconItemIds.Find(a_itemId) - if (index != -1) - ReplaceGroupIcon(index) - if (redrawIcon) - UpdateMenuGroupData(index) + index = 0 + while index < 8 + index = _groupIconItemIds.Find(a_itemId, index) + if (index != -1) + ReplaceGroupIcon(index) + if (redrawIcon) + UpdateMenuGroupData(index) + endIf + index += 1 + else + index = 8 endIf - endIf + endWhile endFunction int function FindFreeIndex(int[] a_itemIds, bool[] a_itemInvalidFlags, int offset)