Browse Source

Remove UInts from the heap in the callback code

Adam Johnson 14 years ago
parent
commit
799a3d13b4
  1. 24
      Sources/Plasma/FeatureLib/pfPython/pyVault.cpp
  2. 10
      Sources/Plasma/FeatureLib/pfPython/pyVault.h
  3. 43
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

24
Sources/Plasma/FeatureLib/pfPython/pyVault.cpp

@ -561,6 +561,12 @@ void pyVault::UnRegisterVisitAge( const char * guidstr )
} }
//============================================================================ //============================================================================
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 ) void pyVault::InvitePlayerToAge( const pyAgeLinkStruct & link, UInt32 playerID )
{ {
NetVaultNode * templateNode = NEWZERO(NetVaultNode); NetVaultNode * templateNode = NEWZERO(NetVaultNode);
@ -569,18 +575,17 @@ void pyVault::InvitePlayerToAge( const pyAgeLinkStruct & link, UInt32 playerID )
VaultTextNoteNode visitAcc(templateNode); VaultTextNoteNode visitAcc(templateNode);
visitAcc.SetNoteType(plVault::kNoteType_Visit); visitAcc.SetNoteType(plVault::kNoteType_Visit);
visitAcc.SetVisitInfo(*link.GetAgeLink()->GetAgeInfo()); visitAcc.SetVisitInfo(*link.GetAgeLink()->GetAgeInfo());
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_InvitePlayerToAge, nil, TRACKED_NEW UInt32(playerID)); VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_InvitePlayerToAge, nil, (void*)playerID);
templateNode->DecRef(); templateNode->DecRef();
} }
void _InvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node) //============================================================================
void _UninvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node)
{ {
if (result == kNetSuccess) if (result == kNetSuccess)
VaultSendNode(node, *((UInt32*)param)); VaultSendNode(node, (UInt32)param);
delete param;
} }
//============================================================================
void pyVault::UnInvitePlayerToAge( const char * str, UInt32 playerID ) void pyVault::UnInvitePlayerToAge( const char * str, UInt32 playerID )
{ {
plAgeInfoStruct info; plAgeInfoStruct info;
@ -602,17 +607,10 @@ void pyVault::UnInvitePlayerToAge( const char * str, UInt32 playerID )
VaultTextNoteNode visitAcc(templateNode); VaultTextNoteNode visitAcc(templateNode);
visitAcc.SetNoteType(plVault::kNoteType_UnVisit); visitAcc.SetNoteType(plVault::kNoteType_UnVisit);
visitAcc.SetVisitInfo(info); visitAcc.SetVisitInfo(info);
VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_UninvitePlayerToAge, nil, TRACKED_NEW UInt32(playerID)); VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_UninvitePlayerToAge, nil, (void*)playerID);
templateNode->DecRef(); templateNode->DecRef();
} }
void _UninvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node)
{
if (result == kNetSuccess)
VaultSendNode(node, *((UInt32*)param));
delete param;
}
//============================================================================ //============================================================================
void pyVault::OfferLinkToPlayer( const pyAgeLinkStruct & link, UInt32 playerID ) void pyVault::OfferLinkToPlayer( const pyAgeLinkStruct & link, UInt32 playerID )
{ {

10
Sources/Plasma/FeatureLib/pfPython/pyVault.h

@ -54,16 +54,6 @@ class pyAgeLinkStruct;
class pySDLStateDataRecord; class pySDLStateDataRecord;
// Async Helpers... :)
#ifndef BUILDING_PYPLASMA
enum ENetError;
struct RelVaultNode;
void _InvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node);
void _UninvitePlayerToAge(ENetError result, void* state, void* param, RelVaultNode* node);
#endif // BUILDING_PYPLASMA
class pyVault class pyVault
{ {
#ifndef BUILDING_PYPLASMA #ifndef BUILDING_PYPLASMA

43
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

@ -2790,11 +2790,10 @@ bool VaultRegisterOwnedAgeAndWait (const plAgeLinkStruct * link) {
namespace _VaultRegisterOwnedAge { namespace _VaultRegisterOwnedAge {
struct _Params { struct _Params {
plSpawnPointInfo* fSpawn; plSpawnPointInfo* fSpawn;
UInt32* fAgeInfoId; void* fAgeInfoId;
~_Params() { ~_Params() {
DEL(fSpawn); DEL(fSpawn);
DEL(fAgeInfoId);
} }
}; };
@ -2831,10 +2830,10 @@ namespace _VaultRegisterOwnedAge {
RelVaultNode* agesIOwn = VaultGetAgesIOwnFolderIncRef(); RelVaultNode* agesIOwn = VaultGetAgesIOwnFolderIncRef();
RelVaultNode* plyrInfo = VaultGetPlayerInfoNodeIncRef(); RelVaultNode* plyrInfo = VaultGetPlayerInfoNodeIncRef();
VaultAddChildNode(agesIOwn->nodeId, node->nodeId, 0, (FVaultAddChildNodeCallback)_AddAgeLinkNode, nil); VaultAddChildNode(agesIOwn->nodeId, node->nodeId, 0, (FVaultAddChildNodeCallback)_AddAgeLinkNode, nil);
VaultAddChildNode(node->nodeId, *(p->fAgeInfoId), 0, (FVaultAddChildNodeCallback)_AddAgeInfoNode, nil); VaultAddChildNode(node->nodeId, (UInt32)p->fAgeInfoId, 0, (FVaultAddChildNodeCallback)_AddAgeInfoNode, nil);
// Add our PlayerInfo to important places // Add our PlayerInfo to important places
if (RelVaultNode* rvnAgeInfo = VaultGetNodeIncRef(*(p->fAgeInfoId))) { if (RelVaultNode* rvnAgeInfo = VaultGetNodeIncRef((UInt32)p->fAgeInfoId)) {
if (RelVaultNode* rvnAgeOwners = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kAgeOwnersFolder, 1)) { if (RelVaultNode* rvnAgeOwners = rvnAgeInfo->GetChildPlayerInfoListNodeIncRef(plVault::kAgeOwnersFolder, 1)) {
VaultAddChildNode(rvnAgeOwners->nodeId, plyrInfo->nodeId, 0, (FVaultAddChildNodeCallback)_AddPlayerInfoNode, nil); VaultAddChildNode(rvnAgeOwners->nodeId, plyrInfo->nodeId, 0, (FVaultAddChildNodeCallback)_AddPlayerInfoNode, nil);
rvnAgeOwners->DecRef(); rvnAgeOwners->DecRef();
@ -2867,7 +2866,7 @@ namespace _VaultRegisterOwnedAge {
void _InitAgeCallback(ENetError result, void* state, void* param, UInt32 ageVaultId, UInt32 ageInfoVaultId) { void _InitAgeCallback(ENetError result, void* state, void* param, UInt32 ageVaultId, UInt32 ageInfoVaultId) {
if (IS_NET_SUCCESS(result)) { if (IS_NET_SUCCESS(result)) {
_Params* p = TRACKED_NEW _Params(); _Params* p = TRACKED_NEW _Params();
p->fAgeInfoId = TRACKED_NEW UInt32(ageInfoVaultId); p->fAgeInfoId = (void*)ageInfoVaultId;
p->fSpawn = (plSpawnPointInfo*)param; p->fSpawn = (plSpawnPointInfo*)param;
VaultDownload( VaultDownload(
@ -3165,11 +3164,10 @@ namespace _VaultRegisterVisitAge {
struct _Params { struct _Params {
plSpawnPointInfo* fSpawn; plSpawnPointInfo* fSpawn;
UInt32* fAgeInfoId; void* fAgeInfoId;
~_Params() { ~_Params() {
DEL(fSpawn); DEL(fSpawn);
DEL(fAgeInfoId);
} }
}; };
@ -3181,7 +3179,7 @@ namespace _VaultRegisterVisitAge {
} }
_Params* p = (_Params*)param; _Params* p = (_Params*)param;
RelVaultNode* ageInfo = VaultGetNodeIncRef(*p->fAgeInfoId); RelVaultNode* ageInfo = VaultGetNodeIncRef((UInt32)p->fAgeInfoId);
// Add ourselves to the Can Visit folder of the age // Add ourselves to the Can Visit folder of the age
if (RelVaultNode * playerInfo = VaultGetPlayerInfoNodeIncRef()) { if (RelVaultNode * playerInfo = VaultGetPlayerInfoNodeIncRef()) {
@ -3234,7 +3232,7 @@ namespace _VaultRegisterVisitAge {
// Save the AgeInfo nodeID, then download the age vault // Save the AgeInfo nodeID, then download the age vault
_Params* p = (_Params*)param; _Params* p = (_Params*)param;
p->fAgeInfoId = TRACKED_NEW UInt32(ageInfoId); p->fAgeInfoId = (void*)ageInfoId;
VaultDownload(L"RegisterVisitAge", VaultDownload(L"RegisterVisitAge",
ageInfoId, ageInfoId,
@ -4436,14 +4434,11 @@ namespace _VaultCreateSubAge {
void _CreateNodeCallback(ENetError result, void* state, void* param, RelVaultNode* node) { void _CreateNodeCallback(ENetError result, void* state, void* param, RelVaultNode* node) {
if (IS_NET_ERROR(result)) { if (IS_NET_ERROR(result)) {
LogMsg(kLogError, "CreateSubAge: Failed to create AgeLink (async)"); LogMsg(kLogError, "CreateSubAge: Failed to create AgeLink (async)");
DEL(param);
return; return;
} }
UInt32 ageInfoId = *(UInt32*)param;
// Add the children to the right places // Add the children to the right places
VaultAddChildNode(node->nodeId, ageInfoId, 0, nil, nil); VaultAddChildNode(node->nodeId, (UInt32)param, 0, nil, nil);
if (RelVaultNode* saFldr = VaultGetAgeSubAgesFolderIncRef()) { if (RelVaultNode* saFldr = VaultGetAgeSubAgesFolderIncRef()) {
VaultAddChildNode(saFldr->nodeId, node->nodeId, 0, nil, nil); VaultAddChildNode(saFldr->nodeId, node->nodeId, 0, nil, nil);
saFldr->DecRef(); saFldr->DecRef();
@ -4456,14 +4451,11 @@ namespace _VaultCreateSubAge {
msg->SetResultCode(result); msg->SetResultCode(result);
msg->GetArgs()->AddInt(plNetCommon::VaultTaskArgs::kAgeLinkNode, node->nodeId); msg->GetArgs()->AddInt(plNetCommon::VaultTaskArgs::kAgeLinkNode, node->nodeId);
msg->Send(); msg->Send();
DEL(param);
} }
void _DownloadCallback(ENetError result, void* param) { void _DownloadCallback(ENetError result, void* param) {
if (IS_NET_ERROR(result)) { if (IS_NET_ERROR(result)) {
LogMsg(kLogError, "CreateSubAge: Failed to download age vault (async)"); LogMsg(kLogError, "CreateSubAge: Failed to download age vault (async)");
DEL(param);
return; return;
} }
@ -4485,7 +4477,7 @@ namespace _VaultCreateSubAge {
VaultDownload(L"CreateSubAge", VaultDownload(L"CreateSubAge",
ageInfoId, ageInfoId,
(FVaultDownloadCallback)_DownloadCallback, (FVaultDownloadCallback)_DownloadCallback,
TRACKED_NEW UInt32(ageInfoId), (void*)ageInfoId,
nil, nil,
nil nil
); );
@ -4799,13 +4791,8 @@ bool VaultAgeFindOrCreateChildAgeLinkAndWait (
//============================================================================ //============================================================================
namespace _VaultCreateChildAge { namespace _VaultCreateChildAge {
struct _Params { struct _Params {
UInt32* fChildAgesFldr; void* fChildAgesFldr;
UInt32* fAgeInfoId; void* fAgeInfoId;
~_Params() {
DEL(fChildAgesFldr);
DEL(fAgeInfoId);
}
}; };
void _CreateNodeCallback(ENetError result, void* state, void* param, RelVaultNode* node) { void _CreateNodeCallback(ENetError result, void* state, void* param, RelVaultNode* node) {
@ -4818,8 +4805,8 @@ namespace _VaultCreateChildAge {
_Params* p = (_Params*)param; _Params* p = (_Params*)param;
// Add the children to the right places // Add the children to the right places
VaultAddChildNode(node->nodeId, *p->fAgeInfoId, 0, nil, nil); VaultAddChildNode(node->nodeId, (UInt32)p->fAgeInfoId, 0, nil, nil);
VaultAddChildNode(*p->fChildAgesFldr, node->nodeId, 0, nil, nil); VaultAddChildNode((UInt32)p->fChildAgesFldr, node->nodeId, 0, nil, nil);
// Send the VaultNotify that the plNetLinkingMgr wants... // Send the VaultNotify that the plNetLinkingMgr wants...
plVaultNotifyMsg * msg = NEWZERO(plVaultNotifyMsg); plVaultNotifyMsg * msg = NEWZERO(plVaultNotifyMsg);
@ -4854,7 +4841,7 @@ namespace _VaultCreateChildAge {
} }
_Params* p = (_Params*)param; _Params* p = (_Params*)param;
p->fAgeInfoId = TRACKED_NEW UInt32(ageInfoId); p->fAgeInfoId = (void*)ageInfoId;
// Download age vault // Download age vault
VaultDownload(L"CreateChildAge", VaultDownload(L"CreateChildAge",
@ -4920,7 +4907,7 @@ UInt8 VaultAgeFindOrCreateChildAgeLink(
retval = TRUE; retval = TRUE;
} else { } else {
_Params* p = TRACKED_NEW _Params; _Params* p = TRACKED_NEW _Params;
p->fChildAgesFldr = TRACKED_NEW UInt32(rvnChildAges->nodeId); p->fChildAgesFldr = (void*)rvnChildAges->nodeId;
VaultAgeInfoNode accParentInfo(rvnParentInfo); VaultAgeInfoNode accParentInfo(rvnParentInfo);
VaultInitAge(info, VaultInitAge(info,

Loading…
Cancel
Save