daemon: fix crash in cc_get_item 0

This commit is contained in:
Crypto City 2021-06-08 15:10:15 +00:00
parent 3879a9e5e3
commit 7d441c2a20

View File

@ -3033,6 +3033,11 @@ bool t_rpc_command_executor::cc_item_info(uint32_t item)
}
const std::string name = is_custom ? cires.items[0].name : cc::get_predefined_item_name(item);
if (name.empty())
{
tools::fail_msg_writer() << "Invalid item";
return true;
}
tools::msg_writer() << "Item " << item << ": " << name;
std::string type = "Other";
bool fixed_supply = false;
@ -3072,7 +3077,7 @@ bool t_rpc_command_executor::cc_item_info(uint32_t item)
uint32_t heating_points = cc::get_heating_points(item);
std::string parent_group_message;
if (cires.items[0].group)
if (is_custom && cires.items[0].group)
parent_group_message = " (part of group " + std::to_string(cires.items[0].group) + ")";
tools::msg_writer() << "Type: " << type << parent_group_message;
if (is_custom && cires.items[0].is_group)