diff --git a/src/Logger/MagnumLogBuffer.h b/src/Logger/MagnumLogBuffer.h index e03b303..010c788 100644 --- a/src/Logger/MagnumLogBuffer.h +++ b/src/Logger/MagnumLogBuffer.h @@ -25,7 +25,7 @@ class MagnumLogBuffer : public std::stringbuf { public: explicit MagnumLogBuffer(EntryType type); - ~MagnumLogBuffer(); + ~MagnumLogBuffer() override; private: int sync() override; diff --git a/src/Maps/StoryProgress.h b/src/Maps/StoryProgress.h index b6432ea..61d857e 100644 --- a/src/Maps/StoryProgress.h +++ b/src/Maps/StoryProgress.h @@ -23,9 +23,9 @@ using namespace Corrade; using namespace Containers::Literals; struct StoryProgressPoint { - std::int32_t id; - Containers::StringView chapter; - Containers::StringView point; + std::int32_t id{}; + Containers::StringView chapter = nullptr; + Containers::StringView point = nullptr; Containers::StringView after = nullptr; }; diff --git a/src/Mass/Mass_Armour.cpp b/src/Mass/Mass_Armour.cpp index 834bd07..990d637 100644 --- a/src/Mass/Mass_Armour.cpp +++ b/src/Mass/Mass_Armour.cpp @@ -185,7 +185,7 @@ Mass::writeArmourPart(ArmourSlot slot) { auto decals_array = part_prop->at(MASS_ARMOUR_DECALS); writeDecals(part.decals, decals_array); - if(part.accessories.size() != 0) { + if(!part.accessories.isEmpty()) { auto accs_array = part_prop->at(MASS_ARMOUR_ACCESSORIES); writeAccessories(part.accessories, accs_array); } diff --git a/src/Profile/Profile.cpp b/src/Profile/Profile.cpp index 8090cd1..a6a9bd2 100644 --- a/src/Profile/Profile.cpp +++ b/src/Profile/Profile.cpp @@ -269,7 +269,7 @@ Profile::setMaterial(MaterialID id, std::int32_t amount) { } auto predicate = [&id](UnrealPropertyBase::ptr& prop){ - auto res_prop = static_cast(prop.get()); + auto res_prop = dynamic_cast(prop.get()); return res_prop->id == id; }; @@ -286,7 +286,7 @@ Profile::setMaterial(MaterialID id, std::int32_t amount) { arrayAppend(mats_prop->items, std::move(prop)); } else { - res_prop = static_cast(it->get()); + res_prop = dynamic_cast(it->get()); } res_prop->quantity = amount; @@ -308,10 +308,10 @@ Profile::getResource(Containers::StringView container, MaterialID id) { } auto predicate = [&id](UnrealPropertyBase::ptr& prop){ - auto res_prop = static_cast(prop.get()); + auto res_prop = dynamic_cast(prop.get()); return res_prop->id == id; }; auto it = std::find_if(mats_prop->items.begin(), mats_prop->items.end(), predicate); - return it != mats_prop->items.end() ? static_cast(it->get())->quantity : 0; + return it != mats_prop->items.end() ? dynamic_cast(it->get())->quantity : 0; } diff --git a/src/ProfileManager/ProfileManager.cpp b/src/ProfileManager/ProfileManager.cpp index 318c332..7919fd8 100644 --- a/src/ProfileManager/ProfileManager.cpp +++ b/src/ProfileManager/ProfileManager.cpp @@ -235,7 +235,7 @@ ProfileManager::refreshBackups() { auto files_view = files->exceptSuffix(files->end() - std::remove_if(files->begin(), files->end(), predicate)); int error_code = 0; - zip_t* zip = nullptr; + zip_t* zip; for(Containers::StringView file : files_view) { Backup backup; backup.filename = file; @@ -324,7 +324,7 @@ ProfileManager::restoreBackup(std::size_t index) { auto error_format = "Extraction of file {} failed: {}"_s; int error_code = 0; - zip_t* zip = nullptr; + zip_t* zip; zip = zip_open(Utility::Path::join(_backupsDirectory, backup.filename).data(), ZIP_RDONLY, &error_code); if(zip == nullptr) { @@ -358,8 +358,8 @@ ProfileManager::restoreBackup(std::size_t index) { Containers::StaticArray<8192, char> buf{ValueInit}; - auto bytes_read = 0l; - while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0) { + std::int64_t bytes_read; + while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0ll) { if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast(bytes_read)) { _lastError = Utility::format(error_format.data(), file, "not enough bytes written."); LOG_ERROR(_lastError); diff --git a/src/SaveTool/SaveTool_MassViewer.cpp b/src/SaveTool/SaveTool_MassViewer.cpp index 62762ca..4bb3da2 100644 --- a/src/SaveTool/SaveTool_MassViewer.cpp +++ b/src/SaveTool/SaveTool_MassViewer.cpp @@ -134,7 +134,7 @@ SaveTool::drawMassViewer() { ImGui::EndTabItem(); } - if(_currentMass->globalStyles().size() != 0 && ImGui::BeginTabItem("Global styles")) { + if(!_currentMass->globalStyles().isEmpty() && ImGui::BeginTabItem("Global styles")) { drawGlobalStyles(); ImGui::EndTabItem(); } diff --git a/src/SaveTool/SaveTool_MassViewer_Armour.cpp b/src/SaveTool/SaveTool_MassViewer_Armour.cpp index 7b9e560..2733a78 100644 --- a/src/SaveTool/SaveTool_MassViewer_Armour.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Armour.cpp @@ -134,7 +134,7 @@ SaveTool::drawArmour() { ImGui::PopID(); - if(part.accessories.size() != 0) { + if(!part.accessories.isEmpty()) { ImGui::Separator(); ImGui::PushID("Accessory"); diff --git a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp b/src/SaveTool/SaveTool_MassViewer_Weapons.cpp index a407e32..c60cdc9 100644 --- a/src/SaveTool/SaveTool_MassViewer_Weapons.cpp +++ b/src/SaveTool/SaveTool_MassViewer_Weapons.cpp @@ -542,7 +542,7 @@ SaveTool::drawWeaponEditor(Weapon& weapon) { ImGui::PopID(); - if(part.accessories.size() != 0) { + if(!part.accessories.isEmpty()) { ImGui::Separator(); ImGui::PushID("Accessory"); diff --git a/src/UESaveFile/BinaryWriter.cpp b/src/UESaveFile/BinaryWriter.cpp index 658d1a1..ab0ebba 100644 --- a/src/UESaveFile/BinaryWriter.cpp +++ b/src/UESaveFile/BinaryWriter.cpp @@ -126,7 +126,7 @@ BinaryWriter::writeDouble(double value) { bool BinaryWriter::writeArray(Containers::ArrayView array) { - if(array.size() == 0) { + if(array.isEmpty()) { return false; } diff --git a/src/UESaveFile/Serialisers/StructSerialiser.cpp b/src/UESaveFile/Serialisers/StructSerialiser.cpp index 770a079..1e8affc 100644 --- a/src/UESaveFile/Serialisers/StructSerialiser.cpp +++ b/src/UESaveFile/Serialisers/StructSerialiser.cpp @@ -198,6 +198,8 @@ StructProperty::ptr StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, std::size_t value_length, BinaryReader& reader, PropertySerialiser& serialiser) { + static_cast(value_length); + auto st_prop = Containers::pointer(); st_prop->structType = type; diff --git a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp b/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp index ce519b3..cba065f 100644 --- a/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp +++ b/src/UESaveFile/Serialisers/TextPropertySerialiser.cpp @@ -50,7 +50,7 @@ TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Contain return nullptr; } - auto interval = reader.position() - start_position; + std::int64_t interval; do { Containers::String str; diff --git a/src/UESaveFile/UESaveFile.cpp b/src/UESaveFile/UESaveFile.cpp index 15c892e..af44e10 100644 --- a/src/UESaveFile/UESaveFile.cpp +++ b/src/UESaveFile/UESaveFile.cpp @@ -114,10 +114,8 @@ UESaveFile::saveToFile() { return false; } - for(std::size_t i = 0; i < _customFormatData.size(); i++) { - if(!writer.writeStaticArray(Containers::StaticArrayView<16, const char>{_customFormatData[i].id}) || - !writer.writeUint32(_customFormatData[i].value)) - { + for(auto& i : _customFormatData) { + if(!writer.writeStaticArray<16>(staticArrayView(i.id)) || !writer.writeUint32(i.value)) { _lastError = "Couldn't write the custom format data."_s; LOG_ERROR(_lastError); return false;