From 9cce806f84c780d90081c102999abc6bf0d80919 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Thu, 17 Aug 2023 22:54:05 +0200 Subject: [PATCH 1/7] Remove unused blocking ptVault.sendToDevice/VaultPublishNode --- Scripts/Python/plasma/Plasma.py | 4 ---- .../Plasma/FeatureLib/pfPython/pyVault.cpp | 10 --------- Sources/Plasma/FeatureLib/pfPython/pyVault.h | 3 --- .../FeatureLib/pfPython/pyVaultGlue.cpp | 20 ----------------- .../PubUtilLib/plVault/plVaultClientApi.cpp | 22 ------------------- .../PubUtilLib/plVault/plVaultClientApi.h | 4 ---- 6 files changed, 63 deletions(-) diff --git a/Scripts/Python/plasma/Plasma.py b/Scripts/Python/plasma/Plasma.py index ee12856ccf..317a93b921 100644 --- a/Scripts/Python/plasma/Plasma.py +++ b/Scripts/Python/plasma/Plasma.py @@ -6531,10 +6531,6 @@ def registerVisitAge(self,link): """Register this age as visitable by this player""" pass - def sendToDevice(self,node,deviceName): - """Sends a ptVaultNode object to an Age's device by deviceName.""" - pass - def setAgePublic(self,ageInfo,makePublic): """Makes the specified age public or private""" pass diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp index 282b263149..ab4631da5a 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp @@ -332,16 +332,6 @@ void pyVault::AddChronicleEntry(const ST::string& name, uint32_t type, const ST: } -void pyVault::SendToDevice(pyVaultNode& node, const ST::string& deviceName) -{ - if (!node.GetNode()) - return; - - // Note: This actually blocks (~Hoikas) - VaultPublishNode(node.GetNode()->GetNodeId(), deviceName); -} - - PyObject* pyVault::GetAgesICanVisitFolder() { PyObject * result = GetAgeInfoList(plVault::kAgesICanVisitFolder); diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVault.h b/Sources/Plasma/FeatureLib/pfPython/pyVault.h index c16a146e63..b2094f31c7 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVault.h +++ b/Sources/Plasma/FeatureLib/pfPython/pyVault.h @@ -122,9 +122,6 @@ class pyVault PyObject* FindChronicleEntry(const ST::string& entryName); // returns pyVaultChronicleNode void AddChronicleEntry(const ST::string& name, uint32_t type, const ST::string& value); /////////////// - // publishing - void SendToDevice(pyVaultNode& node, const ST::string& deviceName); - /////////////// // yeesha pages, etc. PyObject* GetPsnlAgeSDL() const; // returns pySDLStateDataRecord void UpdatePsnlAgeSDL( pySDLStateDataRecord & rec ); diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultGlue.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultGlue.cpp index 700d47a8ba..4c370591b7 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultGlue.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultGlue.cpp @@ -228,25 +228,6 @@ PYTHON_METHOD_DEFINITION(ptVault, findNode, args) return self->fThis->FindNode(templateNode); } -PYTHON_METHOD_DEFINITION(ptVault, sendToDevice, args) -{ - PyObject* nodeObj = nullptr; - ST::string deviceName; - if (!PyArg_ParseTuple(args, "OO&", &nodeObj, PyUnicode_STStringConverter, &deviceName)) - { - PyErr_SetString(PyExc_TypeError, "sendToDevice expects a ptVaultNode and a string"); - PYTHON_RETURN_ERROR; - } - if (!pyVaultNode::Check(nodeObj)) - { - PyErr_SetString(PyExc_TypeError, "sendToDevice expects a ptVaultNode and a string"); - PYTHON_RETURN_ERROR; - } - pyVaultNode* node = pyVaultNode::ConvertFrom(nodeObj); - self->fThis->SendToDevice(*node, deviceName); - PYTHON_RETURN_NONE; -} - PYTHON_METHOD_DEFINITION_NOARGS(ptVault, getPsnlAgeSDL) { return self->fThis->GetPsnlAgeSDL(); @@ -501,7 +482,6 @@ PYTHON_START_METHODS_TABLE(ptVault) PYTHON_BASIC_METHOD(ptVault, createGlobalInbox, "Creates the global inbox folder."), #endif PYTHON_METHOD(ptVault, findNode, "Params: templateNode\nFind the node matching the template"), - PYTHON_METHOD(ptVault, sendToDevice, "Params: node,deviceName\nSends a ptVaultNode object to an Age's device by deviceName."), PYTHON_METHOD_NOARGS(ptVault, getPsnlAgeSDL, "Returns the personal age SDL"), PYTHON_METHOD(ptVault, updatePsnlAgeSDL, "Params: pyrec\nUpdates the personal age SDL to the specified data"), PYTHON_METHOD_NOARGS(ptVault, inMyPersonalAge, "Are we in the player's personal age?"), diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index 04dc8a5ea5..da0f9e9a96 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -1790,28 +1790,6 @@ void VaultDeleteNode ( NetCliAuthVaultNodeDelete(nodeId); } -//============================================================================ -void VaultPublishNode ( - unsigned nodeId, - const ST::string& deviceName -) { - hsRef rvn; - - rvn = VaultAgeGetDeviceInbox(deviceName); - if (!rvn) { - LogMsg(kLogDebug, "Failed to find inbox for device {}, adding it on-the-fly", deviceName); - VaultAgeSetDeviceInboxAndWait(deviceName, DEFAULT_DEVICE_INBOX); - - rvn = VaultAgeGetDeviceInbox(deviceName); - if (!rvn) { - LogMsg(kLogDebug, "Failed to add inbox to device {} on-the-fly", deviceName); - return; - } - } - - VaultAddChildNode(rvn->GetNodeId(), nodeId, VaultGetPlayerId(), nullptr, nullptr); -} - //============================================================================ void VaultSendNode ( hsWeakRef srcNode, diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h index 90995cee57..a14195ee4d 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h @@ -243,10 +243,6 @@ void VaultSetNodeSeen ( void VaultDeleteNode ( unsigned nodeId ); -void VaultPublishNode ( - unsigned nodeId, - const ST::string& deviceName -); void VaultSendNode ( hsWeakRef srcNode, unsigned dstPlayerId From a141185558c2dd838ce4529f16a7c670d7108a98 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Thu, 17 Aug 2023 23:38:48 +0200 Subject: [PATCH 2/7] Make VaultAgeSetDeviceInbox non-blocking --- .../Plasma/FeatureLib/pfPython/pyAgeVault.cpp | 13 ++-- .../pfPython/pyVaultTextNoteNode.cpp | 13 ++-- .../PubUtilLib/plVault/plVaultClientApi.cpp | 74 +++++++++++++------ .../PubUtilLib/plVault/plVaultClientApi.h | 3 +- 4 files changed, 70 insertions(+), 33 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp index cbc55f1ffe..149b7e3b03 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp @@ -210,17 +210,20 @@ PyObject * pyAgeVault::GetDevice(const ST::string& deviceName) PYTHON_RETURN_NONE; } +static void _SetDeviceInboxCallback(ENetError result, hsRef inbox, void* param) +{ + auto cb = static_cast(param); + cb->SetNode(std::move(inbox)); + cb->VaultOperationComplete(result); +} + // Sets the inbox associated with a device. void pyAgeVault::SetDeviceInbox(const ST::string& deviceName, const ST::string& inboxName, PyObject * cbObject, uint32_t cbContext) { pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); cb->VaultOperationStarted( cbContext ); - if (hsRef rvn = VaultAgeSetDeviceInboxAndWait(deviceName, inboxName)) - cb->SetNode(rvn); - - // cb deletes itself here. - cb->VaultOperationComplete(cbContext, cb->GetNode() ? kNetSuccess : kNetErrInternalError); + VaultAgeSetDeviceInbox(deviceName, inboxName, _SetDeviceInboxCallback, cb); } PyObject * pyAgeVault::GetDeviceInbox(const ST::string& deviceName) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp index 533df5d2a6..65c9bc8454 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultTextNoteNode.cpp @@ -144,6 +144,13 @@ PyObject * pyVaultTextNoteNode::GetDeviceInbox() const PYTHON_RETURN_NONE; } +static void _SetDeviceInboxCallback(ENetError result, hsRef inbox, void* param) +{ + auto cb = static_cast(param); + cb->SetNode(std::move(inbox)); + cb->VaultOperationComplete(result); +} + void pyVaultTextNoteNode::SetDeviceInbox(const ST::string& devName, PyObject * cbObject, uint32_t cbContext) { if (!fNode) @@ -152,9 +159,5 @@ void pyVaultTextNoteNode::SetDeviceInbox(const ST::string& devName, PyObject * c pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); cb->VaultOperationStarted( cbContext ); - if (hsRef rvn = VaultAgeSetDeviceInboxAndWait(devName, DEFAULT_DEVICE_INBOX)) - cb->SetNode(rvn); - - // cb deletes itself here. - cb->VaultOperationComplete(cbContext, cb->GetNode() ? kNetSuccess : kNetErrInternalError); + VaultAgeSetDeviceInbox(devName, DEFAULT_DEVICE_INBOX, _SetDeviceInboxCallback, cb); } diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index da0f9e9a96..0643c56b8b 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -3740,36 +3740,66 @@ hsRef VaultAgeGetDevice (const ST::string& deviceName) { } //============================================================================ -hsRef VaultAgeSetDeviceInboxAndWait (const ST::string& deviceName, const ST::string& inboxName) { +namespace _VaultAgeSetDeviceInbox +{ + struct _Params + { + ST::string inboxName; + FVaultAgeSetDeviceInboxCallback callback; + void* param; + hsRef device; + hsRef inbox; + }; + + static void _AddDeviceInboxChildCallback(ENetError result, void* param) + { + _Params* p = static_cast<_Params*>(param); + p->callback(result, IS_NET_SUCCESS(result) ? std::move(p->inbox) : nullptr, p->param); + delete p; + } + + static void _CreateDefaultInboxCallback(ENetError result, void* state, void* param, hsWeakRef node) + { + _Params* p = static_cast<_Params*>(param); + if (IS_NET_SUCCESS(result)) { + VaultFolderNode access(node); + access.SetFolderName(p->inboxName); + access.SetFolderType(plVault::kDeviceInboxFolder); + + p->inbox = node; + VaultAddChildNode(p->device->GetNodeId(), node->GetNodeId(), 0, _AddDeviceInboxChildCallback, p); + } else { + p->callback(result, nullptr, p->param); + delete p; + } + } +} + +void VaultAgeSetDeviceInbox(const ST::string& deviceName, const ST::string& inboxName, FVaultAgeSetDeviceInboxCallback callback, void* param) +{ + using namespace _VaultAgeSetDeviceInbox; + s_ageDeviceInboxes[deviceName] = inboxName; // if we found the inbox or its a global inbox then return here, otherwise if its the default inbox and // it wasn't found then continue on and create the inbox hsRef existing = VaultAgeGetDeviceInbox(deviceName); - if (existing || inboxName != DEFAULT_DEVICE_INBOX) - return existing; - - hsRef device, inbox; - - for (;;) { - device = VaultAgeGetDevice(deviceName); - if (!device) - break; - - ENetError result; - inbox = VaultCreateNodeAndWait(plVault::kNodeType_Folder, &result); - if (!inbox) - break; - - VaultFolderNode access(inbox); - access.SetFolderName(inboxName); - access.SetFolderType(plVault::kDeviceInboxFolder); + if (existing) { + callback(kNetSuccess, std::move(existing), param); + return; + } else if (inboxName != DEFAULT_DEVICE_INBOX) { + callback(kNetErrVaultNodeNotFound, nullptr, param); + return; + } - VaultAddChildNodeAndWait(device->GetNodeId(), inbox->GetNodeId(), 0); - break; + hsRef device = VaultAgeGetDevice(deviceName); + if (!device) { + callback(kNetErrVaultNodeNotFound, nullptr, param); + return; } - return inbox; + _Params* p = new _Params {inboxName, callback, param, std::move(device)}; + VaultCreateNode(plVault::kNodeType_Folder, _CreateDefaultInboxCallback, nullptr, p); } //============================================================================ diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h index a14195ee4d..4b6b0dc75d 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h @@ -408,7 +408,8 @@ hsRef VaultAgeAddDeviceAndWait(const ST::string& deviceName); // void VaultAgeRemoveDevice (const ST::string& deviceName); bool VaultAgeHasDevice (const ST::string& deviceName); hsRef VaultAgeGetDevice(const ST::string& deviceName); -hsRef VaultAgeSetDeviceInboxAndWait(const ST::string& deviceName, const ST::string& inboxName); // blocks until completion +typedef void (*FVaultAgeSetDeviceInboxCallback)(ENetError result, hsRef inbox, void* param); +void VaultAgeSetDeviceInbox(const ST::string& deviceName, const ST::string& inboxName, FVaultAgeSetDeviceInboxCallback callback, void* param); hsRef VaultAgeGetDeviceInbox(const ST::string& deviceName); void VaultClearDeviceInboxMap (); From c2ed4b0eed3bf711920a621560dc1d79f3f3715c Mon Sep 17 00:00:00 2001 From: dgelessus Date: Fri, 18 Aug 2023 01:13:51 +0200 Subject: [PATCH 3/7] Make VaultAgeAddDevice non-blocking --- .../Plasma/FeatureLib/pfPython/pyAgeVault.cpp | 13 ++-- .../PubUtilLib/plVault/plVaultClientApi.cpp | 67 +++++++++++++------ .../PubUtilLib/plVault/plVaultClientApi.h | 3 +- 3 files changed, 57 insertions(+), 26 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp index 149b7e3b03..51b32d9cd4 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyAgeVault.cpp @@ -176,6 +176,13 @@ void pyAgeVault::AddChronicleEntry( const ST::string& name, uint32_t type, const VaultAddAgeChronicleEntry(name, type, value); } +static void _AddDeviceCallback(ENetError result, hsRef device, void* param) +{ + auto cb = static_cast(param); + cb->SetNode(std::move(device)); + cb->VaultOperationComplete(result); +} + // AGE DEVICES. AKA IMAGERS, WHATEVER. // Add a new device. void pyAgeVault::AddDevice(const ST::string& deviceName, PyObject * cbObject, uint32_t cbContext) @@ -183,11 +190,7 @@ void pyAgeVault::AddDevice(const ST::string& deviceName, PyObject * cbObject, ui pyVaultNode::pyVaultNodeOperationCallback * cb = new pyVaultNode::pyVaultNodeOperationCallback( cbObject ); cb->VaultOperationStarted( cbContext ); - if (hsRef rvn = VaultAgeAddDeviceAndWait(deviceName)) - cb->SetNode(rvn); - - // cb deletes itself here. - cb->VaultOperationComplete(cbContext, cb->GetNode() ? kNetSuccess : kNetErrInternalError); + VaultAgeAddDevice(deviceName, _AddDeviceCallback, cb); } // Remove a device. diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index 0643c56b8b..95754c7ba3 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -3668,31 +3668,58 @@ void VaultAddAgeChronicleEntry ( } //============================================================================ -hsRef VaultAgeAddDeviceAndWait (const ST::string& deviceName) { - if (hsRef existing = VaultAgeGetDevice(deviceName)) - return existing; - - hsRef device, folder; - - for (;;) { - folder = VaultGetAgeDevicesFolder(); - if (!folder) - break; +namespace _VaultAgeAddDevice +{ + struct _Params + { + ST::string deviceName; + FVaultAgeAddDeviceCallback callback; + void* param; + hsRef folder; + hsRef device; + }; - ENetError result; - device = VaultCreateNodeAndWait(plVault::kNodeType_TextNote, &result); - if (!device) - break; + static void _AddFolderDeviceChildCallback(ENetError result, void* param) + { + _Params* p = static_cast<_Params*>(param); + p->callback(result, IS_NET_SUCCESS(result) ? std::move(p->device) : nullptr, p->param); + delete p; + } - VaultTextNoteNode access(device); - access.SetNoteType(plVault::kNoteType_Device); - access.SetNoteTitle(deviceName); + static void _CreateDeviceCallback(ENetError result, void* state, void* param, hsWeakRef node) + { + _Params* p = static_cast<_Params*>(param); + if (IS_NET_SUCCESS(result)) { + VaultTextNoteNode access(node); + access.SetNoteType(plVault::kNoteType_Device); + access.SetNoteTitle(p->deviceName); - VaultAddChildNodeAndWait(folder->GetNodeId(), device->GetNodeId(), 0); - break; + p->device = node; + VaultAddChildNode(p->folder->GetNodeId(), node->GetNodeId(), 0, _AddFolderDeviceChildCallback, p); + } else { + p->callback(result, nullptr, p->param); + delete p; + } + } +} + +void VaultAgeAddDevice(const ST::string& deviceName, FVaultAgeAddDeviceCallback callback, void* param) +{ + using namespace _VaultAgeAddDevice; + + if (hsRef existing = VaultAgeGetDevice(deviceName)) { + callback(kNetSuccess, std::move(existing), param); + return; + } + + hsRef folder = VaultGetAgeDevicesFolder(); + if (!folder) { + callback(kNetErrVaultNodeNotFound, nullptr, param); + return; } - return device; + _Params* p = new _Params {deviceName, callback, param, std::move(folder)}; + VaultCreateNode(plVault::kNodeType_TextNote, _CreateDeviceCallback, nullptr, p); } //============================================================================ diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h index 4b6b0dc75d..19afc08977 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h @@ -404,7 +404,8 @@ void VaultAddAgeChronicleEntry ( int entryType, const ST::string& entryValue ); -hsRef VaultAgeAddDeviceAndWait(const ST::string& deviceName); // blocks until completion +typedef void (*FVaultAgeAddDeviceCallback)(ENetError result, hsRef device, void* param); +void VaultAgeAddDevice(const ST::string& deviceName, FVaultAgeAddDeviceCallback callback, void* param); void VaultAgeRemoveDevice (const ST::string& deviceName); bool VaultAgeHasDevice (const ST::string& deviceName); hsRef VaultAgeGetDevice(const ST::string& deviceName); From 97bd41b0600f7b35cb6dda00c3e8350b86b5ddeb Mon Sep 17 00:00:00 2001 From: dgelessus Date: Fri, 18 Aug 2023 01:19:31 +0200 Subject: [PATCH 4/7] Remove unused blocking variants of VaultAgeFindOrCreate*AgeLink --- .../PubUtilLib/plVault/plVaultClientApi.cpp | 479 ------------------ .../PubUtilLib/plVault/plVaultClientApi.h | 10 - 2 files changed, 489 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index 95754c7ba3..a32f5e2eb1 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -3925,228 +3925,6 @@ bool VaultAgeGetSubAgeLink (const plAgeInfoStruct * info, plAgeLinkStruct * link return result; } -//============================================================================ -namespace _VaultCreateSubAgeAndWait { - -struct _InitAgeParam { - ENetError result; - bool complete; - unsigned ageInfoId; -}; -static void _InitAgeCallback ( - ENetError result, - void * , - void * vparam, - unsigned ageVaultId, - unsigned ageInfoVaultId -) { - _InitAgeParam * param = (_InitAgeParam *)vparam; - param->ageInfoId = ageInfoVaultId; - param->result = result; - param->complete = true; -} -struct _FetchVaultParam { - ENetError result; - bool complete; -}; -static void _FetchVaultCallback ( - ENetError result, - void * vparam -) { - _FetchVaultParam * param = (_FetchVaultParam *)vparam; - param->result = result; - param->complete = true; -} -struct _CreateNodeParam { - ENetError result; - bool complete; - unsigned nodeId; -}; -static void _CreateNodeCallback ( - ENetError result, - void * , - void * vparam, - hsWeakRef node -) { - _CreateNodeParam * param = (_CreateNodeParam *)vparam; - if (IS_NET_SUCCESS(result)) - param->nodeId = node->GetNodeId(); - param->result = result; - param->complete = true; -} -struct _AddChildNodeParam { - ENetError result; - bool complete; -}; -static void _AddChildNodeCallback ( - ENetError result, - void * vparam -) { - _AddChildNodeParam * param = (_AddChildNodeParam *)vparam; - param->result = result; - param->complete = true; -} - -} // namespace _VaultCreateSubAgeAndWait - -//============================================================================ -bool VaultAgeFindOrCreateSubAgeLinkAndWait ( - const plAgeInfoStruct * info, - plAgeLinkStruct * link, - const plUUID& parentAgeInstId -) { - if (hsRef rvnLink = VaultFindAgeSubAgeLink(info)) { - VaultAgeLinkNode linkAcc(rvnLink); - linkAcc.CopyTo(link); - if (hsRef rvnInfo = rvnLink->GetChildNode(plVault::kNodeType_AgeInfo, 1)) { - VaultAgeInfoNode infoAcc(rvnInfo); - infoAcc.CopyTo(link->GetAgeInfo()); - return true; - } - } - - using namespace _VaultCreateSubAgeAndWait; - - unsigned subAgesId; - unsigned ageInfoId; - unsigned ageLinkId; - - if (hsRef rvnSubAges = VaultGetAgeSubAgesFolder()) - subAgesId = rvnSubAges->GetNodeId(); - else { - LogMsg(kLogError, "CreateSubAge: Failed to get ages's SubAges folder"); - return false; - } - - { // Init age vault - _InitAgeParam param; - memset(¶m, 0, sizeof(param)); - - VaultInitAge( - info, - parentAgeInstId, - _InitAgeCallback, - nullptr, - ¶m - ); - - while (!param.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param.result)) { - LogMsg(kLogError, "CreateSubAge: Failed to init age {}", link->GetAgeInfo()->GetAgeFilename()); - return false; - } - - ageInfoId = param.ageInfoId; - } - - { // Create age link - _CreateNodeParam param; - memset(¶m, 0, sizeof(param)); - - VaultCreateNode( - plVault::kNodeType_AgeLink, - _CreateNodeCallback, - nullptr, - ¶m - ); - - while (!param.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param.result)) { - LogMsg(kLogError, "CreateSubAge: Failed create age link node"); - return false; - } - - ageLinkId = param.nodeId; - } - - { // Fetch age info node tree - _FetchVaultParam param; - memset(¶m, 0, sizeof(param)); - - VaultDownload( - "CreateSubAge", - ageInfoId, - _FetchVaultCallback, - ¶m, - nullptr, - nullptr - ); - - while (!param.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param.result)) { - LogMsg(kLogError, "CreateSubAge: Failed to download age info vault"); - return false; - } - } - - { // Link: - // ageLink to ages's subages folder - // ageInfo to ageLink - _AddChildNodeParam param1; - _AddChildNodeParam param2; - memset(¶m1, 0, sizeof(param1)); - memset(¶m2, 0, sizeof(param2)); - - VaultAddChildNode( - subAgesId, - ageLinkId, - 0, - _AddChildNodeCallback, - ¶m1 - ); - - VaultAddChildNode( - ageLinkId, - ageInfoId, - 0, - _AddChildNodeCallback, - ¶m2 - ); - - while (!param1.complete && !param2.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param1.result)) { - LogMsg(kLogError, "CreateSubAge: Failed to add link to ages's subages"); - return false; - } - if (IS_NET_ERROR(param2.result)) { - LogMsg(kLogError, "CreateSubAge: Failed to add info to link"); - return false; - } - } - - if (hsRef rvnLink = VaultGetNode(ageLinkId)) { - VaultAgeLinkNode linkAcc(rvnLink); - linkAcc.CopyTo(link); - } - - if (hsRef rvnInfo = VaultGetNode(ageInfoId)) { - VaultAgeInfoNode infoAcc(rvnInfo); - infoAcc.CopyTo(link->GetAgeInfo()); - } - - return true; -} - //============================================================================ namespace _VaultCreateSubAge { void _CreateNodeCallback(ENetError result, void* state, void* param, hsWeakRef node) { @@ -4227,263 +4005,6 @@ bool VaultAgeFindOrCreateSubAgeLink(const plAgeInfoStruct* info, plAgeLinkStruct return false; } -//============================================================================ -namespace _VaultCreateChildAgeAndWait { - -struct _InitAgeParam { - ENetError result; - bool complete; - unsigned ageInfoId; -}; -static void _InitAgeCallback ( - ENetError result, - void * , - void * vparam, - unsigned ageVaultId, - unsigned ageInfoVaultId -) { - _InitAgeParam * param = (_InitAgeParam *)vparam; - param->ageInfoId = ageInfoVaultId; - param->result = result; - param->complete = true; -} -struct _FetchVaultParam { - ENetError result; - bool complete; -}; -static void _FetchVaultCallback ( - ENetError result, - void * vparam -) { - _FetchVaultParam * param = (_FetchVaultParam *)vparam; - param->result = result; - param->complete = true; -} -struct _CreateNodeParam { - ENetError result; - bool complete; - unsigned nodeId; -}; -static void _CreateNodeCallback ( - ENetError result, - void * , - void * vparam, - hsWeakRef node -) { - _CreateNodeParam * param = (_CreateNodeParam *)vparam; - if (IS_NET_SUCCESS(result)) - param->nodeId = node->GetNodeId(); - param->result = result; - param->complete = true; -} -struct _AddChildNodeParam { - ENetError result; - bool complete; -}; -static void _AddChildNodeCallback ( - ENetError result, - void * vparam -) { - _AddChildNodeParam * param = (_AddChildNodeParam *)vparam; - param->result = result; - param->complete = true; -} - -} // namespace _VaultCreateChildAgeAndWait - -//============================================================================ -bool VaultAgeFindOrCreateChildAgeLinkAndWait ( - const ST::string& parentAgeName, - const plAgeInfoStruct * info, - plAgeLinkStruct * link -) { - using namespace _VaultCreateChildAgeAndWait; - - unsigned childAgesId; - unsigned ageInfoId; - unsigned ageLinkId; - - { // Get id of child ages folder - hsRef rvnAgeInfo; - if (!parentAgeName.empty()) { - plAgeInfoStruct pinfo; - pinfo.SetAgeFilename(parentAgeName); - if (hsRef rvnAgeLink = VaultGetOwnedAgeLink(&pinfo)) - rvnAgeInfo = rvnAgeLink->GetChildNode(plVault::kNodeType_AgeInfo, 1); - } else { - rvnAgeInfo = VaultGetAgeInfoNode(); - } - - if (!rvnAgeInfo) { - LogMsg(kLogError, "CreateChildAge: Failed to get ages's AgeInfo node"); - return false; - } - - hsRef rvnChildAges; - if (rvnChildAges = rvnAgeInfo->GetChildAgeInfoListNode(plVault::kChildAgesFolder, 1)) { - childAgesId = rvnChildAges->GetNodeId(); - } - else { - LogMsg(kLogError, "CreateChildAge: Failed to get ages's ChildAges folder"); - return false; - } - - // Check for existing child age in folder - hsRef rvnLink; - NetVaultNode templateNode; - templateNode.SetNodeType(plVault::kNodeType_AgeInfo); - - VaultAgeInfoNode ageInfo(&templateNode); - ageInfo.SetAgeFilename(info->GetAgeFilename()); - - if (hsRef rvnInfo = rvnChildAges->GetChildNode(&templateNode, 2)) { - templateNode.Clear(); - templateNode.SetNodeType(plVault::kNodeType_AgeLink); - rvnLink = rvnInfo->GetParentNode(&templateNode, 1); - } - - if (rvnLink) { - VaultAgeLinkNode access(rvnLink); - access.CopyTo(link); - return true; - } - } - - { // Init age vault - _InitAgeParam param; - memset(¶m, 0, sizeof(param)); - - plUUID parentAgeInstId; - if (hsRef rvnAge = VaultGetAgeNode()) { - VaultAgeNode access(rvnAge); - parentAgeInstId = access.GetAgeInstanceGuid(); - } - - VaultInitAge( - info, - parentAgeInstId, - _InitAgeCallback, - nullptr, - ¶m - ); - - while (!param.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param.result)) { - LogMsg(kLogError, "CreateChildAge: Failed to init age {}", link->GetAgeInfo()->GetAgeFilename()); - return false; - } - - ageInfoId = param.ageInfoId; - } - - { // Create age link - _CreateNodeParam param; - memset(¶m, 0, sizeof(param)); - - VaultCreateNode( - plVault::kNodeType_AgeLink, - _CreateNodeCallback, - nullptr, - ¶m - ); - - while (!param.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param.result)) { - LogMsg(kLogError, "CreateChildAge: Failed create age link node"); - return false; - } - - ageLinkId = param.nodeId; - } - - { // Fetch age info node tree - _FetchVaultParam param; - memset(¶m, 0, sizeof(param)); - - VaultDownload( - "CreateChildAge", - ageInfoId, - _FetchVaultCallback, - ¶m, - nullptr, - nullptr - ); - - while (!param.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param.result)) { - LogMsg(kLogError, "CreateChildAge: Failed to download age info vault"); - return false; - } - } - - { // Link: - // ageLink to ages's subages folder - // ageInfo to ageLink - _AddChildNodeParam param1; - _AddChildNodeParam param2; - memset(¶m1, 0, sizeof(param1)); - memset(¶m2, 0, sizeof(param2)); - - VaultAddChildNode( - childAgesId, - ageLinkId, - 0, - _AddChildNodeCallback, - ¶m1 - ); - - VaultAddChildNode( - ageLinkId, - ageInfoId, - 0, - _AddChildNodeCallback, - ¶m2 - ); - - while (!param1.complete && !param2.complete) { - NetClientUpdate(); - plgDispatch::Dispatch()->MsgQueueProcess(); - std::this_thread::sleep_for(std::chrono::milliseconds(10)); - } - - if (IS_NET_ERROR(param1.result)) { - LogMsg(kLogError, "CreateChildAge: Failed to add link to ages's subages"); - return false; - } - if (IS_NET_ERROR(param2.result)) { - LogMsg(kLogError, "CreateChildAge: Failed to add info to link"); - return false; - } - } - - if (hsRef rvnLink = VaultGetNode(ageLinkId)) { - VaultAgeLinkNode linkAcc(rvnLink); - linkAcc.CopyTo(link); - } - - if (hsRef rvnInfo = VaultGetNode(ageInfoId)) { - VaultAgeInfoNode infoAcc(rvnInfo); - infoAcc.CopyTo(link->GetAgeInfo()); - } - - return true; -} - //============================================================================ namespace _VaultCreateChildAge { struct _Params { diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h index 19afc08977..982464126a 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h @@ -424,17 +424,7 @@ bool VaultAgeGetSubAgeLink ( const plAgeInfoStruct * info, plAgeLinkStruct * link ); -bool VaultAgeFindOrCreateSubAgeLinkAndWait ( - const plAgeInfoStruct * info, - plAgeLinkStruct * link, - const plUUID& parentAgeInstId -); bool VaultAgeFindOrCreateSubAgeLink(const plAgeInfoStruct* info, plAgeLinkStruct* link, const plUUID& arentUuid); -bool VaultAgeFindOrCreateChildAgeLinkAndWait ( - const ST::string& parentAgeName, // nil --> current age, non-nil --> owned age by given name - const plAgeInfoStruct * info, - plAgeLinkStruct * link -); enum class plVaultChildAgeLinkResult { kFailed, From a6fa60eb4649e27e475aa0146e6adaa221812ec2 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Fri, 18 Aug 2023 01:32:25 +0200 Subject: [PATCH 5/7] Rename vault functions that were called ...AndWait despite not blocking --- .../pfConsole/pfConsoleCommandsNet.cpp | 6 +++--- Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp | 4 ++-- Sources/Plasma/FeatureLib/pfPython/pyVault.cpp | 15 ++++++--------- .../FeatureLib/pfPython/pyVaultPlayerNode.cpp | 4 ++-- .../plInputCore/plSceneInputInterface.cpp | 2 +- .../PubUtilLib/plNetClient/plNetLinkingMgr.cpp | 2 +- .../PubUtilLib/plVault/plVaultClientApi.cpp | 16 ++++++++-------- .../Plasma/PubUtilLib/plVault/plVaultClientApi.h | 10 +++++----- 8 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp index 6b886075b8..24ac5a5159 100644 --- a/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp +++ b/Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp @@ -750,7 +750,7 @@ PF_CONSOLE_CMD( Net_Vault, "string stationName, string mtSpawnPt", "Register an MT Station with your Nexus" ) { - VaultRegisterMTStationAndWait(params[0], params[1]); + VaultRegisterMTStation(params[0], params[1]); PrintString("Registered MT Station."); } @@ -779,7 +779,7 @@ PF_CONSOLE_CMD( Net_Vault, { plAgeInfoStruct info; info.SetAgeFilename(params[0]); - bool success = VaultUnregisterOwnedAgeAndWait(&info); + bool success = VaultUnregisterOwnedAge(&info); PrintString(ST::format("Operation {}.", success ? "Successful" : "Failed")); } @@ -809,7 +809,7 @@ PF_CONSOLE_CMD( Net_Vault, info.SetAgeFilename(params[0]); unsigned count = 0; - while (VaultUnregisterVisitAgeAndWait(&info)) + while (VaultUnregisterVisitAge(&info)) ++count; PrintString(ST::format("Operation {}.", count > 0 ? "Successful" : "Failed")); diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index d99474d9ba..97958c8820 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -2195,7 +2195,7 @@ void cyMisc::GetPublicAgeList(const ST::string& ageName, PyObject * cbObject) // void cyMisc::CreatePublicAge( pyAgeInfoStruct * ageInfo, PyObject * cbObject ) { - VaultSetOwnedAgePublicAndWait(ageInfo->GetAgeInfo(), true); + VaultSetOwnedAgePublic(ageInfo->GetAgeInfo(), true); // TODO: make the callback here } @@ -2211,7 +2211,7 @@ void cyMisc::RemovePublicAge(const ST::string& ageInstanceGuid, PyObject * cbObj plAgeInfoStruct info; plUUID uuid(ageInstanceGuid); info.SetAgeInstanceGuid(&uuid); - VaultSetOwnedAgePublicAndWait(&info, false); + VaultSetOwnedAgePublic(&info, false); // TODO: make the callback here } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp index ab4631da5a..60f0eb6e71 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVault.cpp @@ -458,8 +458,7 @@ bool pyVault::AmAgeCzar( const pyAgeInfoStruct * ageInfo ) void pyVault::RegisterMTStation( const ST::string& stationName, const ST::string& backLinkSpawnPtObjName ) { - // Note: This doesn't actually block (~Hoikas) - VaultRegisterMTStationAndWait(stationName, backLinkSpawnPtObjName); + VaultRegisterMTStation(stationName, backLinkSpawnPtObjName); } void pyVault::RegisterOwnedAge( const pyAgeLinkStruct & link ) @@ -471,7 +470,7 @@ void pyVault::UnRegisterOwnedAge(const ST::string& ageFilename) { plAgeInfoStruct info; info.SetAgeFilename(ageFilename); - VaultUnregisterOwnedAgeAndWait(&info); + VaultUnregisterOwnedAge(&info); } void pyVault::RegisterVisitAge( const pyAgeLinkStruct & link ) @@ -484,7 +483,7 @@ void pyVault::UnRegisterVisitAge(const ST::string& guidstr) plAgeInfoStruct info; plUUID guid(guidstr); info.SetAgeInstanceGuid(&guid); - VaultUnregisterVisitAgeAndWait(&info); + VaultUnregisterVisitAge(&info); } //============================================================================ @@ -544,10 +543,9 @@ void pyVault::CreateNeighborhood() plNetClientMgr * nc = plNetClientMgr::GetInstance(); // Unregister old hood - // Note: This doesn't actually block (~Hoikas) plAgeInfoStruct info; info.SetAgeFilename(kNeighborhoodAgeFilename); - VaultUnregisterOwnedAgeAndWait(&info); + VaultUnregisterOwnedAge(&info); // Register new hood plAgeLinkStruct link; @@ -578,13 +576,12 @@ void pyVault::CreateNeighborhood() bool pyVault::SetAgePublic( const pyAgeInfoStruct * ageInfo, bool makePublic ) { - // Note: This doesn't actually block (~Hoikas) - return VaultSetOwnedAgePublicAndWait(ageInfo->GetAgeInfo(), makePublic); + return VaultSetOwnedAgePublic(ageInfo->GetAgeInfo(), makePublic); } bool pyVault::SetAgePublic( const pyVaultAgeInfoNode * ageInfoNode, bool makePublic ) { - return VaultSetAgePublicAndWait(ageInfoNode->GetNode(), makePublic); + return VaultSetAgePublic(ageInfoNode->GetNode(), makePublic); } diff --git a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp index 7f35e80186..35519cfcde 100644 --- a/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/pyVaultPlayerNode.cpp @@ -198,7 +198,7 @@ void pyVaultPlayerNode::RemoveOwnedAgeLink(const ST::string& ageFilename) { plAgeInfoStruct info; info.SetAgeFilename(ageFilename); - VaultUnregisterOwnedAgeAndWait(&info); + VaultUnregisterOwnedAge(&info); } PyObject *pyVaultPlayerNode::GetVisitAgeLink(const pyAgeInfoStruct *info) @@ -214,7 +214,7 @@ void pyVaultPlayerNode::RemoveVisitAgeLink(const ST::string& guidstr) plAgeInfoStruct info; plUUID guid(guidstr); info.SetAgeInstanceGuid(&guid); - VaultUnregisterOwnedAgeAndWait(&info); + VaultUnregisterOwnedAge(&info); } PyObject *pyVaultPlayerNode::FindChronicleEntry(const ST::string& entryName) diff --git a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp index 789367625d..2d81044fef 100644 --- a/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp +++ b/Sources/Plasma/PubUtilLib/plInputCore/plSceneInputInterface.cpp @@ -856,7 +856,7 @@ void plSceneInputInterface::ILinkOffereeToAge() // We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one. VaultAgeLinkNode linkAcc(linkNode); if (linkAcc.GetVolatile()) { - if (VaultUnregisterOwnedAgeAndWait(link.GetAgeInfo())) { + if (VaultUnregisterOwnedAge(link.GetAgeInfo())) { plUUID guid = plUUID::Generate(); link.GetAgeInfo()->SetAgeInstanceGuid(&guid); VaultRegisterOwnedAgeAndWait(&link); diff --git a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp index d6dbe9a03d..4ea52e673f 100644 --- a/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp +++ b/Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp @@ -975,7 +975,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink() // We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one. VaultAgeLinkNode linkAcc(linkNode); if (linkAcc.GetVolatile()) { - if (VaultUnregisterOwnedAgeAndWait(&ageInfo)) { + if (VaultUnregisterOwnedAge(&ageInfo)) { // Fill in fields for new age create. if (!info->HasAgeUserDefinedName()) { diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index a32f5e2eb1..3f631e99eb 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -2343,17 +2343,17 @@ bool VaultAddOwnedAgeSpawnPoint (const plUUID& ageInstId, const plSpawnPointInfo } //============================================================================ -bool VaultSetOwnedAgePublicAndWait (const plAgeInfoStruct * info, bool publicOrNot) { +bool VaultSetOwnedAgePublic(const plAgeInfoStruct* info, bool publicOrNot) { if (hsRef rvnLink = VaultGetOwnedAgeLink(info)) { if (hsRef rvnInfo = rvnLink->GetChildNode(plVault::kNodeType_AgeInfo, 1)) { - VaultSetAgePublicAndWait(rvnInfo, publicOrNot); + VaultSetAgePublic(rvnInfo, publicOrNot); } } return true; } //============================================================================ -bool VaultSetAgePublicAndWait(hsWeakRef ageInfoNode, bool publicOrNot) { +bool VaultSetAgePublic(hsWeakRef ageInfoNode, bool publicOrNot) { NetCliAuthSetAgePublic(ageInfoNode->GetNodeId(), publicOrNot); VaultAgeInfoNode access(ageInfoNode); @@ -3135,7 +3135,7 @@ void VaultRegisterVisitAge(const plAgeLinkStruct* link) { } //============================================================================ -bool VaultUnregisterOwnedAgeAndWait (const plAgeInfoStruct * info) { +bool VaultUnregisterOwnedAge(const plAgeInfoStruct* info) { unsigned ageLinkId = 0; unsigned agesIOwnId; @@ -3193,7 +3193,7 @@ bool VaultUnregisterOwnedAgeAndWait (const plAgeInfoStruct * info) { } //============================================================================ -bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info) { +bool VaultUnregisterVisitAge(const plAgeInfoStruct* info) { unsigned ageLinkId = 0; unsigned agesICanVisitId; @@ -3442,7 +3442,7 @@ bool VaultAmCzarOfAge (const plUUID& ageInstId) { } //============================================================================ -bool VaultRegisterMTStationAndWait ( +bool VaultRegisterMTStation( const ST::string& stationName, const ST::string& linkBackSpawnPtObjName ) { @@ -3477,7 +3477,7 @@ void VaultProcessUnvisitNote(hsWeakRef rvnUnVisit) { plAgeInfoStruct info; if (unvisitAcc.GetVisitInfo(&info)) { // Remove it from our "ages i can visit" folder - VaultUnregisterVisitAgeAndWait(&info); + VaultUnregisterVisitAge(&info); } // remove it from the inbox VaultRemoveChildNode(rvnInbox->GetNodeId(), rvnUnVisit->GetNodeId(), nullptr, nullptr); @@ -3519,7 +3519,7 @@ void VaultProcessPlayerInbox () { plAgeInfoStruct info; if (unvisitAcc.GetVisitInfo(&info)) { // Remove it from our "ages i can visit" folder - VaultUnregisterVisitAgeAndWait(&info); + VaultUnregisterVisitAge(&info); } // remove it from the inbox VaultRemoveChildNode(rvnInbox->GetNodeId(), rvnUnVisit->GetNodeId(), nullptr, nullptr); diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h index 982464126a..6152c99ff9 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.h @@ -339,16 +339,16 @@ hsRef VaultGetOwnedAgeLink(const plAgeInfoStruct * info); hsRef VaultGetOwnedAgeInfo(const plAgeInfoStruct * info); bool VaultGetOwnedAgeLink(const plAgeInfoStruct * info, plAgeLinkStruct * link); bool VaultAddOwnedAgeSpawnPoint(const plUUID& ageInstId, const plSpawnPointInfo & spawnPt); -bool VaultSetOwnedAgePublicAndWait(const plAgeInfoStruct * info, bool publicOrNot); -bool VaultSetAgePublicAndWait(hsWeakRef ageInfoNode, bool publicOrNot); +bool VaultSetOwnedAgePublic(const plAgeInfoStruct* info, bool publicOrNot); +bool VaultSetAgePublic(hsWeakRef ageInfoNode, bool publicOrNot); hsRef VaultGetVisitAgeLink(const plAgeInfoStruct * info); bool VaultGetVisitAgeLink(const plAgeInfoStruct * info, class plAgeLinkStruct * link); bool VaultRegisterOwnedAgeAndWait(const plAgeLinkStruct * link); void VaultRegisterOwnedAge(const plAgeLinkStruct* link); bool VaultRegisterVisitAgeAndWait(const plAgeLinkStruct * link); void VaultRegisterVisitAge(const plAgeLinkStruct* link); -bool VaultUnregisterOwnedAgeAndWait(const plAgeInfoStruct * info); -bool VaultUnregisterVisitAgeAndWait(const plAgeInfoStruct * info); +bool VaultUnregisterOwnedAge(const plAgeInfoStruct* info); +bool VaultUnregisterVisitAge(const plAgeInfoStruct* info); hsRef VaultFindChronicleEntry(const ST::string& entryName, int entryType = -1); bool VaultHasChronicleEntry(const ST::string& entryName, int entryType = -1); // if entry of same name and type already exists, value is updated @@ -369,7 +369,7 @@ bool VaultAmOwnerOfCurrentAge (); bool VaultAmCzarOfCurrentAge (); bool VaultAmOwnerOfAge (const plUUID& ageInstId); bool VaultAmCzarOfAge (const plUUID& ageInstId); -bool VaultRegisterMTStationAndWait ( +bool VaultRegisterMTStation( const ST::string& stationName, const ST::string& linkBackSpawnPtObjName ); From 9b8523cdf7493a2889e81f26abb884cb6a4d98c0 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 17 Sep 2023 00:11:41 +0200 Subject: [PATCH 6/7] Remove unused callbacks from PtCreatePublicAge/PtRemovePublicAge These callback parameters were ignored and no Python code defined a publicAgeCreated or publicAgeRemoved method. The public/private change notification is actually delivered as a plVaultNotifyMsg with type kPublicAgeCreated or kPublicAgeRemoved sent by VaultSetAgePublic. --- Scripts/Python/nxusBookMachine.py | 4 ++-- Scripts/Python/plasma/Plasma.py | 10 ++++----- Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp | 10 ++++----- Sources/Plasma/FeatureLib/pfPython/cyMisc.h | 8 +++---- .../FeatureLib/pfPython/cyMiscGlue4.cpp | 22 ++++++++----------- 5 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Scripts/Python/nxusBookMachine.py b/Scripts/Python/nxusBookMachine.py index 753ac75905..aca3e5250a 100644 --- a/Scripts/Python/nxusBookMachine.py +++ b/Scripts/Python/nxusBookMachine.py @@ -581,14 +581,14 @@ def IMakeHoodPublic(self): hoodInfo = self.IGetHoodInfoNode() if hoodInfo is not None: infoStruct = hoodInfo.asAgeInfoStruct() - PtCreatePublicAge(infoStruct, self) + PtCreatePublicAge(infoStruct) def IMakeHoodPrivate(self): hoodInfo = self.IGetHoodInfoNode() if hoodInfo is not None: guid = hoodInfo.getAgeInstanceGuid() - PtRemovePublicAge(guid, self) + PtRemovePublicAge(guid) def IPublicAgeCreated(self, ageName): PtDebugPrint("IPublicAgeCreated: " + ageName) diff --git a/Scripts/Python/plasma/Plasma.py b/Scripts/Python/plasma/Plasma.py index 317a93b921..513d9ed2af 100644 --- a/Scripts/Python/plasma/Plasma.py +++ b/Scripts/Python/plasma/Plasma.py @@ -164,9 +164,8 @@ def PtCreatePlayer(playerName, avatarShape, invitation): """Creates a new player""" pass -def PtCreatePublicAge(ageInfo, cbObject=None): - """Create a public instance of the given age. -cbObject, if supplied should have a member called publicAgeCreated(self,ageInfo)""" +def PtCreatePublicAge(ageInfo): + """Create a public instance of the given age.""" pass def PtDebugAssert(cond, msg): @@ -686,9 +685,8 @@ def PtRecenterCamera(): """re-centers the camera""" pass -def PtRemovePublicAge(ageInstanceGuid, cbObject=None): - """Remove a public instance of the given age. -cbObject, if supplied should have a member called publicAgeRemoved(self,ageInstanceGuid)""" +def PtRemovePublicAge(ageInstanceGuid): + """Remove a public instance of the given age.""" pass def PtRequestLOSScreen(selfKey,ID,xPos,yPos,distance,what,reportType): diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp index 97958c8820..86f1bde52a 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp @@ -2189,30 +2189,28 @@ void cyMisc::GetPublicAgeList(const ST::string& ageName, PyObject * cbObject) ////////////////////////////////////////////////////////////////////////////// // // Function : CreatePublicAge -// PARAMETERS : ageInfo, callback object +// PARAMETERS : ageInfo // // PURPOSE : Add a public age to the list of available ones. // -void cyMisc::CreatePublicAge( pyAgeInfoStruct * ageInfo, PyObject * cbObject ) +void cyMisc::CreatePublicAge(pyAgeInfoStruct* ageInfo) { VaultSetOwnedAgePublic(ageInfo->GetAgeInfo(), true); - // TODO: make the callback here } ////////////////////////////////////////////////////////////////////////////// // // Function : RemovePublicAge -// PARAMETERS : ageInstanceGuid, callback object +// PARAMETERS : ageInstanceGuid // // PURPOSE : Remove a public age from the list of available ones. // -void cyMisc::RemovePublicAge(const ST::string& ageInstanceGuid, PyObject * cbObject/*=nullptr */) +void cyMisc::RemovePublicAge(const ST::string& ageInstanceGuid) { plAgeInfoStruct info; plUUID uuid(ageInstanceGuid); info.SetAgeInstanceGuid(&uuid); VaultSetOwnedAgePublic(&info, false); - // TODO: make the callback here } int cyMisc::GetKILevel() diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h index ce43fbbd41..91d21f9e04 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMisc.h +++ b/Sources/Plasma/FeatureLib/pfPython/cyMisc.h @@ -753,20 +753,20 @@ class cyMisc ////////////////////////////////////////////////////////////////////////////// // // Function : CreatePublicAge - // PARAMETERS : ageInfo, callback object + // PARAMETERS : ageInfo // // PURPOSE : Add a public age to the list of available ones. // - static void CreatePublicAge(pyAgeInfoStruct * ageInfo, PyObject * cbObject = nullptr); + static void CreatePublicAge(pyAgeInfoStruct* ageInfo); ////////////////////////////////////////////////////////////////////////////// // // Function : RemovePublicAge - // PARAMETERS : ageInstanceGuid, callback object + // PARAMETERS : ageInstanceGuid // // PURPOSE : Remove a public age from the list of available ones. // - static void RemovePublicAge(const ST::string& ageInstanceGuid, PyObject * cbObject = nullptr); + static void RemovePublicAge(const ST::string& ageInstanceGuid); ////////////////////////////////////////////////////////////////////////////// // diff --git a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp index ab150b4a22..440c7ee68b 100644 --- a/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp +++ b/Sources/Plasma/FeatureLib/pfPython/cyMiscGlue4.cpp @@ -243,37 +243,33 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtGetPublicAgeList, args, "Params: ageName, cbOb PYTHON_RETURN_NONE; } -PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePublicAge, args, "Params: ageInfo, cbObject=None\nCreate a public instance of the given age.\n" - "cbObject, if supplied should have a member called publicAgeCreated(self,ageInfo)") +PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePublicAge, args, "Params: ageInfo\nCreate a public instance of the given age.") { PyObject* ageInfoObj = nullptr; - PyObject* cbObject = nullptr; - if (!PyArg_ParseTuple(args, "O|O", &ageInfoObj, &cbObject)) + if (!PyArg_ParseTuple(args, "O", &ageInfoObj)) { - PyErr_SetString(PyExc_TypeError, "PtCreatePublicAge expects a ptAgeInfoStruct object and an optional object with a publicAgeCreated() method"); + PyErr_SetString(PyExc_TypeError, "PtCreatePublicAge expects a ptAgeInfoStruct object"); PYTHON_RETURN_ERROR; } if (!pyAgeInfoStruct::Check(ageInfoObj)) { - PyErr_SetString(PyExc_TypeError, "PtCreatePublicAge expects a ptAgeInfoStruct object and an optional object with a publicAgeCreated() method"); + PyErr_SetString(PyExc_TypeError, "PtCreatePublicAge expects a ptAgeInfoStruct object"); PYTHON_RETURN_ERROR; } pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj); - cyMisc::CreatePublicAge(ageInfo, cbObject); + cyMisc::CreatePublicAge(ageInfo); PYTHON_RETURN_NONE; } -PYTHON_GLOBAL_METHOD_DEFINITION(PtRemovePublicAge, args, "Params: ageInstanceGuid, cbObject=None\nRemove a public instance of the given age.\n" - "cbObject, if supplied should have a member called publicAgeRemoved(self,ageInstanceGuid)") +PYTHON_GLOBAL_METHOD_DEFINITION(PtRemovePublicAge, args, "Params: ageInstanceGuid\nRemove a public instance of the given age.") { ST::string ageInstanceGUID; - PyObject* cbObject = nullptr; - if (!PyArg_ParseTuple(args, "O&|O", PyUnicode_STStringConverter, &ageInstanceGUID, &cbObject)) + if (!PyArg_ParseTuple(args, "O&", PyUnicode_STStringConverter, &ageInstanceGUID)) { - PyErr_SetString(PyExc_TypeError, "PtRemovePublicAge expects a string and an optional object with a publicAgeRemoved() method"); + PyErr_SetString(PyExc_TypeError, "PtRemovePublicAge expects a string"); PYTHON_RETURN_ERROR; } - cyMisc::RemovePublicAge(ageInstanceGUID, cbObject); + cyMisc::RemovePublicAge(ageInstanceGUID); PYTHON_RETURN_NONE; } From 30777dc88ca3654d990a9225aa537291a7dea1bc Mon Sep 17 00:00:00 2001 From: dgelessus Date: Sun, 17 Sep 2023 02:57:11 +0200 Subject: [PATCH 7/7] Fix nb01DRCImager not using ptAgeVault.addDevice callback correctly --- Scripts/Python/nb01DRCImager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Scripts/Python/nb01DRCImager.py b/Scripts/Python/nb01DRCImager.py index 01c8f16b50..27b74e2076 100644 --- a/Scripts/Python/nb01DRCImager.py +++ b/Scripts/Python/nb01DRCImager.py @@ -71,6 +71,10 @@ def doneAddingDevice(node,nodeRef,resultCode): "initializes new imager device with default inbox folder." PtDebugPrint("nb01DRCImager: doneAddingDevice, result code = %d" % resultCode) + if resultCode == 0: + PtDebugPrint("nb01DRCImager: doneAddingDevice, setting device inbox - %s" % ("DRCImagerState%d" % nb01DRCImager.Instance.current_state)) + ptAgeVault().setDeviceInbox("DRCImager", "DRCImagerState%d" % nb01DRCImager.Instance.current_state, doneSettingDeviceInbox) + #==================================== class nb01DRCImager(ptModifier): Instance = None @@ -156,8 +160,6 @@ def OnServerInitComplete(self): PtDebugPrint("nb01DRCImager.OnServerInitComplete: Adding device") ptAgeVault().addDevice("DRCImager",doneAddingDevice) - PtDebugPrint("nb01DRCImager.OnServerInitComplete: Setting device inbox - %s" % ("DRCImagerState%d" % self.current_state)) - ptAgeVault().setDeviceInbox("DRCImager", "DRCImagerState%d" % self.current_state, doneSettingDeviceInbox) def OnTimer(self,id): PtDebugPrint("nb01DRCImager.OnTimer executing")