Make Creature use smart pointers.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-02 16:20:47 +02:00
parent 1ef50fd3a6
commit 62583ecb17
6 changed files with 19 additions and 14 deletions

View File

@@ -44,7 +44,7 @@ export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const Creature
}
SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetBattle, Battle*);
SIMPLE_GET_FUNC(Creature, GetBattleSide, BattleSide*);
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetBattleSide, BattleSide*);
SIMPLE_GET_FUNC(Creature, IsOnBattleField, bool);
export const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().c_str(); }
export size_t CreatureLib_Creature_GetTypesCount(Creature* p) { return p->GetTypes().Count(); }

View File

@@ -8,6 +8,7 @@ export void CreatureLib_ExperienceLibrary_Destruct(const ExperienceLibrary* p) {
export uint8_t CreatureLib_ExperienceLibrary_HandleExperienceGain(const ExperienceLibrary* p, Creature* faintedMon,
Creature* opponents[], size_t opponentsCount) {
Try(auto set = std::unordered_set<Creature*>(opponents, opponents + opponentsCount);
p->HandleExperienceGain(faintedMon, set);)
Try(auto set = std::unordered_set<ArbUt::BorrowedPtr<Creature>>(opponentsCount);
for (size_t i = 0; i < opponentsCount;
i++) { set.insert(opponents[i]); } p->HandleExperienceGain(faintedMon, set);)
}