diff --git a/src/Library/Items/ItemLibrary.hpp b/src/Library/Items/ItemLibrary.hpp index 16addc0..ad2925b 100644 --- a/src/Library/Items/ItemLibrary.hpp +++ b/src/Library/Items/ItemLibrary.hpp @@ -16,9 +16,7 @@ namespace PkmnLib::Library { inline ArbUt::BorrowedPtr Get(const ArbUt::BasicStringView& name) const { return CreatureLib::Library::ItemLibrary::Get(name).ForceAs(); } - inline ArbUt::BorrowedPtr operator[](const ArbUt::BasicStringView& name) const { - return Get(name); - } + inline ArbUt::BorrowedPtr operator[](const ArbUt::BasicStringView& name) const { return Get(name); } void Insert(const ArbUt::StringView& name, const Item* item) { CreatureLib::Library::ItemLibrary::Insert(name, item); diff --git a/src/Library/Moves/MoveData.hpp b/src/Library/Moves/MoveData.hpp index 8d652c1..90f66c0 100644 --- a/src/Library/Moves/MoveData.hpp +++ b/src/Library/Moves/MoveData.hpp @@ -8,10 +8,9 @@ namespace PkmnLib::Library { class MoveData : public CreatureLib::Library::AttackData { private: public: - MoveData(const ArbUt::StringView& name, uint8_t type, PkmnLib::Library::MoveCategory category, - uint8_t power, uint8_t accuracy, uint8_t baseUsage, CreatureLib::Library::AttackTarget target, - int8_t priority, const CreatureLib::Library::SecondaryEffect* effect, - std::unordered_set flags); + MoveData(const ArbUt::StringView& name, uint8_t type, PkmnLib::Library::MoveCategory category, uint8_t power, + uint8_t accuracy, uint8_t baseUsage, CreatureLib::Library::AttackTarget target, int8_t priority, + const CreatureLib::Library::SecondaryEffect* effect, std::unordered_set flags); PkmnLib::Library::MoveCategory GetCategory() const; }; diff --git a/src/Library/Moves/MoveLibrary.hpp b/src/Library/Moves/MoveLibrary.hpp index 7c69c72..26a0546 100644 --- a/src/Library/Moves/MoveLibrary.hpp +++ b/src/Library/Moves/MoveLibrary.hpp @@ -12,8 +12,7 @@ namespace PkmnLib::Library { return Get(name); } - inline bool TryGet(const ArbUt::BasicStringView& name, - ArbUt::BorrowedPtr& move) const { + inline bool TryGet(const ArbUt::BasicStringView& name, ArbUt::BorrowedPtr& move) const { auto v = move.As(); auto res = CreatureLib::Library::AttackLibrary::TryGet(name, v); move = v.As(); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp index e0c9022..e284a8e 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/ConstString.cpp @@ -2,6 +2,9 @@ #include static void ConstructConstString(void* self) { new (self) ArbUt::StringView(); } +static void ConstructConstStringFromStd(void* self, const std::string& s) { + new (self) ArbUt::StringView(s.c_str(), s.length()); +} static void CopyConstructConstString(const ArbUt::StringView& other, void* self) { new (self) ArbUt::StringView(other); } @@ -18,6 +21,9 @@ void ConstStringRegister::Register(asIScriptEngine* engine) { r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructConstString), asCALL_CDECL_OBJLAST); Assert(r >= 0); + r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const string &in s)", + asFUNCTION(ConstructConstStringFromStd), asCALL_CDECL_OBJLAST); + Assert(r >= 0); r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const constString &in)", asFUNCTION(CopyConstructConstString), asCALL_CDECL_OBJLAST);