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

Change all CRLF-text files to LF-text files

to match H'uru for patching
This commit is contained in:
rarified
2021-01-28 12:08:00 -07:00
parent 6ae3df25f5
commit a553708b5b
3385 changed files with 1112046 additions and 1112046 deletions

View File

@ -1,91 +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==*/
////////////////////////////////////////////////////////////////////////////////
// The stuff below seems to be missing fron WinIoCtl.h in MSVC2003 but is
// probably present in later versions. This was robbed from MSDN to fill
// the gap.
#if (_MSC_VER < 1500) // For VS2005 and earlier only (might need to make it VS2003 only (1310))
#define IOCTL_STORAGE_QUERY_PROPERTY CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
// retrieve the storage device descriptor data for a device.
typedef struct _STORAGE_DEVICE_DESCRIPTOR {
ULONG Version;
ULONG Size;
UCHAR DeviceType;
UCHAR DeviceTypeModifier;
BOOLEAN RemovableMedia;
BOOLEAN CommandQueueing;
ULONG VendorIdOffset;
ULONG ProductIdOffset;
ULONG ProductRevisionOffset;
ULONG SerialNumberOffset;
STORAGE_BUS_TYPE BusType;
ULONG RawPropertiesLength;
UCHAR RawDeviceProperties[1];
} STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
// retrieve the properties of a storage device or adapter.
typedef enum _STORAGE_QUERY_TYPE {
PropertyStandardQuery = 0,
PropertyExistsQuery,
PropertyMaskQuery,
PropertyQueryMaxDefined
} STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
// retrieve the properties of a storage device or adapter.
typedef enum _STORAGE_PROPERTY_ID {
StorageDeviceProperty = 0,
StorageAdapterProperty,
StorageDeviceIdProperty
} STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
// retrieve the properties of a storage device or adapter.
typedef struct _STORAGE_PROPERTY_QUERY {
STORAGE_PROPERTY_ID PropertyId;
STORAGE_QUERY_TYPE QueryType;
UCHAR AdditionalParameters[1];
} STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
#endif
// End of stuff taken from MSDN
/*==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==*/
////////////////////////////////////////////////////////////////////////////////
// The stuff below seems to be missing fron WinIoCtl.h in MSVC2003 but is
// probably present in later versions. This was robbed from MSDN to fill
// the gap.
#if (_MSC_VER < 1500) // For VS2005 and earlier only (might need to make it VS2003 only (1310))
#define IOCTL_STORAGE_QUERY_PROPERTY CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
// retrieve the storage device descriptor data for a device.
typedef struct _STORAGE_DEVICE_DESCRIPTOR {
ULONG Version;
ULONG Size;
UCHAR DeviceType;
UCHAR DeviceTypeModifier;
BOOLEAN RemovableMedia;
BOOLEAN CommandQueueing;
ULONG VendorIdOffset;
ULONG ProductIdOffset;
ULONG ProductRevisionOffset;
ULONG SerialNumberOffset;
STORAGE_BUS_TYPE BusType;
ULONG RawPropertiesLength;
UCHAR RawDeviceProperties[1];
} STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
// retrieve the properties of a storage device or adapter.
typedef enum _STORAGE_QUERY_TYPE {
PropertyStandardQuery = 0,
PropertyExistsQuery,
PropertyMaskQuery,
PropertyQueryMaxDefined
} STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
// retrieve the properties of a storage device or adapter.
typedef enum _STORAGE_PROPERTY_ID {
StorageDeviceProperty = 0,
StorageAdapterProperty,
StorageDeviceIdProperty
} STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
// retrieve the properties of a storage device or adapter.
typedef struct _STORAGE_PROPERTY_QUERY {
STORAGE_PROPERTY_ID PropertyId;
STORAGE_QUERY_TYPE QueryType;
UCHAR AdditionalParameters[1];
} STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
#endif
// End of stuff taken from MSDN

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,313 +1,313 @@
/*==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==*/
#pragma once
#ifndef plClient_inc
#define plClient_inc
//#define NEW_CAMERA_CODE
#include "hsWindowHndl.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include "hsUtils.h"
#include "hsStlUtils.h"
#include "../pnKeyedObject/hsKeyedObject.h"
#include "../pnKeyedObject/plUoid.h"
#include "../plScene/plRenderRequest.h"
class plSceneNode;
class plPipeline;
class hsG3DDeviceModeRecord;
class plInputManager;
class plInputController;
class plSceneObject;
class pfConsoleEngine;
class pfConsole;
class plAudioSystem;
class plVirtualCam1;
class plKey;
class plPageTreeMgr;
class plTransitionMgr;
class plLinkEffectsMgr;
class plOperationProgress;
class pfGameGUIMgr;
class pfKI;
class plAnimDebugList;
class plFontCache;
class plClientMsg;
class plLocation;
class plMovieMsg;
class plBinkPlayer;
class plMoviePlayer;
class plPreloaderMsg;
class plNetCommAuthMsg;
class plAgeLoaded2Msg;
typedef void (*plMessagePumpProc)( void );
class plClient : public hsKeyedObject
{
protected:
class plRoomRec
{
public:
plSceneNode *fNode;
UInt32 fFlags;
plRoomRec() { fNode = nil; fFlags = 0; }
plRoomRec( plSceneNode *n, UInt32 f ) : fNode( n ), fFlags( f ) {}
enum Flags
{
kHeld = 0x00000001
};
};
hsBitVector fFlags;
plInputManager* fInputManager;
plPageTreeMgr* fPageMgr;
hsTArray<plRoomRec> fRooms;
plSceneNode* fCurrentNode;
plPipeline* fPipeline;
hsColorRGBA fClearColor;
plTransitionMgr *fTransitionMgr;
plLinkEffectsMgr *fLinkEffectsMgr;
plFontCache *fFontCache;
pfConsoleEngine* fConsoleEngine;
pfConsole* fConsole;
pfKI *fKIGUIGlue;
hsBool fDone;
hsBool fWindowActive;
hsWindowHndl fWindowHndl;
double fLastProgressUpdate;
plOperationProgress *fProgressBar;
pfGameGUIMgr *fGameGUIMgr;
virtual hsG3DDeviceModeRecord ILoadDevMode(const char* devModeFile);
hsBool IUpdate();
hsBool IDraw();
hsBool IDrawProgress();
plVirtualCam1* fNewCamera;
static plClient* fInstance;
char * fpAuxInitDir;
static hsBool fDelayMS;
int fClampCap;
int fQuality;
hsBool fQuitIntro;
hsTArray<plMoviePlayer*> fMovies;
hsBool fPatchGlobalAges;
plMessagePumpProc fMessagePumpProc;
#ifndef PLASMA_EXTERNAL_RELEASE
bool bPythonDebugConnected;
#endif
hsTArray<plRenderRequest*> fPreRenderRequests;
hsTArray<plRenderRequest*> fPostRenderRequests;
bool fHoldLoadRequests;
class LoadRequest
{
public:
LoadRequest(const plLocation& loc, bool hold) { this->loc = loc; this->hold = hold; }
plLocation loc;
bool hold;
};
typedef std::list<LoadRequest*> LoadList;
LoadList fLoadRooms;
int fNumLoadingRooms; // Number of rooms we're waiting for load callbacks on
std::vector<plLocation> fRoomsLoading; // the locations we are currently in the middle of loading
int fNumPostLoadMsgs;
float fPostLoadMsgInc;
void ICompleteInit ();
void IOnAsyncInitComplete ();
void IHandlePreloaderMsg (plPreloaderMsg * msg);
void IHandleNetCommAuthMsg (plNetCommAuthMsg * msg);
bool IHandleAgeLoaded2Msg (plAgeLoaded2Msg * msg);
hsBool IFlushRenderRequests();
void IProcessPreRenderRequests();
void IProcessPostRenderRequests();
void IProcessRenderRequests(hsTArray<plRenderRequest*>& reqs);
void IAddRenderRequest(plRenderRequest* req);
hsBool IPlayIntroMovie(const char* movieName, hsScalar endDelay, hsScalar posX, hsScalar posY, hsScalar scaleX, hsScalar scaleY, hsScalar volume = 1.0);
hsBool IHandleMovieMsg(plMovieMsg* mov);
void IKillMovies();
void IServiceMovies();
void IStartProgress( const char *title, hsScalar len );
void IIncProgress( hsScalar byHowMuch, const char *text );
void IStopProgress( void );
static void IDispatchMsgReceiveCallback();
static void IReadKeyedObjCallback(plKey key);
static void IProgressMgrCallbackProc( plOperationProgress *progress );
void IPatchGlobalAgeFiles( void );
int IFindRoomByLoc(const plLocation& loc);
bool IIsRoomLoading(const plLocation& loc);
void IQueueRoomLoad(const std::vector<plLocation>& locs, bool hold);
void ILoadNextRoom();
void IUnloadRooms(const std::vector<plLocation>& locs);
void IRoomLoaded(plSceneNode* node, bool hold);
void IRoomUnloaded(plSceneNode* node);
void ISetGraphicsDefaults();
public:
plClient();
virtual ~plClient();
CLASSNAME_REGISTER( plClient );
GETINTERFACE_ANY( plClient, hsKeyedObject );
static plClient* GetInstance() { return fInstance; }
static void SetInstance(plClient* v) { fInstance=v; }
virtual hsBool MsgReceive(plMessage* msg);
hsBool InitPipeline();
void InitInputs();
void InitDLLs();
void ShutdownDLLs();
void InitAuxInits();
virtual hsBool StartInit();
virtual hsBool Shutdown();
virtual hsBool MainLoop();
plClient& SetDone(hsBool done) { fDone = done; return *this; }
hsBool GetDone() { return fDone; }
// Set this to true to queue any room load requests that come in. Set it to false to process them.
void SetHoldLoadRequests(bool hold);
enum
{
kFlagIniting,
kFlagDBGDisableRender,
kFlagDBGDisableRRequests,
kFlagAsyncInitComplete,
kFlagGlobalDataLoaded,
};
hsBool HasFlag(int f) const { return fFlags.IsBitSet(f); }
void SetFlag(int f, hsBool on=true) { fFlags.SetBit(f, on); }
virtual plClient& SetWindowHandle(hsWindowHndl hndl) { fWindowHndl=hndl; return *this; }
hsWindowHndl GetWindowHandle() { return fWindowHndl; }
plInputManager* GetInputManager() { return fInputManager; }
plPipeline* GetPipeline() { return fPipeline; }
plSceneNode* GetCurrentScene() { return fCurrentNode; }
pfConsoleEngine *GetConsoleEngine() { return fConsoleEngine; }
void SetAuxInitDir(const char *p) { delete [] fpAuxInitDir; fpAuxInitDir = hsStrcpy(p); }
static void EnableClientDelay() { plClient::fDelayMS = true; }
// These are a hack to let the console fake a lesser capabile board and test out quality settings.
// They should go away once we have this built into ClientSetup et.al.
void SetClampCap(int c) { fClampCap = c; }
int GetClampCap() const { return fClampCap; }
void SetQuality(int q) { fQuality = q; }
int GetQuality() const { return fQuality; }
hsBool GetQuitIntro() const { return fQuitIntro; }
void SetQuitIntro(hsBool on) { fQuitIntro = on; }
void SetClearColor( hsColorRGBA &color );
hsColorRGBA GetClearColor() const { return fClearColor; }
// The client window has focus (true) or lost it (false)
virtual void WindowActivate(bool active);
virtual hsBool WindowActive() const { return fWindowActive; }
void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; }
void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false);
void ResizeDisplayDevice(int Width, int Height, hsBool Windowed);
void IDetectAudioVideoSettings();
void IWriteDefaultGraphicsSettings(const wchar* destFile);
plAnimDebugList *fAnimDebugList;
#if 0
std::string fUsername;
std::string fPasswordDigest;
std::string fServer;
int fPlayerID;
bool fRecreatePlayer;
bool fAuthPassed;
#endif
};
#endif // plClient_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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==*/
#pragma once
#ifndef plClient_inc
#define plClient_inc
//#define NEW_CAMERA_CODE
#include "hsWindowHndl.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include "hsUtils.h"
#include "hsStlUtils.h"
#include "../pnKeyedObject/hsKeyedObject.h"
#include "../pnKeyedObject/plUoid.h"
#include "../plScene/plRenderRequest.h"
class plSceneNode;
class plPipeline;
class hsG3DDeviceModeRecord;
class plInputManager;
class plInputController;
class plSceneObject;
class pfConsoleEngine;
class pfConsole;
class plAudioSystem;
class plVirtualCam1;
class plKey;
class plPageTreeMgr;
class plTransitionMgr;
class plLinkEffectsMgr;
class plOperationProgress;
class pfGameGUIMgr;
class pfKI;
class plAnimDebugList;
class plFontCache;
class plClientMsg;
class plLocation;
class plMovieMsg;
class plBinkPlayer;
class plMoviePlayer;
class plPreloaderMsg;
class plNetCommAuthMsg;
class plAgeLoaded2Msg;
typedef void (*plMessagePumpProc)( void );
class plClient : public hsKeyedObject
{
protected:
class plRoomRec
{
public:
plSceneNode *fNode;
UInt32 fFlags;
plRoomRec() { fNode = nil; fFlags = 0; }
plRoomRec( plSceneNode *n, UInt32 f ) : fNode( n ), fFlags( f ) {}
enum Flags
{
kHeld = 0x00000001
};
};
hsBitVector fFlags;
plInputManager* fInputManager;
plPageTreeMgr* fPageMgr;
hsTArray<plRoomRec> fRooms;
plSceneNode* fCurrentNode;
plPipeline* fPipeline;
hsColorRGBA fClearColor;
plTransitionMgr *fTransitionMgr;
plLinkEffectsMgr *fLinkEffectsMgr;
plFontCache *fFontCache;
pfConsoleEngine* fConsoleEngine;
pfConsole* fConsole;
pfKI *fKIGUIGlue;
hsBool fDone;
hsBool fWindowActive;
hsWindowHndl fWindowHndl;
double fLastProgressUpdate;
plOperationProgress *fProgressBar;
pfGameGUIMgr *fGameGUIMgr;
virtual hsG3DDeviceModeRecord ILoadDevMode(const char* devModeFile);
hsBool IUpdate();
hsBool IDraw();
hsBool IDrawProgress();
plVirtualCam1* fNewCamera;
static plClient* fInstance;
char * fpAuxInitDir;
static hsBool fDelayMS;
int fClampCap;
int fQuality;
hsBool fQuitIntro;
hsTArray<plMoviePlayer*> fMovies;
hsBool fPatchGlobalAges;
plMessagePumpProc fMessagePumpProc;
#ifndef PLASMA_EXTERNAL_RELEASE
bool bPythonDebugConnected;
#endif
hsTArray<plRenderRequest*> fPreRenderRequests;
hsTArray<plRenderRequest*> fPostRenderRequests;
bool fHoldLoadRequests;
class LoadRequest
{
public:
LoadRequest(const plLocation& loc, bool hold) { this->loc = loc; this->hold = hold; }
plLocation loc;
bool hold;
};
typedef std::list<LoadRequest*> LoadList;
LoadList fLoadRooms;
int fNumLoadingRooms; // Number of rooms we're waiting for load callbacks on
std::vector<plLocation> fRoomsLoading; // the locations we are currently in the middle of loading
int fNumPostLoadMsgs;
float fPostLoadMsgInc;
void ICompleteInit ();
void IOnAsyncInitComplete ();
void IHandlePreloaderMsg (plPreloaderMsg * msg);
void IHandleNetCommAuthMsg (plNetCommAuthMsg * msg);
bool IHandleAgeLoaded2Msg (plAgeLoaded2Msg * msg);
hsBool IFlushRenderRequests();
void IProcessPreRenderRequests();
void IProcessPostRenderRequests();
void IProcessRenderRequests(hsTArray<plRenderRequest*>& reqs);
void IAddRenderRequest(plRenderRequest* req);
hsBool IPlayIntroMovie(const char* movieName, hsScalar endDelay, hsScalar posX, hsScalar posY, hsScalar scaleX, hsScalar scaleY, hsScalar volume = 1.0);
hsBool IHandleMovieMsg(plMovieMsg* mov);
void IKillMovies();
void IServiceMovies();
void IStartProgress( const char *title, hsScalar len );
void IIncProgress( hsScalar byHowMuch, const char *text );
void IStopProgress( void );
static void IDispatchMsgReceiveCallback();
static void IReadKeyedObjCallback(plKey key);
static void IProgressMgrCallbackProc( plOperationProgress *progress );
void IPatchGlobalAgeFiles( void );
int IFindRoomByLoc(const plLocation& loc);
bool IIsRoomLoading(const plLocation& loc);
void IQueueRoomLoad(const std::vector<plLocation>& locs, bool hold);
void ILoadNextRoom();
void IUnloadRooms(const std::vector<plLocation>& locs);
void IRoomLoaded(plSceneNode* node, bool hold);
void IRoomUnloaded(plSceneNode* node);
void ISetGraphicsDefaults();
public:
plClient();
virtual ~plClient();
CLASSNAME_REGISTER( plClient );
GETINTERFACE_ANY( plClient, hsKeyedObject );
static plClient* GetInstance() { return fInstance; }
static void SetInstance(plClient* v) { fInstance=v; }
virtual hsBool MsgReceive(plMessage* msg);
hsBool InitPipeline();
void InitInputs();
void InitDLLs();
void ShutdownDLLs();
void InitAuxInits();
virtual hsBool StartInit();
virtual hsBool Shutdown();
virtual hsBool MainLoop();
plClient& SetDone(hsBool done) { fDone = done; return *this; }
hsBool GetDone() { return fDone; }
// Set this to true to queue any room load requests that come in. Set it to false to process them.
void SetHoldLoadRequests(bool hold);
enum
{
kFlagIniting,
kFlagDBGDisableRender,
kFlagDBGDisableRRequests,
kFlagAsyncInitComplete,
kFlagGlobalDataLoaded,
};
hsBool HasFlag(int f) const { return fFlags.IsBitSet(f); }
void SetFlag(int f, hsBool on=true) { fFlags.SetBit(f, on); }
virtual plClient& SetWindowHandle(hsWindowHndl hndl) { fWindowHndl=hndl; return *this; }
hsWindowHndl GetWindowHandle() { return fWindowHndl; }
plInputManager* GetInputManager() { return fInputManager; }
plPipeline* GetPipeline() { return fPipeline; }
plSceneNode* GetCurrentScene() { return fCurrentNode; }
pfConsoleEngine *GetConsoleEngine() { return fConsoleEngine; }
void SetAuxInitDir(const char *p) { delete [] fpAuxInitDir; fpAuxInitDir = hsStrcpy(p); }
static void EnableClientDelay() { plClient::fDelayMS = true; }
// These are a hack to let the console fake a lesser capabile board and test out quality settings.
// They should go away once we have this built into ClientSetup et.al.
void SetClampCap(int c) { fClampCap = c; }
int GetClampCap() const { return fClampCap; }
void SetQuality(int q) { fQuality = q; }
int GetQuality() const { return fQuality; }
hsBool GetQuitIntro() const { return fQuitIntro; }
void SetQuitIntro(hsBool on) { fQuitIntro = on; }
void SetClearColor( hsColorRGBA &color );
hsColorRGBA GetClearColor() const { return fClearColor; }
// The client window has focus (true) or lost it (false)
virtual void WindowActivate(bool active);
virtual hsBool WindowActive() const { return fWindowActive; }
void SetMessagePumpProc( plMessagePumpProc proc ) { fMessagePumpProc = proc; }
void ResetDisplayDevice(int Width, int Height, int ColorDepth, hsBool Windowed, int NumAASamples, int MaxAnisotropicSamples, hsBool VSync = false);
void ResizeDisplayDevice(int Width, int Height, hsBool Windowed);
void IDetectAudioVideoSettings();
void IWriteDefaultGraphicsSettings(const wchar* destFile);
plAnimDebugList *fAnimDebugList;
#if 0
std::string fUsername;
std::string fPasswordDigest;
std::string fServer;
int fPlayerID;
bool fRecreatePlayer;
bool fAuthPassed;
#endif
};
#endif // plClient_inc

View File

@ -1,52 +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 plClientCreatable_inc
#define plClientCreatable_inc
#include "../pnFactory/plCreator.h"
#include "plClient.h"
REGISTER_NONCREATABLE( plClient );
#endif // plClientCreatable
/*==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 plClientCreatable_inc
#define plClientCreatable_inc
#include "../pnFactory/plCreator.h"
#include "plClient.h"
REGISTER_NONCREATABLE( plClient );
#endif // plClientCreatable

View File

@ -1,67 +1,67 @@
/*==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 plClientUpdateFormat_h_inc
#define plClientUpdateFormat_h_inc
namespace ClientUpdate
{
enum
{
kUpdate,
kShutdown,
};
}
//
// Format of the update stream
//
// UInt8 - type (kUpdate, kShutdown)
//
// If type is kUpdate:
// UInt32 - number of deleted keys
// plUoid - uoid of deleted key (* num)
//
// UInt32 - number of new creatables
// plCreatable - new creatable (* num)
//
#endif // plClientUpdateFormat_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 plClientUpdateFormat_h_inc
#define plClientUpdateFormat_h_inc
namespace ClientUpdate
{
enum
{
kUpdate,
kShutdown,
};
}
//
// Format of the update stream
//
// UInt8 - type (kUpdate, kShutdown)
//
// If type is kUpdate:
// UInt32 - number of deleted keys
// plUoid - uoid of deleted key (* num)
//
// UInt32 - number of new creatables
// plCreatable - new creatable (* num)
//
#endif // plClientUpdateFormat_h_inc

View File

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

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

View File

@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="plClient"
type="win32"
/>
<description>plClient</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="plClient"
type="win32"
/>
<description>plClient</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View File

@ -1,332 +1,332 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#endif\r\n"
"\r\n"
"CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST ""plClient.exe.manifest""\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BANNER BITMAP "banner.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON_DIRT ICON "Dirt.ICO"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_LOADING DIALOGEX 0, 0, 161, 26
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER |
WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Starting URU. Please wait...",IDC_STARTING_TEXT,32,9,
127,8
ICON IDI_ICON_DIRT,IDC_STATIC,5,3,20,20
END
IDD_EXCEPTION DIALOGEX 0, 0, 296, 183
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Error"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,239,7,50,14
ICON IDI_ICON_DIRT,IDC_STATIC,7,7,20,20
LTEXT " URU has experienced a serious error. Please report the information below.\n\nWe apologize for any inconvenience. ",
IDC_MSG,38,7,189,37
EDITTEXT IDC_CRASHINFO,7,45,282,131,ES_MULTILINE | ES_AUTOVSCROLL |
ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Copy",IDC_COPY,239,26,50,14
END
IDD_URUTAP_LOGIN DIALOGEX 0, 0, 188, 111
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Enter Login Info"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Enter",IDOK,33,90,50,14
PUSHBUTTON "Cancel",IDCANCEL,107,90,50,14
LTEXT "Username",IDC_STATIC,7,7,38,11
EDITTEXT IDC_URUTAP_USERNAME,52,7,129,13,ES_AUTOHSCROLL
LTEXT "Password",IDC_STATIC,7,30,38,12
EDITTEXT IDC_URUTAP_PASSWORD,52,28,129,12,ES_PASSWORD |
ES_AUTOHSCROLL
LTEXT "Server",IDC_STATIC,7,54,35,12
EDITTEXT IDC_URUTAP_SERVER,51,51,130,13,ES_AUTOHSCROLL
CONTROL "Destroy and recreate player",IDC_URUTAP_DESTROY,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,51,70,130,12
END
IDD_URU_LOGIN DIALOGEX 0, 0, 200, 133
STYLE DS_SETFONT | DS_3DLOOK | WS_POPUP | WS_SYSMENU
EXSTYLE WS_EX_STATICEDGE
FONT 12, "Hobo Std", 500, 0, 0x0
BEGIN
DEFPUSHBUTTON "Submit",IDOK,139,114,50,14
PUSHBUTTON "Quit",IDCANCEL,77,114,50,14
EDITTEXT IDC_USERNAME,65,55,110,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,65,71,110,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username:",IDC_TEXT_USER,25,58,36,8
LTEXT "Password:",IDC_TEXT_PASS,27,73,34,8
LTEXT "Welcome to URU!",IDC_TEXT_WELCOME,72,45,57,8
CONTROL "Remember Password:",IDC_REMEMBER_PASS,"Button",
BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,23,87,85,10
GROUPBOX "",IDC_BOX_01,5,30,190,79
GROUPBOX "",IDC_BOX_02,14,38,172,64
CONTROL 151,IDC_IMAGE_BANNER,"Static",SS_BITMAP |
SS_REALSIZEIMAGE | WS_BORDER,4,4,192,21,WS_EX_CLIENTEDGE
END
IDD_URU_EULA DIALOGEX 0, 0, 201, 158
STYLE DS_SETFONT | WS_POPUP | WS_SYSMENU
FONT 12, "Hobo Std", 500, 0, 0x0
BEGIN
DEFPUSHBUTTON "Accept",IDOK,141,138,50,14
PUSHBUTTON "Decline",IDCANCEL,79,138,50,14
CONTROL 151,IDC_IMAGE_BANNER,"Static",SS_BITMAP |
SS_REALSIZEIMAGE | WS_BORDER,4,4,192,21,WS_EX_CLIENTEDGE
GROUPBOX "",IDC_BOX_03,5,30,190,103
LTEXT "Terms of Use Agreement",IDC_TEXT_TERMS,59,36,83,8
CONTROL "Custom1",IDC_DYN_EULA,"",WS_TABSTOP,13,46,174,80
END
IDD_URULOGIN_MAIN DIALOGEX 0, 0, 302, 230
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS |
DS_CENTER | WS_POPUP
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Login",IDOK,87,209,50,14
PUSHBUTTON "Quit",IDCANCEL,163,209,50,14
CONTROL 151,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE |
WS_BORDER,7,7,289,36
LTEXT "Account name:",IDC_STATIC,69,119,49,10
LTEXT "Password:",IDC_STATIC,69,135,49,10
EDITTEXT IDC_URULOGIN_USERNAME,123,119,108,12,ES_AUTOHSCROLL
EDITTEXT IDC_URULOGIN_PASSWORD,123,135,108,12,ES_PASSWORD |
ES_AUTOHSCROLL
GROUPBOX "",IDC_STATIC,14,99,274,96
CONTROL "Remember Password:",IDC_URULOGIN_REMEMBERPASS,"Button",
BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,69,151,100,10
GROUPBOX "",IDC_STATIC,14,54,274,43
LTEXT "Welcome to URU",IDC_STATUS_TEXT,17,62,267,20
RTEXT "Product String",IDC_PRODUCTSTRING,88,86,194,8
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,49,
288,152
PUSHBUTTON "Need an account?",IDC_URULOGIN_GAMETAPLINK,32,174,95,14,
BS_FLAT
PUSHBUTTON "Donate",IDC_URULOGIN_GAMETAPLINK2,175,174,95,14,BS_FLAT
END
IDD_URULOGIN_EULA DIALOGEX 0, 0, 300, 318
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Accept",IDOK,89,297,50,14
PUSHBUTTON "Decline",IDCANCEL,160,297,50,14
CONTROL 151,IDC_STATIC,"Static",SS_BITMAP,7,7,287,36,
WS_EX_CLIENTEDGE
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,9,46,
284,242
CTEXT "End User License Agreement",IDC_STATIC,46,55,207,10
GROUPBOX "",IDC_STATIC,17,66,266,212
CONTROL "",IDC_URULOGIN_EULATEXT,"RichEdit20A",ES_MULTILINE |
ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL |
WS_HSCROLL | WS_TABSTOP,25,75,250,197
END
IDD_AUTHFAILED DIALOGEX 0, 0, 177, 89
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER |
WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Authentication failed. Please try again.",
IDC_AUTH_TEXT,38,17,127,8
ICON IDI_ICON_DIRT,IDC_STATIC,6,11,21,20
PUSHBUTTON "Ok",IDOK,67,73,42,14
CTEXT "",IDC_AUTH_MESSAGE,0,37,175,32
END
IDD_AUTHENTICATING DIALOGEX 0, 0, 177, 60
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER |
WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
ICON IDI_ICON_DIRT,IDC_STATIC,6,11,21,20
LTEXT "Logging in to URU. Please wait...",IDC_AUTH_TEXT,38,17,
137,8
PUSHBUTTON "Cancel",IDCANCEL,64,42,49,15
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_LOADING, DIALOG
BEGIN
RIGHTMARGIN, 159
END
IDD_EXCEPTION, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 289
TOPMARGIN, 7
BOTTOMMARGIN, 176
END
IDD_URUTAP_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 181
TOPMARGIN, 7
BOTTOMMARGIN, 104
END
IDD_URU_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 168
TOPMARGIN, 7
BOTTOMMARGIN, 128
END
IDD_URU_EULA, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 194
TOPMARGIN, 7
BOTTOMMARGIN, 151
END
IDD_URULOGIN_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 295
TOPMARGIN, 7
BOTTOMMARGIN, 223
END
IDD_URULOGIN_EULA, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 293
TOPMARGIN, 7
BOTTOMMARGIN, 311
END
IDD_AUTHFAILED, DIALOG
BEGIN
RIGHTMARGIN, 175
BOTTOMMARGIN, 87
END
IDD_AUTHENTICATING, DIALOG
BEGIN
RIGHTMARGIN, 175
BOTTOMMARGIN, 57
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// CNSL
//
IDR_CNSL1 CNSL "cnsl1.bin"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#endif
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "plClient.exe.manifest"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"#define _AFX_NO_SPLITTER_RESOURCES\r\n"
"#define _AFX_NO_OLE_RESOURCES\r\n"
"#define _AFX_NO_TRACKER_RESOURCES\r\n"
"#define _AFX_NO_PROPERTY_RESOURCES\r\n"
"\r\n"
"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
"#ifdef _WIN32\r\n"
"LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r\n"
"#pragma code_page(1252)\r\n"
"#endif //_WIN32\r\n"
"#endif\r\n"
"\r\n"
"CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST ""plClient.exe.manifest""\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BANNER BITMAP "banner.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON_DIRT ICON "Dirt.ICO"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_LOADING DIALOGEX 0, 0, 161, 26
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER |
WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Starting URU. Please wait...",IDC_STARTING_TEXT,32,9,
127,8
ICON IDI_ICON_DIRT,IDC_STATIC,5,3,20,20
END
IDD_EXCEPTION DIALOGEX 0, 0, 296, 183
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Error"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
DEFPUSHBUTTON "OK",IDOK,239,7,50,14
ICON IDI_ICON_DIRT,IDC_STATIC,7,7,20,20
LTEXT " URU has experienced a serious error. Please report the information below.\n\nWe apologize for any inconvenience. ",
IDC_MSG,38,7,189,37
EDITTEXT IDC_CRASHINFO,7,45,282,131,ES_MULTILINE | ES_AUTOVSCROLL |
ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Copy",IDC_COPY,239,26,50,14
END
IDD_URUTAP_LOGIN DIALOGEX 0, 0, 188, 111
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION
CAPTION "Enter Login Info"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Enter",IDOK,33,90,50,14
PUSHBUTTON "Cancel",IDCANCEL,107,90,50,14
LTEXT "Username",IDC_STATIC,7,7,38,11
EDITTEXT IDC_URUTAP_USERNAME,52,7,129,13,ES_AUTOHSCROLL
LTEXT "Password",IDC_STATIC,7,30,38,12
EDITTEXT IDC_URUTAP_PASSWORD,52,28,129,12,ES_PASSWORD |
ES_AUTOHSCROLL
LTEXT "Server",IDC_STATIC,7,54,35,12
EDITTEXT IDC_URUTAP_SERVER,51,51,130,13,ES_AUTOHSCROLL
CONTROL "Destroy and recreate player",IDC_URUTAP_DESTROY,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,51,70,130,12
END
IDD_URU_LOGIN DIALOGEX 0, 0, 200, 133
STYLE DS_SETFONT | DS_3DLOOK | WS_POPUP | WS_SYSMENU
EXSTYLE WS_EX_STATICEDGE
FONT 12, "Hobo Std", 500, 0, 0x0
BEGIN
DEFPUSHBUTTON "Submit",IDOK,139,114,50,14
PUSHBUTTON "Quit",IDCANCEL,77,114,50,14
EDITTEXT IDC_USERNAME,65,55,110,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,65,71,110,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username:",IDC_TEXT_USER,25,58,36,8
LTEXT "Password:",IDC_TEXT_PASS,27,73,34,8
LTEXT "Welcome to URU!",IDC_TEXT_WELCOME,72,45,57,8
CONTROL "Remember Password:",IDC_REMEMBER_PASS,"Button",
BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,23,87,85,10
GROUPBOX "",IDC_BOX_01,5,30,190,79
GROUPBOX "",IDC_BOX_02,14,38,172,64
CONTROL 151,IDC_IMAGE_BANNER,"Static",SS_BITMAP |
SS_REALSIZEIMAGE | WS_BORDER,4,4,192,21,WS_EX_CLIENTEDGE
END
IDD_URU_EULA DIALOGEX 0, 0, 201, 158
STYLE DS_SETFONT | WS_POPUP | WS_SYSMENU
FONT 12, "Hobo Std", 500, 0, 0x0
BEGIN
DEFPUSHBUTTON "Accept",IDOK,141,138,50,14
PUSHBUTTON "Decline",IDCANCEL,79,138,50,14
CONTROL 151,IDC_IMAGE_BANNER,"Static",SS_BITMAP |
SS_REALSIZEIMAGE | WS_BORDER,4,4,192,21,WS_EX_CLIENTEDGE
GROUPBOX "",IDC_BOX_03,5,30,190,103
LTEXT "Terms of Use Agreement",IDC_TEXT_TERMS,59,36,83,8
CONTROL "Custom1",IDC_DYN_EULA,"",WS_TABSTOP,13,46,174,80
END
IDD_URULOGIN_MAIN DIALOGEX 0, 0, 302, 230
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS |
DS_CENTER | WS_POPUP
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Login",IDOK,87,209,50,14
PUSHBUTTON "Quit",IDCANCEL,163,209,50,14
CONTROL 151,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE |
WS_BORDER,7,7,289,36
LTEXT "Account name:",IDC_STATIC,69,119,49,10
LTEXT "Password:",IDC_STATIC,69,135,49,10
EDITTEXT IDC_URULOGIN_USERNAME,123,119,108,12,ES_AUTOHSCROLL
EDITTEXT IDC_URULOGIN_PASSWORD,123,135,108,12,ES_PASSWORD |
ES_AUTOHSCROLL
GROUPBOX "",IDC_STATIC,14,99,274,96
CONTROL "Remember Password:",IDC_URULOGIN_REMEMBERPASS,"Button",
BS_AUTOCHECKBOX | BS_LEFTTEXT | WS_TABSTOP,69,151,100,10
GROUPBOX "",IDC_STATIC,14,54,274,43
LTEXT "Welcome to URU",IDC_STATUS_TEXT,17,62,267,20
RTEXT "Product String",IDC_PRODUCTSTRING,88,86,194,8
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,7,49,
288,152
PUSHBUTTON "Need an account?",IDC_URULOGIN_GAMETAPLINK,32,174,95,14,
BS_FLAT
PUSHBUTTON "Donate",IDC_URULOGIN_GAMETAPLINK2,175,174,95,14,BS_FLAT
END
IDD_URULOGIN_EULA DIALOGEX 0, 0, 300, 318
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Accept",IDOK,89,297,50,14
PUSHBUTTON "Decline",IDCANCEL,160,297,50,14
CONTROL 151,IDC_STATIC,"Static",SS_BITMAP,7,7,287,36,
WS_EX_CLIENTEDGE
CONTROL "",IDC_STATIC,"Static",SS_BLACKFRAME | SS_SUNKEN,9,46,
284,242
CTEXT "End User License Agreement",IDC_STATIC,46,55,207,10
GROUPBOX "",IDC_STATIC,17,66,266,212
CONTROL "",IDC_URULOGIN_EULATEXT,"RichEdit20A",ES_MULTILINE |
ES_AUTOHSCROLL | ES_READONLY | WS_BORDER | WS_VSCROLL |
WS_HSCROLL | WS_TABSTOP,25,75,250,197
END
IDD_AUTHFAILED DIALOGEX 0, 0, 177, 89
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER |
WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Authentication failed. Please try again.",
IDC_AUTH_TEXT,38,17,127,8
ICON IDI_ICON_DIRT,IDC_STATIC,6,11,21,20
PUSHBUTTON "Ok",IDOK,67,73,42,14
CTEXT "",IDC_AUTH_MESSAGE,0,37,175,32
END
IDD_AUTHENTICATING DIALOGEX 0, 0, 177, 60
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER |
WS_POPUP | WS_VISIBLE
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
ICON IDI_ICON_DIRT,IDC_STATIC,6,11,21,20
LTEXT "Logging in to URU. Please wait...",IDC_AUTH_TEXT,38,17,
137,8
PUSHBUTTON "Cancel",IDCANCEL,64,42,49,15
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_LOADING, DIALOG
BEGIN
RIGHTMARGIN, 159
END
IDD_EXCEPTION, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 289
TOPMARGIN, 7
BOTTOMMARGIN, 176
END
IDD_URUTAP_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 181
TOPMARGIN, 7
BOTTOMMARGIN, 104
END
IDD_URU_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 4
RIGHTMARGIN, 168
TOPMARGIN, 7
BOTTOMMARGIN, 128
END
IDD_URU_EULA, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 194
TOPMARGIN, 7
BOTTOMMARGIN, 151
END
IDD_URULOGIN_MAIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 295
TOPMARGIN, 7
BOTTOMMARGIN, 223
END
IDD_URULOGIN_EULA, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 293
TOPMARGIN, 7
BOTTOMMARGIN, 311
END
IDD_AUTHFAILED, DIALOG
BEGIN
RIGHTMARGIN, 175
BOTTOMMARGIN, 87
END
IDD_AUTHENTICATING, DIALOG
BEGIN
RIGHTMARGIN, 175
BOTTOMMARGIN, 57
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// CNSL
//
IDR_CNSL1 CNSL "cnsl1.bin"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#endif
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "plClient.exe.manifest"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,61 +1,61 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plClient.rc
//
#define IDI_ICON_DIRT 135
#define IDD_LOADING 136
#define IDD_EXCEPTION 138
#define IDR_CNSL1 139
#define IDD_URUTAP_LOGIN 148
#define IDD_URU_LOGIN 149
#define IDB_BANNER 151
#define IDD_URU_EULA 152
#define IDD_URULOGIN_MAIN 153
#define IDD_URULOGIN_EULA 154
#define IDD_AUTHFAILED 155
#define IDD_AUTHENTICATING 156
#define IDC_CRASHINFO 1001
#define IDC_COPY 1002
#define IDC_MSG 1003
#define IDC_STARTING_TEXT 1004
#define IDC_URUTAP_USERNAME 1005
#define IDC_URUTAP_PASSWORD 1006
#define IDC_URUTAP_SERVER 1008
#define IDC_URUTAP_DESTROY 1009
#define IDC_USERNAME 1010
#define IDC_PASSWORD 1011
#define IDC_REMEMBER_PASS 1012
#define IDC_IMAGE_BANNER 1013
#define IDC_BOX_01 1014
#define IDC_BOX_02 1015
#define IDC_TEXT_WELCOME 1016
#define IDC_TEXT_USER 1017
#define IDC_TEXT_PASS 1018
#define IDC_CUSTOM1 1019
#define IDC_DYN_EULA 1019
#define IDC_BOX_03 1020
#define IDC_TEXT_TERMS 1021
#define IDC_URULOGIN_REMEMBERPASS 1022
#define IDC_URULOGIN_USERNAME 1023
#define IDC_URULOGIN_PASSWORD 1024
#define IDC_URULOGIN_EULATEXT 1025
#define IDC_RICHEDIT22 1028
#define IDC_AUTH_TEXT 1029
#define IDC_BUTTON1 1030
#define IDC_URULOGIN_GAMETAPLINK 1030
#define IDC_AUTH_MESSAGE 1031
#define IDC_URULOGIN_GAMETAPLINK2 1031
#define IDC_PRODUCTSTRING 1033
#define IDC_STATUS_TEXT 1034
#define IDC_HOTKEY1 1035
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 197
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plClient.rc
//
#define IDI_ICON_DIRT 135
#define IDD_LOADING 136
#define IDD_EXCEPTION 138
#define IDR_CNSL1 139
#define IDD_URUTAP_LOGIN 148
#define IDD_URU_LOGIN 149
#define IDB_BANNER 151
#define IDD_URU_EULA 152
#define IDD_URULOGIN_MAIN 153
#define IDD_URULOGIN_EULA 154
#define IDD_AUTHFAILED 155
#define IDD_AUTHENTICATING 156
#define IDC_CRASHINFO 1001
#define IDC_COPY 1002
#define IDC_MSG 1003
#define IDC_STARTING_TEXT 1004
#define IDC_URUTAP_USERNAME 1005
#define IDC_URUTAP_PASSWORD 1006
#define IDC_URUTAP_SERVER 1008
#define IDC_URUTAP_DESTROY 1009
#define IDC_USERNAME 1010
#define IDC_PASSWORD 1011
#define IDC_REMEMBER_PASS 1012
#define IDC_IMAGE_BANNER 1013
#define IDC_BOX_01 1014
#define IDC_BOX_02 1015
#define IDC_TEXT_WELCOME 1016
#define IDC_TEXT_USER 1017
#define IDC_TEXT_PASS 1018
#define IDC_CUSTOM1 1019
#define IDC_DYN_EULA 1019
#define IDC_BOX_03 1020
#define IDC_TEXT_TERMS 1021
#define IDC_URULOGIN_REMEMBERPASS 1022
#define IDC_URULOGIN_USERNAME 1023
#define IDC_URULOGIN_PASSWORD 1024
#define IDC_URULOGIN_EULATEXT 1025
#define IDC_RICHEDIT22 1028
#define IDC_AUTH_TEXT 1029
#define IDC_BUTTON1 1030
#define IDC_URULOGIN_GAMETAPLINK 1030
#define IDC_AUTH_MESSAGE 1031
#define IDC_URULOGIN_GAMETAPLINK2 1031
#define IDC_PRODUCTSTRING 1033
#define IDC_STATUS_TEXT 1034
#define IDC_HOTKEY1 1035
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 197
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_SYMED_VALUE 103
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +1,51 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 <windows.h>
__declspec(dllexport) const unsigned long* GetKey()
{
// So the crackers know who the tard is
static const char* tauntText = "My copy protection is uncrackable! -Brice";
static const unsigned long kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 };
return kDefaultKey;
}
/*==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 <windows.h>
__declspec(dllexport) const unsigned long* GetKey()
{
// So the crackers know who the tard is
static const char* tauntText = "My copy protection is uncrackable! -Brice";
static const unsigned long kDefaultKey[4] = { 0x6c0a5452, 0x3827d0f, 0x3a170b92, 0x16db7fc2 };
return kDefaultKey;
}

View File

@ -1,64 +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==*/
#include "plClientKey.h"
#include "hsWindows.h"
typedef const UInt32* (*GETKEY)();
const UInt32* plClientKey::GetKey()
{
HMODULE hDll = LoadLibrary("sp.dll");
if (hDll)
{
GETKEY getKey = (GETKEY)GetProcAddress(hDll, "GetKey");
if (getKey)
{
static UInt32 key[4];
memcpy(key, getKey(), sizeof(key));
FreeLibrary(hDll);
return key;
}
}
return nil;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "plClientKey.h"
#include "hsWindows.h"
typedef const UInt32* (*GETKEY)();
const UInt32* plClientKey::GetKey()
{
HMODULE hDll = LoadLibrary("sp.dll");
if (hDll)
{
GETKEY getKey = (GETKEY)GetProcAddress(hDll, "GetKey");
if (getKey)
{
static UInt32 key[4];
memcpy(key, getKey(), sizeof(key));
FreeLibrary(hDll);
return key;
}
}
return nil;
}

View File

@ -1,5 +1,5 @@
LIBRARY
EXPORTS
GetKey @1
SECTIONS
.data READ WRITE
LIBRARY
EXPORTS
GetKey @1
SECTIONS
.data READ WRITE

View File

@ -1,59 +1,59 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 plClientKey_h_inc
#define plClientKey_h_inc
#include "hsTypes.h"
//
// For getting the "SafeDisc protected" encryption key in single player mode
//
// Include plClientKey.cpp/h in your project and call plClientKey::GetKey
// It will load the Dll and get the key for you
// Returns nil if it fails
//
namespace plClientKey
{
const UInt32* GetKey();
}
/*==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 plClientKey_h_inc
#define plClientKey_h_inc
#include "hsTypes.h"
//
// For getting the "SafeDisc protected" encryption key in single player mode
//
// Include plClientKey.cpp/h in your project and call plClientKey::GetKey
// It will load the Dll and get the key for you
// Returns nil if it fails
//
namespace plClientKey
{
const UInt32* GetKey();
}
#endif // plClientKey_h_inc

View File

@ -1,58 +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/Apps/plClientPatcher/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plClientPatcher/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_INTERN_H
/*****************************************************************************
*
* SelfPatcher.cpp
*
***/
/*==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/Apps/plClientPatcher/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plClientPatcher/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_INTERN_H
/*****************************************************************************
*
* SelfPatcher.cpp
*
***/

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +1,67 @@
/*==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/Apps/plClientPatcher/UruPlayer.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_URUPLAYER_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plClientPatcher/UruPlayer.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_URUPLAYER_H
/*****************************************************************************
*
* UruPlayer.cpp
*
***/
void InitAsyncCore ();
void ShutdownAsyncCore () ;
void UruPrepProc (void * param);
void UruStartProc (void * param);
void PlayerTerminateProc (void * param);
void PlayerStopProc (void * param);
extern const wchar kPatcherExeFilename[];
/*==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/Apps/plClientPatcher/UruPlayer.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_URUPLAYER_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plClientPatcher/UruPlayer.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLCLIENTPATCHER_URUPLAYER_H
/*****************************************************************************
*
* UruPlayer.cpp
*
***/
void InitAsyncCore ();
void ShutdownAsyncCore () ;
void UruPrepProc (void * param);
void UruStartProc (void * param);
void PlayerTerminateProc (void * param);
void PlayerStopProc (void * param);
extern const wchar kPatcherExeFilename[];

View File

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

View File

@ -1,125 +1,125 @@
/*==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 "../plFile/hsFiles.h"
#include "../plFile/plEncryptedStream.h"
#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
#include "hsUtils.h"
void EncryptFiles(const char* dir, const char* ext, bool encrypt);
void print_version(){
wchar productString[256];
ProductString(productString, arrsize(productString));
printf("%S\n\n", productString);
}
void print_help() {
printf("plFileEncrypt - Encrypts and Decrypts Uru Files.\n\n");
print_version();
printf("Usage: plFileEncrypt \t[(encrypt|-e)|(decrypt|-d|)|(--help|-h|-?|/h)|(-v)]\n");
printf("\tencrypt|-e\t - Encrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n");
printf("\tdecrypt|-d\t - Decrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n");
printf("\t--help|-h|-?|/h\t - Prints Help. This Screen.\n");
printf("\t-v|--version\t - Prints build version information\n");
}
int main(int argc, char *argv[])
{
bool encrypt = true;
const char* dir = ".";
if (argc > 1)
{
if (hsStrEQ(argv[1], "encrypt") || hsStrEQ(argv[1], "-e") )
{
if (argc > 2)
dir = argv[2];
encrypt = true;
}
else if (hsStrEQ(argv[1], "decrypt") || hsStrEQ(argv[1], "-d"))
{
if (argc > 2)
dir = argv[2];
encrypt = false;
}
else if(hsStrEQ(argv[1], "--help") || hsStrEQ(argv[1], "-h") || hsStrEQ(argv[1], "-?") || hsStrEQ(argv[1], "/?"))
{
print_help();
return 0;
}
else if (hsStrEQ(argv[1], "-v") || hsStrEQ(argv[1], "--version"))
{
print_version();
return 0;
}
}
EncryptFiles(dir, ".age", encrypt);
EncryptFiles(dir, ".fni", encrypt);
EncryptFiles(dir, ".ini", encrypt);
EncryptFiles(dir, ".sdl", encrypt);
EncryptFiles(dir, ".csv", encrypt);
return 0;
}
void EncryptFiles(const char* dir, const char* ext, bool encrypt)
{
char filePath[256];
hsFolderIterator folder(dir);
while (folder.NextFileSuffix(ext))
{
folder.GetPathAndName(filePath);
if (encrypt)
{
printf("encrypting: %s\n", folder.GetFileName());
plEncryptedStream::FileEncrypt(filePath);
}
else
{
printf("decrypting: %s\n", folder.GetFileName());
plEncryptedStream::FileDecrypt(filePath);
}
}
}
/*==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 "../plFile/hsFiles.h"
#include "../plFile/plEncryptedStream.h"
#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
#include "hsUtils.h"
void EncryptFiles(const char* dir, const char* ext, bool encrypt);
void print_version(){
wchar productString[256];
ProductString(productString, arrsize(productString));
printf("%S\n\n", productString);
}
void print_help() {
printf("plFileEncrypt - Encrypts and Decrypts Uru Files.\n\n");
print_version();
printf("Usage: plFileEncrypt \t[(encrypt|-e)|(decrypt|-d|)|(--help|-h|-?|/h)|(-v)]\n");
printf("\tencrypt|-e\t - Encrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n");
printf("\tdecrypt|-d\t - Decrypts All .age, .fni, .ini, .csv, and .sdl files in the current folder.\n");
printf("\t--help|-h|-?|/h\t - Prints Help. This Screen.\n");
printf("\t-v|--version\t - Prints build version information\n");
}
int main(int argc, char *argv[])
{
bool encrypt = true;
const char* dir = ".";
if (argc > 1)
{
if (hsStrEQ(argv[1], "encrypt") || hsStrEQ(argv[1], "-e") )
{
if (argc > 2)
dir = argv[2];
encrypt = true;
}
else if (hsStrEQ(argv[1], "decrypt") || hsStrEQ(argv[1], "-d"))
{
if (argc > 2)
dir = argv[2];
encrypt = false;
}
else if(hsStrEQ(argv[1], "--help") || hsStrEQ(argv[1], "-h") || hsStrEQ(argv[1], "-?") || hsStrEQ(argv[1], "/?"))
{
print_help();
return 0;
}
else if (hsStrEQ(argv[1], "-v") || hsStrEQ(argv[1], "--version"))
{
print_version();
return 0;
}
}
EncryptFiles(dir, ".age", encrypt);
EncryptFiles(dir, ".fni", encrypt);
EncryptFiles(dir, ".ini", encrypt);
EncryptFiles(dir, ".sdl", encrypt);
EncryptFiles(dir, ".csv", encrypt);
return 0;
}
void EncryptFiles(const char* dir, const char* ext, bool encrypt)
{
char filePath[256];
hsFolderIterator folder(dir);
while (folder.NextFileSuffix(ext))
{
folder.GetPathAndName(filePath);
if (encrypt)
{
printf("encrypting: %s\n", folder.GetFileName());
plEncryptedStream::FileEncrypt(filePath);
}
else
{
printf("decrypting: %s\n", folder.GetFileName());
plEncryptedStream::FileDecrypt(filePath);
}
}
}

View File

@ -1,212 +1,212 @@
/*==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 "../plFile/hsFiles.h"
#include "../plFile/plFileUtils.h"
#include "../plFile/plSecureStream.h"
#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
#include "hsUtils.h"
#include <time.h>
#include <string>
void print_version() {
wchar productString[256];
ProductString(productString, arrsize(productString));
printf("%S\n\n", productString);
}
void print_help() {
printf("plFileSecure - Secures Uru files and generates encryption.key files.\n\n");
print_version();
printf("Usage:\n");
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n");
printf("\n");
printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n");
printf(" be used with /generate. Uses the %s file in\n", plFileUtils::kKeyFilename);
printf(" the current directory (or default key if no file exists)\n");
printf("/generate : Generates a random key and writes it to a %s\n", plFileUtils::kKeyFilename);
printf(" file in the current directory. Cannot be used with\n");
printf(" <directory> <ext>\n");
printf("/default : If used with /generate, creates a %s file\n", plFileUtils::kKeyFilename);
printf(" with the default key. If used with <directory> <ext>, it\n");
printf(" secures with the default key instead of the\n");
printf(" %s file's key\n", plFileUtils::kKeyFilename);
printf("\n");
}
void GenerateKey(bool useDefault)
{
UInt32 key[4];
if (useDefault)
{
unsigned memSize = min(arrsize(key), arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(UInt32);
memcpy(key, plSecureStream::kDefaultKey, memSize);
}
else
{
srand((unsigned)time(nil));
double randNum = (double)rand() / (double)RAND_MAX; // converts to 0..1
UInt32 keyNum = (UInt32)(randNum * (double)0xFFFFFFFF); // multiply it by the max unsigned 32-bit int
key[0] = keyNum;
randNum = (double)rand() / (double)RAND_MAX;
keyNum = (UInt32)(randNum * (double)0xFFFFFFFF);
key[1] = keyNum;
randNum = (double)rand() / (double)RAND_MAX;
keyNum = (UInt32)(randNum * (double)0xFFFFFFFF);
key[2] = keyNum;
randNum = (double)rand() / (double)RAND_MAX;
keyNum = (UInt32)(randNum * (double)0xFFFFFFFF);
key[3] = keyNum;
}
hsUNIXStream out;
out.Open(plFileUtils::kKeyFilename, "wb");
out.Write(sizeof(UInt32) * arrsize(key), (void*)key);
out.Close();
}
void SecureFiles(std::string dir, std::string ext, UInt32* key)
{
char filePath[256];
hsFolderIterator folder(dir.c_str());
while (folder.NextFileSuffix(ext.c_str()))
{
folder.GetPathAndName(filePath);
printf("securing: %s\n", folder.GetFileName());
plSecureStream::FileEncrypt(filePath, key);
}
}
int main(int argc, char *argv[])
{
bool generatingKey = false;
bool useDefault = false;
std::string directory;
std::string ext;
if (argc > 1)
{
for (int i = 1; i < argc; i++)
{
std::string arg = argv[i];
if ((arg[0] == '-')||(arg[0] == '/'))
{
// this arg is a flag of some kind
arg = arg.substr(1, arg.length()); // trim the dash or slash
if ((stricmp(arg.c_str(), "g") == 0) || (stricmp(arg.c_str(), "generate") == 0))
{
if (!generatingKey)
generatingKey = true;
else
{
print_help();
return 0;
}
}
else if ((stricmp(arg.c_str(), "d") == 0) || (stricmp(arg.c_str(), "default") == 0))
{
if (!useDefault)
useDefault = true;
else
{
print_help();
return 0;
}
}
else
{
print_help();
return 0;
}
}
else
{
// else it is a directory or extension
if (directory == "")
directory = argv[i];
else if (ext == "")
ext = argv[i];
else
{
print_help();
return 0;
}
}
}
if (generatingKey && ((directory != "") || (ext != "")))
{
print_help();
return 0;
}
}
else
{
print_help();
return 0;
}
if (generatingKey)
{
GenerateKey(useDefault);
return 0;
}
if (ext[0] != '.')
ext = "." + ext; // tack on the dot if necessary
if (useDefault)
SecureFiles(directory, ext, nil);
else
{
UInt32 key[4];
plFileUtils::GetSecureEncryptionKey(plFileUtils::kKeyFilename, key, arrsize(key));
SecureFiles(directory, ext, key);
}
return 0;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "../plFile/hsFiles.h"
#include "../plFile/plFileUtils.h"
#include "../plFile/plSecureStream.h"
#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
#include "hsUtils.h"
#include <time.h>
#include <string>
void print_version() {
wchar productString[256];
ProductString(productString, arrsize(productString));
printf("%S\n\n", productString);
}
void print_help() {
printf("plFileSecure - Secures Uru files and generates encryption.key files.\n\n");
print_version();
printf("Usage:\n");
printf("\tplFileSecure (<directory> <ext>)|[/generate /default]\n");
printf("\n");
printf("<directory> <ext> : The directory and extension of files to secure. Cannot\n");
printf(" be used with /generate. Uses the %s file in\n", plFileUtils::kKeyFilename);
printf(" the current directory (or default key if no file exists)\n");
printf("/generate : Generates a random key and writes it to a %s\n", plFileUtils::kKeyFilename);
printf(" file in the current directory. Cannot be used with\n");
printf(" <directory> <ext>\n");
printf("/default : If used with /generate, creates a %s file\n", plFileUtils::kKeyFilename);
printf(" with the default key. If used with <directory> <ext>, it\n");
printf(" secures with the default key instead of the\n");
printf(" %s file's key\n", plFileUtils::kKeyFilename);
printf("\n");
}
void GenerateKey(bool useDefault)
{
UInt32 key[4];
if (useDefault)
{
unsigned memSize = min(arrsize(key), arrsize(plSecureStream::kDefaultKey));
memSize *= sizeof(UInt32);
memcpy(key, plSecureStream::kDefaultKey, memSize);
}
else
{
srand((unsigned)time(nil));
double randNum = (double)rand() / (double)RAND_MAX; // converts to 0..1
UInt32 keyNum = (UInt32)(randNum * (double)0xFFFFFFFF); // multiply it by the max unsigned 32-bit int
key[0] = keyNum;
randNum = (double)rand() / (double)RAND_MAX;
keyNum = (UInt32)(randNum * (double)0xFFFFFFFF);
key[1] = keyNum;
randNum = (double)rand() / (double)RAND_MAX;
keyNum = (UInt32)(randNum * (double)0xFFFFFFFF);
key[2] = keyNum;
randNum = (double)rand() / (double)RAND_MAX;
keyNum = (UInt32)(randNum * (double)0xFFFFFFFF);
key[3] = keyNum;
}
hsUNIXStream out;
out.Open(plFileUtils::kKeyFilename, "wb");
out.Write(sizeof(UInt32) * arrsize(key), (void*)key);
out.Close();
}
void SecureFiles(std::string dir, std::string ext, UInt32* key)
{
char filePath[256];
hsFolderIterator folder(dir.c_str());
while (folder.NextFileSuffix(ext.c_str()))
{
folder.GetPathAndName(filePath);
printf("securing: %s\n", folder.GetFileName());
plSecureStream::FileEncrypt(filePath, key);
}
}
int main(int argc, char *argv[])
{
bool generatingKey = false;
bool useDefault = false;
std::string directory;
std::string ext;
if (argc > 1)
{
for (int i = 1; i < argc; i++)
{
std::string arg = argv[i];
if ((arg[0] == '-')||(arg[0] == '/'))
{
// this arg is a flag of some kind
arg = arg.substr(1, arg.length()); // trim the dash or slash
if ((stricmp(arg.c_str(), "g") == 0) || (stricmp(arg.c_str(), "generate") == 0))
{
if (!generatingKey)
generatingKey = true;
else
{
print_help();
return 0;
}
}
else if ((stricmp(arg.c_str(), "d") == 0) || (stricmp(arg.c_str(), "default") == 0))
{
if (!useDefault)
useDefault = true;
else
{
print_help();
return 0;
}
}
else
{
print_help();
return 0;
}
}
else
{
// else it is a directory or extension
if (directory == "")
directory = argv[i];
else if (ext == "")
ext = argv[i];
else
{
print_help();
return 0;
}
}
}
if (generatingKey && ((directory != "") || (ext != "")))
{
print_help();
return 0;
}
}
else
{
print_help();
return 0;
}
if (generatingKey)
{
GenerateKey(useDefault);
return 0;
}
if (ext[0] != '.')
ext = "." + ext; // tack on the dot if necessary
if (useDefault)
SecureFiles(directory, ext, nil);
else
{
UInt32 key[4];
plFileUtils::GetSecureEncryptionKey(plFileUtils::kKeyFilename, key, arrsize(key));
SecureFiles(directory, ext, key);
}
return 0;
}

View File

@ -1,126 +1,126 @@
/*==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==*/
/*****************************************************************************
*
* plLogDecrypt - Used by mantis to decrypt log files
*
***/
#include <stdio.h>
#include "hsTypes.h"
#include "../plStatusLog/plEncryptLogLine.h"
void IProcessFile(const char *path)
{
char out_path[512];
strcpy(out_path, path);
strcat(out_path, ".decrypt");
FILE * fpIn = fopen(path, "rb");
FILE * fpOut = fopen(out_path, "w");
if( fpIn != nil && fpOut != nil)
{
UInt8 line[ 2048 ];
while( !feof( fpIn ) )
{
// Read next string
long pos = ftell(fpIn);
if( pos == -1L )
break;
UInt8 hint = (UInt8)pos;
UInt16 sizeHint = (UInt16)pos;
UInt16 size;
if( stricmp( path + strlen( path ) - 4, ".log" ) == 0 )
{
int i;
for( i = 0; i < 511; i++ )
{
int c = fgetc( fpIn );
if( c == EOF || c == hint )
break;
line[ i ] = (UInt8)c;
}
line[ i ] = 0;
size = i;
}
else
{
// UInt16 line length is encoded first
int c = fgetc( fpIn );
if( c == EOF )
break;
size = ( c & 0xff ) | ( fgetc( fpIn ) << 8 );
size = size ^ sizeHint;
if( size > sizeof( line ) )
{
hsAssert( size <= sizeof( line ) - 1, "Invalid line size" );
break;
}
fread( line, 1, size, fpIn );
line[ size ] = 0;
}
plStatusEncrypt::Decrypt( line, size, hint );
fprintf(fpOut, "%s\n", (const char *)line);
}
}
if (fpIn)
fclose(fpIn);
if (fpOut)
fclose(fpOut);
}
int main(int argc, const char * argv[])
{
if (argc == 2)
{
IProcessFile(argv[1]);
}
return 0;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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==*/
/*****************************************************************************
*
* plLogDecrypt - Used by mantis to decrypt log files
*
***/
#include <stdio.h>
#include "hsTypes.h"
#include "../plStatusLog/plEncryptLogLine.h"
void IProcessFile(const char *path)
{
char out_path[512];
strcpy(out_path, path);
strcat(out_path, ".decrypt");
FILE * fpIn = fopen(path, "rb");
FILE * fpOut = fopen(out_path, "w");
if( fpIn != nil && fpOut != nil)
{
UInt8 line[ 2048 ];
while( !feof( fpIn ) )
{
// Read next string
long pos = ftell(fpIn);
if( pos == -1L )
break;
UInt8 hint = (UInt8)pos;
UInt16 sizeHint = (UInt16)pos;
UInt16 size;
if( stricmp( path + strlen( path ) - 4, ".log" ) == 0 )
{
int i;
for( i = 0; i < 511; i++ )
{
int c = fgetc( fpIn );
if( c == EOF || c == hint )
break;
line[ i ] = (UInt8)c;
}
line[ i ] = 0;
size = i;
}
else
{
// UInt16 line length is encoded first
int c = fgetc( fpIn );
if( c == EOF )
break;
size = ( c & 0xff ) | ( fgetc( fpIn ) << 8 );
size = size ^ sizeHint;
if( size > sizeof( line ) )
{
hsAssert( size <= sizeof( line ) - 1, "Invalid line size" );
break;
}
fread( line, 1, size, fpIn );
line[ size ] = 0;
}
plStatusEncrypt::Decrypt( line, size, hint );
fprintf(fpOut, "%s\n", (const char *)line);
}
}
if (fpIn)
fclose(fpIn);
if (fpOut)
fclose(fpOut);
}
int main(int argc, const char * argv[])
{
if (argc == 2)
{
IProcessFile(argv[1]);
}
return 0;
}

View File

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

View File

@ -1,74 +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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plMD5/Main.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
int __cdecl main (int argc, char ** argv) {
if (argc < 2) {
fprintf(stderr, "ERROR: Please specify filename.\n");
return 1;
}
plMD5Checksum md5(argv[1]);
if (!md5.IsValid()) {
fprintf(stderr, "ERROR: MD5 failed.\n");
return 1;
}
fprintf(stdout, "%s\n", md5.GetAsHexString());
return 0;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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/Apps/plMD5/Main.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
int __cdecl main (int argc, char ** argv) {
if (argc < 2) {
fprintf(stderr, "ERROR: Please specify filename.\n");
return 1;
}
plMD5Checksum md5(argv[1]);
if (!md5.IsValid()) {
fprintf(stderr, "ERROR: MD5 failed.\n");
return 1;
}
fprintf(stdout, "%s\n", md5.GetAsHexString());
return 0;
}

View File

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

View File

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

View File

@ -1,270 +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==*/
#include "hsUtils.h"
#include "hsTimer.h"
#include "../plFile/hsFiles.h"
#include "../plFile/plFileUtils.h"
#include "../plResMgr/plResManager.h"
#include "../plResMgr/plResMgrSettings.h"
#include "../plAgeDescription/plAgeManifest.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plRegistryNode.h"
#include "../plAudioCore/plSoundBuffer.h"
#include "hsStream.h"
#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
//// Globals /////////////////////////////////////////////////////////////////
plResManager* gResMgr = nil;
bool DumpStats(const char* patchDir);
bool DumpSounds();
//// PrintVersion ///////////////////////////////////////////////////////////////
void PrintVersion()
{
wchar productString[256];
ProductString(productString, arrsize(productString));
_putws(productString);
}
//// PrintHelp ///////////////////////////////////////////////////////////////
int PrintHelp( void )
{
puts("");
PrintVersion();
puts("");
puts("Usage: plPageInfo [-s -i] pageFile");
puts(" plPageInfo -v");
puts("Where:" );
puts(" -v print version and exit.");
puts(" -s dump sounds in page to the console");
puts(" -i dump object size info to .csv files");
puts(" pageFile is the path to the .prp file");
puts("");
return -1;
}
//// main ////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
if (argc >= 1 && hsStrEQ(argv[1], "-v"))
{
PrintVersion();
return 0;
}
if (argc < 3)
return PrintHelp();
bool sounds = false;
bool stats = false;
int arg = 1;
for (arg = 1; arg < argc; arg++)
{
if (hsStrEQ(argv[arg], "-s"))
sounds = true;
else if (hsStrEQ(argv[arg], "-i"))
stats = true;
else
break;
}
// Make sure we have 1 arg left after getting the options
char* pageFile = nil;
if (arg < argc)
pageFile = argv[arg];
else
return PrintHelp();
// Init our special resMgr
plResMgrSettings::Get().SetFilterNewerPageVersions(false);
plResMgrSettings::Get().SetFilterOlderPageVersions(false);
plResMgrSettings::Get().SetLoadPagesOnInit(false);
gResMgr = TRACKED_NEW plResManager;
hsgResMgr::Init(gResMgr);
gResMgr->AddSinglePage(pageFile);
if (sounds)
DumpSounds();
if (stats)
{
char path[256];
strcpy(path, pageFile);
plFileUtils::StripFile(path);
DumpStats(path);
}
hsgResMgr::Shutdown();
return 0;
}
//// plSoundBufferCollector //////////////////////////////////////////////////
// Page iterator that collects all the plSoundBuffers in all of our pages
class plSoundBufferCollector : public plRegistryPageIterator, public plKeyCollector
{
public:
plSoundBufferCollector(std::set<plKey>& keyArray)
: plKeyCollector(keyArray) {}
hsBool EatPage(plRegistryPageNode* page)
{
page->LoadKeys();
return page->IterateKeys(this, plSoundBuffer::Index());
return true;
}
};
bool DumpSounds()
{
std::set<plKey> soundKeys;
plSoundBufferCollector soundCollector(soundKeys);
gResMgr->IterateAllPages(&soundCollector);
for (std::set<plKey>::iterator it = soundKeys.begin(); it != soundKeys.end(); ++it)
{
plSoundBuffer* buffer = plSoundBuffer::ConvertNoRef((*it)->VerifyLoaded());
if (buffer)
{
// Ref it...
buffer->GetKey()->RefObject();
// Get the filename from it and add that file if necessary
const char* filename = buffer->GetFileName();
if (filename)
{
UInt32 flags = 0;
if (stricmp(plFileUtils::GetFileExt(filename), "wav") != 0)
{
if (buffer->HasFlag(plSoundBuffer::kOnlyLeftChannel) ||
buffer->HasFlag(plSoundBuffer::kOnlyRightChannel))
hsSetBits(flags, plManifestFile::kSndFlagCacheSplit);
else if (buffer->HasFlag(plSoundBuffer::kStreamCompressed))
hsSetBits(flags, plManifestFile::kSndFlagStreamCompressed);
else
hsSetBits(flags, plManifestFile::kSndFlagCacheStereo);
}
printf("%s,%u\n", filename, flags);
}
// Unref the object so it goes away
buffer->GetKey()->UnRefObject();
}
}
soundKeys.clear();
plIndirectUnloadIterator iter;
gResMgr->IterateAllPages(&iter);
return true;
}
//////////////////////////////////////////////////////////////////////////
#include "../pnKeyedObject/plKeyImp.h"
class plStatDumpIterator : public plRegistryPageIterator, public plRegistryKeyIterator
{
protected:
const char* fOutputDir;
hsUNIXStream fStream;
public:
plStatDumpIterator(const char* outputDir) : fOutputDir(outputDir) {}
hsBool EatKey(const plKey& key)
{
plKeyImp* imp = (plKey)key;
fStream.WriteString(imp->GetName());
fStream.WriteString(",");
fStream.WriteString(plFactory::GetNameOfClass(imp->GetUoid().GetClassType()));
fStream.WriteString(",");
char buf[30];
sprintf(buf, "%u", imp->GetDataLen());
fStream.WriteString(buf);
fStream.WriteString("\n");
return true;
}
hsBool EatPage(plRegistryPageNode* page)
{
const plPageInfo& info = page->GetPageInfo();
char fileName[256];
sprintf(fileName, "%s%s_%s.csv", fOutputDir, info.GetAge(), info.GetPage());
fStream.Open(fileName, "wt");
page->LoadKeys();
page->IterateKeys(this);
fStream.Close();
return true;
}
};
bool DumpStats(const char* patchDir)
{
plStatDumpIterator statDump(patchDir);
gResMgr->IterateAllPages(&statDump);
return true;
/*==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 "hsUtils.h"
#include "hsTimer.h"
#include "../plFile/hsFiles.h"
#include "../plFile/plFileUtils.h"
#include "../plResMgr/plResManager.h"
#include "../plResMgr/plResMgrSettings.h"
#include "../plAgeDescription/plAgeManifest.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plRegistryNode.h"
#include "../plAudioCore/plSoundBuffer.h"
#include "hsStream.h"
#include "../pnUtils/pnUtils.h"
#include "../pnProduct/pnProduct.h"
//// Globals /////////////////////////////////////////////////////////////////
plResManager* gResMgr = nil;
bool DumpStats(const char* patchDir);
bool DumpSounds();
//// PrintVersion ///////////////////////////////////////////////////////////////
void PrintVersion()
{
wchar productString[256];
ProductString(productString, arrsize(productString));
_putws(productString);
}
//// PrintHelp ///////////////////////////////////////////////////////////////
int PrintHelp( void )
{
puts("");
PrintVersion();
puts("");
puts("Usage: plPageInfo [-s -i] pageFile");
puts(" plPageInfo -v");
puts("Where:" );
puts(" -v print version and exit.");
puts(" -s dump sounds in page to the console");
puts(" -i dump object size info to .csv files");
puts(" pageFile is the path to the .prp file");
puts("");
return -1;
}
//// main ////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])
{
if (argc >= 1 && hsStrEQ(argv[1], "-v"))
{
PrintVersion();
return 0;
}
if (argc < 3)
return PrintHelp();
bool sounds = false;
bool stats = false;
int arg = 1;
for (arg = 1; arg < argc; arg++)
{
if (hsStrEQ(argv[arg], "-s"))
sounds = true;
else if (hsStrEQ(argv[arg], "-i"))
stats = true;
else
break;
}
// Make sure we have 1 arg left after getting the options
char* pageFile = nil;
if (arg < argc)
pageFile = argv[arg];
else
return PrintHelp();
// Init our special resMgr
plResMgrSettings::Get().SetFilterNewerPageVersions(false);
plResMgrSettings::Get().SetFilterOlderPageVersions(false);
plResMgrSettings::Get().SetLoadPagesOnInit(false);
gResMgr = TRACKED_NEW plResManager;
hsgResMgr::Init(gResMgr);
gResMgr->AddSinglePage(pageFile);
if (sounds)
DumpSounds();
if (stats)
{
char path[256];
strcpy(path, pageFile);
plFileUtils::StripFile(path);
DumpStats(path);
}
hsgResMgr::Shutdown();
return 0;
}
//// plSoundBufferCollector //////////////////////////////////////////////////
// Page iterator that collects all the plSoundBuffers in all of our pages
class plSoundBufferCollector : public plRegistryPageIterator, public plKeyCollector
{
public:
plSoundBufferCollector(std::set<plKey>& keyArray)
: plKeyCollector(keyArray) {}
hsBool EatPage(plRegistryPageNode* page)
{
page->LoadKeys();
return page->IterateKeys(this, plSoundBuffer::Index());
return true;
}
};
bool DumpSounds()
{
std::set<plKey> soundKeys;
plSoundBufferCollector soundCollector(soundKeys);
gResMgr->IterateAllPages(&soundCollector);
for (std::set<plKey>::iterator it = soundKeys.begin(); it != soundKeys.end(); ++it)
{
plSoundBuffer* buffer = plSoundBuffer::ConvertNoRef((*it)->VerifyLoaded());
if (buffer)
{
// Ref it...
buffer->GetKey()->RefObject();
// Get the filename from it and add that file if necessary
const char* filename = buffer->GetFileName();
if (filename)
{
UInt32 flags = 0;
if (stricmp(plFileUtils::GetFileExt(filename), "wav") != 0)
{
if (buffer->HasFlag(plSoundBuffer::kOnlyLeftChannel) ||
buffer->HasFlag(plSoundBuffer::kOnlyRightChannel))
hsSetBits(flags, plManifestFile::kSndFlagCacheSplit);
else if (buffer->HasFlag(plSoundBuffer::kStreamCompressed))
hsSetBits(flags, plManifestFile::kSndFlagStreamCompressed);
else
hsSetBits(flags, plManifestFile::kSndFlagCacheStereo);
}
printf("%s,%u\n", filename, flags);
}
// Unref the object so it goes away
buffer->GetKey()->UnRefObject();
}
}
soundKeys.clear();
plIndirectUnloadIterator iter;
gResMgr->IterateAllPages(&iter);
return true;
}
//////////////////////////////////////////////////////////////////////////
#include "../pnKeyedObject/plKeyImp.h"
class plStatDumpIterator : public plRegistryPageIterator, public plRegistryKeyIterator
{
protected:
const char* fOutputDir;
hsUNIXStream fStream;
public:
plStatDumpIterator(const char* outputDir) : fOutputDir(outputDir) {}
hsBool EatKey(const plKey& key)
{
plKeyImp* imp = (plKey)key;
fStream.WriteString(imp->GetName());
fStream.WriteString(",");
fStream.WriteString(plFactory::GetNameOfClass(imp->GetUoid().GetClassType()));
fStream.WriteString(",");
char buf[30];
sprintf(buf, "%u", imp->GetDataLen());
fStream.WriteString(buf);
fStream.WriteString("\n");
return true;
}
hsBool EatPage(plRegistryPageNode* page)
{
const plPageInfo& info = page->GetPageInfo();
char fileName[256];
sprintf(fileName, "%s%s_%s.csv", fOutputDir, info.GetAge(), info.GetPage());
fStream.Open(fileName, "wt");
page->LoadKeys();
page->IterateKeys(this);
fStream.Close();
return true;
}
};
bool DumpStats(const char* patchDir)
{
plStatDumpIterator statDump(patchDir);
gResMgr->IterateAllPages(&statDump);
return true;
}

View File

@ -1,121 +1,121 @@
/*==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 "../plResMgr/plResManager.h"
#include "../pfPython/plPythonFileMod.h"
#include "../plGImage/plFontCache.h"
#include "../plPhysX/plSimulationMgr.h"
#include "../plAvatar/plAvatarMgr.h"
#include "plPageOptimizer.h"
#include "../plFile/plFileUtils.h"
int main(int argc, char* argv[])
{
if (argc != 2)
{
printf("plPageOptimizer: wrong number of arguments");
return 1;
}
printf("Optimizing %s...", plFileUtils::GetFileName(argv[1]));
plFontCache* fontCache;
#ifndef _DEBUG
try
{
#endif
plResManager* resMgr = TRACKED_NEW plResManager;
hsgResMgr::Init(resMgr);
// Setup all the crap that needs to be around to load
plSimulationMgr::Init();
fontCache = TRACKED_NEW plFontCache;
plPythonFileMod::SetAtConvertTime();
#ifndef _DEBUG
} catch (...)
{
printf(" ***crashed on init");
return 2;
}
#endif
#ifndef _DEBUG
try
#endif
{
plPageOptimizer optimizer(argv[1]);
optimizer.Optimize();
}
#ifndef _DEBUG
catch (...)
{
printf(" ***crashed on optimizing");
return 2;
}
#endif
#ifndef _DEBUG
try
{
#endif
// Deinit the crap
fontCache->UnRegisterAs(kFontCache_KEY);
fontCache = nil;
plSimulationMgr::Shutdown();
// Reading in objects may have generated dirty state which we're obviously
// not sending out. Clear it so that we don't have leaked keys before the
// ResMgr goes away.
std::vector<plSynchedObject::StateDefn> carryOvers;
plSynchedObject::ClearDirtyState(carryOvers);
hsgResMgr::Shutdown();
#ifndef _DEBUG
} catch (...)
{
printf(" ***crashed on shutdown");
return 2;
}
#endif
return 0;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "../plResMgr/plResManager.h"
#include "../pfPython/plPythonFileMod.h"
#include "../plGImage/plFontCache.h"
#include "../plPhysX/plSimulationMgr.h"
#include "../plAvatar/plAvatarMgr.h"
#include "plPageOptimizer.h"
#include "../plFile/plFileUtils.h"
int main(int argc, char* argv[])
{
if (argc != 2)
{
printf("plPageOptimizer: wrong number of arguments");
return 1;
}
printf("Optimizing %s...", plFileUtils::GetFileName(argv[1]));
plFontCache* fontCache;
#ifndef _DEBUG
try
{
#endif
plResManager* resMgr = TRACKED_NEW plResManager;
hsgResMgr::Init(resMgr);
// Setup all the crap that needs to be around to load
plSimulationMgr::Init();
fontCache = TRACKED_NEW plFontCache;
plPythonFileMod::SetAtConvertTime();
#ifndef _DEBUG
} catch (...)
{
printf(" ***crashed on init");
return 2;
}
#endif
#ifndef _DEBUG
try
#endif
{
plPageOptimizer optimizer(argv[1]);
optimizer.Optimize();
}
#ifndef _DEBUG
catch (...)
{
printf(" ***crashed on optimizing");
return 2;
}
#endif
#ifndef _DEBUG
try
{
#endif
// Deinit the crap
fontCache->UnRegisterAs(kFontCache_KEY);
fontCache = nil;
plSimulationMgr::Shutdown();
// Reading in objects may have generated dirty state which we're obviously
// not sending out. Clear it so that we don't have leaked keys before the
// ResMgr goes away.
std::vector<plSynchedObject::StateDefn> carryOvers;
plSynchedObject::ClearDirtyState(carryOvers);
hsgResMgr::Shutdown();
#ifndef _DEBUG
} catch (...)
{
printf(" ***crashed on shutdown");
return 2;
}
#endif
return 0;
}

View File

@ -1,56 +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==*/
#include "../pfCharacter/pfCharacterCreatable.h"
#include "../pfCamera/pfCameraCreatable.h"
#include "../pfAnimation/pfAnimationCreatable.h"
#include "../pfConditional/plConditionalObjectCreatable.h"
//#include "../pfConsole/pfConsoleCreatable.h"
#include "../pfSurface/pfSurfaceCreatable.h"
#include "../pfMessage/pfMessageCreatable.h"
#include "../pfAudio/pfAudioCreatable.h"
#include "../pfPython/pfPythonCreatable.h"
#include "../pfGameGUIMgr/pfGameGUIMgrCreatable.h"
#ifdef PLASMA_CCR_RELEASE
#include "../pfCCR/plCCRCreatable.h"
#endif // PLASMA_CCR_RELEASE
#include "../pfJournalBook/pfJournalBookCreatable.h"
#include "../pfGameMgr/pfGameMgrCreatables.h"
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "../pfCharacter/pfCharacterCreatable.h"
#include "../pfCamera/pfCameraCreatable.h"
#include "../pfAnimation/pfAnimationCreatable.h"
#include "../pfConditional/plConditionalObjectCreatable.h"
//#include "../pfConsole/pfConsoleCreatable.h"
#include "../pfSurface/pfSurfaceCreatable.h"
#include "../pfMessage/pfMessageCreatable.h"
#include "../pfAudio/pfAudioCreatable.h"
#include "../pfPython/pfPythonCreatable.h"
#include "../pfGameGUIMgr/pfGameGUIMgrCreatable.h"
#ifdef PLASMA_CCR_RELEASE
#include "../pfCCR/plCCRCreatable.h"
#endif // PLASMA_CCR_RELEASE
#include "../pfJournalBook/pfJournalBookCreatable.h"
#include "../pfGameMgr/pfGameMgrCreatables.h"

View File

@ -1,285 +1,285 @@
/*==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 "plPageOptimizer.h"
#include "../pnKeyedObject/plUoid.h"
#include "../plResMgr/plResManager.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plKeyFinder.h"
#include "../plResMgr/plRegistryNode.h"
#include "../pnFactory/plFactory.h"
#include "../pnKeyedObject/plKeyImp.h"
#include "../plFile/plFileUtils.h"
#include "hsStream.h"
plPageOptimizer* plPageOptimizer::fInstance = nil;
plPageOptimizer::plPageOptimizer(const char* pagePath) :
fOptimized(true),
fPageNode(nil),
fPagePath(pagePath)
{
fInstance = this;
strcpy(fTempPagePath, fPagePath);
plFileUtils::StripExt(fTempPagePath);
strcat(fTempPagePath, "_opt.prp");
fResMgr = (plResManager*)hsgResMgr::ResMgr();
}
void plPageOptimizer::IFindLoc()
{
class plPageIt : public plRegistryPageIterator
{
public:
plLocation fLoc;
virtual hsBool EatPage(plRegistryPageNode* keyNode)
{
fLoc = keyNode->GetPageInfo().GetLocation();
return true;
}
};
plPageIt it;
fResMgr->IterateAllPages(&it);
fLoc = it.fLoc;
}
void plPageOptimizer::Optimize()
{
fResMgr->AddSinglePage(fPagePath);
// Get the location of the page we're optimizing
IFindLoc();
hsBool loaded = true;
// Get the key for the scene node, we'll load it to force a load on all the objects
plKey snKey = plKeyFinder::Instance().FindSceneNodeKey(fLoc);
if (snKey)
{
// Load all the keys
fPageNode = fResMgr->FindPage(fLoc);
fResMgr->LoadPageKeys(fPageNode);
// Put all the keys in a vector, so they won't get unreffed
class plVecKeyCollector : public plRegistryKeyIterator
{
public:
KeyVec& fKeys;
plVecKeyCollector(KeyVec& keys) : fKeys(keys) {}
virtual hsBool EatKey(const plKey& key) { fKeys.push_back(key); return true; }
};
plVecKeyCollector keyIt(fAllKeys);
fResMgr->IterateKeys(&keyIt);
// Set our load proc, which will track the order that objects are loaded
fResMgr->SetProgressBarProc(KeyedObjectProc);
// Load the page
snKey->VerifyLoaded();
// Unload everything
snKey->RefObject();
snKey->UnRefObject();
snKey = nil;
}
else
{
loaded = false;
}
if (loaded)
IRewritePage();
UInt32 oldSize = plFileUtils::GetFileSize(fPagePath);
UInt32 newSize = plFileUtils::GetFileSize(fTempPagePath);
if (!loaded)
{
printf("no scene node.\n");
}
else if (fOptimized)
{
plFileUtils::RemoveFile(fTempPagePath);
printf("already optimized.\n");
}
else if (oldSize == newSize)
{
plFileUtils::RemoveFile(fPagePath, true);
plFileUtils::FileMove(fTempPagePath, fPagePath);
printf("complete\n");
}
else
{
plFileUtils::RemoveFile(fTempPagePath);
printf("failed. File sizes different\n");
}
}
void plPageOptimizer::KeyedObjectProc(plKey key)
{
const char* keyName = key->GetName();
const char* className = plFactory::GetNameOfClass(key->GetUoid().GetClassType());
// For now, ignore any key that isn't in the location we're looking at. That means stuff like textures.
if (fInstance->fLoc != key->GetUoid().GetLocation())
return;
KeySet& loadedKeys = fInstance->fLoadedKeys;
KeyVec& loadOrder = fInstance->fKeyLoadOrder;
KeySet::iterator it = loadedKeys.lower_bound(key);
if (it != loadedKeys.end() && *it == key)
{
printf("Keyed object %s(%s) loaded more than once\n", keyName, className);
}
else
{
loadedKeys.insert(it, key);
loadOrder.push_back(key);
}
}
void plPageOptimizer::IWriteKeyData(hsStream* oldPage, hsStream* newPage, plKey key)
{
class plUpdateKeyImp : public plKeyImp
{
public:
void SetStartPos(UInt32 startPos) { fStartPos = startPos; }
};
plUpdateKeyImp* keyImp = (plUpdateKeyImp*)(plKeyImp*)key;
UInt32 startPos = keyImp->GetStartPos();
UInt32 len = keyImp->GetDataLen();
oldPage->SetPosition(startPos);
if (len > fBuf.size())
fBuf.resize(len);
oldPage->Read(len, &fBuf[0]);
UInt32 newStartPos = newPage->GetPosition();
// If we move any buffers, this page wasn't optimized already
if (newStartPos != startPos)
fOptimized = false;
keyImp->SetStartPos(newStartPos);
newPage->Write(len, &fBuf[0]);
}
void plPageOptimizer::IRewritePage()
{
hsUNIXStream newPage;
if (newPage.Open(fTempPagePath, "wb"))
{
hsUNIXStream oldPage;
oldPage.Open(fPagePath);
const plPageInfo& pageInfo = fPageNode->GetPageInfo();
UInt32 dataStart = pageInfo.GetDataStart();
fBuf.resize(dataStart);
oldPage.Read(dataStart, &fBuf[0]);
newPage.Write(dataStart, &fBuf[0]);
int size = (int)fKeyLoadOrder.size();
for (int i = 0; i < size; i++)
IWriteKeyData(&oldPage, &newPage, fKeyLoadOrder[i]);
// If there are any objects that we didn't write (because they didn't load for
// some reason), put them at the end
for (int i = 0; i < fAllKeys.size(); i++)
{
hsBool found = (fLoadedKeys.find(fAllKeys[i]) != fLoadedKeys.end());
if (!found)
IWriteKeyData(&oldPage, &newPage, fAllKeys[i]);
}
UInt32 newKeyStart = newPage.GetPosition();
UInt32 oldKeyStart = pageInfo.GetIndexStart();
oldPage.SetPosition(oldKeyStart);
UInt32 numTypes = oldPage.ReadSwap32();
newPage.WriteSwap32(numTypes);
for (UInt32 i = 0; i < numTypes; i++)
{
UInt16 classType = oldPage.ReadSwap16();
UInt32 len = oldPage.ReadSwap32();
UInt8 flags = oldPage.ReadByte();
UInt32 numKeys = oldPage.ReadSwap32();
newPage.WriteSwap16(classType);
newPage.WriteSwap32(len);
newPage.WriteByte(flags);
newPage.WriteSwap32(numKeys);
for (UInt32 j = 0; j < numKeys; j++)
{
plUoid uoid;
uoid.Read(&oldPage);
UInt32 startPos = oldPage.ReadSwap32();
UInt32 dataLen = oldPage.ReadSwap32();
// Get the new start pos
plKeyImp* key = (plKeyImp*)fResMgr->FindKey(uoid);
startPos = key->GetStartPos();
uoid.Write(&newPage);
newPage.WriteSwap32(startPos);
newPage.WriteSwap32(dataLen);
}
}
newPage.Close();
oldPage.Close();
}
}
/*==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 "plPageOptimizer.h"
#include "../pnKeyedObject/plUoid.h"
#include "../plResMgr/plResManager.h"
#include "../plResMgr/plRegistryHelpers.h"
#include "../plResMgr/plKeyFinder.h"
#include "../plResMgr/plRegistryNode.h"
#include "../pnFactory/plFactory.h"
#include "../pnKeyedObject/plKeyImp.h"
#include "../plFile/plFileUtils.h"
#include "hsStream.h"
plPageOptimizer* plPageOptimizer::fInstance = nil;
plPageOptimizer::plPageOptimizer(const char* pagePath) :
fOptimized(true),
fPageNode(nil),
fPagePath(pagePath)
{
fInstance = this;
strcpy(fTempPagePath, fPagePath);
plFileUtils::StripExt(fTempPagePath);
strcat(fTempPagePath, "_opt.prp");
fResMgr = (plResManager*)hsgResMgr::ResMgr();
}
void plPageOptimizer::IFindLoc()
{
class plPageIt : public plRegistryPageIterator
{
public:
plLocation fLoc;
virtual hsBool EatPage(plRegistryPageNode* keyNode)
{
fLoc = keyNode->GetPageInfo().GetLocation();
return true;
}
};
plPageIt it;
fResMgr->IterateAllPages(&it);
fLoc = it.fLoc;
}
void plPageOptimizer::Optimize()
{
fResMgr->AddSinglePage(fPagePath);
// Get the location of the page we're optimizing
IFindLoc();
hsBool loaded = true;
// Get the key for the scene node, we'll load it to force a load on all the objects
plKey snKey = plKeyFinder::Instance().FindSceneNodeKey(fLoc);
if (snKey)
{
// Load all the keys
fPageNode = fResMgr->FindPage(fLoc);
fResMgr->LoadPageKeys(fPageNode);
// Put all the keys in a vector, so they won't get unreffed
class plVecKeyCollector : public plRegistryKeyIterator
{
public:
KeyVec& fKeys;
plVecKeyCollector(KeyVec& keys) : fKeys(keys) {}
virtual hsBool EatKey(const plKey& key) { fKeys.push_back(key); return true; }
};
plVecKeyCollector keyIt(fAllKeys);
fResMgr->IterateKeys(&keyIt);
// Set our load proc, which will track the order that objects are loaded
fResMgr->SetProgressBarProc(KeyedObjectProc);
// Load the page
snKey->VerifyLoaded();
// Unload everything
snKey->RefObject();
snKey->UnRefObject();
snKey = nil;
}
else
{
loaded = false;
}
if (loaded)
IRewritePage();
UInt32 oldSize = plFileUtils::GetFileSize(fPagePath);
UInt32 newSize = plFileUtils::GetFileSize(fTempPagePath);
if (!loaded)
{
printf("no scene node.\n");
}
else if (fOptimized)
{
plFileUtils::RemoveFile(fTempPagePath);
printf("already optimized.\n");
}
else if (oldSize == newSize)
{
plFileUtils::RemoveFile(fPagePath, true);
plFileUtils::FileMove(fTempPagePath, fPagePath);
printf("complete\n");
}
else
{
plFileUtils::RemoveFile(fTempPagePath);
printf("failed. File sizes different\n");
}
}
void plPageOptimizer::KeyedObjectProc(plKey key)
{
const char* keyName = key->GetName();
const char* className = plFactory::GetNameOfClass(key->GetUoid().GetClassType());
// For now, ignore any key that isn't in the location we're looking at. That means stuff like textures.
if (fInstance->fLoc != key->GetUoid().GetLocation())
return;
KeySet& loadedKeys = fInstance->fLoadedKeys;
KeyVec& loadOrder = fInstance->fKeyLoadOrder;
KeySet::iterator it = loadedKeys.lower_bound(key);
if (it != loadedKeys.end() && *it == key)
{
printf("Keyed object %s(%s) loaded more than once\n", keyName, className);
}
else
{
loadedKeys.insert(it, key);
loadOrder.push_back(key);
}
}
void plPageOptimizer::IWriteKeyData(hsStream* oldPage, hsStream* newPage, plKey key)
{
class plUpdateKeyImp : public plKeyImp
{
public:
void SetStartPos(UInt32 startPos) { fStartPos = startPos; }
};
plUpdateKeyImp* keyImp = (plUpdateKeyImp*)(plKeyImp*)key;
UInt32 startPos = keyImp->GetStartPos();
UInt32 len = keyImp->GetDataLen();
oldPage->SetPosition(startPos);
if (len > fBuf.size())
fBuf.resize(len);
oldPage->Read(len, &fBuf[0]);
UInt32 newStartPos = newPage->GetPosition();
// If we move any buffers, this page wasn't optimized already
if (newStartPos != startPos)
fOptimized = false;
keyImp->SetStartPos(newStartPos);
newPage->Write(len, &fBuf[0]);
}
void plPageOptimizer::IRewritePage()
{
hsUNIXStream newPage;
if (newPage.Open(fTempPagePath, "wb"))
{
hsUNIXStream oldPage;
oldPage.Open(fPagePath);
const plPageInfo& pageInfo = fPageNode->GetPageInfo();
UInt32 dataStart = pageInfo.GetDataStart();
fBuf.resize(dataStart);
oldPage.Read(dataStart, &fBuf[0]);
newPage.Write(dataStart, &fBuf[0]);
int size = (int)fKeyLoadOrder.size();
for (int i = 0; i < size; i++)
IWriteKeyData(&oldPage, &newPage, fKeyLoadOrder[i]);
// If there are any objects that we didn't write (because they didn't load for
// some reason), put them at the end
for (int i = 0; i < fAllKeys.size(); i++)
{
hsBool found = (fLoadedKeys.find(fAllKeys[i]) != fLoadedKeys.end());
if (!found)
IWriteKeyData(&oldPage, &newPage, fAllKeys[i]);
}
UInt32 newKeyStart = newPage.GetPosition();
UInt32 oldKeyStart = pageInfo.GetIndexStart();
oldPage.SetPosition(oldKeyStart);
UInt32 numTypes = oldPage.ReadSwap32();
newPage.WriteSwap32(numTypes);
for (UInt32 i = 0; i < numTypes; i++)
{
UInt16 classType = oldPage.ReadSwap16();
UInt32 len = oldPage.ReadSwap32();
UInt8 flags = oldPage.ReadByte();
UInt32 numKeys = oldPage.ReadSwap32();
newPage.WriteSwap16(classType);
newPage.WriteSwap32(len);
newPage.WriteByte(flags);
newPage.WriteSwap32(numKeys);
for (UInt32 j = 0; j < numKeys; j++)
{
plUoid uoid;
uoid.Read(&oldPage);
UInt32 startPos = oldPage.ReadSwap32();
UInt32 dataLen = oldPage.ReadSwap32();
// Get the new start pos
plKeyImp* key = (plKeyImp*)fResMgr->FindKey(uoid);
startPos = key->GetStartPos();
uoid.Write(&newPage);
newPage.WriteSwap32(startPos);
newPage.WriteSwap32(dataLen);
}
}
newPage.Close();
oldPage.Close();
}
}

View File

@ -1,86 +1,86 @@
/*==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 plPageOptimizer_h_inc
#define plPageOptimizer_h_inc
#include "../pnKeyedObject/plKey.h"
#include "../pnKeyedObject/plUoid.h"
#include <vector>
#include <set>
class plRegistryPageNode;
class plResManager;
class plPageOptimizer
{
protected:
typedef std::vector<plKey> KeyVec;
typedef std::set<plKey> KeySet;
KeyVec fKeyLoadOrder; // The order objects were loaded in
KeySet fLoadedKeys; // Keys we've loaded objects for, for quick lookup
KeyVec fAllKeys; // All the keys in the page
std::vector<UInt8> fBuf;
bool fOptimized; // True after optimization if the page was already optimized
const char* fPagePath; // Path to our page
char fTempPagePath[512]; // Path to the temp output page
plLocation fLoc; // Location of our page
plRegistryPageNode* fPageNode; // PageNode for our page
plResManager* fResMgr;
static plPageOptimizer* fInstance;
static void KeyedObjectProc(plKey key);
void IWriteKeyData(hsStream* oldPage, hsStream* newPage, plKey key);
void IFindLoc();
void IRewritePage();
public:
plPageOptimizer(const char* pagePath);
void Optimize();
};
/*==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 plPageOptimizer_h_inc
#define plPageOptimizer_h_inc
#include "../pnKeyedObject/plKey.h"
#include "../pnKeyedObject/plUoid.h"
#include <vector>
#include <set>
class plRegistryPageNode;
class plResManager;
class plPageOptimizer
{
protected:
typedef std::vector<plKey> KeyVec;
typedef std::set<plKey> KeySet;
KeyVec fKeyLoadOrder; // The order objects were loaded in
KeySet fLoadedKeys; // Keys we've loaded objects for, for quick lookup
KeyVec fAllKeys; // All the keys in the page
std::vector<UInt8> fBuf;
bool fOptimized; // True after optimization if the page was already optimized
const char* fPagePath; // Path to our page
char fTempPagePath[512]; // Path to the temp output page
plLocation fLoc; // Location of our page
plRegistryPageNode* fPageNode; // PageNode for our page
plResManager* fResMgr;
static plPageOptimizer* fInstance;
static void KeyedObjectProc(plKey key);
void IWriteKeyData(hsStream* oldPage, hsStream* newPage, plKey key);
void IFindLoc();
void IRewritePage();
public:
plPageOptimizer(const char* pagePath);
void Optimize();
};
#endif // plPageOptimizer_h_inc

View File

@ -1,63 +1,63 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "HeadSpin.h"
#include "plPlasmaInstaller.h"
#include "jvCoreUtil.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaInstaller installer;
installer.Create();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!IsDialogMessage(installer.GetHWnd(), &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
/*==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 "HeadSpin.h"
#include "plPlasmaInstaller.h"
#include "jvCoreUtil.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaInstaller installer;
installer.Create();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!IsDialogMessage(installer.GetHWnd(), &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}

View File

@ -1,113 +1,113 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "HeadSpin.h"
#include "plInstallerReg.h"
#include <windows.h>
static HKEY GetInstallerKey()
{
HKEY hSoftKey = NULL;
HKEY hCompanyKey = NULL;
HKEY hAppKey = NULL;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "software", 0, KEY_WRITE|KEY_READ,
&hSoftKey) == ERROR_SUCCESS)
{
DWORD dw;
if(RegCreateKeyEx(hSoftKey, "Cyan", 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hCompanyKey, &dw) == ERROR_SUCCESS)
{
RegCreateKeyEx(hCompanyKey, "PlasmaInstaller", 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hAppKey, &dw);
}
}
if (hSoftKey != NULL)
RegCloseKey(hSoftKey);
if (hCompanyKey != NULL)
RegCloseKey(hCompanyKey);
return hAppKey;
}
static void WriteRegString(const char* valueName, const char* value)
{
HKEY installKey = GetInstallerKey();
RegSetValueEx(installKey, valueName, 0, REG_SZ, (const BYTE*)value, strlen(value)+1);
RegCloseKey(installKey);
}
static bool ReadRegString(const char* valueName, char* value, DWORD size)
{
HKEY installKey = GetInstallerKey();
bool ret = (RegQueryValueEx(installKey, valueName, NULL, NULL, (LPBYTE)value, &size) == ERROR_SUCCESS);
RegCloseKey(installKey);
return ret;
}
void plInstallerReg::SetClientDir(const char* dir)
{
WriteRegString("Client", dir);
}
void plInstallerReg::SetMaxDir(const char* dir)
{
WriteRegString("3dsmax", dir);
}
const char* plInstallerReg::GetClientDir()
{
static char dir[MAX_PATH];
if (!ReadRegString("Client", dir, sizeof(dir)))
strcpy(dir, "C:\\PlasmaClient");
return dir;
}
const char* plInstallerReg::GetMaxDir()
{
static char dir[MAX_PATH];
dir[0] = '\0';
ReadRegString("3dsmax", dir, sizeof(dir));
return dir;
}
/*==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 "HeadSpin.h"
#include "plInstallerReg.h"
#include <windows.h>
static HKEY GetInstallerKey()
{
HKEY hSoftKey = NULL;
HKEY hCompanyKey = NULL;
HKEY hAppKey = NULL;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "software", 0, KEY_WRITE|KEY_READ,
&hSoftKey) == ERROR_SUCCESS)
{
DWORD dw;
if(RegCreateKeyEx(hSoftKey, "Cyan", 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hCompanyKey, &dw) == ERROR_SUCCESS)
{
RegCreateKeyEx(hCompanyKey, "PlasmaInstaller", 0, REG_NONE,
REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
&hAppKey, &dw);
}
}
if (hSoftKey != NULL)
RegCloseKey(hSoftKey);
if (hCompanyKey != NULL)
RegCloseKey(hCompanyKey);
return hAppKey;
}
static void WriteRegString(const char* valueName, const char* value)
{
HKEY installKey = GetInstallerKey();
RegSetValueEx(installKey, valueName, 0, REG_SZ, (const BYTE*)value, strlen(value)+1);
RegCloseKey(installKey);
}
static bool ReadRegString(const char* valueName, char* value, DWORD size)
{
HKEY installKey = GetInstallerKey();
bool ret = (RegQueryValueEx(installKey, valueName, NULL, NULL, (LPBYTE)value, &size) == ERROR_SUCCESS);
RegCloseKey(installKey);
return ret;
}
void plInstallerReg::SetClientDir(const char* dir)
{
WriteRegString("Client", dir);
}
void plInstallerReg::SetMaxDir(const char* dir)
{
WriteRegString("3dsmax", dir);
}
const char* plInstallerReg::GetClientDir()
{
static char dir[MAX_PATH];
if (!ReadRegString("Client", dir, sizeof(dir)))
strcpy(dir, "C:\\PlasmaClient");
return dir;
}
const char* plInstallerReg::GetMaxDir()
{
static char dir[MAX_PATH];
dir[0] = '\0';
ReadRegString("3dsmax", dir, sizeof(dir));
return dir;
}

View File

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

View File

@ -1,408 +1,408 @@
/*==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 "HeadSpin.h"
#include "plPlasmaInstaller.h"
#include "resource.h"
#include <windowsx.h>
#include <commctrl.h>
#include "../plFile/hsFiles.h"
#include "plUnzip.h"
#include "plInstallerReg.h"
#include "../plFile/plBrowseFolder.h"
#include "plSetPlasmaPath.h"
plPlasmaInstaller::plPlasmaInstaller()
{
fDailyDir[0] = '\0';
fDidGet = false;
fStatusList = nil;
INITCOMMONCONTROLSEX icc = {0};
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icc);
}
void plPlasmaInstaller::Create()
{
ICreateDialog(IDD_INSTALLER, NULL);
}
static const char* kAllClientExes = "AllClientExes.zip";
static const char* kAllDllsRelease = "AllDllsRelease.zip";
static const char* kScripts = "Scripts.zip";
static const char* kTools = "AllToolsRelease.zip";
bool FileExists(const char* path, const char* filename)
{
char fullpath[MAX_PATH];
sprintf(fullpath, "%s%s", path, filename);
HANDLE hFile = CreateFile(fullpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return true;
}
return false;
}
bool plPlasmaInstaller::IGetDailyDir()
{
// Get the branch
HWND hBuild = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_GetCurSel(hBuild);
int buildServer = ComboBox_GetItemData(hBuild, idx);
HWND hTime = GetDlgItem(fDlg, IDC_TIME_COMBO);
idx = ComboBox_GetCurSel(hTime);
int time = ComboBox_GetItemData(hTime, idx);
// Get the build date
SYSTEMTIME date;
DateTime_GetSystemtime(GetDlgItem(fDlg, IDC_BRANCH_DATE), &date);
char dateStr[] = "xx-xx-xxxx";
sprintf(dateStr, "%02d-%02d-%04d", date.wMonth, date.wDay, date.wYear);
fDailyDir[0] = '\0';
IAddStatusLine("Searching for %s build...", dateStr);
char buildDir[MAX_PATH];
static const char* kMainBuild = "\\\\Plasmabuild\\Output\\";
static const char* kBranchBuild = "\\\\Branchbuild\\Output\\";
static const char* kActiveBuild = "\\\\Activebuild\\Output\\";
static const char* kInternalMain = "Main-Internal\\";
static const char* kInternalBranch = "Branch-Internal\\";
static const char* kInternalActive = "Active-Internal\\";
switch (buildServer)
{
case kBuildMain: strcpy(buildDir, kMainBuild); break;
case kBuildBranch: strcpy(buildDir, kBranchBuild); break;
case kBuildActive: strcpy(buildDir, kActiveBuild); break;
}
switch (time)
{
case kNightly:
strcat(buildDir, "Nightly\\");
break;
case kAfternoon:
strcat(buildDir, "Afternoon\\");
break;
case kEvening:
strcat(buildDir, "Evening\\");
break;
}
strcat(buildDir, dateStr);
strcat(buildDir, "\\");
switch (buildServer)
{
case kBuildMain: strcat(buildDir, kInternalMain); break;
case kBuildBranch: strcat(buildDir, kInternalBranch); break;
case kBuildActive: strcat(buildDir, kInternalActive); break;
}
if (FileExists(buildDir, kAllClientExes) && FileExists(buildDir, kAllDllsRelease) && FileExists(buildDir, kScripts))
{
strcpy(fDailyDir, buildDir);
const char* serverName = nil;
switch (buildServer)
{
case kBuildMain: serverName = "Main"; break;
case kBuildBranch: serverName = "Branch"; break;
case kBuildActive: serverName = "Active"; break;
}
IAddStatusLine("Found %s at %s", serverName, fDailyDir);
EnableWindow(GetDlgItem(fDlg, IDC_GET_BUTTON), TRUE);
return true;
}
IAddStatusLine("Couldn't find build");
EnableWindow(GetDlgItem(fDlg, IDC_GET_BUTTON), FALSE);
return false;
}
void plPlasmaInstaller::IInit()
{
const char* clientDir = plInstallerReg::GetClientDir();
SetDlgItemText(fDlg, IDC_CLIENT_EDIT, clientDir);
const char* maxDir = plInstallerReg::GetMaxDir();
SetDlgItemText(fDlg, IDC_3DSMAX_EDIT, maxDir);
fStatusList = GetDlgItem(fDlg, IDC_STATUS_LIST);
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_AddString(hCombo, "Main");
ComboBox_SetItemData(hCombo, idx, kBuildMain);
ComboBox_SetCurSel(hCombo, idx);
idx = ComboBox_AddString(hCombo, "Branch");
ComboBox_SetItemData(hCombo, idx, kBuildBranch);
idx = ComboBox_AddString(hCombo, "Active");
ComboBox_SetItemData(hCombo, idx, kBuildActive);
HWND hTime = GetDlgItem(fDlg, IDC_TIME_COMBO);
idx = ComboBox_AddString(hTime, "Nightly");
ComboBox_SetItemData(hTime, idx, kNightly);
ComboBox_SetCurSel(hTime, idx);
idx = ComboBox_AddString(hTime, "Afternoon");
ComboBox_SetItemData(hTime, idx, kAfternoon);
idx = ComboBox_AddString(hTime, "Evening");
ComboBox_SetItemData(hTime, idx, kEvening);
CheckDlgButton(fDlg, IDC_CLIENT_CHECK, BST_CHECKED);
CheckDlgButton(fDlg, IDC_SCRIPTS_CHECK, BST_CHECKED);
CheckDlgButton(fDlg, IDC_PLUGINS_CHECK, BST_CHECKED);
ShowWindow(fDlg, SW_SHOW);
IGetDailyDir();
}
BOOL plPlasmaInstaller::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
IInit();
SetFocus(GetDlgItem(fDlg, IDC_GET_BUTTON));
return FALSE;
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
switch (LOWORD(wParam))
{
case IDCANCEL:
PostMessage(hDlg, WM_CLOSE, 0, 0);
return TRUE;
case IDC_BROWSE_3DSMAX:
case IDC_BROWSE_CLIENT:
IGetFolder(LOWORD(wParam) == IDC_BROWSE_CLIENT);
return TRUE;
case IDC_GET_BUTTON:
if (fDidGet)
PostMessage(hDlg, WM_CLOSE, 0, 0);
else
IGet();
return TRUE;
}
}
else if (HIWORD(wParam) == CBN_SELCHANGE && (LOWORD(wParam) == IDC_TIME_COMBO || LOWORD(wParam) == IDC_BUILD_COMBO))
{
IGetDailyDir();
return TRUE;
}
break;
case WM_NOTIFY:
{
NMHDR* nmhdr = (NMHDR*)lParam;
if (nmhdr->idFrom == IDC_BRANCH_DATE && nmhdr->code == DTN_CLOSEUP/*DTN_DATETIMECHANGE*/)
{
IGetDailyDir();
return TRUE;
}
}
break;
}
return FALSE;
}
void plPlasmaInstaller::IExtractZip(const char* filename, const char* dest)
{
plUnzip unzip;
if (unzip.Open(filename))
{
IAddStatusLine("Extracting %s...", filename);
char buf[MAX_PATH];
while (unzip.ExtractNext(dest, buf))
IAddStatusLine(" %s", buf);
IAddStatusLine(" %s", buf);
unzip.Close();
}
}
void plPlasmaInstaller::IGet()
{
bool getClient = (IsDlgButtonChecked(fDlg, IDC_CLIENT_CHECK) == BST_CHECKED);
bool getScripts = (IsDlgButtonChecked(fDlg, IDC_SCRIPTS_CHECK) == BST_CHECKED);
bool getPlugins = (IsDlgButtonChecked(fDlg, IDC_PLUGINS_CHECK) == BST_CHECKED);
bool getTools = (IsDlgButtonChecked(fDlg, IDC_TOOLS_CHECK) == BST_CHECKED);
const char* clientDir = plInstallerReg::GetClientDir();
if (*clientDir == '\0' && (getClient || getScripts))
{
MessageBox(fDlg, "You need to set your client directory", "Plasma Installer", MB_OK | MB_ICONASTERISK);
return;
}
const char* maxDir = plInstallerReg::GetMaxDir();
if (*maxDir == '\0' && getPlugins)
{
MessageBox(fDlg, "You need to set your 3dsmax directory", "Plasma Installer", MB_OK | MB_ICONASTERISK);
return;
}
HWND hGetButton = GetDlgItem(fDlg, IDC_GET_BUTTON);
EnableWindow(hGetButton, FALSE);
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
char buf[MAX_PATH];
if (getScripts)
{
sprintf(buf, "%s%s", fDailyDir, kScripts);
IExtractZip(buf, clientDir);
}
if (getClient)
{
sprintf(buf, "%s%s", fDailyDir, kAllClientExes);
IExtractZip(buf, clientDir);
}
if (getPlugins)
{
sprintf(buf, "%s%s", fDailyDir, kAllDllsRelease);
char pluginDir[MAX_PATH];
sprintf(pluginDir, "%s\\plugins", maxDir);
IExtractZip(buf, pluginDir);
IAddStatusLine("Updating PlasmaMAX2.ini...");
sprintf(buf, "%s\\plugcfg\\PlasmaMAX2.ini", maxDir);
WritePrivateProfileString("SceneViewer", "Directory", clientDir, buf);
}
if (getTools)
{
sprintf(buf, "%s%s", fDailyDir, kTools);
char toolBuf[MAX_PATH];
sprintf(toolBuf, "%s\\Tools", clientDir);
IExtractZip(buf, toolBuf);
}
IAddStatusLine("Updating path...");
SetPlasmaPath(clientDir);
IAddStatusLine("Done");
SetCursor(hOldCursor);
fDidGet = true;
SetWindowText(hGetButton, "Close");
EnableWindow(hGetButton, TRUE);
}
void plPlasmaInstaller::IGetFolder(bool client)
{
char path[MAX_PATH];
if (client)
strcpy(path, plInstallerReg::GetClientDir());
else
strcpy(path, plInstallerReg::GetMaxDir());
if (plBrowseFolder::GetFolder(path, path))
{
if (client)
{
SetDlgItemText(fDlg, IDC_CLIENT_EDIT, path);
plInstallerReg::SetClientDir(path);
}
else
{
SetDlgItemText(fDlg, IDC_3DSMAX_EDIT, path);
plInstallerReg::SetMaxDir(path);
}
}
}
void plPlasmaInstaller::IAddStatusLine(const char* format, ...)
{
if (!format || *format == '\0')
return;
va_list args;
va_start(args, format);
char buf[2048];
int numWritten = _vsnprintf(buf, sizeof(buf), format, args);
hsAssert(numWritten > 0, "Buffer too small");
va_end(args);
int idx = ListBox_AddString(fStatusList, buf);
ListBox_SetCurSel(fStatusList, idx);
// Pump the message queue
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "HeadSpin.h"
#include "plPlasmaInstaller.h"
#include "resource.h"
#include <windowsx.h>
#include <commctrl.h>
#include "../plFile/hsFiles.h"
#include "plUnzip.h"
#include "plInstallerReg.h"
#include "../plFile/plBrowseFolder.h"
#include "plSetPlasmaPath.h"
plPlasmaInstaller::plPlasmaInstaller()
{
fDailyDir[0] = '\0';
fDidGet = false;
fStatusList = nil;
INITCOMMONCONTROLSEX icc = {0};
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_DATE_CLASSES;
InitCommonControlsEx(&icc);
}
void plPlasmaInstaller::Create()
{
ICreateDialog(IDD_INSTALLER, NULL);
}
static const char* kAllClientExes = "AllClientExes.zip";
static const char* kAllDllsRelease = "AllDllsRelease.zip";
static const char* kScripts = "Scripts.zip";
static const char* kTools = "AllToolsRelease.zip";
bool FileExists(const char* path, const char* filename)
{
char fullpath[MAX_PATH];
sprintf(fullpath, "%s%s", path, filename);
HANDLE hFile = CreateFile(fullpath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
CloseHandle(hFile);
return true;
}
return false;
}
bool plPlasmaInstaller::IGetDailyDir()
{
// Get the branch
HWND hBuild = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_GetCurSel(hBuild);
int buildServer = ComboBox_GetItemData(hBuild, idx);
HWND hTime = GetDlgItem(fDlg, IDC_TIME_COMBO);
idx = ComboBox_GetCurSel(hTime);
int time = ComboBox_GetItemData(hTime, idx);
// Get the build date
SYSTEMTIME date;
DateTime_GetSystemtime(GetDlgItem(fDlg, IDC_BRANCH_DATE), &date);
char dateStr[] = "xx-xx-xxxx";
sprintf(dateStr, "%02d-%02d-%04d", date.wMonth, date.wDay, date.wYear);
fDailyDir[0] = '\0';
IAddStatusLine("Searching for %s build...", dateStr);
char buildDir[MAX_PATH];
static const char* kMainBuild = "\\\\Plasmabuild\\Output\\";
static const char* kBranchBuild = "\\\\Branchbuild\\Output\\";
static const char* kActiveBuild = "\\\\Activebuild\\Output\\";
static const char* kInternalMain = "Main-Internal\\";
static const char* kInternalBranch = "Branch-Internal\\";
static const char* kInternalActive = "Active-Internal\\";
switch (buildServer)
{
case kBuildMain: strcpy(buildDir, kMainBuild); break;
case kBuildBranch: strcpy(buildDir, kBranchBuild); break;
case kBuildActive: strcpy(buildDir, kActiveBuild); break;
}
switch (time)
{
case kNightly:
strcat(buildDir, "Nightly\\");
break;
case kAfternoon:
strcat(buildDir, "Afternoon\\");
break;
case kEvening:
strcat(buildDir, "Evening\\");
break;
}
strcat(buildDir, dateStr);
strcat(buildDir, "\\");
switch (buildServer)
{
case kBuildMain: strcat(buildDir, kInternalMain); break;
case kBuildBranch: strcat(buildDir, kInternalBranch); break;
case kBuildActive: strcat(buildDir, kInternalActive); break;
}
if (FileExists(buildDir, kAllClientExes) && FileExists(buildDir, kAllDllsRelease) && FileExists(buildDir, kScripts))
{
strcpy(fDailyDir, buildDir);
const char* serverName = nil;
switch (buildServer)
{
case kBuildMain: serverName = "Main"; break;
case kBuildBranch: serverName = "Branch"; break;
case kBuildActive: serverName = "Active"; break;
}
IAddStatusLine("Found %s at %s", serverName, fDailyDir);
EnableWindow(GetDlgItem(fDlg, IDC_GET_BUTTON), TRUE);
return true;
}
IAddStatusLine("Couldn't find build");
EnableWindow(GetDlgItem(fDlg, IDC_GET_BUTTON), FALSE);
return false;
}
void plPlasmaInstaller::IInit()
{
const char* clientDir = plInstallerReg::GetClientDir();
SetDlgItemText(fDlg, IDC_CLIENT_EDIT, clientDir);
const char* maxDir = plInstallerReg::GetMaxDir();
SetDlgItemText(fDlg, IDC_3DSMAX_EDIT, maxDir);
fStatusList = GetDlgItem(fDlg, IDC_STATUS_LIST);
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_AddString(hCombo, "Main");
ComboBox_SetItemData(hCombo, idx, kBuildMain);
ComboBox_SetCurSel(hCombo, idx);
idx = ComboBox_AddString(hCombo, "Branch");
ComboBox_SetItemData(hCombo, idx, kBuildBranch);
idx = ComboBox_AddString(hCombo, "Active");
ComboBox_SetItemData(hCombo, idx, kBuildActive);
HWND hTime = GetDlgItem(fDlg, IDC_TIME_COMBO);
idx = ComboBox_AddString(hTime, "Nightly");
ComboBox_SetItemData(hTime, idx, kNightly);
ComboBox_SetCurSel(hTime, idx);
idx = ComboBox_AddString(hTime, "Afternoon");
ComboBox_SetItemData(hTime, idx, kAfternoon);
idx = ComboBox_AddString(hTime, "Evening");
ComboBox_SetItemData(hTime, idx, kEvening);
CheckDlgButton(fDlg, IDC_CLIENT_CHECK, BST_CHECKED);
CheckDlgButton(fDlg, IDC_SCRIPTS_CHECK, BST_CHECKED);
CheckDlgButton(fDlg, IDC_PLUGINS_CHECK, BST_CHECKED);
ShowWindow(fDlg, SW_SHOW);
IGetDailyDir();
}
BOOL plPlasmaInstaller::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
IInit();
SetFocus(GetDlgItem(fDlg, IDC_GET_BUTTON));
return FALSE;
case WM_CLOSE:
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
switch (LOWORD(wParam))
{
case IDCANCEL:
PostMessage(hDlg, WM_CLOSE, 0, 0);
return TRUE;
case IDC_BROWSE_3DSMAX:
case IDC_BROWSE_CLIENT:
IGetFolder(LOWORD(wParam) == IDC_BROWSE_CLIENT);
return TRUE;
case IDC_GET_BUTTON:
if (fDidGet)
PostMessage(hDlg, WM_CLOSE, 0, 0);
else
IGet();
return TRUE;
}
}
else if (HIWORD(wParam) == CBN_SELCHANGE && (LOWORD(wParam) == IDC_TIME_COMBO || LOWORD(wParam) == IDC_BUILD_COMBO))
{
IGetDailyDir();
return TRUE;
}
break;
case WM_NOTIFY:
{
NMHDR* nmhdr = (NMHDR*)lParam;
if (nmhdr->idFrom == IDC_BRANCH_DATE && nmhdr->code == DTN_CLOSEUP/*DTN_DATETIMECHANGE*/)
{
IGetDailyDir();
return TRUE;
}
}
break;
}
return FALSE;
}
void plPlasmaInstaller::IExtractZip(const char* filename, const char* dest)
{
plUnzip unzip;
if (unzip.Open(filename))
{
IAddStatusLine("Extracting %s...", filename);
char buf[MAX_PATH];
while (unzip.ExtractNext(dest, buf))
IAddStatusLine(" %s", buf);
IAddStatusLine(" %s", buf);
unzip.Close();
}
}
void plPlasmaInstaller::IGet()
{
bool getClient = (IsDlgButtonChecked(fDlg, IDC_CLIENT_CHECK) == BST_CHECKED);
bool getScripts = (IsDlgButtonChecked(fDlg, IDC_SCRIPTS_CHECK) == BST_CHECKED);
bool getPlugins = (IsDlgButtonChecked(fDlg, IDC_PLUGINS_CHECK) == BST_CHECKED);
bool getTools = (IsDlgButtonChecked(fDlg, IDC_TOOLS_CHECK) == BST_CHECKED);
const char* clientDir = plInstallerReg::GetClientDir();
if (*clientDir == '\0' && (getClient || getScripts))
{
MessageBox(fDlg, "You need to set your client directory", "Plasma Installer", MB_OK | MB_ICONASTERISK);
return;
}
const char* maxDir = plInstallerReg::GetMaxDir();
if (*maxDir == '\0' && getPlugins)
{
MessageBox(fDlg, "You need to set your 3dsmax directory", "Plasma Installer", MB_OK | MB_ICONASTERISK);
return;
}
HWND hGetButton = GetDlgItem(fDlg, IDC_GET_BUTTON);
EnableWindow(hGetButton, FALSE);
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
char buf[MAX_PATH];
if (getScripts)
{
sprintf(buf, "%s%s", fDailyDir, kScripts);
IExtractZip(buf, clientDir);
}
if (getClient)
{
sprintf(buf, "%s%s", fDailyDir, kAllClientExes);
IExtractZip(buf, clientDir);
}
if (getPlugins)
{
sprintf(buf, "%s%s", fDailyDir, kAllDllsRelease);
char pluginDir[MAX_PATH];
sprintf(pluginDir, "%s\\plugins", maxDir);
IExtractZip(buf, pluginDir);
IAddStatusLine("Updating PlasmaMAX2.ini...");
sprintf(buf, "%s\\plugcfg\\PlasmaMAX2.ini", maxDir);
WritePrivateProfileString("SceneViewer", "Directory", clientDir, buf);
}
if (getTools)
{
sprintf(buf, "%s%s", fDailyDir, kTools);
char toolBuf[MAX_PATH];
sprintf(toolBuf, "%s\\Tools", clientDir);
IExtractZip(buf, toolBuf);
}
IAddStatusLine("Updating path...");
SetPlasmaPath(clientDir);
IAddStatusLine("Done");
SetCursor(hOldCursor);
fDidGet = true;
SetWindowText(hGetButton, "Close");
EnableWindow(hGetButton, TRUE);
}
void plPlasmaInstaller::IGetFolder(bool client)
{
char path[MAX_PATH];
if (client)
strcpy(path, plInstallerReg::GetClientDir());
else
strcpy(path, plInstallerReg::GetMaxDir());
if (plBrowseFolder::GetFolder(path, path))
{
if (client)
{
SetDlgItemText(fDlg, IDC_CLIENT_EDIT, path);
plInstallerReg::SetClientDir(path);
}
else
{
SetDlgItemText(fDlg, IDC_3DSMAX_EDIT, path);
plInstallerReg::SetMaxDir(path);
}
}
}
void plPlasmaInstaller::IAddStatusLine(const char* format, ...)
{
if (!format || *format == '\0')
return;
va_list args;
va_start(args, format);
char buf[2048];
int numWritten = _vsnprintf(buf, sizeof(buf), format, args);
hsAssert(numWritten > 0, "Buffer too small");
va_end(args);
int idx = ListBox_AddString(fStatusList, buf);
ListBox_SetCurSel(fStatusList, idx);
// Pump the message queue
MSG msg;
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (!IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}

View File

@ -1,73 +1,73 @@
/*==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 "jvBaseDlg.h"
class plPlasmaInstaller : public jvBaseDlg
{
protected:
char fDailyDir[MAX_PATH];
bool fDidGet;
HWND fStatusList;
enum { kBuildMain, kBuildBranch, kBuildActive };
enum { kNightly, kAfternoon, kEvening };
virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
bool IGetDailyDir();
void IGetFolder(bool client);
void IGet();
void IInit();
void IExtractZip(const char* filename, const char* dest);
void IAddStatusLine(const char* format, ...);
public:
plPlasmaInstaller();
void Create();
HWND GetHWnd() { return fDlg; }
/*==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 "jvBaseDlg.h"
class plPlasmaInstaller : public jvBaseDlg
{
protected:
char fDailyDir[MAX_PATH];
bool fDidGet;
HWND fStatusList;
enum { kBuildMain, kBuildBranch, kBuildActive };
enum { kNightly, kAfternoon, kEvening };
virtual BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
bool IGetDailyDir();
void IGetFolder(bool client);
void IGet();
void IInit();
void IExtractZip(const char* filename, const char* dest);
void IAddStatusLine(const char* format, ...);
public:
plPlasmaInstaller();
void Create();
HWND GetHWnd() { return fDlg; }
};

View File

@ -1,129 +1,129 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_INSTALLER DIALOG DISCARDABLE 0, 0, 241, 170
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Plasma Installer"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_TIME_COMBO,27,6,46,167,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
LTEXT "3dsmax Directory:",IDC_STATIC,7,26,57,8
EDITTEXT IDC_3DSMAX_EDIT,7,36,173,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_BROWSE_3DSMAX,183,35,50,14
LTEXT "Client Directory:",IDC_STATIC,7,53,50,8
EDITTEXT IDC_CLIENT_EDIT,7,63,173,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_BROWSE_CLIENT,183,62,50,14
DEFPUSHBUTTON "Get",IDC_GET_BUTTON,93,146,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,85,226,54,LBS_NOSEL | WS_VSCROLL |
WS_TABSTOP
CONTROL "DateTimePicker1",IDC_BRANCH_DATE,"SysDateTimePick32",
DTS_RIGHTALIGN | WS_TABSTOP,125,6,55,12
COMBOBOX IDC_BUILD_COMBO,76,6,46,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
CONTROL "Client",IDC_CLIENT_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,159,144,33,10
CONTROL "Scripts",IDC_SCRIPTS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,159,154,37,10
CONTROL "Plugins",IDC_PLUGINS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,197,144,39,10
CONTROL "Tools",IDC_TOOLS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,197,154,33,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_INSTALLER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 234
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_INSTALLER DIALOG DISCARDABLE 0, 0, 241, 170
STYLE DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Plasma Installer"
FONT 8, "MS Sans Serif"
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_TIME_COMBO,27,6,46,167,CBS_DROPDOWNLIST | WS_VSCROLL |
WS_TABSTOP
LTEXT "3dsmax Directory:",IDC_STATIC,7,26,57,8
EDITTEXT IDC_3DSMAX_EDIT,7,36,173,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_BROWSE_3DSMAX,183,35,50,14
LTEXT "Client Directory:",IDC_STATIC,7,53,50,8
EDITTEXT IDC_CLIENT_EDIT,7,63,173,12,ES_AUTOHSCROLL | ES_READONLY
PUSHBUTTON "Browse...",IDC_BROWSE_CLIENT,183,62,50,14
DEFPUSHBUTTON "Get",IDC_GET_BUTTON,93,146,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,85,226,54,LBS_NOSEL | WS_VSCROLL |
WS_TABSTOP
CONTROL "DateTimePicker1",IDC_BRANCH_DATE,"SysDateTimePick32",
DTS_RIGHTALIGN | WS_TABSTOP,125,6,55,12
COMBOBOX IDC_BUILD_COMBO,76,6,46,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
CONTROL "Client",IDC_CLIENT_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,159,144,33,10
CONTROL "Scripts",IDC_SCRIPTS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,159,154,37,10
CONTROL "Plugins",IDC_PLUGINS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,197,144,39,10
CONTROL "Tools",IDC_TOOLS_CHECK,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP,197,154,33,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN
IDD_INSTALLER, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 234
TOPMARGIN, 7
BOTTOMMARGIN, 163
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON DISCARDABLE "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,120 +1,120 @@
/*==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 "HeadSpin.h"
#include <windows.h>
static HKEY GetEnvironKey()
{
HKEY hSystemKey = NULL;
HKEY hControlSetKey = NULL;
HKEY hControlKey = NULL;
HKEY hSessionKey = NULL;
HKEY hEnvironKey = NULL;
if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM", 0, KEY_READ, &hSystemKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hSystemKey, "CurrentControlSet", 0, KEY_READ, &hControlSetKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hControlSetKey, "Control", 0, KEY_READ, &hControlKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hControlKey, "Session Manager", 0, KEY_READ, &hSessionKey) == ERROR_SUCCESS))
{
RegOpenKeyEx(hSessionKey, "Environment", 0, KEY_READ | KEY_WRITE, &hEnvironKey);
}
if (hSystemKey != NULL)
RegCloseKey(hSystemKey);
if (hControlSetKey != NULL)
RegCloseKey(hControlSetKey);
if (hControlKey != NULL)
RegCloseKey(hControlKey);
if (hSessionKey != NULL)
RegCloseKey(hSessionKey);
return hEnvironKey;
}
void SetPlasmaPath(const char* plasmaPath)
{
bool pathSet = false;
HKEY hEnvironKey = GetEnvironKey();
if (hEnvironKey)
{
// Make sure the PlasmaGameDir var is in the path
DWORD size = 0;
if (ERROR_SUCCESS == RegQueryValueEx(hEnvironKey, "Path", NULL, NULL, NULL, &size))
{
char* oldPath = new char[size];
static const char* kPlasmaVar = "%PlasmaGameDir%";
if (ERROR_SUCCESS == RegQueryValueEx(hEnvironKey, "Path", NULL, NULL, (BYTE*)oldPath, &size))
{
pathSet = (strstr(oldPath, kPlasmaVar) != NULL);
if (!pathSet)
{
char* newPath = new char[size+strlen(kPlasmaVar)+1];
strcpy(newPath, oldPath);
strcat(newPath, ";");
strcat(newPath, kPlasmaVar);
RegSetValueEx(hEnvironKey, "Path", 0, REG_EXPAND_SZ, (BYTE*)newPath, strlen(newPath)+1);
delete [] newPath;
}
}
delete [] oldPath;
}
// Set the PlasmaGameDir var
RegSetValueEx(hEnvironKey, "PlasmaGameDir", 0, REG_SZ, (BYTE*)plasmaPath, strlen(plasmaPath)+1);
// Notify command prompts and stuff that environ changed
DWORD ret;
SendMessageTimeout(HWND_BROADCAST,
WM_SETTINGCHANGE,
0,
(LPARAM)"Environment",
SMTO_ABORTIFHUNG,
5000,
&ret);
}
}
/*==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 "HeadSpin.h"
#include <windows.h>
static HKEY GetEnvironKey()
{
HKEY hSystemKey = NULL;
HKEY hControlSetKey = NULL;
HKEY hControlKey = NULL;
HKEY hSessionKey = NULL;
HKEY hEnvironKey = NULL;
if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM", 0, KEY_READ, &hSystemKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hSystemKey, "CurrentControlSet", 0, KEY_READ, &hControlSetKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hControlSetKey, "Control", 0, KEY_READ, &hControlKey) == ERROR_SUCCESS) &&
(RegOpenKeyEx(hControlKey, "Session Manager", 0, KEY_READ, &hSessionKey) == ERROR_SUCCESS))
{
RegOpenKeyEx(hSessionKey, "Environment", 0, KEY_READ | KEY_WRITE, &hEnvironKey);
}
if (hSystemKey != NULL)
RegCloseKey(hSystemKey);
if (hControlSetKey != NULL)
RegCloseKey(hControlSetKey);
if (hControlKey != NULL)
RegCloseKey(hControlKey);
if (hSessionKey != NULL)
RegCloseKey(hSessionKey);
return hEnvironKey;
}
void SetPlasmaPath(const char* plasmaPath)
{
bool pathSet = false;
HKEY hEnvironKey = GetEnvironKey();
if (hEnvironKey)
{
// Make sure the PlasmaGameDir var is in the path
DWORD size = 0;
if (ERROR_SUCCESS == RegQueryValueEx(hEnvironKey, "Path", NULL, NULL, NULL, &size))
{
char* oldPath = new char[size];
static const char* kPlasmaVar = "%PlasmaGameDir%";
if (ERROR_SUCCESS == RegQueryValueEx(hEnvironKey, "Path", NULL, NULL, (BYTE*)oldPath, &size))
{
pathSet = (strstr(oldPath, kPlasmaVar) != NULL);
if (!pathSet)
{
char* newPath = new char[size+strlen(kPlasmaVar)+1];
strcpy(newPath, oldPath);
strcat(newPath, ";");
strcat(newPath, kPlasmaVar);
RegSetValueEx(hEnvironKey, "Path", 0, REG_EXPAND_SZ, (BYTE*)newPath, strlen(newPath)+1);
delete [] newPath;
}
}
delete [] oldPath;
}
// Set the PlasmaGameDir var
RegSetValueEx(hEnvironKey, "PlasmaGameDir", 0, REG_SZ, (BYTE*)plasmaPath, strlen(plasmaPath)+1);
// Notify command prompts and stuff that environ changed
DWORD ret;
SendMessageTimeout(HWND_BROADCAST,
WM_SETTINGCHANGE,
0,
(LPARAM)"Environment",
SMTO_ABORTIFHUNG,
5000,
&ret);
}
}

View File

@ -1,42 +1,42 @@
/*==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==*/
void SetPlasmaPath(const char* plasmaPath);
/*==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==*/
void SetPlasmaPath(const char* plasmaPath);

View File

@ -1,169 +1,169 @@
/*==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 "HeadSpin.h"
#include "plUnzip.h"
#include "hsTypes.h"
#include "hsWindows.h"
#include "hsStream.h"
plUnzip::plUnzip() : fFile(nil)
{
}
bool plUnzip::Open(const char* filename)
{
fFile = unzOpen(filename);
return (fFile != nil);
}
bool plUnzip::Close()
{
bool ret = false;
if (fFile != nil)
{
ret = (UNZ_OK == unzClose(fFile));
fFile = nil;
}
return ret;
}
void plUnzip::IGetFullPath(const char* destDir, const char* filename, char* outFilename)
{
// Make sure the dest ends with a slash
strcpy(outFilename, destDir);
char lastChar = outFilename[strlen(outFilename)-1];
if (lastChar != '\\' && lastChar != '/')
strcat(outFilename, "\\");
// Check if the output filename has any directories in it
const char* forward = strrchr(filename, '/');
const char* backward = strrchr(filename, '\\');
if (!forward && !backward)
{
CreateDirectory(outFilename, NULL);
strcat(outFilename, filename);
}
else
{
const char* fileOnly = (forward > backward) ? forward+1 : backward+1;
strncat(outFilename, filename, fileOnly-filename);
CreateDirectory(outFilename, NULL);
strcat(outFilename, fileOnly);
}
}
void plUnzip::IExtractCurrent(const char* destDir, char* fileName)
{
char filename[MAX_PATH];
if (unzGetCurrentFileInfo(fFile, nil, filename, sizeof(filename), nil, 0, nil, 0) == UNZ_OK)
{
strcpy(fileName, filename);
if (unzOpenCurrentFile(fFile) == UNZ_OK)
{
char outFilename[MAX_PATH];
IGetFullPath(destDir, filename, outFilename);
// Make sure to take off the read-only flag if the file exists, and is RO
DWORD attrs = GetFileAttributes(outFilename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_READONLY))
SetFileAttributes(outFilename, attrs & ~FILE_ATTRIBUTE_READONLY);
hsUNIXStream outFile;
if (outFile.Open(outFilename, "wb"))
{
char buf[2048];
int numRead;
while ((numRead = unzReadCurrentFile(fFile, buf, sizeof(buf))) > 0)
{
outFile.Write(numRead, buf);
}
outFile.Close();
unz_file_info_s info;
unzGetCurrentFileInfo(fFile, &info, NULL, 0, NULL, 0, NULL, 0);
SYSTEMTIME sysTime = {0};
sysTime.wDay = info.tmu_date.tm_mday;
sysTime.wMonth = info.tmu_date.tm_mon+1;
sysTime.wYear = info.tmu_date.tm_year;
sysTime.wHour = info.tmu_date.tm_hour;
sysTime.wMinute = info.tmu_date.tm_min;
sysTime.wSecond = info.tmu_date.tm_sec;
FILETIME localFileTime, utcFileTime;
SystemTimeToFileTime(&sysTime, &localFileTime);
LocalFileTimeToFileTime(&localFileTime, &utcFileTime);
HANDLE hFile = CreateFile(outFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
SetFileTime(hFile, NULL, NULL, &utcFileTime);
CloseHandle(hFile);
}
unzCloseCurrentFile(fFile);
}
}
}
void plUnzip::ExtractAll(const char* destDir)
{
if (unzGoToFirstFile(fFile) != UNZ_OK)
return;
do
{
IExtractCurrent(destDir);
}
while (unzGoToNextFile(fFile) == UNZ_OK);
}
bool plUnzip::ExtractNext(const char* destDir, char* fileName)
{
IExtractCurrent(destDir, fileName);
return (unzGoToNextFile(fFile) == UNZ_OK);
}
/*==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 "HeadSpin.h"
#include "plUnzip.h"
#include "hsTypes.h"
#include "hsWindows.h"
#include "hsStream.h"
plUnzip::plUnzip() : fFile(nil)
{
}
bool plUnzip::Open(const char* filename)
{
fFile = unzOpen(filename);
return (fFile != nil);
}
bool plUnzip::Close()
{
bool ret = false;
if (fFile != nil)
{
ret = (UNZ_OK == unzClose(fFile));
fFile = nil;
}
return ret;
}
void plUnzip::IGetFullPath(const char* destDir, const char* filename, char* outFilename)
{
// Make sure the dest ends with a slash
strcpy(outFilename, destDir);
char lastChar = outFilename[strlen(outFilename)-1];
if (lastChar != '\\' && lastChar != '/')
strcat(outFilename, "\\");
// Check if the output filename has any directories in it
const char* forward = strrchr(filename, '/');
const char* backward = strrchr(filename, '\\');
if (!forward && !backward)
{
CreateDirectory(outFilename, NULL);
strcat(outFilename, filename);
}
else
{
const char* fileOnly = (forward > backward) ? forward+1 : backward+1;
strncat(outFilename, filename, fileOnly-filename);
CreateDirectory(outFilename, NULL);
strcat(outFilename, fileOnly);
}
}
void plUnzip::IExtractCurrent(const char* destDir, char* fileName)
{
char filename[MAX_PATH];
if (unzGetCurrentFileInfo(fFile, nil, filename, sizeof(filename), nil, 0, nil, 0) == UNZ_OK)
{
strcpy(fileName, filename);
if (unzOpenCurrentFile(fFile) == UNZ_OK)
{
char outFilename[MAX_PATH];
IGetFullPath(destDir, filename, outFilename);
// Make sure to take off the read-only flag if the file exists, and is RO
DWORD attrs = GetFileAttributes(outFilename);
if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_READONLY))
SetFileAttributes(outFilename, attrs & ~FILE_ATTRIBUTE_READONLY);
hsUNIXStream outFile;
if (outFile.Open(outFilename, "wb"))
{
char buf[2048];
int numRead;
while ((numRead = unzReadCurrentFile(fFile, buf, sizeof(buf))) > 0)
{
outFile.Write(numRead, buf);
}
outFile.Close();
unz_file_info_s info;
unzGetCurrentFileInfo(fFile, &info, NULL, 0, NULL, 0, NULL, 0);
SYSTEMTIME sysTime = {0};
sysTime.wDay = info.tmu_date.tm_mday;
sysTime.wMonth = info.tmu_date.tm_mon+1;
sysTime.wYear = info.tmu_date.tm_year;
sysTime.wHour = info.tmu_date.tm_hour;
sysTime.wMinute = info.tmu_date.tm_min;
sysTime.wSecond = info.tmu_date.tm_sec;
FILETIME localFileTime, utcFileTime;
SystemTimeToFileTime(&sysTime, &localFileTime);
LocalFileTimeToFileTime(&localFileTime, &utcFileTime);
HANDLE hFile = CreateFile(outFilename, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
SetFileTime(hFile, NULL, NULL, &utcFileTime);
CloseHandle(hFile);
}
unzCloseCurrentFile(fFile);
}
}
}
void plUnzip::ExtractAll(const char* destDir)
{
if (unzGoToFirstFile(fFile) != UNZ_OK)
return;
do
{
IExtractCurrent(destDir);
}
while (unzGoToNextFile(fFile) == UNZ_OK);
}
bool plUnzip::ExtractNext(const char* destDir, char* fileName)
{
IExtractCurrent(destDir, fileName);
return (unzGoToNextFile(fFile) == UNZ_OK);
}

View File

@ -1,66 +1,66 @@
/*==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 plUnzip_h_inc
#define plUnzip_h_inc
#include "hsTypes.h"
#include "contrib/minizip/unzip.h"
class plUnzip
{
protected:
unzFile fFile;
void IGetFullPath(const char* destDir, const char* filename, char* outFilename);
void IExtractCurrent(const char* destDir, char* fileName=nil);
public:
plUnzip();
bool Open(const char* filename);
bool Close();
void ExtractAll(const char* destDir);
bool ExtractNext(const char* destDir, char* fileName);
};
#endif // plUnzip_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 plUnzip_h_inc
#define plUnzip_h_inc
#include "hsTypes.h"
#include "contrib/minizip/unzip.h"
class plUnzip
{
protected:
unzFile fFile;
void IGetFullPath(const char* destDir, const char* filename, char* outFilename);
void IExtractCurrent(const char* destDir, char* fileName=nil);
public:
plUnzip();
bool Open(const char* filename);
bool Close();
void ExtractAll(const char* destDir);
bool ExtractNext(const char* destDir, char* fileName);
};
#endif // plUnzip_h_inc

View File

@ -1,30 +1,30 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by plPlasmaInstaller.rc
//
#define IDD_INSTALLER 101
#define IDI_ICON1 102
#define IDC_3DSMAX_EDIT 1000
#define IDC_BROWSE_3DSMAX 1001
#define IDC_TIME_COMBO 1002
#define IDC_CLIENT_EDIT 1003
#define IDC_BROWSE_CLIENT 1004
#define IDC_GET_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BRANCH_DATE 1007
#define IDC_BUILD_COMBO 1008
#define IDC_CLIENT_CHECK 1009
#define IDC_SCRIPTS_CHECK 1010
#define IDC_PLUGINS_CHECK 1011
#define IDC_TOOLS_CHECK 1012
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by plPlasmaInstaller.rc
//
#define IDD_INSTALLER 101
#define IDI_ICON1 102
#define IDC_3DSMAX_EDIT 1000
#define IDC_BROWSE_3DSMAX 1001
#define IDC_TIME_COMBO 1002
#define IDC_CLIENT_EDIT 1003
#define IDC_BROWSE_CLIENT 1004
#define IDC_GET_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BRANCH_DATE 1007
#define IDC_BUILD_COMBO 1008
#define IDC_CLIENT_CHECK 1009
#define IDC_SCRIPTS_CHECK 1010
#define IDC_PLUGINS_CHECK 1011
#define IDC_TOOLS_CHECK 1012
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 103
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1013
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,68 +1,68 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "jvCoreUtil.h"
#include "hsUtils.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaUpdate installer;
if (!installer.Create())
return 0;
if (!stricmp(lpCmdLine, "AutoDownload"))
installer.SetAutoDownload();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!jvBaseDlg::IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "jvCoreUtil.h"
#include "hsUtils.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaUpdate installer;
if (!installer.Create())
return 0;
if (!stricmp(lpCmdLine, "AutoDownload"))
installer.SetAutoDownload();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!jvBaseDlg::IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}

View File

@ -1,186 +1,186 @@
/*==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 "plFileGrabber.h"
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
plHttpFileGrabber::plHttpFileGrabber()
{
fRequestMgr.SetHostname("");
}
bool plHttpFileGrabber::FileToStream(const char* path, hsStream* stream)
{
std::string pathStr(path);
bool retVal = fRequestMgr.GetFileToStream(path, stream);
stream->SetPosition(0);
return retVal;
}
void plHttpFileGrabber::SetServer(const char* server)
{
std::string serverPath(server);
fRequestMgr.SetHostname(serverPath);
}
void plHttpFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '\\');
if (slash)
*slash = '/';
} while(slash != NULL);
}
void plHttpFileGrabber::SetUsernamePassword(const std::string& username, const std::string& password)
{
fRequestMgr.SetUsername(username);
fRequestMgr.SetPassword(password);
}
bool plHttpFileGrabber::IsServerAvailable(const char* serverName)
{
bool retVal = false;
HINTERNET hInternet = InternetOpen("Parable Patcher",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInternet)
{
HINTERNET hHttp = InternetConnect(hInternet,serverName,8080,fUserName.c_str(),fPassword.c_str(),INTERNET_SERVICE_HTTP,0,0);
if (hHttp)
{
HINTERNET hRequest = HttpOpenRequest(hHttp, "GET", "/Current/Current.txt", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hRequest)
{
DWORD dwCode;
DWORD dwSize = sizeof(dwCode);
HttpSendRequest(hRequest, NULL, 0, NULL, 0);
HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL);
if (dwCode >= 200 && dwCode < 300)
{
retVal = true;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hHttp);
}
InternetCloseHandle(hInternet);
}
return retVal;
}
*/
plNetShareFileGrabber::plNetShareFileGrabber()
{
}
#define BUFFER_SIZE 1024*1024
bool plNetShareFileGrabber::FileToStream(const char* path, hsStream* stream)
{
hsUNIXStream fileStream;
std::string filePath = fServerName + path;
if (fileStream.Open(filePath.c_str()))
{
char* buffer = new char[BUFFER_SIZE];
UInt32 streamSize = fileStream.GetSizeLeft();
while (streamSize > (BUFFER_SIZE))
{
fileStream.Read(BUFFER_SIZE, buffer);
stream->Write(BUFFER_SIZE, buffer);
streamSize = fileStream.GetSizeLeft();
}
if (streamSize > 0)
{
fileStream.Read(streamSize, buffer);
stream->Write(streamSize, buffer);
}
stream->Rewind();
fileStream.Close();
delete [] buffer;
return true;
}
return false;
}
void plNetShareFileGrabber::SetServer(const char* server)
{
fServerName = "\\\\";
fServerName += server;
}
void plNetShareFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '/');
if (slash)
*slash = '\\';
} while(slash != NULL);
}
bool plNetShareFileGrabber::IsServerAvailable(const char* serverName, const char* currentDir)
{
bool retVal = false;
char serverPath[MAX_PATH];
sprintf(serverPath, "\\\\%s\\%s\\Current.txt", serverName, currentDir);
hsUNIXStream si;
if (si.Open(serverPath, "rb"))
{
retVal = true;
si.Close();
}
return retVal;
}
/*==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 "plFileGrabber.h"
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
plHttpFileGrabber::plHttpFileGrabber()
{
fRequestMgr.SetHostname("");
}
bool plHttpFileGrabber::FileToStream(const char* path, hsStream* stream)
{
std::string pathStr(path);
bool retVal = fRequestMgr.GetFileToStream(path, stream);
stream->SetPosition(0);
return retVal;
}
void plHttpFileGrabber::SetServer(const char* server)
{
std::string serverPath(server);
fRequestMgr.SetHostname(serverPath);
}
void plHttpFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '\\');
if (slash)
*slash = '/';
} while(slash != NULL);
}
void plHttpFileGrabber::SetUsernamePassword(const std::string& username, const std::string& password)
{
fRequestMgr.SetUsername(username);
fRequestMgr.SetPassword(password);
}
bool plHttpFileGrabber::IsServerAvailable(const char* serverName)
{
bool retVal = false;
HINTERNET hInternet = InternetOpen("Parable Patcher",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInternet)
{
HINTERNET hHttp = InternetConnect(hInternet,serverName,8080,fUserName.c_str(),fPassword.c_str(),INTERNET_SERVICE_HTTP,0,0);
if (hHttp)
{
HINTERNET hRequest = HttpOpenRequest(hHttp, "GET", "/Current/Current.txt", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hRequest)
{
DWORD dwCode;
DWORD dwSize = sizeof(dwCode);
HttpSendRequest(hRequest, NULL, 0, NULL, 0);
HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL);
if (dwCode >= 200 && dwCode < 300)
{
retVal = true;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hHttp);
}
InternetCloseHandle(hInternet);
}
return retVal;
}
*/
plNetShareFileGrabber::plNetShareFileGrabber()
{
}
#define BUFFER_SIZE 1024*1024
bool plNetShareFileGrabber::FileToStream(const char* path, hsStream* stream)
{
hsUNIXStream fileStream;
std::string filePath = fServerName + path;
if (fileStream.Open(filePath.c_str()))
{
char* buffer = new char[BUFFER_SIZE];
UInt32 streamSize = fileStream.GetSizeLeft();
while (streamSize > (BUFFER_SIZE))
{
fileStream.Read(BUFFER_SIZE, buffer);
stream->Write(BUFFER_SIZE, buffer);
streamSize = fileStream.GetSizeLeft();
}
if (streamSize > 0)
{
fileStream.Read(streamSize, buffer);
stream->Write(streamSize, buffer);
}
stream->Rewind();
fileStream.Close();
delete [] buffer;
return true;
}
return false;
}
void plNetShareFileGrabber::SetServer(const char* server)
{
fServerName = "\\\\";
fServerName += server;
}
void plNetShareFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '/');
if (slash)
*slash = '\\';
} while(slash != NULL);
}
bool plNetShareFileGrabber::IsServerAvailable(const char* serverName, const char* currentDir)
{
bool retVal = false;
char serverPath[MAX_PATH];
sprintf(serverPath, "\\\\%s\\%s\\Current.txt", serverName, currentDir);
hsUNIXStream si;
if (si.Open(serverPath, "rb"))
{
retVal = true;
si.Close();
}
return retVal;
}

View File

@ -1,89 +1,89 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 plFileGrabber_h_inc
#define plFileGrabber_h_inc
#include <string>
#include "hsStream.h"
class plFileGrabber
{
public:
virtual bool IsServerAvailable(const char* serverName, const char* currentDir) = 0;
virtual bool FileToStream(const char* path, hsStream* stream) = 0;
virtual void SetServer(const char* server) = 0;
virtual void MakeProperPath(char* path) = 0;
virtual bool NeedsAuth() { return false; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password) {}
};
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
class plHttpFileGrabber : public plFileGrabber
{
private:
plHttpDiverseRequestMgr fRequestMgr;
public:
plHttpFileGrabber();
virtual bool IsServerAvailable(const char* serverName);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
virtual bool NeedsAuth() { return true; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password);
};
*/
class plNetShareFileGrabber : public plFileGrabber
{
private:
std::string fServerName;
public:
plNetShareFileGrabber();
virtual bool IsServerAvailable(const char* serverName, const char* currentDir);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
};
/*==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 plFileGrabber_h_inc
#define plFileGrabber_h_inc
#include <string>
#include "hsStream.h"
class plFileGrabber
{
public:
virtual bool IsServerAvailable(const char* serverName, const char* currentDir) = 0;
virtual bool FileToStream(const char* path, hsStream* stream) = 0;
virtual void SetServer(const char* server) = 0;
virtual void MakeProperPath(char* path) = 0;
virtual bool NeedsAuth() { return false; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password) {}
};
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
class plHttpFileGrabber : public plFileGrabber
{
private:
plHttpDiverseRequestMgr fRequestMgr;
public:
plHttpFileGrabber();
virtual bool IsServerAvailable(const char* serverName);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
virtual bool NeedsAuth() { return true; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password);
};
*/
class plNetShareFileGrabber : public plFileGrabber
{
private:
std::string fServerName;
public:
plNetShareFileGrabber();
virtual bool IsServerAvailable(const char* serverName, const char* currentDir);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
};
#endif

View File

@ -1,362 +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==*/
#include "HeadSpin.h"
#include "hsUtils.h"
#include "plManifest.h"
#include "../plEncryption/plChecksum.h"
#include "../plCompression/plZlibStream.h"
#include "../plFile/plEncryptedStream.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
class plManifestFile
{
public:
char* fFilename;
plMD5Checksum fSum;
plMD5Checksum fLocalSum;
UInt32 fSize;
UInt32 fCompressedSize;
UInt32 fFlags;
};
plManifest::plManifest(LogFunc log) :
fDownloadFiles(0),
fDownloadBytes(0),
fDirtySums(false),
fLog(log)
{
}
plManifest::~plManifest()
{
if (fDirtySums)
IWriteCache();
delete [] fManifestName;
for (int i = 0; i < fFiles.size(); i++)
{
delete [] fFiles[i]->fFilename;
delete fFiles[i];
}
}
bool plManifest::Read(hsStream* mfsStream, const char* basePath, const char* mfsName)
{
fBasePath = basePath;
fManifestName = hsStrcpy(mfsName);
fLog("--- Reading manifest for %s", fManifestName);
char buf[256];
while (mfsStream->ReadLn(buf, sizeof(buf)))
{
plManifestFile* file = new plManifestFile;
char* tok = strtok(buf, "\t");
file->fFilename = hsStrcpy(tok);
tok = strtok(nil, "\t");
file->fSum.SetFromHexString(tok);
tok = strtok(nil, "\t");
file->fSize = atoi(tok);
tok = strtok(nil, "\t");
file->fCompressedSize = atoi(tok);
tok = strtok(nil, "\t");
file->fFlags = atoi(tok);
fFiles.push_back(file);
}
return true;
}
void plManifest::ValidateFiles(ProgressFunc progress)
{
if (fFiles.empty())
return;
fLog("--- Validating files for %s", fManifestName);
IReadCache(progress);
fDownloadFiles = 0;
fDownloadBytes = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
// If the local checksum is invalid, this file wasn't in our cache.
// Get the sum, and update the progress bar.
if (!file->fLocalSum.IsValid())
{
fLog(" No sum for %s, calculating", file->fFilename);
file->fLocalSum.CalcFromFile(file->fFilename);
fDirtySums = true;
progress(file->fFilename, 1);
}
if (file->fLocalSum != file->fSum)
{
fLog(" Incorrect sum for %s", file->fFilename);
fDownloadFiles++;
fDownloadBytes += file->fCompressedSize;
}
}
fLog("--- Need to download %d files, %.1f MB", fDownloadFiles, float(fDownloadBytes) / (1024.f*1024.f));
}
void plManifest::DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber)
{
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
if (file->fLocalSum != file->fSum)
{
char serverPath[MAX_PATH];
sprintf(serverPath, "%s%s.gz", fBasePath.c_str(), file->fFilename);
grabber->MakeProperPath(serverPath);
hsRAMStream serverStream;
if (grabber->FileToStream(serverPath, &serverStream))
{
plFileUtils::EnsureFilePathExists(file->fFilename);
plFileUtils::RemoveFile(file->fFilename, true);
plZlibStream localStream;
if (localStream.Open(file->fFilename, "wb"))
{
char dataBuf[1024];
UInt32 sizeLeft = serverStream.GetSizeLeft();
while (UInt32 amtRead = serverStream.Read( (sizeof(dataBuf) > sizeLeft) ? sizeLeft : sizeof(dataBuf), dataBuf))
{
progress(file->fFilename, amtRead);
localStream.Write(amtRead, dataBuf);
sizeLeft = serverStream.GetSizeLeft();
}
localStream.Close();
// FIXME - Should we recalc this?
file->fLocalSum = file->fSum;
fDirtySums = true;
if (file->fFlags != 0)
IDecompressSound(file);
}
}
}
}
}
plManifestFile* plManifest::IFindFile(const char* name)
{
// FIXME
for (int i = 0; i < fFiles.size(); i++)
{
if (hsStrEQ(fFiles[i]->fFilename, name))
return fFiles[i];
}
return nil;
}
// KLUDGE - Put age checksums in the dat dir, for backwards compatability
const char* plManifest::IGetCacheDir()
{
const char* prefix = "";
if (strncmp(fFiles[0]->fFilename, "dat\\", strlen("dat\\")) == 0)
return "dat\\";
else
return "";
}
#define kCacheFileVersion 1
void plManifest::IWriteCache()
{
plEncryptedStream s;
bool openedFile = false;
UInt32 numFiles = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
plUnifiedTime modifiedTime;
if (file->fLocalSum.IsValid() &&
plFileUtils::GetFileTimes(file->fFilename, nil, &modifiedTime))
{
if (!openedFile)
{
openedFile = true;
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
s.Open(buf, "wb");
s.WriteSwap32(0);
s.WriteSwap32(kCacheFileVersion);
}
s.WriteSafeString(file->fFilename);
plMD5Checksum& checksum = file->fLocalSum;
s.Write(checksum.GetSize(), checksum.GetValue());
modifiedTime.Write(&s);
numFiles++;
}
}
if (openedFile)
{
s.Rewind();
s.WriteSwap32(numFiles);
s.Close();
}
}
void plManifest::IReadCache(ProgressFunc progress)
{
//
// Load valid cached checksums
//
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
hsStream* s = plEncryptedStream::OpenEncryptedFile(buf);
if (s)
{
UInt32 numCached = s->ReadSwap32();
UInt32 cacheFileVersion = s->ReadSwap32();
if (cacheFileVersion != kCacheFileVersion)
{
s->Close();
delete s;
return;
}
fLog(" Reading cache...found %d cached sums", numCached);
for (int i = 0; i < numCached; i++)
{
char* name = s->ReadSafeString();
UInt8 checksumBuf[MD5_DIGEST_LENGTH];
s->Read(sizeof(checksumBuf), checksumBuf);
plMD5Checksum checksum;
checksum.SetValue(checksumBuf);
plUnifiedTime modifiedTime;
modifiedTime.Read(s);
plManifestFile* file = IFindFile(name);
if (file)
{
plUnifiedTime curModifiedTime;
if (plFileUtils::GetFileTimes(file->fFilename, nil, &curModifiedTime))
{
if (curModifiedTime == modifiedTime)
file->fLocalSum = checksum;
else
fLog(" Invalid modified time for %s", name);
}
else
fLog(" Couldn't get modified time for %s", name);
progress(file->fFilename, 1);
}
else
fLog(" Couldn't find cached file '%s' in manifest, discarding", name);
delete [] name;
}
s->Close();
delete s;
}
}
#include "../plAudioCore/plAudioFileReader.h"
#include "../plAudio/plOGGCodec.h"
#include "../plAudio/plWavFile.h"
bool plManifest::IDecompressSound(plManifestFile* file)
{
enum
{
kSndFlagCacheSplit = 1<<0,
kSndFlagCacheStereo = 1<<2,
};
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit) ||
hsCheckBits(file->fFlags, kSndFlagCacheStereo))
{
plAudioFileReader* reader = plAudioFileReader::CreateReader(file->fFilename, plAudioCore::kAll, plAudioFileReader::kStreamNative);
if (!reader)
return false;
UInt32 size = reader->GetDataSize();
delete reader;
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit))
plAudioFileReader::CacheFile(file->fFilename, true);
if (hsCheckBits(file->fFlags, kSndFlagCacheStereo))
plAudioFileReader::CacheFile(file->fFilename, false);
}
return true;
}
/*==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 "HeadSpin.h"
#include "hsUtils.h"
#include "plManifest.h"
#include "../plEncryption/plChecksum.h"
#include "../plCompression/plZlibStream.h"
#include "../plFile/plEncryptedStream.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
class plManifestFile
{
public:
char* fFilename;
plMD5Checksum fSum;
plMD5Checksum fLocalSum;
UInt32 fSize;
UInt32 fCompressedSize;
UInt32 fFlags;
};
plManifest::plManifest(LogFunc log) :
fDownloadFiles(0),
fDownloadBytes(0),
fDirtySums(false),
fLog(log)
{
}
plManifest::~plManifest()
{
if (fDirtySums)
IWriteCache();
delete [] fManifestName;
for (int i = 0; i < fFiles.size(); i++)
{
delete [] fFiles[i]->fFilename;
delete fFiles[i];
}
}
bool plManifest::Read(hsStream* mfsStream, const char* basePath, const char* mfsName)
{
fBasePath = basePath;
fManifestName = hsStrcpy(mfsName);
fLog("--- Reading manifest for %s", fManifestName);
char buf[256];
while (mfsStream->ReadLn(buf, sizeof(buf)))
{
plManifestFile* file = new plManifestFile;
char* tok = strtok(buf, "\t");
file->fFilename = hsStrcpy(tok);
tok = strtok(nil, "\t");
file->fSum.SetFromHexString(tok);
tok = strtok(nil, "\t");
file->fSize = atoi(tok);
tok = strtok(nil, "\t");
file->fCompressedSize = atoi(tok);
tok = strtok(nil, "\t");
file->fFlags = atoi(tok);
fFiles.push_back(file);
}
return true;
}
void plManifest::ValidateFiles(ProgressFunc progress)
{
if (fFiles.empty())
return;
fLog("--- Validating files for %s", fManifestName);
IReadCache(progress);
fDownloadFiles = 0;
fDownloadBytes = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
// If the local checksum is invalid, this file wasn't in our cache.
// Get the sum, and update the progress bar.
if (!file->fLocalSum.IsValid())
{
fLog(" No sum for %s, calculating", file->fFilename);
file->fLocalSum.CalcFromFile(file->fFilename);
fDirtySums = true;
progress(file->fFilename, 1);
}
if (file->fLocalSum != file->fSum)
{
fLog(" Incorrect sum for %s", file->fFilename);
fDownloadFiles++;
fDownloadBytes += file->fCompressedSize;
}
}
fLog("--- Need to download %d files, %.1f MB", fDownloadFiles, float(fDownloadBytes) / (1024.f*1024.f));
}
void plManifest::DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber)
{
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
if (file->fLocalSum != file->fSum)
{
char serverPath[MAX_PATH];
sprintf(serverPath, "%s%s.gz", fBasePath.c_str(), file->fFilename);
grabber->MakeProperPath(serverPath);
hsRAMStream serverStream;
if (grabber->FileToStream(serverPath, &serverStream))
{
plFileUtils::EnsureFilePathExists(file->fFilename);
plFileUtils::RemoveFile(file->fFilename, true);
plZlibStream localStream;
if (localStream.Open(file->fFilename, "wb"))
{
char dataBuf[1024];
UInt32 sizeLeft = serverStream.GetSizeLeft();
while (UInt32 amtRead = serverStream.Read( (sizeof(dataBuf) > sizeLeft) ? sizeLeft : sizeof(dataBuf), dataBuf))
{
progress(file->fFilename, amtRead);
localStream.Write(amtRead, dataBuf);
sizeLeft = serverStream.GetSizeLeft();
}
localStream.Close();
// FIXME - Should we recalc this?
file->fLocalSum = file->fSum;
fDirtySums = true;
if (file->fFlags != 0)
IDecompressSound(file);
}
}
}
}
}
plManifestFile* plManifest::IFindFile(const char* name)
{
// FIXME
for (int i = 0; i < fFiles.size(); i++)
{
if (hsStrEQ(fFiles[i]->fFilename, name))
return fFiles[i];
}
return nil;
}
// KLUDGE - Put age checksums in the dat dir, for backwards compatability
const char* plManifest::IGetCacheDir()
{
const char* prefix = "";
if (strncmp(fFiles[0]->fFilename, "dat\\", strlen("dat\\")) == 0)
return "dat\\";
else
return "";
}
#define kCacheFileVersion 1
void plManifest::IWriteCache()
{
plEncryptedStream s;
bool openedFile = false;
UInt32 numFiles = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
plUnifiedTime modifiedTime;
if (file->fLocalSum.IsValid() &&
plFileUtils::GetFileTimes(file->fFilename, nil, &modifiedTime))
{
if (!openedFile)
{
openedFile = true;
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
s.Open(buf, "wb");
s.WriteSwap32(0);
s.WriteSwap32(kCacheFileVersion);
}
s.WriteSafeString(file->fFilename);
plMD5Checksum& checksum = file->fLocalSum;
s.Write(checksum.GetSize(), checksum.GetValue());
modifiedTime.Write(&s);
numFiles++;
}
}
if (openedFile)
{
s.Rewind();
s.WriteSwap32(numFiles);
s.Close();
}
}
void plManifest::IReadCache(ProgressFunc progress)
{
//
// Load valid cached checksums
//
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
hsStream* s = plEncryptedStream::OpenEncryptedFile(buf);
if (s)
{
UInt32 numCached = s->ReadSwap32();
UInt32 cacheFileVersion = s->ReadSwap32();
if (cacheFileVersion != kCacheFileVersion)
{
s->Close();
delete s;
return;
}
fLog(" Reading cache...found %d cached sums", numCached);
for (int i = 0; i < numCached; i++)
{
char* name = s->ReadSafeString();
UInt8 checksumBuf[MD5_DIGEST_LENGTH];
s->Read(sizeof(checksumBuf), checksumBuf);
plMD5Checksum checksum;
checksum.SetValue(checksumBuf);
plUnifiedTime modifiedTime;
modifiedTime.Read(s);
plManifestFile* file = IFindFile(name);
if (file)
{
plUnifiedTime curModifiedTime;
if (plFileUtils::GetFileTimes(file->fFilename, nil, &curModifiedTime))
{
if (curModifiedTime == modifiedTime)
file->fLocalSum = checksum;
else
fLog(" Invalid modified time for %s", name);
}
else
fLog(" Couldn't get modified time for %s", name);
progress(file->fFilename, 1);
}
else
fLog(" Couldn't find cached file '%s' in manifest, discarding", name);
delete [] name;
}
s->Close();
delete s;
}
}
#include "../plAudioCore/plAudioFileReader.h"
#include "../plAudio/plOGGCodec.h"
#include "../plAudio/plWavFile.h"
bool plManifest::IDecompressSound(plManifestFile* file)
{
enum
{
kSndFlagCacheSplit = 1<<0,
kSndFlagCacheStereo = 1<<2,
};
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit) ||
hsCheckBits(file->fFlags, kSndFlagCacheStereo))
{
plAudioFileReader* reader = plAudioFileReader::CreateReader(file->fFilename, plAudioCore::kAll, plAudioFileReader::kStreamNative);
if (!reader)
return false;
UInt32 size = reader->GetDataSize();
delete reader;
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit))
plAudioFileReader::CacheFile(file->fFilename, true);
if (hsCheckBits(file->fFlags, kSndFlagCacheStereo))
plAudioFileReader::CacheFile(file->fFilename, false);
}
return true;
}

View File

@ -1,93 +1,93 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plManifest_h_inc
#define plManifest_h_inc
#include "hsTypes.h"
#include "plFileGrabber.h"
#include <vector>
#include <string>
class plManifestFile;
typedef void (*ProgressFunc)(const char* name, int progDelta);
typedef void (*LogFunc)(const char* format, ...);
class plManifest
{
protected:
std::string fBasePath;
char* fManifestName;
typedef std::vector<plManifestFile*> FileVec;
FileVec fFiles;
UInt32 fDownloadFiles;
UInt32 fDownloadBytes;
bool fDirtySums;
LogFunc fLog;
bool IDecompressSound(plManifestFile* file);
plManifestFile* IFindFile(const char* name);
const char* IGetCacheDir();
void IReadCache(ProgressFunc progress);
void IWriteCache();
public:
plManifest(LogFunc log);
~plManifest();
bool Read(hsStream* mfsStream, const char* basePath, const char* mfsName);
void ValidateFiles(ProgressFunc progress);
void DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber);
int NumFiles() { return fFiles.size(); }
UInt32 NumDownloadFiles() { return fDownloadFiles; }
UInt32 DownloadSize() { return fDownloadBytes; }
};
/*==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 plManifest_h_inc
#define plManifest_h_inc
#include "hsTypes.h"
#include "plFileGrabber.h"
#include <vector>
#include <string>
class plManifestFile;
typedef void (*ProgressFunc)(const char* name, int progDelta);
typedef void (*LogFunc)(const char* format, ...);
class plManifest
{
protected:
std::string fBasePath;
char* fManifestName;
typedef std::vector<plManifestFile*> FileVec;
FileVec fFiles;
UInt32 fDownloadFiles;
UInt32 fDownloadBytes;
bool fDirtySums;
LogFunc fLog;
bool IDecompressSound(plManifestFile* file);
plManifestFile* IFindFile(const char* name);
const char* IGetCacheDir();
void IReadCache(ProgressFunc progress);
void IWriteCache();
public:
plManifest(LogFunc log);
~plManifest();
bool Read(hsStream* mfsStream, const char* basePath, const char* mfsName);
void ValidateFiles(ProgressFunc progress);
void DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber);
int NumFiles() { return fFiles.size(); }
UInt32 NumDownloadFiles() { return fDownloadFiles; }
UInt32 DownloadSize() { return fDownloadBytes; }
};
#endif // plManifest_h_inc

View File

@ -1,95 +1,95 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "plPlasmaServers.h"
#include "hsStream.h"
#include "hsUtils.h"
bool plPlasmaServers::GetServerInfo()
{
bool ret = true;
hsUNIXStream si;
if (si.Open("\\\\dirtcake\\ServerInfo\\ServerInfo.txt", "rb"))
{
char line[256];
// Make sure we've got the latest version
if (si.ReadLn(line, sizeof(line)))
{
int version = atoi(line);
si.ReadLn(line, sizeof(line));
if (version != 4)
{
char errorMsg[512];
sprintf(errorMsg, "This installer is out of date.\nPlease get the latest version from:\n\n%s", line);
hsMessageBox(errorMsg, "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
}
else
ret = false;
// Read in the servers, one per line
while (ret && si.ReadLn(line, sizeof(line)))
{
ServerInfo info;
info.fServerAddress = strtok(line, ",");
info.fServerName = strtok(nil, ",");
info.fURLBase = strtok(nil, ",");
info.fOutputDir = strtok(nil, ",");
info.fCurrentDir = strtok(nil, ",");
info.fCodeDir = strtok(nil, ",");
fServers.push_back(info);
}
si.Close();
}
else
{
hsMessageBox("Couldn't find server info", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
return ret;
}
/*==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 "plPlasmaServers.h"
#include "hsStream.h"
#include "hsUtils.h"
bool plPlasmaServers::GetServerInfo()
{
bool ret = true;
hsUNIXStream si;
if (si.Open("\\\\dirtcake\\ServerInfo\\ServerInfo.txt", "rb"))
{
char line[256];
// Make sure we've got the latest version
if (si.ReadLn(line, sizeof(line)))
{
int version = atoi(line);
si.ReadLn(line, sizeof(line));
if (version != 4)
{
char errorMsg[512];
sprintf(errorMsg, "This installer is out of date.\nPlease get the latest version from:\n\n%s", line);
hsMessageBox(errorMsg, "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
}
else
ret = false;
// Read in the servers, one per line
while (ret && si.ReadLn(line, sizeof(line)))
{
ServerInfo info;
info.fServerAddress = strtok(line, ",");
info.fServerName = strtok(nil, ",");
info.fURLBase = strtok(nil, ",");
info.fOutputDir = strtok(nil, ",");
info.fCurrentDir = strtok(nil, ",");
info.fCodeDir = strtok(nil, ",");
fServers.push_back(info);
}
si.Close();
}
else
{
hsMessageBox("Couldn't find server info", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
return ret;
}

View File

@ -1,75 +1,75 @@
/*==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 plPlasmaServers_h_inc
#define plPlasmaServers_h_inc
#include "hsTypes.h"
#include <vector>
class plPlasmaServers
{
protected:
class ServerInfo
{
public:
std::string fServerAddress;
std::string fServerName;
std::string fURLBase;
std::string fOutputDir;
std::string fCurrentDir;
std::string fCodeDir;
};
std::vector<ServerInfo> fServers;
public:
bool GetServerInfo();
int GetNumServers() { return fServers.size(); }
std::string& GetServerAddress(int i) { return fServers[i].fServerAddress; }
std::string& GetServerName(int i) { return fServers[i].fServerName; }
std::string& GetServerURLBase(int i) { return fServers[i].fURLBase; }
std::string& GetServerOutputDir(int i) { return fServers[i].fOutputDir; }
std::string& GetServerCurrentDir(int i) { return fServers[i].fCurrentDir; }
std::string& GetServerCodeDir(int i) { return fServers[i].fCodeDir; }
};
#endif // plPlasmaServers_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 plPlasmaServers_h_inc
#define plPlasmaServers_h_inc
#include "hsTypes.h"
#include <vector>
class plPlasmaServers
{
protected:
class ServerInfo
{
public:
std::string fServerAddress;
std::string fServerName;
std::string fURLBase;
std::string fOutputDir;
std::string fCurrentDir;
std::string fCodeDir;
};
std::vector<ServerInfo> fServers;
public:
bool GetServerInfo();
int GetNumServers() { return fServers.size(); }
std::string& GetServerAddress(int i) { return fServers[i].fServerAddress; }
std::string& GetServerName(int i) { return fServers[i].fServerName; }
std::string& GetServerURLBase(int i) { return fServers[i].fURLBase; }
std::string& GetServerOutputDir(int i) { return fServers[i].fOutputDir; }
std::string& GetServerCurrentDir(int i) { return fServers[i].fCurrentDir; }
std::string& GetServerCodeDir(int i) { return fServers[i].fCodeDir; }
};
#endif // plPlasmaServers_h_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,94 +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==*/
#include "hsTypes.h"
#include "jvBaseDlg.h"
#include <vector>
#include <string>
#include "plPlasmaServers.h"
#include "plFileGrabber.h"
class plManifest;
class jvDialogResizer;
class plPlasmaUpdate : public jvBaseDlg
{
protected:
static BOOL CALLBACK ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static std::string fUserName;
static std::string fPassword;
std::vector<plManifest*> fManifests;
char fIniPath[MAX_PATH];
bool fCanExit;
enum ProgressType { kValidating, kDownloading };
ProgressType fProgressType;
jvDialogResizer* fResizer;
plPlasmaServers fServers;
bool fAutoDownload;
plFileGrabber* fFileGrabber;
void IInit();
void IShutdown();
bool IReadServerInfo();
void IEnableCtrls(bool enable);
BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void ProgressFunc(const char* name, int delta);
static void ILog(const char* format, ...);
void IUpdateServer();
void IDeleteManifests();
bool IGetManifests(const char* serverRoot, bool external);
void IDownloadUpdates();
public:
plPlasmaUpdate();
virtual ~plPlasmaUpdate();
bool Create();
void SetAutoDownload() { fAutoDownload = true; }
};
/*==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 "jvBaseDlg.h"
#include <vector>
#include <string>
#include "plPlasmaServers.h"
#include "plFileGrabber.h"
class plManifest;
class jvDialogResizer;
class plPlasmaUpdate : public jvBaseDlg
{
protected:
static BOOL CALLBACK ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static std::string fUserName;
static std::string fPassword;
std::vector<plManifest*> fManifests;
char fIniPath[MAX_PATH];
bool fCanExit;
enum ProgressType { kValidating, kDownloading };
ProgressType fProgressType;
jvDialogResizer* fResizer;
plPlasmaServers fServers;
bool fAutoDownload;
plFileGrabber* fFileGrabber;
void IInit();
void IShutdown();
bool IReadServerInfo();
void IEnableCtrls(bool enable);
BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void ProgressFunc(const char* name, int delta);
static void ILog(const char* format, ...);
void IUpdateServer();
void IDeleteManifests();
bool IGetManifests(const char* serverRoot, bool external);
void IDownloadUpdates();
public:
plPlasmaUpdate();
virtual ~plPlasmaUpdate();
bool Create();
void SetAutoDownload() { fAutoDownload = true; }
};

View File

@ -1,138 +1,138 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_UPDATE DIALOGEX 0, 0, 128, 105
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "Parable Update"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_BUILD_COMBO,27,6,90,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Download",IDC_DL_BUTTON,34,86,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,36,110,11,LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER |
0x1,7,54,110,16
LTEXT "Latest Updates:",IDC_STATIC,7,26,51,8
CONTROL "xx.x MB of updates to download",IDC_DL_TEXT,"Static",
SS_LEFTNOWORDWRAP | WS_GROUP,7,74,110,8
END
IDD_PLASMAUPDATE_LOGIN DIALOGEX 0, 0, 150, 102
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Login"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,48,80,50,14
EDITTEXT IDC_USERNAME,7,17,135,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,7,45,135,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username",IDC_STATIC,7,7,134,8
LTEXT "Password",IDC_STATIC,7,35,136,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_UPDATE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 121
TOPMARGIN, 7
BOTTOMMARGIN, 98
END
IDD_PLASMAUPDATE_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 143
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_UPDATE DIALOGEX 0, 0, 128, 105
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "Parable Update"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_BUILD_COMBO,27,6,90,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Download",IDC_DL_BUTTON,34,86,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,36,110,11,LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER |
0x1,7,54,110,16
LTEXT "Latest Updates:",IDC_STATIC,7,26,51,8
CONTROL "xx.x MB of updates to download",IDC_DL_TEXT,"Static",
SS_LEFTNOWORDWRAP | WS_GROUP,7,74,110,8
END
IDD_PLASMAUPDATE_LOGIN DIALOGEX 0, 0, 150, 102
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Login"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,48,80,50,14
EDITTEXT IDC_USERNAME,7,17,135,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,7,45,135,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username",IDC_STATIC,7,7,134,8
LTEXT "Password",IDC_STATIC,7,35,136,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_UPDATE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 121
TOPMARGIN, 7
BOTTOMMARGIN, 98
END
IDD_PLASMAUPDATE_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 143
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,27 +1,27 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plPlasmaUpdate.rc
//
#define IDD_UPDATE 101
#define IDI_ICON1 102
#define IDI_ICON 102
#define IDD_PLASMAUPDATE_LOGIN 103
#define IDC_DL_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BUILD_COMBO 1008
#define IDC_PROGRESS 1014
#define IDC_DL_TEXT 1015
#define IDC_EDIT1 1016
#define IDC_USERNAME 1016
#define IDC_PASSWORD 1017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plPlasmaUpdate.rc
//
#define IDD_UPDATE 101
#define IDI_ICON1 102
#define IDI_ICON 102
#define IDD_PLASMAUPDATE_LOGIN 103
#define IDC_DL_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BUILD_COMBO 1008
#define IDC_PROGRESS 1014
#define IDC_DL_TEXT 1015
#define IDC_EDIT1 1016
#define IDC_USERNAME 1016
#define IDC_PASSWORD 1017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,297 +1,297 @@
/*==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 "PythonInterface.h"
#include "compile.h"
#include "eval.h"
#include "marshal.h"
#include "cStringIO.h"
static PyObject* stdFile; // python object of the stdout and err file
void PythonInterface::initPython(std::string rootDir)
{
// if haven't been initialized then do it
if ( Py_IsInitialized() == 0 )
{
// initialize the Python stuff
// let Python do some intialization...
Py_SetProgramName("plasma");
Py_Initialize();
// intialize any of our special plasma python modules
// initP2PInterface();
// save object to the Plasma module
// plasmaMod = PyImport_ImportModule("Plasma");
// create the StringIO for the stdout and stderr file
PycStringIO = (struct PycStringIO_CAPI*)PyCObject_Import("cStringIO", "cStringIO_CAPI");
stdFile = (*PycStringIO->NewOutput)(20000);
// if we need the builtins then find the builtin module
PyObject* sysmod = PyImport_ImportModule("sys");
// then add the builtin dicitionary to our module's dictionary
if (sysmod != NULL )
{
// get the sys's dictionary to find the stdout and stderr
PyObject* sys_dict = PyModule_GetDict(sysmod);
if (stdFile != nil)
{
PyDict_SetItemString(sys_dict,"stdout", stdFile);
PyDict_SetItemString(sys_dict,"stderr", stdFile);
}
// NOTE: we will reset the path to not include paths
// ...that Python may have found in the registery
PyObject* path_list = PyList_New(0);
printf("Setting up include dirs:\n");
printf("%s\n",rootDir.c_str());
PyObject* more_path = PyString_FromString(rootDir.c_str());
PyList_Append(path_list, more_path);
// make sure that our plasma libraries are gotten before the system ones
std::string temp = rootDir + "plasma";
printf("%s\n",temp.c_str());
PyObject* more_path3 = PyString_FromString(temp.c_str());
PyList_Append(path_list, more_path3);
temp = rootDir + "system";
printf("%s\n\n",temp.c_str());
PyObject* more_path2 = PyString_FromString("system");
PyList_Append(path_list, more_path2);
// set the path to be this one
PyDict_SetItemString(sys_dict,"path",path_list);
Py_DECREF(sysmod);
}
}
// initialized++;
}
void PythonInterface::addPythonPath(std::string path)
{
PyObject* sysmod = PyImport_ImportModule("sys");
if (sysmod != NULL)
{
PyObject* sys_dict = PyModule_GetDict(sysmod);
PyObject* path_list = PyDict_GetItemString(sys_dict, "path");
printf("Adding path %s\n", path.c_str());
PyObject* more_path = PyString_FromString(path.c_str());
PyList_Append(path_list, more_path);
Py_DECREF(sysmod);
}
}
void PythonInterface::finiPython()
{
if (Py_IsInitialized() != 0)
{
Py_Finalize();
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : CompileString
// PARAMETERS : command - string of commands to execute in the...
// : filename - filename to say where to code came from
//
// PURPOSE : run a python string in a specific module name
//
PyObject* PythonInterface::CompileString(char *command, char* filename)
{
PyObject* pycode = Py_CompileString(command, filename, Py_file_input);
return pycode;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : DumpObject
// PARAMETERS : pyobject - string of commands to execute in the...
//
// PURPOSE : marshals an object into a char string
//
hsBool PythonInterface::DumpObject(PyObject* pyobj, char** pickle, Int32* size)
{
PyObject *s; // the python string object where the marsalled object wil go
// convert object to a marshalled string python object
s = PyMarshal_WriteObjectToString(pyobj);
// did it actually do it?
if ( s != NULL )
{
// yes, then get the size and the string address
*size = PyString_Size(s);
*pickle = PyString_AsString(s);
return true;
}
else // otherwise, there was an error
{
// Yikes! errors!
PyErr_Print(); // FUTURE: we may have to get the string to display in max...later
return false;
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : getOutputAndReset
// PARAMETERS : none
//
// PURPOSE : get the Output to the error file to be displayed
//
int PythonInterface::getOutputAndReset(char** line)
{
PyObject* pyStr = (*PycStringIO->cgetvalue)(stdFile);
char *str = PyString_AsString( pyStr );
int size = PyString_Size( pyStr );
// reset the file back to zero
PyObject_CallMethod(stdFile,"reset","");
/*
// check to see if the debug python module is loaded
if ( dbgOut != nil )
{
// then send it the new text
if ( PyObject_CallFunction(dbgOut,"s",str) == nil )
{
// for some reason this function didn't, remember that and not call it again
dbgOut = nil;
// if there was an error make sure that the stderr gets flushed so it can be seen
PyErr_Print(); // make sure the error is printed
PyErr_Clear(); // clear the error
}
}
*/
if (line)
*line = str;
return size;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : CreateModule
// PARAMETERS : module - module name to create
//
// PURPOSE : create a new module with built-ins
//
PyObject* PythonInterface::CreateModule(char* module)
{
PyObject *m, *d;
// first we must get rid of any old modules of the same name, we'll replace it
PyObject *modules = PyImport_GetModuleDict();
if ((m = PyDict_GetItemString(modules, module)) != NULL && PyModule_Check(m))
// clear it
_PyModule_Clear(m);
// create the module
m = PyImport_AddModule(module);
if (m == NULL)
return nil;
d = PyModule_GetDict(m);
// add in the built-ins
// first make sure that we don't already have the builtins
if (PyDict_GetItemString(d, "__builtins__") == NULL)
{
// if we need the builtins then find the builtin module
PyObject *bimod = PyImport_ImportModule("__builtin__");
// then add the builtin dicitionary to our module's dictionary
if (bimod == NULL || PyDict_SetItemString(d, "__builtins__", bimod) != 0)
return nil;
Py_DECREF(bimod);
}
return m;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunPYC
// PARAMETERS : code - compiled code
// : module - module name to run the code in
//
// PURPOSE : run a compiled python code in a specific module name
//
hsBool PythonInterface::RunPYC(PyObject* code, PyObject* module)
{
PyObject *d, *v;
// make sure that we're given a good module... or at least one with an address
if ( !module )
{
// if no module was given then use just use the main module
module = PyImport_AddModule("__main__");
if (module == NULL)
return false;
}
// get the dictionaries for this module
d = PyModule_GetDict(module);
// run the string
v = PyEval_EvalCode((PyCodeObject*)code, d, d);
// check for errors and print them
if (v == NULL)
{
// Yikes! errors!
PyErr_Print();
return false;
}
Py_DECREF(v);
if (Py_FlushLine())
PyErr_Clear();
return true;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : GetModuleItem
// PARAMETERS : item - what item in the plasma module to get
//
// PURPOSE : get an item (probably a function) from a specific module
//
PyObject* PythonInterface::GetModuleItem(char* item, PyObject* module)
{
if ( module )
{
PyObject* d = PyModule_GetDict(module);
return PyDict_GetItemString(d, item);
}
return nil;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "PythonInterface.h"
#include "compile.h"
#include "eval.h"
#include "marshal.h"
#include "cStringIO.h"
static PyObject* stdFile; // python object of the stdout and err file
void PythonInterface::initPython(std::string rootDir)
{
// if haven't been initialized then do it
if ( Py_IsInitialized() == 0 )
{
// initialize the Python stuff
// let Python do some intialization...
Py_SetProgramName("plasma");
Py_Initialize();
// intialize any of our special plasma python modules
// initP2PInterface();
// save object to the Plasma module
// plasmaMod = PyImport_ImportModule("Plasma");
// create the StringIO for the stdout and stderr file
PycStringIO = (struct PycStringIO_CAPI*)PyCObject_Import("cStringIO", "cStringIO_CAPI");
stdFile = (*PycStringIO->NewOutput)(20000);
// if we need the builtins then find the builtin module
PyObject* sysmod = PyImport_ImportModule("sys");
// then add the builtin dicitionary to our module's dictionary
if (sysmod != NULL )
{
// get the sys's dictionary to find the stdout and stderr
PyObject* sys_dict = PyModule_GetDict(sysmod);
if (stdFile != nil)
{
PyDict_SetItemString(sys_dict,"stdout", stdFile);
PyDict_SetItemString(sys_dict,"stderr", stdFile);
}
// NOTE: we will reset the path to not include paths
// ...that Python may have found in the registery
PyObject* path_list = PyList_New(0);
printf("Setting up include dirs:\n");
printf("%s\n",rootDir.c_str());
PyObject* more_path = PyString_FromString(rootDir.c_str());
PyList_Append(path_list, more_path);
// make sure that our plasma libraries are gotten before the system ones
std::string temp = rootDir + "plasma";
printf("%s\n",temp.c_str());
PyObject* more_path3 = PyString_FromString(temp.c_str());
PyList_Append(path_list, more_path3);
temp = rootDir + "system";
printf("%s\n\n",temp.c_str());
PyObject* more_path2 = PyString_FromString("system");
PyList_Append(path_list, more_path2);
// set the path to be this one
PyDict_SetItemString(sys_dict,"path",path_list);
Py_DECREF(sysmod);
}
}
// initialized++;
}
void PythonInterface::addPythonPath(std::string path)
{
PyObject* sysmod = PyImport_ImportModule("sys");
if (sysmod != NULL)
{
PyObject* sys_dict = PyModule_GetDict(sysmod);
PyObject* path_list = PyDict_GetItemString(sys_dict, "path");
printf("Adding path %s\n", path.c_str());
PyObject* more_path = PyString_FromString(path.c_str());
PyList_Append(path_list, more_path);
Py_DECREF(sysmod);
}
}
void PythonInterface::finiPython()
{
if (Py_IsInitialized() != 0)
{
Py_Finalize();
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : CompileString
// PARAMETERS : command - string of commands to execute in the...
// : filename - filename to say where to code came from
//
// PURPOSE : run a python string in a specific module name
//
PyObject* PythonInterface::CompileString(char *command, char* filename)
{
PyObject* pycode = Py_CompileString(command, filename, Py_file_input);
return pycode;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : DumpObject
// PARAMETERS : pyobject - string of commands to execute in the...
//
// PURPOSE : marshals an object into a char string
//
hsBool PythonInterface::DumpObject(PyObject* pyobj, char** pickle, Int32* size)
{
PyObject *s; // the python string object where the marsalled object wil go
// convert object to a marshalled string python object
s = PyMarshal_WriteObjectToString(pyobj);
// did it actually do it?
if ( s != NULL )
{
// yes, then get the size and the string address
*size = PyString_Size(s);
*pickle = PyString_AsString(s);
return true;
}
else // otherwise, there was an error
{
// Yikes! errors!
PyErr_Print(); // FUTURE: we may have to get the string to display in max...later
return false;
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : getOutputAndReset
// PARAMETERS : none
//
// PURPOSE : get the Output to the error file to be displayed
//
int PythonInterface::getOutputAndReset(char** line)
{
PyObject* pyStr = (*PycStringIO->cgetvalue)(stdFile);
char *str = PyString_AsString( pyStr );
int size = PyString_Size( pyStr );
// reset the file back to zero
PyObject_CallMethod(stdFile,"reset","");
/*
// check to see if the debug python module is loaded
if ( dbgOut != nil )
{
// then send it the new text
if ( PyObject_CallFunction(dbgOut,"s",str) == nil )
{
// for some reason this function didn't, remember that and not call it again
dbgOut = nil;
// if there was an error make sure that the stderr gets flushed so it can be seen
PyErr_Print(); // make sure the error is printed
PyErr_Clear(); // clear the error
}
}
*/
if (line)
*line = str;
return size;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : CreateModule
// PARAMETERS : module - module name to create
//
// PURPOSE : create a new module with built-ins
//
PyObject* PythonInterface::CreateModule(char* module)
{
PyObject *m, *d;
// first we must get rid of any old modules of the same name, we'll replace it
PyObject *modules = PyImport_GetModuleDict();
if ((m = PyDict_GetItemString(modules, module)) != NULL && PyModule_Check(m))
// clear it
_PyModule_Clear(m);
// create the module
m = PyImport_AddModule(module);
if (m == NULL)
return nil;
d = PyModule_GetDict(m);
// add in the built-ins
// first make sure that we don't already have the builtins
if (PyDict_GetItemString(d, "__builtins__") == NULL)
{
// if we need the builtins then find the builtin module
PyObject *bimod = PyImport_ImportModule("__builtin__");
// then add the builtin dicitionary to our module's dictionary
if (bimod == NULL || PyDict_SetItemString(d, "__builtins__", bimod) != 0)
return nil;
Py_DECREF(bimod);
}
return m;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunPYC
// PARAMETERS : code - compiled code
// : module - module name to run the code in
//
// PURPOSE : run a compiled python code in a specific module name
//
hsBool PythonInterface::RunPYC(PyObject* code, PyObject* module)
{
PyObject *d, *v;
// make sure that we're given a good module... or at least one with an address
if ( !module )
{
// if no module was given then use just use the main module
module = PyImport_AddModule("__main__");
if (module == NULL)
return false;
}
// get the dictionaries for this module
d = PyModule_GetDict(module);
// run the string
v = PyEval_EvalCode((PyCodeObject*)code, d, d);
// check for errors and print them
if (v == NULL)
{
// Yikes! errors!
PyErr_Print();
return false;
}
Py_DECREF(v);
if (Py_FlushLine())
PyErr_Clear();
return true;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : GetModuleItem
// PARAMETERS : item - what item in the plasma module to get
//
// PURPOSE : get an item (probably a function) from a specific module
//
PyObject* PythonInterface::GetModuleItem(char* item, PyObject* module)
{
if ( module )
{
PyObject* d = PyModule_GetDict(module);
return PyDict_GetItemString(d, item);
}
return nil;
}

View File

@ -1,59 +1,59 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "Python.h"
#include <string>
namespace PythonInterface
{
void initPython(std::string rootDir);
void finiPython();
// So the Python packer can add extra paths
void addPythonPath(std::string dir);
PyObject* CompileString(char *command, char* filename);
hsBool DumpObject(PyObject* pyobj, char** pickle, Int32* size);
int getOutputAndReset(char** line=nil);
PyObject* CreateModule(char* module);
hsBool RunPYC(PyObject* code, PyObject* module);
PyObject* GetModuleItem(char* item, PyObject* module);
}
/*==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 "Python.h"
#include <string>
namespace PythonInterface
{
void initPython(std::string rootDir);
void finiPython();
// So the Python packer can add extra paths
void addPythonPath(std::string dir);
PyObject* CompileString(char *command, char* filename);
hsBool DumpObject(PyObject* pyobj, char** pickle, Int32* size);
int getOutputAndReset(char** line=nil);
PyObject* CreateModule(char* module);
hsBool RunPYC(PyObject* code, PyObject* module);
PyObject* GetModuleItem(char* item, PyObject* module);
}

View File

@ -1,467 +1,467 @@
/*==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 "hsStream.h"
#include "../plFile/hsFiles.h"
#include "PythonInterface.h"
#include <vector>
#include <string>
#include <direct.h>
static const char* kPackFileName = "python.pak";
static const char* kGlueFile = ".\\plasma\\glue.py";
static char* glueFile = (char*)kGlueFile;
void WritePythonFile(const char *fileName, const char* path, hsStream *s)
{
hsUNIXStream pyStream, glueStream;
char* pathAndFile = new char[strlen(fileName)+strlen(path)+2];
strcpy(pathAndFile,path);
char lastchar = pathAndFile[strlen(pathAndFile)-1];
if (lastchar != '\\' && lastchar != '/')
strcat(pathAndFile, "\\");
strcat(pathAndFile,fileName);
if (!pyStream.Open(pathAndFile) || !glueStream.Open(glueFile))
{
printf("Unable to open path %s, ",pathAndFile);
return;
}
printf("==Packing %s, ",fileName);
pyStream.FastFwd();
UInt32 pyFileSize = pyStream.GetPosition();
pyStream.Rewind();
glueStream.FastFwd();
UInt32 glueFileSize = glueStream.GetPosition();
glueStream.Rewind();
UInt32 totalSize = pyFileSize + glueFileSize + 2;
char *code = new char[totalSize];
UInt32 amountRead = pyStream.Read(pyFileSize, code);
hsAssert(amountRead == pyFileSize, "Bad read");
code[pyFileSize] = '\n';
amountRead = glueStream.Read(glueFileSize, code+pyFileSize+1);
hsAssert(amountRead == glueFileSize, "Bad read");
code[totalSize-1] = '\0';
// remove the CRs, they seem to give Python heartburn
int k = 0;
for (int i = 0; i < totalSize; i++)
{
if (code[i] != '\r') // is it not a CR?
code[k++] = code[i];
// else
// skip the CRs
}
PyObject* pythonCode = PythonInterface::CompileString(code, (char*)fileName);
if (pythonCode)
{
// we need to find out if this is PythonFile module
// create a module name... with the '.' as an X
// and create a python file name that is without the ".py"
char* modulename = new char[strlen(fileName)+1];
char* pythonfilename = new char[strlen(fileName)+1];
int j;
for (j=0; j<strlen(fileName); j++)
{
if (fileName[j] == '.')
{
modulename[j] = 'X';
pythonfilename[j] = '\0';
}
else
{
modulename[j] = fileName[j];
pythonfilename[j] = fileName[j];
}
}
modulename[j] = '\0';
PyObject* fModule = PythonInterface::CreateModule(modulename);
delete [] modulename;
// run the code
if (PythonInterface::RunPYC(pythonCode, fModule) )
{
// set the name of the file (in the global dictionary of the module)
PyObject* dict = PyModule_GetDict(fModule);
PyObject* pfilename = PyString_FromString(pythonfilename);
PyDict_SetItemString(dict, "glue_name", pfilename);
// next we need to:
// - create instance of class
PyObject* getID = PythonInterface::GetModuleItem("glue_getBlockID",fModule);
hsBool foundID = false;
if ( getID!=nil && PyCallable_Check(getID) )
{
PyObject* id = PyObject_CallFunction(getID,nil);
if ( id && PyInt_Check(id) )
foundID = true;
}
if ( foundID == false ) // then there was an error or no ID or somethin'
{
// oops, this is not a PythonFile modifier
// re-read the source and compile it without the glue code this time
memset(code,0,totalSize);
pyStream.Rewind();
amountRead = pyStream.Read(pyFileSize, code);
hsAssert(amountRead == pyFileSize, "Bad read");
strcat(code,"\n");
k = 0;
for (int i = 0; i < strlen(code)+1; i++)
{
if (code[i] != '\r') // is it not a CR?
code[k++] = code[i];
// else
// skip the CRs
}
pythonCode = PythonInterface::CompileString(code, (char*)fileName);
hsAssert(pythonCode,"Not sure why this didn't compile the second time???");
printf("an import file ");
}
else
printf("a PythonFile modifier(tm) ");
}
else
{
printf("......blast! Error during run-code!\n");
s->WriteSwap32(0);
char* errmsg;
int chars_read = PythonInterface::getOutputAndReset(&errmsg);
if (chars_read > 0)
{
printf(errmsg);
printf("\n");
}
}
delete [] pythonfilename;
}
// make sure that we have code to save
if (pythonCode)
{
Int32 size;
char* pycode;
PythonInterface::DumpObject(pythonCode,&pycode,&size);
printf("\n");
// print any message after each module
char* errmsg;
int chars_read = PythonInterface::getOutputAndReset(&errmsg);
if (chars_read > 0)
{
printf(errmsg);
printf("\n");
}
s->WriteSwap32(size);
s->Write(size, pycode);
}
else
{
printf("......blast! Compile error!\n");
s->WriteSwap32(0);
PyErr_Print();
PyErr_Clear();
char* errmsg;
int chars_read = PythonInterface::getOutputAndReset(&errmsg);
if (chars_read > 0)
{
printf(errmsg);
printf("\n");
}
}
delete [] code;
delete [] pathAndFile; // all done with the path and filename as one
pyStream.Close();
glueStream.Close();
}
void FindFiles(std::vector<std::string> &filenames, std::vector<std::string> &pathnames, const char* path)
{
// Get the names of all the python files
hsFolderIterator folder;
// if there is a path... set it
if ( path )
folder.SetPath(path);
while (folder.NextFileSuffix(".py"))
{
const char *fileName = folder.GetFileName();
filenames.push_back(fileName);
if ( path )
pathnames.push_back(path);
else
pathnames.push_back("");
}
}
std::string ToLowerCase(std::string str)
{
std::string retVal = "";
for (int i=0; i<str.length(); i++)
{
if ((str[i]>='A')&&(str[i]<='Z'))
retVal += (char)tolower(str[i]);
else
retVal += str[i];
}
return retVal;
}
void FindSubDirs(std::vector<std::string> &dirnames, std::vector<std::string> &pakNames, char *path)
{
hsFolderIterator folder;
if (path)
folder.SetPath(path);
while (folder.NextFile())
{
if (folder.IsDirectory())
{
std::string dirName = folder.GetFileName();
if ((dirName != ".")&&(dirName != "..")&&(ToLowerCase(dirName) != "system") && (ToLowerCase(dirName) != "plasma"))
{
dirnames.push_back(dirName);
pakNames.push_back(dirName+".pak");
}
}
}
}
// adds or removes the ending slash in a path as necessary
std::string AdjustEndingSlash(std::string path, bool endingSlash = false)
{
std::string retVal = path;
bool endSlashExists = false;
char temp = path[path.length()-1];
if (temp == '\\')
endSlashExists = true;
if (endingSlash)
{
if (!endSlashExists)
retVal += "\\";
}
else
{
if (endSlashExists)
{
std::string temp = "";
for (int i=0; i<retVal.length()-1; i++)
temp += retVal[i];
retVal = temp;
}
}
return retVal;
}
// appends partialPath onto the end of fullPath, inserting or removing slashes as necesssary
std::string ConcatDirs(std::string fullPath, std::string partialPath)
{
bool fullSlash = false, partialSlash = false;
char temp = fullPath[fullPath.length()-1];
if (temp == '\\')
fullSlash = true;
temp = partialPath[0];
if (temp == '\\')
partialSlash = true;
std::string retVal = "";
if (!fullSlash)
retVal = fullPath + "\\";
if (partialSlash)
{
std::string temp = "";
for (int i=1; i<partialPath.length(); i++)
temp += partialPath[i];
partialPath = temp;
}
retVal += partialPath;
return retVal;
}
void PackDirectory(std::string dir, std::string rootPath, std::string pakName, std::vector<std::string>& extraDirs, bool packSysAndPlasma = false)
{
// make sure the dir ends in a slash
dir = AdjustEndingSlash(dir,true);
printf("\nCreating %s using the contents of %s\n",pakName.c_str(),dir.c_str());
printf("Changing working directory to %s\n",rootPath.c_str());
if (_chdir(rootPath.c_str()))
{
printf("ERROR: Directory change to %s failed for some reason\n",rootPath.c_str());
printf("Unable to continue with the packing of this directory, aborting...\n");
return;
}
else
printf("Directory changed to %s\n",rootPath.c_str());
std::vector<std::string> fileNames;
std::vector<std::string> pathNames;
FindFiles(fileNames,pathNames,dir.c_str());
if (packSysAndPlasma)
{
printf("Adding the system and plasma directories to this pack file\n");
std::string tempPath;
tempPath = dir + "system";
FindFiles(fileNames,pathNames,tempPath.c_str());
tempPath = dir + "plasma";
FindFiles(fileNames,pathNames,tempPath.c_str());
}
// ok, we know how many files we're gonna pack, so make a fake index (we'll fill in later)
hsUNIXStream s;
if (!s.Open(pakName.c_str(), "wb"))
return;
s.WriteSwap32(fileNames.size());
int i;
for (i = 0; i < fileNames.size(); i++)
{
s.WriteSafeString(fileNames[i].c_str());
s.WriteSwap32(0);
}
PythonInterface::initPython(rootPath);
for (i = 0; i < extraDirs.size(); i++)
PythonInterface::addPythonPath(rootPath + extraDirs[i]);
// set to maximum optimization (includes removing __doc__ strings)
Py_OptimizeFlag = 2;
std::vector<UInt32> filePositions;
filePositions.resize(fileNames.size());
for (i = 0; i < fileNames.size(); i++)
{
UInt32 initialPos = s.GetPosition();
WritePythonFile(fileNames[i].c_str(), pathNames[i].c_str(), &s);
UInt32 endPos = s.GetPosition();
filePositions[i] = initialPos;
}
s.SetPosition(sizeof(UInt32));
for (i = 0; i < fileNames.size(); i++)
{
s.WriteSafeString(fileNames[i].c_str());
s.WriteSwap32(filePositions[i]);
}
s.Close();
PythonInterface::finiPython();
}
void PrintUsage()
{
printf("Usage:\n");
printf("plPythonPack [directory to pack...]\n");
printf("NOTE: the directory to pack must have full system and plasma dirs and\n");
printf(" must be a relative path to the current working directory\n");
}
void main(int argc, char *argv[])
{
printf("The Python Pack Utility\n");
char buffer[_MAX_PATH];
_getcwd(buffer,_MAX_PATH);
std::string baseWorkingDir = buffer;
// are they asking for usage?
if (argc == 2)
{
std::string temp = argv[1];
temp = ToLowerCase(temp);
if ((temp == "?") || (temp == "-?") || (temp == "/?") || (temp == "-help") || (temp == "/help")
|| (temp == "-h") || (temp == "/h"))
{
PrintUsage();
return;
}
}
// wrong number of args, print usage
if (argc > 2)
{
PrintUsage();
return;
}
std::vector<std::string> dirNames;
std::vector<std::string> pakNames;
std::string rootPath;
if (argc == 1)
{
FindSubDirs(dirNames,pakNames,nil);
rootPath = AdjustEndingSlash(baseWorkingDir,true);
}
else
{
std::string path = argv[1];
FindSubDirs(dirNames,pakNames,argv[1]);
rootPath = ConcatDirs(baseWorkingDir,path);
rootPath = AdjustEndingSlash(rootPath,true);
}
PackDirectory(rootPath,rootPath,rootPath+kPackFileName,dirNames,true);
for (int i=0; i<dirNames.size(); i++)
{
PackDirectory(dirNames[i],rootPath,rootPath+pakNames[i],dirNames);
}
}
/*==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 "hsStream.h"
#include "../plFile/hsFiles.h"
#include "PythonInterface.h"
#include <vector>
#include <string>
#include <direct.h>
static const char* kPackFileName = "python.pak";
static const char* kGlueFile = ".\\plasma\\glue.py";
static char* glueFile = (char*)kGlueFile;
void WritePythonFile(const char *fileName, const char* path, hsStream *s)
{
hsUNIXStream pyStream, glueStream;
char* pathAndFile = new char[strlen(fileName)+strlen(path)+2];
strcpy(pathAndFile,path);
char lastchar = pathAndFile[strlen(pathAndFile)-1];
if (lastchar != '\\' && lastchar != '/')
strcat(pathAndFile, "\\");
strcat(pathAndFile,fileName);
if (!pyStream.Open(pathAndFile) || !glueStream.Open(glueFile))
{
printf("Unable to open path %s, ",pathAndFile);
return;
}
printf("==Packing %s, ",fileName);
pyStream.FastFwd();
UInt32 pyFileSize = pyStream.GetPosition();
pyStream.Rewind();
glueStream.FastFwd();
UInt32 glueFileSize = glueStream.GetPosition();
glueStream.Rewind();
UInt32 totalSize = pyFileSize + glueFileSize + 2;
char *code = new char[totalSize];
UInt32 amountRead = pyStream.Read(pyFileSize, code);
hsAssert(amountRead == pyFileSize, "Bad read");
code[pyFileSize] = '\n';
amountRead = glueStream.Read(glueFileSize, code+pyFileSize+1);
hsAssert(amountRead == glueFileSize, "Bad read");
code[totalSize-1] = '\0';
// remove the CRs, they seem to give Python heartburn
int k = 0;
for (int i = 0; i < totalSize; i++)
{
if (code[i] != '\r') // is it not a CR?
code[k++] = code[i];
// else
// skip the CRs
}
PyObject* pythonCode = PythonInterface::CompileString(code, (char*)fileName);
if (pythonCode)
{
// we need to find out if this is PythonFile module
// create a module name... with the '.' as an X
// and create a python file name that is without the ".py"
char* modulename = new char[strlen(fileName)+1];
char* pythonfilename = new char[strlen(fileName)+1];
int j;
for (j=0; j<strlen(fileName); j++)
{
if (fileName[j] == '.')
{
modulename[j] = 'X';
pythonfilename[j] = '\0';
}
else
{
modulename[j] = fileName[j];
pythonfilename[j] = fileName[j];
}
}
modulename[j] = '\0';
PyObject* fModule = PythonInterface::CreateModule(modulename);
delete [] modulename;
// run the code
if (PythonInterface::RunPYC(pythonCode, fModule) )
{
// set the name of the file (in the global dictionary of the module)
PyObject* dict = PyModule_GetDict(fModule);
PyObject* pfilename = PyString_FromString(pythonfilename);
PyDict_SetItemString(dict, "glue_name", pfilename);
// next we need to:
// - create instance of class
PyObject* getID = PythonInterface::GetModuleItem("glue_getBlockID",fModule);
hsBool foundID = false;
if ( getID!=nil && PyCallable_Check(getID) )
{
PyObject* id = PyObject_CallFunction(getID,nil);
if ( id && PyInt_Check(id) )
foundID = true;
}
if ( foundID == false ) // then there was an error or no ID or somethin'
{
// oops, this is not a PythonFile modifier
// re-read the source and compile it without the glue code this time
memset(code,0,totalSize);
pyStream.Rewind();
amountRead = pyStream.Read(pyFileSize, code);
hsAssert(amountRead == pyFileSize, "Bad read");
strcat(code,"\n");
k = 0;
for (int i = 0; i < strlen(code)+1; i++)
{
if (code[i] != '\r') // is it not a CR?
code[k++] = code[i];
// else
// skip the CRs
}
pythonCode = PythonInterface::CompileString(code, (char*)fileName);
hsAssert(pythonCode,"Not sure why this didn't compile the second time???");
printf("an import file ");
}
else
printf("a PythonFile modifier(tm) ");
}
else
{
printf("......blast! Error during run-code!\n");
s->WriteSwap32(0);
char* errmsg;
int chars_read = PythonInterface::getOutputAndReset(&errmsg);
if (chars_read > 0)
{
printf(errmsg);
printf("\n");
}
}
delete [] pythonfilename;
}
// make sure that we have code to save
if (pythonCode)
{
Int32 size;
char* pycode;
PythonInterface::DumpObject(pythonCode,&pycode,&size);
printf("\n");
// print any message after each module
char* errmsg;
int chars_read = PythonInterface::getOutputAndReset(&errmsg);
if (chars_read > 0)
{
printf(errmsg);
printf("\n");
}
s->WriteSwap32(size);
s->Write(size, pycode);
}
else
{
printf("......blast! Compile error!\n");
s->WriteSwap32(0);
PyErr_Print();
PyErr_Clear();
char* errmsg;
int chars_read = PythonInterface::getOutputAndReset(&errmsg);
if (chars_read > 0)
{
printf(errmsg);
printf("\n");
}
}
delete [] code;
delete [] pathAndFile; // all done with the path and filename as one
pyStream.Close();
glueStream.Close();
}
void FindFiles(std::vector<std::string> &filenames, std::vector<std::string> &pathnames, const char* path)
{
// Get the names of all the python files
hsFolderIterator folder;
// if there is a path... set it
if ( path )
folder.SetPath(path);
while (folder.NextFileSuffix(".py"))
{
const char *fileName = folder.GetFileName();
filenames.push_back(fileName);
if ( path )
pathnames.push_back(path);
else
pathnames.push_back("");
}
}
std::string ToLowerCase(std::string str)
{
std::string retVal = "";
for (int i=0; i<str.length(); i++)
{
if ((str[i]>='A')&&(str[i]<='Z'))
retVal += (char)tolower(str[i]);
else
retVal += str[i];
}
return retVal;
}
void FindSubDirs(std::vector<std::string> &dirnames, std::vector<std::string> &pakNames, char *path)
{
hsFolderIterator folder;
if (path)
folder.SetPath(path);
while (folder.NextFile())
{
if (folder.IsDirectory())
{
std::string dirName = folder.GetFileName();
if ((dirName != ".")&&(dirName != "..")&&(ToLowerCase(dirName) != "system") && (ToLowerCase(dirName) != "plasma"))
{
dirnames.push_back(dirName);
pakNames.push_back(dirName+".pak");
}
}
}
}
// adds or removes the ending slash in a path as necessary
std::string AdjustEndingSlash(std::string path, bool endingSlash = false)
{
std::string retVal = path;
bool endSlashExists = false;
char temp = path[path.length()-1];
if (temp == '\\')
endSlashExists = true;
if (endingSlash)
{
if (!endSlashExists)
retVal += "\\";
}
else
{
if (endSlashExists)
{
std::string temp = "";
for (int i=0; i<retVal.length()-1; i++)
temp += retVal[i];
retVal = temp;
}
}
return retVal;
}
// appends partialPath onto the end of fullPath, inserting or removing slashes as necesssary
std::string ConcatDirs(std::string fullPath, std::string partialPath)
{
bool fullSlash = false, partialSlash = false;
char temp = fullPath[fullPath.length()-1];
if (temp == '\\')
fullSlash = true;
temp = partialPath[0];
if (temp == '\\')
partialSlash = true;
std::string retVal = "";
if (!fullSlash)
retVal = fullPath + "\\";
if (partialSlash)
{
std::string temp = "";
for (int i=1; i<partialPath.length(); i++)
temp += partialPath[i];
partialPath = temp;
}
retVal += partialPath;
return retVal;
}
void PackDirectory(std::string dir, std::string rootPath, std::string pakName, std::vector<std::string>& extraDirs, bool packSysAndPlasma = false)
{
// make sure the dir ends in a slash
dir = AdjustEndingSlash(dir,true);
printf("\nCreating %s using the contents of %s\n",pakName.c_str(),dir.c_str());
printf("Changing working directory to %s\n",rootPath.c_str());
if (_chdir(rootPath.c_str()))
{
printf("ERROR: Directory change to %s failed for some reason\n",rootPath.c_str());
printf("Unable to continue with the packing of this directory, aborting...\n");
return;
}
else
printf("Directory changed to %s\n",rootPath.c_str());
std::vector<std::string> fileNames;
std::vector<std::string> pathNames;
FindFiles(fileNames,pathNames,dir.c_str());
if (packSysAndPlasma)
{
printf("Adding the system and plasma directories to this pack file\n");
std::string tempPath;
tempPath = dir + "system";
FindFiles(fileNames,pathNames,tempPath.c_str());
tempPath = dir + "plasma";
FindFiles(fileNames,pathNames,tempPath.c_str());
}
// ok, we know how many files we're gonna pack, so make a fake index (we'll fill in later)
hsUNIXStream s;
if (!s.Open(pakName.c_str(), "wb"))
return;
s.WriteSwap32(fileNames.size());
int i;
for (i = 0; i < fileNames.size(); i++)
{
s.WriteSafeString(fileNames[i].c_str());
s.WriteSwap32(0);
}
PythonInterface::initPython(rootPath);
for (i = 0; i < extraDirs.size(); i++)
PythonInterface::addPythonPath(rootPath + extraDirs[i]);
// set to maximum optimization (includes removing __doc__ strings)
Py_OptimizeFlag = 2;
std::vector<UInt32> filePositions;
filePositions.resize(fileNames.size());
for (i = 0; i < fileNames.size(); i++)
{
UInt32 initialPos = s.GetPosition();
WritePythonFile(fileNames[i].c_str(), pathNames[i].c_str(), &s);
UInt32 endPos = s.GetPosition();
filePositions[i] = initialPos;
}
s.SetPosition(sizeof(UInt32));
for (i = 0; i < fileNames.size(); i++)
{
s.WriteSafeString(fileNames[i].c_str());
s.WriteSwap32(filePositions[i]);
}
s.Close();
PythonInterface::finiPython();
}
void PrintUsage()
{
printf("Usage:\n");
printf("plPythonPack [directory to pack...]\n");
printf("NOTE: the directory to pack must have full system and plasma dirs and\n");
printf(" must be a relative path to the current working directory\n");
}
void main(int argc, char *argv[])
{
printf("The Python Pack Utility\n");
char buffer[_MAX_PATH];
_getcwd(buffer,_MAX_PATH);
std::string baseWorkingDir = buffer;
// are they asking for usage?
if (argc == 2)
{
std::string temp = argv[1];
temp = ToLowerCase(temp);
if ((temp == "?") || (temp == "-?") || (temp == "/?") || (temp == "-help") || (temp == "/help")
|| (temp == "-h") || (temp == "/h"))
{
PrintUsage();
return;
}
}
// wrong number of args, print usage
if (argc > 2)
{
PrintUsage();
return;
}
std::vector<std::string> dirNames;
std::vector<std::string> pakNames;
std::string rootPath;
if (argc == 1)
{
FindSubDirs(dirNames,pakNames,nil);
rootPath = AdjustEndingSlash(baseWorkingDir,true);
}
else
{
std::string path = argv[1];
FindSubDirs(dirNames,pakNames,argv[1]);
rootPath = ConcatDirs(baseWorkingDir,path);
rootPath = AdjustEndingSlash(rootPath,true);
}
PackDirectory(rootPath,rootPath,rootPath+kPackFileName,dirNames,true);
for (int i=0; i<dirNames.size(); i++)
{
PackDirectory(dirNames[i],rootPath,rootPath+pakNames[i],dirNames);
}
}

View File

@ -1,61 +1,61 @@
/*==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/Apps/plUruLauncher/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
/*****************************************************************************
*
* SelfPatcher.cpp
*
***/
bool SelfPatch (bool noSelfPatch, bool * abort, ENetError * result, plLauncherInfo *info);
/*==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/Apps/plUruLauncher/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
/*****************************************************************************
*
* SelfPatcher.cpp
*
***/
bool SelfPatch (bool noSelfPatch, bool * abort, ENetError * result, plLauncherInfo *info);
void SetReturnCode (DWORD retCode);

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,104 +1,104 @@
/*==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/Apps/plUruLauncher/plLauncherCallback.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/plLauncherCallback.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
enum EStatus {
kStatusOk,
kStatusError,
kStatusPending,
};
struct PatchInfo {
unsigned progress;
unsigned stage;
unsigned progressStage;
};
typedef void (*launcherCallback)(int status, void *param);
typedef void (*setTextCallback)(const char text[]);
typedef void (*setStatusTextCallback)(const char text[]);
typedef void (*setTimeRemainingCallback)(unsigned seconds);
typedef void (*setBytesRemainingCallback)(unsigned bytes);
struct plLauncherInfo {
wchar path[MAX_PATH];
wchar cmdLine[512];
unsigned buildId; // buildId override
launcherCallback prepCallback;
launcherCallback initCallback;
launcherCallback startCallback;
launcherCallback stopCallback;
launcherCallback terminateCallback;
launcherCallback progressCallback;
launcherCallback exitCallback;
setTextCallback SetText;
setStatusTextCallback SetStatusText;
setTimeRemainingCallback SetTimeRemaining;
setBytesRemainingCallback SetBytesRemaining;
PatchInfo patchInfo;
bool IsTGCider;
DWORD returnCode; // used so we can pass a new process id back to gametap. That way gametap wont think uru has exited when the patcher quits.
HWND dialog;
};
/*****************************************************************************
*
* Main.cpp
*
***/
void SetProgress (unsigned progress) ;
void SetText (const char text[]);
void SetStatusText (const char text[]);
void SetTimeRemaining(unsigned seconds);
/*==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/Apps/plUruLauncher/plLauncherCallback.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/plLauncherCallback.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
enum EStatus {
kStatusOk,
kStatusError,
kStatusPending,
};
struct PatchInfo {
unsigned progress;
unsigned stage;
unsigned progressStage;
};
typedef void (*launcherCallback)(int status, void *param);
typedef void (*setTextCallback)(const char text[]);
typedef void (*setStatusTextCallback)(const char text[]);
typedef void (*setTimeRemainingCallback)(unsigned seconds);
typedef void (*setBytesRemainingCallback)(unsigned bytes);
struct plLauncherInfo {
wchar path[MAX_PATH];
wchar cmdLine[512];
unsigned buildId; // buildId override
launcherCallback prepCallback;
launcherCallback initCallback;
launcherCallback startCallback;
launcherCallback stopCallback;
launcherCallback terminateCallback;
launcherCallback progressCallback;
launcherCallback exitCallback;
setTextCallback SetText;
setStatusTextCallback SetStatusText;
setTimeRemainingCallback SetTimeRemaining;
setBytesRemainingCallback SetBytesRemaining;
PatchInfo patchInfo;
bool IsTGCider;
DWORD returnCode; // used so we can pass a new process id back to gametap. That way gametap wont think uru has exited when the patcher quits.
HWND dialog;
};
/*****************************************************************************
*
* Main.cpp
*
***/
void SetProgress (unsigned progress) ;
void SetText (const char text[]);
void SetStatusText (const char text[]);
void SetTimeRemaining(unsigned seconds);
void SetBytesRemaining(unsigned bytes);

View File

@ -1,125 +1,125 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG DIALOGEX 0, 0, 301, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS |
DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL 109,IDB_BITMAP,"Static",SS_BITMAP | SS_SUNKEN,7,7,288,36
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER | 0x1,7,
162,234,11
LTEXT "Static",IDC_TEXT,10,152,266,8
PUSHBUTTON "Cancel",IDCANCEL,243,162,51,11
LTEXT "Welcome to URU",IDC_STATUS_TEXT,19,57,266,17
GROUPBOX "",IDC_STATIC,7,46,287,49
GROUPBOX "Status",IDC_STATIC,7,103,287,44
LTEXT "Approx. Time Remaining:",IDC_STATIC,19,117,88,11
LTEXT "Update Remaining:",IDC_STATIC,20,130,73,9
LTEXT "...",IDC_TIMEREMAINING,111,117,165,12
LTEXT "...",IDC_BYTESREMAINING,111,130,42,12
RTEXT "Product String",IDC_PRODUCTSTRING,19,85,272,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 294
TOPMARGIN, 7
BOTTOMMARGIN, 173
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP BITMAP "banner.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG DIALOGEX 0, 0, 301, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS |
DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL 109,IDB_BITMAP,"Static",SS_BITMAP | SS_SUNKEN,7,7,288,36
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER | 0x1,7,
162,234,11
LTEXT "Static",IDC_TEXT,10,152,266,8
PUSHBUTTON "Cancel",IDCANCEL,243,162,51,11
LTEXT "Welcome to URU",IDC_STATUS_TEXT,19,57,266,17
GROUPBOX "",IDC_STATIC,7,46,287,49
GROUPBOX "Status",IDC_STATIC,7,103,287,44
LTEXT "Approx. Time Remaining:",IDC_STATIC,19,117,88,11
LTEXT "Update Remaining:",IDC_STATIC,20,130,73,9
LTEXT "...",IDC_TIMEREMAINING,111,117,165,12
LTEXT "...",IDC_BYTESREMAINING,111,130,42,12
RTEXT "Product String",IDC_PRODUCTSTRING,19,85,272,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 294
TOPMARGIN, 7
BOTTOMMARGIN, 173
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP BITMAP "banner.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,25 +1,25 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plUruLauncher.rc
//
#define IDD_DIALOG 106
#define IDB_BITMAP 109
#define IDI_ICON1 111
#define IDC_PROGRESS 1003
#define IDC_TEXT 1006
#define IDC_STATUS_TEXT 1009
#define IDC_TIMEREMAINING 1010
#define IDC_BYTESREMAINING 1011
#define IDC_PRODUCTSTRING 1012
#define IDC_FILESREMAINING 1013
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 112
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plUruLauncher.rc
//
#define IDD_DIALOG 106
#define IDB_BITMAP 109
#define IDI_ICON1 111
#define IDC_PROGRESS 1003
#define IDC_TEXT 1006
#define IDC_STATUS_TEXT 1009
#define IDC_TIMEREMAINING 1010
#define IDC_BYTESREMAINING 1011
#define IDC_PRODUCTSTRING 1012
#define IDC_FILESREMAINING 1013
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 112
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -1,61 +1,61 @@
struct HS_POINT2_NAME {
HS_POINT2_TYPE fX, fY;
HS_POINT2_NAME& Set(HS_POINT2_TYPE x, HS_POINT2_TYPE y)
{
fX = x;
fY = y;
return *this;
}
HS_POINT2_NAME& operator+=(const HS_POINT2_NAME& s)
{
this->fX += s.fX;
this->fY += s.fY;
return *this;
}
HS_POINT2_NAME& operator-=(const HS_POINT2_NAME& s)
{
this->fX -= s.fX;
this->fY -= s.fY;
return *this;
}
#if 0 // Havok reeks
friend int operator==(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
return (s.fX == t.fX && s.fY == t.fY);
}
friend int operator!=(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
return !(s == t);
}
#else // Havok reeks
int operator==(const HS_POINT2_NAME& ss) const
{
return (ss.fX == fX && ss.fY == fY);
}
int operator!=(const HS_POINT2_NAME& ss)
{
return !(ss == *this);
}
#endif // Havok reeks
friend HS_POINT2_NAME operator+(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
HS_POINT2_NAME result;
result.Set(s.fX + t.fX, s.fY + t.fY);
return result;
}
friend HS_POINT2_NAME operator-(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
HS_POINT2_NAME result;
result.Set(s.fX - t.fX, s.fY - t.fY);
return result;
}
friend HS_POINT2_NAME operator-(const HS_POINT2_NAME& s)
{
HS_POINT2_NAME result = { -s.fX, -s.fY };
return result;
}
#undef HS_POINT2_NAME
#undef HS_POINT2_TYPE
struct HS_POINT2_NAME {
HS_POINT2_TYPE fX, fY;
HS_POINT2_NAME& Set(HS_POINT2_TYPE x, HS_POINT2_TYPE y)
{
fX = x;
fY = y;
return *this;
}
HS_POINT2_NAME& operator+=(const HS_POINT2_NAME& s)
{
this->fX += s.fX;
this->fY += s.fY;
return *this;
}
HS_POINT2_NAME& operator-=(const HS_POINT2_NAME& s)
{
this->fX -= s.fX;
this->fY -= s.fY;
return *this;
}
#if 0 // Havok reeks
friend int operator==(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
return (s.fX == t.fX && s.fY == t.fY);
}
friend int operator!=(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
return !(s == t);
}
#else // Havok reeks
int operator==(const HS_POINT2_NAME& ss) const
{
return (ss.fX == fX && ss.fY == fY);
}
int operator!=(const HS_POINT2_NAME& ss)
{
return !(ss == *this);
}
#endif // Havok reeks
friend HS_POINT2_NAME operator+(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
HS_POINT2_NAME result;
result.Set(s.fX + t.fX, s.fY + t.fY);
return result;
}
friend HS_POINT2_NAME operator-(const HS_POINT2_NAME& s, const HS_POINT2_NAME& t)
{
HS_POINT2_NAME result;
result.Set(s.fX - t.fX, s.fY - t.fY);
return result;
}
friend HS_POINT2_NAME operator-(const HS_POINT2_NAME& s)
{
HS_POINT2_NAME result = { -s.fX, -s.fY };
return result;
}
#undef HS_POINT2_NAME
#undef HS_POINT2_TYPE

View File

@ -1,190 +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==*/
#include "HeadSpin.h"
#include "hsRefCnt.h"
#include "hsUtils.h"
#include "hsStlUtils.h"
#include "hsExceptions.h"
#if HS_BUILD_FOR_MAC
#include <Events.h>
#include <ToolUtils.h>
#include <Windows.h>
#endif
#if HS_BUILD_FOR_WIN32
# include <crtdbg.h> /* for _RPT_BASE */
# define WIN32_LEAN_AND_MEAN
# define WIN32_EXTRA_LEAN
# include <windows.h> // For OutputDebugString()
#endif
///////////////////////////////////////////////////////////////////////////
/////////////////// For Status Messages ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////
hsDebugMessageProc gHSStatusProc = nil;
hsDebugMessageProc hsSetStatusMessageProc(hsDebugMessageProc newProc)
{
hsDebugMessageProc oldProc = gHSStatusProc;
gHSStatusProc = newProc;
return oldProc;
}
//////////////////////////////////////////////////////////////////////////
hsDebugMessageProc gHSDebugProc = nil;
hsDebugMessageProc hsSetDebugMessageProc(hsDebugMessageProc newProc)
{
hsDebugMessageProc oldProc = gHSDebugProc;
gHSDebugProc = newProc;
return oldProc;
}
#ifdef HS_DEBUGGING
void hsDebugMessage (const char message[], long val)
{
char s[1024];
#if HS_BUILD_FOR_WIN32
#define strfmt _snprintf
#else
#define strfmt snprintf
#endif
if (val)
s[0] = strfmt(&s[1], 1022, "%s: %ld", message, val);
else
s[0] = strfmt(&s[1], 1022, "%s", message);
if (gHSDebugProc)
gHSDebugProc(&s[1]);
else
#if HS_BUILD_FOR_MAC
DebugStr((unsigned char*)s);
#elif HS_BUILD_FOR_WIN32
{ OutputDebugString(&s[1]);
OutputDebugString("\n");
}
#elif (HS_BUILD_FOR_BE || HS_BUILD_FOR_UNIX )
{ fprintf(stderr, "%s\n", &s[1]);
// hsThrow(&s[1]);
}
#elif HS_BUILD_FOR_PS2
fprintf(stderr, "%s\n", &s[1]);
#else
hsThrow(&s[1]);
#endif
}
#endif
///////////////////////////////////////////////////////////////////
hsRefCnt::~hsRefCnt()
{
hsDebugCode(hsThrowIfFalse(fRefCnt == 1);)
}
void hsRefCnt::Ref()
{
fRefCnt++;
}
void hsRefCnt::UnRef()
{
hsDebugCode(hsThrowIfFalse(fRefCnt >= 1);)
if (fRefCnt == 1) // don't decrement if we call delete
delete this;
else
--fRefCnt;
}
////////////////////////////////////////////////////////////////////////////
#ifndef PLASMA_EXTERNAL_RELEASE
void hsStatusMessage(const char message[])
{
if (gHSStatusProc) {
gHSStatusProc(message);
} else {
#if HS_BUILD_FOR_PS2 || HS_BUILD_FOR_UNIX
printf("%s",message);
int len = strlen(message);
if (len>0 && message[len-1]!='\n')
printf("\n");
#elif HS_BUILD_FOR_WIN32
OutputDebugString(message);
int len = strlen(message);
if (len>0 && message[len-1]!='\n')
OutputDebugString("\n");
#endif // MAC ?????? TODO
}
}
void hsStatusMessageV(const char * fmt, va_list args)
{
char buffer[2000];
vsprintf(buffer, fmt, args);
hsStatusMessage(buffer);
}
void hsStatusMessageF(const char * fmt, ...)
{
va_list args;
va_start(args,fmt);
hsStatusMessageV(fmt,args);
va_end(args);
}
#endif // not PLASMA_EXTERNAL_RELEASE
/*==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 "HeadSpin.h"
#include "hsRefCnt.h"
#include "hsUtils.h"
#include "hsStlUtils.h"
#include "hsExceptions.h"
#if HS_BUILD_FOR_MAC
#include <Events.h>
#include <ToolUtils.h>
#include <Windows.h>
#endif
#if HS_BUILD_FOR_WIN32
# include <crtdbg.h> /* for _RPT_BASE */
# define WIN32_LEAN_AND_MEAN
# define WIN32_EXTRA_LEAN
# include <windows.h> // For OutputDebugString()
#endif
///////////////////////////////////////////////////////////////////////////
/////////////////// For Status Messages ///////////////////////////////////
///////////////////////////////////////////////////////////////////////////
hsDebugMessageProc gHSStatusProc = nil;
hsDebugMessageProc hsSetStatusMessageProc(hsDebugMessageProc newProc)
{
hsDebugMessageProc oldProc = gHSStatusProc;
gHSStatusProc = newProc;
return oldProc;
}
//////////////////////////////////////////////////////////////////////////
hsDebugMessageProc gHSDebugProc = nil;
hsDebugMessageProc hsSetDebugMessageProc(hsDebugMessageProc newProc)
{
hsDebugMessageProc oldProc = gHSDebugProc;
gHSDebugProc = newProc;
return oldProc;
}
#ifdef HS_DEBUGGING
void hsDebugMessage (const char message[], long val)
{
char s[1024];
#if HS_BUILD_FOR_WIN32
#define strfmt _snprintf
#else
#define strfmt snprintf
#endif
if (val)
s[0] = strfmt(&s[1], 1022, "%s: %ld", message, val);
else
s[0] = strfmt(&s[1], 1022, "%s", message);
if (gHSDebugProc)
gHSDebugProc(&s[1]);
else
#if HS_BUILD_FOR_MAC
DebugStr((unsigned char*)s);
#elif HS_BUILD_FOR_WIN32
{ OutputDebugString(&s[1]);
OutputDebugString("\n");
}
#elif (HS_BUILD_FOR_BE || HS_BUILD_FOR_UNIX )
{ fprintf(stderr, "%s\n", &s[1]);
// hsThrow(&s[1]);
}
#elif HS_BUILD_FOR_PS2
fprintf(stderr, "%s\n", &s[1]);
#else
hsThrow(&s[1]);
#endif
}
#endif
///////////////////////////////////////////////////////////////////
hsRefCnt::~hsRefCnt()
{
hsDebugCode(hsThrowIfFalse(fRefCnt == 1);)
}
void hsRefCnt::Ref()
{
fRefCnt++;
}
void hsRefCnt::UnRef()
{
hsDebugCode(hsThrowIfFalse(fRefCnt >= 1);)
if (fRefCnt == 1) // don't decrement if we call delete
delete this;
else
--fRefCnt;
}
////////////////////////////////////////////////////////////////////////////
#ifndef PLASMA_EXTERNAL_RELEASE
void hsStatusMessage(const char message[])
{
if (gHSStatusProc) {
gHSStatusProc(message);
} else {
#if HS_BUILD_FOR_PS2 || HS_BUILD_FOR_UNIX
printf("%s",message);
int len = strlen(message);
if (len>0 && message[len-1]!='\n')
printf("\n");
#elif HS_BUILD_FOR_WIN32
OutputDebugString(message);
int len = strlen(message);
if (len>0 && message[len-1]!='\n')
OutputDebugString("\n");
#endif // MAC ?????? TODO
}
}
void hsStatusMessageV(const char * fmt, va_list args)
{
char buffer[2000];
vsprintf(buffer, fmt, args);
hsStatusMessage(buffer);
}
void hsStatusMessageF(const char * fmt, ...)
{
va_list args;
va_start(args,fmt);
hsStatusMessageV(fmt,args);
va_end(args);
}
#endif // not PLASMA_EXTERNAL_RELEASE

View File

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

View File

@ -1,493 +1,493 @@
/*==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 hsBiExpander_inc
#define hsBiExpander_inc
#include "hsMemory.h"
#include "hsTemplates.h"
///////////////////////////////////////////////////////////////////////////////
////////////// Expander ///////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <class T> class hsExpander {
private:
Int32 fNumPost;
Int32 fNumPostAlloc;
T* fArray;
Int32 fGrowBy; // default = 0, to double
Int32 fMinSize; // default = 1, min == 1
Int32 fCurrent;
hsExpander(const hsExpander& x); // make it passed as ref or pointer
void IExpand(int newSize);
public:
enum { kMissingIndex = -1 };
hsExpander(Int32 minSize = 1, Int32 growBy = 0);
virtual ~hsExpander();
hsExpander<T>& operator=(const hsExpander<T>&orig) { return Copy(orig); }
hsExpander<T>& Copy(const hsExpander<T>& orig);
void SetCount(int cnt) { if( cnt >= fNumPostAlloc )IExpand(cnt); fNumPost = cnt; }
Int32 GetCount() const { return fNumPost; }
hsBool Empty() const { return GetCount() == 0; }
const T& Get(Int32 index) const;
Int32 Get(Int32 index, Int32 count, T data[]) const;
Int32 Find(const T&) const; // returns kMissingIndex if not found
void SetArray(T* a, Int32 cnt);
T* GetArray() { return fArray; }
T& operator[]( Int32 index );
Int32 Append(const T&); // returns t's index
T* Append();
Int32 Push(const T& t) { return Append(t); }
T* Push() { return Append(); }
T* Top() { return fNumPost ? fArray + fNumPost-1 : nil; }
Int32 Pop(T* t); // returns count of remaining
Int32 Pop();
void Reset(); // clears out everything
T& Head() { return fArray[0]; }
T& Tail() { return fArray[fNumPost-1]; }
T& Current() { return fArray[fCurrent]; }
void First();
void Last();
void Plus() { ++fCurrent; }
hsBool More() { return (fCurrent < fNumPost); }
};
template <class T>
hsExpander<T>& hsExpander<T>::Copy(const hsExpander<T>& orig)
{
SetCount(orig.GetCount());
int i;
for( i = 0; i < GetCount(); i++ )
fArray[i] = orig.fArray[i];
return *this;
}
template <class T>
void hsExpander<T>::SetArray(T* a, Int32 cnt)
{
delete [] fArray;
if( a )
fArray = a;
fNumPost = fNumPostAlloc = cnt;
}
template <class T>
void hsExpander<T>::IExpand(int newSize)
{
Int32 newPostAlloc = fNumPostAlloc;
if( !newPostAlloc )
newPostAlloc++;
while( newPostAlloc <= newSize )
newPostAlloc = fGrowBy ? newPostAlloc + fGrowBy : newPostAlloc << 1;
T* newArray = TRACKED_NEW T[newPostAlloc];
int i;
for( i = 0; i < fNumPost; i++ )
newArray[i] = fArray[i];
delete [] (fArray);
fArray = newArray;
fNumPostAlloc = newPostAlloc;
}
template <class T>
hsExpander<T>::hsExpander(Int32 minSize, Int32 growBy)
{
hsThrowIfBadParam(minSize < 0);
hsThrowIfBadParam(growBy < 0);
fMinSize = minSize+1;
fGrowBy = growBy;
fArray = TRACKED_NEW T[fMinSize];
fNumPostAlloc = fMinSize;
fNumPost = 0;
}
template <class T>
hsExpander<T>::~hsExpander()
{
delete [] fArray;
}
template <class T>
void hsExpander<T>::First()
{
fCurrent = 0;
}
template <class T>
void hsExpander<T>::Last()
{
fCurrent = fNumPost-1;
}
template <class T>
T& hsExpander<T>::operator[]( Int32 index )
{
hsDebugCode(hsThrowIfBadParam((index < 0)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
const T& hsExpander<T>::Get( Int32 index ) const
{
hsDebugCode(hsThrowIfBadParam((index < 0)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
Int32 hsExpander<T>::Get(Int32 index, Int32 count, T data[]) const
{
if( count > 0 )
{ hsThrowIfNilParam(data);
hsThrowIfBadParam((index < 0)||(index >= fNumPost));
if (index + count > fNumPost)
count = fNumPost - index;
for (int i = 0; i < count; i++)
data[i] = fArray[i + index];
}
return count;
}
template <class T>
Int32 hsExpander<T>::Find(const T& obj) const
{
for (int i = 0; i < fNumPost; i++)
if (fArray[i] == obj)
return i;
return kMissingIndex;
}
template <class T>
Int32 hsExpander<T>::Append(const T& obj)
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc);
fArray[fNumPost] = obj;
return fNumPost++;
}
template <class T>
T* hsExpander<T>::Append()
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc);
return fArray + fNumPost++;
}
template <class T>
Int32 hsExpander<T>::Pop(T*t)
{
hsThrowIfBadParam(Empty());
--fNumPost;
if( t )
*t = fArray[fNumPost];
return GetCount();
}
template <class T>
Int32 hsExpander<T>::Pop()
{
hsThrowIfBadParam(Empty());
--fNumPost;
return GetCount();
}
template <class T>
void hsExpander<T>::Reset()
{
fNumPost = 0;
}
///////////////////////////////////////////////////////////////////////////////
////////////// BiExpander /////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <class T> class hsBiExpander {
private:
Int32 fNumPre;
Int32 fNumPost;
Int32 fNumPreAlloc;
Int32 fNumPostAlloc;
T* fArray;
Int32 fGrowBy; // default = 0, to double
Int32 fMinSize; // default = 1, min == 1
Int32 fCurrent;
hsBiExpander<T>& operator=(const hsBiExpander<T>&); // don't allow assignment
hsBiExpander(const hsBiExpander<T>&); // make it passed as ref or pointer
void IExpand(int newSize, hsBool towardEnd = true);
public:
enum { kMissingIndex = -1 };
hsBiExpander(Int32 minSize = 1, Int32 growBy = 0);
virtual ~hsBiExpander();
Int32 GetFirst() const { return -fNumPre; }
Int32 GetCount() const { return fNumPre + fNumPost; }
hsBool Empty() const { return GetCount() == 0; }
const T& Get(Int32 index) const;
Int32 Get(Int32 index, Int32 count, T data[]) const;
Int32 Find(const T&) const; // returns kMissingIndex if not found
void SetArray(T* a, Int32 cnt, Int32 numPre=0);
T** GetArray() { return fArray - fNumPre; }
T& operator[]( Int32 index );
T* Append(); // returns t's index
T* Push(); // returns t's index
Int32 Append(const T&); // returns t's index
Int32 Push(const T&); // returns t's index
Int32 Pop(T*t = nil) { return PopHead(t); } // returns count of remaining
Int32 PopHead(T*t = nil); // returns count of remaining
Int32 PopTail(T*t = nil); // returns count of remaining
void Reset(); // clears out everything
T& Head() { return fArray[-fNumPre]; }
T& Tail() { return fArray[fNumPost-1]; }
T& Current() { return fArray[fCurrent]; }
void First();
void Last();
void Plus() { ++fCurrent; }
void Minus() { --fCurrent; }
hsBool More() { return (fCurrent < fNumPost)&&(fCurrent >= -fNumPre); }
};
template <class T>
void hsBiExpander<T>::SetArray(T* a, Int32 cnt, Int32 numPre)
{
if( !numPre )
Reset();
else
{
fNumPreAlloc = fNumPre = numPre;
fNumPostAlloc = fNumPost = cnt - numPre;
fArray = a + numPre;
}
}
template <class T>
void hsBiExpander<T>::IExpand(int newSize, hsBool towardEnd)
{
Int32 newPreAlloc = fNumPreAlloc;
Int32 newPostAlloc = fNumPostAlloc;
if( towardEnd )
{
if( !newPostAlloc )
newPostAlloc++;
while( newPostAlloc <= newSize )
newPostAlloc = fGrowBy ? newPostAlloc + fGrowBy : newPostAlloc << 1;
}
else
{
if( !newPreAlloc )
newPreAlloc++;
while( newPreAlloc <= newSize )
newPreAlloc = fGrowBy ? newPreAlloc + fGrowBy : newPreAlloc << 1;
}
T* newArray = TRACKED_NEW T[newPreAlloc + newPostAlloc];
newArray += newPreAlloc;
int i;
for( i = -fNumPre; i < fNumPost; i++ )
newArray[i] = fArray[i];
// HSMemory::BlockMove(fArray-fNumPre, newArray-fNumPre,
// (fNumPre+fNumPost)*sizeof(*fArray));
delete [] (fArray-fNumPreAlloc);
fArray = newArray;
fNumPreAlloc = newPreAlloc;
fNumPostAlloc = newPostAlloc;
}
template <class T>
hsBiExpander<T>::hsBiExpander(Int32 minSize, Int32 growBy)
{
hsThrowIfBadParam(minSize < 0);
hsThrowIfBadParam(growBy < 0);
fMinSize = minSize+1;
fGrowBy = growBy;
fArray = TRACKED_NEW T[fMinSize << 1];
fNumPreAlloc = fNumPostAlloc = fMinSize;
fArray += fNumPreAlloc;
fNumPre = fNumPost = 0;
}
template <class T>
hsBiExpander<T>::~hsBiExpander()
{
delete [] (fArray - fNumPreAlloc);
}
template <class T>
void hsBiExpander<T>::First()
{
fCurrent = -fNumPre;
}
template <class T>
void hsBiExpander<T>::Last()
{
fCurrent = fNumPost-1;
}
template <class T>
T& hsBiExpander<T>::operator[]( Int32 index )
{
hsDebugCode(hsThrowIfBadParam((index < -fNumPre)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
const T& hsBiExpander<T>::Get( Int32 index ) const
{
hsDebugCode(hsThrowIfBadParam((index < -fNumPre)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
Int32 hsBiExpander<T>::Get(Int32 index, Int32 count, T data[]) const
{
if( count > 0 )
{ hsThrowIfNilParam(data);
hsThrowIfBadParam((index < -fNumPre)||(index >= fNumPost));
if (index + count > fNumPost)
count = fNumPost - index;
for (int i = 0; i < count; i++)
data[i] = fArray[i + index];
}
return count;
}
template <class T>
Int32 hsBiExpander<T>::Find(const T& obj) const
{
for (int i = -fNumPre; i < fNumPost; i++)
if (fArray[i] == obj)
return i;
return kMissingIndex;
}
template <class T>
T* hsBiExpander<T>::Append()
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc, true);
return fArray + fNumPost++;
}
template <class T>
T* hsBiExpander<T>::Push()
{
hsAssert(!(fNumPre >= fNumPreAlloc), "Must be less");
if( ++fNumPre == fNumPreAlloc )
IExpand(fNumPreAlloc, false);
return fArray - fNumPre;
}
template <class T>
Int32 hsBiExpander<T>::Append(const T& obj)
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc, true);
fArray[fNumPost] = obj;
return fNumPost++;
}
template <class T>
Int32 hsBiExpander<T>::Push(const T& obj)
{
hsAssert(!(fNumPre >= fNumPreAlloc), "Must be less");
if( ++fNumPre == fNumPreAlloc )
IExpand(fNumPreAlloc, false);
fArray[-fNumPre] = obj;
return -fNumPre;
}
template <class T>
Int32 hsBiExpander<T>::PopHead(T*t)
{
hsThrowIfBadParam(Empty());
if( t )
*t = fArray[-fNumPre];
--fNumPre;
return GetCount();
}
template <class T>
Int32 hsBiExpander<T>::PopTail(T*t)
{
hsThrowIfBadParam(Empty());
--fNumPost;
if( t )
*t = fArray[fNumPost];
return GetCount();
}
template <class T>
void hsBiExpander<T>::Reset()
{
fNumPre = fNumPost = 0;
}
#endif // hsBiExpander_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsBiExpander_inc
#define hsBiExpander_inc
#include "hsMemory.h"
#include "hsTemplates.h"
///////////////////////////////////////////////////////////////////////////////
////////////// Expander ///////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <class T> class hsExpander {
private:
Int32 fNumPost;
Int32 fNumPostAlloc;
T* fArray;
Int32 fGrowBy; // default = 0, to double
Int32 fMinSize; // default = 1, min == 1
Int32 fCurrent;
hsExpander(const hsExpander& x); // make it passed as ref or pointer
void IExpand(int newSize);
public:
enum { kMissingIndex = -1 };
hsExpander(Int32 minSize = 1, Int32 growBy = 0);
virtual ~hsExpander();
hsExpander<T>& operator=(const hsExpander<T>&orig) { return Copy(orig); }
hsExpander<T>& Copy(const hsExpander<T>& orig);
void SetCount(int cnt) { if( cnt >= fNumPostAlloc )IExpand(cnt); fNumPost = cnt; }
Int32 GetCount() const { return fNumPost; }
hsBool Empty() const { return GetCount() == 0; }
const T& Get(Int32 index) const;
Int32 Get(Int32 index, Int32 count, T data[]) const;
Int32 Find(const T&) const; // returns kMissingIndex if not found
void SetArray(T* a, Int32 cnt);
T* GetArray() { return fArray; }
T& operator[]( Int32 index );
Int32 Append(const T&); // returns t's index
T* Append();
Int32 Push(const T& t) { return Append(t); }
T* Push() { return Append(); }
T* Top() { return fNumPost ? fArray + fNumPost-1 : nil; }
Int32 Pop(T* t); // returns count of remaining
Int32 Pop();
void Reset(); // clears out everything
T& Head() { return fArray[0]; }
T& Tail() { return fArray[fNumPost-1]; }
T& Current() { return fArray[fCurrent]; }
void First();
void Last();
void Plus() { ++fCurrent; }
hsBool More() { return (fCurrent < fNumPost); }
};
template <class T>
hsExpander<T>& hsExpander<T>::Copy(const hsExpander<T>& orig)
{
SetCount(orig.GetCount());
int i;
for( i = 0; i < GetCount(); i++ )
fArray[i] = orig.fArray[i];
return *this;
}
template <class T>
void hsExpander<T>::SetArray(T* a, Int32 cnt)
{
delete [] fArray;
if( a )
fArray = a;
fNumPost = fNumPostAlloc = cnt;
}
template <class T>
void hsExpander<T>::IExpand(int newSize)
{
Int32 newPostAlloc = fNumPostAlloc;
if( !newPostAlloc )
newPostAlloc++;
while( newPostAlloc <= newSize )
newPostAlloc = fGrowBy ? newPostAlloc + fGrowBy : newPostAlloc << 1;
T* newArray = TRACKED_NEW T[newPostAlloc];
int i;
for( i = 0; i < fNumPost; i++ )
newArray[i] = fArray[i];
delete [] (fArray);
fArray = newArray;
fNumPostAlloc = newPostAlloc;
}
template <class T>
hsExpander<T>::hsExpander(Int32 minSize, Int32 growBy)
{
hsThrowIfBadParam(minSize < 0);
hsThrowIfBadParam(growBy < 0);
fMinSize = minSize+1;
fGrowBy = growBy;
fArray = TRACKED_NEW T[fMinSize];
fNumPostAlloc = fMinSize;
fNumPost = 0;
}
template <class T>
hsExpander<T>::~hsExpander()
{
delete [] fArray;
}
template <class T>
void hsExpander<T>::First()
{
fCurrent = 0;
}
template <class T>
void hsExpander<T>::Last()
{
fCurrent = fNumPost-1;
}
template <class T>
T& hsExpander<T>::operator[]( Int32 index )
{
hsDebugCode(hsThrowIfBadParam((index < 0)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
const T& hsExpander<T>::Get( Int32 index ) const
{
hsDebugCode(hsThrowIfBadParam((index < 0)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
Int32 hsExpander<T>::Get(Int32 index, Int32 count, T data[]) const
{
if( count > 0 )
{ hsThrowIfNilParam(data);
hsThrowIfBadParam((index < 0)||(index >= fNumPost));
if (index + count > fNumPost)
count = fNumPost - index;
for (int i = 0; i < count; i++)
data[i] = fArray[i + index];
}
return count;
}
template <class T>
Int32 hsExpander<T>::Find(const T& obj) const
{
for (int i = 0; i < fNumPost; i++)
if (fArray[i] == obj)
return i;
return kMissingIndex;
}
template <class T>
Int32 hsExpander<T>::Append(const T& obj)
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc);
fArray[fNumPost] = obj;
return fNumPost++;
}
template <class T>
T* hsExpander<T>::Append()
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc);
return fArray + fNumPost++;
}
template <class T>
Int32 hsExpander<T>::Pop(T*t)
{
hsThrowIfBadParam(Empty());
--fNumPost;
if( t )
*t = fArray[fNumPost];
return GetCount();
}
template <class T>
Int32 hsExpander<T>::Pop()
{
hsThrowIfBadParam(Empty());
--fNumPost;
return GetCount();
}
template <class T>
void hsExpander<T>::Reset()
{
fNumPost = 0;
}
///////////////////////////////////////////////////////////////////////////////
////////////// BiExpander /////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
template <class T> class hsBiExpander {
private:
Int32 fNumPre;
Int32 fNumPost;
Int32 fNumPreAlloc;
Int32 fNumPostAlloc;
T* fArray;
Int32 fGrowBy; // default = 0, to double
Int32 fMinSize; // default = 1, min == 1
Int32 fCurrent;
hsBiExpander<T>& operator=(const hsBiExpander<T>&); // don't allow assignment
hsBiExpander(const hsBiExpander<T>&); // make it passed as ref or pointer
void IExpand(int newSize, hsBool towardEnd = true);
public:
enum { kMissingIndex = -1 };
hsBiExpander(Int32 minSize = 1, Int32 growBy = 0);
virtual ~hsBiExpander();
Int32 GetFirst() const { return -fNumPre; }
Int32 GetCount() const { return fNumPre + fNumPost; }
hsBool Empty() const { return GetCount() == 0; }
const T& Get(Int32 index) const;
Int32 Get(Int32 index, Int32 count, T data[]) const;
Int32 Find(const T&) const; // returns kMissingIndex if not found
void SetArray(T* a, Int32 cnt, Int32 numPre=0);
T** GetArray() { return fArray - fNumPre; }
T& operator[]( Int32 index );
T* Append(); // returns t's index
T* Push(); // returns t's index
Int32 Append(const T&); // returns t's index
Int32 Push(const T&); // returns t's index
Int32 Pop(T*t = nil) { return PopHead(t); } // returns count of remaining
Int32 PopHead(T*t = nil); // returns count of remaining
Int32 PopTail(T*t = nil); // returns count of remaining
void Reset(); // clears out everything
T& Head() { return fArray[-fNumPre]; }
T& Tail() { return fArray[fNumPost-1]; }
T& Current() { return fArray[fCurrent]; }
void First();
void Last();
void Plus() { ++fCurrent; }
void Minus() { --fCurrent; }
hsBool More() { return (fCurrent < fNumPost)&&(fCurrent >= -fNumPre); }
};
template <class T>
void hsBiExpander<T>::SetArray(T* a, Int32 cnt, Int32 numPre)
{
if( !numPre )
Reset();
else
{
fNumPreAlloc = fNumPre = numPre;
fNumPostAlloc = fNumPost = cnt - numPre;
fArray = a + numPre;
}
}
template <class T>
void hsBiExpander<T>::IExpand(int newSize, hsBool towardEnd)
{
Int32 newPreAlloc = fNumPreAlloc;
Int32 newPostAlloc = fNumPostAlloc;
if( towardEnd )
{
if( !newPostAlloc )
newPostAlloc++;
while( newPostAlloc <= newSize )
newPostAlloc = fGrowBy ? newPostAlloc + fGrowBy : newPostAlloc << 1;
}
else
{
if( !newPreAlloc )
newPreAlloc++;
while( newPreAlloc <= newSize )
newPreAlloc = fGrowBy ? newPreAlloc + fGrowBy : newPreAlloc << 1;
}
T* newArray = TRACKED_NEW T[newPreAlloc + newPostAlloc];
newArray += newPreAlloc;
int i;
for( i = -fNumPre; i < fNumPost; i++ )
newArray[i] = fArray[i];
// HSMemory::BlockMove(fArray-fNumPre, newArray-fNumPre,
// (fNumPre+fNumPost)*sizeof(*fArray));
delete [] (fArray-fNumPreAlloc);
fArray = newArray;
fNumPreAlloc = newPreAlloc;
fNumPostAlloc = newPostAlloc;
}
template <class T>
hsBiExpander<T>::hsBiExpander(Int32 minSize, Int32 growBy)
{
hsThrowIfBadParam(minSize < 0);
hsThrowIfBadParam(growBy < 0);
fMinSize = minSize+1;
fGrowBy = growBy;
fArray = TRACKED_NEW T[fMinSize << 1];
fNumPreAlloc = fNumPostAlloc = fMinSize;
fArray += fNumPreAlloc;
fNumPre = fNumPost = 0;
}
template <class T>
hsBiExpander<T>::~hsBiExpander()
{
delete [] (fArray - fNumPreAlloc);
}
template <class T>
void hsBiExpander<T>::First()
{
fCurrent = -fNumPre;
}
template <class T>
void hsBiExpander<T>::Last()
{
fCurrent = fNumPost-1;
}
template <class T>
T& hsBiExpander<T>::operator[]( Int32 index )
{
hsDebugCode(hsThrowIfBadParam((index < -fNumPre)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
const T& hsBiExpander<T>::Get( Int32 index ) const
{
hsDebugCode(hsThrowIfBadParam((index < -fNumPre)||(index >= fNumPost));)
return fArray[index];
}
template <class T>
Int32 hsBiExpander<T>::Get(Int32 index, Int32 count, T data[]) const
{
if( count > 0 )
{ hsThrowIfNilParam(data);
hsThrowIfBadParam((index < -fNumPre)||(index >= fNumPost));
if (index + count > fNumPost)
count = fNumPost - index;
for (int i = 0; i < count; i++)
data[i] = fArray[i + index];
}
return count;
}
template <class T>
Int32 hsBiExpander<T>::Find(const T& obj) const
{
for (int i = -fNumPre; i < fNumPost; i++)
if (fArray[i] == obj)
return i;
return kMissingIndex;
}
template <class T>
T* hsBiExpander<T>::Append()
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc, true);
return fArray + fNumPost++;
}
template <class T>
T* hsBiExpander<T>::Push()
{
hsAssert(!(fNumPre >= fNumPreAlloc), "Must be less");
if( ++fNumPre == fNumPreAlloc )
IExpand(fNumPreAlloc, false);
return fArray - fNumPre;
}
template <class T>
Int32 hsBiExpander<T>::Append(const T& obj)
{
hsAssert(!(fNumPost >= fNumPostAlloc), "Must be less");
if( fNumPost == fNumPostAlloc-1 )
IExpand(fNumPostAlloc, true);
fArray[fNumPost] = obj;
return fNumPost++;
}
template <class T>
Int32 hsBiExpander<T>::Push(const T& obj)
{
hsAssert(!(fNumPre >= fNumPreAlloc), "Must be less");
if( ++fNumPre == fNumPreAlloc )
IExpand(fNumPreAlloc, false);
fArray[-fNumPre] = obj;
return -fNumPre;
}
template <class T>
Int32 hsBiExpander<T>::PopHead(T*t)
{
hsThrowIfBadParam(Empty());
if( t )
*t = fArray[-fNumPre];
--fNumPre;
return GetCount();
}
template <class T>
Int32 hsBiExpander<T>::PopTail(T*t)
{
hsThrowIfBadParam(Empty());
--fNumPost;
if( t )
*t = fArray[fNumPost];
return GetCount();
}
template <class T>
void hsBiExpander<T>::Reset()
{
fNumPre = fNumPost = 0;
}
#endif // hsBiExpander_inc

View File

@ -1,221 +1,221 @@
/*==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 "hsStream.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include <stdarg.h>
hsBitVector::hsBitVector(int b, ...)
: fBitVectors(nil),
fNumBitVectors(0)
{
va_list vl;
va_start( vl, b );
do {
SetBit( b, true );
} while( (b = va_arg( vl, int )) >= 0 );
va_end( vl );
}
hsBitVector::hsBitVector(const hsTArray<Int16>& src)
: fBitVectors(nil),
fNumBitVectors(0)
{
FromList(src);
}
void hsBitVector::IGrow(UInt32 newNumBitVectors)
{
hsAssert(newNumBitVectors > fNumBitVectors, "Growing smaller");
UInt32 *old = fBitVectors;
fBitVectors = TRACKED_NEW UInt32[newNumBitVectors];
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = old[i];
for( ; i < newNumBitVectors; i++ )
fBitVectors[i] = 0;
delete [] old;
fNumBitVectors = newNumBitVectors;
}
hsBitVector& hsBitVector::Compact()
{
if( !fBitVectors )
return *this;
if( fBitVectors[fNumBitVectors-1] )
return *this;
int hiVec = 0;
for( hiVec = fNumBitVectors-1; (hiVec >= 0)&& !fBitVectors[hiVec]; --hiVec );
if( hiVec >= 0 )
{
UInt32 *old = fBitVectors;
fBitVectors = TRACKED_NEW UInt32[++hiVec];
int i;
for( i = 0; i < hiVec; i++ )
fBitVectors[i] = old[i];
fNumBitVectors = hiVec;
delete [] old;
}
else
{
Reset();
}
return *this;
}
void hsBitVector::Read(hsStream* s)
{
Reset();
s->LogReadSwap(&fNumBitVectors,"NumBitVectors");
if( fNumBitVectors )
{
delete [] fBitVectors;
fBitVectors = TRACKED_NEW UInt32[fNumBitVectors];
int i;
for( i = 0; i < fNumBitVectors; i++ )
s->LogReadSwap(&fBitVectors[i],"BitVector");
}
}
void hsBitVector::Write(hsStream* s) const
{
s->WriteSwap32(fNumBitVectors);
int i;
for( i = 0; i < fNumBitVectors; i++ )
s->WriteSwap32(fBitVectors[i]);
}
hsTArray<Int16>& hsBitVector::Enumerate(hsTArray<Int16>& dst) const
{
dst.SetCount(0);
hsBitIterator iter(*this);
int i = iter.Begin();
while( i >= 0 )
{
dst.Append(i);
i = iter.Advance();
}
return dst;
}
hsBitVector& hsBitVector::FromList(const hsTArray<Int16>& src)
{
Clear();
int i;
for( i = 0; i < src.GetCount(); i++ )
SetBit(src[i]);
return *this;
}
//////////////////////////////////////////////////////////////////////////
int hsBitIterator::IAdvanceVec()
{
hsAssert((fCurrVec >= 0) && (fCurrVec < fBits.fNumBitVectors), "Invalid state to advance from");
while( (++fCurrVec < fBits.fNumBitVectors) && !fBits.fBitVectors[fCurrVec] );
return fCurrVec < fBits.fNumBitVectors;
}
int hsBitIterator::IAdvanceBit()
{
do
{
if( ++fCurrBit > 31 )
{
if( !IAdvanceVec() )
return false;
fCurrBit = 0;
}
} while( !(fBits.fBitVectors[fCurrVec] & (1 << fCurrBit)) );
return true;
}
int hsBitIterator::Advance()
{
if( End() )
return -1;
if( !IAdvanceBit() )
return fCurrVec = -1;
return fCurrent = (fCurrVec << 5) + fCurrBit;
}
int hsBitIterator::Begin()
{
fCurrent = -1;
fCurrVec = -1;
int i;
for( i = 0; i < fBits.fNumBitVectors; i++ )
{
if( fBits.fBitVectors[i] )
{
int j;
for( j = 0; j < 32; j++ )
{
if( fBits.fBitVectors[i] & (1 << j) )
{
fCurrVec = i;
fCurrBit = j;
return fCurrent = (fCurrVec << 5) + fCurrBit;
}
}
}
}
return fCurrent;
}
/*==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 "hsStream.h"
#include "hsBitVector.h"
#include "hsTemplates.h"
#include <stdarg.h>
hsBitVector::hsBitVector(int b, ...)
: fBitVectors(nil),
fNumBitVectors(0)
{
va_list vl;
va_start( vl, b );
do {
SetBit( b, true );
} while( (b = va_arg( vl, int )) >= 0 );
va_end( vl );
}
hsBitVector::hsBitVector(const hsTArray<Int16>& src)
: fBitVectors(nil),
fNumBitVectors(0)
{
FromList(src);
}
void hsBitVector::IGrow(UInt32 newNumBitVectors)
{
hsAssert(newNumBitVectors > fNumBitVectors, "Growing smaller");
UInt32 *old = fBitVectors;
fBitVectors = TRACKED_NEW UInt32[newNumBitVectors];
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = old[i];
for( ; i < newNumBitVectors; i++ )
fBitVectors[i] = 0;
delete [] old;
fNumBitVectors = newNumBitVectors;
}
hsBitVector& hsBitVector::Compact()
{
if( !fBitVectors )
return *this;
if( fBitVectors[fNumBitVectors-1] )
return *this;
int hiVec = 0;
for( hiVec = fNumBitVectors-1; (hiVec >= 0)&& !fBitVectors[hiVec]; --hiVec );
if( hiVec >= 0 )
{
UInt32 *old = fBitVectors;
fBitVectors = TRACKED_NEW UInt32[++hiVec];
int i;
for( i = 0; i < hiVec; i++ )
fBitVectors[i] = old[i];
fNumBitVectors = hiVec;
delete [] old;
}
else
{
Reset();
}
return *this;
}
void hsBitVector::Read(hsStream* s)
{
Reset();
s->LogReadSwap(&fNumBitVectors,"NumBitVectors");
if( fNumBitVectors )
{
delete [] fBitVectors;
fBitVectors = TRACKED_NEW UInt32[fNumBitVectors];
int i;
for( i = 0; i < fNumBitVectors; i++ )
s->LogReadSwap(&fBitVectors[i],"BitVector");
}
}
void hsBitVector::Write(hsStream* s) const
{
s->WriteSwap32(fNumBitVectors);
int i;
for( i = 0; i < fNumBitVectors; i++ )
s->WriteSwap32(fBitVectors[i]);
}
hsTArray<Int16>& hsBitVector::Enumerate(hsTArray<Int16>& dst) const
{
dst.SetCount(0);
hsBitIterator iter(*this);
int i = iter.Begin();
while( i >= 0 )
{
dst.Append(i);
i = iter.Advance();
}
return dst;
}
hsBitVector& hsBitVector::FromList(const hsTArray<Int16>& src)
{
Clear();
int i;
for( i = 0; i < src.GetCount(); i++ )
SetBit(src[i]);
return *this;
}
//////////////////////////////////////////////////////////////////////////
int hsBitIterator::IAdvanceVec()
{
hsAssert((fCurrVec >= 0) && (fCurrVec < fBits.fNumBitVectors), "Invalid state to advance from");
while( (++fCurrVec < fBits.fNumBitVectors) && !fBits.fBitVectors[fCurrVec] );
return fCurrVec < fBits.fNumBitVectors;
}
int hsBitIterator::IAdvanceBit()
{
do
{
if( ++fCurrBit > 31 )
{
if( !IAdvanceVec() )
return false;
fCurrBit = 0;
}
} while( !(fBits.fBitVectors[fCurrVec] & (1 << fCurrBit)) );
return true;
}
int hsBitIterator::Advance()
{
if( End() )
return -1;
if( !IAdvanceBit() )
return fCurrVec = -1;
return fCurrent = (fCurrVec << 5) + fCurrBit;
}
int hsBitIterator::Begin()
{
fCurrent = -1;
fCurrVec = -1;
int i;
for( i = 0; i < fBits.fNumBitVectors; i++ )
{
if( fBits.fBitVectors[i] )
{
int j;
for( j = 0; j < 32; j++ )
{
if( fBits.fBitVectors[i] & (1 << j) )
{
fCurrVec = i;
fCurrBit = j;
return fCurrent = (fCurrVec << 5) + fCurrBit;
}
}
}
}
return fCurrent;
}

View File

@ -1,410 +1,410 @@
/*==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 hsBitVector_inc
#define hsBitVector_inc
#include "hsTypes.h"
template <class T> class hsTArray;
class hsStream;
class hsBitVector {
protected:
UInt32* fBitVectors;
UInt32 fNumBitVectors;
void IGrow(UInt32 newNumBitVectors);
friend class hsBitIterator;
public:
hsBitVector(const hsBitVector& other);
hsBitVector(UInt32 which) : fBitVectors(nil), fNumBitVectors(0) { SetBit(which); }
hsBitVector(int b, ...); // list of one or more integer bits to set. -1 (or any negative) terminates the list (e.g. hsBitVector(0,1,4,-1);
hsBitVector(const hsTArray<Int16>& list); // sets bit for each int in list
hsBitVector() : fBitVectors(nil), fNumBitVectors(0) {}
virtual ~hsBitVector() { Reset(); }
hsBitVector& Reset() { delete [] fBitVectors; fBitVectors = nil; fNumBitVectors = 0; return *this; }
hsBitVector& Clear(); // everyone clear, but no dealloc
hsBitVector& Set(int upToBit=-1); // WARNING - see comments at function
int operator==(const hsBitVector& other) const; // unset (ie uninitialized) bits are clear,
int operator!=(const hsBitVector& other) const { return !(*this == other); }
hsBitVector& operator=(const hsBitVector& other); // will wind up identical
hsBool ClearBit(UInt32 which) { return SetBit(which, 0); } // returns previous state
hsBool SetBit(UInt32 which, hsBool on = true); // returns previous state
hsBool IsBitSet(UInt32 which) const; // returns current state
hsBool ToggleBit(UInt32 which); // returns previous state
hsBitVector& RemoveBit(UInt32 which); // removes bit, sliding higher bits down to fill the gap.
friend inline int Overlap(const hsBitVector& lhs, const hsBitVector& rhs) { return lhs.Overlap(rhs); }
hsBool Overlap(const hsBitVector& other) const;
hsBool Empty() const;
hsBool operator[](UInt32 which) const { return IsBitSet(which); }
friend inline hsBitVector operator&(const hsBitVector& lhs, const hsBitVector& rhs); // See Overlap()
friend inline hsBitVector operator|(const hsBitVector& lhs, const hsBitVector& rhs);
friend inline hsBitVector operator^(const hsBitVector& lhs, const hsBitVector& rhs);
friend inline hsBitVector operator-(const hsBitVector& lhs, const hsBitVector& rhs); // return lhs w/ rhs's bits turned off
hsBitVector& operator&=(const hsBitVector& other); // See Overlap()
hsBitVector& operator|=(const hsBitVector& other);
hsBitVector& operator^=(const hsBitVector& other);
hsBitVector& operator-=(const hsBitVector& other); // return me w/ other's bits turned off
hsBitVector& Compact();
hsBitVector& SetSize(UInt32 numBits) { ClearBit(numBits+1); return *this; }
UInt32 GetSize() { return fNumBitVectors << 5; }
// integer level access
UInt32 GetNumBitVectors() const { return fNumBitVectors; }
UInt32 GetBitVector(int i) const { return fBitVectors[i]; }
void SetNumBitVectors(UInt32 n) { Reset(); fNumBitVectors=n; fBitVectors = TRACKED_NEW UInt32[n]; }
void SetBitVector(int i, UInt32 val) { fBitVectors[i]=val; }
// Do dst.SetCount(0), then add each set bit's index into dst, returning dst.
hsTArray<Int16>& Enumerate(hsTArray<Int16>& dst) const;
// this->Clear(), then set all bits listed in src, returning *this.
hsBitVector& FromList(const hsTArray<Int16>& src);
void Read(hsStream* s);
void Write(hsStream* s) const;
};
inline hsBitVector::hsBitVector(const hsBitVector& other)
{
if( 0 != (fNumBitVectors = other.fNumBitVectors) )
{
fBitVectors = TRACKED_NEW UInt32[fNumBitVectors];
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = other.fBitVectors[i];
}
else
fBitVectors = nil;
}
inline hsBool hsBitVector::Empty() const
{
int i;
for( i = 0; i < fNumBitVectors; i++ )
{
if( fBitVectors[i] )
return false;
}
return true;
}
inline hsBool hsBitVector::Overlap(const hsBitVector& other) const
{
if( fNumBitVectors > other.fNumBitVectors )
return other.Overlap(*this);
int i;
for( i = 0; i < fNumBitVectors; i++ )
{
if( fBitVectors[i] & other.fBitVectors[i] )
return true;
}
return false;
}
inline hsBitVector& hsBitVector::operator=(const hsBitVector& other)
{
if( this != &other )
{
if( fNumBitVectors < other.fNumBitVectors )
{
Reset();
fNumBitVectors = other.fNumBitVectors;
fBitVectors = TRACKED_NEW UInt32[fNumBitVectors];
}
else
{
Clear();
}
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
fBitVectors[i] = other.fBitVectors[i];
}
return *this;
}
inline int hsBitVector::operator==(const hsBitVector& other) const
{
if( fNumBitVectors < other.fNumBitVectors )
return other.operator==(*this);
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
if( fBitVectors[i] ^ other.fBitVectors[i] )
return false;
for( ; i < fNumBitVectors; i++ )
if( fBitVectors[i] )
return false;
return true;
}
inline hsBitVector& hsBitVector::operator&=(const hsBitVector& other)
{
if( this == &other )
return *this;
if( fNumBitVectors > other.fNumBitVectors )
{
fNumBitVectors = other.fNumBitVectors;
}
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] &= other.fBitVectors[i];
return *this;
}
inline hsBitVector& hsBitVector::operator|=(const hsBitVector& other)
{
if( this == &other )
return *this;
if( fNumBitVectors < other.fNumBitVectors )
{
IGrow(other.fNumBitVectors);
}
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
fBitVectors[i] |= other.fBitVectors[i];
return *this;
}
inline hsBitVector& hsBitVector::operator^=(const hsBitVector& other)
{
if( this == &other )
{
Clear();
return *this;
}
if( fNumBitVectors < other.fNumBitVectors )
{
IGrow(other.fNumBitVectors);
}
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
fBitVectors[i] ^= other.fBitVectors[i];
return *this;
}
inline hsBitVector& hsBitVector::operator-=(const hsBitVector& other)
{
if( this == &other )
{
Clear();
return *this;
}
int minNum = fNumBitVectors < other.fNumBitVectors ? fNumBitVectors : other.fNumBitVectors;
int i;
for( i = 0; i < minNum; i++ )
fBitVectors[i] &= ~other.fBitVectors[i];
return *this;
}
inline hsBitVector operator&(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret &= lhs;
}
inline hsBitVector operator|(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret |= lhs;
}
inline hsBitVector operator^(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret ^= lhs;
}
inline hsBitVector operator-(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret -= lhs;
}
inline hsBitVector& hsBitVector::Clear()
{
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = 0;
return *this;
}
// WARNING - since the bitvector is conceptually infinitely long,
// we can't actually set all the bits. If you pass in a non-negative
// upToBit, this sets all bits up to and including that one, otherwise
// it just sets however many bits are currently allocated. You can
// assure this is as many as you want by first calling SetSize, but
// if there are more bits than the requested size, these will also
// get set. Calling Set with a non-negative upToBit will only set
// the bits from 0 to upToBit, but won't clear any higher bits.
inline hsBitVector& hsBitVector::Set(int upToBit)
{
if( upToBit >= 0 )
{
UInt32 major = upToBit >> 5;
UInt32 minor = 1 << (upToBit & 0x1f);
if( major >= fNumBitVectors )
IGrow(major+1);
UInt32 i;
for( i = 0; i < major; i++ )
fBitVectors[i] = 0xffffffff;
for( i = 1; i <= minor && i > 0; i <<= 1 )
fBitVectors[major] |= i;
}
else
{
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = 0xffffffff;
}
return *this;
}
inline hsBool hsBitVector::IsBitSet(UInt32 which) const
{
UInt32 major = which >> 5;
return
(major < fNumBitVectors)
&& (0 != (fBitVectors[major] & 1 << (which & 0x1f)));
}
inline hsBool hsBitVector::SetBit(UInt32 which, hsBool on)
{
UInt32 major = which >> 5;
UInt32 minor = 1 << (which & 0x1f);
if( major >= fNumBitVectors )
IGrow(major+1);
hsBool ret = 0 != (fBitVectors[major] & minor);
if( ret != on )
{
if( on )
fBitVectors[major] |= minor;
else
fBitVectors[major] &= ~minor;
}
return ret;
}
inline hsBool hsBitVector::ToggleBit(UInt32 which)
{
UInt32 major = which >> 5;
UInt32 minor = 1 << (which & 0x1f);
if( major >= fNumBitVectors )
IGrow(major);
hsBool ret = 0 != (fBitVectors[major] & minor);
if( ret )
fBitVectors[major] &= ~minor;
else
fBitVectors[major] |= minor;
return ret;
}
inline hsBitVector& hsBitVector::RemoveBit(UInt32 which)
{
UInt32 major = which >> 5;
if( major >= fNumBitVectors )
return *this;
UInt32 minor = 1 << (which & 0x1f);
UInt32 lowMask = minor-1;
UInt32 hiMask = ~(lowMask);
fBitVectors[major] = (fBitVectors[major] & lowMask)
| ((fBitVectors[major] >> 1) & hiMask);
while( major < fNumBitVectors-1 )
{
if( fBitVectors[major+1] & 0x1 )
fBitVectors[major] |= 0x80000000;
else
fBitVectors[major] &= ~0x80000000;
major++;
fBitVectors[major] >>= 1;
}
fBitVectors[major] &= ~0x80000000;
return *this;
}
class hsBitIterator
{
protected:
const hsBitVector& fBits;
int fCurrent;
int fCurrVec;
int fCurrBit;
int IAdvanceBit();
int IAdvanceVec();
public:
// Must call begin after instanciating.
hsBitIterator(const hsBitVector& bits) : fBits(bits) {}
int Begin();
int Current() const { return fCurrent; }
int Advance();
int End() const { return fCurrVec < 0; }
};
#endif // hsBitVector_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsBitVector_inc
#define hsBitVector_inc
#include "hsTypes.h"
template <class T> class hsTArray;
class hsStream;
class hsBitVector {
protected:
UInt32* fBitVectors;
UInt32 fNumBitVectors;
void IGrow(UInt32 newNumBitVectors);
friend class hsBitIterator;
public:
hsBitVector(const hsBitVector& other);
hsBitVector(UInt32 which) : fBitVectors(nil), fNumBitVectors(0) { SetBit(which); }
hsBitVector(int b, ...); // list of one or more integer bits to set. -1 (or any negative) terminates the list (e.g. hsBitVector(0,1,4,-1);
hsBitVector(const hsTArray<Int16>& list); // sets bit for each int in list
hsBitVector() : fBitVectors(nil), fNumBitVectors(0) {}
virtual ~hsBitVector() { Reset(); }
hsBitVector& Reset() { delete [] fBitVectors; fBitVectors = nil; fNumBitVectors = 0; return *this; }
hsBitVector& Clear(); // everyone clear, but no dealloc
hsBitVector& Set(int upToBit=-1); // WARNING - see comments at function
int operator==(const hsBitVector& other) const; // unset (ie uninitialized) bits are clear,
int operator!=(const hsBitVector& other) const { return !(*this == other); }
hsBitVector& operator=(const hsBitVector& other); // will wind up identical
hsBool ClearBit(UInt32 which) { return SetBit(which, 0); } // returns previous state
hsBool SetBit(UInt32 which, hsBool on = true); // returns previous state
hsBool IsBitSet(UInt32 which) const; // returns current state
hsBool ToggleBit(UInt32 which); // returns previous state
hsBitVector& RemoveBit(UInt32 which); // removes bit, sliding higher bits down to fill the gap.
friend inline int Overlap(const hsBitVector& lhs, const hsBitVector& rhs) { return lhs.Overlap(rhs); }
hsBool Overlap(const hsBitVector& other) const;
hsBool Empty() const;
hsBool operator[](UInt32 which) const { return IsBitSet(which); }
friend inline hsBitVector operator&(const hsBitVector& lhs, const hsBitVector& rhs); // See Overlap()
friend inline hsBitVector operator|(const hsBitVector& lhs, const hsBitVector& rhs);
friend inline hsBitVector operator^(const hsBitVector& lhs, const hsBitVector& rhs);
friend inline hsBitVector operator-(const hsBitVector& lhs, const hsBitVector& rhs); // return lhs w/ rhs's bits turned off
hsBitVector& operator&=(const hsBitVector& other); // See Overlap()
hsBitVector& operator|=(const hsBitVector& other);
hsBitVector& operator^=(const hsBitVector& other);
hsBitVector& operator-=(const hsBitVector& other); // return me w/ other's bits turned off
hsBitVector& Compact();
hsBitVector& SetSize(UInt32 numBits) { ClearBit(numBits+1); return *this; }
UInt32 GetSize() { return fNumBitVectors << 5; }
// integer level access
UInt32 GetNumBitVectors() const { return fNumBitVectors; }
UInt32 GetBitVector(int i) const { return fBitVectors[i]; }
void SetNumBitVectors(UInt32 n) { Reset(); fNumBitVectors=n; fBitVectors = TRACKED_NEW UInt32[n]; }
void SetBitVector(int i, UInt32 val) { fBitVectors[i]=val; }
// Do dst.SetCount(0), then add each set bit's index into dst, returning dst.
hsTArray<Int16>& Enumerate(hsTArray<Int16>& dst) const;
// this->Clear(), then set all bits listed in src, returning *this.
hsBitVector& FromList(const hsTArray<Int16>& src);
void Read(hsStream* s);
void Write(hsStream* s) const;
};
inline hsBitVector::hsBitVector(const hsBitVector& other)
{
if( 0 != (fNumBitVectors = other.fNumBitVectors) )
{
fBitVectors = TRACKED_NEW UInt32[fNumBitVectors];
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = other.fBitVectors[i];
}
else
fBitVectors = nil;
}
inline hsBool hsBitVector::Empty() const
{
int i;
for( i = 0; i < fNumBitVectors; i++ )
{
if( fBitVectors[i] )
return false;
}
return true;
}
inline hsBool hsBitVector::Overlap(const hsBitVector& other) const
{
if( fNumBitVectors > other.fNumBitVectors )
return other.Overlap(*this);
int i;
for( i = 0; i < fNumBitVectors; i++ )
{
if( fBitVectors[i] & other.fBitVectors[i] )
return true;
}
return false;
}
inline hsBitVector& hsBitVector::operator=(const hsBitVector& other)
{
if( this != &other )
{
if( fNumBitVectors < other.fNumBitVectors )
{
Reset();
fNumBitVectors = other.fNumBitVectors;
fBitVectors = TRACKED_NEW UInt32[fNumBitVectors];
}
else
{
Clear();
}
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
fBitVectors[i] = other.fBitVectors[i];
}
return *this;
}
inline int hsBitVector::operator==(const hsBitVector& other) const
{
if( fNumBitVectors < other.fNumBitVectors )
return other.operator==(*this);
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
if( fBitVectors[i] ^ other.fBitVectors[i] )
return false;
for( ; i < fNumBitVectors; i++ )
if( fBitVectors[i] )
return false;
return true;
}
inline hsBitVector& hsBitVector::operator&=(const hsBitVector& other)
{
if( this == &other )
return *this;
if( fNumBitVectors > other.fNumBitVectors )
{
fNumBitVectors = other.fNumBitVectors;
}
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] &= other.fBitVectors[i];
return *this;
}
inline hsBitVector& hsBitVector::operator|=(const hsBitVector& other)
{
if( this == &other )
return *this;
if( fNumBitVectors < other.fNumBitVectors )
{
IGrow(other.fNumBitVectors);
}
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
fBitVectors[i] |= other.fBitVectors[i];
return *this;
}
inline hsBitVector& hsBitVector::operator^=(const hsBitVector& other)
{
if( this == &other )
{
Clear();
return *this;
}
if( fNumBitVectors < other.fNumBitVectors )
{
IGrow(other.fNumBitVectors);
}
int i;
for( i = 0; i < other.fNumBitVectors; i++ )
fBitVectors[i] ^= other.fBitVectors[i];
return *this;
}
inline hsBitVector& hsBitVector::operator-=(const hsBitVector& other)
{
if( this == &other )
{
Clear();
return *this;
}
int minNum = fNumBitVectors < other.fNumBitVectors ? fNumBitVectors : other.fNumBitVectors;
int i;
for( i = 0; i < minNum; i++ )
fBitVectors[i] &= ~other.fBitVectors[i];
return *this;
}
inline hsBitVector operator&(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret &= lhs;
}
inline hsBitVector operator|(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret |= lhs;
}
inline hsBitVector operator^(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret ^= lhs;
}
inline hsBitVector operator-(const hsBitVector& rhs, const hsBitVector& lhs)
{
hsBitVector ret(rhs);
return ret -= lhs;
}
inline hsBitVector& hsBitVector::Clear()
{
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = 0;
return *this;
}
// WARNING - since the bitvector is conceptually infinitely long,
// we can't actually set all the bits. If you pass in a non-negative
// upToBit, this sets all bits up to and including that one, otherwise
// it just sets however many bits are currently allocated. You can
// assure this is as many as you want by first calling SetSize, but
// if there are more bits than the requested size, these will also
// get set. Calling Set with a non-negative upToBit will only set
// the bits from 0 to upToBit, but won't clear any higher bits.
inline hsBitVector& hsBitVector::Set(int upToBit)
{
if( upToBit >= 0 )
{
UInt32 major = upToBit >> 5;
UInt32 minor = 1 << (upToBit & 0x1f);
if( major >= fNumBitVectors )
IGrow(major+1);
UInt32 i;
for( i = 0; i < major; i++ )
fBitVectors[i] = 0xffffffff;
for( i = 1; i <= minor && i > 0; i <<= 1 )
fBitVectors[major] |= i;
}
else
{
int i;
for( i = 0; i < fNumBitVectors; i++ )
fBitVectors[i] = 0xffffffff;
}
return *this;
}
inline hsBool hsBitVector::IsBitSet(UInt32 which) const
{
UInt32 major = which >> 5;
return
(major < fNumBitVectors)
&& (0 != (fBitVectors[major] & 1 << (which & 0x1f)));
}
inline hsBool hsBitVector::SetBit(UInt32 which, hsBool on)
{
UInt32 major = which >> 5;
UInt32 minor = 1 << (which & 0x1f);
if( major >= fNumBitVectors )
IGrow(major+1);
hsBool ret = 0 != (fBitVectors[major] & minor);
if( ret != on )
{
if( on )
fBitVectors[major] |= minor;
else
fBitVectors[major] &= ~minor;
}
return ret;
}
inline hsBool hsBitVector::ToggleBit(UInt32 which)
{
UInt32 major = which >> 5;
UInt32 minor = 1 << (which & 0x1f);
if( major >= fNumBitVectors )
IGrow(major);
hsBool ret = 0 != (fBitVectors[major] & minor);
if( ret )
fBitVectors[major] &= ~minor;
else
fBitVectors[major] |= minor;
return ret;
}
inline hsBitVector& hsBitVector::RemoveBit(UInt32 which)
{
UInt32 major = which >> 5;
if( major >= fNumBitVectors )
return *this;
UInt32 minor = 1 << (which & 0x1f);
UInt32 lowMask = minor-1;
UInt32 hiMask = ~(lowMask);
fBitVectors[major] = (fBitVectors[major] & lowMask)
| ((fBitVectors[major] >> 1) & hiMask);
while( major < fNumBitVectors-1 )
{
if( fBitVectors[major+1] & 0x1 )
fBitVectors[major] |= 0x80000000;
else
fBitVectors[major] &= ~0x80000000;
major++;
fBitVectors[major] >>= 1;
}
fBitVectors[major] &= ~0x80000000;
return *this;
}
class hsBitIterator
{
protected:
const hsBitVector& fBits;
int fCurrent;
int fCurrVec;
int fCurrBit;
int IAdvanceBit();
int IAdvanceVec();
public:
// Must call begin after instanciating.
hsBitIterator(const hsBitVector& bits) : fBits(bits) {}
int Begin();
int Current() const { return fCurrent; }
int Advance();
int End() const { return fCurrVec < 0; }
};
#endif // hsBitVector_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,439 +1,439 @@
/*==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 hsBounds_inc
#define hsBounds_inc
#include "hsGeometry3.h"
#include "hsPoint2.h"
#include "hsMatrix44.h"
class hsTriangle3;
class hsGView3;
class hsG3DDevice;
///////////////////////////////////////////////////////////////////////////////
// BOUNDS
///////////////////////////////////////////////////////////////////////////////
enum hsBoundsType
{
kBoundsNormal,
kBoundsFull,
kBoundsEmpty,
kBoundsUninitialized
};
//
// Abstract base class
//
class hsBounds3;
class hsBounds
{
protected:
hsBoundsType fType;
public:
static const hsScalar kRealSmall;
hsBounds() : fType(kBoundsUninitialized) { };
hsBounds& MakeEmpty() { fType = kBoundsEmpty; return *this; }
hsBounds& MakeFull() { fType = kBoundsFull; return *this; }
hsBoundsType GetType() const { return fType; }
//
// These set type to kBounds Normal
//
virtual void Reset(const hsBounds3*) = 0;
virtual hsBool IsInside(const hsPoint3* pos) const =0; // Only valid for kBounds Normal
virtual void Read(hsStream*);
virtual void Write(hsStream*);
};
//
//
//
class hsGTriMesh;
struct hsMatrix44;
class hsBounds3 : public hsBounds
{
public:
enum {
kCenterValid = 0x1,
kIsSphere = 0x2
};
protected:
mutable UInt32 fBounds3Flags;
hsPoint3 fMins;
hsPoint3 fMaxs;
mutable hsPoint3 fCenter;
void ICalcCenter() const;
public:
hsBounds3() : fBounds3Flags(0) {}
hsBounds3(const hsBounds3 &pRHS) : fBounds3Flags(0) { Reset(&pRHS); }
hsBounds3 &operator=(const hsBounds3 &pRHS )
{ if (&pRHS != this) Reset(&pRHS); return *this; }
//
// These set type to kBounds Normal
//
virtual void Reset(const hsBounds3*);
virtual void Reset(const hsPoint3 *p);
virtual void Reset(int n, const hsPoint3 *p);
virtual void Union(const hsPoint3 *p);
virtual void Union(const hsBounds3 *b);
virtual void Union(const hsVector3 *v); // smears the bounds in given direction
virtual void MakeSymmetric(const hsPoint3* p); // Expands bounds to be symmetric about p
virtual void InscribeSphere();
virtual void Transform(const hsMatrix44*);
//
// Only valid for kBounds Normal
//
void Draw(hsGView3* v, hsG3DDevice* d, hsScalar r, hsScalar g, hsScalar b, hsScalar a, hsBool spheric=false);
virtual void GetCorners(hsPoint3 *b) const;
const hsPoint3& GetMins() const;
const hsPoint3& GetMaxs() const;
hsScalar GetMaxDim() const; // Computes the answer
const hsPoint3& GetCenter() const; // Computes the answer if not already there
// void MakeTriMesh(hsGTriMesh* tMesh, UInt32 triFlags, hsPoint3* cornersIn=nil) const;
// void MakeTriMeshSphere(hsGTriMesh* tMesh, hsPoint3* cornersIn=nil) const;
virtual hsBool IsInside(const hsPoint3* pos) const; // ok for full/empty
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
virtual void TestPlane(const hsPlane3 *p, hsPoint2 &depth) const;
virtual hsBool ClosestPoint(const hsPoint3& p, hsPoint3& inner, hsPoint3& outer) const;
// Test according to my axes only, doesn't check other's axes
// neg, pos, zero == disjoint, I contain other, overlap
virtual Int32 TestBound(const hsBounds3& other) const;
static hsScalar ClosestPointToLine(const hsPoint3 *p, const hsPoint3 *v0, const hsPoint3 *v1, hsPoint3 *out);
static hsScalar ClosestPointToInfiniteLine(const hsPoint3* p, const hsVector3* v, hsPoint3* out);
virtual void Read(hsStream*);
virtual void Write(hsStream*);
};
inline void hsBounds3::ICalcCenter() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for ICalcCenter");
fCenter = ((fMins + fMaxs) / 2.0);
fBounds3Flags |= kCenterValid;
}
inline void hsBounds3::GetCorners(hsPoint3 *b) const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetCorners");
for(int i = 0; i < 8; i++)
{
b[i][0] = (i & 0x1) ? fMins[0] : fMaxs[0];
b[i][1] = (i & 0x2) ? fMins[1] : fMaxs[1];
b[i][2] = (i & 0x4) ? fMins[2] : fMaxs[2];
}
}
inline const hsPoint3& hsBounds3::GetMins() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetMins");
return fMins;
}
inline const hsPoint3& hsBounds3::GetMaxs() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxs");
return fMaxs;
}
inline const hsPoint3& hsBounds3::GetCenter() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetCenter");
if(!(fBounds3Flags & kCenterValid))
ICalcCenter();
return fCenter;
}
inline hsScalar hsBounds3::GetMaxDim() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim");
return hsMaximum(hsMaximum(fMaxs.fX-fMins.fX, fMaxs.fY-fMins.fY), fMaxs.fZ-fMins.fZ);
}
//
// A convex region specified by a series of planes.
//
class hsBoundsOriented : public hsBounds
{
private:
hsBool fCenterValid;
hsPoint3 fCenter;
hsPlane3 *fPlanes;
UInt32 fNumPlanes;
public:
hsBoundsOriented() : fPlanes(nil),fNumPlanes(0),fCenterValid(false) {}
virtual ~hsBoundsOriented() { if (fPlanes) delete [] fPlanes; }
// Center is not computed by the class, it must be set by the creator of the class.
void SetCenter(const hsPoint3* c) { fCenter=*c; fCenterValid = true; }
void SetCenter(const hsBounds3* b) { hsBounds3 bb=*b; fCenter=bb.GetCenter(); fCenterValid = true; }
void SetCenter(const hsBoundsOriented* b) { fCenter=b->GetCenter(); fCenterValid = true; }
hsPoint3 GetCenter() const;
void SetNumberPlanes(UInt32 n);
hsPlane3* GetPlane(int i) { return &fPlanes[i]; }
int GetNumPlanes() { return fNumPlanes; }
//
// These set type to kBounds Normal
//
virtual void Reset(const hsBounds3*);
void Reset(hsGTriMesh *tMesh);
void SetPlane(UInt32 i, hsPlane3 *p);
//
// Only valid for kBounds Normal
//
virtual hsBool IsInside(const hsPoint3* pos) const;
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const; // Complain and refuse
virtual void Write(hsStream *stream);
virtual void Read(hsStream *stream);
};
//class hsBounds3Tri;
class hsHitInfoExt;
class hsBounds3Ext : public hsBounds3 {
protected:
enum {
kAxisAligned =0x1,
kSphereSet =0x2,
kDistsSet =0x4,
kAxisZeroZero =(1<<20),
kAxisOneZero =(1<<21),
kAxisTwoZero =(1<<22)
};
mutable UInt32 fExtFlags;
hsPoint3 fCorner;
hsVector3 fAxes[3];
mutable hsPoint2 fDists[3];
mutable hsScalar fRadius;
hsBool IAxisIsZero(UInt32 i) const { return (fExtFlags & (1 << (20+i))) != 0; };
void IMakeSphere() const;
void IMakeDists() const;
void IMakeMinsMaxs();
public:
hsBounds3Ext() : fExtFlags(kAxisAligned) {};
hsBounds3Ext(const hsBounds3 &b);
hsBounds3Ext &operator=(const hsBounds3 &b);
hsBounds3Ext(const hsBounds3Ext &pRHS) { Reset(&pRHS); }
hsBounds3Ext &operator=(const hsBounds3Ext &pRHS )
{ if (&pRHS != this) Reset(&pRHS); return *this; }
virtual void Reset(const hsBounds3Ext *b);
virtual void Reset(const hsBounds3 *b);
virtual void Reset(const hsPoint3 *p);
virtual void Reset(int n, const hsPoint3 *p);
virtual void Union(const hsPoint3 *p);
virtual void Union(const hsBounds3 *b);
virtual void Union(const hsVector3 *v); // smears the bounds in given direction
virtual void MakeSymmetric(const hsPoint3* p); // Expands bounds to be symmetric about p
virtual void InscribeSphere();
virtual void Unalign();
virtual void Transform(const hsMatrix44 *m);
virtual void Translate(const hsVector3 &v);
virtual hsScalar GetRadius() const;
virtual void GetAxes(hsVector3 *fAxis0, hsVector3 *fAxis1, hsVector3 *fAxis2) const;
virtual hsPoint3 *GetCorner(hsPoint3 *c) const { *c = (fExtFlags & kAxisAligned ? fMins : fCorner); return c; }
virtual void GetCorners(hsPoint3 *b) const;
virtual hsBool ClosestPoint(const hsPoint3& p, hsPoint3& inner, hsPoint3& outer) const;
virtual hsBool IsInside(const hsPoint3* pos) const; // ok for full/empty
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
virtual Int32 TestPoints(int n, const hsPoint3 *pList) const; // pos,neg,zero == allout, allin, cut
// Test according to my axes only, doesn't check other's axes
// neg, pos, zero == disjoint, I contain other, overlap
virtual Int32 TestBound(const hsBounds3Ext& other) const;
virtual void TestPlane(const hsVector3 &n, const hsVector3 &myVel, hsPoint2 &depth) const;
virtual void TestPlane(const hsPlane3 *p, const hsVector3 &myVel, hsPoint2 &depth) const;
virtual Int32 TestPoints(int n, const hsPoint3 *pList, const hsVector3 &ptVel) const; // pos,neg,zero == allout, allin, cut
virtual hsBool ISectBB(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBB(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectABB(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBS(const hsBounds3Ext &other, const hsVector3 &myVel) const;
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual hsBool ISectTriABB(hsBounds3Tri &tri, const hsVector3 &myVel) const;
virtual hsBool ISectTriBB(hsBounds3Tri &tri, const hsVector3 &myVel) const;
virtual hsBool ISectTriBB(hsBounds3Tri &tri, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool TriBSHitInfo(hsBounds3Tri& tri, const hsVector3& myVel, hsHitInfoExt* hit) const;
virtual hsBool TriBBHitInfo(hsBounds3Tri& tri, const hsVector3& myVel, hsHitInfoExt* hit) const;
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual Int32 IClosestISect(const hsBounds3Ext& other, const hsVector3& myVel,
hsScalar* tClose, hsScalar* tImpact) const;
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual hsBool ISectTriBS(hsBounds3Tri &tri, const hsVector3 &myVel) const;
virtual hsBool ISectTriBS(hsBounds3Tri &tri, const hsVector3 &myVel, hsHitInfoExt *hit) const;
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectBSBox(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBSBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectLine(const hsPoint3* from, const hsPoint3* to) const;
virtual hsBool ISectCone(const hsPoint3* from, const hsPoint3* to, hsScalar radius) const;
virtual hsBool ISectRayBS(const hsPoint3& from, const hsPoint3& to, hsPoint3& at) const;
virtual void Read(hsStream *s);
virtual void Write(hsStream *s);
};
inline hsScalar hsBounds3Ext::GetRadius() const
{
if( !(fExtFlags & kSphereSet) )
IMakeSphere();
return fRadius;
}
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
class hsBounds3Tri {
protected:
enum {
kOnEdge0 = (1 << 0),
kOnEdge1 = (1 << 1),
kOnEdge2 = (1 << 2),
kOnTriPlane = (1 << 3)
};
public:
enum {
kAxesSet = 0x1,
kDoubleSide = 0x2
};
hsVector3 fNormal;
// hsVector3 fNormal;
hsScalar fDist;
hsPoint3 fVerts[3];
// hsVector3 fPerpAxes[3];
mutable UInt32 fTriFlags;
mutable hsVector3 fPerpAxes[3];
mutable hsPoint2 fPerpDists[3];
mutable UInt32 fOnIsMax;
hsTriangle3* fTriangle;
void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
hsBool PointOutsideTriPlane(const hsPoint3 *p) const { return fNormal.InnerProduct(p) > fDist; };
hsBool ClosestTriPoint(const hsPoint3 *p, hsPoint3 *out, const hsVector3 *ax=nil) const; // sets out, true if out = p + t*fNormal
hsBool ISectCone(const hsPoint3& from, const hsPoint3& to, hsScalar cosThetaSq, hsBool32 ignoreBackFacing, hsPoint3& at, hsBool32& backSide) const;
void SetAxes() const;
hsBounds3Tri* Transform(const hsMatrix44& x);
hsBounds3Tri* Translate(const hsVector3& v);
void Set(const hsPoint3& v0,
const hsPoint3& v1,
const hsPoint3& v2,
hsTriangle3* t,
const hsMatrix44& x);
hsBounds3Tri(const hsPoint3& v0,
const hsPoint3& v1,
const hsPoint3& v2,
hsTriangle3* t,
const hsMatrix44& x);
hsBounds3Tri(hsTriangle3* t,
const hsMatrix44& x);
void Set(hsPoint3 *v0,
hsPoint3 *v1,
hsPoint3 *v2,
hsVector3 *n,
UInt32 triFlags,
hsTriangle3 *t=nil);
hsBounds3Tri(hsPoint3 *v0,
hsPoint3 *v1,
hsPoint3 *v2,
hsVector3 *n,
UInt32 triFlags,
hsTriangle3 *t=nil);
hsBounds3Tri(hsTriangle3* t);
hsBounds3Tri() {}
~hsBounds3Tri();
friend class hsBounds3Ext;
} ATTRIBUTE_FOR_PS2; /* SUNSOFT */
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
class hsHitInfoExt {
public:
hsScalar fDepth;
hsVector3 fNormal;
hsVector3 fDelPos;
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
const hsBounds3Tri* fTriBnd;
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
const hsBounds3Ext* fBoxBnd;
const hsBounds3Ext* fOtherBoxBnd;
const hsPoint3* fRootCenter;
hsHitInfoExt(const hsPoint3 *ctr, const hsVector3& offset) { fRootCenter=ctr; fDelPos=offset; };
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
void Set(const hsBounds3Ext *m, const hsBounds3Tri *t, const hsVector3* n, hsScalar d)
{ fDepth = d; fTriBnd = t; fBoxBnd = m; fNormal = *n; fOtherBoxBnd = nil; }
void Set(const hsBounds3Ext *m, const hsBounds3Ext *o, const hsVector3 &norm, hsScalar d)
{ fDepth = d; fBoxBnd = m, fOtherBoxBnd = o; fNormal = norm; fTriBnd = nil; }
#else // Commenting out this which will be made redundant and/or obsolete by Havok integration
void Set(const hsBounds3Ext *m, const hsVector3* n, hsScalar d)
{ fDepth = d; fBoxBnd = m; fNormal = *n; fOtherBoxBnd = nil; }
void Set(const hsBounds3Ext *m, const hsBounds3Ext *o, const hsVector3 &norm, hsScalar d)
{ fDepth = d; fBoxBnd = m, fOtherBoxBnd = o; fNormal = norm; }
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
};
#endif // hsBounds_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsBounds_inc
#define hsBounds_inc
#include "hsGeometry3.h"
#include "hsPoint2.h"
#include "hsMatrix44.h"
class hsTriangle3;
class hsGView3;
class hsG3DDevice;
///////////////////////////////////////////////////////////////////////////////
// BOUNDS
///////////////////////////////////////////////////////////////////////////////
enum hsBoundsType
{
kBoundsNormal,
kBoundsFull,
kBoundsEmpty,
kBoundsUninitialized
};
//
// Abstract base class
//
class hsBounds3;
class hsBounds
{
protected:
hsBoundsType fType;
public:
static const hsScalar kRealSmall;
hsBounds() : fType(kBoundsUninitialized) { };
hsBounds& MakeEmpty() { fType = kBoundsEmpty; return *this; }
hsBounds& MakeFull() { fType = kBoundsFull; return *this; }
hsBoundsType GetType() const { return fType; }
//
// These set type to kBounds Normal
//
virtual void Reset(const hsBounds3*) = 0;
virtual hsBool IsInside(const hsPoint3* pos) const =0; // Only valid for kBounds Normal
virtual void Read(hsStream*);
virtual void Write(hsStream*);
};
//
//
//
class hsGTriMesh;
struct hsMatrix44;
class hsBounds3 : public hsBounds
{
public:
enum {
kCenterValid = 0x1,
kIsSphere = 0x2
};
protected:
mutable UInt32 fBounds3Flags;
hsPoint3 fMins;
hsPoint3 fMaxs;
mutable hsPoint3 fCenter;
void ICalcCenter() const;
public:
hsBounds3() : fBounds3Flags(0) {}
hsBounds3(const hsBounds3 &pRHS) : fBounds3Flags(0) { Reset(&pRHS); }
hsBounds3 &operator=(const hsBounds3 &pRHS )
{ if (&pRHS != this) Reset(&pRHS); return *this; }
//
// These set type to kBounds Normal
//
virtual void Reset(const hsBounds3*);
virtual void Reset(const hsPoint3 *p);
virtual void Reset(int n, const hsPoint3 *p);
virtual void Union(const hsPoint3 *p);
virtual void Union(const hsBounds3 *b);
virtual void Union(const hsVector3 *v); // smears the bounds in given direction
virtual void MakeSymmetric(const hsPoint3* p); // Expands bounds to be symmetric about p
virtual void InscribeSphere();
virtual void Transform(const hsMatrix44*);
//
// Only valid for kBounds Normal
//
void Draw(hsGView3* v, hsG3DDevice* d, hsScalar r, hsScalar g, hsScalar b, hsScalar a, hsBool spheric=false);
virtual void GetCorners(hsPoint3 *b) const;
const hsPoint3& GetMins() const;
const hsPoint3& GetMaxs() const;
hsScalar GetMaxDim() const; // Computes the answer
const hsPoint3& GetCenter() const; // Computes the answer if not already there
// void MakeTriMesh(hsGTriMesh* tMesh, UInt32 triFlags, hsPoint3* cornersIn=nil) const;
// void MakeTriMeshSphere(hsGTriMesh* tMesh, hsPoint3* cornersIn=nil) const;
virtual hsBool IsInside(const hsPoint3* pos) const; // ok for full/empty
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
virtual void TestPlane(const hsPlane3 *p, hsPoint2 &depth) const;
virtual hsBool ClosestPoint(const hsPoint3& p, hsPoint3& inner, hsPoint3& outer) const;
// Test according to my axes only, doesn't check other's axes
// neg, pos, zero == disjoint, I contain other, overlap
virtual Int32 TestBound(const hsBounds3& other) const;
static hsScalar ClosestPointToLine(const hsPoint3 *p, const hsPoint3 *v0, const hsPoint3 *v1, hsPoint3 *out);
static hsScalar ClosestPointToInfiniteLine(const hsPoint3* p, const hsVector3* v, hsPoint3* out);
virtual void Read(hsStream*);
virtual void Write(hsStream*);
};
inline void hsBounds3::ICalcCenter() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for ICalcCenter");
fCenter = ((fMins + fMaxs) / 2.0);
fBounds3Flags |= kCenterValid;
}
inline void hsBounds3::GetCorners(hsPoint3 *b) const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetCorners");
for(int i = 0; i < 8; i++)
{
b[i][0] = (i & 0x1) ? fMins[0] : fMaxs[0];
b[i][1] = (i & 0x2) ? fMins[1] : fMaxs[1];
b[i][2] = (i & 0x4) ? fMins[2] : fMaxs[2];
}
}
inline const hsPoint3& hsBounds3::GetMins() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetMins");
return fMins;
}
inline const hsPoint3& hsBounds3::GetMaxs() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxs");
return fMaxs;
}
inline const hsPoint3& hsBounds3::GetCenter() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetCenter");
if(!(fBounds3Flags & kCenterValid))
ICalcCenter();
return fCenter;
}
inline hsScalar hsBounds3::GetMaxDim() const
{
hsAssert(kBoundsNormal == fType, "Invalid type for GetMaxDim");
return hsMaximum(hsMaximum(fMaxs.fX-fMins.fX, fMaxs.fY-fMins.fY), fMaxs.fZ-fMins.fZ);
}
//
// A convex region specified by a series of planes.
//
class hsBoundsOriented : public hsBounds
{
private:
hsBool fCenterValid;
hsPoint3 fCenter;
hsPlane3 *fPlanes;
UInt32 fNumPlanes;
public:
hsBoundsOriented() : fPlanes(nil),fNumPlanes(0),fCenterValid(false) {}
virtual ~hsBoundsOriented() { if (fPlanes) delete [] fPlanes; }
// Center is not computed by the class, it must be set by the creator of the class.
void SetCenter(const hsPoint3* c) { fCenter=*c; fCenterValid = true; }
void SetCenter(const hsBounds3* b) { hsBounds3 bb=*b; fCenter=bb.GetCenter(); fCenterValid = true; }
void SetCenter(const hsBoundsOriented* b) { fCenter=b->GetCenter(); fCenterValid = true; }
hsPoint3 GetCenter() const;
void SetNumberPlanes(UInt32 n);
hsPlane3* GetPlane(int i) { return &fPlanes[i]; }
int GetNumPlanes() { return fNumPlanes; }
//
// These set type to kBounds Normal
//
virtual void Reset(const hsBounds3*);
void Reset(hsGTriMesh *tMesh);
void SetPlane(UInt32 i, hsPlane3 *p);
//
// Only valid for kBounds Normal
//
virtual hsBool IsInside(const hsPoint3* pos) const;
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const; // Complain and refuse
virtual void Write(hsStream *stream);
virtual void Read(hsStream *stream);
};
//class hsBounds3Tri;
class hsHitInfoExt;
class hsBounds3Ext : public hsBounds3 {
protected:
enum {
kAxisAligned =0x1,
kSphereSet =0x2,
kDistsSet =0x4,
kAxisZeroZero =(1<<20),
kAxisOneZero =(1<<21),
kAxisTwoZero =(1<<22)
};
mutable UInt32 fExtFlags;
hsPoint3 fCorner;
hsVector3 fAxes[3];
mutable hsPoint2 fDists[3];
mutable hsScalar fRadius;
hsBool IAxisIsZero(UInt32 i) const { return (fExtFlags & (1 << (20+i))) != 0; };
void IMakeSphere() const;
void IMakeDists() const;
void IMakeMinsMaxs();
public:
hsBounds3Ext() : fExtFlags(kAxisAligned) {};
hsBounds3Ext(const hsBounds3 &b);
hsBounds3Ext &operator=(const hsBounds3 &b);
hsBounds3Ext(const hsBounds3Ext &pRHS) { Reset(&pRHS); }
hsBounds3Ext &operator=(const hsBounds3Ext &pRHS )
{ if (&pRHS != this) Reset(&pRHS); return *this; }
virtual void Reset(const hsBounds3Ext *b);
virtual void Reset(const hsBounds3 *b);
virtual void Reset(const hsPoint3 *p);
virtual void Reset(int n, const hsPoint3 *p);
virtual void Union(const hsPoint3 *p);
virtual void Union(const hsBounds3 *b);
virtual void Union(const hsVector3 *v); // smears the bounds in given direction
virtual void MakeSymmetric(const hsPoint3* p); // Expands bounds to be symmetric about p
virtual void InscribeSphere();
virtual void Unalign();
virtual void Transform(const hsMatrix44 *m);
virtual void Translate(const hsVector3 &v);
virtual hsScalar GetRadius() const;
virtual void GetAxes(hsVector3 *fAxis0, hsVector3 *fAxis1, hsVector3 *fAxis2) const;
virtual hsPoint3 *GetCorner(hsPoint3 *c) const { *c = (fExtFlags & kAxisAligned ? fMins : fCorner); return c; }
virtual void GetCorners(hsPoint3 *b) const;
virtual hsBool ClosestPoint(const hsPoint3& p, hsPoint3& inner, hsPoint3& outer) const;
virtual hsBool IsInside(const hsPoint3* pos) const; // ok for full/empty
virtual void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
virtual Int32 TestPoints(int n, const hsPoint3 *pList) const; // pos,neg,zero == allout, allin, cut
// Test according to my axes only, doesn't check other's axes
// neg, pos, zero == disjoint, I contain other, overlap
virtual Int32 TestBound(const hsBounds3Ext& other) const;
virtual void TestPlane(const hsVector3 &n, const hsVector3 &myVel, hsPoint2 &depth) const;
virtual void TestPlane(const hsPlane3 *p, const hsVector3 &myVel, hsPoint2 &depth) const;
virtual Int32 TestPoints(int n, const hsPoint3 *pList, const hsVector3 &ptVel) const; // pos,neg,zero == allout, allin, cut
virtual hsBool ISectBB(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBB(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectABB(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBS(const hsBounds3Ext &other, const hsVector3 &myVel) const;
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual hsBool ISectTriABB(hsBounds3Tri &tri, const hsVector3 &myVel) const;
virtual hsBool ISectTriBB(hsBounds3Tri &tri, const hsVector3 &myVel) const;
virtual hsBool ISectTriBB(hsBounds3Tri &tri, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool TriBSHitInfo(hsBounds3Tri& tri, const hsVector3& myVel, hsHitInfoExt* hit) const;
virtual hsBool TriBBHitInfo(hsBounds3Tri& tri, const hsVector3& myVel, hsHitInfoExt* hit) const;
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual Int32 IClosestISect(const hsBounds3Ext& other, const hsVector3& myVel,
hsScalar* tClose, hsScalar* tImpact) const;
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual hsBool ISectTriBS(hsBounds3Tri &tri, const hsVector3 &myVel) const;
virtual hsBool ISectTriBS(hsBounds3Tri &tri, const hsVector3 &myVel, hsHitInfoExt *hit) const;
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectBSBox(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectBoxBS(const hsBounds3Ext &other, const hsVector3 &myVel) const;
virtual hsBool ISectBSBS(const hsBounds3Ext &other, const hsVector3 &myVel, hsHitInfoExt *hit) const;
virtual hsBool ISectLine(const hsPoint3* from, const hsPoint3* to) const;
virtual hsBool ISectCone(const hsPoint3* from, const hsPoint3* to, hsScalar radius) const;
virtual hsBool ISectRayBS(const hsPoint3& from, const hsPoint3& to, hsPoint3& at) const;
virtual void Read(hsStream *s);
virtual void Write(hsStream *s);
};
inline hsScalar hsBounds3Ext::GetRadius() const
{
if( !(fExtFlags & kSphereSet) )
IMakeSphere();
return fRadius;
}
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
class hsBounds3Tri {
protected:
enum {
kOnEdge0 = (1 << 0),
kOnEdge1 = (1 << 1),
kOnEdge2 = (1 << 2),
kOnTriPlane = (1 << 3)
};
public:
enum {
kAxesSet = 0x1,
kDoubleSide = 0x2
};
hsVector3 fNormal;
// hsVector3 fNormal;
hsScalar fDist;
hsPoint3 fVerts[3];
// hsVector3 fPerpAxes[3];
mutable UInt32 fTriFlags;
mutable hsVector3 fPerpAxes[3];
mutable hsPoint2 fPerpDists[3];
mutable UInt32 fOnIsMax;
hsTriangle3* fTriangle;
void TestPlane(const hsVector3 &n, hsPoint2 &depth) const;
hsBool PointOutsideTriPlane(const hsPoint3 *p) const { return fNormal.InnerProduct(p) > fDist; };
hsBool ClosestTriPoint(const hsPoint3 *p, hsPoint3 *out, const hsVector3 *ax=nil) const; // sets out, true if out = p + t*fNormal
hsBool ISectCone(const hsPoint3& from, const hsPoint3& to, hsScalar cosThetaSq, hsBool32 ignoreBackFacing, hsPoint3& at, hsBool32& backSide) const;
void SetAxes() const;
hsBounds3Tri* Transform(const hsMatrix44& x);
hsBounds3Tri* Translate(const hsVector3& v);
void Set(const hsPoint3& v0,
const hsPoint3& v1,
const hsPoint3& v2,
hsTriangle3* t,
const hsMatrix44& x);
hsBounds3Tri(const hsPoint3& v0,
const hsPoint3& v1,
const hsPoint3& v2,
hsTriangle3* t,
const hsMatrix44& x);
hsBounds3Tri(hsTriangle3* t,
const hsMatrix44& x);
void Set(hsPoint3 *v0,
hsPoint3 *v1,
hsPoint3 *v2,
hsVector3 *n,
UInt32 triFlags,
hsTriangle3 *t=nil);
hsBounds3Tri(hsPoint3 *v0,
hsPoint3 *v1,
hsPoint3 *v2,
hsVector3 *n,
UInt32 triFlags,
hsTriangle3 *t=nil);
hsBounds3Tri(hsTriangle3* t);
hsBounds3Tri() {}
~hsBounds3Tri();
friend class hsBounds3Ext;
} ATTRIBUTE_FOR_PS2; /* SUNSOFT */
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
class hsHitInfoExt {
public:
hsScalar fDepth;
hsVector3 fNormal;
hsVector3 fDelPos;
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
const hsBounds3Tri* fTriBnd;
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
const hsBounds3Ext* fBoxBnd;
const hsBounds3Ext* fOtherBoxBnd;
const hsPoint3* fRootCenter;
hsHitInfoExt(const hsPoint3 *ctr, const hsVector3& offset) { fRootCenter=ctr; fDelPos=offset; };
#if 0 // Commenting out this which will be made redundant and/or obsolete by Havok integration
void Set(const hsBounds3Ext *m, const hsBounds3Tri *t, const hsVector3* n, hsScalar d)
{ fDepth = d; fTriBnd = t; fBoxBnd = m; fNormal = *n; fOtherBoxBnd = nil; }
void Set(const hsBounds3Ext *m, const hsBounds3Ext *o, const hsVector3 &norm, hsScalar d)
{ fDepth = d; fBoxBnd = m, fOtherBoxBnd = o; fNormal = norm; fTriBnd = nil; }
#else // Commenting out this which will be made redundant and/or obsolete by Havok integration
void Set(const hsBounds3Ext *m, const hsVector3* n, hsScalar d)
{ fDepth = d; fBoxBnd = m; fNormal = *n; fOtherBoxBnd = nil; }
void Set(const hsBounds3Ext *m, const hsBounds3Ext *o, const hsVector3 &norm, hsScalar d)
{ fDepth = d; fBoxBnd = m, fOtherBoxBnd = o; fNormal = norm; }
#endif // Commenting out this which will be made redundant and/or obsolete by Havok integration
};
#endif // hsBounds_inc

View File

@ -1,196 +1,196 @@
/*==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 hsColorRGBA_inc
#define hsColorRGBA_inc
#include "hsScalar.h"
#include "hsStream.h"
struct hsColorRGBA {
hsScalar r,g,b,a;
hsRGBAColor32 ToRGBA32() const;
hsColorRGBA& Set(hsScalar red, hsScalar grn, hsScalar blu, hsScalar alp) { r = red; g = grn; b = blu; a = alp; return *this; }
hsBool operator==(const hsColorRGBA&c) const { return (r==c.r)&&(g==c.g)&&(b==c.b)&&(a==c.a); }
hsBool operator!=(const hsColorRGBA&c) const { return !(c == *this); }
friend inline hsColorRGBA operator+(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator+=(const hsColorRGBA& s);
friend inline hsColorRGBA operator*(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator*=(const hsColorRGBA& s);
friend inline hsColorRGBA operator-(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator-=(const hsColorRGBA& s);
friend inline hsColorRGBA operator*(const hsColorRGBA& c, const hsScalar s);
friend inline hsColorRGBA operator*(const hsScalar s, const hsColorRGBA& c);
hsColorRGBA& operator*=(const hsScalar s);
hsColorRGBA& FromARGB32(UInt32 c);
UInt32 ToARGB32() const;
UInt32 ToARGB32Premultiplied() const;
void Read(hsStream *stream);
void Write(hsStream *stream) const;
};
inline void hsColorRGBA::Read(hsStream *s)
{
r = s->ReadSwapScalar();
g = s->ReadSwapScalar();
b = s->ReadSwapScalar();
a = s->ReadSwapScalar();
}
inline void hsColorRGBA::Write(hsStream *s) const
{
s->WriteSwapScalar(r);
s->WriteSwapScalar(g);
s->WriteSwapScalar(b);
s->WriteSwapScalar(a);
}
inline hsColorRGBA& hsColorRGBA::FromARGB32(UInt32 c)
{
const hsScalar oo255 = 1.f / 255.f;
a = hsScalar((c >> 24) & 0xff) * oo255;
r = hsScalar((c >> 16) & 0xff) * oo255;
g = hsScalar((c >> 8) & 0xff) * oo255;
b = hsScalar((c >> 0) & 0xff) * oo255;
return *this;
}
inline UInt32 hsColorRGBA::ToARGB32() const
{
return (UInt32(a * 255.99f) << 24)
| (UInt32(r * 255.99f) << 16)
| (UInt32(g * 255.99f) << 8)
| (UInt32(b * 255.99f) << 0);
}
inline UInt32 hsColorRGBA::ToARGB32Premultiplied() const
{
return (UInt32(a * 255.0f + 0.5f) << 24)
| (UInt32(a * r * 255.0f + 0.5f) << 16)
| (UInt32(a * g * 255.0f + 0.5f) << 8)
| (UInt32(a * b * 255.0f + 0.5f) << 0);
}
inline hsColorRGBA operator+(const hsColorRGBA& s, const hsColorRGBA& t)
{
hsColorRGBA res;
return res.Set(s.r + t.r, s.g + t.g, s.b + t.b, s.a + t.a);
}
inline hsColorRGBA& hsColorRGBA::operator+=(const hsColorRGBA& s)
{
r += s.r;
g += s.g;
b += s.b;
a += s.a;
return *this;
}
inline hsColorRGBA operator*(const hsColorRGBA& s, const hsColorRGBA& t)
{
hsColorRGBA res;
return res.Set(s.r * t.r, s.g * t.g, s.b * t.b, s.a * t.a);
}
inline hsColorRGBA& hsColorRGBA::operator*=(const hsColorRGBA& s)
{
r *= s.r;
g *= s.g;
b *= s.b;
a *= s.a;
return *this;
}
inline hsColorRGBA operator-(const hsColorRGBA& s, const hsColorRGBA& t)
{
hsColorRGBA res;
return res.Set(s.r - t.r, s.g - t.g, s.b - t.b, s.a - t.a);
}
inline hsColorRGBA& hsColorRGBA::operator-=(const hsColorRGBA& s)
{
r -= s.r;
g -= s.g;
b -= s.b;
a -= s.a;
return *this;
}
inline hsColorRGBA operator*(const hsColorRGBA& t, const hsScalar s)
{
hsColorRGBA res;
return res.Set(s * t.r, s * t.g, s * t.b, s * t.a);
}
inline hsColorRGBA operator*(const hsScalar s, const hsColorRGBA&t)
{
return t * s;
}
inline hsColorRGBA& hsColorRGBA::operator*=(const hsScalar s)
{
r *= s;
g *= s;
b *= s;
a *= s;
return *this;
}
class hsColorOverride
{
public:
enum {
kNone,
kModColor,
kModAlpha,
kModShade
};
hsColorRGBA fShade;
hsColorRGBA fColor;
hsBool fFlags;
};
#endif // hsColorRGBA_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsColorRGBA_inc
#define hsColorRGBA_inc
#include "hsScalar.h"
#include "hsStream.h"
struct hsColorRGBA {
hsScalar r,g,b,a;
hsRGBAColor32 ToRGBA32() const;
hsColorRGBA& Set(hsScalar red, hsScalar grn, hsScalar blu, hsScalar alp) { r = red; g = grn; b = blu; a = alp; return *this; }
hsBool operator==(const hsColorRGBA&c) const { return (r==c.r)&&(g==c.g)&&(b==c.b)&&(a==c.a); }
hsBool operator!=(const hsColorRGBA&c) const { return !(c == *this); }
friend inline hsColorRGBA operator+(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator+=(const hsColorRGBA& s);
friend inline hsColorRGBA operator*(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator*=(const hsColorRGBA& s);
friend inline hsColorRGBA operator-(const hsColorRGBA& s, const hsColorRGBA& t);
hsColorRGBA& operator-=(const hsColorRGBA& s);
friend inline hsColorRGBA operator*(const hsColorRGBA& c, const hsScalar s);
friend inline hsColorRGBA operator*(const hsScalar s, const hsColorRGBA& c);
hsColorRGBA& operator*=(const hsScalar s);
hsColorRGBA& FromARGB32(UInt32 c);
UInt32 ToARGB32() const;
UInt32 ToARGB32Premultiplied() const;
void Read(hsStream *stream);
void Write(hsStream *stream) const;
};
inline void hsColorRGBA::Read(hsStream *s)
{
r = s->ReadSwapScalar();
g = s->ReadSwapScalar();
b = s->ReadSwapScalar();
a = s->ReadSwapScalar();
}
inline void hsColorRGBA::Write(hsStream *s) const
{
s->WriteSwapScalar(r);
s->WriteSwapScalar(g);
s->WriteSwapScalar(b);
s->WriteSwapScalar(a);
}
inline hsColorRGBA& hsColorRGBA::FromARGB32(UInt32 c)
{
const hsScalar oo255 = 1.f / 255.f;
a = hsScalar((c >> 24) & 0xff) * oo255;
r = hsScalar((c >> 16) & 0xff) * oo255;
g = hsScalar((c >> 8) & 0xff) * oo255;
b = hsScalar((c >> 0) & 0xff) * oo255;
return *this;
}
inline UInt32 hsColorRGBA::ToARGB32() const
{
return (UInt32(a * 255.99f) << 24)
| (UInt32(r * 255.99f) << 16)
| (UInt32(g * 255.99f) << 8)
| (UInt32(b * 255.99f) << 0);
}
inline UInt32 hsColorRGBA::ToARGB32Premultiplied() const
{
return (UInt32(a * 255.0f + 0.5f) << 24)
| (UInt32(a * r * 255.0f + 0.5f) << 16)
| (UInt32(a * g * 255.0f + 0.5f) << 8)
| (UInt32(a * b * 255.0f + 0.5f) << 0);
}
inline hsColorRGBA operator+(const hsColorRGBA& s, const hsColorRGBA& t)
{
hsColorRGBA res;
return res.Set(s.r + t.r, s.g + t.g, s.b + t.b, s.a + t.a);
}
inline hsColorRGBA& hsColorRGBA::operator+=(const hsColorRGBA& s)
{
r += s.r;
g += s.g;
b += s.b;
a += s.a;
return *this;
}
inline hsColorRGBA operator*(const hsColorRGBA& s, const hsColorRGBA& t)
{
hsColorRGBA res;
return res.Set(s.r * t.r, s.g * t.g, s.b * t.b, s.a * t.a);
}
inline hsColorRGBA& hsColorRGBA::operator*=(const hsColorRGBA& s)
{
r *= s.r;
g *= s.g;
b *= s.b;
a *= s.a;
return *this;
}
inline hsColorRGBA operator-(const hsColorRGBA& s, const hsColorRGBA& t)
{
hsColorRGBA res;
return res.Set(s.r - t.r, s.g - t.g, s.b - t.b, s.a - t.a);
}
inline hsColorRGBA& hsColorRGBA::operator-=(const hsColorRGBA& s)
{
r -= s.r;
g -= s.g;
b -= s.b;
a -= s.a;
return *this;
}
inline hsColorRGBA operator*(const hsColorRGBA& t, const hsScalar s)
{
hsColorRGBA res;
return res.Set(s * t.r, s * t.g, s * t.b, s * t.a);
}
inline hsColorRGBA operator*(const hsScalar s, const hsColorRGBA&t)
{
return t * s;
}
inline hsColorRGBA& hsColorRGBA::operator*=(const hsScalar s)
{
r *= s;
g *= s;
b *= s;
a *= s;
return *this;
}
class hsColorOverride
{
public:
enum {
kNone,
kModColor,
kModAlpha,
kModShade
};
hsColorRGBA fShade;
hsColorRGBA fColor;
hsBool fFlags;
};
#endif // hsColorRGBA_inc

View File

@ -1,185 +1,185 @@
/*==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 "HeadSpin.h"
#ifndef hsConfigDefined
#define hsConfigDefined
#ifndef SERVER
# define CLIENT
#endif
#ifdef BUILDPS2
#define HS_BUILD_FOR_PS2 1
#define PLASMA_NO_NETWORK 1
#define PLASMA_NO_KEYBOARD 1
#define PLASMA_NO_GLIDE 1
#define PLASMA_NO_DDRAW 1
#define HS_BUILD_PLASMA 1
#define NEXUS_NO_2D 1
#endif
//////////////////// Change the 1s and 0s //////////////////////
#define HS_CAN_USE_FLOAT 1
#define HS_SCALAR_IS_FLOAT 1
#define HS_PIN_MATH_OVERFLOW 0 // This forces hsWide versions of FixMath routines
#define HS_DEBUG_MATH_OVERFLOW 0 // This calls hsDebugMessage on k[Pos,Neg]Infinity
///////////////////////Impulse Defines////////////////////////////////////////////////
#define HS_IMPULSE_SUPPORT_GRAY4 0
///////////////////////Plasma Defines //////////////////////////////////////////////////
#ifdef HS_BUILD_PLASMA
#define HS_IGNORE_T2K 1
#define HS_SUPPORT_NFNT_FONTS 1
#endif // HS_BUILD_PLASMA
//////////////////// Specific Compiler Stuff This Section is computed ////////////
#if defined(macintosh) && defined(__POWERPC__)
#define HS_BUILD_FOR_MACPPC 1
#define HS_CPU_BENDIAN 1
#elif defined(macintosh)
#define HS_BUILD_FOR_MAC68K 1
#elif defined(_M_IX86) && defined(_WIN32)
#define HS_BUILD_FOR_WIN32 1
#define HS_CPU_LENDIAN 1
#elif defined(__unix__)
#define HS_BUILD_FOR_UNIX 1
#if defined(__intel__) || defined(__i386__)
#define HS_CPU_LENDIAN 1
#elif defined(__mips__)
#define HS_CPU_BENDIAN 1
#endif
#elif !HS_BUILD_FOR_PS2
#define HS_BUILD_FOR_REFERENCE 1
#endif
#if defined(HS_BUILD_FOR_MAC68K) || defined(HS_BUILD_FOR_MACPPC)
#define HS_BUILD_FOR_MAC 1
#endif
#if defined(__INTEL__) && defined(HS_BUILD_FOR_MAC)
#error "Can't have HS_BUILD_FOR_MAC defined"
#endif
#if (defined(GENERATING68K) || defined(GENERATINGPOWERPC)) && defined(HS_BUILD_FOR_WIN32)
#define "Can't define HS_BUILD_FOR_WIN32"
#endif
#define HS_SCALAR_IS_FIXED !(HS_SCALAR_IS_FLOAT)
#define HS_NEVER_USE_FLOAT !(HS_CAN_USE_FLOAT)
#if HS_DEBUG_MATH_OVERFLOW && !(HS_PIN_MATH_OVERFLOW)
#error "Can't debug overflow unless HS_PIN_MATH_OVERFLOW is ON"
#endif
///////////////////////Windows Specific Defines /////////////////////////////
#if HS_BUILD_FOR_WIN32
// 4244: Conversion
// 4305: Truncation
// 4503: 'identifier' : decorated name length exceeded, name was truncated
// 4018: signed/unsigned mismatch
// 4786: 255 character debug limit
// 4284: STL template defined operator-> for a class it doesn't make sense for (int, etc)
#if !__MWERKS__
#pragma warning( disable : 4305 4503 4018 4786 4284)
#endif
// VC++ version greater than 6.0, must be building for .NET
#if defined(_MSC_VER) && (_MSC_VER > 1200)
#define HS_BUILD_FOR_WIN32_NET
#endif
#pragma optimize( "y", off )
#endif
/////////////////////Debugging Defines ///////////////////////////////////
#if (defined(_DEBUG)||defined(UNIX_DEBUG)) && !defined(HS_DISABLE_ASSERT)
#define HS_DEBUGGING
#if (!defined(HS_NO_MEM_TRACKER))
#define HS_FIND_MEM_LEAKS
#endif
#endif
#if HS_BUILD_FOR_PS2
#define ATTRIBUTE_FOR_PS2 __attribute__((aligned (16))) /* SUNSOFT */
#else
#define ATTRIBUTE_FOR_PS2
#endif
/////////////////////Myst3D Defines /////////////////////////////////////
#ifdef M3DRELEASE
#define PLASMA_NO_NETWORK 1
#define NEXUS_NO_2D 1
#define NO_LOAD_MSG 1
#define PLASMA_NO_CONSOLE 1
#define NEXUS_NO_DEBUG 1
#endif
///////////////////// Required facilities ///////////////////////////////
#ifndef HeadSpinHDefined
#include "HeadSpin.h"
#endif
#endif // hsConfigDefined
/*==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 "HeadSpin.h"
#ifndef hsConfigDefined
#define hsConfigDefined
#ifndef SERVER
# define CLIENT
#endif
#ifdef BUILDPS2
#define HS_BUILD_FOR_PS2 1
#define PLASMA_NO_NETWORK 1
#define PLASMA_NO_KEYBOARD 1
#define PLASMA_NO_GLIDE 1
#define PLASMA_NO_DDRAW 1
#define HS_BUILD_PLASMA 1
#define NEXUS_NO_2D 1
#endif
//////////////////// Change the 1s and 0s //////////////////////
#define HS_CAN_USE_FLOAT 1
#define HS_SCALAR_IS_FLOAT 1
#define HS_PIN_MATH_OVERFLOW 0 // This forces hsWide versions of FixMath routines
#define HS_DEBUG_MATH_OVERFLOW 0 // This calls hsDebugMessage on k[Pos,Neg]Infinity
///////////////////////Impulse Defines////////////////////////////////////////////////
#define HS_IMPULSE_SUPPORT_GRAY4 0
///////////////////////Plasma Defines //////////////////////////////////////////////////
#ifdef HS_BUILD_PLASMA
#define HS_IGNORE_T2K 1
#define HS_SUPPORT_NFNT_FONTS 1
#endif // HS_BUILD_PLASMA
//////////////////// Specific Compiler Stuff This Section is computed ////////////
#if defined(macintosh) && defined(__POWERPC__)
#define HS_BUILD_FOR_MACPPC 1
#define HS_CPU_BENDIAN 1
#elif defined(macintosh)
#define HS_BUILD_FOR_MAC68K 1
#elif defined(_M_IX86) && defined(_WIN32)
#define HS_BUILD_FOR_WIN32 1
#define HS_CPU_LENDIAN 1
#elif defined(__unix__)
#define HS_BUILD_FOR_UNIX 1
#if defined(__intel__) || defined(__i386__)
#define HS_CPU_LENDIAN 1
#elif defined(__mips__)
#define HS_CPU_BENDIAN 1
#endif
#elif !HS_BUILD_FOR_PS2
#define HS_BUILD_FOR_REFERENCE 1
#endif
#if defined(HS_BUILD_FOR_MAC68K) || defined(HS_BUILD_FOR_MACPPC)
#define HS_BUILD_FOR_MAC 1
#endif
#if defined(__INTEL__) && defined(HS_BUILD_FOR_MAC)
#error "Can't have HS_BUILD_FOR_MAC defined"
#endif
#if (defined(GENERATING68K) || defined(GENERATINGPOWERPC)) && defined(HS_BUILD_FOR_WIN32)
#define "Can't define HS_BUILD_FOR_WIN32"
#endif
#define HS_SCALAR_IS_FIXED !(HS_SCALAR_IS_FLOAT)
#define HS_NEVER_USE_FLOAT !(HS_CAN_USE_FLOAT)
#if HS_DEBUG_MATH_OVERFLOW && !(HS_PIN_MATH_OVERFLOW)
#error "Can't debug overflow unless HS_PIN_MATH_OVERFLOW is ON"
#endif
///////////////////////Windows Specific Defines /////////////////////////////
#if HS_BUILD_FOR_WIN32
// 4244: Conversion
// 4305: Truncation
// 4503: 'identifier' : decorated name length exceeded, name was truncated
// 4018: signed/unsigned mismatch
// 4786: 255 character debug limit
// 4284: STL template defined operator-> for a class it doesn't make sense for (int, etc)
#if !__MWERKS__
#pragma warning( disable : 4305 4503 4018 4786 4284)
#endif
// VC++ version greater than 6.0, must be building for .NET
#if defined(_MSC_VER) && (_MSC_VER > 1200)
#define HS_BUILD_FOR_WIN32_NET
#endif
#pragma optimize( "y", off )
#endif
/////////////////////Debugging Defines ///////////////////////////////////
#if (defined(_DEBUG)||defined(UNIX_DEBUG)) && !defined(HS_DISABLE_ASSERT)
#define HS_DEBUGGING
#if (!defined(HS_NO_MEM_TRACKER))
#define HS_FIND_MEM_LEAKS
#endif
#endif
#if HS_BUILD_FOR_PS2
#define ATTRIBUTE_FOR_PS2 __attribute__((aligned (16))) /* SUNSOFT */
#else
#define ATTRIBUTE_FOR_PS2
#endif
/////////////////////Myst3D Defines /////////////////////////////////////
#ifdef M3DRELEASE
#define PLASMA_NO_NETWORK 1
#define NEXUS_NO_2D 1
#define NO_LOAD_MSG 1
#define PLASMA_NO_CONSOLE 1
#define NEXUS_NO_DEBUG 1
#endif
///////////////////// Required facilities ///////////////////////////////
#ifndef HeadSpinHDefined
#include "HeadSpin.h"
#endif
#endif // hsConfigDefined

View File

@ -1,83 +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/CoreLib/hsCritSect.cpp
*
*
* By Eric Anderson (10/23/2005)
* Copyright 2005 Cyan Worlds, Inc.
*
***/
#include "HeadSpin.h"
#include "hsCritSect.h"
#pragma hdrstop
/****************************************************************************
*
* Critical section implementation
*
***/
#ifdef HS_BUILD_FOR_WIN32
//===========================================================================
CCritSect::CCritSect () {
InitializeCriticalSection(&m_handle);
}
//===========================================================================
CCritSect::~CCritSect () {
DeleteCriticalSection(&m_handle);
}
//===========================================================================
void CCritSect::Enter () {
EnterCriticalSection(&m_handle);
}
//===========================================================================
void CCritSect::Leave () {
LeaveCriticalSection(&m_handle);
}
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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/CoreLib/hsCritSect.cpp
*
*
* By Eric Anderson (10/23/2005)
* Copyright 2005 Cyan Worlds, Inc.
*
***/
#include "HeadSpin.h"
#include "hsCritSect.h"
#pragma hdrstop
/****************************************************************************
*
* Critical section implementation
*
***/
#ifdef HS_BUILD_FOR_WIN32
//===========================================================================
CCritSect::CCritSect () {
InitializeCriticalSection(&m_handle);
}
//===========================================================================
CCritSect::~CCritSect () {
DeleteCriticalSection(&m_handle);
}
//===========================================================================
void CCritSect::Enter () {
EnterCriticalSection(&m_handle);
}
//===========================================================================
void CCritSect::Leave () {
LeaveCriticalSection(&m_handle);
}
#endif

View File

@ -1,79 +1,79 @@
/*==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/CoreLib/hsCritSect.h
*
*
* By Eric Anderson (10/23/2005)
* Copyright 2005 Cyan Worlds, Inc.
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_CORELIB_HSCRITSECT_H
#define PLASMA20_SOURCES_PLASMA_CORELIB_HSCRITSECT_H
/****************************************************************************
*
* Critical section
*
***/
#ifdef HS_BUILD_FOR_WIN32
typedef CRITICAL_SECTION CritSectHandle;
#else
# error "CCritSect: Not implemented on this platform"
#endif
class CCritSect {
protected:
CritSectHandle m_handle;
public:
CCritSect ();
~CCritSect ();
void Enter ();
void Leave ();
};
#endif // PLASMA20_SOURCES_PLASMA_CORELIB_HSCRITSECT_H
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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/CoreLib/hsCritSect.h
*
*
* By Eric Anderson (10/23/2005)
* Copyright 2005 Cyan Worlds, Inc.
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_CORELIB_HSCRITSECT_H
#define PLASMA20_SOURCES_PLASMA_CORELIB_HSCRITSECT_H
/****************************************************************************
*
* Critical section
*
***/
#ifdef HS_BUILD_FOR_WIN32
typedef CRITICAL_SECTION CritSectHandle;
#else
# error "CCritSect: Not implemented on this platform"
#endif
class CCritSect {
protected:
CritSectHandle m_handle;
public:
CCritSect ();
~CCritSect ();
void Enter ();
void Leave ();
};
#endif // PLASMA20_SOURCES_PLASMA_CORELIB_HSCRITSECT_H

View File

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

View File

@ -1,126 +1,126 @@
/*==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 hsExceptionStack_inc
#define hsExceptionStack_inc
#include "hsUtils.h"
#include "hsTypes.h"
#include "hsTemplates.h"
class hsExceptionStackDestroyer;
//
// hsExceptionStack - logs function/scope IDs added by hsStackToken
//
class hsExceptionStack
{
friend class hsExceptionStackDestroyer;
private:
hsExceptionStack() { }
public:
~hsExceptionStack() { }
static hsExceptionStack& Instance();
Int32 GetNumEntries() const { return fEntries.Count(); }
const char* GetEntry(Int32 i) const { return fEntries[i]; }
void Push(const char* str);
// After an exception is caught and stack has been displayed,
// call continue to flush stack
void Continue() { fEntries.Reset(); }
private:
static void FreeInstance();
hsTArray<const char*> fEntries;
static hsExceptionStack* fExceptionStack;
static hsExceptionStackDestroyer fExceptionStackDestroyer;
};
inline hsExceptionStack& hsExceptionStack::Instance()
{
if (!fExceptionStack)
{
fExceptionStack = TRACKED_NEW hsExceptionStack;
}
return *fExceptionStack;
}
inline void hsExceptionStack::Push(const char* str)
{
fEntries.Append(str);
}
//
// hsExceptionStackDestroyer - removes the hsExceptionStack instance
//
class hsExceptionStackDestroyer
{
public:
~hsExceptionStackDestroyer()
{
hsExceptionStack::FreeInstance();
}
};
#ifdef HS_DEBUGGING
#define HS_NO_TRY
#endif
#ifdef HS_NO_TRY
#define hsGuardBegin(X)
#define hsGuardEnd
#else // HS_NO_TRY
#define hsGuardBegin(X) { const char* guardToken = X; try {
#define hsGuardEnd } catch(...) { hsExceptionStack::Instance().Push(guardToken); throw; } }
#endif // HS_NO_TRY
#endif // hsExceptionStack_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsExceptionStack_inc
#define hsExceptionStack_inc
#include "hsUtils.h"
#include "hsTypes.h"
#include "hsTemplates.h"
class hsExceptionStackDestroyer;
//
// hsExceptionStack - logs function/scope IDs added by hsStackToken
//
class hsExceptionStack
{
friend class hsExceptionStackDestroyer;
private:
hsExceptionStack() { }
public:
~hsExceptionStack() { }
static hsExceptionStack& Instance();
Int32 GetNumEntries() const { return fEntries.Count(); }
const char* GetEntry(Int32 i) const { return fEntries[i]; }
void Push(const char* str);
// After an exception is caught and stack has been displayed,
// call continue to flush stack
void Continue() { fEntries.Reset(); }
private:
static void FreeInstance();
hsTArray<const char*> fEntries;
static hsExceptionStack* fExceptionStack;
static hsExceptionStackDestroyer fExceptionStackDestroyer;
};
inline hsExceptionStack& hsExceptionStack::Instance()
{
if (!fExceptionStack)
{
fExceptionStack = TRACKED_NEW hsExceptionStack;
}
return *fExceptionStack;
}
inline void hsExceptionStack::Push(const char* str)
{
fEntries.Append(str);
}
//
// hsExceptionStackDestroyer - removes the hsExceptionStack instance
//
class hsExceptionStackDestroyer
{
public:
~hsExceptionStackDestroyer()
{
hsExceptionStack::FreeInstance();
}
};
#ifdef HS_DEBUGGING
#define HS_NO_TRY
#endif
#ifdef HS_NO_TRY
#define hsGuardBegin(X)
#define hsGuardEnd
#else // HS_NO_TRY
#define hsGuardBegin(X) { const char* guardToken = X; try {
#define hsGuardEnd } catch(...) { hsExceptionStack::Instance().Push(guardToken); throw; } }
#endif // HS_NO_TRY
#endif // hsExceptionStack_inc

View File

@ -1,212 +1,212 @@
/*==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 hsExceptionDefined
#define hsExceptionDefined
#include "hsTypes.h"
// #define HS_NO_EXCEPTIONS -- this will turn off execptions you might want
// to do it with -D or equivalent instead of here since who knows who includes this.
enum hsErrorEnum {
kNo_hsError,
kBadAlloc_hsError,
kNilParam_hsError,
kBadParam_hsError,
kInternal_hsError,
kOS_hsError
};
//////////////////////////////////////////////////////////////////////////////
class hsException {
public:
hsErrorEnum fError;
long fParam;
hsException(hsErrorEnum error, long param = 0) : fError(error), fParam(param) {}
};
class hsBadAllocException : public hsException {
public:
hsBadAllocException() : hsException(kBadAlloc_hsError) {}
};
class hsNilParamException : public hsException {
public:
hsNilParamException() : hsException(kNilParam_hsError) {}
};
class hsBadParamException : public hsException {
public:
hsBadParamException() : hsException(kBadParam_hsError) {}
};
class hsInternalException : public hsException {
public:
hsInternalException() : hsException(kInternal_hsError) {}
};
class hsOSException : public hsException {
public:
hsOSException(long error) : hsException(kOS_hsError, error) {}
};
/////////////////////////////////////////////////////////////////////////////////
#ifndef HS_NO_EXCEPTIONS
#define hsThrow(a) {hsAssert(0,#a);throw a;}
#define hsCatch(a) catch (a)
#define hsCatch2(a,b) catch (a b)
#define hsTry try
inline void hsThrowIfNilParam(const void* p)
{
if (p == nil)
{
hsAssert(0,"hsNilParamException");
throw hsNilParamException();
}
}
inline void hsThrowIfBadParam(hsBool trueIfBadParam)
{
if (trueIfBadParam)
{
hsAssert(0,"hsBadParamException");
throw hsBadParamException();
}
}
inline void hsThrowIfOSErr(long osErr)
{
if (osErr != 0)
{
hsAssert(0,"hsOSException");
throw hsOSException(osErr);
}
}
inline void hsThrowIfTrue(hsBool condition)
{
if (condition)
{
hsAssert(0,"hsThrowIfTrue");
throw hsInternalException();
}
}
inline void hsThrowIfFalse(hsBool condition)
{
if (condition == false)
{
hsAssert(0,"hsThrowIfFalse");
throw hsInternalException();
}
}
inline void hsThrowIfTrue(hsBool condition, const char message[])
{
if (condition)
{
hsAssert(0,message);
throw message;
}
}
inline void hsThrowIfFalse(hsBool condition, const char message[])
{
if (condition == false)
{
hsAssert(0,message);
throw message;
}
}
#else
#define hsThrow(a) {hsAssert(0,#a);}
#define hsCatch(a) if(0)
#define hsCatch2(a,b) if(0)
#define hsTry
inline void hsThrowIfNilParam(const void* p)
{
hsAssert(p!=nil,"hsThrowIfNilParam");
}
inline void hsThrowIfBadParam(hsBool trueIfBadParam)
{
hsAssert(!trueIfBadParam,"hsThrowIfBadParam");
}
inline void hsThrowIfOSErr(long osErr)
{
hsAssert(osErr==0,"hsThrowIfOSErr");
}
inline void hsThrowIfTrue(hsBool condition)
{
hsAssert(!condition,"hsThrowIfTrue");
}
inline void hsThrowIfFalse(hsBool condition)
{
hsAssert(condition,"hsThrowIfFalse");
}
inline void hsThrowIfTrue(hsBool condition, const char message[])
{
hsAssert(!condition,message);
}
inline void hsThrowIfFalse(hsBool condition, const char message[])
{
hsAssert(condition,message);
}
#endif
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsExceptionDefined
#define hsExceptionDefined
#include "hsTypes.h"
// #define HS_NO_EXCEPTIONS -- this will turn off execptions you might want
// to do it with -D or equivalent instead of here since who knows who includes this.
enum hsErrorEnum {
kNo_hsError,
kBadAlloc_hsError,
kNilParam_hsError,
kBadParam_hsError,
kInternal_hsError,
kOS_hsError
};
//////////////////////////////////////////////////////////////////////////////
class hsException {
public:
hsErrorEnum fError;
long fParam;
hsException(hsErrorEnum error, long param = 0) : fError(error), fParam(param) {}
};
class hsBadAllocException : public hsException {
public:
hsBadAllocException() : hsException(kBadAlloc_hsError) {}
};
class hsNilParamException : public hsException {
public:
hsNilParamException() : hsException(kNilParam_hsError) {}
};
class hsBadParamException : public hsException {
public:
hsBadParamException() : hsException(kBadParam_hsError) {}
};
class hsInternalException : public hsException {
public:
hsInternalException() : hsException(kInternal_hsError) {}
};
class hsOSException : public hsException {
public:
hsOSException(long error) : hsException(kOS_hsError, error) {}
};
/////////////////////////////////////////////////////////////////////////////////
#ifndef HS_NO_EXCEPTIONS
#define hsThrow(a) {hsAssert(0,#a);throw a;}
#define hsCatch(a) catch (a)
#define hsCatch2(a,b) catch (a b)
#define hsTry try
inline void hsThrowIfNilParam(const void* p)
{
if (p == nil)
{
hsAssert(0,"hsNilParamException");
throw hsNilParamException();
}
}
inline void hsThrowIfBadParam(hsBool trueIfBadParam)
{
if (trueIfBadParam)
{
hsAssert(0,"hsBadParamException");
throw hsBadParamException();
}
}
inline void hsThrowIfOSErr(long osErr)
{
if (osErr != 0)
{
hsAssert(0,"hsOSException");
throw hsOSException(osErr);
}
}
inline void hsThrowIfTrue(hsBool condition)
{
if (condition)
{
hsAssert(0,"hsThrowIfTrue");
throw hsInternalException();
}
}
inline void hsThrowIfFalse(hsBool condition)
{
if (condition == false)
{
hsAssert(0,"hsThrowIfFalse");
throw hsInternalException();
}
}
inline void hsThrowIfTrue(hsBool condition, const char message[])
{
if (condition)
{
hsAssert(0,message);
throw message;
}
}
inline void hsThrowIfFalse(hsBool condition, const char message[])
{
if (condition == false)
{
hsAssert(0,message);
throw message;
}
}
#else
#define hsThrow(a) {hsAssert(0,#a);}
#define hsCatch(a) if(0)
#define hsCatch2(a,b) if(0)
#define hsTry
inline void hsThrowIfNilParam(const void* p)
{
hsAssert(p!=nil,"hsThrowIfNilParam");
}
inline void hsThrowIfBadParam(hsBool trueIfBadParam)
{
hsAssert(!trueIfBadParam,"hsThrowIfBadParam");
}
inline void hsThrowIfOSErr(long osErr)
{
hsAssert(osErr==0,"hsThrowIfOSErr");
}
inline void hsThrowIfTrue(hsBool condition)
{
hsAssert(!condition,"hsThrowIfTrue");
}
inline void hsThrowIfFalse(hsBool condition)
{
hsAssert(condition,"hsThrowIfFalse");
}
inline void hsThrowIfTrue(hsBool condition, const char message[])
{
hsAssert(!condition,message);
}
inline void hsThrowIfFalse(hsBool condition, const char message[])
{
hsAssert(condition,message);
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,306 +1,306 @@
/*==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 hsFastMath_inc
#define hsFastMath_inc
#include "hsPoint2.h"
#include "hsGeometry3.h"
class hsFastMath {
protected:
static const hsPoint2* fCosSinTable;
public:
static const hsScalar kSqrtTwo;
static const hsScalar kInvSqrtTwo;
static const hsScalar kTwoPI;
static hsScalar IATan2OverTwoPi(hsScalar y, hsScalar x);
static inline hsScalar InvSqrtAppr(hsScalar x);
static inline hsScalar InvSqrt(hsScalar x);
static inline hsVector3& Normalize(hsVector3& v) { return (v *= InvSqrt(v.MagnitudeSquared())); }
static inline hsVector3& NormalizeAppr(hsVector3& v) { return (v *= InvSqrtAppr(v.MagnitudeSquared())); }
static inline void SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads);
static inline void SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads);
static inline void SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads);
static inline void SinCosInRange(hsScalar ang, hsScalar& sinRads, hsScalar& cosRads);
static inline hsScalar Sin(hsScalar rads);
static inline hsScalar Cos(hsScalar rads);
static inline hsScalar SinInRange(hsScalar rads);
static inline hsScalar CosInRange(hsScalar rads);
};
// One over Square Root - from Graphics Gems
// Interesting combo's are
// NUM_ITER LOOKUP_BITS err frac us per call
// 0 8 5e-3 0.045
// 1 8 3e-5 0.082
// 0 6 1e-2 0.045
// 1 6 1e-4 0.082
// 2 6 1e-7 0.11
// 1 4 2e-3 0.082
// 2 4 5e-6 0.11
// 2 3 8e-5 0.11
// Tested on 5000 random numbers from [1.e-6..1.e3] over several runs
// These are tight loops, though, so they don't weigh in a bigger
// table trashing the cache.
#define NUM_ITER 0
#define LOOKUP_BITS 8
#define EXP_POS 23
#define EXP_BIAS 127
#define LOOKUP_POS (EXP_POS - LOOKUP_BITS)
#define SEED_POS (EXP_POS - 8)
#define TABLE_SIZE (2 << LOOKUP_BITS)
#define LOOKUP_MASK (TABLE_SIZE - 1)
#define GET_EXP(a) (((a) >> EXP_POS) & 0xff)
#define SET_EXP(a) ((a) << EXP_POS)
#define GET_EMANT(a) (((a) >> LOOKUP_POS) & LOOKUP_MASK)
#define SET_MANTSEED(a) (((unsigned long) (a)) << SEED_POS)
inline hsScalar hsFastMath::InvSqrtAppr(hsScalar x)
{
register unsigned long a = *(long*)&x;
register float arg = x;
union {
long i;
float f;
} seed;
register float r;
extern unsigned char statSeedTable[];
seed.i = SET_EXP(((3*EXP_BIAS - 1) - GET_EXP(a)) >> 1) | SET_MANTSEED(statSeedTable[GET_EMANT(a)]);
r = seed.f;
#if NUM_ITER > 0
r = (3.0f - r * r * arg) * r * 0.5f;
#if NUM_ITER > 1
r = (3.0f - r * r * arg) * r * 0.5f;
#endif
#endif
return r;
}
inline hsScalar hsFastMath::InvSqrt(hsScalar x)
{
register unsigned long a = *(long*)&x;
register float arg = x;
union {
long i;
float f;
} seed;
register float r;
extern unsigned char statSeedTable[];
seed.i = SET_EXP(((3*EXP_BIAS - 1) - GET_EXP(a)) >> 1) | SET_MANTSEED(statSeedTable[GET_EMANT(a)]);
r = seed.f;
r = (3.0f - r * r * arg) * r * 0.5f;
r = (3.0f - r * r * arg) * r * 0.5f;
return r;
}
inline void hsFastMath::SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
SinCosInRangeAppr(rads, sinRads, cosRads);
}
inline void hsFastMath::SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads)
{
const int kNumSinCosEntries = 8;
const hsScalar kNumEntriesOverTwoPI = kNumSinCosEntries * 0.5f / hsScalarPI;
hsScalar t = rads * kNumEntriesOverTwoPI;
int iLo = (int)t;
t -= iLo;
const hsPoint2* p = &fCosSinTable[iLo + 1];
cosRads = p->fX;
sinRads = p->fY;
p--;
cosRads -= p->fX;
sinRads -= p->fY;
cosRads *= t;
sinRads *= t;
cosRads += p->fX;
sinRads += p->fY;
}
inline hsScalar hsFastMath::Sin(hsScalar rads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
return SinInRange(rads);
}
inline hsScalar hsFastMath::Cos(hsScalar rads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
return CosInRange(rads);
}
inline hsScalar hsFastMath::SinInRange(hsScalar ang)
{
float sgn = 1.f;
if(ang >= (0.75f * kTwoPI))
ang -= kTwoPI;
else if(ang >= (0.25f * kTwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
return (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
}
inline hsScalar hsFastMath::CosInRange(hsScalar ang)
{
float sgn = 1.f;
if(ang >= (0.75f * kTwoPI))
ang -= kTwoPI;
else if(ang >= (0.25f * kTwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
return (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
}
inline void hsFastMath::SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
SinCosInRange(rads, sinRads, cosRads);
}
inline void hsFastMath::SinCosInRange(hsScalar ang, hsScalar& sinRads, hsScalar& cosRads)
{
float sgn = 1.f;
if(ang >= (0.75f * kTwoPI))
ang -= kTwoPI;
else if(ang >= (0.25f * kTwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
sinRads = (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
cosRads = (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
}
//
// Here's an interesting one from GDalgorithms, which doesn't need a LUT
// Not sure how the accuracy compares, but it's probably fine for this purpose.
#if 0 // For future reference
/*
From: "Jason Dorie" <jason.dorie@blackboxgames.com>
To: "GDAlgorithms" <gdalgorithms-list@lists.sourceforge.net>
Date: Wed, 14 Mar 2001 11:43:48 -0800
Subject: [Algorithms] Fast simultaneous Sin() and Cos()
Reply-To: gdalgorithms-list@lists.sourceforge.net
I know someone (Jason Zisk?) was looking for fast rotation matrix
generation code. I realize that a Sin/Cos lookup table is the way to go for
absolute speed, but if storage is a concern and the accuracy isn't, this
code is about 5x faster than using the built-in sin and cos instructions,
and accurate to about 4 decimal places.
If you really want speed, and don't care about accuracy, drop the 2nd
polynomial from each term. It's less accurate and faster still. It could
probably be made even faster by replacing the if/else with branchless code,
but I haven't bothered to figure out how yet.
My angles are 0-65535 so that they can be masked into range easily, stored
as shorts, and converted to normalized floats where necessary using SIMD
instructions.
*/
void FastSinCos(long Angle, float *pSin, float *pCos)
{
float ang, sgn;
ang = (Angle & 65535) * ((1.0f/65536.0f) * TwoPI);
sgn = 1.0f;
if(ang >= (0.75f * TwoPI))
ang -= TwoPI;
else if(ang >= (0.25f * TwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
*pSin = (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
*pCos = (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
}
#endif // For future reference
#endif // hsFastMath_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsFastMath_inc
#define hsFastMath_inc
#include "hsPoint2.h"
#include "hsGeometry3.h"
class hsFastMath {
protected:
static const hsPoint2* fCosSinTable;
public:
static const hsScalar kSqrtTwo;
static const hsScalar kInvSqrtTwo;
static const hsScalar kTwoPI;
static hsScalar IATan2OverTwoPi(hsScalar y, hsScalar x);
static inline hsScalar InvSqrtAppr(hsScalar x);
static inline hsScalar InvSqrt(hsScalar x);
static inline hsVector3& Normalize(hsVector3& v) { return (v *= InvSqrt(v.MagnitudeSquared())); }
static inline hsVector3& NormalizeAppr(hsVector3& v) { return (v *= InvSqrtAppr(v.MagnitudeSquared())); }
static inline void SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads);
static inline void SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads);
static inline void SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads);
static inline void SinCosInRange(hsScalar ang, hsScalar& sinRads, hsScalar& cosRads);
static inline hsScalar Sin(hsScalar rads);
static inline hsScalar Cos(hsScalar rads);
static inline hsScalar SinInRange(hsScalar rads);
static inline hsScalar CosInRange(hsScalar rads);
};
// One over Square Root - from Graphics Gems
// Interesting combo's are
// NUM_ITER LOOKUP_BITS err frac us per call
// 0 8 5e-3 0.045
// 1 8 3e-5 0.082
// 0 6 1e-2 0.045
// 1 6 1e-4 0.082
// 2 6 1e-7 0.11
// 1 4 2e-3 0.082
// 2 4 5e-6 0.11
// 2 3 8e-5 0.11
// Tested on 5000 random numbers from [1.e-6..1.e3] over several runs
// These are tight loops, though, so they don't weigh in a bigger
// table trashing the cache.
#define NUM_ITER 0
#define LOOKUP_BITS 8
#define EXP_POS 23
#define EXP_BIAS 127
#define LOOKUP_POS (EXP_POS - LOOKUP_BITS)
#define SEED_POS (EXP_POS - 8)
#define TABLE_SIZE (2 << LOOKUP_BITS)
#define LOOKUP_MASK (TABLE_SIZE - 1)
#define GET_EXP(a) (((a) >> EXP_POS) & 0xff)
#define SET_EXP(a) ((a) << EXP_POS)
#define GET_EMANT(a) (((a) >> LOOKUP_POS) & LOOKUP_MASK)
#define SET_MANTSEED(a) (((unsigned long) (a)) << SEED_POS)
inline hsScalar hsFastMath::InvSqrtAppr(hsScalar x)
{
register unsigned long a = *(long*)&x;
register float arg = x;
union {
long i;
float f;
} seed;
register float r;
extern unsigned char statSeedTable[];
seed.i = SET_EXP(((3*EXP_BIAS - 1) - GET_EXP(a)) >> 1) | SET_MANTSEED(statSeedTable[GET_EMANT(a)]);
r = seed.f;
#if NUM_ITER > 0
r = (3.0f - r * r * arg) * r * 0.5f;
#if NUM_ITER > 1
r = (3.0f - r * r * arg) * r * 0.5f;
#endif
#endif
return r;
}
inline hsScalar hsFastMath::InvSqrt(hsScalar x)
{
register unsigned long a = *(long*)&x;
register float arg = x;
union {
long i;
float f;
} seed;
register float r;
extern unsigned char statSeedTable[];
seed.i = SET_EXP(((3*EXP_BIAS - 1) - GET_EXP(a)) >> 1) | SET_MANTSEED(statSeedTable[GET_EMANT(a)]);
r = seed.f;
r = (3.0f - r * r * arg) * r * 0.5f;
r = (3.0f - r * r * arg) * r * 0.5f;
return r;
}
inline void hsFastMath::SinCosAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
SinCosInRangeAppr(rads, sinRads, cosRads);
}
inline void hsFastMath::SinCosInRangeAppr(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads)
{
const int kNumSinCosEntries = 8;
const hsScalar kNumEntriesOverTwoPI = kNumSinCosEntries * 0.5f / hsScalarPI;
hsScalar t = rads * kNumEntriesOverTwoPI;
int iLo = (int)t;
t -= iLo;
const hsPoint2* p = &fCosSinTable[iLo + 1];
cosRads = p->fX;
sinRads = p->fY;
p--;
cosRads -= p->fX;
sinRads -= p->fY;
cosRads *= t;
sinRads *= t;
cosRads += p->fX;
sinRads += p->fY;
}
inline hsScalar hsFastMath::Sin(hsScalar rads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
return SinInRange(rads);
}
inline hsScalar hsFastMath::Cos(hsScalar rads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
return CosInRange(rads);
}
inline hsScalar hsFastMath::SinInRange(hsScalar ang)
{
float sgn = 1.f;
if(ang >= (0.75f * kTwoPI))
ang -= kTwoPI;
else if(ang >= (0.25f * kTwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
return (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
}
inline hsScalar hsFastMath::CosInRange(hsScalar ang)
{
float sgn = 1.f;
if(ang >= (0.75f * kTwoPI))
ang -= kTwoPI;
else if(ang >= (0.25f * kTwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
return (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
}
inline void hsFastMath::SinCos(hsScalar rads, hsScalar& sinRads, hsScalar& cosRads)
{
rads = fmodf(rads, kTwoPI);
if( rads < 0 )
rads += kTwoPI;
SinCosInRange(rads, sinRads, cosRads);
}
inline void hsFastMath::SinCosInRange(hsScalar ang, hsScalar& sinRads, hsScalar& cosRads)
{
float sgn = 1.f;
if(ang >= (0.75f * kTwoPI))
ang -= kTwoPI;
else if(ang >= (0.25f * kTwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
sinRads = (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
cosRads = (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
}
//
// Here's an interesting one from GDalgorithms, which doesn't need a LUT
// Not sure how the accuracy compares, but it's probably fine for this purpose.
#if 0 // For future reference
/*
From: "Jason Dorie" <jason.dorie@blackboxgames.com>
To: "GDAlgorithms" <gdalgorithms-list@lists.sourceforge.net>
Date: Wed, 14 Mar 2001 11:43:48 -0800
Subject: [Algorithms] Fast simultaneous Sin() and Cos()
Reply-To: gdalgorithms-list@lists.sourceforge.net
I know someone (Jason Zisk?) was looking for fast rotation matrix
generation code. I realize that a Sin/Cos lookup table is the way to go for
absolute speed, but if storage is a concern and the accuracy isn't, this
code is about 5x faster than using the built-in sin and cos instructions,
and accurate to about 4 decimal places.
If you really want speed, and don't care about accuracy, drop the 2nd
polynomial from each term. It's less accurate and faster still. It could
probably be made even faster by replacing the if/else with branchless code,
but I haven't bothered to figure out how yet.
My angles are 0-65535 so that they can be masked into range easily, stored
as shorts, and converted to normalized floats where necessary using SIMD
instructions.
*/
void FastSinCos(long Angle, float *pSin, float *pCos)
{
float ang, sgn;
ang = (Angle & 65535) * ((1.0f/65536.0f) * TwoPI);
sgn = 1.0f;
if(ang >= (0.75f * TwoPI))
ang -= TwoPI;
else if(ang >= (0.25f * TwoPI))
{
ang -= 3.141592654f;
sgn = -1.0f;
}
*pSin = (ang - (ang*ang*ang) * (1.0f/6.0f) + (ang*ang*ang*ang*ang) / 120.0f) * sgn;
*pCos = (1.0f - (ang*ang / 2.0f) + (ang*ang*ang*ang) / 24.0f) *sgn;
}
#endif // For future reference
#endif // hsFastMath_inc

View File

@ -1,134 +1,134 @@
/*==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 hsFixedTypesDefined
#define hsFixedTypesDefined
#include "hsTypes.h"
#if HS_BUILD_FOR_MAC
#include <ToolUtils.h>
#include <FixMath.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define hsIntToFixed(x) ((hsFixed)(x) << 16)
#define hsFixedToInt(x) ((x) >> 16)
#define hsFixedRound(x) (((x) + 0x8000) >> 16)
#define hsFixed1 hsIntToFixed(1)
#define hsFixedPI (0x3243F)
#define hsFixedPiOver2 (0x1921F)
#define hsFixedToFract(x) ((hsFract)(x) << 14)
#define hsFractToFixed(x) ((hsFixed)(x) >> 14)
#define hsFract1 hsFixedToFract(hsFixed1)
#define hsFractPiOver2 (0x6487ED34) /* needs some work */
#define hsFixFloor(x) \
(hsFixed)((x) < 0 ? -(hsFixed)((-(x) + 0xFFFF) & 0xFFFF0000) : (x) & 0xFFFF0000)
#define hsFixedToFloorInt(x) \
(int)((x) < 0 ? -(int)((-(x) + 0xFFFF) >> 16) : ((x) >> 16))
#define hsFixCeiling(x) \
(hsFixed)((x) < 0 ? -(hsFixed)(-(x) & 0xFFFF0000) : ((x) + 0xFFFF) & 0xFFFF0000)
#define hsFixedToCeilingInt(x) \
(int)((x) < 0 ? -(int)(-(x) >> 16) : (((x) + 0xFFFF) >> 16))
#if HS_CAN_USE_FLOAT
#define hsFixedToFloat(x) ((x) / float(hsFixed1))
#define hsFloatToFixed(x) hsFixed((x) * hsFixed1)
#define hsFractToFloat(x) ((x) / float(hsFract1))
#define hsFloatToFract(x) hsFract((x) * hsFract1)
#endif
#if HS_BUILD_FOR_MAC68K && !(HS_PIN_MATH_OVERFLOW)
#define hsFixMul(a, b) FixMul(a, b)
#else
hsFixed hsFixMul(hsFixed a, hsFixed b);
#endif
#if HS_BUILD_FOR_MAC && !(HS_PIN_MATH_OVERFLOW) && !(HS_MP_SAFE)
#define hsFixDiv(a, b) FixDiv(a, b)
#define hsFracMul(a, b) FracMul(a, b)
#define hsFracDiv(a, b) FracDiv(a, b)
#else
hsFract hsFixDiv(hsFixed a, hsFixed b);
hsFract hsFracMul(hsFract a, hsFract b);
hsFract hsFracDiv(hsFract a, hsFract b);
#endif
hsFract hsFracSqrt(hsFract value);
#define hsFixSqrt(value) (hsFracSqrt(value) >> 7)
hsFract hsFracCubeRoot(hsFract value);
hsFixed hsFixedSin(hsFixed s);
hsFixed hsFixedCos(hsFixed s);
hsFixed hsFixedASin(hsFixed s);
hsFixed hsFixedACos(hsFixed s);
UInt16 hsSqrt32(UInt32 value);
UInt16 hsCubeRoot32(UInt32 value);
Int32 hsMulDiv32(Int32 numer1, Int32 numer2, Int32 denom);
Int32 hsMagnitude32(Int32 x, Int32 y);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
struct hsFixedPlane {
hsFixed fA, fB, fC;
void Set(hsFixed a, hsFixed b, hsFixed c) { fA = a; fB = b; fC = c; }
hsFixed FixEval(hsFixed x, hsFixed y) const { return hsFixMul(fA, x) + hsFixMul(fB, y) + fC; }
Int32 IntEval(Int32 x, Int32 y) const { return fA * x + fB * y + fC; }
void ShiftDown(UInt32 i) { fA >>= i; fB >>= i; fC >>= i;}
};
#endif
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsFixedTypesDefined
#define hsFixedTypesDefined
#include "hsTypes.h"
#if HS_BUILD_FOR_MAC
#include <ToolUtils.h>
#include <FixMath.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#define hsIntToFixed(x) ((hsFixed)(x) << 16)
#define hsFixedToInt(x) ((x) >> 16)
#define hsFixedRound(x) (((x) + 0x8000) >> 16)
#define hsFixed1 hsIntToFixed(1)
#define hsFixedPI (0x3243F)
#define hsFixedPiOver2 (0x1921F)
#define hsFixedToFract(x) ((hsFract)(x) << 14)
#define hsFractToFixed(x) ((hsFixed)(x) >> 14)
#define hsFract1 hsFixedToFract(hsFixed1)
#define hsFractPiOver2 (0x6487ED34) /* needs some work */
#define hsFixFloor(x) \
(hsFixed)((x) < 0 ? -(hsFixed)((-(x) + 0xFFFF) & 0xFFFF0000) : (x) & 0xFFFF0000)
#define hsFixedToFloorInt(x) \
(int)((x) < 0 ? -(int)((-(x) + 0xFFFF) >> 16) : ((x) >> 16))
#define hsFixCeiling(x) \
(hsFixed)((x) < 0 ? -(hsFixed)(-(x) & 0xFFFF0000) : ((x) + 0xFFFF) & 0xFFFF0000)
#define hsFixedToCeilingInt(x) \
(int)((x) < 0 ? -(int)(-(x) >> 16) : (((x) + 0xFFFF) >> 16))
#if HS_CAN_USE_FLOAT
#define hsFixedToFloat(x) ((x) / float(hsFixed1))
#define hsFloatToFixed(x) hsFixed((x) * hsFixed1)
#define hsFractToFloat(x) ((x) / float(hsFract1))
#define hsFloatToFract(x) hsFract((x) * hsFract1)
#endif
#if HS_BUILD_FOR_MAC68K && !(HS_PIN_MATH_OVERFLOW)
#define hsFixMul(a, b) FixMul(a, b)
#else
hsFixed hsFixMul(hsFixed a, hsFixed b);
#endif
#if HS_BUILD_FOR_MAC && !(HS_PIN_MATH_OVERFLOW) && !(HS_MP_SAFE)
#define hsFixDiv(a, b) FixDiv(a, b)
#define hsFracMul(a, b) FracMul(a, b)
#define hsFracDiv(a, b) FracDiv(a, b)
#else
hsFract hsFixDiv(hsFixed a, hsFixed b);
hsFract hsFracMul(hsFract a, hsFract b);
hsFract hsFracDiv(hsFract a, hsFract b);
#endif
hsFract hsFracSqrt(hsFract value);
#define hsFixSqrt(value) (hsFracSqrt(value) >> 7)
hsFract hsFracCubeRoot(hsFract value);
hsFixed hsFixedSin(hsFixed s);
hsFixed hsFixedCos(hsFixed s);
hsFixed hsFixedASin(hsFixed s);
hsFixed hsFixedACos(hsFixed s);
UInt16 hsSqrt32(UInt32 value);
UInt16 hsCubeRoot32(UInt32 value);
Int32 hsMulDiv32(Int32 numer1, Int32 numer2, Int32 denom);
Int32 hsMagnitude32(Int32 x, Int32 y);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
struct hsFixedPlane {
hsFixed fA, fB, fC;
void Set(hsFixed a, hsFixed b, hsFixed c) { fA = a; fB = b; fC = c; }
hsFixed FixEval(hsFixed x, hsFixed y) const { return hsFixMul(fA, x) + hsFixMul(fB, y) + fC; }
Int32 IntEval(Int32 x, Int32 y) const { return fA * x + fB * y + fC; }
void ShiftDown(UInt32 i) { fA >>= i; fB >>= i; fC >>= i;}
};
#endif
#endif

View File

@ -1,133 +1,133 @@
/*==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 "hsGeometry3.h"
#include "hsStream.h"
hsVector3 operator%(const hsVector3& t, const hsVector3& s)
{
hsVector3 result;
return *result.Set( hsScalarMul(t.fY, s.fZ) - hsScalarMul(s.fY, t.fZ),
-hsScalarMul(t.fX, s.fZ) + hsScalarMul(s.fX, t.fZ),
hsScalarMul(t.fX, s.fY) - hsScalarMul(s.fX, t.fY));
}
//////////////////////////////////
/////////////////////////////////
#if HS_SCALAR_IS_FIXED
hsScalar hsScalarTriple::Magnitude() const
{
hsWide result, temp;
result.Mul(fCoord[0], fCoord[0]);
temp.Mul(fCoord[1], fCoord[1]);
result.Add(&temp);
temp.Mul(fCoord[2], fCoord[2]);
result.Add(&temp);
return result.Sqrt();
}
hsScalar hsScalarTriple::MagnitudeSquared() const
{
hsWide result, temp;
result.Mul(fCoord[0], fCoord[0]);
temp.Mul(fCoord[1], fCoord[1]);
result.Add(&temp);
temp.Mul(fCoord[2], fCoord[2]);
result.Add(&temp);
return result.AsFixed();
}
#endif
void hsScalarTriple::Read(hsStream *stream)
{
// DANGER for speed read directly into these variables...ASSUMES fX,fY, and fZ are in contiguous order (PBG)
stream->Read12Bytes(&fX);
#if HS_BUILD_FOR_MAC
fX = hsSwapEndianFloat(fX);
fY = hsSwapEndianFloat(fY);
fZ = hsSwapEndianFloat(fZ);
#endif
}
void hsScalarTriple::Write(hsStream *stream) const
{
stream->WriteSwapScalar(fX);
stream->WriteSwapScalar(fY);
stream->WriteSwapScalar(fZ);
}
hsPlane3::hsPlane3(const hsPoint3* pt1, const hsPoint3* pt2, const hsPoint3* pt3)
{
// convert into a point with two vectors
hsVector3 v1(pt2, pt1);
hsVector3 v2(pt3, pt1);
// calculate the normal (wedge)
fN.fX = (v1.fY * v2.fZ) - (v2.fY * v1.fZ);
fN.fY = (v1.fZ * v2.fX) - (v2.fZ * v1.fX);
fN.fZ = (v1.fX * v2.fY) - (v2.fX * v1.fY);
fN.Normalize();
fD = -pt1->InnerProduct(&fN);
}
void hsPlane3::Read(hsStream *stream)
{
fN.Read(stream);
fD=stream->ReadSwapScalar();
}
void hsPlane3::Write(hsStream *stream) const
{
fN.Write(stream);
stream->WriteSwapScalar(fD);
}
/*==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 "hsGeometry3.h"
#include "hsStream.h"
hsVector3 operator%(const hsVector3& t, const hsVector3& s)
{
hsVector3 result;
return *result.Set( hsScalarMul(t.fY, s.fZ) - hsScalarMul(s.fY, t.fZ),
-hsScalarMul(t.fX, s.fZ) + hsScalarMul(s.fX, t.fZ),
hsScalarMul(t.fX, s.fY) - hsScalarMul(s.fX, t.fY));
}
//////////////////////////////////
/////////////////////////////////
#if HS_SCALAR_IS_FIXED
hsScalar hsScalarTriple::Magnitude() const
{
hsWide result, temp;
result.Mul(fCoord[0], fCoord[0]);
temp.Mul(fCoord[1], fCoord[1]);
result.Add(&temp);
temp.Mul(fCoord[2], fCoord[2]);
result.Add(&temp);
return result.Sqrt();
}
hsScalar hsScalarTriple::MagnitudeSquared() const
{
hsWide result, temp;
result.Mul(fCoord[0], fCoord[0]);
temp.Mul(fCoord[1], fCoord[1]);
result.Add(&temp);
temp.Mul(fCoord[2], fCoord[2]);
result.Add(&temp);
return result.AsFixed();
}
#endif
void hsScalarTriple::Read(hsStream *stream)
{
// DANGER for speed read directly into these variables...ASSUMES fX,fY, and fZ are in contiguous order (PBG)
stream->Read12Bytes(&fX);
#if HS_BUILD_FOR_MAC
fX = hsSwapEndianFloat(fX);
fY = hsSwapEndianFloat(fY);
fZ = hsSwapEndianFloat(fZ);
#endif
}
void hsScalarTriple::Write(hsStream *stream) const
{
stream->WriteSwapScalar(fX);
stream->WriteSwapScalar(fY);
stream->WriteSwapScalar(fZ);
}
hsPlane3::hsPlane3(const hsPoint3* pt1, const hsPoint3* pt2, const hsPoint3* pt3)
{
// convert into a point with two vectors
hsVector3 v1(pt2, pt1);
hsVector3 v2(pt3, pt1);
// calculate the normal (wedge)
fN.fX = (v1.fY * v2.fZ) - (v2.fY * v1.fZ);
fN.fY = (v1.fZ * v2.fX) - (v2.fZ * v1.fX);
fN.fZ = (v1.fX * v2.fY) - (v2.fX * v1.fY);
fN.Normalize();
fD = -pt1->InnerProduct(&fN);
}
void hsPlane3::Read(hsStream *stream)
{
fN.Read(stream);
fD=stream->ReadSwapScalar();
}
void hsPlane3::Write(hsStream *stream) const
{
fN.Write(stream);
stream->WriteSwapScalar(fD);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,199 +1,199 @@
/*==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==*/
// hsHashTable.h
#ifndef _hsHashTable_Included_
#define _hsHashTable_Included_
#include "hsTemplates.h"
template <class T>
class hsHashTableIterator
{
public:
hsHashTableIterator() : fList(nil), fIndex(-1) { }
explicit hsHashTableIterator(hsTArray<T>* list, UInt32 idx) : fList(list), fIndex(idx) { }
T* operator->() const { return &((*fList)[fIndex]); }
T& operator*() const { return (*fList)[fIndex]; }
hsHashTableIterator<T>& operator++() { fIndex--; return *this; }
const hsHashTableIterator<T>& operator++(int) { hsHashTableIterator<T> temp(*this); --(*this); return temp; }
hsHashTableIterator<T>& operator--() { fIndex++; return *this; }
const hsHashTableIterator<T>& operator--(int) { hsHashTableIterator<T> temp(*this); ++(*this); return temp; }
hsBool operator==(const hsHashTableIterator<T>& other) const { return fList==other.fList && fIndex==other.fIndex; }
hsBool operator!=(const hsHashTableIterator<T>& other) const { return !(*this == other); }
private:
hsTArray<T>* fList;
UInt32 fIndex;
};
template <class T>
class hsHashTable
{
public:
hsHashTable(UInt32 size=150001, UInt32 step=1);
~hsHashTable();
typedef hsHashTableIterator<T> iterator;
iterator begin() { return iterator(&fItemList,fItemList.Count()-1); }
iterator end() { return iterator(&fItemList,0); }
void clear();
UInt32 count() { return fItemList.Count()-1; }
UInt32 size() { return fSize; }
UInt32 CollisionCount() { return fCollisionCount; }
inline void insert(T& item);
inline void erase(T& item);
inline iterator find(const T& item);
iterator GetItem(UInt32 i);
private:
hsTArray<T> fItemList;
hsTArray<UInt32> fClearList;
UInt32* fHashTable;
UInt32 fSize;
UInt32 fCollisionStep;
UInt32 fCollisionCount;
// No copy or assignment
hsHashTable(const hsHashTable&);
hsHashTable &operator=(const hsHashTable&);
};
template <class T>
hsHashTable<T>::hsHashTable(UInt32 size, UInt32 step) :
fSize(size),
fCollisionStep(step),
fCollisionCount(0)
{
fItemList.SetCount(1);
fHashTable = TRACKED_NEW UInt32[fSize];
memset(fHashTable,0,fSize*sizeof(UInt32));
}
template <class T>
hsHashTable<T>::~hsHashTable()
{
delete [] fHashTable;
}
template <class T>
void hsHashTable<T>::clear()
{
fItemList.SetCount(1);
for (Int32 i=0; i<fClearList.Count(); i++)
fHashTable[ fClearList[i] ] = 0;
fClearList.Reset();
}
template <class T>
void hsHashTable<T>::insert(T& item)
{
hsAssert(fClearList.Count() < fSize,"Hash table overflow! Increase the table size.");
UInt32 h = item.GetHash();
h %= fSize;
while (UInt32 it = fHashTable[h])
{
if ( fItemList[it] == item)
{
fItemList[it] = item;
return;
}
h += fCollisionStep;
h %= fSize;
fCollisionCount++;
}
fHashTable[h] = fItemList.Count();
fItemList.Append(item);
fClearList.Append(h);
}
template <class T>
void hsHashTable<T>::erase(T& item)
{
UInt32 h = item.GetHash();
h %= fSize;
while (UInt32 it = fHashTable[h])
{
if ( fItemList[it] == item )
{
fHashTable[h] = 0;
return;
}
}
}
template <class T>
hsHashTableIterator<T> hsHashTable<T>::find(const T& item)
{
UInt32 h = item.GetHash();
h %= fSize;
while (UInt32 it = fHashTable[h])
{
if ( fItemList[it] == item )
{
return iterator(&fItemList,it);
}
h += fCollisionStep;
h %= fSize;
fCollisionCount++;
}
return end();
}
template <class T>
hsHashTableIterator<T> hsHashTable<T>::GetItem(UInt32 i)
{
return iterator(&fItemList,i+1);
}
#endif // _hsHashTable_Included_
/*==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==*/
// hsHashTable.h
#ifndef _hsHashTable_Included_
#define _hsHashTable_Included_
#include "hsTemplates.h"
template <class T>
class hsHashTableIterator
{
public:
hsHashTableIterator() : fList(nil), fIndex(-1) { }
explicit hsHashTableIterator(hsTArray<T>* list, UInt32 idx) : fList(list), fIndex(idx) { }
T* operator->() const { return &((*fList)[fIndex]); }
T& operator*() const { return (*fList)[fIndex]; }
hsHashTableIterator<T>& operator++() { fIndex--; return *this; }
const hsHashTableIterator<T>& operator++(int) { hsHashTableIterator<T> temp(*this); --(*this); return temp; }
hsHashTableIterator<T>& operator--() { fIndex++; return *this; }
const hsHashTableIterator<T>& operator--(int) { hsHashTableIterator<T> temp(*this); ++(*this); return temp; }
hsBool operator==(const hsHashTableIterator<T>& other) const { return fList==other.fList && fIndex==other.fIndex; }
hsBool operator!=(const hsHashTableIterator<T>& other) const { return !(*this == other); }
private:
hsTArray<T>* fList;
UInt32 fIndex;
};
template <class T>
class hsHashTable
{
public:
hsHashTable(UInt32 size=150001, UInt32 step=1);
~hsHashTable();
typedef hsHashTableIterator<T> iterator;
iterator begin() { return iterator(&fItemList,fItemList.Count()-1); }
iterator end() { return iterator(&fItemList,0); }
void clear();
UInt32 count() { return fItemList.Count()-1; }
UInt32 size() { return fSize; }
UInt32 CollisionCount() { return fCollisionCount; }
inline void insert(T& item);
inline void erase(T& item);
inline iterator find(const T& item);
iterator GetItem(UInt32 i);
private:
hsTArray<T> fItemList;
hsTArray<UInt32> fClearList;
UInt32* fHashTable;
UInt32 fSize;
UInt32 fCollisionStep;
UInt32 fCollisionCount;
// No copy or assignment
hsHashTable(const hsHashTable&);
hsHashTable &operator=(const hsHashTable&);
};
template <class T>
hsHashTable<T>::hsHashTable(UInt32 size, UInt32 step) :
fSize(size),
fCollisionStep(step),
fCollisionCount(0)
{
fItemList.SetCount(1);
fHashTable = TRACKED_NEW UInt32[fSize];
memset(fHashTable,0,fSize*sizeof(UInt32));
}
template <class T>
hsHashTable<T>::~hsHashTable()
{
delete [] fHashTable;
}
template <class T>
void hsHashTable<T>::clear()
{
fItemList.SetCount(1);
for (Int32 i=0; i<fClearList.Count(); i++)
fHashTable[ fClearList[i] ] = 0;
fClearList.Reset();
}
template <class T>
void hsHashTable<T>::insert(T& item)
{
hsAssert(fClearList.Count() < fSize,"Hash table overflow! Increase the table size.");
UInt32 h = item.GetHash();
h %= fSize;
while (UInt32 it = fHashTable[h])
{
if ( fItemList[it] == item)
{
fItemList[it] = item;
return;
}
h += fCollisionStep;
h %= fSize;
fCollisionCount++;
}
fHashTable[h] = fItemList.Count();
fItemList.Append(item);
fClearList.Append(h);
}
template <class T>
void hsHashTable<T>::erase(T& item)
{
UInt32 h = item.GetHash();
h %= fSize;
while (UInt32 it = fHashTable[h])
{
if ( fItemList[it] == item )
{
fHashTable[h] = 0;
return;
}
}
}
template <class T>
hsHashTableIterator<T> hsHashTable<T>::find(const T& item)
{
UInt32 h = item.GetHash();
h %= fSize;
while (UInt32 it = fHashTable[h])
{
if ( fItemList[it] == item )
{
return iterator(&fItemList,it);
}
h += fCollisionStep;
h %= fSize;
fCollisionCount++;
}
return end();
}
template <class T>
hsHashTableIterator<T> hsHashTable<T>::GetItem(UInt32 i)
{
return iterator(&fItemList,i+1);
}
#endif // _hsHashTable_Included_

View File

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

View File

@ -1,105 +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==*/
#include "hsMMIOStream.h"
//////////////////////////////////////////////////////////////////////////////////////
#if HS_BUILD_FOR_WIN32
#include "hsExceptions.h"
UInt32 hsMMIOStream::Read(UInt32 bytes, void* buffer)
{
fBytesRead += bytes;
fPosition += bytes;
int numItems = ::mmioRead(fHmfr, (char*)buffer, bytes);
if ((unsigned)numItems < bytes)
{
if (numItems>=0 && ::mmioSeek(fHmfr,0,SEEK_CUR)==::mmioSeek(fHmfr,0,SEEK_END)) {
// EOF ocurred
char str[128];
sprintf(str, "Hit EOF on MMIO Read, only read %d out of requested %d bytes\n", numItems, bytes);
hsDebugMessage(str, 0);
}
else
{
hsDebugMessage("Error on MMIO Read",0);
}
}
return numItems;
}
hsBool hsMMIOStream::AtEnd()
{
return (::mmioSeek(fHmfr,0,SEEK_CUR)==::mmioSeek(fHmfr,0,SEEK_END));
}
UInt32 hsMMIOStream::Write(UInt32 bytes, const void* buffer)
{
fPosition += bytes;
return ::mmioWrite(fHmfr,(const char*)buffer,bytes);
}
void hsMMIOStream::Skip(UInt32 delta)
{
fBytesRead += delta;
fPosition += delta;
(void)::mmioSeek(fHmfr, delta, SEEK_CUR);
}
void hsMMIOStream::Rewind()
{
fBytesRead = 0;
fPosition = 0;
(void)::mmioSeek(fHmfr, 0, SEEK_SET);
}
void hsMMIOStream::FastFwd()
{
fBytesRead = fPosition = ::mmioSeek(fHmfr, 0, SEEK_END);
}
void hsMMIOStream::Truncate()
{
hsThrow("Truncate unimplemented by subclass of stream");
}
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "hsMMIOStream.h"
//////////////////////////////////////////////////////////////////////////////////////
#if HS_BUILD_FOR_WIN32
#include "hsExceptions.h"
UInt32 hsMMIOStream::Read(UInt32 bytes, void* buffer)
{
fBytesRead += bytes;
fPosition += bytes;
int numItems = ::mmioRead(fHmfr, (char*)buffer, bytes);
if ((unsigned)numItems < bytes)
{
if (numItems>=0 && ::mmioSeek(fHmfr,0,SEEK_CUR)==::mmioSeek(fHmfr,0,SEEK_END)) {
// EOF ocurred
char str[128];
sprintf(str, "Hit EOF on MMIO Read, only read %d out of requested %d bytes\n", numItems, bytes);
hsDebugMessage(str, 0);
}
else
{
hsDebugMessage("Error on MMIO Read",0);
}
}
return numItems;
}
hsBool hsMMIOStream::AtEnd()
{
return (::mmioSeek(fHmfr,0,SEEK_CUR)==::mmioSeek(fHmfr,0,SEEK_END));
}
UInt32 hsMMIOStream::Write(UInt32 bytes, const void* buffer)
{
fPosition += bytes;
return ::mmioWrite(fHmfr,(const char*)buffer,bytes);
}
void hsMMIOStream::Skip(UInt32 delta)
{
fBytesRead += delta;
fPosition += delta;
(void)::mmioSeek(fHmfr, delta, SEEK_CUR);
}
void hsMMIOStream::Rewind()
{
fBytesRead = 0;
fPosition = 0;
(void)::mmioSeek(fHmfr, 0, SEEK_SET);
}
void hsMMIOStream::FastFwd()
{
fBytesRead = fPosition = ::mmioSeek(fHmfr, 0, SEEK_END);
}
void hsMMIOStream::Truncate()
{
hsThrow("Truncate unimplemented by subclass of stream");
}
#endif

View File

@ -1,72 +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 hsMMIOStream_inc
#define hsMMIOStream_inc
#include "hsWindows.h"
#include "hsStream.h"
#if HS_BUILD_FOR_WIN32
#include <mmsystem.h>
#endif
class hsMMIOStream: public hsStream
{
HMMIO fHmfr;
public:
virtual hsBool Open(const char *, const char *) { hsAssert(0, "hsMMIOStream::Open NotImplemented"); return false; }
virtual hsBool Close() { hsAssert(0, "hsMMIOStream::Close NotImplemented"); return false; }
virtual hsBool AtEnd();
virtual UInt32 Read(UInt32 byteCount, void* buffer);
virtual UInt32 Write(UInt32 byteCount, const void* buffer);
virtual void Skip(UInt32 deltaByteCount);
virtual void Rewind();
virtual void FastFwd();
virtual void Truncate();
HMMIO GetHandle() { return fHmfr; }
void SetHandle(HMMIO handle) { fHmfr = handle; }
};
#endif // hsMMIOStream_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsMMIOStream_inc
#define hsMMIOStream_inc
#include "hsWindows.h"
#include "hsStream.h"
#if HS_BUILD_FOR_WIN32
#include <mmsystem.h>
#endif
class hsMMIOStream: public hsStream
{
HMMIO fHmfr;
public:
virtual hsBool Open(const char *, const char *) { hsAssert(0, "hsMMIOStream::Open NotImplemented"); return false; }
virtual hsBool Close() { hsAssert(0, "hsMMIOStream::Close NotImplemented"); return false; }
virtual hsBool AtEnd();
virtual UInt32 Read(UInt32 byteCount, void* buffer);
virtual UInt32 Write(UInt32 byteCount, const void* buffer);
virtual void Skip(UInt32 deltaByteCount);
virtual void Rewind();
virtual void FastFwd();
virtual void Truncate();
HMMIO GetHandle() { return fHmfr; }
void SetHandle(HMMIO handle) { fHmfr = handle; }
};
#endif // hsMMIOStream_inc

View File

@ -1,56 +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/CoreLib/hsMalloc.cpp
*
***/
#include "HeadSpin.h"
/*****************************************************************************
*
* Exports
*
***/
/*==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/CoreLib/hsMalloc.cpp
*
***/
#include "HeadSpin.h"
/*****************************************************************************
*
* Exports
*
***/

View File

@ -1,183 +1,183 @@
/*==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/CoreLib/hsMalloc.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_CORELIB_HSMALLOC_H
#define PLASMA20_SOURCES_PLASMA_CORELIB_HSMALLOC_H
/****************************************************************************
*
* Allocation functions
*
***/
#ifdef __cplusplus
extern "C" {
#endif
// MemAlloc flags
extern const unsigned kMemReallocInPlaceOnly; // use _expand when realloc'ing
extern const unsigned kMemZero; // fill allocated memory with zeros
extern const unsigned kMemIgnoreBlock; // don't track this allocation
void * MemAlloc (unsigned bytes, unsigned flags, const char file[], int line);
void * MemDup (const void * ptr, unsigned bytes, unsigned flags, const char file[], int line);
void MemFree (void * ptr, unsigned flags);
void * MemRealloc (void * ptr, unsigned bytes, unsigned flags, const char file[], int line);
unsigned MemSize (void * ptr);
/****************************************************************************
*
* Manipulation functions
*
***/
int MemCmp (const void * buf1, const void * buf2, unsigned bytes);
void MemCopy (void * dest, const void * source, unsigned bytes);
void MemMove (void * dest, const void * source, unsigned bytes);
void MemSet (void * dest, unsigned value, unsigned bytes);
void MemZero (void * dest, unsigned bytes);
/*****************************************************************************
*
* Debugging functions
*
***/
void MemDumpAllocReport ();
void MemDumpUsageReport ();
void MemValidateNow ();
void MemSetValidation (unsigned on);
void MemPushDisableTracking ();
void MemPopDisableTracking ();
void MemSetColor (unsigned short color);
#ifdef __cplusplus
}
#endif
/****************************************************************************
*
* C++ Operators
*
***/
#ifdef __cplusplus
// standard new and delete
inline void * __cdecl operator new (size_t bytes) { return MemAlloc((unsigned)bytes, 0, __FILE__, __LINE__); }
inline void __cdecl operator delete (void * ptr) { MemFree(ptr, 0); }
// memcheck-friendly new
inline void * __cdecl operator new (size_t bytes, const char file[], unsigned line) { return MemAlloc((unsigned)bytes, 0, file, line); }
inline void __cdecl operator delete (void * ptr, const char [] , unsigned) { return MemFree(ptr, 0); }
#define TRACKED_NEW new(__FILE__, __LINE__)
// placement new
#ifndef __PLACEMENT_NEW_INLINE
#define __PLACEMENT_NEW_INLINE
inline void * __cdecl operator new (size_t, void * ptr) { return ptr; }
inline void __cdecl operator delete (void *, void *) {}
#endif // ifndef __PLACEMENT_NEW_INLINE
#endif // ifdef __cplusplus
/****************************************************************************
*
* Macros
*
***/
#define ALLOC(b) MemAlloc(b, 0, __FILE__, __LINE__)
#define ALLOCZERO(b) MemAlloc(b, kMemZero, __FILE__, __LINE__)
#define ALLOCFLAGS(b, f) MemAlloc(b, (f), __FILE__, __LINE__)
#define FREE(p) MemFree(p, 0)
#define FREEFLAGS(p, f) MemFree(p, (f))
#define REALLOC(p, b) MemRealloc(p, b, 0, __FILE__, __LINE__)
#define REALLOCFLAGS(p, b, f) MemRealloc(p, b, (f), __FILE__, __LINE__)
#define CALLOC(n, s) MemAlloc((n)*(s), kMemZero, __FILE__, __LINE__)
#define MEMDUP(s, b) MemDup(s, b, 0, __FILE__, __LINE__)
#define ZERO(s) MemSet(&s, 0, sizeof(s))
#define ZEROPTR(p) MemSet(p, 0, sizeof(*p))
// Client must #include <malloc.h>
#define ALLOCA(t, n) (t *)_alloca((n) * sizeof(t))
#ifdef __cplusplus
#define NEW(t) new(MemAlloc(sizeof(t), 0, __FILE__, __LINE__)) t
#define NEWFLAGS(t, f) new(MemAlloc(sizeof(t), (f), __FILE__, __LINE__)) t
#define NEWZERO(t) new(MemAlloc(sizeof(t), kMemZero, __FILE__, __LINE__)) t
#define DEL(t) delete (t)
#endif // __cplusplus
/****************************************************************************
*
* TypeInfo
* (needed for memory leak reporting)
*
***/
#ifdef __cplusplus
#if !defined(HS_NO_TYPEINFO)
#include <typeinfo.h>
#endif
#endif // ifdef __cplusplus
#endif // PLASMA20_SOURCES_PLASMA_CORELIB_HSMALLOC_H
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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/CoreLib/hsMalloc.h
*
***/
#ifndef PLASMA20_SOURCES_PLASMA_CORELIB_HSMALLOC_H
#define PLASMA20_SOURCES_PLASMA_CORELIB_HSMALLOC_H
/****************************************************************************
*
* Allocation functions
*
***/
#ifdef __cplusplus
extern "C" {
#endif
// MemAlloc flags
extern const unsigned kMemReallocInPlaceOnly; // use _expand when realloc'ing
extern const unsigned kMemZero; // fill allocated memory with zeros
extern const unsigned kMemIgnoreBlock; // don't track this allocation
void * MemAlloc (unsigned bytes, unsigned flags, const char file[], int line);
void * MemDup (const void * ptr, unsigned bytes, unsigned flags, const char file[], int line);
void MemFree (void * ptr, unsigned flags);
void * MemRealloc (void * ptr, unsigned bytes, unsigned flags, const char file[], int line);
unsigned MemSize (void * ptr);
/****************************************************************************
*
* Manipulation functions
*
***/
int MemCmp (const void * buf1, const void * buf2, unsigned bytes);
void MemCopy (void * dest, const void * source, unsigned bytes);
void MemMove (void * dest, const void * source, unsigned bytes);
void MemSet (void * dest, unsigned value, unsigned bytes);
void MemZero (void * dest, unsigned bytes);
/*****************************************************************************
*
* Debugging functions
*
***/
void MemDumpAllocReport ();
void MemDumpUsageReport ();
void MemValidateNow ();
void MemSetValidation (unsigned on);
void MemPushDisableTracking ();
void MemPopDisableTracking ();
void MemSetColor (unsigned short color);
#ifdef __cplusplus
}
#endif
/****************************************************************************
*
* C++ Operators
*
***/
#ifdef __cplusplus
// standard new and delete
inline void * __cdecl operator new (size_t bytes) { return MemAlloc((unsigned)bytes, 0, __FILE__, __LINE__); }
inline void __cdecl operator delete (void * ptr) { MemFree(ptr, 0); }
// memcheck-friendly new
inline void * __cdecl operator new (size_t bytes, const char file[], unsigned line) { return MemAlloc((unsigned)bytes, 0, file, line); }
inline void __cdecl operator delete (void * ptr, const char [] , unsigned) { return MemFree(ptr, 0); }
#define TRACKED_NEW new(__FILE__, __LINE__)
// placement new
#ifndef __PLACEMENT_NEW_INLINE
#define __PLACEMENT_NEW_INLINE
inline void * __cdecl operator new (size_t, void * ptr) { return ptr; }
inline void __cdecl operator delete (void *, void *) {}
#endif // ifndef __PLACEMENT_NEW_INLINE
#endif // ifdef __cplusplus
/****************************************************************************
*
* Macros
*
***/
#define ALLOC(b) MemAlloc(b, 0, __FILE__, __LINE__)
#define ALLOCZERO(b) MemAlloc(b, kMemZero, __FILE__, __LINE__)
#define ALLOCFLAGS(b, f) MemAlloc(b, (f), __FILE__, __LINE__)
#define FREE(p) MemFree(p, 0)
#define FREEFLAGS(p, f) MemFree(p, (f))
#define REALLOC(p, b) MemRealloc(p, b, 0, __FILE__, __LINE__)
#define REALLOCFLAGS(p, b, f) MemRealloc(p, b, (f), __FILE__, __LINE__)
#define CALLOC(n, s) MemAlloc((n)*(s), kMemZero, __FILE__, __LINE__)
#define MEMDUP(s, b) MemDup(s, b, 0, __FILE__, __LINE__)
#define ZERO(s) MemSet(&s, 0, sizeof(s))
#define ZEROPTR(p) MemSet(p, 0, sizeof(*p))
// Client must #include <malloc.h>
#define ALLOCA(t, n) (t *)_alloca((n) * sizeof(t))
#ifdef __cplusplus
#define NEW(t) new(MemAlloc(sizeof(t), 0, __FILE__, __LINE__)) t
#define NEWFLAGS(t, f) new(MemAlloc(sizeof(t), (f), __FILE__, __LINE__)) t
#define NEWZERO(t) new(MemAlloc(sizeof(t), kMemZero, __FILE__, __LINE__)) t
#define DEL(t) delete (t)
#endif // __cplusplus
/****************************************************************************
*
* TypeInfo
* (needed for memory leak reporting)
*
***/
#ifdef __cplusplus
#if !defined(HS_NO_TYPEINFO)
#include <typeinfo.h>
#endif
#endif // ifdef __cplusplus
#endif // PLASMA20_SOURCES_PLASMA_CORELIB_HSMALLOC_H

View File

@ -1,113 +1,113 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 "hsMatrix33.h"
#include "hsStream.h"
hsMatrix33* hsMatrix33::Reset()
{
static const hsMatrix33 gIdentity = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
*this = gIdentity;
return this;
}
hsMatrix33* hsMatrix33::SetConcat(const hsMatrix33* a, const hsMatrix33* b)
{
hsMatrix33 tmpMatrix;
hsMatrix33* c;
c = this;
if (this == a || this == b)
c = &tmpMatrix;
c->fMap[0][0] = a->fMap[0][0] * b->fMap[0][0] + a->fMap[0][1] * b->fMap[1][0] + a->fMap[0][2] * b->fMap[2][0];
c->fMap[0][1] = a->fMap[0][0] * b->fMap[0][1] + a->fMap[0][1] * b->fMap[1][1] + a->fMap[0][2] * b->fMap[2][1];
c->fMap[0][2] = a->fMap[0][0] * b->fMap[0][2] + a->fMap[0][1] * b->fMap[1][2] + a->fMap[0][2] * b->fMap[2][2];
c->fMap[1][0] = a->fMap[1][0] * b->fMap[0][0] + a->fMap[1][1] * b->fMap[1][0] + a->fMap[1][2] * b->fMap[2][0];
c->fMap[1][1] = a->fMap[1][0] * b->fMap[0][1] + a->fMap[1][1] * b->fMap[1][1] + a->fMap[1][2] * b->fMap[2][1];
c->fMap[1][2] = a->fMap[1][0] * b->fMap[0][2] + a->fMap[1][1] * b->fMap[1][2] + a->fMap[1][2] * b->fMap[2][2];
c->fMap[2][0] = a->fMap[2][0] * b->fMap[0][0] + a->fMap[2][1] * b->fMap[1][0] + a->fMap[2][2] * b->fMap[2][0];
c->fMap[2][1] = a->fMap[2][0] * b->fMap[0][1] + a->fMap[2][1] * b->fMap[1][1] + a->fMap[2][2] * b->fMap[2][1];
c->fMap[2][2] = a->fMap[2][0] * b->fMap[0][2] + a->fMap[2][1] * b->fMap[1][2] + a->fMap[2][2] * b->fMap[2][2];
if (this != c)
*this = *c;
return this;
}
hsMatrix33 operator*(const hsMatrix33& a, const hsMatrix33& b)
{
hsMatrix33 c;
(void)c.SetConcat(&a, &b);
return c;
}
void hsMatrix33::Read(hsStream* s)
{
int i, j;
for( i = 0; i < 3; i++ )
{
for( j = 0; j < 3; j++ )
{
fMap[i][j] = s->ReadSwapScalar();
}
}
}
void hsMatrix33::Write(hsStream* s)
{
int i, j;
for( i = 0; i < 3; i++ )
{
for( j = 0; j < 3; j++ )
{
s->WriteSwapScalar(fMap[i][j]);
}
}
/*==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 "hsMatrix33.h"
#include "hsStream.h"
hsMatrix33* hsMatrix33::Reset()
{
static const hsMatrix33 gIdentity = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
*this = gIdentity;
return this;
}
hsMatrix33* hsMatrix33::SetConcat(const hsMatrix33* a, const hsMatrix33* b)
{
hsMatrix33 tmpMatrix;
hsMatrix33* c;
c = this;
if (this == a || this == b)
c = &tmpMatrix;
c->fMap[0][0] = a->fMap[0][0] * b->fMap[0][0] + a->fMap[0][1] * b->fMap[1][0] + a->fMap[0][2] * b->fMap[2][0];
c->fMap[0][1] = a->fMap[0][0] * b->fMap[0][1] + a->fMap[0][1] * b->fMap[1][1] + a->fMap[0][2] * b->fMap[2][1];
c->fMap[0][2] = a->fMap[0][0] * b->fMap[0][2] + a->fMap[0][1] * b->fMap[1][2] + a->fMap[0][2] * b->fMap[2][2];
c->fMap[1][0] = a->fMap[1][0] * b->fMap[0][0] + a->fMap[1][1] * b->fMap[1][0] + a->fMap[1][2] * b->fMap[2][0];
c->fMap[1][1] = a->fMap[1][0] * b->fMap[0][1] + a->fMap[1][1] * b->fMap[1][1] + a->fMap[1][2] * b->fMap[2][1];
c->fMap[1][2] = a->fMap[1][0] * b->fMap[0][2] + a->fMap[1][1] * b->fMap[1][2] + a->fMap[1][2] * b->fMap[2][2];
c->fMap[2][0] = a->fMap[2][0] * b->fMap[0][0] + a->fMap[2][1] * b->fMap[1][0] + a->fMap[2][2] * b->fMap[2][0];
c->fMap[2][1] = a->fMap[2][0] * b->fMap[0][1] + a->fMap[2][1] * b->fMap[1][1] + a->fMap[2][2] * b->fMap[2][1];
c->fMap[2][2] = a->fMap[2][0] * b->fMap[0][2] + a->fMap[2][1] * b->fMap[1][2] + a->fMap[2][2] * b->fMap[2][2];
if (this != c)
*this = *c;
return this;
}
hsMatrix33 operator*(const hsMatrix33& a, const hsMatrix33& b)
{
hsMatrix33 c;
(void)c.SetConcat(&a, &b);
return c;
}
void hsMatrix33::Read(hsStream* s)
{
int i, j;
for( i = 0; i < 3; i++ )
{
for( j = 0; j < 3; j++ )
{
fMap[i][j] = s->ReadSwapScalar();
}
}
}
void hsMatrix33::Write(hsStream* s)
{
int i, j;
for( i = 0; i < 3; i++ )
{
for( j = 0; j < 3; j++ )
{
s->WriteSwapScalar(fMap[i][j]);
}
}
}

View File

@ -1,72 +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 hsMatrix33_inc
#define hsMatrix33_inc
class hsStream;
struct hsMatrix33
{
hsScalar fMap[3][3];
hsMatrix33* Reset();
int operator==(const hsMatrix33& aa) const
{
return aa.fMap[0][0] == fMap[0][0] && aa.fMap[0][1] == fMap[0][1] && aa.fMap[0][2] == fMap[0][2] &&
aa.fMap[1][0] == fMap[1][0] && aa.fMap[1][1] == fMap[1][1] && aa.fMap[1][2] == fMap[1][2] &&
aa.fMap[2][0] == fMap[2][0] && aa.fMap[2][1] == fMap[2][1] && aa.fMap[2][2] == fMap[2][2];
}
int operator!=(const hsMatrix33& aa) const
{
return !(aa == *this);
}
hsMatrix33* SetConcat(const hsMatrix33* a, const hsMatrix33* b);
friend hsMatrix33 operator*(const hsMatrix33& a, const hsMatrix33& b);
void Read(hsStream* s);
void Write(hsStream* s);
};
#endif // hsMatrix33_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsMatrix33_inc
#define hsMatrix33_inc
class hsStream;
struct hsMatrix33
{
hsScalar fMap[3][3];
hsMatrix33* Reset();
int operator==(const hsMatrix33& aa) const
{
return aa.fMap[0][0] == fMap[0][0] && aa.fMap[0][1] == fMap[0][1] && aa.fMap[0][2] == fMap[0][2] &&
aa.fMap[1][0] == fMap[1][0] && aa.fMap[1][1] == fMap[1][1] && aa.fMap[1][2] == fMap[1][2] &&
aa.fMap[2][0] == fMap[2][0] && aa.fMap[2][1] == fMap[2][1] && aa.fMap[2][2] == fMap[2][2];
}
int operator!=(const hsMatrix33& aa) const
{
return !(aa == *this);
}
hsMatrix33* SetConcat(const hsMatrix33* a, const hsMatrix33* b);
friend hsMatrix33 operator*(const hsMatrix33& a, const hsMatrix33& b);
void Read(hsStream* s);
void Write(hsStream* s);
};
#endif // hsMatrix33_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,186 +1,186 @@
/*==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 HSMATRIX44_inc
#define HSMATRIX44_inc
#include "hsTypes.h"
#include "hsGeometry3.h"
class hsQuat;
////////////////////////////////////////////////////////////////////////////
class hsStream;
struct hsMatrix44 {
enum {
kIsIdent = 0x1
};
enum {
kRight = 0,
kUp,
kView
};
hsScalar fMap[4][4];
UInt32 fFlags;
hsMatrix44() : fFlags(0) {}
hsMatrix44(const hsScalarTriple &translate, const hsQuat &rotate);
void DecompRigid(hsScalarTriple &translate, hsQuat &rotate) const;
static const hsMatrix44& IdentityMatrix();
// worldToCameras and cameraToWorlds are arrays of 6 matrices. Returned are LEFT,RIGHT,FRONT,BACK,TOP,BOTTOM.
static void MakeEnvMapMatrices(const hsPoint3& pos, hsMatrix44* worldToCameras, hsMatrix44* cameraToWorlds);
static void MakeCameraMatrices(const hsPoint3& from, const hsPoint3& at, const hsVector3& up, hsMatrix44& worldToCamera, hsMatrix44& cameraToWorld);
// Concat transform
hsMatrix44& Translate(const hsVector3 *);
hsMatrix44& Scale(const hsVector3 *);
hsMatrix44& Rotate(int axis, hsScalar radians);
hsMatrix44& Reset(hsBool asIdent=true)
{
fMap[0][0] = 1.0f; fMap[0][1] = 0.0f; fMap[0][2] = 0.0f; fMap[0][3] = 0.0f;
fMap[1][0] = 0.0f; fMap[1][1] = 1.0f; fMap[1][2] = 0.0f; fMap[1][3] = 0.0f;
fMap[2][0] = 0.0f; fMap[2][1] = 0.0f; fMap[2][2] = 1.0f; fMap[2][3] = 0.0f;
fMap[3][0] = 0.0f; fMap[3][1] = 0.0f; fMap[3][2] = 0.0f; fMap[3][3] = 1.0f;
fFlags = asIdent ? kIsIdent : 0;
return *this;
}
// Create matrix from scratch
hsMatrix44& MakeTranslateMat(const hsVector3 *trans);
hsMatrix44& MakeScaleMat(const hsVector3 *scale);
hsMatrix44& MakeRotateMat(int axis, hsScalar radians);
hsMatrix44& Make(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up); // Not a camera matrix
hsMatrix44& MakeUpPreserving(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up); // Not a camera matrix
// Camera matrix
hsMatrix44& MakeCamera(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up);
hsMatrix44& MakeCameraUpPreserving(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up);
hsBool GetParity() const;
hsScalar GetDeterminant() const;
hsMatrix44* GetInverse(hsMatrix44* inverse) const;
hsMatrix44* GetTranspose(hsMatrix44* inverse) const;
hsMatrix44* GetAdjoint(hsMatrix44* adjoint) const;
hsVector3* GetTranslate(hsVector3 *pt) const;
hsPoint3* GetTranslate(hsPoint3 *pt) const
{ return (hsPoint3*)GetTranslate((hsVector3*)pt); }
const hsPoint3 GetTranslate() const;
void GetAxis(hsVector3* view, hsVector3 *up, hsVector3* right);
void GetAxisFromCamera(hsVector3* view, hsVector3 *up, hsVector3* right);
const hsVector3 GetAxis(int i) const;
// Change component of matrix
hsMatrix44& SetTranslate(const hsScalarTriple *);
hsMatrix44& SetScale(const hsVector3 *);
hsMatrix44& SetRotate(int axis, hsScalar radians);
hsVector3 RemoveScale(); // returns old scale
void MakeXRotation(hsScalar radians);
void MakeYRotation(hsScalar radians);
void MakeZRotation(hsScalar radians);
#if 0 // Havok reeks
friend hsPoint3 operator*(const hsMatrix44& m, const hsPoint3& p)
{
if( m.fFlags & hsMatrix44::kIsIdent )
return p;
hsPoint3 rVal;
rVal.fX = hsScalarMul(p.fX, m.fMap[0][0]) + hsScalarMul(p.fY, m.fMap[0][1]) + hsScalarMul(p.fZ, m.fMap[0][2]) + m.fMap[0][3];
rVal.fY = hsScalarMul(p.fX, m.fMap[1][0]) + hsScalarMul(p.fY, m.fMap[1][1]) + hsScalarMul(p.fZ, m.fMap[1][2]) + m.fMap[1][3];
rVal.fZ = hsScalarMul(p.fX, m.fMap[2][0]) + hsScalarMul(p.fY, m.fMap[2][1]) + hsScalarMul(p.fZ, m.fMap[2][2]) + m.fMap[2][3];
return rVal;
}
friend hsVector3 operator*(const hsMatrix44& m, const hsVector3& p);
friend hsMatrix44 operator*(const hsMatrix44& a, const hsMatrix44& b);
#else // Havok reeks
hsPoint3 operator*(const hsPoint3& p) const
{
if( fFlags & hsMatrix44::kIsIdent )
return p;
hsPoint3 rVal;
rVal.fX = hsScalarMul(p.fX, fMap[0][0]) + hsScalarMul(p.fY, fMap[0][1]) + hsScalarMul(p.fZ, fMap[0][2]) + fMap[0][3];
rVal.fY = hsScalarMul(p.fX, fMap[1][0]) + hsScalarMul(p.fY, fMap[1][1]) + hsScalarMul(p.fZ, fMap[1][2]) + fMap[1][3];
rVal.fZ = hsScalarMul(p.fX, fMap[2][0]) + hsScalarMul(p.fY, fMap[2][1]) + hsScalarMul(p.fZ, fMap[2][2]) + fMap[2][3];
return rVal;
}
hsVector3 operator*(const hsVector3& p) const;
hsMatrix44 operator*(const hsMatrix44& b) const;
#endif // Havok reeks
hsPoint3* MapPoints(long count, hsPoint3 points[]) const;
hsBool IsIdentity(void);
void NotIdentity() { fFlags &= ~kIsIdent; }
#if 0 // Havok reeks
friend int operator==(const hsMatrix44& s, const hsMatrix44& t);
friend int operator!=(const hsMatrix44& s, const hsMatrix44& t);
#else // Havok reeks
hsBool operator==(const hsMatrix44& ss) const;
hsBool operator!=(const hsMatrix44& ss) const { return !(ss == *this); }
#endif // Havok reeks
void Read(hsStream *stream);
void Write(hsStream *stream);
} ATTRIBUTE_FOR_PS2; /* SUNSOFT */
#if 0 // Havok reeks
inline int operator!=(const hsMatrix44& s, const hsMatrix44& t)
{
return (!(s==t));
}
#endif // Havok reeks
////////////////////////////////////////////////////////////////////////////
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 HSMATRIX44_inc
#define HSMATRIX44_inc
#include "hsTypes.h"
#include "hsGeometry3.h"
class hsQuat;
////////////////////////////////////////////////////////////////////////////
class hsStream;
struct hsMatrix44 {
enum {
kIsIdent = 0x1
};
enum {
kRight = 0,
kUp,
kView
};
hsScalar fMap[4][4];
UInt32 fFlags;
hsMatrix44() : fFlags(0) {}
hsMatrix44(const hsScalarTriple &translate, const hsQuat &rotate);
void DecompRigid(hsScalarTriple &translate, hsQuat &rotate) const;
static const hsMatrix44& IdentityMatrix();
// worldToCameras and cameraToWorlds are arrays of 6 matrices. Returned are LEFT,RIGHT,FRONT,BACK,TOP,BOTTOM.
static void MakeEnvMapMatrices(const hsPoint3& pos, hsMatrix44* worldToCameras, hsMatrix44* cameraToWorlds);
static void MakeCameraMatrices(const hsPoint3& from, const hsPoint3& at, const hsVector3& up, hsMatrix44& worldToCamera, hsMatrix44& cameraToWorld);
// Concat transform
hsMatrix44& Translate(const hsVector3 *);
hsMatrix44& Scale(const hsVector3 *);
hsMatrix44& Rotate(int axis, hsScalar radians);
hsMatrix44& Reset(hsBool asIdent=true)
{
fMap[0][0] = 1.0f; fMap[0][1] = 0.0f; fMap[0][2] = 0.0f; fMap[0][3] = 0.0f;
fMap[1][0] = 0.0f; fMap[1][1] = 1.0f; fMap[1][2] = 0.0f; fMap[1][3] = 0.0f;
fMap[2][0] = 0.0f; fMap[2][1] = 0.0f; fMap[2][2] = 1.0f; fMap[2][3] = 0.0f;
fMap[3][0] = 0.0f; fMap[3][1] = 0.0f; fMap[3][2] = 0.0f; fMap[3][3] = 1.0f;
fFlags = asIdent ? kIsIdent : 0;
return *this;
}
// Create matrix from scratch
hsMatrix44& MakeTranslateMat(const hsVector3 *trans);
hsMatrix44& MakeScaleMat(const hsVector3 *scale);
hsMatrix44& MakeRotateMat(int axis, hsScalar radians);
hsMatrix44& Make(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up); // Not a camera matrix
hsMatrix44& MakeUpPreserving(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up); // Not a camera matrix
// Camera matrix
hsMatrix44& MakeCamera(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up);
hsMatrix44& MakeCameraUpPreserving(const hsPoint3* from, const hsPoint3* at,
const hsVector3* up);
hsBool GetParity() const;
hsScalar GetDeterminant() const;
hsMatrix44* GetInverse(hsMatrix44* inverse) const;
hsMatrix44* GetTranspose(hsMatrix44* inverse) const;
hsMatrix44* GetAdjoint(hsMatrix44* adjoint) const;
hsVector3* GetTranslate(hsVector3 *pt) const;
hsPoint3* GetTranslate(hsPoint3 *pt) const
{ return (hsPoint3*)GetTranslate((hsVector3*)pt); }
const hsPoint3 GetTranslate() const;
void GetAxis(hsVector3* view, hsVector3 *up, hsVector3* right);
void GetAxisFromCamera(hsVector3* view, hsVector3 *up, hsVector3* right);
const hsVector3 GetAxis(int i) const;
// Change component of matrix
hsMatrix44& SetTranslate(const hsScalarTriple *);
hsMatrix44& SetScale(const hsVector3 *);
hsMatrix44& SetRotate(int axis, hsScalar radians);
hsVector3 RemoveScale(); // returns old scale
void MakeXRotation(hsScalar radians);
void MakeYRotation(hsScalar radians);
void MakeZRotation(hsScalar radians);
#if 0 // Havok reeks
friend hsPoint3 operator*(const hsMatrix44& m, const hsPoint3& p)
{
if( m.fFlags & hsMatrix44::kIsIdent )
return p;
hsPoint3 rVal;
rVal.fX = hsScalarMul(p.fX, m.fMap[0][0]) + hsScalarMul(p.fY, m.fMap[0][1]) + hsScalarMul(p.fZ, m.fMap[0][2]) + m.fMap[0][3];
rVal.fY = hsScalarMul(p.fX, m.fMap[1][0]) + hsScalarMul(p.fY, m.fMap[1][1]) + hsScalarMul(p.fZ, m.fMap[1][2]) + m.fMap[1][3];
rVal.fZ = hsScalarMul(p.fX, m.fMap[2][0]) + hsScalarMul(p.fY, m.fMap[2][1]) + hsScalarMul(p.fZ, m.fMap[2][2]) + m.fMap[2][3];
return rVal;
}
friend hsVector3 operator*(const hsMatrix44& m, const hsVector3& p);
friend hsMatrix44 operator*(const hsMatrix44& a, const hsMatrix44& b);
#else // Havok reeks
hsPoint3 operator*(const hsPoint3& p) const
{
if( fFlags & hsMatrix44::kIsIdent )
return p;
hsPoint3 rVal;
rVal.fX = hsScalarMul(p.fX, fMap[0][0]) + hsScalarMul(p.fY, fMap[0][1]) + hsScalarMul(p.fZ, fMap[0][2]) + fMap[0][3];
rVal.fY = hsScalarMul(p.fX, fMap[1][0]) + hsScalarMul(p.fY, fMap[1][1]) + hsScalarMul(p.fZ, fMap[1][2]) + fMap[1][3];
rVal.fZ = hsScalarMul(p.fX, fMap[2][0]) + hsScalarMul(p.fY, fMap[2][1]) + hsScalarMul(p.fZ, fMap[2][2]) + fMap[2][3];
return rVal;
}
hsVector3 operator*(const hsVector3& p) const;
hsMatrix44 operator*(const hsMatrix44& b) const;
#endif // Havok reeks
hsPoint3* MapPoints(long count, hsPoint3 points[]) const;
hsBool IsIdentity(void);
void NotIdentity() { fFlags &= ~kIsIdent; }
#if 0 // Havok reeks
friend int operator==(const hsMatrix44& s, const hsMatrix44& t);
friend int operator!=(const hsMatrix44& s, const hsMatrix44& t);
#else // Havok reeks
hsBool operator==(const hsMatrix44& ss) const;
hsBool operator!=(const hsMatrix44& ss) const { return !(ss == *this); }
#endif // Havok reeks
void Read(hsStream *stream);
void Write(hsStream *stream);
} ATTRIBUTE_FOR_PS2; /* SUNSOFT */
#if 0 // Havok reeks
inline int operator!=(const hsMatrix44& s, const hsMatrix44& t)
{
return (!(s==t));
}
#endif // Havok reeks
////////////////////////////////////////////////////////////////////////////
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,251 +1,251 @@
/*==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 hsMemoryDefined
#define hsMemoryDefined
#include "hsTypes.h"
//#include "hsTemplates.h"
class HSMemory {
public:
#if HS_BUILD_FOR_MAC
static void BlockMove(const void* src, void* dst, UInt32 length);
#else
static void BlockMove(const void* src, void* dst, UInt32 length);
#endif
static void Clear(void *m, UInt32 byteLen);
static void ClearMemory(void *m, UInt32 byteLen) { HSMemory::Clear(m, byteLen); }
static hsBool EqualBlocks(const void* block1, const void* block2, UInt32 length);
static void* New(UInt32 size);
static void Delete(void* block);
static void* Copy(UInt32 length, const void* source);
static void* SoftNew(UInt32 size); // returns nil if can't allocate
};
///////////////////////////////////////////////////////////////////////////////////////////
class hsAllocator {
public:
virtual void* Alloc(UInt32 size) = 0;
virtual void Free(void* addr) = 0;
};
class hsScratchMem {
enum {
kBufferSize = 32
};
UInt8* fMem;
UInt8 fMemBuffer[kBufferSize];
UInt32 fLength;
public:
hsScratchMem() : fLength(kBufferSize)
{
fMem = fMemBuffer;
}
~hsScratchMem()
{
if (fMem != fMemBuffer)
delete[] fMem;
}
UInt8* GetMem(UInt32 length)
{
if (length > fLength)
{ if (fMem != fMemBuffer)
delete[] fMem;
fMem = TRACKED_NEW UInt8[length];
fLength = length;
}
return fMem;
}
};
class hsChunkAllocator {
enum {
kDefaultChunkSize = 4096
};
UInt32 fChunkSize;
struct hsPrivateChunk* fChunk;
hsDebugCode(UInt32 fChunkCount;)
public:
hsChunkAllocator(UInt32 chunkSize = kDefaultChunkSize);
~hsChunkAllocator();
void Reset();
void SetChunkSize(UInt32 size);
void* Allocate(UInt32 size, const void* data = nil); // throws if fails
void* SoftAllocate(UInt32 size, const void* data = nil); // returns nil if fails
};
///////////////////////////////////////////////////////////////////////////////////////////
class hsAppender {
struct hsAppenderHead* fFirstBlock, *fLastBlock;
UInt32 fElemSize, fElemCount, fCount;
friend class hsAppenderIterator;
public:
hsAppender(UInt32 elemSize, UInt32 minCount = 16);
~hsAppender();
UInt32 ElemSize() const { return fElemSize; }
UInt32 Count() const { return fCount; }
hsBool IsEmpty() const { return fCount == 0; }
void Reset();
UInt32 CopyInto(void* data = nil) const; // return size of data array in bytes
void* PushHead();
void PushHead(const void* data);
void* PushTail();
void PushTail(const void* data);
void PushTail(int count, const void* data); // data[] = count * fElemSize
void* PeekHead() const;
void* PeekTail() const;
hsBool PopHead(void* data = nil);
int PopHead(int count, void* data = nil); // data[] = count * fElemSize
hsBool PopTail(void* data = nil);
// Alternate interfaces
void* Prepend() { return this->PushHead(); }
void* Append() { return this->PushTail(); }
void* Push() { return this->PushHead(); }
void Push(const void* data) { this->PushHead(data); }
hsBool Pop(void* data = nil) { return this->PopHead(data); }
void* Enqueue() { return this->PushTail(); };
void Enqueue(const void* data) { this->PushTail(data); }
void Enqueue(int count, const void* data) { this->PushTail(count, data); }
hsBool Dequeue(void* data = nil) { return this->PopHead(data); }
int Dequeue(int count, void* data = nil) { return this->PopHead(count, data); }
};
class hsAppenderIterator {
const hsAppender* fAppender;
const struct hsAppenderHead* fCurrBlock;
void* fCurrItem;
public:
hsAppenderIterator(const hsAppender* list = nil);
void ResetToHead(const hsAppender* list = nil);
void ResetToTail(const hsAppender* list = nil);
void* Next();
hsBool Next(void* data);
int Next(int count, void* data);
void* Prev();
hsBool Prev(void* data);
// Obsolete interface
void Reset(const hsAppender* list = nil) { this->ResetToHead(list); }
};
///////////////////////////////////////////////////////////////////////////////
template <class T> class hsTAppender : hsAppender {
public:
hsTAppender() : hsAppender(sizeof(T)) {}
hsTAppender(UInt32 minCount) : hsAppender(sizeof(T), minCount) {}
hsAppender* GetAppender() { return this; }
const hsAppender* GetAppender() const { return this; }
UInt32 Count() const { return hsAppender::Count(); }
hsBool IsEmpty() const { return hsAppender::IsEmpty(); }
void Reset() { hsAppender::Reset(); }
UInt32 CopyInto(T copy[]) const { return hsAppender::CopyInto(copy); }
T* PushHead() { return (T*)hsAppender::PushHead(); }
void PushHead(const T& item) { *this->PushHead() = item; }
T* PushTail() { return (T*)hsAppender::PushTail(); }
void PushTail(const T& item) { *this->PushTail() = item; };
void PushTail(int count, const T item[]) { this->hsAppender::PushTail(count, item); };
T* PeekHead() const { return (T*)hsAppender::PeekHead(); }
T* PeekTail() const { return (T*)hsAppender::PeekTail(); }
hsBool PopHead(T* item = nil) { return hsAppender::PopHead(item); }
int PopHead(int count, T item[] = nil) { return hsAppender::PopHead(count, item); }
hsBool PopTail(T* item = nil) { return hsAppender::PopTail(item); }
// Alternate intefaces
T* Prepend() { return this->PushHead(); }
T* Append() { return this->PushTail(); }
void PrependItem(const T& item) { this->PushHead(item); }
void AppendItem(const T& item) { this->PushTail(item); }
T* Push() { return this->PushHead(); }
void Push(const T& item) { this->PushHead(item); }
hsBool Pop(T* item = nil) { return this->PopHead(item); }
T* Enqueue() { return this->PushTail(); };
void Enqueue(const T& item) { this->PushTail(item); }
void Enqueue(int count, const T item[]) { this->PushTail(count, item); }
hsBool Dequeue(T* item = nil) { return this->PopHead(item); }
int Dequeue(int count, T item[] = nil) { return this->PopHead(count, item); }
};
template <class T> class hsTAppenderIterator : hsAppenderIterator {
public:
hsTAppenderIterator() : hsAppenderIterator() {}
hsTAppenderIterator(const hsTAppender<T>* list) : hsAppenderIterator(list->GetAppender()) {}
void ResetToHead() { hsAppenderIterator::ResetToHead(nil); }
void ResetToHead(const hsTAppender<T>* list) { hsAppenderIterator::ResetToHead(list->GetAppender()); }
void ResetToTail() { hsAppenderIterator::ResetToTail(nil); }
void ResetToTail(const hsTAppender<T>* list) { hsAppenderIterator::ResetToTail(list->GetAppender()); }
T* Next() { return (T*)hsAppenderIterator::Next(); }
hsBool Next(T* item) { return hsAppenderIterator::Next(item); }
T* Prev() { return (T*)hsAppenderIterator::Prev(); }
hsBool Prev(T* item) { return hsAppenderIterator::Prev(item); }
// Obsolete interfaces
void Reset() { this->ResetToHead(); }
void Reset(const hsTAppender<T>* list) { this->ResetToHead(list); }
};
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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 hsMemoryDefined
#define hsMemoryDefined
#include "hsTypes.h"
//#include "hsTemplates.h"
class HSMemory {
public:
#if HS_BUILD_FOR_MAC
static void BlockMove(const void* src, void* dst, UInt32 length);
#else
static void BlockMove(const void* src, void* dst, UInt32 length);
#endif
static void Clear(void *m, UInt32 byteLen);
static void ClearMemory(void *m, UInt32 byteLen) { HSMemory::Clear(m, byteLen); }
static hsBool EqualBlocks(const void* block1, const void* block2, UInt32 length);
static void* New(UInt32 size);
static void Delete(void* block);
static void* Copy(UInt32 length, const void* source);
static void* SoftNew(UInt32 size); // returns nil if can't allocate
};
///////////////////////////////////////////////////////////////////////////////////////////
class hsAllocator {
public:
virtual void* Alloc(UInt32 size) = 0;
virtual void Free(void* addr) = 0;
};
class hsScratchMem {
enum {
kBufferSize = 32
};
UInt8* fMem;
UInt8 fMemBuffer[kBufferSize];
UInt32 fLength;
public:
hsScratchMem() : fLength(kBufferSize)
{
fMem = fMemBuffer;
}
~hsScratchMem()
{
if (fMem != fMemBuffer)
delete[] fMem;
}
UInt8* GetMem(UInt32 length)
{
if (length > fLength)
{ if (fMem != fMemBuffer)
delete[] fMem;
fMem = TRACKED_NEW UInt8[length];
fLength = length;
}
return fMem;
}
};
class hsChunkAllocator {
enum {
kDefaultChunkSize = 4096
};
UInt32 fChunkSize;
struct hsPrivateChunk* fChunk;
hsDebugCode(UInt32 fChunkCount;)
public:
hsChunkAllocator(UInt32 chunkSize = kDefaultChunkSize);
~hsChunkAllocator();
void Reset();
void SetChunkSize(UInt32 size);
void* Allocate(UInt32 size, const void* data = nil); // throws if fails
void* SoftAllocate(UInt32 size, const void* data = nil); // returns nil if fails
};
///////////////////////////////////////////////////////////////////////////////////////////
class hsAppender {
struct hsAppenderHead* fFirstBlock, *fLastBlock;
UInt32 fElemSize, fElemCount, fCount;
friend class hsAppenderIterator;
public:
hsAppender(UInt32 elemSize, UInt32 minCount = 16);
~hsAppender();
UInt32 ElemSize() const { return fElemSize; }
UInt32 Count() const { return fCount; }
hsBool IsEmpty() const { return fCount == 0; }
void Reset();
UInt32 CopyInto(void* data = nil) const; // return size of data array in bytes
void* PushHead();
void PushHead(const void* data);
void* PushTail();
void PushTail(const void* data);
void PushTail(int count, const void* data); // data[] = count * fElemSize
void* PeekHead() const;
void* PeekTail() const;
hsBool PopHead(void* data = nil);
int PopHead(int count, void* data = nil); // data[] = count * fElemSize
hsBool PopTail(void* data = nil);
// Alternate interfaces
void* Prepend() { return this->PushHead(); }
void* Append() { return this->PushTail(); }
void* Push() { return this->PushHead(); }
void Push(const void* data) { this->PushHead(data); }
hsBool Pop(void* data = nil) { return this->PopHead(data); }
void* Enqueue() { return this->PushTail(); };
void Enqueue(const void* data) { this->PushTail(data); }
void Enqueue(int count, const void* data) { this->PushTail(count, data); }
hsBool Dequeue(void* data = nil) { return this->PopHead(data); }
int Dequeue(int count, void* data = nil) { return this->PopHead(count, data); }
};
class hsAppenderIterator {
const hsAppender* fAppender;
const struct hsAppenderHead* fCurrBlock;
void* fCurrItem;
public:
hsAppenderIterator(const hsAppender* list = nil);
void ResetToHead(const hsAppender* list = nil);
void ResetToTail(const hsAppender* list = nil);
void* Next();
hsBool Next(void* data);
int Next(int count, void* data);
void* Prev();
hsBool Prev(void* data);
// Obsolete interface
void Reset(const hsAppender* list = nil) { this->ResetToHead(list); }
};
///////////////////////////////////////////////////////////////////////////////
template <class T> class hsTAppender : hsAppender {
public:
hsTAppender() : hsAppender(sizeof(T)) {}
hsTAppender(UInt32 minCount) : hsAppender(sizeof(T), minCount) {}
hsAppender* GetAppender() { return this; }
const hsAppender* GetAppender() const { return this; }
UInt32 Count() const { return hsAppender::Count(); }
hsBool IsEmpty() const { return hsAppender::IsEmpty(); }
void Reset() { hsAppender::Reset(); }
UInt32 CopyInto(T copy[]) const { return hsAppender::CopyInto(copy); }
T* PushHead() { return (T*)hsAppender::PushHead(); }
void PushHead(const T& item) { *this->PushHead() = item; }
T* PushTail() { return (T*)hsAppender::PushTail(); }
void PushTail(const T& item) { *this->PushTail() = item; };
void PushTail(int count, const T item[]) { this->hsAppender::PushTail(count, item); };
T* PeekHead() const { return (T*)hsAppender::PeekHead(); }
T* PeekTail() const { return (T*)hsAppender::PeekTail(); }
hsBool PopHead(T* item = nil) { return hsAppender::PopHead(item); }
int PopHead(int count, T item[] = nil) { return hsAppender::PopHead(count, item); }
hsBool PopTail(T* item = nil) { return hsAppender::PopTail(item); }
// Alternate intefaces
T* Prepend() { return this->PushHead(); }
T* Append() { return this->PushTail(); }
void PrependItem(const T& item) { this->PushHead(item); }
void AppendItem(const T& item) { this->PushTail(item); }
T* Push() { return this->PushHead(); }
void Push(const T& item) { this->PushHead(item); }
hsBool Pop(T* item = nil) { return this->PopHead(item); }
T* Enqueue() { return this->PushTail(); };
void Enqueue(const T& item) { this->PushTail(item); }
void Enqueue(int count, const T item[]) { this->PushTail(count, item); }
hsBool Dequeue(T* item = nil) { return this->PopHead(item); }
int Dequeue(int count, T item[] = nil) { return this->PopHead(count, item); }
};
template <class T> class hsTAppenderIterator : hsAppenderIterator {
public:
hsTAppenderIterator() : hsAppenderIterator() {}
hsTAppenderIterator(const hsTAppender<T>* list) : hsAppenderIterator(list->GetAppender()) {}
void ResetToHead() { hsAppenderIterator::ResetToHead(nil); }
void ResetToHead(const hsTAppender<T>* list) { hsAppenderIterator::ResetToHead(list->GetAppender()); }
void ResetToTail() { hsAppenderIterator::ResetToTail(nil); }
void ResetToTail(const hsTAppender<T>* list) { hsAppenderIterator::ResetToTail(list->GetAppender()); }
T* Next() { return (T*)hsAppenderIterator::Next(); }
hsBool Next(T* item) { return hsAppenderIterator::Next(item); }
T* Prev() { return (T*)hsAppenderIterator::Prev(); }
hsBool Prev(T* item) { return hsAppenderIterator::Prev(item); }
// Obsolete interfaces
void Reset() { this->ResetToHead(); }
void Reset(const hsTAppender<T>* list) { this->ResetToHead(list); }
};
#endif

View File

@ -1,137 +1,137 @@
/*==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 hsPoint2_Defined
#define hsPoint2_Defined
#include "hsScalar.h"
#if __MWERKS__
// This guy disables MetroWerks' desire to only include a file once, which obviously gets
// in the way of our little HS_POINT2.inc trick
#pragma once off
#endif
#define HS_POINT2_NAME hsIntPoint2
#define HS_POINT2_TYPE Int32
#include "HS_POINT2.inc"
};
#define HS_POINT2_NAME hsFixedPoint2
#define HS_POINT2_TYPE hsFixed
#include "HS_POINT2.inc"
hsFixedPoint2& operator=(const hsIntPoint2& src)
{
this->fX = hsIntToFixed(src.fX);
this->fY = hsIntToFixed(src.fY);
return *this;
}
hsFixed Magnitude() const { return hsMagnitude32(fX, fY); }
static hsFixed Magnitude(hsFixed x, hsFixed y)
{
return hsMagnitude32(x, y);
}
static hsFixed Distance(const hsFixedPoint2& p1, const hsFixedPoint2& p2)
{
return hsMagnitude32(p2.fX - p1.fX, p2.fY - p1.fY);
}
};
#if HS_CAN_USE_FLOAT
struct hsPolar {
float fRadius;
float fAngle;
};
#define HS_POINT2_NAME hsFloatPoint2
#define HS_POINT2_TYPE float
#include "HS_POINT2.inc"
hsFloatPoint2& operator=(const hsIntPoint2& src)
{
this->fX = float(src.fX);
this->fY = float(src.fY);
return *this;
}
friend hsFloatPoint2 operator*(const hsFloatPoint2& s, float t)
{
hsFloatPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
friend hsFloatPoint2 operator*(float t, const hsFloatPoint2& s)
{
hsFloatPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
hsFloatPoint2* Grid(float period);
hsBool CloseEnough(const hsFloatPoint2* p, float tolerance) const;
float Magnitude() const { return hsFloatPoint2::Magnitude(fX, fY); }
float MagnitudeSquared() const { return fX * fX + fY * fY; }
hsPolar* ToPolar(hsPolar* polar) const;
static float Magnitude(float x, float y) { return hsSquareRoot(x * x + y * y); }
static hsScalar Distance(const hsFloatPoint2& p1, const hsFloatPoint2& p2);
static hsFloatPoint2 Average(const hsFloatPoint2& a, const hsFloatPoint2& b)
{
hsFloatPoint2 result;
result.Set((a.fX + b.fX) * float(0.5), (a.fY + b.fY) * float(0.5));
return result;
}
static hsScalar ComputeAngle(const hsFloatPoint2& a, const hsFloatPoint2& b, const hsFloatPoint2& c);
};
#endif
#if HS_SCALAR_IS_FIXED
typedef hsFixedPoint2 hsPoint2;
#else
typedef hsFloatPoint2 hsPoint2;
#endif
#endif // hsPoint2_Defined
/*==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 hsPoint2_Defined
#define hsPoint2_Defined
#include "hsScalar.h"
#if __MWERKS__
// This guy disables MetroWerks' desire to only include a file once, which obviously gets
// in the way of our little HS_POINT2.inc trick
#pragma once off
#endif
#define HS_POINT2_NAME hsIntPoint2
#define HS_POINT2_TYPE Int32
#include "HS_POINT2.inc"
};
#define HS_POINT2_NAME hsFixedPoint2
#define HS_POINT2_TYPE hsFixed
#include "HS_POINT2.inc"
hsFixedPoint2& operator=(const hsIntPoint2& src)
{
this->fX = hsIntToFixed(src.fX);
this->fY = hsIntToFixed(src.fY);
return *this;
}
hsFixed Magnitude() const { return hsMagnitude32(fX, fY); }
static hsFixed Magnitude(hsFixed x, hsFixed y)
{
return hsMagnitude32(x, y);
}
static hsFixed Distance(const hsFixedPoint2& p1, const hsFixedPoint2& p2)
{
return hsMagnitude32(p2.fX - p1.fX, p2.fY - p1.fY);
}
};
#if HS_CAN_USE_FLOAT
struct hsPolar {
float fRadius;
float fAngle;
};
#define HS_POINT2_NAME hsFloatPoint2
#define HS_POINT2_TYPE float
#include "HS_POINT2.inc"
hsFloatPoint2& operator=(const hsIntPoint2& src)
{
this->fX = float(src.fX);
this->fY = float(src.fY);
return *this;
}
friend hsFloatPoint2 operator*(const hsFloatPoint2& s, float t)
{
hsFloatPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
friend hsFloatPoint2 operator*(float t, const hsFloatPoint2& s)
{
hsFloatPoint2 result;
result.Set(s.fX * t, s.fY * t);
return result;
}
hsFloatPoint2* Grid(float period);
hsBool CloseEnough(const hsFloatPoint2* p, float tolerance) const;
float Magnitude() const { return hsFloatPoint2::Magnitude(fX, fY); }
float MagnitudeSquared() const { return fX * fX + fY * fY; }
hsPolar* ToPolar(hsPolar* polar) const;
static float Magnitude(float x, float y) { return hsSquareRoot(x * x + y * y); }
static hsScalar Distance(const hsFloatPoint2& p1, const hsFloatPoint2& p2);
static hsFloatPoint2 Average(const hsFloatPoint2& a, const hsFloatPoint2& b)
{
hsFloatPoint2 result;
result.Set((a.fX + b.fX) * float(0.5), (a.fY + b.fY) * float(0.5));
return result;
}
static hsScalar ComputeAngle(const hsFloatPoint2& a, const hsFloatPoint2& b, const hsFloatPoint2& c);
};
#endif
#if HS_SCALAR_IS_FIXED
typedef hsFixedPoint2 hsPoint2;
#else
typedef hsFloatPoint2 hsPoint2;
#endif
#endif // hsPoint2_Defined

View File

@ -1,427 +1,427 @@
/*==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 "HeadSpin.h"
#include "hsQuat.h"
#include "hsMatrix44.h"
#include "hsStream.h"
#include "hsFastMath.h"
//
// Quaternion class.
// For conversion to and from euler angles, see hsEuler.cpp,h.
//
//
// Construct quat from angle (in radians) and axis of rotation
//
hsQuat::hsQuat(hsScalar rad, const hsVector3* axis)
{
// hsAssert(rad >= -hsScalarPI && rad <= hsScalarPI, "Quat: Angle should be between -PI and PI");
fW = hsCosine(rad*0.5f);
hsScalar s = hsSine(rad*0.5f);
fX = axis->fX*s;
fY = axis->fY*s;
fZ = axis->fZ*s;
}
hsQuat hsQuat::Inverse() const
{
hsQuat q2 = Conjugate();
hsScalar msInv = 1.0f/q2.MagnitudeSquared();
return (q2 * msInv);
}
hsPoint3 hsQuat::Rotate(const hsScalarTriple* v) const
{
hsQuat qInv = Inverse();
hsQuat qVec(v->fX, v->fY, v->fZ, 0);
hsQuat t = qInv * qVec;
hsQuat res = (t * (*this));
//hsAssert(hsABS(res.fW)<1e-5, "Error rotating vector");
return hsPoint3(res.fX, res.fY, res.fZ);
}
void hsQuat::SetAngleAxis(const hsScalar rad, const hsVector3 &axis)
{
fW = hsCosine(rad*0.5f);
hsScalar s = hsSine(rad*0.5f);
fX = axis.fX*s;
fY = axis.fY*s;
fZ = axis.fZ*s;
}
//
// Might want to Normalize before calling this
//
void hsQuat::GetAngleAxis(hsScalar *rad, hsVector3 *axis) const
{
hsAssert((fW >= -1) && (fW <= 1), "Invalid acos argument");
hsScalar ac = hsACosine(fW);
*rad = 2.0f * ac;
hsScalar s = hsSine(ac);
if (s != 0.0f)
{
hsScalar invS = 1.0f/s;
axis->Set(fX*invS, fY*invS, fZ*invS);
}
else
axis->Set(0,0,0);
}
//
//
//
hsScalar hsQuat::MagnitudeSquared()
{
return (fX*fX + fY*fY + fZ*fZ + fW*fW);
}
//
//
//
hsScalar hsQuat::Magnitude()
{
return hsSquareRoot(MagnitudeSquared());
}
//
//
//
void hsQuat::Normalize()
{
hsScalar invMag = 1.0f/Magnitude();
fX *= invMag;
fY *= invMag;
fZ *= invMag;
fW *= invMag;
}
//
//
//
void hsQuat::NormalizeIfNeeded()
{
hsScalar magSquared = MagnitudeSquared();
if (magSquared == 1.0f)
return;
hsScalar invMag = 1.0f/hsSquareRoot(magSquared);
fX *= invMag;
fY *= invMag;
fZ *= invMag;
fW *= invMag;
}
//
// This is for a RHS.
// The quat should be normalized first.
//
void hsQuat::MakeMatrix(hsMatrix44 *mat) const
{
// mf horse - this is transpose of both what
// Gems says and what i'm expecting to come
// out of it, so i'm flipping it.
mat->fMap[0][0] = 1.0f - 2.0f*fY*fY - 2.0f*fZ*fZ;
mat->fMap[0][1] = 2.0f*fX*fY - 2.0f*fW*fZ;
mat->fMap[0][2] = 2.0f*fX*fZ + 2.0f*fW*fY;
mat->fMap[0][3] = 0.0f;
mat->fMap[1][0] = 2.0f*fX*fY + 2.0f*fW*fZ;
mat->fMap[1][1] = 1.0f - 2.0f*fX*fX - 2.0f*fZ*fZ;
mat->fMap[1][2] = 2.0f*fY*fZ - 2.0f*fW*fX;
mat->fMap[1][3] = 0.0f;
mat->fMap[2][0] = 2.0f*fX*fZ - 2.0f*fW*fY;
mat->fMap[2][1] = 2.0f*fY*fZ + 2.0f*fW*fX;
mat->fMap[2][2] = 1.0f - 2.0f*fX*fX - 2.0f*fY*fY;
mat->fMap[2][3] = 0.0f;
mat->fMap[3][0] = 0.0f;
mat->fMap[3][1] = 0.0f;
mat->fMap[3][2] = 0.0f;
mat->fMap[3][3] = 1.0f;
#if 0
mat->fMap[0][0] = fW*fW + fX*fX - fY*fY - fZ*fZ;
mat->fMap[1][0] = 2.0f*fX*fY - 2.0f*fW*fZ;
mat->fMap[2][0] = 2.0f*fX*fZ + 2.0f*fW*fY;
mat->fMap[3][0] = 0.0f;
mat->fMap[0][1] = 2.0f*fX*fY + 2.0f*fW*fZ;
mat->fMap[1][1] = fW*fW - fX*fX + fY*fY - fZ*fZ;
mat->fMap[2][1] = 2.0f*fY*fZ - 2.0f*fW*fX;
mat->fMap[3][1] = 0.0f;
mat->fMap[0][2] = 2.0f*fX*fZ - 2.0f*fW*fY;
mat->fMap[1][2] = 2.0f*fY*fZ + 2.0f*fW*fX;
mat->fMap[2][2] = fW*fW - fX*fX - fY*fY + fZ*fZ;
mat->fMap[3][2] = 0.0f;
mat->fMap[0][3] = 0.0f;
mat->fMap[1][3] = 0.0f;
mat->fMap[2][3] = 0.0f;
mat->fMap[3][3] = fW*fW + fX*fX + fY*fY + fZ*fZ;
#endif
mat->NotIdentity();
}
// Binary operators
hsQuat hsQuat::operator-(const hsQuat &in) const
{
return hsQuat(fX-in.fX, fY-in.fY, fZ-in.fZ, fW-in.fW);
}
hsQuat hsQuat::operator+(const hsQuat &in) const
{
return hsQuat(fX+in.fX, fY+in.fY, fZ+in.fZ, fW+in.fW);
}
//
// Return quaternion product (this * in). Note: order is important!
// To combine rotations, use the product (qSecond * qFirst),
// which gives the effect of rotating by qFirst then qSecond.
//
hsQuat hsQuat::operator*(const hsQuat &in) const
{
hsQuat ret;
ret.fW = (fW*in.fW - fX*in.fX - fY*in.fY - fZ*in.fZ);
ret.fX = (fY*in.fZ - in.fY*fZ + fW*in.fX + in.fW*fX);
ret.fY = (fZ*in.fX - in.fZ*fX + fW*in.fY + in.fW*fY);
ret.fZ = (fX*in.fY - in.fX*fY + fW*in.fZ + in.fW*fZ);
return ret;
}
// I/O
void hsQuat::Read(hsStream *stream)
{
fX = stream->ReadSwapFloat();
fY = stream->ReadSwapFloat();
fZ = stream->ReadSwapFloat();
fW = stream->ReadSwapFloat();
}
void hsQuat::Write(hsStream *stream)
{
stream->WriteSwapFloat(fX);
stream->WriteSwapFloat(fY);
stream->WriteSwapFloat(fZ);
stream->WriteSwapFloat(fW);
}
#if 0
//
// Interpolate on a sphere.
//
void hsQuat::SetFromSlerp(hsQuat *q1, hsQuat *q2, hsScalar t)
{
hsAssert(t>=0.0 && t<= 1.0, "Quat slerp param must be between 0 an 1");
hsScalar theta = hsACosine(q1->Dot(*q2));
hsScalar st = hsSine(theta);
assert(st != 0.0);
hsScalar s1 = hsSine(1.0-t)*theta / st;
hsScalar s2 = hsSine(t)*theta / st;
*this = (*q1) * s1 + (*q2) * s2;
}
#else
/*
* Spherical linear interpolation of unit quaternions with spins
*/
#define EPSILON 1.0E-6 /* a tiny number */
void hsQuat::SetFromSlerp(const hsQuat &a, const hsQuat &b, hsScalar alpha, int spin)
// double alpha; /* interpolation parameter (0 to 1) */
// Quaternion *a, *b; /* start and end unit quaternions */
// int spin; /* number of extra spin rotations */
{
hsScalar beta; /* complementary interp parameter */
hsScalar theta; /* angle between A and B */
hsScalar sin_t, cos_t; /* sine, cosine of theta */
hsScalar phi; /* theta plus spins */
int bflip; /* use negation of B? */
/* cosine theta = dot product of A and B */
cos_t = a.Dot(b);
/* if B is on opposite hemisphere from A, use -B instead */
if (cos_t < 0.0)
{
cos_t = -cos_t;
bflip = true;
}
else
bflip = false;
/* if B is (within precision limits) the same as A,
* just linear interpolate between A and B.
* Can't do spins, since we don't know what direction to spin.
*/
if (1.0 - cos_t < EPSILON)
{
beta = 1.0f - alpha;
} else
{ /* normal case */
// hsAssert((cos_t >= -1) && (cos_t <= 1), "Invalid acos argument");
theta = hsACosine(cos_t);
phi = theta + spin * hsScalarPI;
sin_t = hsSine(theta);
hsAssert(sin_t != 0.0, "Invalid sin value in quat slerp");
beta = hsSine(theta - alpha*phi) / sin_t;
alpha = hsSine(alpha*phi) / sin_t;
}
if (bflip)
alpha = -alpha;
/* interpolate */
fX = beta*a.fX + alpha*b.fX;
fY = beta*a.fY + alpha*b.fY;
fZ = beta*a.fZ + alpha*b.fZ;
fW = beta*a.fW + alpha*b.fW;
}
#endif
//
//
//
void hsQuat::SetFromMatrix(const hsMatrix44* mat)
{
hsScalar wSq = 0.25f*(1 + mat->fMap[0][0] + mat->fMap[1][1] + mat->fMap[2][2]);
if (wSq > EPSILON)
{
fW = hsSquareRoot(wSq);
hsScalar iw4 = 1.0f/(4.0f*fW);
fX = (mat->fMap[2][1] - mat->fMap[1][2]) * iw4;
fY = (mat->fMap[0][2] - mat->fMap[2][0]) * iw4;
fZ = (mat->fMap[1][0] - mat->fMap[0][1]) * iw4;
return;
}
fW = 0;
hsScalar xSq = -0.5f*(mat->fMap[1][1] + mat->fMap[2][2]);
if (xSq > EPSILON)
{
fX = hsSquareRoot(xSq);
hsScalar ix2 = 1.0f/(2.0f*fX);
fY = mat->fMap[1][0] * ix2;
fZ = mat->fMap[2][0] * ix2;
return;
}
fX = 0;
hsScalar ySq = 0.5f * (1 - mat->fMap[2][2]);
if (ySq > EPSILON)
{
fY = hsSquareRoot(ySq);
fZ = mat->fMap[2][1] / (2.0f*fY);
return;
}
fY = 0;
fZ = 1;
}
// 9/15/03 - Colin
// Changed to not use hsFastMath::InvSqrt, due to errors occuring at some
// specific angles that caused Havok to blow up.
hsQuat hsQuat::QuatFromMatrix44(const hsMatrix44& mat)
{
/* This algorithm avoids near-zero divides by looking for a large component
* - first w, then x, y, or z. When the trace is greater than zero,
* |w| is greater than 1/2, which is as small as a largest component can be.
* Otherwise, the largest diagonal entry corresponds to the largest of |x|,
* |y|, or |z|, one of which must be larger than |w|, and at least 1/2. */
hsQuat qu;
float tr, s;
const int X = 0;
const int Y = 1;
const int Z = 2;
const int W = 3;
tr = mat.fMap[X][X] + mat.fMap[Y][Y]+ mat.fMap[Z][Z];
if (tr >= 0.0) {
s = float(sqrt(tr + 1.f));
qu.fW = 0.5f * s;
s = 0.5f / s;
qu.fX = (mat.fMap[Z][Y] - mat.fMap[Y][Z]) * s;
qu.fY = (mat.fMap[X][Z] - mat.fMap[Z][X]) * s;
qu.fZ = (mat.fMap[Y][X] - mat.fMap[X][Y]) * s;
} else {
int h = X;
if (mat.fMap[Y][Y] > mat.fMap[X][X])
h = Y;
if (mat.fMap[Z][Z] > mat.fMap[h][h])
h = Z;
switch (h) {
#define caseMacro(i,j,k,I,J,K) \
case I:\
s = float(sqrt( (mat.fMap[I][I] - (mat.fMap[J][J]+mat.fMap[K][K])) + 1.f )); \
qu.i = 0.5f * s; \
s = 0.5f / s; \
qu.j = (mat.fMap[I][J] + mat.fMap[J][I]) * s; \
qu.k = (mat.fMap[K][I] + mat.fMap[I][K]) * s; \
qu.fW = (mat.fMap[K][J] - mat.fMap[J][K]) * s; \
break
caseMacro(fX,fY,fZ,X,Y,Z);
caseMacro(fY,fZ,fX,Y,Z,X);
caseMacro(fZ,fX,fY,Z,X,Y);
}
}
return (qu);
}
hsQuat& hsQuat::SetFromMatrix44(const hsMatrix44& mat)
{
return (*this = QuatFromMatrix44(mat));
/*==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 "HeadSpin.h"
#include "hsQuat.h"
#include "hsMatrix44.h"
#include "hsStream.h"
#include "hsFastMath.h"
//
// Quaternion class.
// For conversion to and from euler angles, see hsEuler.cpp,h.
//
//
// Construct quat from angle (in radians) and axis of rotation
//
hsQuat::hsQuat(hsScalar rad, const hsVector3* axis)
{
// hsAssert(rad >= -hsScalarPI && rad <= hsScalarPI, "Quat: Angle should be between -PI and PI");
fW = hsCosine(rad*0.5f);
hsScalar s = hsSine(rad*0.5f);
fX = axis->fX*s;
fY = axis->fY*s;
fZ = axis->fZ*s;
}
hsQuat hsQuat::Inverse() const
{
hsQuat q2 = Conjugate();
hsScalar msInv = 1.0f/q2.MagnitudeSquared();
return (q2 * msInv);
}
hsPoint3 hsQuat::Rotate(const hsScalarTriple* v) const
{
hsQuat qInv = Inverse();
hsQuat qVec(v->fX, v->fY, v->fZ, 0);
hsQuat t = qInv * qVec;
hsQuat res = (t * (*this));
//hsAssert(hsABS(res.fW)<1e-5, "Error rotating vector");
return hsPoint3(res.fX, res.fY, res.fZ);
}
void hsQuat::SetAngleAxis(const hsScalar rad, const hsVector3 &axis)
{
fW = hsCosine(rad*0.5f);
hsScalar s = hsSine(rad*0.5f);
fX = axis.fX*s;
fY = axis.fY*s;
fZ = axis.fZ*s;
}
//
// Might want to Normalize before calling this
//
void hsQuat::GetAngleAxis(hsScalar *rad, hsVector3 *axis) const
{
hsAssert((fW >= -1) && (fW <= 1), "Invalid acos argument");
hsScalar ac = hsACosine(fW);
*rad = 2.0f * ac;
hsScalar s = hsSine(ac);
if (s != 0.0f)
{
hsScalar invS = 1.0f/s;
axis->Set(fX*invS, fY*invS, fZ*invS);
}
else
axis->Set(0,0,0);
}
//
//
//
hsScalar hsQuat::MagnitudeSquared()
{
return (fX*fX + fY*fY + fZ*fZ + fW*fW);
}
//
//
//
hsScalar hsQuat::Magnitude()
{
return hsSquareRoot(MagnitudeSquared());
}
//
//
//
void hsQuat::Normalize()
{
hsScalar invMag = 1.0f/Magnitude();
fX *= invMag;
fY *= invMag;
fZ *= invMag;
fW *= invMag;
}
//
//
//
void hsQuat::NormalizeIfNeeded()
{
hsScalar magSquared = MagnitudeSquared();
if (magSquared == 1.0f)
return;
hsScalar invMag = 1.0f/hsSquareRoot(magSquared);
fX *= invMag;
fY *= invMag;
fZ *= invMag;
fW *= invMag;
}
//
// This is for a RHS.
// The quat should be normalized first.
//
void hsQuat::MakeMatrix(hsMatrix44 *mat) const
{
// mf horse - this is transpose of both what
// Gems says and what i'm expecting to come
// out of it, so i'm flipping it.
mat->fMap[0][0] = 1.0f - 2.0f*fY*fY - 2.0f*fZ*fZ;
mat->fMap[0][1] = 2.0f*fX*fY - 2.0f*fW*fZ;
mat->fMap[0][2] = 2.0f*fX*fZ + 2.0f*fW*fY;
mat->fMap[0][3] = 0.0f;
mat->fMap[1][0] = 2.0f*fX*fY + 2.0f*fW*fZ;
mat->fMap[1][1] = 1.0f - 2.0f*fX*fX - 2.0f*fZ*fZ;
mat->fMap[1][2] = 2.0f*fY*fZ - 2.0f*fW*fX;
mat->fMap[1][3] = 0.0f;
mat->fMap[2][0] = 2.0f*fX*fZ - 2.0f*fW*fY;
mat->fMap[2][1] = 2.0f*fY*fZ + 2.0f*fW*fX;
mat->fMap[2][2] = 1.0f - 2.0f*fX*fX - 2.0f*fY*fY;
mat->fMap[2][3] = 0.0f;
mat->fMap[3][0] = 0.0f;
mat->fMap[3][1] = 0.0f;
mat->fMap[3][2] = 0.0f;
mat->fMap[3][3] = 1.0f;
#if 0
mat->fMap[0][0] = fW*fW + fX*fX - fY*fY - fZ*fZ;
mat->fMap[1][0] = 2.0f*fX*fY - 2.0f*fW*fZ;
mat->fMap[2][0] = 2.0f*fX*fZ + 2.0f*fW*fY;
mat->fMap[3][0] = 0.0f;
mat->fMap[0][1] = 2.0f*fX*fY + 2.0f*fW*fZ;
mat->fMap[1][1] = fW*fW - fX*fX + fY*fY - fZ*fZ;
mat->fMap[2][1] = 2.0f*fY*fZ - 2.0f*fW*fX;
mat->fMap[3][1] = 0.0f;
mat->fMap[0][2] = 2.0f*fX*fZ - 2.0f*fW*fY;
mat->fMap[1][2] = 2.0f*fY*fZ + 2.0f*fW*fX;
mat->fMap[2][2] = fW*fW - fX*fX - fY*fY + fZ*fZ;
mat->fMap[3][2] = 0.0f;
mat->fMap[0][3] = 0.0f;
mat->fMap[1][3] = 0.0f;
mat->fMap[2][3] = 0.0f;
mat->fMap[3][3] = fW*fW + fX*fX + fY*fY + fZ*fZ;
#endif
mat->NotIdentity();
}
// Binary operators
hsQuat hsQuat::operator-(const hsQuat &in) const
{
return hsQuat(fX-in.fX, fY-in.fY, fZ-in.fZ, fW-in.fW);
}
hsQuat hsQuat::operator+(const hsQuat &in) const
{
return hsQuat(fX+in.fX, fY+in.fY, fZ+in.fZ, fW+in.fW);
}
//
// Return quaternion product (this * in). Note: order is important!
// To combine rotations, use the product (qSecond * qFirst),
// which gives the effect of rotating by qFirst then qSecond.
//
hsQuat hsQuat::operator*(const hsQuat &in) const
{
hsQuat ret;
ret.fW = (fW*in.fW - fX*in.fX - fY*in.fY - fZ*in.fZ);
ret.fX = (fY*in.fZ - in.fY*fZ + fW*in.fX + in.fW*fX);
ret.fY = (fZ*in.fX - in.fZ*fX + fW*in.fY + in.fW*fY);
ret.fZ = (fX*in.fY - in.fX*fY + fW*in.fZ + in.fW*fZ);
return ret;
}
// I/O
void hsQuat::Read(hsStream *stream)
{
fX = stream->ReadSwapFloat();
fY = stream->ReadSwapFloat();
fZ = stream->ReadSwapFloat();
fW = stream->ReadSwapFloat();
}
void hsQuat::Write(hsStream *stream)
{
stream->WriteSwapFloat(fX);
stream->WriteSwapFloat(fY);
stream->WriteSwapFloat(fZ);
stream->WriteSwapFloat(fW);
}
#if 0
//
// Interpolate on a sphere.
//
void hsQuat::SetFromSlerp(hsQuat *q1, hsQuat *q2, hsScalar t)
{
hsAssert(t>=0.0 && t<= 1.0, "Quat slerp param must be between 0 an 1");
hsScalar theta = hsACosine(q1->Dot(*q2));
hsScalar st = hsSine(theta);
assert(st != 0.0);
hsScalar s1 = hsSine(1.0-t)*theta / st;
hsScalar s2 = hsSine(t)*theta / st;
*this = (*q1) * s1 + (*q2) * s2;
}
#else
/*
* Spherical linear interpolation of unit quaternions with spins
*/
#define EPSILON 1.0E-6 /* a tiny number */
void hsQuat::SetFromSlerp(const hsQuat &a, const hsQuat &b, hsScalar alpha, int spin)
// double alpha; /* interpolation parameter (0 to 1) */
// Quaternion *a, *b; /* start and end unit quaternions */
// int spin; /* number of extra spin rotations */
{
hsScalar beta; /* complementary interp parameter */
hsScalar theta; /* angle between A and B */
hsScalar sin_t, cos_t; /* sine, cosine of theta */
hsScalar phi; /* theta plus spins */
int bflip; /* use negation of B? */
/* cosine theta = dot product of A and B */
cos_t = a.Dot(b);
/* if B is on opposite hemisphere from A, use -B instead */
if (cos_t < 0.0)
{
cos_t = -cos_t;
bflip = true;
}
else
bflip = false;
/* if B is (within precision limits) the same as A,
* just linear interpolate between A and B.
* Can't do spins, since we don't know what direction to spin.
*/
if (1.0 - cos_t < EPSILON)
{
beta = 1.0f - alpha;
} else
{ /* normal case */
// hsAssert((cos_t >= -1) && (cos_t <= 1), "Invalid acos argument");
theta = hsACosine(cos_t);
phi = theta + spin * hsScalarPI;
sin_t = hsSine(theta);
hsAssert(sin_t != 0.0, "Invalid sin value in quat slerp");
beta = hsSine(theta - alpha*phi) / sin_t;
alpha = hsSine(alpha*phi) / sin_t;
}
if (bflip)
alpha = -alpha;
/* interpolate */
fX = beta*a.fX + alpha*b.fX;
fY = beta*a.fY + alpha*b.fY;
fZ = beta*a.fZ + alpha*b.fZ;
fW = beta*a.fW + alpha*b.fW;
}
#endif
//
//
//
void hsQuat::SetFromMatrix(const hsMatrix44* mat)
{
hsScalar wSq = 0.25f*(1 + mat->fMap[0][0] + mat->fMap[1][1] + mat->fMap[2][2]);
if (wSq > EPSILON)
{
fW = hsSquareRoot(wSq);
hsScalar iw4 = 1.0f/(4.0f*fW);
fX = (mat->fMap[2][1] - mat->fMap[1][2]) * iw4;
fY = (mat->fMap[0][2] - mat->fMap[2][0]) * iw4;
fZ = (mat->fMap[1][0] - mat->fMap[0][1]) * iw4;
return;
}
fW = 0;
hsScalar xSq = -0.5f*(mat->fMap[1][1] + mat->fMap[2][2]);
if (xSq > EPSILON)
{
fX = hsSquareRoot(xSq);
hsScalar ix2 = 1.0f/(2.0f*fX);
fY = mat->fMap[1][0] * ix2;
fZ = mat->fMap[2][0] * ix2;
return;
}
fX = 0;
hsScalar ySq = 0.5f * (1 - mat->fMap[2][2]);
if (ySq > EPSILON)
{
fY = hsSquareRoot(ySq);
fZ = mat->fMap[2][1] / (2.0f*fY);
return;
}
fY = 0;
fZ = 1;
}
// 9/15/03 - Colin
// Changed to not use hsFastMath::InvSqrt, due to errors occuring at some
// specific angles that caused Havok to blow up.
hsQuat hsQuat::QuatFromMatrix44(const hsMatrix44& mat)
{
/* This algorithm avoids near-zero divides by looking for a large component
* - first w, then x, y, or z. When the trace is greater than zero,
* |w| is greater than 1/2, which is as small as a largest component can be.
* Otherwise, the largest diagonal entry corresponds to the largest of |x|,
* |y|, or |z|, one of which must be larger than |w|, and at least 1/2. */
hsQuat qu;
float tr, s;
const int X = 0;
const int Y = 1;
const int Z = 2;
const int W = 3;
tr = mat.fMap[X][X] + mat.fMap[Y][Y]+ mat.fMap[Z][Z];
if (tr >= 0.0) {
s = float(sqrt(tr + 1.f));
qu.fW = 0.5f * s;
s = 0.5f / s;
qu.fX = (mat.fMap[Z][Y] - mat.fMap[Y][Z]) * s;
qu.fY = (mat.fMap[X][Z] - mat.fMap[Z][X]) * s;
qu.fZ = (mat.fMap[Y][X] - mat.fMap[X][Y]) * s;
} else {
int h = X;
if (mat.fMap[Y][Y] > mat.fMap[X][X])
h = Y;
if (mat.fMap[Z][Z] > mat.fMap[h][h])
h = Z;
switch (h) {
#define caseMacro(i,j,k,I,J,K) \
case I:\
s = float(sqrt( (mat.fMap[I][I] - (mat.fMap[J][J]+mat.fMap[K][K])) + 1.f )); \
qu.i = 0.5f * s; \
s = 0.5f / s; \
qu.j = (mat.fMap[I][J] + mat.fMap[J][I]) * s; \
qu.k = (mat.fMap[K][I] + mat.fMap[I][K]) * s; \
qu.fW = (mat.fMap[K][J] - mat.fMap[J][K]) * s; \
break
caseMacro(fX,fY,fZ,X,Y,Z);
caseMacro(fY,fZ,fX,Y,Z,X);
caseMacro(fZ,fX,fY,Z,X,Y);
}
}
return (qu);
}
hsQuat& hsQuat::SetFromMatrix44(const hsMatrix44& mat)
{
return (*this = QuatFromMatrix44(mat));
}

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