mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Fix line endings and tabs
This commit is contained in:
@ -1,29 +1,29 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(pnKeyedObject_HEADERS
|
||||
hsKeyedObject.h
|
||||
plFixedKey.h
|
||||
plKey.h
|
||||
plKeyImp.h
|
||||
plMsgForwarder.h
|
||||
plReceiver.h
|
||||
plUoid.h
|
||||
pnKeyedObjectCreatable.h
|
||||
)
|
||||
|
||||
set(pnKeyedObject_SOURCES
|
||||
hsKeyedObject.cpp
|
||||
plFixedKey.cpp
|
||||
plKey.cpp
|
||||
plKeyImp.cpp
|
||||
plMsgForwarder.cpp
|
||||
plUoid.cpp
|
||||
)
|
||||
|
||||
add_library(pnKeyedObject STATIC ${pnKeyedObject_HEADERS} ${pnKeyedObject_SOURCES})
|
||||
|
||||
source_group("Header Files" FILES ${pnKeyedObject_HEADERS})
|
||||
source_group("Source Files" FILES ${pnKeyedObject_SOURCES})
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(pnKeyedObject_HEADERS
|
||||
hsKeyedObject.h
|
||||
plFixedKey.h
|
||||
plKey.h
|
||||
plKeyImp.h
|
||||
plMsgForwarder.h
|
||||
plReceiver.h
|
||||
plUoid.h
|
||||
pnKeyedObjectCreatable.h
|
||||
)
|
||||
|
||||
set(pnKeyedObject_SOURCES
|
||||
hsKeyedObject.cpp
|
||||
plFixedKey.cpp
|
||||
plKey.cpp
|
||||
plKeyImp.cpp
|
||||
plMsgForwarder.cpp
|
||||
plUoid.cpp
|
||||
)
|
||||
|
||||
add_library(pnKeyedObject STATIC ${pnKeyedObject_HEADERS} ${pnKeyedObject_SOURCES})
|
||||
|
||||
source_group("Header Files" FILES ${pnKeyedObject_HEADERS})
|
||||
source_group("Source Files" FILES ${pnKeyedObject_SOURCES})
|
||||
|
@ -1,175 +1,175 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "hsKeyedObject.h"
|
||||
#include "plKeyImp.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "pnDispatch/plDispatch.h"
|
||||
#include "pnMessage/plSelfDestructMsg.h"
|
||||
|
||||
void hsKeyedObject::SetKey(plKey k)
|
||||
{
|
||||
if (fpKey != nil)
|
||||
{
|
||||
hsAssert(k == nil || k == fpKey, "Changing an object's key is not allowed");
|
||||
((plKeyImp*)fpKey)->SetObjectPtr(nil);
|
||||
}
|
||||
|
||||
fpKey = k;
|
||||
|
||||
if (fpKey != nil)
|
||||
((plKeyImp*)fpKey)->SetObjectPtr(this);
|
||||
}
|
||||
|
||||
hsBool hsKeyedObject::SendRef(plRefMsg* refMsg, plRefFlags::Type flags)
|
||||
{
|
||||
plKey key = GetKey(); // for linux build
|
||||
return hsgResMgr::SendRef(key, refMsg, flags);
|
||||
}
|
||||
|
||||
const char* hsKeyedObject::GetKeyName() const
|
||||
{
|
||||
if (fpKey)
|
||||
return fpKey->GetName();
|
||||
else
|
||||
return "(unknown)";
|
||||
}
|
||||
|
||||
hsKeyedObject::~hsKeyedObject()
|
||||
{
|
||||
if( fpKey && fpKey->ObjectIsLoaded() )
|
||||
{
|
||||
// If our key is pointing to an object (presumably back to us),
|
||||
// then UnRegister will call SetObjectPtr(nil) will unregister the key (and us), which will
|
||||
// decrement our RefCnt. Unfortunately, we are here because of a call
|
||||
// to our destructor, in which case we don't want to go back into our
|
||||
// destructor again. So we'll just up the RefCnt, plKey::UnRegister will dec it back to 1.
|
||||
hsRefCnt_SafeRef(fpKey->ObjectIsLoaded());
|
||||
}
|
||||
UnRegister();
|
||||
}
|
||||
|
||||
void hsKeyedObject::UnRegister()
|
||||
{
|
||||
if (fpKey)
|
||||
{
|
||||
if (plgDispatch::Dispatch())
|
||||
plgDispatch::Dispatch()->UnRegisterAll(fpKey);
|
||||
|
||||
((plKeyImp *)fpKey)->SetObjectPtr(nil);
|
||||
}
|
||||
}
|
||||
|
||||
plKey hsKeyedObject::RegisterAs(plFixedKeyId fixedKey)
|
||||
{
|
||||
plUoid meUoid(fixedKey);
|
||||
|
||||
hsAssert(meUoid.GetClassType() == ClassIndex(), "Registering as wrong type!");
|
||||
plKey key = hsgResMgr::ResMgr()->FindKey(meUoid);
|
||||
if (key == nil)
|
||||
{
|
||||
key = hsgResMgr::ResMgr()->NewKey(meUoid, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetKey(key);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
void hsKeyedObject::UnRegisterAs(plFixedKeyId fixedKey)
|
||||
{
|
||||
plUoid uoid(fixedKey);
|
||||
UnRegisterAsManual(uoid);
|
||||
}
|
||||
|
||||
plKey hsKeyedObject::RegisterAsManual(plUoid& meUoid, const char* p)
|
||||
{
|
||||
hsAssert(meUoid.GetClassType() == ClassIndex(),"Registering as wrong type!");
|
||||
// Really should be a NewKey() call just for fixed keys, so change this once player rooms behave
|
||||
plKey pkey = hsgResMgr::ResMgr()->ReRegister(p,meUoid);
|
||||
|
||||
if (pkey)
|
||||
SetKey(pkey);
|
||||
return pkey;
|
||||
}
|
||||
|
||||
|
||||
void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid)
|
||||
{
|
||||
if (fpKey)
|
||||
{
|
||||
plUoid myUoid = fpKey->GetUoid();
|
||||
if (!(inUoid == myUoid))
|
||||
{
|
||||
#if !HS_BUILD_FOR_UNIX // disable for unix servers
|
||||
char inStr[255], myStr[255];
|
||||
inUoid.StringIze(inStr);
|
||||
myUoid.StringIze(myStr);
|
||||
hsAssert(false,
|
||||
xtl::format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s",
|
||||
fpKey->GetName() ? fpKey->GetName() : "?", inStr, myStr).c_str());
|
||||
#endif
|
||||
}
|
||||
((plKeyImp*)fpKey)->UnRegister();
|
||||
}
|
||||
}
|
||||
|
||||
void hsKeyedObject::Validate()
|
||||
{
|
||||
const char* msg = "KeyedObject invalid!";
|
||||
|
||||
if (fpKey)
|
||||
{
|
||||
hsAssert(fpKey->GetObjectPtr() == this, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void hsKeyedObject::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plKey pK = mgr->ReadKey(s);
|
||||
SetKey(pK);
|
||||
}
|
||||
|
||||
void hsKeyedObject::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
hsAssert(GetKey(),"hsKeyedObject:Must have a key!");
|
||||
mgr->WriteKey(s, fpKey);
|
||||
}
|
||||
|
||||
hsBool hsKeyedObject::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plSelfDestructMsg* nuke = plSelfDestructMsg::ConvertNoRef(msg);
|
||||
if (nuke)
|
||||
{
|
||||
hsAssert(RefCnt() == 1, "Trying to selfdestruct with bogus refcnt");
|
||||
hsRefCnt_SafeUnRef(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
return plReceiver::MsgReceive(msg);
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "hsKeyedObject.h"
|
||||
#include "plKeyImp.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "pnDispatch/plDispatch.h"
|
||||
#include "pnMessage/plSelfDestructMsg.h"
|
||||
|
||||
void hsKeyedObject::SetKey(plKey k)
|
||||
{
|
||||
if (fpKey != nil)
|
||||
{
|
||||
hsAssert(k == nil || k == fpKey, "Changing an object's key is not allowed");
|
||||
((plKeyImp*)fpKey)->SetObjectPtr(nil);
|
||||
}
|
||||
|
||||
fpKey = k;
|
||||
|
||||
if (fpKey != nil)
|
||||
((plKeyImp*)fpKey)->SetObjectPtr(this);
|
||||
}
|
||||
|
||||
hsBool hsKeyedObject::SendRef(plRefMsg* refMsg, plRefFlags::Type flags)
|
||||
{
|
||||
plKey key = GetKey(); // for linux build
|
||||
return hsgResMgr::SendRef(key, refMsg, flags);
|
||||
}
|
||||
|
||||
const char* hsKeyedObject::GetKeyName() const
|
||||
{
|
||||
if (fpKey)
|
||||
return fpKey->GetName();
|
||||
else
|
||||
return "(unknown)";
|
||||
}
|
||||
|
||||
hsKeyedObject::~hsKeyedObject()
|
||||
{
|
||||
if( fpKey && fpKey->ObjectIsLoaded() )
|
||||
{
|
||||
// If our key is pointing to an object (presumably back to us),
|
||||
// then UnRegister will call SetObjectPtr(nil) will unregister the key (and us), which will
|
||||
// decrement our RefCnt. Unfortunately, we are here because of a call
|
||||
// to our destructor, in which case we don't want to go back into our
|
||||
// destructor again. So we'll just up the RefCnt, plKey::UnRegister will dec it back to 1.
|
||||
hsRefCnt_SafeRef(fpKey->ObjectIsLoaded());
|
||||
}
|
||||
UnRegister();
|
||||
}
|
||||
|
||||
void hsKeyedObject::UnRegister()
|
||||
{
|
||||
if (fpKey)
|
||||
{
|
||||
if (plgDispatch::Dispatch())
|
||||
plgDispatch::Dispatch()->UnRegisterAll(fpKey);
|
||||
|
||||
((plKeyImp *)fpKey)->SetObjectPtr(nil);
|
||||
}
|
||||
}
|
||||
|
||||
plKey hsKeyedObject::RegisterAs(plFixedKeyId fixedKey)
|
||||
{
|
||||
plUoid meUoid(fixedKey);
|
||||
|
||||
hsAssert(meUoid.GetClassType() == ClassIndex(), "Registering as wrong type!");
|
||||
plKey key = hsgResMgr::ResMgr()->FindKey(meUoid);
|
||||
if (key == nil)
|
||||
{
|
||||
key = hsgResMgr::ResMgr()->NewKey(meUoid, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetKey(key);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
void hsKeyedObject::UnRegisterAs(plFixedKeyId fixedKey)
|
||||
{
|
||||
plUoid uoid(fixedKey);
|
||||
UnRegisterAsManual(uoid);
|
||||
}
|
||||
|
||||
plKey hsKeyedObject::RegisterAsManual(plUoid& meUoid, const char* p)
|
||||
{
|
||||
hsAssert(meUoid.GetClassType() == ClassIndex(),"Registering as wrong type!");
|
||||
// Really should be a NewKey() call just for fixed keys, so change this once player rooms behave
|
||||
plKey pkey = hsgResMgr::ResMgr()->ReRegister(p,meUoid);
|
||||
|
||||
if (pkey)
|
||||
SetKey(pkey);
|
||||
return pkey;
|
||||
}
|
||||
|
||||
|
||||
void hsKeyedObject::UnRegisterAsManual(plUoid& inUoid)
|
||||
{
|
||||
if (fpKey)
|
||||
{
|
||||
plUoid myUoid = fpKey->GetUoid();
|
||||
if (!(inUoid == myUoid))
|
||||
{
|
||||
#if !HS_BUILD_FOR_UNIX // disable for unix servers
|
||||
char inStr[255], myStr[255];
|
||||
inUoid.StringIze(inStr);
|
||||
myUoid.StringIze(myStr);
|
||||
hsAssert(false,
|
||||
xtl::format("Request to Unregister wrong FixedKey, keyName=%s, inUoid=%s, myUoid=%s",
|
||||
fpKey->GetName() ? fpKey->GetName() : "?", inStr, myStr).c_str());
|
||||
#endif
|
||||
}
|
||||
((plKeyImp*)fpKey)->UnRegister();
|
||||
}
|
||||
}
|
||||
|
||||
void hsKeyedObject::Validate()
|
||||
{
|
||||
const char* msg = "KeyedObject invalid!";
|
||||
|
||||
if (fpKey)
|
||||
{
|
||||
hsAssert(fpKey->GetObjectPtr() == this, msg);
|
||||
}
|
||||
}
|
||||
|
||||
void hsKeyedObject::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
plKey pK = mgr->ReadKey(s);
|
||||
SetKey(pK);
|
||||
}
|
||||
|
||||
void hsKeyedObject::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
hsAssert(GetKey(),"hsKeyedObject:Must have a key!");
|
||||
mgr->WriteKey(s, fpKey);
|
||||
}
|
||||
|
||||
hsBool hsKeyedObject::MsgReceive(plMessage* msg)
|
||||
{
|
||||
plSelfDestructMsg* nuke = plSelfDestructMsg::ConvertNoRef(msg);
|
||||
if (nuke)
|
||||
{
|
||||
hsAssert(RefCnt() == 1, "Trying to selfdestruct with bogus refcnt");
|
||||
hsRefCnt_SafeUnRef(this);
|
||||
|
||||
return true;
|
||||
}
|
||||
return plReceiver::MsgReceive(msg);
|
||||
}
|
||||
|
@ -1,89 +1,89 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef hsKeyedObject_h_inc
|
||||
#define hsKeyedObject_h_inc
|
||||
|
||||
#include "plReceiver.h"
|
||||
#include "plRefFlags.h"
|
||||
|
||||
#include "plKey.h"
|
||||
#include "plFixedKey.h"
|
||||
|
||||
class hsStream;
|
||||
class plRefMsg;
|
||||
class plUoid;
|
||||
|
||||
class hsKeyedObject : public plReceiver
|
||||
{
|
||||
public:
|
||||
hsKeyedObject() : fpKey(nil) {}
|
||||
virtual ~hsKeyedObject();
|
||||
|
||||
CLASSNAME_REGISTER(hsKeyedObject);
|
||||
GETINTERFACE_ANY(hsKeyedObject, plReceiver);
|
||||
|
||||
const plKey& GetKey() const { return fpKey; }
|
||||
const char* GetKeyName() const;
|
||||
|
||||
virtual void Validate();
|
||||
virtual hsBool IsFinal() { return true; }; // experimental; currently "is ready to process Loads"
|
||||
|
||||
virtual void Read(hsStream* s, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
//----------------------
|
||||
// Send a reference to GetKey() via enclosed message. See plKey::SendRef()
|
||||
//----------------------
|
||||
hsBool SendRef(plRefMsg* refMsg, plRefFlags::Type flags);
|
||||
|
||||
//----------------------------------------
|
||||
// Fixed key functions
|
||||
// The following are to be matched pairs!
|
||||
//----------------------------------------
|
||||
plKey RegisterAs(plFixedKeyId fixedKey); // a fixed Key value from plFixedKey.h
|
||||
void UnRegisterAs(plFixedKeyId fixedKey);
|
||||
|
||||
// used when manually loading the player room
|
||||
plKey RegisterAsManual(plUoid& uoid, const char* p);
|
||||
void UnRegisterAsManual(plUoid& uoid);
|
||||
|
||||
// If you want clone keys to share a type of object, override this function for it.
|
||||
// (You can also return a new object that shares only some of the original's data)
|
||||
virtual hsKeyedObject* GetSharedObject() { return nil; }
|
||||
|
||||
protected:
|
||||
friend class plResManager;
|
||||
|
||||
virtual void SetKey(plKey k);
|
||||
void UnRegister();
|
||||
|
||||
private:
|
||||
plKey fpKey;
|
||||
};
|
||||
|
||||
#endif // hsKeyedObject_h_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef hsKeyedObject_h_inc
|
||||
#define hsKeyedObject_h_inc
|
||||
|
||||
#include "plReceiver.h"
|
||||
#include "plRefFlags.h"
|
||||
|
||||
#include "plKey.h"
|
||||
#include "plFixedKey.h"
|
||||
|
||||
class hsStream;
|
||||
class plRefMsg;
|
||||
class plUoid;
|
||||
|
||||
class hsKeyedObject : public plReceiver
|
||||
{
|
||||
public:
|
||||
hsKeyedObject() : fpKey(nil) {}
|
||||
virtual ~hsKeyedObject();
|
||||
|
||||
CLASSNAME_REGISTER(hsKeyedObject);
|
||||
GETINTERFACE_ANY(hsKeyedObject, plReceiver);
|
||||
|
||||
const plKey& GetKey() const { return fpKey; }
|
||||
const char* GetKeyName() const;
|
||||
|
||||
virtual void Validate();
|
||||
virtual hsBool IsFinal() { return true; }; // experimental; currently "is ready to process Loads"
|
||||
|
||||
virtual void Read(hsStream* s, hsResMgr* mgr);
|
||||
virtual void Write(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
//----------------------
|
||||
// Send a reference to GetKey() via enclosed message. See plKey::SendRef()
|
||||
//----------------------
|
||||
hsBool SendRef(plRefMsg* refMsg, plRefFlags::Type flags);
|
||||
|
||||
//----------------------------------------
|
||||
// Fixed key functions
|
||||
// The following are to be matched pairs!
|
||||
//----------------------------------------
|
||||
plKey RegisterAs(plFixedKeyId fixedKey); // a fixed Key value from plFixedKey.h
|
||||
void UnRegisterAs(plFixedKeyId fixedKey);
|
||||
|
||||
// used when manually loading the player room
|
||||
plKey RegisterAsManual(plUoid& uoid, const char* p);
|
||||
void UnRegisterAsManual(plUoid& uoid);
|
||||
|
||||
// If you want clone keys to share a type of object, override this function for it.
|
||||
// (You can also return a new object that shares only some of the original's data)
|
||||
virtual hsKeyedObject* GetSharedObject() { return nil; }
|
||||
|
||||
protected:
|
||||
friend class plResManager;
|
||||
|
||||
virtual void SetKey(plKey k);
|
||||
void UnRegister();
|
||||
|
||||
private:
|
||||
plKey fpKey;
|
||||
};
|
||||
|
||||
#endif // hsKeyedObject_h_inc
|
||||
|
@ -1,165 +1,165 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// plFixedKey
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
#include "plUoid.h"
|
||||
#include <string.h>
|
||||
|
||||
//// plKeySeed ///////////////////////////////////////////////////////////////
|
||||
// Our seed struct. Defined here so it doesn't have to be in the .h file
|
||||
|
||||
struct plKeySeed
|
||||
{
|
||||
plFixedKeyId feFixedKey;
|
||||
// NOTE: The following fields are broken out to make adding to the fixed key list easier.
|
||||
// However, what they really are, are just the fields of plUoid (including plLocation)
|
||||
UInt16 fType;
|
||||
const char *fObj;
|
||||
|
||||
hsBool Match( plKeySeed *p )
|
||||
{
|
||||
if( ( fType == p->fType ) && stricmp( p->fObj, fObj ) == 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#include "plFixedKey.h"
|
||||
#include "plCreatableIndex.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "../pnFactory/plCreator.h"
|
||||
|
||||
// Rules for SeedList:
|
||||
// 1) Must be in the Same order as enum fixedKey
|
||||
// 2) For now at least, all your fixed keys get put into the kGlobalFixedLoc room, reserved just for fixed keys
|
||||
// 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey
|
||||
// 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime)
|
||||
|
||||
plKeySeed SeedList[] = {
|
||||
// Key Enum Type Obj
|
||||
|
||||
{ kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kFirst_Fixed_KEY" },
|
||||
|
||||
{ kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), "kLOSObject_KEY", },
|
||||
{ kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), "kTimerCallbackManager_KEY", },
|
||||
{ kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), "kConsoleObject_KEY", },
|
||||
{ kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), "kAudioSystem_KEY", },
|
||||
{ kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), "kInput_KEY", },
|
||||
{ kClient_KEY, CLASS_INDEX_SCOPED( plClient ), "kClient_KEY", },
|
||||
{ kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), "kNetClientMgr_KEY", },
|
||||
{ kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), "kListenerMod_KEY", },
|
||||
{ kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), "kTransitionMgr_KEY", },
|
||||
{ kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), "kLinkEffectsMgr_KEY", },
|
||||
{ kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), "kGameGUIMgr_KEY", },
|
||||
{ kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kGameGUIDynamicDlg_KEY", },
|
||||
{ kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), "kVirtualCamera_KEY", },
|
||||
{ kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kDefaultCameraMod1_KEY", },
|
||||
{ kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), "kKIGUIGlue_KEY", },
|
||||
{ kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), "kClothingMgr_KEY", },
|
||||
{ kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), "kInputInterfaceMgr_KEY", },
|
||||
{ kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), "kAVIWriter_KEY", },
|
||||
{ kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), "kResManagerHelper_KEY", },
|
||||
{ kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), "kAvatarMgr_KEY", },
|
||||
{ kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), "kSimulationMgr_KEY", },
|
||||
{ kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kTransitionCamera_KEY", },
|
||||
{ kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), "kCCRMgr_KEY", },
|
||||
{ kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kNetClientCloneRoom_KEY", },
|
||||
{ kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), "kMarkerMgr_KEY", },
|
||||
{ kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), "kAutoProfile_KEY", },
|
||||
{ kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), "kGlobalVisMgr_KEY", },
|
||||
{ kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), "kFontCache_KEY", },
|
||||
{ kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), "kRelevanceMgr_KEY", },
|
||||
{ kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), "kJournalBookMgr_KEY" },
|
||||
{ kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), "kAgeLoader_KEY" },
|
||||
{ kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kBuiltIn3rdPersonCamera_KEY", },
|
||||
{ kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), "kSecurePreloader_KEY", },
|
||||
|
||||
|
||||
{ kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kLast_Fixed_KEY", }
|
||||
};
|
||||
|
||||
|
||||
//// plFixedKeyValidator /////////////////////////////////////////////////////
|
||||
// Static class that validates the fixed key list on startup, to make sure
|
||||
// you didn't mess up the array.
|
||||
|
||||
class plFixedKeyValidator
|
||||
{
|
||||
private:
|
||||
static plFixedKeyValidator fValidator;
|
||||
|
||||
plFixedKeyValidator::plFixedKeyValidator()
|
||||
{
|
||||
// verify that each Seed is in the correct spot...via the enum...
|
||||
int i;
|
||||
for (i= kFirst_Fixed_KEY; i < kLast_Fixed_KEY; i++)
|
||||
{
|
||||
plKeySeed *p= &SeedList[i];
|
||||
hsAssert(i == p->feFixedKey, "The fixed key table in plFixedKey.h is invalid (a fixed key is misplaced). Please ensure the list follows the given restrictions.");
|
||||
}
|
||||
// check for duplicates
|
||||
for (i= kFirst_Fixed_KEY; i < kLast_Fixed_KEY; i++)
|
||||
{
|
||||
for (int c = i+1; c < kLast_Fixed_KEY; c++)
|
||||
{
|
||||
hsAssert(!SeedList[i].Match(&SeedList[c]),
|
||||
"The fixed key table in plFixedKey.h is invalid (there are duplicate fixed keys). Please ensure the list follows the given restrictions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
plFixedKeyValidator plFixedKeyValidator::fValidator;
|
||||
|
||||
//// The plUoid Fixed-Key Constructor ////////////////////////////////////////
|
||||
// Put here because a) it's fixedKey dependant and b) it ensures that this
|
||||
// file gets compiled.
|
||||
|
||||
plUoid::plUoid(plFixedKeyId fixedkey)
|
||||
{
|
||||
hsAssert(fixedkey < kLast_Fixed_KEY, "Request for Fixed key is out of Range");
|
||||
|
||||
fObjectName = nil;
|
||||
Invalidate();
|
||||
|
||||
plKeySeed* p= &SeedList[fixedkey];
|
||||
|
||||
fLocation = plLocation::kGlobalFixedLoc;
|
||||
fClassType = p->fType;
|
||||
fObjectName = hsStrcpy(p->fObj);
|
||||
fObjectID = 0;
|
||||
fCloneID = 0;
|
||||
fClonePlayerID = 0;
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// plFixedKey
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsUtils.h"
|
||||
#include "plUoid.h"
|
||||
#include <string.h>
|
||||
|
||||
//// plKeySeed ///////////////////////////////////////////////////////////////
|
||||
// Our seed struct. Defined here so it doesn't have to be in the .h file
|
||||
|
||||
struct plKeySeed
|
||||
{
|
||||
plFixedKeyId feFixedKey;
|
||||
// NOTE: The following fields are broken out to make adding to the fixed key list easier.
|
||||
// However, what they really are, are just the fields of plUoid (including plLocation)
|
||||
UInt16 fType;
|
||||
const char *fObj;
|
||||
|
||||
hsBool Match( plKeySeed *p )
|
||||
{
|
||||
if( ( fType == p->fType ) && stricmp( p->fObj, fObj ) == 0 )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#include "plFixedKey.h"
|
||||
#include "plCreatableIndex.h"
|
||||
#include "../pnKeyedObject/plKey.h"
|
||||
#include "../pnFactory/plCreator.h"
|
||||
|
||||
// Rules for SeedList:
|
||||
// 1) Must be in the Same order as enum fixedKey
|
||||
// 2) For now at least, all your fixed keys get put into the kGlobalFixedLoc room, reserved just for fixed keys
|
||||
// 2) Be sure your ClassIndex CLASS_INDEX(plSceneObject) matches the type of object you want to have the fixedKey
|
||||
// 3) Make sure the Obj is unique for this location/Type Combo... (validated at runtime)
|
||||
|
||||
plKeySeed SeedList[] = {
|
||||
// Key Enum Type Obj
|
||||
|
||||
{ kFirst_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kFirst_Fixed_KEY" },
|
||||
|
||||
{ kLOSObject_KEY, CLASS_INDEX_SCOPED( plLOSDispatch ), "kLOSObject_KEY", },
|
||||
{ kTimerCallbackManager_KEY, CLASS_INDEX_SCOPED( plTimerCallbackManager ), "kTimerCallbackManager_KEY", },
|
||||
{ kConsoleObject_KEY, CLASS_INDEX_SCOPED( pfConsole ), "kConsoleObject_KEY", },
|
||||
{ kAudioSystem_KEY, CLASS_INDEX_SCOPED( plAudioSystem ), "kAudioSystem_KEY", },
|
||||
{ kInput_KEY, CLASS_INDEX_SCOPED( plInputManager ), "kInput_KEY", },
|
||||
{ kClient_KEY, CLASS_INDEX_SCOPED( plClient ), "kClient_KEY", },
|
||||
{ kNetClientMgr_KEY, CLASS_INDEX_SCOPED( plNetClientMgr ), "kNetClientMgr_KEY", },
|
||||
{ kListenerMod_KEY, CLASS_INDEX_SCOPED( plListener ), "kListenerMod_KEY", },
|
||||
{ kTransitionMgr_KEY, CLASS_INDEX_SCOPED( plTransitionMgr ), "kTransitionMgr_KEY", },
|
||||
{ kLinkEffectsMgr_KEY, CLASS_INDEX_SCOPED( plLinkEffectsMgr ), "kLinkEffectsMgr_KEY", },
|
||||
{ kGameGUIMgr_KEY, CLASS_INDEX_SCOPED( pfGameGUIMgr ), "kGameGUIMgr_KEY", },
|
||||
{ kGameGUIDynamicDlg_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kGameGUIDynamicDlg_KEY", },
|
||||
{ kVirtualCamera1_KEY, CLASS_INDEX_SCOPED( plVirtualCam1 ), "kVirtualCamera_KEY", },
|
||||
{ kDefaultCameraMod1_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kDefaultCameraMod1_KEY", },
|
||||
{ kKIGUIGlue_KEY, CLASS_INDEX_SCOPED( pfKI ), "kKIGUIGlue_KEY", },
|
||||
{ kClothingMgr_KEY, CLASS_INDEX_SCOPED( plClothingMgr ), "kClothingMgr_KEY", },
|
||||
{ kInputInterfaceMgr_KEY, CLASS_INDEX_SCOPED( plInputInterfaceMgr ), "kInputInterfaceMgr_KEY", },
|
||||
{ kAVIWriter_KEY, CLASS_INDEX_SCOPED( plAVIWriter ), "kAVIWriter_KEY", },
|
||||
{ kResManagerHelper_KEY, CLASS_INDEX_SCOPED( plResManagerHelper ), "kResManagerHelper_KEY", },
|
||||
{ kAvatarMgr_KEY, CLASS_INDEX_SCOPED( plAvatarMgr ), "kAvatarMgr_KEY", },
|
||||
{ kSimulationMgr_KEY, CLASS_INDEX_SCOPED( plSimulationMgr ), "kSimulationMgr_KEY", },
|
||||
{ kTransitionCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kTransitionCamera_KEY", },
|
||||
{ kCCRMgr_KEY, CLASS_INDEX_SCOPED( plCCRMgr ), "kCCRMgr_KEY", },
|
||||
{ kNetClientCloneRoom_KEY, CLASS_INDEX_SCOPED( plSceneNode ), "kNetClientCloneRoom_KEY", },
|
||||
{ kMarkerMgr_KEY, CLASS_INDEX_SCOPED( pfMarkerMgr ), "kMarkerMgr_KEY", },
|
||||
{ kAutoProfile_KEY, CLASS_INDEX_SCOPED( plAutoProfile ), "kAutoProfile_KEY", },
|
||||
{ kGlobalVisMgr_KEY, CLASS_INDEX_SCOPED( plVisMgr ), "kGlobalVisMgr_KEY", },
|
||||
{ kFontCache_KEY, CLASS_INDEX_SCOPED( plFontCache ), "kFontCache_KEY", },
|
||||
{ kRelevanceMgr_KEY, CLASS_INDEX_SCOPED( plRelevanceMgr ), "kRelevanceMgr_KEY", },
|
||||
{ kJournalBookMgr_KEY, CLASS_INDEX_SCOPED( pfJournalBook ), "kJournalBookMgr_KEY" },
|
||||
{ kAgeLoader_KEY, CLASS_INDEX_SCOPED( plAgeLoader), "kAgeLoader_KEY" },
|
||||
{ kBuiltIn3rdPersonCamera_KEY, CLASS_INDEX_SCOPED( plCameraModifier1 ), "kBuiltIn3rdPersonCamera_KEY", },
|
||||
{ kSecurePreloader_KEY, CLASS_INDEX_SCOPED( pfSecurePreloader ), "kSecurePreloader_KEY", },
|
||||
|
||||
|
||||
{ kLast_Fixed_KEY, CLASS_INDEX_SCOPED( plSceneObject ), "kLast_Fixed_KEY", }
|
||||
};
|
||||
|
||||
|
||||
//// plFixedKeyValidator /////////////////////////////////////////////////////
|
||||
// Static class that validates the fixed key list on startup, to make sure
|
||||
// you didn't mess up the array.
|
||||
|
||||
class plFixedKeyValidator
|
||||
{
|
||||
private:
|
||||
static plFixedKeyValidator fValidator;
|
||||
|
||||
plFixedKeyValidator::plFixedKeyValidator()
|
||||
{
|
||||
// verify that each Seed is in the correct spot...via the enum...
|
||||
int i;
|
||||
for (i= kFirst_Fixed_KEY; i < kLast_Fixed_KEY; i++)
|
||||
{
|
||||
plKeySeed *p= &SeedList[i];
|
||||
hsAssert(i == p->feFixedKey, "The fixed key table in plFixedKey.h is invalid (a fixed key is misplaced). Please ensure the list follows the given restrictions.");
|
||||
}
|
||||
// check for duplicates
|
||||
for (i= kFirst_Fixed_KEY; i < kLast_Fixed_KEY; i++)
|
||||
{
|
||||
for (int c = i+1; c < kLast_Fixed_KEY; c++)
|
||||
{
|
||||
hsAssert(!SeedList[i].Match(&SeedList[c]),
|
||||
"The fixed key table in plFixedKey.h is invalid (there are duplicate fixed keys). Please ensure the list follows the given restrictions.");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
plFixedKeyValidator plFixedKeyValidator::fValidator;
|
||||
|
||||
//// The plUoid Fixed-Key Constructor ////////////////////////////////////////
|
||||
// Put here because a) it's fixedKey dependant and b) it ensures that this
|
||||
// file gets compiled.
|
||||
|
||||
plUoid::plUoid(plFixedKeyId fixedkey)
|
||||
{
|
||||
hsAssert(fixedkey < kLast_Fixed_KEY, "Request for Fixed key is out of Range");
|
||||
|
||||
fObjectName = nil;
|
||||
Invalidate();
|
||||
|
||||
plKeySeed* p= &SeedList[fixedkey];
|
||||
|
||||
fLocation = plLocation::kGlobalFixedLoc;
|
||||
fClassType = p->fType;
|
||||
fObjectName = hsStrcpy(p->fObj);
|
||||
fObjectID = 0;
|
||||
fCloneID = 0;
|
||||
fClonePlayerID = 0;
|
||||
}
|
||||
|
||||
|
@ -1,78 +1,78 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef PLFIXEDKEY_H
|
||||
#define PLFIXEDKEY_H
|
||||
|
||||
|
||||
// Using Fixed Key feature:
|
||||
// Add a new fixedkey to the enum list below.
|
||||
// Then add, to the Seed list (in plFixedKey.cpp) in the Corresponding
|
||||
// position, (don't screw up, it will be validated...)
|
||||
// The "Full Address" data for you Fixed key (see rules in plFixedKey.cpp)
|
||||
|
||||
enum plFixedKeyId
|
||||
{
|
||||
kFirst_Fixed_KEY,
|
||||
|
||||
kLOSObject_KEY,
|
||||
kTimerCallbackManager_KEY,
|
||||
kConsoleObject_KEY,
|
||||
kAudioSystem_KEY,
|
||||
kInput_KEY,
|
||||
kClient_KEY,
|
||||
kNetClientMgr_KEY,
|
||||
kListenerMod_KEY,
|
||||
kTransitionMgr_KEY,
|
||||
kLinkEffectsMgr_KEY,
|
||||
kGameGUIMgr_KEY,
|
||||
kGameGUIDynamicDlg_KEY,
|
||||
kVirtualCamera1_KEY,
|
||||
kDefaultCameraMod1_KEY,
|
||||
kKIGUIGlue_KEY,
|
||||
kClothingMgr_KEY,
|
||||
kInputInterfaceMgr_KEY,
|
||||
kAVIWriter_KEY,
|
||||
kResManagerHelper_KEY,
|
||||
kAvatarMgr_KEY,
|
||||
kSimulationMgr_KEY,
|
||||
kTransitionCamera_KEY,
|
||||
kCCRMgr_KEY,
|
||||
kNetClientCloneRoom_KEY,
|
||||
kMarkerMgr_KEY,
|
||||
kAutoProfile_KEY,
|
||||
kGlobalVisMgr_KEY,
|
||||
kFontCache_KEY,
|
||||
kRelevanceMgr_KEY,
|
||||
kJournalBookMgr_KEY,
|
||||
kAgeLoader_KEY,
|
||||
kBuiltIn3rdPersonCamera_KEY,
|
||||
kSecurePreloader_KEY,
|
||||
|
||||
kLast_Fixed_KEY
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef PLFIXEDKEY_H
|
||||
#define PLFIXEDKEY_H
|
||||
|
||||
|
||||
// Using Fixed Key feature:
|
||||
// Add a new fixedkey to the enum list below.
|
||||
// Then add, to the Seed list (in plFixedKey.cpp) in the Corresponding
|
||||
// position, (don't screw up, it will be validated...)
|
||||
// The "Full Address" data for you Fixed key (see rules in plFixedKey.cpp)
|
||||
|
||||
enum plFixedKeyId
|
||||
{
|
||||
kFirst_Fixed_KEY,
|
||||
|
||||
kLOSObject_KEY,
|
||||
kTimerCallbackManager_KEY,
|
||||
kConsoleObject_KEY,
|
||||
kAudioSystem_KEY,
|
||||
kInput_KEY,
|
||||
kClient_KEY,
|
||||
kNetClientMgr_KEY,
|
||||
kListenerMod_KEY,
|
||||
kTransitionMgr_KEY,
|
||||
kLinkEffectsMgr_KEY,
|
||||
kGameGUIMgr_KEY,
|
||||
kGameGUIDynamicDlg_KEY,
|
||||
kVirtualCamera1_KEY,
|
||||
kDefaultCameraMod1_KEY,
|
||||
kKIGUIGlue_KEY,
|
||||
kClothingMgr_KEY,
|
||||
kInputInterfaceMgr_KEY,
|
||||
kAVIWriter_KEY,
|
||||
kResManagerHelper_KEY,
|
||||
kAvatarMgr_KEY,
|
||||
kSimulationMgr_KEY,
|
||||
kTransitionCamera_KEY,
|
||||
kCCRMgr_KEY,
|
||||
kNetClientCloneRoom_KEY,
|
||||
kMarkerMgr_KEY,
|
||||
kAutoProfile_KEY,
|
||||
kGlobalVisMgr_KEY,
|
||||
kFontCache_KEY,
|
||||
kRelevanceMgr_KEY,
|
||||
kJournalBookMgr_KEY,
|
||||
kAgeLoader_KEY,
|
||||
kBuiltIn3rdPersonCamera_KEY,
|
||||
kSecurePreloader_KEY,
|
||||
|
||||
kLast_Fixed_KEY
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,287 +1,287 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// plKey - An opaque pointer to actual key data, so that we can keep track
|
||||
// of how many people have pointers (plKeys) to key data (plKeyImp)
|
||||
// and destroy the key data when it's been fully unreffed.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plKey.h"
|
||||
#include "plUoid.h"
|
||||
#include <string.h>
|
||||
#include "hsResMgr.h"
|
||||
#include "hsTypes.h"
|
||||
|
||||
#define TRACK_REFS 0 // MEMLEAKFISH
|
||||
|
||||
#if TRACK_REFS
|
||||
#include "plCreatableIndex.h"
|
||||
#include "plClassIndexMacros.h"
|
||||
#include "plTweak.h"
|
||||
|
||||
int mlfTrack = 1;
|
||||
|
||||
static const char* keyNameToLookFor = "AgeSDLHook";
|
||||
static const UInt16 CLASS_TO_TRACK = CLASS_INDEX_SCOPED(plSceneObject);
|
||||
static const int kCloneID = 0;
|
||||
static const int kClonePlayerID = 0;
|
||||
static plKeyData* lastData = nil;
|
||||
static const int kLocSeq = -1;
|
||||
|
||||
class keyDataFriend : public plKeyData
|
||||
{
|
||||
public:
|
||||
UInt16 RefCount() const { return fRefCount; }
|
||||
};
|
||||
|
||||
static int IsTracked(const plKeyData* keyData)
|
||||
{
|
||||
if( mlfTrack && keyData )
|
||||
{
|
||||
if( keyData->GetUoid().GetObjectName() && !stricmp(keyData->GetUoid().GetObjectName(), keyNameToLookFor)
|
||||
&& (keyData->GetUoid().GetClassType() == CLASS_TO_TRACK) )
|
||||
{
|
||||
if( (kCloneID < 0)
|
||||
||(kCloneID == keyData->GetUoid().GetCloneID()) )
|
||||
{
|
||||
if( (kLocSeq < 0)
|
||||
||(kLocSeq == keyData->GetUoid().GetLocation().GetSequenceNumber()) )
|
||||
{
|
||||
plConst(UInt16) kMinRefCount(0);
|
||||
const keyDataFriend* kdf = (keyDataFriend*)keyData;
|
||||
if( kdf->RefCount() > kMinRefCount )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char* CloneString(const plKeyData* keyData)
|
||||
{
|
||||
static char buff[256];
|
||||
if( keyData )
|
||||
{
|
||||
sprintf(buff, "CID:%d, CPID:%d LOC:%d",
|
||||
keyData->GetUoid().GetCloneID(),
|
||||
keyData->GetUoid().GetClonePlayerID(),
|
||||
keyData->GetUoid().GetLocation().GetSequenceNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buff, "nil");
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
plKey::plKey() : fKeyData(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plKey::plKey(void* ptr) : fKeyData(nil)
|
||||
{
|
||||
hsAssert(!ptr, "Attempting to publically construct a non-nil key");
|
||||
}
|
||||
|
||||
plKey::plKey(const plKey& rhs) : fKeyData(rhs.fKeyData)
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
sprintf( msg, "C: Key %s %s is being constructed using the plKey(plKey&) constructor", keyNameToLookFor, CloneString(fKeyData) );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
IIncRef();
|
||||
}
|
||||
|
||||
plKey::plKey(plKeyData* data, hsBool ignore) : fKeyData(data)
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
sprintf( msg, "C: Key %s %s is being constructed using the plKey(plKeyData*, hsBool) constructor", keyNameToLookFor, CloneString(fKeyData) );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
IIncRef();
|
||||
}
|
||||
|
||||
plKey::~plKey()
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
sprintf( msg, "D: Key %s %s is being destructed", keyNameToLookFor, CloneString(fKeyData) );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
IDecRef();
|
||||
}
|
||||
|
||||
plKey &plKey::operator=( const plKey &rhs )
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( fKeyData != rhs.fKeyData )
|
||||
{
|
||||
if( IsTracked(rhs.fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
if (fKeyData == nil)
|
||||
sprintf( msg, "=: Key %s %s is being assigned to a nil key", keyNameToLookFor, CloneString(rhs.fKeyData) );
|
||||
else
|
||||
sprintf( msg, "=: Key %s %s is being assigned to %s", keyNameToLookFor, CloneString(rhs.fKeyData), fKeyData->GetUoid().GetObjectName() );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
if (fKeyData == nil)
|
||||
sprintf( msg, "=: Nil key is being assigned to %s %s", keyNameToLookFor, CloneString(fKeyData) );
|
||||
else
|
||||
sprintf( msg, "=: Key %s %s is being assigned to %s", fKeyData->GetUoid().GetObjectName(), CloneString(fKeyData), keyNameToLookFor );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if( fKeyData != rhs.fKeyData )
|
||||
{
|
||||
IDecRef();
|
||||
fKeyData = rhs.fKeyData;
|
||||
IIncRef();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
hsBool plKey::operator==( const plKey &rhs ) const
|
||||
{
|
||||
return fKeyData == rhs.fKeyData;
|
||||
}
|
||||
|
||||
hsBool plKey::operator==( const plKeyData *rhs ) const
|
||||
{
|
||||
return fKeyData == rhs;
|
||||
}
|
||||
|
||||
plKeyData *plKey::operator->() const
|
||||
{
|
||||
return fKeyData;
|
||||
}
|
||||
|
||||
plKeyData &plKey::operator*() const
|
||||
{
|
||||
return *fKeyData;
|
||||
}
|
||||
|
||||
void plKey::IIncRef()
|
||||
{
|
||||
if (!fKeyData)
|
||||
return;
|
||||
|
||||
hsAssert(fKeyData->fRefCount < 0xffff, "Too many refs to plKeyImp");
|
||||
fKeyData->fRefCount++;
|
||||
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
plConst(int) kMaxCnt(30);
|
||||
if( fKeyData->fRefCount > kMaxCnt )
|
||||
*msg = 0;
|
||||
if( lastData && (fKeyData != lastData) )
|
||||
*msg = 0;
|
||||
lastData = fKeyData;
|
||||
sprintf( msg, "+: Key %s %s is being reffed! Refcount: %d", keyNameToLookFor, CloneString(fKeyData), fKeyData->fRefCount );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fKeyData->fRefCount == 1)
|
||||
hsgResMgr::ResMgr()->IKeyReffed((plKeyImp*)fKeyData);
|
||||
}
|
||||
|
||||
void plKey::IDecRef()
|
||||
{
|
||||
if (!fKeyData)
|
||||
return;
|
||||
|
||||
hsAssert(fKeyData->fRefCount, "Dec'ing ref on unreffed key");
|
||||
fKeyData->fRefCount--;
|
||||
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
plConst(int) kMinCnt(2);
|
||||
if( fKeyData->fRefCount < kMinCnt )
|
||||
*msg = 0;
|
||||
if( lastData && (fKeyData != lastData) )
|
||||
*msg = 0;
|
||||
lastData = fKeyData;
|
||||
sprintf( msg, "-: Key %s %s is being de-reffed! Refcount: %d", keyNameToLookFor, CloneString(fKeyData), fKeyData->fRefCount );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
if( fKeyData->fRefCount == 0 )
|
||||
*msg = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fKeyData->fRefCount == 0)
|
||||
hsgResMgr::ResMgr()->IKeyUnreffed((plKeyImp*)fKeyData);
|
||||
}
|
||||
|
||||
//// plKeyData ///////////////////////////////////////////////////////////////
|
||||
// Our base class of key data
|
||||
|
||||
plKeyData::plKeyData()
|
||||
{
|
||||
fRefCount = 0;
|
||||
}
|
||||
|
||||
plKeyData::~plKeyData()
|
||||
{
|
||||
// hsAssert(fRefCount == 0, "Deleting key data when someone still has a ref to it");
|
||||
}
|
||||
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// plKey - An opaque pointer to actual key data, so that we can keep track
|
||||
// of how many people have pointers (plKeys) to key data (plKeyImp)
|
||||
// and destroy the key data when it's been fully unreffed.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plKey.h"
|
||||
#include "plUoid.h"
|
||||
#include <string.h>
|
||||
#include "hsResMgr.h"
|
||||
#include "hsTypes.h"
|
||||
|
||||
#define TRACK_REFS 0 // MEMLEAKFISH
|
||||
|
||||
#if TRACK_REFS
|
||||
#include "plCreatableIndex.h"
|
||||
#include "plClassIndexMacros.h"
|
||||
#include "plTweak.h"
|
||||
|
||||
int mlfTrack = 1;
|
||||
|
||||
static const char* keyNameToLookFor = "AgeSDLHook";
|
||||
static const UInt16 CLASS_TO_TRACK = CLASS_INDEX_SCOPED(plSceneObject);
|
||||
static const int kCloneID = 0;
|
||||
static const int kClonePlayerID = 0;
|
||||
static plKeyData* lastData = nil;
|
||||
static const int kLocSeq = -1;
|
||||
|
||||
class keyDataFriend : public plKeyData
|
||||
{
|
||||
public:
|
||||
UInt16 RefCount() const { return fRefCount; }
|
||||
};
|
||||
|
||||
static int IsTracked(const plKeyData* keyData)
|
||||
{
|
||||
if( mlfTrack && keyData )
|
||||
{
|
||||
if( keyData->GetUoid().GetObjectName() && !stricmp(keyData->GetUoid().GetObjectName(), keyNameToLookFor)
|
||||
&& (keyData->GetUoid().GetClassType() == CLASS_TO_TRACK) )
|
||||
{
|
||||
if( (kCloneID < 0)
|
||||
||(kCloneID == keyData->GetUoid().GetCloneID()) )
|
||||
{
|
||||
if( (kLocSeq < 0)
|
||||
||(kLocSeq == keyData->GetUoid().GetLocation().GetSequenceNumber()) )
|
||||
{
|
||||
plConst(UInt16) kMinRefCount(0);
|
||||
const keyDataFriend* kdf = (keyDataFriend*)keyData;
|
||||
if( kdf->RefCount() > kMinRefCount )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char* CloneString(const plKeyData* keyData)
|
||||
{
|
||||
static char buff[256];
|
||||
if( keyData )
|
||||
{
|
||||
sprintf(buff, "CID:%d, CPID:%d LOC:%d",
|
||||
keyData->GetUoid().GetCloneID(),
|
||||
keyData->GetUoid().GetClonePlayerID(),
|
||||
keyData->GetUoid().GetLocation().GetSequenceNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(buff, "nil");
|
||||
}
|
||||
return buff;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
plKey::plKey() : fKeyData(nil)
|
||||
{
|
||||
}
|
||||
|
||||
plKey::plKey(void* ptr) : fKeyData(nil)
|
||||
{
|
||||
hsAssert(!ptr, "Attempting to publically construct a non-nil key");
|
||||
}
|
||||
|
||||
plKey::plKey(const plKey& rhs) : fKeyData(rhs.fKeyData)
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
sprintf( msg, "C: Key %s %s is being constructed using the plKey(plKey&) constructor", keyNameToLookFor, CloneString(fKeyData) );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
IIncRef();
|
||||
}
|
||||
|
||||
plKey::plKey(plKeyData* data, hsBool ignore) : fKeyData(data)
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
sprintf( msg, "C: Key %s %s is being constructed using the plKey(plKeyData*, hsBool) constructor", keyNameToLookFor, CloneString(fKeyData) );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
IIncRef();
|
||||
}
|
||||
|
||||
plKey::~plKey()
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
sprintf( msg, "D: Key %s %s is being destructed", keyNameToLookFor, CloneString(fKeyData) );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
IDecRef();
|
||||
}
|
||||
|
||||
plKey &plKey::operator=( const plKey &rhs )
|
||||
{
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( fKeyData != rhs.fKeyData )
|
||||
{
|
||||
if( IsTracked(rhs.fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
if (fKeyData == nil)
|
||||
sprintf( msg, "=: Key %s %s is being assigned to a nil key", keyNameToLookFor, CloneString(rhs.fKeyData) );
|
||||
else
|
||||
sprintf( msg, "=: Key %s %s is being assigned to %s", keyNameToLookFor, CloneString(rhs.fKeyData), fKeyData->GetUoid().GetObjectName() );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
if (fKeyData == nil)
|
||||
sprintf( msg, "=: Nil key is being assigned to %s %s", keyNameToLookFor, CloneString(fKeyData) );
|
||||
else
|
||||
sprintf( msg, "=: Key %s %s is being assigned to %s", fKeyData->GetUoid().GetObjectName(), CloneString(fKeyData), keyNameToLookFor );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if( fKeyData != rhs.fKeyData )
|
||||
{
|
||||
IDecRef();
|
||||
fKeyData = rhs.fKeyData;
|
||||
IIncRef();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
hsBool plKey::operator==( const plKey &rhs ) const
|
||||
{
|
||||
return fKeyData == rhs.fKeyData;
|
||||
}
|
||||
|
||||
hsBool plKey::operator==( const plKeyData *rhs ) const
|
||||
{
|
||||
return fKeyData == rhs;
|
||||
}
|
||||
|
||||
plKeyData *plKey::operator->() const
|
||||
{
|
||||
return fKeyData;
|
||||
}
|
||||
|
||||
plKeyData &plKey::operator*() const
|
||||
{
|
||||
return *fKeyData;
|
||||
}
|
||||
|
||||
void plKey::IIncRef()
|
||||
{
|
||||
if (!fKeyData)
|
||||
return;
|
||||
|
||||
hsAssert(fKeyData->fRefCount < 0xffff, "Too many refs to plKeyImp");
|
||||
fKeyData->fRefCount++;
|
||||
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
plConst(int) kMaxCnt(30);
|
||||
if( fKeyData->fRefCount > kMaxCnt )
|
||||
*msg = 0;
|
||||
if( lastData && (fKeyData != lastData) )
|
||||
*msg = 0;
|
||||
lastData = fKeyData;
|
||||
sprintf( msg, "+: Key %s %s is being reffed! Refcount: %d", keyNameToLookFor, CloneString(fKeyData), fKeyData->fRefCount );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fKeyData->fRefCount == 1)
|
||||
hsgResMgr::ResMgr()->IKeyReffed((plKeyImp*)fKeyData);
|
||||
}
|
||||
|
||||
void plKey::IDecRef()
|
||||
{
|
||||
if (!fKeyData)
|
||||
return;
|
||||
|
||||
hsAssert(fKeyData->fRefCount, "Dec'ing ref on unreffed key");
|
||||
fKeyData->fRefCount--;
|
||||
|
||||
#if TRACK_REFS // FOR DEBUGGING ONLY
|
||||
if( IsTracked(fKeyData) )
|
||||
{
|
||||
char msg[ 512 ];
|
||||
plConst(int) kMinCnt(2);
|
||||
if( fKeyData->fRefCount < kMinCnt )
|
||||
*msg = 0;
|
||||
if( lastData && (fKeyData != lastData) )
|
||||
*msg = 0;
|
||||
lastData = fKeyData;
|
||||
sprintf( msg, "-: Key %s %s is being de-reffed! Refcount: %d", keyNameToLookFor, CloneString(fKeyData), fKeyData->fRefCount );
|
||||
//hsAssert( false, msg );
|
||||
hsStatusMessageF(msg);
|
||||
if( fKeyData->fRefCount == 0 )
|
||||
*msg = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fKeyData->fRefCount == 0)
|
||||
hsgResMgr::ResMgr()->IKeyUnreffed((plKeyImp*)fKeyData);
|
||||
}
|
||||
|
||||
//// plKeyData ///////////////////////////////////////////////////////////////
|
||||
// Our base class of key data
|
||||
|
||||
plKeyData::plKeyData()
|
||||
{
|
||||
fRefCount = 0;
|
||||
}
|
||||
|
||||
plKeyData::~plKeyData()
|
||||
{
|
||||
// hsAssert(fRefCount == 0, "Deleting key data when someone still has a ref to it");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,141 +1,141 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plKey_h_inc
|
||||
#define plKey_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plRefFlags.h"
|
||||
|
||||
class hsKeyedObject;
|
||||
class plRefMsg;
|
||||
class plUoid;
|
||||
class hsBitVector;
|
||||
|
||||
//// plKey ///////////////////////////////////////////////////////////////////
|
||||
// Pointer to a plKeyData struct, which is a handle to a keyedObject
|
||||
|
||||
class plKeyData;
|
||||
class plKeyImp;
|
||||
|
||||
class plKey
|
||||
{
|
||||
public:
|
||||
// Constructors and destructors and copy stuff
|
||||
plKey();
|
||||
plKey(const plKey& rhs);
|
||||
plKey(void* ptr); // For constructing a nil key
|
||||
~plKey();
|
||||
plKey& operator=(const plKey& rhs);
|
||||
|
||||
hsBool operator==(const plKey& rhs) const;
|
||||
hsBool operator==(const plKeyData* rhs) const;
|
||||
hsBool operator!=(const plKey& rhs) const { return !(*this == rhs); }
|
||||
hsBool operator!=(const plKeyData* rhs) const { return !(*this == rhs); }
|
||||
|
||||
plKeyData* operator->() const;
|
||||
plKeyData& operator*() const;
|
||||
|
||||
operator plKeyImp*() const { return (plKeyImp*)fKeyData; }
|
||||
|
||||
static plKey Make(plKeyData* data) { return plKey(data, false); }
|
||||
|
||||
protected:
|
||||
// Pointer to our real key
|
||||
plKeyData* fKeyData;
|
||||
void IIncRef();
|
||||
void IDecRef();
|
||||
|
||||
// Internal constructor, extra param is to distinguish it from the void* constructor
|
||||
plKey(plKeyData* data, hsBool ignore);
|
||||
};
|
||||
|
||||
//// plKeyData ///////////////////////////////////////////////////////////////
|
||||
// Base virtual class that provides the essential functionality you would
|
||||
// want from a plKey-ish thing.
|
||||
|
||||
class plKeyData
|
||||
{
|
||||
public:
|
||||
virtual const plUoid& GetUoid() const=0;
|
||||
virtual const char* GetName() const=0;
|
||||
|
||||
virtual hsKeyedObject* GetObjectPtr()=0;
|
||||
virtual hsKeyedObject* ObjectIsLoaded() const=0;
|
||||
virtual hsKeyedObject* VerifyLoaded() = 0;
|
||||
|
||||
//----------------------
|
||||
// Allow a keyed object to behave as if it has an active ref when in fact the object
|
||||
// should only be active ref'ed by a non-keyed parent. Essentially just bumps/decs
|
||||
// the active ref count to facilitate normal object creation/destruction
|
||||
//----------------------
|
||||
virtual hsKeyedObject* RefObject(plRefFlags::Type flags = plRefFlags::kActiveRef)=0;
|
||||
virtual void UnRefObject(plRefFlags::Type flags = plRefFlags::kActiveRef)=0;
|
||||
|
||||
//----------------------
|
||||
// Release has two behaviors, depending on whether the ref is active or passive:
|
||||
// Active - Release decs the ActiveRefCnt. When it gets to zero, the object will be deleted.
|
||||
// Passive - Unregisters my interest in when the object is created or destroyed.
|
||||
//----------------------
|
||||
virtual void Release(plKey targetKey)=0;
|
||||
|
||||
virtual UInt16 GetActiveRefs() const = 0;
|
||||
|
||||
virtual UInt16 GetNumNotifyCreated() const = 0;
|
||||
virtual plRefMsg* GetNotifyCreated(int i) const = 0;
|
||||
virtual const hsBitVector& GetActiveBits() const = 0;
|
||||
|
||||
protected:
|
||||
// Protected so only the registry can create it
|
||||
plKeyData();
|
||||
virtual ~plKeyData();
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
// Debugging info fields
|
||||
const char* fIDName;
|
||||
const char* fClassType;
|
||||
#endif
|
||||
|
||||
//// RefCount Stuff //////////////////////////////////////////////////////////
|
||||
// The refcounts on plKeyData/plKeyImps are zero-based. When you first create
|
||||
// a new plKeyImp (which should ONLY ever be done inside the resMgr), it gets
|
||||
// a refcount of zero. Assigning a new plKey to represent it bumps it to 1,
|
||||
// and when that key goes away, the refcount drops to zero and the ResManager
|
||||
// is notified of the fact and may delete the keyImp.
|
||||
// So the only refcounts on keys outside of the resMgr should be one or more;
|
||||
// only inside the resMgr should there EVER exist keys with a refcount of 0.
|
||||
//
|
||||
// Using our own refCount system instead of hsRefCnt allows us to make it all
|
||||
// protected, so that only plKey can actually ref/unref, which is as it should
|
||||
// be.
|
||||
|
||||
// Only one class should ever touch this...
|
||||
friend class plKey;
|
||||
|
||||
// Refcount--the number of plKeys that have pointers to us.
|
||||
UInt16 fRefCount;
|
||||
};
|
||||
|
||||
#endif // plKey_h_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plKey_h_inc
|
||||
#define plKey_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plRefFlags.h"
|
||||
|
||||
class hsKeyedObject;
|
||||
class plRefMsg;
|
||||
class plUoid;
|
||||
class hsBitVector;
|
||||
|
||||
//// plKey ///////////////////////////////////////////////////////////////////
|
||||
// Pointer to a plKeyData struct, which is a handle to a keyedObject
|
||||
|
||||
class plKeyData;
|
||||
class plKeyImp;
|
||||
|
||||
class plKey
|
||||
{
|
||||
public:
|
||||
// Constructors and destructors and copy stuff
|
||||
plKey();
|
||||
plKey(const plKey& rhs);
|
||||
plKey(void* ptr); // For constructing a nil key
|
||||
~plKey();
|
||||
plKey& operator=(const plKey& rhs);
|
||||
|
||||
hsBool operator==(const plKey& rhs) const;
|
||||
hsBool operator==(const plKeyData* rhs) const;
|
||||
hsBool operator!=(const plKey& rhs) const { return !(*this == rhs); }
|
||||
hsBool operator!=(const plKeyData* rhs) const { return !(*this == rhs); }
|
||||
|
||||
plKeyData* operator->() const;
|
||||
plKeyData& operator*() const;
|
||||
|
||||
operator plKeyImp*() const { return (plKeyImp*)fKeyData; }
|
||||
|
||||
static plKey Make(plKeyData* data) { return plKey(data, false); }
|
||||
|
||||
protected:
|
||||
// Pointer to our real key
|
||||
plKeyData* fKeyData;
|
||||
void IIncRef();
|
||||
void IDecRef();
|
||||
|
||||
// Internal constructor, extra param is to distinguish it from the void* constructor
|
||||
plKey(plKeyData* data, hsBool ignore);
|
||||
};
|
||||
|
||||
//// plKeyData ///////////////////////////////////////////////////////////////
|
||||
// Base virtual class that provides the essential functionality you would
|
||||
// want from a plKey-ish thing.
|
||||
|
||||
class plKeyData
|
||||
{
|
||||
public:
|
||||
virtual const plUoid& GetUoid() const=0;
|
||||
virtual const char* GetName() const=0;
|
||||
|
||||
virtual hsKeyedObject* GetObjectPtr()=0;
|
||||
virtual hsKeyedObject* ObjectIsLoaded() const=0;
|
||||
virtual hsKeyedObject* VerifyLoaded() = 0;
|
||||
|
||||
//----------------------
|
||||
// Allow a keyed object to behave as if it has an active ref when in fact the object
|
||||
// should only be active ref'ed by a non-keyed parent. Essentially just bumps/decs
|
||||
// the active ref count to facilitate normal object creation/destruction
|
||||
//----------------------
|
||||
virtual hsKeyedObject* RefObject(plRefFlags::Type flags = plRefFlags::kActiveRef)=0;
|
||||
virtual void UnRefObject(plRefFlags::Type flags = plRefFlags::kActiveRef)=0;
|
||||
|
||||
//----------------------
|
||||
// Release has two behaviors, depending on whether the ref is active or passive:
|
||||
// Active - Release decs the ActiveRefCnt. When it gets to zero, the object will be deleted.
|
||||
// Passive - Unregisters my interest in when the object is created or destroyed.
|
||||
//----------------------
|
||||
virtual void Release(plKey targetKey)=0;
|
||||
|
||||
virtual UInt16 GetActiveRefs() const = 0;
|
||||
|
||||
virtual UInt16 GetNumNotifyCreated() const = 0;
|
||||
virtual plRefMsg* GetNotifyCreated(int i) const = 0;
|
||||
virtual const hsBitVector& GetActiveBits() const = 0;
|
||||
|
||||
protected:
|
||||
// Protected so only the registry can create it
|
||||
plKeyData();
|
||||
virtual ~plKeyData();
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
// Debugging info fields
|
||||
const char* fIDName;
|
||||
const char* fClassType;
|
||||
#endif
|
||||
|
||||
//// RefCount Stuff //////////////////////////////////////////////////////////
|
||||
// The refcounts on plKeyData/plKeyImps are zero-based. When you first create
|
||||
// a new plKeyImp (which should ONLY ever be done inside the resMgr), it gets
|
||||
// a refcount of zero. Assigning a new plKey to represent it bumps it to 1,
|
||||
// and when that key goes away, the refcount drops to zero and the ResManager
|
||||
// is notified of the fact and may delete the keyImp.
|
||||
// So the only refcounts on keys outside of the resMgr should be one or more;
|
||||
// only inside the resMgr should there EVER exist keys with a refcount of 0.
|
||||
//
|
||||
// Using our own refCount system instead of hsRefCnt allows us to make it all
|
||||
// protected, so that only plKey can actually ref/unref, which is as it should
|
||||
// be.
|
||||
|
||||
// Only one class should ever touch this...
|
||||
friend class plKey;
|
||||
|
||||
// Refcount--the number of plKeys that have pointers to us.
|
||||
UInt16 fRefCount;
|
||||
};
|
||||
|
||||
#endif // plKey_h_inc
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,161 +1,161 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plKeyImp_inc
|
||||
#define plKeyImp_inc
|
||||
|
||||
#include "plKey.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "plUoid.h"
|
||||
#include "hsBitVector.h"
|
||||
#include "plRefFlags.h"
|
||||
|
||||
//------------------------------------
|
||||
// plKey is a handle to a keyedObject
|
||||
//------------------------------------
|
||||
class plKeyImp : public plKeyData
|
||||
{
|
||||
public:
|
||||
plKeyImp();
|
||||
plKeyImp(plUoid, UInt32 pos,UInt32 len);
|
||||
virtual ~plKeyImp();
|
||||
|
||||
virtual const plUoid& GetUoid() const { return fUoid; }
|
||||
virtual const char* GetName() const;
|
||||
|
||||
virtual hsKeyedObject* GetObjectPtr();
|
||||
virtual hsKeyedObject* ObjectIsLoaded() const;
|
||||
virtual hsKeyedObject* VerifyLoaded();
|
||||
|
||||
// called before writing to disk so that static keys can have faster lookups (int compare instead of string compare)
|
||||
void SetObjectID(UInt32 id) {fUoid.SetObjectID(id);}
|
||||
|
||||
//----------------------
|
||||
// I/O
|
||||
// ResMgr performs read, so it can search for an existing instance....
|
||||
//----------------------
|
||||
void Read(hsStream* s);
|
||||
void Write(hsStream* s);
|
||||
void WriteObject(hsStream* s);
|
||||
// For when you need to skip over a key in a stream
|
||||
static void SkipRead(hsStream* s);
|
||||
|
||||
UInt32 GetStartPos() const { return fStartPos; } // for ResMgr to read the Objects
|
||||
UInt32 GetDataLen() const { return fDataLen; } // for ResMgr to read the Objects
|
||||
|
||||
//----------------------
|
||||
// Allow a keyed object to behave as if it has an active ref when in fact the object
|
||||
// should only be active ref'ed by a non-keyed parent. Essentially just bumps/decs
|
||||
// the active ref count to facilitate normal object creation/destruction
|
||||
//----------------------
|
||||
virtual hsKeyedObject* RefObject(plRefFlags::Type flags = plRefFlags::kActiveRef);
|
||||
virtual void UnRefObject(plRefFlags::Type flags = plRefFlags::kActiveRef);
|
||||
|
||||
//----------------------
|
||||
// Release has two behaviors, depending on whether the ref is active or passive:
|
||||
// Active - Release decs the ActiveRefCnt. When it gets to zero, the object will be deleted.
|
||||
// Passive - Unregisters my interest in when the object is created or destroyed.
|
||||
//----------------------
|
||||
virtual void Release(plKey targetKey);
|
||||
|
||||
void UnRegister();
|
||||
void SetUoid(const plUoid& uoid);
|
||||
void SetupNotify(plRefMsg* msg, plRefFlags::Type flags);
|
||||
|
||||
// hsKeyedObject use only!
|
||||
hsKeyedObject* SetObjectPtr(hsKeyedObject* p);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ResManager/Registry use only!
|
||||
//
|
||||
|
||||
//----------------------
|
||||
// Clone access
|
||||
//----------------------
|
||||
void AddClone(plKeyImp* c);
|
||||
void RemoveClone(plKeyImp* c) const;
|
||||
plKey GetClone(UInt32 playerID, UInt32 cloneID) const;
|
||||
void CopyForClone(const plKeyImp* p, UInt32 playerID, UInt32 cloneID); // Copy the contents of p for cloning process
|
||||
|
||||
UInt32 GetNumClones();
|
||||
plKey GetCloneByIdx(UInt32 idx);
|
||||
plKey GetCloneOwner() { return fCloneOwner; }
|
||||
|
||||
void NotifyCreated();
|
||||
void ISetupNotify(plRefMsg* msg, plRefFlags::Type flags); // Setup notifcations for reference, don't send anything.
|
||||
|
||||
void AddRef(plKeyImp* key) const;
|
||||
UInt16 GetNumRefs() const { return fRefs.GetCount(); }
|
||||
plKeyImp* GetRef(int i) const { return fRefs[i]; }
|
||||
void RemoveRef(plKeyImp *key) const;
|
||||
|
||||
virtual UInt16 GetActiveRefs() const { return fNumActiveRefs; }
|
||||
virtual UInt16 GetNumNotifyCreated() const { return fNotifyCreated.GetCount(); }
|
||||
virtual plRefMsg* GetNotifyCreated(int i) const { return fNotifyCreated[i]; }
|
||||
virtual const hsBitVector& GetActiveBits() const { return fActiveRefs; }
|
||||
|
||||
protected:
|
||||
void AddNotifyCreated(plRefMsg* msg, plRefFlags::Type flags);
|
||||
void ClearNotifyCreated();
|
||||
UInt16 GetNumNotifyCreated() { return fNotifyCreated.GetCount(); }
|
||||
plRefMsg* GetNotifyCreated(int i) { return fNotifyCreated[i]; }
|
||||
void RemoveNotifyCreated(int i);
|
||||
|
||||
UInt16 IncActiveRefs() { return ++fNumActiveRefs; }
|
||||
UInt16 DecActiveRefs() { return fNumActiveRefs ? --fNumActiveRefs : 0; }
|
||||
|
||||
hsBool IsActiveRef(int i) const { return fActiveRefs.IsBitSet(i) != 0; }
|
||||
void SetActiveRef(int i, hsBool on=true) { fActiveRefs.SetBit(i, on); }
|
||||
hsBool IsNotified(int i) const { return fNotified.IsBitSet(i) != 0; }
|
||||
void SetNotified(int i, hsBool on=true) { fNotified.SetBit(i, on); }
|
||||
|
||||
void SatisfyPending(plRefMsg* msg) const;
|
||||
void SatisfyPending() const;
|
||||
|
||||
void INotifySelf(hsKeyedObject* ko);
|
||||
void INotifyDestroyed();
|
||||
void IClearRefs();
|
||||
|
||||
void IRelease(plKeyImp* keyImp);
|
||||
|
||||
hsKeyedObject* fObjectPtr;
|
||||
|
||||
// These fields are the ones actually saved to disk
|
||||
plUoid fUoid;
|
||||
UInt32 fStartPos; // where I live in the Datafile
|
||||
UInt32 fDataLen; // Length in the Datafile
|
||||
|
||||
// Following used by hsResMgr to notify on defered load or when a passive ref is destroyed.
|
||||
UInt16 fNumActiveRefs; // num active refs on me
|
||||
hsBitVector fActiveRefs; // Which of notify created are active refs
|
||||
hsBitVector fNotified; // which of notifycreated i've already notified.
|
||||
hsTArray<plRefMsg*> fNotifyCreated; // people to notify when I'm created or destroyed
|
||||
mutable hsTArray<plKeyImp*> fRefs; // refs I've made (to be released when I'm unregistered).
|
||||
mutable Int16 fPendingRefs; // Outstanding requests I have out.
|
||||
mutable hsTArray<plKeyImp*> fClones; // clones of me
|
||||
mutable plKey fCloneOwner; // pointer for clones back to the owning key
|
||||
};
|
||||
|
||||
#endif // hsRegistry_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plKeyImp_inc
|
||||
#define plKeyImp_inc
|
||||
|
||||
#include "plKey.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "plUoid.h"
|
||||
#include "hsBitVector.h"
|
||||
#include "plRefFlags.h"
|
||||
|
||||
//------------------------------------
|
||||
// plKey is a handle to a keyedObject
|
||||
//------------------------------------
|
||||
class plKeyImp : public plKeyData
|
||||
{
|
||||
public:
|
||||
plKeyImp();
|
||||
plKeyImp(plUoid, UInt32 pos,UInt32 len);
|
||||
virtual ~plKeyImp();
|
||||
|
||||
virtual const plUoid& GetUoid() const { return fUoid; }
|
||||
virtual const char* GetName() const;
|
||||
|
||||
virtual hsKeyedObject* GetObjectPtr();
|
||||
virtual hsKeyedObject* ObjectIsLoaded() const;
|
||||
virtual hsKeyedObject* VerifyLoaded();
|
||||
|
||||
// called before writing to disk so that static keys can have faster lookups (int compare instead of string compare)
|
||||
void SetObjectID(UInt32 id) {fUoid.SetObjectID(id);}
|
||||
|
||||
//----------------------
|
||||
// I/O
|
||||
// ResMgr performs read, so it can search for an existing instance....
|
||||
//----------------------
|
||||
void Read(hsStream* s);
|
||||
void Write(hsStream* s);
|
||||
void WriteObject(hsStream* s);
|
||||
// For when you need to skip over a key in a stream
|
||||
static void SkipRead(hsStream* s);
|
||||
|
||||
UInt32 GetStartPos() const { return fStartPos; } // for ResMgr to read the Objects
|
||||
UInt32 GetDataLen() const { return fDataLen; } // for ResMgr to read the Objects
|
||||
|
||||
//----------------------
|
||||
// Allow a keyed object to behave as if it has an active ref when in fact the object
|
||||
// should only be active ref'ed by a non-keyed parent. Essentially just bumps/decs
|
||||
// the active ref count to facilitate normal object creation/destruction
|
||||
//----------------------
|
||||
virtual hsKeyedObject* RefObject(plRefFlags::Type flags = plRefFlags::kActiveRef);
|
||||
virtual void UnRefObject(plRefFlags::Type flags = plRefFlags::kActiveRef);
|
||||
|
||||
//----------------------
|
||||
// Release has two behaviors, depending on whether the ref is active or passive:
|
||||
// Active - Release decs the ActiveRefCnt. When it gets to zero, the object will be deleted.
|
||||
// Passive - Unregisters my interest in when the object is created or destroyed.
|
||||
//----------------------
|
||||
virtual void Release(plKey targetKey);
|
||||
|
||||
void UnRegister();
|
||||
void SetUoid(const plUoid& uoid);
|
||||
void SetupNotify(plRefMsg* msg, plRefFlags::Type flags);
|
||||
|
||||
// hsKeyedObject use only!
|
||||
hsKeyedObject* SetObjectPtr(hsKeyedObject* p);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// ResManager/Registry use only!
|
||||
//
|
||||
|
||||
//----------------------
|
||||
// Clone access
|
||||
//----------------------
|
||||
void AddClone(plKeyImp* c);
|
||||
void RemoveClone(plKeyImp* c) const;
|
||||
plKey GetClone(UInt32 playerID, UInt32 cloneID) const;
|
||||
void CopyForClone(const plKeyImp* p, UInt32 playerID, UInt32 cloneID); // Copy the contents of p for cloning process
|
||||
|
||||
UInt32 GetNumClones();
|
||||
plKey GetCloneByIdx(UInt32 idx);
|
||||
plKey GetCloneOwner() { return fCloneOwner; }
|
||||
|
||||
void NotifyCreated();
|
||||
void ISetupNotify(plRefMsg* msg, plRefFlags::Type flags); // Setup notifcations for reference, don't send anything.
|
||||
|
||||
void AddRef(plKeyImp* key) const;
|
||||
UInt16 GetNumRefs() const { return fRefs.GetCount(); }
|
||||
plKeyImp* GetRef(int i) const { return fRefs[i]; }
|
||||
void RemoveRef(plKeyImp *key) const;
|
||||
|
||||
virtual UInt16 GetActiveRefs() const { return fNumActiveRefs; }
|
||||
virtual UInt16 GetNumNotifyCreated() const { return fNotifyCreated.GetCount(); }
|
||||
virtual plRefMsg* GetNotifyCreated(int i) const { return fNotifyCreated[i]; }
|
||||
virtual const hsBitVector& GetActiveBits() const { return fActiveRefs; }
|
||||
|
||||
protected:
|
||||
void AddNotifyCreated(plRefMsg* msg, plRefFlags::Type flags);
|
||||
void ClearNotifyCreated();
|
||||
UInt16 GetNumNotifyCreated() { return fNotifyCreated.GetCount(); }
|
||||
plRefMsg* GetNotifyCreated(int i) { return fNotifyCreated[i]; }
|
||||
void RemoveNotifyCreated(int i);
|
||||
|
||||
UInt16 IncActiveRefs() { return ++fNumActiveRefs; }
|
||||
UInt16 DecActiveRefs() { return fNumActiveRefs ? --fNumActiveRefs : 0; }
|
||||
|
||||
hsBool IsActiveRef(int i) const { return fActiveRefs.IsBitSet(i) != 0; }
|
||||
void SetActiveRef(int i, hsBool on=true) { fActiveRefs.SetBit(i, on); }
|
||||
hsBool IsNotified(int i) const { return fNotified.IsBitSet(i) != 0; }
|
||||
void SetNotified(int i, hsBool on=true) { fNotified.SetBit(i, on); }
|
||||
|
||||
void SatisfyPending(plRefMsg* msg) const;
|
||||
void SatisfyPending() const;
|
||||
|
||||
void INotifySelf(hsKeyedObject* ko);
|
||||
void INotifyDestroyed();
|
||||
void IClearRefs();
|
||||
|
||||
void IRelease(plKeyImp* keyImp);
|
||||
|
||||
hsKeyedObject* fObjectPtr;
|
||||
|
||||
// These fields are the ones actually saved to disk
|
||||
plUoid fUoid;
|
||||
UInt32 fStartPos; // where I live in the Datafile
|
||||
UInt32 fDataLen; // Length in the Datafile
|
||||
|
||||
// Following used by hsResMgr to notify on defered load or when a passive ref is destroyed.
|
||||
UInt16 fNumActiveRefs; // num active refs on me
|
||||
hsBitVector fActiveRefs; // Which of notify created are active refs
|
||||
hsBitVector fNotified; // which of notifycreated i've already notified.
|
||||
hsTArray<plRefMsg*> fNotifyCreated; // people to notify when I'm created or destroyed
|
||||
mutable hsTArray<plKeyImp*> fRefs; // refs I've made (to be released when I'm unregistered).
|
||||
mutable Int16 fPendingRefs; // Outstanding requests I have out.
|
||||
mutable hsTArray<plKeyImp*> fClones; // clones of me
|
||||
mutable plKey fCloneOwner; // pointer for clones back to the owning key
|
||||
};
|
||||
|
||||
#endif // hsRegistry_inc
|
||||
|
@ -1,209 +1,209 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plMsgForwarder.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "hsTypes.h"
|
||||
#include "pnMessage/plMessage.h"
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnNetCommon/plSynchedObject.h"
|
||||
|
||||
#include "pnMessage/plSelfDestructMsg.h"
|
||||
#include "pnMessage/plMessageWithCallbacks.h"
|
||||
|
||||
|
||||
class plForwardCallback
|
||||
{
|
||||
public:
|
||||
hsTArray<plKey> fOrigReceivers;
|
||||
int fNumCallbacks;
|
||||
hsBool fNetPropogate;
|
||||
};
|
||||
|
||||
plMsgForwarder::plMsgForwarder()
|
||||
{
|
||||
}
|
||||
|
||||
plMsgForwarder::~plMsgForwarder()
|
||||
{
|
||||
CallbackMap::iterator i = fCallbacks.begin();
|
||||
|
||||
for (; i != fCallbacks.end(); i++)
|
||||
delete (*i).second;
|
||||
}
|
||||
|
||||
void plMsgForwarder::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
hsKeyedObject::Read(s, mgr);
|
||||
|
||||
int numKeys = s->ReadSwap32();
|
||||
fForwardKeys.Reset();
|
||||
fForwardKeys.Expand(numKeys);
|
||||
fForwardKeys.SetCount(numKeys);
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
{
|
||||
plKey key = mgr->ReadKey(s);
|
||||
fForwardKeys[i] = key;
|
||||
}
|
||||
}
|
||||
|
||||
void plMsgForwarder::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
hsKeyedObject::Write(s, mgr);
|
||||
|
||||
int numKeys = fForwardKeys.Count();
|
||||
s->WriteSwap32(numKeys);
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
mgr->WriteKey(s, fForwardKeys[i]);
|
||||
}
|
||||
|
||||
hsBool plMsgForwarder::MsgReceive(plMessage* msg)
|
||||
{
|
||||
// Self destruct messages are for us only
|
||||
plSelfDestructMsg *selfMsg = plSelfDestructMsg::ConvertNoRef(msg);
|
||||
if (selfMsg)
|
||||
return hsKeyedObject::MsgReceive(msg);
|
||||
|
||||
// If this is a callback message, it needs to be handled differently
|
||||
if (IForwardCallbackMsg(msg))
|
||||
return true;
|
||||
|
||||
// All other messages are forwarded
|
||||
IForwardMsg(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool plMsgForwarder::IForwardCallbackMsg(plMessage *msg)
|
||||
{
|
||||
// Only process as a callback message if it is one, AND it has callbacks
|
||||
plMessageWithCallbacks *callbackMsg = plMessageWithCallbacks::ConvertNoRef(msg);
|
||||
if (callbackMsg && callbackMsg->GetNumCallbacks() > 0)
|
||||
{
|
||||
for (int i = 0; i < callbackMsg->GetNumCallbacks(); i++)
|
||||
{
|
||||
plEventCallbackMsg *event = callbackMsg->GetEventCallback(i);
|
||||
hsAssert(event, "Message forwarder only supports event callback messages");
|
||||
if (event)
|
||||
{
|
||||
plForwardCallback *fc = TRACKED_NEW plForwardCallback;
|
||||
fc->fNumCallbacks = fForwardKeys.Count();
|
||||
|
||||
// Turn off net propagate the callbacks to us will all be local. Only the
|
||||
// callback we send will go over the net
|
||||
fc->fNetPropogate = (event->HasBCastFlag(plMessage::kNetPropagate) != 0);
|
||||
event->SetBCastFlag(plMessage::kNetPropagate, false);
|
||||
|
||||
for (int j = 0; j < event->GetNumReceivers(); j++)
|
||||
fc->fOrigReceivers.Append((plKey)event->GetReceiver(j));
|
||||
|
||||
event->ClearReceivers();
|
||||
event->AddReceiver(GetKey());
|
||||
|
||||
fCallbacks[event] = fc;
|
||||
|
||||
#if 0
|
||||
hsStatusMessageF("Adding CBMsg, eventSender=%s, eventRemoteMsg=%d\n",
|
||||
event->GetSender() ? event->GetSender()->GetName() : "nil", fc->fNetPropogate);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
hsStatusMessageF("Fwding CBMsg, sender=%s, remoteMsg=%d",
|
||||
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
|
||||
#endif
|
||||
IForwardMsg(callbackMsg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Callback from one of our forward keys. Don't send the final callback to the original
|
||||
// requester until all forward keys have reported in.
|
||||
plEventCallbackMsg *eventMsg = plEventCallbackMsg::ConvertNoRef(msg);
|
||||
if (eventMsg)
|
||||
{
|
||||
CallbackMap::const_iterator it = fCallbacks.find(eventMsg);
|
||||
if (it != fCallbacks.end())
|
||||
{
|
||||
plForwardCallback *fc = it->second;
|
||||
if (--fc->fNumCallbacks == 0)
|
||||
{
|
||||
hsStatusMessageF("plEventCallbackMsg received, erasing, sender=%s, remoteMsg=%d\n",
|
||||
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
|
||||
|
||||
fCallbacks.erase(eventMsg);
|
||||
|
||||
plUoid uoid = GetKey()->GetUoid();
|
||||
hsBool locallyOwned = (plNetClientApp::GetInstance()->IsLocallyOwned(uoid) != plSynchedObject::kNo);
|
||||
|
||||
// If the callback was originally net propagated, and we own this forwarder, net propagate the callback
|
||||
if (fc->fNetPropogate && locallyOwned)
|
||||
eventMsg->SetBCastFlag(plMessage::kNetPropagate);
|
||||
|
||||
eventMsg->ClearReceivers();
|
||||
eventMsg->AddReceivers(fc->fOrigReceivers);
|
||||
eventMsg->SetSender(GetKey());
|
||||
hsRefCnt_SafeRef(eventMsg);
|
||||
eventMsg->Send();
|
||||
|
||||
delete fc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hsStatusMessageF("! Unknown plEventCallbackMsg received, sender=%s, remoteMsg=%d\n",
|
||||
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
|
||||
hsAssert(0, "Unknown plEventCallbackMsg received");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void plMsgForwarder::IForwardMsg(plMessage *msg)
|
||||
{
|
||||
// Back up the message's original receivers
|
||||
hsTArray<plKey> oldKeys;
|
||||
for (int i = 0; i < msg->GetNumReceivers(); i++)
|
||||
oldKeys.Append((plKey)msg->GetReceiver(i));
|
||||
|
||||
// Set to our receivers and send
|
||||
hsRefCnt_SafeRef(msg);
|
||||
msg->ClearReceivers();
|
||||
msg->AddReceivers(fForwardKeys);
|
||||
msg->Send();
|
||||
|
||||
// Reset back to the original receivers. This is so we don't screw up objects
|
||||
// who reuse their messages
|
||||
msg->ClearReceivers();
|
||||
msg->AddReceivers(oldKeys);
|
||||
}
|
||||
|
||||
void plMsgForwarder::AddForwardKey(plKey key)
|
||||
{
|
||||
if (fForwardKeys.Find(key) == fForwardKeys.kMissingIndex)
|
||||
fForwardKeys.Append(key);
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plMsgForwarder.h"
|
||||
#include "hsResMgr.h"
|
||||
#include "hsTypes.h"
|
||||
#include "pnMessage/plMessage.h"
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnNetCommon/plSynchedObject.h"
|
||||
|
||||
#include "pnMessage/plSelfDestructMsg.h"
|
||||
#include "pnMessage/plMessageWithCallbacks.h"
|
||||
|
||||
|
||||
class plForwardCallback
|
||||
{
|
||||
public:
|
||||
hsTArray<plKey> fOrigReceivers;
|
||||
int fNumCallbacks;
|
||||
hsBool fNetPropogate;
|
||||
};
|
||||
|
||||
plMsgForwarder::plMsgForwarder()
|
||||
{
|
||||
}
|
||||
|
||||
plMsgForwarder::~plMsgForwarder()
|
||||
{
|
||||
CallbackMap::iterator i = fCallbacks.begin();
|
||||
|
||||
for (; i != fCallbacks.end(); i++)
|
||||
delete (*i).second;
|
||||
}
|
||||
|
||||
void plMsgForwarder::Read(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
hsKeyedObject::Read(s, mgr);
|
||||
|
||||
int numKeys = s->ReadSwap32();
|
||||
fForwardKeys.Reset();
|
||||
fForwardKeys.Expand(numKeys);
|
||||
fForwardKeys.SetCount(numKeys);
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
{
|
||||
plKey key = mgr->ReadKey(s);
|
||||
fForwardKeys[i] = key;
|
||||
}
|
||||
}
|
||||
|
||||
void plMsgForwarder::Write(hsStream* s, hsResMgr* mgr)
|
||||
{
|
||||
hsKeyedObject::Write(s, mgr);
|
||||
|
||||
int numKeys = fForwardKeys.Count();
|
||||
s->WriteSwap32(numKeys);
|
||||
for (int i = 0; i < numKeys; i++)
|
||||
mgr->WriteKey(s, fForwardKeys[i]);
|
||||
}
|
||||
|
||||
hsBool plMsgForwarder::MsgReceive(plMessage* msg)
|
||||
{
|
||||
// Self destruct messages are for us only
|
||||
plSelfDestructMsg *selfMsg = plSelfDestructMsg::ConvertNoRef(msg);
|
||||
if (selfMsg)
|
||||
return hsKeyedObject::MsgReceive(msg);
|
||||
|
||||
// If this is a callback message, it needs to be handled differently
|
||||
if (IForwardCallbackMsg(msg))
|
||||
return true;
|
||||
|
||||
// All other messages are forwarded
|
||||
IForwardMsg(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool plMsgForwarder::IForwardCallbackMsg(plMessage *msg)
|
||||
{
|
||||
// Only process as a callback message if it is one, AND it has callbacks
|
||||
plMessageWithCallbacks *callbackMsg = plMessageWithCallbacks::ConvertNoRef(msg);
|
||||
if (callbackMsg && callbackMsg->GetNumCallbacks() > 0)
|
||||
{
|
||||
for (int i = 0; i < callbackMsg->GetNumCallbacks(); i++)
|
||||
{
|
||||
plEventCallbackMsg *event = callbackMsg->GetEventCallback(i);
|
||||
hsAssert(event, "Message forwarder only supports event callback messages");
|
||||
if (event)
|
||||
{
|
||||
plForwardCallback *fc = TRACKED_NEW plForwardCallback;
|
||||
fc->fNumCallbacks = fForwardKeys.Count();
|
||||
|
||||
// Turn off net propagate the callbacks to us will all be local. Only the
|
||||
// callback we send will go over the net
|
||||
fc->fNetPropogate = (event->HasBCastFlag(plMessage::kNetPropagate) != 0);
|
||||
event->SetBCastFlag(plMessage::kNetPropagate, false);
|
||||
|
||||
for (int j = 0; j < event->GetNumReceivers(); j++)
|
||||
fc->fOrigReceivers.Append((plKey)event->GetReceiver(j));
|
||||
|
||||
event->ClearReceivers();
|
||||
event->AddReceiver(GetKey());
|
||||
|
||||
fCallbacks[event] = fc;
|
||||
|
||||
#if 0
|
||||
hsStatusMessageF("Adding CBMsg, eventSender=%s, eventRemoteMsg=%d\n",
|
||||
event->GetSender() ? event->GetSender()->GetName() : "nil", fc->fNetPropogate);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
hsStatusMessageF("Fwding CBMsg, sender=%s, remoteMsg=%d",
|
||||
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
|
||||
#endif
|
||||
IForwardMsg(callbackMsg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Callback from one of our forward keys. Don't send the final callback to the original
|
||||
// requester until all forward keys have reported in.
|
||||
plEventCallbackMsg *eventMsg = plEventCallbackMsg::ConvertNoRef(msg);
|
||||
if (eventMsg)
|
||||
{
|
||||
CallbackMap::const_iterator it = fCallbacks.find(eventMsg);
|
||||
if (it != fCallbacks.end())
|
||||
{
|
||||
plForwardCallback *fc = it->second;
|
||||
if (--fc->fNumCallbacks == 0)
|
||||
{
|
||||
hsStatusMessageF("plEventCallbackMsg received, erasing, sender=%s, remoteMsg=%d\n",
|
||||
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
|
||||
|
||||
fCallbacks.erase(eventMsg);
|
||||
|
||||
plUoid uoid = GetKey()->GetUoid();
|
||||
hsBool locallyOwned = (plNetClientApp::GetInstance()->IsLocallyOwned(uoid) != plSynchedObject::kNo);
|
||||
|
||||
// If the callback was originally net propagated, and we own this forwarder, net propagate the callback
|
||||
if (fc->fNetPropogate && locallyOwned)
|
||||
eventMsg->SetBCastFlag(plMessage::kNetPropagate);
|
||||
|
||||
eventMsg->ClearReceivers();
|
||||
eventMsg->AddReceivers(fc->fOrigReceivers);
|
||||
eventMsg->SetSender(GetKey());
|
||||
hsRefCnt_SafeRef(eventMsg);
|
||||
eventMsg->Send();
|
||||
|
||||
delete fc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
hsStatusMessageF("! Unknown plEventCallbackMsg received, sender=%s, remoteMsg=%d\n",
|
||||
msg->GetSender() ? msg->GetSender()->GetName() : "nil", msg->HasBCastFlag(plMessage::kNetNonLocal));
|
||||
hsAssert(0, "Unknown plEventCallbackMsg received");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void plMsgForwarder::IForwardMsg(plMessage *msg)
|
||||
{
|
||||
// Back up the message's original receivers
|
||||
hsTArray<plKey> oldKeys;
|
||||
for (int i = 0; i < msg->GetNumReceivers(); i++)
|
||||
oldKeys.Append((plKey)msg->GetReceiver(i));
|
||||
|
||||
// Set to our receivers and send
|
||||
hsRefCnt_SafeRef(msg);
|
||||
msg->ClearReceivers();
|
||||
msg->AddReceivers(fForwardKeys);
|
||||
msg->Send();
|
||||
|
||||
// Reset back to the original receivers. This is so we don't screw up objects
|
||||
// who reuse their messages
|
||||
msg->ClearReceivers();
|
||||
msg->AddReceivers(oldKeys);
|
||||
}
|
||||
|
||||
void plMsgForwarder::AddForwardKey(plKey key)
|
||||
{
|
||||
if (fForwardKeys.Find(key) == fForwardKeys.kMissingIndex)
|
||||
fForwardKeys.Append(key);
|
||||
}
|
||||
|
@ -1,63 +1,63 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plMsgForwarder_h_inc
|
||||
#define plMsgForwarder_h_inc
|
||||
|
||||
#include "hsKeyedObject.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
|
||||
class plMessageWithCallbacks;
|
||||
class plForwardCallback;
|
||||
|
||||
class plMsgForwarder : public hsKeyedObject
|
||||
{
|
||||
protected:
|
||||
hsTArray<plKey> fForwardKeys;
|
||||
|
||||
typedef std::map<plMessage*, plForwardCallback*> CallbackMap;
|
||||
CallbackMap fCallbacks;
|
||||
|
||||
void IForwardMsg(plMessage *msg);
|
||||
hsBool IForwardCallbackMsg(plMessage *msg);
|
||||
|
||||
public:
|
||||
plMsgForwarder();
|
||||
~plMsgForwarder();
|
||||
|
||||
CLASSNAME_REGISTER(plMsgForwarder);
|
||||
GETINTERFACE_ANY(plMsgForwarder, hsKeyedObject);
|
||||
|
||||
void Read(hsStream* s, hsResMgr* mgr);
|
||||
void Write(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
void AddForwardKey(plKey key);
|
||||
};
|
||||
|
||||
#endif // plMsgForwarder_h_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plMsgForwarder_h_inc
|
||||
#define plMsgForwarder_h_inc
|
||||
|
||||
#include "hsKeyedObject.h"
|
||||
#include "hsTemplates.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
|
||||
class plMessageWithCallbacks;
|
||||
class plForwardCallback;
|
||||
|
||||
class plMsgForwarder : public hsKeyedObject
|
||||
{
|
||||
protected:
|
||||
hsTArray<plKey> fForwardKeys;
|
||||
|
||||
typedef std::map<plMessage*, plForwardCallback*> CallbackMap;
|
||||
CallbackMap fCallbacks;
|
||||
|
||||
void IForwardMsg(plMessage *msg);
|
||||
hsBool IForwardCallbackMsg(plMessage *msg);
|
||||
|
||||
public:
|
||||
plMsgForwarder();
|
||||
~plMsgForwarder();
|
||||
|
||||
CLASSNAME_REGISTER(plMsgForwarder);
|
||||
GETINTERFACE_ANY(plMsgForwarder, hsKeyedObject);
|
||||
|
||||
void Read(hsStream* s, hsResMgr* mgr);
|
||||
void Write(hsStream* s, hsResMgr* mgr);
|
||||
|
||||
hsBool MsgReceive(plMessage* msg);
|
||||
|
||||
void AddForwardKey(plKey key);
|
||||
};
|
||||
|
||||
#endif // plMsgForwarder_h_inc
|
||||
|
@ -1,45 +1,45 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plReceiver_inc
|
||||
#define plReceiver_inc
|
||||
|
||||
#include "pnFactory/plCreatable.h"
|
||||
|
||||
class plMessage;
|
||||
|
||||
class plReceiver : public plCreatable
|
||||
{
|
||||
public:
|
||||
plReceiver() {}
|
||||
|
||||
CLASSNAME_REGISTER( plReceiver );
|
||||
GETINTERFACE_ANY( plReceiver, plCreatable );
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg) { return false; }
|
||||
};
|
||||
|
||||
#endif // plReceiver_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef plReceiver_inc
|
||||
#define plReceiver_inc
|
||||
|
||||
#include "pnFactory/plCreatable.h"
|
||||
|
||||
class plMessage;
|
||||
|
||||
class plReceiver : public plCreatable
|
||||
{
|
||||
public:
|
||||
plReceiver() {}
|
||||
|
||||
CLASSNAME_REGISTER( plReceiver );
|
||||
GETINTERFACE_ANY( plReceiver, plCreatable );
|
||||
|
||||
virtual hsBool MsgReceive(plMessage* msg) { return false; }
|
||||
};
|
||||
|
||||
#endif // plReceiver_inc
|
||||
|
@ -1,59 +1,59 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
|
||||
#include "plTempKey.h"
|
||||
#include "hsKeyedObject.h"
|
||||
#include "plUoid.h"
|
||||
|
||||
|
||||
|
||||
plTempKey::plTempKey(hsKeyedObject *pO,const char *nm)
|
||||
{
|
||||
hsAssert(pO,"plTempKey, Need Object!");
|
||||
pO->SetKey(this);
|
||||
plLocation loc( plLocation::kGlobalFixedLoc );
|
||||
fUoid = plUoid( loc, pO->ClassIndex(), "temp");
|
||||
fUoid.SetTemporary( true ); // Must set temp flag!
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
fIDName = fUoid.GetObjectName();
|
||||
fClassType = plFactory::GetNameOfClass( fUoid.GetClassType() );
|
||||
#endif
|
||||
}
|
||||
|
||||
plTempKey::~plTempKey()
|
||||
{
|
||||
UnRegister();
|
||||
delete fObjectPtr;
|
||||
fObjectPtr = nil;
|
||||
}
|
||||
|
||||
void plTempKey::VerifyLoaded() const
|
||||
{
|
||||
// Can't do a whole lot in this case for tempKeys :)
|
||||
}
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "HeadSpin.h"
|
||||
|
||||
#include "plTempKey.h"
|
||||
#include "hsKeyedObject.h"
|
||||
#include "plUoid.h"
|
||||
|
||||
|
||||
|
||||
plTempKey::plTempKey(hsKeyedObject *pO,const char *nm)
|
||||
{
|
||||
hsAssert(pO,"plTempKey, Need Object!");
|
||||
pO->SetKey(this);
|
||||
plLocation loc( plLocation::kGlobalFixedLoc );
|
||||
fUoid = plUoid( loc, pO->ClassIndex(), "temp");
|
||||
fUoid.SetTemporary( true ); // Must set temp flag!
|
||||
|
||||
#ifdef HS_DEBUGGING
|
||||
fIDName = fUoid.GetObjectName();
|
||||
fClassType = plFactory::GetNameOfClass( fUoid.GetClassType() );
|
||||
#endif
|
||||
}
|
||||
|
||||
plTempKey::~plTempKey()
|
||||
{
|
||||
UnRegister();
|
||||
delete fObjectPtr;
|
||||
fObjectPtr = nil;
|
||||
}
|
||||
|
||||
void plTempKey::VerifyLoaded() const
|
||||
{
|
||||
// Can't do a whole lot in this case for tempKeys :)
|
||||
}
|
||||
|
||||
|
@ -1,51 +1,51 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plTempKey_inc
|
||||
#define plTempKey_inc
|
||||
|
||||
#include "plKeyImp.h"
|
||||
|
||||
class hsKeyedObject;
|
||||
|
||||
//------------------------------------
|
||||
// plTempKey is a handle to a keyedObject, which is not registered
|
||||
// The key may be handed to others to send messages.
|
||||
// when done with a plTempKey call ReleaseTemporary (from Base class plKey)
|
||||
//------------------------------------
|
||||
|
||||
class plTempKey : public plKeyImp
|
||||
{
|
||||
|
||||
public:
|
||||
plTempKey(hsKeyedObject *pO,const char *nm=nil);
|
||||
plTempKey(plUoid u) { fUoid=u; } // used server side
|
||||
~plTempKey(); // USE plKey->ReleaseTemporary to delete this...
|
||||
|
||||
virtual void VerifyLoaded() const;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#ifndef plTempKey_inc
|
||||
#define plTempKey_inc
|
||||
|
||||
#include "plKeyImp.h"
|
||||
|
||||
class hsKeyedObject;
|
||||
|
||||
//------------------------------------
|
||||
// plTempKey is a handle to a keyedObject, which is not registered
|
||||
// The key may be handed to others to send messages.
|
||||
// when done with a plTempKey call ReleaseTemporary (from Base class plKey)
|
||||
//------------------------------------
|
||||
|
||||
class plTempKey : public plKeyImp
|
||||
{
|
||||
|
||||
public:
|
||||
plTempKey(hsKeyedObject *pO,const char *nm=nil);
|
||||
plTempKey(plUoid u) { fUoid=u; } // used server side
|
||||
~plTempKey(); // USE plKey->ReleaseTemporary to delete this...
|
||||
|
||||
virtual void VerifyLoaded() const;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,268 +1,268 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plUoid.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
//// plLocation //////////////////////////////////////////////////////////////
|
||||
|
||||
const plLocation plLocation::kGlobalFixedLoc(plLocation::kGlobalFixedLocIdx);
|
||||
const plLocation plLocation::kLocalStartLoc(plLocation::kLocalLocStartIdx);
|
||||
const plLocation plLocation::kLocalEndLoc(plLocation::kLocalLocEndIdx);
|
||||
const plLocation plLocation::kNormalStartLoc(plLocation::kNormalLocStartIdx);
|
||||
const plLocation plLocation::kGlobalServerLoc(plLocation::kGlobalServerLocIdx, plLocation::kReserved);
|
||||
const plLocation plLocation::kInvalidLoc;
|
||||
|
||||
plLocation::plLocation(const plLocation& toCopyFrom)
|
||||
{
|
||||
*this = toCopyFrom;
|
||||
}
|
||||
|
||||
void plLocation::Read(hsStream* s)
|
||||
{
|
||||
s->LogReadSwap(&fSequenceNumber, "Location Sequence Number");
|
||||
s->LogReadSwap(&fFlags, "Location Flags");
|
||||
}
|
||||
|
||||
void plLocation::Write(hsStream* s) const
|
||||
{
|
||||
s->WriteSwap(fSequenceNumber);
|
||||
s->WriteSwap(fFlags);
|
||||
}
|
||||
|
||||
plLocation& plLocation::operator=(const plLocation& rhs)
|
||||
{
|
||||
fSequenceNumber = rhs.fSequenceNumber;
|
||||
fFlags = rhs.fFlags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
hsBool plLocation::operator==(const plLocation& u) const
|
||||
{
|
||||
// Ignore the itinerant flag when comparing, because
|
||||
return (fSequenceNumber == u.fSequenceNumber) && ((fFlags & ~kItinerant) == (u.fFlags & ~kItinerant));
|
||||
}
|
||||
|
||||
void plLocation::Set(UInt32 seqNum)
|
||||
{
|
||||
fSequenceNumber = seqNum;
|
||||
}
|
||||
|
||||
void plLocation::Invalidate()
|
||||
{
|
||||
fSequenceNumber = kInvalidLocIdx;
|
||||
fFlags = 0; // Set to kInvalid?
|
||||
}
|
||||
|
||||
hsBool plLocation::IsValid() const
|
||||
{
|
||||
return (fSequenceNumber == kInvalidLocIdx) ? false : true;
|
||||
}
|
||||
|
||||
hsBool plLocation::IsReserved() const
|
||||
{
|
||||
return hsCheckBits(fFlags, kReserved);
|
||||
}
|
||||
|
||||
hsBool plLocation::IsItinerant() const
|
||||
{
|
||||
return hsCheckBits(fFlags, kItinerant);
|
||||
}
|
||||
|
||||
hsBool plLocation::IsVirtual() const
|
||||
{
|
||||
// This returns whether the location is "virtual", i.e. isn't a true room per se. Like fixed keys
|
||||
if (fSequenceNumber == kGlobalFixedLocIdx)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* plLocation::StringIze(char* str) const // Format to displayable string
|
||||
{
|
||||
sprintf(str, "S0x%xF0x%x", fSequenceNumber, int(fFlags));
|
||||
return str;
|
||||
}
|
||||
|
||||
plLocation plLocation::MakeReserved(UInt32 number)
|
||||
{
|
||||
return plLocation(kReservedLocAvailableStart + number, kReserved);
|
||||
}
|
||||
|
||||
plLocation plLocation::MakeNormal(UInt32 number)
|
||||
{
|
||||
return plLocation(kNormalLocStartIdx + number);
|
||||
}
|
||||
|
||||
//// plUoid //////////////////////////////////////////////////////////////////
|
||||
|
||||
plUoid::plUoid(const plLocation& location, UInt16 classType, const char* objectName, const plLoadMask& m)
|
||||
{
|
||||
fObjectName = nil;
|
||||
Invalidate();
|
||||
|
||||
fLocation = location;
|
||||
fClassType = classType;
|
||||
fObjectName = hsStrcpy(objectName);
|
||||
fLoadMask = m;
|
||||
fClonePlayerID = 0;
|
||||
}
|
||||
|
||||
plUoid::plUoid(const plUoid& src)
|
||||
{
|
||||
fObjectName = nil;
|
||||
Invalidate();
|
||||
*this = src;
|
||||
}
|
||||
|
||||
plUoid::~plUoid()
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void plUoid::Read(hsStream* s)
|
||||
{
|
||||
hsAssert(fObjectName == nil, "Reading over an old uoid? You're just asking for trouble, aren't you?");
|
||||
|
||||
// first read contents flags
|
||||
UInt8 contents = s->ReadByte();
|
||||
|
||||
fLocation.Read(s);
|
||||
|
||||
// conditional loadmask read
|
||||
if (contents & kHasLoadMask)
|
||||
fLoadMask.Read(s);
|
||||
else
|
||||
fLoadMask.SetAlways();
|
||||
|
||||
s->LogReadSwap(&fClassType, "ClassType");
|
||||
s->LogReadSwap(&fObjectID, "ObjectID");
|
||||
s->LogSubStreamPushDesc("ObjectName");
|
||||
fObjectName = s->LogReadSafeString();
|
||||
|
||||
// conditional cloneIDs read
|
||||
if (contents & kHasCloneIDs)
|
||||
{
|
||||
s->LogReadSwap( &fCloneID ,"CloneID");
|
||||
UInt16 dummy;
|
||||
s->LogReadSwap(&dummy, "dummy"); // To avoid breaking format
|
||||
s->LogReadSwap( &fClonePlayerID ,"ClonePlayerID");
|
||||
}
|
||||
else
|
||||
{
|
||||
fCloneID = 0;
|
||||
fClonePlayerID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void plUoid::Write(hsStream* s) const
|
||||
{
|
||||
// first write contents byte
|
||||
UInt8 contents = IsClone() ? kHasCloneIDs : 0;
|
||||
if (fLoadMask.IsUsed())
|
||||
contents |= kHasLoadMask;
|
||||
s->WriteByte(contents);
|
||||
|
||||
fLocation.Write(s);
|
||||
|
||||
// conditional loadmask write
|
||||
if (contents & kHasLoadMask)
|
||||
fLoadMask.Write(s);
|
||||
|
||||
s->WriteSwap( fClassType );
|
||||
s->WriteSwap( fObjectID );
|
||||
s->WriteSafeString( fObjectName );
|
||||
|
||||
// conditional cloneIDs write
|
||||
if (contents & kHasCloneIDs)
|
||||
{
|
||||
s->WriteSwap(fCloneID);
|
||||
UInt16 dummy = 0;
|
||||
s->WriteSwap(dummy); // to avoid breaking format
|
||||
s->WriteSwap(fClonePlayerID);
|
||||
}
|
||||
}
|
||||
|
||||
void plUoid::Invalidate()
|
||||
{
|
||||
fObjectID = 0;
|
||||
fCloneID = 0;
|
||||
fClonePlayerID = 0;
|
||||
fClassType = 0;
|
||||
if (fObjectName)
|
||||
delete [] fObjectName;
|
||||
fObjectName = nil;
|
||||
fLocation.Invalidate();
|
||||
fLoadMask = plLoadMask::kAlways;
|
||||
|
||||
}
|
||||
|
||||
hsBool plUoid::IsValid() const
|
||||
{
|
||||
if (!fLocation.IsValid() || fObjectName == nil)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool plUoid::operator==(const plUoid& u) const
|
||||
{
|
||||
return fLocation == u.fLocation
|
||||
&& fLoadMask == u.fLoadMask
|
||||
&& fClassType == u.fClassType
|
||||
&& hsStrEQ(fObjectName, u.fObjectName)
|
||||
&& fObjectID == u.fObjectID
|
||||
&& fCloneID == u.fCloneID
|
||||
&& fClonePlayerID == u.fClonePlayerID;
|
||||
}
|
||||
|
||||
plUoid& plUoid::operator=(const plUoid& rhs)
|
||||
{
|
||||
fObjectID = rhs.fObjectID;
|
||||
fCloneID = rhs.fCloneID;
|
||||
fClonePlayerID = rhs.fClonePlayerID;
|
||||
fClassType = rhs.fClassType;
|
||||
if (fObjectName)
|
||||
delete [] fObjectName;
|
||||
fObjectName = hsStrcpy(rhs.fObjectName);
|
||||
fLocation = rhs.fLocation;
|
||||
fLoadMask = rhs.fLoadMask;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* plUoid::StringIze(char* str) const // Format to displayable string
|
||||
{
|
||||
sprintf(str, "(0x%x:0x%x:%s:C:[%lu,%lu])",
|
||||
fLocation.GetSequenceNumber(),
|
||||
int(fLocation.GetFlags()),
|
||||
fObjectName,
|
||||
GetClonePlayerID(),
|
||||
GetCloneID());
|
||||
return str;
|
||||
}
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
#include "plUoid.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsUtils.h"
|
||||
|
||||
//// plLocation //////////////////////////////////////////////////////////////
|
||||
|
||||
const plLocation plLocation::kGlobalFixedLoc(plLocation::kGlobalFixedLocIdx);
|
||||
const plLocation plLocation::kLocalStartLoc(plLocation::kLocalLocStartIdx);
|
||||
const plLocation plLocation::kLocalEndLoc(plLocation::kLocalLocEndIdx);
|
||||
const plLocation plLocation::kNormalStartLoc(plLocation::kNormalLocStartIdx);
|
||||
const plLocation plLocation::kGlobalServerLoc(plLocation::kGlobalServerLocIdx, plLocation::kReserved);
|
||||
const plLocation plLocation::kInvalidLoc;
|
||||
|
||||
plLocation::plLocation(const plLocation& toCopyFrom)
|
||||
{
|
||||
*this = toCopyFrom;
|
||||
}
|
||||
|
||||
void plLocation::Read(hsStream* s)
|
||||
{
|
||||
s->LogReadSwap(&fSequenceNumber, "Location Sequence Number");
|
||||
s->LogReadSwap(&fFlags, "Location Flags");
|
||||
}
|
||||
|
||||
void plLocation::Write(hsStream* s) const
|
||||
{
|
||||
s->WriteSwap(fSequenceNumber);
|
||||
s->WriteSwap(fFlags);
|
||||
}
|
||||
|
||||
plLocation& plLocation::operator=(const plLocation& rhs)
|
||||
{
|
||||
fSequenceNumber = rhs.fSequenceNumber;
|
||||
fFlags = rhs.fFlags;
|
||||
return *this;
|
||||
}
|
||||
|
||||
hsBool plLocation::operator==(const plLocation& u) const
|
||||
{
|
||||
// Ignore the itinerant flag when comparing, because
|
||||
return (fSequenceNumber == u.fSequenceNumber) && ((fFlags & ~kItinerant) == (u.fFlags & ~kItinerant));
|
||||
}
|
||||
|
||||
void plLocation::Set(UInt32 seqNum)
|
||||
{
|
||||
fSequenceNumber = seqNum;
|
||||
}
|
||||
|
||||
void plLocation::Invalidate()
|
||||
{
|
||||
fSequenceNumber = kInvalidLocIdx;
|
||||
fFlags = 0; // Set to kInvalid?
|
||||
}
|
||||
|
||||
hsBool plLocation::IsValid() const
|
||||
{
|
||||
return (fSequenceNumber == kInvalidLocIdx) ? false : true;
|
||||
}
|
||||
|
||||
hsBool plLocation::IsReserved() const
|
||||
{
|
||||
return hsCheckBits(fFlags, kReserved);
|
||||
}
|
||||
|
||||
hsBool plLocation::IsItinerant() const
|
||||
{
|
||||
return hsCheckBits(fFlags, kItinerant);
|
||||
}
|
||||
|
||||
hsBool plLocation::IsVirtual() const
|
||||
{
|
||||
// This returns whether the location is "virtual", i.e. isn't a true room per se. Like fixed keys
|
||||
if (fSequenceNumber == kGlobalFixedLocIdx)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* plLocation::StringIze(char* str) const // Format to displayable string
|
||||
{
|
||||
sprintf(str, "S0x%xF0x%x", fSequenceNumber, int(fFlags));
|
||||
return str;
|
||||
}
|
||||
|
||||
plLocation plLocation::MakeReserved(UInt32 number)
|
||||
{
|
||||
return plLocation(kReservedLocAvailableStart + number, kReserved);
|
||||
}
|
||||
|
||||
plLocation plLocation::MakeNormal(UInt32 number)
|
||||
{
|
||||
return plLocation(kNormalLocStartIdx + number);
|
||||
}
|
||||
|
||||
//// plUoid //////////////////////////////////////////////////////////////////
|
||||
|
||||
plUoid::plUoid(const plLocation& location, UInt16 classType, const char* objectName, const plLoadMask& m)
|
||||
{
|
||||
fObjectName = nil;
|
||||
Invalidate();
|
||||
|
||||
fLocation = location;
|
||||
fClassType = classType;
|
||||
fObjectName = hsStrcpy(objectName);
|
||||
fLoadMask = m;
|
||||
fClonePlayerID = 0;
|
||||
}
|
||||
|
||||
plUoid::plUoid(const plUoid& src)
|
||||
{
|
||||
fObjectName = nil;
|
||||
Invalidate();
|
||||
*this = src;
|
||||
}
|
||||
|
||||
plUoid::~plUoid()
|
||||
{
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
void plUoid::Read(hsStream* s)
|
||||
{
|
||||
hsAssert(fObjectName == nil, "Reading over an old uoid? You're just asking for trouble, aren't you?");
|
||||
|
||||
// first read contents flags
|
||||
UInt8 contents = s->ReadByte();
|
||||
|
||||
fLocation.Read(s);
|
||||
|
||||
// conditional loadmask read
|
||||
if (contents & kHasLoadMask)
|
||||
fLoadMask.Read(s);
|
||||
else
|
||||
fLoadMask.SetAlways();
|
||||
|
||||
s->LogReadSwap(&fClassType, "ClassType");
|
||||
s->LogReadSwap(&fObjectID, "ObjectID");
|
||||
s->LogSubStreamPushDesc("ObjectName");
|
||||
fObjectName = s->LogReadSafeString();
|
||||
|
||||
// conditional cloneIDs read
|
||||
if (contents & kHasCloneIDs)
|
||||
{
|
||||
s->LogReadSwap( &fCloneID ,"CloneID");
|
||||
UInt16 dummy;
|
||||
s->LogReadSwap(&dummy, "dummy"); // To avoid breaking format
|
||||
s->LogReadSwap( &fClonePlayerID ,"ClonePlayerID");
|
||||
}
|
||||
else
|
||||
{
|
||||
fCloneID = 0;
|
||||
fClonePlayerID = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void plUoid::Write(hsStream* s) const
|
||||
{
|
||||
// first write contents byte
|
||||
UInt8 contents = IsClone() ? kHasCloneIDs : 0;
|
||||
if (fLoadMask.IsUsed())
|
||||
contents |= kHasLoadMask;
|
||||
s->WriteByte(contents);
|
||||
|
||||
fLocation.Write(s);
|
||||
|
||||
// conditional loadmask write
|
||||
if (contents & kHasLoadMask)
|
||||
fLoadMask.Write(s);
|
||||
|
||||
s->WriteSwap( fClassType );
|
||||
s->WriteSwap( fObjectID );
|
||||
s->WriteSafeString( fObjectName );
|
||||
|
||||
// conditional cloneIDs write
|
||||
if (contents & kHasCloneIDs)
|
||||
{
|
||||
s->WriteSwap(fCloneID);
|
||||
UInt16 dummy = 0;
|
||||
s->WriteSwap(dummy); // to avoid breaking format
|
||||
s->WriteSwap(fClonePlayerID);
|
||||
}
|
||||
}
|
||||
|
||||
void plUoid::Invalidate()
|
||||
{
|
||||
fObjectID = 0;
|
||||
fCloneID = 0;
|
||||
fClonePlayerID = 0;
|
||||
fClassType = 0;
|
||||
if (fObjectName)
|
||||
delete [] fObjectName;
|
||||
fObjectName = nil;
|
||||
fLocation.Invalidate();
|
||||
fLoadMask = plLoadMask::kAlways;
|
||||
|
||||
}
|
||||
|
||||
hsBool plUoid::IsValid() const
|
||||
{
|
||||
if (!fLocation.IsValid() || fObjectName == nil)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
hsBool plUoid::operator==(const plUoid& u) const
|
||||
{
|
||||
return fLocation == u.fLocation
|
||||
&& fLoadMask == u.fLoadMask
|
||||
&& fClassType == u.fClassType
|
||||
&& hsStrEQ(fObjectName, u.fObjectName)
|
||||
&& fObjectID == u.fObjectID
|
||||
&& fCloneID == u.fCloneID
|
||||
&& fClonePlayerID == u.fClonePlayerID;
|
||||
}
|
||||
|
||||
plUoid& plUoid::operator=(const plUoid& rhs)
|
||||
{
|
||||
fObjectID = rhs.fObjectID;
|
||||
fCloneID = rhs.fCloneID;
|
||||
fClonePlayerID = rhs.fClonePlayerID;
|
||||
fClassType = rhs.fClassType;
|
||||
if (fObjectName)
|
||||
delete [] fObjectName;
|
||||
fObjectName = hsStrcpy(rhs.fObjectName);
|
||||
fLocation = rhs.fLocation;
|
||||
fLoadMask = rhs.fLoadMask;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* plUoid::StringIze(char* str) const // Format to displayable string
|
||||
{
|
||||
sprintf(str, "(0x%x:0x%x:%s:C:[%lu,%lu])",
|
||||
fLocation.GetSequenceNumber(),
|
||||
int(fLocation.GetFlags()),
|
||||
fObjectName,
|
||||
GetClonePlayerID(),
|
||||
GetCloneID());
|
||||
return str;
|
||||
}
|
||||
|
@ -1,179 +1,179 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// plUoid - A Unique Object IDentifier -- basically, each unique Uoid refers
|
||||
// to one and exactly one object.
|
||||
// To define such, it contains three elements:
|
||||
// - A plLocation, which specifies an (age,chapter,page) combo
|
||||
// (as a sequence number)
|
||||
// - A creatable class type (from plFactory)
|
||||
// - An object name
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef plUoid_h_inc
|
||||
#define plUoid_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plFixedKey.h"
|
||||
#include "plLoadMask.h"
|
||||
|
||||
class hsStream;
|
||||
|
||||
//// plLocation //////////////////////////////////////////////////////////////
|
||||
|
||||
class plLocation
|
||||
{
|
||||
public:
|
||||
enum LocFlags
|
||||
{
|
||||
kLocalOnly = 0x1, // Set if nothing in the room saves state.
|
||||
kVolatile = 0x2, // Set is nothing in the room persists when the server exits.
|
||||
kReserved = 0x4,
|
||||
kBuiltIn = 0x8,
|
||||
kItinerant = 0x10,
|
||||
};
|
||||
|
||||
protected:
|
||||
UInt32 fSequenceNumber;
|
||||
UInt16 fFlags;
|
||||
|
||||
enum
|
||||
{
|
||||
kGlobalFixedLocIdx = 0, // Fixed keys go here, think of as "global,fixed,keys"
|
||||
kSceneViewerLocIdx = 1,
|
||||
|
||||
kLocalLocStartIdx = 3, // These are a range of #s that go to local, testing-only pages.
|
||||
kLocalLocEndIdx = 32, // You can't go over the network with any keys with these locs.
|
||||
|
||||
kNormalLocStartIdx = kLocalLocEndIdx + 1,
|
||||
|
||||
kReservedLocStart = 0xff000000, // Reserved locations are ones that aren't real game locations,
|
||||
kGlobalServerLocIdx = kReservedLocStart, // Global pool room for the server. Only the server gets this one
|
||||
|
||||
kReservedLocAvailableStart = kGlobalServerLocIdx + 1, // This is the start of the *really* available ones
|
||||
kReservedLocEnd = 0xfffffffe, // But instead act as a holding place for data
|
||||
|
||||
kInvalidLocIdx = 0xffffffff
|
||||
};
|
||||
|
||||
plLocation(UInt32 seqNum, UInt16 flags=0) : fFlags(flags) { Set(seqNum); }
|
||||
|
||||
public:
|
||||
plLocation() { Invalidate(); }
|
||||
plLocation(const plLocation& toCopyFrom);
|
||||
~plLocation() {}
|
||||
|
||||
void Invalidate();
|
||||
hsBool IsValid() const;
|
||||
hsBool IsReserved() const;
|
||||
hsBool IsItinerant() const;
|
||||
void Set(UInt32 seqNum);
|
||||
UInt32 GetSequenceNumber() const { return fSequenceNumber; }
|
||||
hsBool IsVirtual() const;
|
||||
|
||||
void SetFlags(UInt16 flags) { fFlags |= flags; }
|
||||
UInt16 GetFlags() const { return fFlags; }
|
||||
|
||||
void Read(hsStream* s);
|
||||
void Write(hsStream* s) const;
|
||||
|
||||
hsBool operator==(const plLocation& loc) const;
|
||||
hsBool operator!=(const plLocation& loc) const { return !(loc == *this); }
|
||||
plLocation& operator=(const plLocation& loc);
|
||||
bool operator<(const plLocation& loc ) const { return fSequenceNumber < loc.fSequenceNumber; }
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* StringIze(char* str) const; // Format to displayable string. Returns the same string for convenience
|
||||
|
||||
static plLocation MakeReserved(UInt32 number);
|
||||
static plLocation MakeNormal(UInt32 number);
|
||||
|
||||
static const plLocation kGlobalFixedLoc;
|
||||
static const plLocation kSceneViewerLoc;
|
||||
static const plLocation kLocalStartLoc;
|
||||
static const plLocation kLocalEndLoc;
|
||||
static const plLocation kNormalStartLoc;
|
||||
static const plLocation kGlobalServerLoc;
|
||||
static const plLocation kInvalidLoc;
|
||||
};
|
||||
|
||||
//// plUoid //////////////////////////////////////////////////////////////////
|
||||
|
||||
class plUoid
|
||||
{
|
||||
public:
|
||||
plUoid() { fObjectName = nil; Invalidate(); }
|
||||
plUoid(const plLocation& location, UInt16 classType, const char* objectName, const plLoadMask& m=plLoadMask::kAlways);
|
||||
plUoid(plFixedKeyId fixedKey);
|
||||
plUoid(const plUoid& src);
|
||||
~plUoid();
|
||||
|
||||
const plLocation& GetLocation() const { return fLocation; }
|
||||
UInt16 GetClassType() const { return fClassType; }
|
||||
const char* GetObjectName() const { return fObjectName; }
|
||||
const plLoadMask& GetLoadMask() const { return fLoadMask; }
|
||||
|
||||
void Read(hsStream* s);
|
||||
void Write(hsStream* s) const;
|
||||
|
||||
void Invalidate();
|
||||
hsBool IsValid() const;
|
||||
|
||||
plUoid& operator=(const plUoid& u);
|
||||
hsBool operator==(const plUoid& u) const;
|
||||
hsBool operator!=(const plUoid& u) const { return !operator==(u); }
|
||||
|
||||
hsBool IsClone() const { return fCloneID != 0; }
|
||||
UInt32 GetClonePlayerID() const { return fClonePlayerID; }
|
||||
UInt32 GetCloneID() const { return fCloneID; }
|
||||
void SetClone(UInt32 playerID, UInt32 cloneID) { hsAssert(cloneID < 0xffff, "Clone id too high"); fCloneID = UInt16(cloneID); fClonePlayerID = playerID; }
|
||||
|
||||
UInt32 GetObjectID() const { return fObjectID; }
|
||||
// Export time only. Only plRegistryKeyList should call this.
|
||||
void SetObjectID(UInt32 id) { fObjectID = id; }
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* StringIze(char* str) const; // Format to displayable string
|
||||
|
||||
protected:
|
||||
enum ContentsFlags // for read/write functions
|
||||
{
|
||||
kHasCloneIDs = 0x1,
|
||||
kHasLoadMask = 0x2,
|
||||
};
|
||||
|
||||
UInt32 fObjectID;
|
||||
UInt32 fClonePlayerID; // The ID of the player who made this clone
|
||||
UInt16 fCloneID; // The ID of this clone (unique per client)
|
||||
UInt16 fClassType;
|
||||
char* fObjectName;
|
||||
plLocation fLocation;
|
||||
plLoadMask fLoadMask;
|
||||
};
|
||||
|
||||
#endif // plUoid_h_inc
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// plUoid - A Unique Object IDentifier -- basically, each unique Uoid refers
|
||||
// to one and exactly one object.
|
||||
// To define such, it contains three elements:
|
||||
// - A plLocation, which specifies an (age,chapter,page) combo
|
||||
// (as a sequence number)
|
||||
// - A creatable class type (from plFactory)
|
||||
// - An object name
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef plUoid_h_inc
|
||||
#define plUoid_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "plFixedKey.h"
|
||||
#include "plLoadMask.h"
|
||||
|
||||
class hsStream;
|
||||
|
||||
//// plLocation //////////////////////////////////////////////////////////////
|
||||
|
||||
class plLocation
|
||||
{
|
||||
public:
|
||||
enum LocFlags
|
||||
{
|
||||
kLocalOnly = 0x1, // Set if nothing in the room saves state.
|
||||
kVolatile = 0x2, // Set is nothing in the room persists when the server exits.
|
||||
kReserved = 0x4,
|
||||
kBuiltIn = 0x8,
|
||||
kItinerant = 0x10,
|
||||
};
|
||||
|
||||
protected:
|
||||
UInt32 fSequenceNumber;
|
||||
UInt16 fFlags;
|
||||
|
||||
enum
|
||||
{
|
||||
kGlobalFixedLocIdx = 0, // Fixed keys go here, think of as "global,fixed,keys"
|
||||
kSceneViewerLocIdx = 1,
|
||||
|
||||
kLocalLocStartIdx = 3, // These are a range of #s that go to local, testing-only pages.
|
||||
kLocalLocEndIdx = 32, // You can't go over the network with any keys with these locs.
|
||||
|
||||
kNormalLocStartIdx = kLocalLocEndIdx + 1,
|
||||
|
||||
kReservedLocStart = 0xff000000, // Reserved locations are ones that aren't real game locations,
|
||||
kGlobalServerLocIdx = kReservedLocStart, // Global pool room for the server. Only the server gets this one
|
||||
|
||||
kReservedLocAvailableStart = kGlobalServerLocIdx + 1, // This is the start of the *really* available ones
|
||||
kReservedLocEnd = 0xfffffffe, // But instead act as a holding place for data
|
||||
|
||||
kInvalidLocIdx = 0xffffffff
|
||||
};
|
||||
|
||||
plLocation(UInt32 seqNum, UInt16 flags=0) : fFlags(flags) { Set(seqNum); }
|
||||
|
||||
public:
|
||||
plLocation() { Invalidate(); }
|
||||
plLocation(const plLocation& toCopyFrom);
|
||||
~plLocation() {}
|
||||
|
||||
void Invalidate();
|
||||
hsBool IsValid() const;
|
||||
hsBool IsReserved() const;
|
||||
hsBool IsItinerant() const;
|
||||
void Set(UInt32 seqNum);
|
||||
UInt32 GetSequenceNumber() const { return fSequenceNumber; }
|
||||
hsBool IsVirtual() const;
|
||||
|
||||
void SetFlags(UInt16 flags) { fFlags |= flags; }
|
||||
UInt16 GetFlags() const { return fFlags; }
|
||||
|
||||
void Read(hsStream* s);
|
||||
void Write(hsStream* s) const;
|
||||
|
||||
hsBool operator==(const plLocation& loc) const;
|
||||
hsBool operator!=(const plLocation& loc) const { return !(loc == *this); }
|
||||
plLocation& operator=(const plLocation& loc);
|
||||
bool operator<(const plLocation& loc ) const { return fSequenceNumber < loc.fSequenceNumber; }
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* StringIze(char* str) const; // Format to displayable string. Returns the same string for convenience
|
||||
|
||||
static plLocation MakeReserved(UInt32 number);
|
||||
static plLocation MakeNormal(UInt32 number);
|
||||
|
||||
static const plLocation kGlobalFixedLoc;
|
||||
static const plLocation kSceneViewerLoc;
|
||||
static const plLocation kLocalStartLoc;
|
||||
static const plLocation kLocalEndLoc;
|
||||
static const plLocation kNormalStartLoc;
|
||||
static const plLocation kGlobalServerLoc;
|
||||
static const plLocation kInvalidLoc;
|
||||
};
|
||||
|
||||
//// plUoid //////////////////////////////////////////////////////////////////
|
||||
|
||||
class plUoid
|
||||
{
|
||||
public:
|
||||
plUoid() { fObjectName = nil; Invalidate(); }
|
||||
plUoid(const plLocation& location, UInt16 classType, const char* objectName, const plLoadMask& m=plLoadMask::kAlways);
|
||||
plUoid(plFixedKeyId fixedKey);
|
||||
plUoid(const plUoid& src);
|
||||
~plUoid();
|
||||
|
||||
const plLocation& GetLocation() const { return fLocation; }
|
||||
UInt16 GetClassType() const { return fClassType; }
|
||||
const char* GetObjectName() const { return fObjectName; }
|
||||
const plLoadMask& GetLoadMask() const { return fLoadMask; }
|
||||
|
||||
void Read(hsStream* s);
|
||||
void Write(hsStream* s) const;
|
||||
|
||||
void Invalidate();
|
||||
hsBool IsValid() const;
|
||||
|
||||
plUoid& operator=(const plUoid& u);
|
||||
hsBool operator==(const plUoid& u) const;
|
||||
hsBool operator!=(const plUoid& u) const { return !operator==(u); }
|
||||
|
||||
hsBool IsClone() const { return fCloneID != 0; }
|
||||
UInt32 GetClonePlayerID() const { return fClonePlayerID; }
|
||||
UInt32 GetCloneID() const { return fCloneID; }
|
||||
void SetClone(UInt32 playerID, UInt32 cloneID) { hsAssert(cloneID < 0xffff, "Clone id too high"); fCloneID = UInt16(cloneID); fClonePlayerID = playerID; }
|
||||
|
||||
UInt32 GetObjectID() const { return fObjectID; }
|
||||
// Export time only. Only plRegistryKeyList should call this.
|
||||
void SetObjectID(UInt32 id) { fObjectID = id; }
|
||||
|
||||
// THIS SHOULD BE FOR DEBUGGING ONLY <hint hint>
|
||||
char* StringIze(char* str) const; // Format to displayable string
|
||||
|
||||
protected:
|
||||
enum ContentsFlags // for read/write functions
|
||||
{
|
||||
kHasCloneIDs = 0x1,
|
||||
kHasLoadMask = 0x2,
|
||||
};
|
||||
|
||||
UInt32 fObjectID;
|
||||
UInt32 fClonePlayerID; // The ID of the player who made this clone
|
||||
UInt16 fCloneID; // The ID of this clone (unique per client)
|
||||
UInt16 fClassType;
|
||||
char* fObjectName;
|
||||
plLocation fLocation;
|
||||
plLoadMask fLoadMask;
|
||||
};
|
||||
|
||||
#endif // plUoid_h_inc
|
||||
|
@ -1,43 +1,43 @@
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef pnKeyedObject_inc
|
||||
#define pnKeyedObject_inc
|
||||
|
||||
#include "pnFactory/plCreator.h"
|
||||
|
||||
#include "hsKeyedObject.h"
|
||||
REGISTER_CREATABLE( hsKeyedObject );
|
||||
|
||||
#include "plReceiver.h"
|
||||
|
||||
REGISTER_NONCREATABLE( plReceiver );
|
||||
|
||||
#include "plMsgForwarder.h"
|
||||
REGISTER_CREATABLE(plMsgForwarder);
|
||||
|
||||
#endif // pnKeyedObject_inc
|
||||
|
||||
/*==LICENSE==*
|
||||
|
||||
CyanWorlds.com Engine - MMOG client, server and tools
|
||||
Copyright (C) 2011 Cyan Worlds, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
or by snail mail at:
|
||||
Cyan Worlds, Inc.
|
||||
14617 N Newport Hwy
|
||||
Mead, WA 99021
|
||||
|
||||
*==LICENSE==*/
|
||||
|
||||
#ifndef pnKeyedObject_inc
|
||||
#define pnKeyedObject_inc
|
||||
|
||||
#include "pnFactory/plCreator.h"
|
||||
|
||||
#include "hsKeyedObject.h"
|
||||
REGISTER_CREATABLE( hsKeyedObject );
|
||||
|
||||
#include "plReceiver.h"
|
||||
|
||||
REGISTER_NONCREATABLE( plReceiver );
|
||||
|
||||
#include "plMsgForwarder.h"
|
||||
REGISTER_CREATABLE(plMsgForwarder);
|
||||
|
||||
#endif // pnKeyedObject_inc
|
||||
|
||||
|
Reference in New Issue
Block a user