Update to new Arbutils
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-26 17:08:23 +02:00
parent f50f76e993
commit 48639eeee5
44 changed files with 177 additions and 200 deletions

View File

@@ -56,21 +56,21 @@ export BattleParty* const* CreatureLib_Battle_GetParties(const Battle* p) {
}
export Script* CreatureLib_Battle_GetVolatileScript(Battle* p, const char* key) {
return p->GetVolatileScript(ConstString::GetHash(key)).GetRaw();
return p->GetVolatileScript(ArbUt::StringView::CalculateHash(key)).GetRaw();
}
export uint8_t CreatureLib_Battle_AddVolatileScriptByName(Battle* p, const char* key) {
Try(p->AddVolatileScript(ConstString(key));)
Try(p->AddVolatileScript(ArbUt::StringView(key));)
}
export uint8_t CreatureLib_Battle_AddVolatileScript(Battle* p, Script* script) { Try(p->AddVolatileScript(script);) }
export uint8_t CreatureLib_Battle_RemoveVolatileScript(Battle* p, const char* key) {
Try(p->RemoveVolatileScript(ConstString::GetHash(key));)
Try(p->RemoveVolatileScript(ArbUt::StringView::CalculateHash(key));)
}
export uint8_t CreatureLib_Battle_RemoveVolatileScriptWithScript(Battle* p, Script* script) {
Try(p->RemoveVolatileScript(script);)
}
export bool CreatureLib_Battle_HasVolatileScript(Battle* p, const char* key) {
return p->HasVolatileScript(ConstString::GetHash(key));
return p->HasVolatileScript(ArbUt::StringView::CalculateHash(key));
}
export uint8_t CreatureLib_Battle_RegisterEventListener(Battle* p, void (*func)(const EventData*)) {

View File

@@ -36,12 +36,12 @@ SIMPLE_GET_FUNC(Creature, GetGender, CreatureLib::Library::Gender);
SIMPLE_GET_FUNC(Creature, GetColoring, uint8_t);
export bool CreatureLib_Creature_HasHeldItem(const Creature* p, const char* name) {
return p->HasHeldItem(ArbUt::CaseInsensitiveConstString(name));
return p->HasHeldItem(ArbUt::StringView(name));
}
export bool CreatureLib_Creature_HasHeldItemWithHash(const Creature* p, uint32_t hash) { return p->HasHeldItem(hash); }
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetHeldItem, const CreatureLib::Library::Item*);
export uint8_t CreatureLib_Creature_SetHeldItem(Creature* p, const char* name) {
Try(p->SetHeldItem(ArbUt::CaseInsensitiveConstString(name));)
Try(p->SetHeldItem(ArbUt::StringView(name));)
}
export uint8_t CreatureLib_Creature_SetHeldItemWithHash(Creature* p, uint32_t hash) { Try(p->SetHeldItem(hash);) }
export void CreatureLib_Creature_SetHeldItemFromItem(Creature* p, const CreatureLib::Library::Item* item) {
@@ -51,7 +51,7 @@ SIMPLE_GET_FUNC(Creature, GetCurrentHealth, uint32_t);
SIMPLE_GET_FUNC_SMART_PTR(Creature, GetBattle, Battle*);
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 const char* CreatureLib_Creature_GetNickname(Creature* p) { return p->GetNickname().data(); }
export bool CreatureLib_Creature_HasType(Creature* p, uint8_t type) { return p->HasType(type); }
SIMPLE_GET_FUNC(Creature, GetMaxHealth, uint32_t);
export uint8_t CreatureLib_Creature_ChangeLevelBy(Creature* p, int8_t level) { Try(p->ChangeLevelBy(level);) }
@@ -62,26 +62,26 @@ export uint8_t CreatureLib_Creature_Heal(Creature* p, uint32_t health, bool canR
Try(p->Heal(health, canRevive);)
}
export uint8_t CreatureLib_Creature_OverrideActiveTalent(Creature* p, const char* talent) {
Try(p->OverrideActiveTalent(ArbUt::CaseInsensitiveConstString(talent));)
Try(p->OverrideActiveTalent(ArbUt::StringView(talent));)
}
export uint8_t CreatureLib_Creature_AddExperience(Creature* p, uint32_t experience) {
Try(p->AddExperience(experience);)
}
export uint8_t CreatureLib_Creature_ClearVolatileScripts(Creature* p) { Try(p->ClearVolatileScripts();) }
export uint8_t CreatureLib_Creature_AddVolatileScriptByName(Creature* p, const char* scriptName) {
Try(p->AddVolatileScript(ArbUt::CaseInsensitiveConstString(scriptName));)
Try(p->AddVolatileScript(ArbUt::StringView(scriptName));)
}
export uint8_t CreatureLib_Creature_AddVolatileScript(Creature* p, Script* script) {
Try(p->AddVolatileScript(script);)
}
export uint8_t CreatureLib_Creature_RemoveVolatileScriptByName(Creature* p, const char* scriptName) {
Try(p->RemoveVolatileScript(ArbUt::CaseInsensitiveConstString(scriptName));)
Try(p->RemoveVolatileScript(ArbUt::StringView(scriptName));)
}
export uint8_t CreatureLib_Creature_RemoveVolatileScript(Creature* p, Script* script) {
Try(p->RemoveVolatileScript(script);)
}
export bool CreatureLib_Creature_HasVolatileScript(Creature* p, const char* scriptName) {
return p->HasVolatileScript(ArbUt::CaseInsensitiveConstString(scriptName));
return p->HasVolatileScript(ArbUt::StringView(scriptName));
}
export size_t CreatureLib_Creature_GetAttacksCount(Creature* p) { return p->GetAttacks().Count(); }
export LearnedAttack* const* CreatureLib_Creature_GetAttack(Creature* p, size_t index) {

View File

@@ -11,8 +11,7 @@ export const char* CreatureLib_Script_GetName(Script* p) { return p->GetName().c
export uint8_t CreatureLib_Script_OnBeforeTurn(Script* p, const BaseTurnChoice* choice) {
Try(p->OnBeforeTurn(choice));
}
export uint8_t CreatureLib_Script_ChangeAttack(Script* p, AttackTurnChoice* choice,
ArbUt::CaseInsensitiveConstString* outAttack) {
export uint8_t CreatureLib_Script_ChangeAttack(Script* p, AttackTurnChoice* choice, ArbUt::StringView* outAttack) {
Try(p->ChangeAttack(choice, outAttack));
}
export uint8_t CreatureLib_Script_PreventAttack(Script* p, ExecutingAttack* attack, bool* outResult) {

View File

@@ -11,5 +11,5 @@ export uint8_t CreatureLib_ScriptResolver_Initialize(ScriptResolver* p, BattleLi
};
export uint8_t CreatureLib_ScriptResolver_LoadScript(Script*& out, ScriptResolver* p, ScriptCategory category,
const char* scriptName) {
Try(out = p->LoadScript(category, ArbUt::CaseInsensitiveConstString(scriptName));)
Try(out = p->LoadScript(category, ArbUt::StringView(scriptName));)
};

View File

@@ -11,18 +11,17 @@ export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* na
Try({
std::unordered_set<uint32_t> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ArbUt::CaseInsensitiveConstString::GetHash(flags[i]));
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
}
ArbUt::List<EffectParameter*> effectParameterList(effectParameterCount);
for (size_t i = 0; i < effectParameterCount; i++) {
effectParameterList[i] = effectParameters[i];
}
auto effect =
new SecondaryEffect(effectChance, ArbUt::CaseInsensitiveConstString(effectName), effectParameterList);
auto effect = new SecondaryEffect(effectChance, ArbUt::StringView(effectName), effectParameterList);
out = new AttackData(ArbUt::CaseInsensitiveConstString(name), type, category, power, accuracy, baseUsage,
target, priority, effect, conversedFlags);
out = new AttackData(ArbUt::StringView(name), type, category, power, accuracy, baseUsage, target, priority,
effect, conversedFlags);
})
};
@@ -51,7 +50,7 @@ export const char* CreatureLib_AttackData_GetSecondaryEffectName(const AttackDat
}
export bool CreatureLib_AttackData_HasFlag(const AttackData* p, const char* key) {
return p->HasFlag(ArbUt::CaseInsensitiveConstString::GetHash(key));
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}
#undef SIMPLE_GET_FUNC

View File

@@ -2,7 +2,7 @@
#define BASELIBRARY(simpleName, fullname, returnType) \
export uint8_t simpleName##_Insert(fullname* p, const char* name, returnType* t) { \
Try(p->Insert(ArbUt::CaseInsensitiveConstString::GetHash(name), t);) \
Try(p->Insert(ArbUt::StringView::CalculateHash(name), t);) \
} \
\
export uint8_t simpleName##_InsertWithHash(fullname* p, uint32_t hashedKey, returnType* t) { \
@@ -10,14 +10,14 @@
} \
\
export uint8_t simpleName##_Delete(fullname* p, const char* name) { \
Try(p->Delete(ArbUt::CaseInsensitiveConstString::GetHash(name));) \
Try(p->Delete(ArbUt::StringView::CalculateHash(name));) \
} \
\
export uint8_t simpleName##_DeleteWithHash(fullname* p, uint32_t hashedKey) { Try(p->Delete(hashedKey);) } \
\
export bool simpleName##_TryGet(fullname* p, const char* name, const returnType*& out) { \
ArbUt::BorrowedPtr<const returnType> o; \
auto v = p->TryGet(ArbUt::CaseInsensitiveConstString::GetHash(name), o); \
auto v = p->TryGet(ArbUt::StringView::CalculateHash(name), o); \
out = o.operator->(); \
return v; \
} \
@@ -30,7 +30,7 @@
} \
\
export uint8_t simpleName##_Get(fullname* p, const char* name, const returnType*& out) { \
Try(out = p->Get(ArbUt::CaseInsensitiveConstString::GetHash(name)).operator->();) \
Try(out = p->Get(ArbUt::StringView::CalculateHash(name)).operator->();) \
} \
\
export uint8_t simpleName##_GetWithHash(fullname* p, uint32_t hashedKey, const returnType*& out) { \

View File

@@ -6,8 +6,8 @@ export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint
SpeciesVariant* defaultVariant, float genderRatio,
const char* growthRate, uint8_t captureRate) {
Try(out = new CreatureSpecies(id, ArbUt::CaseInsensitiveConstString(name), defaultVariant, genderRatio,
ArbUt::CaseInsensitiveConstString(growthRate), captureRate);)
Try(out = new CreatureSpecies(id, ArbUt::StringView(name), defaultVariant, genderRatio,
ArbUt::StringView(growthRate), captureRate);)
}
export void CreatureLib_CreatureSpecies_Destruct(const CreatureSpecies* p) { delete p; }
@@ -23,7 +23,7 @@ export const char* CreatureLib_CreatureSpecies_GetGrowthRate(const CreatureSpeci
return p->GetGrowthRate().c_str();
}
export bool CreatureLib_CreatureSpecies_HasVariant(const CreatureSpecies* p, const char* name) {
return p->HasVariant(ArbUt::CaseInsensitiveConstString::GetHash(name));
return p->HasVariant(ArbUt::StringView::CalculateHash(name));
}
export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies* p, uint32_t hash) {
return p->HasVariant(hash);
@@ -31,7 +31,7 @@ export bool CreatureLib_CreatureSpecies_HasVariantWithHash(const CreatureSpecies
export bool CreatureLib_CreatureSpecies_TryGetVariant(const CreatureSpecies* p, const char* name,
const SpeciesVariant*& out) {
ArbUt::BorrowedPtr<const SpeciesVariant> o;
auto res = p->TryGetVariant(ArbUt::CaseInsensitiveConstString::GetHash(name), o);
auto res = p->TryGetVariant(ArbUt::StringView::CalculateHash(name), o);
out = o.GetRaw();
return res;
}
@@ -45,14 +45,14 @@ export bool CreatureLib_CreatureSpecies_TryGetVariantWithHash(const CreatureSpec
export uint8_t CreatureLib_CreatureSpecies_GetVariant(const SpeciesVariant*& out, const CreatureSpecies* p,
const char* name) {
Try(out = p->GetVariant(ArbUt::CaseInsensitiveConstString::GetHash(name)).GetRaw();)
Try(out = p->GetVariant(ArbUt::StringView::CalculateHash(name)).GetRaw();)
}
export uint8_t CreatureLib_CreatureSpecies_GetVariantWithHash(const SpeciesVariant* out, const CreatureSpecies* p,
uint32_t hash) {
Try(out = p->GetVariant(hash).GetRaw();)
}
export uint8_t CreatureLib_CreatureSpecies_SetVariant(CreatureSpecies* p, const char* name, SpeciesVariant* variant) {
Try(p->SetVariant(ArbUt::CaseInsensitiveConstString(name), variant);)
Try(p->SetVariant(ArbUt::StringView(name), variant);)
}
#undef SIMPLE_GET_FUNC

View File

@@ -6,7 +6,7 @@ export EffectParameter* CreatureLib_EffectParameter_FromBool(bool b) { return ne
export EffectParameter* CreatureLib_EffectParameter_FromInt(int64_t i) { return new EffectParameter(i); }
export EffectParameter* CreatureLib_EffectParameter_FromFloat(float f) { return new EffectParameter(f); }
export EffectParameter* CreatureLib_EffectParameter_FromString(const char* c) {
return new EffectParameter(ArbUt::CaseInsensitiveConstString(c));
return new EffectParameter(ArbUt::StringView(c));
}
export void CreatureLib_EffectParameter_Destruct(const EffectParameter* p) { delete p; }

View File

@@ -10,7 +10,7 @@ export void CreatureLib_GrowthRateLibrary_Destruct(GrowthRateLibrary* p) { delet
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevel(uint8_t& out, GrowthRateLibrary* library,
const char* growthRate, uint32_t experience) {
Try(out = library->CalculateLevel(ArbUt::CaseInsensitiveConstString::GetHash(growthRate), experience);)
Try(out = library->CalculateLevel(ArbUt::StringView::CalculateHash(growthRate), experience);)
}
export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(uint8_t& out, GrowthRateLibrary* library,
uint32_t growthRateHash, uint32_t experience) {
@@ -19,7 +19,7 @@ export uint8_t CreatureLib_GrowthRateLibrary_CalculateLevelWithHash(uint8_t& out
export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperience(uint32_t& out, GrowthRateLibrary* library,
const char* growthRate, uint8_t level) {
Try(out = library->CalculateExperience(ArbUt::CaseInsensitiveConstString::GetHash(growthRate), level);)
Try(out = library->CalculateExperience(ArbUt::StringView::CalculateHash(growthRate), level);)
}
export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(uint32_t& out, GrowthRateLibrary* library,
@@ -28,7 +28,7 @@ export uint8_t CreatureLib_GrowthRateLibrary_CalculateExperienceWithHash(uint32_
}
export uint8_t CreatureLib_GrowthRateLibrary_AddGrowthRate(GrowthRateLibrary* library, const char* growthRateName,
GrowthRate* growthRate) {
Try(library->AddGrowthRate(ArbUt::CaseInsensitiveConstString::GetHash(growthRateName), growthRate);)
Try(library->AddGrowthRate(ArbUt::StringView::CalculateHash(growthRateName), growthRate);)
}
export uint8_t CreatureLib_GrowthRateLibrary_AddGrowthRateWithHash(GrowthRateLibrary* library, uint32_t growthRateHash,

View File

@@ -1,16 +1,15 @@
#include "../../src/Library/Items/Item.hpp"
#include "../Core.hpp"
using namespace CreatureLib::Library;
using ConstString = ArbUt::CaseInsensitiveConstString;
export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory,
int32_t price, const char* flags[], size_t flagsCount) {
std::unordered_set<uint32_t> conversedFlags(flagsCount);
for (size_t i = 0; i < flagsCount; i++) {
conversedFlags.insert(ConstString::GetHash(flags[i]));
conversedFlags.insert(ArbUt::StringView::CalculateHash(flags[i]));
}
return new Item(ConstString(name), category, battleCategory, price, conversedFlags);
return new Item(ArbUt::StringView(name), category, battleCategory, price, conversedFlags);
};
export void CreatureLib_Item_Destruct(const Item* p) { delete p; }
@@ -23,6 +22,8 @@ SIMPLE_GET_FUNC(Item, GetCategory, ItemCategory);
SIMPLE_GET_FUNC(Item, GetBattleCategory, BattleItemCategory);
SIMPLE_GET_FUNC(Item, GetPrice, int32_t);
export bool CreatureLib_Item_HasFlag(const Item* p, const char* key) { return p->HasFlag(ConstString::GetHash(key)); }
export bool CreatureLib_Item_HasFlag(const Item* p, const char* key) {
return p->HasFlag(ArbUt::StringView::CalculateHash(key));
}
#undef SIMPLE_GET_FUNC

View File

@@ -9,21 +9,20 @@ export SpeciesVariant* CreatureLib_SpeciesVariant_Construct(
uint16_t baseMagicalDefense, uint16_t baseSpeed, const char* talents[], size_t talentsLength,
const char* secretTalents[], size_t secretTalentsLength, const LearnableAttacks* attacks) {
auto talentsWrapped = ArbUt::List<ArbUt::CaseInsensitiveConstString>(talentsLength);
auto talentsWrapped = ArbUt::List<ArbUt::StringView>(talentsLength);
for (size_t i = 0; i < talentsLength; i++) {
talentsWrapped.Append(ArbUt::CaseInsensitiveConstString(talents[i]));
talentsWrapped.Append(ArbUt::StringView(talents[i]));
}
auto secretTalentsWrapped = ArbUt::List<ArbUt::CaseInsensitiveConstString>(secretTalentsLength);
auto secretTalentsWrapped = ArbUt::List<ArbUt::StringView>(secretTalentsLength);
for (size_t i = 0; i < secretTalentsLength; i++) {
secretTalentsWrapped.Append(ArbUt::CaseInsensitiveConstString(secretTalents[i]));
secretTalentsWrapped.Append(ArbUt::StringView(secretTalents[i]));
}
return new SpeciesVariant(ArbUt::CaseInsensitiveConstString(name), height, weight, baseExperience,
ArbUt::List<uint8_t>(types, types + typeLength),
CreatureLib::Library::StatisticSet<uint16_t>(baseHealth, baseAttack, baseDefense,
baseMagicalAttack, baseMagicalDefense,
baseSpeed),
talentsWrapped, secretTalentsWrapped, attacks);
return new SpeciesVariant(
ArbUt::StringView(name), height, weight, baseExperience, ArbUt::List<uint8_t>(types, types + typeLength),
CreatureLib::Library::StatisticSet<uint16_t>(baseHealth, baseAttack, baseDefense, baseMagicalAttack,
baseMagicalDefense, baseSpeed),
talentsWrapped, secretTalentsWrapped, attacks);
}
export void CreatureLib_SpeciesVariant_Destruct(SpeciesVariant* p) { delete p; }

View File

@@ -9,14 +9,14 @@ export TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) {
export void CreatureLib_TypeLibrary_Destruct(const TypeLibrary* p) { delete p; }
export uint8_t CreatureLib_TypeLibrary_GetTypeId(uint8_t& out, const TypeLibrary* p, const char* type) {
Try(out = p->GetTypeId(ArbUt::CaseInsensitiveConstString::GetHash(type));)
Try(out = p->GetTypeId(ArbUt::StringView::CalculateHash(type));)
}
export uint8_t CreatureLib_TypeLibrary_GetTypeIdWithHash(uint8_t& out, const TypeLibrary* p, uint32_t type) {
Try(out = p->GetTypeId(type);)
}
export uint8_t CreatureLib_TypeLibrary_RegisterType(uint8_t& out, TypeLibrary* p, const char* type) {
Try(out = p->RegisterType(ArbUt::CaseInsensitiveConstString::GetHash(type));)
Try(out = p->RegisterType(ArbUt::StringView::CalculateHash(type));)
}
export uint8_t CreatureLib_TypeLibrary_RegisterTypeWithHash(uint8_t& out, TypeLibrary* p, uint32_t type) {
Try(out = p->RegisterType(type);)