Implements extern growthrate that uses function pointers.

This commit is contained in:
2020-03-04 15:00:57 +01:00
parent 81e173ec1a
commit 6bffea953d
3 changed files with 25 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
#include "../../src/Library/GrowthRates/GrowthRate.hpp"
#include "../../src/Library/GrowthRates/ExternGrowthRate.hpp"
#include "../../src/Library/GrowthRates/LookupGrowthRate.hpp"
#define export extern "C"
using namespace CreatureLib::Library;
@@ -8,6 +9,11 @@ export GrowthRate* CreatureLib_LookupGrowthRate_Construct(uint32_t experiencePer
return new LookupGrowthRate(exp);
};
export GrowthRate* CreatureLib_ExternGrowthRate_Construct(uint8_t (*calcLevel)(uint32_t),
uint32_t (*calcExperience)(uint8_t)) {
return new ExternGrowthRate(calcLevel, calcExperience);
};
export void CreatureLib_GrowthRate_Destruct(const GrowthRate* p) { delete p; }
export uint8_t CreatureLib_GrowthRate_CalculateLevel(const GrowthRate* p, uint32_t experience) {