Revert "Reduces some overhead from creating AngelScript array for Pokemon.GetTypes()"
continuous-integration/drone/push Build is passing Details

This reverts commit cec9f090, as it doesn't account for multiple different script engines
This commit is contained in:
Deukhoofd 2020-02-02 11:01:49 +01:00
parent cec9f0907f
commit e04ab6497a
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 11 additions and 16 deletions

View File

@ -53,25 +53,20 @@ void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) {
ENUM__SIZE_WRAPPER(Pkmn_GenderWrapper, PkmnLib::Battling::Pokemon, GetGender)
static asITypeInfo* _uint8TypeInfo = nullptr;
static CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) {
if (_uint8TypeInfo == nullptr){
CScriptArray* GetTypes(const PkmnLib::Battling::Pokemon* obj) {
asIScriptContext* ctx = asGetActiveContext();
if (!ctx) {
return nullptr;
}
if (ctx) {
asIScriptEngine* engine = ctx->GetEngine();
_uint8TypeInfo = engine->GetTypeInfoByDecl("array<uint8>");
}
asITypeInfo* t = engine->GetTypeInfoByDecl("array<uint8>");
auto a = obj->GetTypes();
CScriptArray* arr = CScriptArray::Create(_uint8TypeInfo, a.size());
CScriptArray* arr = CScriptArray::Create(t, a.size());
for (size_t i = 0; i < a.size(); i++){
arr->SetValue(i, &a[i]);
}
return arr;
}
return nullptr;
}
void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT);