|
|
@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com |
|
|
|
#include "plAvatar/plArmatureMod.h" |
|
|
|
#include "plAvatar/plArmatureMod.h" |
|
|
|
#include "plFile/hsFiles.h" |
|
|
|
#include "plFile/hsFiles.h" |
|
|
|
#include "plMessage/plNCAgeJoinerMsg.h" |
|
|
|
#include "plMessage/plNCAgeJoinerMsg.h" |
|
|
|
#include "plVault/plVault.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
/*****************************************************************************
|
|
|
@ -314,6 +313,13 @@ hsBool plNetLinkingMgr::MsgReceive( plMessage *msg ) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If a link was deferred in order to register an owned age, we will
|
|
|
|
|
|
|
|
// get a VaultNotify about the registration
|
|
|
|
|
|
|
|
if (plVaultNotifyMsg* vaultMsg = plVaultNotifyMsg::ConvertNoRef(msg)) { |
|
|
|
|
|
|
|
IProcessVaultNotifyMsg(vaultMsg); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -347,8 +353,35 @@ bool plNetLinkingMgr::IProcessLinkToAgeMsg( plLinkToAgeMsg * msg ) |
|
|
|
GetPrevAgeLink()->CopyFrom( GetAgeLink() ); |
|
|
|
GetPrevAgeLink()->CopyFrom( GetAgeLink() ); |
|
|
|
GetAgeLink()->CopyFrom( msg->GetAgeLink() ); |
|
|
|
GetAgeLink()->CopyFrom( msg->GetAgeLink() ); |
|
|
|
|
|
|
|
|
|
|
|
if ( IPreProcessLink() ) |
|
|
|
// Actually do stuff...
|
|
|
|
|
|
|
|
UInt8 pre = IPreProcessLink(); |
|
|
|
|
|
|
|
if (pre == kLinkImmediately) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
msg->Ref(); |
|
|
|
|
|
|
|
IDoLink(msg); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (pre == kLinkDeferred) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
msg->Ref(); |
|
|
|
|
|
|
|
fDeferredLink = msg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (pre == kLinkFailed) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
hsLogEntry( nc->ErrorMsg( "IPreProcessLink failed. Not linking." ) ); |
|
|
|
|
|
|
|
// Restore previous age info state.
|
|
|
|
|
|
|
|
GetAgeLink()->CopyFrom( GetPrevAgeLink() ); |
|
|
|
|
|
|
|
GetPrevAgeLink()->CopyFrom( &save ); |
|
|
|
|
|
|
|
result = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void plNetLinkingMgr::IDoLink(plLinkToAgeMsg* msg) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
plNetClientMgr* nc = plNetClientMgr::GetInstance(); |
|
|
|
GetAgeLink()->SetSpawnPoint(msg->GetAgeLink()->SpawnPoint()); |
|
|
|
GetAgeLink()->SetSpawnPoint(msg->GetAgeLink()->SpawnPoint()); |
|
|
|
|
|
|
|
|
|
|
|
if (fLinkedIn) { |
|
|
|
if (fLinkedIn) { |
|
|
@ -376,17 +409,9 @@ bool plNetLinkingMgr::IProcessLinkToAgeMsg( plLinkToAgeMsg * msg ) |
|
|
|
arrsize(joinAgeOp->age.spawnPtName) |
|
|
|
arrsize(joinAgeOp->age.spawnPtName) |
|
|
|
); |
|
|
|
); |
|
|
|
QueueOp(joinAgeOp); |
|
|
|
QueueOp(joinAgeOp); |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
hsLogEntry( nc->ErrorMsg( "IPreProcessLink failed. Not linking." ) ); |
|
|
|
|
|
|
|
// Restore previous age info state.
|
|
|
|
|
|
|
|
GetAgeLink()->CopyFrom( GetPrevAgeLink() ); |
|
|
|
|
|
|
|
GetPrevAgeLink()->CopyFrom( &save ); |
|
|
|
|
|
|
|
result = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
// UnRef
|
|
|
|
|
|
|
|
msg->UnRef(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@ -443,6 +468,50 @@ bool plNetLinkingMgr::IProcessLinkingMgrMsg( plLinkingMgrMsg * msg ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// No deferred link? Bye bye.
|
|
|
|
|
|
|
|
if (fDeferredLink == nil) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
plAgeLinkStruct* cur = GetAgeLink(); |
|
|
|
|
|
|
|
RelVaultNode* cVaultLink = nil; |
|
|
|
|
|
|
|
switch (msg->GetType()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case plVaultNotifyMsg::kRegisteredChildAgeLink: |
|
|
|
|
|
|
|
case plVaultNotifyMsg::kRegisteredOwnedAge: |
|
|
|
|
|
|
|
case plVaultNotifyMsg::kRegisteredSubAgeLink: |
|
|
|
|
|
|
|
cVaultLink = VaultGetNodeIncRef(msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode)); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cVaultLink != nil) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// This is something that Cyan does... >.<
|
|
|
|
|
|
|
|
// It's very useful though...
|
|
|
|
|
|
|
|
VaultAgeLinkNode accLink(cVaultLink); |
|
|
|
|
|
|
|
accLink.CopyTo(cur); |
|
|
|
|
|
|
|
if (RelVaultNode* rvnInfo = cVaultLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
VaultAgeInfoNode accInfo(rvnInfo); |
|
|
|
|
|
|
|
accInfo.CopyTo(cur->GetAgeInfo()); |
|
|
|
|
|
|
|
rvnInfo->DecRef(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IDoLink(fDeferredLink); |
|
|
|
|
|
|
|
fDeferredLink = nil; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cVaultLink->DecRef(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
bool plNetLinkingMgr::IDispatchMsg( plMessage * msg, UInt32 playerID ) |
|
|
|
bool plNetLinkingMgr::IDispatchMsg( plMessage * msg, UInt32 playerID ) |
|
|
@ -512,7 +581,7 @@ void plNetLinkingMgr::LinkToMyPersonalAge( UInt32 playerID ) |
|
|
|
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg( "Not linking. Linking is disabled." ) ); |
|
|
|
hsLogEntry( plNetClientMgr::GetInstance()->DebugMsg( "Not linking. Linking is disabled." ) ); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
plNetClientMgr * nc = plNetClientMgr::GetInstance(); |
|
|
|
plNetClientMgr* nc = plNetClientMgr::GetInstance(); |
|
|
|
|
|
|
|
|
|
|
|
plAgeLinkStruct link; |
|
|
|
plAgeLinkStruct link; |
|
|
|
link.GetAgeInfo()->SetAgeFilename( kPersonalAgeFilename ); |
|
|
|
link.GetAgeInfo()->SetAgeFilename( kPersonalAgeFilename ); |
|
|
@ -665,23 +734,27 @@ void plNetLinkingMgr::OfferLinkToPlayer( const plAgeInfoStruct * inInfo, UInt32 |
|
|
|
|
|
|
|
|
|
|
|
void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool city = (0 == stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kCityAgeFilename )); |
|
|
|
// Grab some useful things...
|
|
|
|
bool hood = (0 == stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kNeighborhoodAgeFilename )); |
|
|
|
plAgeLinkStruct* link = GetAgeLink(); |
|
|
|
bool psnl = (0 == stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kPersonalAgeFilename )); |
|
|
|
plAgeInfoStruct* info = link->GetAgeInfo(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool city = (stricmp(info->GetAgeFilename(), kCityAgeFilename) == 0); |
|
|
|
|
|
|
|
bool hood = (stricmp(info->GetAgeFilename(), kNeighborhoodAgeFilename) == 0); |
|
|
|
|
|
|
|
bool psnl = (stricmp(info->GetAgeFilename(), kPersonalAgeFilename) == 0); |
|
|
|
|
|
|
|
|
|
|
|
// Update our online status
|
|
|
|
// Update our online status
|
|
|
|
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) { |
|
|
|
if (RelVaultNode* rvnInfo = VaultGetPlayerInfoNodeIncRef()) { |
|
|
|
VaultPlayerInfoNode accInfo(rvnInfo); |
|
|
|
VaultPlayerInfoNode accInfo(rvnInfo); |
|
|
|
wchar ageInstName[MAX_PATH]; |
|
|
|
wchar ageInstName[MAX_PATH]; |
|
|
|
Uuid ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
Uuid ageInstGuid = *info->GetAgeInstanceGuid(); |
|
|
|
StrToUnicode(ageInstName, GetAgeLink()->GetAgeInfo()->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
accInfo.SetAgeInstName(ageInstName); |
|
|
|
accInfo.SetAgeInstName(ageInstName); |
|
|
|
accInfo.SetAgeInstUuid(ageInstGuid); |
|
|
|
accInfo.SetAgeInstUuid(ageInstGuid); |
|
|
|
accInfo.SetOnline(true); |
|
|
|
accInfo.SetOnline(true); |
|
|
|
rvnInfo->DecRef(); |
|
|
|
rvnInfo->DecRef(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch (GetAgeLink()->GetLinkingRules()) { |
|
|
|
switch (link->GetLinkingRules()) { |
|
|
|
|
|
|
|
|
|
|
|
case plNetCommon::LinkingRules::kOwnedBook: { |
|
|
|
case plNetCommon::LinkingRules::kOwnedBook: { |
|
|
|
// SPECIAL CASE: City: Every player ever created would be in the list; avoid that.
|
|
|
|
// SPECIAL CASE: City: Every player ever created would be in the list; avoid that.
|
|
|
@ -689,15 +762,17 @@ void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
{ // Ensure we're in the AgeOwners folder
|
|
|
|
{ // Ensure we're in the AgeOwners folder
|
|
|
|
RelVaultNode * fldr = VaultGetAgeAgeOwnersFolderIncRef(); |
|
|
|
RelVaultNode* fldr = VaultGetAgeAgeOwnersFolderIncRef(); |
|
|
|
RelVaultNode * info = VaultGetPlayerInfoNodeIncRef(); |
|
|
|
RelVaultNode* info = VaultGetPlayerInfoNodeIncRef(); |
|
|
|
|
|
|
|
|
|
|
|
if (fldr && info) |
|
|
|
if (fldr && info) |
|
|
|
if (!fldr->IsParentOf(info->nodeId, 1)) |
|
|
|
if (!fldr->IsParentOf(info->nodeId, 1)) |
|
|
|
VaultAddChildNodeAndWait( |
|
|
|
VaultAddChildNode( |
|
|
|
fldr->nodeId, |
|
|
|
fldr->nodeId, |
|
|
|
info->nodeId, |
|
|
|
info->nodeId, |
|
|
|
NetCommGetPlayer()->playerInt |
|
|
|
NetCommGetPlayer()->playerInt, |
|
|
|
|
|
|
|
nil, |
|
|
|
|
|
|
|
nil |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (fldr) |
|
|
|
if (fldr) |
|
|
@ -714,15 +789,17 @@ void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
{ // Ensure we're in the CanVisit folder
|
|
|
|
{ // Ensure we're in the CanVisit folder
|
|
|
|
RelVaultNode * fldr = VaultGetAgeCanVisitFolderIncRef(); |
|
|
|
RelVaultNode* fldr = VaultGetAgeCanVisitFolderIncRef(); |
|
|
|
RelVaultNode * info = VaultGetPlayerInfoNodeIncRef(); |
|
|
|
RelVaultNode* info = VaultGetPlayerInfoNodeIncRef(); |
|
|
|
|
|
|
|
|
|
|
|
if (fldr && info) |
|
|
|
if (fldr && info) |
|
|
|
if (!fldr->IsParentOf(info->nodeId, 1)) |
|
|
|
if (!fldr->IsParentOf(info->nodeId, 1)) |
|
|
|
VaultAddChildNodeAndWait( |
|
|
|
VaultAddChildNode( |
|
|
|
fldr->nodeId, |
|
|
|
fldr->nodeId, |
|
|
|
info->nodeId, |
|
|
|
info->nodeId, |
|
|
|
NetCommGetPlayer()->playerInt |
|
|
|
NetCommGetPlayer()->playerInt, |
|
|
|
|
|
|
|
nil, |
|
|
|
|
|
|
|
nil |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (fldr) |
|
|
|
if (fldr) |
|
|
@ -736,7 +813,7 @@ void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
case plNetCommon::LinkingRules::kSubAgeBook: { |
|
|
|
case plNetCommon::LinkingRules::kSubAgeBook: { |
|
|
|
// Register the previous age as a sub age of the current one so that we can link back to that instance
|
|
|
|
// Register the previous age as a sub age of the current one so that we can link back to that instance
|
|
|
|
plAgeLinkStruct subAgeLink; |
|
|
|
plAgeLinkStruct subAgeLink; |
|
|
|
VaultAgeFindOrCreateSubAgeLinkAndWait(GetPrevAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId); |
|
|
|
VaultAgeFindOrCreateSubAgeLink(GetPrevAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -744,16 +821,19 @@ void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
UInt8 plNetLinkingMgr::IPreProcessLink(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plNetClientMgr * nc = plNetClientMgr::GetInstance(); |
|
|
|
// Grab some stuff we're gonna use extensively
|
|
|
|
|
|
|
|
plNetClientMgr* nc = plNetClientMgr::GetInstance(); |
|
|
|
|
|
|
|
plAgeLinkStruct* link = GetAgeLink(); |
|
|
|
|
|
|
|
plAgeInfoStruct* info = link->GetAgeInfo(); |
|
|
|
|
|
|
|
|
|
|
|
bool success = true; |
|
|
|
PreProcessResult success = kLinkImmediately; |
|
|
|
|
|
|
|
|
|
|
|
if ( nc->GetFlagsBit( plNetClientMgr::kNullSend ) ) |
|
|
|
if ( nc->GetFlagsBit( plNetClientMgr::kNullSend ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hsLogEntry( nc->DebugMsg( "NetClientMgr nullsend. Not linking." ) ); |
|
|
|
hsLogEntry( nc->DebugMsg( "NetClientMgr nullsend. Not linking." ) ); |
|
|
|
return false; |
|
|
|
return kLinkFailed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
#if 0 |
|
|
@ -771,7 +851,7 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
VaultPlayerInfoNode accInfo(rvnInfo); |
|
|
|
VaultPlayerInfoNode accInfo(rvnInfo); |
|
|
|
wchar ageInstName[MAX_PATH]; |
|
|
|
wchar ageInstName[MAX_PATH]; |
|
|
|
Uuid ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
Uuid ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
StrToUnicode(ageInstName, GetAgeLink()->GetAgeInfo()->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
accInfo.SetAgeInstName(ageInstName); |
|
|
|
accInfo.SetAgeInstName(ageInstName); |
|
|
|
accInfo.SetAgeInstUuid(ageInstGuid); |
|
|
|
accInfo.SetAgeInstUuid(ageInstGuid); |
|
|
|
accInfo.SetOnline(true); |
|
|
|
accInfo.SetOnline(true); |
|
|
@ -781,50 +861,44 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Fixup empty fields
|
|
|
|
// Fixup empty fields
|
|
|
|
if ( GetAgeLink()->GetAgeInfo()->HasAgeFilename() ) |
|
|
|
if (info->HasAgeFilename()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeFilename( plNetLinkingMgr::GetProperAgeName( GetAgeLink()->GetAgeInfo()->GetAgeFilename() ).c_str() ); |
|
|
|
info->SetAgeFilename(plNetLinkingMgr::GetProperAgeName(info->GetAgeFilename()).c_str()); |
|
|
|
|
|
|
|
|
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeInstanceName() ) |
|
|
|
if (!info->HasAgeInstanceName()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeInstanceName( GetAgeLink()->GetAgeInfo()->GetAgeFilename() ); |
|
|
|
info->SetAgeInstanceName(info->GetAgeFilename()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hsLogEntry( nc->DebugMsg( "plNetLinkingMgr: Pre-Process: Linking with %s rules...", |
|
|
|
hsLogEntry(nc->DebugMsg( "plNetLinkingMgr: Pre-Process: Linking with %s rules...", |
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr( GetAgeLink()->GetLinkingRules() ) ) ); |
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules()))); |
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// SPECIAL CASE: StartUp: force basic link
|
|
|
|
// SPECIAL CASE: StartUp: force basic link
|
|
|
|
if ( stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kStartUpAgeFilename )==0 ) |
|
|
|
if (stricmp(info->GetAgeFilename(), kStartUpAgeFilename) == 0) |
|
|
|
{ |
|
|
|
link->SetLinkingRules( plNetCommon::LinkingRules::kBasicLink ); |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kBasicLink ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// SPECIAL CASE: Nexus: force original link
|
|
|
|
// SPECIAL CASE: Nexus: force original link
|
|
|
|
if ( stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kNexusAgeFilename )==0 ) |
|
|
|
if (stricmp(info->GetAgeFilename(), kNexusAgeFilename) == 0) |
|
|
|
{ |
|
|
|
link->SetLinkingRules(plNetCommon::LinkingRules::kOriginalBook); |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// SPECIAL CASE: ACA: force original link
|
|
|
|
// SPECIAL CASE: ACA: force original link
|
|
|
|
if ( stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kAvCustomizationFilename )==0 ) |
|
|
|
if (stricmp(info->GetAgeFilename(), kAvCustomizationFilename ) == 0) |
|
|
|
{ |
|
|
|
link->SetLinkingRules(plNetCommon::LinkingRules::kOriginalBook); |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hsLogEntry( nc->DebugMsg( "plNetLinkingMgr: Process: Linking with %s rules...", |
|
|
|
hsLogEntry(nc->DebugMsg("plNetLinkingMgr: Process: Linking with %s rules...", |
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr( GetAgeLink()->GetLinkingRules() ) ) ); |
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules()))); |
|
|
|
|
|
|
|
|
|
|
|
switch ( GetAgeLink()->GetLinkingRules() ) |
|
|
|
switch (link->GetLinkingRules()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// BASIC LINK. Link to a unique instance of the age, if no instance specified.
|
|
|
|
// BASIC LINK. Link to a unique instance of the age, if no instance specified.
|
|
|
|
case plNetCommon::LinkingRules::kBasicLink: |
|
|
|
case plNetCommon::LinkingRules::kBasicLink: |
|
|
|
if (!GetAgeLink()->GetAgeInfo()->HasAgeInstanceGuid()) |
|
|
|
if (!info->HasAgeInstanceGuid()) |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
info->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//--------------------------------------------------------------------
|
|
|
@ -835,89 +909,98 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
// we just want to find out if we own *any* link to the age, not the specific
|
|
|
|
// we just want to find out if we own *any* link to the age, not the specific
|
|
|
|
// link that we're linking through
|
|
|
|
// link that we're linking through
|
|
|
|
plAgeInfoStruct ageInfo; |
|
|
|
plAgeInfoStruct ageInfo; |
|
|
|
ageInfo.SetAgeFilename(GetAgeLink()->GetAgeInfo()->GetAgeFilename()); |
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
|
|
|
|
|
|
|
|
plAgeLinkStruct ownedLink; |
|
|
|
plAgeLinkStruct ownedLink; |
|
|
|
if (!VaultGetOwnedAgeLink(&ageInfo, &ownedLink)) { |
|
|
|
if (!VaultGetOwnedAgeLink(&ageInfo, &ownedLink)) { |
|
|
|
// Fill in fields for new age create.
|
|
|
|
// Fill in fields for new age create.
|
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeUserDefinedName() ) |
|
|
|
if (!info->HasAgeUserDefinedName()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// set user-defined name
|
|
|
|
// set user-defined name
|
|
|
|
std::string title; |
|
|
|
std::string title; |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
xtl::format( title, "%s'", nc->GetPlayerName() ); |
|
|
|
xtl::format(title, "%s'", nc->GetPlayerName()); |
|
|
|
else |
|
|
|
else |
|
|
|
xtl::format( title, "%s's", nc->GetPlayerName() ); |
|
|
|
xtl::format(title, "%s's", nc->GetPlayerName()); |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeUserDefinedName( title.c_str() ); |
|
|
|
info->SetAgeUserDefinedName(title.c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeDescription() ) |
|
|
|
if (!info->HasAgeDescription()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// set description
|
|
|
|
// set description
|
|
|
|
std::string desc; |
|
|
|
std::string desc; |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
xtl::format( desc, "%s' %s", nc->GetPlayerName(), GetAgeLink()->GetAgeInfo()->GetAgeInstanceName() ); |
|
|
|
xtl::format(desc, "%s' %s", nc->GetPlayerName(), info->GetAgeInstanceName()); |
|
|
|
else |
|
|
|
else |
|
|
|
xtl::format( desc, "%s's %s", nc->GetPlayerName(), GetAgeLink()->GetAgeInfo()->GetAgeInstanceName() ); |
|
|
|
xtl::format(desc, "%s's %s", nc->GetPlayerName(), info->GetAgeInstanceName()); |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeDescription( desc.c_str() ); |
|
|
|
info->SetAgeDescription(desc.c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!GetAgeLink()->GetAgeInfo()->HasAgeInstanceGuid()) { |
|
|
|
if (!info->HasAgeInstanceGuid()) { |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
info->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// register this as an owned age now before we link to it.
|
|
|
|
// register this as an owned age now before we link to it.
|
|
|
|
VaultRegisterOwnedAgeAndWait(GetAgeLink()); |
|
|
|
// Note: We MUST break or the OwnedBook code will fail!
|
|
|
|
|
|
|
|
VaultRegisterOwnedAge(link); |
|
|
|
|
|
|
|
success = kLinkDeferred; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (RelVaultNode * linkNode = VaultGetOwnedAgeLinkIncRef(&ageInfo)) { |
|
|
|
else if (RelVaultNode* linkNode = VaultGetOwnedAgeLinkIncRef(&ageInfo)) { |
|
|
|
// We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
|
|
|
|
// We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
|
|
|
|
VaultAgeLinkNode linkAcc(linkNode); |
|
|
|
VaultAgeLinkNode linkAcc(linkNode); |
|
|
|
if (linkAcc.volat) { |
|
|
|
if (linkAcc.volat) { |
|
|
|
if (VaultUnregisterOwnedAgeAndWait(&ageInfo)) { |
|
|
|
if (VaultUnregisterOwnedAgeAndWait(&ageInfo)) { |
|
|
|
// Fill in fields for new age create.
|
|
|
|
// Fill in fields for new age create.
|
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeUserDefinedName() ) |
|
|
|
if (!info->HasAgeUserDefinedName()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// set user-defined name
|
|
|
|
// set user-defined name
|
|
|
|
std::string title; |
|
|
|
std::string title; |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
xtl::format( title, "%s'", nc->GetPlayerName() ); |
|
|
|
xtl::format(title, "%s'", nc->GetPlayerName()); |
|
|
|
else |
|
|
|
else |
|
|
|
xtl::format( title, "%s's", nc->GetPlayerName() ); |
|
|
|
xtl::format(title, "%s's", nc->GetPlayerName()); |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeUserDefinedName( title.c_str() ); |
|
|
|
info->SetAgeUserDefinedName(title.c_str()); |
|
|
|
} |
|
|
|
} |
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeDescription() ) |
|
|
|
|
|
|
|
|
|
|
|
if (!info->HasAgeDescription()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// set description
|
|
|
|
// set description
|
|
|
|
std::string desc; |
|
|
|
std::string desc; |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
if (nc->GetPlayerName()[nameLen - 1] == 's' || nc->GetPlayerName()[nameLen - 1] == 'S') |
|
|
|
xtl::format( desc, "%s' %s", nc->GetPlayerName(), GetAgeLink()->GetAgeInfo()->GetAgeInstanceName() ); |
|
|
|
xtl::format(desc, "%s' %s", nc->GetPlayerName(), info->GetAgeInstanceName()); |
|
|
|
else |
|
|
|
else |
|
|
|
xtl::format( desc, "%s's %s", nc->GetPlayerName(), GetAgeLink()->GetAgeInfo()->GetAgeInstanceName() ); |
|
|
|
xtl::format(desc, "%s's %s", nc->GetPlayerName(), info->GetAgeInstanceName()); |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeDescription( desc.c_str() ); |
|
|
|
info->SetAgeDescription( desc.c_str() ); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!GetAgeLink()->GetAgeInfo()->HasAgeInstanceGuid()) { |
|
|
|
|
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
if (!info->HasAgeInstanceGuid()) { |
|
|
|
|
|
|
|
info->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
VaultRegisterOwnedAgeAndWait(GetAgeLink()); |
|
|
|
VaultRegisterOwnedAge(link); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Note: We MUST break or the OwnedBook code will fail!
|
|
|
|
|
|
|
|
success = kLinkDeferred; |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (stricmp(GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kNeighborhoodAgeFilename) == 0) { |
|
|
|
if (stricmp(info->GetAgeFilename(), kNeighborhoodAgeFilename) == 0) { |
|
|
|
// if we get here then its because we're linking to a neighborhood that we don't belong to
|
|
|
|
// if we get here then it's because we're linking to a neighborhood that we don't belong to
|
|
|
|
// and our own neighborhood book is not volatile, so really we want to basic link
|
|
|
|
// and our own neighborhood book is not volatile, so really we want to basic link
|
|
|
|
GetAgeLink()->SetLinkingRules(plNetCommon::LinkingRules::kBasicLink); |
|
|
|
link->SetLinkingRules(plNetCommon::LinkingRules::kBasicLink); |
|
|
|
success = true; |
|
|
|
success = kLinkImmediately; |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
linkNode->DecRef(); |
|
|
|
linkNode->DecRef(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOwnedBook ); |
|
|
|
|
|
|
|
|
|
|
|
link->SetLinkingRules(plNetCommon::LinkingRules::kOwnedBook); |
|
|
|
// falls thru to OWNED BOOK case...
|
|
|
|
// falls thru to OWNED BOOK case...
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//--------------------------------------------------------------------
|
|
|
@ -925,14 +1008,14 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
case plNetCommon::LinkingRules::kOwnedBook: |
|
|
|
case plNetCommon::LinkingRules::kOwnedBook: |
|
|
|
{ |
|
|
|
{ |
|
|
|
plAgeLinkStruct ownedLink; |
|
|
|
plAgeLinkStruct ownedLink; |
|
|
|
if (VaultGetOwnedAgeLink(GetAgeLink()->GetAgeInfo(), &ownedLink)) { |
|
|
|
if (VaultGetOwnedAgeLink(info, &ownedLink)) { |
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(ownedLink.GetAgeInfo()); |
|
|
|
info->CopyFrom(ownedLink.GetAgeInfo()); |
|
|
|
// Remember spawn point (treasure book support)
|
|
|
|
// Remember spawn point (treasure book support)
|
|
|
|
plSpawnPointInfo theSpawnPt = GetAgeLink()->SpawnPoint(); |
|
|
|
plSpawnPointInfo theSpawnPt = link->SpawnPoint(); |
|
|
|
VaultAddOwnedAgeSpawnPoint(*GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(), theSpawnPt); |
|
|
|
VaultAddOwnedAgeSpawnPoint(*info->GetAgeInstanceGuid(), theSpawnPt); |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
success = false; |
|
|
|
success = kLinkFailed; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
@ -942,10 +1025,10 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
case plNetCommon::LinkingRules::kVisitBook: |
|
|
|
case plNetCommon::LinkingRules::kVisitBook: |
|
|
|
{ |
|
|
|
{ |
|
|
|
plAgeLinkStruct visitLink; |
|
|
|
plAgeLinkStruct visitLink; |
|
|
|
if (VaultGetVisitAgeLink(GetAgeLink()->GetAgeInfo(), &visitLink)) |
|
|
|
if (VaultGetVisitAgeLink(info, &visitLink)) |
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(visitLink.GetAgeInfo()); |
|
|
|
info->CopyFrom(visitLink.GetAgeInfo()); |
|
|
|
else |
|
|
|
else |
|
|
|
success = false; |
|
|
|
success = kLinkFailed; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -955,10 +1038,10 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
case plNetCommon::LinkingRules::kSubAgeBook: |
|
|
|
case plNetCommon::LinkingRules::kSubAgeBook: |
|
|
|
{ |
|
|
|
{ |
|
|
|
plAgeLinkStruct subAgeLink; |
|
|
|
plAgeLinkStruct subAgeLink; |
|
|
|
if (VaultAgeFindOrCreateSubAgeLinkAndWait(GetAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId)) |
|
|
|
if (VaultAgeFindOrCreateSubAgeLink(info, &subAgeLink, NetCommGetAge()->ageInstId)) |
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(subAgeLink.GetAgeInfo()); |
|
|
|
info->CopyFrom(subAgeLink.GetAgeInfo()); |
|
|
|
else |
|
|
|
else |
|
|
|
success = false; |
|
|
|
success = kLinkDeferred; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
@ -969,28 +1052,38 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plAgeLinkStruct childLink; |
|
|
|
plAgeLinkStruct childLink; |
|
|
|
wchar parentAgeName[MAX_PATH]; |
|
|
|
wchar parentAgeName[MAX_PATH]; |
|
|
|
if (GetAgeLink()->HasParentAgeFilename()) { |
|
|
|
if (link->HasParentAgeFilename()) |
|
|
|
StrToUnicode(parentAgeName, GetAgeLink()->GetParentAgeFilename(), arrsize(parentAgeName)); |
|
|
|
StrToUnicode(parentAgeName, link->GetParentAgeFilename(), arrsize(parentAgeName)); |
|
|
|
success = VaultAgeFindOrCreateChildAgeLinkAndWait(parentAgeName, GetAgeLink()->GetAgeInfo(), &childLink); |
|
|
|
|
|
|
|
} |
|
|
|
switch(VaultAgeFindOrCreateChildAgeLink( |
|
|
|
else { |
|
|
|
(link->HasParentAgeFilename() ? parentAgeName : nil), |
|
|
|
success = VaultAgeFindOrCreateChildAgeLinkAndWait(nil, GetAgeLink()->GetAgeInfo(), &childLink); |
|
|
|
info, |
|
|
|
|
|
|
|
&childLink)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case hsFail: |
|
|
|
|
|
|
|
success = kLinkFailed; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case FALSE: |
|
|
|
|
|
|
|
success = kLinkDeferred; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case TRUE: |
|
|
|
|
|
|
|
success = kLinkImmediately; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (success) |
|
|
|
if (success == kLinkImmediately) |
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(childLink.GetAgeInfo()); |
|
|
|
info->CopyFrom(childLink.GetAgeInfo()); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
// ???
|
|
|
|
// ???
|
|
|
|
DEFAULT_FATAL(GetAgeLink()->GetLinkingRules()); |
|
|
|
DEFAULT_FATAL(link->GetLinkingRules()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
hsLogEntry( nc->DebugMsg( "plNetLinkingMgr: Post-Process: Linking with %s rules...", |
|
|
|
hsLogEntry(nc->DebugMsg( "plNetLinkingMgr: Post-Process: Linking with %s rules...", |
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr( GetAgeLink()->GetLinkingRules() ) ) ); |
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules()))); |
|
|
|
|
|
|
|
|
|
|
|
hsAssert( GetAgeLink()->GetAgeInfo()->HasAgeFilename(), "AgeLink has no AgeFilename. Link will fail." ); |
|
|
|
hsAssert(info->HasAgeFilename(), "AgeLink has no AgeFilename. Link will fail."); |
|
|
|
|
|
|
|
|
|
|
|
return success; |
|
|
|
return success; |
|
|
|
} |
|
|
|
} |
|
|
|