diff --git a/CInterface/Core.cpp b/CInterface/Core.cpp index 75f7a32..b1a8224 100644 --- a/CInterface/Core.cpp +++ b/CInterface/Core.cpp @@ -1,3 +1,4 @@ #include "Core.hpp" +std::string ExceptionHandler::_creatureLibLastException = ""; export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); } diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index 1eaaa24..61ce85a 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -11,15 +11,15 @@ #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) class ExceptionHandler { - static std::string _lastException; + static std::string _creatureLibLastException; public: static void SetLastException(std::string function, const std::exception& e) { std::stringstream ss; ss << "[" << function << "] " << e.what(); - _lastException = ss.str(); + _creatureLibLastException = ss.str(); } - static const char* GetLastException() { return _lastException.c_str(); } + static const char* GetLastException() { return _creatureLibLastException.c_str(); } }; #define Try(data) \ diff --git a/src/Battling/Models/Battle.cpp b/src/Battling/Models/Battle.cpp index 6694d6a..cd52fc6 100644 --- a/src/Battling/Models/Battle.cpp +++ b/src/Battling/Models/Battle.cpp @@ -19,7 +19,7 @@ bool Battle::CanUse(const ArbUt::BorrowedPtr& choice) { } bool Battle::TrySetChoice(BaseTurnChoice* choice) { - AssertNotNull(choice) + AssertNotNull(choice); if (!CanUse(choice)) return false; choice->GetUser()->GetBattleSide()->SetChoice(choice); diff --git a/src/Battling/Models/CreateCreature.cpp b/src/Battling/Models/CreateCreature.cpp index 7cdf609..af3be84 100644 --- a/src/Battling/Models/CreateCreature.cpp +++ b/src/Battling/Models/CreateCreature.cpp @@ -1,5 +1,6 @@ #include "CreateCreature.hpp" +#include #include #include "../Library/BattleLibrary.hpp" @@ -21,8 +22,9 @@ CreateCreature CreateCreature::WithGender(Library::Gender gender) { } CreateCreature CreateCreature::WithAttack(const ArbUt::StringView& attackName, AttackLearnMethod learnMethod) { - if (_attacks.Count() >= _library->GetSettings()->GetMaximalMoves()) + if (_attacks.Count() >= _library->GetSettings()->GetMaximalMoves()) { THROW_CREATURE("You have already set the maximum amount of allowed moves."); + } auto attackData = _library->GetAttackLibrary()->Get(attackName.GetHash()); _attacks.Append(std::tuple(attackData, learnMethod)); diff --git a/src/Library/Exceptions/CreatureException.hpp b/src/Library/Exceptions/CreatureException.hpp index 8753ee9..932a947 100644 --- a/src/Library/Exceptions/CreatureException.hpp +++ b/src/Library/Exceptions/CreatureException.hpp @@ -13,9 +13,8 @@ public: }; #define THROW_CREATURE(message) \ - { \ - std::stringstream ss; \ - ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \ - throw CreatureException(ss.str()); \ - } + std::stringstream ___ss; \ + ___ss << "[" << __FILENAME__ << ":" << __LINE__ << "] " << message; \ + throw CreatureException(___ss.str()); + #endif // CREATURELIB_CREATUREEXCEPTION_HPP