2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

CWE Directory Reorganization

Rearrange directory structure of CWE to be loosely equivalent to
the H'uru Plasma repository.

Part 1: Movement of directories and files.
This commit is contained in:
rarified
2021-05-15 12:49:46 -06:00
parent c3f4a640a3
commit 96903e8dca
4002 changed files with 159 additions and 644 deletions

View File

@ -0,0 +1,99 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plNetCommonMessage_inc
#define plNetCommonMessage_inc
#include "hsTypes.h"
#include "hsSafeRefCnt.h"
//
// refcntable data
//
class plNetCommonMessageData : public hsSafeRefCnt
{
private:
char *fData; // sent
public:
plNetCommonMessageData(char* d) : fData(d) {}
~plNetCommonMessageData()
{
hsAssert(RefCnt()==1, "illegal refcnt");
delete [] fData;
}
char* GetData() const { return fData; }
};
//
// basic msg payload w/ refcntable data
//
class plNetCommonMessage
{
plNetCommonMessage(const plNetCommonMessage & other);
private:
plNetCommonMessageData* fMsgData;
protected:
UInt32 fLen; // sent
public:
plNetCommonMessage() : fLen(0),fMsgData(nil) {}
virtual ~plNetCommonMessage() { hsRefCnt_SafeUnRef(fMsgData); }
// setters
void SetData(char *d)
{
plNetCommonMessageData* n = d ? TRACKED_NEW plNetCommonMessageData(d) : nil;
hsRefCnt_SafeAssign(fMsgData, n);
hsRefCnt_SafeUnRef(n);
}
void SetMsgData(plNetCommonMessageData* d)
{
hsRefCnt_SafeAssign(fMsgData, d);
}
void SetLen(UInt32 l) { fLen=l; }
// getters
char* GetData() const { return fMsgData ? fMsgData->GetData() : nil; }
virtual UInt32 GetDataLen() { return fLen; }
UInt32 GetLen() const { return fLen; }
plNetCommonMessageData* GetMsgData() const { return fMsgData; }
};
#endif // plNetCommonMessage_inc

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plNetMsgCreatable_h
#define plNetMsgCreatable_h
// kept separate for a reason
#include "../pnFactory/plCreator.h"
#include "plNetMessage.h"
// NON CREATABLES
REGISTER_NONCREATABLE(plNetMessage);
REGISTER_NONCREATABLE(plNetMsgObject);
REGISTER_NONCREATABLE(plNetMsgStream);
REGISTER_NONCREATABLE(plNetMsgRoomsList);
REGISTER_NONCREATABLE(plNetMsgStreamedObject);
REGISTER_NONCREATABLE(plNetMsgSharedState);
// HELPERS
REGISTER_CREATABLE(plNetMsgStreamHelper);
REGISTER_CREATABLE(plNetMsgObjectHelper);
REGISTER_CREATABLE(plNetMsgObjectListHelper);
REGISTER_CREATABLE(plNetMsgMemberInfoHelper);
REGISTER_CREATABLE(plNetMsgMemberListHelper);
REGISTER_CREATABLE(plNetMsgStreamableHelper);
REGISTER_CREATABLE(plNetMsgReceiversListHelper);
REGISTER_CREATABLE(plNetMsgCreatableHelper);
// CLIENT MSGS
REGISTER_CREATABLE(plNetMsgGameStateRequest);
REGISTER_CREATABLE(plNetMsgSDLState);
REGISTER_CREATABLE(plNetMsgSDLStateBCast);
REGISTER_CREATABLE(plNetMsgLoadClone);
REGISTER_CREATABLE(plNetMsgPlayerPage);
REGISTER_CREATABLE(plNetMsgGameMessage);
REGISTER_CREATABLE(plNetMsgGameMessageDirected);
REGISTER_CREATABLE(plNetMsgPagingRoom);
REGISTER_CREATABLE(plNetMsgGroupOwner);
REGISTER_CREATABLE(plNetMsgVoice);
REGISTER_CREATABLE(plNetMsgTestAndSet);
REGISTER_CREATABLE(plNetMsgGetSharedState);
REGISTER_CREATABLE(plNetMsgObjStateRequest);
REGISTER_CREATABLE(plNetMsgObjectUpdateFilter);
REGISTER_CREATABLE(plNetMsgMembersListReq );
REGISTER_CREATABLE(plNetMsgMembersList );
REGISTER_CREATABLE(plNetMsgServerToClient);
REGISTER_CREATABLE(plNetMsgMemberUpdate );
REGISTER_CREATABLE(plNetMsgListenListUpdate);
REGISTER_CREATABLE(plNetMsgInitialAgeStateSent);
REGISTER_CREATABLE(plNetMsgRelevanceRegions);
#endif // plNetMsgCreatable_h

View File

@ -0,0 +1,563 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 "plNetMsgHelpers.h"
#include "plNetMessage.h"
#include "../plCompression/plZlibCompress.h"
#include "../pnNetCommon/plNetServers.h"
#include "../pnNetCommon/plNetApp.h"
#include "../pnKeyedObject/plKey.h"
#include "../pnMessage/plMessage.h"
#include "hsStream.h"
#include <algorithm>
////////////////////////////////////////////////////////////////////
// plNetMsgStreamableHelper
plNetMsgStreamableHelper & plNetMsgStreamableHelper::operator =(hsStreamable * value)
{
fObject = value;
return *this;
}
int plNetMsgStreamableHelper::Poke(hsStream* stream, UInt32 peekOptions)
{
hsAssert(fObject, "plNetMsgStreamableHelper::Poke: fObject not set.");
fObject->Write(stream);
return stream->GetPosition();
}
int plNetMsgStreamableHelper::Peek(hsStream* stream, UInt32 peekOptions)
{
hsAssert(fObject, "plNetMsgStreamableHelper::Peek: fObject not set.");
fObject->Read(stream);
return stream->GetPosition();
}
////////////////////////////////////////////////////////////////////
// plNetMsgCreatableHelper
plNetMsgCreatableHelper::plNetMsgCreatableHelper(plCreatable * object)
:fCreatable(object)
,fWeCreatedIt(false)
{
}
plNetMsgCreatableHelper::~plNetMsgCreatableHelper()
{
if (fWeCreatedIt)
hsRefCnt_SafeUnRef(fCreatable);
}
plNetMsgCreatableHelper & plNetMsgCreatableHelper::operator =(plCreatable * value)
{
SetObject(value);
return *this;
}
plNetMsgCreatableHelper::operator plCreatable*()
{
return GetObject();
}
plNetMsgCreatableHelper::operator const plCreatable*()
{
return GetObject();
}
void plNetMsgCreatableHelper::SetObject(plCreatable * object)
{
if (fWeCreatedIt)
hsRefCnt_SafeUnRef(fCreatable);
fCreatable = object;
fWeCreatedIt = false;
}
plCreatable * plNetMsgCreatableHelper::GetObject()
{
return fCreatable;
}
int plNetMsgCreatableHelper::Poke(hsStream * s, UInt32 peekOptions)
{
hsAssert(fCreatable,"plNetMsgCreatableHelper::Poke: fCreatable not set");
UInt16 classIndex = fCreatable->ClassIndex();
s->WriteSwap(classIndex);
fCreatable->Write(s,nil);
return s->GetPosition();
}
int plNetMsgCreatableHelper::Peek(hsStream * s, UInt32 peekOptions)
{
UInt16 classIndex;
s->LogSubStreamStart("push me");
s->LogReadSwap(&classIndex,"ClassIdx");
SetObject(plFactory::Create(classIndex));
fWeCreatedIt = true;
hsAssert(fCreatable,"plNetMsgCreatableHelper::Peek: Failed to create plCreatable. Invalid ClassIndex?");
fCreatable->Read(s,nil);
s->LogSubStreamEnd();
return s->GetPosition();
}
/////////////////////////////////////////////////////////
// NOT A MSG
// PL STREAM MSG - HELPER class
/////////////////////////////////////////////////////////
plNetMsgStreamHelper::plNetMsgStreamHelper() : fStreamBuf(nil), fStreamType(-1), fStreamLen(0),
fCompressionType(plNetMessage::kCompressionNone), fUncompressedSize(0),
fCompressionThreshold( kDefaultCompressionThreshold )
{
}
void plNetMsgStreamHelper::Clear()
{
delete [] fStreamBuf;
fStreamBuf = nil;
fStreamType = 0xff;
fStreamLen = 0;
fCompressionType = plNetMessage::kCompressionNone;
fCompressionThreshold = kDefaultCompressionThreshold;
}
int plNetMsgStreamHelper::Poke(hsStream* stream, UInt32 peekOptions)
{
if ( !(peekOptions & plNetMessage::kDontCompress) )
Compress();
stream->WriteSwap(fUncompressedSize);
stream->WriteSwap(fCompressionType);
stream->WriteSwap(fStreamLen);
stream->Write(fStreamLen, fStreamBuf);
return stream->GetPosition();
}
int plNetMsgStreamHelper::Peek(hsStream* stream, const UInt32 peekOptions)
{
stream->LogSubStreamStart("Stream Helper");
stream->LogReadSwap(&fUncompressedSize,"UncompressedSize");
stream->LogReadSwap(&fCompressionType,"CompressionType");
stream->LogReadSwap(&fStreamLen,"StreamLen");
if (fStreamLen) // stream data exists
{
if (!(peekOptions & plNetMessage::kSkipStream))
{
if (!fStreamBuf)
IAllocStream(fStreamLen);
stream->LogRead(fStreamLen, fStreamBuf,"StreamData");
if ( !(peekOptions & plNetMessage::kDontCompress) )
Uncompress();
fStreamType = *(Int16*)fStreamBuf; // grab from start fo stream
}
else
{
stream->ReadSwap(&fStreamType); // never compressed, set by reading directly from stream
stream->LogSkip(fStreamLen-sizeof(fStreamType),"SkippedStreamHelper");
}
}
stream->LogSubStreamEnd();
return stream->GetPosition();
}
void plNetMsgStreamHelper::ReadVersion(hsStream* s, hsResMgr* mgr)
{
hsBitVector contentFlags;
contentFlags.Read(s);
if (contentFlags.IsBitSet(kUncompressedSize))
s->ReadSwap(&fUncompressedSize);
if (contentFlags.IsBitSet(kCompressionType))
s->ReadSwap(&fCompressionType);
if (contentFlags.IsBitSet(kStreamLen))
s->ReadSwap(&fStreamLen);
if (contentFlags.IsBitSet(kStreamBuf))
{
if (!fStreamBuf)
IAllocStream(fStreamLen);
s->Read(fStreamLen,fStreamBuf);
}
}
void plNetMsgStreamHelper::WriteVersion(hsStream* s, hsResMgr* mgr)
{
hsBitVector contentFlags;
contentFlags.SetBit(kUncompressedSize);
contentFlags.SetBit(kCompressionType);
contentFlags.SetBit(kStreamLen);
contentFlags.SetBit(kStreamBuf);
contentFlags.Write(s);
s->WriteSwap(fUncompressedSize);
s->WriteSwap(fCompressionType);
s->WriteSwap(fStreamLen);
s->Write(fStreamLen,fStreamBuf);
}
void plNetMsgStreamHelper::IAllocStream(UInt32 len)
{
delete [] fStreamBuf;
fStreamBuf=nil;
fStreamLen=len;
if (len)
fStreamBuf = TRACKED_NEW UInt8[len];
}
void plNetMsgStreamHelper::CopyStream(hsStream* ssStream)
{
UInt32 len=ssStream->GetEOF();
IAllocStream(len);
ssStream->CopyToMem(fStreamBuf);
fStreamType = *(Int16*)fStreamBuf;
}
void plNetMsgStreamHelper::CopyStream(Int32 len, const void* buf)
{
IAllocStream(len);
memcpy(fStreamBuf, buf, len);
fStreamType = *(Int16*)fStreamBuf;
}
void plNetMsgStreamHelper::CopyFrom(const plNetMsgStreamHelper* other)
{
fUncompressedSize = other->GetUncompressedSize();
fCompressionType = other->GetCompressionType();
CopyStream(other->GetStreamLen(), other->GetStreamBuf());
}
bool plNetMsgStreamHelper::Compress(int offset)
{
if ( !IsCompressable() )
return true;
plZlibCompress compressor;
UInt8* buf = (UInt8*)GetStreamBuf(); // skip creatable index
UInt32 bufLen = GetStreamLen();
UInt32 uncompressedSize = bufLen;
SetUncompressedSize( uncompressedSize );
if ( compressor.Compress( &buf, &bufLen, offset) )
{
SetCompressionType( plNetMessage::kCompressionZlib );
SetStreamLen(bufLen);
SetStreamBuf(buf);
Int32 diff = uncompressedSize-bufLen;
#if 0
plNetApp::StaticDebugMsg( "\tCompressed stream: %lu->%lu bytes, (%s %d bytes, %.1f%%)",
uncompressedSize, bufLen, (diff>=0)?"shrunk":"GREW?!?", diff, (diff/(float)uncompressedSize)*100 );
#endif
return true;
}
else
{
hsAssert( false, "plNetMsgStreamHelper: Compression failed" );
SetCompressionType( plNetMessage::kCompressionFailed );
return false;
}
}
bool plNetMsgStreamHelper::Uncompress(int offset)
{
if ( !IsCompressed() )
return true;
UInt32 origLen = GetStreamLen();
plZlibCompress compressor;
UInt8* buf = (UInt8*)GetStreamBuf();
UInt32 bufLen = origLen;
if ( compressor.Uncompress( &buf, &bufLen, GetUncompressedSize(), offset ) )
{
SetCompressionType( plNetMessage::kCompressionNone );
SetStreamLen(bufLen);
SetStreamBuf(buf);
Int32 diff = bufLen-origLen;
#if 0
plNetApp::StaticDebugMsg( "\tUncompressed stream: %lu->%lu bytes, (%s %d bytes, %.1f%%)",
origLen, bufLen, (diff>=0)?"grew":"SHRUNK?!?", diff, (diff/(float)bufLen)*100 );
#endif
return true;
}
else
{
hsAssert( false, "plNetMsgStreamHelper: Uncompression failed" );
SetCompressionType( plNetMessage::kCompressionFailed );
return false;
}
}
bool plNetMsgStreamHelper::IsCompressed() const
{
return ( fCompressionType==plNetMessage::kCompressionZlib );
}
bool plNetMsgStreamHelper::IsCompressable() const
{
return ( fCompressionType==plNetMessage::kCompressionNone
&& fStreamLen>fCompressionThreshold );
}
////////////////////////////////////////////////////////
// NOT A MSG
// plNetMsgObject - HELPER class
////////////////////////////////////////////////////////
plNetMsgObjectHelper & plNetMsgObjectHelper::operator =(const plNetMsgObjectHelper & other)
{
fUoid = other.GetUoid();
return *this;
}
int plNetMsgObjectHelper::Poke(hsStream* stream, UInt32 peekOptions)
{
fUoid.Write(stream);
return stream->GetPosition();
}
int plNetMsgObjectHelper::Peek(hsStream* stream, const UInt32 peekOptions)
{
stream->LogSubStreamStart("push me");
fUoid.Read(stream);
stream->LogSubStreamEnd();
return stream->GetPosition();
}
hsBool plNetMsgObjectHelper::SetFromKey(const plKey &key)
{
if (!key || !key->GetName())
return false;
fUoid = key->GetUoid();
return true;
}
void plNetMsgObjectHelper::ReadVersion(hsStream* s, hsResMgr* mgr)
{
hsBitVector contentFlags;
contentFlags.Read(s);
if (contentFlags.IsBitSet(kObjHelperUoid))
fUoid.Read(s);
}
void plNetMsgObjectHelper::WriteVersion(hsStream* s, hsResMgr* mgr)
{
hsBitVector contentFlags;
contentFlags.SetBit(kObjHelperUoid);
contentFlags.Write(s);
// kObjHelperUoid
fUoid.Write(s);
}
////////////////////////////////////////////////////////
// NOT A MSG
// plNetMsgObjectList - HELPER class
////////////////////////////////////////////////////////
plNetMsgObjectListHelper::~plNetMsgObjectListHelper()
{
Reset();
}
void plNetMsgObjectListHelper::Reset()
{
int i;
for( i=0 ; i<GetNumObjects() ; i++ )
{
delete GetObject(i);
fObjects[i] = nil;
} // for
fObjects.clear();
}
int plNetMsgObjectListHelper::Poke(hsStream* stream, UInt32 peekOptions)
{
Int16 num = GetNumObjects();
stream->WriteSwap(num);
int i;
for( i=0 ;i<num ;i++ )
{
GetObject(i)->Poke(stream, peekOptions);
} // for
return stream->GetPosition();
}
int plNetMsgObjectListHelper::Peek(hsStream* stream, const UInt32 peekOptions)
{
Reset();
stream->LogSubStreamStart("push me");
Int16 num;
stream->LogReadSwap(&num,"ObjectListHelper Num");
int i;
for( i=0 ;i<num ;i++ )
{
fObjects.push_back(TRACKED_NEW plNetMsgObjectHelper);
GetObject(i)->Peek(stream, peekOptions);
} // for
stream->LogSubStreamEnd();
return stream->GetPosition();
}
////////////////////////////////////////////////////////
// NOT A MSG
// plNetMsgMemberInfoHelper - HELPER class
////////////////////////////////////////////////////////
plNetMsgMemberInfoHelper::plNetMsgMemberInfoHelper()
: fFlags(0)
{
}
int plNetMsgMemberInfoHelper::Peek(hsStream* s, const UInt32 peekOptions)
{
s->LogSubStreamStart("push me");
s->LogReadSwap(&fFlags,"MemberInfoHelper Flags");
fClientGuid.Read( s, nil );
fAvatarUoid.Read(s);
s->LogSubStreamEnd();
return s->GetPosition();
}
int plNetMsgMemberInfoHelper::Poke(hsStream* s, const UInt32 peekOptions)
{
s->WriteSwap(fFlags);
fClientGuid.Write( s, nil );
fAvatarUoid.Write(s);
return s->GetPosition();
}
////////////////////////////////////////////////////////
// NOT A MSG
// plNetMsgMemberListHelper - HELPER class
////////////////////////////////////////////////////////
plNetMsgMemberListHelper::~plNetMsgMemberListHelper()
{
int i;
for(i=0;i<GetNumMembers();i++)
delete fMembers[i];
}
int plNetMsgMemberListHelper::Peek(hsStream* stream, const UInt32 peekOptions)
{
Int16 numMembers;
stream->LogSubStreamStart("push me");
stream->LogReadSwap(&numMembers,"MemberListHelper NumMembers");
fMembers.clear();
int i;
for(i=0;i<numMembers;i++)
{
plNetMsgMemberInfoHelper* addr=TRACKED_NEW plNetMsgMemberInfoHelper;
addr->Peek(stream, peekOptions);
AddMember(addr);
}
stream->LogSubStreamEnd();
return stream->GetPosition();
}
int plNetMsgMemberListHelper::Poke(hsStream* stream, const UInt32 peekOptions)
{
Int16 numMembers = (Int16)GetNumMembers();
stream->WriteSwap(numMembers);
int i;
for(i=0;i<numMembers;i++)
{
fMembers[i]->GetClientGuid()->SetClientKey("");
fMembers[i]->GetClientGuid()->SetAccountUUID(plUUID());
fMembers[i]->Poke(stream, peekOptions);
}
return stream->GetPosition();
}
////////////////////////////////////////////////////////
// NOT A MSG
// plNetMsgReceiversListHelper - HELPER class
////////////////////////////////////////////////////////
int plNetMsgReceiversListHelper::Peek(hsStream* stream, const UInt32 peekOptions)
{
UInt8 numIDs;
stream->LogSubStreamStart("push me");
stream->LogReadSwap(&numIDs,"ReceiversListHelper NumIDs");
fPlayerIDList.clear();
int i;
for(i=0;i<numIDs;i++)
{
UInt32 ID;
stream->LogReadSwap(&ID,"ReceiversListHelper ID");
AddReceiverPlayerID(ID);
}
stream->LogSubStreamEnd();
return stream->GetPosition();
}
int plNetMsgReceiversListHelper::Poke(hsStream* stream, const UInt32 peekOptions)
{
UInt8 numIDs = (UInt8)GetNumReceivers();
stream->WriteSwap(numIDs);
int i;
for(i=0;i<numIDs;i++)
stream->WriteSwap(GetReceiverPlayerID(i));
return stream->GetPosition();
}
bool plNetMsgReceiversListHelper::RemoveReceiverPlayerID(UInt32 n)
{
std::vector<UInt32>::iterator res = std::find(fPlayerIDList.begin(), fPlayerIDList.end(), n);
if (res != fPlayerIDList.end())
{
fPlayerIDList.erase(res);
return true;
}
return false;
}

View File

@ -0,0 +1,343 @@
/*==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/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 PL_NET_MSG_HELPERS_inc
#define PL_NET_MSG_HELPERS_inc
//
// These are not messages per se, but helper classes which are used
// in to avoid multiple derivation by net messages.
//
#include "hsTypes.h"
#include "hsUtils.h"
#include "hsStream.h"
#include "hsStlUtils.h"
#include "../pnNetCommon/pnNetCommon.h"
#include "../pnFactory/plCreatable.h"
#include "../pnKeyedObject/plUoid.h"
#include "../pnKeyedObject/plKey.h"
#include "../plUnifiedTime/plUnifiedTime.h"
#include "../plNetCommon/plClientGuid.h"
#include <algorithm>
class plKey;
class hsStream;
////////////////////////////////////////////////////////////////////
// plNetMsgStreamableHelper
// Will peek/poke anything derived from hsStreamable
class plNetMsgStreamableHelper : public plCreatable
{
hsStreamable * fObject;
public:
plNetMsgStreamableHelper():fObject(nil){}
plNetMsgStreamableHelper(hsStreamable * object):fObject(object){}
plNetMsgStreamableHelper & operator =(hsStreamable * value);
operator hsStreamable *() const { return fObject;}
operator const hsStreamable *() const { return fObject;}
CLASSNAME_REGISTER( plNetMsgStreamableHelper );
GETINTERFACE_ANY(plNetMsgStreamableHelper, plCreatable);
void SetObject(hsStreamable * object) { fObject=object;}
hsStreamable * GetObject() const { return fObject;}
int Poke(hsStream* stream, UInt32 peekOptions=0);
int Peek(hsStream* stream, UInt32 peekOptions=0);
};
////////////////////////////////////////////////////////////////////
// plNetMsgCreatableHelper
// Will peek/poke anything derived from plCreatable.
// Will create the object upon read if it hasn't been set by SetObject().
// When helper goes away, object will be unref-ed if it was created by
// the helper, so if you GetObject() and want to keep it longer than the
// lifetime of the helper, ref it.
class plNetMsgCreatableHelper : public plCreatable
{
plCreatable * fCreatable;
bool fWeCreatedIt;
public:
plNetMsgCreatableHelper(plCreatable * object = nil);
~plNetMsgCreatableHelper();
plNetMsgCreatableHelper & operator =(plCreatable * value);
operator plCreatable*();
operator const plCreatable*();
CLASSNAME_REGISTER( plNetMsgCreatableHelper );
GETINTERFACE_ANY(plNetMsgCreatableHelper, plCreatable);
void SetObject(plCreatable * object);
plCreatable * GetObject();
int Poke(hsStream* stream, UInt32 peekOptions=0);
int Peek(hsStream* stream, UInt32 peekOptions=0);
};
////////////////////////////////////////////////////////////////////
//
// Net msg helper class for a stream buffer of some type (saveState, voice, plMessage...)
//
class plNetMsgStreamHelper : public plCreatable
{
private:
enum ContentsFlags
{
kUncompressedSize,
kStreamBuf,
kStreamLen,
kCompressionType,
};
protected:
UInt32 fUncompressedSize;
Int16 fStreamType; // set to creatable type, not read/written, gleaned from creatable stream
UInt8* fStreamBuf;
UInt32 fStreamLen;
UInt8 fCompressionType; // see plNetMessage::CompressionType
UInt32 fCompressionThreshold; // NOT WRITTEN
void IAllocStream(UInt32 len);
public:
enum { kDefaultCompressionThreshold = 255 }; // bytes
plNetMsgStreamHelper();
virtual ~plNetMsgStreamHelper() { delete [] fStreamBuf; }
CLASSNAME_REGISTER( plNetMsgStreamHelper );
GETINTERFACE_ANY(plNetMsgStreamHelper, plCreatable);
virtual int Poke(hsStream* stream, UInt32 peekOptions=0);
virtual int Peek(hsStream* stream, UInt32 peekOptions=0);
// creatable ops
virtual void Read(hsStream* s, hsResMgr* mgr) { Peek(s); }
virtual void Write(hsStream* s, hsResMgr* mgr) { Poke(s); }
void ReadVersion(hsStream* s, hsResMgr* mgr);
void WriteVersion(hsStream* s, hsResMgr* mgr);
void Clear();
// copiers
void CopyFrom(const plNetMsgStreamHelper* other);
void CopyStream(hsStream* ssStream); // copies to fStream
void CopyStream(Int32 len, const void* buf); // copies to fStream
// setters
void SetCompressionType(UInt8 t) { fCompressionType=t; }
void SetStreamLen(UInt32 l) { fStreamLen=l; }
void SetStreamBuf(UInt8* b) { fStreamBuf=b; }
void SetUncompressedSize(UInt32 s) { fUncompressedSize=s; }
// Getters
UInt8 GetCompressionType() const { return fCompressionType; }
Int16 GetStreamType() const { return fStreamType; }
UInt32 GetStreamLen() const { return fStreamLen; }
UInt8* GetStreamBuf() const { return fStreamBuf; }
UInt32 GetUncompressedSize() const { return fUncompressedSize; }
bool Compress(int offset=2 /* skip 2 bytes as creatable index */ );
bool Uncompress(int offset=2 /* skip 2 bytes as creatable index */ );
bool IsCompressed() const;
bool IsCompressable() const;
UInt32 GetCompressionThreshold() const { return fCompressionThreshold; }
void SetCompressionThreshold( UInt32 v ) { fCompressionThreshold=v; }
};
//
// Contains info about a scene object
//
class plNetMsgObjectHelper : public plCreatable
{
private:
enum ContentFlags
{
kObjHelperUoid,
};
protected:
// string names for debug purposes only
plUoid fUoid;
// update operator()= fxn when adding new members
public:
plNetMsgObjectHelper() {}
plNetMsgObjectHelper(const plKey key) { SetFromKey(key); }
virtual ~plNetMsgObjectHelper() { }
CLASSNAME_REGISTER( plNetMsgObjectHelper );
GETINTERFACE_ANY(plNetMsgObjectHelper, plCreatable);
virtual int Poke(hsStream* stream, UInt32 peekOptions=0);
virtual int Peek(hsStream* stream, UInt32 peekOptions=0);
plNetMsgObjectHelper & operator =(const plNetMsgObjectHelper & other);
// setters
hsBool SetFromKey(const plKey &key);
void SetUoid(const plUoid &u) { fUoid=u; }
// getters
const char* GetObjectName() const { return fUoid.GetObjectName(); }
UInt32 GetPageID() const { return fUoid.GetLocation().GetSequenceNumber(); }
const plUoid& GetUoid() const { return fUoid; }
void ReadVersion(hsStream* s, hsResMgr* mgr);
void WriteVersion(hsStream* s, hsResMgr* mgr);
};
//
// Contains a list of info about scene objects.
//
class plNetMsgObjectListHelper : public plCreatable
{
protected:
std::vector<plNetMsgObjectHelper*> fObjects;
public:
plNetMsgObjectListHelper() {}
virtual ~plNetMsgObjectListHelper();
CLASSNAME_REGISTER( plNetMsgObjectListHelper );
GETINTERFACE_ANY(plNetMsgObjectListHelper, plCreatable);
virtual int Poke(hsStream* stream, UInt32 peekOptions=0);
virtual int Peek(hsStream* stream, UInt32 peekOptions=0);
void Reset();
int GetNumObjects() const { return fObjects.size(); }
plNetMsgObjectHelper* GetObject(int i) { return fObjects[i]; }
void AddObject(plKey key) { fObjects.push_back(TRACKED_NEW plNetMsgObjectHelper(key)); }
};
//
// Contains a info about a net member.
//
class plNetMsgMemberInfoHelper : public plCreatable
{
protected:
UInt32 fFlags;
plUoid fAvatarUoid;
plClientGuid fClientGuid;
public:
plNetMsgMemberInfoHelper();
CLASSNAME_REGISTER( plNetMsgMemberInfoHelper );
GETINTERFACE_ANY( plNetMsgMemberInfoHelper, plCreatable);
virtual int Poke(hsStream* stream, UInt32 peekOptions=0);
virtual int Peek(hsStream* stream, UInt32 peekOptions=0);
const plClientGuid * GetClientGuid() const { return &fClientGuid; }
plClientGuid * GetClientGuid() { return &fClientGuid; }
UInt32 GetFlags() const { return fFlags; }
plUoid GetAvatarUoid() const { return fAvatarUoid; }
void SetFlags(UInt32 v) { fFlags=v; }
void SetAvatarUoid(plUoid u) { fAvatarUoid=u; }
};
//
// Contains a info about a list of net members.
// This is sent from server to client.
//
class plNetMsgMemberListHelper : public plCreatable
{
public:
typedef std::vector<plNetMsgMemberInfoHelper*> MemberInfoHelperVec;
struct MatchesPlayerID
{
UInt32 fID;
MatchesPlayerID( UInt32 id ): fID( id ){}
bool operator()( const plNetMsgMemberInfoHelper * mbr ) const
{
return ( mbr && mbr->GetClientGuid()->GetPlayerID()==fID );
}
};
protected:
MemberInfoHelperVec fMembers;
public:
plNetMsgMemberListHelper() {}
virtual ~plNetMsgMemberListHelper();
CLASSNAME_REGISTER( plNetMsgMemberListHelper );
GETINTERFACE_ANY( plNetMsgMemberListHelper, plCreatable);
virtual int Poke(hsStream* stream, UInt32 peekOptions=0);
virtual int Peek(hsStream* stream, UInt32 peekOptions=0);
int GetNumMembers() const { return fMembers.size(); }
const plNetMsgMemberInfoHelper* GetMember(int i) const { return fMembers[i]; }
void AddMember(plNetMsgMemberInfoHelper* a) { fMembers.push_back(a); }
const MemberInfoHelperVec * GetMembers() const { return &fMembers;}
};
/////////////////////////////////////////////////////////////////
//
// Contains a list of other players (members).
// This is commonly used to route p2p msgs to groups of players.
// Sent client to server.
//
class plNetMsgReceiversListHelper : public plCreatable
{
protected:
std::vector<UInt32> fPlayerIDList;
public:
plNetMsgReceiversListHelper() {}
virtual ~plNetMsgReceiversListHelper() {}
CLASSNAME_REGISTER( plNetMsgReceiversListHelper );
GETINTERFACE_ANY( plNetMsgReceiversListHelper, plCreatable);
virtual int Poke(hsStream* stream, UInt32 peekOptions=0);
virtual int Peek(hsStream* stream, UInt32 peekOptions=0);
void Clear() { fPlayerIDList.clear(); }
int GetNumReceivers() const { return fPlayerIDList.size(); }
UInt32 GetReceiverPlayerID(int i) const { return fPlayerIDList[i]; }
void AddReceiverPlayerID(UInt32 a) { fPlayerIDList.push_back(a); }
bool RemoveReceiverPlayerID(UInt32 n); // returns true if found and removed
};
#endif // PL_NET_MSG__HELPERS_inc

View File

@ -0,0 +1,161 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
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 plNetMsgVersion_h_inc
#define plNetMsgVersion_h_inc
// Changing the version number(s)? Make an entry in the corresponding log below.
#define PLASMA2_NETMSG_MAJOR_VERSION 12
#define PLASMA2_NETMSG_MINOR_VERSION 6
/*--- Major Version Log ---
# Date Who Comment
2 10/05/01 eap Moved handling of VaultRequestData message from game server to lobby server
3 10/09/01 ee Made Uoid changes that impact the net messages
4 10/11/01 ee Made Uoid changes that impact the net messages
5 02/12/02 eap Modified auth messages.
6 4/18/02 MT Changed to using SDL saveStates
7 04/18/02 eap Redesigned KI messaging
8 05/17/02 Colin Changed format of Uoid
9 07/01/02 rje Changed Authentication Scheme
10 10/16/02 eap Removed low-level KI. Replaced with plVault.
11 07/03/03 MT Optimized plNetMessage headers for size
12 09/17/03 eap Removed UInt32 acctID. Added Uuid acctUUID. Changed PlayerUpdate enum values.
*/
/*--- Minor Version Log ---
# Date Who Comment
5 9/28/01 MT Added senderClientNum to GameMessages (mostly for debugging)
0 10/05/01 eap Reset on Major Version change
1 10/26/01 eap Upon sending join ack, the game server now sends a set of initial local unique ids to client.
2 10/31/01 eap Added (Un)RegisterServer msgs (actually renamed from ServerStarted family msgs). Changed StartProcess msg a little.
3 11/05/01 eap Changes to request/receive avatar msgs.
4 11/21/01 MT Removed obsolete plNetMessage flags due to client task reorg
5 02/02/02 eap Added/Updated KI message classes.
0 02/12/02 eap Reset on major version change
1 03/22/02 eap Removed acctID from plNetMsgCreatePlayer.
2 3/31/02 MT moved uncompressed size from voiceMsg to streamHelper
0 04/18/02 MT Reset on major version change.
0 04/18/02 eap Reset on major version change
1 4/29/02 MT added joinOrder to joinAck
2 05/02/02 eap Changed plNetServerSessionInfo stream format.
3 05/08/02 eap Changed KI stream formats.
0 05/17/02 Colin Reset on major version change
1 06/03/02 eap Changed KIOperations enum values. Affects KI messages.
2 06/06/02 eap More changes to KI message format.
3 6/07/02 MT Enabled compression on SDL msgs
4 6/19/02 MT Removed general timeOffset in favor of UnifiedTime in game msg
4 06/12/02 eap Yet more changes to KI messaging stuff
1 7/01/02 MT Added a member to SDLBCast msgs
2 07/16/02 eap Added linking rule info to net msgs related to age linking.
3 08/15/02 eap Changed plNetMsgKI format.
4 8/15/02 MT Changes related to cloning reorg
5 08/21/02 eap Changed plNetMsgKI format.
6 9/17/02 MT Added fIsPlayer to plNetMsgLoadClone
7 9/24/02 rje Added Packet Size in Client Hello
8 10/01/02 eap Changed the way the KI is fetched.
9 10/02/02 eap Changed KI storable stream format (made flag-based instead of stream version-based)
10 10/03/02 eap Changed KI manifest stream format.
11 10/04/02 thamer Changed timeSent to be unified time not double, short-circuit version checking
0 10/16/02 eap Reset on major version change.
1 10/15/02 thamer minor changes for CCR
2 11/04/02 eap Changed plNetMsgVault format.
3 12/04/02 eap Moved compression into plNetMsgStreamHelper. Changed plNetMsgVault format.
4 12/04/02 eap Changed plNetMsgStreamHelper fUncompressedSize type to UInt32.
5 12/05/02 eap Added PlayerName and AvatarShape to CreatePlayer msg.
6 12/11/02 thamer Moved PlayerID into the base class
7 12/18/02 thamer Changed SDL format
8 12/17/02 eap Changed format of vault negotiate manifest msg.
9 01/14/03 eap Added CCRLevel to plClientGuid and plNetMsgSetMyActivePlayer. Removed from plNetMsgJoinReq
10 01/30/03 eap Changed linking rules and associated net msgs.
11 02/04/03 eap Changed vault msg format.
12 02/05/03 thamer Added initial age state to joinAck
13 02/10/03 eap Changed format of vault FetchNodes msg to support bundling of multiple nodes into one msg.
14 02/12/03 eap Changed the way ages are (un)registered. client used to do it. now vault server does it.
15 02/24/03 eap Added a byte to plNetMsgLeave to specify the reason for leaving.
16 02/25/03 thamer Changed the auth response generation
17 02/26/03 thamer again
18 02/28/03 eap Support for multiple spawn points for vault age link nodes.
19 03/14/03 eap Changed plVaultNode format.
20 03/14/03 thamer Added buildType and 'experimental' values to authHello and JoinAck msgs
21 03/17/03 thamer Added streamSubType var to StreamHelper
22 03/21/03 eap Changed auth error enum values to be negative.
23 03/24/03 rje Added Invites to CreatePlayer.
24 04/11/03 eap Changed create player error enum values to be negative.
25 04/14/03 thamer Changed SharedState R/W format
26 05/13/03 eap Changed plNetMsgVault a little bit to allow multiple age vaults to live in one process.
27 05/16/03 thamer Bob changed the LoadClone msg format
28 05/30/03 thamer Optimized the Uoid read/write format
29 06/01/03 eap Changed stream format of plGenericType class
30 06/01/03 eap Changed stream format of plGenericType class
31 06/02/03 thamer Changed plNetMsgLoadClone format
32 06/06/03 eap Reimplemented inter-age messaging. Removed vaultserver from the process.
33 06/10/03 eap Changed plVaultNode stream format
34 06/24/03 eap Client is now in charge of creating personal age when needed.
35 06/27/03 eap Added reply msg to SetActivePlayer
36 06/25/03 thamer SDL size optimizations
37 07/01/03 eap Vault db version bumped.
0 07/03/03 thamer Reset on major version change.
1 07/11/03 eap Added fCreateFlags to CreatePlayer msg.
2 07/16/03 thamer Added flags to vault player list desc
3 07/22/03 eap Changed plNetMsgVault and plNetMsgVaultTask format.
4 07/23/03 eap Changed plNetMsgDeletePlayer format.
5 07/28/03 thamer Changed StreamHelper format.
6 08/01/03 eap Changed the format of some vault operations (RegisterOwnedAge et.al.)
7 08/01/03 eap Added disconnect reply msg to vault protocol.
8 08/06/03 eap Added some buffer room to the last enum value in plNetMsgTerminated/Leave/ServerMsgUpdatePlayer
9 08/07/03 eap Fixed enum values in plNetMsgTerminated/Leave/ServerMsgUpdatePlayer
10 08/22/03 eap Game server no longer queries auth server when authenticating a client.
11 09/04/03 eap Added camera stack to plSpawnPointInfo.
12 09/08/03 eap Added server guid to plNetMsgAuthenticated
13 09/17/03 bob Changed format of Read/WriteSafeString, (and the "long" versions)
0 09/17/03 eap Reset on major version change.
1 10/22/03 eap Changed format of VaultFetchNodes message
2 10/23/03 eap Changed format of VaultFetchNodes message again
3 10/25/03 bob Changed the format of plLinkEffectsTriggerMsg, which the NetMsgScreener reads.
4 11/18/03 eap Changed c/s initial SDL state send transaction.
5 10/29/03 jeffrey Changed the plDynamicTextMsg to use unicode
6 12/01/03 eap Changed plNetMessage flags (kNoGameTimeSent became kTimeSent)
*/
#endif