diff --git a/CInterface/Library/EvolutionData.cpp b/CInterface/Library/EvolutionData.cpp index b5a5af1..2388c1b 100644 --- a/CInterface/Library/EvolutionData.cpp +++ b/CInterface/Library/EvolutionData.cpp @@ -74,6 +74,6 @@ export const PokemonSpecies* PkmnLib_EvolutionData_GetNewSpecies(const Evolution } export size_t PkmnLib_EvolutionData_GetDataCount(const EvolutionData* data) { return data->GetDataCount(); } export uint8_t PkmnLib_EvolutionData_GetDataAt(const EvolutionData* data, size_t index, - const CreatureLib::Library::EffectParameter*& out) { + const CreatureLib::Library::EffectParameter*& out) { Try(out = data->GetDataAt(index).GetRaw()); } diff --git a/src/Battling/Pokemon/CreatePokemon.hpp b/src/Battling/Pokemon/CreatePokemon.hpp index b533b3d..12d08d2 100644 --- a/src/Battling/Pokemon/CreatePokemon.hpp +++ b/src/Battling/Pokemon/CreatePokemon.hpp @@ -68,7 +68,6 @@ namespace PkmnLib::Battling { CreatePokemon& IsAllowedExperienceGain(bool value); CreatePokemon& WithNickname(const std::string& nickname); - Pokemon* Build() { auto rand = ArbUt::Random(); return Build(rand); diff --git a/src/ScriptResolving/AngelScript/AngelScriptMetadata.hpp b/src/ScriptResolving/AngelScript/AngelScriptMetadata.hpp index 71e898a..97a9397 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptMetadata.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptMetadata.hpp @@ -38,7 +38,7 @@ private: auto current = idEnd; while (true) { current = FindNextNonSpace(metadataString, current); - if (current >= metadataString.length()){ + if (current >= metadataString.length()) { break; } ParseParameter(metadataString, current); @@ -61,7 +61,7 @@ private: } auto value = metadataString.substr(start, current - start); _parameters.Insert(name, value); - if (isQuoted){ + if (isQuoted) { current += 1; } } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 0962565..9ae068c 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -42,10 +42,14 @@ void RegisterPokemonClass::RegisterMoveLearnMethod(asIScriptEngine* engine) { void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT); Ensure(r >= 0); - REGISTER_GETTER("LearnedMove", "const MoveData@ get_MoveData() const property", CreatureLib::Battling::LearnedAttack, GetAttack); - REGISTER_GETTER("LearnedMove", "uint8 get_MaxUses() const property", CreatureLib::Battling::LearnedAttack, GetMaxUses); - REGISTER_GETTER("LearnedMove", "uint8 get_RemainingUses() const property", CreatureLib::Battling::LearnedAttack, GetRemainingUses); - REGISTER_GETTER("LearnedMove", "Gender get_LearnMethod() const property", CreatureLib::Battling::LearnedAttack, GetLearnMethod); + REGISTER_GETTER("LearnedMove", "const MoveData@ get_MoveData() const property", + CreatureLib::Battling::LearnedAttack, GetAttack); + REGISTER_GETTER("LearnedMove", "uint8 get_MaxUses() const property", CreatureLib::Battling::LearnedAttack, + GetMaxUses); + REGISTER_GETTER("LearnedMove", "uint8 get_RemainingUses() const property", CreatureLib::Battling::LearnedAttack, + GetRemainingUses); + REGISTER_GETTER("LearnedMove", "Gender get_LearnMethod() const property", CreatureLib::Battling::LearnedAttack, + GetLearnMethod); } static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& str) { @@ -103,7 +107,7 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { GetMoves); auto r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const constString &in name) const", - asFUNCTION(HasHeldItem), asCALL_CDECL_OBJFIRST); + asFUNCTION(HasHeldItem), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const constString &in name)", asFUNCTION(SetHeldItemWrapper), asCALL_CDECL_OBJFIRST); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp index 679d66b..7e345fb 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterTurnChoices.cpp @@ -35,10 +35,10 @@ void RegisterTurnChoices::RegisterMoveTurnChoice(asIScriptEngine* engine) { REGISTER_EXPLICIT_GETTER("MoveTurnChoice", "Pokemon@ get_User() const property", CreatureLib::Battling::BaseTurnChoice, GetUser, const ArbUt::BorrowedPtr&); - REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property", - CreatureLib::Battling::AttackTurnChoice, GetAttack); - REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property", - CreatureLib::Battling::AttackTurnChoice, GetPriority); + REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property", CreatureLib::Battling::AttackTurnChoice, + GetAttack); + REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property", CreatureLib::Battling::AttackTurnChoice, + GetPriority); r = engine->RegisterObjectMethod( "BaseTurnChoice", "MoveTurnChoice@ opCast()", @@ -56,11 +56,13 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) { int r = engine->RegisterObjectType("SwitchTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT); Ensure(r >= 0); - REGISTER_GETTER("SwitchTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::SwitchTurnChoice, GetKind); + REGISTER_GETTER("SwitchTurnChoice", "TurnChoiceKind get_Kind() const property", + CreatureLib::Battling::SwitchTurnChoice, GetKind); REGISTER_EXPLICIT_GETTER("SwitchTurnChoice", "const Pokemon@ get_User() const property", CreatureLib::Battling::BaseTurnChoice, GetUser, const ArbUt::BorrowedPtr&); - REGISTER_GETTER("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property", CreatureLib::Battling::SwitchTurnChoice, GetNewCreature); + REGISTER_GETTER("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property", + CreatureLib::Battling::SwitchTurnChoice, GetNewCreature); r = engine->RegisterObjectMethod( "BaseTurnChoice", "SwitchTurnChoice@ opCast()", @@ -76,7 +78,8 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) { void RegisterTurnChoices::RegisterFleeTurnChoice(asIScriptEngine* engine) { int r = engine->RegisterObjectType("FleeTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT); Ensure(r >= 0); - REGISTER_GETTER("FleeTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::FleeTurnChoice, GetKind); + REGISTER_GETTER("FleeTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::FleeTurnChoice, + GetKind); REGISTER_EXPLICIT_GETTER("FleeTurnChoice", "const Pokemon@ get_User() const property", CreatureLib::Battling::BaseTurnChoice, GetUser, const ArbUt::BorrowedPtr&); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterEffectParameter.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterEffectParameter.cpp index 3a99b2d..a206f80 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterEffectParameter.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterEffectParameter.cpp @@ -38,6 +38,4 @@ void RegisterEffectParameter::Register(asIScriptEngine* engine) { asFUNCTIONPR(AsString, (const CreatureLib::Library::EffectParameter*), const ArbUt::StringView&), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); - - } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp index 36c8eb9..55fe675 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterSpeciesTypes.cpp @@ -44,11 +44,15 @@ static const PkmnLib::Library::PokemonForme* GetFormeWrapper(const std::string& void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) { int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT); Ensure(r >= 0); - REGISTER_GETTER("Species", "const constString& get_Name() const property", CreatureLib::Library::CreatureSpecies, GetName); + REGISTER_GETTER("Species", "const constString& get_Name() const property", CreatureLib::Library::CreatureSpecies, + GetName); REGISTER_GETTER("Species", "uint16 get_Id() const property", CreatureLib::Library::CreatureSpecies, GetId); - REGISTER_GETTER("Species", "float get_GenderRate() const property", CreatureLib::Library::CreatureSpecies, GetGenderRate); - REGISTER_GETTER("Species", "uint8 get_CaptureRate() const property", CreatureLib::Library::CreatureSpecies, GetCaptureRate); - REGISTER_GETTER("Species", "const Forme@ get_DefaultForme() const property", PkmnLib::Library::PokemonSpecies, GetDefaultForme); + REGISTER_GETTER("Species", "float get_GenderRate() const property", CreatureLib::Library::CreatureSpecies, + GetGenderRate); + REGISTER_GETTER("Species", "uint8 get_CaptureRate() const property", CreatureLib::Library::CreatureSpecies, + GetCaptureRate); + REGISTER_GETTER("Species", "const Forme@ get_DefaultForme() const property", PkmnLib::Library::PokemonSpecies, + GetDefaultForme); r = engine->RegisterObjectMethod("Species", "Gender GetRandomGender() const", asMETHOD(PkmnLib::Library::PokemonSpecies, GetRandomGender), asCALL_THISCALL); @@ -65,10 +69,12 @@ const ArbUt::StringView& GetAbility(PkmnLib::Library::PokemonForme* p, bool hidd void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) { int r = engine->RegisterObjectType("Forme", 0, asOBJ_REF | asOBJ_NOCOUNT); Ensure(r >= 0); - REGISTER_GETTER("Forme", "const constString& get_Name() const property", CreatureLib::Library::SpeciesVariant, GetName); + REGISTER_GETTER("Forme", "const constString& get_Name() const property", CreatureLib::Library::SpeciesVariant, + GetName); REGISTER_GETTER("Forme", "float get_Weight() const property", CreatureLib::Library::SpeciesVariant, GetWeight); REGISTER_GETTER("Forme", "float get_Height() const property", CreatureLib::Library::SpeciesVariant, GetHeight); - REGISTER_GETTER("Forme", "uint get_BaseExperience() const property", CreatureLib::Library::SpeciesVariant, GetBaseExperience); + REGISTER_GETTER("Forme", "uint get_BaseExperience() const property", CreatureLib::Library::SpeciesVariant, + GetBaseExperience); REGISTER_GETTER("Forme", "int get_TypeCount() const property", CreatureLib::Library::SpeciesVariant, GetTypeCount); r = engine->RegisterObjectMethod("Forme", "uint8 GetType(int index) const", @@ -92,16 +98,18 @@ void RegisterSpeciesTypes::RegisterEvolutionData(asIScriptEngine* engine) { int r = engine->RegisterObjectType("EvolutionData", 0, asOBJ_REF | asOBJ_NOCOUNT); Ensure(r >= 0); - REGISTER_GETTER("EvolutionData", "const Species& get_NewSpecies() const property", PkmnLib::Library::EvolutionData, GetNewSpecies); - REGISTER_GETTER("EvolutionData", "EvolutionMethod get_Method() const property", PkmnLib::Library::EvolutionData, GetMethod); - REGISTER_GETTER("EvolutionData", "uint64 get_DataCount() const property", PkmnLib::Library::EvolutionData, GetDataCount); - REGISTER_GETTER("EvolutionData", "const narray@ get_Data() const property", PkmnLib::Library::EvolutionData, GetData); + REGISTER_GETTER("EvolutionData", "const Species& get_NewSpecies() const property", PkmnLib::Library::EvolutionData, + GetNewSpecies); + REGISTER_GETTER("EvolutionData", "EvolutionMethod get_Method() const property", PkmnLib::Library::EvolutionData, + GetMethod); + REGISTER_GETTER("EvolutionData", "uint64 get_DataCount() const property", PkmnLib::Library::EvolutionData, + GetDataCount); + REGISTER_GETTER("EvolutionData", "const narray@ get_Data() const property", + PkmnLib::Library::EvolutionData, GetData); r = engine->RegisterObjectMethod("EvolutionData", "EffectParameter@ GetDataAt(uint64 index) const", asMETHOD(PkmnLib::Library::EvolutionData, GetDataAt), asCALL_THISCALL); Ensure(r >= 0); - - } void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) { diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp index ca345ab..3120cd5 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/NativeArray.hpp @@ -9,11 +9,9 @@ private: const T* _array; std::atomic _refCount; - void AddRef() { - _refCount++; - } + void AddRef() { _refCount++; } void Release() { - if (--_refCount <= 0){ + if (--_refCount <= 0) { delete this; } } @@ -27,20 +25,19 @@ public: [[nodiscard]] void* At(size_t index) { return _array->At(index).GetRaw(); } static void Register(asIScriptEngine* engine) { - Ensure(engine->RegisterObjectType("narray", sizeof(NativeArray), - asOBJ_REF | asOBJ_TEMPLATE) >= 0); + Ensure(engine->RegisterObjectType("narray", sizeof(NativeArray), asOBJ_REF | asOBJ_TEMPLATE) >= 0); - Ensure(engine->RegisterObjectBehaviour("narray", asBEHAVE_ADDREF, "void f()", - asMETHOD(NativeArray, AddRef), asCALL_THISCALL)); + Ensure(engine->RegisterObjectBehaviour("narray", asBEHAVE_ADDREF, "void f()", asMETHOD(NativeArray, AddRef), + asCALL_THISCALL)); Ensure(engine->RegisterObjectBehaviour("narray", asBEHAVE_RELEASE, "void f()", asMETHOD(NativeArray, Release), asCALL_THISCALL)); - Ensure(engine->RegisterObjectMethod("narray", "uint64 get_Length() const property", asMETHOD(NativeArray, Length), - asCALL_THISCALL) >= 0); + Ensure(engine->RegisterObjectMethod("narray", "uint64 get_Length() const property", + asMETHOD(NativeArray, Length), asCALL_THISCALL) >= 0); Ensure(engine->RegisterObjectMethod("narray", "const T@ At(uint64 index) const", asMETHOD(NativeArray, At), asCALL_THISCALL) >= 0); - Ensure(engine->RegisterObjectMethod("narray", "const T@ get_opIndex(uint64 index) const property", asMETHOD(NativeArray, At), - asCALL_THISCALL) >= 0); + Ensure(engine->RegisterObjectMethod("narray", "const T@ get_opIndex(uint64 index) const property", + asMETHOD(NativeArray, At), asCALL_THISCALL) >= 0); } };