diff --git a/src/GameObjects/Mass_Weapons.cpp b/src/GameObjects/Mass_Weapons.cpp index 5b29e38..9852a1f 100644 --- a/src/GameObjects/Mass_Weapons.cpp +++ b/src/GameObjects/Mass_Weapons.cpp @@ -136,21 +136,21 @@ void Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { - LOG_ERROR_FORMAT("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename); + LOG_ERROR(_lastError = Utility::format("Couldn't find {} in {}.", MASS_UNIT_DATA, _filename)); _state = State::Invalid; return; } auto prop = unit_data->at(prop_name); if(!prop) { - LOG_ERROR_FORMAT("Couldn't find {} in {}.", prop_name, _filename); + LOG_ERROR(_lastError = Utility::format("Couldn't find {} in {}.", prop_name, _filename)); _state = State::Invalid; return; } if(prop->items.size() != weapon_array.size()) { - LOG_ERROR_FORMAT("Weapon arrays are not of the same size. Expected {}, got {} instead.", - weapon_array.size(), prop->items.size()); + LOG_ERROR(_lastError = Utility::format("Weapon arrays are not of the same size. Expected {}, got {} instead.", + weapon_array.size(), prop->items.size())); _state = State::Invalid; return; } @@ -165,7 +165,7 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_CUSTOM_WEAPON_STYLES); if(!custom_styles) { - LOG_ERROR_FORMAT("Can't find weapon custom styles in {}", _filename); + LOG_ERROR(_lastError = Utility::format("Can't find weapon custom styles in {}", _filename)); _state = State::Invalid; return; } if(custom_styles->items.size() != weapon.customStyles.size()) { - LOG_ERROR_FORMAT("Custom weapon style arrays are not of the same size. Expected {}, got {} instead.", - weapon.customStyles.size(), custom_styles->items.size()); - _state = State::Invalid; - return; + _lastError = Utility::format("Custom weapon style arrays are not of the same size. Expected {}, got {} instead.", + weapon.customStyles.size(), custom_styles->items.size()); + if(!weapon.parts.isEmpty()) { + LOG_ERROR(_lastError); + _state = State::Invalid; + return; + } + LOG_WARNING(_lastError); + } + else { + getCustomStyles(weapon.customStyles, custom_styles); } - - getCustomStyles(weapon.customStyles, custom_styles); for(auto& style : weapon.customStyles) { style.type = CustomStyle::Type::Weapon; @@ -229,7 +234,7 @@ Mass::getWeaponType(Containers::StringView prop_name, Containers::ArrayView weapon_array) { auto unit_data = _mass->at(MASS_UNIT_DATA); if(!unit_data) { - _lastError = "No unit data in "_s + _filename; - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = Utility::format("No unit data in {}", _filename)); _state = State::Invalid; return false; } auto prop = unit_data->at(prop_name); if(!prop) { - _lastError = prop_name + " not found in "_s + _filename; - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = Utility::format("Property {} not found in {}.", prop_name, _filename)); _state = State::Invalid; return false; } if(prop->items.size() != weapon_array.size()) { - _lastError = Utility::format("Weapon arrays are not of the same size. Expected {}, got {} instead.", - weapon_array.size(), prop->items.size()); - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = Utility::format("Weapon arrays are not of the same size. Expected {}, got {} instead.", + weapon_array.size(), prop->items.size())); _state = State::Invalid; return false; } @@ -284,16 +286,14 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_ELEMENT); if(parts_prop->items.size() != weapon.parts.size()) { - _lastError = Utility::format("Weapon part arrays are not of the same size. Expected {}, got {} instead.", - weapon.parts.size(), parts_prop->items.size()); - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = Utility::format("Weapon part arrays are not of the same size. Expected {}, got {} instead.", + weapon.parts.size(), parts_prop->items.size())); _state = State::Invalid; return false; } @@ -318,9 +318,8 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewitems.size() != part.accessories.size()) { - _lastError = Utility::format("Part accessory arrays are not of the same size. Expected {}, got {} instead.", - part.accessories.size(), part_accs->items.size()); - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = Utility::format("Part accessory arrays are not of the same size. Expected {}, got {} instead.", + part.accessories.size(), part_accs->items.size())); _state = State::Invalid; return false; } @@ -330,16 +329,14 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_CUSTOM_WEAPON_STYLES); if(!custom_styles) { - _lastError = "No custom styles found for weapon."_s; - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = "No custom styles found for weapon."_s); _state = State::Invalid; return false; } if(custom_styles->items.size() != weapon.customStyles.size()) { - _lastError = Utility::format("Custom style arrays are not of the same size. Expected {}, got {} instead.", - weapon.customStyles.size(), custom_styles->items.size()); - LOG_ERROR(_lastError); + LOG_ERROR(_lastError = Utility::format("Custom style arrays are not of the same size. Expected {}, got {} instead.", + weapon.customStyles.size(), custom_styles->items.size())); _state = State::Invalid; return false; } @@ -354,8 +351,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_DUAL_WIELD)->value = weapon.dualWield; @@ -366,8 +362,7 @@ Mass::writeWeaponType(Containers::StringView prop_name, Containers::ArrayViewat(MASS_WEAPON_COLOUR_EFX);