2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-13 18:17:49 -04:00

CWE Directory Reorganization

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

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

View File

@ -0,0 +1,58 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcAllIncludes.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACALLINCLUDES_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcAllIncludes.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACALLINCLUDES_H
#include "pnAcCore.h"
#include "pnAcIo.h"
#include "pnAcLog.h"
#include "pnAcThread.h"
#include "pnAcTimer.h"

View File

@ -0,0 +1,113 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcCore.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACCORE_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcCore.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACCORE_H
/****************************************************************************
*
* Library initialization
*
***/
void AsyncCoreInitialize ();
void AsyncCoreDestroy (unsigned waitMs);
/*****************************************************************************
*
* Performance counters
*
***/
enum EAsyncPerfCounter {
// Sockets
kAsyncPerfSocketsCurr,
kAsyncPerfSocketsTotal,
kAsyncPerfSocketBytesWriteQueued,
kAsyncPerfSocketBytesWaitQueued,
kAsyncPerfSocketConnAttemptsOutCurr,
kAsyncPerfSocketConnAttemptsOutTotal,
kAsyncPerfSocketConnAttemptsInCurr,
kAsyncPerfSocketConnAttemptsInTotal,
kAsyncPerfSocketDisconnectBacklog,
kAsyncPerfSocketDisconnectInvalidConnType,
kAsyncPerfNameLookupAttemptsCurr,
kAsyncPerfNameLookupAttemptsTotal,
// Files
kAsyncPerfFilesCurr,
kAsyncPerfFilesTotal,
kAsyncPerfFileBytesReadQueued,
kAsyncPerfFileBytesWriteQueued,
// Threads
kAsyncPerfThreadsCurr,
kAsyncPerfThreadsTotal,
// Thread tasks
kAsyncPerfThreadTaskListCount,
kAsyncPerfThreadTaskThreadsDesired,
kAsyncPerfThreadTaskThreadsRunning,
kAsyncPerfThreadTaskThreadsActive,
kNumAsyncPerfCounters
};
long AsyncPerfGetCounter (unsigned id);
/*****************************************************************************
*
* Misc functions
*
***/
void AsyncSignalShutdown ();
void AsyncWaitForShutdown ();

View File

@ -0,0 +1,491 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACIO_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcIo.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACIO_H
/****************************************************************************
*
* Global types and constants
*
***/
typedef struct AsyncIdStruct * AsyncId;
typedef struct AsyncFileStruct * AsyncFile;
typedef struct AsyncSocketStruct * AsyncSocket;
typedef struct AsyncCancelIdStruct * AsyncCancelId;
const unsigned kAsyncSocketBufferSize = 1460;
enum EFileError {
kFileSuccess,
kFileErrorInvalidParameter,
kFileErrorFileNotFound,
kFileErrorPathNotFound,
kFileErrorAccessDenied,
kFileErrorSharingViolation,
kNumFileErrors
};
EFileError AsyncGetLastFileError ();
const wchar * FileErrorToString (EFileError error);
/****************************************************************************
*
* File notifications
*
***/
enum EAsyncNotifyFile {
kNotifyFileFlush,
kNotifyFileRead,
kNotifyFileWrite,
kNotifyFileSequence,
kNumFileNotifications
};
struct AsyncNotifyFile {
void * param;
AsyncId asyncId;
};
struct AsyncNotifyFileConnect : AsyncNotifyFile {
qword fileSize;
qword fileLastWriteTime;
};
struct AsyncNotifyFileFlush : AsyncNotifyFile {
EFileError error;
qword truncateSize;
};
struct AsyncNotifyFileRead : AsyncNotifyFile {
qword offset;
byte * buffer;
unsigned bytes;
};
typedef AsyncNotifyFileRead AsyncNotifyFileWrite;
struct AsyncNotifyFileSequence : AsyncNotifyFile {
// no additional fields
};
typedef void (* FAsyncNotifyFileProc)(
AsyncFile file,
EAsyncNotifyFile code,
AsyncNotifyFile * notify,
void ** userState
);
/****************************************************************************
*
* File I/O functions
*
***/
// Desired access
const unsigned kAsyncFileReadAccess = 0x80000000;
const unsigned kAsyncFileWriteAccess = 0x40000000;
// Open mode (creation disposition)
const unsigned kAsyncFileModeCreateNew = 1;
const unsigned kAsyncFileModeCreateAlways = 2;
const unsigned kAsyncFileModeOpenExisting = 3;
const unsigned kAsyncFileModeOpenAlways = 4;
// Share mode flags
const unsigned kAsyncFileShareRead = 0x00000001;
const unsigned kAsyncFileShareWrite = 0x00000002;
AsyncFile AsyncFileOpen (
const wchar fullPath[],
FAsyncNotifyFileProc notifyProc,
EFileError * error,
unsigned desiredAccess,
unsigned openMode,
unsigned shareModeFlags, // optional
void * userState, // optional
qword * fileSize, // optional
qword * fileLastWriteTime // optional
);
// Use with AsyncFileDelete/AsyncFileFlushBuffers
const qword kAsyncFileDontTruncate = (qword) -1;
// This function may ONLY be called when there is no outstanding I/O against a file
// and no more I/O will be initiated against it. This function guarantees that it
// will close the system file handle before it returns to that another open against
// the same filename can succeed.
void AsyncFileClose (
AsyncFile file,
qword truncateSize
);
void AsyncFileSetLastWriteTime (
AsyncFile file,
qword lastWriteTime
);
qword AsyncFileGetLastWriteTime (
const wchar fileName[]
);
// Truncation occurs atomically, any writes which occur after
// AsyncFileFlushBuffers will be queued until the truncation completes
AsyncId AsyncFileFlushBuffers (
AsyncFile file,
qword truncateSize,
bool notify,
void * param
);
const unsigned kAsyncFileRwNotify = 1<<0;
const unsigned kAsyncFileRwSync = 1<<1;
AsyncId AsyncFileRead (
AsyncFile file,
qword offset,
void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
// Buffer must stay valid until I/O is completed
AsyncId AsyncFileWrite (
AsyncFile file,
qword offset,
const void * buffer,
unsigned bytes,
unsigned flags,
void * param
);
// Inserts a "null operation" into the list of reads and writes. The callback
// will be called when all preceding operations have successfully completed.
AsyncId AsyncFileCreateSequence (
AsyncFile file,
bool notify,
void * param
);
enum EFileSeekFrom {
kFileSeekFromBegin,
kFileSeekFromCurrent,
kFileSeekFromEnd,
kNumFileSeekFroms
};
bool AsyncFileSeek (
AsyncFile file,
qword distance,
EFileSeekFrom seekFrom
);
/****************************************************************************
*
* Socket connect packet
*
***/
#include <PshPack1.h>
struct AsyncSocketConnectPacket {
byte connType;
word hdrBytes;
dword buildId;
dword buildType;
dword branchId;
Uuid productId;
};
#include <PopPack.h>
/****************************************************************************
*
* Socket event notifications
*
***/
enum EAsyncNotifySocket {
kNotifySocketConnectFailed,
kNotifySocketConnectSuccess,
kNotifySocketDisconnect,
kNotifySocketListenSuccess,
kNotifySocketRead,
kNotifySocketWrite
};
struct AsyncNotifySocket {
void * param;
AsyncId asyncId;
};
struct AsyncNotifySocketConnect : AsyncNotifySocket {
NetAddress localAddr;
NetAddress remoteAddr;
unsigned connType;
};
struct AsyncNotifySocketListen : AsyncNotifySocketConnect {
unsigned buildId;
unsigned buildType;
unsigned branchId;
Uuid productId;
NetAddress addr;
byte * buffer;
unsigned bytes;
unsigned bytesProcessed;
};
struct AsyncNotifySocketRead : AsyncNotifySocket {
byte * buffer;
unsigned bytes;
unsigned bytesProcessed;
};
typedef AsyncNotifySocketRead AsyncNotifySocketWrite;
typedef bool (* FAsyncNotifySocketProc) ( // return false to disconnect
AsyncSocket sock,
EAsyncNotifySocket code,
AsyncNotifySocket * notify,
void ** userState
);
/****************************************************************************
*
* Connection type functions
*
***/
// These codes may not be changed unless ALL servers and clients are
// simultaneously replaced; so basically forget it =)
enum EConnType {
kConnTypeNil = 0,
// For test applications
kConnTypeDebug = 1,
// Binary connections
kConnTypeCliToAuth = 10,
kConnTypeCliToGame = 11,
kConnTypeSrvToAgent = 12,
kConnTypeSrvToMcp = 13,
kConnTypeSrvToVault = 14,
kConnTypeSrvToDb = 15,
kConnTypeCliToFile = 16,
kConnTypeSrvToState = 17,
kConnTypeSrvToLog = 18,
kConnTypeSrvToScore = 19,
kConnTypeCliToCsr = 20,
kConnTypeSimpleNet = 21,
kConnTypeCliToGateKeeper = 22,
// Text connections
kConnTypeAdminInterface = 97, // 'a'
kNumConnTypes
};
COMPILER_ASSERT_HEADER(EConnType, kNumConnTypes < 256);
#define IS_TEXT_CONNTYPE(c) \
(((int)(c)) == kConnTypeAdminInterface)
void AsyncSocketRegisterNotifyProc (
byte connType,
FAsyncNotifySocketProc notifyProc,
unsigned buildId = 0,
unsigned buildType = 0,
unsigned branchId = 0,
const Uuid & productId = kNilGuid
);
void AsyncSocketUnregisterNotifyProc (
byte connType,
FAsyncNotifySocketProc notifyProc,
unsigned buildId = 0,
unsigned buildType = 0,
unsigned branchId = 0,
const Uuid & productId = kNilGuid
);
FAsyncNotifySocketProc AsyncSocketFindNotifyProc (
const byte buffer[],
unsigned bytes,
unsigned * bytesProcessed,
unsigned * connType,
unsigned * buildId,
unsigned * buildType,
unsigned * branchId,
Uuid * productId
);
/****************************************************************************
*
* Socket functions
*
***/
void AsyncSocketConnect (
AsyncCancelId * cancelId,
const NetAddress & netAddr,
FAsyncNotifySocketProc notifyProc,
void * param = nil,
const void * sendData = nil,
unsigned sendBytes = 0,
unsigned connectMs = 0, // 0 => use default value
unsigned localPort = 0 // 0 => don't bind local port
);
// Due to the asynchronous nature of sockets, the connect may complete
// before the cancel does... you have been warned.
void AsyncSocketConnectCancel (
FAsyncNotifySocketProc notifyProc,
AsyncCancelId cancelId
);
void AsyncSocketDisconnect (
AsyncSocket sock,
bool hardClose
);
// This function must only be called after receiving a kNotifySocketDisconnect
void AsyncSocketDelete (AsyncSocket sock);
// Returns false of socket has been closed
bool AsyncSocketSend (
AsyncSocket sock,
const void * data,
unsigned bytes
);
// Buffer must stay valid until I/O has completed
// Returns false if socket has been closed
bool AsyncSocketWrite (
AsyncSocket sock,
const void * buffer,
unsigned bytes,
void * param
);
// This function must only be called from with a socket notification callback.
// Calling at any other time is a crash bug waiting to happen!
void AsyncSocketSetNotifyProc (
AsyncSocket sock,
FAsyncNotifySocketProc notifyProc
);
// A backlog of zero (the default) means that no buffering is performed when
// the TCP send buffer is full, and the send() function will close the socket
// on send fail
void AsyncSocketSetBacklogAlloc (
AsyncSocket sock,
unsigned bufferSize
);
// On failure, returns 0
// On success, returns bound port (if port number was zero, returns assigned port)
// For connections that will use kConnType* connections, set notifyProc = nil;
// the handler will be found when connection packet is received.
// for connections with hard-coded behavior, set the notifyProc here (e.g. for use
// protocols like SNMP on port 25)
unsigned AsyncSocketStartListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc = nil
);
void AsyncSocketStopListening (
const NetAddress & listenAddr,
FAsyncNotifySocketProc notifyProc = nil
);
void AsyncSocketEnableNagling (
AsyncSocket sock,
bool enable
);
/****************************************************************************
*
* Dns functions
*
***/
typedef void (* FAsyncLookupProc) (
void * param,
const wchar name[],
unsigned addrCount,
const NetAddress addrs[]
);
void AsyncAddressLookupName (
AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc,
const wchar name[],
unsigned port,
void * param
);
void AsyncAddressLookupAddr (
AsyncCancelId * cancelId,
FAsyncLookupProc lookupProc,
const NetAddress & address,
void * param
);
void AsyncAddressLookupCancel (
FAsyncLookupProc lookupProc,
AsyncCancelId cancelId
);

View File

@ -0,0 +1,190 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcLog.cpp
*
***/
#include "../Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private
*
***/
static const unsigned kMaxHandlers = 8;
static CCritSect s_critsect;
static FLogHandler s_asyncHandlers[kMaxHandlers];
/*****************************************************************************
*
* Internal functions
*
***/
//===========================================================================
static void Dispatch (ELogSeverity severity, const wchar msg[]) {
// Dispatch to default debug handler
char dbg[1024];
StrToAnsi(dbg, msg, arrsize(dbg));
DEBUG_MSG(dbg);
// We don't need to enter a critical section to read the handlers because they
// are atomically set and cleared
for (unsigned i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (FLogHandler asyncHandler = s_asyncHandlers[i])
asyncHandler(severity, msg);
}
}
/*****************************************************************************
*
* Exports
*
***/
//===========================================================================
void LogRegisterHandler (FLogHandler callback) {
ASSERT(callback);
unsigned i;
s_critsect.Enter();
for (i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (!s_asyncHandlers[i]) {
s_asyncHandlers[i] = callback;
break;
}
}
s_critsect.Leave();
#ifdef HS_DEBUGGING
if (i >= arrsize(s_asyncHandlers))
FATAL("Maximum number of log handlers exceeded.");
#endif
}
//===========================================================================
void LogUnregisterHandler (FLogHandler callback) {
s_critsect.Enter();
for (unsigned i = 0; i < arrsize(s_asyncHandlers); ++i) {
if (s_asyncHandlers[i] == callback) {
s_asyncHandlers[i] = nil;
break;
}
}
s_critsect.Leave();
}
//===========================================================================
void __cdecl LogMsg (ELogSeverity severity, const char format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(severity, format, args);
va_end(args);
}
//===========================================================================
void __cdecl LogMsg (ELogSeverity severity, const wchar format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(severity, format, args);
va_end(args);
}
//===========================================================================
void LogMsgV (ELogSeverity severity, const char format[], va_list args) {
ASSERT(format);
char msg[1024];
StrPrintfV(msg, arrsize(msg), format, args);
wchar uniMsg[1024];
StrToUnicode(uniMsg, msg, arrsize(uniMsg));
Dispatch(severity, uniMsg);
}
//===========================================================================
void LogMsgV (ELogSeverity severity, const wchar format[], va_list args) {
ASSERT(format);
ASSERT(args);
wchar msg[1024];
StrPrintfV(msg, arrsize(msg), format, args);
Dispatch(severity, msg);
}
//============================================================================
//#ifdef HS_DEBUGGING
void LogMsgDebug (const char format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(kLogDebug, format, args);
va_end(args);
}
//#endif
//============================================================================
//#ifdef HS_DEBUGGING
void LogMsgDebug (const wchar format[], ...) {
ASSERT(format);
va_list args;
va_start(args, format);
LogMsgV(kLogDebug, format, args);
va_end(args);
}
//#endif

View File

@ -0,0 +1,127 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcLog.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACLOG_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcLog.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACLOG_H
/****************************************************************************
*
* Log API
*
***/
enum ELogSeverity {
// For indicating design problems
kLogDebug,
// For indicating performance warnings
// (e.g. transaction failed, retrying...)
kLogPerf,
// For indicating error conditions that change program behavior
// (e.g. socket connect failed)
kLogError,
// For indicating failures that may lead to program termination
// (e.g. out of memory)
kLogFatal,
kNumLogSeverity
};
void LogMsg (ELogSeverity severity, const char format[], ...);
void LogMsg (ELogSeverity severity, const wchar format[], ...);
void LogMsgV (ELogSeverity severity, const char format[], va_list args);
void LogMsgV (ELogSeverity severity, const wchar format[], va_list args);
void LogBreakOnErrors (bool breakOnErrors);
void AsyncLogInitialize (
const wchar logDirName[],
bool breakOnErrors
);
void AsyncLogDestroy ();
void AsyncLogFlush ();
void AsyncLogGetDirectory (wchar * dest, unsigned destChars);
// Low(er) level log API; call this from your LogHander function
// if you want to use the asynchronous log facility.
void AsyncLogWriteMsg (
const wchar facility[],
ELogSeverity severity,
const wchar msg[]
);
// FLogHandler must be capable of handling multiple threads and re-entrancy
typedef void (* FLogHandler) (ELogSeverity severity, const wchar msg[]);
void LogRegisterHandler (FLogHandler callback);
void LogUnregisterHandler (FLogHandler callback);
/****************************************************************************
*
* Debugging API
*
***/
//#ifdef HS_DEBUGGING
void LogMsgDebug (const char format[], ...);
void LogMsgDebug (const wchar format[], ...);
//#else
//
// inline void LogMsgDebug (const char *, ...) { }
// inline void LogMsgDebug (const wchar *, ...) { }
//
//#endif

View File

@ -0,0 +1,146 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcThread.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTHREAD_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcThread.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTHREAD_H
/****************************************************************************
*
* Type definitions
*
***/
// for IoWaitId/TimerCreate/TimerUpdate
const unsigned kAsyncTimeInfinite = (unsigned) -1;
#ifdef _MSC_VER
#define THREADCALL __stdcall
#else
#define THREADCALL __cdecl
#endif
struct AsyncThread;
typedef unsigned (THREADCALL * FAsyncThreadProc)(AsyncThread * thread);
// Threads are also allowed to set the workTimeMs field of their
// structure to a nonzero value for "on", and IO_TIME_INFINITE for
// "off" to avoid the overhead of calling these functions. Note
// that this function may not be called for the main thread. I
// suggest that application code not worry that timeMs might
// "accidentally" equal the IO_TIME_INFINITE value, as it only
// happens for one millisecond every 49 days.
struct AsyncThread {
LINK(AsyncThread) link;
FAsyncThreadProc proc;
void * handle;
void * argument;
unsigned workTimeMs;
wchar name[16];
};
/*****************************************************************************
*
* Thread functions
*
***/
void * AsyncThreadCreate (
FAsyncThreadProc proc,
void * argument,
const wchar name[]
);
// This function should ONLY be called during shutdown while waiting for things to expire
void AsyncSleep (unsigned sleepMs);
/*****************************************************************************
*
* Thread task functions
*
***/
enum EThreadTaskPriority {
kThreadTaskPriorityNormal = 1,
kNumThreadTaskPriorities
};
const unsigned kThreadTaskMinThreads = 5;
const unsigned kThreadTaskDefThreads = 100;
const unsigned kThreadTaskMaxThreads = 1000;
struct AsyncThreadTaskList;
typedef void (* FAsyncThreadTask)(
void * param,
ENetError error
);
void AsyncThreadTaskInitialize (unsigned threads);
void AsyncThreadTaskDestroy ();
unsigned AsyncThreadTaskGetThreadCount ();
void AsyncThreadTaskSetThreadCount (unsigned threads);
AsyncThreadTaskList * AsyncThreadTaskListCreate ();
void AsyncThreadTaskListDestroy (
AsyncThreadTaskList * taskList,
ENetError error
);
void AsyncThreadTaskAdd (
AsyncThreadTaskList * taskList,
FAsyncThreadTask callback,
void * param,
const wchar debugStr[],
EThreadTaskPriority priority = kThreadTaskPriorityNormal
);

View File

@ -0,0 +1,105 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcTimer.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTIMER_H
#error "Header $/Plasma20/Sources/Plasma/NucleusLib/pnAsyncCore/Private/pnAcTimer.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_NUCLEUSLIB_PNASYNCCORE_PRIVATE_PNACTIMER_H
/*****************************************************************************
*
* Timer functions
*
* Timers are repeatedly called back at a scheduled interval. Not that all
* timer procedures share the same thread, so timer procedures should:
*
* 1) Not be called too frequently
* 2) Not take too long to run or block for a long time
*
***/
struct AsyncTimer;
// Return callbackMs to wait that long until next callback.
// Return kAsyncTimeInfinite to stop callbacks (note: does not destroy Timer structure)
typedef unsigned (* FAsyncTimerProc)(void * param);
// 1) Timer procs do not get starved by I/O, they are called periodically.
// 2) Timer procs will never be called by multiple threads simultaneously.
void AsyncTimerCreate (
AsyncTimer ** timer,
FAsyncTimerProc timerProc,
unsigned callbackMs,
void * param = nil
);
// Timer procs can be in the process of getting called in
// another thread during the unregister function -- be careful!
// -- waitComplete = will wait until the timer has been unregistered and is
// no longer in the process of being called before returning. The flag may only
// be set by init/destruct threads, not I/O worker threads. In addition, extreme
// care should be used to avoid a deadlock when this flag is set; in general, it
// is a good idea not to hold any locks or critical sections when setting the flag.
const unsigned kAsyncTimerDestroyWaitComplete = 1<<0;
void AsyncTimerDelete (
AsyncTimer * timer,
unsigned flags = 0
);
void AsyncTimerDeleteCallback (
AsyncTimer * timer,
FAsyncTimerProc destroyProc
);
// To set the time value for a timer, use this function with flags = 0.
// To set the time to MoreRecentOf(nextTimerCallbackMs, callbackMs), use SetPriorityHigher
const unsigned kAsyncTimerUpdateSetPriorityHigher = 1<<0;
void AsyncTimerUpdate (
AsyncTimer * timer,
unsigned callbackMs,
unsigned flags = 0
);