diff --git a/src/ItemParameterTable.cc b/src/ItemParameterTable.cc index 97749647..a58609ec 100644 --- a/src/ItemParameterTable.cc +++ b/src/ItemParameterTable.cc @@ -151,7 +151,7 @@ const ItemParameterTable::ArmorOrShieldV4& ItemParameterTable::get_armor_or_shie } return ret; } catch (const std::out_of_range&) { - if (data1_2 <= parsed_vec.size()) { + if (data1_2 >= parsed_vec.size()) { parsed_vec.resize(data1_2 + 1); } auto& def_v4 = parsed_vec[data1_2]; @@ -230,7 +230,7 @@ const ItemParameterTable::UnitV4& ItemParameterTable::get_unit(uint8_t data1_2) } return ret; } catch (const std::out_of_range&) { - if (data1_2 <= this->parsed_units.size()) { + if (data1_2 >= this->parsed_units.size()) { this->parsed_units.resize(data1_2 + 1); } auto& def_v4 = this->parsed_units[data1_2]; @@ -283,7 +283,7 @@ const ItemParameterTable::MagV4& ItemParameterTable::get_mag(uint8_t data1_1) co } return ret; } catch (const std::out_of_range&) { - if (data1_1 <= this->parsed_mags.size()) { + if (data1_1 >= this->parsed_mags.size()) { this->parsed_mags.resize(data1_1 + 1); } auto& def_v4 = this->parsed_mags[data1_1]; @@ -527,8 +527,8 @@ const ItemParameterTable::Special& ItemParameterTable::get_special(uint8_ if (this->offsets_v2) { return this->r.pget>(this->offsets_v2->special_data_table + sizeof(Special) * special); } else if (this->offsets_v3) { - if ((this->parsed_specials.size() <= special) || (this->parsed_specials[special].type != 0xFFFF)) { - if (this->parsed_specials.size() <= special) { + if ((special >= this->parsed_specials.size()) || (this->parsed_specials[special].type != 0xFFFF)) { + if (special >= this->parsed_specials.size()) { this->parsed_specials.resize(special + 1); } const auto& sp_be = this->r.pget>(this->offsets_v3->special_data_table + sizeof(Special) * special); diff --git a/src/Items.cc b/src/Items.cc index e1083bce..f41171e3 100644 --- a/src/Items.cc +++ b/src/Items.cc @@ -481,7 +481,6 @@ void player_feed_mag(std::shared_ptr c, size_t mag_item_index, size_t fe // If the mag has evolved, add its new photon blast if (mag_number != mag_item.data.data1[1]) { - auto item_parameter_table = s->item_parameter_table_for_version(c->version()); const auto& new_mag_def = item_parameter_table->get_mag(mag_item.data.data1[1]); mag_item.data.add_mag_photon_blast(new_mag_def.photon_blast); } diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index df2afd08..adefc128 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -1107,7 +1107,7 @@ static void on_feed_mag( size_t fed_index = p->inventory.find_item(cmd.fed_item_id); string mag_name, mag_colored_name, fed_name, fed_colored_name; { - // Note: We do this weird scoping thing because player_use_item will + // Note: We do this weird scoping thing because player_feed_mag will // likely delete the item, which will break the reference here. const auto& fed_item = p->inventory.items[fed_index].data; fed_name = s->describe_item(c->version(), fed_item, false);