Skip to content
Snippets Groups Projects
Commit 7d6e80a4 authored by Perttu Ahola's avatar Perttu Ahola
Browse files

Add proper error messages to GUIInventoryMenu when inventory lists are invalid

parent f3ec1452
No related branches found
No related tags found
No related merge requests found
...@@ -531,10 +531,18 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event) ...@@ -531,10 +531,18 @@ bool GUIInventoryMenu::OnEvent(const SEvent& event)
assert(inv_s); assert(inv_s);
InventoryList *list = inv_s->getList(s.listname); InventoryList *list = inv_s->getList(s.listname);
if(list != NULL && (u32) s.i < list->getSize()) if(list == NULL){
s_count = list->getItem(s.i).count; errorstream<<"InventoryMenu: The selected inventory list "
else <<"does not exist"<<std::endl;
s.i = -1; // make it invalid again
} else if((u32)s.i >= list->getSize()){
errorstream<<"InventoryMenu: The selected inventory list "
<<"is too small (i="<<s.i<<", size="
<<list->getSize()<<")"<<std::endl;
s.i = -1; // make it invalid again s.i = -1; // make it invalid again
} else{
s_count = list->getItem(s.i).count;
}
} }
bool identical = (m_selected_item != NULL) && s.isValid() && bool identical = (m_selected_item != NULL) && s.isValid() &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment