C interfaces for GrowthRateLibrary and TypeLibrary/
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-29 16:06:47 +01:00
parent 70ad3eb838
commit f95c625971
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#include "../../src/Library/GrowthRates/GrowthRateLibrary.hpp"
#define export extern "C"
export CreatureLib::Library::GrowthRateLibrary* CreatureLib_GrowthRateLibrary_Construct(size_t initialCapacity) {
return new CreatureLib::Library::GrowthRateLibrary(initialCapacity);
}
export void CreatureLib_GrowthRateLibrary_Destruct(CreatureLib::Library::GrowthRateLibrary* p) { delete p; }
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevel(CreatureLib::Library::GrowthRateLibrary* library,
const char* growthRate, uint32_t experience) {
return library->CalculateLevel(Arbutils::CaseInsensitiveConstString::GetHash(growthRate), experience);
}
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(CreatureLib::Library::GrowthRateLibrary* library,
uint32_t growthRateHash, uint32_t experience) {
return library->CalculateLevel(growthRateHash, experience);
}
export uint32_t CreatureLib_GrowthRateLibrary_CalculateExperience(CreatureLib::Library::GrowthRateLibrary* library,
const char* growthRate, uint8_t level) {
return library->CalculateExperience(Arbutils::CaseInsensitiveConstString::GetHash(growthRate), level);
}
export uint32_t
CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(CreatureLib::Library::GrowthRateLibrary* library,
uint32_t growthRateHash, uint8_t level) {
return library->CalculateExperience(growthRateHash, level);
}
export void CreatureLib_GrowthRateLibrary_AddGrowthRate(CreatureLib::Library::GrowthRateLibrary* library,
const char* growthRateName,
CreatureLib::Library::GrowthRate* growthRate) {
return library->AddGrowthRate(Arbutils::CaseInsensitiveConstString::GetHash(growthRateName), growthRate);
}
export void CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(CreatureLib::Library::GrowthRateLibrary* library,
uint32_t growthRateHash,
CreatureLib::Library::GrowthRate* growthRate) {
return library->AddGrowthRate(growthRateHash, growthRate);
}

View File

@ -0,0 +1,37 @@
#include "../../src/Library/TypeLibrary.hpp"
#define export extern "C"
export CreatureLib::Library::TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) {
return new CreatureLib::Library::TypeLibrary(initialCapacity);
};
export void CreatureLib_TypeLibrary_Destruct(const CreatureLib::Library::TypeLibrary* p) { delete p; }
export uint8_t CreatureLib_TypeLibrary_GetTypeId(const CreatureLib::Library::TypeLibrary* p, const char* type) {
return p->GetTypeId(Arbutils::CaseInsensitiveConstString::GetHash(type));
}
export uint8_t CreatureLib_TypeLibrary_GetTypeIdWithHash(const CreatureLib::Library::TypeLibrary* p, uint32_t type) {
return p->GetTypeId(type);
}
export uint8_t CreatureLib_TypeLibrary_RegisterType(CreatureLib::Library::TypeLibrary* p, const char* type) {
return p->RegisterType(Arbutils::CaseInsensitiveConstString::GetHash(type));
}
export uint8_t CreatureLib_TypeLibrary_RegisterTypeWithHash(CreatureLib::Library::TypeLibrary* p, uint32_t type) {
return p->RegisterType(type);
}
export void CreatureLib_TypeLibrary_SetEffectiveness(CreatureLib::Library::TypeLibrary* p, uint8_t attacking,
uint8_t defensive, float effectiveness) {
p->SetEffectiveness(attacking, defensive, effectiveness);
}
export float CreatureLib_TypeLibrary_GetSingleEffectiveness(CreatureLib::Library::TypeLibrary* p, uint8_t attacking,
uint8_t defensive) {
return p->GetSingleEffectiveness(attacking, defensive);
}
export float CreatureLib_TypeLibrary_GetEffectiveness(CreatureLib::Library::TypeLibrary* p, uint8_t attacking,
uint8_t defensive[], size_t defensiveCount) {
return p->GetEffectiveness(attacking, std::vector<uint8_t>(defensive, defensive + defensiveCount));
}