From 728bc13ac1cde2645b61aad1d670dec5f7edbcd3 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 19 Sep 2021 11:43:02 +0200 Subject: [PATCH] Update to new CreatureLib nickname handling --- CMakeLists.txt | 5 ----- src/Battling/Pokemon/Pokemon.hpp | 2 +- .../TypeRegistry/Battling/RegisterPokemonClass.cpp | 12 ++++++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 527fe3b..e960de1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,11 +61,6 @@ else () message(FATAL_ERROR, "Invalid level size was given.") endif () -message(STATUS "Using Conan Libs:") -foreach (_conanLib ${CONAN_LIBS}) - message(STATUS "\t ${_conanLib}") -endforeach () - if (CMAKE_BUILD_TYPE MATCHES Release AND NOT WINDOWS) # Include debug symbols in all linux builds message("Including debug symbols") diff --git a/src/Battling/Pokemon/Pokemon.hpp b/src/Battling/Pokemon/Pokemon.hpp index cb17fd1..e44863e 100644 --- a/src/Battling/Pokemon/Pokemon.hpp +++ b/src/Battling/Pokemon/Pokemon.hpp @@ -22,7 +22,7 @@ namespace PkmnLib::Battling { const ArbUt::BorrowedPtr& species, const ArbUt::BorrowedPtr& forme, level_int_t level, uint32_t experience, uint32_t uid, CreatureLib::Library::Gender gender, uint8_t coloring, - ArbUt::OptionalBorrowedPtr heldItem, const std::string& nickname, + ArbUt::OptionalBorrowedPtr heldItem, const std::optional& nickname, const CreatureLib::Library::TalentIndex& talent, const std::vector& moves, CreatureLib::Library::ClampedStatisticSet individualValues, diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 106b4bc..d7458e2 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -81,7 +81,12 @@ static void SetHeldItemWrapper(PkmnLib::Battling::Pokemon* obj, const ArbUt::Str return obj->SetHeldItem(str); } -static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { return std::string(obj->GetNickname()); } +static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { + if (!obj->GetNickname().has_value()) { + return ""; + } + return std::string(obj->GetNickname().value()); +} BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies); BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme); @@ -127,9 +132,8 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const constString &in name) const", asFUNCTION(HasHeldItem), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); - r = engine->RegisterObjectMethod( - "Pokemon", "void SetHeldItem(const constString &in name)", - asFUNCTION(SetHeldItemWrapper), asCALL_CDECL_OBJFIRST); + r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const constString &in name)", + asFUNCTION(SetHeldItemWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const Item@ item)", asMETHODPR(PkmnLib::Battling::Pokemon, SetHeldItem,