Style fixes.
This commit is contained in:
parent
4841590c17
commit
accf582a51
|
@ -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 size_t PkmnLib_EvolutionData_GetDataCount(const EvolutionData* data) { return data->GetDataCount(); }
|
||||||
export uint8_t PkmnLib_EvolutionData_GetDataAt(const EvolutionData* data, size_t index,
|
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());
|
Try(out = data->GetDataAt(index).GetRaw());
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ namespace PkmnLib::Battling {
|
||||||
CreatePokemon& IsAllowedExperienceGain(bool value);
|
CreatePokemon& IsAllowedExperienceGain(bool value);
|
||||||
CreatePokemon& WithNickname(const std::string& nickname);
|
CreatePokemon& WithNickname(const std::string& nickname);
|
||||||
|
|
||||||
|
|
||||||
Pokemon* Build() {
|
Pokemon* Build() {
|
||||||
auto rand = ArbUt::Random();
|
auto rand = ArbUt::Random();
|
||||||
return Build(rand);
|
return Build(rand);
|
||||||
|
|
|
@ -38,7 +38,7 @@ private:
|
||||||
auto current = idEnd;
|
auto current = idEnd;
|
||||||
while (true) {
|
while (true) {
|
||||||
current = FindNextNonSpace(metadataString, current);
|
current = FindNextNonSpace(metadataString, current);
|
||||||
if (current >= metadataString.length()){
|
if (current >= metadataString.length()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ParseParameter(metadataString, current);
|
ParseParameter(metadataString, current);
|
||||||
|
@ -61,7 +61,7 @@ private:
|
||||||
}
|
}
|
||||||
auto value = metadataString.substr(start, current - start);
|
auto value = metadataString.substr(start, current - start);
|
||||||
_parameters.Insert(name, value);
|
_parameters.Insert(name, value);
|
||||||
if (isQuoted){
|
if (isQuoted) {
|
||||||
current += 1;
|
current += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,14 @@ void RegisterPokemonClass::RegisterMoveLearnMethod(asIScriptEngine* engine) {
|
||||||
void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
|
void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
REGISTER_GETTER("LearnedMove", "const MoveData@ get_MoveData() const property", CreatureLib::Battling::LearnedAttack, GetAttack);
|
REGISTER_GETTER("LearnedMove", "const MoveData@ get_MoveData() const property",
|
||||||
REGISTER_GETTER("LearnedMove", "uint8 get_MaxUses() const property", CreatureLib::Battling::LearnedAttack, GetMaxUses);
|
CreatureLib::Battling::LearnedAttack, GetAttack);
|
||||||
REGISTER_GETTER("LearnedMove", "uint8 get_RemainingUses() const property", CreatureLib::Battling::LearnedAttack, GetRemainingUses);
|
REGISTER_GETTER("LearnedMove", "uint8 get_MaxUses() const property", CreatureLib::Battling::LearnedAttack,
|
||||||
REGISTER_GETTER("LearnedMove", "Gender get_LearnMethod() const property", CreatureLib::Battling::LearnedAttack, GetLearnMethod);
|
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) {
|
static bool HasHeldItem(const PkmnLib::Battling::Pokemon* obj, const ArbUt::StringView& str) {
|
||||||
|
@ -103,7 +107,7 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
GetMoves);
|
GetMoves);
|
||||||
|
|
||||||
auto r = engine->RegisterObjectMethod("Pokemon", "bool HasHeldItem(const constString &in name) const",
|
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);
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const constString &in name)",
|
r = engine->RegisterObjectMethod("Pokemon", "void SetHeldItem(const constString &in name)",
|
||||||
asFUNCTION(SetHeldItemWrapper), asCALL_CDECL_OBJFIRST);
|
asFUNCTION(SetHeldItemWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
|
|
@ -35,10 +35,10 @@ void RegisterTurnChoices::RegisterMoveTurnChoice(asIScriptEngine* engine) {
|
||||||
REGISTER_EXPLICIT_GETTER("MoveTurnChoice", "Pokemon@ get_User() const property",
|
REGISTER_EXPLICIT_GETTER("MoveTurnChoice", "Pokemon@ get_User() const property",
|
||||||
CreatureLib::Battling::BaseTurnChoice, GetUser,
|
CreatureLib::Battling::BaseTurnChoice, GetUser,
|
||||||
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
|
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
|
||||||
REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property",
|
REGISTER_GETTER("MoveTurnChoice", "LearnedMove@ get_Move() const property", CreatureLib::Battling::AttackTurnChoice,
|
||||||
CreatureLib::Battling::AttackTurnChoice, GetAttack);
|
GetAttack);
|
||||||
REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property",
|
REGISTER_GETTER("MoveTurnChoice", "int8 get_Priority() const property", CreatureLib::Battling::AttackTurnChoice,
|
||||||
CreatureLib::Battling::AttackTurnChoice, GetPriority);
|
GetPriority);
|
||||||
|
|
||||||
r = engine->RegisterObjectMethod(
|
r = engine->RegisterObjectMethod(
|
||||||
"BaseTurnChoice", "MoveTurnChoice@ opCast()",
|
"BaseTurnChoice", "MoveTurnChoice@ opCast()",
|
||||||
|
@ -56,11 +56,13 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
|
||||||
int r = engine->RegisterObjectType("SwitchTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
int r = engine->RegisterObjectType("SwitchTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
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",
|
REGISTER_EXPLICIT_GETTER("SwitchTurnChoice", "const Pokemon@ get_User() const property",
|
||||||
CreatureLib::Battling::BaseTurnChoice, GetUser,
|
CreatureLib::Battling::BaseTurnChoice, GetUser,
|
||||||
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
|
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(
|
r = engine->RegisterObjectMethod(
|
||||||
"BaseTurnChoice", "SwitchTurnChoice@ opCast()",
|
"BaseTurnChoice", "SwitchTurnChoice@ opCast()",
|
||||||
|
@ -76,7 +78,8 @@ void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
|
||||||
void RegisterTurnChoices::RegisterFleeTurnChoice(asIScriptEngine* engine) {
|
void RegisterTurnChoices::RegisterFleeTurnChoice(asIScriptEngine* engine) {
|
||||||
int r = engine->RegisterObjectType("FleeTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
int r = engine->RegisterObjectType("FleeTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
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",
|
REGISTER_EXPLICIT_GETTER("FleeTurnChoice", "const Pokemon@ get_User() const property",
|
||||||
CreatureLib::Battling::BaseTurnChoice, GetUser,
|
CreatureLib::Battling::BaseTurnChoice, GetUser,
|
||||||
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
|
const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>&);
|
||||||
|
|
|
@ -38,6 +38,4 @@ void RegisterEffectParameter::Register(asIScriptEngine* engine) {
|
||||||
asFUNCTIONPR(AsString, (const CreatureLib::Library::EffectParameter*), const ArbUt::StringView&),
|
asFUNCTIONPR(AsString, (const CreatureLib::Library::EffectParameter*), const ArbUt::StringView&),
|
||||||
asCALL_CDECL_OBJFIRST);
|
asCALL_CDECL_OBJFIRST);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,15 @@ static const PkmnLib::Library::PokemonForme* GetFormeWrapper(const std::string&
|
||||||
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
|
void RegisterSpeciesTypes::RegisterSpeciesType(asIScriptEngine* engine) {
|
||||||
int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
int r = engine->RegisterObjectType("Species", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
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", "uint16 get_Id() const property", CreatureLib::Library::CreatureSpecies, GetId);
|
||||||
REGISTER_GETTER("Species", "float get_GenderRate() const property", CreatureLib::Library::CreatureSpecies, GetGenderRate);
|
REGISTER_GETTER("Species", "float get_GenderRate() const property", CreatureLib::Library::CreatureSpecies,
|
||||||
REGISTER_GETTER("Species", "uint8 get_CaptureRate() const property", CreatureLib::Library::CreatureSpecies, GetCaptureRate);
|
GetGenderRate);
|
||||||
REGISTER_GETTER("Species", "const Forme@ get_DefaultForme() const property", PkmnLib::Library::PokemonSpecies, GetDefaultForme);
|
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",
|
r = engine->RegisterObjectMethod("Species", "Gender GetRandomGender() const",
|
||||||
asMETHOD(PkmnLib::Library::PokemonSpecies, GetRandomGender), asCALL_THISCALL);
|
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) {
|
void RegisterSpeciesTypes::RegisterFormeType(asIScriptEngine* engine) {
|
||||||
int r = engine->RegisterObjectType("Forme", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
int r = engine->RegisterObjectType("Forme", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
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_Weight() const property", CreatureLib::Library::SpeciesVariant, GetWeight);
|
||||||
REGISTER_GETTER("Forme", "float get_Height() const property", CreatureLib::Library::SpeciesVariant, GetHeight);
|
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);
|
REGISTER_GETTER("Forme", "int get_TypeCount() const property", CreatureLib::Library::SpeciesVariant, GetTypeCount);
|
||||||
|
|
||||||
r = engine->RegisterObjectMethod("Forme", "uint8 GetType(int index) const",
|
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);
|
int r = engine->RegisterObjectType("EvolutionData", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
|
||||||
REGISTER_GETTER("EvolutionData", "const Species& get_NewSpecies() const property", PkmnLib::Library::EvolutionData, GetNewSpecies);
|
REGISTER_GETTER("EvolutionData", "const Species& get_NewSpecies() const property", PkmnLib::Library::EvolutionData,
|
||||||
REGISTER_GETTER("EvolutionData", "EvolutionMethod get_Method() const property", PkmnLib::Library::EvolutionData, GetMethod);
|
GetNewSpecies);
|
||||||
REGISTER_GETTER("EvolutionData", "uint64 get_DataCount() const property", PkmnLib::Library::EvolutionData, GetDataCount);
|
REGISTER_GETTER("EvolutionData", "EvolutionMethod get_Method() const property", PkmnLib::Library::EvolutionData,
|
||||||
REGISTER_GETTER("EvolutionData", "const narray<EffectParameter@>@ get_Data() const property", PkmnLib::Library::EvolutionData, GetData);
|
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",
|
r = engine->RegisterObjectMethod("EvolutionData", "EffectParameter@ GetDataAt(uint64 index) const",
|
||||||
asMETHOD(PkmnLib::Library::EvolutionData, GetDataAt), asCALL_THISCALL);
|
asMETHOD(PkmnLib::Library::EvolutionData, GetDataAt), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) {
|
void RegisterSpeciesTypes::RegisterSpeciesLibrary(asIScriptEngine* engine) {
|
||||||
|
|
|
@ -9,11 +9,9 @@ private:
|
||||||
const T* _array;
|
const T* _array;
|
||||||
std::atomic<u64> _refCount;
|
std::atomic<u64> _refCount;
|
||||||
|
|
||||||
void AddRef() {
|
void AddRef() { _refCount++; }
|
||||||
_refCount++;
|
|
||||||
}
|
|
||||||
void Release() {
|
void Release() {
|
||||||
if (--_refCount <= 0){
|
if (--_refCount <= 0) {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,20 +25,19 @@ public:
|
||||||
[[nodiscard]] void* At(size_t index) { return _array->At(index).GetRaw(); }
|
[[nodiscard]] void* At(size_t index) { return _array->At(index).GetRaw(); }
|
||||||
|
|
||||||
static void Register(asIScriptEngine* engine) {
|
static void Register(asIScriptEngine* engine) {
|
||||||
Ensure(engine->RegisterObjectType("narray<class T>", sizeof(NativeArray),
|
Ensure(engine->RegisterObjectType("narray<class T>", sizeof(NativeArray), asOBJ_REF | asOBJ_TEMPLATE) >= 0);
|
||||||
asOBJ_REF | asOBJ_TEMPLATE) >= 0);
|
|
||||||
|
|
||||||
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_ADDREF, "void f()",
|
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_ADDREF, "void f()", asMETHOD(NativeArray, AddRef),
|
||||||
asMETHOD(NativeArray, AddRef), asCALL_THISCALL));
|
asCALL_THISCALL));
|
||||||
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_RELEASE, "void f()",
|
Ensure(engine->RegisterObjectBehaviour("narray<T>", asBEHAVE_RELEASE, "void f()",
|
||||||
asMETHOD(NativeArray, Release), asCALL_THISCALL));
|
asMETHOD(NativeArray, Release), asCALL_THISCALL));
|
||||||
|
|
||||||
Ensure(engine->RegisterObjectMethod("narray<T>", "uint64 get_Length() const property", asMETHOD(NativeArray, Length),
|
Ensure(engine->RegisterObjectMethod("narray<T>", "uint64 get_Length() const property",
|
||||||
asCALL_THISCALL) >= 0);
|
asMETHOD(NativeArray, Length), asCALL_THISCALL) >= 0);
|
||||||
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ At(uint64 index) const", asMETHOD(NativeArray, At),
|
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ At(uint64 index) const", asMETHOD(NativeArray, At),
|
||||||
asCALL_THISCALL) >= 0);
|
asCALL_THISCALL) >= 0);
|
||||||
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ get_opIndex(uint64 index) const property", asMETHOD(NativeArray, At),
|
Ensure(engine->RegisterObjectMethod("narray<T>", "const T@ get_opIndex(uint64 index) const property",
|
||||||
asCALL_THISCALL) >= 0);
|
asMETHOD(NativeArray, At), asCALL_THISCALL) >= 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue