[Bug Fix] Fix IDFile Crash with spaces or invalid data. (#2597)

* [Bug Fix] Fix IDFile Crash with spaces or invalid data.

* Update mob_appearance.cpp
This commit is contained in:
Alex King 2022-11-30 21:31:28 -05:00 committed by GitHub
parent a9cfacf54b
commit ecc34940b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -240,7 +240,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const
if (inst) {
if (inst->GetOrnamentationAug(ornamentation_augment_type)) {
item = inst->GetOrnamentationAug(ornamentation_augment_type)->GetItem();
if (item && strlen(item->IDFile) > 2) {
if (item && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) {
equipment_material = std::stoi(&item->IDFile[2]);
}
} else if (inst->GetOrnamentationIDFile()) {
@ -249,7 +249,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const
}
}
if (equipment_material == 0 && strlen(item->IDFile) > 2) {
if (!equipment_material && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) {
equipment_material = std::stoi(&item->IDFile[2]);
}
}