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

View File

@@ -49,16 +49,16 @@ export const EvolutionData* PkmnLib_Evolution_CreateTradeWithSpeciesEvolution(co
}
export const EvolutionData* PkmnLib_Evolution_CreateCustomEvolution(const CreatureLib::Library::EffectParameter** data,
size_t dataLength, const PokemonSpecies* into) {
auto list = ArbUt::List<const CreatureLib::Library::EffectParameter*>(data, data + dataLength);
auto list = std::vector<const CreatureLib::Library::EffectParameter*>(data, data + dataLength);
return EvolutionData::CreateCustomEvolution(list, into);
}
export EvolutionMethod PkmnLib_Evolution_GetMethod(const EvolutionData* data) { return data->GetMethod(); }
export const PokemonSpecies* PkmnLib_Evolution_GetNewSpecies(const EvolutionData* data) {
return data->GetNewSpecies();
return data->GetNewSpecies().GetRaw();
}
export size_t PkmnLib_Evolution_GetDataCount(const EvolutionData* data) { return data->GetDataCount(); }
export uint8_t PkmnLib_Evolution_GetData(const EvolutionData* data, size_t index,
const CreatureLib::Library::EffectParameter*& out) {
Try(out = data->GetData(index));
Try(out = data->GetData(index).GetRaw());
}

View File

@@ -11,7 +11,7 @@ export uint8_t PkmnLib_NatureLibrary_LoadNature(NatureLibrary* p, const char* na
Try(p->LoadNature(ArbUt::CaseInsensitiveConstString(name), nature);)
}
export uint8_t PkmnLib_NatureLibrary_GetNatureByName(NatureLibrary* p, const char* name, const Nature*& out) {
Try(out = p->GetNatureByName(ArbUt::CaseInsensitiveConstString(name)));
Try(out = p->GetNatureByName(ArbUt::CaseInsensitiveConstString(name)).GetRaw());
}
export const char* PkmnLib_NatureLibrary_GetRandomNatureName(NatureLibrary* p, ArbUt::Random* rand) {

View File

@@ -12,5 +12,5 @@ export uint8_t PkmnLib_PokemonLibrary_Construct(PokemonLibrary*& out, PkmnLib::L
export void PkmnLib_PokemonLibrary_Destruct(const PokemonLibrary* p) { delete p; }
export const NatureLibrary* PkmnLib_PokemonLibrary_GetNatureLibrary(const PokemonLibrary* p) {
return p->GetNatureLibrary();
return p->GetNatureLibrary().GetRaw();
}

View File

@@ -24,5 +24,5 @@ export void PkmnLib_PokemonSpecies_AddEvolution(PokemonSpecies* p, EvolutionData
export size_t PkmnLib_PokemonSpecies_GetEvolutionCount(const PokemonSpecies* p) { return p->GetEvolutions().Count(); }
export uint8_t PkmnLib_PokemonSpecies_GetEvolution(const PokemonSpecies* p, size_t index, const EvolutionData*& out) {
Try(out = p->GetEvolutions().At(index));
Try(out = p->GetEvolutions().At(index).GetRaw());
}