|
|
@ -181,8 +181,24 @@ struct VaultDownloadTrans { |
|
|
|
unsigned vaultId; |
|
|
|
unsigned vaultId; |
|
|
|
ENetError result; |
|
|
|
ENetError result; |
|
|
|
|
|
|
|
|
|
|
|
VaultDownloadTrans (); |
|
|
|
VaultDownloadTrans() |
|
|
|
|
|
|
|
: callback(), cbParam(), progressCallback(), cbProgressParam(), |
|
|
|
|
|
|
|
nodeCount(), nodesLeft(), vaultId(), result(kNetSuccess) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VaultDownloadTrans(const wchar_t* _tag, FVaultDownloadCallback _callback, |
|
|
|
|
|
|
|
void* _cbParam, FVaultProgressCallback _progressCallback, |
|
|
|
|
|
|
|
void* _cbProgressParam, unsigned _vaultId) |
|
|
|
|
|
|
|
: callback(_callback), cbParam(_cbParam), progressCallback(_progressCallback), |
|
|
|
|
|
|
|
cbProgressParam(_cbProgressParam), nodeCount(), nodesLeft(), |
|
|
|
|
|
|
|
vaultId(_vaultId), result(kNetSuccess) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StrCopy(tag, _tag, arrsize(tag)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual ~VaultDownloadTrans() { } |
|
|
|
|
|
|
|
|
|
|
|
static void VaultNodeFetched ( |
|
|
|
static void VaultNodeFetched ( |
|
|
|
ENetError result, |
|
|
|
ENetError result, |
|
|
|
void * param, |
|
|
|
void * param, |
|
|
@ -196,6 +212,28 @@ struct VaultDownloadTrans { |
|
|
|
); |
|
|
|
); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct VaultDownloadNoCallbacksTrans : VaultDownloadTrans { |
|
|
|
|
|
|
|
VaultDownloadNoCallbacksTrans() |
|
|
|
|
|
|
|
: VaultDownloadTrans() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VaultSuppressCallbacks(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VaultDownloadNoCallbacksTrans(const wchar_t* _tag, FVaultDownloadCallback _callback, |
|
|
|
|
|
|
|
void* _cbParam, FVaultProgressCallback _progressCallback, |
|
|
|
|
|
|
|
void* _cbProgressParam, unsigned _vaultId) |
|
|
|
|
|
|
|
: VaultDownloadTrans(_tag, _callback, _cbParam, _progressCallback, _cbProgressParam, _vaultId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VaultSuppressCallbacks(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
~VaultDownloadNoCallbacksTrans() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VaultEnableCallbacks(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
struct VaultAgeInitTrans { |
|
|
|
struct VaultAgeInitTrans { |
|
|
|
FVaultInitAgeCallback callback; |
|
|
|
FVaultInitAgeCallback callback; |
|
|
|
void * cbState; |
|
|
|
void * cbState; |
|
|
@ -262,6 +300,8 @@ static HASHTABLEDECL( |
|
|
|
|
|
|
|
|
|
|
|
static bool s_processPlayerInbox = false; |
|
|
|
static bool s_processPlayerInbox = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static long s_suppressCallbacks = 0; |
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
/*****************************************************************************
|
|
|
|
* |
|
|
|
* |
|
|
|
* Local functions |
|
|
|
* Local functions |
|
|
@ -303,8 +343,10 @@ static void VaultNodeAddedDownloadCallback(ENetError result, void * param) { |
|
|
|
VaultProcessUnvisitNote(childLink->node); |
|
|
|
VaultProcessUnvisitNote(childLink->node); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
if (s_suppressCallbacks == 0) { |
|
|
|
cb->cb->AddedChildNode(parentLink->node, childLink->node); |
|
|
|
for (IVaultCallback* cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
|
|
|
|
cb->cb->AddedChildNode(parentLink->node, childLink->node); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -377,9 +419,11 @@ static void BuildNodeTree ( |
|
|
|
parentNode->state->children.Add(childLink); |
|
|
|
parentNode->state->children.Add(childLink); |
|
|
|
|
|
|
|
|
|
|
|
if (notifyNow || childNode->nodeType != 0) { |
|
|
|
if (notifyNow || childNode->nodeType != 0) { |
|
|
|
// We made a new link, so make the callbacks
|
|
|
|
if (s_suppressCallbacks == 0) { |
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
// We made a new link, so make the callbacks
|
|
|
|
cb->cb->AddedChildNode(parentNode, childNode); |
|
|
|
for (IVaultCallback* cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
|
|
|
|
cb->cb->AddedChildNode(parentNode, childNode); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
INotifyAfterDownload* notify = NEWZERO(INotifyAfterDownload)(parentNode->nodeId, childNode->nodeId); |
|
|
|
INotifyAfterDownload* notify = NEWZERO(INotifyAfterDownload)(parentNode->nodeId, childNode->nodeId); |
|
|
@ -543,6 +587,10 @@ static void ChangedVaultNodeFetched ( |
|
|
|
|
|
|
|
|
|
|
|
RelVaultNodeLink* savedLink = s_nodes.Find(node->nodeId); |
|
|
|
RelVaultNodeLink* savedLink = s_nodes.Find(node->nodeId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Yeah, we are purposefully allowing this global callback to go out,
|
|
|
|
|
|
|
|
// even if callback suppression has been enabled. The intent behind
|
|
|
|
|
|
|
|
// that is to suppress spurious callbacks, but node changes are
|
|
|
|
|
|
|
|
// probably not spurious.
|
|
|
|
if (savedLink) { |
|
|
|
if (savedLink) { |
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
cb->cb->ChangedNode(savedLink->node); |
|
|
|
cb->cb->ChangedNode(savedLink->node); |
|
|
@ -638,7 +686,7 @@ static void VaultNodeAdded ( |
|
|
|
RelVaultNodeLink* parentLink = s_nodes.Find(parentId); |
|
|
|
RelVaultNodeLink* parentLink = s_nodes.Find(parentId); |
|
|
|
RelVaultNodeLink* childLink = s_nodes.Find(childId); |
|
|
|
RelVaultNodeLink* childLink = s_nodes.Find(childId); |
|
|
|
|
|
|
|
|
|
|
|
if (childLink->node->nodeType != 0) { |
|
|
|
if (childLink->node->nodeType != 0 && s_suppressCallbacks == 0) { |
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
cb->cb->AddedChildNode(parentLink->node, childLink->node); |
|
|
|
cb->cb->AddedChildNode(parentLink->node, childLink->node); |
|
|
|
} |
|
|
|
} |
|
|
@ -660,7 +708,7 @@ static void VaultNodeRemoved ( |
|
|
|
if (!childLink) |
|
|
|
if (!childLink) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
if (parentLink->node->IsParentOf(childId, 1)) { |
|
|
|
if (parentLink->node->IsParentOf(childId, 1) && s_suppressCallbacks == 0) { |
|
|
|
// We have the relationship, so make the callbacks
|
|
|
|
// We have the relationship, so make the callbacks
|
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
cb->cb->RemovingChildNode(parentLink->node, childLink->node); |
|
|
|
cb->cb->RemovingChildNode(parentLink->node, childLink->node); |
|
|
@ -831,11 +879,6 @@ void VaultFindNodeTrans::VaultNodeFound ( |
|
|
|
* |
|
|
|
* |
|
|
|
***/ |
|
|
|
***/ |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
VaultDownloadTrans::VaultDownloadTrans () { |
|
|
|
|
|
|
|
ASSERT(!nodeCount); // must be alloced with
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void VaultDownloadTrans::VaultNodeFetched ( |
|
|
|
void VaultDownloadTrans::VaultNodeFetched ( |
|
|
|
ENetError result, |
|
|
|
ENetError result, |
|
|
@ -1047,8 +1090,10 @@ void IRelVaultNode::UnlinkFromRelatives () { |
|
|
|
next = parents.Next(link); |
|
|
|
next = parents.Next(link); |
|
|
|
|
|
|
|
|
|
|
|
// We have the relationship, so make the callbacks
|
|
|
|
// We have the relationship, so make the callbacks
|
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
if (s_suppressCallbacks == 0) { |
|
|
|
cb->cb->RemovingChildNode(link->node, this->node); |
|
|
|
for (IVaultCallback* cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
|
|
|
|
cb->cb->RemovingChildNode(link->node, this->node); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
link->node->state->Unlink(node); |
|
|
|
link->node->state->Unlink(node); |
|
|
|
} |
|
|
|
} |
|
|
@ -1478,6 +1523,16 @@ void VaultUnregisterCallback (VaultCallback * cb) { |
|
|
|
cb->internal = nil; |
|
|
|
cb->internal = nil; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void VaultSuppressCallbacks() { |
|
|
|
|
|
|
|
AtomicAdd(&s_suppressCallbacks, 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void VaultEnableCallbacks() { |
|
|
|
|
|
|
|
long prevValue = AtomicAdd(&s_suppressCallbacks, -1); |
|
|
|
|
|
|
|
hsAssert(prevValue > 0, "Hmm... A negative vault callback suppression count?"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
/*****************************************************************************
|
|
|
|
* |
|
|
|
* |
|
|
@ -1772,8 +1827,10 @@ void VaultRemoveChildNode ( |
|
|
|
|
|
|
|
|
|
|
|
if (parentLink->node->IsParentOf(childId, 1)) { |
|
|
|
if (parentLink->node->IsParentOf(childId, 1)) { |
|
|
|
// We have the relationship, so make the callbacks
|
|
|
|
// We have the relationship, so make the callbacks
|
|
|
|
for (IVaultCallback * cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
if (s_suppressCallbacks == 0) { |
|
|
|
cb->cb->RemovingChildNode(parentLink->node, childLink->node); |
|
|
|
for (IVaultCallback* cb = s_callbacks.Head(); cb; cb = s_callbacks.Next(cb)) |
|
|
|
|
|
|
|
cb->cb->RemovingChildNode(parentLink->node, childLink->node); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parentLink->node->state->Unlink(childLink->node); |
|
|
|
parentLink->node->state->Unlink(childLink->node); |
|
|
@ -4945,13 +5002,27 @@ void VaultDownload ( |
|
|
|
FVaultProgressCallback progressCallback, |
|
|
|
FVaultProgressCallback progressCallback, |
|
|
|
void * cbProgressParam |
|
|
|
void * cbProgressParam |
|
|
|
) { |
|
|
|
) { |
|
|
|
VaultDownloadTrans * trans = NEWZERO(VaultDownloadTrans); |
|
|
|
VaultDownloadTrans * trans = new VaultDownloadTrans(tag, callback, cbParam, |
|
|
|
StrCopy(trans->tag, tag, arrsize(trans->tag)); |
|
|
|
progressCallback, cbProgressParam, vaultId); |
|
|
|
trans->callback = callback; |
|
|
|
|
|
|
|
trans->cbParam = cbParam; |
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
trans->progressCallback = progressCallback; |
|
|
|
vaultId, |
|
|
|
trans->cbProgressParam = cbProgressParam; |
|
|
|
VaultDownloadTrans::VaultNodeRefsFetched, |
|
|
|
trans->vaultId = vaultId; |
|
|
|
trans |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void VaultDownloadNoCallbacks ( |
|
|
|
|
|
|
|
const wchar tag[], |
|
|
|
|
|
|
|
unsigned vaultId, |
|
|
|
|
|
|
|
FVaultDownloadCallback callback, |
|
|
|
|
|
|
|
void* cbParam, |
|
|
|
|
|
|
|
FVaultProgressCallback progressCallback, |
|
|
|
|
|
|
|
void* cbProgressParam |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
VaultDownloadNoCallbacksTrans* trans = new VaultDownloadNoCallbacksTrans(tag, callback, |
|
|
|
|
|
|
|
cbParam, progressCallback, cbProgressParam, vaultId); |
|
|
|
|
|
|
|
|
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
NetCliAuthVaultFetchNodeRefs( |
|
|
|
vaultId, |
|
|
|
vaultId, |
|
|
@ -5001,6 +5072,8 @@ void VaultDownloadAndWait ( |
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//============================================================================
|
|
|
|
void VaultCull (unsigned vaultId) { |
|
|
|
void VaultCull (unsigned vaultId) { |
|
|
|
|
|
|
|
VaultCallbackSuppressor suppress; |
|
|
|
|
|
|
|
|
|
|
|
// Remove the node from the global table
|
|
|
|
// Remove the node from the global table
|
|
|
|
if (RelVaultNodeLink * link = s_nodes.Find(vaultId)) { |
|
|
|
if (RelVaultNodeLink * link = s_nodes.Find(vaultId)) { |
|
|
|
LogMsg(kLogDebug, L"Vault: Culling node %u", link->node->nodeId); |
|
|
|
LogMsg(kLogDebug, L"Vault: Culling node %u", link->node->nodeId); |
|
|
|