Style fixes.
continuous-integration/drone/push Build is failing Details
continuous-integration/drone Build is failing Details

This commit is contained in:
Deukhoofd 2021-09-26 10:53:26 +02:00
parent 4841590c17
commit accf582a51
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
8 changed files with 51 additions and 42 deletions

View File

@ -74,6 +74,6 @@ export const PokemonSpecies* PkmnLib_EvolutionData_GetNewSpecies(const Evolution
}
export size_t PkmnLib_EvolutionData_GetDataCount(const EvolutionData* data) { return data->GetDataCount(); }
export uint8_t PkmnLib_EvolutionData_GetDataAt(const EvolutionData* data, size_t index,
const CreatureLib::Library::EffectParameter*& out) {
const CreatureLib::Library::EffectParameter*& out) {
Try(out = data->GetDataAt(index).GetRaw());
}

View File

@ -68,7 +68,6 @@ namespace PkmnLib::Battling {
CreatePokemon& IsAllowedExperienceGain(bool value);
CreatePokemon& WithNickname(const std::string& nickname);
Pokemon* Build() {
auto rand = ArbUt::Random();
return Build(rand);

View File

@ -38,7 +38,7 @@ private:
auto current = idEnd;
while (true) {
current = FindNextNonSpace(metadataString, current);
if (current >= metadataString.length()){
if (current >= metadataString.length()) {
break;
}
ParseParameter(metadataString, current);
@ -61,7 +61,7 @@ private:
}
auto value = metadataString.substr(start, current - start);
_parameters.Insert(name, value);
if (isQuoted){
if (isQuoted) {
current += 1;
}
}

View File

@ -42,10 +42,14 @@ void RegisterPokemonClass::RegisterMoveLearnMethod(asIScriptEngine* engine) {
void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("LearnedMove", "const MoveData@ get_MoveData() const property", CreatureLib::Battling::LearnedAttack, GetAttack);
REGISTER_GETTER("LearnedMove", "uint8 get_MaxUses() const property", CreatureLib::Battling::LearnedAttack, GetMaxUses);
REGISTER_GETTER("LearnedMove", "uint8 get_RemainingUses() const property", CreatureLib::Battling::LearnedAttack, GetRemainingUses);
REGISTER_GETTER("LearnedMove", "Gender get_LearnMethod() const property", CreatureLib::Battling::LearnedAttack, GetLearnMethod);
REGISTER_GETTER("LearnedMove", "const MoveData@ get_MoveData() const property",
CreatureLib::Battling::LearnedAttack, GetAttack);
REGISTER_GETTER("LearnedMove", "uint8 get_MaxUses() const property", CreatureLib::Battling::LearnedAttack,
GetMaxUses);
REGISTER_GETTER("LearnedMove", "uint8 get_RemainingUses() const property", CreatureLib::Battling::LearnedAttack,
GetRemainingUses);
REGISTER_GETTER("LearnedMove", "Gender get_LearnMethod() const property", CreatureLib::Battling::LearnedAttack,
GetLearnMethod);
}
static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& str) {
@ -103,7 +107,7 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
GetMoves);
auto r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const constString &in name) const",
asFUNCTION(HasHeldItem), asCALL_CDECL_OBJFIRST);
asFUNCTION(HasHeldItem), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const constString &in name)",
asFUNCTION(SetHeldItemWrapper), asCALL_CDECL_OBJFIRST);

View File

@ -35,10 +35,10 @@ void RegisterTurnChoices::RegisterMoveTurnChoice(asIScriptEngine* engine) {
REGISTER_EXPLICIT_GETTER("MoveTurnChoice", "Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property",
CreatureLib::Battling::AttackTurnChoice, GetAttack);
REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property",
CreatureLib::Battling::AttackTurnChoice, GetPriority);
REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property", CreatureLib::Battling::AttackTurnChoice,
GetAttack);
REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property", CreatureLib::Battling::AttackTurnChoice,
GetPriority);
r = engine->RegisterObjectMethod(
"BaseTurnChoice", "MoveTurnChoice@ opCast()",
@ -56,11 +56,13 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("SwitchTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("SwitchTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::SwitchTurnChoice, GetKind);
REGISTER_GETTER("SwitchTurnChoice", "TurnChoiceKind get_Kind() const property",
CreatureLib::Battling::SwitchTurnChoice, GetKind);
REGISTER_EXPLICIT_GETTER("SwitchTurnChoice", "const Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
REGISTER_GETTER("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property", CreatureLib::Battling::SwitchTurnChoice, GetNewCreature);
REGISTER_GETTER("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property",
CreatureLib::Battling::SwitchTurnChoice, GetNewCreature);
r = engine->RegisterObjectMethod(
"BaseTurnChoice", "SwitchTurnChoice@ opCast()",
@ -76,7 +78,8 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
void RegisterTurnChoices::RegisterFleeTurnChoice(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("FleeTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("FleeTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::FleeTurnChoice, GetKind);
REGISTER_GETTER("FleeTurnChoice", "TurnChoiceKind get_Kind() const property", CreatureLib::Battling::FleeTurnChoice,
GetKind);
REGISTER_EXPLICIT_GETTER("FleeTurnChoice", "const Pokemon@ get_User() const property",
CreatureLib::Battling::BaseTurnChoice, GetUser,
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);

View File

@ -38,6 +38,4 @@ void RegisterEffectParameter::Register(asIScriptEngine* engine) {
asFUNCTIONPR(AsString, (const CreatureLib::Library::EffectParameter*), const ArbUt::StringView&),
asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
}

View File

@ -44,11 +44,15 @@ static const PkmnLib::Library::PokemonForme* GetFormeWrapper(const std::string&
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("Species", "const constString& get_Name() const property", CreatureLib::Library::CreatureSpecies, GetName);
REGISTER_GETTER("Species", "const constString& get_Name() const property", CreatureLib::Library::CreatureSpecies,
GetName);
REGISTER_GETTER("Species", "uint16 get_Id() const property", CreatureLib::Library::CreatureSpecies, GetId);
REGISTER_GETTER("Species", "float get_GenderRate() const property", CreatureLib::Library::CreatureSpecies, GetGenderRate);
REGISTER_GETTER("Species", "uint8 get_CaptureRate() const property", CreatureLib::Library::CreatureSpecies, GetCaptureRate);
REGISTER_GETTER("Species", "const Forme@ get_DefaultForme() const property", PkmnLib::Library::PokemonSpecies, GetDefaultForme);
REGISTER_GETTER("Species", "float get_GenderRate() const property", CreatureLib::Library::CreatureSpecies,
GetGenderRate);
REGISTER_GETTER("Species", "uint8 get_CaptureRate() const property", CreatureLib::Library::CreatureSpecies,
GetCaptureRate);
REGISTER_GETTER("Species", "const Forme@ get_DefaultForme() const property", PkmnLib::Library::PokemonSpecies,
GetDefaultForme);
r = engine->RegisterObjectMethod("Species", "Gender GetRandomGender() const",
asMETHOD(PkmnLib::Library::PokemonSpecies, GetRandomGender), asCALL_THISCALL);
@ -65,10 +69,12 @@ const ArbUt::StringView& GetAbility(PkmnLib::Library::PokemonForme* p, bool hidd
void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("Forme", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("Forme", "const constString& get_Name() const property", CreatureLib::Library::SpeciesVariant, GetName);
REGISTER_GETTER("Forme", "const constString& get_Name() const property", CreatureLib::Library::SpeciesVariant,
GetName);
REGISTER_GETTER("Forme", "float get_Weight() const property", CreatureLib::Library::SpeciesVariant, GetWeight);
REGISTER_GETTER("Forme", "float get_Height() const property", CreatureLib::Library::SpeciesVariant, GetHeight);
REGISTER_GETTER("Forme", "uint get_BaseExperience() const property", CreatureLib::Library::SpeciesVariant, GetBaseExperience);
REGISTER_GETTER("Forme", "uint get_BaseExperience() const property", CreatureLib::Library::SpeciesVariant,
GetBaseExperience);
REGISTER_GETTER("Forme", "int get_TypeCount() const property", CreatureLib::Library::SpeciesVariant, GetTypeCount);
r = engine->RegisterObjectMethod("Forme", "uint8 GetType(int index) const",
@ -92,16 +98,18 @@ void RegisterSpeciesTypes::RegisterEvolutionData(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("EvolutionData", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
REGISTER_GETTER("EvolutionData", "const Species& get_NewSpecies() const property", PkmnLib::Library::EvolutionData, GetNewSpecies);
REGISTER_GETTER("EvolutionData", "EvolutionMethod get_Method() const property", PkmnLib::Library::EvolutionData, GetMethod);
REGISTER_GETTER("EvolutionData", "uint64 get_DataCount() const property", PkmnLib::Library::EvolutionData, GetDataCount);
REGISTER_GETTER("EvolutionData", "const narray<EffectParameter@>@ get_Data() const property", PkmnLib::Library::EvolutionData, GetData);
REGISTER_GETTER("EvolutionData", "const Species& get_NewSpecies() const property", PkmnLib::Library::EvolutionData,
GetNewSpecies);
REGISTER_GETTER("EvolutionData", "EvolutionMethod get_Method() const property", PkmnLib::Library::EvolutionData,
GetMethod);
REGISTER_GETTER("EvolutionData", "uint64 get_DataCount() const property", PkmnLib::Library::EvolutionData,
GetDataCount);
REGISTER_GETTER("EvolutionData", "const narray<EffectParameter@>@ get_Data() const property",
PkmnLib::Library::EvolutionData, GetData);
r = engine->RegisterObjectMethod("EvolutionData", "EffectParameter@ GetDataAt(uint64 index) const",
asMETHOD(PkmnLib::Library::EvolutionData, GetDataAt), asCALL_THISCALL);
Ensure(r >= 0);
}
void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) {

View File

@ -9,11 +9,9 @@ private:
const T* _array;
std::atomic<u64> _refCount;
void AddRef() {
_refCount++;
}
void AddRef() { _refCount++; }
void Release() {
if (--_refCount <= 0){
if (--_refCount <= 0) {
delete this;
}
}
@ -27,20 +25,19 @@ public:
[[nodiscard]] void* At(size_t index) { return _array->At(index).GetRaw(); }
static void Register(asIScriptEngine* engine) {
Ensure(engine->RegisterObjectType("narray<class T>", sizeof(NativeArray),
asOBJ_REF | asOBJ_TEMPLATE) >= 0);
Ensure(engine->RegisterObjectType("narray<class T>", sizeof(NativeArray), asOBJ_REF | asOBJ_TEMPLATE) >= 0);
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_ADDREF, "void f()",
asMETHOD(NativeArray, AddRef), asCALL_THISCALL));
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_ADDREF, "void f()", asMETHOD(NativeArray, AddRef),
asCALL_THISCALL));
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_RELEASE, "void f()",
asMETHOD(NativeArray, Release), asCALL_THISCALL));
Ensure(engine->RegisterObjectMethod("narray<T>", "uint64 get_Length() const property", asMETHOD(NativeArray, Length),
asCALL_THISCALL) >= 0);
Ensure(engine->RegisterObjectMethod("narray<T>", "uint64 get_Length() const property",
asMETHOD(NativeArray, Length), asCALL_THISCALL) >= 0);
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ At(uint64 index) const", asMETHOD(NativeArray, At),
asCALL_THISCALL) >= 0);
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ get_opIndex(uint64 index) const property", asMETHOD(NativeArray, At),
asCALL_THISCALL) >= 0);
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ get_opIndex(uint64 index) const property",
asMETHOD(NativeArray, At), asCALL_THISCALL) >= 0);
}
};