Fix creative inventory crash with Art Tools debug option (#399)
Fix vector out-of-bounds crash when scrolling the potions tab in the creative inventory with Art Tools debug enabled. - Fix getPageCount() returning total rows instead of scrollable pages in Art Tools mode - Fix off-by-one boundary check in populateMenu() for both static and debug group loops (< should be <=) Fixes #386
This commit is contained in:
@@ -880,7 +880,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, i
|
|||||||
for(; currentGroup < m_staticGroupsCount; ++currentGroup)
|
for(; currentGroup < m_staticGroupsCount; ++currentGroup)
|
||||||
{
|
{
|
||||||
int size = categoryGroups[m_staticGroupsA[currentGroup]].size();
|
int size = categoryGroups[m_staticGroupsA[currentGroup]].size();
|
||||||
if( currentIndex + size < startIndex)
|
if( currentIndex + size <= startIndex)
|
||||||
{
|
{
|
||||||
currentIndex += size;
|
currentIndex += size;
|
||||||
continue;
|
continue;
|
||||||
@@ -930,7 +930,7 @@ void IUIScene_CreativeMenu::TabSpec::populateMenu(AbstractContainerMenu *menu, i
|
|||||||
for(; currentGroup < m_debugGroupsCount; ++currentGroup)
|
for(; currentGroup < m_debugGroupsCount; ++currentGroup)
|
||||||
{
|
{
|
||||||
int size = categoryGroups[m_debugGroupsA[currentGroup]].size();
|
int size = categoryGroups[m_debugGroupsA[currentGroup]].size();
|
||||||
if( currentIndex + size < startIndex)
|
if( currentIndex + size <= startIndex)
|
||||||
{
|
{
|
||||||
currentIndex += size;
|
currentIndex += size;
|
||||||
continue;
|
continue;
|
||||||
@@ -971,7 +971,9 @@ unsigned int IUIScene_CreativeMenu::TabSpec::getPageCount()
|
|||||||
#ifndef _CONTENT_PACKAGE
|
#ifndef _CONTENT_PACKAGE
|
||||||
if(app.DebugArtToolsOn())
|
if(app.DebugArtToolsOn())
|
||||||
{
|
{
|
||||||
return (int)ceil((float)(m_staticItems + m_debugItems) / m_staticPerPage);
|
int totalItems = m_staticItems + m_debugItems;
|
||||||
|
const int totalRows = (totalItems + columns - 1) / columns;
|
||||||
|
return std::max<int>(1, totalRows - rows + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user