From 3c7bd6710cc3b2e13e3d725757251eeb01b96a94 Mon Sep 17 00:00:00 2001 From: George Tokmaji Date: Wed, 25 Sep 2024 14:39:39 +0200 Subject: [PATCH] C4HudBarDef::Gfx: Capitalize public members and remove unnecessary constructors and operator== implementation --- src/C4HudBars.cpp | 34 +++++++++++----------------------- src/C4HudBars.h | 13 +++++-------- 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/src/C4HudBars.cpp b/src/C4HudBars.cpp index 5dc1cd2c..481f7c0b 100644 --- a/src/C4HudBars.cpp +++ b/src/C4HudBars.cpp @@ -270,24 +270,12 @@ namespace } } -C4HudBarsDef::Gfx::Gfx(std::string key, std::string file, const std::int32_t amount, const std::int32_t scale) noexcept - : key{std::move(key)}, - file{std::move(file)}, - amount{amount}, - scale{scale} -{} - -bool C4HudBarsDef::Gfx::operator==(const Gfx &rhs) const noexcept -{ - return key == rhs.key && file == rhs.file && amount == rhs.amount && scale == rhs.scale; -} - void C4HudBarsDef::Gfx::CompileFunc(StdCompiler *const comp) { - comp->Value(mkNamingAdapt(key, "Key")); - comp->Value(mkNamingAdapt(file, "File")); - comp->Value(mkNamingAdapt(amount, "Amount")); - comp->Value(mkNamingAdapt(scale, "Scale")); + comp->Value(mkNamingAdapt(Key, "Key")); + comp->Value(mkNamingAdapt(File, "File")); + comp->Value(mkNamingAdapt(Amount, "Amount")); + comp->Value(mkNamingAdapt(Scale, "Scale")); } C4HudBarsDef::C4HudBarsDef(Gfxs &&gfxs, Bars &&bars) : gfxs{std::move(gfxs)}, bars{std::move(bars)} @@ -321,7 +309,7 @@ std::size_t C4HudBarsDef::GetHash() const noexcept std::size_t result{0}; for (const auto &gfx : gfxs) { - HashCombineArguments(result, gfx.second.key, gfx.second.file, gfx.second.amount, gfx.second.scale); + HashCombineArguments(result, gfx.second.Key, gfx.second.File, gfx.second.Amount, gfx.second.Scale); } for (const auto &bardef : bars) @@ -391,9 +379,9 @@ std::shared_ptr C4HudBarsUniquifier::GetFacet(const std::functionsecond.amount; - scale = it->second.scale; - file = it->second.file; + amount = it->second.Amount; + scale = it->second.Scale; + file = it->second.File; } else { @@ -645,7 +633,7 @@ void C4HudBarsUniquifier::ProcessHudBar(std::int32_t &valueIndex, const C4HudBar bar.max = _max; bar.visible = _visible; bar.advance = advance; - auto scale = graphics.at(file.getData()).scale; + auto scale = graphics.at(file.getData()).Scale; bar.scale = static_cast(scale) / 100.0f; bars.push_back(bar); } @@ -674,7 +662,7 @@ void C4HudBarsAdapt::CompileFunc(StdCompiler *const comp) std::vector temp; comp->Value(mkNamingAdapt(mkSTLContainerAdapt(temp), "Gfx", std::vector{})); for (const auto &gfx : temp) - gfxs_.emplace(gfx.key, gfx); + gfxs_.emplace(gfx.Key, gfx); C4HudBarsDef::Bars bars_; comp->Value(mkNamingAdapt(mkSTLContainerAdapt(bars_), "Def", C4HudBarsDef::Bars{})); @@ -691,7 +679,7 @@ void C4HudBarsAdapt::CompileFunc(StdCompiler *const comp) bars = Game.HudBars.DefaultBars(); return; } - bar.scale = static_cast(def->gfxs.at(bar.gfx).scale) / 100.0f; + bar.scale = static_cast(def->gfxs.at(bar.gfx).Scale) / 100.0f; } const auto instance = Game.HudBars.RegisterAndCreateInstance(std::move(def)); diff --git a/src/C4HudBars.h b/src/C4HudBars.h index 0807448e..e8a48a9b 100644 --- a/src/C4HudBars.h +++ b/src/C4HudBars.h @@ -123,15 +123,12 @@ class C4HudBarsDef public: struct Gfx { - std::string key; - std::string file; - std::int32_t amount{0}; - std::int32_t scale{0}; + std::string Key; + std::string File; + std::int32_t Amount{0}; + std::int32_t Scale{0}; - Gfx() noexcept = default; - Gfx(std::string key, std::string file, std::int32_t amount, std::int32_t scale) noexcept; - - bool operator==(const Gfx &rhs) const noexcept; + constexpr bool operator==(const Gfx &rhs) const noexcept = default; void CompileFunc(StdCompiler *comp); };