forked from mirror/openmw-tes3mp
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)
|
if (selected != -1)
|
||||||
lastId = model.getItem(selected).mBase.getCellRef().getRefId();
|
lastId = model.getItem(selected).mBase.getCellRef().getRefId();
|
||||||
ItemModel::ModelIndex cycled = selected;
|
ItemModel::ModelIndex cycled = selected;
|
||||||
while (!found)
|
for (int i=0; i<model.getItemCount(); ++i)
|
||||||
{
|
{
|
||||||
cycled += incr;
|
cycled += incr;
|
||||||
cycled = (cycled + model.getItemCount()) % model.getItemCount();
|
cycled = (cycled + model.getItemCount()) % model.getItemCount();
|
||||||
|
|
||||||
MWWorld::Ptr item = model.getItem(cycled).mBase;
|
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
|
// 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()))
|
if (Misc::StringUtils::ciEqual(lastId, item.getCellRef().getRefId()))
|
||||||
continue;
|
continue;
|
||||||
|
@ -670,9 +667,15 @@ namespace MWGui
|
||||||
lastId = item.getCellRef().getRefId();
|
lastId = item.getCellRef().getRefId();
|
||||||
|
|
||||||
if (item.getClass().getTypeName() == typeid(ESM::Weapon).name() && isRightHandWeapon(item))
|
if (item.getClass().getTypeName() == typeid(ESM::Weapon).name() && isRightHandWeapon(item))
|
||||||
|
{
|
||||||
found = true;
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
return;
|
||||||
|
|
||||||
useItem(model.getItem(cycled).mBase);
|
useItem(model.getItem(cycled).mBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue