|
|
|
@ -62,7 +62,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|
|
|
|
#include "../plAvatar/plArmatureMod.h" |
|
|
|
|
#include "../plFile/hsFiles.h" |
|
|
|
|
#include "../plMessage/plNCAgeJoinerMsg.h" |
|
|
|
|
#include "../plVault/plVault.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
@ -330,6 +329,13 @@ hsBool plNetLinkingMgr::MsgReceive( plMessage *msg )
|
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -363,8 +369,35 @@ bool plNetLinkingMgr::IProcessLinkToAgeMsg( plLinkToAgeMsg * msg )
|
|
|
|
|
GetPrevAgeLink()->CopyFrom( 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()); |
|
|
|
|
|
|
|
|
|
if (fLinkedIn) { |
|
|
|
@ -392,17 +425,9 @@ bool plNetLinkingMgr::IProcessLinkToAgeMsg( plLinkToAgeMsg * msg )
|
|
|
|
|
arrsize(joinAgeOp->age.spawnPtName) |
|
|
|
|
); |
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
@ -458,6 +483,49 @@ bool plNetLinkingMgr::IProcessLinkingMgrMsg( plLinkingMgrMsg * msg )
|
|
|
|
|
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 ) |
|
|
|
|
{ |
|
|
|
|
bool city = (0 == stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kCityAgeFilename )); |
|
|
|
|
bool hood = (0 == stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kNeighborhoodAgeFilename )); |
|
|
|
|
bool psnl = (0 == stricmp( GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kPersonalAgeFilename )); |
|
|
|
|
// Grab some useful things...
|
|
|
|
|
plAgeLinkStruct* link = GetAgeLink(); |
|
|
|
|
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
|
|
|
|
|
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) { |
|
|
|
|
VaultPlayerInfoNode accInfo(rvnInfo); |
|
|
|
|
wchar ageInstName[MAX_PATH]; |
|
|
|
|
Uuid ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
|
StrToUnicode(ageInstName, GetAgeLink()->GetAgeInfo()->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
|
Uuid ageInstGuid = *info->GetAgeInstanceGuid(); |
|
|
|
|
StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
|
accInfo.SetAgeInstName(ageInstName); |
|
|
|
|
accInfo.SetAgeInstUuid(ageInstGuid); |
|
|
|
|
accInfo.SetOnline(true); |
|
|
|
|
rvnInfo->DecRef(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
switch (GetAgeLink()->GetLinkingRules()) { |
|
|
|
|
switch (link->GetLinkingRules()) { |
|
|
|
|
|
|
|
|
|
case plNetCommon::LinkingRules::kOwnedBook: { |
|
|
|
|
// 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->IsParentOf(info->nodeId, 1)) |
|
|
|
|
VaultAddChildNodeAndWait( |
|
|
|
|
VaultAddChildNode( |
|
|
|
|
fldr->nodeId, |
|
|
|
|
info->nodeId, |
|
|
|
|
NetCommGetPlayer()->playerInt |
|
|
|
|
NetCommGetPlayer()->playerInt, |
|
|
|
|
nil, |
|
|
|
|
nil |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (fldr) |
|
|
|
@ -735,10 +809,12 @@ void plNetLinkingMgr::IPostProcessLink( void )
|
|
|
|
|
|
|
|
|
|
if (fldr && info) |
|
|
|
|
if (!fldr->IsParentOf(info->nodeId, 1)) |
|
|
|
|
VaultAddChildNodeAndWait( |
|
|
|
|
VaultAddChildNode( |
|
|
|
|
fldr->nodeId, |
|
|
|
|
info->nodeId, |
|
|
|
|
NetCommGetPlayer()->playerInt |
|
|
|
|
NetCommGetPlayer()->playerInt, |
|
|
|
|
nil, |
|
|
|
|
nil |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (fldr) |
|
|
|
@ -752,7 +828,7 @@ void plNetLinkingMgr::IPostProcessLink( void )
|
|
|
|
|
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
|
|
|
|
|
plAgeLinkStruct subAgeLink; |
|
|
|
|
VaultAgeFindOrCreateSubAgeLinkAndWait(GetPrevAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId); |
|
|
|
|
VaultAgeFindOrCreateSubAgeLink(GetPrevAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -760,16 +836,19 @@ void plNetLinkingMgr::IPostProcessLink( void )
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
|
UInt8 plNetLinkingMgr::IPreProcessLink( void ) |
|
|
|
|
{ |
|
|
|
|
// 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 ) ) |
|
|
|
|
{ |
|
|
|
|
hsLogEntry( nc->DebugMsg( "NetClientMgr nullsend. Not linking." ) ); |
|
|
|
|
return false; |
|
|
|
|
return kLinkFailed; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
@ -787,7 +866,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
VaultPlayerInfoNode accInfo(rvnInfo); |
|
|
|
|
wchar ageInstName[MAX_PATH]; |
|
|
|
|
Uuid ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(); |
|
|
|
|
StrToUnicode(ageInstName, GetAgeLink()->GetAgeInfo()->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
|
StrToUnicode(ageInstName, info->GetAgeInstanceName(), arrsize(ageInstName)); |
|
|
|
|
accInfo.SetAgeInstName(ageInstName); |
|
|
|
|
accInfo.SetAgeInstUuid(ageInstGuid); |
|
|
|
|
accInfo.SetOnline(true); |
|
|
|
@ -797,50 +876,50 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// Fixup empty fields
|
|
|
|
|
if ( GetAgeLink()->GetAgeInfo()->HasAgeFilename() ) |
|
|
|
|
if (info->HasAgeFilename()) |
|
|
|
|
{ |
|
|
|
|
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...", |
|
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr( GetAgeLink()->GetLinkingRules() ) ) ); |
|
|
|
|
plNetCommon::LinkingRules::LinkingRuleStr( link->GetLinkingRules() ) ) ); |
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
// 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
|
|
|
|
|
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
|
|
|
|
|
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...", |
|
|
|
|
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.
|
|
|
|
|
case plNetCommon::LinkingRules::kBasicLink: |
|
|
|
|
if (!GetAgeLink()->GetAgeInfo()->HasAgeInstanceGuid()) |
|
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
|
if (!info->HasAgeInstanceGuid()) |
|
|
|
|
info->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
|
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
|
|
|
|
|
// link that we're linking through
|
|
|
|
|
plAgeInfoStruct ageInfo; |
|
|
|
|
ageInfo.SetAgeFilename(GetAgeLink()->GetAgeInfo()->GetAgeFilename()); |
|
|
|
|
ageInfo.SetAgeFilename(info->GetAgeFilename()); |
|
|
|
|
|
|
|
|
|
plAgeLinkStruct ownedLink; |
|
|
|
|
if (!VaultGetOwnedAgeLink(&ageInfo, &ownedLink)) { |
|
|
|
|
// Fill in fields for new age create.
|
|
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeUserDefinedName() ) |
|
|
|
|
if (!info->HasAgeUserDefinedName()) |
|
|
|
|
{ |
|
|
|
|
// set user-defined name
|
|
|
|
|
std::string title; |
|
|
|
@ -865,25 +944,28 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
xtl::format( title, "%s'", nc->GetPlayerName() ); |
|
|
|
|
else |
|
|
|
|
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
|
|
|
|
|
std::string desc; |
|
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
|
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 |
|
|
|
|
xtl::format( desc, "%s's %s", nc->GetPlayerName(), GetAgeLink()->GetAgeInfo()->GetAgeInstanceName() ); |
|
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeDescription( desc.c_str() ); |
|
|
|
|
xtl::format( desc, "%s's %s", nc->GetPlayerName(), info->GetAgeInstanceName() ); |
|
|
|
|
info->SetAgeDescription( desc.c_str() ); |
|
|
|
|
} |
|
|
|
|
if (!GetAgeLink()->GetAgeInfo()->HasAgeInstanceGuid()) { |
|
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
|
if (!info->HasAgeInstanceGuid()) { |
|
|
|
|
info->SetAgeInstanceGuid(&plUUID(GuidGenerate())); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 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)) { |
|
|
|
|
// 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 (VaultUnregisterOwnedAgeAndWait(&ageInfo)) { |
|
|
|
|
// Fill in fields for new age create.
|
|
|
|
|
if ( !GetAgeLink()->GetAgeInfo()->HasAgeUserDefinedName() ) |
|
|
|
|
if ( !info->HasAgeUserDefinedName() ) |
|
|
|
|
{ |
|
|
|
|
// set user-defined name
|
|
|
|
|
std::string title; |
|
|
|
@ -900,32 +982,36 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
xtl::format( title, "%s'", nc->GetPlayerName() ); |
|
|
|
|
else |
|
|
|
|
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
|
|
|
|
|
std::string desc; |
|
|
|
|
unsigned nameLen = StrLen(nc->GetPlayerName()); |
|
|
|
|
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 |
|
|
|
|
xtl::format( desc, "%s's %s", nc->GetPlayerName(), GetAgeLink()->GetAgeInfo()->GetAgeInstanceName() ); |
|
|
|
|
GetAgeLink()->GetAgeInfo()->SetAgeDescription( desc.c_str() ); |
|
|
|
|
xtl::format( desc, "%s's %s", nc->GetPlayerName(), info->GetAgeInstanceName() ); |
|
|
|
|
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 { |
|
|
|
|
if (stricmp(GetAgeLink()->GetAgeInfo()->GetAgeFilename(), kNeighborhoodAgeFilename) == 0) { |
|
|
|
|
// if we get here then its because we're linking to a neighborhood that we don't belong to
|
|
|
|
|
if (stricmp(info->GetAgeFilename(), kNeighborhoodAgeFilename) == 0) { |
|
|
|
|
// 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
|
|
|
|
|
GetAgeLink()->SetLinkingRules(plNetCommon::LinkingRules::kBasicLink); |
|
|
|
|
success = true; |
|
|
|
|
link->SetLinkingRules(plNetCommon::LinkingRules::kBasicLink); |
|
|
|
|
success = kLinkImmediately; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -933,7 +1019,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
linkNode->DecRef(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOwnedBook ); |
|
|
|
|
link->SetLinkingRules( plNetCommon::LinkingRules::kOwnedBook ); |
|
|
|
|
// falls thru to OWNED BOOK case...
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
@ -941,14 +1027,14 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
case plNetCommon::LinkingRules::kOwnedBook: |
|
|
|
|
{ |
|
|
|
|
plAgeLinkStruct ownedLink; |
|
|
|
|
if (VaultGetOwnedAgeLink(GetAgeLink()->GetAgeInfo(), &ownedLink)) { |
|
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(ownedLink.GetAgeInfo()); |
|
|
|
|
if (VaultGetOwnedAgeLink(info, &ownedLink)) { |
|
|
|
|
info->CopyFrom(ownedLink.GetAgeInfo()); |
|
|
|
|
// Remember spawn point (treasure book support)
|
|
|
|
|
plSpawnPointInfo theSpawnPt = GetAgeLink()->SpawnPoint(); |
|
|
|
|
VaultAddOwnedAgeSpawnPoint(*GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid(), theSpawnPt); |
|
|
|
|
plSpawnPointInfo theSpawnPt = link->SpawnPoint(); |
|
|
|
|
VaultAddOwnedAgeSpawnPoint(*info->GetAgeInstanceGuid(), theSpawnPt); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
success = false; |
|
|
|
|
success = kLinkFailed; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
@ -958,10 +1044,10 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
case plNetCommon::LinkingRules::kVisitBook: |
|
|
|
|
{ |
|
|
|
|
plAgeLinkStruct visitLink; |
|
|
|
|
if (VaultGetVisitAgeLink(GetAgeLink()->GetAgeInfo(), &visitLink)) |
|
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(visitLink.GetAgeInfo()); |
|
|
|
|
if (VaultGetVisitAgeLink(info, &visitLink)) |
|
|
|
|
info->CopyFrom(visitLink.GetAgeInfo()); |
|
|
|
|
else |
|
|
|
|
success = false; |
|
|
|
|
success = kLinkFailed; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
@ -971,10 +1057,10 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
case plNetCommon::LinkingRules::kSubAgeBook: |
|
|
|
|
{ |
|
|
|
|
plAgeLinkStruct subAgeLink; |
|
|
|
|
if (VaultAgeFindOrCreateSubAgeLinkAndWait(GetAgeLink()->GetAgeInfo(), &subAgeLink, NetCommGetAge()->ageInstId)) |
|
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(subAgeLink.GetAgeInfo()); |
|
|
|
|
if (VaultAgeFindOrCreateSubAgeLink(info, &subAgeLink, NetCommGetAge()->ageInstId)) |
|
|
|
|
info->CopyFrom(subAgeLink.GetAgeInfo()); |
|
|
|
|
else |
|
|
|
|
success = false; |
|
|
|
|
success = kLinkDeferred; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
@ -985,28 +1071,38 @@ bool plNetLinkingMgr::IPreProcessLink( void )
|
|
|
|
|
{ |
|
|
|
|
plAgeLinkStruct childLink; |
|
|
|
|
wchar parentAgeName[MAX_PATH]; |
|
|
|
|
if (GetAgeLink()->HasParentAgeFilename()) { |
|
|
|
|
StrToUnicode(parentAgeName, GetAgeLink()->GetParentAgeFilename(), arrsize(parentAgeName)); |
|
|
|
|
success = VaultAgeFindOrCreateChildAgeLinkAndWait(parentAgeName, GetAgeLink()->GetAgeInfo(), &childLink); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
success = VaultAgeFindOrCreateChildAgeLinkAndWait(nil, GetAgeLink()->GetAgeInfo(), &childLink); |
|
|
|
|
if (link->HasParentAgeFilename()) |
|
|
|
|
StrToUnicode(parentAgeName, link->GetParentAgeFilename(), arrsize(parentAgeName)); |
|
|
|
|
|
|
|
|
|
switch(VaultAgeFindOrCreateChildAgeLink( |
|
|
|
|
(link->HasParentAgeFilename() ? parentAgeName : nil), |
|
|
|
|
info, |
|
|
|
|
&childLink)) |
|
|
|
|
{ |
|
|
|
|
case hsFail: |
|
|
|
|
success = kLinkFailed; |
|
|
|
|
break; |
|
|
|
|
case FALSE: |
|
|
|
|
success = kLinkDeferred; |
|
|
|
|
break; |
|
|
|
|
case TRUE: |
|
|
|
|
success = kLinkImmediately; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (success) |
|
|
|
|
GetAgeLink()->GetAgeInfo()->CopyFrom(childLink.GetAgeInfo()); |
|
|
|
|
if (success == kLinkImmediately) |
|
|
|
|
info->CopyFrom(childLink.GetAgeInfo()); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------
|
|
|
|
|
// ???
|
|
|
|
|
DEFAULT_FATAL(GetAgeLink()->GetLinkingRules()); |
|
|
|
|
DEFAULT_FATAL(link->GetLinkingRules()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|