fix range check bug in non-v4 ItemParameterTable
This commit is contained in:
@@ -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<false>& ItemParameterTable::get_special(uint8_
|
||||
if (this->offsets_v2) {
|
||||
return this->r.pget<Special<false>>(this->offsets_v2->special_data_table + sizeof(Special<false>) * 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<Special<true>>(this->offsets_v3->special_data_table + sizeof(Special<true>) * special);
|
||||
|
||||
@@ -481,7 +481,6 @@ void player_feed_mag(std::shared_ptr<Client> 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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user