Skip to content

Commit

Permalink
return empty array from array functions by default instead of Ar_Null
Browse files Browse the repository at this point in the history
  • Loading branch information
c6-dev committed Aug 15, 2022
1 parent 5997250 commit b719cc1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
25 changes: 11 additions & 14 deletions JG/functions/fn_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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<TESModelTextureSwap::Texture>* 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;
}

Expand Down Expand Up @@ -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<TESModelTextureSwap::Texture>* 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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions JG/functions/fn_gameplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions JG/functions/fn_region.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, &region) && IS_TYPE(region, TESRegion)) {
TESRegionDataWeather* weatherData = GetWeatherData(region);
if (weatherData) {
NVSEArrayVar* weatherArr = g_arrInterface->CreateArray(NULL, 0, scriptObj);
ListNode<WeatherEntry>* iter = weatherData->weatherTypes.Head();
do {
if (iter->data) {
Expand All @@ -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) {
Expand Down

0 comments on commit b719cc1

Please sign in to comment.