1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Use hsRef for storage of the remaining vault nodes

This commit is contained in:
2014-05-30 21:31:00 -07:00
parent 8fa9171415
commit 403528a24b
24 changed files with 47 additions and 159 deletions

View File

@ -1471,10 +1471,8 @@ bool plClothingOutfit::WriteToFile(const plFileName &filename)
return false;
hsUNIXStream S;
if (!S.Open(filename, "wb")) {
rvn->UnRef();
if (!S.Open(filename, "wb"))
return false;
}
S.WriteByte(fGroup);
@ -1614,7 +1612,7 @@ void plClothingMgr::AddItemsToCloset(hsTArray<plClosetItem> &items)
hsTArray<plClosetItem> closet;
GetClosetItems(closet);
ARRAY(RelVaultNode*) templates;
RelVaultNode::RefList templates;
for (unsigned i = 0; i < items.GetCount(); ++i) {
bool match = false;
@ -1632,26 +1630,24 @@ void plClothingMgr::AddItemsToCloset(hsTArray<plClosetItem> &items)
plStateDataRecord rec(plClothingSDLModifier::GetClothingItemSDRName());
plClothingSDLModifier::PutSingleItemIntoSDR(&items[i], &rec);
RelVaultNode * templateNode = new RelVaultNode;
templateNode->Ref();
hsRef<RelVaultNode> templateNode = new RelVaultNode;
templateNode->SetNodeType(plVault::kNodeType_SDL);
VaultSDLNode sdl(templateNode);
sdl.SetStateDataRecord(&rec);
templates.Add(templateNode);
templates.push_back(templateNode);
}
for (unsigned i = 0; i < templates.Count(); ++i) {
for (const hsRef<RelVaultNode> &temp : templates) {
ENetError result;
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(templates[i], &result)) {
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(temp, &result)) {
VaultAddChildNodeAndWait(
rvn->GetNodeId(),
actual->GetNodeId(),
NetCommGetPlayer()->playerInt
);
}
templates[i]->UnRef(); // REF: Create
}
}

View File

@ -726,7 +726,7 @@ struct VaultFetchNodeTrans : NetAuthTrans {
FNetCliAuthVaultNodeFetched m_callback;
void * m_param;
NetVaultNode * m_node;
hsRef<NetVaultNode> m_node;
VaultFetchNodeTrans (
unsigned nodeId,
@ -751,14 +751,13 @@ struct VaultFindNodeTrans : NetAuthTrans {
FNetCliAuthVaultNodeFind m_callback;
void * m_param;
NetVaultNode * m_node;
hsRef<NetVaultNode> m_node;
VaultFindNodeTrans (
NetVaultNode * templateNode,
FNetCliAuthVaultNodeFind callback,
void * param
);
~VaultFindNodeTrans ();
bool Send ();
@ -774,7 +773,7 @@ struct VaultFindNodeTrans : NetAuthTrans {
//============================================================================
struct VaultCreateNodeTrans : NetAuthTrans {
NetVaultNode * m_templateNode;
hsRef<NetVaultNode> m_templateNode;
FNetCliAuthVaultNodeCreated m_callback;
void * m_param;
@ -3940,8 +3939,6 @@ void VaultFetchNodeTrans::Post () {
m_param,
m_node
);
if (m_node)
m_node->UnRef("Recv");
}
//============================================================================
@ -3954,7 +3951,6 @@ bool VaultFetchNodeTrans::Recv (
if (IS_NET_SUCCESS(reply.result)) {
m_node = new NetVaultNode;
m_node->Read_LCS(reply.nodeBuffer, reply.nodeBytes, 0);
m_node->Ref("Recv");
}
m_result = reply.result;
@ -3980,12 +3976,6 @@ VaultFindNodeTrans::VaultFindNodeTrans (
, m_param(param)
, m_node(templateNode)
{
m_node->Ref();
}
//============================================================================
VaultFindNodeTrans::~VaultFindNodeTrans () {
m_node->UnRef();
}
//============================================================================
@ -4056,7 +4046,6 @@ VaultCreateNodeTrans::VaultCreateNodeTrans (
, m_param(param)
, m_nodeId(0)
{
m_templateNode->Ref();
}
//============================================================================
@ -4086,7 +4075,6 @@ void VaultCreateNodeTrans::Post () {
m_param,
m_nodeId
);
m_templateNode->UnRef();
}
//============================================================================

View File

@ -104,7 +104,7 @@ struct RelVaultNodeLink : THashKeyVal<unsigned> {
struct IRelVaultNode {
RelVaultNode * node;
hsRef<RelVaultNode> node;
HASHTABLEDECL(
RelVaultNodeLink,
@ -135,7 +135,7 @@ struct VaultCreateNodeTrans {
void * param;
unsigned nodeId;
RelVaultNode * node;
hsRef<RelVaultNode> node;
VaultCreateNodeTrans ()
: callback(nil), state(nil), param(nil), nodeId(0), node(nil) { }
@ -397,8 +397,8 @@ static void BuildNodeTree (
childLink->ownerId = ownerId;
}
RelVaultNode * parentNode = parentLink->node;
RelVaultNode * childNode = childLink->node;
hsRef<RelVaultNode> parentNode = parentLink->node;
hsRef<RelVaultNode> childNode = childLink->node;
bool isImmediateParent = parentNode->IsParentOf(refs[i].childId, 1);
bool isImmediateChild = childNode->IsChildOf(refs[i].parentId, 1);
@ -1316,10 +1316,9 @@ void RelVaultNode::GetChildNodes (
RelVaultNodeLink * link;
link = state->children.Head();
for (; link; link = state->children.Next(link)) {
if (link->node->Matches(templateNode)) {
if (link->node->Matches(templateNode))
nodes->push_back(link->node);
link->node->Ref();
}
link->node->GetChildNodes(
templateNode,
maxDepth - 1,