From de8bea1385913e9755dfa69f0de9f8ac7a38f571 Mon Sep 17 00:00:00 2001 From: Demorome <69116996+Demorome@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:28:53 -0300 Subject: [PATCH] Revert "add DeleteClonedForm" This reverts commit d2bc5e8d8d9ad615fa88092ed2b1e45e3218ff3f. --- nvse/nvse/CommandTable.cpp | 1 - nvse/nvse/Commands_Inventory.cpp | 58 +++++++++----------------------- nvse/nvse/Commands_Inventory.h | 19 +++-------- 3 files changed, 20 insertions(+), 58 deletions(-) diff --git a/nvse/nvse/CommandTable.cpp b/nvse/nvse/CommandTable.cpp index 657ec1e1..4b1c0a57 100644 --- a/nvse/nvse/CommandTable.cpp +++ b/nvse/nvse/CommandTable.cpp @@ -1885,7 +1885,6 @@ void CommandTable::AddCommandsV6() // 6.3 beta 03 ADD_CMD_RET(CopyIRAlt, kRetnType_Form); ADD_CMD_RET(CompileScript, kRetnType_Form); - ADD_CMD(DeleteClonedForm); } namespace PluginAPI diff --git a/nvse/nvse/Commands_Inventory.cpp b/nvse/nvse/Commands_Inventory.cpp index 26264532..f02d4168 100644 --- a/nvse/nvse/Commands_Inventory.cpp +++ b/nvse/nvse/Commands_Inventory.cpp @@ -2817,35 +2817,27 @@ bool Cmd_SetNameEx_Execute(COMMAND_ARGS) return true; } -std::unordered_set s_clonedFormsWithInheritedModIdx; // kept for backwards compat -std::unordered_set s_clonedForms; +extern std::unordered_set s_clonedFormsWithInheritedModIdx; bool Cmd_IsClonedForm_Execute(COMMAND_ARGS) { *result = 0; TESForm* form = NULL; - UInt32 bCheckForTrueClone = 0; - ExtractArgsEx(EXTRACT_ARGS_EX, &form, &bCheckForTrueClone); + ExtractArgsEx(EXTRACT_ARGS_EX, &form); form = form->TryGetREFRParent(); if (!form) { if (!thisObj) return true; form = thisObj->baseForm; } - if (bCheckForTrueClone) - { - if (s_clonedForms.contains(form->refID)) - *result = 1; - } - else { - // Do the old code. - if (form->GetModIndex() == 0xFF || s_clonedFormsWithInheritedModIdx.contains(form->refID)) - *result = 1; - } + if (form->GetModIndex() == 0xFF || s_clonedFormsWithInheritedModIdx.contains(form->refID)) + *result = 1; return true; } +std::unordered_set s_clonedFormsWithInheritedModIdx; + bool CloneForm_Execute(COMMAND_ARGS, bool bPersist) { *result = 0; @@ -2871,7 +2863,6 @@ bool CloneForm_Execute(COMMAND_ARGS, bool bPersist) } } *refResult = clonedForm->refID; - s_clonedForms.insert(clonedForm->refID); if (IsConsoleMode()) Console_Print("Created cloned form: %08x", *refResult); } @@ -2889,26 +2880,6 @@ bool Cmd_CloneForm_Execute(COMMAND_ARGS) return CloneForm_Execute(PASS_COMMAND_ARGS, true); } -bool Cmd_DeleteClonedForm_Execute(COMMAND_ARGS) -{ - *result = 0; - UInt32* refResult = (UInt32*)result; - TESForm* form = NULL; - ExtractArgsEx(EXTRACT_ARGS_EX, &form); - if (!form) { - if (!thisObj) return true; - form = thisObj->baseForm; - } - - if (s_clonedForms.contains(form->refID)) - { - s_clonedForms.erase(form->refID); - form->Destroy(true); - *result = 1; - } - return true; -} - void GetEquippedWeaponModFlags_Call(TESObjectREFR* thisObj, double *result) { MatchBySlot matcher(5); @@ -3296,18 +3267,21 @@ bool Cmd_PickOneOf_Execute(COMMAND_ARGS) { UInt32* refResult = (UInt32*)result; *refResult = 0; BGSListForm* pFormList = NULL; + Actor* pActor = NULL; + SInt32 count; + UInt32 random; - if (!thisObj || !thisObj->IsActor()) + //DEBUG_MESSAGE("\n\tCI PickOneOf Called"); + pActor = DYNAMIC_CAST(thisObj, TESForm, Actor); + if (!pActor) return true; if (ExtractArgs(EXTRACT_ARGS, &pFormList)) { std::vector present; - for (auto* nthForm : pFormList->list) { - SInt32 count; - GetItemByRefID(thisObj, nthForm->refID, &count); + for (int i = 0; i < pFormList->Count(); i++) { + GetItemByRefID(thisObj, pFormList->GetNthForm(i)->refID, &count); if (count > 0) - present.push_back(nthForm); + present.push_back(pFormList->GetNthForm(i)); } - switch (present.size()) { case 0: @@ -3316,7 +3290,7 @@ bool Cmd_PickOneOf_Execute(COMMAND_ARGS) { *refResult = present.at(0)->refID; break; default: - UInt32 random = MersenneTwister::genrand_real2() * (present.size()); + random = MersenneTwister::genrand_real2() * (present.size()); *refResult = present.at(random)->refID; } } diff --git a/nvse/nvse/Commands_Inventory.h b/nvse/nvse/Commands_Inventory.h index 1b2db11d..b9e7230b 100644 --- a/nvse/nvse/Commands_Inventory.h +++ b/nvse/nvse/Commands_Inventory.h @@ -185,27 +185,16 @@ DEFINE_CMD_COND(GetEquippedWeaponUsesAmmoList, "returns if the equipped weapon uses a specific list of ammo", true, kParams_OneFormList); -static ParamInfo kParams_IsClonedForm[2] = -{ - { "form", kParamType_AnyForm, 1 }, - { "bCheckForTrueClone", kParamType_Integer, 1 }, -}; +DEFINE_GET_FORM(CloneForm, , clones the specified form and returns a new base form which will not be saved in the save game.); +DEFINE_GET_FORM(IsClonedForm, IsCloned, returns whether the specified form is a created object or not.); -DEFINE_CMD_ALIAS(IsClonedForm, IsCloned, "returns whether the specified form is a created object or not.", - false, kParams_IsClonedForm); - -static ParamInfo kParamsCloneForm[2] = +static ParamInfo kParamsTempCloneForm[2] = { { "form", kParamType_AnyForm, 0 }, { "bInheritModIndex", kParamType_Integer, 1 }, }; -DEFINE_CMD(TempCloneForm, "clones the specified form and returns a new base form which will be saved in the save game.", - false, kParamsCloneForm); -DEFINE_CMD(CloneForm, "clones the specified form and returns a new base form which will not be saved in the save game.", - false, kParamsCloneForm); - -DEFINE_GET_FORM(DeleteClonedForm, , ""); +DEFINE_CMD(TempCloneForm, "clones the specified form and returns a new base form which will be saved in the save game.", false, kParamsTempCloneForm); #undef DEFINE_GET_INV #undef DEFINE_SET_INV_INT