Reduces some overhead from creating AngelScript array for Pokemon.GetTypes()
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
72df9ba01a
commit
cec9f0907f
|
@ -53,19 +53,24 @@ void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
|
||||||
|
|
||||||
ENUM__SIZE_WRAPPER(Pkmn_GenderWrapper, PkmnLib::Battling::Pokemon, GetGender)
|
ENUM__SIZE_WRAPPER(Pkmn_GenderWrapper, PkmnLib::Battling::Pokemon, GetGender)
|
||||||
|
|
||||||
CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) {
|
|
||||||
asIScriptContext* ctx = asGetActiveContext();
|
static asITypeInfo* _uint8TypeInfo = nullptr;
|
||||||
if (ctx) {
|
static CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) {
|
||||||
asIScriptEngine* engine = ctx->GetEngine();
|
if (_uint8TypeInfo == nullptr){
|
||||||
asITypeInfo* t = engine->GetTypeInfoByDecl("array<uint8>");
|
asIScriptContext* ctx = asGetActiveContext();
|
||||||
auto a = obj->GetTypes();
|
if (!ctx) {
|
||||||
CScriptArray* arr = CScriptArray::Create(t, a.size());
|
return nullptr;
|
||||||
for (size_t i = 0; i < a.size(); i++){
|
|
||||||
arr->SetValue(i, &a[i]);
|
|
||||||
}
|
}
|
||||||
return arr;
|
asIScriptEngine* engine = ctx->GetEngine();
|
||||||
|
_uint8TypeInfo = engine->GetTypeInfoByDecl("array<uint8>");
|
||||||
}
|
}
|
||||||
return nullptr;
|
|
||||||
|
auto a = obj->GetTypes();
|
||||||
|
CScriptArray* arr = CScriptArray::Create(_uint8TypeInfo, a.size());
|
||||||
|
for (size_t i = 0; i < a.size(); i++){
|
||||||
|
arr->SetValue(i, &a[i]);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
|
|
Loading…
Reference in New Issue