Browse Source

Registering an owned age no longer blocks the LinkingMgr. (w00t Portal 2 in an hour :D)

Adam Johnson 13 years ago
parent
commit
9c399df596
  1. 4
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  2. 163
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp
  3. 16
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h

4
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -68,6 +68,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plNetVoiceListMsg.h" #include "plMessage/plNetVoiceListMsg.h"
#include "plMessage/plNetCommMsgs.h" #include "plMessage/plNetCommMsgs.h"
#include "plMessage/plNetClientMgrMsg.h" #include "plMessage/plNetClientMgrMsg.h"
#include "plMessage/plVaultNotifyMsg.h"
#include "plResMgr/plKeyFinder.h" #include "plResMgr/plKeyFinder.h"
#include "plResMgr/plPageInfo.h" #include "plResMgr/plPageInfo.h"
#include "plNetTransport/plNetTransportMember.h" #include "plNetTransport/plNetTransportMember.h"
@ -336,6 +337,9 @@ int plNetClientMgr::Init()
plgDispatch::Dispatch()->RegisterForExactType(plNetCommActivePlayerMsg::Index(), GetKey()); plgDispatch::Dispatch()->RegisterForExactType(plNetCommActivePlayerMsg::Index(), GetKey());
plgDispatch::Dispatch()->RegisterForExactType(plNetCommLinkToAgeMsg::Index(), GetKey()); plgDispatch::Dispatch()->RegisterForExactType(plNetCommLinkToAgeMsg::Index(), GetKey());
// We need plVaultNotifyMsgs for the NetLinkingMgr
plgDispatch::Dispatch()->RegisterForType(plVaultNotifyMsg::Index(), GetKey());
IInitNetClientComm(); IInitNetClientComm();
return ret; return ret;

163
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -314,6 +314,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,37 +354,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.
@ -391,6 +380,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();
@ -443,6 +469,37 @@ bool plNetLinkingMgr::IProcessLinkingMgrMsg( plLinkingMgrMsg * msg )
} }
////////////////////////////////////////////////////////////////////
bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
{
// No deferred link? Bye bye.
if (fDeferredLink == nil)
return false;
if (msg->GetType() != plVaultNotifyMsg::kRegisteredOwnedAge)
return false;
// Find the AgeLinks
plAgeLinkStruct* cur = GetAgeLink();
if (RelVaultNode* cVaultLink = VaultGetOwnedAgeLinkIncRef(cur->GetAgeInfo()))
{
// Test to see if this is what we want
if (cVaultLink->nodeId == msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode))
{
IDoLink(fDeferredLink);
return true;
}
cVaultLink->DecRef();
}
// Nuke the deferred link ptr, just 'cause
fDeferredLink = nil;
return false;
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool plNetLinkingMgr::IDispatchMsg( plMessage * msg, UInt32 playerID ) bool plNetLinkingMgr::IDispatchMsg( plMessage * msg, UInt32 playerID )
@ -748,19 +805,19 @@ void plNetLinkingMgr::IPostProcessLink( void )
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
bool plNetLinkingMgr::IPreProcessLink( void ) UInt8 plNetLinkingMgr::IPreProcessLink(void)
{ {
// Grab some stuff we're gonna use extensively // Grab some stuff we're gonna use extensively
plNetClientMgr* nc = plNetClientMgr::GetInstance(); plNetClientMgr* nc = plNetClientMgr::GetInstance();
plAgeLinkStruct* link = GetAgeLink(); plAgeLinkStruct* link = GetAgeLink();
plAgeInfoStruct* info = link->GetAgeInfo(); 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
@ -788,9 +845,9 @@ bool plNetLinkingMgr::IPreProcessLink( void )
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// Fixup empty fields // Fixup empty fields
if ( GetAgeLink()->GetAgeInfo()->HasAgeFilename() ) if (info->HasAgeFilename())
{ {
GetAgeLink()->GetAgeInfo()->SetAgeFilename(plNetLinkingMgr::GetProperAgeName(info->GetAgeFilename()).c_str()); info->SetAgeFilename(plNetLinkingMgr::GetProperAgeName(info->GetAgeFilename()).c_str());
if (!info->HasAgeInstanceName()) if (!info->HasAgeInstanceName())
{ {
@ -798,7 +855,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
} }
} }
hsLogEntry( nc->DebugMsg( "plNetLinkingMgr: Pre-Process: Linking with %s rules...", hsLogEntry(nc->DebugMsg( "plNetLinkingMgr: Pre-Process: Linking with %s rules...",
plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules()))); plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules())));
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -808,7 +865,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// SPECIAL CASE: Nexus: force original link // SPECIAL CASE: Nexus: force original link
if (stricmp(info->GetAgeFilename(), kNexusAgeFilename) == 0 ) if (stricmp(info->GetAgeFilename(), kNexusAgeFilename) == 0)
GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook ); GetAgeLink()->SetLinkingRules( plNetCommon::LinkingRules::kOriginalBook );
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@ -816,7 +873,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
if (stricmp(info->GetAgeFilename(), kAvCustomizationFilename ) == 0) if (stricmp(info->GetAgeFilename(), kAvCustomizationFilename ) == 0)
GetAgeLink()->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(link->GetLinkingRules()))); plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules())));
switch (link->GetLinkingRules()) switch (link->GetLinkingRules())
@ -868,7 +925,10 @@ bool plNetLinkingMgr::IPreProcessLink( void )
} }
// 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(link); // 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.
@ -904,7 +964,11 @@ bool plNetLinkingMgr::IPreProcessLink( void )
info->SetAgeInstanceGuid(&plUUID(GuidGenerate())); info->SetAgeInstanceGuid(&plUUID(GuidGenerate()));
} }
VaultRegisterOwnedAgeAndWait(link); VaultRegisterOwnedAge(link);
// Note: We MUST break or the OwnedBook code will fail!
success = kLinkDeferred;
break;
} }
} }
else { else {
@ -912,8 +976,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
// if we get here then it's 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
link->SetLinkingRules(plNetCommon::LinkingRules::kBasicLink); link->SetLinkingRules(plNetCommon::LinkingRules::kBasicLink);
success = true; success = kLinkImmediately;
break; break;
} }
} }
@ -930,13 +993,13 @@ bool plNetLinkingMgr::IPreProcessLink( void )
{ {
plAgeLinkStruct ownedLink; plAgeLinkStruct ownedLink;
if (VaultGetOwnedAgeLink(info, &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 = link->SpawnPoint(); plSpawnPointInfo theSpawnPt = link->SpawnPoint();
VaultAddOwnedAgeSpawnPoint(*info->GetAgeInstanceGuid(), theSpawnPt); VaultAddOwnedAgeSpawnPoint(*info->GetAgeInstanceGuid(), theSpawnPt);
} }
else { else {
success = false; success = kLinkFailed;
} }
} }
break; break;
@ -949,7 +1012,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
if (VaultGetVisitAgeLink(info, &visitLink)) if (VaultGetVisitAgeLink(info, &visitLink))
info->CopyFrom(visitLink.GetAgeInfo()); info->CopyFrom(visitLink.GetAgeInfo());
else else
success = false; success = kLinkFailed;
} }
break; break;
@ -962,7 +1025,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
if (VaultAgeFindOrCreateSubAgeLinkAndWait(info, &subAgeLink, NetCommGetAge()->ageInstId)) if (VaultAgeFindOrCreateSubAgeLinkAndWait(info, &subAgeLink, NetCommGetAge()->ageInstId))
info->CopyFrom(subAgeLink.GetAgeInfo()); info->CopyFrom(subAgeLink.GetAgeInfo());
else else
success = false; success = kLinkFailed;
} }
break; break;
@ -975,13 +1038,15 @@ bool plNetLinkingMgr::IPreProcessLink( void )
wchar parentAgeName[MAX_PATH]; wchar parentAgeName[MAX_PATH];
if (link->HasParentAgeFilename()) { if (link->HasParentAgeFilename()) {
StrToUnicode(parentAgeName, link->GetParentAgeFilename(), arrsize(parentAgeName)); StrToUnicode(parentAgeName, link->GetParentAgeFilename(), arrsize(parentAgeName));
success = VaultAgeFindOrCreateChildAgeLinkAndWait(parentAgeName, info, &childLink); if(!VaultAgeFindOrCreateChildAgeLinkAndWait(parentAgeName, info, &childLink))
success = kLinkFailed;
} }
else { else {
success = VaultAgeFindOrCreateChildAgeLinkAndWait(nil, info, &childLink); if(!VaultAgeFindOrCreateChildAgeLinkAndWait(nil, info, &childLink))
success = kLinkFailed;
} }
if (success) if (success != kLinkFailed)
info->CopyFrom(childLink.GetAgeInfo()); info->CopyFrom(childLink.GetAgeInfo());
} }
break; break;
@ -991,7 +1056,7 @@ bool plNetLinkingMgr::IPreProcessLink( void )
DEFAULT_FATAL(link->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(link->GetLinkingRules()))); plNetCommon::LinkingRules::LinkingRuleStr(link->GetLinkingRules())));
hsAssert(info->HasAgeFilename(), "AgeLink has no AgeFilename. Link will fail."); hsAssert(info->HasAgeFilename(), "AgeLink has no AgeFilename. Link will fail.");

16
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.h

@ -34,6 +34,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plLinkToAgeMsg.h" #include "plMessage/plLinkToAgeMsg.h"
class plMessage; class plMessage;
class plVaultNotifyMsg;
struct plNCAgeJoiner; struct plNCAgeJoiner;
struct plNCAgeLeaver; struct plNCAgeLeaver;
@ -75,10 +76,23 @@ class plNetLinkingMgr
kLinkPlayerToPrevAge kLinkPlayerToPrevAge
}; };
bool IPreProcessLink( void ); plLinkToAgeMsg* fDeferredLink;
enum PreProcessResult {
// Old style IPreProcessLink style "false" result
kLinkFailed,
// Old style IPreProcessLink style "true" result
kLinkImmediately,
// Defer the link until later, don't trash the structs
kLinkDeferred,
};
UInt8 IPreProcessLink( void );
void IPostProcessLink( void ); void IPostProcessLink( void );
bool IProcessLinkingMgrMsg( plLinkingMgrMsg * msg ); bool IProcessLinkingMgrMsg( plLinkingMgrMsg * msg );
bool IProcessLinkToAgeMsg( plLinkToAgeMsg * msg ); bool IProcessLinkToAgeMsg( plLinkToAgeMsg * msg );
void IDoLink(plLinkToAgeMsg* link);
bool IProcessVaultNotifyMsg(plVaultNotifyMsg* msg);
bool IDispatchMsg( plMessage * msg, UInt32 playerID ); bool IDispatchMsg( plMessage * msg, UInt32 playerID );

Loading…
Cancel
Save