From b719cc115f333970abd6d3dcefe7e2426870c5f9 Mon Sep 17 00:00:00 2001 From: c6 <31777460+c6-dev@users.noreply.github.com> Date: Mon, 15 Aug 2022 17:41:53 +0400 Subject: [PATCH] return empty array from array functions by default instead of Ar_Null --- JG/functions/fn_form.h | 25 +++++++++++-------------- JG/functions/fn_gameplay.h | 4 ++-- JG/functions/fn_region.h | 4 ++-- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/JG/functions/fn_form.h b/JG/functions/fn_form.h index 62136b1..0caaf82 100644 --- a/JG/functions/fn_form.h +++ b/JG/functions/fn_form.h @@ -88,9 +88,9 @@ void* (__thiscall* TESNPC_GetFaceGenData)(TESNPC*) = (void* (__thiscall*)(TESNPC bool Cmd_GetFormRecipesAlt_Execute(COMMAND_ARGS) { *result = 0; TESForm* form = nullptr; + NVSEArrayVar* rcpArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); if (ExtractArgsEx(EXTRACT_ARGS_EX, &form)) { auto it = g_dataHandler->recipeList.Head(); - NVSEArrayVar* rcpArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); do { if (it->data && !it->data->outputs.Empty()) { TESRecipe::ComponentList* outputs = &it->data->outputs; @@ -104,9 +104,9 @@ bool Cmd_GetFormRecipesAlt_Execute(COMMAND_ARGS) { } } while (it = it->next); - if (g_arrInterface->GetArraySize(rcpArr)) g_arrInterface->AssignCommandResult(rcpArr, result); } + g_arrInterface->AssignCommandResult(rcpArr, result); return true; } @@ -367,32 +367,30 @@ bool Cmd_GetRefActivationPromptOverride_Execute(COMMAND_ARGS) { bool Cmd_GetWeaponAltTextures_Execute(COMMAND_ARGS) { *result = 0; TESObjectWEAP* weapon; + NVSEArrayVar* txstArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); if (ExtractArgsEx(EXTRACT_ARGS_EX, &weapon) && IS_TYPE(weapon, TESObjectWEAP)) { TESModelTextureSwap* model = &weapon->textureSwap; if (!model) return true; - NVSEArrayVar* txstArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); ListNode* iter = model->textureList.Head(); do { if (iter->data && iter->data->textureID) g_arrInterface->AppendElement(txstArr, NVSEArrayElement(iter->data->textureID)); } while (iter = iter->next); - - if (g_arrInterface->GetArraySize(txstArr)) g_arrInterface->AssignCommandResult(txstArr, result); } + g_arrInterface->AssignCommandResult(txstArr, result); return true; } bool Cmd_GetIdleMarkerAnimations_Execute(COMMAND_ARGS) { *result = 0; BGSIdleMarker* marker; + NVSEArrayVar* idleArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); if (ExtractArgsEx(EXTRACT_ARGS_EX, &marker) && marker->idleCollection.animCount > 0) { - NVSEArrayVar* idleArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); for (int i = 0; i < marker->idleCollection.animCount; i++) { g_arrInterface->AppendElement(idleArr, NVSEArrayElement(marker->idleCollection.idleList[i])); } - if (g_arrInterface->GetArraySize(idleArr)) g_arrInterface->AssignCommandResult(idleArr, result); } - + g_arrInterface->AssignCommandResult(idleArr, result); return true; } @@ -494,19 +492,18 @@ bool Cmd_GetArmorAltTextures_Execute(COMMAND_ARGS) { *result = 0; TESObjectARMO* armor; UInt32 whichModel; - + NVSEArrayVar* txstArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); if (ExtractArgsEx(EXTRACT_ARGS_EX, &armor, &whichModel) && IS_TYPE(armor, TESObjectARMO)) { TESModelTextureSwap* model = GetArmorModel(armor, whichModel); if (!model) return true; - NVSEArrayVar* txstArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); ListNode* iter = model->textureList.Head(); do { if (iter->data && iter->data->textureID) g_arrInterface->AppendElement(txstArr, NVSEArrayElement(iter->data->textureID)); } while (iter = iter->next); - if (g_arrInterface->GetArraySize(txstArr)) g_arrInterface->AssignCommandResult(txstArr, result); } + g_arrInterface->AssignCommandResult(txstArr, result); return true; } bool Cmd_SetWeaponAltTexture_Execute(COMMAND_ARGS) { @@ -761,7 +758,7 @@ bool Cmd_GetAvailablePerks_Execute(COMMAND_ARGS) { } } } while (perkIter = perkIter->next); - if (g_arrInterface->GetArraySize(perkArr)) g_arrInterface->AssignCommandResult(perkArr, result); + g_arrInterface->AssignCommandResult(perkArr, result); return true; } bool Cmd_FaceGenRefreshAppearance_Execute(COMMAND_ARGS) { @@ -1175,9 +1172,9 @@ bool Cmd_GetFactionMembers_Execute(COMMAND_ARGS) { *result = 0; TESFaction* faction; SInt32 rank = -1; + NVSEArrayVar* factionMemberArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); ExtractArgsEx(EXTRACT_ARGS_EX, &faction, &rank); if (faction) { - NVSEArrayVar* factionMemberArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); for (TESBoundObject* object = g_dataHandler->boundObjectList->first; object; object = object->next) { TESActorBase* actorBase = DYNAMIC_CAST(object, TESBoundObject, TESActorBase); if (actorBase && actorBase->baseData.factionList.Count() != 0) { @@ -1193,8 +1190,8 @@ bool Cmd_GetFactionMembers_Execute(COMMAND_ARGS) { } while (fctIter = fctIter->next); } } - if (g_arrInterface->GetArraySize(factionMemberArr)) g_arrInterface->AssignCommandResult(factionMemberArr, result); } + g_arrInterface->AssignCommandResult(factionMemberArr, result); return true; } bool Cmd_SetEquipType_Execute(COMMAND_ARGS) { diff --git a/JG/functions/fn_gameplay.h b/JG/functions/fn_gameplay.h index 8f6c5dc..7575d75 100644 --- a/JG/functions/fn_gameplay.h +++ b/JG/functions/fn_gameplay.h @@ -110,7 +110,7 @@ bool Cmd_GetPlayingEffectShaders_Execute(COMMAND_ARGS) { } } while (iter = iter->next); - if (g_arrInterface->GetArraySize(effArr)) g_arrInterface->AssignCommandResult(effArr, result); + g_arrInterface->AssignCommandResult(effArr, result); return true; } @@ -222,7 +222,7 @@ bool Cmd_GetCompassHostiles_Execute(COMMAND_ARGS) { g_arrInterface->AppendElement(hostileArr, NVSEArrayElement(target->target)); } } - if (g_arrInterface->GetArraySize(hostileArr)) g_arrInterface->AssignCommandResult(hostileArr, result); + g_arrInterface->AssignCommandResult(hostileArr, result); return true; } diff --git a/JG/functions/fn_region.h b/JG/functions/fn_region.h index 244ca0a..2455277 100644 --- a/JG/functions/fn_region.h +++ b/JG/functions/fn_region.h @@ -82,10 +82,10 @@ bool Cmd_GetRegionMapName_Execute(COMMAND_ARGS) { bool Cmd_GetRegionWeathers_Execute(COMMAND_ARGS) { TESRegion* region = NULL; + NVSEArrayVar* weatherArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); if (ExtractArgsEx(EXTRACT_ARGS_EX, ®ion) && IS_TYPE(region, TESRegion)) { TESRegionDataWeather* weatherData = GetWeatherData(region); if (weatherData) { - NVSEArrayVar* weatherArr = g_arrInterface->CreateArray(NULL, 0, scriptObj); ListNode* iter = weatherData->weatherTypes.Head(); do { if (iter->data) { @@ -94,9 +94,9 @@ bool Cmd_GetRegionWeathers_Execute(COMMAND_ARGS) { Console_Print(iter->data->weather->GetName()); } } while (iter = iter->next); - if (g_arrInterface->GetArraySize(weatherArr)) g_arrInterface->AssignCommandResult(weatherArr, result); } } + g_arrInterface->AssignCommandResult(weatherArr, result); return true; } bool Cmd_ClearRegionWeathers_Execute(COMMAND_ARGS) {