Added 'SkyUI - Ghost Item Bug Fix' by EdmanSA

This commit is contained in:
Eddoursul 2021-10-07 01:08:29 +02:00
parent 11107a3938
commit 901c402874
2 changed files with 81 additions and 29 deletions

Binary file not shown.

View File

@ -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
@ -222,6 +224,11 @@ event OnVersionUpdate(int a_version)
_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,10 @@ 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
;Debug.Trace(self + ": PlayerREF.GetEquippedObject(0) is " + PlayerREF.GetEquippedObject(0) + ", PlayerREF.GetEquippedObject(1) is " + PlayerREF.GetEquippedObject(1))
;Debug.Trace(self + ": PlayerREF.GetEquippedItemId(0) is " + PlayerREF.GetEquippedItemId(0) + ", PlayerREF.GetEquippedItemId(1) is " + PlayerREF.GetEquippedItemId(1))
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 +970,83 @@ 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 loop
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
; GroupData [1-4]
;loop = 0
index = 0
while index < 128
index = _itemIds1.Find(a_itemId, index)
if (index != -1)
;Debug.Trace(self + ": Setting _itemInvalidFlags1[" + index + "] = true. Loop number " + loop)
;loop += 1
_itemInvalidFlags1[index] = true
index += 1
else
index = 128
endIf
endWhile
; GroupData [5-8]
;loop = 0
index = 0
while index < 128
index = _itemIds2.Find(a_itemId, index)
if (index != -1)
;Debug.Trace(self + ": Setting _itemInvalidFlags2[" + index + "] = true. Loop number " + loop)
;loop += 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)