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,33 +1,33 @@
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../FeatureLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(plNetCommon_SOURCES
|
||||
plClientGuid.cpp
|
||||
plNetCommon.cpp
|
||||
plNetCommonHelpers.cpp
|
||||
plNetMember.cpp
|
||||
plNetMsgScreener.cpp
|
||||
plNetServerSessionInfo.cpp
|
||||
plSpawnPointInfo.cpp
|
||||
)
|
||||
|
||||
set(plNetCommon_HEADERS
|
||||
plClientGuid.h
|
||||
plNetCommon.h
|
||||
plNetCommonConstants.h
|
||||
plNetCommonCreatable.h
|
||||
plNetCommonHelpers.h
|
||||
plNetMember.h
|
||||
plNetMsgHandler.h
|
||||
plNetMsgScreener.h
|
||||
plNetServerSessionInfo.h
|
||||
plSpawnPointInfo.h
|
||||
)
|
||||
|
||||
add_library(plNetCommon STATIC ${plNetCommon_SOURCES} ${plNetCommon_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plNetCommon_SOURCES})
|
||||
source_group("Header Files" FILES ${plNetCommon_HEADERS})
|
||||
include_directories("../../CoreLib")
|
||||
include_directories("../../FeatureLib")
|
||||
include_directories("../../NucleusLib/inc")
|
||||
include_directories("../../NucleusLib")
|
||||
include_directories("../../PubUtilLib")
|
||||
|
||||
set(plNetCommon_SOURCES
|
||||
plClientGuid.cpp
|
||||
plNetCommon.cpp
|
||||
plNetCommonHelpers.cpp
|
||||
plNetMember.cpp
|
||||
plNetMsgScreener.cpp
|
||||
plNetServerSessionInfo.cpp
|
||||
plSpawnPointInfo.cpp
|
||||
)
|
||||
|
||||
set(plNetCommon_HEADERS
|
||||
plClientGuid.h
|
||||
plNetCommon.h
|
||||
plNetCommonConstants.h
|
||||
plNetCommonCreatable.h
|
||||
plNetCommonHelpers.h
|
||||
plNetMember.h
|
||||
plNetMsgHandler.h
|
||||
plNetMsgScreener.h
|
||||
plNetServerSessionInfo.h
|
||||
plSpawnPointInfo.h
|
||||
)
|
||||
|
||||
add_library(plNetCommon STATIC ${plNetCommon_SOURCES} ${plNetCommon_HEADERS})
|
||||
|
||||
source_group("Source Files" FILES ${plNetCommon_SOURCES})
|
||||
source_group("Header Files" FILES ${plNetCommon_HEADERS})
|
||||
|
@ -1,424 +1,424 @@
|
||||
/*==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 "plClientGuid.h"
|
||||
#include "hsStream.h"
|
||||
#include <sstream>
|
||||
#include "plNetCommon.h"
|
||||
#include "pnMessage/plMessage.h"
|
||||
#include "plSockets/plNet.h"
|
||||
|
||||
plClientGuid::plClientGuid()
|
||||
:fPlayerID(0)
|
||||
,fCCRLevel(0)
|
||||
,fFlags(0)
|
||||
,fProtectedLogin(false)
|
||||
,fBuildType(plNetCommon::BuildType::kUnknown)
|
||||
,fSrcAddr(0)
|
||||
,fSrcPort(0)
|
||||
,fReserved(false)
|
||||
{
|
||||
fAccountUUID.Clear();
|
||||
}
|
||||
|
||||
void plClientGuid::SetAccountUUID(const plUUID * v )
|
||||
{
|
||||
fAccountUUID.CopyFrom( v );
|
||||
if ( !fAccountUUID.IsNull() )
|
||||
fFlags|=kAccountUUID;
|
||||
else
|
||||
fFlags&=~kAccountUUID;
|
||||
}
|
||||
|
||||
void plClientGuid::SetAccountUUID(const plUUID & v )
|
||||
{
|
||||
SetAccountUUID( &v );
|
||||
}
|
||||
|
||||
void plClientGuid::SetBuildType(UInt8 type)
|
||||
{
|
||||
fBuildType=type;
|
||||
fFlags|=kBuildType;
|
||||
}
|
||||
|
||||
void plClientGuid::SetPlayerID(UInt32 id)
|
||||
{
|
||||
fPlayerID=id;
|
||||
if ( fPlayerID )
|
||||
{
|
||||
fFlags|=kPlayerID;
|
||||
fFlags&=~kTempPlayerID;
|
||||
}
|
||||
else
|
||||
fFlags&=~kPlayerID;
|
||||
}
|
||||
|
||||
void plClientGuid::SetTempPlayerID(UInt32 id)
|
||||
{
|
||||
fPlayerID=id;
|
||||
if ( fPlayerID )
|
||||
{
|
||||
fFlags&=~kPlayerID;
|
||||
fFlags|=kTempPlayerID;
|
||||
}
|
||||
else
|
||||
{
|
||||
fFlags&=~kTempPlayerID;
|
||||
}
|
||||
}
|
||||
|
||||
void plClientGuid::SetPlayerName( const char * v )
|
||||
{
|
||||
fPlayerName = v?v:"";
|
||||
if ( fPlayerName.size() )
|
||||
fFlags|=kPlayerName;
|
||||
else
|
||||
fFlags&=~kPlayerName;
|
||||
}
|
||||
|
||||
void plClientGuid::SetCCRLevel(UInt8 v)
|
||||
{
|
||||
fCCRLevel=v;
|
||||
fFlags|=kCCRLevel;
|
||||
}
|
||||
|
||||
void plClientGuid::SetProtectedLogin(bool b)
|
||||
{
|
||||
fProtectedLogin=b;
|
||||
fFlags |= kProtectedLogin;
|
||||
}
|
||||
|
||||
void plClientGuid::SetSrcAddr( UInt32 v )
|
||||
{
|
||||
fSrcAddr = v;
|
||||
if ( fSrcAddr )
|
||||
fFlags|=kSrcAddr;
|
||||
else
|
||||
fFlags&=~kSrcAddr;
|
||||
}
|
||||
|
||||
void plClientGuid::SetSrcAddrFromStr( const char * s )
|
||||
{
|
||||
hsAssert(false, "eric, port me");
|
||||
}
|
||||
|
||||
void plClientGuid::SetSrcPort( UInt16 v )
|
||||
{
|
||||
fSrcPort = v;
|
||||
if ( fSrcPort )
|
||||
fFlags|=kSrcPort;
|
||||
else
|
||||
fFlags&=~kSrcPort;
|
||||
}
|
||||
|
||||
void plClientGuid::SetReserved(bool b)
|
||||
{
|
||||
fReserved=b;
|
||||
fFlags |= kReserved;
|
||||
}
|
||||
|
||||
void plClientGuid::SetClientKey(const std::string& key)
|
||||
{
|
||||
fClientKey = key;
|
||||
if ( fClientKey.size() )
|
||||
fFlags|=kClientKey;
|
||||
else
|
||||
fFlags&=~kClientKey;
|
||||
}
|
||||
|
||||
const char * plClientGuid::GetSrcAddrStr() const
|
||||
{
|
||||
hsAssert(false, "eric, port me");
|
||||
static const char foo[] = "";
|
||||
return foo;
|
||||
}
|
||||
|
||||
std::string plClientGuid::AsStdString() const
|
||||
{
|
||||
#define kComma ","
|
||||
#define kEmpty ""
|
||||
const char * spacer = kEmpty;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "[";
|
||||
|
||||
if (IsFlagSet(kPlayerID))
|
||||
{
|
||||
ss << spacer << "Pid:" << fPlayerID;
|
||||
spacer = kComma;
|
||||
}
|
||||
else if (IsFlagSet(kTempPlayerID))
|
||||
{
|
||||
ss << spacer << "tPd:" << fPlayerID;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kPlayerName))
|
||||
{
|
||||
ss << spacer << "Plr:" << fPlayerName;
|
||||
}
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
{
|
||||
ss << spacer << "CCR:" << (int)fCCRLevel;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
{
|
||||
ss << spacer << "Pro:" << (int)fProtectedLogin;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kBuildType))
|
||||
{
|
||||
ss << spacer << "Bld:" << plNetCommon::BuildType::BuildTypeStr(fBuildType);
|
||||
spacer = kComma;
|
||||
}
|
||||
if ( IsFlagSet(kSrcAddr) )
|
||||
{
|
||||
ss << spacer << "Addr:" << GetSrcAddrStr();
|
||||
spacer = kComma;
|
||||
}
|
||||
if ( IsFlagSet(kSrcPort) )
|
||||
{
|
||||
ss << spacer << "Port:" << (int)fSrcPort;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
{
|
||||
ss << spacer << "plUUID:" << fAccountUUID.AsStdString();
|
||||
spacer = kComma;
|
||||
}
|
||||
if ( IsFlagSet(kReserved))
|
||||
{
|
||||
ss << spacer << "Res:" << (int)fReserved;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kClientKey))
|
||||
{
|
||||
ss << spacer << "ClientKey:" << fClientKey;
|
||||
spacer = kComma;
|
||||
}
|
||||
ss << "]";
|
||||
|
||||
return ss.str().c_str();
|
||||
}
|
||||
|
||||
std::string plClientGuid::AsLogString() const
|
||||
{
|
||||
#define kSemicolon ";"
|
||||
const char* spacer = kSemicolon;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
{
|
||||
ss << "AcctUUID=" << fAccountUUID.AsStdString();
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kPlayerID))
|
||||
{
|
||||
ss << "PlayerID=" << fPlayerID;
|
||||
ss << spacer;
|
||||
}
|
||||
// else if (IsFlagSet(kTempPlayerID))
|
||||
// {
|
||||
// ss << "tempPlayerID:" << fPlayerID;
|
||||
// ss << spacer;
|
||||
// }
|
||||
if ( IsFlagSet(kSrcAddr) )
|
||||
{
|
||||
ss << "SrcAddr=" << GetSrcAddrStr();
|
||||
ss << spacer;
|
||||
}
|
||||
if ( IsFlagSet(kSrcPort) )
|
||||
{
|
||||
ss << "SrcPort=" << (int)fSrcPort;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
{
|
||||
ss << "CCRLevel=" << (int)fCCRLevel;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
{
|
||||
ss << "Protected=" << (int)fProtectedLogin;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kBuildType))
|
||||
{
|
||||
ss << "Build=" << plNetCommon::BuildType::BuildTypeStr(fBuildType);
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kReserved))
|
||||
{
|
||||
ss << "Reserved=" << (int)fReserved;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kClientKey))
|
||||
{
|
||||
ss << "ClientKey=" << fClientKey;
|
||||
ss << spacer;
|
||||
}
|
||||
|
||||
return ss.str().c_str();
|
||||
}
|
||||
|
||||
void plClientGuid::Read(hsStream * s, hsResMgr* mgr)
|
||||
{
|
||||
s->LogSubStreamStart("push me");
|
||||
s->LogReadSwap(&fFlags,"Flags");
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
{
|
||||
s->LogSubStreamPushDesc("AcctUUID");
|
||||
fAccountUUID.Read( s );
|
||||
}
|
||||
if (IsFlagSet(kPlayerID))
|
||||
s->LogReadSwap(&fPlayerID,"PlayerID");
|
||||
else if (IsFlagSet(kTempPlayerID))
|
||||
s->LogReadSwap(&fPlayerID,"TempPlayerID");
|
||||
if (IsFlagSet(kPlayerName))
|
||||
{
|
||||
s->LogSubStreamPushDesc("PlayerName");
|
||||
plMsgStdStringHelper::Peek( fPlayerName, s );
|
||||
}
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
s->LogReadSwap(&fCCRLevel,"CCRLevel");
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
s->LogReadSwap(&fProtectedLogin,"ProtectedLogin");
|
||||
if (IsFlagSet(kBuildType))
|
||||
s->LogReadSwap(&fBuildType,"BuildType");
|
||||
if (IsFlagSet(kSrcAddr))
|
||||
s->LogReadSwap(&fSrcAddr,"SrcAddr");
|
||||
if (IsFlagSet(kSrcPort))
|
||||
s->LogReadSwap(&fSrcPort,"SrcPort");
|
||||
if (IsFlagSet(kReserved))
|
||||
s->LogReadSwap(&fReserved,"Reserved");
|
||||
if (IsFlagSet(kClientKey))
|
||||
{
|
||||
s->LogSubStreamPushDesc("ClientKey");
|
||||
plMsgStdStringHelper::Peek( fClientKey, s );
|
||||
}
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plClientGuid::Write(hsStream * s, hsResMgr* mgr)
|
||||
{
|
||||
s->WriteSwap(fFlags);
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
fAccountUUID.Write( s );
|
||||
if (IsFlagSet(kPlayerID))
|
||||
s->WriteSwap(fPlayerID);
|
||||
else if (IsFlagSet(kTempPlayerID))
|
||||
s->WriteSwap(fPlayerID);
|
||||
if (IsFlagSet(kPlayerName))
|
||||
plMsgStdStringHelper::Poke( fPlayerName, s );
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
s->WriteSwap(fCCRLevel);
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
s->WriteSwap(fProtectedLogin);
|
||||
if (IsFlagSet(kBuildType))
|
||||
s->WriteSwap(fBuildType);
|
||||
if (IsFlagSet(kSrcAddr))
|
||||
s->WriteSwap(fSrcAddr);
|
||||
if (IsFlagSet(kSrcPort))
|
||||
s->WriteSwap(fSrcPort);
|
||||
if (IsFlagSet(kReserved))
|
||||
s->WriteSwap(fReserved);
|
||||
if (IsFlagSet(kClientKey))
|
||||
plMsgStdStringHelper::Poke( fClientKey, s );
|
||||
}
|
||||
|
||||
void plClientGuid::CopyFrom(const plClientGuid * other)
|
||||
{
|
||||
fFlags = other->fFlags;
|
||||
fAccountUUID.CopyFrom( &other->fAccountUUID );
|
||||
fPlayerID = other->fPlayerID;
|
||||
fPlayerName = other->fPlayerName;
|
||||
fCCRLevel = other->fCCRLevel;
|
||||
fProtectedLogin = other->fProtectedLogin;
|
||||
fBuildType = other->fBuildType;
|
||||
fSrcAddr = other->fSrcAddr;
|
||||
fSrcPort = other->fSrcPort;
|
||||
fReserved = other->fReserved;
|
||||
fClientKey = other->fClientKey;
|
||||
}
|
||||
|
||||
void plClientGuid::UpdateFrom(const plClientGuid * other)
|
||||
{
|
||||
if ( !HasAccountUUID() && other->HasAccountUUID() )
|
||||
SetAccountUUID( other->GetAccountUUID() );
|
||||
if ( !HasPlayerID() && other->HasPlayerID() )
|
||||
SetPlayerID( other->GetPlayerID() );
|
||||
if ( !HasPlayerName() && other->HasPlayerName() )
|
||||
SetPlayerName( other->GetPlayerName() );
|
||||
if ( !HasProtectedLogin() && other->HasProtectedLogin() )
|
||||
SetProtectedLogin( other->GetProtectedLogin() );
|
||||
if ( !HasCCRLevel() && other->HasCCRLevel() )
|
||||
SetCCRLevel( other->GetCCRLevel() );
|
||||
if ( !HasBuildType() && other->HasBuildType() )
|
||||
SetBuildType( other->GetBuildType() );
|
||||
if ( !HasSrcAddr() && other->HasSrcAddr() )
|
||||
SetSrcAddr( other->GetSrcAddr() );
|
||||
if ( !HasSrcPort() && other->HasSrcPort() )
|
||||
SetSrcPort( other->GetSrcPort() );
|
||||
if ( !HasReservedBit() && other->HasReservedBit() )
|
||||
SetReserved( other->IsReserved() );
|
||||
if ( !HasClientKey() && other->HasClientKey() )
|
||||
SetClientKey( other->GetClientKey() );
|
||||
}
|
||||
|
||||
void plClientGuid::Clear()
|
||||
{
|
||||
plClientGuid tmp;
|
||||
CopyFrom( &tmp );
|
||||
}
|
||||
|
||||
bool plClientGuid::IsEqualTo(const plClientGuid * other) const
|
||||
{
|
||||
return
|
||||
fFlags == other->fFlags &&
|
||||
fAccountUUID.IsEqualTo( &other->fAccountUUID ) &&
|
||||
fPlayerID == other->fPlayerID &&
|
||||
fPlayerName == other->fPlayerName &&
|
||||
fCCRLevel == other->fCCRLevel &&
|
||||
fProtectedLogin == other->fProtectedLogin &&
|
||||
fBuildType == other->fBuildType &&
|
||||
fReserved == other->fReserved &&
|
||||
fClientKey == other->fClientKey;
|
||||
}
|
||||
|
||||
bool operator==(const plClientGuid & X, const plClientGuid & Y)
|
||||
{
|
||||
return ( X.fAccountUUID.IsEqualTo( &Y.fAccountUUID )&&X.fPlayerID==Y.fPlayerID&&X.fFlags==Y.fFlags);
|
||||
}
|
||||
bool operator!=(const plClientGuid & X, const plClientGuid & Y)
|
||||
{
|
||||
return ( !X.fAccountUUID.IsEqualTo( &Y.fAccountUUID )||X.fPlayerID!=Y.fPlayerID||X.fFlags!=Y.fFlags);
|
||||
}
|
||||
bool operator<(const plClientGuid & X, const plClientGuid & Y)
|
||||
{
|
||||
return ( X.fAccountUUID.CompareTo( &Y.fAccountUUID )<0||X.fPlayerID<Y.fPlayerID);
|
||||
}
|
||||
|
||||
/*==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 "plClientGuid.h"
|
||||
#include "hsStream.h"
|
||||
#include <sstream>
|
||||
#include "plNetCommon.h"
|
||||
#include "pnMessage/plMessage.h"
|
||||
#include "plSockets/plNet.h"
|
||||
|
||||
plClientGuid::plClientGuid()
|
||||
:fPlayerID(0)
|
||||
,fCCRLevel(0)
|
||||
,fFlags(0)
|
||||
,fProtectedLogin(false)
|
||||
,fBuildType(plNetCommon::BuildType::kUnknown)
|
||||
,fSrcAddr(0)
|
||||
,fSrcPort(0)
|
||||
,fReserved(false)
|
||||
{
|
||||
fAccountUUID.Clear();
|
||||
}
|
||||
|
||||
void plClientGuid::SetAccountUUID(const plUUID * v )
|
||||
{
|
||||
fAccountUUID.CopyFrom( v );
|
||||
if ( !fAccountUUID.IsNull() )
|
||||
fFlags|=kAccountUUID;
|
||||
else
|
||||
fFlags&=~kAccountUUID;
|
||||
}
|
||||
|
||||
void plClientGuid::SetAccountUUID(const plUUID & v )
|
||||
{
|
||||
SetAccountUUID( &v );
|
||||
}
|
||||
|
||||
void plClientGuid::SetBuildType(UInt8 type)
|
||||
{
|
||||
fBuildType=type;
|
||||
fFlags|=kBuildType;
|
||||
}
|
||||
|
||||
void plClientGuid::SetPlayerID(UInt32 id)
|
||||
{
|
||||
fPlayerID=id;
|
||||
if ( fPlayerID )
|
||||
{
|
||||
fFlags|=kPlayerID;
|
||||
fFlags&=~kTempPlayerID;
|
||||
}
|
||||
else
|
||||
fFlags&=~kPlayerID;
|
||||
}
|
||||
|
||||
void plClientGuid::SetTempPlayerID(UInt32 id)
|
||||
{
|
||||
fPlayerID=id;
|
||||
if ( fPlayerID )
|
||||
{
|
||||
fFlags&=~kPlayerID;
|
||||
fFlags|=kTempPlayerID;
|
||||
}
|
||||
else
|
||||
{
|
||||
fFlags&=~kTempPlayerID;
|
||||
}
|
||||
}
|
||||
|
||||
void plClientGuid::SetPlayerName( const char * v )
|
||||
{
|
||||
fPlayerName = v?v:"";
|
||||
if ( fPlayerName.size() )
|
||||
fFlags|=kPlayerName;
|
||||
else
|
||||
fFlags&=~kPlayerName;
|
||||
}
|
||||
|
||||
void plClientGuid::SetCCRLevel(UInt8 v)
|
||||
{
|
||||
fCCRLevel=v;
|
||||
fFlags|=kCCRLevel;
|
||||
}
|
||||
|
||||
void plClientGuid::SetProtectedLogin(bool b)
|
||||
{
|
||||
fProtectedLogin=b;
|
||||
fFlags |= kProtectedLogin;
|
||||
}
|
||||
|
||||
void plClientGuid::SetSrcAddr( UInt32 v )
|
||||
{
|
||||
fSrcAddr = v;
|
||||
if ( fSrcAddr )
|
||||
fFlags|=kSrcAddr;
|
||||
else
|
||||
fFlags&=~kSrcAddr;
|
||||
}
|
||||
|
||||
void plClientGuid::SetSrcAddrFromStr( const char * s )
|
||||
{
|
||||
hsAssert(false, "eric, port me");
|
||||
}
|
||||
|
||||
void plClientGuid::SetSrcPort( UInt16 v )
|
||||
{
|
||||
fSrcPort = v;
|
||||
if ( fSrcPort )
|
||||
fFlags|=kSrcPort;
|
||||
else
|
||||
fFlags&=~kSrcPort;
|
||||
}
|
||||
|
||||
void plClientGuid::SetReserved(bool b)
|
||||
{
|
||||
fReserved=b;
|
||||
fFlags |= kReserved;
|
||||
}
|
||||
|
||||
void plClientGuid::SetClientKey(const std::string& key)
|
||||
{
|
||||
fClientKey = key;
|
||||
if ( fClientKey.size() )
|
||||
fFlags|=kClientKey;
|
||||
else
|
||||
fFlags&=~kClientKey;
|
||||
}
|
||||
|
||||
const char * plClientGuid::GetSrcAddrStr() const
|
||||
{
|
||||
hsAssert(false, "eric, port me");
|
||||
static const char foo[] = "";
|
||||
return foo;
|
||||
}
|
||||
|
||||
std::string plClientGuid::AsStdString() const
|
||||
{
|
||||
#define kComma ","
|
||||
#define kEmpty ""
|
||||
const char * spacer = kEmpty;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
ss << "[";
|
||||
|
||||
if (IsFlagSet(kPlayerID))
|
||||
{
|
||||
ss << spacer << "Pid:" << fPlayerID;
|
||||
spacer = kComma;
|
||||
}
|
||||
else if (IsFlagSet(kTempPlayerID))
|
||||
{
|
||||
ss << spacer << "tPd:" << fPlayerID;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kPlayerName))
|
||||
{
|
||||
ss << spacer << "Plr:" << fPlayerName;
|
||||
}
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
{
|
||||
ss << spacer << "CCR:" << (int)fCCRLevel;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
{
|
||||
ss << spacer << "Pro:" << (int)fProtectedLogin;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kBuildType))
|
||||
{
|
||||
ss << spacer << "Bld:" << plNetCommon::BuildType::BuildTypeStr(fBuildType);
|
||||
spacer = kComma;
|
||||
}
|
||||
if ( IsFlagSet(kSrcAddr) )
|
||||
{
|
||||
ss << spacer << "Addr:" << GetSrcAddrStr();
|
||||
spacer = kComma;
|
||||
}
|
||||
if ( IsFlagSet(kSrcPort) )
|
||||
{
|
||||
ss << spacer << "Port:" << (int)fSrcPort;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
{
|
||||
ss << spacer << "plUUID:" << fAccountUUID.AsStdString();
|
||||
spacer = kComma;
|
||||
}
|
||||
if ( IsFlagSet(kReserved))
|
||||
{
|
||||
ss << spacer << "Res:" << (int)fReserved;
|
||||
spacer = kComma;
|
||||
}
|
||||
if (IsFlagSet(kClientKey))
|
||||
{
|
||||
ss << spacer << "ClientKey:" << fClientKey;
|
||||
spacer = kComma;
|
||||
}
|
||||
ss << "]";
|
||||
|
||||
return ss.str().c_str();
|
||||
}
|
||||
|
||||
std::string plClientGuid::AsLogString() const
|
||||
{
|
||||
#define kSemicolon ";"
|
||||
const char* spacer = kSemicolon;
|
||||
|
||||
std::stringstream ss;
|
||||
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
{
|
||||
ss << "AcctUUID=" << fAccountUUID.AsStdString();
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kPlayerID))
|
||||
{
|
||||
ss << "PlayerID=" << fPlayerID;
|
||||
ss << spacer;
|
||||
}
|
||||
// else if (IsFlagSet(kTempPlayerID))
|
||||
// {
|
||||
// ss << "tempPlayerID:" << fPlayerID;
|
||||
// ss << spacer;
|
||||
// }
|
||||
if ( IsFlagSet(kSrcAddr) )
|
||||
{
|
||||
ss << "SrcAddr=" << GetSrcAddrStr();
|
||||
ss << spacer;
|
||||
}
|
||||
if ( IsFlagSet(kSrcPort) )
|
||||
{
|
||||
ss << "SrcPort=" << (int)fSrcPort;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
{
|
||||
ss << "CCRLevel=" << (int)fCCRLevel;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
{
|
||||
ss << "Protected=" << (int)fProtectedLogin;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kBuildType))
|
||||
{
|
||||
ss << "Build=" << plNetCommon::BuildType::BuildTypeStr(fBuildType);
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kReserved))
|
||||
{
|
||||
ss << "Reserved=" << (int)fReserved;
|
||||
ss << spacer;
|
||||
}
|
||||
if (IsFlagSet(kClientKey))
|
||||
{
|
||||
ss << "ClientKey=" << fClientKey;
|
||||
ss << spacer;
|
||||
}
|
||||
|
||||
return ss.str().c_str();
|
||||
}
|
||||
|
||||
void plClientGuid::Read(hsStream * s, hsResMgr* mgr)
|
||||
{
|
||||
s->LogSubStreamStart("push me");
|
||||
s->LogReadSwap(&fFlags,"Flags");
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
{
|
||||
s->LogSubStreamPushDesc("AcctUUID");
|
||||
fAccountUUID.Read( s );
|
||||
}
|
||||
if (IsFlagSet(kPlayerID))
|
||||
s->LogReadSwap(&fPlayerID,"PlayerID");
|
||||
else if (IsFlagSet(kTempPlayerID))
|
||||
s->LogReadSwap(&fPlayerID,"TempPlayerID");
|
||||
if (IsFlagSet(kPlayerName))
|
||||
{
|
||||
s->LogSubStreamPushDesc("PlayerName");
|
||||
plMsgStdStringHelper::Peek( fPlayerName, s );
|
||||
}
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
s->LogReadSwap(&fCCRLevel,"CCRLevel");
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
s->LogReadSwap(&fProtectedLogin,"ProtectedLogin");
|
||||
if (IsFlagSet(kBuildType))
|
||||
s->LogReadSwap(&fBuildType,"BuildType");
|
||||
if (IsFlagSet(kSrcAddr))
|
||||
s->LogReadSwap(&fSrcAddr,"SrcAddr");
|
||||
if (IsFlagSet(kSrcPort))
|
||||
s->LogReadSwap(&fSrcPort,"SrcPort");
|
||||
if (IsFlagSet(kReserved))
|
||||
s->LogReadSwap(&fReserved,"Reserved");
|
||||
if (IsFlagSet(kClientKey))
|
||||
{
|
||||
s->LogSubStreamPushDesc("ClientKey");
|
||||
plMsgStdStringHelper::Peek( fClientKey, s );
|
||||
}
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plClientGuid::Write(hsStream * s, hsResMgr* mgr)
|
||||
{
|
||||
s->WriteSwap(fFlags);
|
||||
if (IsFlagSet(kAccountUUID))
|
||||
fAccountUUID.Write( s );
|
||||
if (IsFlagSet(kPlayerID))
|
||||
s->WriteSwap(fPlayerID);
|
||||
else if (IsFlagSet(kTempPlayerID))
|
||||
s->WriteSwap(fPlayerID);
|
||||
if (IsFlagSet(kPlayerName))
|
||||
plMsgStdStringHelper::Poke( fPlayerName, s );
|
||||
if (IsFlagSet(kCCRLevel))
|
||||
s->WriteSwap(fCCRLevel);
|
||||
if (IsFlagSet(kProtectedLogin))
|
||||
s->WriteSwap(fProtectedLogin);
|
||||
if (IsFlagSet(kBuildType))
|
||||
s->WriteSwap(fBuildType);
|
||||
if (IsFlagSet(kSrcAddr))
|
||||
s->WriteSwap(fSrcAddr);
|
||||
if (IsFlagSet(kSrcPort))
|
||||
s->WriteSwap(fSrcPort);
|
||||
if (IsFlagSet(kReserved))
|
||||
s->WriteSwap(fReserved);
|
||||
if (IsFlagSet(kClientKey))
|
||||
plMsgStdStringHelper::Poke( fClientKey, s );
|
||||
}
|
||||
|
||||
void plClientGuid::CopyFrom(const plClientGuid * other)
|
||||
{
|
||||
fFlags = other->fFlags;
|
||||
fAccountUUID.CopyFrom( &other->fAccountUUID );
|
||||
fPlayerID = other->fPlayerID;
|
||||
fPlayerName = other->fPlayerName;
|
||||
fCCRLevel = other->fCCRLevel;
|
||||
fProtectedLogin = other->fProtectedLogin;
|
||||
fBuildType = other->fBuildType;
|
||||
fSrcAddr = other->fSrcAddr;
|
||||
fSrcPort = other->fSrcPort;
|
||||
fReserved = other->fReserved;
|
||||
fClientKey = other->fClientKey;
|
||||
}
|
||||
|
||||
void plClientGuid::UpdateFrom(const plClientGuid * other)
|
||||
{
|
||||
if ( !HasAccountUUID() && other->HasAccountUUID() )
|
||||
SetAccountUUID( other->GetAccountUUID() );
|
||||
if ( !HasPlayerID() && other->HasPlayerID() )
|
||||
SetPlayerID( other->GetPlayerID() );
|
||||
if ( !HasPlayerName() && other->HasPlayerName() )
|
||||
SetPlayerName( other->GetPlayerName() );
|
||||
if ( !HasProtectedLogin() && other->HasProtectedLogin() )
|
||||
SetProtectedLogin( other->GetProtectedLogin() );
|
||||
if ( !HasCCRLevel() && other->HasCCRLevel() )
|
||||
SetCCRLevel( other->GetCCRLevel() );
|
||||
if ( !HasBuildType() && other->HasBuildType() )
|
||||
SetBuildType( other->GetBuildType() );
|
||||
if ( !HasSrcAddr() && other->HasSrcAddr() )
|
||||
SetSrcAddr( other->GetSrcAddr() );
|
||||
if ( !HasSrcPort() && other->HasSrcPort() )
|
||||
SetSrcPort( other->GetSrcPort() );
|
||||
if ( !HasReservedBit() && other->HasReservedBit() )
|
||||
SetReserved( other->IsReserved() );
|
||||
if ( !HasClientKey() && other->HasClientKey() )
|
||||
SetClientKey( other->GetClientKey() );
|
||||
}
|
||||
|
||||
void plClientGuid::Clear()
|
||||
{
|
||||
plClientGuid tmp;
|
||||
CopyFrom( &tmp );
|
||||
}
|
||||
|
||||
bool plClientGuid::IsEqualTo(const plClientGuid * other) const
|
||||
{
|
||||
return
|
||||
fFlags == other->fFlags &&
|
||||
fAccountUUID.IsEqualTo( &other->fAccountUUID ) &&
|
||||
fPlayerID == other->fPlayerID &&
|
||||
fPlayerName == other->fPlayerName &&
|
||||
fCCRLevel == other->fCCRLevel &&
|
||||
fProtectedLogin == other->fProtectedLogin &&
|
||||
fBuildType == other->fBuildType &&
|
||||
fReserved == other->fReserved &&
|
||||
fClientKey == other->fClientKey;
|
||||
}
|
||||
|
||||
bool operator==(const plClientGuid & X, const plClientGuid & Y)
|
||||
{
|
||||
return ( X.fAccountUUID.IsEqualTo( &Y.fAccountUUID )&&X.fPlayerID==Y.fPlayerID&&X.fFlags==Y.fFlags);
|
||||
}
|
||||
bool operator!=(const plClientGuid & X, const plClientGuid & Y)
|
||||
{
|
||||
return ( !X.fAccountUUID.IsEqualTo( &Y.fAccountUUID )||X.fPlayerID!=Y.fPlayerID||X.fFlags!=Y.fFlags);
|
||||
}
|
||||
bool operator<(const plClientGuid & X, const plClientGuid & Y)
|
||||
{
|
||||
return ( X.fAccountUUID.CompareTo( &Y.fAccountUUID )<0||X.fPlayerID<Y.fPlayerID);
|
||||
}
|
||||
|
||||
|
@ -1,129 +1,129 @@
|
||||
/*==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 plClientGuid_h_inc
|
||||
#define plClientGuid_h_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
#include "plUUID/plUUID.h"
|
||||
|
||||
class plClientGuid : public plCreatable
|
||||
{
|
||||
UInt16 fFlags;
|
||||
plUUID fAccountUUID;
|
||||
UInt32 fPlayerID;
|
||||
UInt8 fCCRLevel;
|
||||
bool fProtectedLogin;
|
||||
UInt8 fBuildType; // see plNetCommon.h
|
||||
std::string fPlayerName;
|
||||
UInt32 fSrcAddr;
|
||||
UInt16 fSrcPort;
|
||||
bool fReserved;
|
||||
std::string fClientKey;
|
||||
|
||||
public:
|
||||
enum Flags // 16 bits.
|
||||
{
|
||||
kAccountUUID = 1<<0,
|
||||
kPlayerID = 1<<1,
|
||||
kTempPlayerID = 1<<2,
|
||||
kCCRLevel = 1<<3,
|
||||
kProtectedLogin = 1<<4,
|
||||
kBuildType = 1<<5,
|
||||
kPlayerName = 1<<6,
|
||||
kSrcAddr = 1<<7,
|
||||
kSrcPort = 1<<8,
|
||||
kReserved = 1<<9,
|
||||
kClientKey = 1<<10,
|
||||
};
|
||||
plClientGuid();
|
||||
CLASSNAME_REGISTER( plClientGuid );
|
||||
GETINTERFACE_ANY( plClientGuid, plCreatable );
|
||||
|
||||
std::string AsStdString() const;
|
||||
std::string AsLogString() const;
|
||||
void Clear();
|
||||
void CopyFrom(const plClientGuid * other);
|
||||
void UpdateFrom(const plClientGuid * other);
|
||||
bool IsEqualTo(const plClientGuid * other) const;
|
||||
bool IsFlagSet( UInt16 flag ) const { return (fFlags&flag)!=0; }
|
||||
bool IsFullyQualified() const { return HasAccountUUID()&&HasPlayerID();}
|
||||
|
||||
void Read(hsStream * s, hsResMgr* =nil);
|
||||
void Write(hsStream * s, hsResMgr* =nil);
|
||||
|
||||
bool HasAccountUUID() const { return (fFlags&kAccountUUID&&!fAccountUUID.IsNull())?true:false;}
|
||||
bool HasPlayerID() const { return (fFlags&kPlayerID&&fPlayerID>0)?true:false;}
|
||||
bool HasPlayerName() const { return (fFlags&kPlayerName&&fPlayerName.size())?true:false; }
|
||||
bool HasCCRLevel() const { return (fFlags&kCCRLevel)?true:false;}
|
||||
bool HasProtectedLogin() const { return (fFlags&kProtectedLogin)?true:false;}
|
||||
bool HasBuildType() const { return (fFlags&kBuildType)?true:false;}
|
||||
bool HasSrcAddr() const { return (fFlags&kSrcAddr)!=0;}
|
||||
bool HasSrcPort() const { return (fFlags&kSrcPort)!=0;}
|
||||
bool HasReservedBit() const { return (fFlags&kReserved)!=0;}
|
||||
bool HasClientKey() const { return (fFlags&kClientKey)!=0;}
|
||||
|
||||
const plUUID * GetAccountUUID() const { return &fAccountUUID;}
|
||||
UInt32 GetPlayerID() const { return fPlayerID;}
|
||||
const char * GetPlayerName() const { return fPlayerName.c_str(); }
|
||||
UInt8 GetCCRLevel() const { return fCCRLevel; }
|
||||
bool GetProtectedLogin() const { return ( fProtectedLogin!=0 ); }
|
||||
UInt8 GetFlags() const { return (UInt8)fFlags;}
|
||||
UInt8 GetBuildType() const { return fBuildType;}
|
||||
UInt32 GetSrcAddr() const { return fSrcAddr; }
|
||||
const char * GetSrcAddrStr() const;
|
||||
UInt16 GetSrcPort() const { return fSrcPort; }
|
||||
bool IsReserved() const { return fReserved!=0; }
|
||||
const std::string& GetClientKey() const { return fClientKey; }
|
||||
|
||||
void SetAccountUUID(const plUUID * v);
|
||||
void SetAccountUUID(const plUUID & v);
|
||||
void SetPlayerID(UInt32 v);
|
||||
void SetPlayerName( const char * v );
|
||||
void SetCCRLevel(UInt8 v);
|
||||
void SetProtectedLogin(bool v);
|
||||
void SetBuildType(UInt8 v);
|
||||
void SetSrcAddr( UInt32 v );
|
||||
void SetSrcAddrFromStr( const char * s );
|
||||
void SetSrcPort( UInt16 v );
|
||||
void SetReserved( bool v );
|
||||
void SetClientKey( const std::string& key );
|
||||
// When a client hasn't selected a player yet,
|
||||
// we need to uniquely identify them in the lobby server.
|
||||
// We do this by stuffing a temp value into the fPlayerID
|
||||
// while keeping the kPlayerID flag cleared.
|
||||
void SetTempPlayerID(UInt32 id);
|
||||
|
||||
friend bool operator==(const plClientGuid & X, const plClientGuid & Y);
|
||||
friend bool operator!=(const plClientGuid & X, const plClientGuid & Y);
|
||||
friend bool operator<(const plClientGuid & X, const plClientGuid & Y);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // plClientGuid_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 plClientGuid_h_inc
|
||||
#define plClientGuid_h_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
#include "plUUID/plUUID.h"
|
||||
|
||||
class plClientGuid : public plCreatable
|
||||
{
|
||||
UInt16 fFlags;
|
||||
plUUID fAccountUUID;
|
||||
UInt32 fPlayerID;
|
||||
UInt8 fCCRLevel;
|
||||
bool fProtectedLogin;
|
||||
UInt8 fBuildType; // see plNetCommon.h
|
||||
std::string fPlayerName;
|
||||
UInt32 fSrcAddr;
|
||||
UInt16 fSrcPort;
|
||||
bool fReserved;
|
||||
std::string fClientKey;
|
||||
|
||||
public:
|
||||
enum Flags // 16 bits.
|
||||
{
|
||||
kAccountUUID = 1<<0,
|
||||
kPlayerID = 1<<1,
|
||||
kTempPlayerID = 1<<2,
|
||||
kCCRLevel = 1<<3,
|
||||
kProtectedLogin = 1<<4,
|
||||
kBuildType = 1<<5,
|
||||
kPlayerName = 1<<6,
|
||||
kSrcAddr = 1<<7,
|
||||
kSrcPort = 1<<8,
|
||||
kReserved = 1<<9,
|
||||
kClientKey = 1<<10,
|
||||
};
|
||||
plClientGuid();
|
||||
CLASSNAME_REGISTER( plClientGuid );
|
||||
GETINTERFACE_ANY( plClientGuid, plCreatable );
|
||||
|
||||
std::string AsStdString() const;
|
||||
std::string AsLogString() const;
|
||||
void Clear();
|
||||
void CopyFrom(const plClientGuid * other);
|
||||
void UpdateFrom(const plClientGuid * other);
|
||||
bool IsEqualTo(const plClientGuid * other) const;
|
||||
bool IsFlagSet( UInt16 flag ) const { return (fFlags&flag)!=0; }
|
||||
bool IsFullyQualified() const { return HasAccountUUID()&&HasPlayerID();}
|
||||
|
||||
void Read(hsStream * s, hsResMgr* =nil);
|
||||
void Write(hsStream * s, hsResMgr* =nil);
|
||||
|
||||
bool HasAccountUUID() const { return (fFlags&kAccountUUID&&!fAccountUUID.IsNull())?true:false;}
|
||||
bool HasPlayerID() const { return (fFlags&kPlayerID&&fPlayerID>0)?true:false;}
|
||||
bool HasPlayerName() const { return (fFlags&kPlayerName&&fPlayerName.size())?true:false; }
|
||||
bool HasCCRLevel() const { return (fFlags&kCCRLevel)?true:false;}
|
||||
bool HasProtectedLogin() const { return (fFlags&kProtectedLogin)?true:false;}
|
||||
bool HasBuildType() const { return (fFlags&kBuildType)?true:false;}
|
||||
bool HasSrcAddr() const { return (fFlags&kSrcAddr)!=0;}
|
||||
bool HasSrcPort() const { return (fFlags&kSrcPort)!=0;}
|
||||
bool HasReservedBit() const { return (fFlags&kReserved)!=0;}
|
||||
bool HasClientKey() const { return (fFlags&kClientKey)!=0;}
|
||||
|
||||
const plUUID * GetAccountUUID() const { return &fAccountUUID;}
|
||||
UInt32 GetPlayerID() const { return fPlayerID;}
|
||||
const char * GetPlayerName() const { return fPlayerName.c_str(); }
|
||||
UInt8 GetCCRLevel() const { return fCCRLevel; }
|
||||
bool GetProtectedLogin() const { return ( fProtectedLogin!=0 ); }
|
||||
UInt8 GetFlags() const { return (UInt8)fFlags;}
|
||||
UInt8 GetBuildType() const { return fBuildType;}
|
||||
UInt32 GetSrcAddr() const { return fSrcAddr; }
|
||||
const char * GetSrcAddrStr() const;
|
||||
UInt16 GetSrcPort() const { return fSrcPort; }
|
||||
bool IsReserved() const { return fReserved!=0; }
|
||||
const std::string& GetClientKey() const { return fClientKey; }
|
||||
|
||||
void SetAccountUUID(const plUUID * v);
|
||||
void SetAccountUUID(const plUUID & v);
|
||||
void SetPlayerID(UInt32 v);
|
||||
void SetPlayerName( const char * v );
|
||||
void SetCCRLevel(UInt8 v);
|
||||
void SetProtectedLogin(bool v);
|
||||
void SetBuildType(UInt8 v);
|
||||
void SetSrcAddr( UInt32 v );
|
||||
void SetSrcAddrFromStr( const char * s );
|
||||
void SetSrcPort( UInt16 v );
|
||||
void SetReserved( bool v );
|
||||
void SetClientKey( const std::string& key );
|
||||
// When a client hasn't selected a player yet,
|
||||
// we need to uniquely identify them in the lobby server.
|
||||
// We do this by stuffing a temp value into the fPlayerID
|
||||
// while keeping the kPlayerID flag cleared.
|
||||
void SetTempPlayerID(UInt32 id);
|
||||
|
||||
friend bool operator==(const plClientGuid & X, const plClientGuid & Y);
|
||||
friend bool operator!=(const plClientGuid & X, const plClientGuid & Y);
|
||||
friend bool operator<(const plClientGuid & X, const plClientGuid & Y);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // plClientGuid_h_inc
|
||||
|
@ -1,114 +1,114 @@
|
||||
/*==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 "plNetCommon.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "plUUID/plUUID.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace plNetCommon
|
||||
{
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace VaultTasks
|
||||
{
|
||||
const char * VaultTaskStr( int taskID )
|
||||
{
|
||||
switch ( taskID )
|
||||
{
|
||||
case kCreatePlayer: return "CreatePlayer";
|
||||
case kDeletePlayer: return "DeletePlayer";
|
||||
case kGetPlayerList: return "GetPlayerList";
|
||||
case kCreateNeighborhood: return "CreateNeighborhood";
|
||||
case kJoinNeighborhood: return "JoinNeighborhood";
|
||||
case kSetAgePublic: return "SetAgePublic";
|
||||
case kIncPlayerOnlineTime: return "IncPlayerOnlineTime";
|
||||
case kEnablePlayer: return "EnablePlayer";
|
||||
case kRegisterOwnedAge: return "RegisterOwnedAge";
|
||||
case kUnRegisterOwnedAge: return "UnRegisterOwnedAge";
|
||||
case kRegisterVisitAge: return "RegisterVisitAge";
|
||||
case kUnRegisterVisitAge: return "UnRegisterVisitAge";
|
||||
case kFriendInvite: return "FriendInvite";
|
||||
default: return "UNKNOWN VAULT TASK";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace Accounts
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
namespace Reserved
|
||||
{
|
||||
////////////////////////////////////////////
|
||||
// Adding a new reserved Avatar? Make sure you:
|
||||
// 1) Add it to the switch statement in GetReservedAvatarShape()
|
||||
// 2) Add the name to the list in GetReservedPlayerNames()
|
||||
#define kPlayerNameDrWatson "Dr. Watson"
|
||||
#define kAvatarShapeDrWatson "DrWatson"
|
||||
#define kPlayerNameRand "Rand"
|
||||
#define kAvatarShapeRand "RandMiller"
|
||||
#define kPlayerNameSutherland "Marie Sutherland"
|
||||
#define kAvatarShapeSutherland "Sutherland"
|
||||
#define kPlayerNameLaxman "Victor Laxman"
|
||||
#define kAvatarShapeLaxman "Victor"
|
||||
#define kPlayerNameKodama "Dr. Kodama"
|
||||
#define kAvatarShapeKodama "Kodama"
|
||||
#define kPlayerNameEngberg "Michael Engberg"
|
||||
#define kAvatarShapeEngberg "Engberg"
|
||||
#define kPlayerNameZandi "Zandi"
|
||||
#define kAvatarShapeZandi "Zandi"
|
||||
#define kPlayerNameYeesha "Yeesha"
|
||||
#define kAvatarShapeYeesha "Yeesha"
|
||||
////////////////////////////////////////////
|
||||
|
||||
const char * GetReservedAvatarShape( const char * playerName, const char * currShapeName )
|
||||
{
|
||||
if ( stricmp( playerName, kPlayerNameDrWatson )==0 )
|
||||
return kAvatarShapeDrWatson;
|
||||
if ( stricmp( playerName, kPlayerNameRand )==0 )
|
||||
return kAvatarShapeRand;
|
||||
if ( stricmp( playerName, kPlayerNameDrWatson )==0 )
|
||||
return kAvatarShapeDrWatson;
|
||||
if ( stricmp( playerName, kPlayerNameRand )==0 )
|
||||
return kAvatarShapeRand;
|
||||
if ( stricmp( playerName, kPlayerNameSutherland )==0 )
|
||||
return kAvatarShapeSutherland;
|
||||
if ( stricmp( playerName, kPlayerNameLaxman )==0 )
|
||||
return kAvatarShapeLaxman;
|
||||
if ( stricmp( playerName, kPlayerNameKodama )==0 )
|
||||
return kAvatarShapeKodama;
|
||||
if ( stricmp( playerName, kPlayerNameEngberg )==0 )
|
||||
return kAvatarShapeEngberg;
|
||||
if ( stricmp( playerName, kPlayerNameZandi )==0 )
|
||||
return kAvatarShapeZandi;
|
||||
if ( stricmp( playerName, kPlayerNameYeesha )==0 )
|
||||
return kAvatarShapeYeesha;
|
||||
// other reserved players go here.
|
||||
return currShapeName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/*==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 "plNetCommon.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "plUUID/plUUID.h"
|
||||
#include <algorithm>
|
||||
|
||||
namespace plNetCommon
|
||||
{
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace VaultTasks
|
||||
{
|
||||
const char * VaultTaskStr( int taskID )
|
||||
{
|
||||
switch ( taskID )
|
||||
{
|
||||
case kCreatePlayer: return "CreatePlayer";
|
||||
case kDeletePlayer: return "DeletePlayer";
|
||||
case kGetPlayerList: return "GetPlayerList";
|
||||
case kCreateNeighborhood: return "CreateNeighborhood";
|
||||
case kJoinNeighborhood: return "JoinNeighborhood";
|
||||
case kSetAgePublic: return "SetAgePublic";
|
||||
case kIncPlayerOnlineTime: return "IncPlayerOnlineTime";
|
||||
case kEnablePlayer: return "EnablePlayer";
|
||||
case kRegisterOwnedAge: return "RegisterOwnedAge";
|
||||
case kUnRegisterOwnedAge: return "UnRegisterOwnedAge";
|
||||
case kRegisterVisitAge: return "RegisterVisitAge";
|
||||
case kUnRegisterVisitAge: return "UnRegisterVisitAge";
|
||||
case kFriendInvite: return "FriendInvite";
|
||||
default: return "UNKNOWN VAULT TASK";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace Accounts
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
namespace Reserved
|
||||
{
|
||||
////////////////////////////////////////////
|
||||
// Adding a new reserved Avatar? Make sure you:
|
||||
// 1) Add it to the switch statement in GetReservedAvatarShape()
|
||||
// 2) Add the name to the list in GetReservedPlayerNames()
|
||||
#define kPlayerNameDrWatson "Dr. Watson"
|
||||
#define kAvatarShapeDrWatson "DrWatson"
|
||||
#define kPlayerNameRand "Rand"
|
||||
#define kAvatarShapeRand "RandMiller"
|
||||
#define kPlayerNameSutherland "Marie Sutherland"
|
||||
#define kAvatarShapeSutherland "Sutherland"
|
||||
#define kPlayerNameLaxman "Victor Laxman"
|
||||
#define kAvatarShapeLaxman "Victor"
|
||||
#define kPlayerNameKodama "Dr. Kodama"
|
||||
#define kAvatarShapeKodama "Kodama"
|
||||
#define kPlayerNameEngberg "Michael Engberg"
|
||||
#define kAvatarShapeEngberg "Engberg"
|
||||
#define kPlayerNameZandi "Zandi"
|
||||
#define kAvatarShapeZandi "Zandi"
|
||||
#define kPlayerNameYeesha "Yeesha"
|
||||
#define kAvatarShapeYeesha "Yeesha"
|
||||
////////////////////////////////////////////
|
||||
|
||||
const char * GetReservedAvatarShape( const char * playerName, const char * currShapeName )
|
||||
{
|
||||
if ( stricmp( playerName, kPlayerNameDrWatson )==0 )
|
||||
return kAvatarShapeDrWatson;
|
||||
if ( stricmp( playerName, kPlayerNameRand )==0 )
|
||||
return kAvatarShapeRand;
|
||||
if ( stricmp( playerName, kPlayerNameDrWatson )==0 )
|
||||
return kAvatarShapeDrWatson;
|
||||
if ( stricmp( playerName, kPlayerNameRand )==0 )
|
||||
return kAvatarShapeRand;
|
||||
if ( stricmp( playerName, kPlayerNameSutherland )==0 )
|
||||
return kAvatarShapeSutherland;
|
||||
if ( stricmp( playerName, kPlayerNameLaxman )==0 )
|
||||
return kAvatarShapeLaxman;
|
||||
if ( stricmp( playerName, kPlayerNameKodama )==0 )
|
||||
return kAvatarShapeKodama;
|
||||
if ( stricmp( playerName, kPlayerNameEngberg )==0 )
|
||||
return kAvatarShapeEngberg;
|
||||
if ( stricmp( playerName, kPlayerNameZandi )==0 )
|
||||
return kAvatarShapeZandi;
|
||||
if ( stricmp( playerName, kPlayerNameYeesha )==0 )
|
||||
return kAvatarShapeYeesha;
|
||||
// other reserved players go here.
|
||||
return currShapeName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,242 +1,242 @@
|
||||
/*==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 plNetCommon_h_inc
|
||||
#define plNetCommon_h_inc
|
||||
|
||||
#ifndef PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
#include "plNetServerSessionInfo.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
#endif // PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Default age info
|
||||
|
||||
#define kStartUpAgeFilename "StartUp"
|
||||
|
||||
#define kNeighborhoodAgeFilename "Neighborhood"
|
||||
#define kNeighborhoodAgeFilenameW L"Neighborhood"
|
||||
#define kNeighborhoodAgeInstanceName "Bevin"
|
||||
#define kNeighborhoodAgeInstanceNameW L"Bevin"
|
||||
#define kStartupNeighborhoodUserDefinedName "DRC"
|
||||
#define kStartupNeighborhoodUserDefinedNameW L"DRC"
|
||||
|
||||
#define kCityAgeFilename "city"
|
||||
#define kCityAgeFilenameW L"city"
|
||||
#define kCityAgeInstanceName "Ae'gura"
|
||||
#define kCityAgeInstanceNameW L"Ae'gura"
|
||||
|
||||
#define kAvCustomizationFilename "AvatarCustomization"
|
||||
#define kAvCustomizationAgeInstanceName "AvatarCustomization"
|
||||
|
||||
#define kNexusAgeFilename "Nexus"
|
||||
#define kNexusAgeInstanceName "Nexus"
|
||||
|
||||
#define kCleftAgeFilename "Cleft"
|
||||
#define kCleftAgeInstanceName "Cleft"
|
||||
#define kCleftAgeLinkInPointFissureDrop "LinkInPointFissureDrop"
|
||||
|
||||
#define kDemoAgeFilename "Demo"
|
||||
#define kDemoAgeInstanceName "Demo"
|
||||
|
||||
#define kPersonalAgeFilename "Personal"
|
||||
#define kPersonalAgeFilenameW L"Personal"
|
||||
#define kPersonalAgeInstanceName "Relto"
|
||||
#define kPersonalAgeInstanceNameW L"Relto"
|
||||
#define kPersonalAgeLinkInPointCloset "LinkInPointCloset"
|
||||
|
||||
#define kCityFerryTerminalLinkSpawnPtName "LinkInPointFerry"
|
||||
#define kCityFerryTerminalLinkTitle "Ferry Terminal"
|
||||
|
||||
#define kDescentLinkFromShell "dsntShaftFromShell"
|
||||
|
||||
#define kWatchersPubAgeFilenameW L"GreatTreePub"
|
||||
#define kWatchersPubAgeInstanceNameW L"The Watcher's Pub"
|
||||
|
||||
#define kKirelFilenameW L"Neighborhood02"
|
||||
#define kKirelInstanceNameW L"Kirel"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Chronicle Var Names
|
||||
|
||||
#define kChronicle_CurCityInstance "CurCityInstance"
|
||||
#define kChronicle_InitialAvCustomizationsDone "InitialAvCustomizationsDone"
|
||||
#define kChronicle_CleftSolved "CleftSolved"
|
||||
#define kChronicle_GiveYeeshaReward "GiveYeeshaReward"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#define kInvalidVaultNodeID 0
|
||||
#define kInvalidPlayerID kInvalidVaultNodeID
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Namespace for holding net-oriented shared enums, utils, etc.
|
||||
|
||||
#ifndef PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
namespace plNetCommon
|
||||
{
|
||||
// Topics for plNetMsgVaultTask msg
|
||||
namespace VaultTasks
|
||||
{
|
||||
enum
|
||||
{
|
||||
kInvalidLow,
|
||||
kCreatePlayer,
|
||||
kDeletePlayer,
|
||||
kGetPlayerList,
|
||||
kCreateNeighborhood,
|
||||
kJoinNeighborhood,
|
||||
kSetAgePublic,
|
||||
kIncPlayerOnlineTime,
|
||||
kEnablePlayer,
|
||||
kRegisterOwnedAge,
|
||||
kUnRegisterOwnedAge,
|
||||
kRegisterVisitAge,
|
||||
kUnRegisterVisitAge,
|
||||
kFriendInvite,
|
||||
kLastVaultTask,
|
||||
};
|
||||
const char * VaultTaskStr( int taskID );
|
||||
}
|
||||
|
||||
// Args for plNetMsgVaultTask msg
|
||||
namespace VaultTaskArgs
|
||||
{
|
||||
enum
|
||||
{
|
||||
kInvalidLow,
|
||||
kHoodTitle,
|
||||
kHoodDesc,
|
||||
kAgePublic,
|
||||
kIntArg1,
|
||||
kIntArg2,
|
||||
kAgeInfoNodeID,
|
||||
kAgeLinkNodeID,
|
||||
kMTStationName,
|
||||
kSpawnPointName,
|
||||
kAgeInfoStruct,
|
||||
kAgeLinkStruct,
|
||||
kAgeFilename,
|
||||
kAgeInstanceGuid,
|
||||
kNodeID,
|
||||
kFriendName, // Use with key
|
||||
kInviteKey, // Use with friend
|
||||
kAgeLinkNode,
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace Accounts
|
||||
{
|
||||
namespace Reserved
|
||||
{
|
||||
const char * GetReservedAvatarShape( const char * playerName, const char * currShapeName );
|
||||
void GetReservedPlayerNames( std::vector<std::string> & out );
|
||||
bool IsReservedPlayerName( const char * name );
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace LinkingRules
|
||||
{
|
||||
enum Rules
|
||||
{
|
||||
// Link to public age: Use PLS-MCP load balancing rules. Don't remember this link in KI/vault.
|
||||
kBasicLink,
|
||||
// Link and create a book in the AgesIOwn folder
|
||||
kOriginalBook,
|
||||
// Link to a sub age of current age.
|
||||
kSubAgeBook,
|
||||
// Link using info from my AgesIOwn folder
|
||||
kOwnedBook,
|
||||
// Link using info from my AgesICanVisit folder
|
||||
kVisitBook,
|
||||
// Link to a child age of current age.
|
||||
kChildAgeBook,
|
||||
};
|
||||
|
||||
static const char * LinkingRuleStr( int rule )
|
||||
{
|
||||
switch ( rule )
|
||||
{
|
||||
case kBasicLink: return "kBasicLink";
|
||||
case kOriginalBook: return "kOriginalBook";
|
||||
case kSubAgeBook: return "kSubAgeBook";
|
||||
case kOwnedBook: return "kOwnedBook";
|
||||
case kVisitBook: return "kVisitBook";
|
||||
case kChildAgeBook: return "kChildAgeBook";
|
||||
default: return "UNKNOWN LINKING RULE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PetitionTypes
|
||||
{
|
||||
enum Types
|
||||
{
|
||||
kGeneralHelp = 0,
|
||||
kBug,
|
||||
kFeedback,
|
||||
kExploit,
|
||||
kHarass,
|
||||
kStuck,
|
||||
kTechnical
|
||||
};
|
||||
}
|
||||
|
||||
namespace BuildType
|
||||
{
|
||||
enum Types
|
||||
{
|
||||
kUnknown = 0,
|
||||
kDebug,
|
||||
kInternalRelease,
|
||||
kExternalRelease
|
||||
};
|
||||
|
||||
static const char * BuildTypeStr( int rule )
|
||||
{
|
||||
switch ( rule )
|
||||
{
|
||||
case kDebug: return "Dbg";
|
||||
case kInternalRelease: return "IntRel";
|
||||
case kExternalRelease: return "ExtRel";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // plNetCommon_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 plNetCommon_h_inc
|
||||
#define plNetCommon_h_inc
|
||||
|
||||
#ifndef PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
#include "plNetServerSessionInfo.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
#endif // PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Default age info
|
||||
|
||||
#define kStartUpAgeFilename "StartUp"
|
||||
|
||||
#define kNeighborhoodAgeFilename "Neighborhood"
|
||||
#define kNeighborhoodAgeFilenameW L"Neighborhood"
|
||||
#define kNeighborhoodAgeInstanceName "Bevin"
|
||||
#define kNeighborhoodAgeInstanceNameW L"Bevin"
|
||||
#define kStartupNeighborhoodUserDefinedName "DRC"
|
||||
#define kStartupNeighborhoodUserDefinedNameW L"DRC"
|
||||
|
||||
#define kCityAgeFilename "city"
|
||||
#define kCityAgeFilenameW L"city"
|
||||
#define kCityAgeInstanceName "Ae'gura"
|
||||
#define kCityAgeInstanceNameW L"Ae'gura"
|
||||
|
||||
#define kAvCustomizationFilename "AvatarCustomization"
|
||||
#define kAvCustomizationAgeInstanceName "AvatarCustomization"
|
||||
|
||||
#define kNexusAgeFilename "Nexus"
|
||||
#define kNexusAgeInstanceName "Nexus"
|
||||
|
||||
#define kCleftAgeFilename "Cleft"
|
||||
#define kCleftAgeInstanceName "Cleft"
|
||||
#define kCleftAgeLinkInPointFissureDrop "LinkInPointFissureDrop"
|
||||
|
||||
#define kDemoAgeFilename "Demo"
|
||||
#define kDemoAgeInstanceName "Demo"
|
||||
|
||||
#define kPersonalAgeFilename "Personal"
|
||||
#define kPersonalAgeFilenameW L"Personal"
|
||||
#define kPersonalAgeInstanceName "Relto"
|
||||
#define kPersonalAgeInstanceNameW L"Relto"
|
||||
#define kPersonalAgeLinkInPointCloset "LinkInPointCloset"
|
||||
|
||||
#define kCityFerryTerminalLinkSpawnPtName "LinkInPointFerry"
|
||||
#define kCityFerryTerminalLinkTitle "Ferry Terminal"
|
||||
|
||||
#define kDescentLinkFromShell "dsntShaftFromShell"
|
||||
|
||||
#define kWatchersPubAgeFilenameW L"GreatTreePub"
|
||||
#define kWatchersPubAgeInstanceNameW L"The Watcher's Pub"
|
||||
|
||||
#define kKirelFilenameW L"Neighborhood02"
|
||||
#define kKirelInstanceNameW L"Kirel"
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Chronicle Var Names
|
||||
|
||||
#define kChronicle_CurCityInstance "CurCityInstance"
|
||||
#define kChronicle_InitialAvCustomizationsDone "InitialAvCustomizationsDone"
|
||||
#define kChronicle_CleftSolved "CleftSolved"
|
||||
#define kChronicle_GiveYeeshaReward "GiveYeeshaReward"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#define kInvalidVaultNodeID 0
|
||||
#define kInvalidPlayerID kInvalidVaultNodeID
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Namespace for holding net-oriented shared enums, utils, etc.
|
||||
|
||||
#ifndef PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
namespace plNetCommon
|
||||
{
|
||||
// Topics for plNetMsgVaultTask msg
|
||||
namespace VaultTasks
|
||||
{
|
||||
enum
|
||||
{
|
||||
kInvalidLow,
|
||||
kCreatePlayer,
|
||||
kDeletePlayer,
|
||||
kGetPlayerList,
|
||||
kCreateNeighborhood,
|
||||
kJoinNeighborhood,
|
||||
kSetAgePublic,
|
||||
kIncPlayerOnlineTime,
|
||||
kEnablePlayer,
|
||||
kRegisterOwnedAge,
|
||||
kUnRegisterOwnedAge,
|
||||
kRegisterVisitAge,
|
||||
kUnRegisterVisitAge,
|
||||
kFriendInvite,
|
||||
kLastVaultTask,
|
||||
};
|
||||
const char * VaultTaskStr( int taskID );
|
||||
}
|
||||
|
||||
// Args for plNetMsgVaultTask msg
|
||||
namespace VaultTaskArgs
|
||||
{
|
||||
enum
|
||||
{
|
||||
kInvalidLow,
|
||||
kHoodTitle,
|
||||
kHoodDesc,
|
||||
kAgePublic,
|
||||
kIntArg1,
|
||||
kIntArg2,
|
||||
kAgeInfoNodeID,
|
||||
kAgeLinkNodeID,
|
||||
kMTStationName,
|
||||
kSpawnPointName,
|
||||
kAgeInfoStruct,
|
||||
kAgeLinkStruct,
|
||||
kAgeFilename,
|
||||
kAgeInstanceGuid,
|
||||
kNodeID,
|
||||
kFriendName, // Use with key
|
||||
kInviteKey, // Use with friend
|
||||
kAgeLinkNode,
|
||||
};
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace Accounts
|
||||
{
|
||||
namespace Reserved
|
||||
{
|
||||
const char * GetReservedAvatarShape( const char * playerName, const char * currShapeName );
|
||||
void GetReservedPlayerNames( std::vector<std::string> & out );
|
||||
bool IsReservedPlayerName( const char * name );
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
namespace LinkingRules
|
||||
{
|
||||
enum Rules
|
||||
{
|
||||
// Link to public age: Use PLS-MCP load balancing rules. Don't remember this link in KI/vault.
|
||||
kBasicLink,
|
||||
// Link and create a book in the AgesIOwn folder
|
||||
kOriginalBook,
|
||||
// Link to a sub age of current age.
|
||||
kSubAgeBook,
|
||||
// Link using info from my AgesIOwn folder
|
||||
kOwnedBook,
|
||||
// Link using info from my AgesICanVisit folder
|
||||
kVisitBook,
|
||||
// Link to a child age of current age.
|
||||
kChildAgeBook,
|
||||
};
|
||||
|
||||
static const char * LinkingRuleStr( int rule )
|
||||
{
|
||||
switch ( rule )
|
||||
{
|
||||
case kBasicLink: return "kBasicLink";
|
||||
case kOriginalBook: return "kOriginalBook";
|
||||
case kSubAgeBook: return "kSubAgeBook";
|
||||
case kOwnedBook: return "kOwnedBook";
|
||||
case kVisitBook: return "kVisitBook";
|
||||
case kChildAgeBook: return "kChildAgeBook";
|
||||
default: return "UNKNOWN LINKING RULE";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace PetitionTypes
|
||||
{
|
||||
enum Types
|
||||
{
|
||||
kGeneralHelp = 0,
|
||||
kBug,
|
||||
kFeedback,
|
||||
kExploit,
|
||||
kHarass,
|
||||
kStuck,
|
||||
kTechnical
|
||||
};
|
||||
}
|
||||
|
||||
namespace BuildType
|
||||
{
|
||||
enum Types
|
||||
{
|
||||
kUnknown = 0,
|
||||
kDebug,
|
||||
kInternalRelease,
|
||||
kExternalRelease
|
||||
};
|
||||
|
||||
static const char * BuildTypeStr( int rule )
|
||||
{
|
||||
switch ( rule )
|
||||
{
|
||||
case kDebug: return "Dbg";
|
||||
case kInternalRelease: return "IntRel";
|
||||
case kExternalRelease: return "ExtRel";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PLNETCOMMON_CONSTANTS_ONLY
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // plNetCommon_h_inc
|
||||
|
@ -1,33 +1,33 @@
|
||||
/*==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 plNetCommonConstants_h_inc
|
||||
#define plNetCommonConstants_h_inc
|
||||
|
||||
|
||||
|
||||
#endif // plNetCommonConstants_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 plNetCommonConstants_h_inc
|
||||
#define plNetCommonConstants_h_inc
|
||||
|
||||
|
||||
|
||||
#endif // plNetCommonConstants_h_inc
|
||||
|
||||
|
||||
|
@ -1,55 +1,55 @@
|
||||
/*==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 plNetCommonCreatable_inc
|
||||
#define plNetCommonCreatable_inc
|
||||
|
||||
#include "pnFactory/plCreator.h"
|
||||
|
||||
#ifndef SERVER
|
||||
#include "plNetMember.h"
|
||||
REGISTER_NONCREATABLE( plNetMember );
|
||||
#endif // SERVER
|
||||
|
||||
#include "plNetCommonHelpers.h"
|
||||
#ifndef SERVER
|
||||
REGISTER_CREATABLE( plNetCoreStatsSummary );
|
||||
#endif // SERVER
|
||||
REGISTER_CREATABLE( plCreatableListHelper );
|
||||
|
||||
// HACK: plUUID should have it's own creatable include
|
||||
#include "../plUUID/plUUID.h"
|
||||
REGISTER_CREATABLE( plCreatableUuid );
|
||||
|
||||
#include "plClientGuid.h"
|
||||
REGISTER_CREATABLE( plClientGuid );
|
||||
#include "plNetServerSessionInfo.h"
|
||||
REGISTER_CREATABLE( plNetServerSessionInfo );
|
||||
REGISTER_CREATABLE( plAgeInfoStruct );
|
||||
REGISTER_CREATABLE( plAgeLinkStruct );
|
||||
|
||||
#endif // plNetCommonCreatable_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 plNetCommonCreatable_inc
|
||||
#define plNetCommonCreatable_inc
|
||||
|
||||
#include "pnFactory/plCreator.h"
|
||||
|
||||
#ifndef SERVER
|
||||
#include "plNetMember.h"
|
||||
REGISTER_NONCREATABLE( plNetMember );
|
||||
#endif // SERVER
|
||||
|
||||
#include "plNetCommonHelpers.h"
|
||||
#ifndef SERVER
|
||||
REGISTER_CREATABLE( plNetCoreStatsSummary );
|
||||
#endif // SERVER
|
||||
REGISTER_CREATABLE( plCreatableListHelper );
|
||||
|
||||
// HACK: plUUID should have it's own creatable include
|
||||
#include "../plUUID/plUUID.h"
|
||||
REGISTER_CREATABLE( plCreatableUuid );
|
||||
|
||||
#include "plClientGuid.h"
|
||||
REGISTER_CREATABLE( plClientGuid );
|
||||
#include "plNetServerSessionInfo.h"
|
||||
REGISTER_CREATABLE( plNetServerSessionInfo );
|
||||
REGISTER_CREATABLE( plAgeInfoStruct );
|
||||
REGISTER_CREATABLE( plAgeLinkStruct );
|
||||
|
||||
#endif // plNetCommonCreatable_inc
|
||||
|
||||
|
||||
|
@ -1,345 +1,345 @@
|
||||
/*==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 "hsTypes.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "plNetCommonHelpers.h"
|
||||
#include "pnNetCommon/plGenericVar.h"
|
||||
#include "plCompression/plZlibCompress.h"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef SERVER
|
||||
const UInt8 plNetCoreStatsSummary::StreamVersion = 1;
|
||||
|
||||
plNetCoreStatsSummary::plNetCoreStatsSummary()
|
||||
:fULBitsPS(0),
|
||||
fDLBitsPS(0),
|
||||
fULPeakBitsPS(0),
|
||||
fDLPeakBitsPS(0),
|
||||
fULPeakPktsPS(0),
|
||||
fDLPeakPktsPS(0),
|
||||
fDLDroppedPackets(0)
|
||||
{
|
||||
}
|
||||
|
||||
void plNetCoreStatsSummary::Read(hsStream* s, hsResMgr*)
|
||||
{
|
||||
UInt8 streamVer;
|
||||
s->ReadSwap(&streamVer);
|
||||
hsAssert(streamVer==StreamVersion,"plNetCoreStatsSummary invalid stream version.");
|
||||
s->ReadSwap(&fULBitsPS);
|
||||
s->ReadSwap(&fDLBitsPS);
|
||||
s->ReadSwap(&fULPeakBitsPS);
|
||||
s->ReadSwap(&fDLPeakBitsPS);
|
||||
s->ReadSwap(&fULPeakPktsPS);
|
||||
s->ReadSwap(&fDLPeakPktsPS);
|
||||
s->ReadSwap(&fDLDroppedPackets);
|
||||
}
|
||||
|
||||
void plNetCoreStatsSummary::Write(hsStream* s, hsResMgr*)
|
||||
{
|
||||
s->WriteSwap(StreamVersion);
|
||||
s->WriteSwap(fULBitsPS);
|
||||
s->WriteSwap(fDLBitsPS);
|
||||
s->WriteSwap(fULPeakBitsPS);
|
||||
s->WriteSwap(fDLPeakBitsPS);
|
||||
s->WriteSwap(fULPeakPktsPS);
|
||||
s->WriteSwap(fDLPeakPktsPS);
|
||||
s->WriteSwap(fDLDroppedPackets);
|
||||
}
|
||||
#endif // SERVER
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
plCreatableListHelper::plCreatableListHelper()
|
||||
: fCompressionThreshold( kDefaultCompressionThreshold )
|
||||
, fFlags( kWantCompression )
|
||||
{
|
||||
}
|
||||
|
||||
void plCreatableListHelper::IClearItems()
|
||||
{
|
||||
std::for_each( fManagedItems.begin(), fManagedItems.end(), xtl::delete_ptr() );
|
||||
fManagedItems.clear();
|
||||
fItems.clear();
|
||||
}
|
||||
|
||||
void plCreatableListHelper::CopyFrom( const plCreatableListHelper * other, bool manageItems )
|
||||
{
|
||||
IClearItems();
|
||||
fFlags = other->fFlags;
|
||||
std::copy( other->fItems.begin(), other->fItems.end(), std::inserter(fItems, fItems.begin() ) );
|
||||
fCompressionThreshold = other->fCompressionThreshold;
|
||||
fWritten = other->fWritten;
|
||||
if ( manageItems )
|
||||
{
|
||||
std::copy( other->fManagedItems.begin(), other->fManagedItems.end(), std::back_inserter( fManagedItems ) );
|
||||
other->fManagedItems.clear(); // we'll take responsibility for these.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void plCreatableListHelper::AddItem( UInt16 id, plCreatable * item, bool manageItem )
|
||||
{
|
||||
RemoveItem( id );
|
||||
fItems[id] = item;
|
||||
if ( manageItem )
|
||||
fManagedItems.push_back( item );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddItem( UInt16 id, const plCreatable * item, bool manageItem )
|
||||
{
|
||||
AddItem( id, const_cast<plCreatable*>( item ), manageItem );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::RemoveItem( UInt16 id, bool unManageItem )
|
||||
{
|
||||
plCreatable * item = GetItem( id );
|
||||
if ( !item )
|
||||
return;
|
||||
std::vector<plCreatable*>::iterator ii = std::find( fManagedItems.begin(),fManagedItems.end(), item );
|
||||
if ( ii!=fManagedItems.end() )
|
||||
{
|
||||
if ( !unManageItem )
|
||||
delete ( *ii );
|
||||
fManagedItems.erase( ii );
|
||||
}
|
||||
fItems.erase( id );
|
||||
}
|
||||
|
||||
plCreatable * plCreatableListHelper::GetItem( UInt16 id, bool unManageItem/*=false */) const
|
||||
{
|
||||
std::map<UInt16,plCreatable*>::const_iterator it=fItems.find( id );
|
||||
if ( it!=fItems.end() )
|
||||
{
|
||||
if ( unManageItem )
|
||||
{
|
||||
std::vector<plCreatable*>::iterator ii = std::find( fManagedItems.begin(),fManagedItems.end(), it->second );
|
||||
if ( ii!=fManagedItems.end() )
|
||||
fManagedItems.erase( ii );
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
bool plCreatableListHelper::ItemExists( UInt16 id ) const
|
||||
{
|
||||
return ( fItems.find( id )!=fItems.end() );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddString(UInt16 id, const char * value)
|
||||
{
|
||||
plCreatableGenericValue * V = TRACKED_NEW plCreatableGenericValue();
|
||||
V->Value().SetString( (char*)value );
|
||||
AddItem( id, V, true );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddString( UInt16 id, std::string & value )
|
||||
{
|
||||
AddString( id, value.c_str() );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddInt( UInt16 id, Int32 value )
|
||||
{
|
||||
plCreatableGenericValue * V = TRACKED_NEW plCreatableGenericValue();
|
||||
V->Value().SetInt(value);
|
||||
AddItem( id, V, true );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddDouble( UInt16 id, double value )
|
||||
{
|
||||
plCreatableGenericValue * V = TRACKED_NEW plCreatableGenericValue();
|
||||
V->Value().SetDouble(value);
|
||||
AddItem( id, V, true );
|
||||
}
|
||||
|
||||
const char * plCreatableListHelper::GetString( UInt16 id )
|
||||
{
|
||||
plCreatableGenericValue * V = plCreatableGenericValue::ConvertNoRef( GetItem( id ) );
|
||||
if ( !V ) return nil;
|
||||
return (const char *)V->Value();
|
||||
}
|
||||
|
||||
Int32 plCreatableListHelper::GetInt( UInt16 id )
|
||||
{
|
||||
plCreatableGenericValue * V = plCreatableGenericValue::ConvertNoRef( GetItem( id ) );
|
||||
if ( !V ) return 0;
|
||||
return (Int32)V->Value();
|
||||
}
|
||||
|
||||
double plCreatableListHelper::GetDouble( UInt16 id )
|
||||
{
|
||||
plCreatableGenericValue * V = plCreatableGenericValue::ConvertNoRef( GetItem( id ) );
|
||||
if ( !V ) return 0;
|
||||
return (double)V->Value();
|
||||
}
|
||||
|
||||
void plCreatableListHelper::Read( hsStream* s, hsResMgr* mgr )
|
||||
{
|
||||
IClearItems();
|
||||
|
||||
s->LogSubStreamStart("CreatableListHelper");
|
||||
|
||||
s->LogReadSwap( &fFlags, "Flags" );
|
||||
|
||||
fFlags &= ~kWritten;
|
||||
|
||||
UInt32 bufSz;
|
||||
s->LogReadSwap( &bufSz, "BufSz" );
|
||||
std::string buf;
|
||||
buf.resize( bufSz );
|
||||
|
||||
if ( fFlags&kCompressed )
|
||||
{
|
||||
UInt32 zBufSz;
|
||||
s->LogReadSwap( &zBufSz, "Compressed BufSz" );
|
||||
std::string zBuf;
|
||||
zBuf.resize( zBufSz );
|
||||
s->LogSubStreamPushDesc("Compressed Data");
|
||||
s->Read( zBufSz, (void*)zBuf.data() );
|
||||
plZlibCompress compressor;
|
||||
UInt32 tmp;
|
||||
hsBool ans = compressor.Uncompress( (UInt8*)buf.data(), &tmp, (UInt8*)zBuf.data(), zBufSz );
|
||||
hsAssert( ans!=0, "plCreatableListHelper: Failed to uncompress buffer." );
|
||||
hsAssert( tmp==bufSz, "compression size mismatch" );
|
||||
fFlags&=~kCompressed;
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "plCreatableListHelper: uncompressed from %lu to %lu", zBufSz, bufSz ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
s->LogSubStreamPushDesc("Uncompressed Data");
|
||||
s->Read( bufSz, (void*)buf.data() );
|
||||
}
|
||||
|
||||
hsReadOnlyStream ram( bufSz, (void*)buf.data() );
|
||||
|
||||
UInt16 nItems;
|
||||
ram.ReadSwap( &nItems );
|
||||
for ( int i=0; i<nItems; i++ )
|
||||
{
|
||||
UInt16 id;
|
||||
UInt16 classIdx;
|
||||
ram.ReadSwap( &id );
|
||||
ram.ReadSwap( &classIdx );
|
||||
plCreatable * object = plFactory::Create( classIdx );
|
||||
hsAssert( object,"plCreatableListHelper: Failed to create plCreatable object (invalid class index?)" );
|
||||
if ( object )
|
||||
{
|
||||
fManagedItems.push_back( object );
|
||||
object->Read( &ram, mgr );
|
||||
fItems[id] = object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plCreatableListHelper::Write( hsStream* s, hsResMgr* mgr )
|
||||
{
|
||||
if ( !( fFlags&kWritten ) )
|
||||
{
|
||||
// write items to ram stream
|
||||
hsRAMStream ram;
|
||||
UInt16 nItems = fItems.size();
|
||||
ram.WriteSwap( nItems );
|
||||
for ( std::map<UInt16,plCreatable*>::iterator ii=fItems.begin(); ii!=fItems.end(); ++ii )
|
||||
{
|
||||
UInt16 id = ii->first;
|
||||
plCreatable * item = ii->second;
|
||||
UInt16 classIdx = item->ClassIndex();
|
||||
ram.WriteSwap( id );
|
||||
ram.WriteSwap( classIdx );
|
||||
item->Write( &ram, mgr );
|
||||
}
|
||||
|
||||
// read ram stream into a buffer
|
||||
UInt32 bufSz = ram.GetPosition();
|
||||
ram.Rewind();
|
||||
std::string buf;
|
||||
buf.resize( bufSz );
|
||||
ram.Read( bufSz, (void*)buf.data() );
|
||||
|
||||
// maybe compress the buffer
|
||||
if ( fFlags&kWantCompression && bufSz>fCompressionThreshold )
|
||||
{
|
||||
plZlibCompress compressor;
|
||||
UInt32 zBufSz;
|
||||
std::string zBuf;
|
||||
zBuf.resize( bufSz );
|
||||
hsBool ans = compressor.Compress( (UInt8*)zBuf.data(), &zBufSz, (const UInt8*)buf.data(), bufSz );
|
||||
bool compressed = ( ans && zBufSz );
|
||||
hsAssert( compressed, "plCreatableListHelper: Failed to compress buffer." );
|
||||
if ( compressed )
|
||||
{
|
||||
zBuf.resize( zBufSz );
|
||||
buf = zBuf;
|
||||
fFlags |= kCompressed;
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "plCreatableListHelper: compressed from %lu to %lu", bufSz, zBufSz ) );
|
||||
}
|
||||
}
|
||||
|
||||
ram.Truncate();
|
||||
|
||||
ram.WriteSwap( fFlags );
|
||||
ram.WriteSwap( bufSz );
|
||||
|
||||
if ( fFlags&kCompressed )
|
||||
{
|
||||
UInt32 zBufSz = buf.size();
|
||||
ram.WriteSwap( zBufSz );
|
||||
}
|
||||
|
||||
ram.Write( buf.size(), buf.data() );
|
||||
UInt32 sz = ram.GetPosition();
|
||||
ram.Rewind();
|
||||
|
||||
fWritten.resize( sz );
|
||||
ram.Read( sz, (void*)fWritten.data() );
|
||||
|
||||
fFlags |= kWritten;
|
||||
}
|
||||
|
||||
s->Write( fWritten.size(), fWritten.data() );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::GetItemsAsVec( std::vector<plCreatable*>& out )
|
||||
{
|
||||
for ( std::map<UInt16,plCreatable*>::iterator ii=fItems.begin(); ii!=fItems.end(); ++ii )
|
||||
{
|
||||
out.push_back( ii->second );
|
||||
}
|
||||
}
|
||||
|
||||
void plCreatableListHelper::GetItems( std::map<UInt16,plCreatable*>& out )
|
||||
{
|
||||
for ( std::map<UInt16,plCreatable*>::iterator ii=fItems.begin(); ii!=fItems.end(); ++ii )
|
||||
{
|
||||
out[ii->first] = ii->second;
|
||||
}
|
||||
}
|
||||
/*==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 "hsTypes.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "plNetCommonHelpers.h"
|
||||
#include "pnNetCommon/plGenericVar.h"
|
||||
#include "plCompression/plZlibCompress.h"
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
#ifndef SERVER
|
||||
const UInt8 plNetCoreStatsSummary::StreamVersion = 1;
|
||||
|
||||
plNetCoreStatsSummary::plNetCoreStatsSummary()
|
||||
:fULBitsPS(0),
|
||||
fDLBitsPS(0),
|
||||
fULPeakBitsPS(0),
|
||||
fDLPeakBitsPS(0),
|
||||
fULPeakPktsPS(0),
|
||||
fDLPeakPktsPS(0),
|
||||
fDLDroppedPackets(0)
|
||||
{
|
||||
}
|
||||
|
||||
void plNetCoreStatsSummary::Read(hsStream* s, hsResMgr*)
|
||||
{
|
||||
UInt8 streamVer;
|
||||
s->ReadSwap(&streamVer);
|
||||
hsAssert(streamVer==StreamVersion,"plNetCoreStatsSummary invalid stream version.");
|
||||
s->ReadSwap(&fULBitsPS);
|
||||
s->ReadSwap(&fDLBitsPS);
|
||||
s->ReadSwap(&fULPeakBitsPS);
|
||||
s->ReadSwap(&fDLPeakBitsPS);
|
||||
s->ReadSwap(&fULPeakPktsPS);
|
||||
s->ReadSwap(&fDLPeakPktsPS);
|
||||
s->ReadSwap(&fDLDroppedPackets);
|
||||
}
|
||||
|
||||
void plNetCoreStatsSummary::Write(hsStream* s, hsResMgr*)
|
||||
{
|
||||
s->WriteSwap(StreamVersion);
|
||||
s->WriteSwap(fULBitsPS);
|
||||
s->WriteSwap(fDLBitsPS);
|
||||
s->WriteSwap(fULPeakBitsPS);
|
||||
s->WriteSwap(fDLPeakBitsPS);
|
||||
s->WriteSwap(fULPeakPktsPS);
|
||||
s->WriteSwap(fDLPeakPktsPS);
|
||||
s->WriteSwap(fDLDroppedPackets);
|
||||
}
|
||||
#endif // SERVER
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
plCreatableListHelper::plCreatableListHelper()
|
||||
: fCompressionThreshold( kDefaultCompressionThreshold )
|
||||
, fFlags( kWantCompression )
|
||||
{
|
||||
}
|
||||
|
||||
void plCreatableListHelper::IClearItems()
|
||||
{
|
||||
std::for_each( fManagedItems.begin(), fManagedItems.end(), xtl::delete_ptr() );
|
||||
fManagedItems.clear();
|
||||
fItems.clear();
|
||||
}
|
||||
|
||||
void plCreatableListHelper::CopyFrom( const plCreatableListHelper * other, bool manageItems )
|
||||
{
|
||||
IClearItems();
|
||||
fFlags = other->fFlags;
|
||||
std::copy( other->fItems.begin(), other->fItems.end(), std::inserter(fItems, fItems.begin() ) );
|
||||
fCompressionThreshold = other->fCompressionThreshold;
|
||||
fWritten = other->fWritten;
|
||||
if ( manageItems )
|
||||
{
|
||||
std::copy( other->fManagedItems.begin(), other->fManagedItems.end(), std::back_inserter( fManagedItems ) );
|
||||
other->fManagedItems.clear(); // we'll take responsibility for these.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void plCreatableListHelper::AddItem( UInt16 id, plCreatable * item, bool manageItem )
|
||||
{
|
||||
RemoveItem( id );
|
||||
fItems[id] = item;
|
||||
if ( manageItem )
|
||||
fManagedItems.push_back( item );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddItem( UInt16 id, const plCreatable * item, bool manageItem )
|
||||
{
|
||||
AddItem( id, const_cast<plCreatable*>( item ), manageItem );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::RemoveItem( UInt16 id, bool unManageItem )
|
||||
{
|
||||
plCreatable * item = GetItem( id );
|
||||
if ( !item )
|
||||
return;
|
||||
std::vector<plCreatable*>::iterator ii = std::find( fManagedItems.begin(),fManagedItems.end(), item );
|
||||
if ( ii!=fManagedItems.end() )
|
||||
{
|
||||
if ( !unManageItem )
|
||||
delete ( *ii );
|
||||
fManagedItems.erase( ii );
|
||||
}
|
||||
fItems.erase( id );
|
||||
}
|
||||
|
||||
plCreatable * plCreatableListHelper::GetItem( UInt16 id, bool unManageItem/*=false */) const
|
||||
{
|
||||
std::map<UInt16,plCreatable*>::const_iterator it=fItems.find( id );
|
||||
if ( it!=fItems.end() )
|
||||
{
|
||||
if ( unManageItem )
|
||||
{
|
||||
std::vector<plCreatable*>::iterator ii = std::find( fManagedItems.begin(),fManagedItems.end(), it->second );
|
||||
if ( ii!=fManagedItems.end() )
|
||||
fManagedItems.erase( ii );
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
bool plCreatableListHelper::ItemExists( UInt16 id ) const
|
||||
{
|
||||
return ( fItems.find( id )!=fItems.end() );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddString(UInt16 id, const char * value)
|
||||
{
|
||||
plCreatableGenericValue * V = TRACKED_NEW plCreatableGenericValue();
|
||||
V->Value().SetString( (char*)value );
|
||||
AddItem( id, V, true );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddString( UInt16 id, std::string & value )
|
||||
{
|
||||
AddString( id, value.c_str() );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddInt( UInt16 id, Int32 value )
|
||||
{
|
||||
plCreatableGenericValue * V = TRACKED_NEW plCreatableGenericValue();
|
||||
V->Value().SetInt(value);
|
||||
AddItem( id, V, true );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::AddDouble( UInt16 id, double value )
|
||||
{
|
||||
plCreatableGenericValue * V = TRACKED_NEW plCreatableGenericValue();
|
||||
V->Value().SetDouble(value);
|
||||
AddItem( id, V, true );
|
||||
}
|
||||
|
||||
const char * plCreatableListHelper::GetString( UInt16 id )
|
||||
{
|
||||
plCreatableGenericValue * V = plCreatableGenericValue::ConvertNoRef( GetItem( id ) );
|
||||
if ( !V ) return nil;
|
||||
return (const char *)V->Value();
|
||||
}
|
||||
|
||||
Int32 plCreatableListHelper::GetInt( UInt16 id )
|
||||
{
|
||||
plCreatableGenericValue * V = plCreatableGenericValue::ConvertNoRef( GetItem( id ) );
|
||||
if ( !V ) return 0;
|
||||
return (Int32)V->Value();
|
||||
}
|
||||
|
||||
double plCreatableListHelper::GetDouble( UInt16 id )
|
||||
{
|
||||
plCreatableGenericValue * V = plCreatableGenericValue::ConvertNoRef( GetItem( id ) );
|
||||
if ( !V ) return 0;
|
||||
return (double)V->Value();
|
||||
}
|
||||
|
||||
void plCreatableListHelper::Read( hsStream* s, hsResMgr* mgr )
|
||||
{
|
||||
IClearItems();
|
||||
|
||||
s->LogSubStreamStart("CreatableListHelper");
|
||||
|
||||
s->LogReadSwap( &fFlags, "Flags" );
|
||||
|
||||
fFlags &= ~kWritten;
|
||||
|
||||
UInt32 bufSz;
|
||||
s->LogReadSwap( &bufSz, "BufSz" );
|
||||
std::string buf;
|
||||
buf.resize( bufSz );
|
||||
|
||||
if ( fFlags&kCompressed )
|
||||
{
|
||||
UInt32 zBufSz;
|
||||
s->LogReadSwap( &zBufSz, "Compressed BufSz" );
|
||||
std::string zBuf;
|
||||
zBuf.resize( zBufSz );
|
||||
s->LogSubStreamPushDesc("Compressed Data");
|
||||
s->Read( zBufSz, (void*)zBuf.data() );
|
||||
plZlibCompress compressor;
|
||||
UInt32 tmp;
|
||||
hsBool ans = compressor.Uncompress( (UInt8*)buf.data(), &tmp, (UInt8*)zBuf.data(), zBufSz );
|
||||
hsAssert( ans!=0, "plCreatableListHelper: Failed to uncompress buffer." );
|
||||
hsAssert( tmp==bufSz, "compression size mismatch" );
|
||||
fFlags&=~kCompressed;
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "plCreatableListHelper: uncompressed from %lu to %lu", zBufSz, bufSz ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
s->LogSubStreamPushDesc("Uncompressed Data");
|
||||
s->Read( bufSz, (void*)buf.data() );
|
||||
}
|
||||
|
||||
hsReadOnlyStream ram( bufSz, (void*)buf.data() );
|
||||
|
||||
UInt16 nItems;
|
||||
ram.ReadSwap( &nItems );
|
||||
for ( int i=0; i<nItems; i++ )
|
||||
{
|
||||
UInt16 id;
|
||||
UInt16 classIdx;
|
||||
ram.ReadSwap( &id );
|
||||
ram.ReadSwap( &classIdx );
|
||||
plCreatable * object = plFactory::Create( classIdx );
|
||||
hsAssert( object,"plCreatableListHelper: Failed to create plCreatable object (invalid class index?)" );
|
||||
if ( object )
|
||||
{
|
||||
fManagedItems.push_back( object );
|
||||
object->Read( &ram, mgr );
|
||||
fItems[id] = object;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void plCreatableListHelper::Write( hsStream* s, hsResMgr* mgr )
|
||||
{
|
||||
if ( !( fFlags&kWritten ) )
|
||||
{
|
||||
// write items to ram stream
|
||||
hsRAMStream ram;
|
||||
UInt16 nItems = fItems.size();
|
||||
ram.WriteSwap( nItems );
|
||||
for ( std::map<UInt16,plCreatable*>::iterator ii=fItems.begin(); ii!=fItems.end(); ++ii )
|
||||
{
|
||||
UInt16 id = ii->first;
|
||||
plCreatable * item = ii->second;
|
||||
UInt16 classIdx = item->ClassIndex();
|
||||
ram.WriteSwap( id );
|
||||
ram.WriteSwap( classIdx );
|
||||
item->Write( &ram, mgr );
|
||||
}
|
||||
|
||||
// read ram stream into a buffer
|
||||
UInt32 bufSz = ram.GetPosition();
|
||||
ram.Rewind();
|
||||
std::string buf;
|
||||
buf.resize( bufSz );
|
||||
ram.Read( bufSz, (void*)buf.data() );
|
||||
|
||||
// maybe compress the buffer
|
||||
if ( fFlags&kWantCompression && bufSz>fCompressionThreshold )
|
||||
{
|
||||
plZlibCompress compressor;
|
||||
UInt32 zBufSz;
|
||||
std::string zBuf;
|
||||
zBuf.resize( bufSz );
|
||||
hsBool ans = compressor.Compress( (UInt8*)zBuf.data(), &zBufSz, (const UInt8*)buf.data(), bufSz );
|
||||
bool compressed = ( ans && zBufSz );
|
||||
hsAssert( compressed, "plCreatableListHelper: Failed to compress buffer." );
|
||||
if ( compressed )
|
||||
{
|
||||
zBuf.resize( zBufSz );
|
||||
buf = zBuf;
|
||||
fFlags |= kCompressed;
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "plCreatableListHelper: compressed from %lu to %lu", bufSz, zBufSz ) );
|
||||
}
|
||||
}
|
||||
|
||||
ram.Truncate();
|
||||
|
||||
ram.WriteSwap( fFlags );
|
||||
ram.WriteSwap( bufSz );
|
||||
|
||||
if ( fFlags&kCompressed )
|
||||
{
|
||||
UInt32 zBufSz = buf.size();
|
||||
ram.WriteSwap( zBufSz );
|
||||
}
|
||||
|
||||
ram.Write( buf.size(), buf.data() );
|
||||
UInt32 sz = ram.GetPosition();
|
||||
ram.Rewind();
|
||||
|
||||
fWritten.resize( sz );
|
||||
ram.Read( sz, (void*)fWritten.data() );
|
||||
|
||||
fFlags |= kWritten;
|
||||
}
|
||||
|
||||
s->Write( fWritten.size(), fWritten.data() );
|
||||
}
|
||||
|
||||
void plCreatableListHelper::GetItemsAsVec( std::vector<plCreatable*>& out )
|
||||
{
|
||||
for ( std::map<UInt16,plCreatable*>::iterator ii=fItems.begin(); ii!=fItems.end(); ++ii )
|
||||
{
|
||||
out.push_back( ii->second );
|
||||
}
|
||||
}
|
||||
|
||||
void plCreatableListHelper::GetItems( std::map<UInt16,plCreatable*>& out )
|
||||
{
|
||||
for ( std::map<UInt16,plCreatable*>::iterator ii=fItems.begin(); ii!=fItems.end(); ++ii )
|
||||
{
|
||||
out[ii->first] = ii->second;
|
||||
}
|
||||
}
|
||||
|
@ -1,164 +1,164 @@
|
||||
/*==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 plNetCommonHelpers_h_inc
|
||||
#define plNetCommonHelpers_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "hsTimer.h"
|
||||
#include "pnNetCommon/pnNetCommon.h"
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SERVER
|
||||
class plNetCoreStatsSummary : public plCreatable
|
||||
{
|
||||
static const UInt8 plNetCoreStatsSummary::StreamVersion;
|
||||
float fULBitsPS;
|
||||
float fDLBitsPS;
|
||||
float fULPeakBitsPS;
|
||||
float fDLPeakBitsPS;
|
||||
float fULPeakPktsPS;
|
||||
float fDLPeakPktsPS;
|
||||
UInt32 fDLDroppedPackets;
|
||||
public:
|
||||
plNetCoreStatsSummary();
|
||||
CLASSNAME_REGISTER( plNetCoreStatsSummary );
|
||||
GETINTERFACE_ANY( plNetCoreStatsSummary, plCreatable );
|
||||
void Read(hsStream* s, hsResMgr* mgr=nil);
|
||||
void Write(hsStream* s, hsResMgr* mgr=nil);
|
||||
float GetULBitsPS() const { return fULBitsPS; }
|
||||
float GetDLBitsPS() const { return fDLBitsPS; }
|
||||
float GetULPeakBitsPS() const { return fULPeakBitsPS; }
|
||||
float GetDLPeakBitsPS() const { return fDLPeakBitsPS; }
|
||||
float GetULPeakPktsPS() const { return fULPeakPktsPS; }
|
||||
float GetDLPeakPktsPS() const { return fDLPeakPktsPS; }
|
||||
UInt32 GetDLDroppedPackets() const { return fDLDroppedPackets; }
|
||||
};
|
||||
#endif // SERVER
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class plCreatableListHelper : public plCreatable
|
||||
{
|
||||
enum { kDefaultCompressionThreshold = 255 }; // bytes
|
||||
enum Flags
|
||||
{
|
||||
kWantCompression = 1<<0,
|
||||
kCompressed = 1<<1,
|
||||
kWritten = 1<<2,
|
||||
};
|
||||
UInt8 fFlags;
|
||||
std::map<UInt16,plCreatable*> fItems;
|
||||
mutable std::vector<plCreatable*> fManagedItems;
|
||||
UInt32 fCompressionThreshold; // NOT WRITTEN
|
||||
std::string fWritten;
|
||||
void IClearItems();
|
||||
|
||||
public:
|
||||
plCreatableListHelper();
|
||||
~plCreatableListHelper() { IClearItems();}
|
||||
|
||||
CLASSNAME_REGISTER( plCreatableListHelper );
|
||||
GETINTERFACE_ANY( plCreatableListHelper, plCreatable );
|
||||
|
||||
void Read( hsStream* s, hsResMgr* mgr );
|
||||
void Write( hsStream* s, hsResMgr* mgr );
|
||||
void Clear() { IClearItems(); }
|
||||
void CopyFrom( const plCreatableListHelper * other, bool manageItems );
|
||||
|
||||
void SetWantCompression( bool v ) { if ( v ) fFlags|=kWantCompression; else fFlags&=~kWantCompression; }
|
||||
bool WantCompression() const { return ( fFlags&kWantCompression )!=0; }
|
||||
UInt32 GetCompressionThreshold() const { return fCompressionThreshold; }
|
||||
void SetCompressionThreshold( UInt32 v ) { fCompressionThreshold=v; }
|
||||
|
||||
// support for generic arguments
|
||||
void AddItem( UInt16 id, plCreatable * item, bool manageItem=false );
|
||||
void AddItem( UInt16 id, const plCreatable * item, bool manageItem=false );
|
||||
plCreatable* GetItem( UInt16 id, bool unManageItem=false ) const;
|
||||
void RemoveItem( UInt16 id, bool unManageItem=false );
|
||||
bool ItemExists( UInt16 id ) const;
|
||||
int GetNumItems() const { return fItems.size();}
|
||||
// helpers for typed arguments
|
||||
void AddString( UInt16 id, const char * value );
|
||||
void AddString( UInt16 id, std::string & value );
|
||||
const char * GetString( UInt16 id );
|
||||
void AddInt( UInt16 id, Int32 value );
|
||||
Int32 GetInt( UInt16 id );
|
||||
void AddDouble( UInt16 id, double value );
|
||||
double GetDouble( UInt16 id );
|
||||
void GetItemsAsVec( std::vector<plCreatable*>& out );
|
||||
void GetItems( std::map<UInt16,plCreatable*>& out );
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
struct plOperationTimer
|
||||
{
|
||||
bool fRunning;
|
||||
double fStartTime;
|
||||
double fEndTime;
|
||||
std::string fComment;
|
||||
std::string fSpacer;
|
||||
bool fPrintAtStart;
|
||||
std::string fTag;
|
||||
plOperationTimer( const char * tag="", bool printAtStart=false )
|
||||
: fRunning( false )
|
||||
, fTag( tag )
|
||||
, fStartTime( 0.0 )
|
||||
, fEndTime( 0.0 )
|
||||
, fPrintAtStart( printAtStart )
|
||||
{}
|
||||
~plOperationTimer() { Stop(); }
|
||||
void Start( const char * comment, int level=0 )
|
||||
{
|
||||
fSpacer = std::string( level, '\t' );
|
||||
Stop();
|
||||
fRunning = true;
|
||||
fComment = comment;
|
||||
fStartTime = hsTimer::GetSeconds();
|
||||
if ( fPrintAtStart )
|
||||
{
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "%s%s Timing: %s",
|
||||
fSpacer.c_str(), fTag.c_str(), fComment.c_str() ) );
|
||||
}
|
||||
}
|
||||
void Stop()
|
||||
{
|
||||
if ( !fRunning )
|
||||
return;
|
||||
fRunning = false;
|
||||
fEndTime = hsTimer::GetSeconds()-fStartTime;
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "%s%s Timed: %f secs: %s",
|
||||
fSpacer.c_str(), fTag.c_str(), fEndTime, fComment.c_str() ) );
|
||||
}
|
||||
double GetTime() const { return fEndTime;}
|
||||
};
|
||||
|
||||
|
||||
#endif // plNetCommonHelpers_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 plNetCommonHelpers_h_inc
|
||||
#define plNetCommonHelpers_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "hsTimer.h"
|
||||
#include "pnNetCommon/pnNetCommon.h"
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SERVER
|
||||
class plNetCoreStatsSummary : public plCreatable
|
||||
{
|
||||
static const UInt8 plNetCoreStatsSummary::StreamVersion;
|
||||
float fULBitsPS;
|
||||
float fDLBitsPS;
|
||||
float fULPeakBitsPS;
|
||||
float fDLPeakBitsPS;
|
||||
float fULPeakPktsPS;
|
||||
float fDLPeakPktsPS;
|
||||
UInt32 fDLDroppedPackets;
|
||||
public:
|
||||
plNetCoreStatsSummary();
|
||||
CLASSNAME_REGISTER( plNetCoreStatsSummary );
|
||||
GETINTERFACE_ANY( plNetCoreStatsSummary, plCreatable );
|
||||
void Read(hsStream* s, hsResMgr* mgr=nil);
|
||||
void Write(hsStream* s, hsResMgr* mgr=nil);
|
||||
float GetULBitsPS() const { return fULBitsPS; }
|
||||
float GetDLBitsPS() const { return fDLBitsPS; }
|
||||
float GetULPeakBitsPS() const { return fULPeakBitsPS; }
|
||||
float GetDLPeakBitsPS() const { return fDLPeakBitsPS; }
|
||||
float GetULPeakPktsPS() const { return fULPeakPktsPS; }
|
||||
float GetDLPeakPktsPS() const { return fDLPeakPktsPS; }
|
||||
UInt32 GetDLDroppedPackets() const { return fDLDroppedPackets; }
|
||||
};
|
||||
#endif // SERVER
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class plCreatableListHelper : public plCreatable
|
||||
{
|
||||
enum { kDefaultCompressionThreshold = 255 }; // bytes
|
||||
enum Flags
|
||||
{
|
||||
kWantCompression = 1<<0,
|
||||
kCompressed = 1<<1,
|
||||
kWritten = 1<<2,
|
||||
};
|
||||
UInt8 fFlags;
|
||||
std::map<UInt16,plCreatable*> fItems;
|
||||
mutable std::vector<plCreatable*> fManagedItems;
|
||||
UInt32 fCompressionThreshold; // NOT WRITTEN
|
||||
std::string fWritten;
|
||||
void IClearItems();
|
||||
|
||||
public:
|
||||
plCreatableListHelper();
|
||||
~plCreatableListHelper() { IClearItems();}
|
||||
|
||||
CLASSNAME_REGISTER( plCreatableListHelper );
|
||||
GETINTERFACE_ANY( plCreatableListHelper, plCreatable );
|
||||
|
||||
void Read( hsStream* s, hsResMgr* mgr );
|
||||
void Write( hsStream* s, hsResMgr* mgr );
|
||||
void Clear() { IClearItems(); }
|
||||
void CopyFrom( const plCreatableListHelper * other, bool manageItems );
|
||||
|
||||
void SetWantCompression( bool v ) { if ( v ) fFlags|=kWantCompression; else fFlags&=~kWantCompression; }
|
||||
bool WantCompression() const { return ( fFlags&kWantCompression )!=0; }
|
||||
UInt32 GetCompressionThreshold() const { return fCompressionThreshold; }
|
||||
void SetCompressionThreshold( UInt32 v ) { fCompressionThreshold=v; }
|
||||
|
||||
// support for generic arguments
|
||||
void AddItem( UInt16 id, plCreatable * item, bool manageItem=false );
|
||||
void AddItem( UInt16 id, const plCreatable * item, bool manageItem=false );
|
||||
plCreatable* GetItem( UInt16 id, bool unManageItem=false ) const;
|
||||
void RemoveItem( UInt16 id, bool unManageItem=false );
|
||||
bool ItemExists( UInt16 id ) const;
|
||||
int GetNumItems() const { return fItems.size();}
|
||||
// helpers for typed arguments
|
||||
void AddString( UInt16 id, const char * value );
|
||||
void AddString( UInt16 id, std::string & value );
|
||||
const char * GetString( UInt16 id );
|
||||
void AddInt( UInt16 id, Int32 value );
|
||||
Int32 GetInt( UInt16 id );
|
||||
void AddDouble( UInt16 id, double value );
|
||||
double GetDouble( UInt16 id );
|
||||
void GetItemsAsVec( std::vector<plCreatable*>& out );
|
||||
void GetItems( std::map<UInt16,plCreatable*>& out );
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
struct plOperationTimer
|
||||
{
|
||||
bool fRunning;
|
||||
double fStartTime;
|
||||
double fEndTime;
|
||||
std::string fComment;
|
||||
std::string fSpacer;
|
||||
bool fPrintAtStart;
|
||||
std::string fTag;
|
||||
plOperationTimer( const char * tag="", bool printAtStart=false )
|
||||
: fRunning( false )
|
||||
, fTag( tag )
|
||||
, fStartTime( 0.0 )
|
||||
, fEndTime( 0.0 )
|
||||
, fPrintAtStart( printAtStart )
|
||||
{}
|
||||
~plOperationTimer() { Stop(); }
|
||||
void Start( const char * comment, int level=0 )
|
||||
{
|
||||
fSpacer = std::string( level, '\t' );
|
||||
Stop();
|
||||
fRunning = true;
|
||||
fComment = comment;
|
||||
fStartTime = hsTimer::GetSeconds();
|
||||
if ( fPrintAtStart )
|
||||
{
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "%s%s Timing: %s",
|
||||
fSpacer.c_str(), fTag.c_str(), fComment.c_str() ) );
|
||||
}
|
||||
}
|
||||
void Stop()
|
||||
{
|
||||
if ( !fRunning )
|
||||
return;
|
||||
fRunning = false;
|
||||
fEndTime = hsTimer::GetSeconds()-fStartTime;
|
||||
hsLogEntry( plNetApp::StaticDebugMsg( "%s%s Timed: %f secs: %s",
|
||||
fSpacer.c_str(), fTag.c_str(), fEndTime, fComment.c_str() ) );
|
||||
}
|
||||
double GetTime() const { return fEndTime;}
|
||||
};
|
||||
|
||||
|
||||
#endif // plNetCommonHelpers_h_inc
|
||||
|
@ -1,50 +1,50 @@
|
||||
/*==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 "plNetMember.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// plNetMember
|
||||
////////////////////////////////////////////////////////
|
||||
plNetMember::plNetMember(plNetApp* na)
|
||||
{
|
||||
Reset();
|
||||
fNetApp=(na);
|
||||
}
|
||||
|
||||
plNetMember::plNetMember()
|
||||
: fNetApp(nil)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
//
|
||||
// doesn't remove from session, just resets to initial state
|
||||
//
|
||||
void plNetMember::Reset()
|
||||
{
|
||||
fFlags=(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==*/
|
||||
#include "plNetMember.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// plNetMember
|
||||
////////////////////////////////////////////////////////
|
||||
plNetMember::plNetMember(plNetApp* na)
|
||||
{
|
||||
Reset();
|
||||
fNetApp=(na);
|
||||
}
|
||||
|
||||
plNetMember::plNetMember()
|
||||
: fNetApp(nil)
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
//
|
||||
// doesn't remove from session, just resets to initial state
|
||||
//
|
||||
void plNetMember::Reset()
|
||||
{
|
||||
fFlags=(0);
|
||||
}
|
@ -1,88 +1,88 @@
|
||||
/*==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 PLNETMEMBER_inc
|
||||
#define PLNETMEMBER_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsUtils.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
|
||||
class plNetApp;
|
||||
class plNetGenericServer;
|
||||
////////////////////////////////
|
||||
// A participant (peer) who we can send and recv messages from/to
|
||||
////////////////////////////////
|
||||
class plNetMember : public plCreatable
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
kWaitingForLinkQuery = 1<<0, // only used server side
|
||||
kIndirectMember = 1<<1, // this guy is behind a firewall of some sort
|
||||
kRequestP2P = 1<<2, // wants to play peer to peer
|
||||
kWaitingForChallengeResponse = 1<<3, // waiting for client response
|
||||
kIsServer = 1<<4, // used by transport member
|
||||
kAllowTimeOut = 1<<5, // used by gameserver
|
||||
};
|
||||
|
||||
protected:
|
||||
friend class plNetGenericServer;
|
||||
friend class plNetClientMgr;
|
||||
friend class plNetClientMsgHandler;
|
||||
friend class plNetClientGamePlayMsgHandler;
|
||||
|
||||
Int32 fPeerID; // low-level netPlayer object for msg send/recv
|
||||
UInt32 fFlags;
|
||||
plNetApp* fNetApp;
|
||||
|
||||
// these calls should be made by the client/server app only,
|
||||
// so they can keep the netCorePeer userData point to the right member
|
||||
virtual ~plNetMember() {}
|
||||
|
||||
public:
|
||||
CLASSNAME_REGISTER( plNetMember );
|
||||
GETINTERFACE_ANY( plNetMember, plCreatable );
|
||||
|
||||
plNetMember();
|
||||
plNetMember(plNetApp* na);
|
||||
|
||||
virtual void Reset(); // doesn't remove from session, just resets to initial state
|
||||
virtual bool IsEqualTo(const plNetMember * other) const = 0;
|
||||
|
||||
// getters
|
||||
Int32 GetPeerID() const { return fPeerID; }
|
||||
UInt32 GetFlags() const { return fFlags; }
|
||||
plNetApp* GetNetApp() { return fNetApp; }
|
||||
virtual std::string AsStdString() const = 0;
|
||||
|
||||
// setters
|
||||
void SetFlags(UInt32 f) { fFlags=f; }
|
||||
void SetNetApp(plNetApp* n) { fNetApp=n; }
|
||||
void SetPeerID(Int32 p) { fPeerID=p; }
|
||||
};
|
||||
|
||||
#endif // PLNETMEMBER_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 PLNETMEMBER_inc
|
||||
#define PLNETMEMBER_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsUtils.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
|
||||
class plNetApp;
|
||||
class plNetGenericServer;
|
||||
////////////////////////////////
|
||||
// A participant (peer) who we can send and recv messages from/to
|
||||
////////////////////////////////
|
||||
class plNetMember : public plCreatable
|
||||
{
|
||||
public:
|
||||
enum Flags
|
||||
{
|
||||
kWaitingForLinkQuery = 1<<0, // only used server side
|
||||
kIndirectMember = 1<<1, // this guy is behind a firewall of some sort
|
||||
kRequestP2P = 1<<2, // wants to play peer to peer
|
||||
kWaitingForChallengeResponse = 1<<3, // waiting for client response
|
||||
kIsServer = 1<<4, // used by transport member
|
||||
kAllowTimeOut = 1<<5, // used by gameserver
|
||||
};
|
||||
|
||||
protected:
|
||||
friend class plNetGenericServer;
|
||||
friend class plNetClientMgr;
|
||||
friend class plNetClientMsgHandler;
|
||||
friend class plNetClientGamePlayMsgHandler;
|
||||
|
||||
Int32 fPeerID; // low-level netPlayer object for msg send/recv
|
||||
UInt32 fFlags;
|
||||
plNetApp* fNetApp;
|
||||
|
||||
// these calls should be made by the client/server app only,
|
||||
// so they can keep the netCorePeer userData point to the right member
|
||||
virtual ~plNetMember() {}
|
||||
|
||||
public:
|
||||
CLASSNAME_REGISTER( plNetMember );
|
||||
GETINTERFACE_ANY( plNetMember, plCreatable );
|
||||
|
||||
plNetMember();
|
||||
plNetMember(plNetApp* na);
|
||||
|
||||
virtual void Reset(); // doesn't remove from session, just resets to initial state
|
||||
virtual bool IsEqualTo(const plNetMember * other) const = 0;
|
||||
|
||||
// getters
|
||||
Int32 GetPeerID() const { return fPeerID; }
|
||||
UInt32 GetFlags() const { return fFlags; }
|
||||
plNetApp* GetNetApp() { return fNetApp; }
|
||||
virtual std::string AsStdString() const = 0;
|
||||
|
||||
// setters
|
||||
void SetFlags(UInt32 f) { fFlags=f; }
|
||||
void SetNetApp(plNetApp* n) { fNetApp=n; }
|
||||
void SetPeerID(Int32 p) { fPeerID=p; }
|
||||
};
|
||||
|
||||
#endif // PLNETMEMBER_inc
|
||||
|
@ -1,80 +1,80 @@
|
||||
/*==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 plNetMsgHandler_inc
|
||||
#define plNetMsgHandler_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsTypes.h" // for nil
|
||||
|
||||
class plNetMessage;
|
||||
class plNetApp;
|
||||
|
||||
#define kMsgSendInterval 0.25f // time between message re-send
|
||||
#define kNetOperationTimeout 10.f // amount of time we try a network operation before complaining
|
||||
|
||||
//
|
||||
// Base msg handler class
|
||||
//
|
||||
class plNetMsgHandler
|
||||
{
|
||||
protected:
|
||||
plNetApp* fNetApp;
|
||||
public:
|
||||
plNetMsgHandler() : fNetApp(nil) {}
|
||||
virtual ~plNetMsgHandler() {}
|
||||
|
||||
void SetNetApp(plNetApp* na) { fNetApp=na; }
|
||||
plNetApp* GetNetApp() { return fNetApp; }
|
||||
|
||||
// return -1 on error, 0 if ok.
|
||||
virtual int ReceiveMsg(plNetMessage*& netMsg) = 0;
|
||||
};
|
||||
|
||||
#define MSG_HANDLER(msgClassName) msgClassName##HandleMsg
|
||||
|
||||
//
|
||||
// Use to declare msg handler fxns in your MsgHandler .h class header
|
||||
//
|
||||
#define MSG_HANDLER_DECL(msgClassName) \
|
||||
virtual int MSG_HANDLER(msgClassName)(plNetMessage*& netMsg);
|
||||
|
||||
//
|
||||
// Use to define msg handler fxns in your MsgHandler .cpp file
|
||||
//
|
||||
#define MSG_HANDLER_DEFN(handlerClassName, msgClassName) \
|
||||
int handlerClassName::MSG_HANDLER(msgClassName)(plNetMessage*& netMsg)
|
||||
|
||||
//
|
||||
// Use in the switch statement in your ReceiveMsg function
|
||||
//
|
||||
#define MSG_HANDLER_CASE(msgClassName) \
|
||||
case CLASS_INDEX_SCOPED(msgClassName): \
|
||||
{ \
|
||||
return MSG_HANDLER(msgClassName)(netMsg); \
|
||||
}
|
||||
|
||||
|
||||
#endif // plNetMsgHandler_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 plNetMsgHandler_inc
|
||||
#define plNetMsgHandler_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsTypes.h" // for nil
|
||||
|
||||
class plNetMessage;
|
||||
class plNetApp;
|
||||
|
||||
#define kMsgSendInterval 0.25f // time between message re-send
|
||||
#define kNetOperationTimeout 10.f // amount of time we try a network operation before complaining
|
||||
|
||||
//
|
||||
// Base msg handler class
|
||||
//
|
||||
class plNetMsgHandler
|
||||
{
|
||||
protected:
|
||||
plNetApp* fNetApp;
|
||||
public:
|
||||
plNetMsgHandler() : fNetApp(nil) {}
|
||||
virtual ~plNetMsgHandler() {}
|
||||
|
||||
void SetNetApp(plNetApp* na) { fNetApp=na; }
|
||||
plNetApp* GetNetApp() { return fNetApp; }
|
||||
|
||||
// return -1 on error, 0 if ok.
|
||||
virtual int ReceiveMsg(plNetMessage*& netMsg) = 0;
|
||||
};
|
||||
|
||||
#define MSG_HANDLER(msgClassName) msgClassName##HandleMsg
|
||||
|
||||
//
|
||||
// Use to declare msg handler fxns in your MsgHandler .h class header
|
||||
//
|
||||
#define MSG_HANDLER_DECL(msgClassName) \
|
||||
virtual int MSG_HANDLER(msgClassName)(plNetMessage*& netMsg);
|
||||
|
||||
//
|
||||
// Use to define msg handler fxns in your MsgHandler .cpp file
|
||||
//
|
||||
#define MSG_HANDLER_DEFN(handlerClassName, msgClassName) \
|
||||
int handlerClassName::MSG_HANDLER(msgClassName)(plNetMessage*& netMsg)
|
||||
|
||||
//
|
||||
// Use in the switch statement in your ReceiveMsg function
|
||||
//
|
||||
#define MSG_HANDLER_CASE(msgClassName) \
|
||||
case CLASS_INDEX_SCOPED(msgClassName): \
|
||||
{ \
|
||||
return MSG_HANDLER(msgClassName)(netMsg); \
|
||||
}
|
||||
|
||||
|
||||
#endif // plNetMsgHandler_inc
|
||||
|
@ -1,248 +1,248 @@
|
||||
/*==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 "hsTypes.h"
|
||||
#include "plNetMsgScreener.h"
|
||||
#include "plCreatableIndex.h"
|
||||
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnMessage/plNotifyMsg.h"
|
||||
#include "pnMessage/plEnableMsg.h"
|
||||
#include "pnMessage/plSetNetGroupIDMsg.h"
|
||||
#include "pnInputCore/plControlEventCodes.h"
|
||||
|
||||
#include "plMessage/plCCRMsg.h"
|
||||
#include "plMessage/plLinkToAgeMsg.h"
|
||||
#include "plMessage/plAvatarMsg.h"
|
||||
#include "plMessage/plInputIfaceMgrMsg.h"
|
||||
#include "plMessage/plInputEventMsg.h"
|
||||
#include "plMessage/plAnimCmdMsg.h"
|
||||
#include "plMessage/plBulletMsg.h"
|
||||
#include "plMessage/plAvCoopMsg.h"
|
||||
#include "plMessage/plParticleUpdateMsg.h"
|
||||
|
||||
#include "pfMessage/pfKIMsg.h"
|
||||
#include "pfMessage/plClothingMsg.h"
|
||||
|
||||
//
|
||||
// say why the msg got rejected
|
||||
//
|
||||
void plNetMsgScreener::IRejectLogMsg(Int16 classIndex, const char* desc, const plNetGameMember* gm) const
|
||||
{
|
||||
DebugMsg("Message %s was rejected, reason:%s, age:%s, client:%s",
|
||||
plFactory::GetNameOfClass(classIndex), desc, IGetAgeName(), IGetSenderName(gm));
|
||||
}
|
||||
|
||||
//
|
||||
// say why the msg got rejected
|
||||
//
|
||||
void plNetMsgScreener::IRejectLogMsg(const plMessage* msg, const char* desc, const plNetGameMember* gm) const
|
||||
{
|
||||
const char* senderName = msg->GetSender() ? msg->GetSender()->GetUoid().GetObjectName() : "?";
|
||||
const char* rcvrName = msg->GetNumReceivers() && msg->GetReceiver(0) ? msg->GetReceiver(0)->GetUoid().GetObjectName() : "?";
|
||||
|
||||
DebugMsg("Message %s was rejected, reason:%s, age:%s, client:%s, msgSndr:%s, msgRcvr:%s",
|
||||
msg->ClassName(), desc, IGetAgeName(), IGetSenderName(gm),
|
||||
senderName, rcvrName);
|
||||
}
|
||||
|
||||
//
|
||||
// Try to accept/reject quickly
|
||||
// the netMsg arg has been peeked except for the stream
|
||||
//
|
||||
plNetMsgScreener::Answer plNetMsgScreener::IAllowMessageType(Int16 classIndex, const plNetGameMember* gm) const
|
||||
{
|
||||
// Check based on baseclass
|
||||
if (plFactory::DerivesFrom(plCCRMessage::Index(), classIndex))
|
||||
{
|
||||
ILogCCRMessage(classIndex, gm);
|
||||
Answer ans=IIsSenderCCR(gm) ? kYes : kNo;
|
||||
if (ans==kNo)
|
||||
{
|
||||
IRejectLogMsg(classIndex, "Not a CCR", gm);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
// Check based on exact type
|
||||
switch(classIndex)
|
||||
{
|
||||
// these are wrapped in their own net msg, so the client will see them this way, but not the server
|
||||
// that's why they check IAmClient() - this is a special case
|
||||
case CLASS_INDEX_SCOPED(plLoadAvatarMsg):
|
||||
case CLASS_INDEX_SCOPED(plLoadCloneMsg):
|
||||
{
|
||||
Answer ans=IAmClient() ? kYes : kNo;
|
||||
if (ans==kNo)
|
||||
{
|
||||
IRejectLogMsg(classIndex, "Only seen in native form on client", gm);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
// definitely yes
|
||||
case CLASS_INDEX_SCOPED(pfMarkerMsg):
|
||||
case CLASS_INDEX_SCOPED(plBulletMsg):
|
||||
case CLASS_INDEX_SCOPED(plNotifyMsg):
|
||||
case CLASS_INDEX_SCOPED(plSetNetGroupIDMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvCoopMsg):
|
||||
case CLASS_INDEX_SCOPED(plClothingMsg):
|
||||
case CLASS_INDEX_SCOPED(plEnableMsg):
|
||||
case CLASS_INDEX_SCOPED(plLinkToAgeMsg):
|
||||
return kYes;
|
||||
|
||||
// definitely yes or no (based on whether sender is a CCR)
|
||||
case CLASS_INDEX_SCOPED(plWarpMsg):
|
||||
{
|
||||
Answer ans=IIsSenderCCR(gm) ? kYes : kNo;
|
||||
if (ans==kNo)
|
||||
{
|
||||
IRejectLogMsg(classIndex, "Not a CCR", gm);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
// conditionally yes, requires further validation of msg contents
|
||||
case CLASS_INDEX_SCOPED(plAnimCmdMsg):
|
||||
case CLASS_INDEX_SCOPED(pfKIMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvTaskMsg):
|
||||
case CLASS_INDEX_SCOPED(plLinkEffectsTriggerMsg):
|
||||
case CLASS_INDEX_SCOPED(plInputIfaceMgrMsg):
|
||||
case CLASS_INDEX_SCOPED(plParticleKillMsg):
|
||||
case CLASS_INDEX_SCOPED(plParticleTransferMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvatarInputStateMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvBrainGenericMsg):
|
||||
case CLASS_INDEX_SCOPED(plMultistageModMsg):
|
||||
return kMaybe;
|
||||
|
||||
// definitely no
|
||||
default:
|
||||
IRejectLogMsg(classIndex, "Illegal msg class", gm);
|
||||
return kNo;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Message may be allowed if contents or conditions are met
|
||||
//
|
||||
bool plNetMsgScreener::IValidateMessage(const plMessage* msg, const plNetGameMember* gm) const
|
||||
{
|
||||
if (!msg)
|
||||
return true;
|
||||
|
||||
switch(msg->ClassIndex())
|
||||
{
|
||||
// Only chat KI msgs are allowed.
|
||||
// Admin/system-wide chat msgs are only allowed by CCRs
|
||||
case CLASS_INDEX_SCOPED(pfKIMsg):
|
||||
{
|
||||
const pfKIMsg* km = pfKIMsg::ConvertNoRef(msg);
|
||||
if (km->GetCommand() != pfKIMsg::kHACKChatMsg)
|
||||
{
|
||||
IRejectLogMsg(msg, "Non-chat KI msg", gm);
|
||||
return false;
|
||||
}
|
||||
|
||||
ILogChatMessage(msg, gm);
|
||||
if (km->GetFlags() & pfKIMsg::kAdminMsg)
|
||||
{
|
||||
if (!IIsSenderCCR(gm))
|
||||
{
|
||||
IRejectLogMsg(msg, "Must be a CCR to send an Admin KI msg", gm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Allowed for local avatar
|
||||
case CLASS_INDEX_SCOPED(plAvTaskMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvatarInputStateMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvBrainGenericMsg):
|
||||
case CLASS_INDEX_SCOPED(plMultistageModMsg):
|
||||
{
|
||||
bool ret=IIsLocalArmatureModKey(msg->GetReceiver(0), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Allowed for local avatar
|
||||
case CLASS_INDEX_SCOPED(plLinkEffectsTriggerMsg):
|
||||
{
|
||||
const plLinkEffectsTriggerMsg* linkMsg = plLinkEffectsTriggerMsg::ConvertNoRef(msg);
|
||||
bool ret=IIsLocalAvatarKey(linkMsg->GetLinkKey(), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Allowed for local avatar
|
||||
case CLASS_INDEX_SCOPED(plInputIfaceMgrMsg):
|
||||
{
|
||||
const plInputIfaceMgrMsg* iMsg = plInputIfaceMgrMsg::ConvertNoRef(msg);
|
||||
bool ret=IIsLocalAvatarKey(iMsg->GetAvKey(), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case CLASS_INDEX_SCOPED(plParticleKillMsg):
|
||||
case CLASS_INDEX_SCOPED(plParticleTransferMsg):
|
||||
{
|
||||
bool ret = IIsLocalAvatarKey(msg->GetReceiver(0), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case CLASS_INDEX_SCOPED(plAnimCmdMsg):
|
||||
{
|
||||
const plAnimCmdMsg *animMsg = plAnimCmdMsg::ConvertNoRef(msg);
|
||||
bool ret = (animMsg->GetNumCallbacks() == 0);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg has callbacks", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*==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 "hsTypes.h"
|
||||
#include "plNetMsgScreener.h"
|
||||
#include "plCreatableIndex.h"
|
||||
|
||||
#include "pnNetCommon/plNetApp.h"
|
||||
#include "pnMessage/plNotifyMsg.h"
|
||||
#include "pnMessage/plEnableMsg.h"
|
||||
#include "pnMessage/plSetNetGroupIDMsg.h"
|
||||
#include "pnInputCore/plControlEventCodes.h"
|
||||
|
||||
#include "plMessage/plCCRMsg.h"
|
||||
#include "plMessage/plLinkToAgeMsg.h"
|
||||
#include "plMessage/plAvatarMsg.h"
|
||||
#include "plMessage/plInputIfaceMgrMsg.h"
|
||||
#include "plMessage/plInputEventMsg.h"
|
||||
#include "plMessage/plAnimCmdMsg.h"
|
||||
#include "plMessage/plBulletMsg.h"
|
||||
#include "plMessage/plAvCoopMsg.h"
|
||||
#include "plMessage/plParticleUpdateMsg.h"
|
||||
|
||||
#include "pfMessage/pfKIMsg.h"
|
||||
#include "pfMessage/plClothingMsg.h"
|
||||
|
||||
//
|
||||
// say why the msg got rejected
|
||||
//
|
||||
void plNetMsgScreener::IRejectLogMsg(Int16 classIndex, const char* desc, const plNetGameMember* gm) const
|
||||
{
|
||||
DebugMsg("Message %s was rejected, reason:%s, age:%s, client:%s",
|
||||
plFactory::GetNameOfClass(classIndex), desc, IGetAgeName(), IGetSenderName(gm));
|
||||
}
|
||||
|
||||
//
|
||||
// say why the msg got rejected
|
||||
//
|
||||
void plNetMsgScreener::IRejectLogMsg(const plMessage* msg, const char* desc, const plNetGameMember* gm) const
|
||||
{
|
||||
const char* senderName = msg->GetSender() ? msg->GetSender()->GetUoid().GetObjectName() : "?";
|
||||
const char* rcvrName = msg->GetNumReceivers() && msg->GetReceiver(0) ? msg->GetReceiver(0)->GetUoid().GetObjectName() : "?";
|
||||
|
||||
DebugMsg("Message %s was rejected, reason:%s, age:%s, client:%s, msgSndr:%s, msgRcvr:%s",
|
||||
msg->ClassName(), desc, IGetAgeName(), IGetSenderName(gm),
|
||||
senderName, rcvrName);
|
||||
}
|
||||
|
||||
//
|
||||
// Try to accept/reject quickly
|
||||
// the netMsg arg has been peeked except for the stream
|
||||
//
|
||||
plNetMsgScreener::Answer plNetMsgScreener::IAllowMessageType(Int16 classIndex, const plNetGameMember* gm) const
|
||||
{
|
||||
// Check based on baseclass
|
||||
if (plFactory::DerivesFrom(plCCRMessage::Index(), classIndex))
|
||||
{
|
||||
ILogCCRMessage(classIndex, gm);
|
||||
Answer ans=IIsSenderCCR(gm) ? kYes : kNo;
|
||||
if (ans==kNo)
|
||||
{
|
||||
IRejectLogMsg(classIndex, "Not a CCR", gm);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
// Check based on exact type
|
||||
switch(classIndex)
|
||||
{
|
||||
// these are wrapped in their own net msg, so the client will see them this way, but not the server
|
||||
// that's why they check IAmClient() - this is a special case
|
||||
case CLASS_INDEX_SCOPED(plLoadAvatarMsg):
|
||||
case CLASS_INDEX_SCOPED(plLoadCloneMsg):
|
||||
{
|
||||
Answer ans=IAmClient() ? kYes : kNo;
|
||||
if (ans==kNo)
|
||||
{
|
||||
IRejectLogMsg(classIndex, "Only seen in native form on client", gm);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
// definitely yes
|
||||
case CLASS_INDEX_SCOPED(pfMarkerMsg):
|
||||
case CLASS_INDEX_SCOPED(plBulletMsg):
|
||||
case CLASS_INDEX_SCOPED(plNotifyMsg):
|
||||
case CLASS_INDEX_SCOPED(plSetNetGroupIDMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvCoopMsg):
|
||||
case CLASS_INDEX_SCOPED(plClothingMsg):
|
||||
case CLASS_INDEX_SCOPED(plEnableMsg):
|
||||
case CLASS_INDEX_SCOPED(plLinkToAgeMsg):
|
||||
return kYes;
|
||||
|
||||
// definitely yes or no (based on whether sender is a CCR)
|
||||
case CLASS_INDEX_SCOPED(plWarpMsg):
|
||||
{
|
||||
Answer ans=IIsSenderCCR(gm) ? kYes : kNo;
|
||||
if (ans==kNo)
|
||||
{
|
||||
IRejectLogMsg(classIndex, "Not a CCR", gm);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
// conditionally yes, requires further validation of msg contents
|
||||
case CLASS_INDEX_SCOPED(plAnimCmdMsg):
|
||||
case CLASS_INDEX_SCOPED(pfKIMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvTaskMsg):
|
||||
case CLASS_INDEX_SCOPED(plLinkEffectsTriggerMsg):
|
||||
case CLASS_INDEX_SCOPED(plInputIfaceMgrMsg):
|
||||
case CLASS_INDEX_SCOPED(plParticleKillMsg):
|
||||
case CLASS_INDEX_SCOPED(plParticleTransferMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvatarInputStateMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvBrainGenericMsg):
|
||||
case CLASS_INDEX_SCOPED(plMultistageModMsg):
|
||||
return kMaybe;
|
||||
|
||||
// definitely no
|
||||
default:
|
||||
IRejectLogMsg(classIndex, "Illegal msg class", gm);
|
||||
return kNo;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Message may be allowed if contents or conditions are met
|
||||
//
|
||||
bool plNetMsgScreener::IValidateMessage(const plMessage* msg, const plNetGameMember* gm) const
|
||||
{
|
||||
if (!msg)
|
||||
return true;
|
||||
|
||||
switch(msg->ClassIndex())
|
||||
{
|
||||
// Only chat KI msgs are allowed.
|
||||
// Admin/system-wide chat msgs are only allowed by CCRs
|
||||
case CLASS_INDEX_SCOPED(pfKIMsg):
|
||||
{
|
||||
const pfKIMsg* km = pfKIMsg::ConvertNoRef(msg);
|
||||
if (km->GetCommand() != pfKIMsg::kHACKChatMsg)
|
||||
{
|
||||
IRejectLogMsg(msg, "Non-chat KI msg", gm);
|
||||
return false;
|
||||
}
|
||||
|
||||
ILogChatMessage(msg, gm);
|
||||
if (km->GetFlags() & pfKIMsg::kAdminMsg)
|
||||
{
|
||||
if (!IIsSenderCCR(gm))
|
||||
{
|
||||
IRejectLogMsg(msg, "Must be a CCR to send an Admin KI msg", gm);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
||||
// Allowed for local avatar
|
||||
case CLASS_INDEX_SCOPED(plAvTaskMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvatarInputStateMsg):
|
||||
case CLASS_INDEX_SCOPED(plAvBrainGenericMsg):
|
||||
case CLASS_INDEX_SCOPED(plMultistageModMsg):
|
||||
{
|
||||
bool ret=IIsLocalArmatureModKey(msg->GetReceiver(0), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Allowed for local avatar
|
||||
case CLASS_INDEX_SCOPED(plLinkEffectsTriggerMsg):
|
||||
{
|
||||
const plLinkEffectsTriggerMsg* linkMsg = plLinkEffectsTriggerMsg::ConvertNoRef(msg);
|
||||
bool ret=IIsLocalAvatarKey(linkMsg->GetLinkKey(), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Allowed for local avatar
|
||||
case CLASS_INDEX_SCOPED(plInputIfaceMgrMsg):
|
||||
{
|
||||
const plInputIfaceMgrMsg* iMsg = plInputIfaceMgrMsg::ConvertNoRef(msg);
|
||||
bool ret=IIsLocalAvatarKey(iMsg->GetAvKey(), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case CLASS_INDEX_SCOPED(plParticleKillMsg):
|
||||
case CLASS_INDEX_SCOPED(plParticleTransferMsg):
|
||||
{
|
||||
bool ret = IIsLocalAvatarKey(msg->GetReceiver(0), gm);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg must refer to local avatar", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
|
||||
case CLASS_INDEX_SCOPED(plAnimCmdMsg):
|
||||
{
|
||||
const plAnimCmdMsg *animMsg = plAnimCmdMsg::ConvertNoRef(msg);
|
||||
bool ret = (animMsg->GetNumCallbacks() == 0);
|
||||
if (!ret)
|
||||
{
|
||||
IRejectLogMsg(msg, "msg has callbacks", gm);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,65 +1,65 @@
|
||||
/*==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 plNetMsgScreener_h
|
||||
#define plNetMsgScreener_h
|
||||
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "plStatusLog/plLoggable.h"
|
||||
|
||||
//
|
||||
// Class which decides what game messages are allowed to be sent to the server.
|
||||
// Used both client and server-side.
|
||||
//
|
||||
class plNetGameMember;
|
||||
class plMessage;
|
||||
class plNetMessage;
|
||||
class pfKIMsg;
|
||||
class plNetMsgScreener : public plLoggable
|
||||
{
|
||||
protected:
|
||||
enum Answer
|
||||
{
|
||||
kMaybe = -1,
|
||||
kNo,
|
||||
kYes
|
||||
};
|
||||
virtual const char* IGetSenderName(const plNetGameMember* gm) const = 0;
|
||||
virtual const char* IGetAgeName() const = 0;
|
||||
virtual bool IIsSenderCCR(const plNetGameMember* gm=nil) const = 0;
|
||||
virtual bool IIsLocalAvatarKey(plKey key, const plNetGameMember* gm) const = 0;
|
||||
virtual bool IIsLocalArmatureModKey(plKey key, const plNetGameMember* gm) const { return true; }
|
||||
|
||||
virtual void ILogChatMessage(const plMessage* msg_, const plNetGameMember* gm) const {}
|
||||
virtual void ILogCCRMessage(Int16 classIndex, const plNetGameMember* gm) const {}
|
||||
|
||||
Answer IAllowMessageType(Int16 classIndex, const plNetGameMember* gm=nil) const;
|
||||
bool IValidateMessage(const plMessage* msg, const plNetGameMember* gm=nil) const;
|
||||
void IRejectLogMsg(Int16 classIndex, const char* desc, const plNetGameMember* gm) const;
|
||||
void IRejectLogMsg(const plMessage* msg, const char* desc, const plNetGameMember* gm) const;
|
||||
virtual bool IAmClient() const = 0;
|
||||
};
|
||||
|
||||
#endif // plNetMsgScreener_h
|
||||
/*==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 plNetMsgScreener_h
|
||||
#define plNetMsgScreener_h
|
||||
|
||||
#include "pnKeyedObject/plKey.h"
|
||||
#include "plStatusLog/plLoggable.h"
|
||||
|
||||
//
|
||||
// Class which decides what game messages are allowed to be sent to the server.
|
||||
// Used both client and server-side.
|
||||
//
|
||||
class plNetGameMember;
|
||||
class plMessage;
|
||||
class plNetMessage;
|
||||
class pfKIMsg;
|
||||
class plNetMsgScreener : public plLoggable
|
||||
{
|
||||
protected:
|
||||
enum Answer
|
||||
{
|
||||
kMaybe = -1,
|
||||
kNo,
|
||||
kYes
|
||||
};
|
||||
virtual const char* IGetSenderName(const plNetGameMember* gm) const = 0;
|
||||
virtual const char* IGetAgeName() const = 0;
|
||||
virtual bool IIsSenderCCR(const plNetGameMember* gm=nil) const = 0;
|
||||
virtual bool IIsLocalAvatarKey(plKey key, const plNetGameMember* gm) const = 0;
|
||||
virtual bool IIsLocalArmatureModKey(plKey key, const plNetGameMember* gm) const { return true; }
|
||||
|
||||
virtual void ILogChatMessage(const plMessage* msg_, const plNetGameMember* gm) const {}
|
||||
virtual void ILogCCRMessage(Int16 classIndex, const plNetGameMember* gm) const {}
|
||||
|
||||
Answer IAllowMessageType(Int16 classIndex, const plNetGameMember* gm=nil) const;
|
||||
bool IValidateMessage(const plMessage* msg, const plNetGameMember* gm=nil) const;
|
||||
void IRejectLogMsg(Int16 classIndex, const char* desc, const plNetGameMember* gm) const;
|
||||
void IRejectLogMsg(const plMessage* msg, const char* desc, const plNetGameMember* gm) const;
|
||||
virtual bool IAmClient() const = 0;
|
||||
};
|
||||
|
||||
#endif // plNetMsgScreener_h
|
File diff suppressed because it is too large
Load Diff
@ -1,334 +1,334 @@
|
||||
/*==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 plNetServerSessionInfo_h_inc
|
||||
#define plNetServerSessionInfo_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
#include "pnNetCommon/plNetServers.h"
|
||||
#include "plNetCommon/plSpawnPointInfo.h"
|
||||
#include "plUUID/plUUID.h"
|
||||
|
||||
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
class plVaultAgeInfoNode;
|
||||
class plVaultAgeLinkNode;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Holds info that describes an age
|
||||
|
||||
class plAgeInfoStruct : public plCreatable
|
||||
{
|
||||
mutable UInt8 fFlags;
|
||||
|
||||
// Age dataset name "Neighborhood"
|
||||
std::string fAgeFilename;
|
||||
|
||||
// Age string ID "Bevin"
|
||||
std::string fAgeInstanceName;
|
||||
|
||||
// Age guid. Same as game server guid.
|
||||
plUUID fAgeInstanceGuid;
|
||||
|
||||
// User-defined age name: "My Teledahn"
|
||||
std::string fAgeUserDefinedName;
|
||||
|
||||
// User-defined age description "This is Joe's Neighborhood"
|
||||
std::string fAgeDescription;
|
||||
|
||||
// A modifier to user-defined name to make it unique in gui lists.
|
||||
// Assigned by vault server.
|
||||
Int32 fAgeSequenceNumber;
|
||||
|
||||
// The language of the client that created this age
|
||||
Int32 fAgeLanguage;
|
||||
|
||||
mutable std::string fDisplayName;
|
||||
|
||||
enum
|
||||
{
|
||||
kHasAgeFilename = 1<<0,
|
||||
kHasAgeInstanceName = 1<<1,
|
||||
kHasAgeInstanceGuid = 1<<2,
|
||||
kHasAgeUserDefinedName = 1<<3,
|
||||
kHasAgeSequenceNumber = 1<<4,
|
||||
kHasAgeDescription = 1<<5,
|
||||
kHasAgeLanguage = 1<<6,
|
||||
};
|
||||
|
||||
void SetFlag( UInt8 bit, bool on=true ) const { (on)?fFlags|=bit:fFlags&=~bit;}
|
||||
void ClearFlag( UInt8 bit ) { fFlags&=~bit;}
|
||||
bool IsFlagSet( UInt8 bit ) const { return (fFlags&bit)!=0;}
|
||||
|
||||
public:
|
||||
plAgeInfoStruct()
|
||||
: fFlags( 0 )
|
||||
, fAgeSequenceNumber( 0 )
|
||||
, fAgeLanguage( -1 )
|
||||
{}
|
||||
|
||||
CLASSNAME_REGISTER( plAgeInfoStruct );
|
||||
GETINTERFACE_ANY( plAgeInfoStruct, plCreatable );
|
||||
|
||||
void Clear();
|
||||
void UpdateFlags() const;
|
||||
void CopyFrom( const plAgeInfoStruct * other ) { *this=*other; }
|
||||
void CopyFrom( const plVaultAgeInfoNode * node );
|
||||
void CopyFrom(const struct NetAgeInfo & info);
|
||||
bool IsEqualTo( const plAgeInfoStruct * other ) const;
|
||||
|
||||
const char * GetAgeFilename() const { return fAgeFilename.c_str(); }
|
||||
const char * GetAgeInstanceName() const { return fAgeInstanceName.c_str(); }
|
||||
const plUUID * GetAgeInstanceGuid() const { return &fAgeInstanceGuid; }
|
||||
const char * GetAgeUserDefinedName() const { return fAgeUserDefinedName.c_str(); }
|
||||
const char * GetAgeDescription() const { return fAgeDescription.c_str(); }
|
||||
UInt32 GetAgeSequenceNumber() const { return fAgeSequenceNumber; }
|
||||
UInt32 GetAgeLanguage() const { return fAgeLanguage; }
|
||||
|
||||
void SetAgeFilename( const char * v );
|
||||
void SetAgeInstanceName( const char * v );
|
||||
void SetAgeInstanceGuid( const plUUID * v );
|
||||
void SetAgeUserDefinedName( const char * v );
|
||||
void SetAgeDescription( const char * v );
|
||||
void SetAgeSequenceNumber( UInt32 v );
|
||||
void SetAgeLanguage( UInt32 v );
|
||||
|
||||
bool HasAgeFilename() const { return IsFlagSet( kHasAgeFilename ); }
|
||||
bool HasAgeInstanceName() const { return IsFlagSet( kHasAgeInstanceName ); }
|
||||
bool HasAgeInstanceGuid() const { return IsFlagSet( kHasAgeInstanceGuid ) && fAgeInstanceGuid.IsSet(); }
|
||||
bool HasAgeUserDefinedName() const { return IsFlagSet( kHasAgeUserDefinedName ); }
|
||||
bool HasAgeDescription() const { return IsFlagSet( kHasAgeDescription ); }
|
||||
bool HasAgeSequenceNumber() const { return IsFlagSet( kHasAgeSequenceNumber ); }
|
||||
bool HasAgeLanguage() const { return IsFlagSet( kHasAgeLanguage ); }
|
||||
|
||||
void Read( hsStream * s, hsResMgr* );
|
||||
void Write( hsStream * s, hsResMgr* );
|
||||
|
||||
const char * GetDisplayName() const;
|
||||
|
||||
std::string AsStdString() const;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class plAgeLinkStruct : public plCreatable
|
||||
{
|
||||
UInt16 fFlags;
|
||||
|
||||
// Where we want to link.
|
||||
plAgeInfoStruct fAgeInfo;
|
||||
|
||||
// The linking rule to use. See plNetCommon::LinkingRules
|
||||
Int8 fLinkingRules;
|
||||
|
||||
// Where to spawn avatar when we load the age specified in fAgeInfo
|
||||
plSpawnPointInfo fSpawnPoint;
|
||||
|
||||
// Override PLS/MCP load balancing rules for CCRs.
|
||||
UInt8 fAmCCR;
|
||||
|
||||
// If this is a child age link, who is the parent
|
||||
// ...Age dataset name like "Neighborhood"
|
||||
std::string fParentAgeFilename;
|
||||
|
||||
enum
|
||||
{
|
||||
kHasAgeInfo = 1<<0,
|
||||
kHasLinkingRules = 1<<1,
|
||||
kHasSpawnPt_DEAD = 1<<2,
|
||||
kHasSpawnPt_DEAD2 = 1<<3,
|
||||
kHasAmCCR = 1<<4,
|
||||
kHasSpawnPt = 1<<5,
|
||||
kHasParentAgeFilename = 1<<6,
|
||||
};
|
||||
|
||||
void SetFlag( UInt16 bit, bool on=true ) { (on)?fFlags|=bit:fFlags&=~bit;}
|
||||
void ClearFlag( UInt16 bit ) { fFlags&=~bit;}
|
||||
bool IsFlagSet( UInt16 bit ) const { return (fFlags&bit)!=0;}
|
||||
|
||||
public:
|
||||
plAgeLinkStruct();
|
||||
CLASSNAME_REGISTER( plAgeLinkStruct );
|
||||
GETINTERFACE_ANY( plAgeLinkStruct, plCreatable );
|
||||
|
||||
plAgeInfoStruct * GetAgeInfo() { return &fAgeInfo; }
|
||||
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
|
||||
|
||||
const char * GetParentAgeFilename() const { return fParentAgeFilename.c_str(); }
|
||||
void SetParentAgeFilename( const char * v );
|
||||
|
||||
void CopyFrom( const plAgeLinkStruct * other );
|
||||
void CopyFrom( const plVaultAgeLinkNode * node );
|
||||
bool IsEqualTo( const plAgeLinkStruct * other ) const;
|
||||
void Clear();
|
||||
|
||||
bool HasAgeInfo() const { return IsFlagSet( kHasAgeInfo ); }
|
||||
bool HasLinkingRules() const { return IsFlagSet( kHasLinkingRules ); }
|
||||
bool HasSpawnPt() const { return IsFlagSet( kHasSpawnPt ); }
|
||||
bool HasAmCCR() const { return IsFlagSet( kHasAmCCR ); }
|
||||
bool HasParentAgeFilename() const { return IsFlagSet( kHasParentAgeFilename ); }
|
||||
|
||||
void SetLinkingRules( int v ) { SetFlag( kHasLinkingRules ); fLinkingRules=v; }
|
||||
int GetLinkingRules() const { return fLinkingRules; }
|
||||
void SetSpawnPoint( const plSpawnPointInfo & point ) { SetFlag( kHasSpawnPt ); fSpawnPoint=point; }
|
||||
plSpawnPointInfo & SpawnPoint() { return fSpawnPoint; }
|
||||
const plSpawnPointInfo & SpawnPoint() const { return fSpawnPoint; }
|
||||
void SetAmCCR( bool v ) { SetFlag( kHasAmCCR ); fAmCCR=v?1:0; }
|
||||
bool GetAmCCR() const { return fAmCCR!=0; }
|
||||
|
||||
void Read( hsStream * s, hsResMgr* );
|
||||
void Write( hsStream * s, hsResMgr* );
|
||||
|
||||
std::string AsStdString() const;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Holds info that describes a server session
|
||||
//
|
||||
|
||||
class plNetServerSessionInfo : public plCreatable
|
||||
{
|
||||
UInt8 fFlags;
|
||||
std::string fServerName;
|
||||
UInt8 fServerType;
|
||||
std::string fServerAddr;
|
||||
UInt16 fServerPort;
|
||||
plUUID fServerGuid;
|
||||
|
||||
enum
|
||||
{
|
||||
kHasServerName = 1<<0,
|
||||
kHasServerType = 1<<1,
|
||||
kHasServerAddr = 1<<2,
|
||||
kHasServerPort = 1<<3,
|
||||
kHasServerGuid = 1<<4,
|
||||
};
|
||||
|
||||
void SetFlag( UInt8 bit ) { fFlags|=bit;}
|
||||
void ClearFlag( UInt8 bit ) { fFlags&=~bit;}
|
||||
bool IsFlagSet( UInt8 bit ) const { return (fFlags&bit)!=0;}
|
||||
|
||||
public:
|
||||
plNetServerSessionInfo()
|
||||
: fServerType(plNetServerConstants::kInvalidLo)
|
||||
, fServerPort(0)
|
||||
, fFlags(0)
|
||||
{}
|
||||
CLASSNAME_REGISTER( plNetServerSessionInfo );
|
||||
GETINTERFACE_ANY( plNetServerSessionInfo, plCreatable );
|
||||
|
||||
void SetServerName(const char * val);
|
||||
void SetServerType(UInt8 val);
|
||||
void SetServerAddr(const char * val);
|
||||
void SetServerPort(UInt16 val);
|
||||
void SetServerGuid(const plUUID * val);
|
||||
void CopyServerGuid(const plUUID & val);
|
||||
|
||||
const char * GetServerName() const { return fServerName.c_str();}
|
||||
UInt8 GetServerType() const { return fServerType;}
|
||||
const char * GetServerAddr() const { return fServerAddr.c_str(); }
|
||||
UInt16 GetServerPort() const { return fServerPort; }
|
||||
const plUUID *GetServerGuid() const { return &fServerGuid; }
|
||||
plUUID * GetServerGuid() { return &fServerGuid; }
|
||||
|
||||
bool HasServerName() const { return IsFlagSet(kHasServerName);}
|
||||
bool HasServerType() const { return IsFlagSet(kHasServerType);}
|
||||
bool HasServerAddr() const { return IsFlagSet(kHasServerAddr);}
|
||||
bool HasServerPort() const { return IsFlagSet(kHasServerPort);}
|
||||
bool HasServerGuid() const { return IsFlagSet(kHasServerGuid);}
|
||||
bool IsFullyQualified() const
|
||||
{
|
||||
return
|
||||
IsFlagSet(kHasServerName)&&
|
||||
IsFlagSet(kHasServerType)&&
|
||||
IsFlagSet(kHasServerAddr)&&
|
||||
IsFlagSet(kHasServerPort)&&
|
||||
IsFlagSet(kHasServerGuid);
|
||||
}
|
||||
|
||||
void Clear();
|
||||
void CopyFrom(const plNetServerSessionInfo * other);
|
||||
bool IsEqualTo(const plNetServerSessionInfo * other) const;
|
||||
virtual std::string AsStdString() const;
|
||||
virtual std::string AsLogString() const;
|
||||
|
||||
void Read(hsStream* s, hsResMgr* mgr=nil);
|
||||
void Write(hsStream* s, hsResMgr* mgr=nil);
|
||||
|
||||
// WriteVersion writes the current version of this creatable and ReadVersion will read in
|
||||
// any previous version.
|
||||
virtual void ReadVersion(hsStream* s, hsResMgr* mgr);
|
||||
virtual void WriteVersion(hsStream* s, hsResMgr* mgr);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
//class plVaultAgeInfoNode;
|
||||
//class plAgeLinkingInfo : public plCreatable
|
||||
//{
|
||||
// int fLinkingRules;
|
||||
// UInt32 fPlayerID;
|
||||
// hsBool8 fSuperUser;
|
||||
// mutable plAgeInfoStruct fAgeInfo;
|
||||
// mutable plNetServerSessionInfo fServerInfo;
|
||||
//
|
||||
//public:
|
||||
// plAgeLinkingInfo();
|
||||
//
|
||||
// CLASSNAME_REGISTER( plAgeLinkingInfo );
|
||||
// GETINTERFACE_ANY( plAgeLinkingInfo, plCreatable );
|
||||
//
|
||||
// int GetLinkingRules( void ) const { return fLinkingRules;}
|
||||
// void SetLinkingRules( int v ) { fLinkingRules=v;}
|
||||
// UInt32 GetPlayerID( void ) const { return fPlayerID;}
|
||||
// void SetPlayerID( UInt32 v ) { fPlayerID=v;}
|
||||
// void SetSuperUser(bool b) { fSuperUser=b; }
|
||||
// bool GetSuperUser() const { return fSuperUser ? true : false; }
|
||||
//
|
||||
// plAgeInfoStruct * GetAgeInfo();
|
||||
// const plAgeInfoStruct * GetAgeInfo() const;
|
||||
//
|
||||
// // initializes info with age name and guid for you.
|
||||
// plNetServerSessionInfo * GetServerInfo();
|
||||
// const plNetServerSessionInfo * GetServerInfo() const;
|
||||
// const plNetServerSessionInfo * AsServerInfo() const;
|
||||
//
|
||||
// void Clear( void );
|
||||
// void CopyFrom( const plAgeLinkingInfo * other );
|
||||
// void CopyFrom( const plVaultAgeInfoNode * node );
|
||||
// void CopyFrom( const plNetServerSessionInfo * info );
|
||||
// void CopyFrom( const plAgeInfoStruct * info );
|
||||
//
|
||||
// void Read(hsStream* s, hsResMgr* mgr=nil);
|
||||
// void Write(hsStream* s, hsResMgr* mgr=nil);
|
||||
//
|
||||
// std::string AsStdString() const;
|
||||
//};
|
||||
|
||||
#endif // plNetServerSessionInfo_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 plNetServerSessionInfo_h_inc
|
||||
#define plNetServerSessionInfo_h_inc
|
||||
|
||||
#include "hsTypes.h"
|
||||
#include "hsStlUtils.h"
|
||||
#include "pnFactory/plCreatable.h"
|
||||
#include "pnNetCommon/plNetServers.h"
|
||||
#include "plNetCommon/plSpawnPointInfo.h"
|
||||
#include "plUUID/plUUID.h"
|
||||
|
||||
|
||||
class hsStream;
|
||||
class hsResMgr;
|
||||
class plVaultAgeInfoNode;
|
||||
class plVaultAgeLinkNode;
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// Holds info that describes an age
|
||||
|
||||
class plAgeInfoStruct : public plCreatable
|
||||
{
|
||||
mutable UInt8 fFlags;
|
||||
|
||||
// Age dataset name "Neighborhood"
|
||||
std::string fAgeFilename;
|
||||
|
||||
// Age string ID "Bevin"
|
||||
std::string fAgeInstanceName;
|
||||
|
||||
// Age guid. Same as game server guid.
|
||||
plUUID fAgeInstanceGuid;
|
||||
|
||||
// User-defined age name: "My Teledahn"
|
||||
std::string fAgeUserDefinedName;
|
||||
|
||||
// User-defined age description "This is Joe's Neighborhood"
|
||||
std::string fAgeDescription;
|
||||
|
||||
// A modifier to user-defined name to make it unique in gui lists.
|
||||
// Assigned by vault server.
|
||||
Int32 fAgeSequenceNumber;
|
||||
|
||||
// The language of the client that created this age
|
||||
Int32 fAgeLanguage;
|
||||
|
||||
mutable std::string fDisplayName;
|
||||
|
||||
enum
|
||||
{
|
||||
kHasAgeFilename = 1<<0,
|
||||
kHasAgeInstanceName = 1<<1,
|
||||
kHasAgeInstanceGuid = 1<<2,
|
||||
kHasAgeUserDefinedName = 1<<3,
|
||||
kHasAgeSequenceNumber = 1<<4,
|
||||
kHasAgeDescription = 1<<5,
|
||||
kHasAgeLanguage = 1<<6,
|
||||
};
|
||||
|
||||
void SetFlag( UInt8 bit, bool on=true ) const { (on)?fFlags|=bit:fFlags&=~bit;}
|
||||
void ClearFlag( UInt8 bit ) { fFlags&=~bit;}
|
||||
bool IsFlagSet( UInt8 bit ) const { return (fFlags&bit)!=0;}
|
||||
|
||||
public:
|
||||
plAgeInfoStruct()
|
||||
: fFlags( 0 )
|
||||
, fAgeSequenceNumber( 0 )
|
||||
, fAgeLanguage( -1 )
|
||||
{}
|
||||
|
||||
CLASSNAME_REGISTER( plAgeInfoStruct );
|
||||
GETINTERFACE_ANY( plAgeInfoStruct, plCreatable );
|
||||
|
||||
void Clear();
|
||||
void UpdateFlags() const;
|
||||
void CopyFrom( const plAgeInfoStruct * other ) { *this=*other; }
|
||||
void CopyFrom( const plVaultAgeInfoNode * node );
|
||||
void CopyFrom(const struct NetAgeInfo & info);
|
||||
bool IsEqualTo( const plAgeInfoStruct * other ) const;
|
||||
|
||||
const char * GetAgeFilename() const { return fAgeFilename.c_str(); }
|
||||
const char * GetAgeInstanceName() const { return fAgeInstanceName.c_str(); }
|
||||
const plUUID * GetAgeInstanceGuid() const { return &fAgeInstanceGuid; }
|
||||
const char * GetAgeUserDefinedName() const { return fAgeUserDefinedName.c_str(); }
|
||||
const char * GetAgeDescription() const { return fAgeDescription.c_str(); }
|
||||
UInt32 GetAgeSequenceNumber() const { return fAgeSequenceNumber; }
|
||||
UInt32 GetAgeLanguage() const { return fAgeLanguage; }
|
||||
|
||||
void SetAgeFilename( const char * v );
|
||||
void SetAgeInstanceName( const char * v );
|
||||
void SetAgeInstanceGuid( const plUUID * v );
|
||||
void SetAgeUserDefinedName( const char * v );
|
||||
void SetAgeDescription( const char * v );
|
||||
void SetAgeSequenceNumber( UInt32 v );
|
||||
void SetAgeLanguage( UInt32 v );
|
||||
|
||||
bool HasAgeFilename() const { return IsFlagSet( kHasAgeFilename ); }
|
||||
bool HasAgeInstanceName() const { return IsFlagSet( kHasAgeInstanceName ); }
|
||||
bool HasAgeInstanceGuid() const { return IsFlagSet( kHasAgeInstanceGuid ) && fAgeInstanceGuid.IsSet(); }
|
||||
bool HasAgeUserDefinedName() const { return IsFlagSet( kHasAgeUserDefinedName ); }
|
||||
bool HasAgeDescription() const { return IsFlagSet( kHasAgeDescription ); }
|
||||
bool HasAgeSequenceNumber() const { return IsFlagSet( kHasAgeSequenceNumber ); }
|
||||
bool HasAgeLanguage() const { return IsFlagSet( kHasAgeLanguage ); }
|
||||
|
||||
void Read( hsStream * s, hsResMgr* );
|
||||
void Write( hsStream * s, hsResMgr* );
|
||||
|
||||
const char * GetDisplayName() const;
|
||||
|
||||
std::string AsStdString() const;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
class plAgeLinkStruct : public plCreatable
|
||||
{
|
||||
UInt16 fFlags;
|
||||
|
||||
// Where we want to link.
|
||||
plAgeInfoStruct fAgeInfo;
|
||||
|
||||
// The linking rule to use. See plNetCommon::LinkingRules
|
||||
Int8 fLinkingRules;
|
||||
|
||||
// Where to spawn avatar when we load the age specified in fAgeInfo
|
||||
plSpawnPointInfo fSpawnPoint;
|
||||
|
||||
// Override PLS/MCP load balancing rules for CCRs.
|
||||
UInt8 fAmCCR;
|
||||
|
||||
// If this is a child age link, who is the parent
|
||||
// ...Age dataset name like "Neighborhood"
|
||||
std::string fParentAgeFilename;
|
||||
|
||||
enum
|
||||
{
|
||||
kHasAgeInfo = 1<<0,
|
||||
kHasLinkingRules = 1<<1,
|
||||
kHasSpawnPt_DEAD = 1<<2,
|
||||
kHasSpawnPt_DEAD2 = 1<<3,
|
||||
kHasAmCCR = 1<<4,
|
||||
kHasSpawnPt = 1<<5,
|
||||
kHasParentAgeFilename = 1<<6,
|
||||
};
|
||||
|
||||
void SetFlag( UInt16 bit, bool on=true ) { (on)?fFlags|=bit:fFlags&=~bit;}
|
||||
void ClearFlag( UInt16 bit ) { fFlags&=~bit;}
|
||||
bool IsFlagSet( UInt16 bit ) const { return (fFlags&bit)!=0;}
|
||||
|
||||
public:
|
||||
plAgeLinkStruct();
|
||||
CLASSNAME_REGISTER( plAgeLinkStruct );
|
||||
GETINTERFACE_ANY( plAgeLinkStruct, plCreatable );
|
||||
|
||||
plAgeInfoStruct * GetAgeInfo() { return &fAgeInfo; }
|
||||
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
|
||||
|
||||
const char * GetParentAgeFilename() const { return fParentAgeFilename.c_str(); }
|
||||
void SetParentAgeFilename( const char * v );
|
||||
|
||||
void CopyFrom( const plAgeLinkStruct * other );
|
||||
void CopyFrom( const plVaultAgeLinkNode * node );
|
||||
bool IsEqualTo( const plAgeLinkStruct * other ) const;
|
||||
void Clear();
|
||||
|
||||
bool HasAgeInfo() const { return IsFlagSet( kHasAgeInfo ); }
|
||||
bool HasLinkingRules() const { return IsFlagSet( kHasLinkingRules ); }
|
||||
bool HasSpawnPt() const { return IsFlagSet( kHasSpawnPt ); }
|
||||
bool HasAmCCR() const { return IsFlagSet( kHasAmCCR ); }
|
||||
bool HasParentAgeFilename() const { return IsFlagSet( kHasParentAgeFilename ); }
|
||||
|
||||
void SetLinkingRules( int v ) { SetFlag( kHasLinkingRules ); fLinkingRules=v; }
|
||||
int GetLinkingRules() const { return fLinkingRules; }
|
||||
void SetSpawnPoint( const plSpawnPointInfo & point ) { SetFlag( kHasSpawnPt ); fSpawnPoint=point; }
|
||||
plSpawnPointInfo & SpawnPoint() { return fSpawnPoint; }
|
||||
const plSpawnPointInfo & SpawnPoint() const { return fSpawnPoint; }
|
||||
void SetAmCCR( bool v ) { SetFlag( kHasAmCCR ); fAmCCR=v?1:0; }
|
||||
bool GetAmCCR() const { return fAmCCR!=0; }
|
||||
|
||||
void Read( hsStream * s, hsResMgr* );
|
||||
void Write( hsStream * s, hsResMgr* );
|
||||
|
||||
std::string AsStdString() const;
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Holds info that describes a server session
|
||||
//
|
||||
|
||||
class plNetServerSessionInfo : public plCreatable
|
||||
{
|
||||
UInt8 fFlags;
|
||||
std::string fServerName;
|
||||
UInt8 fServerType;
|
||||
std::string fServerAddr;
|
||||
UInt16 fServerPort;
|
||||
plUUID fServerGuid;
|
||||
|
||||
enum
|
||||
{
|
||||
kHasServerName = 1<<0,
|
||||
kHasServerType = 1<<1,
|
||||
kHasServerAddr = 1<<2,
|
||||
kHasServerPort = 1<<3,
|
||||
kHasServerGuid = 1<<4,
|
||||
};
|
||||
|
||||
void SetFlag( UInt8 bit ) { fFlags|=bit;}
|
||||
void ClearFlag( UInt8 bit ) { fFlags&=~bit;}
|
||||
bool IsFlagSet( UInt8 bit ) const { return (fFlags&bit)!=0;}
|
||||
|
||||
public:
|
||||
plNetServerSessionInfo()
|
||||
: fServerType(plNetServerConstants::kInvalidLo)
|
||||
, fServerPort(0)
|
||||
, fFlags(0)
|
||||
{}
|
||||
CLASSNAME_REGISTER( plNetServerSessionInfo );
|
||||
GETINTERFACE_ANY( plNetServerSessionInfo, plCreatable );
|
||||
|
||||
void SetServerName(const char * val);
|
||||
void SetServerType(UInt8 val);
|
||||
void SetServerAddr(const char * val);
|
||||
void SetServerPort(UInt16 val);
|
||||
void SetServerGuid(const plUUID * val);
|
||||
void CopyServerGuid(const plUUID & val);
|
||||
|
||||
const char * GetServerName() const { return fServerName.c_str();}
|
||||
UInt8 GetServerType() const { return fServerType;}
|
||||
const char * GetServerAddr() const { return fServerAddr.c_str(); }
|
||||
UInt16 GetServerPort() const { return fServerPort; }
|
||||
const plUUID *GetServerGuid() const { return &fServerGuid; }
|
||||
plUUID * GetServerGuid() { return &fServerGuid; }
|
||||
|
||||
bool HasServerName() const { return IsFlagSet(kHasServerName);}
|
||||
bool HasServerType() const { return IsFlagSet(kHasServerType);}
|
||||
bool HasServerAddr() const { return IsFlagSet(kHasServerAddr);}
|
||||
bool HasServerPort() const { return IsFlagSet(kHasServerPort);}
|
||||
bool HasServerGuid() const { return IsFlagSet(kHasServerGuid);}
|
||||
bool IsFullyQualified() const
|
||||
{
|
||||
return
|
||||
IsFlagSet(kHasServerName)&&
|
||||
IsFlagSet(kHasServerType)&&
|
||||
IsFlagSet(kHasServerAddr)&&
|
||||
IsFlagSet(kHasServerPort)&&
|
||||
IsFlagSet(kHasServerGuid);
|
||||
}
|
||||
|
||||
void Clear();
|
||||
void CopyFrom(const plNetServerSessionInfo * other);
|
||||
bool IsEqualTo(const plNetServerSessionInfo * other) const;
|
||||
virtual std::string AsStdString() const;
|
||||
virtual std::string AsLogString() const;
|
||||
|
||||
void Read(hsStream* s, hsResMgr* mgr=nil);
|
||||
void Write(hsStream* s, hsResMgr* mgr=nil);
|
||||
|
||||
// WriteVersion writes the current version of this creatable and ReadVersion will read in
|
||||
// any previous version.
|
||||
virtual void ReadVersion(hsStream* s, hsResMgr* mgr);
|
||||
virtual void WriteVersion(hsStream* s, hsResMgr* mgr);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
//class plVaultAgeInfoNode;
|
||||
//class plAgeLinkingInfo : public plCreatable
|
||||
//{
|
||||
// int fLinkingRules;
|
||||
// UInt32 fPlayerID;
|
||||
// hsBool8 fSuperUser;
|
||||
// mutable plAgeInfoStruct fAgeInfo;
|
||||
// mutable plNetServerSessionInfo fServerInfo;
|
||||
//
|
||||
//public:
|
||||
// plAgeLinkingInfo();
|
||||
//
|
||||
// CLASSNAME_REGISTER( plAgeLinkingInfo );
|
||||
// GETINTERFACE_ANY( plAgeLinkingInfo, plCreatable );
|
||||
//
|
||||
// int GetLinkingRules( void ) const { return fLinkingRules;}
|
||||
// void SetLinkingRules( int v ) { fLinkingRules=v;}
|
||||
// UInt32 GetPlayerID( void ) const { return fPlayerID;}
|
||||
// void SetPlayerID( UInt32 v ) { fPlayerID=v;}
|
||||
// void SetSuperUser(bool b) { fSuperUser=b; }
|
||||
// bool GetSuperUser() const { return fSuperUser ? true : false; }
|
||||
//
|
||||
// plAgeInfoStruct * GetAgeInfo();
|
||||
// const plAgeInfoStruct * GetAgeInfo() const;
|
||||
//
|
||||
// // initializes info with age name and guid for you.
|
||||
// plNetServerSessionInfo * GetServerInfo();
|
||||
// const plNetServerSessionInfo * GetServerInfo() const;
|
||||
// const plNetServerSessionInfo * AsServerInfo() const;
|
||||
//
|
||||
// void Clear( void );
|
||||
// void CopyFrom( const plAgeLinkingInfo * other );
|
||||
// void CopyFrom( const plVaultAgeInfoNode * node );
|
||||
// void CopyFrom( const plNetServerSessionInfo * info );
|
||||
// void CopyFrom( const plAgeInfoStruct * info );
|
||||
//
|
||||
// void Read(hsStream* s, hsResMgr* mgr=nil);
|
||||
// void Write(hsStream* s, hsResMgr* mgr=nil);
|
||||
//
|
||||
// std::string AsStdString() const;
|
||||
//};
|
||||
|
||||
#endif // plNetServerSessionInfo_h_inc
|
||||
|
@ -1,275 +1,275 @@
|
||||
/*==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 "hsWindows.h"
|
||||
#include "plServerGuid.h"
|
||||
#include "../pnMessage/plMessage.h"
|
||||
#include "../PubUtilLib/plStreamLogger/plStreamLogger.h"
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
|
||||
// Taken from plUnifiedTime, in turn taken from python source.
|
||||
// TODO: Move this down to CoreLib someday (and rename it maybe).
|
||||
#define MAGICWINDOWSOFFSET ((__int64)11644473600)
|
||||
static UInt32 SecsSinceUNIXEpoch()
|
||||
{
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */
|
||||
__int64 ff,ffsecs;
|
||||
ff = *(__int64*)(&ft);
|
||||
ffsecs = ff/(__int64)10000000;
|
||||
return (UInt32)(ffsecs-MAGICWINDOWSOFFSET);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static UInt32 SecsSinceUNIXEpoch()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nil);
|
||||
return tv.tv_sec;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
UInt32 plServerGuid::fGuidSeed = 0;
|
||||
|
||||
plServerGuid::plServerGuid()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
plServerGuid::plServerGuid( const plServerGuid & other )
|
||||
{
|
||||
Clear();
|
||||
CopyFrom( other );
|
||||
}
|
||||
|
||||
plServerGuid::plServerGuid(const char * s)
|
||||
{
|
||||
Clear();
|
||||
FromString(s);
|
||||
}
|
||||
|
||||
plServerGuid::plServerGuid(const hsWide & v)
|
||||
{
|
||||
Clear();
|
||||
FromWide( v );
|
||||
}
|
||||
|
||||
plServerGuid& plServerGuid::operator=( const plServerGuid & rhs )
|
||||
{
|
||||
CopyFrom(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const plServerGuid & X, const plServerGuid & Y)
|
||||
{
|
||||
return memcmp(X.N,Y.N,plServerGuid::kGuidBytes)==0;
|
||||
}
|
||||
bool operator!=(const plServerGuid & X, const plServerGuid & Y)
|
||||
{
|
||||
return memcmp(X.N,Y.N,plServerGuid::kGuidBytes)!=0;
|
||||
}
|
||||
bool operator<(const plServerGuid & X, const plServerGuid & Y)
|
||||
{
|
||||
return memcmp(X.N,Y.N,plServerGuid::kGuidBytes)<0;
|
||||
}
|
||||
|
||||
|
||||
hsWide plServerGuid::AsWide() const
|
||||
{
|
||||
return fWide;
|
||||
}
|
||||
|
||||
void plServerGuid::FromWide( const hsWide & v )
|
||||
{
|
||||
fWide = v;
|
||||
}
|
||||
|
||||
|
||||
bool plServerGuid::IsSet() const
|
||||
{
|
||||
return N[0]||N[1]||N[2]||N[3]||N[4]||N[5]||N[6]||N[7];
|
||||
}
|
||||
|
||||
bool plServerGuid::IsEqualTo(const plServerGuid * other) const
|
||||
{
|
||||
return (*this)==(*other);
|
||||
}
|
||||
|
||||
const char * plServerGuid::AsString() const
|
||||
{
|
||||
static char str[kGuidBytes*2+1];
|
||||
sprintf(str,"%02X%02X%02X%02X%02X%02X%02X%02X",N[0],N[1],N[2],N[3],N[4],N[5],N[6],N[7]);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string plServerGuid::AsStdString( void ) const
|
||||
{
|
||||
std::string str;
|
||||
str.resize(kGuidBytes*2+1);
|
||||
int n = sprintf(const_cast<char*>(str.data()),"%02X%02X%02X%02X%02X%02X%02X%02X",N[0],N[1],N[2],N[3],N[4],N[5],N[6],N[7]);
|
||||
str.resize(n);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
static unsigned char hexValues[] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
};
|
||||
|
||||
|
||||
bool plServerGuid::FromString(const char * s)
|
||||
{
|
||||
if (!s || (s && strlen(s)!=kGuidBytes*2 ) )
|
||||
{
|
||||
Clear();
|
||||
return false;
|
||||
}
|
||||
N[0] = hexValues[s[0]]<<4;
|
||||
N[0] += hexValues[s[1]];
|
||||
N[1] = hexValues[s[2]]<<4;
|
||||
N[1] += hexValues[s[3]];
|
||||
N[2] = hexValues[s[4]]<<4;
|
||||
N[2] += hexValues[s[5]];
|
||||
N[3] = hexValues[s[6]]<<4;
|
||||
N[3] += hexValues[s[7]];
|
||||
N[4] = hexValues[s[8]]<<4;
|
||||
N[4] += hexValues[s[9]];
|
||||
N[5] = hexValues[s[10]]<<4;
|
||||
N[5] += hexValues[s[11]];
|
||||
N[6] = hexValues[s[12]]<<4;
|
||||
N[6] += hexValues[s[13]];
|
||||
N[7] = hexValues[s[14]]<<4;
|
||||
N[7] += hexValues[s[15]];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void plServerGuid::Read(hsStream * s, hsResMgr*)
|
||||
{
|
||||
s->LogSubStreamStart("push me");
|
||||
s->LogSubStreamPushDesc("plServerGuid");
|
||||
plMsgCArrayHelper::Peek(N,kGuidBytes,s);
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plServerGuid::Write(hsStream * s, hsResMgr*)
|
||||
{
|
||||
plMsgCArrayHelper::Poke(N,kGuidBytes,s);
|
||||
}
|
||||
|
||||
void plServerGuid::CopyFrom(const plServerGuid & other)
|
||||
{
|
||||
memcpy(N,other.N,kGuidBytes);
|
||||
}
|
||||
|
||||
void plServerGuid::CopyFrom(const plServerGuid * other)
|
||||
{
|
||||
if(other)
|
||||
memcpy(N,other->N,kGuidBytes);
|
||||
else
|
||||
Clear();
|
||||
}
|
||||
|
||||
void plServerGuid::Clear()
|
||||
{
|
||||
memset(N,0,kGuidBytes);
|
||||
}
|
||||
|
||||
void plServerGuid::SetGuidSeed(UInt32 seed)
|
||||
{
|
||||
fGuidSeed = seed;
|
||||
}
|
||||
|
||||
plServerGuid plServerGuid::GenerateGuid()
|
||||
{
|
||||
// | N[0] | N[1] | N[2] | N[3] | N[4] | N[5] | N[6] | N[7] |
|
||||
// 43210987654321098765432109876543210987654321098765432109876543210
|
||||
// 01234567890123456789012345678901234567890123456789012345678901234
|
||||
// 64 48 32 16 0
|
||||
// | fGuidSeed | Current Time | Counter |
|
||||
//
|
||||
// fGuidSeed: 24 bits (settable. default is getpid())
|
||||
// Current Time: 24 bits (seconds. ~8.5 year cycle)
|
||||
// Counter: 16 bits (always increasing per process)
|
||||
|
||||
static UInt16 StaticCounter = 0;
|
||||
if (!fGuidSeed)
|
||||
{
|
||||
hsStatusMessage( "fGuidSeed not set yet. Cannot generate a reliable guid! Setting fGuidSeed=getpid()." );
|
||||
// hsAssert(fGuidSeed,"fGuidSeed not set yet. Cannot generate a reliable guid.\nIgnoring this assert will set fGuidSeed=getpid().");
|
||||
fGuidSeed = getpid();
|
||||
}
|
||||
|
||||
UInt32 currTime = SecsSinceUNIXEpoch();
|
||||
|
||||
plServerGuid guid;
|
||||
guid.N[0] = (UInt8)((fGuidSeed & 0x00FF0000)>>16);
|
||||
guid.N[1] = (UInt8)((fGuidSeed & 0x0000FF00)>> 8);
|
||||
guid.N[2] = (UInt8)(fGuidSeed & 0x000000FF);
|
||||
guid.N[3] = (UInt8)((currTime & 0x00FF0000)>>16);
|
||||
guid.N[4] = (UInt8)((currTime & 0x0000FF00)>> 8);
|
||||
guid.N[5] = (UInt8)(currTime & 0x000000FF);
|
||||
guid.N[6] = (StaticCounter & 0xFF00)>> 8;
|
||||
guid.N[7] = (StaticCounter & 0x00FF);
|
||||
|
||||
StaticCounter++;
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// End.
|
||||
/*==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 "hsWindows.h"
|
||||
#include "plServerGuid.h"
|
||||
#include "../pnMessage/plMessage.h"
|
||||
#include "../PubUtilLib/plStreamLogger/plStreamLogger.h"
|
||||
#if HS_BUILD_FOR_WIN32
|
||||
#include <process.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
|
||||
// Taken from plUnifiedTime, in turn taken from python source.
|
||||
// TODO: Move this down to CoreLib someday (and rename it maybe).
|
||||
#define MAGICWINDOWSOFFSET ((__int64)11644473600)
|
||||
static UInt32 SecsSinceUNIXEpoch()
|
||||
{
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft); /* 100 ns blocks since 01-Jan-1641 */
|
||||
__int64 ff,ffsecs;
|
||||
ff = *(__int64*)(&ft);
|
||||
ffsecs = ff/(__int64)10000000;
|
||||
return (UInt32)(ffsecs-MAGICWINDOWSOFFSET);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static UInt32 SecsSinceUNIXEpoch()
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, nil);
|
||||
return tv.tv_sec;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
UInt32 plServerGuid::fGuidSeed = 0;
|
||||
|
||||
plServerGuid::plServerGuid()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
plServerGuid::plServerGuid( const plServerGuid & other )
|
||||
{
|
||||
Clear();
|
||||
CopyFrom( other );
|
||||
}
|
||||
|
||||
plServerGuid::plServerGuid(const char * s)
|
||||
{
|
||||
Clear();
|
||||
FromString(s);
|
||||
}
|
||||
|
||||
plServerGuid::plServerGuid(const hsWide & v)
|
||||
{
|
||||
Clear();
|
||||
FromWide( v );
|
||||
}
|
||||
|
||||
plServerGuid& plServerGuid::operator=( const plServerGuid & rhs )
|
||||
{
|
||||
CopyFrom(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const plServerGuid & X, const plServerGuid & Y)
|
||||
{
|
||||
return memcmp(X.N,Y.N,plServerGuid::kGuidBytes)==0;
|
||||
}
|
||||
bool operator!=(const plServerGuid & X, const plServerGuid & Y)
|
||||
{
|
||||
return memcmp(X.N,Y.N,plServerGuid::kGuidBytes)!=0;
|
||||
}
|
||||
bool operator<(const plServerGuid & X, const plServerGuid & Y)
|
||||
{
|
||||
return memcmp(X.N,Y.N,plServerGuid::kGuidBytes)<0;
|
||||
}
|
||||
|
||||
|
||||
hsWide plServerGuid::AsWide() const
|
||||
{
|
||||
return fWide;
|
||||
}
|
||||
|
||||
void plServerGuid::FromWide( const hsWide & v )
|
||||
{
|
||||
fWide = v;
|
||||
}
|
||||
|
||||
|
||||
bool plServerGuid::IsSet() const
|
||||
{
|
||||
return N[0]||N[1]||N[2]||N[3]||N[4]||N[5]||N[6]||N[7];
|
||||
}
|
||||
|
||||
bool plServerGuid::IsEqualTo(const plServerGuid * other) const
|
||||
{
|
||||
return (*this)==(*other);
|
||||
}
|
||||
|
||||
const char * plServerGuid::AsString() const
|
||||
{
|
||||
static char str[kGuidBytes*2+1];
|
||||
sprintf(str,"%02X%02X%02X%02X%02X%02X%02X%02X",N[0],N[1],N[2],N[3],N[4],N[5],N[6],N[7]);
|
||||
return str;
|
||||
}
|
||||
|
||||
std::string plServerGuid::AsStdString( void ) const
|
||||
{
|
||||
std::string str;
|
||||
str.resize(kGuidBytes*2+1);
|
||||
int n = sprintf(const_cast<char*>(str.data()),"%02X%02X%02X%02X%02X%02X%02X%02X",N[0],N[1],N[2],N[3],N[4],N[5],N[6],N[7]);
|
||||
str.resize(n);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
static unsigned char hexValues[] =
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
};
|
||||
|
||||
|
||||
bool plServerGuid::FromString(const char * s)
|
||||
{
|
||||
if (!s || (s && strlen(s)!=kGuidBytes*2 ) )
|
||||
{
|
||||
Clear();
|
||||
return false;
|
||||
}
|
||||
N[0] = hexValues[s[0]]<<4;
|
||||
N[0] += hexValues[s[1]];
|
||||
N[1] = hexValues[s[2]]<<4;
|
||||
N[1] += hexValues[s[3]];
|
||||
N[2] = hexValues[s[4]]<<4;
|
||||
N[2] += hexValues[s[5]];
|
||||
N[3] = hexValues[s[6]]<<4;
|
||||
N[3] += hexValues[s[7]];
|
||||
N[4] = hexValues[s[8]]<<4;
|
||||
N[4] += hexValues[s[9]];
|
||||
N[5] = hexValues[s[10]]<<4;
|
||||
N[5] += hexValues[s[11]];
|
||||
N[6] = hexValues[s[12]]<<4;
|
||||
N[6] += hexValues[s[13]];
|
||||
N[7] = hexValues[s[14]]<<4;
|
||||
N[7] += hexValues[s[15]];
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void plServerGuid::Read(hsStream * s, hsResMgr*)
|
||||
{
|
||||
s->LogSubStreamStart("push me");
|
||||
s->LogSubStreamPushDesc("plServerGuid");
|
||||
plMsgCArrayHelper::Peek(N,kGuidBytes,s);
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plServerGuid::Write(hsStream * s, hsResMgr*)
|
||||
{
|
||||
plMsgCArrayHelper::Poke(N,kGuidBytes,s);
|
||||
}
|
||||
|
||||
void plServerGuid::CopyFrom(const plServerGuid & other)
|
||||
{
|
||||
memcpy(N,other.N,kGuidBytes);
|
||||
}
|
||||
|
||||
void plServerGuid::CopyFrom(const plServerGuid * other)
|
||||
{
|
||||
if(other)
|
||||
memcpy(N,other->N,kGuidBytes);
|
||||
else
|
||||
Clear();
|
||||
}
|
||||
|
||||
void plServerGuid::Clear()
|
||||
{
|
||||
memset(N,0,kGuidBytes);
|
||||
}
|
||||
|
||||
void plServerGuid::SetGuidSeed(UInt32 seed)
|
||||
{
|
||||
fGuidSeed = seed;
|
||||
}
|
||||
|
||||
plServerGuid plServerGuid::GenerateGuid()
|
||||
{
|
||||
// | N[0] | N[1] | N[2] | N[3] | N[4] | N[5] | N[6] | N[7] |
|
||||
// 43210987654321098765432109876543210987654321098765432109876543210
|
||||
// 01234567890123456789012345678901234567890123456789012345678901234
|
||||
// 64 48 32 16 0
|
||||
// | fGuidSeed | Current Time | Counter |
|
||||
//
|
||||
// fGuidSeed: 24 bits (settable. default is getpid())
|
||||
// Current Time: 24 bits (seconds. ~8.5 year cycle)
|
||||
// Counter: 16 bits (always increasing per process)
|
||||
|
||||
static UInt16 StaticCounter = 0;
|
||||
if (!fGuidSeed)
|
||||
{
|
||||
hsStatusMessage( "fGuidSeed not set yet. Cannot generate a reliable guid! Setting fGuidSeed=getpid()." );
|
||||
// hsAssert(fGuidSeed,"fGuidSeed not set yet. Cannot generate a reliable guid.\nIgnoring this assert will set fGuidSeed=getpid().");
|
||||
fGuidSeed = getpid();
|
||||
}
|
||||
|
||||
UInt32 currTime = SecsSinceUNIXEpoch();
|
||||
|
||||
plServerGuid guid;
|
||||
guid.N[0] = (UInt8)((fGuidSeed & 0x00FF0000)>>16);
|
||||
guid.N[1] = (UInt8)((fGuidSeed & 0x0000FF00)>> 8);
|
||||
guid.N[2] = (UInt8)(fGuidSeed & 0x000000FF);
|
||||
guid.N[3] = (UInt8)((currTime & 0x00FF0000)>>16);
|
||||
guid.N[4] = (UInt8)((currTime & 0x0000FF00)>> 8);
|
||||
guid.N[5] = (UInt8)(currTime & 0x000000FF);
|
||||
guid.N[6] = (StaticCounter & 0xFF00)>> 8;
|
||||
guid.N[7] = (StaticCounter & 0x00FF);
|
||||
|
||||
StaticCounter++;
|
||||
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// End.
|
||||
|
@ -1,95 +1,95 @@
|
||||
/*==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 plServerGuid_h_inc
|
||||
#define plServerGuid_h_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsWide.h"
|
||||
#include "../pnFactory/plCreatable.h"
|
||||
#include <string>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// plServerGuid
|
||||
|
||||
class plServerGuid : public plCreatable
|
||||
{
|
||||
public:
|
||||
enum { kGuidBytes = 8 };
|
||||
struct Match
|
||||
{
|
||||
const plServerGuid * fGuid;
|
||||
Match( const plServerGuid * guid ):fGuid( guid ){}
|
||||
bool operator()( const plServerGuid * guid ) const { return guid->IsEqualTo( fGuid );}
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
UInt8 N[kGuidBytes];
|
||||
hsWide fWide;
|
||||
};
|
||||
plServerGuid();
|
||||
plServerGuid( const plServerGuid & other );
|
||||
explicit plServerGuid( const char * s );
|
||||
explicit plServerGuid( const hsWide & v );
|
||||
|
||||
|
||||
plServerGuid& operator=( const plServerGuid & rhs );
|
||||
friend bool operator==( const plServerGuid & X, const plServerGuid & Y );
|
||||
friend bool operator!=( const plServerGuid & X, const plServerGuid & Y );
|
||||
friend bool operator<( const plServerGuid & X, const plServerGuid & Y) ;
|
||||
|
||||
const char * AsString( void ) const; // returns static buffer.
|
||||
std::string AsStdString( void ) const;
|
||||
bool FromString( const char * s );
|
||||
|
||||
hsWide AsWide() const;
|
||||
void FromWide( const hsWide & v );
|
||||
|
||||
bool IsSet( void ) const;
|
||||
bool IsEqualTo( const plServerGuid * other ) const;
|
||||
operator std::string ( void ) const { return AsString();}
|
||||
|
||||
void Read( hsStream * s, hsResMgr* mgr=nil );
|
||||
void Write( hsStream * s, hsResMgr* mgr=nil );
|
||||
void CopyFrom( const plServerGuid & other );
|
||||
void CopyFrom( const plServerGuid * other );
|
||||
void Clear();
|
||||
|
||||
static void SetGuidSeed( UInt32 seed );
|
||||
static bool GuidSeedIsSet( void ) { return fGuidSeed!=0;}
|
||||
static plServerGuid GenerateGuid( void );
|
||||
|
||||
CLASSNAME_REGISTER( plServerGuid );
|
||||
GETINTERFACE_ANY( plServerGuid, plCreatable );
|
||||
|
||||
private:
|
||||
static UInt32 fGuidSeed; // only low 24 bits are used
|
||||
};
|
||||
|
||||
|
||||
#endif // plServerGuid_h_inc
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// End.
|
||||
/*==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 plServerGuid_h_inc
|
||||
#define plServerGuid_h_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsWide.h"
|
||||
#include "../pnFactory/plCreatable.h"
|
||||
#include <string>
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// plServerGuid
|
||||
|
||||
class plServerGuid : public plCreatable
|
||||
{
|
||||
public:
|
||||
enum { kGuidBytes = 8 };
|
||||
struct Match
|
||||
{
|
||||
const plServerGuid * fGuid;
|
||||
Match( const plServerGuid * guid ):fGuid( guid ){}
|
||||
bool operator()( const plServerGuid * guid ) const { return guid->IsEqualTo( fGuid );}
|
||||
};
|
||||
|
||||
union
|
||||
{
|
||||
UInt8 N[kGuidBytes];
|
||||
hsWide fWide;
|
||||
};
|
||||
plServerGuid();
|
||||
plServerGuid( const plServerGuid & other );
|
||||
explicit plServerGuid( const char * s );
|
||||
explicit plServerGuid( const hsWide & v );
|
||||
|
||||
|
||||
plServerGuid& operator=( const plServerGuid & rhs );
|
||||
friend bool operator==( const plServerGuid & X, const plServerGuid & Y );
|
||||
friend bool operator!=( const plServerGuid & X, const plServerGuid & Y );
|
||||
friend bool operator<( const plServerGuid & X, const plServerGuid & Y) ;
|
||||
|
||||
const char * AsString( void ) const; // returns static buffer.
|
||||
std::string AsStdString( void ) const;
|
||||
bool FromString( const char * s );
|
||||
|
||||
hsWide AsWide() const;
|
||||
void FromWide( const hsWide & v );
|
||||
|
||||
bool IsSet( void ) const;
|
||||
bool IsEqualTo( const plServerGuid * other ) const;
|
||||
operator std::string ( void ) const { return AsString();}
|
||||
|
||||
void Read( hsStream * s, hsResMgr* mgr=nil );
|
||||
void Write( hsStream * s, hsResMgr* mgr=nil );
|
||||
void CopyFrom( const plServerGuid & other );
|
||||
void CopyFrom( const plServerGuid * other );
|
||||
void Clear();
|
||||
|
||||
static void SetGuidSeed( UInt32 seed );
|
||||
static bool GuidSeedIsSet( void ) { return fGuidSeed!=0;}
|
||||
static plServerGuid GenerateGuid( void );
|
||||
|
||||
CLASSNAME_REGISTER( plServerGuid );
|
||||
GETINTERFACE_ANY( plServerGuid, plCreatable );
|
||||
|
||||
private:
|
||||
static UInt32 fGuidSeed; // only low 24 bits are used
|
||||
};
|
||||
|
||||
|
||||
#endif // plServerGuid_h_inc
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// End.
|
||||
|
@ -1,113 +1,113 @@
|
||||
/*==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 "plSpawnPointInfo.h"
|
||||
#include "pnMessage/plMessage.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
|
||||
const plSpawnPointInfo kDefaultSpawnPoint( kDefaultSpawnPtTitle, kDefaultSpawnPtName );
|
||||
|
||||
|
||||
namespace SpawnPointInfoStreamFlags
|
||||
{
|
||||
enum
|
||||
{
|
||||
kHasTitle,
|
||||
kHasName,
|
||||
kHasCameraStack,
|
||||
};
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::ReadOld( hsStream * s )
|
||||
{
|
||||
s->LogSubStreamStart("push me");
|
||||
s->LogSubStreamPushDesc("Title");
|
||||
plMsgStdStringHelper::Peek( fTitle, s );
|
||||
s->LogSubStreamPushDesc("Name");
|
||||
plMsgStdStringHelper::Peek( fSpawnPt, s );
|
||||
fCameraStack = "";
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::Read( hsStream * s )
|
||||
{
|
||||
hsBitVector flags;
|
||||
flags.Read( s );
|
||||
|
||||
s->LogSubStreamStart("push me");
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasTitle ) )
|
||||
{
|
||||
s->LogSubStreamPushDesc("Title");
|
||||
plMsgStdStringHelper::Peek( fTitle, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasName ) )
|
||||
{
|
||||
s->LogSubStreamPushDesc("Name");
|
||||
plMsgStdStringHelper::Peek( fSpawnPt, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasCameraStack ) )
|
||||
{
|
||||
s->LogSubStreamPushDesc("CameraStack");
|
||||
plMsgStdStringHelper::Peek( fCameraStack, s );
|
||||
}
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::Write( hsStream * s ) const
|
||||
{
|
||||
hsBitVector flags;
|
||||
flags.SetBit( SpawnPointInfoStreamFlags::kHasTitle );
|
||||
flags.SetBit( SpawnPointInfoStreamFlags::kHasName );
|
||||
flags.SetBit( SpawnPointInfoStreamFlags::kHasCameraStack );
|
||||
flags.Write( s );
|
||||
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasTitle ) )
|
||||
{
|
||||
plMsgStdStringHelper::Poke( fTitle, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasName ) )
|
||||
{
|
||||
plMsgStdStringHelper::Poke( fSpawnPt, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasCameraStack ) )
|
||||
{
|
||||
plMsgStdStringHelper::Poke( fCameraStack, s );
|
||||
}
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::Reset()
|
||||
{
|
||||
(*this)=kDefaultSpawnPoint;
|
||||
}
|
||||
|
||||
std::string plSpawnPointInfo::AsStdString() const
|
||||
{
|
||||
return xtl::format( "t:%s,n:%s,c:%s",
|
||||
fTitle.size()?fTitle.c_str():"(nil)",
|
||||
fSpawnPt.size()?fSpawnPt.c_str():"(nil)",
|
||||
fCameraStack.size()?fCameraStack.c_str():"(nil)" );
|
||||
}
|
||||
/*==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 "plSpawnPointInfo.h"
|
||||
#include "pnMessage/plMessage.h"
|
||||
#include "hsStream.h"
|
||||
#include "hsBitVector.h"
|
||||
|
||||
|
||||
const plSpawnPointInfo kDefaultSpawnPoint( kDefaultSpawnPtTitle, kDefaultSpawnPtName );
|
||||
|
||||
|
||||
namespace SpawnPointInfoStreamFlags
|
||||
{
|
||||
enum
|
||||
{
|
||||
kHasTitle,
|
||||
kHasName,
|
||||
kHasCameraStack,
|
||||
};
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::ReadOld( hsStream * s )
|
||||
{
|
||||
s->LogSubStreamStart("push me");
|
||||
s->LogSubStreamPushDesc("Title");
|
||||
plMsgStdStringHelper::Peek( fTitle, s );
|
||||
s->LogSubStreamPushDesc("Name");
|
||||
plMsgStdStringHelper::Peek( fSpawnPt, s );
|
||||
fCameraStack = "";
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::Read( hsStream * s )
|
||||
{
|
||||
hsBitVector flags;
|
||||
flags.Read( s );
|
||||
|
||||
s->LogSubStreamStart("push me");
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasTitle ) )
|
||||
{
|
||||
s->LogSubStreamPushDesc("Title");
|
||||
plMsgStdStringHelper::Peek( fTitle, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasName ) )
|
||||
{
|
||||
s->LogSubStreamPushDesc("Name");
|
||||
plMsgStdStringHelper::Peek( fSpawnPt, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasCameraStack ) )
|
||||
{
|
||||
s->LogSubStreamPushDesc("CameraStack");
|
||||
plMsgStdStringHelper::Peek( fCameraStack, s );
|
||||
}
|
||||
s->LogSubStreamEnd();
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::Write( hsStream * s ) const
|
||||
{
|
||||
hsBitVector flags;
|
||||
flags.SetBit( SpawnPointInfoStreamFlags::kHasTitle );
|
||||
flags.SetBit( SpawnPointInfoStreamFlags::kHasName );
|
||||
flags.SetBit( SpawnPointInfoStreamFlags::kHasCameraStack );
|
||||
flags.Write( s );
|
||||
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasTitle ) )
|
||||
{
|
||||
plMsgStdStringHelper::Poke( fTitle, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasName ) )
|
||||
{
|
||||
plMsgStdStringHelper::Poke( fSpawnPt, s );
|
||||
}
|
||||
if ( flags.IsBitSet( SpawnPointInfoStreamFlags::kHasCameraStack ) )
|
||||
{
|
||||
plMsgStdStringHelper::Poke( fCameraStack, s );
|
||||
}
|
||||
}
|
||||
|
||||
void plSpawnPointInfo::Reset()
|
||||
{
|
||||
(*this)=kDefaultSpawnPoint;
|
||||
}
|
||||
|
||||
std::string plSpawnPointInfo::AsStdString() const
|
||||
{
|
||||
return xtl::format( "t:%s,n:%s,c:%s",
|
||||
fTitle.size()?fTitle.c_str():"(nil)",
|
||||
fSpawnPt.size()?fSpawnPt.c_str():"(nil)",
|
||||
fCameraStack.size()?fCameraStack.c_str():"(nil)" );
|
||||
}
|
||||
|
@ -1,68 +1,68 @@
|
||||
/*==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 plSpawnPointInfo_h_inc
|
||||
#define plSpawnPointInfo_h_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#define kDefaultSpawnPtTitle "Default"
|
||||
#define kDefaultSpawnPtName "LinkInPointDefault"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
class hsStream;
|
||||
|
||||
struct plSpawnPointInfo
|
||||
{
|
||||
std::string fTitle; // friendly title for GUIs
|
||||
std::string fSpawnPt; // name of spawn point in dataset
|
||||
std::string fCameraStack;
|
||||
plSpawnPointInfo(){}
|
||||
plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; }
|
||||
plSpawnPointInfo( const char * title, const char * spawnPt )
|
||||
: fTitle( title ), fSpawnPt( spawnPt ) {}
|
||||
const char * GetTitle() const { return fTitle.c_str(); }
|
||||
void SetTitle( const char * v ) { fTitle=v; }
|
||||
const char * GetName() const { return fSpawnPt.c_str(); }
|
||||
void SetName( const char * v ) { fSpawnPt = v; }
|
||||
const char * GetCameraStack() const { return fCameraStack.c_str(); }
|
||||
void SetCameraStack( const char * v ) { fCameraStack=v; }
|
||||
void Reset();
|
||||
void Read( hsStream * s );
|
||||
void ReadOld( hsStream * s );
|
||||
void Write( hsStream * s ) const;
|
||||
std::string AsStdString() const;
|
||||
};
|
||||
typedef std::vector<plSpawnPointInfo> plSpawnPointVec;
|
||||
|
||||
extern const plSpawnPointInfo kDefaultSpawnPoint;
|
||||
|
||||
|
||||
|
||||
#endif // plSpawnPointInfo_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 plSpawnPointInfo_h_inc
|
||||
#define plSpawnPointInfo_h_inc
|
||||
|
||||
#include "hsConfig.h"
|
||||
#include "hsStlUtils.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
#define kDefaultSpawnPtTitle "Default"
|
||||
#define kDefaultSpawnPtName "LinkInPointDefault"
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
|
||||
class hsStream;
|
||||
|
||||
struct plSpawnPointInfo
|
||||
{
|
||||
std::string fTitle; // friendly title for GUIs
|
||||
std::string fSpawnPt; // name of spawn point in dataset
|
||||
std::string fCameraStack;
|
||||
plSpawnPointInfo(){}
|
||||
plSpawnPointInfo( const plSpawnPointInfo & other ) { (*this)=other; }
|
||||
plSpawnPointInfo( const char * title, const char * spawnPt )
|
||||
: fTitle( title ), fSpawnPt( spawnPt ) {}
|
||||
const char * GetTitle() const { return fTitle.c_str(); }
|
||||
void SetTitle( const char * v ) { fTitle=v; }
|
||||
const char * GetName() const { return fSpawnPt.c_str(); }
|
||||
void SetName( const char * v ) { fSpawnPt = v; }
|
||||
const char * GetCameraStack() const { return fCameraStack.c_str(); }
|
||||
void SetCameraStack( const char * v ) { fCameraStack=v; }
|
||||
void Reset();
|
||||
void Read( hsStream * s );
|
||||
void ReadOld( hsStream * s );
|
||||
void Write( hsStream * s ) const;
|
||||
std::string AsStdString() const;
|
||||
};
|
||||
typedef std::vector<plSpawnPointInfo> plSpawnPointVec;
|
||||
|
||||
extern const plSpawnPointInfo kDefaultSpawnPoint;
|
||||
|
||||
|
||||
|
||||
#endif // plSpawnPointInfo_h_inc
|
||||
|
Reference in New Issue
Block a user