From 27556e30e3f2b8eb469a05757e299e6bf2418565 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 19 Apr 2020 12:38:15 +0200 Subject: [PATCH] Updates to new PkmnLib, fixed same named scripts in different folders not handling both scripts. --- src/BuildData/BuildNatures.cpp | 5 +++-- src/LibraryTests/NaturesTests.cpp | 19 +++++++++---------- src/main.cpp | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/BuildData/BuildNatures.cpp b/src/BuildData/BuildNatures.cpp index d9b8c52..6fc5474 100644 --- a/src/BuildData/BuildNatures.cpp +++ b/src/BuildData/BuildNatures.cpp @@ -79,8 +79,9 @@ PkmnLib::Library::NatureLibrary* BuildNatures::Build(const std::string& path) { decreasedModifier = 1.0; std::cout << "Registered nature with name '" << natureName << "'.\n"; - library->LoadNature(natureName, PkmnLib::Library::Nature(parsedIncreased, parsedDecreased, increasedModifier, - decreasedModifier)); + library->LoadNature( + Arbutils::CaseInsensitiveConstString(natureName), + new PkmnLib::Library::Nature(parsedIncreased, parsedDecreased, increasedModifier, decreasedModifier)); } return library; } diff --git a/src/LibraryTests/NaturesTests.cpp b/src/LibraryTests/NaturesTests.cpp index 3a90083..491b62c 100644 --- a/src/LibraryTests/NaturesTests.cpp +++ b/src/LibraryTests/NaturesTests.cpp @@ -1,21 +1,20 @@ #include "../../extern/catch.hpp" #include "../Library.hpp" -#define CHECK_NATURE_NEUTRAL(name) \ +#define CHECK_NATURE_NEUTRAL(name) \ { \ - auto nature = natureLib->GetNatureByName( #name ); \ - CHECK(nature.GetIncreaseModifier() == Approx(1.0)); \ - CHECK(nature.GetDecreaseModifier() == Approx(1.0)); \ + auto nature = natureLib->GetNatureByName(Arbutils::CaseInsensitiveConstString(#name)); \ + CHECK(nature->GetIncreaseModifier() == Approx(1.0)); \ + CHECK(nature->GetDecreaseModifier() == Approx(1.0)); \ } - #define CHECK_NATURE(name, increasedStat, decreasedStat) \ { \ - auto nature = natureLib->GetNatureByName( #name ); \ - CHECK(nature.GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \ - CHECK(nature.GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \ - CHECK(nature.GetIncreaseModifier() == Approx(1.1)); \ - CHECK(nature.GetDecreaseModifier() == Approx(0.9)); \ + auto nature = natureLib->GetNatureByName(Arbutils::CaseInsensitiveConstString(#name)); \ + CHECK(nature->GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \ + CHECK(nature->GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \ + CHECK(nature->GetIncreaseModifier() == Approx(1.1)); \ + CHECK(nature->GetDecreaseModifier() == Approx(0.9)); \ } TEST_CASE("Nature Checks", "[natures]") { diff --git a/src/main.cpp b/src/main.cpp index 24097e9..4ceffe7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -102,7 +102,7 @@ int main(int argc, char* argv[]) { continue; std::ifstream in(dirEntry.path()); std::string contents((std::istreambuf_iterator(in)), std::istreambuf_iterator()); - asScriptResolver->CreateScript(dirEntry.path().filename().c_str(), contents.c_str()); + asScriptResolver->CreateScript(dirEntry.path().c_str(), contents.c_str()); } asScriptResolver->CreateScript("TriggerEffectChance", R"(