Smart pointers for most library and battle classes.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-02 20:37:21 +02:00
parent 1d1dc877a0
commit 2d3a2fc63b
22 changed files with 91 additions and 89 deletions

View File

@@ -8,8 +8,8 @@ export uint8_t PkmnLib_ExperienceLibrary_HandleExperienceGain(ExperienceLibrary*
CreatureLib::Battling::Creature* faintedMon,
CreatureLib::Battling::Creature* const* opponents,
size_t numberOfOpponents) {
Try(p->HandleExperienceGain(
faintedMon, std::unordered_set<CreatureLib::Battling::Creature*>(opponents, opponents + numberOfOpponents));)
Try(p->HandleExperienceGain(faintedMon, std::unordered_set<ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>>(
opponents, opponents + numberOfOpponents));)
}
export void PkmnLib_ExperienceLibrary_Destruct(ExperienceLibrary* p) { delete p; }

View File

@@ -12,7 +12,7 @@ export Pokemon* PkmnLib_Pokemon_Construct(const BattleLibrary* library, const Pk
uint8_t spIv, uint8_t hpEv, uint8_t attEv, uint8_t defEv, uint8_t sAtEv,
uint8_t sDeEv, uint8_t spEv, const PkmnLib::Library::Nature* nature) {
std::string nick(nickname);
ArbUt::List<CreatureLib::Battling::LearnedAttack*> cMoves(moves, moves + moveCount);
std::vector<CreatureLib::Battling::LearnedAttack*> cMoves(moves, moves + moveCount);
return new Pokemon(library, species, forme, level, experience, uid, gender, coloring, heldItem, nick,
CreatureLib::Library::TalentIndex(hiddenAbility, abilityIndex), cMoves,
@@ -24,9 +24,11 @@ export void PkmnLib_Pokemon_Destruct(const Pokemon* p) { delete p; }
#define SIMPLE_GET_FUNC(type, name, returnType) \
export returnType PkmnLib_##type##_##name(const PkmnLib::Battling::type* p) { return p->name(); }
#define SIMPLE_GET_FUNC_SMART_PTR(type, name, returnType) \
export returnType PkmnLib_##type##_##name(const PkmnLib::Battling::type* p) { return p->name().operator->(); }
SIMPLE_GET_FUNC(Pokemon, IsShiny, bool)
SIMPLE_GET_FUNC(Pokemon, GetNature, const PkmnLib::Library::Nature*)
SIMPLE_GET_FUNC_SMART_PTR(Pokemon, GetNature, const PkmnLib::Library::Nature*)
#undef SIMPLE_GET_FUNC
@@ -35,4 +37,7 @@ export uint8_t PkmnLib_Pokemon_GetIndividualValue(const Pokemon* p, CreatureLib:
}
export uint8_t PkmnLib_Pokemon_GetEffortValue(const Pokemon* p, CreatureLib::Library::Statistic stat) {
return p->GetEffortValue(stat);
}
}
#undef SIMPLE_GET_FUNC
#undef SIMPLE_GET_FUNC_SMART_PTR