Skip to content

Commit

Permalink
fix some compiler warnings, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz-h committed Jan 11, 2025
1 parent 9711e9c commit 914ea5c
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace SatisfactorySave {
MapTypeListImplBase(const MapTypeListImplBase& other) requires IsSharedPtr<T> : MapTypeList(other) {
List.reserve(other.List.size());
for (const auto& l : other.List) {
List.push_back(std::move(l->clone()));
List.push_back(l->clone());
}
}

Expand All @@ -32,7 +32,7 @@ namespace SatisfactorySave {
List.clear();
List.reserve(other.List.size());
for (const auto& l : other.List) {
List.push_back(std::move(l->clone()));
List.push_back(l->clone());
}
}
return *this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace SatisfactorySave {
SetImplBase(const SetImplBase& other) requires IsSharedPtr<T> : Set(other) {
Values.reserve(other.Values.size());
for (const auto& s : other.Values) {
Values.push_back(std::move(s->clone()));
Values.push_back(s->clone());
}
}

Expand All @@ -32,7 +32,7 @@ namespace SatisfactorySave {
Values.clear();
Values.reserve(other.Values.size());
for (const auto& s : other.Values) {
Values.push_back(std::move(s->clone()));
Values.push_back(s->clone());
}
}
return *this;
Expand Down
2 changes: 1 addition & 1 deletion libsave/include/SatisfactorySave/IO/Archive/Archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ namespace SatisfactorySave {

protected:
Archive() = default;
~Archive() = default;
virtual ~Archive() = default;

virtual void serialize(void* data, std::size_t size) = 0;
virtual void serializeString(std::string& s) = 0;
Expand Down
4 changes: 2 additions & 2 deletions libsave/src/GameTypes/Arrays/StructArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SatisfactorySave::StructArray::StructArray() {
SatisfactorySave::StructArray::StructArray(const StructArray& other) : Array(other) {
Values.reserve(other.Values.size());
for (const auto& v : other.Values) {
Values.push_back(std::move(v->clone()));
Values.push_back(v->clone());
}
inner_tag_ = other.inner_tag_;
}
Expand All @@ -23,7 +23,7 @@ SatisfactorySave::StructArray& SatisfactorySave::StructArray::operator=(const St
Values.clear();
Values.reserve(other.Values.size());
for (const auto& v : other.Values) {
Values.push_back(std::move(v->clone()));
Values.push_back(v->clone());
}
inner_tag_ = other.inner_tag_;
}
Expand Down
8 changes: 4 additions & 4 deletions libsave/src/GameTypes/Properties/Base/PropertyList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#include "IO/Archive/IStreamArchive.h"
#include "IO/Archive/OStreamArchive.h"

SatisfactorySave::PropertyList::PropertyList(const PropertyList& other) {
SatisfactorySave::PropertyList::PropertyList(const PropertyList& other) : std::vector<std::shared_ptr<Property>>() {
this->reserve(other.size());
for (const auto& p : other) {
this->push_back(std::move(p->clone()));
this->push_back(p->clone());
}
}

Expand All @@ -15,7 +15,7 @@ SatisfactorySave::PropertyList& SatisfactorySave::PropertyList::operator=(const
this->clear();
this->reserve(other.size());
for (const auto& p : other) {
this->push_back(std::move(p->clone()));
this->push_back(p->clone());
}
}
return *this;
Expand All @@ -31,7 +31,7 @@ void SatisfactorySave::PropertyList::serialize(Archive& ar) {
if (property == nullptr) {
done = true;
} else {
this->emplace_back(std::move(property));
this->push_back(std::move(property));
}
} while (!done);
} else {
Expand Down
2 changes: 1 addition & 1 deletion libsave/src/GameTypes/Save/ChunkHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void SatisfactorySave::ChunkHeader::serialize(Archive& ar) {
if (archive_header_ != ARCHIVE_V2_HEADER) {
throw std::runtime_error("Invalid package format!");
}
if (compression_chunk_size_ != 131072) {
if (compression_chunk_size_ != COMPRESSION_CHUNK_SIZE) {
throw std::runtime_error("Invalid compression chunk size!");
}

Expand Down
16 changes: 8 additions & 8 deletions map/src/MapWindow/AboutWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace {
using namespace Satisfactory3DMap;

void parseCopyright(std::map<std::string, std::string>& licenseMap, const std::string& prefix) {
void parseCopyright(std::map<std::string, std::string>& licenseMap) {
const std::string copyrightDir("copyright");
for (const auto& entry : resourceDirContent(copyrightDir)) {
const auto entryDir = copyrightDir + "/" + entry;
Expand All @@ -26,7 +26,7 @@ namespace {

Satisfactory3DMap::AboutWindow::AboutWindow() : show_(false) {
try {
parseCopyright(licenseMap_, "library");
parseCopyright(licenseMap_);
} catch (const std::exception& ex) {
spdlog::error("Error initializing about window: {}", ex.what());
}
Expand All @@ -46,11 +46,11 @@ void Satisfactory3DMap::AboutWindow::renderGui() {
const auto& size = ImGui::GetIO().DisplaySize;
ImGui::SetNextWindowPos(ImVec2(size.x * 0.5f, size.y * 0.5f), ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
ImGui::Begin("About", &show_);
ImGui::Text("Satisfactory 3D Map");
ImGui::TextUnformatted("Satisfactory 3D Map");
ImGui::Text("Version: %s (Git: %s)", versionFull.c_str(), gitVersion.c_str());
ImGui::Text("");
ImGui::Text("Copyright (C) 2021 - 2024 Moritz Heinemann");
ImGui::Text("Homepage:");
ImGui::TextUnformatted("");
ImGui::TextUnformatted("Copyright (C) 2021 - 2024 Moritz Heinemann");
ImGui::TextUnformatted("Homepage:");
ImGui::SameLine();
if (ImGui::SmallButton(githubUrl.c_str())) {
openLink(githubUrl);
Expand All @@ -59,10 +59,10 @@ void Satisfactory3DMap::AboutWindow::renderGui() {
ImGui::Text("%s", licenseText.c_str());
ImGui::TreePop();
}
ImGui::Text("");
ImGui::TextUnformatted("");
ImGui::Separator();

ImGui::Text("Third-party software and resources:");
ImGui::TextUnformatted("Third-party software and resources:");
for (const auto& entry : licenseMap_) {
if (ImGui::CollapsingHeader(entry.first.c_str(), ImGuiTreeNodeFlags_None)) {
ImGui::Text("%s", entry.second.c_str());
Expand Down
10 changes: 6 additions & 4 deletions map/src/MapWindow/Pak/AssetWindow.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "AssetWindow.h"

#include <cinttypes>

#include <imgui.h>
#include <spdlog/spdlog.h>

Expand Down Expand Up @@ -59,13 +61,13 @@ void Satisfactory3DMap::AssetWindow::renderGui() {
ImGui::Text("CompressionFlags: %i", sum.CompressionFlags);
ImGui::Text("PackageSource: %i", sum.PackageSource);
ImGui::Text("AssetRegistryDataOffset: %i", sum.AssetRegistryDataOffset);
ImGui::Text("BulkDataStartOffset: %lli", sum.BulkDataStartOffset);
ImGui::Text("BulkDataStartOffset: %" PRIi64, sum.BulkDataStartOffset);
ImGui::Text("WorldTileInfoDataOffset: %i", sum.WorldTileInfoDataOffset);
ImGui::Text("ChunkIDs: TODO"); // std::vector<int32_t> ChunkIDs;
ImGui::Text("PreloadDependencyCount: %i", sum.PreloadDependencyCount);
ImGui::Text("PreloadDependencyOffset: %i", sum.PreloadDependencyOffset);
ImGui::Text("NamesReferencedFromExportDataCount: %i", sum.NamesReferencedFromExportDataCount);
ImGui::Text("PayloadTocOffset: %lli", sum.PayloadTocOffset);
ImGui::Text("PayloadTocOffset: %" PRIi64, sum.PayloadTocOffset);
}
if (ImGui::CollapsingHeader("Name Map")) {
if (ImGui::Button("Copy")) {
Expand Down Expand Up @@ -138,8 +140,8 @@ void Satisfactory3DMap::AssetWindow::renderGui() {
ImGui::Text("OuterIndex: %i", exportEntry.OuterIndex);
ImGui::Text("ObjectName: %s", exportEntry.ObjectName.toString().c_str());
ImGui::Text("Save: %i", exportEntry.Save);
ImGui::Text("SerialSize: %lli", exportEntry.SerialSize);
ImGui::Text("SerialOffset: %lli", exportEntry.SerialOffset);
ImGui::Text("SerialSize: %" PRIi64, exportEntry.SerialSize);
ImGui::Text("SerialOffset: %" PRIi64, exportEntry.SerialOffset);
ImGui::Text("bForcedExport: %i", exportEntry.bForcedExport);
ImGui::Text("bNotForClient: %i", exportEntry.bNotForClient);
ImGui::Text("bNotForServer: %i", exportEntry.bNotForServer);
Expand Down
2 changes: 1 addition & 1 deletion map/src/MapWindow/UI/ObjectWidgets.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ namespace Satisfactory3DMap::UI {
}
EditorTreeEndLeaf();
EditorTreeStartLeaf("Rotation");
ImGui::SetItemTooltip(glm::to_string(glmCast(t.Rotation)).c_str());
ImGui::SetItemTooltip("%s", glm::to_string(glmCast(t.Rotation)).c_str());
ImGui::TableNextColumn();
ImGui::SetNextItemWidth(-FLT_MIN);
if (ImGui::DragFloat3("##rot", glm::value_ptr(eulerAngels), 1.0f, 0.0f, 360.0f, "%.3f",
Expand Down
4 changes: 2 additions & 2 deletions map/src/MapWindow/UI/PropertyEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ void Satisfactory3DMap::UI::PropertyEditor::StructEditor::visit(s::InventoryItem

void Satisfactory3DMap::UI::PropertyEditor::StructEditor::visit(s::LBBalancerIndexingStruct& s) {
if (EditorTreeNode("Data", ImGuiTreeNodeFlags_DefaultOpen)) {
static constexpr int32_t step = 1.0f;
static constexpr int32_t step_fast = 100.0f;
static constexpr int32_t step = 1;
static constexpr int32_t step_fast = 100;
parent_.changed_ |= EditorScalar("mNormalIndex", ImGuiDataType_S32, &s.Data.mNormalIndex, &step, &step_fast);
parent_.changed_ |=
EditorScalar("mOverflowIndex", ImGuiDataType_S32, &s.Data.mOverflowIndex, &step, &step_fast);
Expand Down
5 changes: 3 additions & 2 deletions map/src/Utils/GLMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ namespace Satisfactory3DMap {

template<typename T>
inline glm::vec3 glmCast(const SatisfactorySave::TVector<T>& vec) {
return {vec.X, vec.Y, vec.Z};
return {static_cast<float>(vec.X), static_cast<float>(vec.Y), static_cast<float>(vec.Z)};
}

template<typename T>
inline glm::quat glmCast(const SatisfactorySave::TQuat<T>& quat) {
return glm::quat(quat.W, quat.X, quat.Y, quat.Z);
return glm::quat(static_cast<float>(quat.W), static_cast<float>(quat.X), static_cast<float>(quat.Y),
static_cast<float>(quat.Z));
}

template<typename T>
Expand Down

0 comments on commit 914ea5c

Please sign in to comment.