mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 11:19:10 +00:00
Also use hsRef for the vault functions which "return" lists
This commit is contained in:
@ -206,20 +206,16 @@ PyObject* pyVault::GetKIUsage(void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// Get child nodes up to two levels deep
|
// Get child nodes up to two levels deep
|
||||||
ARRAY(RelVaultNode*) nodeArr;
|
RelVaultNode::RefList nodeArr;
|
||||||
rvnAgeJrnlz->GetChildNodesIncRef(2, &nodeArr);
|
rvnAgeJrnlz->GetChildNodes(2, &nodeArr);
|
||||||
|
|
||||||
RelVaultNode ** cur = nodeArr.Ptr();
|
for (const hsRef<RelVaultNode> &rvn : nodeArr) {
|
||||||
RelVaultNode ** end = nodeArr.Term();
|
|
||||||
for (; cur != end; ++cur) {
|
|
||||||
RelVaultNode * rvn = *cur;
|
|
||||||
if (rvn->GetNodeType() == plVault::kNodeType_Image)
|
if (rvn->GetNodeType() == plVault::kNodeType_Image)
|
||||||
++pictures;
|
++pictures;
|
||||||
else if (rvn->GetNodeType() == plVault::kNodeType_TextNote)
|
else if (rvn->GetNodeType() == plVault::kNodeType_TextNote)
|
||||||
++notes;
|
++notes;
|
||||||
else if (rvn->GetNodeType() == plVault::kNodeType_MarkerGame)
|
else if (rvn->GetNodeType() == plVault::kNodeType_MarkerGame)
|
||||||
++markerGames;
|
++markerGames;
|
||||||
rvn->UnRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -606,17 +606,13 @@ PyObject* pyVaultNode::GetChildNodeRefList()
|
|||||||
// fill in the elements list of this folder
|
// fill in the elements list of this folder
|
||||||
if (fNode)
|
if (fNode)
|
||||||
{
|
{
|
||||||
ARRAY(RelVaultNode*) nodes;
|
RelVaultNode::RefList nodes;
|
||||||
fNode->GetChildNodesIncRef(
|
fNode->GetChildNodes(1, &nodes);
|
||||||
1,
|
|
||||||
&nodes
|
|
||||||
);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < nodes.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &node : nodes) {
|
||||||
PyObject* elementObj = pyVaultNodeRef::New(fNode, nodes[i]);
|
PyObject* elementObj = pyVaultNodeRef::New(fNode, node);
|
||||||
PyList_Append(pyEL, elementObj);
|
PyList_Append(pyEL, elementObj);
|
||||||
Py_DECREF(elementObj);
|
Py_DECREF(elementObj);
|
||||||
nodes[i]->UnRef();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,11 +806,11 @@ bool plClothingOutfit::IReadFromVault()
|
|||||||
if (!rvn)
|
if (!rvn)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ARRAY(RelVaultNode*) nodes;
|
RelVaultNode::RefList nodes;
|
||||||
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
|
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
|
||||||
|
|
||||||
for (unsigned i = 0; i < nodes.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &node : nodes) {
|
||||||
VaultSDLNode sdl(nodes[i]);
|
VaultSDLNode sdl(node);
|
||||||
if (sdl.GetSDLDataLength()) {
|
if (sdl.GetSDLDataLength()) {
|
||||||
hsRAMStream ram;
|
hsRAMStream ram;
|
||||||
ram.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
|
ram.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
|
||||||
@ -831,7 +831,6 @@ bool plClothingOutfit::IReadFromVault()
|
|||||||
delete sdlDataRec;
|
delete sdlDataRec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodes[i]->UnRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fSynchClients = true; // set true if the next synch should be bcast
|
fSynchClients = true; // set true if the next synch should be bcast
|
||||||
@ -904,12 +903,12 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ARRAY(RelVaultNode*) templates;
|
RelVaultNode::RefList templates;
|
||||||
ARRAY(RelVaultNode*) actuals;
|
RelVaultNode::RefList actuals;
|
||||||
ARRAY(RelVaultNode*) nodes;
|
RelVaultNode::RefList nodes;
|
||||||
|
|
||||||
// Get all existing clothing SDRs
|
// Get all existing clothing SDRs
|
||||||
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes); // REF: Find
|
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes); // REF: Find
|
||||||
|
|
||||||
const ARRAY(plStateDataRecord*) * arrs[] = {
|
const ARRAY(plStateDataRecord*) * arrs[] = {
|
||||||
&SDRs,
|
&SDRs,
|
||||||
@ -921,14 +920,14 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
|
|||||||
// Write all SDL to to the outfit folder, reusing existing nodes and creating new ones as necessary
|
// Write all SDL to to the outfit folder, reusing existing nodes and creating new ones as necessary
|
||||||
for (unsigned i = 0; i < arr->Count(); ++i) {
|
for (unsigned i = 0; i < arr->Count(); ++i) {
|
||||||
hsRef<RelVaultNode> node;
|
hsRef<RelVaultNode> node;
|
||||||
if (nodes.Count()) {
|
if (!nodes.empty()) {
|
||||||
node = nodes[0];
|
node = nodes.front();
|
||||||
nodes.DeleteUnordered(0);
|
nodes.pop_front();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
node = new RelVaultNode;
|
node = new RelVaultNode;
|
||||||
node->SetNodeType(plVault::kNodeType_SDL);
|
node->SetNodeType(plVault::kNodeType_SDL);
|
||||||
templates.Add(node);
|
templates.push_back(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
VaultSDLNode sdl(node);
|
VaultSDLNode sdl(node);
|
||||||
@ -937,33 +936,24 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete any leftover nodes
|
// Delete any leftover nodes
|
||||||
for (unsigned i = 0; i < nodes.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &node : nodes)
|
||||||
VaultDeleteNode(nodes[i]->GetNodeId());
|
VaultDeleteNode(node->GetNodeId());
|
||||||
nodes[i]->UnRef(); // REF: Array
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create actual new nodes from their templates
|
// Create actual new nodes from their templates
|
||||||
for (unsigned i = 0; i < templates.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &temp : templates) {
|
||||||
ENetError result;
|
ENetError result;
|
||||||
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(templates[i], &result)) {
|
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(temp, &result))
|
||||||
actual->Ref();
|
actuals.push_back(actual);
|
||||||
actuals.Add(actual);
|
|
||||||
}
|
|
||||||
templates[i]->UnRef(); // REF: Create
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new nodes to outfit folder
|
// Add new nodes to outfit folder
|
||||||
for (unsigned i = 0; i < actuals.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &act : actuals)
|
||||||
VaultAddChildNodeAndWait(rvn->GetNodeId(), actuals[i]->GetNodeId(), NetCommGetPlayer()->playerInt);
|
VaultAddChildNodeAndWait(rvn->GetNodeId(), act->GetNodeId(), NetCommGetPlayer()->playerInt);
|
||||||
actuals[i]->UnRef(); // REF: Create
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cleanup morph SDRs
|
// Cleanup morph SDRs
|
||||||
for (unsigned i = 0; i < morphs.Count(); ++i) {
|
for (unsigned i = 0; i < morphs.Count(); ++i) {
|
||||||
delete morphs[i];
|
delete morphs[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
rvn->UnRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX HACK. DON'T USE (this function exists for the temp console command Clothing.SwapClothTexHACK)
|
// XXX HACK. DON'T USE (this function exists for the temp console command Clothing.SwapClothTexHACK)
|
||||||
@ -1488,15 +1478,14 @@ bool plClothingOutfit::WriteToFile(const plFileName &filename)
|
|||||||
|
|
||||||
S.WriteByte(fGroup);
|
S.WriteByte(fGroup);
|
||||||
|
|
||||||
ARRAY(RelVaultNode*) nodes;
|
RelVaultNode::RefList nodes;
|
||||||
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
|
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
|
||||||
S.WriteLE32(nodes.Count());
|
S.WriteLE32(nodes.size());
|
||||||
for (size_t i = 0; i < nodes.Count(); i++) {
|
for (const hsRef<RelVaultNode> &node : nodes) {
|
||||||
VaultSDLNode sdl(nodes[i]);
|
VaultSDLNode sdl(node);
|
||||||
S.WriteLE32(sdl.GetSDLDataLength());
|
S.WriteLE32(sdl.GetSDLDataLength());
|
||||||
if (sdl.GetSDLDataLength())
|
if (sdl.GetSDLDataLength())
|
||||||
S.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
|
S.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
|
||||||
nodes[i]->UnRef();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
S.Close();
|
S.Close();
|
||||||
@ -1672,12 +1661,13 @@ void plClothingMgr::GetClosetItems(hsTArray<plClosetItem> &out)
|
|||||||
if (!rvn)
|
if (!rvn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ARRAY(RelVaultNode*) nodes;
|
RelVaultNode::RefList nodes;
|
||||||
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
|
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
|
||||||
out.SetCount(nodes.Count());
|
out.SetCount(nodes.size());
|
||||||
|
|
||||||
for (unsigned i = 0; i < nodes.Count(); ++i) {
|
auto iter = nodes.begin();
|
||||||
VaultSDLNode sdl(nodes[i]);
|
for (unsigned i = 0; i < nodes.size(); ++i, ++iter) {
|
||||||
|
VaultSDLNode sdl(*iter);
|
||||||
plStateDataRecord * rec = new plStateDataRecord;
|
plStateDataRecord * rec = new plStateDataRecord;
|
||||||
if (sdl.GetStateDataRecord(rec, 0))
|
if (sdl.GetStateDataRecord(rec, 0))
|
||||||
plClothingSDLModifier::HandleSingleSDR(rec, nil, &out[i]);
|
plClothingSDLModifier::HandleSingleSDR(rec, nil, &out[i]);
|
||||||
|
@ -1289,9 +1289,9 @@ hsRef<RelVaultNode> RelVaultNode::GetChildAgeInfoListNode (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void RelVaultNode::GetChildNodesIncRef (
|
void RelVaultNode::GetChildNodes (
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RelVaultNode::RefList * nodes
|
||||||
) {
|
) {
|
||||||
if (maxDepth == 0)
|
if (maxDepth == 0)
|
||||||
return;
|
return;
|
||||||
@ -1299,9 +1299,8 @@ void RelVaultNode::GetChildNodesIncRef (
|
|||||||
RelVaultNodeLink * link;
|
RelVaultNodeLink * link;
|
||||||
link = state->children.Head();
|
link = state->children.Head();
|
||||||
for (; link; link = state->children.Next(link)) {
|
for (; link; link = state->children.Next(link)) {
|
||||||
nodes->Add(link->node);
|
nodes->push_back(link->node);
|
||||||
link->node->Ref();
|
link->node->GetChildNodes(
|
||||||
link->node->GetChildNodesIncRef(
|
|
||||||
maxDepth - 1,
|
maxDepth - 1,
|
||||||
nodes
|
nodes
|
||||||
);
|
);
|
||||||
@ -1309,19 +1308,19 @@ void RelVaultNode::GetChildNodesIncRef (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void RelVaultNode::GetChildNodesIncRef (
|
void RelVaultNode::GetChildNodes (
|
||||||
NetVaultNode * templateNode,
|
NetVaultNode * templateNode,
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RelVaultNode::RefList * nodes
|
||||||
) {
|
) {
|
||||||
RelVaultNodeLink * link;
|
RelVaultNodeLink * link;
|
||||||
link = state->children.Head();
|
link = state->children.Head();
|
||||||
for (; link; link = state->children.Next(link)) {
|
for (; link; link = state->children.Next(link)) {
|
||||||
if (link->node->Matches(templateNode)) {
|
if (link->node->Matches(templateNode)) {
|
||||||
nodes->Add(link->node);
|
nodes->push_back(link->node);
|
||||||
link->node->Ref();
|
link->node->Ref();
|
||||||
}
|
}
|
||||||
link->node->GetChildNodesIncRef(
|
link->node->GetChildNodes(
|
||||||
templateNode,
|
templateNode,
|
||||||
maxDepth - 1,
|
maxDepth - 1,
|
||||||
nodes
|
nodes
|
||||||
@ -1330,14 +1329,14 @@ void RelVaultNode::GetChildNodesIncRef (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void RelVaultNode::GetChildNodesIncRef (
|
void RelVaultNode::GetChildNodes (
|
||||||
unsigned nodeType,
|
unsigned nodeType,
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RelVaultNode::RefList * nodes
|
||||||
) {
|
) {
|
||||||
hsRef<NetVaultNode> templateNode = new NetVaultNode;
|
hsRef<NetVaultNode> templateNode = new NetVaultNode;
|
||||||
templateNode->SetNodeType(nodeType);
|
templateNode->SetNodeType(nodeType);
|
||||||
GetChildNodesIncRef(
|
GetChildNodes(
|
||||||
templateNode,
|
templateNode,
|
||||||
maxDepth,
|
maxDepth,
|
||||||
nodes
|
nodes
|
||||||
@ -1345,16 +1344,16 @@ void RelVaultNode::GetChildNodesIncRef (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void RelVaultNode::GetChildFolderNodesIncRef (
|
void RelVaultNode::GetChildFolderNodes (
|
||||||
unsigned folderType,
|
unsigned folderType,
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RelVaultNode::RefList * nodes
|
||||||
) {
|
) {
|
||||||
hsRef<NetVaultNode> templateNode = new NetVaultNode;
|
hsRef<NetVaultNode> templateNode = new NetVaultNode;
|
||||||
templateNode->SetNodeType(plVault::kNodeType_Folder);
|
templateNode->SetNodeType(plVault::kNodeType_Folder);
|
||||||
VaultFolderNode fldr(templateNode);
|
VaultFolderNode fldr(templateNode);
|
||||||
fldr.SetFolderType(folderType);
|
fldr.SetFolderType(folderType);
|
||||||
GetChildNodesIncRef(
|
GetChildNodes(
|
||||||
templateNode,
|
templateNode,
|
||||||
maxDepth,
|
maxDepth,
|
||||||
nodes
|
nodes
|
||||||
@ -3606,15 +3605,14 @@ void VaultProcessUnvisitNote(RelVaultNode * rvnUnVisit) {
|
|||||||
void VaultProcessPlayerInbox () {
|
void VaultProcessPlayerInbox () {
|
||||||
if (hsRef<RelVaultNode> rvnInbox = VaultGetPlayerInboxFolder()) {
|
if (hsRef<RelVaultNode> rvnInbox = VaultGetPlayerInboxFolder()) {
|
||||||
{ // Process new visit requests
|
{ // Process new visit requests
|
||||||
ARRAY(RelVaultNode*) visits;
|
RelVaultNode::RefList visits;
|
||||||
hsRef<RelVaultNode> templateNode = new RelVaultNode;
|
hsRef<RelVaultNode> templateNode = new RelVaultNode;
|
||||||
templateNode->SetNodeType(plVault::kNodeType_TextNote);
|
templateNode->SetNodeType(plVault::kNodeType_TextNote);
|
||||||
VaultTextNoteNode tmpAcc(templateNode);
|
VaultTextNoteNode tmpAcc(templateNode);
|
||||||
tmpAcc.SetNoteType(plVault::kNoteType_Visit);
|
tmpAcc.SetNoteType(plVault::kNoteType_Visit);
|
||||||
rvnInbox->GetChildNodesIncRef(templateNode, 1, &visits);
|
rvnInbox->GetChildNodes(templateNode, 1, &visits);
|
||||||
|
|
||||||
for (unsigned i = 0; i < visits.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &rvnVisit : visits) {
|
||||||
hsRef<RelVaultNode> rvnVisit = visits[i];
|
|
||||||
VaultTextNoteNode visitAcc(rvnVisit);
|
VaultTextNoteNode visitAcc(rvnVisit);
|
||||||
plAgeLinkStruct link;
|
plAgeLinkStruct link;
|
||||||
if (visitAcc.GetVisitInfo(link.GetAgeInfo())) {
|
if (visitAcc.GetVisitInfo(link.GetAgeInfo())) {
|
||||||
@ -3626,15 +3624,14 @@ void VaultProcessPlayerInbox () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
{ // Process new unvisit requests
|
{ // Process new unvisit requests
|
||||||
ARRAY(RelVaultNode*) unvisits;
|
RelVaultNode::RefList unvisits;
|
||||||
hsRef<RelVaultNode> templateNode = new RelVaultNode;
|
hsRef<RelVaultNode> templateNode = new RelVaultNode;
|
||||||
templateNode->SetNodeType(plVault::kNodeType_TextNote);
|
templateNode->SetNodeType(plVault::kNodeType_TextNote);
|
||||||
VaultTextNoteNode tmpAcc(templateNode);
|
VaultTextNoteNode tmpAcc(templateNode);
|
||||||
tmpAcc.SetNoteType(plVault::kNoteType_UnVisit);
|
tmpAcc.SetNoteType(plVault::kNoteType_UnVisit);
|
||||||
rvnInbox->GetChildNodesIncRef(templateNode, 1, &unvisits);
|
rvnInbox->GetChildNodes(templateNode, 1, &unvisits);
|
||||||
|
|
||||||
for (unsigned i = 0; i < unvisits.Count(); ++i) {
|
for (const hsRef<RelVaultNode> &rvnUnVisit : unvisits) {
|
||||||
hsRef<RelVaultNode> rvnUnVisit = unvisits[i];
|
|
||||||
VaultTextNoteNode unvisitAcc(rvnUnVisit);
|
VaultTextNoteNode unvisitAcc(rvnUnVisit);
|
||||||
plAgeInfoStruct info;
|
plAgeInfoStruct info;
|
||||||
if (unvisitAcc.GetVisitInfo(&info)) {
|
if (unvisitAcc.GetVisitInfo(&info)) {
|
||||||
|
@ -94,6 +94,8 @@ void VaultUnregisterCallback (VaultCallback * cb);
|
|||||||
*
|
*
|
||||||
***/
|
***/
|
||||||
struct RelVaultNode : NetVaultNode {
|
struct RelVaultNode : NetVaultNode {
|
||||||
|
typedef std::list<hsRef<RelVaultNode>> RefList;
|
||||||
|
|
||||||
struct IRelVaultNode * state;
|
struct IRelVaultNode * state;
|
||||||
|
|
||||||
RelVaultNode ();
|
RelVaultNode ();
|
||||||
@ -153,24 +155,24 @@ struct RelVaultNode : NetVaultNode {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// returns all matching nodes found
|
// returns all matching nodes found
|
||||||
void GetChildNodesIncRef (
|
void GetChildNodes (
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RefList * nodes
|
||||||
);
|
);
|
||||||
void GetChildNodesIncRef (
|
void GetChildNodes (
|
||||||
NetVaultNode * templateNode,
|
NetVaultNode * templateNode,
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RefList * nodes
|
||||||
);
|
);
|
||||||
void GetChildNodesIncRef (
|
void GetChildNodes (
|
||||||
unsigned nodeType,
|
unsigned nodeType,
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RefList * nodes
|
||||||
);
|
);
|
||||||
void GetChildFolderNodesIncRef (
|
void GetChildFolderNodes (
|
||||||
unsigned folderType,
|
unsigned folderType,
|
||||||
unsigned maxDepth,
|
unsigned maxDepth,
|
||||||
ARRAY(RelVaultNode*) * nodes
|
RefList * nodes
|
||||||
);
|
);
|
||||||
|
|
||||||
unsigned GetRefOwnerId (unsigned parentId);
|
unsigned GetRefOwnerId (unsigned parentId);
|
||||||
|
Reference in New Issue
Block a user