diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f4b255..24d73fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,10 @@ option(TESTS "Whether the test executable should be build as well." OFF) option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF) set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.") +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options(-fconcepts) +endif () + if (WINDOWS) SET(CMAKE_SYSTEM_NAME Windows) ADD_DEFINITIONS(-D WINDOWS=1) diff --git a/src/Battling/Library/StatCalculator.cpp b/src/Battling/Library/StatCalculator.cpp index 717f148..fd3c519 100644 --- a/src/Battling/Library/StatCalculator.cpp +++ b/src/Battling/Library/StatCalculator.cpp @@ -34,7 +34,7 @@ float PkmnLib::Battling::StatCalculator::GetStatBoostModifier(const CreatureLib: case 4: return 6.0 / 2; case 5: return 7.0 / 2; case 6: return 8.0 / 2; - default: throw CreatureException("Stat boost was out of expected range of -6 till 6."); + default: throw ArbUt::Exception("Stat boost was out of expected range of -6 till 6."); } } CreatureLib::Library::StatisticSet diff --git a/src/Battling/Pokemon/CreatePokemon.cpp b/src/Battling/Pokemon/CreatePokemon.cpp index 1da461c..ac3dc41 100644 --- a/src/Battling/Pokemon/CreatePokemon.cpp +++ b/src/Battling/Pokemon/CreatePokemon.cpp @@ -40,13 +40,13 @@ namespace PkmnLib::Battling { if (!this->_library->GetSpeciesLibrary()->TryGet(this->_species, species)) { std::stringstream err; err << "Invalid species '" << _species << "'."; - throw CreatureException(err.str()); + throw ArbUt::Exception(err.str()); } ArbUt::BorrowedPtr forme; if (!species->TryGetForme(this->_forme, forme)) { std::stringstream err; err << "Invalid forme '" << _forme << "' for species '" << _forme << "'."; - throw CreatureException(err.str()); + throw ArbUt::Exception(err.str()); } AssertNotNull(forme); CreatureLib::Library::TalentIndex ability; @@ -151,7 +151,7 @@ namespace PkmnLib::Battling { THROW_CREATURE("Invalid Move given: " << moveName.std_str()); } if (_currentMove >= _library->GetSettings()->GetMaximalAttacks()) { - throw CreatureException("This pokemon already has the maximal allowed moves."); + throw ArbUt::Exception("This pokemon already has the maximal allowed moves."); } Assert(move != nullptr); _attacks.Append(ToLearnMethod(move, method)); diff --git a/src/Library/Natures/NatureLibrary.hpp b/src/Library/Natures/NatureLibrary.hpp index b807eed..d4cb795 100644 --- a/src/Library/Natures/NatureLibrary.hpp +++ b/src/Library/Natures/NatureLibrary.hpp @@ -40,7 +40,7 @@ namespace PkmnLib::Library { return v.first; } } - throw CreatureException("Nature not found."); + throw ArbUt::Exception("Nature not found."); } size_t GetNatureCount() const noexcept { return _items.size(); } diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index f9de554..d48a807 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -56,7 +56,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) int32_t r = _engine->SetMessageCallback(asFUNCTION(MessageCallback), nullptr, asCALL_CDECL); if (r < 0) - throw CreatureException("Registering message callback failed."); + throw ArbUt::Exception("Registering message callback failed."); _engine->SetEngineProperty(asEP_DISALLOW_EMPTY_LIST_ELEMENTS, true); _engine->SetEngineProperty(asEP_DISALLOW_VALUE_ASSIGN_FOR_REF_TYPE, false); @@ -75,7 +75,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) r = _engine->RegisterGlobalFunction("void print(const string &in)", asFUNCTION(Print), asCALL_CDECL); if (r < 0) - throw CreatureException("Registering print function failed."); + throw ArbUt::Exception("Registering print function failed."); RegisterScriptHandle(_engine); _builder.StartNewModule(_engine, "pkmn"); @@ -148,7 +148,7 @@ CreatureLib::Battling::Script* AngelScriptResolver::LoadScript(ScriptCategory ca void AngelScriptResolver::FinalizeModule() { int r = _builder.BuildModule(); if (r < 0) - throw CreatureException("Building Script Module failed."); + throw ArbUt::Exception("Building Script Module failed."); asUINT count = _mainModule->GetObjectTypeCount(); std::regex metadataMatcher(R"(^\s*(\w+)([\w\s=]*)$)", std::regex_constants::icase); std::regex variableMatcher(R"(\s*(\w+)=(\w+))", std::regex_constants::icase); diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index 63aa2a3..2361712 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -27,14 +27,14 @@ } else { \ ctx->PopState(); \ } \ - throw CreatureException(err.str()); \ + throw ArbUt::Exception(err.str()); \ } \ if (newContext) { \ _ctxPool->ReturnContextToPool(ctx); \ } else { \ ctx->PopState(); \ } \ - throw CreatureException("Script didn't finish properly; message " + std::to_string(scriptResult)); \ + throw ArbUt::Exception("Script didn't finish properly; message " + std::to_string(scriptResult)); \ } \ if (newContext) { \ _ctxPool->ReturnContextToPool(ctx); \ diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 9c806d7..9ac24c3 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -2,7 +2,6 @@ #define PKMNLIB_ANGELSCRIPTSCRIPT_HPP #include #define ANGELSCRIPT_DLL_LIBRARY_IMPORT -#include #include #include #include "../../../extern/angelscript_addons/scriptarray/scriptarray.h" diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index b2d6940..9cc0916 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -64,7 +64,7 @@ public: ctx->Prepare(factory); auto result = ctx->Execute(); if (result != asEXECUTION_FINISHED) { - throw CreatureException("Instantiation failed."); + throw ArbUt::Exception("Instantiation failed."); } asIScriptObject* obj = *(asIScriptObject**)ctx->GetAddressOfReturnValue(); obj->AddRef(); diff --git a/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp b/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp index e06f913..f46d2f3 100644 --- a/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp +++ b/src/ScriptResolving/AngelScript/ByteCodeHandling/MemoryByteCodeStream.hpp @@ -30,7 +30,7 @@ public: _capacity += MEM_STEPS; auto newLoc = realloc(_out, _capacity * sizeof(uint8_t)); if (newLoc == nullptr) { - throw CreatureException("Out of memory."); + throw ArbUt::Exception("Out of memory."); } _out = (uint8_t*)newLoc; }