mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Hoikas' performance fixes
1) Asyncfixes https://github.com/H-uru/Plasma/pull/22 2) One small change from "LocalizationData String Stuff" (Simplifify wData in LocalizationXMLFile::HandleData) https://github.com/H-uru/Plasma/pull/229 3) Fix buddy-add stutter https://github.com/H-uru/Plasma/pull/346
This commit is contained in:
@ -365,7 +365,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);
|
||||
@ -379,6 +379,8 @@ void pyVault::SendToDevice( pyVaultNode& node, const char * deviceName )
|
||||
|
||||
wchar wDevName[256];
|
||||
StrToUnicode(wDevName, deviceName, arrsize(wDevName));
|
||||
|
||||
// Note: This actually blocks (~Hoikas)
|
||||
VaultPublishNode(node.GetNode()->nodeId, wDevName);
|
||||
}
|
||||
|
||||
@ -544,12 +546,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 )
|
||||
@ -561,7 +565,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 )
|
||||
@ -573,22 +577,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;
|
||||
@ -604,32 +618,32 @@ 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
|
||||
plAgeInfoStruct info;
|
||||
info.SetAgeFilename(kNeighborhoodAgeFilename);
|
||||
|
||||
// Note: This doesn't actually block (~Hoikas)
|
||||
VaultUnregisterOwnedAgeAndWait(&info);
|
||||
|
||||
// Register new hood
|
||||
@ -656,11 +670,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);
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,7 @@ pyVaultNode::pyVaultNodeOperationCallback::~pyVaultNodeOperationCallback()
|
||||
|
||||
void pyVaultNode::pyVaultNodeOperationCallback::VaultOperationStarted( UInt32 context )
|
||||
{
|
||||
fContext = context;
|
||||
if ( fCbObject )
|
||||
{
|
||||
// Call the callback.
|
||||
@ -407,6 +408,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);
|
||||
@ -437,21 +446,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
|
||||
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
|
||||
@ -468,14 +482,18 @@ 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
|
||||
{
|
||||
|
@ -85,12 +85,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 ();
|
||||
|
@ -92,15 +92,22 @@ hsBool pyVaultPlayerInfoListNode::HasPlayer( UInt32 playerID )
|
||||
return (rvn != nil);
|
||||
}
|
||||
|
||||
hsBool pyVaultPlayerInfoListNode::AddPlayer( UInt32 playerID )
|
||||
//==================================================================
|
||||
|
||||
static void IAddPlayer_NodesFound(ENetError result, void* param, unsigned nodeIdCount, const unsigned nodeIds[])
|
||||
{
|
||||
if (HasPlayer(playerID))
|
||||
return true;
|
||||
|
||||
if (!fNode)
|
||||
return false;
|
||||
|
||||
NetVaultNode * templateNode = NEWZERO(NetVaultNode);
|
||||
NetVaultNode* parent = static_cast<NetVaultNode*>(param);
|
||||
if (nodeIdCount)
|
||||
VaultAddChildNode(parent->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr);
|
||||
parent->DecRef();
|
||||
}
|
||||
|
||||
void pyVaultPlayerInfoListNode::AddPlayer( UInt32 playerID )
|
||||
{
|
||||
if (HasPlayer(playerID) || !fNode)
|
||||
return;
|
||||
|
||||
NetVaultNode* templateNode = new NetVaultNode();
|
||||
templateNode->IncRef();
|
||||
templateNode->SetNodeType(plVault::kNodeType_PlayerInfo);
|
||||
VaultPlayerInfoNode access(templateNode);
|
||||
@ -108,15 +115,14 @@ hsBool pyVaultPlayerInfoListNode::AddPlayer( UInt32 playerID )
|
||||
|
||||
ARRAY(unsigned) nodeIds;
|
||||
VaultLocalFindNodes(templateNode, &nodeIds);
|
||||
|
||||
if (!nodeIds.Count())
|
||||
VaultFindNodesAndWait(templateNode, &nodeIds);
|
||||
|
||||
|
||||
// So, if we know about this node, we can take it easy. If not, we lazy load it.
|
||||
if (nodeIds.Count())
|
||||
VaultAddChildNodeAndWait(fNode->nodeId, nodeIds[0], VaultGetPlayerId());
|
||||
|
||||
templateNode->DecRef();
|
||||
return nodeIds.Count() != 0;
|
||||
VaultAddChildNode(fNode->GetNodeId(), nodeIds[0], VaultGetPlayerId(), nullptr, nullptr);
|
||||
else {
|
||||
fNode->IncRef();
|
||||
VaultFindNodes(templateNode, IAddPlayer_NodesFound, fNode);
|
||||
}
|
||||
}
|
||||
|
||||
void pyVaultPlayerInfoListNode::RemovePlayer( UInt32 playerID )
|
||||
|
@ -82,8 +82,8 @@ public:
|
||||
//==================================================================
|
||||
// class RelVaultNode : public plVaultFolderNode
|
||||
//
|
||||
virtual hsBool HasPlayer( UInt32 playerID );
|
||||
hsBool AddPlayer( UInt32 playerID );
|
||||
hsBool HasPlayer( UInt32 playerID );
|
||||
void AddPlayer( UInt32 playerID );
|
||||
void RemovePlayer( UInt32 playerID );
|
||||
PyObject * GetPlayer( UInt32 playerID ); // returns pyVaultPlayerInfoNode
|
||||
|
||||
|
@ -81,7 +81,8 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoListNode, playerlistAddPlayer, args)
|
||||
PyErr_SetString(PyExc_TypeError, "playerlistAddPlayer expects an unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
PYTHON_RETURN_BOOL(self->fThis->AddPlayer(playerID));
|
||||
self->fThis->AddPlayer(playerID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoListNode, playerlistRemovePlayer, args)
|
||||
@ -126,7 +127,8 @@ PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoListNode, addPlayer, args)
|
||||
PyErr_SetString(PyExc_TypeError, "addPlayer expects an unsigned long");
|
||||
PYTHON_RETURN_ERROR;
|
||||
}
|
||||
PYTHON_RETURN_BOOL(self->fThis->AddPlayer(playerID));
|
||||
self->fThis->AddPlayer(playerID);
|
||||
PYTHON_RETURN_NONE;
|
||||
}
|
||||
|
||||
PYTHON_METHOD_DEFINITION(ptVaultPlayerInfoListNode, removePlayer, args)
|
||||
|
Reference in New Issue
Block a user