2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Async creation of subages (thanks to all the people whose Delins/Tsogals I randomly popped in on)

This commit is contained in:
2011-04-23 20:12:16 -04:00
parent 22440541ea
commit 7a1c977ded
4 changed files with 121 additions and 17 deletions

View File

@ -4426,6 +4426,95 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait (
return true;
}
//============================================================================
namespace _VaultCreateSubAge {
void _CreateNodeCallback(ENetError result, void* state, void* param, RelVaultNode* node) {
if (IS_NET_ERROR(result)) {
LogMsg(kLogError, "CreateSubAge: Failed to create AgeLink (async)");
DEL(param);
return;
}
UInt32 ageInfoId = *(UInt32*)param;
// Add the children to the right places
VaultAddChildNode(node->nodeId, ageInfoId, 0, nil, nil);
if (RelVaultNode* saFldr = VaultGetAgeSubAgesFolderIncRef()) {
VaultAddChildNode(saFldr->nodeId, node->nodeId, 0, nil, nil);
saFldr->DecRef();
} else
LogMsg(kLogError, "CreateSubAge: Couldn't find SubAges folder (async)");
// Send the VaultNotify that the plNetLinkingMgr wants...
plVaultNotifyMsg * msg = NEWZERO(plVaultNotifyMsg);
msg->SetType(plVaultNotifyMsg::kRegisteredSubAgeLink);
msg->SetResultCode(result);
msg->GetArgs()->AddInt(plNetCommon::VaultTaskArgs::kAgeLinkNode, node->nodeId);
msg->Send();
DEL(param);
}
void _DownloadCallback(ENetError result, void* param) {
if (IS_NET_ERROR(result)) {
LogMsg(kLogError, "CreateSubAge: Failed to download age vault (async)");
DEL(param);
return;
}
// Create the AgeLink node
VaultCreateNode(plVault::kNodeType_AgeLink,
(FVaultCreateNodeCallback)_CreateNodeCallback,
nil,
param
);
}
void _InitAgeCallback(ENetError result, void* state, void* param, UInt32 ageVaultId, UInt32 ageInfoId) {
if (IS_NET_ERROR(result)) {
LogMsg(kLogError, "CreateSubAge: Failed to init age (async)");
return;
}
// Download age vault
VaultDownload(L"CreateSubAge",
ageInfoId,
(FVaultDownloadCallback)_DownloadCallback,
TRACKED_NEW UInt32(ageInfoId),
nil,
nil
);
}
}; // namespace _VaultCreateSubAge
bool VaultAgeFindOrCreateSubAgeLink(const plAgeInfoStruct* info, plAgeLinkStruct* link, const Uuid& parentUuid) {
using namespace _VaultCreateSubAge;
// First, try to find an already existing subage
if (RelVaultNode* rvnLink = VaultGetSubAgeLinkIncRef(info)) {
VaultAgeLinkNode accLink(rvnLink);
accLink.CopyTo(link);
if (RelVaultNode* rvnInfo = rvnLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) {
VaultAgeInfoNode accInfo(rvnInfo);
accInfo.CopyTo(link->GetAgeInfo());
rvnInfo->DecRef();
}
rvnLink->DecRef();
return true;
}
VaultInitAge(info,
parentUuid,
(FVaultInitAgeCallback)_InitAgeCallback,
nil,
nil
);
return false;
}
//============================================================================
namespace _VaultCreateChildAgeAndWait {

View File

@ -408,6 +408,7 @@ void VaultAgeUpdateAgeSDL (const class plStateDataRecord * rec);
unsigned VaultAgeGetAgeTime ();
RelVaultNode * VaultGetSubAgeLinkIncRef (const plAgeInfoStruct * info);
bool VaultAgeGetSubAgeLink (
const plAgeInfoStruct * info,
plAgeLinkStruct * link
@ -417,6 +418,7 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait (
plAgeLinkStruct * link,
const Uuid & parentAgeInstId
);
bool VaultAgeFindOrCreateSubAgeLink(const plAgeInfoStruct* info, plAgeLinkStruct* link, const Uuid& parentUuid);
bool VaultAgeFindOrCreateChildAgeLinkAndWait (
const wchar parentAgeName[], // nil --> current age, non-nil --> owned age by given name
const plAgeInfoStruct * info,