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,270 @@
/*==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 hsGMatState_inc
#define hsGMatState_inc
#include "hsColorRGBA.h"
class hsStream;
class hsGMatState {
public:
enum hsGMatBlendFlags {
kBlendTest = 0x1, // dev
// Rest of blends are mutually exclusive
kBlendAlpha = 0x2, // dev
kBlendMult = 0x4, // dev
kBlendAdd = 0x8, // dev
kBlendAddColorTimesAlpha = 0x10, // dev
kBlendAntiAlias = 0x20,
kBlendDetail = 0x40,
kBlendNoColor = 0x80, // dev
kBlendMADD = 0x100,
kBlendDot3 = 0x200,
kBlendAddSigned = 0x400,
kBlendAddSigned2X = 0x800,
kBlendMask = kBlendAlpha
| kBlendMult
| kBlendAdd
| kBlendAddColorTimesAlpha
| kBlendDetail
| kBlendMADD
| kBlendDot3
| kBlendAddSigned
| kBlendAddSigned2X,
kBlendInvertAlpha = 0x1000, // dev
kBlendInvertColor = 0x2000, // dev
kBlendAlphaMult = 0x4000,
kBlendAlphaAdd = 0x8000,
kBlendNoVtxAlpha = 0x10000,
kBlendNoTexColor = 0x20000,
kBlendNoTexAlpha = 0x40000,
kBlendInvertVtxAlpha = 0x80000, // Invert ONLY the vertex alpha source
kBlendAlphaAlways = 0x100000, // Alpha test always passes (even for alpha=0).
kBlendInvertFinalColor = 0x200000,
kBlendInvertFinalAlpha = 0x400000,
kBlendEnvBumpNext = 0x800000,
kBlendSubtract = 0x1000000,
kBlendRevSubtract = 0x2000000,
kBlendAlphaTestHigh = 0x4000000,
kBlendAlphaPremultiplied = 0x8000000
};
enum hsGMatClampFlags {
kClampTextureU = 0x1, // dev
kClampTextureV = 0x2, // dev
kClampTexture = 0x3 // dev
};
enum hsGMatShadeFlags {
kShadeSoftShadow = 0x1, // view, dev
kShadeNoProjectors = 0x2, // projector
kShadeEnvironMap = 0x4, // dev, load
kShadeVertexShade = 0x20, // dev
kShadeNoShade = 0x40, // view,dev
kShadeBlack = kShadeNoShade,
kShadeSpecular = 0x80, // view, dev
//kShadeNoFog = 0x100, // dev
kShadeWhite = 0x200,
kShadeSpecularAlpha = 0x400,
kShadeSpecularColor = 0x800,
kShadeSpecularHighlight = 0x1000,
kShadeVertColShade = 0x2000,
kShadeInherit = 0x4000,
kShadeIgnoreVtxIllum = 0x8000,
kShadeEmissive = 0x10000, // Moved here 8.27 mcn. Only really sane to use with kMiscEndPassHere
kShadeReallyNoFog = 0x20000
};
enum hsGMatZFlags {
kZIncLayer = 0x1, // dev
kZClearZ = 0x4, // dev
kZNoZRead = 0x8, // dev
kZNoZWrite = 0x10,
kZMask = kZNoZWrite | kZClearZ | kZNoZRead,
kZLODBias = 0x20
};
enum hsGMatMiscFlags {
kMiscWireFrame = 0x1, // dev (running out of bits)
kMiscDrawMeshOutlines = 0x2, // dev, currently unimplemented
kMiscTwoSided = 0x4, // view,dev
kMiscDrawAsSplats = 0x8, // dev? bwt
kMiscAdjustPlane = 0x10,
kMiscAdjustCylinder = 0x20,
kMiscAdjustSphere = 0x40,
kMiscAdjust = kMiscAdjustPlane | kMiscAdjustCylinder| kMiscAdjustSphere,
kMiscTroubledLoner = 0x80,
kMiscBindSkip = 0x100,
kMiscBindMask = 0x200,
kMiscBindNext = 0x400,
kMiscLightMap = 0x800,
kMiscUseReflectionXform = 0x1000, // Use the calculated reflection environment
// texture transform instead of layer->GetTransform()
kMiscPerspProjection = 0x2000,
kMiscOrthoProjection = 0x4000,
kMiscProjection = kMiscPerspProjection | kMiscOrthoProjection,
kMiscRestartPassHere = 0x8000, // Tells pipeline to start a new pass beginning with this layer
// Kinda like troubledLoner, but only cuts off lower layers, not
// higher ones (kMiscBindNext sometimes does this by implication)
kMiscBumpLayer = 0x10000,
kMiscBumpDu = 0x20000,
kMiscBumpDv = 0x40000,
kMiscBumpDw = 0x80000,
kMiscBumpChans = kMiscBumpDu | kMiscBumpDv | kMiscBumpDw,
kMiscNoShadowAlpha = 0x100000,
kMiscUseRefractionXform = 0x200000, // Use a refraction-like hack.
kMiscCam2Screen = 0x400000, // Expects tex coords to be XYZ in camera space. Does a cam to screen (not NDC) projection
// and swaps Z with W, so that the texture projection can produce projected 2D screen coordinates.
kAllMiscFlags = 0xffffffff
};
enum StateIdx {
kBlend,
kClamp,
kShade,
kZ,
kMisc
};
UInt32 fBlendFlags;
UInt32 fClampFlags;
UInt32 fShadeFlags;
UInt32 fZFlags;
UInt32 fMiscFlags;
static hsBool Differs(UInt32 mine, UInt32 hers, UInt32 mask)
{
return (mine & mask) ^ (hers & mask);
}
static hsBool Differs(UInt32 mine, UInt32 hers)
{
return mine ^ hers;
}
hsBool operator!=(const hsGMatState& other)
{
return ((fBlendFlags ^ other.fBlendFlags)
| (fClampFlags ^ other.fClampFlags)
| (fShadeFlags ^ other.fShadeFlags)
| (fZFlags ^ other.fZFlags)
| (fMiscFlags ^ other.fMiscFlags));
}
UInt32 Value(int i) const
{
switch(i)
{
case kBlend:
return fBlendFlags;
case kClamp:
return fClampFlags;
case kShade:
return fShadeFlags;
case kZ:
return fZFlags;
case kMisc:
return fMiscFlags;
}
hsAssert(false, "Bad param");
return fBlendFlags;
}
UInt32& operator[](const int i)
{
switch(i)
{
case kBlend:
return fBlendFlags;
case kClamp:
return fClampFlags;
case kShade:
return fShadeFlags;
case kZ:
return fZFlags;
case kMisc:
return fMiscFlags;
}
hsAssert(false, "Bad param");
return fBlendFlags;
}
hsGMatState& operator|=(const hsGMatState& other)
{
fBlendFlags |= other.fBlendFlags;
fClampFlags |= other.fClampFlags;
fShadeFlags |= other.fShadeFlags;
fZFlags |= other.fZFlags;
fMiscFlags |= other.fMiscFlags;
return *this;
}
hsGMatState& operator+=(const hsGMatState& other)
{
return operator|=(other);
}
hsGMatState& operator-=(const hsGMatState& other)
{
fBlendFlags &= ~other.fBlendFlags;
fClampFlags &= ~other.fClampFlags;
fShadeFlags &= ~other.fShadeFlags;
fZFlags &= ~other.fZFlags;
fMiscFlags &= ~other.fMiscFlags;
return *this;
}
inline void Read(hsStream* s);
inline void Write(hsStream* s);
hsGMatState(UInt32 blend=0, UInt32 clamp=0, UInt32 shade=0, UInt32 z=0, UInt32 misc=0)
: fBlendFlags(blend),
fClampFlags(clamp),
fShadeFlags(shade),
fZFlags(z),
fMiscFlags(misc) {}
void Reset() { fBlendFlags = fClampFlags = fShadeFlags = fZFlags = fMiscFlags = 0; }
inline void Clear(const hsGMatState& state);
inline void Composite(const hsGMatState& want, const hsGMatState& on, const hsGMatState& off);
};
#endif // hsGMatState_inc

View File

@ -0,0 +1,53 @@
#ifndef hsGMatStateInline_inc
#define hsGMatStateInline_inc
#include "hsGMatState.h"
#include "hsStream.h"
void hsGMatState::Read(hsStream* s)
{
fBlendFlags = s->ReadSwap32();
fClampFlags = s->ReadSwap32();
fShadeFlags = s->ReadSwap32();
fZFlags = s->ReadSwap32();
fMiscFlags = s->ReadSwap32();
}
void hsGMatState::Write(hsStream* s)
{
s->WriteSwap32(fBlendFlags);
s->WriteSwap32(fClampFlags);
s->WriteSwap32(fShadeFlags);
s->WriteSwap32(fZFlags);
s->WriteSwap32(fMiscFlags);
}
void hsGMatState::Clear(const hsGMatState& state)
{
fBlendFlags &= ~state.fBlendFlags;
fClampFlags &= ~state.fClampFlags;
fShadeFlags &= ~state.fShadeFlags;
fZFlags &= ~state.fZFlags;
fMiscFlags &= ~state.fMiscFlags;
}
void hsGMatState::Composite(const hsGMatState& want, const hsGMatState& on, const hsGMatState& off)
{
fBlendFlags = want.fBlendFlags & ~off.fBlendFlags;
if( !(fBlendFlags & (kBlendMask & ~(kBlendAlpha|kBlendAntiAlias))) )
fBlendFlags |= on.fBlendFlags;
fClampFlags = (want.fClampFlags | on.fClampFlags) & ~off.fClampFlags;
fShadeFlags = (want.fShadeFlags | on.fShadeFlags) & ~off.fShadeFlags;
#if 0 // This restriction is only valid for glide - handle in glideDevice
if( fBlendFlags & (kBlendAntiAlias | kBlendAlpha) )
fShadeFlags &= ~(kShadeSpecularAlpha | kShadeSpecularHighlight);
#endif // This restriction is only valid for glide - handle in glideDevice
fZFlags = (want.fZFlags | on.fZFlags) & ~off.fZFlags;
fMiscFlags = (want.fMiscFlags | on.fMiscFlags) & ~off.fMiscFlags;
}
#endif // hsGMatStateInline_inc

View File

@ -0,0 +1,157 @@
/*==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 hsResMgr_inc
#define hsResMgr_inc
#include "hsTypes.h"
#include "hsRefCnt.h"
#include "plLoadMask.h"
#include "plRefFlags.h"
#include "../pnKeyedObject/plKey.h"
class hsStream;
class plKeyImp;
class hsKeyedObject;
class plRefMsg;
class plUoid;
class plLocation;
class plCreatable;
class plDispatchBase;
class hsResMgr : public hsRefCnt
{
public:
//---------------------------
// Load and Unload
//---------------------------
virtual void Load (const plKey& objKey)=0; // places on list to be loaded
virtual hsBool Unload(const plKey& objKey)=0; // Unregisters (deletes) an object, Return true if successful
virtual plKey CloneKey(const plKey& objKey)=0;
//---------------------------
// Finding Functions
//---------------------------
virtual plKey FindKey(const plUoid& uoid)=0;
//---------------------------
// Establish reference linkage
//---------------------------
virtual hsBool AddViaNotify(const plKey& sentKey, plRefMsg* msg, plRefFlags::Type flags)=0;
virtual hsBool AddViaNotify(plRefMsg* msg, plRefFlags::Type flags)=0; // msg->fRef->GetKey() == sentKey
virtual hsBool SendRef(const plKey& key, plRefMsg* refMsg, plRefFlags::Type flags)=0;
virtual hsBool SendRef(hsKeyedObject* ko, plRefMsg* refMsg, plRefFlags::Type flags)=0;
//---------------------------
// Reading and Writing keys
//---------------------------
// Read a Key in, and Notify me when the Object is loaded
virtual plKey ReadKeyNotifyMe(hsStream* s, plRefMsg* retMsg, plRefFlags::Type flags)=0;
// Just read the Key data in and find a match in the registry and return it.
virtual plKey ReadKey(hsStream* s)=0;
// For convenience you can write a key using the KeyedObject or the Key...same result
virtual void WriteKey(hsStream* s, hsKeyedObject* obj)=0;
virtual void WriteKey(hsStream* s, const plKey& key)=0;
//---------------------------
// Reading and Writing Objects directly
//---------------------------
virtual plCreatable* ReadCreatable(hsStream* s)=0;
virtual void WriteCreatable(hsStream* s, plCreatable* cre)=0;
virtual plCreatable* ReadCreatableVersion(hsStream* s)=0;
virtual void WriteCreatableVersion(hsStream* s, plCreatable* cre)=0;
//---------------------------
// Registry Modification Functions
//---------------------------
virtual plKey NewKey(const char* name, hsKeyedObject* object, const plLocation& loc, const plLoadMask& m = plLoadMask::kAlways)=0;
virtual plKey NewKey(plUoid& newUoid, hsKeyedObject* object)=0;
virtual plDispatchBase* Dispatch()=0;
virtual void BeginShutdown() {}
protected:
friend class hsKeyedObject;
friend class plKey;
friend class plKeyImp;
friend class plArmatureMod; // Temp hack until a findkey/clone issue is fixed. -Bob
virtual plKey ReRegister(const char *nm, const plUoid& oid)=0;
virtual hsBool ReadObject(plKeyImp* key)=0; // plKeys call this when needed
// Sets a key as used or unused in the registry. When all keys in a page of a
// particular type in an page are unused, we can free the memory associated with them.
// Only called by plKeyImp
virtual void IKeyReffed(plKeyImp* key)=0;
virtual void IKeyUnreffed(plKeyImp* key)=0;
protected: // hsgResMgr only
friend class hsgResMgr;
virtual hsBool IReset()=0;
virtual hsBool IInit()=0;
virtual void IShutdown()=0;
};
class hsgResMgr
{
private:
static hsResMgr* fResMgr;
public:
static hsResMgr* ResMgr() { return (hsResMgr*)fResMgr; }
static plDispatchBase* Dispatch() { hsAssert(fResMgr, "No resmgr"); return fResMgr->Dispatch(); }
static hsBool Init(hsResMgr* m);
static hsBool Reset() { return fResMgr->IReset(); }
static void Shutdown();
static hsBool SendRef(plKey& key, plRefMsg* refMsg, plRefFlags::Type flags) { return fResMgr->SendRef(key, refMsg, flags); }
static hsBool SendRef(hsKeyedObject* ko, plRefMsg* refMsg, plRefFlags::Type flags) { return fResMgr->SendRef(ko, refMsg, flags); }
};
#endif // hsResMgr_inc

View File

@ -0,0 +1,172 @@
/*==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 hsTimer_Defined
#define hsTimer_Defined
#include "hsWide.h"
#include "hsScalar.h"
#if !HS_CAN_USE_FLOAT
#error "Unsupported without double's"
#endif // !HS_CAN_USE_FLOAT
class plTimerShare
{
protected:
mutable hsBool fFirstTime;
mutable hsWide fRawTimeZero;
mutable hsBool fResetSmooth;
enum {
kSmoothBuffLen = 10
};
double fSmoothBuff[kSmoothBuffLen];
int fCurrSlot;
hsScalar fSysTimeScale;
double fRealSeconds;
double fSysSeconds;
hsScalar fDelSysSeconds;
hsScalar fFrameTimeInc;
hsBool fRunningFrameTime;
hsScalar fTimeClampSecs;
hsScalar fSmoothingClampSecs;
hsBool fClamping;
hsWide* FactorInTimeZero(hsWide* ticks) const;
double GetSeconds() const;
double GetMilliSeconds() const;
hsWide* GetRawTicks(hsWide* ticks) const;
double RawTicksToDSeconds(const hsWide& ticks);
hsWide DSecondsToRawTicks(double secs);
hsScalar GetDelSysSeconds() const { return fDelSysSeconds; }
double GetSysSeconds() const { return fSysSeconds; }
double IncSysSeconds();
void SetRealTime(hsBool realTime);
hsBool IsRealTime() const { return !fRunningFrameTime; }
void SetFrameTimeInc(hsScalar inc) { fFrameTimeInc = inc; }
void SetTimeScale(hsScalar s) { fSysTimeScale = s; }
hsScalar GetTimeScale() const { return fSysTimeScale; }
void SetTimeClamp(hsScalar secs) { fTimeClampSecs = secs; }
void SetSmoothingCap(hsScalar secs) { fSmoothingClampSecs = secs; }
hsScalar GetTimeClamp() const { return fTimeClampSecs; }
hsBool IsClamping() const { return fClamping; }
friend class hsTimer;
public:
plTimerShare();
~plTimerShare();
};
class hsTimer
{
protected:
static const double fPrecTicksPerSec;
static const hsWide fRawBase;
static hsWide IInitRawBase();
static plTimerShare* fTimer;
public:
static hsBool VerifyRawBase() { return fRawBase == IInitRawBase(); }
static const hsWide& GetRawBase() { return fRawBase; }
static hsWide* GetRawTicks(hsWide* ticks) { return fTimer->GetRawTicks(ticks); }
static double GetSeconds() { return fTimer->GetSeconds(); }
static double GetMilliSeconds() { return fTimer->GetMilliSeconds(); }
static double RawTicksToDSeconds(const hsWide& ticks) { return fTimer->RawTicksToDSeconds(ticks); }
static hsWide DSecondsToRawTicks(double secs) { return fTimer->DSecondsToRawTicks(secs); }
static hsScalar GetDelSysSeconds() { return fTimer->GetDelSysSeconds(); }
static double GetSysSeconds() { return fTimer->GetSysSeconds(); }
static double IncSysSeconds() { return fTimer->IncSysSeconds(); }
static void SetRealTime(hsBool realTime) { fTimer->SetRealTime(realTime); }
static hsBool IsRealTime() { return fTimer->IsRealTime(); }
static void SetFrameTimeInc(hsScalar inc) { fTimer->SetFrameTimeInc(inc); }
static void SetTimeScale(hsScalar s) { fTimer->SetTimeScale(s); }
static hsScalar GetTimeScale() { return fTimer->GetTimeScale(); }
static void SetTimeClamp(hsScalar secs) { fTimer->SetTimeClamp(secs); }
static void SetTimeSmoothingClamp(hsScalar secs) { fTimer->SetSmoothingCap(secs); }
static hsScalar GetTimeClamp() { return fTimer->GetTimeClamp(); }
static hsBool IsClamping() { return fTimer->IsClamping(); }
///////////////////////////
// Precision timer routines - these are stateless and implemented as statics.
///////////////////////////
static UInt32 GetPrecTickCount();
static double GetPrecTicksPerSec();
static UInt32 PrecSecsToTicks(hsScalar secs);
static double PrecTicksToSecs(UInt32 ticks);
static double PrecTicksToHz(UInt32 ticks);
// If you need to time something longer than 20 seconds, use this instead of
// the precision timer. It works the same, it just gives you full resolution.
static UInt64 GetFullTickCount();
static float FullTicksToMs(UInt64 ticks);
//
// Pass GetTheTimer() into other process space, and then call SetTheTimer() on it.
static void SetTheTimer(plTimerShare* timer);
static plTimerShare* GetTheTimer() { return fTimer; }
};
#endif

View File

@ -0,0 +1,118 @@
/*==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 plAudible_inc
#define plAudible_inc
#include "hsTemplates.h"
#include "../pnKeyedObject/hsKeyedObject.h"
class plSound;
class hsStream;
class hsResMgr;
struct hsMatrix44;
struct hsVector3;
struct hsPoint3;
class hsBounds3Ext;
class plSoundMsg;
class plEventCallbackMsg;
class plAudible : public hsKeyedObject
{
public:
CLASSNAME_REGISTER( plAudible );
GETINTERFACE_ANY( plAudible, hsKeyedObject );
virtual plAudible& SetProperty(int prop, hsBool on) = 0;
virtual hsBool GetProperty(int prop) = 0;
virtual plAudible& SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l, int index = -1) { return *this; }
virtual void Read(hsStream* s, hsResMgr* mgr){hsKeyedObject::Read(s, mgr);}
virtual void Write(hsStream* s, hsResMgr* mgr){hsKeyedObject::Write(s, mgr);}
virtual void SetSceneObject(plKey obj) = 0;
virtual plKey GetSceneObject() const = 0;
// These two should only be called by the SceneNode
virtual void SetSceneNode(plKey node) = 0;
virtual plKey GetSceneNode() const = 0;
virtual void Play(int index = -1) = 0;
virtual void SynchedPlay(int index = -1) = 0;
virtual void Stop(int index = -1) = 0;
virtual void FastForwardPlay(int index = -1) = 0;
virtual void FastForwardToggle( int index = -1) = 0;
virtual void SetMin(const hsScalar m,int index = -1) = 0; // sets minimum falloff distance
virtual void SetMax(const hsScalar m,int index = -1) = 0; // sets maximum falloff distance
virtual hsScalar GetMin(int index = -1) const = 0;
virtual hsScalar GetMax(int index = -1) const = 0;
virtual void SetVelocity(const hsVector3 vel,int index = -1) = 0;
virtual hsVector3 GetVelocity(int index = -1) const = 0;
virtual hsPoint3 GetPosition(int index = -1) = 0;
virtual void SetLooping(hsBool loop,int index = -1) = 0; // sets continuous loop or stops looping
virtual hsBool IsPlaying(int index = -1) = 0;
virtual void SetTime(double t, int index = -1) = 0;
virtual void Activate() = 0;
virtual void DeActivate() = 0;
virtual void RemoveCallbacks(plSoundMsg* pMsg) = 0;
virtual void AddCallbacks(plSoundMsg* pMsg) = 0;
virtual void GetStatus(plSoundMsg* pMsg) = 0;
virtual int GetNumSounds() const = 0;
virtual plSound* GetSound(int i) const = 0;
virtual int GetSoundIndex(const char *keyname) const = 0;
virtual void Init(hsBool isLocal){;}
virtual void SetVolume(const float volume,int index = -1) = 0;
virtual void SetMuted( hsBool muted, int index = -1 ) = 0;
virtual void ToggleMuted( int index = -1 ) = 0;
virtual void SetTalkIcon(int index, UInt32 str) = 0;
virtual void ClearTalkIcon() = 0;
virtual void SetFilename(int index, const char *filename, hsBool isCompressed) = 0; // set filename for a streaming sound
virtual void SetFadeIn( const int type, const float length, int index = -1 ) = 0;
virtual void SetFadeOut( const int type, const float length, int index = -1 ) = 0;
protected:
hsTArray<plEventCallbackMsg*> fCallbacks;
};
#endif // plAudible_inc

View File

@ -0,0 +1,60 @@
/*==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 plCCRMgrBase_inc
#define plCCRMgrBase_inc
//
// Abstract base class for CCR Mgr
//
#include "../pnKeyedObject/hsKeyedObject.h"
class plCCRMgrBase : public hsKeyedObject
{
protected:
static plCCRMgrBase* fBaseInstance;
public:
static plCCRMgrBase* GetInstance() { return fBaseInstance; }
};
#endif // plCCRMgrBase_inc

View File

@ -0,0 +1,74 @@
/*==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 plClassIndexMacros_inc
#define plClassIndexMacros_inc
// Macros for deriving the class index enum from the class name.
// These should always be used in place of 'plFooIDX'.
// Place before includes to avoid recursive include prob.
// --For use within plCreatableIndex
#define CLASS_INDEX(plClassName) plClassName##IDX
// --For use within plExternalCreatableIndex
#define EXTERN_CLASS_INDEX(plClassName) plClassName##IDX
// --For use outside of plCreatableIndex
#define CLASS_INDEX_SCOPED(plClassName) plCreatableIndex::CLASS_INDEX(plClassName)
// --For use outside of plExternalCreatableIndex
#define EXTERN_CLASS_INDEX_SCOPED(plClassName) plExternalCreatableIndex::EXTERN_CLASS_INDEX(plClassName)
// Macros for the start and end of the class index list
#define CLASS_INDEX_LIST_START const int KEYED_OBJ_DELINEATOR = 512; \
const int EXTERNAL_KEYED_DLL_BEGIN = 256; \
const int EXTERNAL_KEYED_DLL_END = 511; \
const int EXTERNAL_NONKEYED_DLL_BEGIN = 1436; \
const int EXTERNAL_NONKEYED_DLL_END = 1536; \
class plCreatableIndex { public: enum {
#define CLASS_INDEX_LIST_END plNumClassIndices = EXTERNAL_NONKEYED_DLL_END + 1, }; };
// Macro to mark which class index is the start of the nonkeyed object section
#define CLASS_INDEX_NONKEYED_OBJ_START kKeyedObjDelineator = KEYED_OBJ_DELINEATOR-1,
#define CLASS_INDEX_DATABASE_STRUCT_INDEXES_START kDatabaseStructIndexesStart,
#define CLASS_INDEX_DATABASE_STRUCT_INDEXES_END kDatabaseStructIndexesEnd=kDatabaseStructIndexesStart+100,
#endif // plClassIndexMacros_inc

View File

@ -0,0 +1,952 @@
/*==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 plCreatableIndex_inc
#define plCreatableIndex_inc
#include "plClassIndexMacros.h" // for CLASS_INDEX macro defn
CLASS_INDEX_LIST_START
//---------------------------------------------------------------------
// hsKeyedObjects should appear in the first section of the enum list
// And everything else in the next section
// Otherwise you will get an Assert
//---------------------------------------------------------------------
CLASS_INDEX(plSceneNode),
CLASS_INDEX(plSceneObject),
CLASS_INDEX(hsKeyedObject),
CLASS_INDEX(plBitmap),
CLASS_INDEX(plMipmap),
CLASS_INDEX(plCubicEnvironmap),
CLASS_INDEX(plLayer),
CLASS_INDEX(hsGMaterial),
CLASS_INDEX(plParticleSystem),
CLASS_INDEX(plParticleEffect),
CLASS_INDEX(plParticleCollisionEffectBeat),
CLASS_INDEX(plParticleFadeVolumeEffect),
CLASS_INDEX(plBoundInterface),
CLASS_INDEX(plRenderTarget),
CLASS_INDEX(plCubicRenderTarget),
CLASS_INDEX(plCubicRenderTargetModifier),
CLASS_INDEX(plObjInterface),
CLASS_INDEX(plAudioInterface),
CLASS_INDEX(plAudible),
CLASS_INDEX(plAudibleNull),
CLASS_INDEX(plWinAudible),
CLASS_INDEX(plCoordinateInterface),
CLASS_INDEX(plDrawInterface),
CLASS_INDEX(plDrawable),
CLASS_INDEX(plDrawableMesh),
CLASS_INDEX(plDrawableIce),
CLASS_INDEX(plPhysical),
CLASS_INDEX(plPhysicalMesh),
CLASS_INDEX(plSimulationInterface),
CLASS_INDEX(plCameraModifier),
CLASS_INDEX(plModifier),
CLASS_INDEX(plSingleModifier),
CLASS_INDEX(plSimpleModifier),
CLASS_INDEX(pfSecurePreloader),
CLASS_INDEX(UNUSED_plRandomTMModifier),
CLASS_INDEX(plInterestingModifier),
CLASS_INDEX(plDetectorModifier),
CLASS_INDEX(plSimplePhysicalMesh),
CLASS_INDEX(plCompoundPhysicalMesh),
CLASS_INDEX(plMultiModifier),
CLASS_INDEX(plSynchedObject),
CLASS_INDEX(plSoundBuffer),
CLASS_INDEX(UNUSED_plAliasModifier),
CLASS_INDEX(plPickingDetector),
CLASS_INDEX(plCollisionDetector),
CLASS_INDEX(plLogicModifier),
CLASS_INDEX(plConditionalObject),
CLASS_INDEX(plANDConditionalObject),
CLASS_INDEX(plORConditionalObject),
CLASS_INDEX(plPickedConditionalObject),
CLASS_INDEX(plActivatorConditionalObject),
CLASS_INDEX(plTimerCallbackManager),
CLASS_INDEX(plKeyPressConditionalObject),
CLASS_INDEX(plAnimationEventConditionalObject),
CLASS_INDEX(plControlEventConditionalObject),
CLASS_INDEX(plObjectInBoxConditionalObject),
CLASS_INDEX(plLocalPlayerInBoxConditionalObject),
CLASS_INDEX(plObjectIntersectPlaneConditionalObject),
CLASS_INDEX(plLocalPlayerIntersectPlaneConditionalObject),
CLASS_INDEX(plPortalDrawable),
CLASS_INDEX(plPortalPhysical),
CLASS_INDEX(plSpawnModifier),
CLASS_INDEX(plFacingConditionalObject),
CLASS_INDEX(plPXPhysical),
CLASS_INDEX(plViewFaceModifier),
CLASS_INDEX(plLayerInterface),
CLASS_INDEX(plLayerWrapper),
CLASS_INDEX(plLayerAnimation),
CLASS_INDEX(plLayerDepth),
CLASS_INDEX(plLayerMovie),
CLASS_INDEX(plLayerBink),
CLASS_INDEX(plLayerAVI),
CLASS_INDEX(plSound),
CLASS_INDEX(plWin32Sound),
CLASS_INDEX(plLayerOr),
CLASS_INDEX(plAudioSystem),
CLASS_INDEX(plDrawableSpans),
CLASS_INDEX(UNUSED_plDrawablePatchSet),
CLASS_INDEX(plInputManager),
CLASS_INDEX(plLogicModBase),
CLASS_INDEX(plFogEnvironment),
CLASS_INDEX(plNetApp),
CLASS_INDEX(plNetClientMgr),
CLASS_INDEX(pl2WayWinAudible),
CLASS_INDEX(plLightInfo),
CLASS_INDEX(plDirectionalLightInfo),
CLASS_INDEX(plOmniLightInfo),
CLASS_INDEX(plSpotLightInfo),
CLASS_INDEX(plLightSpace),
CLASS_INDEX(plNetClientApp),
CLASS_INDEX(plNetServerApp),
CLASS_INDEX(plClient),
CLASS_INDEX(UNUSED_plCompoundTMModifier),
CLASS_INDEX(plCameraBrain),
CLASS_INDEX(plCameraBrain_Default),
CLASS_INDEX(plCameraBrain_Drive),
CLASS_INDEX(plCameraBrain_Fixed),
CLASS_INDEX(plCameraBrain_FixedPan),
CLASS_INDEX(pfGUIClickMapCtrl),
CLASS_INDEX(plListener),
CLASS_INDEX(plAvatarMod),
CLASS_INDEX(plAvatarAnim),
CLASS_INDEX(plAvatarAnimMgr),
CLASS_INDEX(plOccluder),
CLASS_INDEX(plMobileOccluder),
CLASS_INDEX(plLayerShadowBase),
CLASS_INDEX(plLimitedDirLightInfo),
CLASS_INDEX(plAGAnim),
CLASS_INDEX(plAGModifier),
CLASS_INDEX(plAGMasterMod),
CLASS_INDEX(plCameraBrain_Avatar),
CLASS_INDEX(plCameraRegionDetector),
CLASS_INDEX(plCameraBrain_FP),
CLASS_INDEX(plLineFollowMod),
CLASS_INDEX(plLightModifier),
CLASS_INDEX(plOmniModifier),
CLASS_INDEX(plSpotModifier),
CLASS_INDEX(plLtdDirModifier),
CLASS_INDEX(plSeekPointMod),
CLASS_INDEX(plOneShotMod),
CLASS_INDEX(plRandomCommandMod),
CLASS_INDEX(plRandomSoundMod),
CLASS_INDEX(plPostEffectMod),
CLASS_INDEX(plObjectInVolumeDetector),
CLASS_INDEX(plResponderModifier),
CLASS_INDEX(plAxisAnimModifier),
CLASS_INDEX(plLayerLightBase),
CLASS_INDEX(plFollowMod),
CLASS_INDEX(plTransitionMgr),
CLASS_INDEX(UNUSED___plInventoryMod),
CLASS_INDEX(UNUSED___plInventoryObjMod),
CLASS_INDEX(plLinkEffectsMgr),
CLASS_INDEX(plWin32StreamingSound),
CLASS_INDEX(UNUSED___plPythonMod),
CLASS_INDEX(plActivatorActivatorConditionalObject),
CLASS_INDEX(plSoftVolume),
CLASS_INDEX(plSoftVolumeSimple),
CLASS_INDEX(plSoftVolumeComplex),
CLASS_INDEX(plSoftVolumeUnion),
CLASS_INDEX(plSoftVolumeIntersect),
CLASS_INDEX(plSoftVolumeInvert),
CLASS_INDEX(plWin32LinkSound),
CLASS_INDEX(plLayerLinkAnimation),
CLASS_INDEX(plArmatureMod),
CLASS_INDEX(plCameraBrain_Freelook),
CLASS_INDEX(plHavokConstraintsMod),
CLASS_INDEX(plHingeConstraintMod),
CLASS_INDEX(plWheelConstraintMod),
CLASS_INDEX(plStrongSpringConstraintMod),
CLASS_INDEX(plArmatureLODMod),
CLASS_INDEX(plWin32StaticSound),
CLASS_INDEX(pfGameGUIMgr),
CLASS_INDEX(pfGUIDialogMod),
CLASS_INDEX(plCameraBrain1),
CLASS_INDEX(plVirtualCam1),
CLASS_INDEX(plCameraModifier1),
CLASS_INDEX(plCameraBrain1_Drive),
CLASS_INDEX(plCameraBrain1_POA),
CLASS_INDEX(plCameraBrain1_Avatar),
CLASS_INDEX(plCameraBrain1_Fixed),
CLASS_INDEX(plCameraBrain1_POAFixed),
CLASS_INDEX(pfGUIButtonMod),
CLASS_INDEX(plPythonFileMod),
CLASS_INDEX(pfGUIControlMod),
CLASS_INDEX(plExcludeRegionModifier),
CLASS_INDEX(pfGUIDraggableMod),
CLASS_INDEX(plVolumeSensorConditionalObject),
CLASS_INDEX(plVolActivatorConditionalObject),
CLASS_INDEX(plMsgForwarder),
CLASS_INDEX(plBlower),
CLASS_INDEX(pfGUIListBoxMod),
CLASS_INDEX(pfGUITextBoxMod),
CLASS_INDEX(pfGUIEditBoxMod),
CLASS_INDEX(plDynamicTextMap),
CLASS_INDEX(plSittingModifier),
CLASS_INDEX(pfGUIUpDownPairMod),
CLASS_INDEX(pfGUIValueCtrl),
CLASS_INDEX(pfGUIKnobCtrl),
CLASS_INDEX(plAvLadderMod),
CLASS_INDEX(plCameraBrain1_FirstPerson),
CLASS_INDEX(plCloneSpawnModifier),
CLASS_INDEX(plClothingItem),
CLASS_INDEX(plClothingOutfit),
CLASS_INDEX(plClothingBase),
CLASS_INDEX(plClothingMgr),
CLASS_INDEX(pfGUIDragBarCtrl),
CLASS_INDEX(pfGUICheckBoxCtrl),
CLASS_INDEX(pfGUIRadioGroupCtrl),
CLASS_INDEX(pfPlayerBookMod),
CLASS_INDEX(pfGUIDynDisplayCtrl),
CLASS_INDEX(UNUSED_plLayerProject),
CLASS_INDEX(plInputInterfaceMgr),
CLASS_INDEX(plRailCameraMod),
CLASS_INDEX(plMultistageBehMod),
CLASS_INDEX(plCameraBrain1_Circle),
CLASS_INDEX(plParticleWindEffect),
CLASS_INDEX(plAnimEventModifier),
CLASS_INDEX(plAutoProfile),
CLASS_INDEX(pfGUISkin),
CLASS_INDEX(plAVIWriter),
CLASS_INDEX(plParticleCollisionEffect),
CLASS_INDEX(plParticleCollisionEffectDie),
CLASS_INDEX(plParticleCollisionEffectBounce),
CLASS_INDEX(plInterfaceInfoModifier),
CLASS_INDEX(plSharedMesh),
CLASS_INDEX(plArmatureEffectsMgr),
CLASS_INDEX(pfMarkerMgr),
CLASS_INDEX(plVehicleModifier),
CLASS_INDEX(plParticleLocalWind),
CLASS_INDEX(plParticleUniformWind),
CLASS_INDEX(plInstanceDrawInterface),
CLASS_INDEX(plShadowMaster),
CLASS_INDEX(plShadowCaster),
CLASS_INDEX(plPointShadowMaster),
CLASS_INDEX(plDirectShadowMaster),
CLASS_INDEX(plSDLModifier),
CLASS_INDEX(plPhysicalSDLModifier),
CLASS_INDEX(plClothingSDLModifier),
CLASS_INDEX(plAvatarSDLModifier),
CLASS_INDEX(plAGMasterSDLModifier),
CLASS_INDEX(plPythonSDLModifier),
CLASS_INDEX(plLayerSDLModifier),
CLASS_INDEX(plAnimTimeConvertSDLModifier),
CLASS_INDEX(plResponderSDLModifier),
CLASS_INDEX(plSoundSDLModifier),
CLASS_INDEX(plResManagerHelper),
CLASS_INDEX(plAvatarPhysicalSDLModifier),
CLASS_INDEX(plArmatureEffect),
CLASS_INDEX(plArmatureEffectFootSound),
CLASS_INDEX(plEAXListenerMod),
CLASS_INDEX(plDynaDecalMgr),
CLASS_INDEX(plObjectInVolumeAndFacingDetector),
CLASS_INDEX(plDynaFootMgr),
CLASS_INDEX(plDynaRippleMgr),
CLASS_INDEX(plDynaBulletMgr),
CLASS_INDEX(plDecalEnableMod),
CLASS_INDEX(plPrintShape),
CLASS_INDEX(plDynaPuddleMgr),
CLASS_INDEX(pfGUIMultiLineEditCtrl),
CLASS_INDEX(plLayerAnimationBase),
CLASS_INDEX(plLayerSDLAnimation),
CLASS_INDEX(plATCAnim),
CLASS_INDEX(plAgeGlobalAnim),
CLASS_INDEX(plSubworldRegionDetector),
CLASS_INDEX(plAvatarMgr),
CLASS_INDEX(plNPCSpawnMod),
CLASS_INDEX(plActivePrintShape),
CLASS_INDEX(plExcludeRegionSDLModifier),
CLASS_INDEX(plLOSDispatch),
CLASS_INDEX(plDynaWakeMgr),
CLASS_INDEX(plSimulationMgr),
CLASS_INDEX(plWaveSet7),
CLASS_INDEX(plPanicLinkRegion),
CLASS_INDEX(plWin32GroupedSound),
CLASS_INDEX(plFilterCoordInterface),
CLASS_INDEX(plStereizer),
CLASS_INDEX( plCCRMgr ),
CLASS_INDEX( plCCRSpecialist ),
CLASS_INDEX( plCCRSeniorSpecialist ),
CLASS_INDEX( plCCRShiftSupervisor ),
CLASS_INDEX( plCCRGameOperator ),
CLASS_INDEX(plShader),
CLASS_INDEX(plDynamicEnvMap),
CLASS_INDEX(plSimpleRegionSensor),
CLASS_INDEX(plMorphSequence),
CLASS_INDEX(plEmoteAnim),
CLASS_INDEX(plDynaRippleVSMgr),
CLASS_INDEX(UNUSED_plWaveSet6),
CLASS_INDEX(pfGUIProgressCtrl),
CLASS_INDEX(plMaintainersMarkerModifier),
CLASS_INDEX(plMorphSequenceSDLMod),
CLASS_INDEX(plMorphDataSet),
CLASS_INDEX(plHardRegion),
CLASS_INDEX(plHardRegionPlanes),
CLASS_INDEX(plHardRegionComplex),
CLASS_INDEX(plHardRegionUnion),
CLASS_INDEX(plHardRegionIntersect),
CLASS_INDEX(plHardRegionInvert),
CLASS_INDEX(plVisRegion),
CLASS_INDEX(plVisMgr),
CLASS_INDEX(plRegionBase),
CLASS_INDEX(pfGUIPopUpMenu),
CLASS_INDEX(pfGUIMenuItem),
CLASS_INDEX(plCoopCoordinator),
CLASS_INDEX(plFont),
CLASS_INDEX(plFontCache),
CLASS_INDEX(plRelevanceRegion),
CLASS_INDEX(plRelevanceMgr),
CLASS_INDEX(pfJournalBook),
CLASS_INDEX(plLayerTargetContainer),
CLASS_INDEX(plImageLibMod),
CLASS_INDEX(plParticleFlockEffect),
CLASS_INDEX(plParticleSDLMod),
CLASS_INDEX(plAgeLoader),
CLASS_INDEX(plWaveSetBase),
CLASS_INDEX(plPhysicalSndGroup),
CLASS_INDEX(pfBookData),
CLASS_INDEX(plDynaTorpedoMgr),
CLASS_INDEX(plDynaTorpedoVSMgr),
CLASS_INDEX(plClusterGroup),
CLASS_INDEX(plGameMarkerModifier),
CLASS_INDEX(plLODMipmap),
CLASS_INDEX(plSwimDetector),
CLASS_INDEX(plFadeOpacityMod),
CLASS_INDEX(plFadeOpacityLay),
CLASS_INDEX(plDistOpacityMod),
CLASS_INDEX(plArmatureModBase),
CLASS_INDEX(plSwimRegionInterface),
CLASS_INDEX(plSwimCircularCurrentRegion),
CLASS_INDEX(plParticleFollowSystemEffect),
CLASS_INDEX(plSwimStraightCurrentRegion),
CLASS_INDEX(pfObjectFlocker),
CLASS_INDEX(plGrassShaderMod),
CLASS_INDEX(plDynamicCamMap),
CLASS_INDEX(plRidingAnimatedPhysicalDetector),
CLASS_INDEX(plVolumeSensorConditionalObjectNoArbitration),
//---------------------------------------------------------
// Keyed objects above this line, unkeyed (such as messages) below..
//---------------------------------------------------------
CLASS_INDEX_NONKEYED_OBJ_START
CLASS_INDEX(plObjRefMsg),
CLASS_INDEX(plNodeRefMsg),
CLASS_INDEX(plMessage),
CLASS_INDEX(plRefMsg),
CLASS_INDEX(plGenRefMsg),
CLASS_INDEX(plTimeMsg),
CLASS_INDEX(plAnimCmdMsg),
CLASS_INDEX(plParticleUpdateMsg),
CLASS_INDEX(plLayRefMsg),
CLASS_INDEX(plMatRefMsg),
CLASS_INDEX(plCameraMsg),
CLASS_INDEX(plInputEventMsg),
CLASS_INDEX(plKeyEventMsg),
CLASS_INDEX(plMouseEventMsg),
CLASS_INDEX(plEvalMsg),
CLASS_INDEX(plTransformMsg),
CLASS_INDEX(plControlEventMsg),
CLASS_INDEX(plVaultCCRNode),
CLASS_INDEX(plLOSRequestMsg),
CLASS_INDEX(plLOSHitMsg),
CLASS_INDEX(plSingleModMsg),
CLASS_INDEX(plMultiModMsg),
CLASS_INDEX(plAvatarPhysicsEnableCallbackMsg),
CLASS_INDEX(plMemberUpdateMsg),
CLASS_INDEX(plNetMsgPagingRoom),
CLASS_INDEX(plActivatorMsg),
CLASS_INDEX(plDispatch),
CLASS_INDEX(plReceiver),
CLASS_INDEX(plMeshRefMsg),
CLASS_INDEX(hsGRenderProcs),
CLASS_INDEX(hsSfxAngleFade),
CLASS_INDEX(hsSfxDistFade),
CLASS_INDEX(hsSfxDistShade),
CLASS_INDEX(hsSfxGlobalShade),
CLASS_INDEX(hsSfxIntenseAlpha),
CLASS_INDEX(hsSfxObjDistFade),
CLASS_INDEX(hsSfxObjDistShade),
CLASS_INDEX(hsDynamicValue),
CLASS_INDEX(hsDynamicScalar),
CLASS_INDEX(hsDynamicColorRGBA),
CLASS_INDEX(hsDynamicMatrix33),
CLASS_INDEX(hsDynamicMatrix44),
CLASS_INDEX(plOmniSqApplicator),
CLASS_INDEX(plPreResourceMsg),
CLASS_INDEX(UNUSED_hsDynamicColorRGBA),
CLASS_INDEX(UNUSED_hsDynamicMatrix33),
CLASS_INDEX(UNUSED_hsDynamicMatrix44),
CLASS_INDEX(plController),
CLASS_INDEX(plLeafController),
CLASS_INDEX(plCompoundController),
CLASS_INDEX(UNUSED_plRotController),
CLASS_INDEX(UNUSED_plPosController),
CLASS_INDEX(UNUSED_plScalarController),
CLASS_INDEX(UNUSED_plPoint3Controller),
CLASS_INDEX(UNUSED_plScaleValueController),
CLASS_INDEX(UNUSED_plQuatController),
CLASS_INDEX(UNUSED_plMatrix33Controller),
CLASS_INDEX(UNUSED_plMatrix44Controller),
CLASS_INDEX(UNUSED_plEaseController),
CLASS_INDEX(UNUSED_plSimpleScaleController),
CLASS_INDEX(UNUSED_plSimpleRotController),
CLASS_INDEX(plCompoundRotController),
CLASS_INDEX(UNUSED_plSimplePosController),
CLASS_INDEX(plCompoundPosController),
CLASS_INDEX(plTMController),
CLASS_INDEX(hsFogControl),
CLASS_INDEX(plIntRefMsg),
CLASS_INDEX(plCollisionReactor),
CLASS_INDEX(plCorrectionMsg),
CLASS_INDEX(plPhysicalModifier),
CLASS_INDEX(plPickedMsg),
CLASS_INDEX(plCollideMsg),
CLASS_INDEX(plTriggerMsg),
CLASS_INDEX(plInterestingModMsg),
CLASS_INDEX(plDebugKeyEventMsg),
CLASS_INDEX(plPhysicalProperties_DEAD),
CLASS_INDEX(plSimplePhys),
CLASS_INDEX(plMatrixUpdateMsg),
CLASS_INDEX(plCondRefMsg),
CLASS_INDEX(plTimerCallbackMsg),
CLASS_INDEX(plEventCallbackMsg),
CLASS_INDEX(plSpawnModMsg),
CLASS_INDEX(plSpawnRequestMsg),
CLASS_INDEX(plLoadCloneMsg),
CLASS_INDEX(plEnableMsg),
CLASS_INDEX(plWarpMsg),
CLASS_INDEX(plAttachMsg),
CLASS_INDEX(pfConsole),
CLASS_INDEX(plRenderMsg),
CLASS_INDEX(plAnimTimeConvert),
CLASS_INDEX(plSoundMsg),
CLASS_INDEX(plInterestingPing),
CLASS_INDEX(plNodeCleanupMsg),
CLASS_INDEX(plSpaceTree),
CLASS_INDEX(plNetMessage),
CLASS_INDEX(plNetMsgJoinReq),
CLASS_INDEX(plNetMsgJoinAck),
CLASS_INDEX(plNetMsgLeave),
CLASS_INDEX(plNetMsgPing),
CLASS_INDEX(plNetMsgRoomsList),
CLASS_INDEX(plNetMsgGroupOwner),
CLASS_INDEX(plNetMsgGameStateRequest),
CLASS_INDEX(plNetMsgSessionReset),
CLASS_INDEX(plNetMsgOmnibus),
CLASS_INDEX(plNetMsgObject),
CLASS_INDEX(plCCRInvisibleMsg),
CLASS_INDEX(plLinkInDoneMsg),
CLASS_INDEX(plNetMsgGameMessage),
CLASS_INDEX(plNetMsgStream),
CLASS_INDEX(plAudioSysMsg),
CLASS_INDEX(plDispatchBase),
CLASS_INDEX(plServerReplyMsg),
CLASS_INDEX(plDeviceRecreateMsg),
CLASS_INDEX(plNetMsgStreamHelper),
CLASS_INDEX(plNetMsgObjectHelper),
CLASS_INDEX(plIMouseXEventMsg),
CLASS_INDEX(plIMouseYEventMsg),
CLASS_INDEX(plIMouseBEventMsg),
CLASS_INDEX(plLogicTriggerMsg),
CLASS_INDEX(plPipeline),
CLASS_INDEX(plDXPipeline),
CLASS_INDEX(plNetMsgVoice),
CLASS_INDEX(plLightRefMsg),
CLASS_INDEX(plNetMsgStreamedObject),
CLASS_INDEX(plNetMsgSharedState),
CLASS_INDEX(plNetMsgTestAndSet),
CLASS_INDEX(plNetMsgGetSharedState),
CLASS_INDEX(plSharedStateMsg),
CLASS_INDEX(plNetGenericServerTask),
CLASS_INDEX(plNetClientMgrMsg),
CLASS_INDEX(plLoadAgeMsg),
CLASS_INDEX(plMessageWithCallbacks),
CLASS_INDEX(plClientMsg),
CLASS_INDEX(plClientRefMsg),
CLASS_INDEX(plNetMsgObjStateRequest),
CLASS_INDEX(plCCRPetitionMsg),
CLASS_INDEX(plVaultCCRInitializationTask),
CLASS_INDEX(plNetServerMsg),
CLASS_INDEX(plNetServerMsgWithContext),
CLASS_INDEX(plNetServerMsgRegisterServer),
CLASS_INDEX(plNetServerMsgUnregisterServer),
CLASS_INDEX(plNetServerMsgStartProcess),
CLASS_INDEX(plNetServerMsgRegisterProcess),
CLASS_INDEX(plNetServerMsgUnregisterProcess),
CLASS_INDEX(plNetServerMsgFindProcess),
CLASS_INDEX(plNetServerMsgProcessFound),
CLASS_INDEX(plNetMsgRoutingInfo),
CLASS_INDEX(plNetServerSessionInfo),
CLASS_INDEX(plSimulationMsg),
CLASS_INDEX(plSimulationSynchMsg),
CLASS_INDEX(plHKSimulationSynchMsg),
CLASS_INDEX(plAvatarMsg),
CLASS_INDEX(plAvTaskMsg),
CLASS_INDEX(plAvSeekMsg),
CLASS_INDEX(plAvOneShotMsg),
CLASS_INDEX(plSatisfiedMsg),
CLASS_INDEX(plNetMsgObjectListHelper),
CLASS_INDEX(plNetMsgObjectUpdateFilter),
CLASS_INDEX(plProxyDrawMsg),
CLASS_INDEX(plSelfDestructMsg),
CLASS_INDEX(plSimInfluenceMsg ),
CLASS_INDEX(plForceMsg ),
CLASS_INDEX(plOffsetForceMsg ),
CLASS_INDEX(plTorqueMsg ),
CLASS_INDEX(plImpulseMsg ),
CLASS_INDEX(plOffsetImpulseMsg ),
CLASS_INDEX(plAngularImpulseMsg ),
CLASS_INDEX(plDampMsg ),
CLASS_INDEX(plShiftMassMsg ),
CLASS_INDEX(plSimStateMsg ),
CLASS_INDEX(plFreezeMsg ),
CLASS_INDEX(plEventGroupMsg ),
CLASS_INDEX(plSuspendEventMsg ),
CLASS_INDEX(plNetMsgMembersListReq),
CLASS_INDEX(plNetMsgMembersList),
CLASS_INDEX(plNetMsgMemberInfoHelper),
CLASS_INDEX(plNetMsgMemberListHelper),
CLASS_INDEX(plNetMsgMemberUpdate),
CLASS_INDEX(plNetMsgServerToClient),
CLASS_INDEX(plNetMsgCreatePlayer),
CLASS_INDEX(plNetMsgAuthenticateHello),
CLASS_INDEX(plNetMsgAuthenticateChallenge),
CLASS_INDEX(plConnectedToVaultMsg),
CLASS_INDEX(plCCRCommunicationMsg),
CLASS_INDEX(plNetMsgInitialAgeStateSent),
CLASS_INDEX(plInitialAgeStateLoadedMsg),
CLASS_INDEX(plNetServerMsgFindServerBase),
CLASS_INDEX(plNetServerMsgFindServerReplyBase),
CLASS_INDEX(plNetServerMsgFindAuthServer),
CLASS_INDEX(plNetServerMsgFindAuthServerReply),
CLASS_INDEX(plNetServerMsgFindVaultServer),
CLASS_INDEX(plNetServerMsgFindVaultServerReply),
CLASS_INDEX(plAvTaskSeekDoneMsg),
CLASS_INDEX(plNCAgeJoinerMsg),
CLASS_INDEX(plNetServerMsgVaultTask),
CLASS_INDEX(plNetMsgVaultTask),
CLASS_INDEX(plAgeLinkStruct),
CLASS_INDEX(plVaultAgeInfoNode),
CLASS_INDEX(plNetMsgStreamableHelper),
CLASS_INDEX(plNetMsgReceiversListHelper),
CLASS_INDEX(plNetMsgListenListUpdate),
CLASS_INDEX(plNetServerMsgPing),
CLASS_INDEX(plNetMsgAlive),
CLASS_INDEX(plNetMsgTerminated),
CLASS_INDEX(plSDLModifierMsg),
CLASS_INDEX(plNetMsgSDLState),
CLASS_INDEX(plNetServerMsgSessionReset),
CLASS_INDEX(plCCRBanLinkingMsg),
CLASS_INDEX(plCCRSilencePlayerMsg),
CLASS_INDEX(plRenderRequestMsg),
CLASS_INDEX(plRenderRequestAck),
CLASS_INDEX(plNetMember),
CLASS_INDEX(plNetGameMember),
CLASS_INDEX(plNetTransportMember),
CLASS_INDEX(plConvexVolume),
CLASS_INDEX(plParticleGenerator),
CLASS_INDEX(plSimpleParticleGenerator),
CLASS_INDEX(plParticleEmitter),
CLASS_INDEX(plAGChannel),
CLASS_INDEX(plMatrixChannel),
CLASS_INDEX(plMatrixTimeScale),
CLASS_INDEX(plMatrixBlend),
CLASS_INDEX(plMatrixControllerChannel),
CLASS_INDEX(plQuatPointCombine),
CLASS_INDEX(plPointChannel),
CLASS_INDEX(plPointConstant),
CLASS_INDEX(plPointBlend),
CLASS_INDEX(plQuatChannel),
CLASS_INDEX(plQuatConstant),
CLASS_INDEX(plQuatBlend),
CLASS_INDEX(plLinkToAgeMsg),
CLASS_INDEX(plPlayerPageMsg),
CLASS_INDEX(plCmdIfaceModMsg),
CLASS_INDEX(plNetServerMsgPlsUpdatePlayer),
CLASS_INDEX(plListenerMsg),
CLASS_INDEX(plAnimPath),
CLASS_INDEX(plClothingUpdateBCMsg),
CLASS_INDEX(plNotifyMsg),
CLASS_INDEX(plFakeOutMsg),
CLASS_INDEX(plCursorChangeMsg),
CLASS_INDEX(plNodeChangeMsg),
CLASS_INDEX(UNUSED_plAvEnableMsg),
CLASS_INDEX(plLinkCallbackMsg),
CLASS_INDEX(plTransitionMsg),
CLASS_INDEX(plConsoleMsg),
CLASS_INDEX(plVolumeIsect),
CLASS_INDEX(plSphereIsect),
CLASS_INDEX(plConeIsect),
CLASS_INDEX(plCylinderIsect),
CLASS_INDEX(plParallelIsect),
CLASS_INDEX(plConvexIsect),
CLASS_INDEX(plComplexIsect),
CLASS_INDEX(plUnionIsect),
CLASS_INDEX(plIntersectionIsect),
CLASS_INDEX(plModulator),
CLASS_INDEX(UNUSED___plInventoryMsg),
CLASS_INDEX(plLinkEffectsTriggerMsg),
CLASS_INDEX(plLinkEffectBCMsg),
CLASS_INDEX(plResponderEnableMsg),
CLASS_INDEX(plNetServerMsgHello),
CLASS_INDEX(plNetServerMsgHelloReply),
CLASS_INDEX(plNetServerMember),
CLASS_INDEX(plResponderMsg),
CLASS_INDEX(plOneShotMsg),
CLASS_INDEX(plVaultAgeInfoListNode),
CLASS_INDEX(plNetServerMsgServerRegistered),
CLASS_INDEX(plPointTimeScale),
CLASS_INDEX(plPointControllerChannel),
CLASS_INDEX(plQuatTimeScale),
CLASS_INDEX(plAGApplicator),
CLASS_INDEX(plMatrixChannelApplicator),
CLASS_INDEX(plPointChannelApplicator),
CLASS_INDEX(plLightDiffuseApplicator),
CLASS_INDEX(plLightAmbientApplicator),
CLASS_INDEX(plLightSpecularApplicator),
CLASS_INDEX(plOmniApplicator),
CLASS_INDEX(plQuatChannelApplicator),
CLASS_INDEX(plScalarChannel),
CLASS_INDEX(plScalarTimeScale),
CLASS_INDEX(plScalarBlend),
CLASS_INDEX(plScalarControllerChannel),
CLASS_INDEX(plScalarChannelApplicator),
CLASS_INDEX(plSpotInnerApplicator),
CLASS_INDEX(plSpotOuterApplicator),
CLASS_INDEX(plNetServerMsgPlsRoutableMsg),
CLASS_INDEX(_UNUSED_plPuppetBrainMsg),
CLASS_INDEX(plATCEaseCurve),
CLASS_INDEX(plConstAccelEaseCurve),
CLASS_INDEX(plSplineEaseCurve),
CLASS_INDEX(plVaultAgeInfoInitializationTask),
CLASS_INDEX(pfGameGUIMsg),
CLASS_INDEX(plNetServerMsgVaultRequestGameState),
CLASS_INDEX(plNetServerMsgVaultGameState),
CLASS_INDEX(plNetServerMsgVaultGameStateSave),
CLASS_INDEX(plNetServerMsgVaultGameStateSaved),
CLASS_INDEX(plNetServerMsgVaultGameStateLoad),
CLASS_INDEX(plNetClientTask),
CLASS_INDEX(plNetMsgSDLStateBCast),
CLASS_INDEX(plReplaceGeometryMsg),
CLASS_INDEX(plNetServerMsgExitProcess),
CLASS_INDEX(plNetServerMsgSaveGameState),
CLASS_INDEX(plDniCoordinateInfo),
CLASS_INDEX(plNetMsgGameMessageDirected),
CLASS_INDEX(plLinkOutUnloadMsg),
CLASS_INDEX(plScalarConstant),
CLASS_INDEX(plMatrixConstant),
CLASS_INDEX(plAGCmdMsg),
CLASS_INDEX(plParticleTransferMsg),
CLASS_INDEX(plParticleKillMsg),
CLASS_INDEX(plExcludeRegionMsg),
CLASS_INDEX(plOneTimeParticleGenerator),
CLASS_INDEX(plParticleApplicator),
CLASS_INDEX(plParticleLifeMinApplicator),
CLASS_INDEX(plParticleLifeMaxApplicator),
CLASS_INDEX(plParticlePPSApplicator),
CLASS_INDEX(plParticleAngleApplicator),
CLASS_INDEX(plParticleVelMinApplicator),
CLASS_INDEX(plParticleVelMaxApplicator),
CLASS_INDEX(plParticleScaleMinApplicator),
CLASS_INDEX(plParticleScaleMaxApplicator),
CLASS_INDEX(plDynamicTextMsg),
CLASS_INDEX(plCameraTargetFadeMsg),
CLASS_INDEX(plAgeLoadedMsg),
CLASS_INDEX(plPointControllerCacheChannel),
CLASS_INDEX(plScalarControllerCacheChannel),
CLASS_INDEX(plLinkEffectsTriggerPrepMsg),
CLASS_INDEX(plLinkEffectPrepBCMsg),
CLASS_INDEX(plAvatarInputStateMsg),
CLASS_INDEX(plAgeInfoStruct),
CLASS_INDEX(plSDLNotificationMsg),
CLASS_INDEX(plNetClientConnectAgeVaultTask),
CLASS_INDEX(plLinkingMgrMsg),
CLASS_INDEX(plVaultNotifyMsg),
CLASS_INDEX(plPlayerInfo),
CLASS_INDEX(plSwapSpansRefMsg),
CLASS_INDEX(pfKI),
CLASS_INDEX(plDISpansMsg),
CLASS_INDEX(plNetMsgCreatableHelper),
CLASS_INDEX(plCreatableUuid),
CLASS_INDEX(plNetMsgRequestMyVaultPlayerList),
CLASS_INDEX(plDelayedTransformMsg),
CLASS_INDEX(plSuperVNodeMgrInitTask),
CLASS_INDEX(plElementRefMsg),
CLASS_INDEX(plClothingMsg),
CLASS_INDEX(plEventGroupEnableMsg),
CLASS_INDEX(pfGUINotifyMsg),
CLASS_INDEX(UNUSED_plAvBrain),
CLASS_INDEX(plArmatureBrain),
CLASS_INDEX(plAvBrainHuman),
CLASS_INDEX(plAvBrainCritter),
CLASS_INDEX(plAvBrainDrive),
CLASS_INDEX(plAvBrainSample),
CLASS_INDEX(plAvBrainGeneric),
CLASS_INDEX(plPreloaderMsg),
CLASS_INDEX(plAvBrainLadder),
CLASS_INDEX(plInputIfaceMgrMsg),
CLASS_INDEX(pfKIMsg),
CLASS_INDEX(plRemoteAvatarInfoMsg),
CLASS_INDEX(plMatrixDelayedCorrectionApplicator),
CLASS_INDEX(plAvPushBrainMsg),
CLASS_INDEX(plAvPopBrainMsg),
CLASS_INDEX(plRoomLoadNotifyMsg),
CLASS_INDEX(plAvTask),
CLASS_INDEX(plAvAnimTask),
CLASS_INDEX(plAvSeekTask),
CLASS_INDEX(plNetCommAuthConnectedMsg),
CLASS_INDEX(plAvOneShotTask),
CLASS_INDEX(UNUSED_plAvEnableTask),
CLASS_INDEX(plAvTaskBrain),
CLASS_INDEX(plAnimStage),
CLASS_INDEX(plNetClientMember),
CLASS_INDEX(plNetClientCommTask),
CLASS_INDEX(plNetServerMsgAuthRequest),
CLASS_INDEX(plNetServerMsgAuthReply),
CLASS_INDEX(plNetClientCommAuthTask),
CLASS_INDEX(plClientGuid),
CLASS_INDEX(plNetMsgVaultPlayerList),
CLASS_INDEX(plNetMsgSetMyActivePlayer),
CLASS_INDEX(plNetServerMsgRequestAccountPlayerList),
CLASS_INDEX(plNetServerMsgAccountPlayerList),
CLASS_INDEX(plNetMsgPlayerCreated),
CLASS_INDEX(plNetServerMsgVaultCreatePlayer),
CLASS_INDEX(plNetServerMsgVaultPlayerCreated),
CLASS_INDEX(plNetMsgFindAge),
CLASS_INDEX(plNetMsgFindAgeReply),
CLASS_INDEX(plNetClientConnectPrepTask),
CLASS_INDEX(plNetClientAuthTask),
CLASS_INDEX(plNetClientGetPlayerVaultTask),
CLASS_INDEX(plNetClientSetActivePlayerTask),
CLASS_INDEX(plNetClientFindAgeTask),
CLASS_INDEX(plNetClientLeaveTask),
CLASS_INDEX(plNetClientJoinTask),
CLASS_INDEX(plNetClientCalibrateTask),
CLASS_INDEX(plNetMsgDeletePlayer),
CLASS_INDEX(plNetServerMsgVaultDeletePlayer),
CLASS_INDEX(plNetCoreStatsSummary),
CLASS_INDEX(plCreatableGenericValue),
CLASS_INDEX(plCreatableListHelper),
CLASS_INDEX(plCreatableStream),
CLASS_INDEX(plAvBrainGenericMsg),
CLASS_INDEX(plAvTaskSeek),
CLASS_INDEX(plAGInstanceCallbackMsg),
CLASS_INDEX(plArmatureEffectMsg),
CLASS_INDEX(plArmatureEffectStateMsg),
CLASS_INDEX(plShadowCastMsg),
CLASS_INDEX(plBoundsIsect),
CLASS_INDEX(plResMgrHelperMsg),
CLASS_INDEX(plNetCommAuthMsg),
CLASS_INDEX(plNetCommFileListMsg),
CLASS_INDEX(plNetCommFileDownloadMsg),
CLASS_INDEX(plNetCommLinkToAgeMsg),
CLASS_INDEX(plNetCommPlayerListMsg),
CLASS_INDEX(plNetCommActivePlayerMsg),
CLASS_INDEX(plNetCommCreatePlayerMsg),
CLASS_INDEX(plNetCommDeletePlayerMsg),
CLASS_INDEX(plNetCommPublicAgeListMsg),
CLASS_INDEX(plNetCommPublicAgeMsg),
CLASS_INDEX(plNetCommRegisterAgeMsg),
CLASS_INDEX(plVaultAdminInitializationTask),
CLASS_INDEX(plMultistageModMsg),
CLASS_INDEX(plSoundVolumeApplicator),
CLASS_INDEX(plCutter),
CLASS_INDEX(plBulletMsg),
CLASS_INDEX(plDynaDecalEnableMsg),
CLASS_INDEX(plOmniCutoffApplicator),
CLASS_INDEX(plArmatureUpdateMsg),
CLASS_INDEX(plAvatarFootMsg),
CLASS_INDEX(plNetOwnershipMsg),
CLASS_INDEX(plNetMsgRelevanceRegions),
CLASS_INDEX(plParticleFlockMsg),
CLASS_INDEX(plAvatarBehaviorNotifyMsg),
CLASS_INDEX(plATCChannel),
CLASS_INDEX(plScalarSDLChannel),
CLASS_INDEX(plLoadAvatarMsg),
CLASS_INDEX(plAvatarSetTypeMsg),
CLASS_INDEX(plNetMsgLoadClone),
CLASS_INDEX(plNetMsgPlayerPage),
CLASS_INDEX(plVNodeInitTask),
CLASS_INDEX(plRippleShapeMsg),
CLASS_INDEX(plEventManager),
CLASS_INDEX(plVaultNeighborhoodInitializationTask),
CLASS_INDEX(plNetServerMsgAgentRecoveryRequest),
CLASS_INDEX(plNetServerMsgFrontendRecoveryRequest),
CLASS_INDEX(plNetServerMsgBackendRecoveryRequest),
CLASS_INDEX(plNetServerMsgAgentRecoveryData),
CLASS_INDEX(plNetServerMsgFrontendRecoveryData),
CLASS_INDEX(plNetServerMsgBackendRecoveryData),
CLASS_INDEX(plSubWorldMsg),
CLASS_INDEX(plMatrixDifferenceApp),
CLASS_INDEX(plAvatarSpawnNotifyMsg),
// ** NOTE **: DO NOT INSERT CLASS_INDEXES HERE. Ignore all this junk
// and continue adding them at the bottom of the enum. - EAp
// -- Reserve a block of class indexes for auto-generated server database structs --
CLASS_INDEX_DATABASE_STRUCT_INDEXES_START
CLASS_INDEX_DATABASE_STRUCT_INDEXES_END
CLASS_INDEX(plVaultGameServerInitializationTask),
CLASS_INDEX(plNetClientFindDefaultAgeTask),
CLASS_INDEX(plVaultAgeNode),
CLASS_INDEX(plVaultAgeInitializationTask),
CLASS_INDEX(plSetListenerMsg),
CLASS_INDEX(plVaultSystemNode),
CLASS_INDEX(plAvBrainSwim),
CLASS_INDEX(plNetMsgVault),
CLASS_INDEX(plNetServerMsgVault),
CLASS_INDEX(plVaultTask), // =1066
CLASS_INDEX(plVaultConnectTask),
CLASS_INDEX(plVaultNegotiateManifestTask),
CLASS_INDEX(plVaultFetchNodesTask),
CLASS_INDEX(plVaultSaveNodeTask),
CLASS_INDEX(plVaultFindNodeTask),
CLASS_INDEX(plVaultAddNodeRefTask),
CLASS_INDEX(plVaultRemoveNodeRefTask),
CLASS_INDEX(plVaultSendNodeTask),
CLASS_INDEX(plVaultNotifyOperationCallbackTask),
CLASS_INDEX(plVNodeMgrInitializationTask),
CLASS_INDEX(plVaultPlayerInitializationTask),
CLASS_INDEX(plNetVaultServerInitializationTask),
CLASS_INDEX(plCommonNeighborhoodsInitTask),
CLASS_INDEX(plVaultNodeRef),
CLASS_INDEX(plVaultNode),
CLASS_INDEX(plVaultFolderNode),
CLASS_INDEX(plVaultImageNode),
CLASS_INDEX(plVaultTextNoteNode),
CLASS_INDEX(plVaultSDLNode),
CLASS_INDEX(plVaultAgeLinkNode),
CLASS_INDEX(plVaultChronicleNode),
CLASS_INDEX(plVaultPlayerInfoNode),
CLASS_INDEX(plVaultMgrNode),
CLASS_INDEX(plVaultPlayerNode),
CLASS_INDEX(plSynchEnableMsg),
CLASS_INDEX(plNetVaultServerNode),
CLASS_INDEX(plVaultAdminNode),
CLASS_INDEX(plVaultGameServerNode),
CLASS_INDEX(plVaultPlayerInfoListNode),
CLASS_INDEX(plAvatarStealthModeMsg),
CLASS_INDEX(plEventCallbackInterceptMsg),
CLASS_INDEX(plDynamicEnvMapMsg),
CLASS_INDEX(plClimbMsg),
CLASS_INDEX(plIfaceFadeAvatarMsg),
CLASS_INDEX(plAvBrainClimb),
CLASS_INDEX(plSharedMeshBCMsg),
CLASS_INDEX(plNetVoiceListMsg),
CLASS_INDEX(plSwimMsg),
CLASS_INDEX(plMorphDelta),
CLASS_INDEX(plMatrixControllerCacheChannel),
CLASS_INDEX(plVaultMarkerNode),
CLASS_INDEX(pfMarkerMsg),
CLASS_INDEX(plPipeResMakeMsg),
CLASS_INDEX(plPipeRTMakeMsg),
CLASS_INDEX(plPipeGeoMakeMsg),
CLASS_INDEX(plAvCoopMsg),
CLASS_INDEX(plAvBrainCoop),
CLASS_INDEX(plSimSuppressMsg),
CLASS_INDEX(plVaultMarkerListNode),
CLASS_INDEX(UNUSED_plAvTaskOrient),
CLASS_INDEX(plAgeBeginLoadingMsg),
CLASS_INDEX(plSetNetGroupIDMsg),
CLASS_INDEX(pfBackdoorMsg),
CLASS_INDEX(plAIMsg),
CLASS_INDEX(plAIBrainCreatedMsg),
CLASS_INDEX(plStateDataRecord),
CLASS_INDEX(plNetClientCommDeletePlayerTask),
CLASS_INDEX(plNetMsgSetTimeout),
CLASS_INDEX(plNetMsgActivePlayerSet),
CLASS_INDEX(plNetClientCommSetTimeoutTask),
CLASS_INDEX(plNetRoutableMsgOmnibus),
CLASS_INDEX(plNetMsgGetPublicAgeList),
CLASS_INDEX(plNetMsgPublicAgeList),
CLASS_INDEX(plNetMsgCreatePublicAge),
CLASS_INDEX(plNetMsgPublicAgeCreated),
CLASS_INDEX(plNetServerMsgEnvelope),
CLASS_INDEX(plNetClientCommGetPublicAgeListTask),
CLASS_INDEX(plNetClientCommCreatePublicAgeTask),
CLASS_INDEX(plNetServerMsgPendingMsgs),
CLASS_INDEX(plNetServerMsgRequestPendingMsgs),
CLASS_INDEX(plDbInterface),
CLASS_INDEX(plDbProxyInterface),
CLASS_INDEX(plDBGenericSQLDB),
CLASS_INDEX(pfGameMgrMsg),
CLASS_INDEX(pfGameCliMsg),
CLASS_INDEX(pfGameCli),
CLASS_INDEX(pfGmTicTacToe),
CLASS_INDEX(pfGmHeek),
CLASS_INDEX(pfGmMarker),
CLASS_INDEX(pfGmBlueSpiral),
CLASS_INDEX(pfGmClimbingWall),
CLASS_INDEX(plAIArrivedAtGoalMsg),
CLASS_INDEX(pfGmVarSync),
CLASS_INDEX(plNetMsgRemovePublicAge),
CLASS_INDEX(plNetMsgPublicAgeRemoved),
CLASS_INDEX(plNetClientCommRemovePublicAgeTask),
CLASS_INDEX(plCCRMessage),
CLASS_INDEX(plAvOneShotLinkTask),
CLASS_INDEX(plNetAuthDatabase),
CLASS_INDEX(plAvatarOpacityCallbackMsg),
CLASS_INDEX(plAGDetachCallbackMsg),
CLASS_INDEX(pfMovieEventMsg),
CLASS_INDEX(plMovieMsg),
CLASS_INDEX(plPipeTexMakeMsg),
CLASS_INDEX(plEventLog),
CLASS_INDEX(plDbEventLog),
CLASS_INDEX(plSyslogEventLog),
CLASS_INDEX(plCaptureRenderMsg),
CLASS_INDEX(plAgeLoaded2Msg),
CLASS_INDEX(plPseudoLinkEffectMsg),
CLASS_INDEX(plPseudoLinkAnimTriggerMsg),
CLASS_INDEX(plPseudoLinkAnimCallbackMsg),
CLASS_INDEX(__UNUSED__pfClimbingWallMsg),
CLASS_INDEX(plClimbEventMsg),
CLASS_INDEX(__UNUSED__plAvBrainQuab),
CLASS_INDEX(plAccountUpdateMsg),
CLASS_INDEX(plLinearVelocityMsg),
CLASS_INDEX(plAngularVelocityMsg),
CLASS_INDEX(plRideAnimatedPhysMsg),
CLASS_INDEX(plAvBrainRideAnimatedPhysical),
CLASS_INDEX_LIST_END
#endif // plCreatableIndex_inc

View File

@ -0,0 +1,94 @@
/*==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==*/
//////////////////////////////////////////////////////////////////////////////
//
// plCreatableStrings.h - Handy header file that declares a class with two
// static public string arrays representing the names
// of the classes before and after keyedObjDelineator
// in plCreatableIndex.h. Note the cunning (and humble)
// use of macros to avoid having to change this file
// whenever plCreatableIndex.h changes.
//
// Should only be included once, probably in plFactory.cpp
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _plCreatableStrings_h
#define _plCreatableStrings_h
// Step 0: Undefine plCreatableIndex_inc, since we're doing something sneaky with it
#undef plCreatableIndex_inc
// Step 1: Define plCreator_inc, so the plCreator.h include in plCI.h won't do anything
#define plCreator_inc
// Step 2: Define the CLASS_INDEX macros so we generate our class. The class name
// is plCreatableStrings and the arrays are fKeyedStrings and fNonKeyedStrings
#undef CLASS_INDEX_LIST_START
#undef CLASS_INDEX
#undef CLASS_INDEX_NONKEYED_OBJ_START
#undef CLASS_INDEX_LIST_END
#define CLASS_INDEX_LIST_START class plCreatableStrings { public:\
static char *fKeyedStrings[]; static char *fNonKeyedStrings[]; static char *fNonKeyedPostDBStrings[];\
}; \
char *plCreatableStrings::fKeyedStrings[] = {
#define CLASS_INDEX(ci) #ci
#define CLASS_INDEX_NONKEYED_OBJ_START }; char *plCreatableStrings::fNonKeyedStrings[] = {
#define CLASS_INDEX_LIST_END };
#undef CLASS_INDEX_DATABASE_STRUCT_INDEXES_START
#undef CLASS_INDEX_DATABASE_STRUCT_INDEXES_END
#define CLASS_INDEX_DATABASE_STRUCT_INDEXES_START
#define CLASS_INDEX_DATABASE_STRUCT_INDEXES_END }; char *plCreatableStrings::fNonKeyedPostDBStrings[] = {
// Step 3: Include plCI.h
#include "plCreatableIndex.h"
#endif // _plCreatableStrings_h

View File

@ -0,0 +1,202 @@
/*==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 plDrawable_inc
#define plDrawable_inc
#include "../pnKeyedObject/hsKeyedObject.h"
#include "plLoadMask.h"
#include "hsTemplates.h"
#include "plRenderLevel.h"
class plSpaceTree;
class hsStream;
class hsResMgr;
struct hsMatrix44;
class hsBounds3Ext;
class plPipeline;
class plGeometrySpan;
class hsGMaterial;
class plParticleEmitter;
class plAccessSpan;
class plDrawableCriteria
{
public:
plDrawableCriteria(UInt32 crit, const plRenderLevel& lev, const plLoadMask& m, UInt32 ty=1 /* Normal */ ) : fCriteria(crit), fLevel(lev), fType(ty), fLoadMask(m) {}
UInt32 fCriteria;
plRenderLevel fLevel;
UInt32 fType;
plLoadMask fLoadMask;
};
class plDrawable : public hsKeyedObject
{
public:
enum {
// Renumber these the next time we bump major version #s (no reason to do it now)
kPropNoDraw = 0x01,
kPropUNUSED = 0x02,
kPropSortSpans = 0x04,
kPropSortFaces = 0x08,
kPropVolatile = 0x10, // Means that spans DEFAULT to kPropVolatile, but if this
// is not set, spans can still be volatile
kPropNoReSort = 0x20, // Don't do sorting of spans for optimization.
kPropPartialSort = 0x40, // Sort spans on an individual basis.
kPropCharacter = 0x80, // Lights want to know if this is in the general class of "characters"
kPropSortAsOne = 0x100,
kPropHasVisLOS = 0x200
};
// Criteria for drawables. Used when searching through a sceneNode for a particular drawable
enum
{
kCritStatic = 0x01,
kCritSortSpans = 0x02,
kCritSortFaces = 0x08,
kCritCharacter = 0x10
};
// Types of drawables for rendering filtering.
enum plDrawableType {
kNormal = 0x00000001,
kNonDrawable = 0x00000002, //e.g. a light, affects drawing, but isn't drawn.
kEnviron = 0x00000004,
// Proxies in the upper 16 bits.
kLightProxy = 0x00010000,
kOccluderProxy = 0x00020000,
kAudibleProxy = 0x00040000,
kPhysicalProxy = 0x00080000,
kCoordinateProxy = 0x00100000,
kOccSnapProxy = 0x00200000,
kGenericProxy = 0x00400000,
kCameraProxy = 0x00800000,
kAllProxies = 0x00ff0000,
kAllTypes = 0xffffffff
};
enum plSubDrawableType {
kSubNormal = 0x00000001,
kSubNonDrawable = 0x00000002,
kSubEnviron = 0x00000004,
kSubAllTypes = 0xffffffff
};
enum plAccessFlags {
kReadSrc = 0x1,
kWriteDst = 0x2,
kWriteSrc = 0x4
};
enum MsgTypes
{
kMsgMaterial,
kMsgDISpans, // UNUSED
kMsgFogEnviron,
kMsgPermaLight,
kMsgPermaProj,
kMsgPermaLightDI,
kMsgPermaProjDI
};
CLASSNAME_REGISTER( plDrawable );
GETINTERFACE_ANY( plDrawable, hsKeyedObject );
virtual plDrawable& SetProperty( int prop, hsBool on ) = 0;
virtual hsBool GetProperty( int prop ) const = 0;
virtual plDrawable& SetProperty( UInt32 index, int prop, hsBool on ) = 0;
virtual hsBool GetProperty( UInt32 index, int prop ) const = 0;
virtual plDrawable& SetNativeProperty( int prop, hsBool on ) = 0;
virtual hsBool GetNativeProperty( int prop ) const = 0;
virtual plDrawable& SetNativeProperty( UInt32 index, int prop, hsBool on ) = 0;
virtual hsBool GetNativeProperty( UInt32 index, int prop ) const = 0;
virtual plDrawable& SetSubType( UInt32 index, plSubDrawableType t, hsBool on ) = 0;
virtual UInt32 GetSubType( UInt32 index ) const = 0; // returns or of all spans with this index (index==-1 is all spans).
virtual UInt32 GetType( void ) const = 0;
virtual void SetType( UInt32 type ) = 0;
virtual void SetRenderLevel(const plRenderLevel& l) = 0;
virtual const plRenderLevel& GetRenderLevel() const = 0;
virtual plDrawable& SetTransform( UInt32 index, const hsMatrix44& l2w, const hsMatrix44& w2l ) = 0;
virtual const hsMatrix44& GetLocalToWorld( UInt32 span = (UInt32)-1 ) const = 0;
virtual const hsMatrix44& GetWorldToLocal( UInt32 span = (UInt32)-1 ) const = 0;
virtual const hsBounds3Ext& GetLocalBounds( UInt32 index = (UInt32)-1 ) const = 0;
virtual const hsBounds3Ext& GetWorldBounds( UInt32 index = (UInt32)-1 ) const = 0;
virtual const hsBounds3Ext& GetMaxWorldBounds( UInt32 index = (UInt32)-1 ) const = 0;
virtual plSpaceTree* GetSpaceTree() const = 0;
virtual void SetDISpanVisSet(UInt32 diIndex, hsKeyedObject* reg, hsBool on) = 0;
// Taking span index. DI Index doesn't make sense here, because one object's DI can dereference into many materials etc.
virtual hsGMaterial* GetSubMaterial(int index) const = 0;
virtual hsBool GetSubVisDists(int index, hsScalar& minDist, hsScalar& maxDist) const = 0; // return true if span invisible before minDist and/or after maxDist
// Should implement hsKeyedObject Read/Write/Save/Load as well
// These two should only be called by the SceneNode
virtual void SetSceneNode(plKey node) = 0;
virtual plKey GetSceneNode() const = 0;
/// Funky particle system functions
virtual UInt32 CreateParticleSystem( UInt32 maxNumEmitters, UInt32 maxNumParticles, hsGMaterial *material ) = 0;
virtual void ResetParticleSystem( UInt32 index ) = 0;
virtual void AssignEmitterToParticleSystem( UInt32 index, plParticleEmitter *emitter ) = 0;
/// EXPORT-ONLY
// Called by the sceneNode to determine if we match the criteria
virtual hsBool DoIMatch( const plDrawableCriteria& crit ) = 0;
// Take the list of triMeshes and convert them to buffers, building a list of spans for each
virtual void Optimize( void ) = 0;
};
#endif // plDrawable_inc

View File

@ -0,0 +1,41 @@
/*==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==*/

View File

@ -0,0 +1,132 @@
/*==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 plPhysical_inc
#define plPhysical_inc
#include "../pnNetCommon/plSynchedObject.h"
#include "hsTemplates.h"
struct hsMatrix44;
struct hsPoint3;
struct hsVector3;
class hsQuat;
class plPhysicalSndGroup;
class plDrawableSpans;
class hsGMaterial;
// Primary interface object for physics functionality. A physical corresponds to
// a single rigid body in a simulation. (Note that there can be multiple
// simulations.) The plPhysical is reached through the simulation interface on a
// plSceneObject
//
// Any function that ends with 'Sim' gets or sets a simulation space value. If
// the physical is in the main world, this will be the same as a global value,
// but if it's in a subworld, it will be relative to that.
class plPhysical : public plSynchedObject
{
public:
CLASSNAME_REGISTER(plPhysical);
GETINTERFACE_ANY(plPhysical, plSynchedObject);
virtual plPhysical& SetProperty(int prop, hsBool b) = 0;
virtual hsBool GetProperty(int prop) const = 0;
virtual void SetObjectKey(plKey oKey) = 0;
virtual plKey GetObjectKey() const = 0;
// These two should only be called by the SceneNode
virtual void SetSceneNode(plKey node) = 0;
virtual plKey GetSceneNode() const = 0;
virtual hsBool GetLinearVelocitySim(hsVector3& vel) const = 0;
virtual void SetLinearVelocitySim(const hsVector3& vel) = 0;
virtual void ClearLinearVelocity() = 0;
virtual hsBool GetAngularVelocitySim(hsVector3& vel) const = 0;
virtual void SetAngularVelocitySim(const hsVector3& vel) = 0;
virtual void SetHitForce(const hsVector3& force, const hsPoint3& pos)=0;
/** Standard plasma transform interface, in global coordinates by convention.
If you send in the same matrix that the physical last sent out in its correction message,
it will be ignored as an "echo" -- UNLESS you set force to true, in which case the transform
will be applied regardless.
Set force to true if you don't want the transform to be ignored for any reason. Without it,
this will ignore the incoming transform if it's the same one it sent out last time. */
virtual void SetTransform(const hsMatrix44& l2w, const hsMatrix44& w2l, hsBool force=false) = 0;
virtual void GetTransform(hsMatrix44& l2w, hsMatrix44& w2l) = 0;
// From plSimDefs::Group
virtual int GetGroup() const = 0;
// Flags in plSimDefs::plLOSDB
virtual void AddLOSDB(UInt16 flag) = 0;
virtual void RemoveLOSDB(UInt16 flag) = 0;
virtual UInt16 GetAllLOSDBs() = 0;
virtual hsBool IsInLOSDB(UInt16 flag) = 0;
// Return the key of our subworld. May be a nil key.
virtual plKey GetWorldKey() const = 0;
virtual plPhysicalSndGroup* GetSoundGroup() const = 0;
virtual void GetPositionSim(hsPoint3& pos) const = 0;
/** Send the current simulation location to the coordinate interface.
If the simulation is a subworld, this will also factor in the subworld's
transform. The sent transform is global. "isSynchUpdate" tells us if this
is an update due to receiving remote state.*/
virtual void SendNewLocation(hsBool synchTransform = false, hsBool isSynchUpdate = false) = 0;
// For the physics SDL only. For Set, any of the values may be set to nil, if
// they're not used.
virtual void GetSyncState(hsPoint3& pos, hsQuat& rot, hsVector3& linV, hsVector3& angV) = 0;
virtual void SetSyncState(hsPoint3* pos, hsQuat* rot, hsVector3* linV, hsVector3* angV) = 0;
virtual hsScalar GetMass() = 0;
// I wish I could think of a better way to do this, but this is how it's
// going to be for now.
virtual void ExcludeRegionHack(hsBool cleared) = 0;
virtual plDrawableSpans* CreateProxy(hsGMaterial* mat, hsTArray<UInt32>& idx, plDrawableSpans* addTo) = 0;
};
#endif // plPhysical_inc

View File

@ -0,0 +1,69 @@
/*==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 plPipeResReq_inc
#define plPipeResReq_inc
//#define PIPERES_VERBOSE
#ifdef PIPERES_VERBOSE
#define PIPELOG(a) hsStatusMessage(a)
#else // PIPERES_VERBOSE
#define PIPELOG(a)
#endif // PIPERES_VERBOSE
class plPipeResReq
{
protected:
hsBool fReq;
plPipeResReq() : fReq(false) {}
static plPipeResReq& Instance();
public:
static void Request() { PIPELOG("Request"); Instance().fReq = true; }
static hsBool Check() { PIPELOG("Check"); return Instance().fReq; }
static void Clear() { PIPELOG("Clear"); Instance().fReq = false; }
};
#endif // plPipeResReq_inc

View File

@ -0,0 +1,362 @@
/*==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 plPipeline_inc
#define plPipeline_inc
#include "../pnFactory/plCreatable.h"
#include "hsGMatState.h"
#include "hsTemplates.h"
#include "hsStlUtils.h"
#define MIN_WIDTH 640
#define MIN_HEIGHT 480
#define DEFAULT_WIDTH 800
#define DEFAULT_HEIGHT 600
#define DEFAULT_WINDOWED false
#define DEFAULT_COLORDEPTH 32
#define DEFAULT_ANTIALIASAMOUNT 0
#define DEFAULT_ANISOLEVEL 0
#define DEFAULT_TEXTUREQUALITY 2
#define DEFAULT_VIDEOQUALITY 2
#define DEFAULT_SHADOWS 0
#define DEFAULT_PLANARREFLECTIONS 0
struct hsPoint3;
struct hsVector3;
struct hsMatrix44;
struct hsColorRGBA;
class hsBounds3Ext;
class hsGMaterial;
class plDrawPrim;
class plRenderTarget;
class hsG3DDevice;
class hsGView3;
class plDrawable;
class plGBufferGroup;
class plLayerInterface;
class plSpaceTree;
class plCullPoly;
class plRenderRequest;
class plShadowSlave;
class plAccessSpan;
class plTextFont;
class plVertexSpan;
class plDrawableSpans;
class plSceneObject;
class plClothingOutfit;
class hsGDeviceRef;
class plFogEnvironment;
class plLightInfo;
class plMipmap;
class plVisMgr;
class plViewTransform;
struct PipelineParams
{
PipelineParams():
Width(DEFAULT_WIDTH),
Height(DEFAULT_HEIGHT),
Windowed(DEFAULT_WINDOWED),
ColorDepth(DEFAULT_COLORDEPTH),
AntiAliasingAmount(DEFAULT_ANTIALIASAMOUNT),
AnisotropicLevel(DEFAULT_ANISOLEVEL),
TextureQuality(DEFAULT_TEXTUREQUALITY),
VideoQuality(DEFAULT_VIDEOQUALITY),
Shadows(DEFAULT_SHADOWS),
PlanarReflections(DEFAULT_PLANARREFLECTIONS),
#ifndef PLASMA_EXTERNAL_RELEASE
ForceSecondMonitor(false),
#endif // PLASMA_EXTERNAL_RELEASE
VSync(false)
{
}
int Width;
int Height;
hsBool Windowed;
int ColorDepth;
int AntiAliasingAmount;
int AnisotropicLevel;
int TextureQuality;
int VideoQuality;
int Shadows;
int PlanarReflections;
hsBool VSync;
#ifndef PLASMA_EXTERNAL_RELEASE
hsBool ForceSecondMonitor;
#endif // PLASMA_EXTERNAL_RELEASE
};
class plDisplayMode
{
public:
int Width;
int Height;
int ColorDepth;
};
class plPipeline : public plCreatable
{
public:
CLASSNAME_REGISTER( plPipeline );
GETINTERFACE_ANY( plPipeline, plCreatable );
// Typical 3D device
//
// PreRender - fill out the visList with which spans from drawable will be drawn.
// visList is write only. On output, visList is UNSORTED visible spans.
// Called once per scene render (maybe multiple times per frame).
// Returns true if rendering should proceed.
virtual hsBool PreRender(plDrawable* drawable, hsTArray<Int16>& visList, plVisMgr* visMgr=nil) = 0;
// PrepForRender - perform any processing on the drawable data nessecary before rendering.
// visList is read only. On input, visList is SORTED visible spans, and is ALL spans which will be drawn this render.
// Called once per scene render.
// Returns true if rendering should proceed.
virtual hsBool PrepForRender(plDrawable* drawable, hsTArray<Int16>& visList, plVisMgr* visMgr=nil) = 0;
// Render - draw the drawable to the current render target.
// visList is read only. On input, visList is SORTED visible spans. May not be the complete list of visible spans
// for this drawable.
// Called multiple times per scene render e.g.:
// Render(drawable0, visList0) // visList0 contains furthest spans in drawable0
// Render(drawable1, visList1) // visList1 contains spans from drawable1 between drawable0's visList0 and visList2
// Render(drawable0, visList2) // visList2 contains closest spans in drawable0.
virtual void Render(plDrawable* d, const hsTArray<Int16>& visList) = 0;
// Draw - Convenience wrapper for standalone renders. Calls PreRender, PrepForRender, Render. Currently for internal
// use only, but may prove useful for procedurals (render to texture).
virtual void Draw(plDrawable* d) = 0;
// Device-specific ref creation. Includes buffers and fonts
virtual plTextFont *MakeTextFont( char *face, UInt16 size ) = 0;
// Create and/or Refresh geometry buffers
virtual void CheckVertexBufferRef(plGBufferGroup* owner, UInt32 idx) = 0;
virtual void CheckIndexBufferRef(plGBufferGroup* owner, UInt32 idx) = 0;
virtual hsBool OpenAccess(plAccessSpan& dst, plDrawableSpans* d, const plVertexSpan* span, hsBool readOnly) = 0;
virtual hsBool CloseAccess(plAccessSpan& acc) = 0;
virtual void CheckTextureRef(plLayerInterface* lay) = 0;
// Default fog settings
virtual void SetDefaultFogEnviron( plFogEnvironment *fog ) = 0;
virtual const plFogEnvironment &GetDefaultFogEnviron( void ) const = 0;
virtual void RegisterLight(plLightInfo* light) = 0;
virtual void UnRegisterLight(plLightInfo* light) = 0;
enum RenderTargetFlags
{
kRTMainScreen = 0x0000,
kRTOffscreen = 0x0001,
kRTTexture = 0x0002,
kRTPerspProjected = 0x0004,
kRTOrthoProjected = 0x0008,
kRTProjected = kRTPerspProjected | kRTOrthoProjected
};
enum RenderStateSettings
{
kRenderNormal = 0x0,
kRenderProjection = 0x1,
kRenderShadow = 0x2,
kRenderBaseLayerOnly = 0x4,
kRenderNoPiggyBacks = 0x8,
kRenderClearColor = 0x10,
kRenderClearDepth = 0x20,
kRenderOrthogonal = 0x40,
kRenderNoProjection = 0x80,
kRenderNoLights = 0x100,
kRenderShadowErase = 0x200
};
virtual void PushRenderRequest(plRenderRequest* req) = 0;
virtual void PopRenderRequest(plRenderRequest* req) = 0;
virtual void ClearRenderTarget( plDrawable* d ) = 0; // nil d reverts to ClearRenderTarget(nil, nil).
virtual void ClearRenderTarget(const hsColorRGBA* col = nil, const hsScalar* depth = nil) = 0; // col/depth are overrides for current default.
virtual void SetClear(const hsColorRGBA* col=nil, const hsScalar* depth=nil) = 0; // sets the default clear for current render target.
virtual hsColorRGBA GetClearColor() const = 0;
virtual hsScalar GetClearDepth() const = 0;
virtual hsGDeviceRef *MakeRenderTargetRef( plRenderTarget *owner ) = 0;
virtual void PushRenderTarget( plRenderTarget *target ) = 0;
virtual plRenderTarget *PopRenderTarget( void ) = 0;
virtual hsBool BeginRender() = 0;
virtual hsBool EndRender() = 0;
virtual void RenderScreenElements( void ) = 0;
virtual hsBool BeginDrawable(plDrawable* d) = 0;
virtual hsBool EndDrawable(plDrawable* d) = 0;
virtual void BeginVisMgr(plVisMgr* visMgr) = 0;
virtual void EndVisMgr(plVisMgr* visMgr) = 0;
virtual hsBool IsFullScreen() const = 0;
virtual UInt32 Width() const = 0;
virtual UInt32 Height() const = 0;
virtual UInt32 ColorDepth() const = 0;
virtual void Resize( UInt32 width, UInt32 height ) = 0;
// Culling. Might be used in Update before bothering to do any serious computation.
virtual hsBool TestVisibleWorld(const hsBounds3Ext& wBnd) = 0;
virtual hsBool TestVisibleWorld(const plSceneObject* sObj) = 0;
virtual hsBool HarvestVisible(plSpaceTree* space, hsTArray<Int16>& visList) = 0;
virtual hsBool SubmitOccluders(const hsTArray<const plCullPoly*>& polyList) = 0;
virtual void SetDebugFlag( UInt32 flag, hsBool on ) = 0;
virtual hsBool IsDebugFlagSet( UInt32 flag ) const = 0;
virtual void SetMaxCullNodes(UInt16 n) = 0; // Debug/analysis only
virtual UInt16 GetMaxCullNodes() const = 0; // Debug/analysis only
// Properties
enum Properties
{
kPropDontDeleteTextures = 0x00000001 // Keeps the pipeline from deleting textures on
// MakeTextureRef, regardless of the kUserOwnsBitmap flag
};
virtual hsBool CheckResources() = 0; // Do we need to call LoadResources?
virtual void LoadResources() = 0;
virtual void SetProperty( UInt32 prop, hsBool on ) = 0;
virtual hsBool GetProperty( UInt32 prop ) const = 0;
virtual UInt32 GetMaxLayersAtOnce() const = 0;
// Drawable type mask
virtual void SetDrawableTypeMask( UInt32 mask ) = 0;
virtual UInt32 GetDrawableTypeMask( void ) const = 0;
virtual void SetSubDrawableTypeMask( UInt32 mask ) = 0;
virtual UInt32 GetSubDrawableTypeMask( void ) const = 0;
// View state
virtual hsPoint3 GetViewPositionWorld() const = 0;
virtual hsVector3 GetViewAcrossWorld() const = 0;
virtual hsVector3 GetViewUpWorld() const = 0;
virtual hsVector3 GetViewDirWorld() const = 0;
virtual void GetViewAxesWorld(hsVector3 axes[3] /* ac,up,at */ ) const = 0;
virtual void GetFOV(hsScalar& fovX, hsScalar& fovY) const = 0;
virtual void SetFOV(hsScalar fovX, hsScalar fovY) = 0;
virtual void GetSize(hsScalar& width, hsScalar& height) const = 0;
virtual void SetSize(hsScalar width, hsScalar height) = 0;
virtual void GetDepth(hsScalar& hither, hsScalar& yon) const = 0;
virtual void SetDepth(hsScalar hither, hsScalar yon) = 0;
virtual void SetZBiasScale( hsScalar scale ) = 0;
virtual hsScalar GetZBiasScale( void ) const = 0;
virtual const hsMatrix44& GetWorldToCamera() const = 0;
virtual const hsMatrix44& GetCameraToWorld() const = 0;
virtual void SetWorldToCamera(const hsMatrix44& w2c, const hsMatrix44& c2w) = 0;
virtual const hsMatrix44& GetWorldToLocal() const = 0;
virtual const hsMatrix44& GetLocalToWorld() const = 0;
virtual const plViewTransform& GetViewTransform() const = 0;
virtual void ScreenToWorldPoint( int n, UInt32 stride, Int32 *scrX, Int32 *scrY,
hsScalar dist, UInt32 strideOut, hsPoint3 *worldOut ) = 0;
virtual void RefreshMatrices( void ) = 0;
virtual void RefreshScreenMatrices( void ) = 0;
// Overrides, always push returns whatever is necessary to restore on pop.
virtual hsGMaterial* PushOverrideMaterial(hsGMaterial* mat) = 0;
virtual void PopOverrideMaterial(hsGMaterial* restore) = 0;
virtual hsGMaterial* GetOverrideMaterial() const = 0;
virtual plLayerInterface* AppendLayerInterface(plLayerInterface* li, hsBool onAllLayers = false) = 0;
virtual plLayerInterface* RemoveLayerInterface(plLayerInterface* li, hsBool onAllLayers = false) = 0;
virtual UInt32 GetMaterialOverrideOn(hsGMatState::StateIdx category) const = 0;
virtual UInt32 GetMaterialOverrideOff(hsGMatState::StateIdx category) const = 0;
virtual hsGMatState PushMaterialOverride(const hsGMatState& state, hsBool on) = 0;
virtual hsGMatState PushMaterialOverride(hsGMatState::StateIdx cat, UInt32 which, hsBool on) = 0;
virtual void PopMaterialOverride(const hsGMatState& restore, hsBool on) = 0;
virtual const hsGMatState& GetMaterialOverride(hsBool on) const = 0;
virtual hsColorOverride PushColorOverride(const hsColorOverride& over) = 0;
virtual void PopColorOverride(const hsColorOverride& restore) = 0;
virtual const hsColorOverride& GetColorOverride() const = 0;
virtual void SubmitShadowSlave(plShadowSlave* slave) = 0;
virtual void SubmitClothingOutfit(plClothingOutfit* co) = 0;
// These all return true if the gamma was successfully set.
virtual hsBool SetGamma(hsScalar eR, hsScalar eG, hsScalar eB) = 0;
virtual hsBool SetGamma(const UInt16* const tabR, const UInt16* const tabG, const UInt16* const tabB) = 0; // len table = 256.
virtual hsBool SetGamma(hsScalar e) { return SetGamma(e, e, e); }
virtual hsBool SetGamma(const UInt16* const table) { return SetGamma(table, table, table); }
// flipVertical is for the AVI writer, which wants it's frames upside down
virtual hsBool CaptureScreen( plMipmap *dest, bool flipVertical = false, UInt16 desiredWidth = 0, UInt16 desiredHeight = 0 ) = 0;
// Returns an un-named (GetKey()==nil) mipmap same dimensions as targ. You are responsible for deleting said mipMap.
virtual plMipmap* ExtractMipMap(plRenderTarget* targ) = 0;
/// Error handling
virtual const char *GetErrorString( void ) = 0;
// info about current rendering device
virtual void GetSupportedDisplayModes(std::vector<plDisplayMode> *res, int ColorDepth = 32 ) = 0;
virtual int GetMaxAnisotropicSamples() = 0;
virtual int GetMaxAntiAlias(int Width, int Height, int ColorDepth) = 0;
int GetDesktopWidth() { return fDesktopParams.Width; }
int GetDesktopHeight() { return fDesktopParams.Height; }
int GetDesktopColorDepth() { return fDesktopParams.ColorDepth; }
PipelineParams *GetDefaultParams() { return &fDefaultPipeParams; }
virtual void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool vSync = false ) = 0;
static PipelineParams fDefaultPipeParams;
static PipelineParams fInitialPipeParams;
plDisplayMode fDesktopParams;
};
#endif // plPipeline_inc

View File

@ -0,0 +1,252 @@
/*==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 plProfile_h_inc
#define plProfile_h_inc
#include "hsTypes.h"
#ifndef PLASMA_EXTERNAL_RELEASE
#define PL_PROFILE_ENABLED
#endif
//
// These macros are all you should need to use to profile your code. They are
// compiled out in external release mode for maximum performance.
//
// plProfile_Create* should only be used at global scope, not in functions.
// Use plProfile_Extern if the plProfile_Create* for a variable is in another source file.
//
// --Examples--
//
// plProfile_CreateCounter("Num Foobars", "Test", NumFoobars);
// void SomeFunc1()
// {
// plProfile_Inc(NumFoobars);
// plProfile_IncCount(NumFoobars, 5);
// }
//
// plProfile_CreateTimer("Foobar Time", "Test", FoobarTime);
// void SomeFunc2()
// {
// plProfile_BeginTiming(FoobarTime);
// (execute some code...)
// plProfile_EndTiming(FoobarTime);
//
// plProfile_BeginLap(FoobarTime, pKeyedObj->GetKeyName());
// pKeyedObj->DoStuff();
// plProfile_EndLap(FoobarTime, pKeyedObj->GetKeyName());
// }
//
#ifdef PL_PROFILE_ENABLED
#define plProfile_CreateTimerNoReset(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayTime | plProfileVar::kDisplayNoReset)
#define plProfile_CreateTimer(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayTime)
#define plProfile_CreateAsynchTimer(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayTime | plProfileVar::kDisplayResetEveryBegin | plProfileVar::kDisplayNoReset)
#define plProfile_BeginTiming(varName) gProfileVar##varName.BeginTiming()
#define plProfile_EndTiming(varName) gProfileVar##varName.EndTiming()
#define plProfile_BeginLap(varName, lapName) gProfileVar##varName.BeginLap(lapName)
#define plProfile_EndLap(varName, lapName) gProfileVar##varName.EndLap(lapName)
#define plProfile_CreateCounter(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayCount)
#define plProfile_CreateCounterNoReset(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayCount | plProfileVar::kDisplayNoReset)
#define plProfile_Inc(varName) gProfileVar##varName.Inc()
#define plProfile_IncCount(varName, count) gProfileVar##varName.Inc(count)
#define plProfile_Dec(varName) gProfileVar##varName.Dec()
#define plProfile_Set(varName, value) gProfileVar##varName.Set(value)
#define plProfile_CreateMemCounter(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayMem | plProfileVar::kDisplayNoReset)
#define plProfile_CreateMemCounterReset(name, group, varName) plProfileVar gProfileVar##varName(name, group, plProfileVar::kDisplayMem)
#define plProfile_NewMem(varName, memAmount) gProfileVar##varName.NewMem(memAmount)
#define plProfile_DelMem(varName, memAmount) gProfileVar##varName.DelMem(memAmount)
#define plProfile_StopVar(varName) gProfileVar##varName.Stop()
#define plProfile_StartVar(varName) gProfileVar##varName.Start()
#define plProfile_Extern(varName) extern plProfileVar gProfileVar##varName
#else
#define plProfile_CreateTimerNoReset(name, group, varName)
#define plProfile_CreateTimer(name, group, varName)
#define plProfile_CreateAsynchTimer(name, group, varName)
#define plProfile_BeginTiming(varName)
#define plProfile_EndTiming(varName)
#define plProfile_BeginLap(varName, lapName)
#define plProfile_EndLap(varName, lapName)
#define plProfile_CreateCounter(name, group, varName)
#define plProfile_CreateCounterNoReset(name, group, varName)
#define plProfile_Inc(varName)
#define plProfile_IncCount(varName, count)
#define plProfile_Dec(varName)
#define plProfile_Set(varName, value)
#define plProfile_CreateMemCounter(name, group, varName)
#define plProfile_CreateMemCounterReset(name, group, varName)
#define plProfile_NewMem(varName, memAmount)
#define plProfile_DelMem(varName, memAmount)
#define plProfile_StopVar(varName)
#define plProfile_StartVar(varName)
#define plProfile_Extern(varName)
#endif
class plProfileLaps;
class plProfileBase
{
public:
enum
{
kDisplayCount = 0x1,
kDisplayTime = 0x2,
kDisplayMem = 0x4,
kDisplayNoReset = 0x8,
kDisplayFPS = 0x10,
kDisplayLaps = 0x20,
kDisplaySelected = 0x40,
kDisplayResetEveryBegin = 0x80
};
protected:
const char* fName; // Name of timer
UInt32 fValue;
UInt32 fAvgCount;
UInt64 fAvgTotal;
UInt32 fLastAvg;
UInt32 fMax;
hsBool fActive;
hsBool fRunning;
UInt8 fDisplayFlags;
// Number of times EndTiming was called. Can be used to combine timing and counting in one timer
UInt32 fTimerSamples;
void IAddAvg();
void IPrintValue(UInt32 value, char* buf, hsBool printType);
public:
plProfileBase();
virtual ~plProfileBase();
virtual void BeginFrame();
virtual void EndFrame();
void UpdateAvg();
UInt32 GetValue();
void PrintValue(char* buf, hsBool printType=true);
void PrintAvg(char* buf, hsBool printType=true);
void PrintMax(char* buf, hsBool printType=true);
UInt32 GetTimerSamples() const { return fTimerSamples; }
const char* GetName() { return fName; }
void SetActive(hsBool s) { fActive = s; }
void Stop() { fRunning = false; }
void Start() { fRunning = true; }
UInt8 GetDisplayFlags() const { return fDisplayFlags; }
void ResetMax() { fMax = 0; }
};
class plProfileVar : public plProfileBase
{
protected:
const char* fGroup;
plProfileLaps* fLaps;
hsBool fLapsActive;
plProfileVar() {}
void IBeginTiming();
void IEndTiming();
void IBeginLap(const char* lapName);
void IEndLap(const char* lapName);
public:
// Name is the timer name. Each timer group gets its own plStatusLog
plProfileVar(const char *name, const char* group, UInt8 flags);
~plProfileVar();
// For timing
void BeginTiming() { if (fActive && fRunning) IBeginTiming(); }
void EndTiming() { if (fActive && fRunning) IEndTiming(); }
void NewMem(UInt32 memAmount) { fValue += memAmount; }
void DelMem(UInt32 memAmount) { fValue -= memAmount; }
// For Counting
void Inc(int i = 1) { fValue += i;}
void Dec(int i = 1) { fValue -= i;}
void Set(UInt32 value) { fValue = value; }
//
// For multiple timings per frame of the same thing ie. Each particle system
//
// Will output to log like
// Timername : lapCnt: (lapName) : 3.22 msec
//
void BeginLap(const char* lapName) { if(fActive && fRunning) IBeginLap(lapName); }
void EndLap(const char* lapName) { if(fActive && fRunning) IEndLap(lapName); }
const char* GetGroup() { return fGroup; }
plProfileLaps* GetLaps() { return fLaps; }
// Enable Lap Sampling
void SetLapsActive(hsBool s) { fLapsActive = s; }
};
#endif // plProfile_h_inc

View File

@ -0,0 +1,535 @@
/*==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 "plProfileManager.h"
#include "plProfile.h"
#include "hsTimer.h"
#include "hsUtils.h"
static UInt32 gCyclesPerMS = 0;
#ifdef HS_BUILD_FOR_WIN32
#define USE_FAST_TIMER
#endif
#ifdef USE_FAST_TIMER
#pragma warning (push)
#pragma warning (disable : 4035) // disable no return value warning
__forceinline UInt32 GetPentiumCounter()
{
__asm
{
xor eax,eax // VC won't realize that eax is modified w/out this
// instruction to modify the val.
// Problem shows up in release mode builds
_emit 0x0F // Pentium high-freq counter to edx;eax
_emit 0x31 // only care about low 32 bits in eax
xor edx,edx // so VC gets that edx is modified
}
}
#pragma warning (pop)
#include "hsWindows.h"
static UInt32 GetProcSpeed()
{
const char* keypath[] =
{
"HARDWARE",
"DESCRIPTION",
"System",
"CentralProcessor",
"0"
};
HKEY hKey = HKEY_LOCAL_MACHINE;
int numKeys = sizeof(keypath) / sizeof(char*);
for (int i = 0; i < numKeys; i++)
{
HKEY thisKey = NULL;
hsBool success = (RegOpenKeyEx(hKey, keypath[i], 0, KEY_READ, &thisKey) == ERROR_SUCCESS);
RegCloseKey(hKey);
hKey = thisKey;
if (!success)
return 0;
}
DWORD value=0, size=sizeof(DWORD);
hsBool success = (RegQueryValueEx(hKey, "~MHz", 0, NULL, (BYTE*)&value, &size) == ERROR_SUCCESS);
RegCloseKey(hKey);
return value*1000000;
}
UInt32 GetProcSpeedAlt()
{
const UInt32 kSamplePeriodMS = 250;
// Raise priority to avoid interference from other threads.
int priority = GetThreadPriority(GetCurrentThread());
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
UInt32 startTicks, endTicks;
UInt64 pcStart, pcEnd;
// Count number of processor cycles inside the specified interval
QueryPerformanceCounter((LARGE_INTEGER*)&pcStart);
startTicks = plProfileManager::GetTime();
Sleep(kSamplePeriodMS);
endTicks = plProfileManager::GetTime();
QueryPerformanceCounter((LARGE_INTEGER*)&pcEnd);
// Restore thread priority.
SetThreadPriority(GetCurrentThread(), priority);
// Calculate Rdtsc/PerformanceCounter ratio;
UInt32 numTicks = endTicks - startTicks;
UInt64 pcDiff = pcEnd - pcStart;
double ratio = double(numTicks) / double(pcDiff);
UInt64 pcFreq;
QueryPerformanceFrequency((LARGE_INTEGER*)&pcFreq);
// Calculate CPU frequency.
UInt64 cpuFreq = UInt64(pcFreq * ratio);
return (UInt32)cpuFreq;
}
#define GetProfileTicks() GetPentiumCounter()
#else
#define GetProfileTicks() hsTimer::GetPrecTickCount()
#endif // USE_FAST_TIMER
#define TicksToMSec(t) (float(t) / float(gCyclesPerMS))
#define MSecToTicks(t) (float(t) * float(gCyclesPerMS))
plProfileManager::plProfileManager() : fLastAvgTime(0), fProcessorSpeed(0)
{
#ifdef USE_FAST_TIMER
fProcessorSpeed = GetProcSpeed();
// Registry stuff only works on NT OS's, have to calc it otherwise
if (fProcessorSpeed == 0)
fProcessorSpeed = GetProcSpeedAlt();
gCyclesPerMS = fProcessorSpeed / 1000;
#else
gCyclesPerMS = hsTimer::GetPrecTicksPerSec() / 1000;
#endif
}
plProfileManager::~plProfileManager()
{
}
plProfileManager& plProfileManager::Instance()
{
static plProfileManager theInstance;
return theInstance;
}
void plProfileManager::AddTimer(plProfileVar* var)
{
fVars.push_back(var);
}
static UInt32 kAvgMilliseconds = 1000;
void plProfileManager::SetAvgTime(UInt32 avgMS)
{
kAvgMilliseconds = avgMS;
}
static plProfileVar gVarEFPS("EFPS", "General", plProfileVar::kDisplayTime | plProfileVar::kDisplayFPS);
void plProfileManager::BeginFrame()
{
for (int i = 0; i < fVars.size(); i++)
{
fVars[i]->BeginFrame();
if (fVars[i]->GetLaps())
fVars[i]->GetLaps()->BeginFrame();
}
gVarEFPS.BeginTiming();
}
void plProfileManager::EndFrame()
{
gVarEFPS.EndTiming();
hsBool updateAvgs = false;
// If enough time has passed, update the averages
double curTime = hsTimer::GetMilliSeconds();
if (curTime - fLastAvgTime > kAvgMilliseconds)
{
fLastAvgTime = curTime;
updateAvgs = true;
}
int i;
//
// Update all the variables
//
for (i = 0; i < fVars.size(); i++)
{
plProfileVar* var = fVars[i];
if (updateAvgs)
{
// Timers that reset at every BeginTiming() call don't want to average over frames
if (!hsCheckBits(var->GetDisplayFlags(), plProfileBase::kDisplayResetEveryBegin))
{
var->UpdateAvg();
if (var->GetLaps())
var->GetLaps()->UpdateAvgs();
}
}
var->EndFrame();
if (var->GetLaps())
var->GetLaps()->EndFrame();
}
}
UInt32 plProfileManager::GetTime()
{
return GetProfileTicks();
}
///////////////////////////////////////////////////////////////////////////////
plProfileBase::plProfileBase() :
fName(nil),
fDisplayFlags(0),
fValue(0),
fTimerSamples(0),
fAvgCount(0),
fAvgTotal(0),
fLastAvg(0),
fMax(0),
fActive(false),
fRunning(true)
{
}
plProfileBase::~plProfileBase()
{
}
void plProfileBase::BeginFrame()
{
if (!hsCheckBits(fDisplayFlags, kDisplayNoReset))
fValue = 0;
fTimerSamples = 0;
}
void plProfileBase::EndFrame()
{
fAvgCount++;
fAvgTotal += fValue;
fMax = hsMaximum(fMax, fValue);
}
void plProfileBase::UpdateAvg()
{
if (fAvgCount > 0)
{
fLastAvg = (UInt32)(fAvgTotal / fAvgCount);
fAvgCount = 0;
fAvgTotal = 0;
}
}
UInt32 plProfileBase::GetValue()
{
if (hsCheckBits(fDisplayFlags, kDisplayTime))
return (UInt32)TicksToMSec(fValue);
else
return fValue;
}
// Stolen from plMemTracker.cpp
static const char *insertCommas(unsigned int value)
{
static char str[30];
memset(str, 0, sizeof(str));
sprintf(str, "%u", value);
if (strlen(str) > 3)
{
memmove(&str[strlen(str)-3], &str[strlen(str)-4], 4);
str[strlen(str) - 4] = ',';
}
if (strlen(str) > 7)
{
memmove(&str[strlen(str)-7], &str[strlen(str)-8], 8);
str[strlen(str) - 8] = ',';
}
if (strlen(str) > 11)
{
memmove(&str[strlen(str)-11], &str[strlen(str)-12], 12);
str[strlen(str) - 12] = ',';
}
return str;
}
void plProfileBase::IPrintValue(UInt32 value, char* buf, hsBool printType)
{
if (hsCheckBits(fDisplayFlags, kDisplayCount))
{
if (printType)
{
const char* valueStr = insertCommas(value);
strcpy(buf, valueStr);
}
else
sprintf(buf, "%u", value);
}
else if (hsCheckBits(fDisplayFlags, kDisplayFPS))
{
sprintf(buf, "%.1f", 1000.0f / TicksToMSec(value));
}
else if (hsCheckBits(fDisplayFlags, kDisplayTime))
{
sprintf(buf, "%.1f", TicksToMSec(value));
if (printType)
strcat(buf, " ms");
}
else if (hsCheckBits(fDisplayFlags, kDisplayMem))
{
if (printType)
{
if (value > (1024*1000))
sprintf(buf, "%.1f MB", float(value) / (1024.f * 1024.f));
else if (value > 1024)
sprintf(buf, "%d KB", value / 1024);
else
sprintf(buf, "%d b", value);
}
else
sprintf(buf, "%u", value);
}
}
void plProfileBase::PrintValue(char* buf, hsBool printType)
{
IPrintValue(fValue, buf, printType);
}
void plProfileBase::PrintAvg(char* buf, hsBool printType)
{
IPrintValue(fLastAvg, buf, printType);
}
void plProfileBase::PrintMax(char* buf, hsBool printType)
{
IPrintValue(fMax, buf, printType);
}
////////////////////////////////////////////////////////////////////////////////
plProfileLaps::LapInfo* plProfileLaps::IFindLap(const char* lapName)
{
static int lastSearch = 0;
int i;
for (i = lastSearch; i < fLapTimes.size(); i++)
{
if(fLapTimes[i].GetName() == lapName)
{
lastSearch = i;
return &fLapTimes[i];
}
}
if(lastSearch > fLapTimes.size()) lastSearch = fLapTimes.size();
for (i = 0; i < lastSearch; i++)
{
if(fLapTimes[i].GetName() == lapName)
{
lastSearch = i;
return &fLapTimes[i];
}
}
return nil;
}
void plProfileLaps::BeginLap(UInt32 curValue, const char* name)
{
LapInfo* lap = IFindLap(name);
if (!lap)
{
// Technically we shouldn't hold on to this pointer. However, I think
// it will be ok in all cases, so I'll wait until this blows up
LapInfo info(name);
fLapTimes.push_back(info);
lap = &(*(fLapTimes.end()-1));
}
lap->fUsedThisFrame = true;
lap->BeginTiming(curValue);
}
void plProfileLaps::EndLap(UInt32 curValue, const char* name)
{
LapInfo* lap = IFindLap(name);
// There's a lap timer around the input code. You display it with "Stats.ShowLaps Update Input"
// Since the command activates the timer INSIDE the lap, the first call to this function fails to
// find it. (the timer wasn't active when BeginLap was called)
if (lap)
lap->EndTiming(curValue);
}
void plProfileLaps::BeginFrame()
{
for (int i = 0; i < fLapTimes.size(); i++)
{
fLapTimes[i].BeginFrame();
fLapTimes[i].fUsedThisFrame = false;
}
}
void plProfileLaps::EndFrame()
{
for (int i = 0; i < fLapTimes.size(); i++)
{
fLapTimes[i].EndFrame();
if (!fLapTimes[i].fUsedThisFrame)
{
char buf[200];
sprintf(buf, "Dropping unused lap %s", fLapTimes[i].GetName());
hsStatusMessage(buf);
fLapTimes.erase(fLapTimes.begin()+i);
i--;
}
}
}
void plProfileLaps::UpdateAvgs()
{
for (int i = 0; i < fLapTimes.size(); i++)
fLapTimes[i].UpdateAvg();
}
int plProfileLaps::GetNumLaps()
{
// std::sort(fLapTimes.begin(), fLapTimes.end());
return fLapTimes.size();
}
plProfileBase* plProfileLaps::GetLap(int i)
{
return &fLapTimes[i];
}
///////////////////////////////////////////////////////////////////////////////
plProfileVar::plProfileVar(const char *name, const char* group, UInt8 flags) :
fGroup(group),
fLaps(nil)
{
fName = name;
fDisplayFlags = flags;
plProfileManager::Instance().AddTimer(this);
fLapsActive = 0;
}
plProfileVar::~plProfileVar()
{
delete fLaps;
}
void plProfileVar::IBeginLap(const char* lapName)
{
if (!fLaps)
fLaps = TRACKED_NEW plProfileLaps;
fDisplayFlags |= kDisplayLaps;
if(fLapsActive)
fLaps->BeginLap(fValue, lapName);
BeginTiming();
}
void plProfileVar::IEndLap(const char* lapName)
{
EndTiming();
if(fLapsActive)
fLaps->EndLap(fValue, lapName);
}
void plProfileVar::IBeginTiming()
{
if( hsCheckBits( fDisplayFlags, kDisplayResetEveryBegin ) )
fValue = 0;
fValue -= GetProfileTicks();
}
void plProfileVar::IEndTiming()
{
fValue += GetProfileTicks();
fTimerSamples++;
// If we reset every BeginTiming(), then we want to average all the timing calls
// independent of framerate
if (hsCheckBits(fDisplayFlags, plProfileBase::kDisplayResetEveryBegin))
UpdateAvg();
}

View File

@ -0,0 +1,112 @@
/*==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 plProfileManager_h_inc
#define plProfileManager_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plProfile.h"
class plProfileManager
{
protected:
friend class plProfileManagerFull;
typedef std::vector<plProfileVar*> VarVec;
VarVec fVars;
double fLastAvgTime;
UInt32 fProcessorSpeed;
plProfileManager();
public:
~plProfileManager();
static plProfileManager& Instance();
void AddTimer(plProfileVar* var); // Called by plProfileVar
void BeginFrame(); // Call begin frame on all timers
void EndFrame(); // Call end frame on all timers
void SetAvgTime(UInt32 avgMS);
UInt32 GetProcessorSpeed() { return fProcessorSpeed; }
// Backdoor for hack timers in calculated profiles
static UInt32 GetTime();
};
class plProfileLaps
{
protected:
class LapInfo : public plProfileBase
{
protected:
public:
bool fUsedThisFrame;
LapInfo(const char* name) { fName = name; fDisplayFlags = kDisplayTime; }
bool operator<(const LapInfo& rhs) const { return fLastAvg < rhs.fLastAvg; }
void BeginTiming(UInt32 value) { fValue -= value; }
void EndTiming(UInt32 value) { fValue += value; fTimerSamples++; }
};
std::vector<LapInfo> fLapTimes;
LapInfo* IFindLap(const char* lapName);
public:
void BeginLap(UInt32 curValue, const char* name);
void EndLap(UInt32 curValue, const char* name);
void BeginFrame();
void EndFrame();
void UpdateAvgs();
int GetNumLaps();
plProfileBase* GetLap(int i);
};
#endif // plProfileManager_h_inc

View File

@ -0,0 +1,53 @@
/*==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 plRefFlags_inc
#define plRefFlags_inc
namespace plRefFlags
{
enum Type {
kActiveRef, // If one is resident, return it, else create and load one to return. Keep it loaded till I release.
kPassiveRef // Just notify me when it is loaded or unloaded until I release.
};
};
#endif // plRefFlags_inc

View File

@ -0,0 +1,83 @@
/*==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 plDispatchBase_inc
#define plDispatchBase_inc
#include "../pnFactory/plCreatable.h"
class plMessage;
class plKey;
class plDispatchBase : public plCreatable
{
public:
CLASSNAME_REGISTER( plDispatchBase );
GETINTERFACE_ANY( plDispatchBase, plCreatable );
virtual void RegisterForType(UInt16 hClass, const plKey& receiver) = 0;
virtual void RegisterForExactType(UInt16 hClass, const plKey& receiver) = 0;
virtual void UnRegisterForType(UInt16 hClass, const plKey& receiver) = 0;
virtual void UnRegisterForExactType(UInt16 hClass, const plKey& receiver) = 0;
virtual void UnRegisterAll(const plKey& receiver) = 0;
virtual hsBool MsgSend(plMessage* msg, hsBool async=false) = 0;
virtual void MsgQueue(plMessage* msg)=0; // Used by other thread to Send Messages, they are handled as soon as Practicable
virtual void MsgQueueProcess() = 0;
virtual void MsgQueueOnOff(hsBool) = 0; // Turn on or off Queued Messages, if off, uses MsgSend Immediately (for plugins)
virtual hsBool SetMsgBuffering(hsBool on) = 0; // On starts deferring msg delivery until buffering is set to off again.
virtual void BeginShutdown() = 0;
};
class plgDispatch
{
public:
static plDispatchBase* Dispatch();
static hsBool MsgSend(plMessage* msg, hsBool async = false) { return Dispatch()->MsgSend(msg, async); }
};

View File

@ -0,0 +1,49 @@
/*==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 pnAllCreatables_inc
#define pnAllCreatables_inc
#include "pnNucleusCreatables.h"
#include "../../Apps/plClient/plClientCreatable.h"
#endif // pnAllCreatables_inc

View File

@ -0,0 +1,72 @@
/*==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 pnNucleusCreatables_inc
#define pnNucleusCreatables_inc
#include "../pnFactory/plCreator.h"
#include "plPipeline.h"
REGISTER_NONCREATABLE( plPipeline );
#include "plAudible.h"
REGISTER_NONCREATABLE( plAudible );
#include "plDrawable.h"
REGISTER_NONCREATABLE( plDrawable );
#include "plPhysical.h"
REGISTER_NONCREATABLE( plPhysical );
#include "plgDispatch.h"
REGISTER_NONCREATABLE( plDispatchBase );
#include "../pnDispatch/pnDispatchCreatable.h"
#include "../pnKeyedObject/pnKeyedObjectCreatable.h"
#include "../pnMessage/pnMessageCreatable.h"
#include "../pnModifier/pnModifierCreatable.h"
#include "../pnNetCommon/pnNetCommonCreatable.h"
#include "../pnSceneObject/pnSceneObjectCreatable.h"
#include "../pnTimer/pnTimerCreatable.h"
#endif // pnNucleusCreatables_inc

View File

@ -0,0 +1,84 @@
/*==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 "plgDispatch.h"
#include "hsResMgr.h"
#include "plPipeResReq.h"
hsResMgr* hsgResMgr::fResMgr = nil;
plDispatchBase* plgDispatch::Dispatch()
{
return hsgResMgr::Dispatch();
}
hsBool hsgResMgr::Init(hsResMgr* m)
{
hsRefCnt_SafeAssign(fResMgr, m);
hsRefCnt_SafeUnRef(m);
if (!m->IInit())
return false;
return true;
}
void hsgResMgr::Shutdown()
{
if (fResMgr)
{
if (fResMgr->RefCnt() <= 1)
{
fResMgr->IShutdown();
hsRefCnt_SafeUnRef(fResMgr);
fResMgr = nil;
}
else
{
hsRefCnt_SafeUnRef(fResMgr);
}
}
}
plPipeResReq& plPipeResReq::Instance()
{
static plPipeResReq r;
return r;
}

View File

@ -0,0 +1,177 @@
/*==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 SERVER
#include "hsTypes.h"
#include "pnAddrInfo.h"
#include <string.h>
#if HS_BUILD_FOR_UNIX
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <net/if.h>
#include <sys/ioctl.h>
#endif
const pnAddrInfo* pnAddrInfo::GetInterface()
{
static pnAddrInfo addrinfo;
return &addrinfo;
}
struct addrinfo* pnAddrInfo::GetAddrByNameSimple(const char* name, const int family)
{
struct addrinfo* info;
struct addrinfo hints;
memset(&hints,0,sizeof(hints));
hints.ai_family = family;
hints.ai_flags = AI_CANONNAME;
if (Get(name,NULL,&hints,&info) != 0)
info = NULL;
return info;
};
int pnAddrInfo::Get(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res)
{
return getaddrinfo(node,service,hints,res);
}
void pnAddrInfo::Free(struct addrinfo* res)
{
freeaddrinfo(res);
}
const char* pnAddrInfo::GetErrorString(int errcode)
{
return gai_strerror(errcode);
}
//////////////////////////////////
//// UNIX
//////////////////////////////////
#if HS_BUILD_FOR_UNIX
pnAddrInfo::pnAddrInfo()
{
}
pnAddrInfo::~pnAddrInfo()
{
}
void pnAddrInfo::GetLocalAddrs(List& addrslist, bool incLoopBack)
{
struct ifconf info;
struct ifreq infos[128];
info.ifc_len = sizeof(infos);
info.ifc_req = infos;
int s = socket(AF_INET, SOCK_DGRAM, 0);
if (ioctl(s,SIOCGIFCONF,&info) == 0)
{
int i;
int entries = info.ifc_len / sizeof(struct ifreq);
for (i = 0; i < entries; i++)
{
struct in_addr addr = ((struct sockaddr_in *)&(infos[i].ifr_addr))->sin_addr;
if (incLoopBack || (addr.s_addr != htonl(INADDR_LOOPBACK)))
{
addrslist.push_back(inet_ntoa(addr));
}
}
}
close(s);
}
#endif
////////////////////////////////////
//// Windows
////////////////////////////////////
#if HS_BUILD_FOR_WIN32
pnAddrInfo::pnAddrInfo()
{
WSADATA data;
WSAStartup(MAKEWORD( 2, 2 ), &data);
}
pnAddrInfo::~pnAddrInfo()
{
WSACleanup();
}
void pnAddrInfo::GetLocalAddrs(List& addrslist, bool incLoopBack)
{
INTERFACE_INFO infos[128]; // get at most 128 interfaces
const unsigned int bufSize = sizeof(infos);
DWORD retSize;
SOCKET s = socket(AF_INET, SOCK_DGRAM, 0);
if (WSAIoctl(s,SIO_GET_INTERFACE_LIST,NULL,NULL,(void*)infos,bufSize,&retSize,NULL,NULL) == 0)
{
unsigned int entries = retSize/sizeof(INTERFACE_INFO);
int i;
for (i = 0; i < entries; i++)
{
if (infos[i].iiFlags & IFF_UP)
{
struct in_addr addr = infos[i].iiAddress.AddressIn.sin_addr;
if (incLoopBack || (addr.s_addr != htonl(INADDR_LOOPBACK)))
addrslist.push_back(inet_ntoa(addr));
}
}
}
closesocket(s);
}
#endif
#endif // SERVER

View File

@ -0,0 +1,85 @@
/*==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 PN_ADDR_INFO_H
#define PN_ADDR_INFO_H
#ifndef SERVER
// A wrapper library for getaddrinfo
// made to support Windows 98, Me, 2k
// Unix and XP use native code
#if HS_BUILD_FOR_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#elif HS_BUILD_FOR_WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#error "pnAddrInfo Not Implemented!"
#endif
#include "hsTypes.h"
#include "hsStlUtils.h"
class pnAddrInfo
{
public:
typedef std::list<std::string> List;
pnAddrInfo();
~pnAddrInfo();
static const pnAddrInfo* GetInterface();
static struct addrinfo* GetAddrByNameSimple(const char* name, const int family = PF_INET);
static int Get(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res);
static const char* GetErrorString(int errcode);
static void Free(struct addrinfo* res);
static void GetLocalAddrs(List& addrslist, bool incLoopBack = false);
};
#endif // SERVER
#endif // PN_ADDR_INFO_H

View File

@ -0,0 +1,57 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "Private/pnAcAllIncludes.h"

View File

@ -0,0 +1,58 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcAllIncludes.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACALLINCLUDES_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcAllIncludes.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACALLINCLUDES_H
#include "pnAcCore.h"
#include "pnAcIo.h"
#include "pnAcLog.h"
#include "pnAcThread.h"
#include "pnAcTimer.h"

View File

@ -0,0 +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/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcCore.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACCORE_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcCore.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACCORE_H
/****************************************************************************
*
* Library initialization
*
***/
void AsyncCoreInitialize ();
void AsyncCoreDestroy (unsigned waitMs);
/*****************************************************************************
*
* Performance counters
*
***/
enum EAsyncPerfCounter {
// Sockets
kAsyncPerfSocketsCurr,
kAsyncPerfSocketsTotal,
kAsyncPerfSocketBytesWriteQueued,
kAsyncPerfSocketBytesWaitQueued,
kAsyncPerfSocketConnAttemptsOutCurr,
kAsyncPerfSocketConnAttemptsOutTotal,
kAsyncPerfSocketConnAttemptsInCurr,
kAsyncPerfSocketConnAttemptsInTotal,
kAsyncPerfSocketDisconnectBacklog,
kAsyncPerfSocketDisconnectInvalidConnType,
kAsyncPerfNameLookupAttemptsCurr,
kAsyncPerfNameLookupAttemptsTotal,
// Files
kAsyncPerfFilesCurr,
kAsyncPerfFilesTotal,
kAsyncPerfFileBytesReadQueued,
kAsyncPerfFileBytesWriteQueued,
// Threads
kAsyncPerfThreadsCurr,
kAsyncPerfThreadsTotal,
// Thread tasks
kAsyncPerfThreadTaskListCount,
kAsyncPerfThreadTaskThreadsDesired,
kAsyncPerfThreadTaskThreadsRunning,
kAsyncPerfThreadTaskThreadsActive,
kNumAsyncPerfCounters
};
long AsyncPerfGetCounter (unsigned id);
/*****************************************************************************
*
* Misc functions
*
***/
void AsyncSignalShutdown ();
void AsyncWaitForShutdown ();

View File

@ -0,0 +1,491 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACIO_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACIO_H
/****************************************************************************
*
* Global types and constants
*
***/
typedef struct AsyncIdStruct * AsyncId;
typedef struct AsyncFileStruct * AsyncFile;
typedef struct AsyncSocketStruct * AsyncSocket;
typedef struct AsyncCancelIdStruct * AsyncCancelId;
const unsigned kAsyncSocketBufferSize = 1460;
enum EFileError {
kFileSuccess,
kFileErrorInvalidParameter,
kFileErrorFileNotFound,
kFileErrorPathNotFound,
kFileErrorAccessDenied,
kFileErrorSharingViolation,
kNumFileErrors
};
EFileError AsyncGetLastFileError ();
const wchar * FileErrorToString (EFileError error);
/****************************************************************************
*
* File notifications
*
***/
enum EAsyncNotifyFile {
kNotifyFileFlush,
kNotifyFileRead,
kNotifyFileWrite,
kNotifyFileSequence,
kNumFileNotifications
};
struct AsyncNotifyFile {
void * param;
AsyncId asyncId;
};
struct AsyncNotifyFileConnect : AsyncNotifyFile {
qword fileSize;
qword fileLastWriteTime;
};
struct AsyncNotifyFileFlush : AsyncNotifyFile {
EFileError error;
qword truncateSize;
};
struct AsyncNotifyFileRead : AsyncNotifyFile {
qword offset;
byte * buffer;
unsigned bytes;
};
typedef AsyncNotifyFileRead AsyncNotifyFileWrite;
struct AsyncNotifyFileSequence : AsyncNotifyFile {
// no additional fields
};
typedef void (* FAsyncNotifyFileProc)(
AsyncFile file,
EAsyncNotifyFile code,
AsyncNotifyFile * notify,
void ** userState
);
/****************************************************************************
*
* File I/O functions
*
***/
// Desired access
const unsigned kAsyncFileReadAccess = 0x80000000;
const unsigned kAsyncFileWriteAccess = 0x40000000;
// Open mode (creation disposition)
const unsigned kAsyncFileModeCreateNew = 1;
const unsigned kAsyncFileModeCreateAlways = 2;
const unsigned kAsyncFileModeOpenExisting = 3;
const unsigned kAsyncFileModeOpenAlways = 4;
// Share mode flags
const unsigned kAsyncFileShareRead = 0x00000001;
const unsigned kAsyncFileShareWrite = 0x00000002;
AsyncFile AsyncFileOpen (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags, // optional
void * userState, // optional
qword * fileSize, // optional
qword * fileLastWriteTime // optional
);
// Use with AsyncFileDelete/AsyncFileFlushBuffers
const qword kAsyncFileDontTruncate = (qword) -1;
// This function may ONLY be called when there is no outstanding I/O against a file
// and no more I/O will be initiated against it. This function guarantees that it
// will close the system file handle before it returns to that another open against
// the same filename can succeed.
void AsyncFileClose (
AsyncFile file,
qword truncateSize
);
void AsyncFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
);
qword AsyncFileGetLastWriteTime (
const wchar fileName[]
);
// Truncation occurs atomically, any writes which occur after
// AsyncFileFlushBuffers will be queued until the truncation completes
AsyncId AsyncFileFlushBuffers (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
);
const unsigned kAsyncFileRwNotify = 1<<0;
const unsigned kAsyncFileRwSync = 1<<1;
AsyncId AsyncFileRead (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
// Buffer must stay valid until I/O is completed
AsyncId AsyncFileWrite (
AsyncFile file,
qword offset,
const void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
// Inserts a "null operation" into the list of reads and writes. The callback
// will be called when all preceding operations have successfully completed.
AsyncId AsyncFileCreateSequence (
AsyncFile file,
bool notify,
void * param
);
enum EFileSeekFrom {
kFileSeekFromBegin,
kFileSeekFromCurrent,
kFileSeekFromEnd,
kNumFileSeekFroms
};
bool AsyncFileSeek (
AsyncFile file,
qword distance,
EFileSeekFrom seekFrom
);
/****************************************************************************
*
* Socket connect packet
*
***/
#include <PshPack1.h>
struct AsyncSocketConnectPacket {
byte connType;
word hdrBytes;
dword buildId;
dword buildType;
dword branchId;
Uuid productId;
};
#include <PopPack.h>
/****************************************************************************
*
* Socket event notifications
*
***/
enum EAsyncNotifySocket {
kNotifySocketConnectFailed,
kNotifySocketConnectSuccess,
kNotifySocketDisconnect,
kNotifySocketListenSuccess,
kNotifySocketRead,
kNotifySocketWrite
};
struct AsyncNotifySocket {
void * param;
AsyncId asyncId;
};
struct AsyncNotifySocketConnect : AsyncNotifySocket {
NetAddress localAddr;
NetAddress remoteAddr;
unsigned connType;
};
struct AsyncNotifySocketListen : AsyncNotifySocketConnect {
unsigned buildId;
unsigned buildType;
unsigned branchId;
Uuid productId;
NetAddress addr;
byte * buffer;
unsigned bytes;
unsigned bytesProcessed;
};
struct AsyncNotifySocketRead : AsyncNotifySocket {
byte * buffer;
unsigned bytes;
unsigned bytesProcessed;
};
typedef AsyncNotifySocketRead AsyncNotifySocketWrite;
typedef bool (* FAsyncNotifySocketProc) ( // return false to disconnect
AsyncSocket sock,
EAsyncNotifySocket code,
AsyncNotifySocket * notify,
void ** userState
);
/****************************************************************************
*
* Connection type functions
*
***/
// These codes may not be changed unless ALL servers and clients are
// simultaneously replaced; so basically forget it =)
enum EConnType {
kConnTypeNil = 0,
// For test applications
kConnTypeDebug = 1,
// Binary connections
kConnTypeCliToAuth = 10,
kConnTypeCliToGame = 11,
kConnTypeSrvToAgent = 12,
kConnTypeSrvToMcp = 13,
kConnTypeSrvToVault = 14,
kConnTypeSrvToDb = 15,
kConnTypeCliToFile = 16,
kConnTypeSrvToState = 17,
kConnTypeSrvToLog = 18,
kConnTypeSrvToScore = 19,
kConnTypeCliToCsr = 20,
kConnTypeSimpleNet = 21,
kConnTypeCliToGateKeeper = 22,
// Text connections
kConnTypeAdminInterface = 97, // 'a'
kNumConnTypes
};
COMPILER_ASSERT_HEADER(EConnType, kNumConnTypes < 256);
#define IS_TEXT_CONNTYPE(c) \
(((int)(c)) == kConnTypeAdminInterface)
void AsyncSocketRegisterNotifyProc (
byte connType,
FAsyncNotifySocketProc notifyProc,
unsigned buildId = 0,
unsigned buildType = 0,
unsigned branchId = 0,
const Uuid & productId = kNilGuid
);
void AsyncSocketUnregisterNotifyProc (
byte connType,
FAsyncNotifySocketProc notifyProc,
unsigned buildId = 0,
unsigned buildType = 0,
unsigned branchId = 0,
const Uuid & productId = kNilGuid
);
FAsyncNotifySocketProc AsyncSocketFindNotifyProc (
const byte buffer[],
unsigned bytes,
unsigned * bytesProcessed,
unsigned * connType,
unsigned * buildId,
unsigned * buildType,
unsigned * branchId,
Uuid * productId
);
/****************************************************************************
*
* Socket functions
*
***/
void AsyncSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
FAsyncNotifySocketProc notifyProc,
void * param = nil,
const void * sendData = nil,
unsigned sendBytes = 0,
unsigned connectMs = 0, // 0 => use default value
unsigned localPort = 0 // 0 => don't bind local port
);
// Due to the asynchronous nature of sockets, the connect may complete
// before the cancel does... you have been warned.
void AsyncSocketConnectCancel (
FAsyncNotifySocketProc notifyProc,
AsyncCancelId cancelId
);
void AsyncSocketDisconnect (
AsyncSocket sock,
bool hardClose
);
// This function must only be called after receiving a kNotifySocketDisconnect
void AsyncSocketDelete (AsyncSocket sock);
// Returns false of socket has been closed
bool AsyncSocketSend (
AsyncSocket sock,
const void * data,
unsigned bytes
);
// Buffer must stay valid until I/O has completed
// Returns false if socket has been closed
bool AsyncSocketWrite (
AsyncSocket sock,
const void * buffer,
unsigned bytes,
void * param
);
// This function must only be called from with a socket notification callback.
// Calling at any other time is a crash bug waiting to happen!
void AsyncSocketSetNotifyProc (
AsyncSocket sock,
FAsyncNotifySocketProc notifyProc
);
// A backlog of zero (the default) means that no buffering is performed when
// the TCP send buffer is full, and the send() function will close the socket
// on send fail
void AsyncSocketSetBacklogAlloc (
AsyncSocket sock,
unsigned bufferSize
);
// On failure, returns 0
// On success, returns bound port (if port number was zero, returns assigned port)
// For connections that will use kConnType* connections, set notifyProc = nil;
// the handler will be found when connection packet is received.
// for connections with hard-coded behavior, set the notifyProc here (e.g. for use
// protocols like SNMP on port 25)
unsigned AsyncSocketStartListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc = nil
);
void AsyncSocketStopListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc = nil
);
void AsyncSocketEnableNagling (
AsyncSocket sock,
bool enable
);
/****************************************************************************
*
* Dns functions
*
***/
typedef void (* FAsyncLookupProc) (
void * param,
const wchar name[],
unsigned addrCount,
const NetAddress addrs[]
);
void AsyncAddressLookupName (
AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc,
const wchar name[],
unsigned port,
void * param
);
void AsyncAddressLookupAddr (
AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc,
const NetAddress & address,
void * param
);
void AsyncAddressLookupCancel (
FAsyncLookupProc lookupProc,
AsyncCancelId cancelId
);

View File

@ -0,0 +1,190 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcLog.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private
*
***/
static const unsigned kMaxHandlers = 8;
static CCritSect s_critsect;
static FLogHandler s_asyncHandlers[kMaxHandlers];
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static void Dispatch (ELogSeverity severity, const wchar msg[]) {
// Dispatch to default debug handler
char dbg[1024];
StrToAnsi(dbg, msg, arrsize(dbg));
DEBUG_MSG(dbg);
// We don't need to enter a critical section to read the handlers because they
// are atomically set and cleared
for (unsigned i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (FLogHandler asyncHandler = s_asyncHandlers[i])
asyncHandler(severity, msg);
}
}
/*****************************************************************************
*
* Exports
*
***/
//===========================================================================
void LogRegisterHandler (FLogHandler callback) {
ASSERT(callback);
unsigned i;
s_critsect.Enter();
for (i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (!s_asyncHandlers[i]) {
s_asyncHandlers[i] = callback;
break;
}
}
s_critsect.Leave();
#ifdef HS_DEBUGGING
if (i >= arrsize(s_asyncHandlers))
FATAL("Maximum number of log handlers exceeded.");
#endif
}
//===========================================================================
void LogUnregisterHandler (FLogHandler callback) {
s_critsect.Enter();
for (unsigned i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (s_asyncHandlers[i] == callback) {
s_asyncHandlers[i] = nil;
break;
}
}
s_critsect.Leave();
}
//===========================================================================
void __cdecl LogMsg (ELogSeverity severity, const char format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(severity, format, args);
va_end(args);
}
//===========================================================================
void __cdecl LogMsg (ELogSeverity severity, const wchar format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(severity, format, args);
va_end(args);
}
//===========================================================================
void LogMsgV (ELogSeverity severity, const char format[], va_list args) {
ASSERT(format);
char msg[1024];
StrPrintfV(msg, arrsize(msg), format, args);
wchar uniMsg[1024];
StrToUnicode(uniMsg, msg, arrsize(uniMsg));
Dispatch(severity, uniMsg);
}
//===========================================================================
void LogMsgV (ELogSeverity severity, const wchar format[], va_list args) {
ASSERT(format);
ASSERT(args);
wchar msg[1024];
StrPrintfV(msg, arrsize(msg), format, args);
Dispatch(severity, msg);
}
//============================================================================
//#ifdef HS_DEBUGGING
void LogMsgDebug (const char format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(kLogDebug, format, args);
va_end(args);
}
//#endif
//============================================================================
//#ifdef HS_DEBUGGING
void LogMsgDebug (const wchar format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(kLogDebug, format, args);
va_end(args);
}
//#endif

View File

@ -0,0 +1,127 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcLog.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACLOG_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcLog.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACLOG_H
/****************************************************************************
*
* Log API
*
***/
enum ELogSeverity {
// For indicating design problems
kLogDebug,
// For indicating performance warnings
// (e.g. transaction failed, retrying...)
kLogPerf,
// For indicating error conditions that change program behavior
// (e.g. socket connect failed)
kLogError,
// For indicating failures that may lead to program termination
// (e.g. out of memory)
kLogFatal,
kNumLogSeverity
};
void LogMsg (ELogSeverity severity, const char format[], ...);
void LogMsg (ELogSeverity severity, const wchar format[], ...);
void LogMsgV (ELogSeverity severity, const char format[], va_list args);
void LogMsgV (ELogSeverity severity, const wchar format[], va_list args);
void LogBreakOnErrors (bool breakOnErrors);
void AsyncLogInitialize (
const wchar logDirName[],
bool breakOnErrors
);
void AsyncLogDestroy ();
void AsyncLogFlush ();
void AsyncLogGetDirectory (wchar * dest, unsigned destChars);
// Low(er) level log API; call this from your LogHander function
// if you want to use the asynchronous log facility.
void AsyncLogWriteMsg (
const wchar facility[],
ELogSeverity severity,
const wchar msg[]
);
// FLogHandler must be capable of handling multiple threads and re-entrancy
typedef void (* FLogHandler) (ELogSeverity severity, const wchar msg[]);
void LogRegisterHandler (FLogHandler callback);
void LogUnregisterHandler (FLogHandler callback);
/****************************************************************************
*
* Debugging API
*
***/
//#ifdef HS_DEBUGGING
void LogMsgDebug (const char format[], ...);
void LogMsgDebug (const wchar format[], ...);
//#else
//
// inline void LogMsgDebug (const char *, ...) { }
// inline void LogMsgDebug (const wchar *, ...) { }
//
//#endif

View File

@ -0,0 +1,146 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcThread.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTHREAD_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcThread.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTHREAD_H
/****************************************************************************
*
* Type definitions
*
***/
// for IoWaitId/TimerCreate/TimerUpdate
const unsigned kAsyncTimeInfinite = (unsigned) -1;
#ifdef _MSC_VER
#define THREADCALL __stdcall
#else
#define THREADCALL __cdecl
#endif
struct AsyncThread;
typedef unsigned (THREADCALL * FAsyncThreadProc)(AsyncThread * thread);
// Threads are also allowed to set the workTimeMs field of their
// structure to a nonzero value for "on", and IO_TIME_INFINITE for
// "off" to avoid the overhead of calling these functions. Note
// that this function may not be called for the main thread. I
// suggest that application code not worry that timeMs might
// "accidentally" equal the IO_TIME_INFINITE value, as it only
// happens for one millisecond every 49 days.
struct AsyncThread {
LINK(AsyncThread) link;
FAsyncThreadProc proc;
void * handle;
void * argument;
unsigned workTimeMs;
wchar name[16];
};
/*****************************************************************************
*
* Thread functions
*
***/
void * AsyncThreadCreate (
FAsyncThreadProc proc,
void * argument,
const wchar name[]
);
// This function should ONLY be called during shutdown while waiting for things to expire
void AsyncSleep (unsigned sleepMs);
/*****************************************************************************
*
* Thread task functions
*
***/
enum EThreadTaskPriority {
kThreadTaskPriorityNormal = 1,
kNumThreadTaskPriorities
};
const unsigned kThreadTaskMinThreads = 5;
const unsigned kThreadTaskDefThreads = 100;
const unsigned kThreadTaskMaxThreads = 1000;
struct AsyncThreadTaskList;
typedef void (* FAsyncThreadTask)(
void * param,
ENetError error
);
void AsyncThreadTaskInitialize (unsigned threads);
void AsyncThreadTaskDestroy ();
unsigned AsyncThreadTaskGetThreadCount ();
void AsyncThreadTaskSetThreadCount (unsigned threads);
AsyncThreadTaskList * AsyncThreadTaskListCreate ();
void AsyncThreadTaskListDestroy (
AsyncThreadTaskList * taskList,
ENetError error
);
void AsyncThreadTaskAdd (
AsyncThreadTaskList * taskList,
FAsyncThreadTask callback,
void * param,
const wchar debugStr[],
EThreadTaskPriority priority = kThreadTaskPriorityNormal
);

View File

@ -0,0 +1,105 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcTimer.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTIMER_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcTimer.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTIMER_H
/*****************************************************************************
*
* Timer functions
*
* Timers are repeatedly called back at a scheduled interval. Not that all
* timer procedures share the same thread, so timer procedures should:
*
* 1) Not be called too frequently
* 2) Not take too long to run or block for a long time
*
***/
struct AsyncTimer;
// Return callbackMs to wait that long until next callback.
// Return kAsyncTimeInfinite to stop callbacks (note: does not destroy Timer structure)
typedef unsigned (* FAsyncTimerProc)(void * param);
// 1) Timer procs do not get starved by I/O, they are called periodically.
// 2) Timer procs will never be called by multiple threads simultaneously.
void AsyncTimerCreate (
AsyncTimer ** timer,
FAsyncTimerProc timerProc,
unsigned callbackMs,
void * param = nil
);
// Timer procs can be in the process of getting called in
// another thread during the unregister function -- be careful!
// -- waitComplete = will wait until the timer has been unregistered and is
// no longer in the process of being called before returning. The flag may only
// be set by init/destruct threads, not I/O worker threads. In addition, extreme
// care should be used to avoid a deadlock when this flag is set; in general, it
// is a good idea not to hold any locks or critical sections when setting the flag.
const unsigned kAsyncTimerDestroyWaitComplete = 1<<0;
void AsyncTimerDelete (
AsyncTimer * timer,
unsigned flags = 0
);
void AsyncTimerDeleteCallback (
AsyncTimer * timer,
FAsyncTimerProc destroyProc
);
// To set the time value for a timer, use this function with flags = 0.
// To set the time to MoreRecentOf(nextTimerCallbackMs, callbackMs), use SetPriorityHigher
const unsigned kAsyncTimerUpdateSetPriorityHigher = 1<<0;
void AsyncTimerUpdate (
AsyncTimer * timer,
unsigned callbackMs,
unsigned flags = 0
);

View File

@ -0,0 +1,62 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/pnAsyncCore.h
*
* Asynchronous APIs:
* Sockets
* Files
* Threads
* Logging facility
* Callback facility
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PNASYNCCORE_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PNASYNCCORE_H
#include "Private/pnAcAllIncludes.h"
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PNASYNCCORE_H

View File

@ -0,0 +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/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#ifdef SERVER
#include "pnCrash/pnCrash.h" // deadlock API
#endif
#include "Private/pnAceInt.h"
#include "Private/W9x/pnAceW9x.h"
#include "Private/Nt/pnAceNt.h"
#include "Private/Unix/pnAceUx.h"
#include <process.h>
#include <malloc.h>

View File

@ -0,0 +1,503 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
#include "pnAceNtInt.h"
namespace Nt {
/****************************************************************************
*
* Private data
*
***/
// Use non-allocated arrays for worker threads since they're used so frequently.
const unsigned kMaxWorkerThreads = 32; // handles 8-processor computer w/hyperthreading
static bool s_running;
static HANDLE s_waitEvent;
static long s_ioThreadCount;
static HANDLE s_ioThreadHandles[kMaxWorkerThreads];
static HANDLE s_ioPort;
static unsigned s_pageSizeMask;
/****************************************************************************
*
* Waitable event handles
*
***/
//===========================================================================
CNtWaitHandle::CNtWaitHandle () {
m_refCount = 1;
m_event = CreateEvent(
(LPSECURITY_ATTRIBUTES) nil,
true, // manual reset
false, // initial state
(LPCTSTR) nil
);
}
//===========================================================================
CNtWaitHandle::~CNtWaitHandle () {
CloseHandle(m_event);
}
//===========================================================================
void CNtWaitHandle::IncRef () {
InterlockedIncrement(&m_refCount);
}
//===========================================================================
void CNtWaitHandle::DecRef () {
if (!InterlockedDecrement(&m_refCount))
DEL(this);
}
//===========================================================================
bool CNtWaitHandle::WaitForObject (unsigned timeMs) const {
return WAIT_TIMEOUT != WaitForSingleObject(m_event, timeMs);
}
//===========================================================================
void CNtWaitHandle::SignalObject () const {
SetEvent(m_event);
}
/****************************************************************************
*
* OPERATIONS
*
***/
//===========================================================================
static void INtOpDispatch (
NtObject * ntObj,
Operation * op,
dword bytes
) {
for (;;) {
switch (op->opType) {
case kOpConnAttempt:
INtSocketOpCompleteSocketConnect((NtOpConnAttempt *) op);
// operation not associated with ntObj so there is no next operation.
// operation has already been deleted by OpCompleteSocketConnect.
return;
case kOpQueuedSocketWrite:
INtSocketOpCompleteQueuedSocketWrite((NtSock *) ntObj, (NtOpSocketWrite *) op);
// operation converted into kOpSocketWrite so we cannot move
// to next operation until write operation completes
return;
case kOpSocketRead:
ASSERT(bytes != (dword) -1);
INtSocketOpCompleteSocketRead((NtSock *) ntObj, bytes);
return;
case kOpSocketWrite:
ASSERT(bytes != (dword) -1);
INtSocketOpCompleteSocketWrite((NtSock *) ntObj, (NtOpSocketWrite *) op);
break;
case kOpQueuedFileRead:
case kOpQueuedFileWrite:
INtFileOpCompleteQueuedReadWrite((NtFile *) ntObj, (NtOpFileReadWrite *) op);
// operation converted into kOpFileWrite so we cannot move
// to next operation until write operation completes
return;
case kOpFileRead:
case kOpFileWrite:
ASSERT(bytes != (dword) -1);
if (!INtFileOpCompleteReadWrite((NtFile *) ntObj, (NtOpFileReadWrite *) op, bytes))
return;
break;
case kOpFileFlush:
INtFileOpCompleteFileFlush((NtFile *) ntObj, (NtOpFileFlush *) op);
break;
case kOpSequence:
INtFileOpCompleteSequence((NtFile *) ntObj, (NtOpFileSequence *) op);
break;
DEFAULT_FATAL(opType);
}
// if this operation is not at the head of the list then it can't be completed
// because nextCompleteSequence would be prematurely incremented. Instead
// convert the operation to OP_NULL, which will get completed when it reaches
// the head of the list.
ntObj->critsect.Enter();
if (ntObj->opList.Prev(op)) {
// setting the completion flag must be done inside the critical section
// because it will be checked by sibling operations when they have the
// critical section.
op->pending = 0;
ntObj->critsect.Leave();
return;
}
// complete processing this event, and, since we're still inside the critical
// section, finish all completed operations since we don't have to leave the
// critical section to do so. This is a big win because a single operation
// that takes a long time to complete can backlog a long list of completed ops.
bool continueDispatch;
for (;;) {
// wake up any other threads waiting on this event
CNtWaitHandle * signalComplete = op->signalComplete;
op->signalComplete = nil;
// since this operation is at the head of the list we can complete it
if (op->asyncId && !++ntObj->nextCompleteSequence)
++ntObj->nextCompleteSequence;
Operation * next = ntObj->opList.Next(op);
ntObj->opList.Delete(op);
op = next;
// set event *after* operation is complete
if (signalComplete) {
signalComplete->SignalObject();
signalComplete->DecRef();
}
// if we just deleted the last operation then stop dispatching
if (!op) {
continueDispatch = false;
break;
}
// opTypes >= kOpSequence complete when they reach the head of the list
continueDispatch = op->opType >= kOpSequence;
if (op->pending)
break;
InterlockedDecrement(&ntObj->ioCount);
}
ntObj->critsect.Leave();
INtConnCompleteOperation(ntObj);
if (!continueDispatch)
break;
// certain operations which depend upon the value of bytes (reads & writes)
// can only be dispatched when they are completed normally. To ensure that
// we're not accidentally processing an operation that shouldn't be executed,
// set the bytes field to an invalid value.
bytes = (dword) -1;
}
}
//===========================================================================
static unsigned THREADCALL NtWorkerThreadProc (AsyncThread * thread) {
REF(thread);
ThreadDenyBlock();
unsigned sleepMs = INFINITE;
while (s_running) {
// process I/O operations
{
dword bytes;
NtObject * ntObj;
Operation * op;
(void) GetQueuedCompletionStatus(
s_ioPort,
&bytes,
#ifdef _WIN64
(PULONG_PTR) &ntObj,
#else
(LPDWORD) &ntObj,
#endif
(LPOVERLAPPED *) &op,
sleepMs
);
if (op) {
// Queue for deadlock detection
#ifdef SERVER
void * check = CrashAddDeadlockCheck(thread->handle, L"pnAceNt.NtWorkerThread");
#endif
// Dispatch event to app
INtOpDispatch(ntObj, op, bytes);
// Unqueue from deadlock detection
#ifdef SERVER
CrashRemoveDeadlockCheck(check);
#endif
sleepMs = 0;
continue;
}
}
sleepMs = INFINITE;
continue;
}
return 0;
}
/****************************************************************************
*
* Module functions
*
***/
//===========================================================================
void INtConnPostOperation (NtObject * ntObj, Operation * op, unsigned bytes) {
PostQueuedCompletionStatus(
s_ioPort,
bytes,
#ifdef _WIN64
(ULONG_PTR) ntObj,
#else
(DWORD) ntObj,
#endif
&op->overlapped
);
}
//===========================================================================
AsyncId INtConnSequenceStart (NtObject * ntObj) {
unsigned result;
if (0 == (result = ++ntObj->nextStartSequence))
result = ++ntObj->nextStartSequence;
return (AsyncId) result;
}
//===========================================================================
bool INtConnInitialize (NtObject * ntObj) {
if (!CreateIoCompletionPort(ntObj->handle, s_ioPort, (DWORD) ntObj, 0)) {
LogMsg(kLogFatal, "CreateIoCompletionPort failed");
return false;
}
return true;
}
//===========================================================================
void INtConnCompleteOperation (NtObject * ntObj) {
// are we completing the last operation for this object?
if (InterlockedDecrement(&ntObj->ioCount))
return;
DWORD err = GetLastError();
REF(err);
switch (ntObj->ioType) {
case kNtFile:
INtFileDelete((NtFile *) ntObj);
break;
case kNtSocket:
INtSockDelete((NtSock *) ntObj);
break;
default:
LogMsg(kLogError, "NtConnCompleteOp %p %u", ntObj, ntObj->ioType);
break;
}
}
/*****************************************************************************
*
* Module exports
*
***/
//===========================================================================
void NtInitialize () {
// ensure initialization only occurs once
if (s_running)
return;
s_running = true;
// create a cleanup event
s_waitEvent = CreateEvent(
(LPSECURITY_ATTRIBUTES) 0,
true, // manual reset
false, // initial state off
(LPCTSTR) nil // name
);
if (!s_waitEvent)
ErrorFatal(__LINE__, __FILE__, "CreateEvent %#x", GetLastError());
// create IO completion port
if (0 == (s_ioPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0)))
ErrorFatal(__LINE__, __FILE__, "CreateIoCompletionPort %#x", GetLastError());
// calculate number of IO worker threads to create
if (!s_pageSizeMask) {
SYSTEM_INFO si;
GetSystemInfo(&si);
s_pageSizeMask = si.dwPageSize - 1;
// Set worker thread count
s_ioThreadCount = si.dwNumberOfProcessors * 2;
if (s_ioThreadCount > kMaxWorkerThreads) {
s_ioThreadCount = kMaxWorkerThreads;
LogMsg(kLogError, "kMaxWorkerThreads too small!");
}
}
// create IO worker threads
for (long thread = 0; thread < s_ioThreadCount; thread++) {
s_ioThreadHandles[thread] = (HANDLE) AsyncThreadCreate(
NtWorkerThreadProc,
(void *) thread,
L"NtWorkerThread"
);
}
INtFileInitialize();
INtSocketInitialize();
}
//===========================================================================
// DANGER: calling this function will slam closed any files which are still open.
// MOST PROGRAMS DO NOT NEED TO CALL THIS FUNCTION. In general, the best way to
// shut down the program is to simply let the atexit() handler take care of it.
void NtDestroy (unsigned exitThreadWaitMs) {
// cleanup modules that post completion notifications as part of their shutdown
INtFileStartCleanup();
INtSocketStartCleanup(exitThreadWaitMs);
// cleanup worker threads
s_running = false;
if (s_ioPort) {
// Post a completion notification to worker threads to wake them up
long thread;
for (thread = 0; thread < s_ioThreadCount; thread++)
PostQueuedCompletionStatus(s_ioPort, 0, 0, 0);
// Close each thread
for (thread = 0; thread < s_ioThreadCount; thread++) {
if (s_ioThreadHandles[thread]) {
WaitForSingleObject(s_ioThreadHandles[thread], exitThreadWaitMs);
CloseHandle(s_ioThreadHandles[thread]);
s_ioThreadHandles[thread] = nil;
}
}
// Cleanup port
CloseHandle(s_ioPort);
s_ioPort = 0;
}
if (s_waitEvent) {
CloseHandle(s_waitEvent);
s_waitEvent = 0;
}
INtFileDestroy();
INtSocketDestroy();
}
//===========================================================================
void NtSignalShutdown () {
SetEvent(s_waitEvent);
}
//===========================================================================
void NtWaitForShutdown () {
if (s_waitEvent)
WaitForSingleObject(s_waitEvent, INFINITE);
}
} using namespace Nt;
/****************************************************************************
*
* Public exports
*
***/
//===========================================================================
void NtGetApi (AsyncApi * api) {
api->initialize = NtInitialize;
api->destroy = NtDestroy;
api->signalShutdown = NtSignalShutdown;
api->waitForShutdown = NtWaitForShutdown;
api->sleep = NtSleep;
api->fileOpen = NtFileOpen;
api->fileClose = NtFileClose;
api->fileRead = NtFileRead;
api->fileWrite = NtFileWrite;
api->fileFlushBuffers = NtFileFlushBuffers;
api->fileSetLastWriteTime = NtFileSetLastWriteTime;
api->fileGetLastWriteTime = NtFileGetLastWriteTime;
api->fileCreateSequence = NtFileCreateSequence;
api->fileSeek = NtFileSeek;
api->socketConnect = NtSocketConnect;
api->socketConnectCancel = NtSocketConnectCancel;
api->socketDisconnect = NtSocketDisconnect;
api->socketDelete = NtSocketDelete;
api->socketSend = NtSocketSend;
api->socketWrite = NtSocketWrite;
api->socketSetNotifyProc = NtSocketSetNotifyProc;
api->socketSetBacklogAlloc = NtSocketSetBacklogAlloc;
api->socketStartListening = NtSocketStartListening;
api->socketStopListening = NtSocketStopListening;
api->socketEnableNagling = NtSocketEnableNagling;
}

View File

@ -0,0 +1,64 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_NT_PNACENT_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNt.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_NT_PNACENT_H
#ifdef HS_BUILD_FOR_WIN32
/****************************************************************************
*
* Nt API functions
*
***/
void NtGetApi (AsyncApi * api);
#endif // HS_BUILD_FOR_WIN32

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,336 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_NT_PNACENTINT_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtInt.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_NT_PNACENTINT_H
namespace Nt {
/****************************************************************************
*
* Type definitions
*
***/
enum EIoType {
kNtFile,
kNtSocket,
kIoTypes
};
enum EOpType {
// Completed by GetQueuedCompletionStatus
kOpConnAttempt,
kOpSocketRead,
kOpSocketWrite,
kOpFileRead,
kOpFileWrite,
// opType >= kOpSequence complete when they reach the head of the list
kOpSequence,
kOpFileFlush,
kOpQueuedFileRead,
kOpQueuedFileWrite,
kOpQueuedSocketWrite,
kNumOpTypes
};
class CNtCritSect : public CCritSect {
public:
BOOL TryEnter () { return TryEnterCriticalSection(&m_handle); }
};
class CNtWaitHandle {
long m_refCount;
HANDLE m_event;
public:
CNtWaitHandle ();
~CNtWaitHandle ();
void IncRef ();
void DecRef ();
bool WaitForObject (unsigned timeMs) const;
void SignalObject () const;
};
struct Operation {
OVERLAPPED overlapped;
EOpType opType;
AsyncId asyncId;
bool notify;
unsigned pending;
CNtWaitHandle * signalComplete;
LINK(Operation) link;
#ifdef HS_DEBUGGING
~Operation () {
ASSERT(!signalComplete);
}
#endif
};
struct NtObject {
CNtCritSect critsect;
EIoType ioType;
HANDLE handle;
void * userState;
LISTDECL(Operation, link) opList;
long nextCompleteSequence;
long nextStartSequence;
long ioCount;
bool closed;
};
/****************************************************************************
*
* Nt.cpp internal functions
*
***/
void INtWakeupMainIoThreads ();
void INtConnPostOperation (NtObject * ntObj, Operation * op, unsigned bytes);
AsyncId INtConnSequenceStart (NtObject * ntObj);
bool INtConnInitialize (NtObject * ntObj);
void INtConnCompleteOperation (NtObject * ntObj);
/*****************************************************************************
*
* NtFile.cpp internal functions
*
***/
struct NtFile;
struct NtOpFileFlush;
struct NtOpFileReadWrite;
struct NtOpFileSequence;
void INtFileInitialize ();
void INtFileStartCleanup ();
void INtFileDestroy ();
void INtFileDelete (
NtFile * file
);
bool INtFileOpCompleteReadWrite (
NtFile * ioConn,
NtOpFileReadWrite * op,
unsigned bytes
);
void INtFileOpCompleteQueuedReadWrite (
NtFile * ioConn,
NtOpFileReadWrite * op
);
void INtFileOpCompleteFileFlush (
NtFile * ioConn,
NtOpFileFlush * op
);
void INtFileOpCompleteSequence (
NtFile * ioConn,
NtOpFileSequence * op
);
void INtFileStartCleanup ();
/*****************************************************************************
*
* NtSocket.cpp internal functions
*
***/
struct NtSock;
struct NtOpConnAttempt;
struct NtOpSocketWrite;
void INtSocketInitialize ();
void INtSocketStartCleanup (unsigned exitThreadWaitMs);
void INtSocketDestroy ();
void INtSockDelete (
NtSock * sock
);
void INtSocketOpCompleteSocketConnect (
NtOpConnAttempt * op
);
void INtSocketOpCompleteSocketRead (
NtSock * sock,
unsigned bytes
);
void INtSocketOpCompleteSocketWrite (
NtSock * sock,
NtOpSocketWrite * op
);
bool INtSocketOpCompleteQueuedSocketWrite (
NtSock * sock,
NtOpSocketWrite * op
);
/*****************************************************************************
*
* NT Async API functions
*
***/
void NtInitialize ();
void NtDestroy (unsigned exitThreadWaitMs);
void NtSignalShutdown ();
void NtWaitForShutdown ();
void NtSleep (unsigned sleepMs);
AsyncFile NtFileOpen (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
);
void NtFileClose (
AsyncFile file,
qword truncateSize
);
void NtFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
);
qword NtFileGetLastWriteTime (
const wchar fileName[]
);
AsyncId NtFileFlushBuffers (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
);
AsyncId NtFileRead (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
AsyncId NtFileWrite (
AsyncFile file,
qword offset,
const void *buffer,
unsigned bytes,
unsigned flags,
void * param
);
AsyncId NtFileCreateSequence (
AsyncFile file,
bool notify,
void * param
);
bool NtFileSeek (
AsyncFile file,
qword distance,
EFileSeekFrom from
);
void NtSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
unsigned sendBytes,
unsigned connectMs,
unsigned localPort
);
void NtSocketConnectCancel (
FAsyncNotifySocketProc notifyProc,
AsyncCancelId cancelId
);
void NtSocketDisconnect (
AsyncSocket sock,
bool hardClose
);
void NtSocketDelete (AsyncSocket sock);
bool NtSocketSend (
AsyncSocket sock,
const void * data,
unsigned bytes
);
bool NtSocketWrite (
AsyncSocket sock,
const void * buffer,
unsigned bytes,
void * param
);
void NtSocketSetNotifyProc (
AsyncSocket sock,
FAsyncNotifySocketProc notifyProc
);
void NtSocketSetBacklogAlloc (
AsyncSocket sock,
unsigned bufferSize
);
unsigned NtSocketStartListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
);
void NtSocketStopListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
);
void NtSocketEnableNagling (
AsyncSocket conn,
bool enable
);
} // namespace Nt

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +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/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Nt/pnAceNtThread.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
#include "pnAceNtInt.h"
namespace Nt {
/*****************************************************************************
*
* Module exports
*
***/
//===========================================================================
void NtSleep (unsigned sleepMs) {
ThreadAssertCanBlock(__FILE__, __LINE__);
Sleep(sleepMs);
}
} using namespace Nt;

View File

@ -0,0 +1,64 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Unix/pnAceUx.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_UNIX_PNACEUX_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Unix/pnAceUx.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_UNIX_PNACEUX_H
#ifdef HS_BUILD_FOR_UNIX
/****************************************************************************
*
* Win9x API functions
*
***/
void UxGetApi (AsyncApi * api);
#endif // HS_BUILD_FOR_UNIX

View File

@ -0,0 +1,91 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9x.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
#include "pnAceW9xInt.h"
/****************************************************************************
*
* Exported functions
*
***/
//===========================================================================
void W9xGetApi (AsyncApi * api) {
using namespace W9x;
api->initialize = W9xThreadInitialize;
api->destroy = W9xThreadDestroy;
api->signalShutdown = W9xThreadSignalShutdown;
api->waitForShutdown = W9xThreadWaitForShutdown;
api->sleep = W9xThreadSleep;
api->fileOpen = W9xFileOpen;
api->fileClose = W9xFileClose;
api->fileRead = W9xFileRead;
api->fileWrite = W9xFileWrite;
api->fileFlushBuffers = W9xFileFlushBuffers;
api->fileSetLastWriteTime = W9xFileSetLastWriteTime;
api->fileGetLastWriteTime = W9xFileGetLastWriteTime;
api->fileCreateSequence = W9xFileCreateSequence;
api->fileSeek = W9xFileSeek;
api->socketConnect = W9xSocketConnect;
api->socketConnectCancel = W9xSocketConnectCancel;
api->socketDisconnect = W9xSocketDisconnect;
api->socketDelete = W9xSocketDelete;
api->socketSend = W9xSocketSend;
api->socketWrite = W9xSocketWrite;
api->socketSetNotifyProc = W9xSocketSetNotifyProc;
api->socketSetBacklogAlloc = W9xSocketSetBacklogAlloc;
api->socketStartListening = W9xSocketStartListening;
api->socketStopListening = W9xSocketStopListening;
api->socketEnableNagling = W9xSocketEnableNagling;
}

View File

@ -0,0 +1,64 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9x.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_W9X_PNACEW9X_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9x.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_W9X_PNACEW9X_H
#ifdef HS_BUILD_FOR_WIN32
/****************************************************************************
*
* Win9x API functions
*
***/
void W9xGetApi (AsyncApi * api);
#endif // HS_BUILD_FOR_WIN32

View File

@ -0,0 +1,518 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xFile.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
#include "pnAceW9xInt.h"
namespace W9x {
/****************************************************************************
*
* FileOp
*
***/
struct FileOp {
EAsyncNotifyFile code;
bool notify;
union {
AsyncNotifyFileFlush flush;
AsyncNotifyFileRead read;
AsyncNotifyFileSequence sequence;
AsyncNotifyFileWrite write;
} data;
};
/****************************************************************************
*
* CFile
*
***/
class CFile : public CThreadDispObject {
private:
CCritSect m_critSect;
HANDLE m_handle;
FAsyncNotifyFileProc m_notifyProc;
void * m_userState;
protected:
void Complete (void * op, CCritSect * critSect, AsyncId asyncId);
void Delete (void * op);
public:
CFile (
HANDLE handle,
FAsyncNotifyFileProc notifyProc,
void * userState
);
~CFile ();
void Read (
qword offset,
void * buffer,
unsigned bytes
);
void SetLastWriteTime (qword lastWriteTime);
void Truncate (qword size);
void Write (
qword offset,
const void * buffer,
unsigned bytes
);
bool Seek (qword offset, EFileSeekFrom from);
};
//===========================================================================
CFile::CFile (
HANDLE handle,
FAsyncNotifyFileProc notifyProc,
void * userState
) :
m_handle(handle),
m_notifyProc(notifyProc),
m_userState(userState)
{
}
//===========================================================================
CFile::~CFile () {
CloseHandle(m_handle);
m_handle = INVALID_HANDLE_VALUE;
}
//===========================================================================
void CFile::Complete (void * op, CCritSect * critSect, AsyncId asyncId) {
FileOp * fileOp = (FileOp *)op;
// Enter our local critical section and leave the global one
m_critSect.Enter();
critSect->Leave();
// Complete the operation
switch (fileOp->code) {
case kNotifyFileFlush: {
if (fileOp->data.flush.truncateSize != kAsyncFileDontTruncate)
Truncate(fileOp->data.flush.truncateSize);
BOOL result = FlushFileBuffers(m_handle);
fileOp->data.flush.error = result ? kFileSuccess : AsyncGetLastFileError();
}
break;
case kNotifyFileRead:
Read(
fileOp->data.read.offset,
fileOp->data.read.buffer,
fileOp->data.read.bytes
);
break;
case kNotifyFileWrite:
Write(
fileOp->data.write.offset,
fileOp->data.write.buffer,
fileOp->data.write.bytes
);
break;
}
// Leave our local critical section
m_critSect.Leave();
// Dispatch a completion notification
if (fileOp->notify) {
fileOp->data.flush.asyncId = asyncId;
m_notifyProc(
(AsyncFile)this,
fileOp->code,
&fileOp->data.flush,
&m_userState
);
}
}
//===========================================================================
void CFile::Delete (void * op) {
FileOp * fileOp = (FileOp *)op;
DEL(fileOp);
}
//===========================================================================
void CFile::Read (
qword offset,
void * buffer,
unsigned bytes
) {
// Seek to the start of the read
Seek(offset, kFileSeekFromBegin);
// Perform the read
DWORD bytesRead;
BOOL result = ReadFile(
m_handle,
buffer,
bytes,
&bytesRead,
nil // overlapped
);
// Handle errors
if (bytesRead != bytes)
MemZero((byte *)buffer + bytesRead, bytes - bytesRead);
if ( (!result && (GetLastError() != ERROR_IO_PENDING)) ||
(bytesRead != bytes) )
LogMsg(kLogFatal, "failed: ReadFile");
}
//===========================================================================
bool CFile::Seek (qword offset, EFileSeekFrom from) {
COMPILER_ASSERT(kFileSeekFromBegin == FILE_BEGIN);
COMPILER_ASSERT(kFileSeekFromCurrent == FILE_CURRENT);
COMPILER_ASSERT(kFileSeekFromEnd == FILE_END);
LONG low = (LONG)(offset % 0x100000000ul);
LONG high = (LONG)(offset / 0x100000000ul);
dword result = SetFilePointer(m_handle, low, &high, from);
if ((result == (dword)-1) && (GetLastError() != NO_ERROR)) {
LogMsg(kLogFatal, "failed: SetFilePointer");
return false;
}
else
return true;
}
//===========================================================================
void CFile::SetLastWriteTime (qword lastWriteTime) {
COMPILER_ASSERT(sizeof(lastWriteTime) == sizeof(FILETIME));
SetFileTime(m_handle, nil, nil, (const FILETIME *)&lastWriteTime);
}
//===========================================================================
void CFile::Truncate (qword size) {
ASSERT(size != kAsyncFileDontTruncate);
if (Seek(size, kFileSeekFromBegin) && !SetEndOfFile(m_handle))
LogMsg(kLogFatal, "failed: SetEndOfFile");
}
//===========================================================================
void CFile::Write (
qword offset,
const void * buffer,
unsigned bytes
) {
// Seek to the start of the write
Seek(offset, kFileSeekFromBegin);
// Perform the write
DWORD bytesWritten;
BOOL result = WriteFile(
m_handle,
buffer,
bytes,
&bytesWritten,
nil // overlapped
);
// Handle errors
if ( (!result && (GetLastError() != ERROR_IO_PENDING)) ||
(bytesWritten != bytes) ) {
LogMsg(kLogFatal, "failed: WriteFile");
if (!result && (GetLastError() == ERROR_DISK_FULL)) {
MessageBox(nil, "Disk full!", "Error", MB_ICONSTOP | MB_SYSTEMMODAL);
// DebugDisableLeakChecking();
ExitProcess(1);
}
}
}
/****************************************************************************
*
* Exported functions
*
***/
//===========================================================================
void W9xFileClose (
AsyncFile file,
qword truncateSize
) {
// Dereference the object
CFile * object = (CFile *)file;
// If requested, truncate the file
if (truncateSize != kAsyncFileDontTruncate)
object->Truncate(truncateSize);
// Close the file object
object->Close();
}
//===========================================================================
AsyncId W9xFileCreateSequence (
AsyncFile file,
bool notify,
void * param
) {
// Dereference the object
CFile * object = (CFile *)file;
// Queue an operation
FileOp * op = NEW(FileOp);
op->code = kNotifyFileSequence;
op->notify = notify;
op->data.flush.param = param;
return object->Queue(op);
}
//===========================================================================
AsyncId W9xFileFlushBuffers (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
) {
// Dereference the object
CFile * object = (CFile *)file;
// Queue an operation
FileOp * op = NEW(FileOp);
op->code = kNotifyFileFlush;
op->notify = notify;
op->data.flush.param = param;
op->data.flush.truncateSize = truncateSize;
// op->data.flush.error filled in upon completion
return object->Queue(op);
}
//===========================================================================
AsyncFile W9xFileOpen (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
) {
HANDLE fileHandle = CreateFileW(
fullPath,
desiredAccess,
shareModeFlags,
nil, // plSecurityAttributes
openMode,
0, // attributeFlags
nil // hTemplateFile
);
*error = AsyncGetLastFileError();
if (INVALID_HANDLE_VALUE == fileHandle)
return nil;
// don't allow users to open devices like "LPT1", etc.
if (GetFileType(fileHandle) != FILE_TYPE_DISK) {
LogMsg(kLogFatal, "failed: !FILE_TYPE_DISK");
*error = kFileErrorFileNotFound;
CloseHandle(fileHandle);
return nil;
}
// Get the file size
DWORD sizeHi, sizeLo = GetFileSize(fileHandle, &sizeHi);
if ((sizeLo == (DWORD) -1) && (NO_ERROR != GetLastError())) {
*error = AsyncGetLastFileError();
LogMsg(kLogFatal, "failed: GetFileSize");
CloseHandle(fileHandle);
return nil;
}
const qword size = ((qword) sizeHi << (qword) 32) | (qword) sizeLo;
qword lastWriteTime;
ASSERT(sizeof(lastWriteTime) >= sizeof(FILETIME));
GetFileTime(fileHandle, nil, nil, (FILETIME *) &lastWriteTime);
// Create a file object
CFile * object = NEW(CFile)(
fileHandle,
notifyProc,
userState
);
// return out parameters
if (fileSize)
*fileSize = size;
if (fileLastWriteTime)
*fileLastWriteTime = lastWriteTime;
return (AsyncFile)object;
}
//===========================================================================
AsyncId W9xFileRead (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
) {
// Dereference the object
CFile * object = (CFile *)file;
// Perform synchronous operations immediately
if (flags & kAsyncFileRwSync) {
object->Read(offset, buffer, bytes);
return 0;
}
// Queue asynchronous operations
else {
FileOp * op = NEW(FileOp);
op->code = kNotifyFileRead;
op->notify = (flags & kAsyncFileRwNotify) != 0;
op->data.read.param = param;
op->data.read.offset = offset;
op->data.read.buffer = (byte *)buffer;
op->data.read.bytes = bytes;
return object->Queue(op);
}
}
//===========================================================================
void W9xFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
) {
// Dereference the object
CFile * object = (CFile *)file;
// Set the file time
object->SetLastWriteTime(lastWriteTime);
}
//===========================================================================
qword W9xFileGetLastWriteTime (
const wchar fileName[]
) {
WIN32_FILE_ATTRIBUTE_DATA info;
bool f = GetFileAttributesExW(fileName, GetFileExInfoStandard, &info);
return f ? *((qword *) &info.ftLastWriteTime) : 0;
}
//===========================================================================
AsyncId W9xFileWrite (
AsyncFile file,
qword offset,
const void * buffer,
unsigned bytes,
unsigned flags,
void * param
) {
// Dereference the object
CFile * object = (CFile *)file;
// Perform synchronous operations immediately
if (flags & kAsyncFileRwSync) {
object->Write(offset, buffer, bytes);
return 0;
}
// Queue asynchronous operations
else {
FileOp * op = NEW(FileOp);
op->code = kNotifyFileWrite;
op->notify = (flags & kAsyncFileRwNotify) != 0;
op->data.write.param = param;
op->data.write.offset = offset;
op->data.write.buffer = (byte *)buffer;
op->data.write.bytes = bytes;
return object->Queue(op);
}
}
//============================================================================
bool W9xFileSeek (
AsyncFile file,
qword distance,
EFileSeekFrom from
) {
CFile * object = (CFile *)file;
return object->Seek(distance, from);
}
} // namespace W9x

View File

@ -0,0 +1,197 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xInt.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_W9X_PNACEW9XINT_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xInt.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_W9X_PNACEW9XINT_H
namespace W9x {
/*****************************************************************************
*
* Internal types
*
***/
class CThreadDispObject : public AtomicRef {
public:
CThreadDispObject ();
virtual ~CThreadDispObject () { }
void Close ();
virtual void Complete (void * op, CCritSect * critSect, AsyncId asyncId) = 0;
virtual void Delete (void * op) = 0;
AsyncId Queue (void * op);
};
/*****************************************************************************
*
* W9x internal async API
*
***/
void W9xThreadInitialize ();
void W9xThreadDestroy (unsigned exitThreadWaitMs);
void W9xThreadSignalShutdown ();
void W9xThreadWaitForShutdown ();
void W9xThreadSleep (unsigned sleepMs);
bool W9xThreadWaitId (
AsyncFile file,
AsyncId asyncId,
unsigned timeoutMs
);
AsyncFile W9xFileOpen (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
);
void W9xFileClose (
AsyncFile file,
qword truncateSize
);
void W9xFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
);
qword W9xFileGetLastWriteTime (
const wchar fileName[]
);
AsyncId W9xFileFlushBuffers (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
);
AsyncId W9xFileRead (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
AsyncId W9xFileWrite (
AsyncFile file,
qword offset,
const void *buffer,
unsigned bytes,
unsigned flags,
void * param
);
AsyncId W9xFileCreateSequence (
AsyncFile file,
bool notify,
void * param
);
bool W9xFileSeek (
AsyncFile file,
qword distance,
EFileSeekFrom from
);
void W9xSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
unsigned sendBytes,
unsigned connectMs,
unsigned localPort
);
void W9xSocketConnectCancel (
FAsyncNotifySocketProc notifyProc,
AsyncCancelId cancelId
);
void W9xSocketDisconnect (
AsyncSocket sock,
bool hardClose
);
void W9xSocketDelete (AsyncSocket sock);
void W9xSocketDestroy ();
bool W9xSocketSend (
AsyncSocket sock,
const void * data,
unsigned bytes
);
bool W9xSocketWrite (
AsyncSocket sock,
const void * buffer,
unsigned bytes,
void * param
);
void W9xSocketSetNotifyProc (
AsyncSocket sock,
FAsyncNotifySocketProc notifyProc
);
void W9xSocketSetBacklogAlloc (
AsyncSocket sock,
unsigned bufferSize
);
unsigned W9xSocketStartListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
);
void W9xSocketStopListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
);
void W9xSocketEnableNagling (
AsyncSocket conn,
bool enable
);
} // namespace W9x

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,453 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/W9x/pnAceW9xThread.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
#include "pnAceW9xInt.h"
namespace W9x {
/*****************************************************************************
*
* Private data
*
***/
const unsigned kThreadCount = 2;
static CCritSect s_critSect;
static bool s_destroying;
static HANDLE s_destroyEvent;
static unsigned s_sequence;
static HANDLE s_shutdownEvent;
static HANDLE s_signalEvent;
static HANDLE s_thread[kThreadCount];
/****************************************************************************
*
* ThreadWaitRec
*
***/
struct ThreadWaitRec {
HANDLE event;
LINK(ThreadWaitRec) link;
};
/****************************************************************************
*
* CThreadDispRec
*
***/
class CThreadDispRec {
private:
CThreadDispObject * m_object;
void * m_op;
AsyncId m_ioId;
LISTDECL(ThreadWaitRec, link) m_waitList;
public:
LINK(CThreadDispRec) m_link;
CThreadDispRec (
CThreadDispObject * object,
void * op,
AsyncId * asyncId
);
~CThreadDispRec ();
void Complete (CCritSect * critSect);
AsyncId GetId () const { return m_ioId; }
void LinkWait (ThreadWaitRec * wait);
};
static LISTDECL(CThreadDispRec, m_link) s_dispList;
static LISTDECL(CThreadDispRec, m_link) s_dispInProcList;
//===========================================================================
CThreadDispRec::CThreadDispRec (
CThreadDispObject * object,
void * op,
AsyncId * asyncId
) :
m_object(object),
m_op(op)
{
s_critSect.Enter();
// Verify that this module is not being destroyed
ASSERT(!s_destroying);
// Increment the owning object's reference count
object->IncRef();
// Assign an id
m_ioId = (AsyncId)++s_sequence;
if (!m_ioId)
m_ioId = (AsyncId)++s_sequence;
*asyncId = m_ioId;
// Link this record to the dispatch list
s_dispList.Link(this);
s_critSect.Leave();
}
//===========================================================================
CThreadDispRec::~CThreadDispRec () {
// Delete the operation data
CThreadDispObject * object = m_object;
object->Delete(m_op);
s_critSect.Enter();
// Unlink this record
m_link.Unlink();
// Wake up all threads blocking on this operation. We must unlink each
// wait record before we signal it.
for (ThreadWaitRec * rec; (rec = m_waitList.Head()) != nil; ) {
m_waitList.Unlink(rec);
SetEvent(rec->event);
}
// Decrement the owning object's reference count
object->DecRef();
s_critSect.Leave();
}
//===========================================================================
void CThreadDispRec::Complete (CCritSect * critSect) {
m_object->Complete(m_op, critSect, m_ioId);
}
//===========================================================================
void CThreadDispRec::LinkWait (ThreadWaitRec * wait) {
// The caller should have already claimed the critical section before
// calling this function
m_waitList.Link(wait);
}
/****************************************************************************
*
* CThreadDispObject
*
***/
//===========================================================================
CThreadDispObject::CThreadDispObject () {
IncRef();
}
//===========================================================================
void CThreadDispObject::Close () {
s_critSect.Enter();
DecRef();
s_critSect.Leave();
}
//===========================================================================
AsyncId CThreadDispObject::Queue (void * op) {
AsyncId asyncId = 0;
NEW(CThreadDispRec)(this, op, &asyncId);
SetEvent(s_signalEvent);
return asyncId;
}
/****************************************************************************
*
* Thread procedure
*
***/
//===========================================================================
static unsigned CALLBACK W9xThreadProc (AsyncThread *) {
// Perform the main thread loop
for (;;) {
unsigned timeout = (unsigned)-1;
// If an operation is queued, complete it and dispatch a notification.
// The code that processes the operation is responsible for leaving
// our critical section. This ensures that operations are completed
// in order.
s_critSect.Enter();
CThreadDispRec * rec = s_dispList.Head();
if (rec) {
s_dispInProcList.Link(rec);
rec->Complete(&s_critSect);
DEL(rec);
timeout = 0;
}
else {
s_critSect.Leave();
}
// Consume events, check for destruction, and block if we have
// nothing to do.
HANDLE events[] = {s_destroyEvent, s_signalEvent};
dword result = WaitForMultipleObjects(
arrsize(events),
events,
FALSE,
INFINITE
);
if (result == WAIT_OBJECT_0)
return 0;
}
}
/****************************************************************************
*
* Exported functions
*
***/
//===========================================================================
void W9xThreadDestroy (
unsigned exitThreadWaitMs
) {
// Wait until all outstanding I/O is complete. We allow new I/O
// operations to be queued while old ones are completing.
s_critSect.Enter();
while (s_dispList.Head() || s_dispInProcList.Head()) {
s_critSect.Leave();
Sleep(10);
s_critSect.Enter();
}
// Once all I/O operations are complete, we disallow any future
// I/O operations from being queued.
s_destroying = true;
s_critSect.Leave();
// Signal thread destruction
if (s_destroyEvent)
SetEvent(s_destroyEvent);
// Wait for thread destruction
for (unsigned thread = kThreadCount; thread--; )
if (s_thread[thread]) {
// Wait for the thread to terminate
WaitForSingleObject(s_thread[thread], exitThreadWaitMs);
// Close the thread handle
CloseHandle(s_thread[thread]);
s_thread[thread] = 0;
}
// Destroy internal modules
W9xSocketDestroy();
// Destroy events
if (s_destroyEvent) {
CloseHandle(s_destroyEvent);
s_destroyEvent = 0;
}
if (s_shutdownEvent) {
CloseHandle(s_shutdownEvent);
s_shutdownEvent = 0;
}
if (s_signalEvent) {
CloseHandle(s_signalEvent);
s_signalEvent = 0;
}
}
//===========================================================================
void W9xThreadInitialize () {
// Reset static variables
s_destroying = false;
// Create a manual reset event to use for signaling thread destruction
if (s_destroyEvent)
ResetEvent(s_destroyEvent);
else {
s_destroyEvent = CreateEvent(nil, TRUE, FALSE, nil);
ASSERT(s_destroyEvent);
}
// Create an auto-reset event to use for signaling the thread to process
// notifications
if (!s_signalEvent) {
s_signalEvent = CreateEvent(nil, FALSE, FALSE, nil);
ASSERT(s_signalEvent);
}
// Create a manual reset event to use for signaling application shutdown
if (s_shutdownEvent)
ResetEvent(s_shutdownEvent);
else {
s_shutdownEvent = CreateEvent(nil, TRUE, FALSE, nil);
ASSERT(s_shutdownEvent);
}
// Create threads
for (unsigned thread = 0; thread < kThreadCount; ++thread) {
if (!s_thread[thread]) {
s_thread[thread] = (HANDLE) AsyncThreadCreate(
W9xThreadProc,
(void *) thread,
L"W9xWorkerThread"
);
}
}
}
//===========================================================================
void W9xThreadSignalShutdown () {
SetEvent(s_shutdownEvent);
}
//===========================================================================
void W9xThreadSleep (
unsigned sleepMs
) {
Sleep(sleepMs);
}
//===========================================================================
void W9xThreadWaitForShutdown () {
// We know that the applicaton is finished initializing at this point.
// While it was still initializing, it may have returned an infinite
// sleep time from the idle procedure, which would prevent us from ever
// calling it again. Therefore, we trigger an idle callback here.
SetEvent(s_signalEvent);
// Wait for the application to signal shutdown
WaitForSingleObject(s_shutdownEvent, INFINITE);
}
//===========================================================================
bool W9xThreadWaitId (
AsyncFile file,
AsyncId asyncId,
unsigned timeoutMs
) {
REF(file);
// Find a pending I/O operation with the given id
s_critSect.Enter();
CThreadDispRec * disp;
for (disp = s_dispList.Head(); disp && (disp->GetId() != asyncId); disp = s_dispList.Next(disp))
;
if (!disp)
for (disp = s_dispInProcList.Head(); disp && (disp->GetId() != asyncId); disp = s_dispInProcList.Next(disp))
;
// If we couldn't find the given id, the operation must have already
// completed, so return true.
if (!disp) {
s_critSect.Leave();
return true;
}
// The operation has not completed. If the timeout is zero, return
// false.
if (!timeoutMs) {
s_critSect.Leave();
return false;
}
// Create a wait event
HANDLE event = CreateEvent(nil, FALSE, FALSE, nil);
// Create a wait record and link it to the I/O operation
ThreadWaitRec wait;
wait.event = event;
disp->LinkWait(&wait);
s_critSect.Leave();
// Wait for the operation to complete
DWORD result = WaitForSingleObject(event, timeoutMs);
// If the operation completed then the dispatcher unlinked our wait
// record before signaling it. We can simply free the event and return.
if (result == WAIT_OBJECT_0) {
CloseHandle(event);
return true;
}
// Unlink our wait record from the I/O operation
s_critSect.Enter();
wait.link.Unlink();
s_critSect.Leave();
// Free the event
CloseHandle(event);
// Return false, because the operation did not complete during the
// timeout period
return false;
}
} // namespace W9x

View File

@ -0,0 +1,400 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Dns.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private
*
***/
enum {
WM_LOOKUP_EXIT = WM_APP,
WM_LOOKUP_FOUND_HOST
};
const unsigned kMaxLookupName = 128;
struct Lookup {
LINK(Lookup) link;
AsyncCancelId cancelId;
HANDLE cancelHandle;
FAsyncLookupProc lookupProc;
unsigned port;
void * param;
wchar name[kMaxLookupName];
char buffer[MAXGETHOSTSTRUCT];
};
static CCritSect s_critsect;
static LISTDECL(Lookup, link) s_lookupList;
static HANDLE s_lookupThread;
static HWND s_lookupWindow;
static unsigned s_nextLookupCancelId = 1;
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static void LookupProcess (Lookup * lookup, unsigned error) {
unsigned count = 0;
NetAddress * addrs = nil;
for (ONCE) {
if (error)
break;
const HOSTENT & host = * (HOSTENT *) lookup->buffer;
if (host.h_addrtype != AF_INET)
break;
if (host.h_length != sizeof(in_addr))
break;
if (!host.h_addr_list)
break;
in_addr const * const * const inAddr = (in_addr **) host.h_addr_list;
// count the number of addresses
while (inAddr[count])
++count;
// allocate a buffer large enough to hold all the addresses
addrs = (NetAddress *) _alloca(sizeof(*addrs) * count);
MemZero(addrs, sizeof(*addrs) * count);
// fill in address data
const word port = htons((word) lookup->port);
for (unsigned i = 0; i < count; ++i) {
sockaddr_in * inetaddr = (sockaddr_in *) &addrs[i];
inetaddr->sin_family = AF_INET;
inetaddr->sin_addr = *inAddr[i];
inetaddr->sin_port = port;
}
if (host.h_name && host.h_name[0])
StrToUnicode(lookup->name, host.h_name, arrsize(lookup->name));
}
if (lookup->lookupProc)
lookup->lookupProc(lookup->param, lookup->name, count, addrs);
// we can delete the operation outside an IoConn critical
// section because it isn't linked into an ioConn opList
// and because connection attempts are not waitable
ASSERT(!lookup->link.IsLinked());
DEL(lookup);
PerfSubCounter(kAsyncPerfNameLookupAttemptsCurr, 1);
}
//===========================================================================
static void LookupFindAndProcess (HANDLE cancelHandle, unsigned error) {
// find the operation for this cancel handle
Lookup * lookup;
s_critsect.Enter();
for (lookup = s_lookupList.Head(); lookup; lookup = s_lookupList.Next(lookup)) {
if (lookup->cancelHandle == cancelHandle) {
lookup->cancelHandle = nil;
s_lookupList.Unlink(lookup);
break;
}
}
s_critsect.Leave();
if (lookup)
LookupProcess(lookup, error);
}
//===========================================================================
static unsigned THREADCALL LookupThreadProc (AsyncThread * thread) {
static const char WINDOW_CLASS[] = "AsyncLookupWnd";
WNDCLASS wc;
ZERO(wc);
wc.lpfnWndProc = DefWindowProc;
wc.hInstance = GetModuleHandle(0);
wc.lpszClassName = WINDOW_CLASS;
RegisterClass(&wc);
s_lookupWindow = CreateWindow(
WINDOW_CLASS,
WINDOW_CLASS,
WS_OVERLAPPED,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
(HWND)0,
(HMENU) 0,
wc.hInstance,
0
);
if (!s_lookupWindow)
ErrorFatal(__LINE__, __FILE__, "CreateWindow %#x", GetLastError());
HANDLE lookupStartEvent = (HANDLE) thread->argument;
SetEvent(lookupStartEvent);
MSG msg;
while (GetMessage(&msg, s_lookupWindow, 0, 0)) {
if (msg.message == WM_LOOKUP_FOUND_HOST)
LookupFindAndProcess((HANDLE) msg.wParam, HIWORD(msg.lParam));
else if (msg.message == WM_LOOKUP_EXIT)
break;
else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
// fail all pending name lookups
for (;;) {
s_critsect.Enter();
Lookup * lookup = s_lookupList.Head();
if (lookup) {
WSACancelAsyncRequest(lookup->cancelHandle);
lookup->cancelHandle = nil;
s_lookupList.Unlink(lookup);
}
s_critsect.Leave();
if (!lookup)
break;
LookupProcess(lookup, (unsigned) -1);
}
// cleanup
DestroyWindow(s_lookupWindow);
s_lookupWindow = nil;
return 0;
}
//===========================================================================
static void StartLookupThread () {
if (s_lookupThread)
return;
// create a shutdown event
HANDLE lookupStartEvent = CreateEvent(
(LPSECURITY_ATTRIBUTES) 0,
true, // manual reset
false, // initial state off
(LPCTSTR) 0 // name
);
if (!lookupStartEvent)
ErrorFatal(__LINE__, __FILE__, "CreateEvent %#x", GetLastError());
// create a thread to perform lookups
s_lookupThread = (HANDLE) AsyncThreadCreate(
LookupThreadProc,
lookupStartEvent,
L"AsyncLookupThread"
);
WaitForSingleObject(lookupStartEvent, INFINITE);
CloseHandle(lookupStartEvent);
ASSERT(s_lookupWindow);
}
/*****************************************************************************
*
* Module functions
*
***/
//===========================================================================
void DnsDestroy (unsigned exitThreadWaitMs) {
if (s_lookupThread) {
PostMessage(s_lookupWindow, WM_LOOKUP_EXIT, 0, 0);
WaitForSingleObject(s_lookupThread, exitThreadWaitMs);
CloseHandle(s_lookupThread);
s_lookupThread = nil;
ASSERT(!s_lookupWindow);
}
}
/*****************************************************************************
*
* Public functions
*
***/
//===========================================================================
void AsyncAddressLookupName (
AsyncCancelId * cancelId, // out
FAsyncLookupProc lookupProc,
const wchar name[],
unsigned port,
void * param
) {
ASSERT(lookupProc);
ASSERT(name);
PerfAddCounter(kAsyncPerfNameLookupAttemptsCurr, 1);
PerfAddCounter(kAsyncPerfNameLookupAttemptsTotal, 1);
// Get name/port
char ansiName[kMaxLookupName];
StrToAnsi(ansiName, name, arrsize(ansiName));
if (char * portStr = StrChr(ansiName, ':')) {
if (unsigned newPort = StrToUnsigned(portStr + 1, nil, 10))
port = newPort;
*portStr = 0;
}
// Initialize lookup
Lookup * lookup = NEW(Lookup);
lookup->lookupProc = lookupProc;
lookup->port = port;
lookup->param = param;
StrCopy(lookup->name, name, arrsize(lookup->name));
s_critsect.Enter();
{
// Start the lookup thread if it wasn't started already
StartLookupThread();
s_lookupList.Link(lookup);
// get cancel id; we can avoid checking for zero by always using an odd number
ASSERT(s_nextLookupCancelId & 1);
s_nextLookupCancelId += 2;
*cancelId = lookup->cancelId = (AsyncCancelId) s_nextLookupCancelId;
// Perform async lookup
lookup->cancelHandle = WSAAsyncGetHostByName(
s_lookupWindow,
WM_LOOKUP_FOUND_HOST,
ansiName,
&lookup->buffer[0],
sizeof(lookup->buffer)
);
if (!lookup->cancelHandle) {
PostMessage(s_lookupWindow, WM_LOOKUP_FOUND_HOST, nil, (unsigned) -1);
}
}
s_critsect.Leave();
}
//===========================================================================
void AsyncAddressLookupAddr (
AsyncCancelId * cancelId, // out
FAsyncLookupProc lookupProc,
const NetAddress & address,
void * param
) {
ASSERT(lookupProc);
PerfAddCounter(kAsyncPerfNameLookupAttemptsCurr, 1);
PerfAddCounter(kAsyncPerfNameLookupAttemptsTotal, 1);
// Initialize lookup
Lookup * lookup = NEW(Lookup);
lookup->lookupProc = lookupProc;
lookup->port = 1;
lookup->param = param;
NetAddressToString(
address,
lookup->name,
arrsize(lookup->name),
kNetAddressFormatNodeNumber
);
s_critsect.Enter();
{
// Start the lookup thread if it wasn't started already
StartLookupThread();
s_lookupList.Link(lookup);
// get cancel id; we can avoid checking for zero by always using an odd number
ASSERT(s_nextLookupCancelId & 1);
s_nextLookupCancelId += 2;
*cancelId = lookup->cancelId = (AsyncCancelId) s_nextLookupCancelId;
// Perform async lookup
u_long addr = ((const sockaddr_in *) &address)->sin_addr.S_un.S_addr;
lookup->cancelHandle = WSAAsyncGetHostByAddr(
s_lookupWindow,
WM_LOOKUP_FOUND_HOST,
(const char *) &addr,
sizeof(addr),
AF_INET,
&lookup->buffer[0],
sizeof(lookup->buffer)
);
if (!lookup->cancelHandle) {
PostMessage(s_lookupWindow, WM_LOOKUP_FOUND_HOST, nil, (unsigned) -1);
}
}
s_critsect.Leave();
}
//===========================================================================
void AsyncAddressLookupCancel (
FAsyncLookupProc lookupProc,
AsyncCancelId cancelId // nil = cancel all with specified lookupProc
) {
s_critsect.Enter();
for (Lookup * lookup = s_lookupList.Head(); lookup; lookup = s_lookupList.Next(lookup)) {
if (lookup->lookupProc && (lookup->lookupProc != lookupProc))
continue;
if (cancelId && (lookup->cancelId != cancelId))
continue;
if (!lookup->cancelHandle)
continue;
// cancel this request
WSACancelAsyncRequest(lookup->cancelHandle);
lookup->cancelHandle = nil;
// initiate user callback
PostMessage(s_lookupWindow, WM_LOOKUP_FOUND_HOST, nil, (unsigned) -1);
}
s_critsect.Leave();
}

View File

@ -0,0 +1,280 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/Win32/pnAceW32Thread.cpp
*
***/
#include "../../Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private
*
***/
struct AsyncThreadTaskList : AtomicRef {
ENetError error;
AsyncThreadTaskList ();
~AsyncThreadTaskList ();
};
struct ThreadTask {
AsyncThreadTaskList * taskList;
FAsyncThreadTask callback;
void * param;
wchar debugStr[256];
};
static HANDLE s_taskPort;
/*****************************************************************************
*
* AsyncThreadTaskList
*
***/
//===========================================================================
AsyncThreadTaskList::AsyncThreadTaskList ()
: error(kNetSuccess)
{
PerfAddCounter(kAsyncPerfThreadTaskListCount, 1);
}
//============================================================================
AsyncThreadTaskList::~AsyncThreadTaskList () {
PerfSubCounter(kAsyncPerfThreadTaskListCount, 1);
}
/*****************************************************************************
*
* Local functions
*
***/
/****************************************************************************
*
* ThreadTaskProc
*
***/
//===========================================================================
static unsigned THREADCALL ThreadTaskProc (AsyncThread * thread) {
REF(thread);
PerfAddCounter(kAsyncPerfThreadTaskThreadsActive, 1);
for (;;) {
long desired = AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsDesired);
if (AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsRunning) > desired) {
long runningCount = PerfSubCounter(kAsyncPerfThreadTaskThreadsRunning, 1) - 1;
if (runningCount >= desired) {
if (runningCount > desired)
PostQueuedCompletionStatus(s_taskPort, 0, 0, 0);
break;
}
PerfAddCounter(kAsyncPerfThreadTaskThreadsRunning, 1);
}
// Get the next work item
DWORD bytes;
ThreadTask * task;
LPOVERLAPPED op;
PerfSubCounter(kAsyncPerfThreadTaskThreadsActive, 1);
(void) GetQueuedCompletionStatus(
s_taskPort,
&bytes,
#ifdef _WIN64
(PULONG_PTR) &task,
#else
(LPDWORD) &task,
#endif
&op,
INFINITE
);
PerfAddCounter(kAsyncPerfThreadTaskThreadsActive, 1);
if (task) {
#ifdef SERVER
void * check = CrashAddDeadlockCheck(thread->handle, task->debugStr);
#endif
task->callback(task->param, task->taskList->error);
#ifdef SERVER
CrashRemoveDeadlockCheck(check);
#endif
task->taskList->DecRef("task");
DEL(task);
}
}
PerfSubCounter(kAsyncPerfThreadTaskThreadsActive, 1);
return 0;
}
//===========================================================================
static unsigned THREADCALL FirstThreadTaskProc (AsyncThread * param) {
while (AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsRunning) < AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsDesired)) {
PerfAddCounter(kAsyncPerfThreadTaskThreadsRunning, 1);
AsyncThreadCreate(ThreadTaskProc, nil, L"AsyncThreadTaskList");
}
return ThreadTaskProc(param);
}
/*****************************************************************************
*
* Module functions
*
***/
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void AsyncThreadTaskInitialize (unsigned threads) {
// Create completion port
s_taskPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, 0, 0, 0);
ASSERT(s_taskPort);
// Create threads
AsyncThreadTaskSetThreadCount(threads);
}
//============================================================================
void AsyncThreadTaskDestroy () {
ASSERT(!AsyncPerfGetCounter(kAsyncPerfThreadTaskListCount));
if (s_taskPort) {
PerfSetCounter(kAsyncPerfThreadTaskThreadsDesired, 0);
PostQueuedCompletionStatus(s_taskPort, 0, 0, 0);
// Wait until all threads have exited
while (AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsActive))
AsyncSleep(10);
while (AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsRunning))
AsyncSleep(10);
// Cleanup completion port
CloseHandle(s_taskPort);
s_taskPort = nil;
}
}
//===========================================================================
unsigned AsyncThreadTaskGetThreadCount () {
return AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsDesired);
}
//===========================================================================
void AsyncThreadTaskSetThreadCount (unsigned threads) {
ASSERT(threads >= kThreadTaskMinThreads);
ASSERT(threads <= kThreadTaskMaxThreads);
if (AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsDesired) == (long) threads)
return;
PerfSetCounter(kAsyncPerfThreadTaskThreadsDesired, (long) threads);
if (AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsRunning) < AsyncPerfGetCounter(kAsyncPerfThreadTaskThreadsDesired)) {
PerfAddCounter(kAsyncPerfThreadTaskThreadsRunning, 1);
AsyncThreadCreate(FirstThreadTaskProc, nil, L"ThreadTaskList");
}
else {
PostQueuedCompletionStatus(s_taskPort, 0, 0, 0);
}
}
//===========================================================================
AsyncThreadTaskList * AsyncThreadTaskListCreate () {
ASSERT(s_taskPort);
AsyncThreadTaskList * taskList = NEW(AsyncThreadTaskList);
taskList->IncRef("TaskList");
return taskList;
}
//===========================================================================
void AsyncThreadTaskListDestroy (
AsyncThreadTaskList * taskList,
ENetError error
) {
ASSERT(taskList);
ASSERT(error);
ASSERT(!taskList->error);
taskList->error = error;
taskList->DecRef(); // REF:TaskList
}
//===========================================================================
void AsyncThreadTaskAdd (
AsyncThreadTaskList * taskList,
FAsyncThreadTask callback,
void * param,
const wchar debugStr[],
EThreadTaskPriority priority /* = kThreadTaskPriorityNormal */
) {
ASSERT(s_taskPort);
ASSERT(taskList);
ASSERT(callback);
ASSERT(priority == kThreadTaskPriorityNormal);
REF(priority);
// Allocate a new task record
ThreadTask * task = NEW(ThreadTask);
task->taskList = taskList;
task->callback = callback;
task->param = param;
StrCopy(task->debugStr, debugStr, arrsize(task->debugStr)); // this will be sent with the deadlock checker email if this thread exceeds time set in plServer.ini
taskList->IncRef("Task");
PostQueuedCompletionStatus(s_taskPort, 0, (DWORD) task, NULL);
}

View File

@ -0,0 +1,280 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/pnAceInt.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_PNACEINT_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/Private/pnAceInt.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCOREEXE_PRIVATE_PNACEINT_H
/*****************************************************************************
*
* Core.cpp
*
***/
// Performance counter functions
long PerfAddCounter (unsigned id, unsigned n);
long PerfSubCounter (unsigned id, unsigned n);
long PerfSetCounter (unsigned id, unsigned n);
/*****************************************************************************
*
* Dns.cpp
*
***/
void DnsDestroy (unsigned exitThreadWaitMs);
/*****************************************************************************
*
* Thread.cpp
*
***/
void ThreadDestroy (unsigned exitThreadWaitMs);
/*****************************************************************************
*
* Timer.cpp
*
***/
void TimerDestroy (unsigned exitThreadWaitMs);
/****************************************************************************
*
* Async API function types
*
***/
// Core
typedef void (* FInitialize) ();
typedef void (* FDestroy) (unsigned exitThreadWaitMs);
typedef void (* FSignalShutdown) ();
typedef void (* FWaitForShutdown) ();
typedef void (* FSleep) (unsigned sleepMs);
// Files
typedef AsyncFile (* FAsyncFileOpen) (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
);
typedef void (* FAsyncFileClose) (
AsyncFile file,
qword truncateSize
);
typedef void (* FAsyncFileSetLastWriteTime) (
AsyncFile file,
qword lastWriteTime
);
typedef qword (* FAsyncFileGetLastWriteTime) (
const wchar fileName[]
);
typedef AsyncId (* FAsyncFileFlushBuffers) (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
);
typedef AsyncId (* FAsyncFileRead) (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
typedef AsyncId (* FAsyncFileWrite) (
AsyncFile file,
qword offset,
const void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
typedef AsyncId (* FAsyncFileCreateSequence) (
AsyncFile file,
bool notify,
void * param
);
typedef bool (* FAsyncFileSeek) (
AsyncFile file,
qword distance,
EFileSeekFrom from
);
typedef bool (* FAsyncFileWaitId) (
AsyncFile file,
AsyncId asyncId,
unsigned timeoutMs
);
// Sockets
typedef void (* FAsyncSocketConnect) (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
unsigned sendBytes,
unsigned connectMs,
unsigned localPort
);
typedef void (* FAsyncSocketConnectCancel) (
FAsyncNotifySocketProc notifyProc,
AsyncCancelId cancelId
);
typedef void (* FAsyncSocketDisconnect) (
AsyncSocket sock,
bool hardClose
);
typedef void (* FAsyncSocketDelete) (AsyncSocket sock);
typedef bool (* FAsyncSocketSend) (
AsyncSocket sock,
const void * data,
unsigned bytes
);
typedef bool (* FAsyncSocketWrite) (
AsyncSocket sock,
const void * buffer,
unsigned bytes,
void * param
);
typedef void (* FAsyncSocketSetNotifyProc) (
AsyncSocket sock,
FAsyncNotifySocketProc notifyProc
);
typedef void (* FAsyncSocketSetBacklogAlloc) (
AsyncSocket sock,
unsigned bufferSize
);
typedef unsigned (* FAsyncSocketStartListening) (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
);
typedef void (* FAsyncSocketStopListening) (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
);
typedef void (* FAsyncSocketEnableNagling) (
AsyncSocket conn,
bool enable
);
/****************************************************************************
*
* I/O API
*
***/
struct AsyncApi {
// Init
FInitialize initialize;
FDestroy destroy;
FSignalShutdown signalShutdown;
FWaitForShutdown waitForShutdown;
FSleep sleep;
// Files
FAsyncFileOpen fileOpen;
FAsyncFileClose fileClose;
FAsyncFileRead fileRead;
FAsyncFileWrite fileWrite;
FAsyncFileFlushBuffers fileFlushBuffers;
FAsyncFileSetLastWriteTime fileSetLastWriteTime;
FAsyncFileGetLastWriteTime fileGetLastWriteTime;
FAsyncFileCreateSequence fileCreateSequence;
FAsyncFileSeek fileSeek;
// Sockets
FAsyncSocketConnect socketConnect;
FAsyncSocketConnectCancel socketConnectCancel;
FAsyncSocketDisconnect socketDisconnect;
FAsyncSocketDelete socketDelete;
FAsyncSocketSend socketSend;
FAsyncSocketWrite socketWrite;
FAsyncSocketSetNotifyProc socketSetNotifyProc;
FAsyncSocketSetBacklogAlloc socketSetBacklogAlloc;
FAsyncSocketStartListening socketStartListening;
FAsyncSocketStopListening socketStopListening;
FAsyncSocketEnableNagling socketEnableNagling;
};
extern AsyncApi g_api;

View File

@ -0,0 +1,246 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceCore.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private data
*
***/
static long s_perf[kNumAsyncPerfCounters];
/****************************************************************************
*
* Module data exports
*
***/
AsyncApi g_api;
bool s_transgaming;
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static void DoTransgamingCheck () {
#ifdef HS_BUILD_FOR_WIN32
#ifdef CLIENT
HMODULE hMod = GetModuleHandle("ntdll");
if (!hMod)
return;
s_transgaming = GetProcAddress(hMod, "IsTransgaming") != nil;
#endif
#endif
}
//===========================================================================
static void IAsyncInitUseW9x () {
REF(IAsyncInitUseW9x);
#ifdef HS_BUILD_FOR_WIN32
W9xGetApi(&g_api);
#else
ErrorFatal("W9x I/O Not supported on this platform");
#endif
}
//===========================================================================
static void IAsyncInitUseNt () {
REF(IAsyncInitUseNt);
#ifdef HS_BUILD_FOR_WIN32
NtGetApi(&g_api);
#else
ErrorFatal("Nt I/O Not supported on this platform");
#endif
}
//===========================================================================
static void IAsyncInitUseUnix () {
REF(IAsyncInitUseUnix);
#ifdef HS_BUILD_FOR_UNIX
#error Unix I/O not implemented yet
UxGetApi(&g_api);
#else
ErrorFatal(__LINE__, __FILE__, "Unix I/O Not supported on this platform");
#endif
}
//===========================================================================
static void IAsyncInitForClient () {
REF(IAsyncInitForClient);
#ifdef HS_BUILD_FOR_WIN32
DoTransgamingCheck();
if (s_transgaming) {
IAsyncInitUseW9x();
}
else {
IAsyncInitUseNt();
}
#elif HS_BUILD_FOR_UNIX
IAsyncInitUseUnix();
#else
ErrorFatal("AsyncCore: No default implementation for this platform");
#endif
}
//===========================================================================
static void IAsyncInitForServer () {
REF(IAsyncInitForServer);
#ifdef HS_BUILD_FOR_WIN32
IAsyncInitUseNt();
#elif HS_BUILD_FOR_UNIX
IAsyncInitUseUnix();
#else
ErrorFatal("AsyncCore: No default implementation for this platform");
#endif
}
/*****************************************************************************
*
* Module exports
*
***/
//============================================================================
long PerfAddCounter (unsigned id, unsigned n) {
ASSERT(id < kNumAsyncPerfCounters);
return AtomicAdd(&s_perf[id], n);
}
//============================================================================
long PerfSubCounter (unsigned id, unsigned n) {
ASSERT(id < kNumAsyncPerfCounters);
return AtomicAdd(&s_perf[id], -(signed)n);
}
//============================================================================
long PerfSetCounter (unsigned id, unsigned n) {
ASSERT(id < kNumAsyncPerfCounters);
return AtomicSet(&s_perf[id], n);
}
/*****************************************************************************
*
* Public exports
*
***/
//===========================================================================
void AsyncCoreInitialize () {
ASSERTMSG(!g_api.initialize, "AsyncCore already initialized");
#ifdef HS_BUILD_FOR_WIN32
// Initialize WinSock
WSADATA wsaData;
if (WSAStartup(0x101, &wsaData))
ErrorFatal(__LINE__, __FILE__, "WSA startup failed");
if (wsaData.wVersion != 0x101)
ErrorFatal(__LINE__, __FILE__, "WSA version failed");
#endif
#ifdef CLIENT
IAsyncInitForClient();
#elif SERVER
IAsyncInitForServer();
#else
# error "Neither CLIENT nor SERVER defined. Cannot configure AsyncCore for target"
#endif
ASSERT(g_api.initialize);
g_api.initialize();
}
//============================================================================
void AsyncCoreDestroy (unsigned waitMs) {
if (g_api.destroy) {
g_api.destroy(waitMs);
}
DnsDestroy(waitMs);
TimerDestroy(waitMs);
ThreadDestroy(waitMs);
ZERO(g_api);
}
//============================================================================
void AsyncSignalShutdown () {
ASSERT(g_api.signalShutdown);
g_api.signalShutdown();
}
//============================================================================
void AsyncWaitForShutdown () {
ASSERT(g_api.waitForShutdown);
g_api.waitForShutdown();
}
//============================================================================
void AsyncSleep (unsigned sleepMs) {
ASSERT(g_api.sleep);
g_api.sleep(sleepMs);
}
//============================================================================
long AsyncPerfGetCounter (unsigned id) {
COMPILER_ASSERT(arrsize(s_perf) == kNumAsyncPerfCounters);
ASSERT(id < kNumAsyncPerfCounters);
return s_perf[id];
}

View File

@ -0,0 +1,606 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceIo.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/****************************************************************************
*
* ISocketConnHash
*
***/
// socket notification procedures
// connection data format:
// byte connType;
// dword buildId; [optional]
// dword branchId; [optional]
// dword buildType; [optional]
// Uuid productId; [optional]
const unsigned kConnHashFlagsIgnore = 0x01;
const unsigned kConnHashFlagsExactMatch = 0x02;
struct ISocketConnHash {
unsigned connType;
unsigned buildId;
unsigned buildType;
unsigned branchId;
Uuid productId;
unsigned flags;
unsigned GetHash () const;
bool operator== (const ISocketConnHash & rhs) const;
};
struct ISocketConnType : ISocketConnHash {
HASHLINK(ISocketConnType) hashlink;
FAsyncNotifySocketProc notifyProc;
};
static CLock s_notifyProcLock;
static HASHTABLEDECL(
ISocketConnType,
ISocketConnHash,
hashlink
) s_notifyProcs;
//===========================================================================
unsigned ISocketConnHash::GetHash () const {
CHashValue hash;
hash.Hash32(connType);
/*
if (buildId)
hash.Hash32(buildId);
if (buildType)
hash.Hash32(buildType);
if (branchId)
hash.Hash32(branchId);
if (productId != kNilGuid)
hash.Hash(&productId, sizeof(productId));
*/
return hash.GetHash();
}
//===========================================================================
bool ISocketConnHash::operator== (const ISocketConnHash & rhs) const {
ASSERT(flags & kConnHashFlagsIgnore);
for (;;) {
// Check connType
if (connType != rhs.connType)
break;
// Check buildId
if (buildId != rhs.buildId) {
if (rhs.flags & kConnHashFlagsExactMatch)
break;
if (buildId)
break;
}
// Check buildType
if (buildType != rhs.buildType) {
if (rhs.flags & kConnHashFlagsExactMatch)
break;
if (buildType)
break;
}
// Check branchId
if (branchId != rhs.branchId) {
if (rhs.flags & kConnHashFlagsExactMatch)
break;
if (branchId)
break;
}
// Check productId
if (productId != rhs.productId) {
if (rhs.flags & kConnHashFlagsExactMatch)
break;
if (productId != kNilGuid)
break;
}
// Success!
return true;
}
// Failed!
return false;
}
//===========================================================================
static unsigned GetConnHash (
ISocketConnHash * hash,
const byte buffer[],
unsigned bytes
) {
if (!bytes)
return 0;
if (IS_TEXT_CONNTYPE(buffer[0])) {
hash->connType = buffer[0];
hash->buildId = 0;
hash->buildType = 0;
hash->branchId = 0;
hash->productId = 0;
hash->flags = 0;
// one byte consumed
return 1;
}
else {
if (bytes < sizeof(AsyncSocketConnectPacket))
return 0;
const AsyncSocketConnectPacket & connect = * (const AsyncSocketConnectPacket *) buffer;
if (connect.hdrBytes < sizeof(connect))
return 0;
hash->connType = connect.connType;
hash->buildId = connect.buildId;
hash->buildType = connect.buildType;
hash->branchId = connect.branchId;
hash->productId = connect.productId;
hash->flags = 0;
return connect.hdrBytes;
}
}
/****************************************************************************
*
* Public exports
*
***/
//===========================================================================
EFileError AsyncGetLastFileError () {
const unsigned error = GetLastError();
switch (error) {
case NO_ERROR:
return kFileSuccess;
case ERROR_FILE_NOT_FOUND:
return kFileErrorFileNotFound;
case ERROR_ACCESS_DENIED:
case ERROR_FILE_EXISTS:
case ERROR_ALREADY_EXISTS:
return kFileErrorAccessDenied;
case ERROR_SHARING_VIOLATION:
return kFileErrorSharingViolation;
case ERROR_BAD_NETPATH:
case ERROR_PATH_NOT_FOUND:
case ERROR_INVALID_NAME:
case ERROR_BAD_NET_NAME:
case ERROR_CANT_ACCESS_DOMAIN_INFO:
case ERROR_NETWORK_UNREACHABLE:
case ERROR_HOST_UNREACHABLE:
return kFileErrorPathNotFound;
}
LogMsg(kLogPerf, "Unexpected Win32 error [%#x]", error);
return kFileErrorPathNotFound;
}
//============================================================================
const wchar * FileErrorToString (EFileError error) {
static wchar * s_fileErrorStrings[] = {
L"FileSuccess",
L"FileErrorInvalidParameter",
L"FileErrorFileNotFound",
L"FileErrorPathNotFound",
L"FileErrorAccessDenied",
L"FileErrorSharingViolation",
};
COMPILER_ASSERT(kNumFileErrors == arrsize(s_fileErrorStrings));
return s_fileErrorStrings[error];
}
//============================================================================
AsyncFile AsyncFileOpen (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags,
void * userState,
qword * fileSize,
qword * fileLastWriteTime
) {
ASSERT(g_api.fileOpen);
return g_api.fileOpen(
fullPath,
notifyProc,
error,
desiredAccess,
openMode,
shareModeFlags,
userState,
fileSize,
fileLastWriteTime
);
}
//============================================================================
void AsyncFileClose (
AsyncFile file,
qword truncateSize
) {
ASSERT(g_api.fileClose);
g_api.fileClose(file, truncateSize);
}
//============================================================================
void AsyncFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
) {
ASSERT(g_api.fileSetLastWriteTime);
g_api.fileSetLastWriteTime(file, lastWriteTime);
}
//============================================================================
qword AsyncFileGetLastWriteTime (
const wchar fileName[]
) {
ASSERT(g_api.fileGetLastWriteTime);
return g_api.fileGetLastWriteTime(fileName);
}
//============================================================================
AsyncId AsyncFileFlushBuffers (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
) {
ASSERT(g_api.fileFlushBuffers);
return g_api.fileFlushBuffers(file, truncateSize, notify, param);
}
//============================================================================
AsyncId AsyncFileRead (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
) {
ASSERT(g_api.fileRead);
return g_api.fileRead(
file,
offset,
buffer,
bytes,
flags,
param
);
}
//============================================================================
AsyncId AsyncFileWrite (
AsyncFile file,
qword offset,
const void * buffer,
unsigned bytes,
unsigned flags,
void * param
) {
ASSERT(g_api.fileWrite);
return g_api.fileWrite(
file,
offset,
buffer,
bytes,
flags,
param
);
}
//============================================================================
AsyncId AsyncFileCreateSequence (
AsyncFile file,
bool notify,
void * param
) {
ASSERT(g_api.fileCreateSequence);
return g_api.fileCreateSequence(file, notify, param);
}
//============================================================================
bool AsyncFileSeek (
AsyncFile file,
qword distance,
EFileSeekFrom seekFrom
) {
ASSERT(g_api.fileSeek);
return g_api.fileSeek(file, distance, seekFrom);
}
//===========================================================================
void AsyncSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
FAsyncNotifySocketProc notifyProc,
void * param,
const void * sendData,
unsigned sendBytes,
unsigned connectMs,
unsigned localPort
) {
ASSERT(g_api.socketConnect);
g_api.socketConnect(
cancelId,
netAddr,
notifyProc,
param,
sendData,
sendBytes,
connectMs,
localPort
);
}
//===========================================================================
void AsyncSocketConnectCancel (
FAsyncNotifySocketProc notifyProc,
AsyncCancelId cancelId
) {
ASSERT(g_api.socketConnectCancel);
g_api.socketConnectCancel(notifyProc, cancelId);
}
//===========================================================================
void AsyncSocketDisconnect (
AsyncSocket sock,
bool hardClose
) {
ASSERT(g_api.socketDisconnect);
g_api.socketDisconnect(sock, hardClose);
}
//===========================================================================
void AsyncSocketDelete (AsyncSocket sock) {
ASSERT(g_api.socketDelete);
g_api.socketDelete(sock);
}
//===========================================================================
bool AsyncSocketSend (
AsyncSocket sock,
const void * data,
unsigned bytes
) {
ASSERT(g_api.socketSend);
return g_api.socketSend(sock, data, bytes);
}
//===========================================================================
bool AsyncSocketWrite (
AsyncSocket sock,
const void * buffer,
unsigned bytes,
void * param
) {
ASSERT(g_api.socketWrite);
return g_api.socketWrite(sock, buffer, bytes, param);
}
//===========================================================================
void AsyncSocketSetNotifyProc (
AsyncSocket sock,
FAsyncNotifySocketProc notifyProc
) {
ASSERT(g_api.socketSetNotifyProc);
g_api.socketSetNotifyProc(sock, notifyProc);
}
//===========================================================================
void AsyncSocketSetBacklogAlloc (
AsyncSocket sock,
unsigned bufferSize
) {
ASSERT(g_api.socketSetBacklogAlloc);
g_api.socketSetBacklogAlloc(sock, bufferSize);
}
//===========================================================================
unsigned AsyncSocketStartListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
) {
ASSERT(g_api.socketStartListening);
return g_api.socketStartListening(listenAddr, notifyProc);
}
//===========================================================================
void AsyncSocketStopListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc
) {
ASSERT(g_api.socketStopListening);
g_api.socketStopListening(listenAddr, notifyProc);
}
//============================================================================
void AsyncSocketEnableNagling (
AsyncSocket sock,
bool enable
) {
ASSERT(g_api.socketEnableNagling);
g_api.socketEnableNagling(sock, enable);
}
//===========================================================================
void AsyncSocketRegisterNotifyProc (
byte connType,
FAsyncNotifySocketProc notifyProc,
unsigned buildId,
unsigned buildType,
unsigned branchId,
const Uuid & productId
) {
ASSERT(connType != kConnTypeNil);
ASSERT(notifyProc);
// Perform memory allocation outside lock
ISocketConnType * ct = NEW(ISocketConnType);
ct->notifyProc = notifyProc;
ct->connType = connType;
ct->buildId = buildId;
ct->buildType = buildType;
ct->branchId = branchId;
ct->productId = productId;
ct->flags = kConnHashFlagsIgnore;
s_notifyProcLock.EnterWrite();
{
s_notifyProcs.Add(ct);
}
s_notifyProcLock.LeaveWrite();
}
//===========================================================================
void AsyncSocketUnregisterNotifyProc (
byte connType,
FAsyncNotifySocketProc notifyProc,
unsigned buildId,
unsigned buildType,
unsigned branchId,
const Uuid & productId
) {
ISocketConnHash hash;
hash.connType = connType;
hash.buildId = buildId;
hash.buildType = buildType;
hash.branchId = branchId;
hash.productId = productId;
hash.flags = kConnHashFlagsExactMatch;
ISocketConnType * scan;
s_notifyProcLock.EnterWrite();
{
scan = s_notifyProcs.Find(hash);
for (; scan; scan = s_notifyProcs.FindNext(hash, scan)) {
if (scan->notifyProc != notifyProc)
continue;
// Unlink the object so it can be deleted outside the lock
s_notifyProcs.Unlink(scan);
break;
}
}
s_notifyProcLock.LeaveWrite();
// perform memory deallocation outside the lock
DEL(scan);
}
//===========================================================================
FAsyncNotifySocketProc AsyncSocketFindNotifyProc (
const byte buffer[],
unsigned bytes,
unsigned * bytesProcessed,
unsigned * connType,
unsigned * buildId,
unsigned * buildType,
unsigned * branchId,
Uuid * productId
) {
for (;;) {
// Get the connType
ISocketConnHash hash;
*bytesProcessed = GetConnHash(&hash, buffer, bytes);
if (!*bytesProcessed)
break;
// Lookup notifyProc based on connType
FAsyncNotifySocketProc proc;
s_notifyProcLock.EnterRead();
if (const ISocketConnType * scan = s_notifyProcs.Find(hash))
proc = scan->notifyProc;
else
proc = nil;
s_notifyProcLock.LeaveRead();
if (!proc)
break;
// Success!
*connType = hash.connType;
*buildId = hash.buildId;
*buildType = hash.buildType;
*branchId = hash.branchId;
*productId = hash.productId;
return proc;
}
// Failure!
PerfAddCounter(kAsyncPerfSocketDisconnectInvalidConnType, 1);
*bytesProcessed = 0;
*connType = 0;
*buildId = 0;
*buildType = 0;
*branchId = 0;
*productId = 0;
return nil;
}

View File

@ -0,0 +1,494 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceLog.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
#if defined(PLASMA_EXTERNAL_RELEASE) && (BUILD_TYPE == BUILD_TYPE_LIVE)
// If this is an external live build then don't write log files
#define ACELOG_NO_LOG_FILES
#endif
namespace AsyncLog {
/****************************************************************************
*
* Private
*
***/
static const unsigned kLogFlushMs = 10 * 1000;
enum ELogType {
#ifdef SERVER
kLogTypeDebug,
kLogTypePerf,
kLogTypeError,
#else
kLogTypeDebug,
#endif
kNumLogTypes
};
static bool s_breakOnErrors;
static wchar s_directory[MAX_PATH];
static CCritSect s_logCrit[kNumLogTypes];
static char * s_logBuf[kNumLogTypes];
static unsigned s_logPos[kNumLogTypes];
static qword s_logWritePos[kNumLogTypes];
static TimeDesc s_logTime[kNumLogTypes];
static unsigned s_logWriteMs[kNumLogTypes];
static AsyncFile s_logFile[kNumLogTypes];
static long s_opsPending;
static bool s_running;
static AsyncTimer * s_timer;
static unsigned s_logSize[kNumLogTypes] = {
#ifdef SERVER
64 * 1024,
64 * 1024,
8 * 1024,
#else
64 * 1024,
#endif
};
static const wchar * s_logNameFmt[kNumLogTypes] = {
#ifdef SERVER
L"Dbg%02u%02u%02u.%s.log",
L"Inf%02u%02u%02u.%s.log",
L"Err%02u%02u%02u.%s.log",
#else
L"%s%02u%02u%02u.%s.log",
#endif
};
static ELogType s_logSeverityToType[kNumLogSeverity] = {
#ifdef SERVER
kLogTypeDebug, // kLogDebug
kLogTypePerf, // kLogPerf
kLogTypeError, // kLogError
kLogTypeError, // kLogFatal
#else
kLogTypeDebug, // kLogDebug
kLogTypeDebug, // kLogPerf
kLogTypeDebug, // kLogError
kLogTypeDebug, // kLogFatal
#endif
};
static char * s_logSeverityToText[kNumLogSeverity] = {
"Debug",
"Info",
"Error",
"Fatal",
};
/****************************************************************************
*
* Local functions
*
***/
//============================================================================
static void LogFileNotifyProc (
AsyncFile file,
EAsyncNotifyFile code,
AsyncNotifyFile * notify,
void ** userState
) {
REF(file);
REF(userState);
switch (code) {
case kNotifyFileWrite:
FREE(notify->param);
AtomicAdd(&s_opsPending, -1);
break;
case kNotifyFileFlush:
AsyncFileClose(file, kAsyncFileDontTruncate);
AtomicAdd(&s_opsPending, -1);
break;
DEFAULT_FATAL(code);
}
}
//============================================================================
static void AllocLogBuffer_CS (unsigned index) {
REF(AllocLogBuffer_CS);
ASSERT(!s_logBuf[index]);
s_logBuf[index] = (char *)ALLOC(s_logSize[index]);
s_logPos[index] = 0;
if (!s_logBuf[index])
ErrorAssert(__LINE__, __FILE__, "Out of memory");
}
//============================================================================
static void FreeLogBuffer_CS (unsigned index) {
REF(FreeLogBuffer_CS);
if (s_logBuf[index]) {
FREE(s_logBuf[index]);
s_logBuf[index] = nil;
}
}
//============================================================================
static void GetLogFilename (
unsigned index,
TimeDesc timeDesc,
wchar * filename,
unsigned chars
) {
StrPrintf(
filename,
chars,
s_logNameFmt[index],
#ifndef SERVER
ProductShortName(),
#endif
timeDesc.year % 100,
timeDesc.month,
timeDesc.day,
BuildTypeString()
);
PathAddFilename(filename, s_directory, filename, chars);
}
//============================================================================
static bool OpenLogFile_CS (unsigned index) {
if (s_logFile[index] != nil)
return true;
// Build filename
wchar filename[MAX_PATH];
GetLogFilename(
index,
s_logTime[index],
filename,
arrsize(filename)
);
// Open file
qword fileTime;
EFileError fileError;
bool fileExist = PathDoesFileExist(filename);
s_logFile[index] = AsyncFileOpen(
filename,
LogFileNotifyProc,
&fileError,
kAsyncFileWriteAccess,
kAsyncFileModeOpenAlways,
kAsyncFileShareRead,
nil, // userState
&s_logWritePos[index],
&fileTime
);
if (s_logFile[index] == nil)
return false;
TimeGetDesc(fileTime, &s_logTime[index]);
s_logWriteMs[index] = TimeGetMs();
// Seek to end of file
AsyncFileSeek(s_logFile[index], s_logWritePos[index], kFileSeekFromBegin);
// If this is a new file, write Byte Order Mark
if (!fileExist) {
static const char s_bom[] = "\xEF\xBB\xBF";
AsyncFileWrite(
s_logFile[index],
s_logWritePos[index],
s_bom,
arrsize(s_bom)- 1,
kAsyncFileRwSync, // perform blocking write
nil // param
);
s_logWritePos[index] += arrsize(s_bom) - 1;
}
// Write a sentinel in case there are multiple runs in one day
static const char s_logOpened[] = "Log Opened\r\n";
AsyncFileWrite(
s_logFile[index],
s_logWritePos[index],
s_logOpened,
arrsize(s_logOpened)- 1,
kAsyncFileRwSync, // perform blocking write
nil
);
s_logWritePos[index] += arrsize(s_logOpened) - 1;
return true;
}
//============================================================================
static void WriteLogFile_CS (unsigned index, bool close) {
unsigned flags = kAsyncFileRwSync; // kAsyncFileRwNotify
if (s_logPos[index]) {
if (OpenLogFile_CS(index)) {
AsyncFileWrite(
s_logFile[index],
s_logWritePos[index],
s_logBuf[index],
s_logPos[index],
flags,
s_logBuf[index]
);
if (flags == kAsyncFileRwSync)
DEL(s_logBuf[index]);
else
AtomicAdd(&s_opsPending, 1);
s_logWritePos[index] += s_logPos[index];
s_logWriteMs[index] = TimeGetMs();
s_logBuf[index] = nil;
s_logPos[index] = 0;
}
}
if (close && s_logFile[index]) {
if (flags == kAsyncFileRwNotify) {
AtomicAdd(&s_opsPending, 1);
AsyncFileFlushBuffers(
s_logFile[index],
kAsyncFileDontTruncate,
true,
nil
);
}
else {
AsyncFileClose(
s_logFile[index],
kAsyncFileDontTruncate
);
}
s_logFile[index] = nil;
}
}
//============================================================================
static void FlushLogFile_CS (
unsigned index,
TimeDesc timeDesc
) {
REF(FlushLogFile_CS);
bool close = !s_running || (s_logTime[index].day != timeDesc.day);
WriteLogFile_CS(index, close);
if (close)
s_logTime[index] = timeDesc;
}
//============================================================================
static unsigned FlushLogsTimerCallback (void *) {
REF(FlushLogsTimerCallback);
AsyncLogFlush();
return kAsyncTimeInfinite;
}
} using namespace AsyncLog;
/****************************************************************************
*
* Exported functions
*
***/
//============================================================================
void AsyncLogInitialize (
const wchar logDirName[],
bool breakOnErrors
) {
s_running = true;
// Save options
s_breakOnErrors = breakOnErrors;
// Build log directory name
#ifdef SERVER
PathGetProgramDirectory(s_directory, arrsize(s_directory));
#else
PathGetUserDirectory(s_directory, arrsize(s_directory));
#endif
PathAddFilename(s_directory, s_directory, logDirName, arrsize(s_directory));
#ifndef ACELOG_NO_LOG_FILES
// Create log directory
if (kPathCreateDirSuccess != PathCreateDirectory(s_directory, 0))
PathRemoveFilename(s_directory, s_directory, arrsize(s_directory));
// Allocate log buffers
for (unsigned index = 0; index < kNumLogTypes; ++index) {
s_logCrit[index].Enter();
AllocLogBuffer_CS(index);
s_logCrit[index].Leave();
}
AsyncTimerCreate(&s_timer, FlushLogsTimerCallback, kAsyncTimeInfinite, nil);
#endif // ndef ACELOG_NO_LOG_FILES
}
//============================================================================
void AsyncLogDestroy () {
s_running = false;
#ifndef ACELOG_NO_LOG_FILES
AsyncTimerDelete(s_timer, kAsyncTimerDestroyWaitComplete);
for (unsigned index = 0; index < kNumLogTypes; ++index) {
s_logCrit[index].Enter();
{
WriteLogFile_CS(index, true);
FreeLogBuffer_CS(index);
}
s_logCrit[index].Leave();
}
while (s_opsPending)
AsyncSleep(10);
#endif // ndef ACELOG_NO_LOG_FILES
}
//============================================================================
void AsyncLogFlush () {
#ifndef ACELOG_NO_LOG_FILES
TimeDesc timeDesc;
TimeGetDesc(TimeGetTime(), &timeDesc);
for (unsigned index = 0; index < kNumLogTypes; ++index) {
s_logCrit[index].Enter();
FlushLogFile_CS(index, timeDesc);
s_logCrit[index].Leave();
}
#endif // ndef ACELOG_NO_LOG_FILES
}
//============================================================================
void LogBreakOnErrors (bool breakOnErrors) {
s_breakOnErrors = breakOnErrors;
}
//============================================================================
void AsyncLogWriteMsg (
const wchar facility[],
ELogSeverity severity,
const wchar msg[]
) {
REF(facility);
REF(severity);
REF(msg);
if (!s_running)
return;
#ifndef ACELOG_NO_LOG_FILES
TimeDesc timeDesc;
TimeGetDesc(TimeGetTime(), &timeDesc);
char buffer[2048];
const unsigned chars = StrPrintf(
buffer,
arrsize(buffer),
"%02u/%02u/%02u % 2u:%02u:%02u [%S] %s %S\r\n",
timeDesc.month,
timeDesc.day,
timeDesc.year % 100,
timeDesc.hour,
timeDesc.minute,
timeDesc.second,
facility,
s_logSeverityToText[severity],
msg
);
unsigned index = s_logSeverityToType[severity];
s_logCrit[index].Enter();
{
// If day changed then write and flush file
if (s_logTime[index].day != timeDesc.day)
FlushLogFile_CS(index, timeDesc);
// Otherwise if the buffer is full then write to file
else if (s_logPos[index] + chars > s_logSize[index])
WriteLogFile_CS(index, false);
// Allocate log buffer if necessary
if (!s_logBuf[index])
AllocLogBuffer_CS(index);
// Add new data to the log buffer
MemCopy(s_logBuf[index] + s_logPos[index], buffer, chars);
s_logPos[index] += chars;
// Write, flush and close file immediately if this is a fatal error
if (severity == kLogFatal)
WriteLogFile_CS(index, true);
// Drop to debugger if this is an error msg and that option was specified
if (s_breakOnErrors && severity >= kLogError)
DebugBreakIfDebuggerPresent();
}
s_logCrit[index].Leave();
// Queue flush
AsyncTimerUpdate(s_timer, kLogFlushMs, kAsyncTimerUpdateSetPriorityHigher);
#endif // ndef ACELOG_NO_LOG_FILES
}
//============================================================================
void AsyncLogGetDirectory (wchar * dest, unsigned destChars) {
ASSERT(dest);
StrCopy(dest, s_directory, destChars);
}

View File

@ -0,0 +1,136 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceThread.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private data
*
***/
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static unsigned CALLBACK CreateThreadProc (LPVOID param) {
PerfAddCounter(kAsyncPerfThreadsTotal, 1);
PerfAddCounter(kAsyncPerfThreadsCurr, 1);
// Initialize thread
AsyncThread * thread = (AsyncThread *) param;
// Call thread procedure
unsigned result = thread->proc(thread);
// Cleanup thread
DEL(thread);
PerfSubCounter(kAsyncPerfThreadsCurr, 1);
return result;
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void ThreadDestroy (unsigned exitThreadWaitMs) {
unsigned bailAt = TimeGetMs() + exitThreadWaitMs;
while (AsyncPerfGetCounter(kAsyncPerfThreadsCurr) && signed(bailAt - TimeGetMs()) > 0)
AsyncSleep(10);
}
/*****************************************************************************
*
* Public exports
*
***/
//===========================================================================
void * AsyncThreadCreate (
FAsyncThreadProc threadProc,
void * argument,
const wchar name[]
) {
AsyncThread * thread = NEW(AsyncThread);
thread->proc = threadProc;
thread->handle = nil;
thread->argument = argument;
thread->workTimeMs = kAsyncTimeInfinite;
StrCopy(thread->name, name, arrsize(thread->name));
// Create thread suspended
unsigned threadId;
HANDLE handle = (HANDLE) _beginthreadex(
(LPSECURITY_ATTRIBUTES) 0,
0, // stack size
CreateThreadProc,
thread, // argument
0, // initFlag
&threadId
);
if (!handle) {
LogMsg(kLogFatal, "%s (%u)", __FILE__, GetLastError());
ErrorFatal(__LINE__, __FILE__, "_beginthreadex failed");
}
thread->handle = handle;
return handle;
}

View File

@ -0,0 +1,368 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCoreExe/pnAceTimer.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/****************************************************************************
*
* Private
*
***/
// timer callbacks
struct AsyncTimer {
PRIORITY_TIME(AsyncTimer) priority;
FAsyncTimerProc timerProc;
FAsyncTimerProc destroyProc;
void * param;
LINK(AsyncTimer) deleteLink;
};
static CCritSect s_timerCrit;
static FAsyncTimerProc s_timerCurr;
static HANDLE s_timerThread;
static HANDLE s_timerEvent;
static bool s_running;
static PRIQDECL(
AsyncTimer,
PRIORITY_TIME(AsyncTimer),
priority
) s_timerProcs;
static LISTDECL(
AsyncTimer,
deleteLink
) s_timerDelete;
/****************************************************************************
*
* Timer implementation
*
***/
//===========================================================================
static void UpdateTimer (
AsyncTimer * timer,
unsigned timeMs,
unsigned flags
) {
// If the timer isn't already linked then it doesn't
// matter whether kAsyncTimerUpdateSetPriorityHigher is
// set; just add the timer to the queue
if (!timer->priority.IsLinked()) {
timer->priority.Set(timeMs);
s_timerProcs.Enqueue(timer);
}
else if (((flags & kAsyncTimerUpdateSetPriorityHigher) == 0)
|| !timer->priority.IsPriorityHigher(timeMs)
) {
timer->priority.Set(timeMs);
}
}
//===========================================================================
static unsigned CallTimerProc (AsyncTimer * t, FAsyncTimerProc timerProc) {
// Cache parameters to make timer callback outside critical section
s_timerCurr = timerProc;
// Leave critical section to make timer callback
s_timerCrit.Leave();
unsigned sleepMs = s_timerCurr(t->param);
s_timerCurr = nil;
s_timerCrit.Enter();
return sleepMs;
}
//===========================================================================
// inline because it is called only once
static inline unsigned RunTimers () {
unsigned currTimeMs = TimeGetMs();
for (;;) {
// Delete old timers
while (AsyncTimer * t = s_timerDelete.Head()) {
if (t->destroyProc)
CallTimerProc(t, t->destroyProc);
DEL(t);
}
// Get first timer to run
AsyncTimer * t = s_timerProcs.Root();
if (!t)
return INFINITE;
// If it isn't time to run this timer then exit
unsigned sleepMs;
if (0 < (signed) (sleepMs = (unsigned) t->priority.Get() - currTimeMs))
return sleepMs;
// Remove from timer queue and call timer
s_timerProcs.Dequeue();
sleepMs = CallTimerProc(t, t->timerProc);
// Note if return is kAsyncTimeInfinite, we do not remove the timer
// from the queue. Some users depend on the fact that they can
// call AsyncTimerUpdate and not get overridden by a return from the
// handler at the same time.
// Requeue timer
currTimeMs = TimeGetMs();
if (sleepMs != kAsyncTimeInfinite)
UpdateTimer(t, sleepMs + currTimeMs, kAsyncTimerUpdateSetPriorityHigher);
}
}
//===========================================================================
static unsigned THREADCALL TimerThreadProc (AsyncThread *) {
do {
s_timerCrit.Enter();
const unsigned sleepMs = RunTimers();
s_timerCrit.Leave();
WaitForSingleObject(s_timerEvent, sleepMs);
} while (s_running);
return 0;
}
//===========================================================================
// inline because it is called only once
static inline void InitializeTimer () {
if (!s_timerThread) {
s_running = true;
s_timerEvent = CreateEvent(
(LPSECURITY_ATTRIBUTES) nil,
false, // auto-reset event
false, // initial state = off
(LPCTSTR) nil
);
if (!s_timerEvent)
ErrorFatal(__LINE__, __FILE__, "CreateEvent %u", GetLastError());
s_timerThread = (HANDLE) AsyncThreadCreate(
TimerThreadProc,
nil,
L"AsyncTimerThread"
);
}
}
/****************************************************************************
*
* Module functions
*
***/
//===========================================================================
void TimerDestroy (unsigned exitThreadWaitMs) {
s_running = false;
if (s_timerThread) {
SetEvent(s_timerEvent);
WaitForSingleObject(s_timerThread, exitThreadWaitMs);
CloseHandle(s_timerThread);
s_timerThread = nil;
}
if (s_timerEvent) {
CloseHandle(s_timerEvent);
s_timerEvent = nil;
}
// Cleanup any timers that have been stopped but not deleted
s_timerCrit.Enter();
while (AsyncTimer * t = s_timerDelete.Head()) {
if (t->destroyProc)
CallTimerProc(t, t->destroyProc);
DEL(t);
}
s_timerCrit.Leave();
if (AsyncTimer * timer = s_timerProcs.Root())
ErrorFatal(__LINE__, __FILE__, "TimerProc not destroyed: %p", timer->timerProc);
}
/****************************************************************************
*
* Exported functions
*
***/
//===========================================================================
// 1. Timer procs do not get starved by I/O, they are called periodically.
// 2. Timer procs will never be called by multiple threads simultaneously.
void AsyncTimerCreate (
AsyncTimer ** timer,
FAsyncTimerProc timerProc,
unsigned callbackMs,
void * param
) {
ASSERT(timer);
ASSERT(timerProc);
// Allocate timer outside critical section
AsyncTimer * t = NEW(AsyncTimer);
t->timerProc = timerProc;
t->destroyProc = nil;
t->param = param;
t->priority.Set(TimeGetMs() + callbackMs);
// Set result pointer before queueing timer
// so that the value is set before a callback
*timer = t;
bool setEvent;
s_timerCrit.Enter();
{
InitializeTimer();
// Does this timer need to be queued?
if (callbackMs != kAsyncTimeInfinite)
s_timerProcs.Enqueue(t);
// Does the timer thread need to be awakened?
setEvent = t == s_timerProcs.Root();
}
s_timerCrit.Leave();
if (setEvent)
SetEvent(s_timerEvent);
}
//===========================================================================
// Timer procs can be in the process of getting called in
// another thread during the unregister function -- be careful!
// -- waitComplete = will wait until the timer has been unregistered and is
// no longer in the process of being called before returning. The flag may only
// be set by init/destruct threads, not I/O worker threads. In addition, extreme
// care should be used to avoid a deadlock when this flag is set; in general, it
// is a good idea not to hold any locks or critical sections when setting the flag.
void AsyncTimerDelete (
AsyncTimer * timer,
unsigned flags
) {
// If the timer has already been destroyed then exit
ASSERT(timer);
// Wait for timer before exiting function?
FAsyncTimerProc timerProc;
if (flags & kAsyncTimerDestroyWaitComplete)
timerProc = timer->timerProc;
else
timerProc = nil;
AsyncTimerDeleteCallback(timer, nil);
// Wait until the timer procedure completes
if (timerProc) {
// ensure that I/O worker threads don't call this function with waitComplete=true
// to prevent a possible deadlock of a timer callback waiting for itself to complete
ThreadAssertCanBlock(__FILE__, __LINE__);
while (s_timerCurr == timerProc)
Sleep(1);
}
}
//===========================================================================
void AsyncTimerDeleteCallback (
AsyncTimer * timer,
FAsyncTimerProc destroyProc
) {
// If the timer has already been destroyed then exit
ASSERT(timer);
ASSERT(!timer->deleteLink.IsLinked());
// Link the timer to the deletion list
s_timerCrit.Enter();
{
timer->destroyProc = destroyProc;
s_timerDelete.Link(timer);
}
s_timerCrit.Leave();
// Force the timer thread to wake up and perform the deletion
if (destroyProc)
SetEvent(s_timerEvent);
}
//===========================================================================
// To set the time value for a timer, use this function with flags = 0.
// To set the time to MoreRecentOf(nextTimerCallbackMs, callbackMs), use SETPRIORITYHIGHER
void AsyncTimerUpdate (
AsyncTimer * timer,
unsigned callbackMs,
unsigned flags
) {
ASSERT(timer);
bool setEvent;
s_timerCrit.Enter();
{
if (callbackMs != kAsyncTimeInfinite) {
UpdateTimer(timer, callbackMs + TimeGetMs(), flags);
setEvent = timer == s_timerProcs.Root();
}
else {
if ((flags & kAsyncTimerUpdateSetPriorityHigher) == 0)
timer->priority.Unlink();
setEvent = false;
}
}
s_timerCrit.Leave();
if (setEvent)
SetEvent(s_timerEvent);
}

View File

@ -0,0 +1,54 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrash/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASH_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCrash/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASH_PCH_H
#include "pnUtils/pnUtils.h"

View File

@ -0,0 +1,6 @@
@echo off
:Top
echo Running pnCrash.py
C:\Python23\python pnCrash.py
Sleep 1
goto :Top

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrash/pnCrash.cpp
*
***/
#include "Pch.h"
#pragma hdrstop

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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrash/pnCrash.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASH_PNCRASH_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASH_PNCRASH_H
/*****************************************************************************
*
* Crash API
*
***/
void CrashExceptionDump (const char occasion[], void * info);
void CrashSetEmailParameters (
const char smtp[],
const char sender[],
const char recipients[], // separate multiple recipients with semicolons
const char username[], // optional (see auth notes in pnMail.h)
const char password[], // optional (see auth notes in pnMail.h)
const char replyTo[] // optional
);
void * CrashAddModule (
unsigned_ptr address,
unsigned buildId,
unsigned branchId,
const wchar name[],
const wchar buildString[]
);
void CrashRemoveModule (
void * module
);
/*****************************************************************************
*
* Deadlock detection (server only)
*
***/
#ifdef SERVER
void * CrashAddDeadlockCheck (void * thread, const wchar debugstr[] );
void CrashRemoveDeadlockCheck (void * check);
void CrashSetDeadlockCheckTimes (unsigned emailSec, unsigned terminateSec);
// returns previous setting
bool CrashEnableDeadlockChecking (bool enable);
void CrashDeadlockCheckNow ();
void CrashSendThreadReport ();
#endif
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASH_PNCRASH_H

View File

@ -0,0 +1,469 @@
""" *==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==* """
import sys, os, re, poplib, smtplib, time
#*****************************************************************************
#*
#* Private data
#*
#***
s_pop3Srv = 'catherine.cyan.com'
s_pop3User = 'crashhandler'
s_pop3Pass = 'crashhandler'
s_smtpSrv = 'catherine.cyan.com'
#s_smtpRecipients = ['eric@cyan.com']
s_smtpRecipients = ['crash2@cyan.com']
#s_mapFileBasePath = 'P:\\Plasma20\\Scripts\\Server\\Admin\\';
s_mapFileBasePath = '\\\\dirtcake\\MapFiles\\';
s_modules = {}
s_mapfiles = {}
s_sortedModuleKeys = []
#*****************************************************************************
#*
#* Local functions
#*
#***
#=============================================================================
def UndecorateCppName (name):
name = re.sub('^\?', '', name, 1)
name = re.sub('^_', '', name, 1)
name = re.sub('@', ' ', name)
name = re.sub('\s+', ' ', name)
return name
#=============================================================================
# returns index of the first entry for which 'eval' returns false
def bsearch (a, eval):
low = 0
high = len(a)
if low != high:
while True:
mid = (low + high) // 2
result = eval(a[mid])
if result > 0:
if mid == low:
break
low = mid
else:
high = mid
if mid == low:
break
return high
#*****************************************************************************
#*
#* Function class
#*
#***
class Function:
#=========================================================================
def __init__ (self, name, baseAddr, relocAddr, module):
self.name = UndecorateCppName(name)
self.baseAddr = baseAddr
self.relocAddr = relocAddr
self.module = module
#print "Function: %08x,%s,%s" % (self.relocAddr, self.module, self.name)
#*****************************************************************************
#*
#* Mapfile class
#*
#***
class Mapfile:
#=========================================================================
def __init__ (self, filename):
self.filename = filename
self.prefLoadAddr = 0
self.functions = {}
self.sortedFunctionKeys = []
try:
file = open(filename, 'rb')
# print "mapfile opened " + filename
lines = file.readlines()
file.close()
self.ParseMapfile(lines)
except IOError:
# print 'mapfile not found: ' + filename
pass
#=========================================================================
def ParseMapfile (self, lines):
# Preferred load address is xxxxxxxx
pattern = re.compile('\s*Preferred.*([\dA-Fa-f]{8})')
for line in lines:
match = pattern.match(line)
if not match:
continue
self.prefLoadAddr = int(match.group(1), 16)
break
# section:baseAddr functionName relocAddr flags module
pattern = re.compile('^\s?([\dA-Fa-f]{4}:[\dA-Fa-f]{8})\s+(\S+)\s+([\dA-Fa-f]{8})\s(.)\s.\s(\S+)')
for line in lines:
match = pattern.match(line)
if not match:
continue
baseAddr = match.group(1)
name = match.group(2)
relocAddr = int(match.group(3), 16)
if match.group(4) != 'f':
continue
module = match.group(5)
if self.functions.has_key(relocAddr):
# print " duplicate: %s %08x %s" % (baseAddr, relocAddr, name)
# print " with : %s %08x %s" % (self.functions[relocAddr].baseAddr, self.functions[relocAddr].relocAddr, self.functions[relocAddr].name)
pass
else:
self.functions[relocAddr] = Function(name, baseAddr, relocAddr, module)
self.sortedFunctionKeys = self.functions.keys()
self.sortedFunctionKeys.sort()
# print " function count: %u" % (len(self.sortedFunctionKeys))
#=========================================================================
def FindNearestFunction (self, relocAddr):
#=====================================================================
def eval (a, b=relocAddr):
return b > a
index = bsearch(self.sortedFunctionKeys, eval)
if index > 0 and index < len(self.sortedFunctionKeys):
return self.functions[self.sortedFunctionKeys[index-1]]
return Function("<FunctionNotFound> relocAddr %x" % (relocAddr), 0, relocAddr, self.filename)
#=============================================================================
def LoadMapfile (mapfilename):
global s_mapfiles
if not s_mapfiles.has_key(mapfilename):
s_mapfiles[mapfilename] = Mapfile(mapfilename)
return s_mapfiles[mapfilename]
#*****************************************************************************
#*
#* Module class
#*
#***
class Module:
#=========================================================================
def __init__ (self, loadAddr, name, buildId, buildMark):
# print 'module: %s:%u, loadaddr: %08x' % (name, buildId, loadAddr)
self.loadAddr = loadAddr
self.name = name
self.buildMark = buildMark
self.buildId = buildId
mapfilename = s_mapFileBasePath + buildMark + '\\' + name.split('.')[0].split('_')[0] + '.map'
self.mapfile = LoadMapfile(mapfilename)
#=========================================================================
def FindNearestFunction (self, trueAddr):
relocAddr = trueAddr + self.mapfile.prefLoadAddr - self.loadAddr
# print 'searching for function near Pc:%08x, Ra:%08x in %s' % (trueAddr, relocAddr, self.mapfile.filename)
function = self.mapfile.FindNearestFunction(relocAddr)
if function:
# print " found function %s, Ra:%08x, %s" % (function.baseAddr, function.relocAddr, function.name)
return function
print "Function not found for Pc:%08x, Ra:%08x in %s" % (trueAddr, relocAddr, self.mapfile.filename)
return None
#=============================================================================
def FindNearestModule (loadAddr):
#=========================================================================
def eval (a, b=loadAddr):
return b > a
global s_modules
global s_sortedModuleKeys
if len(s_sortedModuleKeys) == 0:
return None
index = bsearch(s_sortedModuleKeys, eval)
if index > 0 and index <= len(s_sortedModuleKeys):
return s_modules[s_sortedModuleKeys[index-1]]
print "Module not found for loadAddr %08x" % (loadAddr)
return Module(loadAddr, "<ModuleNotFound> loadAddr %x" %(loadAddr), 0, "<NoBuildMark>")
#*****************************************************************************
#*
#* pnCrash class
#*
#***
class pnCrash:
#=========================================================================
def SendCrash (self, msgLines, smtp):
pass
#=========================================================================
def GetModules (self, msgLines):
global s_modules
global s_sortedModuleKeys
# Parse modules and open mapfiles
pattern = re.compile('^([\dA-Fa-f]{8})\s(.*)\((\d+)\.\d+\.(.*)\)')
for line in msgLines:
match = pattern.match(line)
if not match:
continue
loadAddr = int(match.group(1), 16)
filename = os.path.basename(match.group(2)).strip()
buildId = int(match.group(3))
buildMark = match.group(4)
#assert not s_modules.has_key(loadAddr)
s_modules[loadAddr] = Module(loadAddr, filename, buildId, buildMark)
s_sortedModuleKeys = s_modules.keys()
s_sortedModuleKeys.sort()
# if no modules found, use the reporting application's info
if len(s_sortedModuleKeys) == 0:
buildId = 0
loadAddr = int('00400000', 16) # temp hack
patternApp = re.compile('^App\s+:\s+(.*)')
patternBuildMark = re.compile('^BuildMark\s+:\s+(.*)')
for line in msgLines:
if patternApp:
match = patternApp.match(line)
if match:
patternApp = None
filename = os.path.basename(match.group(1)).strip().strip('\r\n')
continue
else:
match = patternBuildMark.match(line)
if match:
buildMark = match.group(1).strip().strip('\r\n')
# print 'No modules found, adding %s, %08x, %u, %s' % (filename, loadAddr, buildId, buildMark)
s_modules[loadAddr] = Module(loadAddr, filename, buildId, buildMark)
s_sortedModuleKeys = s_modules.keys()
s_sortedModuleKeys.sort()
break
#=========================================================================
def ConvertTraces (self, msgLines):
lines = []
callstack = []
intrace = False
pattern = re.compile('Pc:([\dA-Fa-f]{8})\s+Fr:[\dA-Fa-f]{8}\s+Rt:([\dA-Fa-f]{8})')
for rawline in msgLines:
line = rawline.strip('\r\n')
if line.find('|') >= 0: # a previous conversion, skip over it
continue
lines.append(line)
match = pattern.match(line)
if not match:
if intrace:
callstack.append('')
lines += callstack
callstack = []
lines.append('')
intrace = False
continue
if not intrace:
callstack.append('|--------> Callstack <--------')
intrace = True
returnAddr = int(match.group(2), 16)
if not returnAddr:
continue
programCounter = int(match.group(1), 16)
module = FindNearestModule(programCounter)
function = module.FindNearestFunction(programCounter)
callstack.append('| %s, %s:%s' % (function.name, function.module, module.name))
if intrace:
callstack.append('')
lines += callstack
callstack = []
intrace = False
return lines
#=========================================================================
def ProcessClientCrash(self, msgLines):
lines = []
fd = open('untranslated.txt', 'w')
for x in msgLines:
fd.write(x)
fd.write('\n')
fd.close()
os.spawnl(os.P_WAIT, 'plStackTrace.exe', 'plStackTrace.exe', 'untranslated.txt')
fd = open('out.txt', 'r')
lines = fd.readlines()
return lines
#=========================================================================
def ProcessCrash (self, msgLines, smtp):
global s_modules
global s_sortedModuleKeys
subject = '[Crash]'
pattern = re.compile('^Subject: (.*)$')
serverPattern = re.compile('App : plServer.exe')
serverCrash = 0
for line in msgLines:
match = serverPattern.match(line)
if match:
serverCrash = 1
break
if not serverCrash:
subject = 'Client Crash Report'
for line in msgLines:
match = pattern.match(line)
if match:
subject = match.group(1)
subject.strip('\r\n')
from_ = 'crash2@cyan.com'
pattern = re.compile('^From: (.*)$')
for line in msgLines:
match = pattern.match(line)
if match:
from_ = match.group(1)
from_.strip('\r\n')
break
print "Rcvd: %s from %s" % (subject, from_)
smtp.helo()
smtp.mail(from_, [])
for rcpt in s_smtpRecipients:
smtp.rcpt(rcpt, [])
lines = []
lines.append('From: %s' % (from_))
lines.append('Subject: %s' % (subject))
lines.append('')
if not serverCrash:
lines += self.ProcessClientCrash(msgLines) # process client callstack
for x in range(len(lines)):
lines[x] = lines[x].strip('\r\n')
if serverCrash:
s_modules.clear()
s_sortedModuleKeys = []
self.GetModules(msgLines)
lines += self.ConvertTraces(msgLines)
s_sortedModuleKeys = []
s_modules.clear()
msg = '\n'.join([line for line in lines])
smtp.data(msg)
print "Sent: %s from %s" % (subject, from_)
#=========================================================================
def GetAndProcessCrashes (self):
global s_mapfiles
s_mapfiles.clear()
# print "initializing pop3"
pop3 = poplib.POP3(s_pop3Srv)
pop3.user(s_pop3User)
pop3.pass_(s_pop3Pass)
pop3.list()
(numMsgs, totalSize) = pop3.stat()
if numMsgs > 0:
# print "initializing smtp"
smtp = smtplib.SMTP(s_smtpSrv)
# print "retrieving emails"
for i in range(1, numMsgs + 1):
(header, msg, octets) = pop3.retr(i)
self.ProcessCrash(msg, smtp)
pop3.dele(i)
smtp.quit()
pop3.quit()
s_mapfiles.clear()
#=========================================================================
def RunForever (self):
global s_modules
s_modules[0] = Module(0, "<NilModule>", 0, "<NilBuild>")
while 1:
self.GetAndProcessCrashes()
# sleep for an interruptable minute
for i in range(1, 20):
time.sleep(1)
#*****************************************************************************
#*
#* Program entry point
#*
#***
#=============================================================================
if __name__ == '__main__':
pnCrash().RunForever()

View File

@ -0,0 +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/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnMail/pnMail.h"
#include <ImageHlp.h>
#include <process.h>
#ifdef HS_BUILD_FOR_WIN32
#include "Win32/W32Int.h"
#endif

View File

@ -0,0 +1,147 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCRASHEXE_INTERN_H
namespace Crash {
/*****************************************************************************
*
* Mail
*
***/
void CrashSendEmail (
const char smtp[],
const char sender[],
const char recipients[],
const char replyTo[],
const char username[],
const char password[],
const char programName[],
const char errorType[],
const char logBuffer[]
);
/*****************************************************************************
*
* ImgHlp
*
***/
// make our own IMAGEAPI type because the real definition uses DECLSPEC_IMPORT
#define MYIMAGEAPI __stdcall
class CImageHelp {
private:
HMODULE m_libInst;
HANDLE m_process;
char * m_appName;
char m_appPath[MAX_PATH];
public:
CImageHelp (HINSTANCE instance);
~CImageHelp ();
inline HANDLE Process () const {
return m_process;
}
inline const char * GetProgramPath () const {
return m_appPath;
}
inline const char * GetProgramName () const {
return m_appName;
}
BOOL (MYIMAGEAPI * SymGetModuleInfo)(
HANDLE hProcess,
DWORD dwAddr,
IMAGEHLP_MODULE * ModuleInfo
);
BOOL (MYIMAGEAPI * StackWalk)(
DWORD MachineType,
HANDLE hProcess,
HANDLE hThread,
LPSTACKFRAME StackFrame,
LPVOID ContextRecord,
PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,
PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,
PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,
PTRANSLATE_ADDRESS_ROUTINE TranslateAddress
);
LPVOID (MYIMAGEAPI * SymFunctionTableAccess)(
HANDLE hProcess,
DWORD AddrBase
);
DWORD (MYIMAGEAPI * SymGetModuleBase)(
HANDLE hProcess,
DWORD dwAddr
);
BOOL (MYIMAGEAPI * SymGetSymFromAddr)(
HANDLE hProcess,
DWORD Address,
LPDWORD Displacement,
PIMAGEHLP_SYMBOL Symbol
);
};
} using namespace Crash;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/pnCreGui.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,214 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/Win32/pnCreMail.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
//============================================================================
namespace Crash {
//============================================================================
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static bool CreateInheritablePipe (
HANDLE * read,
HANDLE * write,
bool inheritRead
) {
// create pipe for std error read/write
if (!CreatePipe(read, write, (LPSECURITY_ATTRIBUTES) NULL, 0))
return false;
// make the appropriate handle inheritable
HANDLE hProcess = GetCurrentProcess();
HANDLE * inherit = inheritRead ? read : write;
bool result = DuplicateHandle(
hProcess,
*inherit,
hProcess,
inherit,
0,
true, // make inheritable
DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS
);
if (!result)
return false;
return true;
}
/*****************************************************************************
*
* Module functions
*
***/
//============================================================================
void CrashSendEmail (
const char smtp[],
const char sender[],
const char recipients[],
const char replyTo[],
const char username[],
const char password[],
const char programName[],
const char errorType[],
const char logBuffer[]
) {
enum {
IN_CHILD,
IN_PARENT,
NUM_PIPES
};
unsigned i;
HANDLE pipes[NUM_PIPES];
for (i = 0; i < arrsize(pipes); ++i)
pipes[i] = INVALID_HANDLE_VALUE;
for (;;) {
// create pipes for Server -> StdIn -> Client
if (!CreateInheritablePipe(&pipes[IN_CHILD], &pipes[IN_PARENT], true))
break;
char subject[512];
StrPrintf(
subject,
arrsize(subject),
"\"[Crash] %s, %s\"",
programName,
errorType
);
char cmdLine[512];
StrPrintf(
cmdLine,
arrsize(cmdLine),
"plMail.exe -smtp %s -sender %s",
smtp,
sender
);
if (replyTo && replyTo[0]) {
StrPack(cmdLine, " -replyTo ", arrsize(cmdLine));
StrPack(cmdLine, replyTo, arrsize(cmdLine));
}
if (username && username[0]) {
StrPack(cmdLine, " -u ", arrsize(cmdLine));
StrPack(cmdLine, username, arrsize(cmdLine));
}
if (password && password[0]) {
StrPack(cmdLine, " -p ", arrsize(cmdLine));
StrPack(cmdLine, password, arrsize(cmdLine));
}
StrPack(cmdLine, " ", arrsize(cmdLine));
StrPack(cmdLine, recipients, arrsize(cmdLine));
StrPack(cmdLine, " ", arrsize(cmdLine));
StrPack(cmdLine, subject, arrsize(cmdLine));
// create process
STARTUPINFO si;
ZERO(si);
si.cb = sizeof(si);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
si.wShowWindow = SW_HIDE;
si.hStdInput = pipes[IN_CHILD];
si.hStdOutput = INVALID_HANDLE_VALUE;
si.hStdError = INVALID_HANDLE_VALUE;
PROCESS_INFORMATION pi;
BOOL result = CreateProcess(
NULL,
cmdLine,
(LPSECURITY_ATTRIBUTES) NULL,
(LPSECURITY_ATTRIBUTES) NULL,
true, // => inherit handles
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi
);
if (!result)
break;
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
// Write output data
DWORD written, length = StrLen(logBuffer);
WriteFile(pipes[IN_PARENT], logBuffer, length, &written, NULL);
// complete
break;
}
// cleanup pipes
for (i = 0; i < arrsize(pipes); ++i) {
if (pipes[i] != INVALID_HANDLE_VALUE)
CloseHandle(pipes[i]);
}
}
//============================================================================
} // namespace Crash
//============================================================================

View File

@ -0,0 +1,201 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCrashExe/pnCreTools.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
//============================================================================
namespace Crash {
//============================================================================
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static BOOL MYIMAGEAPI iSymGetModuleInfo (
HANDLE,
DWORD,
IMAGEHLP_MODULE * ModuleInfo
) {
ZEROPTR(ModuleInfo);
return false;
}
//===========================================================================
static BOOL MYIMAGEAPI iStackWalk (
DWORD,
HANDLE,
HANDLE,
LPSTACKFRAME,
LPVOID,
PREAD_PROCESS_MEMORY_ROUTINE,
PFUNCTION_TABLE_ACCESS_ROUTINE,
PGET_MODULE_BASE_ROUTINE,
PTRANSLATE_ADDRESS_ROUTINE
) {
return false;
}
//===========================================================================
static LPVOID MYIMAGEAPI iSymFunctionTableAccess (
HANDLE,
DWORD
) {
return nil;
}
//===========================================================================
static DWORD MYIMAGEAPI iSymGetModuleBase (
HANDLE,
DWORD
) {
return 0;
}
//===========================================================================
static BOOL MYIMAGEAPI iSymGetSymFromAddr (
HANDLE,
DWORD,
LPDWORD Displacement,
PIMAGEHLP_SYMBOL Symbol
) {
*Displacement = 0;
ZEROPTR(Symbol);
return false;
}
/*****************************************************************************
*
* CImageHelp
*
***/
//============================================================================
CImageHelp::CImageHelp (HINSTANCE instance)
: m_libInst(nil),
m_process(nil)
{
// get program directory and filename
if (!GetModuleFileNameA(instance, m_appPath, arrsize(m_appPath)))
m_appPath[0] = 0;
if (nil != (m_appName = StrChrR(m_appPath, '\\')))
*m_appName++ = '\0';
else
m_appName = m_appPath;
// initialize symbols
for (;;) {
if (nil == (m_libInst = LoadLibrary("ImageHlp.dll")))
break;
// initialize symbols for this process
BOOL (MYIMAGEAPI * SymInitialize)(HANDLE hProcess, char * path, BOOL fInvade);
* (FARPROC *) &SymInitialize = GetProcAddress(m_libInst, "SymInitialize");
if (!SymInitialize)
break;
HANDLE hProcess = GetCurrentProcess();
if (!SymInitialize(hProcess, m_appPath, false))
break;
// import functions
FARPROC proc;
#define BIND(x) * (FARPROC *) &(x) = ((proc = GetProcAddress(m_libInst, #x)) != nil) ? proc : (FARPROC) i##x
BIND(SymGetModuleInfo);
BIND(StackWalk);
BIND(SymFunctionTableAccess);
BIND(SymGetModuleBase);
BIND(SymGetSymFromAddr);
#undef BIND
// success
m_process = hProcess;
return;
}
// failure!
if (m_libInst) {
FreeLibrary(m_libInst);
m_libInst = nil;
}
#define INIT(x) x = i##x
INIT(SymGetModuleInfo);
INIT(StackWalk);
INIT(SymFunctionTableAccess);
INIT(SymGetModuleBase);
INIT(SymGetSymFromAddr);
#undef INIT
}
//============================================================================
CImageHelp::~CImageHelp () {
if (m_process) {
BOOL (MYIMAGEAPI * SymCleanup)(HANDLE hProcess);
* (FARPROC *) &SymCleanup = GetProcAddress(m_libInst, "SymCleanup");
if (SymCleanup)
SymCleanup(m_process);
m_process = 0;
}
if (m_libInst) {
FreeLibrary(m_libInst);
m_libInst = 0;
}
}
//============================================================================
} // namespace Crash
//============================================================================

View File

@ -0,0 +1,56 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PCH_H
#include "pnCsrCli.h"
#include <malloc.h>

View File

@ -0,0 +1,269 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Local types
*
***/
/*****************************************************************************
*
* Local data
*
***/
static bool s_running;
static CCritSect s_critsect;
static SimpleNetConn * s_conn;
static FCsrCliOnError s_onError;
/*****************************************************************************
*
* Local functions
*
***/
//============================================================================
static SimpleNetConn * GetConnIncRef () {
SimpleNetConn * conn;
s_critsect.Enter();
{
if (nil != (conn = s_conn))
SimpleNetConnIncRef(conn);
}
s_critsect.Leave();
return conn;
}
//============================================================================
static bool SimpleNetOnMsg (
SimpleNetConn * ,
SimpleNet_MsgHeader *
) {
LogMsg(kLogPerf, L"pnCsrCli: Rcvd unexpected message from peer");
return false;
}
//============================================================================
static void SimpleNetOnError (
SimpleNetConn * ,
ENetError error
) {
if (!s_running)
return;
LogMsg(kLogPerf, L"pnCsrCli: NetError: %s", NetErrorToString(error));
if (error == kNetErrDisconnected)
CsrCliDisconnect();
s_onError(error);
}
//============================================================================
static void SimpleNetOnConnect (
void * param,
SimpleNetConn * conn,
ENetError result
) {
FCsrCliOnConnect onConnect = (FCsrCliOnConnect)param;
LogMsg(kLogPerf, L"pnCsrCli: OnConnect: %s", NetErrorToString(result));
if (s_conn)
CsrCliDisconnect();
if (IS_NET_SUCCESS(result)) {
s_critsect.Enter();
{
s_conn = conn;
}
s_critsect.Leave();
}
if (onConnect)
onConnect(result);
}
//============================================================================
static void Send_ExecConsoleCmd (const char cmd[]) {
SimpleNetConn * conn = GetConnIncRef();
if (!conn)
return;
unsigned cmdBytes = StrBytes(cmd);
CsrNet_ExecConsoleCmd * msg;
unsigned msgBytes
= sizeof(*msg)
- sizeof(msg->cmd)
+ cmdBytes
+ sizeof(cmd[0])
;
msg = new(_alloca(msgBytes)) CsrNet_ExecConsoleCmd();
msg->messageBytes = msgBytes;
StrCopy(msg->cmd, cmd, cmdBytes / sizeof(cmd[0]));
msg->cmd[cmdBytes] = 0;
SimpleNetSend(conn, msg);
SimpleNetConnDecRef(conn);
}
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
void CsrCliInitialize (FCsrCliOnError onError) {
ASSERT(!s_running);
ASSERT(onError);
s_running = true;
s_onError = onError;
SimpleNetInitialize();
SimpleNetCreateChannel(kSimpleNetChannelCsr, SimpleNetOnMsg, SimpleNetOnError);
};
//============================================================================
void CsrCliShutdown () {
s_running = false;
s_onError = nil;
CsrCliDisconnect();
SimpleNetDestroyChannel(kSimpleNetChannelCsr);
SimpleNetShutdown();
}
//============================================================================
void CsrCliStartConnecting (
const wchar addr[],
FCsrCliOnConnect onConnect
) {
ASSERT(s_running);
CsrCliDisconnect();
SimpleNetStartConnecting(kSimpleNetChannelCsr, addr, SimpleNetOnConnect, onConnect);
}
//============================================================================
void CsrCliDisconnect () {
SimpleNetConn * conn = nil;
s_critsect.Enter();
{
SWAP(conn, s_conn);
}
s_critsect.Leave();
if (conn)
SimpleNetDisconnect(conn);
}
//============================================================================
void CsrCliToggleAvatarPhysical () {
ASSERT(s_running);
Send_ExecConsoleCmd("Avatar.Physics.TogglePhysical");
}
//============================================================================
void CsrCliWarpPlayerHere (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.WarpPlayerHere %u", playerId);
Send_ExecConsoleCmd(cmd);
}
//============================================================================
void CsrCliWarpToPlayer (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.WarpToPlayer %u", playerId);
Send_ExecConsoleCmd(cmd);
}
//============================================================================
void CsrCliLinkPlayerHere (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.LinkPlayerHere %u", playerId);
Send_ExecConsoleCmd(cmd);
}
//============================================================================
void CsrCliLinkToPlayer (unsigned playerId) {
ASSERT(s_running);
char cmd[1024];
StrPrintf(cmd, arrsize(cmd), "CCR.LinkToPlayer %u", playerId);
Send_ExecConsoleCmd(cmd);
}

View File

@ -0,0 +1,83 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrCli/pnCsrCli.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H
#include "pnCsrNet/pnCsrNet.h"
/*****************************************************************************
*
* pnCsrCli
* - Connects to pfCsrSrv in remote CSR client.
* - Sends commands to pfCsrSrv for remote execution.
*
***/
typedef void (*FCsrCliOnError) (ENetError error);
void CsrCliInitialize (FCsrCliOnError onError);
void CsrCliShutdown ();
typedef void (*FCsrCliOnConnect) (ENetError result);
void CsrCliStartConnecting (
const wchar addr[],
FCsrCliOnConnect onConnect
);
void CsrCliDisconnect ();
void CsrCliToggleAvatarPhysical ();
void CsrCliWarpPlayerHere (unsigned playerId);
void CsrCliWarpToPlayer (unsigned playerId);
void CsrCliLinkPlayerHere (unsigned playerId);
void CsrCliLinkToPlayer (unsigned playerId);
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRCLI_PNCSRCLI_H

View File

@ -0,0 +1,54 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PCH_H
#include "pnCsrNet.h"

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.cpp
*
***/
#include "Pch.h"
#pragma hdrstop

View File

@ -0,0 +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/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnCsrNet/pnCsrNet.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H
#include "pnSimpleNet/pnSimpleNet.h"
/*****************************************************************************
*
* CSR Client Automation - Types and Constants
*
***/
// Newer CSR game clients must remain compatible with older CSR tools,
// therefore these values may not change. Only append to this enum.
enum {
kCsrNet_ExecConsoleCmd,
};
//============================================================================
// BEGIN PACKED DATA STRUCTURES
//============================================================================
#include <PshPack1.h>
#define CSRNET_MSG(a) \
CsrNet_##a () : SimpleNet_MsgHeader(kSimpleNetChannelCsr, kCsrNet_##a) { }
struct CsrNet_ExecConsoleCmd : SimpleNet_MsgHeader {
CSRNET_MSG (ExecConsoleCmd);
char cmd[1]; // null-terminated string
};
#undef CSRNET_MSG
//============================================================================
// END PACKED DATA STRUCTURES
//============================================================================
#include <PopPack.h>
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNCSRNET_PNCSRNET_H

View File

@ -0,0 +1,648 @@
/*==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 "hsTypes.h"
#include "hsResMgr.h"
#include "plDispatch.h"
#define PLMESSAGE_PRIVATE
#include "../pnMessage/plMessage.h"
#include "../pnKeyedObject/hsKeyedObject.h"
#include "hsTimer.h"
#include "../pnMessage/plTimeMsg.h"
#include "../pnKeyedObject/plKey.h"
#include "plDispatchLogBase.h"
#include "../pnNetCommon/plNetApp.h"
#include "../pnNetCommon/plSynchedObject.h"
#include "../pnNetCommon/pnNetCommon.h"
#include "hsThread.h"
#include "plProfile.h"
plProfile_CreateTimer("MsgReceive", "Update", MsgReceive);
plProfile_CreateTimer(" TimeMsg", "Update", TimeMsg);
plProfile_CreateTimer(" EvalMsg", "Update", EvalMsg);
plProfile_CreateTimer(" TransformMsg", "Update", TransformMsg);
plProfile_CreateTimer(" CameraMsg", "Update", CameraMsg);
class plMsgWrap
{
public:
plMsgWrap** fBack;
plMsgWrap* fNext;
hsTArray<plKey> fReceivers;
plMessage* fMsg;
plMsgWrap(plMessage* msg) : fMsg(msg) { hsRefCnt_SafeRef(msg); }
virtual ~plMsgWrap() { hsRefCnt_SafeUnRef(fMsg); }
plMsgWrap& ClearReceivers() { fReceivers.SetCount(0); return *this; }
plMsgWrap& AddReceiver(const plKey& rcv)
{
hsAssert(rcv, "Trying to send mail to nil receiver");
fReceivers.Append(rcv); return *this;
}
const plKey& GetReceiver(int i) const { return fReceivers[i]; }
UInt32 GetNumReceivers() const { return fReceivers.GetCount(); }
};
Int32 plDispatch::fNumBufferReq = 0;
hsBool plDispatch::fMsgActive = false;
plMsgWrap* plDispatch::fMsgCurrent = nil;
plMsgWrap* plDispatch::fMsgHead = nil;
plMsgWrap* plDispatch::fMsgTail = nil;
hsTArray<plMessage*> plDispatch::fMsgWatch;
MsgRecieveCallback plDispatch::fMsgRecieveCallback = nil;
hsMutex plDispatch::fMsgCurrentMutex; // mutex for fMsgCurrent
hsMutex plDispatch::fMsgDispatchLock; // mutex for IMsgDispatch
plDispatch::plDispatch()
: fOwner(nil), fFutureMsgQueue(nil), fQueuedMsgOn(true)
{
}
plDispatch::~plDispatch()
{
hsAssert(fRegisteredExactTypes.GetCount() == 0, "registered type after Dispatch shutdown");
ITrashUndelivered();
}
void plDispatch::BeginShutdown()
{
fRegisteredExactTypes.Reset();
ITrashUndelivered();
}
void plDispatch::ITrashUndelivered()
{
while( fFutureMsgQueue )
{
plMsgWrap* nuke = fFutureMsgQueue;
fFutureMsgQueue = fFutureMsgQueue->fNext;
hsRefCnt_SafeUnRef(nuke->fMsg);
delete nuke;
}
// If we're the main dispatch, any unsent messages at this
// point are just trashed. Slave dispatches just go away and
// leave their messages to be delivered when the main dispatch
// gets around to it.
if( this == plgDispatch::Dispatch() )
{
while( fMsgHead )
{
plMsgWrap* nuke = fMsgHead;
fMsgHead = fMsgHead->fNext;
// hsRefCnt_SafeUnRef(nuke->fMsg); // MOOSE - done in plMsgWrap dtor
delete nuke;
}
// reset static members which we just deleted - MOOSE
fMsgCurrent=fMsgHead=fMsgTail=nil;
fMsgActive = false;
}
}
plMsgWrap* plDispatch::IInsertToQueue(plMsgWrap** curr, plMsgWrap* isert)
{
isert->fNext = *curr;
isert->fBack = curr;
if( *curr )
(*curr)->fBack = &isert->fNext;
*curr = isert;
return isert;
}
plMsgWrap* plDispatch::IDequeue(plMsgWrap** head, plMsgWrap** tail)
{
plMsgWrap* retVal = *head;
if( *head )
{
*head = (*head)->fNext;
if( *head )
(*head)->fBack = head;
}
if( tail && (*tail == retVal) )
*tail = *head;
return retVal;
}
hsBool plDispatch::ISortToDeferred(plMessage* msg)
{
plMsgWrap* msgWrap = TRACKED_NEW plMsgWrap(msg);
if( !fFutureMsgQueue )
{
if( IGetOwner() )
plgDispatch::Dispatch()->RegisterForExactType(plTimeMsg::Index(), IGetOwnerKey());
IInsertToQueue(&fFutureMsgQueue, msgWrap);
return false;
}
if( fFutureMsgQueue->fMsg->fTimeStamp > msgWrap->fMsg->fTimeStamp )
{
IInsertToQueue(&fFutureMsgQueue, msgWrap);
return false;
}
plMsgWrap* after = fFutureMsgQueue;
while( after->fNext && (after->fNext->fMsg->fTimeStamp < msgWrap->fMsg->fTimeStamp) )
after = after->fNext;
IInsertToQueue(&after->fNext, msgWrap);
return false;
}
void plDispatch::ICheckDeferred(double secs)
{
while( fFutureMsgQueue && (fFutureMsgQueue->fMsg->fTimeStamp < secs) )
{
plMsgWrap* send = IDequeue(&fFutureMsgQueue, nil);
MsgSend(send->fMsg);
delete send;
}
int timeIdx = plTimeMsg::Index();
if( IGetOwner()
&& !fFutureMsgQueue
&&
(
(timeIdx >= fRegisteredExactTypes.GetCount())
||
!fRegisteredExactTypes[plTimeMsg::Index()]
)
)
plgDispatch::Dispatch()->UnRegisterForExactType(plTimeMsg::Index(), IGetOwnerKey());
}
hsBool plDispatch::IListeningForExactType(UInt16 hClass)
{
if( (hClass == plTimeMsg::Index()) && fFutureMsgQueue )
return true;
return false;
}
void plDispatch::IMsgEnqueue(plMsgWrap* msgWrap, hsBool async)
{
fMsgCurrentMutex.Lock();
#ifdef HS_DEBUGGING
if( msgWrap->fMsg->HasBCastFlag(plMessage::kMsgWatch) )
fMsgWatch.Append(msgWrap->fMsg);
#endif // HS_DEBUGGING
if( fMsgTail )
fMsgTail = IInsertToQueue(&fMsgTail->fNext, msgWrap);
else
fMsgTail = IInsertToQueue(&fMsgHead, msgWrap);
fMsgCurrentMutex.Unlock();
if( !async )
// Test for fMsgActive in IMsgDispatch(), properly wrapped inside a mutex -mcn
IMsgDispatch();
}
// On starts deferring msg delivery until buffering is set to off again.
hsBool plDispatch::SetMsgBuffering(hsBool on)
{
fMsgCurrentMutex.Lock();
if( on )
{
hsAssert(fNumBufferReq || !fMsgActive, "Can't start deferring message delivery while delivering messages. See mf");
if( !fNumBufferReq && fMsgActive )
{
fMsgCurrentMutex.Unlock();
return false;
}
fNumBufferReq++;
fMsgActive = true;
fMsgCurrentMutex.Unlock();
}
else if( !--fNumBufferReq )
{
fMsgActive = false;
fMsgCurrentMutex.Unlock();
IMsgDispatch();
}
hsAssert(fNumBufferReq >= 0, "Mismatched number of on/off dispatch buffering requests");
return true;
}
void plDispatch::IMsgDispatch()
{
if( !fMsgDispatchLock.TryLock() )
return;
if( fMsgActive )
{
fMsgDispatchLock.Unlock();
return;
}
fMsgActive = true;
int responseLevel=0;
fMsgCurrentMutex.Lock();
plMsgWrap* origTail = fMsgTail;
while( fMsgCurrent = fMsgHead )
{
IDequeue(&fMsgHead, &fMsgTail);
fMsgCurrentMutex.Unlock();
plMessage* msg = fMsgCurrent->fMsg;
hsBool nonLocalMsg = msg && msg->HasBCastFlag(plMessage::kNetNonLocal);
#ifdef HS_DEBUGGING
int watchIdx = fMsgWatch.Find(msg);
if( fMsgWatch.kMissingIndex != watchIdx )
{
fMsgWatch.Remove(watchIdx);
#if HS_BUILD_FOR_WIN32
__asm { int 3 }
#endif // HS_BUILD_FOR_WIN32
}
#endif // HS_DEBUGGING
static UInt64 startTicks = 0;
if (plDispatchLogBase::IsLogging())
startTicks = hsTimer::GetFullTickCount();
int i, numReceivers=0;
for( i = 0; fMsgCurrent && i < fMsgCurrent->GetNumReceivers(); i++ )
{
const plKey& rcvKey = fMsgCurrent->GetReceiver(i);
plReceiver* rcv = rcvKey ? plReceiver::ConvertNoRef(rcvKey->ObjectIsLoaded()) : nil;
if( rcv )
{
if (nonLocalMsg)
{
// localOnly objects should not get remote messages
plSynchedObject* synchedObj = plSynchedObject::ConvertNoRef(rcv);
if (synchedObj && !synchedObj->IsNetSynched() )
{
continue;
}
if (plNetObjectDebuggerBase::GetInstance())
{ // log net msg if this is a debug object
hsKeyedObject* ko = hsKeyedObject::ConvertNoRef(rcv);
if (plNetObjectDebuggerBase::GetInstance()->IsDebugObject(ko))
{
hsLogEntry(plNetObjectDebuggerBase::GetInstance()->LogMsg(
xtl::format("<RCV> object:%s, GameMessage %s st=%.3f rt=%.3f",
ko->GetKeyName(), msg->ClassName(), hsTimer::GetSysSeconds(), hsTimer::GetSeconds()).c_str()));
}
}
}
#ifndef PLASMA_EXTERNAL_RELEASE
UInt32 rcvTicks = hsTimer::GetPrecTickCount();
// Object could be deleted by this message, so we need to log this stuff now
const char* keyname = "(unknown)";
const char* className = "(unknown)";
UInt32 clonePlayerID = 0;
if (plDispatchLogBase::IsLoggingLong())
{
hsKeyedObject* ko = hsKeyedObject::ConvertNoRef(rcv);
if (ko)
{
keyname = ko->GetKeyName();
clonePlayerID = ko->GetKey()->GetUoid().GetClonePlayerID();
className = ko->ClassName();
}
}
#endif // PLASMA_EXTERNAL_RELEASE
#ifdef HS_DEBUGGING
if (msg->GetBreakBeforeDispatch())
DebugBreakIfDebuggerPresent();
#endif
plProfile_BeginTiming(MsgReceive);
rcv->MsgReceive(msg);
plProfile_EndTiming(MsgReceive);
#ifndef PLASMA_EXTERNAL_RELEASE
if (plDispatchLogBase::IsLoggingLong())
{
rcvTicks = hsTimer::GetPrecTickCount() - rcvTicks;
float rcvTime = (float)(hsTimer::PrecTicksToSecs(rcvTicks) * 1000.f);
// If the receiver takes more than 5 ms to process its message, log it
if (rcvTime > 5.f)
plDispatchLogBase::GetInstance()->LogLongReceive(keyname, className, clonePlayerID, msg, rcvTime);
}
#endif // PLASMA_EXTERNAL_RELEASE
numReceivers++;
if (fMsgRecieveCallback != nil)
fMsgRecieveCallback();
}
}
// for message logging
// if (plDispatchLogBase::IsLogging())
// {
// float sendTime = hsTimer::FullTicksToMs(hsTimer::GetFullTickCount() - startTicks);
//
// plDispatchLogBase::GetInstance()->DumpMsg(msg, numReceivers, (int)sendTime, responseLevel*2 /* indent */);
// if (origTail==fMsgCurrent)
// { // if we deliver more msgs after this, they must be response msgs
// responseLevel++;
// origTail = fMsgTail;
// }
// }
fMsgCurrentMutex.Lock();
delete fMsgCurrent;
// TEMP
fMsgCurrent = (class plMsgWrap *)0xdeadc0de;
}
fMsgCurrentMutex.Unlock();
fMsgActive = false;
fMsgDispatchLock.Unlock();
}
//
// returns true if msg has been consumed and deleted
//
hsBool plDispatch::IMsgNetPropagate(plMessage* msg)
{
fMsgCurrentMutex.Lock();
// Make sure cascaded messages all have the same net flags
plNetClientApp::InheritNetMsgFlags(fMsgCurrent ? fMsgCurrent->fMsg : nil, msg, false);
fMsgCurrentMutex.Unlock();
// Decide if msg should go out over the network.
// If kNetForce is used, this message should always go out over the network, even if it's already
// part of a net cascade. We still want to inherit net status flags (but ignore them)
// so that response messages obey cascading rules. In other words, we are not
// halting the cascade, just overriding the send rule for this message.
if( msg->HasBCastFlag(plMessage::kNetPropagate) &&
(!msg->HasBCastFlag(plMessage::kNetSent) ||
msg->HasBCastFlag(plMessage::kNetForce) ||
msg->HasBCastFlag(plMessage::kNetNonDeterministic) ||
msg->HasBCastFlag(plMessage::kCCRSendToAllPlayers )) )
{
// send it off...
hsAssert(!msg->HasBCastFlag(plMessage::kNetStartCascade), "initial net cascade msg getting sent over the net again?");
if (plNetClientApp::GetInstance() && plNetClientApp::GetInstance()->ISendGameMessage(msg)>=0)
msg->SetBCastFlag(plMessage::kNetSent);
}
// Decide if msg should get sent locally
if (!msg->HasBCastFlag(plMessage::kLocalPropagate))
{
hsRefCnt_SafeUnRef(msg);
return true;
}
// since we've already checked this property, and the msg will be dispatched locally,
// it should not start any more net cascades.
msg->SetBCastFlag(plMessage::kNetStartCascade, false);
return false;
}
hsBool plDispatch::MsgSend(plMessage* msg, hsBool async)
{
if( IMsgNetPropagate(msg) )
return true;
plTimeMsg* timeMsg;
if( msg->GetTimeStamp() > hsTimer::GetSysSeconds() )
return ISortToDeferred(msg);
else if( timeMsg = plTimeMsg::ConvertNoRef(msg) )
ICheckDeferred(timeMsg->DSeconds());
plMsgWrap* msgWrap = TRACKED_NEW plMsgWrap(msg);
hsRefCnt_SafeUnRef(msg);
// broadcast
if( msg->HasBCastFlag(plMessage::kBCastByExactType) | msg->HasBCastFlag(plMessage::kBCastByType) )
{
int idx = msg->ClassIndex();
if( idx < fRegisteredExactTypes.GetCount() )
{
plTypeFilter* filt = fRegisteredExactTypes[idx];
if( filt )
{
int j;
for( j = 0; j < filt->fReceivers.GetCount(); j++ )
{
msgWrap->AddReceiver(filt->fReceivers[j]);
}
if( msg->HasBCastFlag(plMessage::kClearAfterBCast) )
{
delete filt;
fRegisteredExactTypes[idx] = nil;
}
}
}
}
// Direct communique
else
if( msg->GetNumReceivers() )
{
msgWrap->fReceivers = msg->fReceivers;
}
IMsgEnqueue(msgWrap, async);
return true;
}
void plDispatch::MsgQueueOnOff(hsBool sw)
{
fQueuedMsgOn = sw;
}
void plDispatch::MsgQueue(plMessage* msg)
{
if (fQueuedMsgOn)
{
fQueuedMsgListMutex.Lock();
hsAssert(msg,"Message missing");
fQueuedMsgList.push_back(msg);
fQueuedMsgListMutex.Unlock();
}
else
MsgSend(msg, false);
}
void plDispatch::MsgQueueProcess()
{
// Process all messages on Queue, unlock while sending them
// this would allow other threads to put new messages on the list while we send()
while (1)
{
plMessage * pMsg = nil;
fQueuedMsgListMutex.Lock();
int size = fQueuedMsgList.size();
if (size)
{ pMsg = fQueuedMsgList.front();
fQueuedMsgList.pop_front();
}
fQueuedMsgListMutex.Unlock();
if (pMsg)
{ MsgSend(pMsg, false);
}
if (!size)
break;
}
}
void plDispatch::RegisterForType(UInt16 hClass, const plKey& receiver)
{
int i;
for( i = 0; i < plFactory::GetNumClasses(); i++ )
{
if( plFactory::DerivesFrom(hClass, i) )
RegisterForExactType(i, receiver);
}
}
void plDispatch::RegisterForExactType(UInt16 hClass, const plKey& receiver)
{
int idx = hClass;
fRegisteredExactTypes.ExpandAndZero(idx+1);
plTypeFilter* filt = fRegisteredExactTypes[idx];
if( !filt )
{
filt = TRACKED_NEW plTypeFilter;
fRegisteredExactTypes[idx] = filt;
filt->fHClass = hClass;
}
if( filt->fReceivers.kMissingIndex == filt->fReceivers.Find(receiver) )
filt->fReceivers.Append(receiver);
}
void plDispatch::UnRegisterForType(UInt16 hClass, const plKey& receiver)
{
int i;
for( i = 0; i < fRegisteredExactTypes.GetCount(); i++ )
{
if( plFactory::DerivesFrom(hClass, i) )
IUnRegisterForExactType(i , receiver);
}
}
hsBool plDispatch::IUnRegisterForExactType(int idx, const plKey& receiver)
{
hsAssert(idx < fRegisteredExactTypes.GetCount(), "Out of range should be filtered before call to internal");
plTypeFilter* filt = fRegisteredExactTypes[idx];
if (!filt)
return false;
int j;
for( j = 0; j < filt->fReceivers.GetCount(); j++ )
{
if( receiver == filt->fReceivers[j] )
{
if( filt->fReceivers.GetCount() > 1 )
{
if( j < filt->fReceivers.GetCount() - 1 )
filt->fReceivers[j] = filt->fReceivers[filt->fReceivers.GetCount() - 1];
filt->fReceivers[filt->fReceivers.GetCount()-1] = nil;
filt->fReceivers.SetCount(filt->fReceivers.GetCount()-1);
}
else
{
delete filt;
fRegisteredExactTypes[idx] = nil;
}
break;
}
}
return false;
}
void plDispatch::UnRegisterAll(const plKey& receiver)
{
int i;
for( i = 0; i < fRegisteredExactTypes.GetCount(); i++ )
{
plTypeFilter* filt = fRegisteredExactTypes[i];
if( filt )
{
int idx = filt->fReceivers.Find(receiver);
if( idx != filt->fReceivers.kMissingIndex )
{
if( filt->fReceivers.GetCount() > 1 )
{
if( idx < filt->fReceivers.GetCount() - 1 )
filt->fReceivers[idx] = filt->fReceivers[filt->fReceivers.GetCount() - 1];
filt->fReceivers[filt->fReceivers.GetCount()-1] = nil;
filt->fReceivers.SetCount(filt->fReceivers.GetCount()-1);
}
else
{
delete filt;
fRegisteredExactTypes[i] = nil;
}
}
}
}
}
void plDispatch::UnRegisterForExactType(UInt16 hClass, const plKey& receiver)
{
int idx = hClass;
if( idx >= fRegisteredExactTypes.GetCount() )
return;
plTypeFilter* filt = fRegisteredExactTypes[idx];
if( !filt )
return;
IUnRegisterForExactType(idx, receiver);
}

View File

@ -0,0 +1,156 @@
/*==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 plDispatch_inc
#define plDispatch_inc
#include "hsTemplates.h"
#include "hsStlUtils.h"
#include "plgDispatch.h"
#include "hsThread.h"
#include "../pnKeyedObject/hsKeyedObject.h"
#pragma warning(disable: 4284)
class hsResMgr;
class plMessage;
class plKey;
class plTypeFilter
{
public:
plTypeFilter() : fHClass(0) {}
UInt16 fHClass;
hsTArray<plKey> fReceivers;
};
class plMsgWrap;
typedef void (*MsgRecieveCallback)();
class plDispatch : public plDispatchBase
{
protected:
hsKeyedObject* fOwner;
plMsgWrap* fFutureMsgQueue;
static Int32 fNumBufferReq;
static plMsgWrap* fMsgCurrent;
static hsMutex fMsgCurrentMutex; // mutex for above
static hsMutex fMsgDispatchLock; // mutex for IMsgDispatch
static plMsgWrap* fMsgHead;
static plMsgWrap* fMsgTail;
static hsBool fMsgActive;
static hsTArray<plMessage*> fMsgWatch;
static MsgRecieveCallback fMsgRecieveCallback;
hsTArray<plTypeFilter*> fRegisteredExactTypes;
std::list<plMessage*> fQueuedMsgList;
hsMutex fQueuedMsgListMutex; // mutex for above
hsBool fQueuedMsgOn; // Turns on or off Queued Messages, Plugins need them off
hsKeyedObject* IGetOwner() { return fOwner; }
plKey IGetOwnerKey() { return IGetOwner() ? IGetOwner()->GetKey() : nil; }
int IFindType(UInt16 hClass);
int IFindSender(const plKey& sender);
hsBool IUnRegisterForExactType(int idx, const plKey& receiver);
static plMsgWrap* IInsertToQueue(plMsgWrap** back, plMsgWrap* isert);
static plMsgWrap* IDequeue(plMsgWrap** head, plMsgWrap** tail);
hsBool IMsgNetPropagate(plMessage* msg);
static void IMsgDispatch();
static void IMsgEnqueue(plMsgWrap* msgWrap, hsBool async);
hsBool ISortToDeferred(plMessage* msg);
void ICheckDeferred(double stamp);
hsBool IListeningForExactType(UInt16 hClass);
void ITrashUndelivered(); // Just pitches them, doesn't try to deliver.
public:
plDispatch();
virtual ~plDispatch();
CLASSNAME_REGISTER( plDispatch );
GETINTERFACE_ANY( plDispatch, plCreatable );
virtual void RegisterForType(UInt16 hClass, const plKey& receiver);
virtual void RegisterForExactType(UInt16 hClass, const plKey& receiver);
virtual void UnRegisterForType(UInt16 hClass, const plKey& receiver);
virtual void UnRegisterForExactType(UInt16 hClass, const plKey& receiver);
virtual void UnRegisterAll(const plKey& receiver);
virtual hsBool MsgSend(plMessage* msg, hsBool async=false);
virtual void MsgQueue(plMessage* msg); // Used by other thread to Send Messages, they are handled as soon as Practicable
virtual void MsgQueueProcess();
virtual void MsgQueueOnOff(hsBool ); // Turn on or off Queued Messages, if off, uses MsgSend Immediately
virtual hsBool SetMsgBuffering(hsBool on); // On starts deferring msg delivery until buffering is set to off again.
virtual void BeginShutdown();
static void SetMsgRecieveCallback(MsgRecieveCallback callback) { fMsgRecieveCallback = callback; }
};
class plNullDispatch : public plDispatch
{
public:
virtual void RegisterForExactType(UInt16 hClass, const plKey& receiver) {}
virtual void RegisterForType(UInt16 hClass, const plKey& receiver) {}
virtual void UnRegisterForExactType(UInt16 hClass, const plKey& receiver) {}
virtual void UnRegisterForType(UInt16 hClass, const plKey& receiver) {}
virtual hsBool MsgSend(plMessage* msg) {}
virtual void MsgQueue(plMessage* msg){}
virtual void MsgQueueProcess(){}
};
#endif // plDispatch_inc

View File

@ -0,0 +1,45 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "plDispatchLogBase.h"
plDispatchLogBase* plDispatchLogBase::fInstance = nil;
UInt32 plDispatchLogBase::fFlags = 0;

View File

@ -0,0 +1,89 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 plDispatchLogBase_inc
#define plDispatchLogBase_inc
#include "hsTypes.h"
//
// For debugging messaging code.
//
class plMessage;
class plReceiver;
class plDispatchLogBase
{
public:
enum Flags
{
kInclude = 0x1,
kLogLongReceives = 0x2,
};
protected:
static UInt32 fFlags;
static plDispatchLogBase* fInstance;
public:
static plDispatchLogBase* GetInstance() { return fInstance; }
virtual ~plDispatchLogBase() {}
static void SetFlags(UInt32 f) { fFlags=f; }
static UInt32 GetFlags() { return fFlags; }
static bool IsLogging() { return fInstance != nil; }
static bool IsLoggingLong() { return (fFlags & kLogLongReceives) != 0; }
virtual void AddFilterType(UInt16 type)=0;
virtual void AddFilterExactType(UInt16 type)=0;
virtual void RemoveFilterType(UInt16 type)=0;
virtual void RemoveFilterExactType(UInt16 type)=0;
virtual void LogStatusBarChange(const char* name, const char* action)=0;
virtual void LogLongReceive(const char* keyname, const char* className, UInt32 clonePlayerID, plMessage* msg, float ms)=0;
virtual void DumpMsg(plMessage* msg, int numReceivers, int sendTime, Int32 indent)=0;
};
#endif // plDispatchLogBase_inc

View File

@ -0,0 +1,52 @@
/*==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 pnDispatchCreatable_inc
#define pnDispatchCreatable_inc
#include "../pnFactory/plCreatable.h"
#include "plDispatch.h"
REGISTER_CREATABLE( plDispatch );
#endif // pnDispatchCreatable_inc

View File

@ -0,0 +1,301 @@
/*==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 plCreatable_inc
#define plCreatable_inc
#include "hsRefCnt.h"
#include "plFactory.h"
class plCreator;
class hsStream;
class hsResMgr;
class plCreatable : public hsRefCnt
{
public:
virtual const char* ClassName() const = 0;
virtual plCreatable* GetInterface(UInt16 hClass) { return nil; }
virtual const plCreatable* GetConstInterface(UInt16 hClass) const { return nil; }
static hsBool HasBaseClass(UInt16 hBase) { return false; }
virtual UInt16 ClassIndex() const = 0;
virtual void Read(hsStream* s, hsResMgr* mgr) {}
virtual void Write(hsStream* s, hsResMgr* mgr) {}
// WriteVersion writes the current version of this creatable and ReadVersion will read in
// any previous version.
virtual void ReadVersion(hsStream* s, hsResMgr* mgr) { hsAssert(0, "ReadVersion not implemented!"); }
virtual void WriteVersion(hsStream* s, hsResMgr* mgr) { hsAssert(0, "WriteVersion not implemented!"); }
};
// Macros:
// NOTE: Comfortable use of these macros assumes the compiler is comfortable eating
// a spurious semi-colon (;) following a curly brace. If that isn't the case, they
// can easily be wrapped in something like do { original macro } while(0) or the like.
//
// Normal setup for a class:
// In public section of class declaration, insert the following two macros:
// CLASSNAME_REGISTER( myClassName );
// GETINTERFACE_ANY( myClassName, classIWasDerivedFromName );
// Then in the *Creatable.h file for that library (e.g. plSurfaceCreatable.h), add macro
// REGISTER_CREATABLE( myClassName )
// Finally, add an enum to the plCreatableIndex.h file using CLASS_INDEX(className)
// ( e.g. CLASS_INDEX(hsGMaterial) )
//
// CLASSNAME_REGISTER( plClassName ) - Sets up identification for this
// class. The exposed methods are
// static UInt16 Index() - returns the index for that class.
// virtual UInt16 ClassIndex() - returns index for this object's class.
// static plClassName* Convert(plCreatable* c) - if c exposes an interface
// as plClassName, return that, else nil. Incs the ref count of the object.
// static plClassName* ConvertNoRef(plCreatable* c) - Same as Convert(), but
// doesn't inc the ref count.
// static plClassName* Create() - returns a new object of type plClassName
// Insert into public section of class definition.
//
// Normally one of the next 3 macros should follow CLASSNAME_REGISTER
// GETINTERFACE_ANY - allows an interface to an object as plClassName if an object
// is or is derived from plClassName.
// GETINTERFACE_EXACT - allows an interface as plClassName only if the type is
// exactly of type plClassName
// GETINTERFACE_NONE - Never provide an interface as plClassName.
// Instead of using these macros, the class can provide a method
// virtual plCreatable* GetInterface(UInt16 hClass) which returns an object of
// type matching class handle hClass.
// Insert into public section of class definition (like right after CLASSNAME_REGISTER).
//
// REGISTER_CREATABLE( plClassName ) - normal creatable type, any you can instantiate.
// or
// REGISTER_NONCREATABLE( plClassName ) - can't be created either because it's pure virtual
// or just doesn't want to be creatable. It's Create member returns nil. But Convert
// may return an interface, depending on the GETINTERFACE above.
// - This line is the only exposure to the plCreator.
// This will define a Creator for class plClassName, instantiate it as a static, and register
// it with the Factory. The registration also sets the class index value in the plCreator
// subclass, as well as in the class being registered.
// Put after includes in the *Creatable.h file for the library the class belongs to..
//
// USAGE:
// There is a method of identifying an object's type. You should rarely need it,
// using Create() and Convert() instead.
// ClassIndex() the class handle is an immutable index to this class. It provides an
// instantaneous lookup. It may be stored, loaded, sent over the wire, etc.
//
// Create()
// If you know what type object you want to create at compile time, use
// <ObjectType>::Create()
// But if you have a class index at run-time (e.g. loaded from file), use
// plCreatable* plFactory::Create(hClass);
// The ultra-safe way to do this is:
// plCreatable* tmp = plFactory::Create(idx);
// plWantClassName* p = plWantClassName::Convert(tmp);
// hsRefCnt_SafeUnRef(tmp);
//
// If you have a fred interface to an object f, and want a wilma interface, use
// fred* f = fred::Create(); more likely f was passed in.
// wilma* w = wilma::Convert(f)
// NOTE that two strange things may be true here:
// 1) f != nil, w == nil
// either fred's not really derived from wilma,
// or fred doesn't like to be cast down,
// or wilma just doesn't want to expose an interface.
// 2) f != nil, w != nil, and f != w
// fred has pulled a sneaky and created a wilma to return.
// so unrelated classes can still "Convert" as one another.
//
//
////////////////////////////
// EAp - 01/10/2003
// Added macros to support multiple AUX interfaces primarily,
// but they are not limited to that. Usage example:
//
// plBeginInterfaceMap( plMyClass, plBaseClass );
// plAddInterfaceAux( plFooClass, fFooMember );
// plAddInterfaceAux( plBarClass, fBarMember );
// plAddInterface( plSomeOtherClass );
// plEndInterfaceMap();
//
#define CLASSNAME_REGISTER( plClassName ) \
public: \
virtual const char* ClassName() const { return #plClassName; } \
private: \
static UInt16 plClassName##ClassIndex; \
static void SetClassIndex(UInt16 hClass) { \
plClassName##ClassIndex = hClass; \
} \
public: \
virtual UInt16 ClassIndex() const { \
return plClassName::Index(); \
} \
static UInt16 Index() { \
return plClassName##ClassIndex; \
} \
static plClassName * Create() { \
return (plClassName*)plFactory::Create(plClassName##ClassIndex); \
} \
static plClassName * ConvertNoRef(plCreatable* c) { \
plClassName* retVal = c \
? (plClassName *)c->GetInterface(plClassName##ClassIndex) \
: nil; \
return retVal; \
} \
static const plClassName * ConvertNoRef(const plCreatable* c) { \
const plClassName* retVal = c \
? (const plClassName *)c->GetConstInterface(plClassName##ClassIndex) \
: nil; \
return retVal; \
} \
static plClassName * Convert(plCreatable* c) { \
plClassName* retVal = ConvertNoRef(c); \
hsRefCnt_SafeRef(retVal); \
return retVal; \
} \
static hsBool HasDerivedClass(UInt16 hDer) { \
return plFactory::DerivesFrom(plClassName##ClassIndex, hDer); \
} \
friend class plClassName##__Creator;
#define GETINTERFACE_ANY( plClassName, plBaseName ) \
static hsBool HasBaseClass(UInt16 hBaseClass) { \
if( hBaseClass == plClassName##ClassIndex ) \
return true; \
else \
return plBaseName::HasBaseClass(hBaseClass); \
} \
virtual plCreatable* GetInterface(UInt16 hClass) { \
if( hClass == plClassName##ClassIndex ) \
return this; \
else \
return plBaseName::GetInterface(hClass); \
} \
virtual const plCreatable* GetConstInterface(UInt16 hClass) const { \
if( hClass == plClassName##ClassIndex ) \
return this; \
else \
return plBaseName::GetConstInterface(hClass); \
}
#define GETINTERFACE_EXACT( plClassName ) \
static hsBool HasBaseClass(UInt16 hBaseClass) { \
return hBaseClass == plClassName##ClassIndex; \
} \
virtual plCreatable* GetInterface(UInt16 hClass) { \
return hClass == plClassName##ClassIndex ? this : nil; \
} \
virtual const plCreatable* GetConstInterface(UInt16 hClass) const { \
return hClass == plClassName##ClassIndex ? this : nil; \
}
#define GETINTERFACE_NONE( plClassName ) \
static hsBool HasBaseClass(UInt16 hBaseClass) { return false; } \
virtual plCreatable* GetInterface(UInt16 hClass) { \
return nil; \
} \
virtual const plCreatable* GetConstInterface(UInt16 hClass) const { \
return nil; \
}
//
// Macro for converting to base class OR a class member
//
#define GETINTERFACE_ANY_AUX( plClassName, plBaseName, plAuxClassName, plAuxClassMember ) \
static hsBool HasBaseClass(UInt16 hBaseClass) { \
if( hBaseClass == plClassName##ClassIndex ) \
return true; \
else \
return plBaseName::HasBaseClass(hBaseClass); \
} \
virtual plCreatable* GetInterface(UInt16 hClass) { \
if( hClass == plClassName##ClassIndex ) \
return this; \
else \
if (hClass == plAuxClassName::Index()) \
return &plAuxClassMember; \
else \
return plBaseName::GetInterface(hClass); \
} \
virtual const plCreatable* GetConstInterface(UInt16 hClass) const { \
if( hClass == plClassName##ClassIndex ) \
return this; \
else \
if (hClass == plAuxClassName::Index()) \
return &plAuxClassMember; \
else \
return plBaseName::GetConstInterface(hClass); \
}
#define plBeginInterfaceMap( plClassName, plBaseName ) \
static hsBool HasBaseClass(UInt16 hBaseClass) { \
if( hBaseClass == plClassName##ClassIndex ) \
return true; \
else \
return plBaseName::HasBaseClass(hBaseClass); \
} \
virtual plCreatable* GetInterface(UInt16 hClass) { \
/* NOTE: pulling const off the ptr should be ok, right? */ \
return const_cast<plCreatable*>( GetConstInterface( hClass ) ); \
} \
virtual const plCreatable* GetConstInterface(UInt16 hClass) const { \
typedef plBaseName MyBaseClass; \
if( hClass == plClassName##ClassIndex ) \
return this
#define plAddInterface( plClassName ) \
else if ( hClass == plClassName::Index() ) \
return plClassName::GetConstInterface(hClass)
#define plAddInterfaceAux( plAuxClassName, plAuxClassMember ) \
else if ( hClass == plAuxClassName::Index() ) \
return &plAuxClassMember
#define plEndInterfaceMap() \
else \
return MyBaseClass::GetConstInterface(hClass); \
}
#endif // plCreatable_inc

View File

@ -0,0 +1,187 @@
/*==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 plCreator_inc
#define plCreator_inc
#include "plClassIndexMacros.h"
#include "plCreatableIndex.h"
#include "plFactory.h"
class plCreatable;
class plCreator
{
private:
protected:
public:
plCreator() { }
virtual ~plCreator() { }
virtual plCreatable* Create() const = 0;
virtual UInt16 ClassIndex() = 0;
virtual const char* ClassName() const = 0;
virtual hsBool HasBaseClass(UInt16 hBase) = 0;
friend class plFactory;
};
#define REGISTER_CREATABLE( plClassName ) \
\
class plClassName##__Creator : public plCreator \
{ \
public: \
plClassName##__Creator() \
{ \
plFactory::Register( CLASS_INDEX_SCOPED(plClassName), this); \
plClassName::SetClassIndex(ClassIndex()); \
} \
virtual ~plClassName##__Creator() \
{ \
plFactory::UnRegister(CLASS_INDEX_SCOPED(plClassName), this); \
} \
\
virtual hsBool HasBaseClass(UInt16 hBase) { return plClassName::HasBaseClass(hBase); } \
\
virtual UInt16 ClassIndex() { return CLASS_INDEX_SCOPED(plClassName); } \
virtual const char* ClassName() const { return #plClassName; } \
\
virtual plCreatable* Create() const { return TRACKED_NEW plClassName; } \
\
}; \
static plClassName##__Creator static##plClassName##__Creator; \
UInt16 plClassName::plClassName##ClassIndex = 0; //
#define REGISTER_NONCREATABLE( plClassName ) \
\
class plClassName##__Creator : public plCreator \
{ \
public: \
plClassName##__Creator() \
{ \
plFactory::Register( CLASS_INDEX_SCOPED(plClassName), this); \
plClassName::SetClassIndex(ClassIndex()); \
} \
virtual ~plClassName##__Creator() \
{ \
plFactory::UnRegister(CLASS_INDEX_SCOPED(plClassName), this); \
} \
\
virtual hsBool HasBaseClass(UInt16 hBase) { return plClassName::HasBaseClass(hBase); } \
\
virtual UInt16 ClassIndex() { return CLASS_INDEX_SCOPED(plClassName); } \
virtual const char* ClassName() const { return #plClassName; } \
\
virtual plCreatable* Create() const { return nil; } \
\
}; \
static plClassName##__Creator static##plClassName##__Creator; \
UInt16 plClassName::plClassName##ClassIndex = 0; //
#define DECLARE_EXTERNAL_CREATABLE( plClassName ) \
\
class plClassName##__Creator : public plCreator \
{ \
public: \
plClassName##__Creator() \
{ \
} \
virtual ~plClassName##__Creator() \
{ \
plFactory::UnRegister(EXTERN_CLASS_INDEX_SCOPED(plClassName), this); \
} \
void Register() \
{ \
plFactory::Register( EXTERN_CLASS_INDEX_SCOPED(plClassName), this); \
plClassName::SetClassIndex(ClassIndex()); \
} \
void UnRegister() \
{ \
plFactory::UnRegister(EXTERN_CLASS_INDEX_SCOPED(plClassName), this); \
} \
\
virtual hsBool HasBaseClass(UInt16 hBase) { return plClassName::HasBaseClass(hBase); } \
\
virtual UInt16 ClassIndex() { return EXTERN_CLASS_INDEX_SCOPED(plClassName); } \
virtual const char* ClassName() const { return #plClassName; } \
\
virtual plCreatable* Create() const { return TRACKED_NEW plClassName; } \
\
}; \
static plClassName##__Creator static##plClassName##__Creator; \
UInt16 plClassName::plClassName##ClassIndex = 0; //
#define REGISTER_EXTERNAL_CREATABLE(plClassName) \
static##plClassName##__Creator.Register(); //
#define UNREGISTER_EXTERNAL_CREATABLE(plClassName) \
plFactory::UnRegister(EXTERN_CLASS_INDEX_SCOPED(plClassName), &static##plClassName##__Creator);
#define REGISTER_EXTERNAL_NONCREATABLE( plClassName ) \
\
class plClassName##__Creator : public plCreator \
{ \
public: \
plClassName##__Creator() \
{ \
plFactory::Register( EXTERN_CLASS_INDEX_SCOPED(plClassName), this); \
plClassName::SetClassIndex(ClassIndex()); \
} \
virtual ~plClassName##__Creator() \
{ \
plFactory::UnRegister(EXTERN_CLASS_INDEX_SCOPED(plClassName), this); \
} \
\
virtual hsBool HasBaseClass(UInt16 hBase) { return plClassName::HasBaseClass(hBase); } \
\
virtual UInt16 ClassIndex() { return EXTERN_CLASS_INDEX_SCOPED(plClassName); } \
virtual const char* ClassName() const { return #plClassName; } \
\
virtual plCreatable* Create() const { return nil; } \
\
}; \
static plClassName##__Creator static##plClassName##__Creator; \
UInt16 plClassName::plClassName##ClassIndex = 0; //
#endif // plCreator_inc

View File

@ -0,0 +1,357 @@
/*==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==*/
#define PLFACTORY_PRIVATE
#include "hsTypes.h"
#include "plFactory.h"
#include "hsStream.h"
#include "plCreatable.h"
#include "plCreator.h"
#include "hsUtils.h"
// For class names
#include "../NucleusLib/inc/plCreatableStrings.h"
static plFactory* theFactory = nil;
plFactory::plFactory()
{
fCreators.SetCountAndZero(plCreatableIndex::plNumClassIndices);
}
plFactory::~plFactory()
{
}
hsBool plFactory::ICreateTheFactory()
{
if( theFactory )
return true;
theFactory = TRACKED_NEW plFactory;
return theFactory != nil;
}
UInt16 plFactory::IGetNumClasses()
{
return plCreatableIndex::plNumClassIndices;
}
void plFactory::IForceShutdown()
{
int i;
for( i = 0; i < fCreators.GetCount(); i++ )
{
if( fCreators[i] )
{
hsRefCnt_SafeUnRef(this);
fCreators[i] = nil;
}
}
}
void plFactory::IShutdown()
{
delete theFactory;
theFactory = nil;
}
UInt16 plFactory::IRegister(UInt16 hClass, plCreator* worker)
{
delete fCreators[hClass];
fCreators[hClass] = worker;
return hClass;
}
//
// return true if creator exists
//
bool plFactory::CanCreate(UInt16 hClass)
{
if( hClass & 0x8000 ) // nil creatable
return false;
if( !theFactory && !ICreateTheFactory() ) // no factory
return false;
if( hClass >= theFactory->IGetNumClasses() ) // invalid index
return false;
return ( theFactory->fCreators[ hClass ] != nil ); // check creator
}
plCreatable* plFactory::ICreate(UInt16 hClass)
{
if (CanCreate(hClass))
{
return fCreators[hClass]->Create();
}
if (!(hClass & 0x8000))
{
hsAssert( false, "Invalid class index or nil creator : plFactory::Create()" );
}
return nil;
}
void plFactory::UnRegister(UInt16 hClass, plCreator* worker)
{
if( theFactory )
{
theFactory->IUnRegister(hClass);
hsRefCnt_SafeUnRef(theFactory);
if( theFactory->RefCnt() < 2 )
IShutdown();
}
}
void plFactory::IUnRegister(UInt16 hClass)
{
fCreators[hClass] = nil;
}
UInt16 plFactory::Register(UInt16 hClass, plCreator* worker)
{
if( !theFactory && !ICreateTheFactory() )
return nil;
hsRefCnt_SafeRef(theFactory);
return theFactory->IRegister(hClass, worker);
}
plCreatable* plFactory::Create(UInt16 hClass)
{
if( !theFactory && !ICreateTheFactory() )
return nil;
return theFactory->ICreate(hClass);
}
UInt16 plFactory::GetNumClasses()
{
if( !theFactory && !ICreateTheFactory() )
return 0;
return theFactory->IGetNumClasses();
}
hsBool plFactory::IDerivesFrom(UInt16 hBase, UInt16 hDer)
{
if( hDer >= fCreators.GetCount() )
return false;
return fCreators[hDer] ? fCreators[hDer]->HasBaseClass(hBase) : false;
}
hsBool plFactory::DerivesFrom(UInt16 hBase, UInt16 hDer)
{
if( !theFactory && !ICreateTheFactory() )
return 0;
return theFactory->IDerivesFrom(hBase, hDer);
}
// slow lookup for things like console
UInt16 plFactory::FindClassIndex(const char* className)
{
int numClasses=GetNumClasses();
if (className && theFactory)
{
int i;
for( i = 0; i < theFactory->fCreators.GetCount(); i++ )
{
if( theFactory->fCreators[i] && !_stricmp(className, theFactory->fCreators[i]->ClassName()) )
{
return theFactory->fCreators[i]->ClassIndex();
}
}
}
return numClasses; // err
}
hsBool plFactory::IIsValidClassIndex(UInt16 hClass)
{
return ( hClass < fCreators.GetCount() );
}
hsBool plFactory::IsValidClassIndex(UInt16 hClass)
{
return theFactory->IIsValidClassIndex(hClass);
}
void plFactory::SetTheFactory(plFactory* fac)
{
// There are four cases here.
// 1) Our factory is nil, and we're being given one to use
// Just take it and ref it.
// 2) Our factory is non-nil, and we're being given on to use
// Ours is bogus, pitch it and use the new one.
// 3) Our factory is non-nil, and we're being given a nil one
// Means we're being shut down. Unref the old one. If
// the refcnt drops to one, we're the last one out, so
// go ahead and delete it.
// 4) Our factory is nil and the new one is nil
// Shouldn't happen, but if it does, just ignore it.
if( !theFactory && fac )
{
hsRefCnt_SafeAssign(theFactory, fac);
}
else if( theFactory && fac )
{
theFactory->IForceShutdown();
hsRefCnt_SafeAssign(theFactory, fac);
}
else if( theFactory && !fac )
{
hsRefCnt_SafeUnRef(theFactory);
if( theFactory->RefCnt() < 2 )
delete theFactory;
theFactory = nil;
}
}
plFactory* plFactory::GetTheFactory()
{
if( !theFactory && !ICreateTheFactory() )
return nil;
return theFactory;
}
// For my own nefarious purposes... hsStatusMessage plCreatableIndex
const char *plFactory::GetNameOfClass(UInt16 type)
{
if( type < GetNumClasses() )
{
if( theFactory->fCreators[ type ] )
return theFactory->fCreators[ type ]->ClassName();
static int keyedStringsSize = sizeof(plCreatableStrings::fKeyedStrings)/4;
// If we don't have a creator yet, try falling back on plCreatableStrings
if( type < KEYED_OBJ_DELINEATOR && type<keyedStringsSize)
return plCreatableStrings::fKeyedStrings[ type ];
if (type < plCreatableIndex::kDatabaseStructIndexesStart)
{
static int nonKeyedStringsSize = sizeof(plCreatableStrings::fNonKeyedStrings)/4;
int idx=type - KEYED_OBJ_DELINEATOR;
if (idx<nonKeyedStringsSize)
return plCreatableStrings::fNonKeyedStrings[ idx ];
}
static int nonKeyedPostDBStringsSize = sizeof(plCreatableStrings::fNonKeyedPostDBStrings)/4;
int idx=type - plCreatableIndex::kDatabaseStructIndexesEnd -1;
if (idx<nonKeyedPostDBStringsSize)
return plCreatableStrings::fNonKeyedPostDBStrings[ idx ];
}
hsAssert(type < GetNumClasses() || type==0xffff,"InValid type");
return nil;
}
#ifdef HS_DEBUGGING
/*
**
** Function Name: Validate
** Input(s): Void
** Output(s): Void
** Function Description: This function examines all the Workers in the Factory and compares their Factory
** index to the Enums found in plCreatableIndex. If they are Keyed objects, and
** larger than 512 on the Factory index, or non-Keyed objects with a Factory
** index of less than 512, exit with an Error Message. Otherwise continue through
** the iteration of Factory Indices.
**
**
*/
void plFactory::IValidate(UInt16 keyIndex)
{
int FactoryIndex = GetNumClasses();
hsBool bogus = false;
for(int iter=0; iter < FactoryIndex; iter++)
{
if (IDerivesFrom(keyIndex, iter))
{
if(iter >= KEYED_OBJ_DELINEATOR && theFactory->fCreators[iter])
{
char Buffer[512];
sprintf(Buffer, "Object %s is a hsKeyedObject, Must appear before 'KEYED_OBJ_DELINEATOR' in plCreatableIndex.h\n",GetNameOfClass(iter));
hsStatusMessage(Buffer);
bogus = true;
}
}
else
{
if(iter < KEYED_OBJ_DELINEATOR && theFactory->fCreators[iter])
{
char Buffer[512];
sprintf(Buffer, "Object %s is NOT a hsKeyedObject, Must appear after 'KEYED_OBJ_DELINEATOR' in plCreatableIndex.h\n",GetNameOfClass(iter));
hsStatusMessage(Buffer);
bogus = true;
}
}
}
hsAssert(!bogus,"The class(s) you just added to plCreatableIndex.h in wrong spot, see output window");
}
void plFactory::Validate(UInt16 keyIndex)
{
theFactory->IValidate(keyIndex);
}
#endif

View File

@ -0,0 +1,112 @@
/*==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 plFactory_inc
#define plFactory_inc
#ifdef PLFACTORY_PRIVATE
#include "hsTemplates.h"
#endif
#include "hsRefCnt.h"
#include "hsTypes.h"
class plCreator;
class plCreatable;
class hsStream;
class hsResMgr;
class plFactory : public hsRefCnt
{
#ifdef PLFACTORY_PRIVATE
private:
hsTArray<plCreator*> fCreators;
void IForceShutdown();
void IUnRegister(UInt16 hClass);
UInt16 IRegister(UInt16 hClass, plCreator* worker);
hsBool IIsEmpty();
UInt16 IGetNumClasses();
plCreatable* ICreate(UInt16 hClass);
hsBool IDerivesFrom(UInt16 hBase, UInt16 hDer);
hsBool IIsValidClassIndex(UInt16 hClass);
static hsBool ICreateTheFactory();
static void IShutdown();
plFactory();
~plFactory();
#endif
public:
// Don't use this unless you're initializing a DLL
friend class plClient;
static plFactory* GetTheFactory();
static UInt16 Register(UInt16 hClass, plCreator* worker); // returns hClass
static void UnRegister(UInt16 hClass, plCreator* worker);
static bool CanCreate(UInt16 hClass); // return true if creator exists. doesn't assert
static plCreatable* Create(UInt16 hClass);
static hsBool DerivesFrom(UInt16 hBase, UInt16 hDer);
static UInt16 GetNumClasses();
static UInt16 FindClassIndex(const char* className); // slow lookup for things like console
static hsBool IsValidClassIndex(UInt16 hClass);
// Don't call this unless you're a DLL being initialized.
static void SetTheFactory(plFactory* fac);
static const char *GetNameOfClass(UInt16 type);
#ifdef HS_DEBUGGING
void IValidate(UInt16 keyIndex);
static void Validate(UInt16 keyIndex);
#endif
};
#endif // plFactory_inc

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/BlueSpiral/pnGmBlueSpiral.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,138 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/BlueSpiral/pnGmBlueSpiral.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_BLUESPIRAL_PNGMBLUESPIRAL_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/BlueSpiral/pnGmBlueSpiral.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_BLUESPIRAL_PNGMBLUESPIRAL_H
/*****************************************************************************
*
* BlueSpiral
*
***/
enum EBlueSpiralInitResult {
kBlueSpiralInitSuccess,
kBlueSpiralInitError,
kNumBlueSpiralInitResults
};
//============================================================================
// Game type id
//============================================================================
const Uuid kGameTypeId_BlueSpiral = Uuid(L"5ff98165-913e-4fd1-a2c2-9c7f31be2cc8");
//============================================================================
// Network message ids
//============================================================================
// Cli2Srv message ids
enum {
kCli2Srv_BlueSpiral_StartGame = kCli2Srv_NumGameMsgIds,
kCli2Srv_BlueSpiral_HitCloth,
};
// Srv2Cli message ids
enum {
kSrv2Cli_BlueSpiral_ClothOrder = kSrv2Cli_NumGameMsgIds,
kSrv2Cli_BlueSpiral_SuccessfulHit,
kSrv2Cli_BlueSpiral_GameWon,
kSrv2Cli_BlueSpiral_GameOver, // sent on time out and incorrect entry
kSrv2Cli_BlueSpiral_GameStarted,
};
//============================================================================
// Begin networked data scructures
#include <PshPack1.h>
//============================================================================
//========================================================================
// Message parameters
//========================================================================
struct BlueSpiral_CreateParam {
// empty
};
//========================================================================
// Tic-Tac-Toe message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_BlueSpiral_StartGame : GameMsgHeader {
// empty
};
struct Cli2Srv_BlueSpiral_HitCloth : GameMsgHeader {
byte clothNum; // the cloth we hit, 0..6
};
// Srv2Cli
struct Srv2Cli_BlueSpiral_ClothOrder : GameMsgHeader {
byte order[7]; // each value is the cloth to hit, 0..6, the order is the order in the array
};
struct Srv2Cli_BlueSpiral_SuccessfulHit : GameMsgHeader {
// empty
};
struct Srv2Cli_BlueSpiral_GameWon : GameMsgHeader {
// empty
};
struct Srv2Cli_BlueSpiral_GameOver : GameMsgHeader {
// empty
};
struct Srv2Cli_BlueSpiral_GameStarted : GameMsgHeader {
bool startSpin; // if true, start spinning the door thingy
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/ClimbingWall/pnGmClimbingWall.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,184 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/ClimbingWall/pnGmClimbingWall.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_CLIMBINGWALL_PNGMCLIMBINGWALL_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/ClimbingWall/pnGmClimbingWall.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_CLIMBINGWALL_PNGMCLIMBINGWALL_H
/*****************************************************************************
*
* Climbing Wall
*
***/
enum EClimbingWallInitResult {
kClimbingWallInitSuccess,
kClimbingWallInitError,
kNumClimbingWallInitResults
};
enum EClimbingWallReadyType {
kClimbingWallReadyNumBlockers,
kClimbingWallReadyBlockers,
};
const unsigned kClimbingWallMaxBlockers = 20; // TODO: Adjust this to the right size
const int kClimbingWallNoBlocker = -1; // the value of a slot in the blocker array when no blocker is in that slot
//============================================================================
// Game type id
//============================================================================
const Uuid kGameTypeId_ClimbingWall = Uuid(L"6224cdf4-3556-4740-b7cd-d637562d07be");
//============================================================================
// Network message ids
//============================================================================
// Cli2Srv message ids
enum {
kCli2Srv_ClimbingWall_ChangeNumBlockers = kCli2Srv_NumGameMsgIds,
kCli2Srv_ClimbingWall_Ready,
kCli2Srv_ClimbingWall_BlockerChanged,
kCli2Srv_ClimbingWall_Reset,
kCli2Srv_ClimbingWall_PlayerEntered,
kCli2Srv_ClimbingWall_FinishedGame,
kCli2Srv_ClimbingWall_Panic,
};
// Srv2Cli message ids
enum {
kSrv2Cli_ClimbingWall_NumBlockersChanged = kSrv2Cli_NumGameMsgIds,
kSrv2Cli_ClimbingWall_Ready,
kSrv2Cli_ClimbingWall_BlockersChanged,
kSrv2Cli_ClimbingWall_PlayerEntered,
kSrv2Cli_ClimbingWall_SuitMachineLocked,
kSrv2Cli_ClimbingWall_GameOver,
};
//============================================================================
// Begin networked data structures
#include <PshPack1.h>
//============================================================================
//========================================================================
// Message parameters
//========================================================================
struct ClimbingWall_CreateParam {
// no params
};
//========================================================================
// Climbing Wall message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_ClimbingWall_ChangeNumBlockers : GameMsgHeader {
int amountToAdjust; // + or - value to adjust the number of blockers by
};
struct Cli2Srv_ClimbingWall_Ready : GameMsgHeader {
byte readyType; // the type of ready this message represents (EClimbingWallReadyType)
byte teamNumber; // the team that you are saying is ready (1 or 2)
};
struct Cli2Srv_ClimbingWall_BlockerChanged : GameMsgHeader {
byte teamNumber; // the team that is adjusting their blockers
byte blockerNumber; // the number of the blocker that was added/removed
bool added; // was the blocker added, or removed?
};
struct Cli2Srv_ClimbingWall_Reset : GameMsgHeader {
// <no data>
};
struct Cli2Srv_ClimbingWall_PlayerEntered : GameMsgHeader {
byte teamNumber; // the team this player is playing for
};
struct Cli2Srv_ClimbingWall_FinishedGame : GameMsgHeader {
// <no data>
};
struct Cli2Srv_ClimbingWall_Panic : GameMsgHeader {
// <no data>
};
// Srv2Cli
struct Srv2Cli_ClimbingWall_NumBlockersChanged : GameMsgHeader {
byte newBlockerCount; // the new number of blocker we are playing with
bool localOnly; // only adjust your local display, don't net prop
};
struct Srv2Cli_ClimbingWall_Ready : GameMsgHeader {
byte readyType; // the type of ready this message represents (EClimbingWallReadyType)
bool team1Ready;
bool team2Ready;
bool localOnly; // only adjust your local display, don't net prop
};
struct Srv2Cli_ClimbingWall_BlockersChanged : GameMsgHeader {
byte teamNumber; // the team this set of blockers is for
int blockersSet[kClimbingWallMaxBlockers]; // which blockers are set
bool localOnly; // only adjust your local display, don't net prop
};
struct Srv2Cli_ClimbingWall_PlayerEntered : GameMsgHeader {
// <no data>
};
struct Srv2Cli_ClimbingWall_SuitMachineLocked : GameMsgHeader {
bool team1MachineLocked;
bool team2MachineLocked;
bool localOnly; // only adjust your local display, don't net prop
};
struct Srv2Cli_ClimbingWall_GameOver : GameMsgHeader {
byte teamWon; // which team won the game
int team1Blockers[kClimbingWallMaxBlockers];
int team2Blockers[kClimbingWallMaxBlockers];
bool localOnly; // only adjust your local display, don't net prop
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/Heek/pnGmHeek.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,203 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/Heek/pnGmHeek.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_HEEK_PNGMHEEK_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/Heek/pnGmHeek.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_HEEK_PNGMHEEK_H
/*****************************************************************************
*
* Heek
*
***/
enum EHeekInitResult {
kHeekInitSuccess,
kHeekInitError,
kNumHeekInitResults
};
enum EHeekChoice {
kHeekRock,
kHeekPaper,
kHeekScissors,
kNumHeekChoices
};
enum EHeekSeqFinished {
kHeekCountdownSeq,
kHeekChoiceAnimSeq,
kHeekGameWinAnimSeq,
kNumHeekSeq
};
enum EHeekLightState {
kHeekLightOn,
kHeekLightOff,
kHeekLightFlash,
kNumHeekLightStates
};
enum EHeekCountdownState {
kHeekCountdownStart,
kHeekCountdownStop,
kHeekCountdownIdle,
kNumHeekCountdownStates
};
//============================================================================
// Game type id
//============================================================================
const Uuid kGameTypeId_Heek = Uuid(L"9d83c2e2-7835-4477-9aaa-22254c59a753");
//============================================================================
// Network message ids
//============================================================================
// Cli2Srv message ids
enum {
kCli2Srv_Heek_PlayGame = kCli2Srv_NumGameMsgIds, // Sent when a player wants to join in the game (instead of observing)
kCli2Srv_Heek_LeaveGame, // Sent when a player is done playing (and starts observing)
kCli2Srv_Heek_Choose, // Sent when a player choses a move
kCli2Srv_Heek_SeqFinished, // Sent when a client-side animation ends
};
// Srv2Cli message ids
enum {
kSrv2Cli_Heek_PlayGame = kSrv2Cli_NumGameMsgIds, // Sent when the server allows or disallows a player to play
kSrv2Cli_Heek_Goodbye, // Sent when the server confirms the player leaving
kSrv2Cli_Heek_Welcome, // Sent to everyone when a new player joins
kSrv2Cli_Heek_Drop, // Sent when the admin needs to reset a position
kSrv2Cli_Heek_Setup, // Sent on link-in so observers see the correct game state (fast-forwarded)
kSrv2Cli_Heek_LightState, // Sent to a player when a light he owns changes state (animated)
kSrv2Cli_Heek_InterfaceState, // Sent to a player when his buttons change state (animated)
kSrv2Cli_Heek_CountdownState, // Sent to the admin to adjust the countdown state
kSrv2Cli_Heek_WinLose, // Sent to a player when he wins or loses a hand
kSrv2Cli_Heek_GameWin, // Sent to the admin when a game is won
kSrv2Cli_Heek_PointUpdate, // Sent to a player when their points change
};
//============================================================================
// Begin networked data structures
#include <PshPack1.h>
//============================================================================
//========================================================================
// Message parameters
//========================================================================
// No creation parameters
//========================================================================
// Heek message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_Heek_PlayGame : GameMsgHeader {
byte position; // 0...4
dword points;
wchar name[256];
};
struct Cli2Srv_Heek_LeaveGame : GameMsgHeader {
// no extra data
};
struct Cli2Srv_Heek_Choose : GameMsgHeader {
byte choice; // kHeekRock...kHeekScissors
};
struct Cli2Srv_Heek_SeqFinished : GameMsgHeader {
byte seqFinished; // kHeekCountdownSeq...kHeekGameWinSeq
};
// Srv2Cli
struct Srv2Cli_Heek_PlayGame : GameMsgHeader {
bool isPlaying;
bool isSinglePlayer;
bool enableButtons;
};
struct Srv2Cli_Heek_Goodbye : GameMsgHeader {
// no extra data
};
struct Srv2Cli_Heek_Welcome : GameMsgHeader {
dword points;
dword rank;
wchar name[256];
};
struct Srv2Cli_Heek_Drop : GameMsgHeader {
byte position; // 0...4
};
struct Srv2Cli_Heek_Setup : GameMsgHeader {
byte position; // 0...4
bool buttonState;
bool lightOn[6];
};
struct Srv2Cli_Heek_LightState : GameMsgHeader {
byte lightNum;
byte state; // kHeekLightOn...kHeekLightFlash
};
struct Srv2Cli_Heek_InterfaceState : GameMsgHeader {
bool buttonsEnabled;
};
struct Srv2Cli_Heek_CountdownState : GameMsgHeader {
byte state; // kHeekCountdownStart...kHeekCountdownIdle
};
struct Srv2Cli_Heek_WinLose : GameMsgHeader {
bool win;
byte choice; // kHeekRock...kHeekScissors
};
struct Srv2Cli_Heek_GameWin : GameMsgHeader {
byte choice; // kHeekRock...kHeekScissors
};
struct Srv2Cli_Heek_PointUpdate : GameMsgHeader {
bool displayUpdate;
dword points;
dword rank;
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================

View File

@ -0,0 +1,51 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGamesCommon/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMESCOMMON_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGamesCommon/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMESCOMMON_INTERN_H

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/Marker/pnGmMarker.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,229 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/Marker/pnGmMarker.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_MARKER_PNGMMARKER_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/Marker/pnGmMarker.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_MARKER_PNGMMARKER_H
/*****************************************************************************
*
* Marker
*
***/
enum EMarkerInitResult {
kMarkerInitSuccess,
kMarkerInitError,
kNumMarkerInitResults
};
enum EMarkerGameType {
kMarkerGameQuest,
kMarkerGameCGZ, // this is a quest game, but differentiating between the two on the client side makes some things easier
kMarkerGameCapture,
kMarkerGameCaptureAndHold,
kNumMarkerGameTypes
};
//============================================================================
// Game type id
//============================================================================
const Uuid kGameTypeId_Marker = Uuid(L"000b2c39-0319-4be1-b06c-7a105b160fcf");
//============================================================================
// Network message ids
//============================================================================
// Cli2Srv message ids
enum {
kCli2Srv_Marker_StartGame = kCli2Srv_NumGameMsgIds,
kCli2Srv_Marker_PauseGame,
kCli2Srv_Marker_ResetGame,
kCli2Srv_Marker_ChangeGameName,
kCli2Srv_Marker_ChangeTimeLimit,
kCli2Srv_Marker_DeleteGame,
kCli2Srv_Marker_AddMarker,
kCli2Srv_Marker_DeleteMarker,
kCli2Srv_Marker_ChangeMarkerName,
kCli2Srv_Marker_CaptureMarker,
};
// Srv2Cli message ids
enum {
kSrv2Cli_Marker_TemplateCreated = kSrv2Cli_NumGameMsgIds,
kSrv2Cli_Marker_TeamAssigned,
kSrv2Cli_Marker_GameType,
kSrv2Cli_Marker_GameStarted,
kSrv2Cli_Marker_GamePaused,
kSrv2Cli_Marker_GameReset,
kSrv2Cli_Marker_GameOver,
kSrv2Cli_Marker_GameNameChanged,
kSrv2Cli_Marker_TimeLimitChanged,
kSrv2Cli_Marker_GameDeleted,
kSrv2Cli_Marker_MarkerAdded,
kSrv2Cli_Marker_MarkerDeleted,
kSrv2Cli_Marker_MarkerNameChanged,
kSrv2Cli_Marker_MarkerCaptured,
};
//============================================================================
// Begin networked data structures
#include <PshPack1.h>
//============================================================================
//========================================================================
// Message parameters
//========================================================================
struct Marker_CreateParam {
byte gameType; // member of EMarkerGameType
wchar gameName[256];
dword timeLimit;
wchar templateID[80]; // empty if creating a new game, guid if a quest game and we need to grab the data from the state server
};
//========================================================================
// Tic-Tac-Toe message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_Marker_StartGame : GameMsgHeader {
// nothing
};
struct Cli2Srv_Marker_PauseGame : GameMsgHeader {
// nothing
};
struct Cli2Srv_Marker_ResetGame : GameMsgHeader {
// nothing
};
struct Cli2Srv_Marker_ChangeGameName : GameMsgHeader {
wchar gameName[256];
};
struct Cli2Srv_Marker_ChangeTimeLimit : GameMsgHeader {
dword timeLimit;
};
struct Cli2Srv_Marker_DeleteGame : GameMsgHeader {
// nothing
};
struct Cli2Srv_Marker_AddMarker : GameMsgHeader {
double x;
double y;
double z;
wchar name[256];
wchar age[80];
};
struct Cli2Srv_Marker_DeleteMarker : GameMsgHeader {
dword markerID;
};
struct Cli2Srv_Marker_ChangeMarkerName : GameMsgHeader {
dword markerID;
wchar markerName[256];
};
struct Cli2Srv_Marker_CaptureMarker : GameMsgHeader {
dword markerID;
};
// Srv2Cli
struct Srv2Cli_Marker_TemplateCreated : GameMsgHeader {
wchar templateID[80];
};
struct Srv2Cli_Marker_TeamAssigned : GameMsgHeader {
byte teamNumber; // 1 or 2
};
struct Srv2Cli_Marker_GameType : GameMsgHeader {
byte gameType; // member of EMarkerGameType
};
struct Srv2Cli_Marker_GameStarted : GameMsgHeader {
// nothing
};
struct Srv2Cli_Marker_GamePaused : GameMsgHeader {
dword timeLeft; // 0 if quest game, since they don't have a timer
};
struct Srv2Cli_Marker_GameReset : GameMsgHeader {
// nothing
};
struct Srv2Cli_Marker_GameOver : GameMsgHeader {
// nothing
};
struct Srv2Cli_Marker_GameNameChanged : GameMsgHeader {
wchar newName[256];
};
struct Srv2Cli_Marker_TimeLimitChanged : GameMsgHeader {
dword newTimeLimit;
};
struct Srv2Cli_Marker_GameDeleted : GameMsgHeader {
bool failed; // did the delete fail?
};
struct Srv2Cli_Marker_MarkerAdded : GameMsgHeader {
double x;
double y;
double z;
dword markerID;
wchar name[256];
wchar age[80];
};
struct Srv2Cli_Marker_MarkerDeleted : GameMsgHeader {
dword markerID;
};
struct Srv2Cli_Marker_MarkerNameChanged : GameMsgHeader {
dword markerID;
wchar newName[256];
};
struct Srv2Cli_Marker_MarkerCaptured : GameMsgHeader {
dword markerID;
byte team; // 0 for no team, or for quest games
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================

View File

@ -0,0 +1,59 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGamesCommon/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMESCOMMON_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGamesCommon/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMESCOMMON_PCH_H
#include "../pnUtils/pnUtils.h"
#include "../pnNetBase/pnNetBase.h"
#include "../pnProduct/pnProduct.h"
#include "pnGameMgr.h"
#include "Intern.h"

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/TicTacToe/pnGmTicTacToe.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,136 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/TicTacToe/pnGmTicTacToe.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_TICTACTOE_PNGMTICTACTOE_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/TicTacToe/pnGmTicTacToe.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_TICTACTOE_PNGMTICTACTOE_H
/*****************************************************************************
*
* Tic-Tac-Toe
*
***/
enum ETTTInitResult {
kTTTInitSuccess,
kTTTInitError,
kNumTTTInitResults
};
enum ETTTGameResult {
kTTTGameResultWinner, // there was a winning player
kTTTGameResultTied, // players tied (a "cat's game")
kTTTGameResultGave, // other player left the game
kTTTGameResultError, // something bad happened on the server
kNumTTTGameResults
};
//============================================================================
// Game type id
//============================================================================
const Uuid kGameTypeId_TicTacToe = Uuid(L"a7236529-11d8-4758-9368-59cb43445a83");
//============================================================================
// Network message ids
//============================================================================
// Cli2Srv message ids
enum {
kCli2Srv_TTT_MakeMove = kCli2Srv_NumGameMsgIds,
};
// Srv2Cli message ids
enum {
kSrv2Cli_TTT_GameStarted = kSrv2Cli_NumGameMsgIds,
kSrv2Cli_TTT_GameOver,
kSrv2Cli_TTT_MoveMade,
};
//============================================================================
// Begin networked data scructures
#include <PshPack1.h>
//============================================================================
//========================================================================
// Message parameters
//========================================================================
struct TTT_CreateParam {
byte playerCount; // 1 or 2
};
//========================================================================
// Tic-Tac-Toe message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_TTT_MakeMove : GameMsgHeader {
byte row; // 1..3
byte col; // 1..3
};
// Srv2Cli
struct Srv2Cli_TTT_GameStarted : GameMsgHeader {
bool yourTurn; // randomly selected first player
};
struct Srv2Cli_TTT_GameOver : GameMsgHeader {
ETTTGameResult result;
dword winnerId;
};
struct Srv2Cli_TTT_MoveMade : GameMsgHeader {
dword playerId;
byte row; // 1..3
byte col; // 1..3
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/VarSync/pnGmVarSync.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,157 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/VarSync/pnGmVarSync.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_VARSYNC_PNGMVARSYNC_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/VarSync/pnGmVarSync.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_VARSYNC_PNGMVARSYNC_H
/*****************************************************************************
*
* Var Sync
*
***/
enum EVarSyncInitResult {
kVarSyncInitSuccess,
kVarSyncInitError,
kNumVarSyncInitResults
};
//============================================================================
// Game type id
//============================================================================
const Uuid kGameTypeId_VarSync = Uuid(L"475c2e9b-a245-4106-a047-9b25d41ff333");
//============================================================================
// Network message ids
//============================================================================
// Cli2Srv message ids
enum {
kCli2Srv_VarSync_SetStringVar = kCli2Srv_NumGameMsgIds,
kCli2Srv_VarSync_SetNumericVar,
kCli2Srv_VarSync_RequestAllVars,
kCli2Srv_VarSync_CreateStringVar,
kCli2Srv_VarSync_CreateNumericVar,
};
// Srv2Cli message ids
enum {
kSrv2Cli_VarSync_StringVarChanged = kSrv2Cli_NumGameMsgIds,
kSrv2Cli_VarSync_NumericVarChanged,
kSrv2Cli_VarSync_AllVarsSent,
kSrv2Cli_VarSync_StringVarCreated,
kSrv2Cli_VarSync_NumericVarCreated,
};
//============================================================================
// Begin networked data structures
#include <PshPack1.h>
//============================================================================
//========================================================================
// Message parameters
//========================================================================
struct VarSync_CreateParam {
};
//========================================================================
// VarSync message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_VarSync_SetStringVar : GameMsgHeader {
unsigned long varID;
wchar varValue[256];
};
struct Cli2Srv_VarSync_SetNumericVar : GameMsgHeader {
unsigned long varID;
double varValue;
};
struct Cli2Srv_VarSync_RequestAllVars : GameMsgHeader {
};
struct Cli2Srv_VarSync_CreateStringVar : GameMsgHeader {
wchar varName[256];
wchar varValue[256];
};
struct Cli2Srv_VarSync_CreateNumericVar : GameMsgHeader {
wchar varName[256];
double varValue;
};
// Srv2Cli
struct Srv2Cli_VarSync_StringVarChanged : GameMsgHeader {
unsigned long varID;
wchar varValue[256];
};
struct Srv2Cli_VarSync_NumericVarChanged : GameMsgHeader {
unsigned long varID;
double varValue;
};
struct Srv2Cli_VarSync_AllVarsSent : GameMsgHeader {
};
struct Srv2Cli_VarSync_StringVarCreated : GameMsgHeader {
wchar varName[256];
unsigned long varID;
wchar varValue[256];
};
struct Srv2Cli_VarSync_NumericVarCreated : GameMsgHeader {
wchar varName[256];
unsigned long varID;
double varValue;
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================

View File

@ -0,0 +1,49 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/pnGameMgr.cpp
*
***/
#include "Pch.h"
#pragma hdrstop

View File

@ -0,0 +1,268 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnGameMgr/pnGameMgr.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_PNGAMEMGR_H
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_PNGAMEMGR_H
#include "../pnUtils/pnUtils.h"
#include "../pnNetBase/pnNetBase.h"
#include "../pnAsyncCore/pnAsyncCore.h"
#include "../pnNetCli/pnNetCli.h"
#include "../pnProduct/pnProduct.h"
#include "../pnKeyedObject/plKey.h"
#include "hsGeometry3.h"
/*****************************************************************************
*
* GameMgr
*
***/
const unsigned kGameMgrGlobalGameIdFlag = !((unsigned)-1 - 1); // 0x10000000
//============================================================================
// EGameJoinError
//============================================================================
enum EGameJoinError {
kGameJoinSuccess,
kGameJoinErrNotExist,
kGameJoinErrInitFailed,
kGameJoinErrGameStarted,
kGameJoinErrGameOver,
kGameJoinErrMaxPlayers,
kGameJoinErrAlreadyJoined,
kGameJoinErrNoInvite,
kNumGameJoinErrors
};
//============================================================================
// EGameInviteError
//============================================================================
enum EGameInviteError {
kGameInviteSuccess,
kGameInviteErrNotOwner,
kGameInviteErrAlreadyInvited,
kGameInviteErrAlreadyJoined,
kGameInviteErrGameStarted,
kGameInviteErrGameOver,
kGameInviteErrGameFull,
kGameInviteErrNoJoin, // GameSrv reports the player may not join right now
kNumGameInviteErrors
};
//============================================================================
// Game create/join options
//============================================================================
/*
If set : Anyone may join; no invite necessary.
Not set : Only players with invites may join.
*/
const unsigned kGameCreatePublic = 1<<0;
/*
If set : Anyone may invite others to play.
Not set : Only the game owner may send invites.
*/
const unsigned kGameCreateOpen = 1<<1;
/*
If set : Player joins or creates the "common" instance of the game. In
this case, the 'newGameId' field is not meaningful. If the
common instance doesn't exist, it'll be created on-the-fly and
the player will receive a GameCreated message as well as the
normal GameJoined. This allows the game to be initialized once
when first instanced.
Not set : A game with the specified gameId must exist on the server.
Depending on the options set during the game's creation, the
player may need to have been sent an invite. Also, the game may
not be in a state where it allows new players to join. Player
receives a GameJoined reply in any case. Inspect the 'result'
field to see whether the join was successful.
*/
const unsigned kGameJoinCommon = 1<<2;
/*
*/
const unsigned kGameJoinObserver = 1<<3;
//============================================================================
// GameMgr Network message ids
//============================================================================
enum {
kCli2Srv_GameMgr_CreateGame,
kCli2Srv_GameMgr_JoinGame,
};
enum {
kSrv2Cli_GameMgr_GameInstance, // Internal, not sent out in pfGameMgrMsg
kSrv2Cli_GameMgr_InviteReceived,
kSrv2Cli_GameMgr_InviteRevoked,
};
//============================================================================
// GameCli/Srv Network message ids
//============================================================================
enum {
kCli2Srv_Game_LeaveGame,
kCli2Srv_Game_Invite,
kCli2Srv_Game_Uninvite,
// Cli2Srv msgIds for specific games must begin with this value. See TicTacToe for example
kCli2Srv_NumGameMsgIds
};
enum {
kSrv2Cli_Game_PlayerJoined,
kSrv2Cli_Game_PlayerLeft,
kSrv2Cli_Game_InviteFailed,
kSrv2Cli_Game_OwnerChange,
// Srv2Cli msgIds for specific games must begin with this value. See TicTacToe for example
kSrv2Cli_NumGameMsgIds
};
//============================================================================
// Begin networked data scructures
#include <PshPack1.h>
//============================================================================
struct GameMsgHeader {
dword messageId;
dword transId;
dword recvGameId; // 0 --> GameMgr, non-zero --> GameSrv
dword messageBytes;
};
//========================================================================
// GameMgr message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_GameMgr_CreateGame : GameMsgHeader {
Uuid gameTypeId;
dword createOptions;
dword createDataBytes;
byte createData[1]; // [createDataBytes]
};
struct Cli2Srv_GameMgr_JoinGame : GameMsgHeader {
// Field ordering here is vitally important, see pfGameMgr::JoinGame for explanation
dword newGameId;
dword createOptions;
Uuid gameTypeId;
dword createDataBytes;
byte createData[1]; // [createDataBytes]
};
// Srv2Cli
struct Srv2Cli_GameMgr_GameInstance : GameMsgHeader {
EGameJoinError result;
dword ownerId;
Uuid gameTypeId;
dword newGameId;
};
struct Srv2Cli_GameMgr_InviteReceived : GameMsgHeader {
dword inviterId;
Uuid gameTypeId;
dword newGameId;
};
struct Srv2Cli_GameMgr_InviteRevoked : GameMsgHeader {
dword inviterId;
Uuid gameTypeId;
dword newGameId;
};
//========================================================================
// GameCli/Srv message structures
//========================================================================
// Cli2Srv
struct Cli2Srv_Game_LeaveGame : GameMsgHeader {
};
struct Cli2Srv_Game_Invite : GameMsgHeader {
dword playerId;
};
struct Cli2Srv_Game_Uninvite : GameMsgHeader {
dword playerId;
};
// Srv2Cli
struct Srv2Cli_Game_PlayerJoined : GameMsgHeader {
dword playerId;
};
struct Srv2Cli_Game_PlayerLeft : GameMsgHeader {
dword playerId;
};
struct Srv2Cli_Game_InviteFailed : GameMsgHeader {
dword inviteeId;
dword operationId;
EGameInviteError error;
};
struct Srv2Cli_Game_OwnerChange : GameMsgHeader {
dword ownerId;
};
//============================================================================
// End networked data structures
#include <PopPack.h>
//============================================================================
/*****************************************************************************
*
* Games
*
***/
#include "TicTacToe/pnGmTicTacToe.h"
#include "Heek/pnGmHeek.h"
#include "Marker/pnGmMarker.h"
#include "BlueSpiral/pnGmBlueSpiral.h"
#include "ClimbingWall/pnGmClimbingWall.h"
#include "VarSync/pnGmVarSync.h"
#endif // PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNGAMEMGR_PNGAMEMGR_H

View File

@ -0,0 +1,101 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_INTERN_H
/*****************************************************************************
*
* Ini
*
***/
struct IniValue {
ARRAY(wchar *) fArgs;
IniKey * fKey;
unsigned fIndex;
unsigned fLineNum;
IniValue (IniKey * key, unsigned lineNum);
~IniValue ();
};
struct IniKey {
HASHLINK(IniKey) fLink;
ARRAY(IniValue *) fValues;
IniSection * fSection;
wchar fName[1]; // variable length
// no more fields
IniKey (IniSection * section, const wchar name[]);
~IniKey ();
unsigned GetHash () const;
bool operator== (const CHashKeyStrPtrI & rhs) const;
};
struct IniSection {
HASHTABLEDECL(IniKey, CHashKeyStrPtrI, fLink) fKeys;
HASHLINK(IniSection) fLink;
wchar fName[1]; // variable length
// no more fields
IniSection (const wchar name[]);
~IniSection ();
unsigned GetHash () const;
bool operator== (const CHashKeyStrPtrI & rhs) const;
};
struct Ini {
HASHTABLEDECL(IniSection, CHashKeyStrPtrI, fLink) fSections;
~Ini ();
};

View File

@ -0,0 +1,63 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PCH_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "Private/pnIniAllIncludes.h"
#include "Intern.h"
#include <malloc.h>

View File

@ -0,0 +1,56 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniAllIncludes.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINIALLINCLUDES_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnIni/Private/pnIniAllIncludes.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNINI_PRIVATE_PNINIALLINCLUDES_H
#include "pnIniCore.h"
#include "pnIniChange.h"
#include "pnIniSrv.h"

Some files were not shown because too many files have changed in this diff Show More