Replace most collections with Arbutils collections for more safety.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-03-22 19:21:40 +01:00
parent f190121e74
commit 27288563cd
40 changed files with 234 additions and 226 deletions

View File

@@ -5,7 +5,7 @@
using namespace CreatureLib::Library;
export GrowthRate* CreatureLib_LookupGrowthRate_Construct(uint32_t experiencePerLevel[], size_t count) {
std::vector<uint32_t> exp(experiencePerLevel, experiencePerLevel + count);
Arbutils::Collections::List<uint32_t> exp(experiencePerLevel, experiencePerLevel + count);
return new LookupGrowthRate(exp);
};

View File

@@ -13,8 +13,8 @@ export void CreatureLib_LearnableAttacks_AddLevelMove(LearnableAttacks* p, uint8
}
export const AttackData* const* CreatureLib_LearnableAttacks_GetAttacksForLevel(LearnableAttacks* p, uint8_t level) {
return p->GetAttacksForLevel(level).data();
return p->GetAttacksForLevel(level).RawData();
}
export size_t CreatureLib_LearnableAttacks_GetAttacksForLevelCount(LearnableAttacks* p, uint8_t level) {
return p->GetAttacksForLevel(level).size();
return p->GetAttacksForLevel(level).Count();
}

View File

@@ -10,17 +10,17 @@ export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
uint16_t baseMagicalDefense, uint8_t baseSpeed, const char* talents[], size_t talentsLength,
const char* secretTalents[], size_t secretTalentsLength, const LearnableAttacks* attacks) {
auto talentsWrapped = std::vector<ConstString>(talentsLength);
auto talentsWrapped = Arbutils::Collections::List<ConstString>(talentsLength);
for (size_t i = 0; i < talentsLength; i++) {
talentsWrapped[i] = ConstString(talents[i]);
}
auto secretTalentsWrapped = std::vector<ConstString>(secretTalentsLength);
auto secretTalentsWrapped = Arbutils::Collections::List<ConstString>(secretTalentsLength);
for (size_t i = 0; i < secretTalentsLength; i++) {
secretTalentsWrapped[i] = ConstString(secretTalents[i]);
}
return new SpeciesVariant(Arbutils::CaseInsensitiveConstString(name), height, weight, baseExperience,
std::vector<uint8_t>(types, types + typeLength),
Arbutils::Collections::List<uint8_t>(types, types + typeLength),
CreatureLib::Library::StatisticSet<uint16_t>(baseHealth, baseAttack, baseDefense,
baseMagicalAttack, baseMagicalDefense,
baseSpeed),

View File

@@ -33,5 +33,5 @@ export float CreatureLib_TypeLibrary_GetSingleEffectiveness(TypeLibrary* p, uint
export float CreatureLib_TypeLibrary_GetEffectiveness(TypeLibrary* p, uint8_t attacking, uint8_t defensive[],
size_t defensiveCount) {
return p->GetEffectiveness(attacking, std::vector<uint8_t>(defensive, defensive + defensiveCount));
return p->GetEffectiveness(attacking, List<uint8_t>(defensive, defensive + defensiveCount));
}