Skip to content

Commit

Permalink
Revert "add DeleteClonedForm"
Browse files Browse the repository at this point in the history
This reverts commit d2bc5e8.
  • Loading branch information
Demorome committed Sep 14, 2023
1 parent e0151c9 commit de8bea1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 58 deletions.
1 change: 0 additions & 1 deletion nvse/nvse/CommandTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 16 additions & 42 deletions nvse/nvse/Commands_Inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2817,35 +2817,27 @@ bool Cmd_SetNameEx_Execute(COMMAND_ARGS)
return true;
}

std::unordered_set<UInt32> s_clonedFormsWithInheritedModIdx; // kept for backwards compat
std::unordered_set<UInt32> s_clonedForms;
extern std::unordered_set<UInt32> 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<UInt32> s_clonedFormsWithInheritedModIdx;

bool CloneForm_Execute(COMMAND_ARGS, bool bPersist)
{
*result = 0;
Expand All @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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<TESForm*> 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:
Expand All @@ -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;
}
}
Expand Down
19 changes: 4 additions & 15 deletions nvse/nvse/Commands_Inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit de8bea1

Please sign in to comment.