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

Merge pull request #22 from Hoikas/asyncfixes

This commit is contained in:
Branan Purvine-Riley
2011-05-25 18:17:03 -07:00
10 changed files with 790 additions and 162 deletions

View File

@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSDL/plSDL.h"
//============================================================================
static PyObject * GetFolder (unsigned folderType) {
PyObject * result = nil;
@ -349,7 +348,7 @@ void pyVault::AddChronicleEntry( const char * name, UInt32 type, const char * va
wchar * wEntryName = StrDupToUnicode(name);
wchar * wEntryValue = StrDupToUnicode(value);
VaultAddChronicleEntryAndWait(wEntryName, type, wEntryValue);
VaultAddChronicleEntry(wEntryName, type, wEntryValue);
FREE(wEntryName);
FREE(wEntryValue);
@ -362,7 +361,9 @@ void pyVault::SendToDevice( pyVaultNode& node, const char * deviceName )
return;
wchar wDevName[256];
StrToUnicode(wDevName, deviceName, arrsize(wDevName));
StrToUnicode(wDevName, deviceName, arrsize(wDevName));
// Note: This actually blocks (~Hoikas)
VaultPublishNode(node.GetNode()->nodeId, wDevName);
}
@ -528,12 +529,14 @@ void pyVault::RegisterMTStation( const char * stationName, const char * backLink
wchar wSpawnPt[256];
StrToUnicode(wStationName, stationName, arrsize(wStationName));
StrToUnicode(wSpawnPt, backLinkSpawnPtObjName, arrsize(wSpawnPt));
// Note: This doesn't actually block (~Hoikas)
VaultRegisterMTStationAndWait( wStationName, wSpawnPt);
}
void pyVault::RegisterOwnedAge( const pyAgeLinkStruct & link )
{
VaultRegisterOwnedAgeAndWait(link.GetAgeLink());
VaultRegisterOwnedAge(link.GetAgeLink());
}
void pyVault::UnRegisterOwnedAge( const char * ageFilename )
@ -545,7 +548,7 @@ void pyVault::UnRegisterOwnedAge( const char * ageFilename )
void pyVault::RegisterVisitAge( const pyAgeLinkStruct & link )
{
VaultRegisterVisitAgeAndWait(link.GetAgeLink());
VaultRegisterVisitAge(link.GetAgeLink());
}
void pyVault::UnRegisterVisitAge( const char * guidstr )
@ -557,22 +560,32 @@ void pyVault::UnRegisterVisitAge( const char * guidstr )
VaultUnregisterVisitAgeAndWait(&info);
}
//============================================================================
void _InvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node)
{
if (result == kNetSuccess)
VaultSendNode(node, (UInt32)param);
}
void pyVault::InvitePlayerToAge( const pyAgeLinkStruct & link, UInt32 playerID )
{
ENetError error;
NetVaultNode * templateNode = NEWZERO(NetVaultNode);
templateNode->IncRef();
templateNode->SetNodeType(plVault::kNodeType_TextNote);
VaultTextNoteNode visitAcc(templateNode);
visitAcc.SetNoteType(plVault::kNoteType_Visit);
visitAcc.SetVisitInfo(*link.GetAgeLink()->GetAgeInfo());
if (RelVaultNode * rvn = VaultCreateNodeAndWaitIncRef(templateNode, &error)) {
VaultSendNode(rvn, playerID);
rvn->DecRef();
}
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_InvitePlayerToAge, nil, (void*)playerID);
templateNode->DecRef();
}
//============================================================================
void _UninvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node)
{
if (result == kNetSuccess)
VaultSendNode(node, (UInt32)param);
}
void pyVault::UnInvitePlayerToAge( const char * str, UInt32 playerID )
{
plAgeInfoStruct info;
@ -588,30 +601,29 @@ void pyVault::UnInvitePlayerToAge( const char * str, UInt32 playerID )
rvnLink->DecRef();
}
ENetError error;
NetVaultNode * templateNode = NEWZERO(NetVaultNode);
templateNode->IncRef();
templateNode->SetNodeType(plVault::kNodeType_TextNote);
VaultTextNoteNode visitAcc(templateNode);
visitAcc.SetNoteType(plVault::kNoteType_UnVisit);
visitAcc.SetVisitInfo(info);
if (RelVaultNode * rvn = VaultCreateNodeAndWaitIncRef(templateNode, &error)) {
VaultSendNode(rvn, playerID);
rvn->DecRef();
}
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_UninvitePlayerToAge, nil, (void*)playerID);
templateNode->DecRef();
}
//============================================================================
void pyVault::OfferLinkToPlayer( const pyAgeLinkStruct & link, UInt32 playerID )
{
hsAssert(false, "eric, port me");
}
//============================================================================
void pyVault::CreateNeighborhood()
{
plNetClientMgr * nc = plNetClientMgr::GetInstance();
// Unregister old hood
// Unregister old hood
// Note: This doesn't actually block (~Hoikas)
plAgeInfoStruct info;
info.SetAgeFilename(kNeighborhoodAgeFilename);
VaultUnregisterOwnedAgeAndWait(&info);
@ -640,11 +652,12 @@ void pyVault::CreateNeighborhood()
link.GetAgeInfo()->SetAgeUserDefinedName( title.c_str() );
link.GetAgeInfo()->SetAgeDescription( desc.c_str() );
VaultRegisterOwnedAgeAndWait(&link);
VaultRegisterOwnedAge(&link);
}
bool pyVault::SetAgePublic( const pyAgeInfoStruct * ageInfo, bool makePublic )
{
// Note: This doesn't actually block (~Hoikas)
return VaultSetOwnedAgePublicAndWait(ageInfo->GetAgeInfo(), makePublic);
}

View File

@ -54,7 +54,6 @@ class pyAgeLinkStruct;
class pySDLStateDataRecord;
class pyVault
{
#ifndef BUILDING_PYPLASMA

View File

@ -92,6 +92,7 @@ pyVaultNode::pyVaultNodeOperationCallback::~pyVaultNodeOperationCallback()
void pyVaultNode::pyVaultNodeOperationCallback::VaultOperationStarted( UInt32 context )
{
fContext = context;
if ( fCbObject )
{
// Call the callback.
@ -391,6 +392,14 @@ void pyVaultNode::SetCreateAgeGuid( const char * v )
// Vault Node API
// Add child node
void _AddNodeCallback(ENetError result, void* param) {
pyVaultNode::pyVaultNodeOperationCallback* cb = (pyVaultNode::pyVaultNodeOperationCallback*)param;
if (IS_NET_SUCCESS(result))
cb->VaultOperationComplete(hsOK);
else
cb->VaultOperationComplete(hsFail);
}
PyObject* pyVaultNode::AddNode(pyVaultNode* pynode, PyObject* cbObject, UInt32 cbContext)
{
pyVaultNodeOperationCallback * cb = NEWZERO(pyVaultNodeOperationCallback)(cbObject);
@ -421,21 +430,26 @@ PyObject* pyVaultNode::AddNode(pyVaultNode* pynode, PyObject* cbObject, UInt32 c
}
}
// Block here until we have the child node =(
VaultAddChildNodeAndWait(fNode->nodeId, pynode->fNode->nodeId, NetCommGetPlayer()->playerInt);
PyObject * nodeRef = cb->fPyNodeRef = pyVaultNodeRef::New(fNode, pynode->fNode);
Py_INCREF(nodeRef); // incref it, because we MUST return a new PyObject, and the callback "steals" the ref from us
PyObject* nodeRef = cb->fPyNodeRef = pyVaultNodeRef::New(fNode, pynode->fNode);
Py_INCREF(nodeRef); // The callback steals the ref, according to Eric...
cb->SetNode(pynode->fNode);
cb->VaultOperationComplete(cbContext, hsResult);
VaultAddChildNode(fNode->nodeId,
pynode->fNode->nodeId,
NetCommGetPlayer()->playerInt,
(FVaultAddChildNodeCallback)_AddNodeCallback,
cb
);
// Evil undocumented functionality that some fool
// decided to use in xKI.py. Really???
return nodeRef;
}
else
{
// manually make the callback
cb->VaultOperationStarted( cbContext );
cb->VaultOperationComplete( cbContext, hsFail );
cb->VaultOperationComplete(hsFail);
}
// just return a None object
@ -451,15 +465,19 @@ void pyVaultNode::LinkToNode(int nodeID, PyObject* cbObject, UInt32 cbContext)
{
// Hack the callbacks until vault notification is in place
cb->VaultOperationStarted( cbContext );
VaultAddChildNodeAndWait(fNode->nodeId, nodeID, NetCommGetPlayer()->playerInt);
if (RelVaultNode * rvn = VaultGetNodeIncRef(nodeID)) {
cb->SetNode(rvn);
cb->fPyNodeRef = pyVaultNodeRef::New(fNode, rvn);
rvn->DecRef();
}
cb->VaultOperationComplete( cbContext, hsOK );
VaultAddChildNode(fNode->nodeId,
nodeID,
NetCommGetPlayer()->playerInt,
(FVaultAddChildNodeCallback)_AddNodeCallback,
cb
);
}
else
{

View File

@ -69,12 +69,14 @@ public:
PyObject * fCbObject;
RelVaultNode * fNode;
PyObject * fPyNodeRef;
UInt32 fContext;
pyVaultNodeOperationCallback(PyObject * cbObject);
~pyVaultNodeOperationCallback();
void VaultOperationStarted(UInt32 context);
void VaultOperationComplete(UInt32 context, int resultCode);
void VaultOperationComplete(int resultCode) { VaultOperationComplete(fContext, resultCode); }
void SetNode (RelVaultNode * rvn);
RelVaultNode * GetNode ();