|
|
@ -62,7 +62,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" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
/*****************************************************************************
|
|
|
@ -330,6 +329,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; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -363,37 +369,19 @@ 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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GetAgeLink()->SetSpawnPoint(msg->GetAgeLink()->SpawnPoint()); |
|
|
|
msg->Ref(); |
|
|
|
|
|
|
|
IDoLink(msg); |
|
|
|
if (fLinkedIn) { |
|
|
|
|
|
|
|
// Set the link out animation we should use
|
|
|
|
|
|
|
|
if (plSceneObject *localSO = plSceneObject::ConvertNoRef(nc->GetLocalPlayer())) { |
|
|
|
|
|
|
|
plArmatureMod *avMod = const_cast<plArmatureMod*>(plArmatureMod::ConvertNoRef(localSO->GetModifierByType(plArmatureMod::Index()))); |
|
|
|
|
|
|
|
avMod->SetLinkInAnim(msg->GetLinkInAnimName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Queue leave op
|
|
|
|
|
|
|
|
NlmLeaveAgeOp * leaveAgeOp = NEWZERO(NlmLeaveAgeOp); |
|
|
|
|
|
|
|
QueueOp(leaveAgeOp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Queue join op
|
|
|
|
|
|
|
|
NlmJoinAgeOp * joinAgeOp = NEWZERO(NlmJoinAgeOp); |
|
|
|
|
|
|
|
joinAgeOp->age.ageInstId = (Uuid) *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
|
|
|
|
StrCopy( |
|
|
|
|
|
|
|
joinAgeOp->age.ageDatasetName, |
|
|
|
|
|
|
|
GetAgeLink()->GetAgeInfo()->GetAgeFilename(), |
|
|
|
|
|
|
|
arrsize(joinAgeOp->age.ageDatasetName) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
StrCopy( |
|
|
|
|
|
|
|
joinAgeOp->age.spawnPtName, |
|
|
|
|
|
|
|
GetAgeLink()->SpawnPoint().GetName(), |
|
|
|
|
|
|
|
arrsize(joinAgeOp->age.spawnPtName) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
QueueOp(joinAgeOp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else if (pre == kLinkDeferred) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
msg->Ref(); |
|
|
|
|
|
|
|
fDeferredLink = msg; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (pre == kLinkFailed) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hsLogEntry( nc->ErrorMsg( "IPreProcessLink failed. Not linking." ) ); |
|
|
|
hsLogEntry( nc->ErrorMsg( "IPreProcessLink failed. Not linking." ) ); |
|
|
|
// Restore previous age info state.
|
|
|
|
// Restore previous age info state.
|
|
|
@ -407,6 +395,43 @@ bool plNetLinkingMgr::IProcessLinkToAgeMsg( plLinkToAgeMsg * msg ) |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void plNetLinkingMgr::IDoLink(plLinkToAgeMsg* msg) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
plNetClientMgr* nc = plNetClientMgr::GetInstance(); |
|
|
|
|
|
|
|
GetAgeLink()->SetSpawnPoint(msg->GetAgeLink()->SpawnPoint()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (fLinkedIn) { |
|
|
|
|
|
|
|
// Set the link out animation we should use
|
|
|
|
|
|
|
|
if (plSceneObject *localSO = plSceneObject::ConvertNoRef(nc->GetLocalPlayer())) { |
|
|
|
|
|
|
|
plArmatureMod *avMod = const_cast<plArmatureMod*>(plArmatureMod::ConvertNoRef(localSO->GetModifierByType(plArmatureMod::Index()))); |
|
|
|
|
|
|
|
avMod->SetLinkInAnim(msg->GetLinkInAnimName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// Queue leave op
|
|
|
|
|
|
|
|
NlmLeaveAgeOp * leaveAgeOp = NEWZERO(NlmLeaveAgeOp); |
|
|
|
|
|
|
|
QueueOp(leaveAgeOp); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Queue join op
|
|
|
|
|
|
|
|
NlmJoinAgeOp * joinAgeOp = NEWZERO(NlmJoinAgeOp); |
|
|
|
|
|
|
|
joinAgeOp->age.ageInstId = (Uuid) *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
|
|
|
|
StrCopy( |
|
|
|
|
|
|
|
joinAgeOp->age.ageDatasetName, |
|
|
|
|
|
|
|
GetAgeLink()->GetAgeInfo()->GetAgeFilename(), |
|
|
|
|
|
|
|
arrsize(joinAgeOp->age.ageDatasetName) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
StrCopy( |
|
|
|
|
|
|
|
joinAgeOp->age.spawnPtName, |
|
|
|
|
|
|
|
GetAgeLink()->SpawnPoint().GetName(), |
|
|
|
|
|
|
|
arrsize(joinAgeOp->age.spawnPtName) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
QueueOp(joinAgeOp); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// UnRef
|
|
|
|
|
|
|
|
msg->UnRef(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
bool plNetLinkingMgr::IProcessLinkingMgrMsg( plLinkingMgrMsg * msg ) |
|
|
|
bool plNetLinkingMgr::IProcessLinkingMgrMsg( plLinkingMgrMsg * msg ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
plNetClientMgr * nc = plNetClientMgr::GetInstance(); |
|
|
|
plNetClientMgr * nc = plNetClientMgr::GetInstance(); |
|
|
@ -458,6 +483,49 @@ bool plNetLinkingMgr::IProcessLinkingMgrMsg( plLinkingMgrMsg * msg ) |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
@ -681,23 +749,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.
|
|
|
@ -710,10 +782,12 @@ void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
@ -735,10 +809,12 @@ void plNetLinkingMgr::IPostProcessLink( void ) |
|
|
|
|
|
|
|
|
|
|
|
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) |
|
|
@ -752,7 +828,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; |
|
|
|
} |
|
|
|
} |
|
|
@ -760,16 +836,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 |
|
|
@ -787,7 +866,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); |
|
|
@ -797,50 +876,50 @@ 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() ); |
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeFilename( plNetLinkingMgr::GetProperAgeName( GetAgeLink()->GetAgeInfo()->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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kBasicLink ); |
|
|
|
link->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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); |
|
|
|
link->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) |
|
|
|
{ |
|
|
|
{ |
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); |
|
|
|
link->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; |
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//--------------------------------------------------------------------
|
|
|
@ -851,12 +930,12 @@ 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; |
|
|
@ -865,25 +944,28 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
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.
|
|
|
@ -891,7 +973,7 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
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; |
|
|
@ -900,32 +982,36 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
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())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
@ -933,7 +1019,7 @@ bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
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...
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
//--------------------------------------------------------------------
|
|
|
@ -941,14 +1027,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; |
|
|
@ -958,10 +1044,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; |
|
|
|
|
|
|
|
|
|
|
@ -971,10 +1057,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; |
|
|
|
|
|
|
|
|
|
|
@ -985,28 +1071,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; |
|
|
|
} |
|
|
|
} |
|
|
|