1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Merge pull request #437 from zrax/hsRef

Clean up ref-counting
This commit is contained in:
2014-07-15 21:33:18 -04:00
60 changed files with 888 additions and 1423 deletions

View File

@ -802,15 +802,15 @@ bool plClothingOutfit::IReadFromVault()
WearDefaultClothing();
RelVaultNode * rvn = VaultGetAvatarOutfitFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return false;
ARRAY(RelVaultNode*) nodes;
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
RelVaultNode::RefList nodes;
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
for (unsigned i = 0; i < nodes.Count(); ++i) {
VaultSDLNode sdl(nodes[i]);
for (const hsRef<RelVaultNode> &node : nodes) {
VaultSDLNode sdl(node);
if (sdl.GetSDLDataLength()) {
hsRAMStream ram;
ram.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
@ -831,13 +831,11 @@ bool plClothingOutfit::IReadFromVault()
delete sdlDataRec;
}
}
nodes[i]->UnRef();
}
fSynchClients = true; // set true if the next synch should be bcast
ForceUpdate(true);
rvn->UnRef();
return true;
}
@ -857,8 +855,8 @@ void plClothingOutfit::WriteToVault()
if (!fVaultSaveEnabled)
return;
RelVaultNode * rvn;
if (nil == (rvn = VaultGetAvatarOutfitFolderIncRef()))
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return;
ARRAY(plStateDataRecord*) SDRs;
@ -874,7 +872,6 @@ void plClothingOutfit::WriteToVault()
SDRs.Add(appearanceStateDesc->GetStateDataRecord(0));
WriteToVault(SDRs);
rvn->UnRef();
}
void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
@ -883,8 +880,8 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
if (fAvatar->GetTarget(0) != plNetClientApp::GetInstance()->GetLocalPlayer())
return;
RelVaultNode * rvn;
if (nil == (rvn = VaultGetAvatarOutfitFolderIncRef()))
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return;
ARRAY(plStateDataRecord*) morphs;
@ -906,12 +903,12 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
}
}
ARRAY(RelVaultNode*) templates;
ARRAY(RelVaultNode*) actuals;
ARRAY(RelVaultNode*) nodes;
RelVaultNode::RefList templates;
RelVaultNode::RefList actuals;
RelVaultNode::RefList nodes;
// Get all existing clothing SDRs
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes); // REF: Find
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes); // REF: Find
const ARRAY(plStateDataRecord*) * arrs[] = {
&SDRs,
@ -922,55 +919,41 @@ void plClothingOutfit::WriteToVault(const ARRAY(plStateDataRecord*) & SDRs)
// Write all SDL to to the outfit folder, reusing existing nodes and creating new ones as necessary
for (unsigned i = 0; i < arr->Count(); ++i) {
RelVaultNode * node;
if (nodes.Count()) {
node = nodes[0];
nodes.DeleteUnordered(0);
node->Ref(); // REF: Work
node->UnRef(); // REF: Find
hsRef<RelVaultNode> node;
if (!nodes.empty()) {
node = nodes.front();
nodes.pop_front();
}
else {
RelVaultNode * templateNode = new RelVaultNode;
templateNode->SetNodeType(plVault::kNodeType_SDL);
templates.Add(templateNode);
node = templateNode;
node->Ref(); // REF: Create
node->Ref(); // REF: Work
node = new RelVaultNode;
node->SetNodeType(plVault::kNodeType_SDL);
templates.push_back(node);
}
VaultSDLNode sdl(node);
sdl.SetStateDataRecord((*arr)[i], 0);
node->UnRef(); // REF: Work
}
}
// Delete any leftover nodes
for (unsigned i = 0; i < nodes.Count(); ++i) {
VaultDeleteNode(nodes[i]->GetNodeId());
nodes[i]->UnRef(); // REF: Array
}
for (const hsRef<RelVaultNode> &node : nodes)
VaultDeleteNode(node->GetNodeId());
// Create actual new nodes from their templates
for (unsigned i = 0; i < templates.Count(); ++i) {
for (const hsRef<RelVaultNode> &temp : templates) {
ENetError result;
if (RelVaultNode * actual = VaultCreateNodeAndWaitIncRef(templates[i], &result)) {
actuals.Add(actual);
}
templates[i]->UnRef(); // REF: Create
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(temp, &result))
actuals.push_back(actual);
}
// Add new nodes to outfit folder
for (unsigned i = 0; i < actuals.Count(); ++i) {
VaultAddChildNodeAndWait(rvn->GetNodeId(), actuals[i]->GetNodeId(), NetCommGetPlayer()->playerInt);
actuals[i]->UnRef(); // REF: Create
}
for (const hsRef<RelVaultNode> &act : actuals)
VaultAddChildNodeAndWait(rvn->GetNodeId(), act->GetNodeId(), NetCommGetPlayer()->playerInt);
// Cleanup morph SDRs
for (unsigned i = 0; i < morphs.Count(); ++i) {
delete morphs[i];
}
rvn->UnRef();
}
// XXX HACK. DON'T USE (this function exists for the temp console command Clothing.SwapClothTexHACK)
@ -1483,29 +1466,25 @@ bool plClothingOutfit::WriteToFile(const plFileName &filename)
if (!filename.IsValid())
return false;
RelVaultNode* rvn = VaultGetAvatarOutfitFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarOutfitFolder();
if (!rvn)
return false;
hsUNIXStream S;
if (!S.Open(filename, "wb")) {
rvn->UnRef();
if (!S.Open(filename, "wb"))
return false;
}
S.WriteByte(fGroup);
ARRAY(RelVaultNode*) nodes;
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
S.WriteLE32(nodes.Count());
for (size_t i = 0; i < nodes.Count(); i++) {
VaultSDLNode sdl(nodes[i]);
RelVaultNode::RefList nodes;
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
S.WriteLE32(nodes.size());
for (const hsRef<RelVaultNode> &node : nodes) {
VaultSDLNode sdl(node);
S.WriteLE32(sdl.GetSDLDataLength());
if (sdl.GetSDLDataLength())
S.Write(sdl.GetSDLDataLength(), sdl.GetSDLData());
nodes[i]->UnRef();
}
rvn->UnRef();
S.Close();
return true;
@ -1626,14 +1605,14 @@ plClothingElement *plClothingMgr::FindElementByName(const plString &name) const
void plClothingMgr::AddItemsToCloset(hsTArray<plClosetItem> &items)
{
RelVaultNode * rvn = VaultGetAvatarClosetFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarClosetFolder();
if (!rvn)
return;
hsTArray<plClosetItem> closet;
GetClosetItems(closet);
ARRAY(RelVaultNode*) templates;
RelVaultNode::RefList templates;
for (unsigned i = 0; i < items.GetCount(); ++i) {
bool match = false;
@ -1651,44 +1630,40 @@ void plClothingMgr::AddItemsToCloset(hsTArray<plClosetItem> &items)
plStateDataRecord rec(plClothingSDLModifier::GetClothingItemSDRName());
plClothingSDLModifier::PutSingleItemIntoSDR(&items[i], &rec);
RelVaultNode * templateNode = new RelVaultNode;
templateNode->Ref();
hsRef<RelVaultNode> templateNode = new RelVaultNode;
templateNode->SetNodeType(plVault::kNodeType_SDL);
VaultSDLNode sdl(templateNode);
sdl.SetStateDataRecord(&rec);
templates.Add(templateNode);
templates.push_back(templateNode);
}
for (unsigned i = 0; i < templates.Count(); ++i) {
for (const hsRef<RelVaultNode> &temp : templates) {
ENetError result;
if (RelVaultNode * actual = VaultCreateNodeAndWaitIncRef(templates[i], &result)) {
if (hsRef<RelVaultNode> actual = VaultCreateNodeAndWait(temp, &result)) {
VaultAddChildNodeAndWait(
rvn->GetNodeId(),
actual->GetNodeId(),
NetCommGetPlayer()->playerInt
);
actual->UnRef(); // REF: Create
}
templates[i]->UnRef(); // REF: Create
}
rvn->UnRef();
}
void plClothingMgr::GetClosetItems(hsTArray<plClosetItem> &out)
{
RelVaultNode * rvn = VaultGetAvatarClosetFolderIncRef();
hsRef<RelVaultNode> rvn = VaultGetAvatarClosetFolder();
if (!rvn)
return;
ARRAY(RelVaultNode*) nodes;
rvn->GetChildNodesIncRef(plVault::kNodeType_SDL, 1, &nodes);
out.SetCount(nodes.Count());
RelVaultNode::RefList nodes;
rvn->GetChildNodes(plVault::kNodeType_SDL, 1, &nodes);
out.SetCount(nodes.size());
for (unsigned i = 0; i < nodes.Count(); ++i) {
VaultSDLNode sdl(nodes[i]);
auto iter = nodes.begin();
for (unsigned i = 0; i < nodes.size(); ++i, ++iter) {
VaultSDLNode sdl(*iter);
plStateDataRecord * rec = new plStateDataRecord;
if (sdl.GetStateDataRecord(rec, 0))
plClothingSDLModifier::HandleSingleSDR(rec, nil, &out[i]);
@ -1701,9 +1676,7 @@ void plClothingMgr::GetClosetItems(hsTArray<plClosetItem> &out)
out.Remove(i);
}
}
rvn->UnRef();
}
}
void plClothingMgr::GetAllWithSameMesh(plClothingItem *item, hsTArray<plClothingItem*> &out)
{

View File

@ -858,7 +858,7 @@ void plSceneInputInterface::ILinkOffereeToAge()
return;
}
}
else if (RelVaultNode * linkNode = VaultGetOwnedAgeLinkIncRef(&info)) {
else if (hsRef<RelVaultNode> linkNode = VaultGetOwnedAgeLink(&info)) {
// We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
VaultAgeLinkNode linkAcc(linkNode);
if (linkAcc.GetVolatile()) {
@ -868,7 +868,6 @@ void plSceneInputInterface::ILinkOffereeToAge()
VaultRegisterOwnedAgeAndWait(&link);
}
}
linkNode->UnRef();
}
if (!fSpawnPoint.IsEmpty()) {

View File

@ -513,13 +513,13 @@ bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
return false;
plAgeLinkStruct* cur = GetAgeLink();
RelVaultNode* cVaultLink = nil;
hsRef<RelVaultNode> cVaultLink;
switch (msg->GetType())
{
case plVaultNotifyMsg::kRegisteredChildAgeLink:
case plVaultNotifyMsg::kRegisteredOwnedAge:
case plVaultNotifyMsg::kRegisteredSubAgeLink:
cVaultLink = VaultGetNodeIncRef(msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode));
cVaultLink = VaultGetNode(msg->GetArgs()->GetInt(plNetCommon::VaultTaskArgs::kAgeLinkNode));
break;
default:
return false;
@ -531,18 +531,15 @@ bool plNetLinkingMgr::IProcessVaultNotifyMsg(plVaultNotifyMsg* msg)
// It's very useful though...
VaultAgeLinkNode accLink(cVaultLink);
accLink.CopyTo(cur);
if (RelVaultNode* rvnInfo = cVaultLink->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1))
if (hsRef<RelVaultNode> rvnInfo = cVaultLink->GetChildNode(plVault::kNodeType_AgeInfo, 1))
{
VaultAgeInfoNode accInfo(rvnInfo);
accInfo.CopyTo(cur->GetAgeInfo());
rvnInfo->UnRef();
}
IDoLink(fDeferredLink);
fDeferredLink = nil;
return true;
cVaultLink->UnRef();
}
return false;
@ -778,7 +775,7 @@ void plNetLinkingMgr::IPostProcessLink( void )
bool psnl = (info->GetAgeFilename().CompareI(kPersonalAgeFilename) == 0);
// Update our online status
if (RelVaultNode* rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
wchar_t ageInstName[MAX_PATH];
plUUID ageInstGuid = *info->GetAgeInstanceGuid();
@ -786,7 +783,6 @@ void plNetLinkingMgr::IPostProcessLink( void )
accInfo.SetAgeInstName(ageInstName);
accInfo.SetAgeInstUuid(ageInstGuid);
accInfo.SetOnline(true);
rvnInfo->UnRef();
}
switch (link->GetLinkingRules()) {
@ -797,8 +793,8 @@ void plNetLinkingMgr::IPostProcessLink( void )
break;
{ // Ensure we're in the AgeOwners folder
RelVaultNode* fldr = VaultGetAgeAgeOwnersFolderIncRef();
RelVaultNode* info = VaultGetPlayerInfoNodeIncRef();
hsRef<RelVaultNode> fldr = VaultGetAgeAgeOwnersFolder();
hsRef<RelVaultNode> info = VaultGetPlayerInfoNode();
if (fldr && info)
if (!fldr->IsParentOf(info->GetNodeId(), 1))
@ -809,11 +805,6 @@ void plNetLinkingMgr::IPostProcessLink( void )
nil,
nil
);
if (fldr)
fldr->UnRef();
if (info)
info->UnRef();
}
}
break;
@ -824,8 +815,8 @@ void plNetLinkingMgr::IPostProcessLink( void )
break;
{ // Ensure we're in the CanVisit folder
RelVaultNode* fldr = VaultGetAgeCanVisitFolderIncRef();
RelVaultNode* info = VaultGetPlayerInfoNodeIncRef();
hsRef<RelVaultNode> fldr = VaultGetAgeCanVisitFolder();
hsRef<RelVaultNode> info = VaultGetPlayerInfoNode();
if (fldr && info)
if (!fldr->IsParentOf(info->GetNodeId(), 1))
@ -836,11 +827,6 @@ void plNetLinkingMgr::IPostProcessLink( void )
nil,
nil
);
if (fldr)
fldr->UnRef();
if (info)
info->UnRef();
}
}
break;
@ -873,16 +859,15 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
#if 0
// Appear offline until we're done linking
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
accInfo.SetAgeInstName(nil);
accInfo.SetAgeInstUuid(kNilUuid);
accInfo.SetOnline(false);
rvnInfo->UnRef();
}
#else
// Update our online status
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode accInfo(rvnInfo);
wchar_t ageInstName[MAX_PATH];
plUUID ageInstGuid = *GetAgeLink()->GetAgeInfo()->GetAgeInstanceGuid();
@ -890,7 +875,6 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
accInfo.SetAgeInstName(ageInstName);
accInfo.SetAgeInstUuid(ageInstGuid);
accInfo.SetOnline(true);
rvnInfo->UnRef();
}
#endif
@ -984,7 +968,7 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
success = kLinkDeferred;
break;
}
else if (RelVaultNode* linkNode = VaultGetOwnedAgeLinkIncRef(&ageInfo)) {
else if (hsRef<RelVaultNode> linkNode = VaultGetOwnedAgeLink(&ageInfo)) {
// We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one.
VaultAgeLinkNode linkAcc(linkNode);
if (linkAcc.GetVolatile()) {
@ -1035,7 +1019,6 @@ uint8_t plNetLinkingMgr::IPreProcessLink(void)
break;
}
}
linkNode->UnRef();
}
}

View File

@ -275,10 +275,9 @@ static void PlayerInitCallback (
// Ensure the city link has the required spawn points
plAgeInfoStruct info;
info.SetAgeFilename(kCityAgeFilename);
if (RelVaultNode * rvn = VaultGetOwnedAgeLinkIncRef(&info)) {
if (hsRef<RelVaultNode> rvn = VaultGetOwnedAgeLink(&info)) {
VaultAgeLinkNode acc(rvn);
acc.AddSpawnPoint(plSpawnPointInfo(kCityFerryTerminalLinkTitle, kCityFerryTerminalLinkSpawnPtName));
rvn->UnRef();
}
VaultProcessPlayerInbox();
@ -1119,14 +1118,12 @@ void NetCommSetActivePlayer (//--> plNetCommActivePlayerMsg
unsigned playerInt = 0;
if (s_player) {
if (RelVaultNode* rvn = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvn = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode pInfo(rvn);
pInfo.SetAgeInstName(nil);
pInfo.SetAgeInstUuid(kNilUuid);
pInfo.SetOnline(false);
NetCliAuthVaultNodeSave(rvn, nil, nil);
rvn->UnRef();
}
VaultCull(s_player->playerInt);
@ -1321,10 +1318,9 @@ void NetCommUpgradeVisitorToExplorer (
void NetCommSetCCRLevel (
unsigned ccrLevel
) {
if (RelVaultNode * rvnInfo = VaultGetPlayerInfoNodeIncRef()) {
if (hsRef<RelVaultNode> rvnInfo = VaultGetPlayerInfoNode()) {
VaultPlayerInfoNode pInfo(rvnInfo);
pInfo.SetCCRLevel(ccrLevel);
rvnInfo->UnRef();
}
NetCliAuthSetCCRLevel(ccrLevel);

View File

@ -132,6 +132,20 @@ bool plAgeInfoStruct::IsEqualTo( const plAgeInfoStruct * other ) const
return match;
}
void plAgeInfoStruct::CopyFrom(const plAgeInfoStruct * other)
{
hsAssert(other, "CopyFrom called with null struct");
fFlags = other->fFlags;
fAgeFilename = other->fAgeFilename;
fAgeInstanceName = other->fAgeInstanceName;
fAgeInstanceGuid = other->fAgeInstanceGuid;
fAgeUserDefinedName = other->fAgeUserDefinedName;
fAgeDescription = other->fAgeDescription;
fAgeSequenceNumber = other->fAgeSequenceNumber;
fAgeLanguage = other->fAgeLanguage;
}
void plAgeInfoStruct::CopyFrom( const plVaultAgeInfoNode * node )
{
hsAssert(false, "eric, port me");
@ -441,7 +455,12 @@ void plAgeLinkStruct::CopyFrom( const plAgeLinkStruct * other )
{
if ( other )
{
*this=*other;
fFlags = other->fFlags;
fAgeInfo.CopyFrom(&other->fAgeInfo);
fLinkingRules = other->fLinkingRules;
fSpawnPoint = other->fSpawnPoint;
fAmCCR = other->fAmCCR;
fParentAgeFilename = other->fParentAgeFilename;
}
else
{

View File

@ -112,7 +112,7 @@ public:
void Clear();
void UpdateFlags() const;
void CopyFrom( const plAgeInfoStruct * other ) { *this=*other; }
void CopyFrom( const plAgeInfoStruct * other );
void CopyFrom( const plVaultAgeInfoNode * node );
void CopyFrom(const struct NetAgeInfo & info);
bool IsEqualTo( const plAgeInfoStruct * other ) const;

View File

@ -287,7 +287,7 @@ enum ENetTransState {
kTransStateComplete,
};
struct NetTrans : hsAtomicRefCnt {
struct NetTrans : hsRefCnt {
LINK(NetTrans) m_link;
ENetTransState m_state;
ENetError m_result;

View File

@ -57,7 +57,7 @@ namespace Ngl { namespace Auth {
*
***/
struct CliAuConn : hsAtomicRefCnt {
struct CliAuConn : hsRefCnt {
CliAuConn ();
~CliAuConn ();
@ -726,7 +726,7 @@ struct VaultFetchNodeTrans : NetAuthTrans {
FNetCliAuthVaultNodeFetched m_callback;
void * m_param;
NetVaultNode * m_node;
hsRef<NetVaultNode> m_node;
VaultFetchNodeTrans (
unsigned nodeId,
@ -751,14 +751,13 @@ struct VaultFindNodeTrans : NetAuthTrans {
FNetCliAuthVaultNodeFind m_callback;
void * m_param;
NetVaultNode * m_node;
hsRef<NetVaultNode> m_node;
VaultFindNodeTrans (
NetVaultNode * templateNode,
FNetCliAuthVaultNodeFind callback,
void * param
);
~VaultFindNodeTrans ();
bool Send ();
@ -774,7 +773,7 @@ struct VaultFindNodeTrans : NetAuthTrans {
//============================================================================
struct VaultCreateNodeTrans : NetAuthTrans {
NetVaultNode * m_templateNode;
hsRef<NetVaultNode> m_templateNode;
FNetCliAuthVaultNodeCreated m_callback;
void * m_param;
@ -1589,7 +1588,7 @@ static unsigned CliAuConnPingTimerProc (void * param) {
//============================================================================
CliAuConn::CliAuConn ()
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
: hsRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)
@ -3940,8 +3939,6 @@ void VaultFetchNodeTrans::Post () {
m_param,
m_node
);
if (m_node)
m_node->UnRef("Recv");
}
//============================================================================
@ -3954,7 +3951,6 @@ bool VaultFetchNodeTrans::Recv (
if (IS_NET_SUCCESS(reply.result)) {
m_node = new NetVaultNode;
m_node->Read_LCS(reply.nodeBuffer, reply.nodeBytes, 0);
m_node->Ref("Recv");
}
m_result = reply.result;
@ -3980,12 +3976,6 @@ VaultFindNodeTrans::VaultFindNodeTrans (
, m_param(param)
, m_node(templateNode)
{
m_node->Ref();
}
//============================================================================
VaultFindNodeTrans::~VaultFindNodeTrans () {
m_node->UnRef();
}
//============================================================================
@ -4056,7 +4046,6 @@ VaultCreateNodeTrans::VaultCreateNodeTrans (
, m_param(param)
, m_nodeId(0)
{
m_templateNode->Ref();
}
//============================================================================
@ -4086,7 +4075,6 @@ void VaultCreateNodeTrans::Post () {
m_param,
m_nodeId
);
m_templateNode->UnRef();
}
//============================================================================

View File

@ -60,7 +60,7 @@ namespace Ngl { namespace File {
*
***/
struct CliFileConn : hsAtomicRefCnt {
struct CliFileConn : hsRefCnt {
LINK(CliFileConn) link;
hsReaderWriterLock sockLock; // to protect the socket pointer so we don't nuke it while using it
AsyncSocket sock;
@ -581,7 +581,7 @@ static void AsyncLookupCallback (
//============================================================================
CliFileConn::CliFileConn ()
: hsAtomicRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false)
: hsRefCnt(0), sock(nil), seq(0), cancelId(nil), abandoned(false)
, buildId(0), serverType(0)
, reconnectTimer(nil), reconnectStartMs(0), connectStartMs(0)
, numImmediateDisconnects(0), numFailedConnects(0)

View File

@ -55,7 +55,7 @@ namespace Ngl { namespace Game {
*
***/
struct CliGmConn : hsAtomicRefCnt {
struct CliGmConn : hsRefCnt {
LINK(CliGmConn) link;
CCritSect critsect;
@ -415,7 +415,7 @@ static unsigned CliGmConnPingTimerProc (void * param) {
//============================================================================
CliGmConn::CliGmConn ()
: hsAtomicRefCnt(0), sock(nil), cancelId(nil), cli(nil)
: hsRefCnt(0), sock(nil), cancelId(nil), cli(nil)
, seq(0), abandoned(false)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
{

View File

@ -56,7 +56,7 @@ namespace Ngl { namespace GateKeeper {
*
***/
struct CliGkConn : hsAtomicRefCnt {
struct CliGkConn : hsRefCnt {
CliGkConn ();
~CliGkConn ();
@ -525,7 +525,7 @@ static unsigned CliGkConnPingTimerProc (void * param) {
//============================================================================
CliGkConn::CliGkConn ()
: hsAtomicRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
: hsRefCnt(0), reconnectTimer(nil), reconnectStartMs(0)
, pingTimer(nil), pingSendTimeMs(0), lastHeardTimeMs(0)
, sock(nil), cli(nil), seq(0), serverChallenge(0)
, cancelId(nil), abandoned(false)

View File

@ -117,7 +117,7 @@ static void CancelTrans_CS (NetTrans * trans, ENetError error) {
//============================================================================
NetTrans::NetTrans (ENetProtocol protocol, ETransType transType)
: hsAtomicRefCnt(0)
: hsRefCnt(0)
, m_state(kTransStateWaitServerConnect)
, m_result(kNetPending)
, m_transId(0)

View File

@ -48,7 +48,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//
// refcntable data
//
class plNetCommonMessageData : public hsAtomicRefCnt
class plNetCommonMessageData : public hsRefCnt
{
private:
char *fData; // sent

View File

@ -71,6 +71,16 @@ plFogEnvironment::~plFogEnvironment()
{
}
plFogEnvironment &plFogEnvironment::operator=(const plFogEnvironment &copy)
{
fType = copy.fType;
fStart = copy.fStart;
fEnd = copy.fEnd;
fDensity = copy.fDensity;
fColor = copy.fColor;
return *this;
}
//// Set /////////////////////////////////////////////////////////////////////
void plFogEnvironment::Set( float start, float end, float density, const hsColorRGBA *color )

View File

@ -85,6 +85,9 @@ class plFogEnvironment : public hsKeyedObject
plFogEnvironment( FogType type, float end, float density, hsColorRGBA &color );
~plFogEnvironment();
plFogEnvironment(const plFogEnvironment &copy) { operator=(copy); }
plFogEnvironment &operator=(const plFogEnvironment &copy);
// Sets the parameters for linear fog
void Set( float start, float end, float density, const hsColorRGBA *color = nil );

File diff suppressed because it is too large Load Diff

View File

@ -94,6 +94,8 @@ void VaultUnregisterCallback (VaultCallback * cb);
*
***/
struct RelVaultNode : NetVaultNode {
typedef std::list<hsRef<RelVaultNode>> RefList;
struct IRelVaultNode * state;
RelVaultNode ();
@ -126,51 +128,51 @@ struct RelVaultNode : NetVaultNode {
unsigned maxDepth
);
// returns first matching node found
RelVaultNode * GetParentNodeIncRef (
// returns first matching node found
hsRef<RelVaultNode> GetParentNode (
NetVaultNode * templateNode,
unsigned maxDepth
);
RelVaultNode * GetChildNodeIncRef (
hsRef<RelVaultNode> GetChildNode (
NetVaultNode * templateNode,
unsigned maxDepth
);
RelVaultNode * GetChildNodeIncRef (
hsRef<RelVaultNode> GetChildNode (
unsigned nodeType,
unsigned maxDepth
);
RelVaultNode * GetChildFolderNodeIncRef (
hsRef<RelVaultNode> GetChildFolderNode (
unsigned folderType,
unsigned maxDepth
);
RelVaultNode * GetChildPlayerInfoListNodeIncRef (
hsRef<RelVaultNode> GetChildPlayerInfoListNode (
unsigned folderType,
unsigned maxDepth
);
RelVaultNode * GetChildAgeInfoListNodeIncRef (
hsRef<RelVaultNode> GetChildAgeInfoListNode (
unsigned folderType,
unsigned maxDepth
);
// returns all matching nodes found
void GetChildNodesIncRef (
void GetChildNodes (
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
void GetChildNodesIncRef (
void GetChildNodes (
NetVaultNode * templateNode,
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
void GetChildNodesIncRef (
void GetChildNodes (
unsigned nodeType,
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
void GetChildFolderNodesIncRef (
void GetChildFolderNodes (
unsigned folderType,
unsigned maxDepth,
ARRAY(RelVaultNode*) * nodes
RefList * nodes
);
unsigned GetRefOwnerId (unsigned parentId);
@ -183,7 +185,7 @@ struct RelVaultNode : NetVaultNode {
void PrintTree (FStateDump dumpProc, unsigned level);
// AgeInfoNode-specific (and it checks!)
RelVaultNode * GetParentAgeLinkIncRef ();
hsRef<RelVaultNode> GetParentAgeLink ();
};
@ -204,12 +206,9 @@ void VaultUpdate ();
*
***/
RelVaultNode * VaultGetNodeIncRef (
unsigned nodeId
);
RelVaultNode * VaultGetNodeIncRef (
NetVaultNode * templateNode
);
hsRef<RelVaultNode> VaultGetNode(unsigned nodeId);
hsRef<RelVaultNode> VaultGetNode(NetVaultNode * templateNode);
// VaultAddChildNode will download the child node if necessary
// the parent exists locally before making the callback.
typedef void (*FVaultAddChildNodeCallback)(
@ -272,11 +271,11 @@ void VaultCreateNode ( // non-blocking
void * state,
void * param
);
RelVaultNode * VaultCreateNodeAndWaitIncRef ( // block until completion. returns node. nil --> failure
hsRef<RelVaultNode> VaultCreateNodeAndWait ( // block until completion. returns node. nil --> failure
plVault::NodeTypes nodeType,
ENetError * result
);
RelVaultNode * VaultCreateNodeAndWaitIncRef ( // block until completion. returns node. nil --> failure
hsRef<RelVaultNode> VaultCreateNodeAndWait ( // block until completion. returns node. nil --> failure
NetVaultNode * templateNode,
ENetError * result
);
@ -303,7 +302,7 @@ void VaultLocalFindNodes (
NetVaultNode * templateNode,
ARRAY(unsigned) * nodeIds
);
void VaultFetchNodesAndWait ( // Use VaultGetNodeIncRef to access the fetched nodes
void VaultFetchNodesAndWait ( // Use VaultGetNode to access the fetched nodes
const unsigned nodeIds[],
unsigned count,
bool force = false
@ -330,32 +329,32 @@ void VaultInitAge (
*
***/
unsigned VaultGetPlayerId ();
RelVaultNode * VaultGetPlayerNodeIncRef ();
RelVaultNode * VaultGetPlayerInfoNodeIncRef ();
RelVaultNode * VaultGetAvatarOutfitFolderIncRef ();
RelVaultNode * VaultGetAvatarClosetFolderIncRef ();
bool VaultGetLinkToMyNeighborhood (plAgeLinkStruct * link);
bool VaultGetLinkToMyPersonalAge (plAgeLinkStruct * link);
bool VaultGetLinkToCity (plAgeLinkStruct * link);
RelVaultNode * VaultGetAgesIOwnFolderIncRef ();
RelVaultNode * VaultGetAgesICanVisitFolderIncRef ();
RelVaultNode * VaultGetPlayerInboxFolderIncRef ();
RelVaultNode * VaultGetOwnedAgeLinkIncRef (const plAgeInfoStruct * info);
RelVaultNode * VaultGetOwnedAgeInfoIncRef (const plAgeInfoStruct * info);
bool VaultGetOwnedAgeLink (const plAgeInfoStruct * info, plAgeLinkStruct * link);
bool VaultAddOwnedAgeSpawnPoint (const plUUID& ageInstId, const plSpawnPointInfo & spawnPt);
bool VaultSetOwnedAgePublicAndWait (const plAgeInfoStruct * info, bool publicOrNot);
RelVaultNode * VaultGetVisitAgeLinkIncRef (const plAgeInfoStruct * info);
bool VaultGetVisitAgeLink (const plAgeInfoStruct * info, class plAgeLinkStruct * link);
bool VaultRegisterOwnedAgeAndWait (const plAgeLinkStruct * link);
void VaultRegisterOwnedAge(const plAgeLinkStruct* link);
bool VaultRegisterVisitAgeAndWait (const plAgeLinkStruct * link);
void VaultRegisterVisitAge (const plAgeLinkStruct* link);
bool VaultUnregisterOwnedAgeAndWait (const plAgeInfoStruct * info);
bool VaultUnregisterVisitAgeAndWait (const plAgeInfoStruct * info);
RelVaultNode * VaultFindChronicleEntryIncRef (const wchar_t entryName[], int entryType = -1);
bool VaultHasChronicleEntry (const wchar_t entryName[], int entryType = -1);
unsigned VaultGetPlayerId();
hsRef<RelVaultNode> VaultGetPlayerNode();
hsRef<RelVaultNode> VaultGetPlayerInfoNode();
hsRef<RelVaultNode> VaultGetAvatarOutfitFolder();
hsRef<RelVaultNode> VaultGetAvatarClosetFolder();
bool VaultGetLinkToMyNeighborhood(plAgeLinkStruct * link);
bool VaultGetLinkToMyPersonalAge(plAgeLinkStruct * link);
bool VaultGetLinkToCity(plAgeLinkStruct * link);
hsRef<RelVaultNode> VaultGetAgesIOwnFolder();
hsRef<RelVaultNode> VaultGetAgesICanVisitFolder();
hsRef<RelVaultNode> VaultGetPlayerInboxFolder();
hsRef<RelVaultNode> VaultGetOwnedAgeLink(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultGetOwnedAgeInfo(const plAgeInfoStruct * info);
bool VaultGetOwnedAgeLink(const plAgeInfoStruct * info, plAgeLinkStruct * link);
bool VaultAddOwnedAgeSpawnPoint(const plUUID& ageInstId, const plSpawnPointInfo & spawnPt);
bool VaultSetOwnedAgePublicAndWait(const plAgeInfoStruct * info, bool publicOrNot);
hsRef<RelVaultNode> VaultGetVisitAgeLink(const plAgeInfoStruct * info);
bool VaultGetVisitAgeLink(const plAgeInfoStruct * info, class plAgeLinkStruct * link);
bool VaultRegisterOwnedAgeAndWait(const plAgeLinkStruct * link);
void VaultRegisterOwnedAge(const plAgeLinkStruct* link);
bool VaultRegisterVisitAgeAndWait(const plAgeLinkStruct * link);
void VaultRegisterVisitAge(const plAgeLinkStruct* link);
bool VaultUnregisterOwnedAgeAndWait(const plAgeInfoStruct * info);
bool VaultUnregisterVisitAgeAndWait(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultFindChronicleEntry(const wchar_t entryName[], int entryType = -1);
bool VaultHasChronicleEntry(const wchar_t entryName[], int entryType = -1);
// if entry of same name and type already exists, value is updated
void VaultAddChronicleEntryAndWait (
const wchar_t entryName[],
@ -390,32 +389,32 @@ void VaultProcessPlayerInbox ();
#define DEFAULT_DEVICE_INBOX L"DevInbox"
RelVaultNode * VaultGetAgeNodeIncRef ();
RelVaultNode * VaultGetAgeInfoNodeIncRef ();
RelVaultNode * VaultGetAgeChronicleFolderIncRef ();
RelVaultNode * VaultGetAgeDevicesFolderIncRef ();
RelVaultNode * VaultGetAgeSubAgesFolderIncRef ();
RelVaultNode * VaultGetAgeChildAgesFolderIncRef ();
RelVaultNode * VaultGetAgeAgeOwnersFolderIncRef ();
RelVaultNode * VaultGetAgeCanVisitFolderIncRef ();
RelVaultNode * VaultGetAgePeopleIKnowAboutFolderIncRef ();
RelVaultNode * VaultGetAgePublicAgesFolderIncRef ();
RelVaultNode * VaultAgeGetBookshelfFolderIncRef ();
RelVaultNode * VaultFindAgeSubAgeLinkIncRef (const plAgeInfoStruct * info);
RelVaultNode * VaultFindAgeChildAgeLinkIncRef (const plAgeInfoStruct * info);
RelVaultNode * VaultFindAgeChronicleEntryIncRef (const wchar_t entryName[], int entryType = -1);
hsRef<RelVaultNode> VaultGetAgeNode();
hsRef<RelVaultNode> VaultGetAgeInfoNode();
hsRef<RelVaultNode> VaultGetAgeChronicleFolder();
hsRef<RelVaultNode> VaultGetAgeDevicesFolder();
hsRef<RelVaultNode> VaultGetAgeSubAgesFolder();
hsRef<RelVaultNode> VaultGetAgeChildAgesFolder();
hsRef<RelVaultNode> VaultGetAgeAgeOwnersFolder();
hsRef<RelVaultNode> VaultGetAgeCanVisitFolder();
hsRef<RelVaultNode> VaultGetAgePeopleIKnowAboutFolder();
hsRef<RelVaultNode> VaultGetAgePublicAgesFolder();
hsRef<RelVaultNode> VaultAgeGetBookshelfFolder();
hsRef<RelVaultNode> VaultFindAgeSubAgeLink(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultFindAgeChildAgeLink(const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultFindAgeChronicleEntry(const wchar_t entryName[], int entryType = -1);
// if entry of same name and type already exists, value is updated
void VaultAddAgeChronicleEntry (
const wchar_t entryName[],
int entryType,
const wchar_t entryValue[]
);
RelVaultNode * VaultAgeAddDeviceAndWaitIncRef (const wchar_t deviceName[]); // blocks until completion
hsRef<RelVaultNode> VaultAgeAddDeviceAndWait(const wchar_t deviceName[]); // blocks until completion
void VaultAgeRemoveDevice (const wchar_t deviceName[]);
bool VaultAgeHasDevice (const wchar_t deviceName[]);
RelVaultNode * VaultAgeGetDeviceIncRef (const wchar_t deviceName[]);
RelVaultNode * VaultAgeSetDeviceInboxAndWaitIncRef (const wchar_t deviceName[], const wchar_t inboxName[]); // blocks until completion
RelVaultNode * VaultAgeGetDeviceInboxIncRef (const wchar_t deviceName[]);
hsRef<RelVaultNode> VaultAgeGetDevice(const wchar_t deviceName[]);
hsRef<RelVaultNode> VaultAgeSetDeviceInboxAndWait(const wchar_t deviceName[], const wchar_t inboxName[]); // blocks until completion
hsRef<RelVaultNode> VaultAgeGetDeviceInbox(const wchar_t deviceName[]);
void VaultClearDeviceInboxMap ();
bool VaultAgeGetAgeSDL (class plStateDataRecord * out);
@ -423,7 +422,7 @@ void VaultAgeUpdateAgeSDL (const class plStateDataRecord * rec);
unsigned VaultAgeGetAgeTime ();
RelVaultNode * VaultGetSubAgeLinkIncRef (const plAgeInfoStruct * info);
hsRef<RelVaultNode> VaultGetSubAgeLink(const plAgeInfoStruct * info);
bool VaultAgeGetSubAgeLink (
const plAgeInfoStruct * info,
plAgeLinkStruct * link
@ -435,7 +434,7 @@ bool VaultAgeFindOrCreateSubAgeLinkAndWait (
);
bool VaultAgeFindOrCreateSubAgeLink(const plAgeInfoStruct* info, plAgeLinkStruct* link, const plUUID& arentUuid);
bool VaultAgeFindOrCreateChildAgeLinkAndWait (
const wchar_t parentAgeName[], // nil --> current age, non-nil --> owned age by given name
const wchar_t parentAgeName[], // nil --> current age, non-nil --> owned age by given name
const plAgeInfoStruct * info,
plAgeLinkStruct * link
);
@ -494,7 +493,7 @@ void VaultCull (
*
***/
RelVaultNode * VaultGetSystemNodeIncRef ();
RelVaultNode * VaultGetGlobalInboxIncRef ();
hsRef<RelVaultNode> VaultGetSystemNode();
hsRef<RelVaultNode> VaultGetGlobalInbox();
#endif // def CLIENT

View File

@ -435,14 +435,12 @@ struct MatchesSpawnPointName
//============================================================================
#ifdef CLIENT
bool VaultAgeLinkNode::CopyTo (plAgeLinkStruct * link) {
if (RelVaultNode * me = VaultGetNodeIncRef(base->GetNodeId())) {
if (RelVaultNode * info = me->GetChildNodeIncRef(plVault::kNodeType_AgeInfo, 1)) {
if (hsRef<RelVaultNode> me = VaultGetNode(base->GetNodeId())) {
if (hsRef<RelVaultNode> info = me->GetChildNode(plVault::kNodeType_AgeInfo, 1)) {
VaultAgeInfoNode access(info);
access.CopyTo(link->GetAgeInfo());
me->UnRef();
return true;
}
me->UnRef();
}
link->Clear();
return false;