Compare commits

...

2 commits

Author SHA1 Message Date
83fe02a8dc Mass: improve readability and reliability. 2021-10-17 09:24:44 +02:00
7e452db3a4 Mass: improve readability. 2021-10-17 08:44:23 +02:00

View file

@ -578,15 +578,14 @@ void Mass::getArmourParts() {
return; return;
} }
if(armour_array->items.size() != 38) { if(armour_array->items.size() != _armour.parts.size()) {
_state = State::Invalid; _state = State::Invalid;
return; return;
} }
for(UnsignedInt i = 0; i < armour_array->items.size(); i++) { for(UnsignedInt i = 0; i < armour_array->items.size(); i++) {
auto part_prop = armour_array->at<GenericStructProperty>(i); auto part_prop = armour_array->at<GenericStructProperty>(i);
auto& part = _armour.parts[i];
ArmourPart part;
part.slot = part_prop->at<ByteProperty>("Slot_3_408BA56F4C9605C7E805CF91B642249C")->enumValue; part.slot = part_prop->at<ByteProperty>("Slot_3_408BA56F4C9605C7E805CF91B642249C")->enumValue;
part.id = part_prop->at<IntProperty>("ID_5_ACD101864D3481DE96EDACACC09BDD25")->value; part.id = part_prop->at<IntProperty>("ID_5_ACD101864D3481DE96EDACACC09BDD25")->value;
@ -597,7 +596,7 @@ void Mass::getArmourParts() {
return; return;
} }
if(part_styles->items.size() != 4) { if(part_styles->items.size() != part.styles.size()) {
_state = State::Invalid; _state = State::Invalid;
return; return;
} }
@ -612,15 +611,14 @@ void Mass::getArmourParts() {
return; return;
} }
if(decals_array->items.size() != 8) { if(decals_array->items.size() != part.decals.size()) {
part.demoDecals = decals_array->items.size(); part.demoDecals = decals_array->items.size();
_demo = true; _demo = true;
} }
for(UnsignedInt j = 0; j < decals_array->items.size(); j++) { for(UnsignedInt j = 0; j < decals_array->items.size(); j++) {
auto decal_prop = decals_array->at<GenericStructProperty>(j); auto decal_prop = decals_array->at<GenericStructProperty>(j);
auto& decal = part.decals[j];
Decal decal;
decal.id = decal_prop->at<IntProperty>("ID_3_694C0B35404D8A3168AEC89026BC8CF9")->value; decal.id = decal_prop->at<IntProperty>("ID_3_694C0B35404D8A3168AEC89026BC8CF9")->value;
auto colour_prop = decal_prop->at<ColourStructProperty>("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606"); auto colour_prop = decal_prop->at<ColourStructProperty>("Color_8_1B0B9D2B43DA6AAB9FA549B374D3E606");
@ -637,25 +635,23 @@ void Mass::getArmourParts() {
decal.rotation = decal_prop->at<FloatProperty>("Rotation_27_12D7C314493D203D5C2326A03C5F910F")->value; decal.rotation = decal_prop->at<FloatProperty>("Rotation_27_12D7C314493D203D5C2326A03C5F910F")->value;
decal.flip = decal_prop->at<BoolProperty>("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1")->value; decal.flip = decal_prop->at<BoolProperty>("Flip_35_CECCFB184CCD9412BD93FE9A8B656BE1")->value;
decal.wrap = decal_prop->at<BoolProperty>("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62")->value; decal.wrap = decal_prop->at<BoolProperty>("Wrap_43_A7C68CDF4A92AF2ECDA53F953EE7CA62")->value;
part.decals[j] = decal;
} }
if(!_demo) { if(!_demo) {
auto accs_array = part_prop->at<ArrayProperty>("Accessories_52_D902DD4241FA0050C2529596255153F3"); auto accs_array = part_prop->at<ArrayProperty>("Accessories_52_D902DD4241FA0050C2529596255153F3");
if(!accs_array) { if(!accs_array) {
_demo = true; _demo = true;
continue;
} }
if(accs_array->items.size() != 8) { if(accs_array->items.size() != part.accessories.size()) {
_state = State::Invalid; _state = State::Invalid;
return; return;
} }
for(UnsignedInt j = 0; j < accs_array->items.size(); j++) { for(UnsignedInt j = 0; j < accs_array->items.size(); j++) {
auto acc_prop = accs_array->at<GenericStructProperty>(j); auto acc_prop = accs_array->at<GenericStructProperty>(j);
auto& accessory = part.accessories[j];
Accessory accessory;
accessory.attachIndex = acc_prop->at<IntProperty>("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20")->value; accessory.attachIndex = acc_prop->at<IntProperty>("AttachIndex_2_4AFCF6024E4BA7426C6B9F80B8179D20")->value;
accessory.id = acc_prop->at<IntProperty>("ID_4_5757B32647BAE263266259B8A7DFFFC1")->value; accessory.id = acc_prop->at<IntProperty>("ID_4_5757B32647BAE263266259B8A7DFFFC1")->value;
@ -673,12 +669,8 @@ void Mass::getArmourParts() {
accessory.relativeRotationOffset = Vector3{rel_rot_offset_prop->x, rel_rot_offset_prop->y, rel_rot_offset_prop->z}; accessory.relativeRotationOffset = Vector3{rel_rot_offset_prop->x, rel_rot_offset_prop->y, rel_rot_offset_prop->z};
auto local_scale_prop = acc_prop->at<VectorStructProperty>("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53"); auto local_scale_prop = acc_prop->at<VectorStructProperty>("LocalScale_24_DC2D93A742A41A46E7E61D988F15ED53");
accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z}; accessory.localScale = Vector3{local_scale_prop->x, local_scale_prop->y, local_scale_prop->z};
part.accessories[j] = std::move(accessory);
} }
} }
_armour.parts[i] = std::move(part);
} }
} }
@ -1055,9 +1047,9 @@ void Mass::getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> we
auto part_accs = part_prop->at<ArrayProperty>("Accessories_21_3878DE8B4ED0EA0DB725E98BCDC20E0C"); auto part_accs = part_prop->at<ArrayProperty>("Accessories_21_3878DE8B4ED0EA0DB725E98BCDC20E0C");
if(!part_accs) { if(!part_accs) {
_demo = true; _demo = true;
continue;
} }
if(!_demo) {
if(part_accs->items.size() != 8) { if(part_accs->items.size() != 8) {
_state = State::Invalid; _state = State::Invalid;
return; return;
@ -1088,4 +1080,3 @@ void Mass::getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> we
} }
} }
} }
}