mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 13:15:32 +00:00
Cycle infinite loop fix (Fixes #2421)
This commit is contained in:
parent
191c0104f6
commit
730138035d
1 changed files with 7 additions and 4 deletions
|
@ -653,16 +653,13 @@ namespace MWGui
|
|||
if (selected != -1)
|
||||
lastId = model.getItem(selected).mBase.getCellRef().getRefId();
|
||||
ItemModel::ModelIndex cycled = selected;
|
||||
while (!found)
|
||||
for (int i=0; i<model.getItemCount(); ++i)
|
||||
{
|
||||
cycled += incr;
|
||||
cycled = (cycled + model.getItemCount()) % model.getItemCount();
|
||||
|
||||
MWWorld::Ptr item = model.getItem(cycled).mBase;
|
||||
|
||||
if (cycled == selected) // we've been through all items, nothing found
|
||||
return;
|
||||
|
||||
// skip different stacks of the same item, or we will get stuck as stacking/unstacking them may change their relative ordering
|
||||
if (Misc::StringUtils::ciEqual(lastId, item.getCellRef().getRefId()))
|
||||
continue;
|
||||
|
@ -670,9 +667,15 @@ namespace MWGui
|
|||
lastId = item.getCellRef().getRefId();
|
||||
|
||||
if (item.getClass().getTypeName() == typeid(ESM::Weapon).name() && isRightHandWeapon(item))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
return;
|
||||
|
||||
useItem(model.getItem(cycled).mBase);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue