Initial full mirror of c:\VWE (source + assets + toolchain + outputs) via Git LFS

Complete disaster-recovery snapshot: engine/game source, game data assets,
VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive.
Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false,
no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
This commit is contained in:
Cyd
2026-06-24 21:28:16 -05:00
commit 2b8ca921cb
66341 changed files with 7923174 additions and 0 deletions
+906
View File
@@ -0,0 +1,906 @@
#if !defined(__ARRAY__)
#define __ARRAY__
//{{NO_DEPENDENCIES}}
//
// Array Templates
//
#pragma warning(disable: 4786)
#ifndef NULL_CLASS_DEFINED
#define NULL_CLASS_DEFINED
class CNullClass {};
#endif
#define TARRAY(TYPE) TArray<TYPE, CNullClass> // TARRAY(int) - none/none
#define TARRAYREF(TYPE) TArrayDynamic<TYPE, TConNCon<TYPE>, TDesNDes<TYPE>, CNullClass> // TARRAYREF(CStr) - constructor/destructor
#define TARRAYPTR(TYPE) TArrayDynamic<TYPE, TConNFZ<TYPE>, TDesNDEL<TYPE>, CNullClass> // TARRAYREF(CStr*) - new/delete
#define TARRAYPTR2(TYPE) TArrayDynamic<TYPE, TConNFZ<TYPE>, TDesNDEL2<TYPE>, CNullClass> // // TARRAYREF(char*) - malloc/free
#define TARRAYSIMPLE(TYPE) TArraySimple<TYPE, CNullClass> // TARRAYSIMPLE(int), TARRAYZERO(float)
// above class definition
#define DECLARE_TARRAYREF_EX(CClass) inline void* _cdecl operator new(size_t nSize, CClass* pData) { return (void*)pData; } inline void _cdecl operator delete(void* p, CClass* pData) { }
#define DECLARE_TARRAYREF(CClass) class CClass; DECLARE_TARRAYREF_EX(CClass);
#define DECLARE_TARRAYREF_CLASS_EX(CClass, BaseClass) DECLARE_TARRAYREF(CClass) class CClass : public BaseClass { public: CClass() {} ~CClass() {} };
#define DECLARE_TARRAYREF_CLASS(Class,TYPE) DECLARE_TARRAYREF_CLASS_EX(Class, TARRAYREF(TYPE))
// in class definition
#define DECLARE_STATIC_CONSTRUCTION(CClass) inline void new##CClass() { new (this) CClass; } inline void delete##CClass() { this-> ~CClass(); }
template <class TYPE> inline void SwapValue(TYPE& a, TYPE& b)
{
a ^= b;
b ^= a;
a ^= b;
}
template <class TYPE> inline void SwapPointer(TYPE*& a, TYPE*& b)
{
TYPE* p;
p = a;
a = b;
b = p;
}
/*
All the structures starting with TCon are the Template-Constructor.
TCon1XXXX means the constructor for 1 element.
TConNXXXX means the constructor for arbitrary number of elements.
All the structures starting with TDes are the Template-Destructor.
*/
template <class TYPE>
struct TCon1None
{
// constructor: do NOTHING
static void Construct(TYPE* pData)
{
ASSERT(pData);
}
};
template <class TYPE>
struct TCon1Con
{
// constructor: call the constructor...
static void Construct(TYPE* pData)
{
ASSERT(pData);
new (pData) TYPE;
}
};
template <class TYPE>
struct TCon1AZ
{
// constructor: assign zero.
static void Construct(TYPE* pData)
{
ASSERT(pData);
*pData = 0;
}
};
template <class TYPE>
struct TCon1FZ
{
// constructor: fill with zero
static void Construct(TYPE* pData)
{
ASSERT(pData);
memset(pData, 0, sizeof(TYPE));
}
};
template <class TYPE>
struct TConNNone
{
// constructor: do NOTHING
static void Construct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
}
};
template <class TYPE>
struct TConNCon : public TCon1Con<TYPE>
{
// constructor: call the constructor
static void Construct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
while(nCount-- > 0) {
TCon1Con<TYPE>::Construct(pData++);
}
}
};
template <class TYPE>
struct TConNAZ : public TCon1AZ<TYPE>
{
// constructor: assign zero
static void Construct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
while(nCount-- > 0) {
TCon1AZ<TYPE>::Construct(pData++);
}
}
};
template <class TYPE>
struct TConNFZ
{
// constructor: fill with zero
static void Construct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
if (nCount > 0) {
memset(pData, 0, sizeof(TYPE) * nCount);
}
}
};
template <class TYPE>
struct TDes1None
{
// destructor: do NOTHING
static void Destruct(TYPE* pData)
{
ASSERT(pData);
}
};
template <class TYPE>
struct TDes1Des
{
// destructor: call the destructor
static void Destruct(TYPE* pData)
{
ASSERT(pData);
pData-> ~TYPE();
}
};
template <class TYPE>
struct TDes1AZ
{
// destructor: assign zero
static void Destruct(TYPE* pData)
{
ASSERT(pData);
*pData = 0;
}
};
template <class TYPE>
struct TDes1FZ
{
// destructor: fill with zero
static void Destruct(TYPE* pData)
{
ASSERT(pData);
memset(pData, 0, sizeof(TYPE));
}
};
template <class TYPE>
struct TDesNNone
{
// destructor: do NOTHING
static void Destruct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
}
};
template <class TYPE>
struct TDesNDes : public TDes1Des<TYPE>
{
// destructor: call the destructor
static void Destruct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
while(nCount-- > 0) {
TDes1Des<TYPE>::Destruct(pData++);
}
}
};
template <class TYPE>
struct TDesNAZ : public TDes1AZ<TYPE>
{
// destructor: assign zero
static void Destruct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
while(nCount-- > 0) {
TDes1AZ<TYPE>::Destruct(pData++);
}
}
};
template <class TYPE>
struct TDesNFZ
{
// destructor: fill with zero
static void Destruct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
if (nCount > 0) {
memset(pData, 0, sizeof(TYPE) * nCount);
}
}
};
template <class TYPE>
struct TDesNDEL
{
// destructor: fill with zero
static void Destruct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
while(nCount-- > 0) {
TYPE t = *pData++;
if (t)
delete t;
}
}
};
template <class TYPE>
struct TDesNDEL2
{
// destructor: fill with zero
static void Destruct(TYPE* pData, int nCount)
{
ASSERT((nCount >= 0) && (pData || (nCount == 0)));
while(nCount-- > 0) {
TYPE t = *pData++;
if (t)
delete [] t;
}
}
};
template <class TYPE, class BaseClass>
class TArray : public BaseClass
{
/*
This class is the classical array implementation.
*/
public:
typedef TYPE Type;
public: // This may should be protected or private, but...
TYPE* m_pData; // Data Type Pointer - classic data array pointer
int m_nSize; // Exact Array Size - size of array being used
protected:
int m_nGrowBy; // Number used to determine the allocate unit.
private:
int m_nSizeMax; // Allocated Array Size - It could be modified by SetGrowBy()... - size of array allocated (memory allocation)
public: // Construction & Desturction
TArray()
{
// as is...
m_pData = NULL;
m_nSize = m_nSizeMax = 0;
m_nGrowBy = 100;
}
~TArray()
{
// as is...
Reset();
}
void RemoveAll()
{
// remove all the elements, and free all the memory used.
// but no destruction of object-itself.
// IMPORTANT: don't call this method, when constructor/destructor should be called.
if (m_pData) {
ASSERT(m_nSizeMax > 0);
free(m_pData);
m_pData = NULL;
m_nSize = m_nSizeMax = 0;
} else {
ASSERT((m_nSize == 0) && (m_nSizeMax == 0));
}
}
void Reset()
{
// same with RemoveAll
RemoveAll();
}
void Swap(TArray<TYPE, BaseClass>& that)
{
SwapPointer(m_pData, that.m_pData);
SwapValue(m_nSize, that.m_nSize);
SwapValue(m_nGrowBy, that.m_nGrowBy);
SwapValue(m_nSizeMax, that.m_nSizeMax);
}
BOOL IsEqual(const TArray<TYPE, BaseClass>& that) const
{
int nSize = m_nSize;
if (nSize == that.m_nSize) {
if (nSize > 0) {
if (memcmp(m_pData, that.m_pData, nSize * sizeof(TYPE)) == 0) {
return TRUE;
}
} else {
return TRUE;
}
}
return FALSE;
}
BOOL operator == (const TArray<TYPE, BaseClass>& that) const
{
return IsEqual(that);
}
BOOL operator != (const TArray<TYPE, BaseClass>& that) const
{
return !IsEqual(that);
}
void SetAllValue(const TYPE one)
{
int i, nSize = m_nSize;
TYPE* pDest = m_pData;
for(i = 0; i < nSize; i++) {
*pDest = one;
pDest++;
}
}
void SetAll(const TYPE& one)
{
int i, nSize = m_nSize;
TYPE* pDest = m_pData;
for(i = 0; i < nSize; i++) {
*pDest = one;
pDest++;
}
}
int SetGrowBy(int nGrowBy)
{
ASSERT(nGrowBy >= 0);
// swap m_nGrowBy with nGrowBy, and return nGrowBy(old value)...
SwapValue(m_nGrowBy, nGrowBy);
return nGrowBy;
}
int GetSize() const
{
// as is...
return m_nSize;
}
void SetSize(int nSize)
{
ASSERT(nSize >= 0);
int nDiff = nSize - m_nSize;
if (nDiff != 0) {
if (nDiff < 0) {
// shrink
Del(m_nSize + nDiff, -nDiff);
} else {
// grow
Add(nDiff);
}
}
}
void ResetSize(int nSize)
{
Reset();
SetSize(nSize);
}
TYPE At(int nIndex) const // return data
{
// used to retrive values(as like char, int, long...)
// usually this method used retrieve small(accuping 1 or 2 CPU register) objects
ASSERT((0 <= nIndex) && (nIndex < m_nSize));
return m_pData[nIndex];
}
TYPE& GetAt(int nIndex) const // return reference to data
{
// used to retrive structures(as like POINT, RECT, MSG...)
// usually this method used retrieve large(accuping 2 or more CPU registers) objects
ASSERT(0 <= nIndex); // (nIndex < m_nSize) - used as pointer?
return m_pData[nIndex];
}
TYPE& operator [] (int nIndex) const // return reference to data
{
// same with "TYPE& GetAt(int nIndex) const"
ASSERT(0 <= nIndex); // (nIndex < m_nSize) - used as pointer?
return m_pData[nIndex];
}
int Find(TYPE data) const
{
int i, nSize = m_nSize;
TYPE* pData = m_pData;
for(i = 0; i < nSize; i++) {
if (*pData == data)
return i;
pData++;
}
return -1;
}
TYPE& Add(int nRoom = 1) // return reference to the first slot added
{
// add nRoom element(s), and return its starting memory reference...
ASSERT(nRoom > 0);
TYPE* pData = m_pData;
nRoom += m_nSize;
if (nRoom > m_nSizeMax) { // insufficient slot. grow array
int nSizeMax = nRoom + m_nGrowBy;
if (pData) {
pData = (TYPE*)realloc(pData, sizeof(TYPE) * nSizeMax);
} else {
pData = (TYPE*)malloc(sizeof(TYPE) * nSizeMax);
}
#if 0
if (!pData)
return *(TYPE*)NULL;
#endif
m_pData = pData;
m_nSizeMax = nSizeMax;
}
pData = &m_pData[m_nSize]; // point to the first slot added
m_nSize = nRoom;
return *pData;
}
TYPE& Ins(int nIndex, int nRoom = 1) // return reference to the first slot inserted
{
// insert nRoom element(s) before nIndex, and return its starting memory reference...
ASSERT(nRoom > 0);
ASSERT((0 <= nIndex) && (nIndex <= m_nSize));
int nSize = m_nSize - nIndex; // number of array to move
TYPE* pData = &Add(nRoom);
if (nSize) {
int nCount = nSize * sizeof(TYPE);
TYPE* pDataSrc = (TYPE*)((char*)pData - nCount);
memmove(&pDataSrc[nRoom], pDataSrc, nCount);
return *pDataSrc;
}
return *pData;
}
void FreeExtra()
{
// used to free extra memories(make m_nSizeMax same with m_nSize)...
if (m_pData) {
if (m_nSize) {
// realloc to smaller size: always successive.
m_pData = (TYPE*)realloc(m_pData, sizeof(TYPE) * m_nSize);
} else {
free(m_pData);
m_pData = NULL;
}
m_nSizeMax = m_nSize;
} else {
ASSERT(m_nSize == 0); // (m_nSizeMax == 0)
}
}
void Del(int nIndex, int nCount = 1)
{
// delete nCount element(s) where nIndex...
ASSERT(nCount > 0);
ASSERT((0 <= nIndex) && (nIndex <= m_nSize));
int nSize = m_nSize;
if (nIndex < nSize) {
ASSERT(nIndex + nCount <= nSize);
TYPE* pDataDst = &m_pData[nIndex];
nIndex += nCount;
int nMove = nSize - nIndex;
if (nMove) {
memcpy(pDataDst, &pDataDst[nCount], nMove * sizeof(TYPE));
}
m_nSize = nSize - nCount;
} else {
TRACE("TArray::Del() : deletion at the out of bound\n");
ASSERT(nIndex == nSize);
}
}
int DelFind(TYPE data)
{
int nIndex = Find(data);
if (0 <= nIndex) {
Del(nIndex);
}
return nIndex;
}
void Append(const TArray<TYPE, BaseClass>& that)
{
// append array...
int nSize = that.m_nSize;
if (nSize > 0) {
memcpy(&Add(nSize), that.m_pData, nSize * sizeof(TYPE));
}
}
void Assign(const TArray<TYPE, BaseClass>& that)
{
// append array...
int nSize = that.m_nSize;
SetSize(nSize);
if (nSize > 0) {
memcpy(m_pData, that.m_pData, nSize * sizeof(TYPE));
}
}
TArray<TYPE, BaseClass>& operator = (const TArray<TYPE, BaseClass>& that)
{
Assign(that);
return *this;
}
void operator *= (const TArray<TYPE, BaseClass>& that)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
ASSERT(nSize == that.GetSize());
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
const TYPE* pSrc = that.m_pData;
while(pStart < pEnd) {
*pStart *= *pSrc;
pSrc++;
pStart++;
}
}
void operator /= (const TArray<TYPE, BaseClass>& that)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
ASSERT(nSize == that.GetSize());
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
const TYPE* pSrc = that.m_pData;
while(pStart < pEnd) {
*pStart /= *pSrc;
pSrc++;
pStart++;
}
}
void operator += (const TArray<TYPE, BaseClass>& that)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
ASSERT(nSize == that.GetSize());
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
const TYPE* pSrc = that.m_pData;
while(pStart < pEnd) {
*pStart += *pSrc;
pSrc++;
pStart++;
}
}
void operator -= (const TArray<TYPE, BaseClass>& that)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
ASSERT(nSize == that.GetSize());
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
const TYPE* pSrc = that.m_pData;
while(pStart < pEnd) {
*pStart -= *pSrc;
pSrc++;
pStart++;
}
}
void operator *= (TYPE tValue)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
while(pStart < pEnd) {
*pStart *= tValue;
pStart++;
}
}
void operator /= (TYPE tValue)
{
ASSERT(tValue != 0);
int nSize = m_nSize;
ASSERT(nSize > 0);
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
while(pStart < pEnd) {
*pStart /= tValue;
pStart++;
}
}
void operator += (TYPE tValue)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
while(pStart < pEnd) {
*pStart += tValue;
pStart++;
}
}
void operator -= (TYPE tValue)
{
int nSize = m_nSize;
ASSERT(nSize > 0);
TYPE* pStart = m_pData;
TYPE* pEnd = &pStart[nSize];
while(pStart < pEnd) {
*pStart -= tValue;
pStart++;
}
}
};
template <class TYPE, class CON, class DES, class BaseClass>
class TArrayDynamic : public TArray<TYPE, BaseClass>
{
/*
This class is used to call constructor or destructor when enlarged or reduced.
CON: constructor template(TConNNone, TConNCon, TConNAZ, TConNFZ)
DES: destructor template(TDesNNone, TDesNCon, TDesNAZ, TDesNFZ)
*/
public:
~TArrayDynamic()
{
Reset();
}
void ConstructAll()
{
CON::Construct(m_pData, m_nSize);
}
void DestructAll()
{
DES::Destruct(m_pData, m_nSize);
}
void Reset()
{
// call the specified destructor(see DES)
DES::Destruct(m_pData, m_nSize);
TArray<TYPE, BaseClass>::Reset();
}
BOOL IsEqual(const TArrayDynamic<TYPE, CON, DES, BaseClass>& that) const
{
int nSize = m_nSize;
if (nSize == that.m_nSize) {
if (nSize > 0) {
const TYPE* pDest = m_pData;
const TYPE* pSrc = that.m_pData;
for(int i = 0; i < nSize; i++) {
if (!(*pDest == *pSrc)) {
return FALSE;
}
pDest++;
pSrc++;
}
}
return TRUE;
}
return FALSE;
}
BOOL operator == (const TArrayDynamic<TYPE, CON, DES, BaseClass>& that) const
{
return IsEqual(that);
}
BOOL operator != (const TArrayDynamic<TYPE, CON, DES, BaseClass>& that) const
{
return !IsEqual(that);
}
void SetSize(int nSize)
{
ASSERT(nSize >= 0);
int nDiff = nSize - m_nSize;
if (nDiff != 0) {
if (nDiff < 0) {
// shrink
Del(m_nSize + nDiff, -nDiff);
} else {
// grow
Add(nDiff);
}
}
}
void ResetSize(int nSize)
{
Reset();
SetSize(nSize);
}
TYPE& Add(int nRoom = 1)
{
ASSERT(nRoom >= 0);
TYPE* pData;
if (nRoom) {
pData = &TArray<TYPE, BaseClass>::Add(nRoom);
CON::Construct(pData, nRoom);
} else {
pData = NULL;
}
return *pData;
}
TYPE& Ins(int nIndex, int nRoom = 1)
{
ASSERT((0 <= nIndex) && (nIndex <= m_nSize) && (nRoom >= 0));
TYPE* pData;
if (nRoom) {
pData = &TArray<TYPE, BaseClass>::Ins(nIndex, nRoom);
CON::Construct(pData, nRoom);
} else {
pData = NULL;
}
return *pData;
}
void Del(int nIndex, int nCount = 1)
{
ASSERT(nCount > 0);
ASSERT((0 <= nIndex) && (nIndex < m_nSize));
TYPE* pData = &m_pData[nIndex];
DES::Destruct(pData, nCount);
TArray<TYPE, BaseClass>::Del(nIndex, nCount);
}
int DelFind(TYPE data)
{
int nIndex = Find(data);
if (0 <= nIndex) {
Del(nIndex);
}
return nIndex;
}
void Append(const TArrayDynamic<TYPE, CON, DES, BaseClass>& that)
{
// append array...
int nSize = that.m_nSize;
TYPE* pDest = &Add(nSize);
const TYPE* pSrc = that.m_pData;
for(int i = 0; i < nSize; i++) {
*pDest = *pSrc;
pDest++;
pSrc++;
}
}
void Assign(const TArrayDynamic<TYPE, CON, DES, BaseClass>& that)
{
// append array...
int nSize = that.m_nSize;
SetSize(nSize);
TYPE* pDest = m_pData;
const TYPE* pSrc = that.m_pData;
for(int i = 0; i < nSize; i++) {
*pDest = *pSrc;
pDest++;
pSrc++;
}
}
TArrayDynamic<TYPE, CON, DES, BaseClass>& operator = (const TArrayDynamic<TYPE, CON, DES, BaseClass>& that)
{
Assign(that);
return *this;
}
};
template <class TYPE, class BaseClass>
class TArraySimple : public TArrayDynamic<TYPE, TConNFZ<TYPE>, TDesNNone<TYPE>, BaseClass>
{
public:
BOOL IsEqual(const TArraySimple<TYPE, BaseClass>& that) const
{
return TArray<TYPE, BaseClass>::IsEqual(that);
}
BOOL operator == (const TArraySimple<TYPE, BaseClass>& that) const
{
return TArray<TYPE, BaseClass>::IsEqual(that);
}
BOOL operator != (const TArraySimple<TYPE, BaseClass>& that) const
{
return !TArray<TYPE, BaseClass>::IsEqual(that);
}
void Append(const TArraySimple<TYPE, BaseClass>& that)
{
// append array...
int nSize = that.m_nSize;
if (nSize > 0) {
memcpy(&TArray<TYPE, BaseClass>::Add(nSize), that.m_pData, nSize * sizeof(TYPE));
}
}
void Assign(const TArraySimple<TYPE, BaseClass>& that)
{
// append array...
int nSize = that.m_nSize;
TArray<TYPE, BaseClass>::SetSize(nSize);
if (nSize > 0) {
memcpy(m_pData, that.m_pData, nSize * sizeof(TYPE));
}
}
TArraySimple<TYPE, BaseClass>& operator = (const TArraySimple<TYPE, BaseClass>& that)
{
Assign(that);
return *this;
}
};
#endif // !defined(__ARRAY__)
File diff suppressed because it is too large Load Diff
+197
View File
@@ -0,0 +1,197 @@
#if !defined(__CStr__)
#define __CStr__
// include: cstr.h, stdarg.h
#if !defined(CHAR)
#define CHAR char
#endif // !defined(CHAR)
#if !defined(USE_STRLOCK)
#define USE_STRLOCK
#endif // !defined(USE_STRLOCK)
#if !defined(__QSortCompareProc_DEFINED__)
typedef int (__cdecl* QSortCompareProc)(const void* elem1, const void* elem2);
#define __QSortCompareProc_DEFINED__
#endif // !defined(__QSortCompareProc_DEFINED__)
int __cdecl str_memcmp(const void* elem1, const void* elem2);
#if !defined(WIN32)
#define lstrcmp strcmp
#define lstrcmpi strcasecmp
char* _strupr(char *string);
char* _strlwr(char *string);
#endif // !defined(WIN32)
int __cdecl str_Compare(const void* elem1, const void* elem2);
int __cdecl str_CompareReverse(const void* elem1, const void* elem2);
int __cdecl str_CompareIC(const void* elem1, const void* elem2);
int __cdecl str_CompareICReverse(const void* elem1, const void* elem2);
DECLARE_TARRAYREF(CStr);
class CStr
{
private:
CHAR* m_psz;
// all data in this section must be INITIALIZED!!!!!!!!!!!!!
public:
CStr();
CStr(const CHAR* pcsz);
CStr(const CHAR* pcsz, int nLen);
CStr(CHAR c, int nLen);
CStr(const CStr& that);
private:
CStr(int nMax);
public:
~CStr();
public:
operator const CHAR* () const { return m_psz; }
CHAR* GetRawBuffer() const { return m_psz; } // be very cautious!!!!
int GetLength() const { return strlen(m_psz); }
BOOL IsEmpty() const { return m_psz[0] == '\0'; }
const CHAR* String() const { return m_psz; }
const CHAR* Empty();
void Swap(CStr& that);
#ifdef USE_STRLOCK
WORD IsLocked() const;
CHAR* LockBuffer();
WORD UnlockBuffer();
#endif // USE_STRLOCK
#ifndef _DEBUG
#define CheckRange(nIndex)
#else // _DEBUG
void CheckRange(int nIndex) const
{
ASSERT((0 <= nIndex) && (nIndex <= lstrlen(m_psz)));
}
#endif // !_DEBUG
CHAR operator () (int nIndex) const { CheckRange(nIndex); return m_psz[nIndex]; }
const CHAR& operator [] (int nIndex) const { CheckRange(nIndex); return m_psz[nIndex]; }
CHAR& operator [] (int nIndex) { CheckRange(nIndex); return m_psz[nIndex]; }
CHAR GetAt(int nIndex) const { CheckRange(nIndex); return m_psz[nIndex]; }
void SetAt(int nIndex, CHAR c) { CheckRange(nIndex); m_psz[nIndex] = c; }
#ifndef _DEBUG
#undef CheckRange
#endif // !_DEBUG
const CHAR* Assign(const CHAR* pcsz, int nLen = -1);
CStr& operator = (const CHAR* pcsz) { Assign(pcsz); return *this; }
CStr& operator = (const CStr& that) { Assign(that.m_psz); return *this; }
BOOL operator == (const CHAR* pcsz) const { return pcsz ? strcmp(m_psz, pcsz) == 0: m_psz[0] == '\0'; }
BOOL operator != (const CHAR* pcsz) const { return pcsz ? strcmp(m_psz, pcsz) != 0: m_psz[0] != '\0'; }
BOOL operator > (const CHAR* pcsz) const { return pcsz ? strcmp(m_psz, pcsz) > 0: m_psz[0] != '\0'; }
BOOL operator >= (const CHAR* pcsz) const { return pcsz ? strcmp(m_psz, pcsz) >= 0: TRUE; }
BOOL operator < (const CHAR* pcsz) const { return pcsz ? strcmp(m_psz, pcsz) < 0: FALSE; }
BOOL operator <= (const CHAR* pcsz) const { return pcsz ? strcmp(m_psz, pcsz) <= 0: m_psz[0] == '\0'; }
CStr operator + (const CHAR* pcsz) const;
CStr& operator += (const CHAR* pcsz);
CStr operator + (CHAR c) const;
CStr& operator += (CHAR c);
void MakeUpper() { _strupr(m_psz); }
void MakeLower() { _strlwr(m_psz); }
void MakeReverse();
const CHAR* Prune(const CHAR* pcszDELs = NULL);
const CHAR* TrimLeft();
const CHAR* TrimRight();
const CHAR* TrimAll();
void __cdecl Format(LPCTSTR lpszFormat, ...);
void vFormat(LPCTSTR lpszFormat, va_list marker);
CHAR* GetBuffer(int nLen);
const CHAR* ReleaseBuffer(int nLen = -1);
CHAR* GetBufferSetLength(int nLen);
void ChangeChars(CHAR cBefore, CHAR cAfter);
BOOL AsDirectory(BOOL bRemoveLastDEL = FALSE);
BOOL AddDirDEL();
int FindExtPos() const;
const char* FindExt() const;
BOOL ChangeExt(const char* pcszExt, BOOL bForce = TRUE);
const CHAR* Left(CStr& strLeft, int nCount) const;
const CHAR* Right(CStr& strRight, int nCount) const;
const CHAR* Mid(CStr& strMid, int nFirst) const;
const CHAR* Mid(CStr& strMid, int nFirst, int nCount) const;
CStr Left(int nCount) const;
CStr Right(int nCount) const;
CStr Mid(int nFirst) const;
CStr Mid(int nFirst, int nCount) const;
int FindNext(CHAR c, int nStart) const;
int Find(CHAR c) const;
int rFindNext(CHAR c, int nStart) const;
int rFind(CHAR c) const;
int Find(const CHAR* pcsz, int nStart) const;
int Find(const CHAR* pcsz) const;
int FindSet(const CHAR* pcszSet) const;
int rFindSet(const CHAR* pcszSet) const;
#if defined(WIN32)
BOOL GetWindowText(HWND hWnd);
#endif // defined(WIN32)
protected:
const CHAR* AssignNoCheck(const CHAR* pcsz, int nLen = -1);
private:
CHAR* Reset();
#ifdef USE_STRLOCK
CHAR* ResetLocked();
#endif // USE_STRLOCK
};
#if !defined(USE_CSTR_ISTREAM) && defined(_INC_ISTREAM)
#define USE_CSTR_ISTREAM
#endif // !defined(USE_CSTR_ISTREAM) && defined(_INC_ISTREAM)
#if defined(NO_USE_CSTR_ISTREAM)
#undef USE_CSTR_ISTREAM
#endif // defined(NO_USE_CSTR_ISTREAM)
#ifdef USE_CSTR_ISTREAM
istream& operator >> (istream& s, CStr& str);
#endif // USE_CSTR_ISTREAM
#define LSTRS_TOLOWER 0x0001
#define LSTRS_TOUPPER 0x0002
#define LSTRS_ALLOWDUP 0x0004
#define LSTRS_DOSORT 0x0008
class CStrArray : public TARRAYREF(CStr)
{
public:
int GetTotalLength() const;
int Find(const char* pcsz) const;
int AddIfNotFound(const char* pcsz);
int AddIfNotFound(const CStr astrs[], int nCount);
void Sort(QSortCompareProc pQSortCompareProc = (QSortCompareProc)NULL);
BOOL LoadStrs(const char* pcszFile, const char* pcszVals = NULL, UINT uFlags = 0);
BOOL LoadStrs(FILE* pFile, const char* pcszVals = NULL, UINT uFlags = 0);
void LSTRS_CheckAdd(CStr& str, UINT uFlags);
};
#ifdef _DEBUG
#define ASSERT_VALIDSTRING(pcszStr) ASSERT(IsValidString(pcszStr))
#define ASSERT_VALIDSTRINGSAFE(pcszStr) ASSERT(IsValidStringSafe(pcszStr))
#define ASSERT_CLSPTR(p) ASSERT(IsValidMemory(p, sizeof(*p), TRUE))
BOOL IsValidString(const CHAR* pcszStr, int nLen = -1);
BOOL IsValidStringSafe(const CHAR* pcszStr, int nLen = -1);
BOOL IsValidMemory(const void* pMem, UINT uBytes, BOOL bWriteCheck = TRUE);
BOOL IsValidMemorySafe(const void* pMem, UINT uBytes, BOOL bWriteCheck = TRUE);
#else // !_DEBUG
#define ASSERT_VALIDSTRING(pcszStr)
#define ASSERT_VALIDSTRINGSAFE(pcszStr)
#define ASSERT_CLSPTR(p)
inline BOOL __RelIsValidAddr(const void* p, int nLen = -1) { &p, &nLen; return TRUE; }
#define IsValidString 1 ? 1: __RelIsValidAddr
#define IsValidStringSafe 1 ? 1: __RelIsValidAddr
#define IsValidMemory 1 ? 1: __RelIsValidAddr
#define IsValidMemorySafe 1 ? 1: __RelIsValidAddr
#endif // _DEBUG
#ifdef _DEBUG
void CStrTestMain();
#endif // _DEBUG
#endif // !defined(__CStr__)
Binary file not shown.
Binary file not shown.
+346
View File
@@ -0,0 +1,346 @@
// Launcher.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include "ctcls.h"
#include "ctcl.h"
#define MAX_LOADSTRING 100
#define WM_1ST_RUN (WM_USER + 100)
#pragma data_seg(".SHARED_DATA")
// all data in this section must be INITIALIZED!!!!!!!!!!!!!
BOOL g_bLaunched = FALSE;
#pragma data_seg()
#pragma comment(linker, "/section:.SHARED_DATA,RWS")
// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, LPSTR, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
bool _stdcall RunExec(const CStr& strExec);
void Do1stRun()
{
char sz[1024];
char szName[64];
GetPrivateProfileString(SECT_CONFIG, "run", "", szName, sizeof(szName), PROF_INI);
if (strlen(szName) > 0) {
GetPrivateProfileString(SECT_GAMES, szName, "", sz, sizeof(sz), PROF_INI);
CStr strExec(sz);
strExec.TrimAll();
//WinExec(sz, SW_SHOWNORMAL);
RunExec(strExec);
}
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// TODO: Place code here.
MSG msg;
if (!g_bLaunched) {
g_bLaunched = TRUE;
if (CTCL_Start(_ECTCL_Launcher)) {
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_LAUNCHER, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (InitInstance (hInstance, lpCmdLine, nCmdShow)) {
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_LAUNCHER);
// Main message loop:
do {
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
if (msg.message == WM_QUIT)
break;
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
} else {
Sleep(3);
}
CTCL_Run();
} while(TRUE);
}
CTCL_Stop();
}
g_bLaunched = FALSE;
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_LAUNCHER);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
#ifdef _DEBUG
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_LAUNCHER;
#else // !_DEBUG
wcex.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wcex.lpszMenuName = (LPCSTR)NULL;
#endif // _DEBUG
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
BOOL bNoMax = strstr(lpCmdLine, "-nomax") ? TRUE: FALSE;
#ifdef _DEBUG
DWORD dwExStyle = 0;
DWORD dwStyle = WS_OVERLAPPEDWINDOW;
#else // !_DEBUG
DWORD dwExStyle;
DWORD dwStyle;
if (bNoMax) {
dwExStyle = 0;
dwStyle = WS_OVERLAPPEDWINDOW;
} else {
dwExStyle = /*WS_EX_TOPMOST | */WS_EX_APPWINDOW; // top most & onto task bar
dwStyle = WS_POPUP | WS_VISIBLE | WS_MAXIMIZE;
}
#endif // _DEBUG
hWnd = CreateWindowEx(dwExStyle, szWindowClass, szTitle, dwStyle, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
PostMessage(hWnd, WM_1ST_RUN, GetTickCount() + 3000, 0);
#ifdef _DEBUG
ShowWindow(hWnd, nCmdShow);
#else // !_DEBUG
if (bNoMax)
ShowWindow(hWnd, nCmdShow); // SW_MINIMIZE
else
ShowWindow(hWnd, SW_MAXIMIZE); // SW_MINIMIZE
#endif // _DEBUG
UpdateWindow(hWnd);
//#if !defined(_DEBUG)
// SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, (LPVOID)0, SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
//#endif // !defined(_DEBUG)
SetFocus(hWnd);
SetForegroundWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_1ST_RUN:
if (GetTickCount() < wParam)
PostMessage(hWnd, WM_1ST_RUN, wParam, 0);
else
Do1stRun();
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
/*
RECT rt;
GetClientRect(hWnd, &rt);
{
const char* pcszMsg = " Mech Warrior 4 ";
DrawText(hdc, pcszMsg, strlen(pcszMsg), &rt, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
}
*/
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
// to avoid linking error
void CTCL_API CTCL_DoTerminateAppl()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_DoEndMission()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_DoMainShell()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_DoCreateGame()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_DoJoinGame()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_StartGame(BOOL bRealLaunch)
{
&bRealLaunch;
ASSERT(FALSE);
}
void CTCL_API CTCL_InitMechDatas()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_CheckJoinGame()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_CheckNetConnectedToServer()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_SetMissionParams()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_CheckMissionParams()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_SetMechs()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_CheckClientReady()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_CheckServerReady()
{
ASSERT(FALSE);
}
void CTCL_API CTCL_DefaultHostSetup()
{
ASSERT(FALSE);
}
+255
View File
@@ -0,0 +1,255 @@
# Microsoft Developer Studio Project File - Name="Launcher" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=Launcher - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "Launcher.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "Launcher.mak" CFG="Launcher - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "Launcher - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "Launcher - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE "Launcher - Win32 Profile" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""$/GameLeapCode/Launcher", TYBAAAAA"
# PROP Scc_LocalPath "."
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "Launcher - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../rel.bin"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /GR /Oa /Og /Oi /Gy /D "_WINDOWS" /D "_MBCS" /D "CTCL_LAUNCHER" /D "NDEBUG" /D "WIN32" /Yu"stdafx.h" /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x412 /d "NDEBUG"
# ADD RSC /l 0x412 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
!ELSEIF "$(CFG)" == "Launcher - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "../dbg.bin"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c
# ADD CPP /nologo /G6 /Zp4 /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "WIN32" /D "CTCL_LAUNCHER" /FR /Yu"stdafx.h" /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x412 /d "_DEBUG"
# ADD RSC /l 0x412 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ELSEIF "$(CFG)" == "Launcher - Win32 Profile"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Launcher___Win32_Profile"
# PROP BASE Intermediate_Dir "Launcher___Win32_Profile"
# PROP BASE Ignore_Export_Lib 0
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "../pro.bin"
# PROP Intermediate_Dir "Profile"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G6 /Gz /Zp4 /MD /W3 /GX /Zi /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /FD /c
# ADD CPP /nologo /G6 /Zp4 /MD /W3 /GX /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "WIN32" /D "CTCL_LAUNCHER" /Yu"stdafx.h" /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x412 /d "NDEBUG"
# ADD RSC /l 0x412 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386
!ENDIF
# Begin Target
# Name "Launcher - Win32 Release"
# Name "Launcher - Win32 Debug"
# Name "Launcher - Win32 Profile"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\Launcher.cpp
# End Source File
# Begin Source File
SOURCE=.\Launcher.rc
# End Source File
# Begin Source File
SOURCE=.\StdAfx.cpp
# ADD CPP /Yc"stdafx.h"
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=.\Launcher.h
# End Source File
# Begin Source File
SOURCE=.\resource.h
# End Source File
# Begin Source File
SOURCE=.\StdAfx.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# Begin Source File
SOURCE=.\Launcher.ico
# End Source File
# Begin Source File
SOURCE=.\small.ico
# End Source File
# End Group
# Begin Group "ctcl"
# PROP Default_Filter ""
# Begin Group "cpp"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\Cstr.cpp
# End Source File
# Begin Source File
SOURCE=.\ctcl.cpp
# End Source File
# Begin Source File
SOURCE=.\ctime.cpp
# End Source File
# Begin Source File
SOURCE=.\mugSocs.cpp
# End Source File
# End Group
# Begin Group "h"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\Cstr.h
# End Source File
# Begin Source File
SOURCE=.\ctcl.h
# End Source File
# Begin Source File
SOURCE=.\ctime.h
# End Source File
# Begin Source File
SOURCE=.\mugpdefs.h
# End Source File
# Begin Source File
SOURCE=.\mugsocs.h
# End Source File
# Begin Source File
SOURCE=.\nonmfc.h
# End Source File
# Begin Source File
SOURCE=.\Stddefs.h
# End Source File
# End Group
# Begin Group "inl"
# PROP Default_Filter ""
# Begin Source File
SOURCE=.\ARRAY.INL
# End Source File
# Begin Source File
SOURCE=.\bsearch.inl
# End Source File
# Begin Source File
SOURCE=.\dblinks.inl
# End Source File
# Begin Source File
SOURCE=.\dqfixed.inl
# End Source File
# Begin Source File
SOURCE=.\Qsort.inl
# End Source File
# Begin Source File
SOURCE=.\treenode.inl
# End Source File
# End Group
# End Group
# Begin Source File
SOURCE=.\ReadMe.txt
# End Source File
# End Target
# End Project
+12
View File
@@ -0,0 +1,12 @@
#if !defined(AFX_LAUNCHER_H__350DF16B_46CB_41E7_82E6_F0A3F5AE9F83__INCLUDED_)
#define AFX_LAUNCHER_H__350DF16B_46CB_41E7_82E6_F0A3F5AE9F83__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "resource.h"
#endif // !defined(AFX_LAUNCHER_H__350DF16B_46CB_41E7_82E6_F0A3F5AE9F83__INCLUDED_)
+140
View File
@@ -0,0 +1,140 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
#include "resource.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
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_LAUNCHER ICON DISCARDABLE "Launcher.ICO"
IDI_SMALL ICON DISCARDABLE "SMALL.ICO"
/////////////////////////////////////////////////////////////////////////////
//
// Menu
//
IDC_LAUNCHER MENU DISCARDABLE
BEGIN
POPUP "&File"
BEGIN
MENUITEM "E&xit", IDM_EXIT
END
POPUP "&Help"
BEGIN
MENUITEM "&About ...", IDM_ABOUT
END
END
/////////////////////////////////////////////////////////////////////////////
//
// Accelerator
//
IDC_LAUNCHER ACCELERATORS MOVEABLE PURE
BEGIN
"?", IDM_ABOUT, ASCII, ALT
"/", IDM_ABOUT, ASCII, ALT
END
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 230, 75
STYLE DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "About"
FONT 8, "System"
BEGIN
ICON IDI_LAUNCHER,IDC_MYICON,14,9,16,16
LTEXT "Launcher Version 1.0",IDC_STATIC,49,10,119,8,
SS_NOPREFIX
LTEXT "Copyright (C) 2001",IDC_STATIC,49,20,119,8
DEFPUSHBUTTON "OK",IDOK,195,6,30,11,WS_GROUP
END
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""resource.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "Launcher"
IDS_HELLO "Hello World!"
IDC_LAUNCHER "LAUNCHER"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+336
View File
@@ -0,0 +1,336 @@
#if !defined(__QSORT__)
#define __QSORT__
// stealed from qsort.c
#if !defined(FASTAPICALLCONVENTION)
#if defined(_WINDOWS)
#ifdef WIN32
#define FASTAPICALLCONVENTION __fastcall
#else // !WIN32
#define FASTAPICALLCONVENTION PASCAL
#endif // WIN32
#else // !defined(_WINDOWS)
#define FASTAPICALLCONVENTION
#endif // defined(_WINDOWS)
#endif // !defined(TSORTCALL)
#define TQSORT_VALUE(TYPE,ptr,count) TQSORT<TYPE, TCompDiff<TYPE>, TSwapAssign<TYPE> >::qsort(ptr,count)
#define TQSORT_VALUEUNSIGNED(TYPE,ptr,count) TQSORT<TYPE, TCompDiffUnsigned<TYPE>, TSwapAssign<TYPE> >::qsort(ptr,count)
#define TQSORT_MEM(TYPE,ptr,count) TQSORT<TYPE, TCompMEM<TYPE>, TSwapMEM<TYPE> >::qsort(ptr,count)
#define TQSORT_PTR(TYPE,ptr,count) TQSORT<TYPE, TCompPtr<TYPE>, TSwapAssign<TYPE> >::qsort(ptr,count)
/* this parameter defines the cutoff between using quick sort and
insertion sort for arrays; arrays with lengths shorter or equal to the
below value use insertion sort */
#define TQSORT_CUTOFF 8 /* testing shows that this is good value */
template <class TYPE>
struct TCompDiff
{
static int FASTAPICALLCONVENTION Compare(const TYPE* pa, const TYPE* pb)
{
return *pa - *pb;
}
};
template <class TYPE>
struct TCompDiffUnsigned
{
static int FASTAPICALLCONVENTION Compare(const TYPE* pa, const TYPE* pb)
{
TYPE tmpA = *pa;
TYPE tmpB = *pb;
if (tmpA != tmpB) {
if (tmpA > tmpB) {
return +1;
}
return -1;
}
return 0;
}
};
template <class TYPE>
struct TCompMEM
{
static int FASTAPICALLCONVENTION Compare(const TYPE* pa, const TYPE* pb)
{
return memcmp(pa, pb, sizeof(TYPE));
}
};
template <class TYPE>
struct TCompPtr
{
static int FASTAPICALLCONVENTION Compare(const TYPE* pa, const TYPE* pb)
{
BYTE* p1 = (BYTE**)pa;
BYTE* p2 = (BYTE**)pb;
if (p1 != p2) {
if (p1 > p2) {
return +1;
}
return -1;
}
return 0;
}
};
template <class TYPE>
struct TSwapAssign
{
static void FASTAPICALLCONVENTION Swap(TYPE* pa, TYPE* pb)
{
if (pa != pb) {
TYPE tmp;
tmp = *pa;
*pa = *pb;
*pb = tmp;
}
}
};
template <class TYPE>
struct TSwapMEM
{
static void FASTAPICALLCONVENTION Swap(BYTE* pa, BYTE* pb)
{
if (pa != pb) {
int nWidth = sizeof(TYPE);
/* Do the swap one character at a time to avoid potential alignment problems. */
while(nWidth-- > 0) {
BYTE tmp;
tmp = *(BYTE*)pa;
*pa++ = *pb;
*pb++ = tmp;
}
}
}
};
template <class TYPE, class COMP, class SWAP>
class TQSORT
{
public:
public:
private:
static void FASTAPICALLCONVENTION shortsort(BYTE *lo, BYTE *hi)
{
/***
*shortsort(hi, lo) - insertion sort for sorting short arrays
*
*Purpose:
* sorts the sub-array of elements between lo and hi (inclusive)
* side effects: sorts in place
* assumes that lo < hi
*
*Entry:
* BYTE *lo = pointer to low element to sort
* BYTE *hi = pointer to high element to sort
*Exit:
* returns void
*
*Exceptions:
*
*******************************************************************************/
BYTE *p, *max;
/* Note: in assertions below, i and j are alway inside original bound of
array to sort. */
while (hi > lo) {
/* A[i] <= A[j] for i <= j, j > hi */
max = lo;
for (p = lo+sizeof(TYPE); p <= hi; p += sizeof(TYPE)) {
/* A[i] <= A[max] for lo <= i < p */
if (COMP::Compare((TYPE*)p, (TYPE*)max) > 0) {
max = p;
}
/* A[i] <= A[max] for lo <= i <= p */
}
/* A[i] <= A[max] for lo <= i <= hi */
SWAP::Swap((TYPE*)max, (TYPE*)hi);
/* A[i] <= A[hi] for i <= hi, so A[i] <= A[j] for i <= j, j >= hi */
hi -= sizeof(TYPE);
/* A[i] <= A[j] for i <= j, j > hi, loop top condition established */
}
/* A[i] <= A[j] for i <= j, j > lo, which implies A[i] <= A[j] for i < j,
so array is sorted */
}
public:
static void FASTAPICALLCONVENTION qsort(TYPE* base, size_t num)
{
/* sort the array between lo and hi (inclusive) */
/***
*qsort(base, num, wid) - quicksort function for sorting arrays
*
*Purpose:
* quicksort the array of elements
* side effects: sorts in place
*
*Entry:
* TYPE *base = pointer to base of array
* size_t num = number of elements in the array
*Exit:
* returns void
*
*Exceptions:
*
*******************************************************************************/
BYTE *lo, *hi; /* ends of sub-array currently sorting */
BYTE *mid; /* points to middle of subarray */
BYTE *loguy, *higuy; /* traveling pointers for partition step */
unsigned size; /* size of the sub-array */
BYTE *lostk[30], *histk[30];
int stkptr; /* stack for saving sub-array to be processed */
/* Note: the number of stack entries required is no more than
1 + log2(size), so 30 is sufficient for any array */
if (num < 2 || sizeof(TYPE) == 0)
return; /* nothing to do */
stkptr = 0; /* initialize stack */
lo = (BYTE*)&base[0];
hi = (BYTE*)&base[num - 1]; /* initialize limits */
/* this entry point is for pseudo-recursion calling: setting
lo and hi and jumping to here is like recursion, but stkptr is
prserved, locals aren't, so we preserve stuff on the stack */
recurse:
size = (hi - lo) / sizeof(TYPE) + 1; /* number of el's to sort */
/* below a certain size, it is faster to use a O(n^2) sorting method */
if (size <= TQSORT_CUTOFF) {
shortsort(lo, hi);
} else {
/* First we pick a partititioning element. The efficiency of the
algorithm demands that we find one that is approximately the
median of the values, but also that we select one fast. Using
the first one produces bad performace if the array is already
sorted, so we use the middle one, which would require a very
wierdly arranged array for worst case performance. Testing shows
that a median-of-three algorithm does not, in general, increase
performance. */
mid = lo + (size / 2) * sizeof(TYPE); /* find middle element */
SWAP::Swap((TYPE*)mid, (TYPE*)lo); /* swap it to beginning of array */
/* We now wish to partition the array into three pieces, one
consisiting of elements <= partition element, one of elements
equal to the parition element, and one of element >= to it. This
is done below; comments indicate conditions established at every
step. */
loguy = lo;
higuy = hi + sizeof(TYPE);
/* Note that higuy decreases and loguy increases on every iteration,
so loop must terminate. */
for (;;) {
/* lo <= loguy < hi, lo < higuy <= hi + 1,
A[i] <= A[lo] for lo <= i <= loguy,
A[i] >= A[lo] for higuy <= i <= hi */
do {
loguy += sizeof(TYPE);
} while (loguy <= hi && COMP::Compare((const TYPE*)loguy, (const TYPE*)lo) <= 0);
/* lo < loguy <= hi+1, A[i] <= A[lo] for lo <= i < loguy,
either loguy > hi or A[loguy] > A[lo] */
do {
higuy -= sizeof(TYPE);
} while (higuy > lo && COMP::Compare((const TYPE*)higuy, (const TYPE*)lo) >= 0);
/* lo-1 <= higuy <= hi, A[i] >= A[lo] for higuy < i <= hi,
either higuy <= lo or A[higuy] < A[lo] */
if (higuy < loguy)
break;
/* if loguy > hi or higuy <= lo, then we would have exited, so
A[loguy] > A[lo], A[higuy] < A[lo],
loguy < hi, highy > lo */
SWAP::Swap((TYPE*)loguy, (TYPE*)higuy);
/* A[loguy] < A[lo], A[higuy] > A[lo]; so condition at top
of loop is re-established */
}
/* A[i] >= A[lo] for higuy < i <= hi,
A[i] <= A[lo] for lo <= i < loguy,
higuy < loguy, lo <= higuy <= hi
implying:
A[i] >= A[lo] for loguy <= i <= hi,
A[i] <= A[lo] for lo <= i <= higuy,
A[i] = A[lo] for higuy < i < loguy */
SWAP::Swap((TYPE*)lo, (TYPE*)higuy); /* put partition element in place */
/* OK, now we have the following:
A[i] >= A[higuy] for loguy <= i <= hi,
A[i] <= A[higuy] for lo <= i < higuy
A[i] = A[lo] for higuy <= i < loguy */
/* We've finished the partition, now we want to sort the subarrays
[lo, higuy-1] and [loguy, hi].
We do the smaller one first to minimize stack usage.
We only sort arrays of length 2 or more.*/
if ( higuy - 1 - lo >= hi - loguy ) {
if (lo + sizeof(TYPE) < higuy) {
lostk[stkptr] = lo;
histk[stkptr] = higuy - sizeof(TYPE);
++stkptr;
} /* save big recursion for later */
if (loguy < hi) {
lo = loguy;
goto recurse; /* do small recursion */
}
} else {
if (loguy < hi) {
lostk[stkptr] = loguy;
histk[stkptr] = hi;
++stkptr; /* save big recursion for later */
}
if (lo + sizeof(TYPE) < higuy) {
hi = higuy - sizeof(TYPE);
goto recurse; /* do small recursion */
}
}
}
/* We have sorted the array, except for any pending sorts on the stack.
Check if there are any, and do them. */
--stkptr;
if (stkptr >= 0) {
lo = lostk[stkptr];
hi = histk[stkptr];
goto recurse; /* pop subarray from stack */
}
//return; /* all subarrays done */
}
};
#endif // !defined(__QSORT__)
+56
View File
@@ -0,0 +1,56 @@
========================================================================
WIN32 APPLICATION : Launcher
========================================================================
AppWizard has created this Launcher application for you.
This file contains a summary of what you will find in each of the files that
make up your Launcher application.
Launcher.cpp
This is the main application source file.
Launcher.dsp
This file (the project file) contains information at the project level and
is used to build a single project or subproject. Other users can share the
project (.dsp) file, but they should export the makefiles locally.
/////////////////////////////////////////////////////////////////////////////
AppWizard has created the following resources:
Launcher.rc
This is a listing of all of the Microsoft Windows resources that the
program uses. It includes the icons, bitmaps, and cursors that are stored
in the RES subdirectory. This file can be directly edited in Microsoft
Visual C++.
res\Launcher.ico
This is an icon file, which is used as the application's icon (32x32).
This icon is included by the main resource file Launcher.rc.
small.ico
%%This is an icon file, which contains a smaller version (16x16)
of the application's icon. This icon is included by the main resource
file Launcher.rc.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named Launcher.pch and a precompiled types file named StdAfx.obj.
Resource.h
This is the standard header file, which defines new resource IDs.
Microsoft Visual C++ reads and updates this file.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+8
View File
@@ -0,0 +1,8 @@
// stdafx.cpp : source file that includes just the standard includes
// Launcher.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
+55
View File
@@ -0,0 +1,55 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Insert your headers here
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
#include <windows.h>
// C RunTime Header Files
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include <limits.h>
#include <malloc.h>
#include <math.h>
#include <memory.h>
#include <tchar.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <crtdbg.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <errno.h>
#include <limits.h>
#include <fcntl.h>
#include "nonmfc.h"
#include "mugpdefs.h"
#include "ctime.h"
// Local Header Files
// TODO: reference additional headers your program requires here
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_)
+163
View File
@@ -0,0 +1,163 @@
#if !defined(__STDDEFS__)
#define __STDDEFS__
#ifdef RC_INVOKED
#else // RC_INVOKED
#ifdef WIN32
#pragma warning (disable:4200)
#endif // WIN32
#if 0 // def _DEBUG
inline void HEAPCHK()
{
PVOID pa[10];
int i;
for(i = 0; i < 10; i++) {
pa[i] = malloc(rand() % 32000 + 767);
ASSERT(_heapchk() == _HEAPOK);
}
_HEAPINFO hh;
int nRet;
hh._pentry = NULL;
while((nRet = _heapwalk(&hh)) == _HEAPOK)
;
if (nRet != _HEAPEND) {
ASSERT(FALSE);
}
for(i = 0; i < 10; i++) {
free(pa[i]);
ASSERT(_heapchk() == _HEAPOK);
}
}
#else
#define HEAPCHK()
#endif
#ifdef WIN32
#pragma pack(push, 1)
#endif // WIN32
union WORDPACK {
struct {
BYTE m_bLow;
BYTE m_bHigh;
} m_W;
WORD m_wValue;
};
typedef WORDPACK* PWORDPACK;
union DWORDPACK {
struct {
WORDPACK m_wLow;
WORDPACK m_wHigh;
} m_DW;
DWORD m_dwValue;
};
typedef DWORDPACK* PDWORDPACK;
#ifdef WIN32
#pragma pack(pop)
#endif // WIN32
#define GETLBYTE(W) (((PWORDPACK)&(W))->m_W.m_bLow)
#define GETHBYTE(W) (((PWORDPACK)&(W))->m_W.m_bHigh)
#define GETLWORD(D) (((PDWORDPACK)&(D))->m_DW.m_wLow.m_wValue)
#define GETHWORD(D) (((PDWORDPACK)&(D))->m_DW.m_wHigh.m_wValue)
#define WORDHI(lvalue) (*((LPWORD)&(lvalue) + 1))
#define BYTEHI(lvalue) (*((LPBYTE)&(lvalue) + 1))
#define MAKE_VERSION(rmj, rmm, rup) (((DWORD)rmj) << 16) | (((DWORD)rmm) << 8) | (((DWORD)rup) << 0)
#define NOFA(name_of_array) (sizeof(name_of_array)/sizeof(name_of_array[0]))
#define ChkFlag(flag,mask) ((flag) & (mask))
#define SetFlag(flag,mask) ((flag) |= (mask))
#define XorFlag(flag,mask) ((flag) ^= (mask))
#define ClrFlag(flag,mask) ((flag) &= ~(mask))
#ifdef _DEBUG
#define DEBUGONLY(expr) (expr)
#else
#define DEBUGONLY(expr)
#endif
typedef signed long SINT; // logical unit, signed 32bit
typedef short SINT16;
typedef unsigned short UINT16;
typedef int SINT32;
#if _MSC_VER <= 1100
typedef unsigned int UINT32;
#endif // _MSC_VER <== 1100(developers studio 5.0)
#ifdef WIN32
typedef __int64 SINT64;
typedef unsigned __int64 UINT64;
#else // WIN32
typedef long long SINT64;
typedef unsigned long long UINT64;
#endif // WIN32
typedef float FLOAT;
typedef double DOUBLE;
typedef unsigned char U8;
typedef signed char S8;
typedef unsigned short U16;
typedef signed short S16;
typedef unsigned int U32;
typedef signed int S32;
#define SIZE_SINT 4
#define SIZE_SINT16 2
#define SIZE_UINT16 2
#define SIZE_SINT32 4
#define SIZE_UINT32 4
#define SIZE_SINT64 8
#define SIZE_UINT64 8
#define SIZE_FLOAT 4
#define SIZE_DOUBLE 8
typedef SINT* PSINT;
typedef PSINT* PPSINT;
typedef SINT16* PSINT16;
typedef PSINT16* PPSINT16;
typedef UINT16* PUINT16;
typedef PUINT16* PPUINT16;
typedef SINT32* PSINT32;
typedef PSINT32* PPSINT32;
typedef UINT32* PUINT32;
typedef PUINT32* PPUINT32;
typedef SINT64* PSINT64;
typedef PSINT64* PPSINT64;
typedef UINT64* PUINT64;
typedef PUINT64* PPUINT64;
typedef FLOAT* PFLOAT;
typedef PFLOAT* PPFLOAT;
typedef DOUBLE* PDOUBLE;
typedef PDOUBLE* PPDOUBLE;
#if !(defined(BOOL) || defined(TRUE) || defined(FALSE))
#define BOOL int
#define TRUE 1
#define FALSE 0
#endif
#if 1 // def WIN32
#define DECLARE_VOIDHANDLE(name) struct __##name##__ { int unused; }; typedef const struct __##name##__* name
#define DECLARE_CLASS(name) __DECLARE_CLASS(C,name)
#define DECLARE_CLASS_PTR(name) __DECLARE_CLASS_PTR(C,name)
#define __DECLARE_CLASS(prefix,name) class prefix##name; typedef class prefix##name* P##name; typedef const class prefix##name* PC##name
#define __DECLARE_CLASS_PTR(prefix,name) __DECLARE_CLASS(prefix, name); typedef P##name* PP##name; typedef PC##name* PPC##name
#define DECLARE_STRUCT(name) __DECLARE_STRUCT(S,name)
#define DECLARE_STRUCT_PTR(name) __DECLARE_STRUCT_PTR(S,name)
#define __DECLARE_STRUCT(prefix,name) struct prefix##name; typedef struct prefix##name* P##name; typedef const struct prefix##name* PC##name;
#define __DECLARE_STRUCT_PTR(prefix,name) __DECLARE_STRUCT(prefix,name); typedef P##name* PP##name; typedef PC##name* PPC##name
#endif // WIN32
#define DLLDAT // will be redefined, if necessary in dllapi.h
#define DLLAPI // will be redefined, if necessary in dllapi.h
#define DLLCLS // will be redefined, if necessary in dllapi.h
#endif // RC_INVOKED
#endif // __STDDEFS__
+193
View File
@@ -0,0 +1,193 @@
#if !defined(__BSEARCH__)
#define __BSEARCH__
// stealed from bsearch.c
#if !defined(FASTAPICALLCONVENTION)
#if defined(_WINDOWS)
#ifdef WIN32
#define FASTAPICALLCONVENTION __fastcall
#else // !WIN32
#define FASTAPICALLCONVENTION PASCAL
#endif // WIN32
#else // !defined(_WINDOWS)
#define FASTAPICALLCONVENTION
#endif // defined(_WINDOWS)
#endif // !defined(TSORTCALL)
#define TBSEARCH_SAMEVALUE(TYPE,key,ptr,count) TBSEARCH<TYPE, TYPE, TBsearchSameDiff<TYPE,TYPE> >::bsearch(key,ptr,count)
#define TBSEARCH_SAMEVALUEUNSIGNED(TYPE,key,ptr,count) TBSEARCH<TYPE, TYPE, TBsearchSameDiffUnsigned<TYPE,TYPE> >::bsearch(key,ptr,count)
#define TBSEARCH_SAMEMEM(TYPE,pKey,ptr,count) TBSEARCH<const TYPE*, TYPE, TBsearchSameMEM<const TYPE*,TYPE> >::bsearch(pKey,ptr,count)
#define TBSEARCH_SAMEPTR(TYPE,pKey,ptr,count) TBSEARCH<const TYPE*, TYPE, TBsearchSameDiffUnsigned<const TYPE,TYPE> >::bsearch(pKey,ptr,count)
#define TBRANGE_SAMEVALUE(TYPE,key,ptr,count,bRange) TBRANGE<TYPE, TYPE, TBsearchSameDiff<TYPE,TYPE> >::GetIndexViaKey(key,ptr,count,bRange)
#define TBRANGE_SAMEVALUEUNSIGNED(TYPE,key,ptr,count,bRange) TBRANGE<TYPE, TYPE, TBsearchSameDiffUnsigned<TYPE,TYPE> >::GetIndexViaKey(key,ptr,count,bRange)
#define TBRANGE_SAMEMEM(TYPE,pKey,ptr,count,bRange) TBRANGE<const TYPE*, TYPE, TBsearchSameMEM<const TYPE*,TYPE> >::GetIndexViaKey(pKey,ptr,count,bRange)
#define TBRANGE_SAMEPTR(TYPE,pKey,ptr,count,bRange) TBRANGE<const TYPE*, TYPE, TBsearchSameDiffUnsigned<const TYPE,TYPE> >::GetIndexViaKey(pKey,ptr,count,bRange)
template <class KEY, class TYPE>
struct TBsearchSameDiff
{
static int FASTAPICALLCONVENTION Compare(KEY key, const TYPE* pb)
{
return key - *pb;
}
};
template <class KEY, class TYPE>
struct TBsearchSameDiffUnsigned
{
static int FASTAPICALLCONVENTION Compare(KEY key, const TYPE* pb)
{
TYPE tmp = *pb;
if (key != tmp) {
if (key > tmp)
return +1;
return -1;
}
return 0;
}
};
template <class KEY, class TYPE>
struct TBsearchSameMEM
{
static int FASTAPICALLCONVENTION Compare(KEY key, const TYPE* pb)
{
return memcmp(key, pb, sizeof(TYPE));
}
};
template <class KEY, class TYPE, class COMP>
struct TBSEARCH
{
public:
public:
static TYPE* FASTAPICALLCONVENTION bsearch(KEY key, const TYPE* base, size_t num)
{
/***
*TYPE *bsearch() - do a binary search on an array
*
*Purpose:
* Does a binary search of a sorted array for a key.
*
*Entry:
* const char *key - key to search for
* const char *base - base of sorted array to search
* unsigned int num - number of elements in array
*
*Exit:
* if key is found:
* returns pointer to occurrence of key in array
* if key is not found:
* returns NULL
*
*Exceptions:
*
*******************************************************************************/
BYTE *lo = (BYTE *)base;
BYTE *hi = (BYTE *)base + (num - 1) * sizeof(TYPE);
BYTE *mid;
size_t half;
int result;
while(lo <= hi) {
if ((half = num / 2) != 0) {
mid = lo + (num & 1 ? half : (half - 1)) * sizeof(TYPE);
if ((result = COMP::Compare(key, (const TYPE*)mid)) == 0)
return (TYPE*)mid;
else if (result < 0) {
hi = mid - sizeof(TYPE);
num = num & 1 ? half : half-1;
} else {
lo = mid + sizeof(TYPE);
num = half;
}
} else if (num)
return (TYPE*)(COMP::Compare(key, (const TYPE*)lo) ? NULL : lo);
else
break;
}
return NULL;
}
};
template <class KEY, class TYPE, class COMP>
struct TBRANGE
{
public:
public:
static int FASTAPICALLCONVENTION GetIndexViaKey(KEY key, const TYPE* base, int nSize, BOOL bRange = FALSE)
{
if (nSize > 0) {
int nNum = nSize;
const TYPE* pStart = &base[0];
const TYPE* pLo = pStart;
const TYPE* pHi = &pStart[nNum - 1];
const TYPE* pMd;
int nHalf;
int nIndex;
int nDiffer;
while(pLo <= pHi) {
nHalf = nNum / 2;
if (nHalf) {
int nNum2 = nNum & 1 ? nHalf : (nHalf - 1);
pMd = &pLo[nNum2];
nDiffer = COMP::Compare(key, pMd);
if (nDiffer) {
if (nDiffer > 0) {
pLo = &pMd[1];
nNum = nHalf;
} else {
nNum = nNum2;
if (!nNum) {
if (bRange) {
nIndex = pLo - pStart;
goto check_1below;
}
break;
}
pHi = &pMd[-1];
}
} else {
nIndex = pMd - pStart;
pLo = pMd;
goto check_before;
}
} else {
ASSERT(nNum == 1);
nDiffer = COMP::Compare(key, pLo);
nIndex = pLo - pStart;
if (bRange) {
if (nDiffer < 0) {
check_1below:
if (0 < nIndex) {
pLo--;
if (COMP::Compare(key, pLo) >= 0) {
ASSERT(COMP::Compare(key, pLo) != 0);
nIndex--;
goto check_before;
}
}
break;
}
} else {
if (nDiffer != 0)
break;
}
check_before:
return nIndex;
}
}
}
return -1;
}
};
#endif // !defined(__BSEARCH__)
File diff suppressed because it is too large Load Diff
+174
View File
@@ -0,0 +1,174 @@
#if !defined(__CTCL_H__)
#define __CTCL_H__
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the CTCL_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// CTCL_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#define CTCL_API _stdcall
#if !defined(BOOL)
#define BOOL int
#if !defined(TRUE)
#define TRUE 1
#define FALSE 0
#endif // !defined(TRUE)
#endif // !defined(BOOL)
#pragma pack(push, 1)
#if !defined(CTCLS_EXPORTS)
class CInviteCOOP
{
public:
void* m_pParent;
int m_nTimeInvite;
int m_nResult; // 0: not inited, 1: requesting, 2: no, 3: yes...
int m_nResultAccepted;
GUID m_guidGameData;
public:
CInviteCOOP();
void Clear();
};
#endif // !defined(CTCLS_EXPORTS)
struct STeslaInfo
{
public:
BOOL m_bCameraShip;
unsigned long m_ulAddr;
const char* m_pcsz;
int m_nLauncherConnection; // 0: no connection, +1: connection, -1: connecting
int m_nConnection2; // m_bCameraShip값에 따라 게임 혹은 카메라 쉽과의 접속을 의미, 0: no connection, +1: connection, -1: connecting
int m_nApplType;
int m_nApplState;
int m_nGameState;
int m_nGameTime;
int m_nGameIsServer;
public:
};
#define MAX_PLYR_NAME 20
struct SPlayerInfo
{
public:
BYTE m_bBot;
BYTE m_bTeam;
int m_nLevelOrTesla;
char m_szName[MAX_PLYR_NAME];
UINT m_uPlayerID;
int m_nMechIndex;
short m_fileID;
WORD m_recordID;
char m_szMech[64];
int m_nTeamOrSkin;
int m_nDecal;
DWORD m_dwAddr;
};
#pragma pack(pop)
#define C_GameInfo 1 // Console 2 Launcher
#define S_GameInfo 1 // Launcher 2 Console
#define C_OrderAppl 10 // Console 2 Launcher
#define C_ErrorStartGame 19 // to server & client - error occurred, to mainmenu
#define C_ReadyStartGame 20 // to server - Game Server Start w/ HostSetup & Mission Params...
#define C_BOTS 21 // to server - Bot Infos
#define C_SetMechs 22 // to server & client -
#define C_GetReady 23 // to server & client -
#define C_DoLaunch 24 // to server
#define S_GameReturn 30 // game to console
#define C_SendFile 40
#define S_SendFile 40
#define C_InviteCOOP 50 // to server & client - invite clients
#define S_InviteCOOP 50 // to server & client - reply to server for invitation
class CTeslaInfo;
typedef CTeslaInfo* TESLA_HANDLE;
BOOL CTCL_API CTCL_Start(int nCTCLType);
void CTCL_API CTCL_Stop();
void CTCL_API CTCL_Run();
// Used by All
int CTCL_API CTCL_API CTCL_GetType();
BOOL CTCL_API CTCL_IsNone(); // no -ctcltype...
BOOL CTCL_API CTCL_IsConsole(); // Console Only
bool CTCL_API CTCL_IsCOOP(); // is COOP?
BOOL CTCL_API CTCL_IsConsoleOrCOOP(); // Console or COOP(COin OPerational)
BOOL CTCL_API CTCL_IsConsoleX(); // Game & Cameraship
// Used by Console(+ COOP)
int CTCL_API CTCL_GetTeslaCountAll();
int CTCL_API CTCL_GetTeslaCount();
TESLA_HANDLE CTCL_API CTCL_GetTeslaInfo(int nIndex, STeslaInfo& TI);
int CTCL_API CTCL_InviteCOOP(int nTimeInvite, int& nYes, int& nNo);
const char* CTCL_API CTCL_GetTeslaName(int nIndex);
int CTCL_API CTCL_OrderAppl(int nIndex, int nOrder, int nParam);
// Used by Launcher
// Used by Game
// Used by CameraShip
void CTCL_API CTCL_DoTerminateAppl();
void CTCL_API CTCL_DoEndMission();
void CTCL_API CTCL_DoMainShell();
void CTCL_API CTCL_DoCreateGame();
void CTCL_API CTCL_DoJoinGame();
void CTCL_API CTCL_StartGame(BOOL bRealLaunch);
void CTCL_API CTCL_InitMechDatas();
void CTCL_API CTCL_CheckJoinGame();
void CTCL_API CTCL_CheckNetConnectedToServer();
void CTCL_API CTCL_SetMissionParams();
void CTCL_API CTCL_CheckMissionParams();
void CTCL_API CTCL_SetMechs();
void CTCL_API CTCL_CheckClientReady();
void CTCL_API CTCL_CheckServerReady();
void CTCL_API CTCL_DefaultHostSetup(int nMode);
// from here - Mech4 only
void CTCL_API CTCL_DoSendGameReturn(int nValue);
void CTCL_API CTCL_SaveNMP(const void* p, int nSize);
void* CTCL_API CTCL_LoadNMP(int& nSize);
void CTCL_API CTCL_SendFile(const SYSTEMTIME& SysTime, const GUID& guid, int nType);
bool CTCL_API CTCL_DoReprintOrCheck(bool bRealPrint);
void CTCL_API CTCL_SetGameStateAsIdle();
// to here - Mech4 only
extern "C" {
extern int g_nCTCLType;
extern int g_nCTCL_DoLaunchGame;
#if !defined(CTCLS_EXPORTS)
extern CInviteCOOP g_InviteCOOP;
// console only...
// Mech4 only
extern int g_nMech4Comm;
// server & client only
extern BOOL g_bIsServer;
// console(All), server & client only(g_aPlayerInfos[0]), server only(g_aPlayerInfos[1..g_nBOTs]
extern SPlayerInfo g_aPlayerInfos[20];
extern int g_nPlayerInfos;
extern int g_nServer;
extern int g_nTeslas;
extern int g_nPrintOut;
extern int g_nMissionReview;
extern SYSTEMTIME g_SysTime;
extern GUID g_guidGameDatas;
// Tesla Server & Clients only
extern char g_szGameName[128];
extern int g_nBOTs;
extern DWORD g_dwJoinStartTicks;
#endif // !defined(CTCLS_EXPORTS)
extern const char PROF_INI[];
extern const char SECT_TESLAS[];
extern const char SECT_GAMES[];
extern const char SECT_CONFIG[];
} // end of extern "C"
#endif // !defined(__CTCL_H__)
+49
View File
@@ -0,0 +1,49 @@
#define _EAT_None 0
#define _EAT_MW4 1
#define _EAT_RP 2
#define _EAT_MAX 2 // max appl count...
#define _EAS_None 0
#define _EAS_PreLaunch 1
#define _EAS_Launched 2
#define _EAS_PostLaunch 3
#define _EGS_None 0
#define _EGS_Idle 1
#define _EGS_Preparing 2
#define _EGS_Running 3
#define _EGS_Closing 4
#define _EGR_NotConnected (-2)
#define _EGR_Connected (-1)
#define _EGR_NoError 0
#define _EGR_PreparingStarted 1
#define _EGR_ErrCreateSession 2
#define _EGR_OkCreateSession 3
#define _EGR_OkLaunchReady 4
#define _EGR_ErrJoinSession 5
#define _EGR_OkJoinSession 6
// CTCL_GetType return value
#define _ECTCL_Launcher 0
#define _ECTCL_Console 1 // CTCL_IsConsole()
#define _ECTCL_Game 2
#define _ECTCL_CameraShip 3
#define _ECTCL_None 4
// CTCL_Get/Set Param...
#define _CTCL_GetTeslaCountAll 100
#define _CTCL_GetTeslaCount 101
#define _CTCL_GetTeslaInfo 102
#define _CTCL_GetTeslaName 103
#define _CTCL_OrderAppl 104 // param: 0 - terminate, 1 - launch, 2 - end mission
#define _CTCL_Order_Terminate 0
#define _CTCL_Order_EndMission 1
#define _CTCL_Order_Launch 100
#define _CTCL_Order_Shutdown 101
#define _CTCL_Order_Reboot 102
#define _CTCL_Order_Unload 103
#define _CTCL_GetInviteCOOP 105
#define _CTCL_SetInviteCOOP 106
+26
View File
@@ -0,0 +1,26 @@
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the CTCLS_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// CTCLS_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef CTCLS_EXPORTS
#define CTCLS_API __declspec(dllexport)
#else
#define CTCLS_API __declspec(dllimport)
#endif
#include "ctcl_params.h"
CTCLS_API DWORD CTCL_GetVersion();
CTCLS_API int CTCL_GetApplType();
CTCLS_API void CTCL_SetApplType(int nApplType);
CTCLS_API int CTCL_GetApplState();
CTCLS_API void CTCL_SetApplState(int nApplState);
CTCLS_API int CTCL_GetGameState();
CTCLS_API void CTCL_SetGameState(int nGameState);
CTCLS_API int CTCL_GetGameTime();
CTCLS_API void CTCL_SetGameTime(int nGameTime);
CTCLS_API int CTCL_GetGameIsServer();
CTCLS_API void CTCL_SetGameIsServer(int nGameIsServer);
+191
View File
@@ -0,0 +1,191 @@
#include "stdafx.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/*
BOOL IsLeapYear(int nYear)
{
// nYear is in Solar system, 1982...
if (nYear % 4 == 0) {
if (nYear % 100 == 0) {
if (nYear % 400 == 0) {
//...
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
int GetDayEnd(int nYear, int nMonth)
{
int nDayEnd;
if (nMonth == 2) {
nDayEnd = 28;
if (IsLeapYear(nYear)) {
nDayEnd++;
} else {
// 28
}
} else {
nDayEnd = 30;
if ((nMonth == 1) || (nMonth == 3) || (nMonth == 5) || (nMonth == 7) || (nMonth == 8) || (nMonth == 10) || (nMonth == 12))
nDayEnd++; // 31
}
return nDayEnd;
}
long GetTotalSeconds(int nYear, int nMonth, int nDay)
{
// nYear, nMonth, nDay날의 0시 0분 0초를 0으로 한 초단위 수...
ASSERT(nYear >= 1970);
ASSERT((1 <= nMonth) && (nMonth <= 12));
ASSERT(1 <= nDay);
ASSERT(nDay <= GetDayEnd(nYear, nMonth));
long lTotal = 0;
int nStart;
for(nStart = 1970; nStart < nYear; nStart++) {
int nDays = 365;
if (IsLeapYear(nStart)) {
nDays++;
}
lTotal += nDays * 24 * 60 * 60; // 24시간 60분 60초
}
for(nStart = 1; nStart < nMonth; nStart++) {
int nDayEnd = GetDayEnd(nYear, nStart);
lTotal += nDayEnd * 24 * 60 * 60; // 24시간 60분 60초
}
lTotal += (nDay - 1) * 24 * 60 * 60; // 24시간 60분 60초
return lTotal;
}
*/
BOOL CTimeDate::IsLeapYear(int nYear)
{
// nYear is in Solar system, 1982...
if (nYear % 4 == 0) {
if (nYear % 100 == 0) {
if (nYear % 400 == 0) {
//...
return FALSE;
}
}
return TRUE;
}
return FALSE;
}
long CTimeDate::GetCurrent()
{
CTimeDate t;
t.CurrentDate();
return t.m_lDate;
}
void CTimeDate::CurrentDate()
{
ASSERT(this);
time_t t;
struct tm* p;
time(&t);
p = localtime(&t);
m_lDate = 0;
m_LN.m_xDay = p->tm_mday - 1;
m_LN.m_xMonth = p->tm_mon;
m_LN.m_xYear = (p->tm_year + 1900) - TIMEDATE_YEAR_BASE;
//m_LN.m_xReserved = 0;
//m_LN.m_xLunar = 0;
//m_LN.m_xLeap = 0;
}
BOOL CTimeDate::GetDate(long lDate, BOOL bLunar/* = FALSE*/, BOOL bLeap/* = FALSE*/)
{
ASSERT(!bLunar && !bLeap); // not yet implemented...
int nDay = lDate % 100;
lDate /= 100;
int nMonth = lDate % 100;
lDate /= 100;
int nYear = lDate;
BOOL bLeapYear = IsLeapYear(nYear);
nYear -= TIMEDATE_YEAR_BASE;
if ((nYear < 0) || (nYear >= (1 << TIMEDATE_YEAR_BITS)))
return FALSE;
if (!((1 <= nMonth) && (nMonth <= 12))) {
return FALSE;
}
int nDayMax = 30;
switch(nMonth) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
nDayMax++; // 31
break;
case 2:
nDayMax--; // 29
if (!bLeapYear) {
nDayMax--; // 28
}
break;
default:
break;
}
if (!((1 <= nDay) && (nDay <= nDayMax))) {
return FALSE;
}
nMonth--;
nDay--;
m_lDate = 0;
m_LN.m_xYear = nYear;
m_LN.m_xMonth = nMonth;
m_LN.m_xDay = nDay;
//m_LN.m_xReserved = 0;
//m_LN.m_xLunar = 0;
//m_LN.m_xLeap = 0;
return TRUE;
}
long CTimeLong::GetCurrent()
{
CTimeLong t;
t.CurrentTime();
return t.m_lTime;
}
void CTimeLong::CurrentTime()
{
ASSERT(this);
time_t t;
time(&t);
m_lTime = t;
}
void CTimeLong::GetTime(tm& t) const
{
ASSERT(this);
t = *localtime(&m_lTime);
}
+55
View File
@@ -0,0 +1,55 @@
#if !defined(__CTIME__)
#define __CTIME__
#if !defined(TIMEDATE_YEAR_BASE)
#define TIMEDATE_YEAR_BASE 1900
#endif // !defined(TIMEDATE_YEAR_BASE)
#if !defined(TIMEDATE_YEAR_BITS)
#define TIMEDATE_YEAR_BITS 8
#endif // !defined(TIMEDATE_YEAR_BITS)
#define TIMEDATE_RESERVED_BITS (32 - (5 + 4 + TIMEDATE_YEAR_BITS + 1 + 1)) // 13?
class CTimeDate
{
public:
union {
struct {
// Bit Field는 앞쪽에 지정된 것이 LowBit이다.
DWORD m_xDay: 5; // 2^0, 2^5-1
DWORD m_xMonth: 4; // 2^5, 2^4-1
DWORD m_xYear: TIMEDATE_YEAR_BITS; // from 1900-2155 // 2^9, 2^8-1
DWORD m_xReserved: TIMEDATE_RESERVED_BITS; // 2^17,2^13-1
DWORD m_xLunar: 1; // lunar system not solar system // 2^30, 2^1-1
DWORD m_xLeap: 1; // leap month? in case of lunar system // 2^31, 2^1-1
} m_LN;
long m_lDate;
};
public:
CTimeDate() { m_lDate = 0; } // TIMEDATE_YEAR_BASE/1/1 in solar
CTimeDate(const CTimeDate& that) { m_lDate = that.m_lDate; }
operator long& () { return *(long*)&m_lDate; }
static BOOL IsLeapYear(int nYear);
static long GetCurrent();
int const GetYear() const { return m_LN.m_xYear + TIMEDATE_YEAR_BASE; }
int const GetMonth() const { return m_LN.m_xMonth; }
int const GetDay() const { return m_LN.m_xDay; }
void CurrentDate();
BOOL GetDate(long lDate, BOOL bLunar = FALSE, BOOL bLeap = FALSE);
};
class CTimeLong
{
public:
long m_lTime; // time_t
public:
CTimeLong() { m_lTime = 0; }
CTimeLong(const CTimeLong& that) { m_lTime = that.m_lTime; }
operator long& () { return *(long*)&m_lTime; }
static long GetCurrent();
void CurrentTime();
void GetTime(tm& t) const;
};
#endif //!defined(__CTIME__)
+748
View File
@@ -0,0 +1,748 @@
#if !defined(__DBLINKS__)
#define __DBLINKS__
#ifndef NULL_CLASS_DEFINED
#define NULL_CLASS_DEFINED
class CNullClass {};
#endif
#define TDBLNK(TYPE) TDoubleLinkRef<TYPE,CNullClass> // TDBLNK(CObject*)
#define TDBLNKCUT(TYPE) TDoubleLinkCut<TYPE,CNullClass> // TDBLNKDESTROY(TDBLNK(CObject*))
#define TDBLNKFREE(TYPE) TDoubleLinkFree<TYPE,CNullClass> // TDBLNKFREE(TDBLNK(CObject*))
#define TDBLNKDESTROY(TYPE) TDoubleLinkDestroy<TYPE,CNullClass> // TDBLNKDESTROY(TDBLNK(CObject*))
#define TDBLNKTREE(TYPE) TDoubleLinkTreeRef<TYPE,CNullClass> // TDBLNKTREE(CObject*)
#if !defined(DO_VERIFY)
#ifdef _DEBUG
#define DO_VERIFY 0
#else // !_DEBUG
#define DO_VERIFY 0
#endif // _DEBUG
#endif // !defined(DO_VERIFY)
template <class TYPE, class BaseClass>
class TDoubleLinkRef : public BaseClass
{
public:
TYPE m_pPrev;
TYPE m_pNext;
public:
#if DO_VERIFY
void VerifyLinks(const TYPE& pHead) const
{
ASSERT(&pHead);
if (pHead) {
ASSERT(!pHead->m_pPrev);
TYPE pLink = (TYPE)this;
while(pLink != pHead) {
ASSERT(pLink);
pLink = pLink->m_pPrev;
}
while((pLink = pLink->m_pNext) != NULL)
;
} else {
ASSERT(!this);
}
}
#endif // DO_VERIFY
public:
TDoubleLinkRef()
{
m_pPrev = NULL;
m_pNext = NULL;
}
static TYPE CutHead(TYPE& pHead);
static void CutListAll(TYPE& pHead);
static void FreeListAll(TYPE& pHead);
static void DestroyListAll(TYPE& pHead);
int GetCount() const;
TYPE GetHead() const;
TYPE GetTail() const;
TYPE GetNeighbor(BOOL bNext);
TYPE GetTerminal(BOOL bNext);
BOOL CutCheck(TYPE& pHead);
TYPE Cut(TYPE& pHead);
void InsHead(TYPE& pHead);
void InsBefore(TYPE& pHead, TYPE pPrev = NULL);
void InsAfter(TYPE& pHead, TYPE pNext = NULL);
void AddTail(TYPE& pHead);
TYPE CutGroup(TYPE& pHead);
void InsHeadGroup(TYPE& pHead);
void InsGroup(TYPE& pHead, TYPE pPrev = NULL);
void AddTailGroup(TYPE& pHead);
};
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::CutHead(TYPE& pHead)
{
#if DO_VERIFY
pHead->VerifyLinks(pHead);
#endif // DO_VERIFY
TYPE pLink = pHead;
if (pLink) {
ASSERT(!pLink->m_pPrev);
TYPE pLink2 = pLink->m_pNext;
if (pLink2) {
ASSERT(pLink2->m_pPrev == pLink);
pLink2->m_pPrev = NULL;
pLink->m_pNext = NULL;
}
pHead = pLink2;
}
return pLink;
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::CutListAll(TYPE& pHead)
{
#if DO_VERIFY
pHead->VerifyLinks(pHead);
#endif // DO_VERIFY
TYPE pLink;
while((pLink = CutHead(pHead)) != NULL)
;
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::FreeListAll(TYPE& pHead)
{
#if DO_VERIFY
pHead->VerifyLinks(pHead);
#endif // DO_VERIFY
TYPE pLink;
while((pLink = CutHead(pHead)) != NULL)
free(pLink);
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::DestroyListAll(TYPE& pHead)
{
#if DO_VERIFY
pHead->VerifyLinks(pHead);
#endif // DO_VERIFY
TYPE pLink;
while((pLink = CutHead(pHead)) != NULL)
delete pLink;
}
template <class TYPE, class BaseClass>
int TDoubleLinkRef<TYPE, BaseClass>::GetCount() const
{
int nCount = 0;
TYPE pLink = (TYPE)this;
while(pLink) {
nCount++;
pLink = pLink->m_pNext;
}
return nCount;
}
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::GetHead() const
{
TYPE p = (TYPE)this;
if (p) {
TYPE pLink;
while((pLink = p->m_pPrev) != NULL)
p = pLink;
}
return p;
}
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::GetTail() const
{
TYPE p = (TYPE)this;
if (p) {
TYPE pLink;
while((pLink = p->m_pNext) != NULL)
p = pLink;
}
return p;
}
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::GetNeighbor(BOOL bNext)
{
ASSERT(this);
if (bNext)
return m_pNext;
return m_pPrev;
}
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::GetTerminal(BOOL bNext)
{
if (bNext) {
return GetTail();
}
return GetHead();
}
template <class TYPE, class BaseClass>
BOOL TDoubleLinkRef<TYPE, BaseClass>::CutCheck(TYPE& pHead)
{
ASSERT(this);
TYPE pPrev = m_pPrev;
if (pPrev) {
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
pPrev->m_pNext = m_pNext;
TYPE pNext;
if ((pNext = m_pNext) != NULL) {
pNext->m_pPrev = pPrev;
m_pNext = NULL;
}
m_pPrev = NULL;
return TRUE;
} else {
if (this == pHead) {
TYPE pNext = m_pNext;
pHead = pNext;
if (pNext) {
pNext->m_pPrev = NULL;
m_pNext = NULL;
}
return TRUE;
} else {
ASSERT(!m_pNext);
return FALSE;
}
}
}
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::Cut(TYPE& pHead)
{
ASSERT(this);
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
TYPE pPrev = m_pPrev;
TYPE pNext = m_pNext;
if (pPrev) {
pPrev->m_pNext = pNext;
if (pNext != NULL) {
pNext->m_pPrev = pPrev;
m_pNext = NULL;
}
m_pPrev = NULL;
} else {
ASSERT(this == pHead);
pHead = pNext;
if (pNext) {
pNext->m_pPrev = NULL;
m_pNext = NULL;
}
}
return pPrev;
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::InsHead(TYPE& pHead)
{
ASSERT(this && !m_pPrev && !m_pNext);
m_pNext = pHead;
if (pHead) {
pHead->m_pPrev = (TYPE)this;
}
pHead = (TYPE)this;
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::InsBefore(TYPE& pHead, TYPE pPrev/* = NULL*/)
{
ASSERT(this && !m_pPrev && !m_pNext);
if (pPrev) {
TYPE pPrevPrev = pPrev->m_pPrev;
pPrev->m_pPrev = (TYPE)this;
m_pNext = pPrev;
if (pPrevPrev) {
pPrevPrev->m_pNext = (TYPE)this;
m_pPrev = pPrevPrev;
} else {
pHead = (TYPE)this;
}
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
} else {
AddTail(pHead);
}
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::InsAfter(TYPE& pHead, TYPE pNext/* = NULL*/)
{
ASSERT(this && !m_pPrev && !m_pNext);
if (pNext) {
TYPE pNextNext = pNext->m_pNext;
pNext->m_pNext = (TYPE)this;
m_pPrev = pNext;
if (pNextNext) {
pNextNext->m_pPrev = (TYPE)this;
m_pNext = pNextNext;
}
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
} else {
AddTail(pHead);
}
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::AddTail(TYPE& pHead)
{
ASSERT(this && !m_pPrev && !m_pNext);
if (pHead) {
TYPE pTail = pHead->GetTail();
ASSERT(pTail && !pTail->m_pNext);
pTail->m_pNext = (TYPE)this;
m_pPrev = pTail;
} else {
pHead = (TYPE)this;
}
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
}
template <class TYPE, class BaseClass>
TYPE TDoubleLinkRef<TYPE, BaseClass>::CutGroup(TYPE& pHead)
{
if (this) {
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
TYPE pPrev = m_pPrev;
if (pPrev) {
pPrev->m_pNext = NULL;
m_pPrev = NULL;
} else {
ASSERT(this == pHead);
pHead = NULL;
}
}
return (TYPE)this;
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::InsHeadGroup(TYPE& pHead)
{
if (this) {
ASSERT(!m_pPrev);
if (pHead) {
TYPE pTail = GetTail();
pTail->m_pNext = pHead;
pHead->m_pPrev = pTail;
}
pHead = (TYPE)this;
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
}
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::InsGroup(TYPE& pHead, TYPE pPrev/* = NULL*/)
{
if (this) {
ASSERT(!m_pPrev);
if (pPrev) {
TYPE pNext = pPrev->m_pNext;
pPrev->m_pNext = (TYPE)this;
m_pPrev = pPrev;
if (pNext) {
TYPE pTail = GetTail();
pTail->m_pNext = pNext;
pNext->m_pPrev = pTail;
}
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
} else {
InsHeadGroup(pHead);
}
}
}
template <class TYPE, class BaseClass>
void TDoubleLinkRef<TYPE, BaseClass>::AddTailGroup(TYPE& pHead)
{
if (this) {
ASSERT(!m_pPrev);
if (pHead) {
TYPE pTail = pHead->GetTail();
ASSERT(pTail && !pTail->m_pNext);
pTail->m_pNext = (TYPE)this;
m_pPrev = pTail;
} else {
pHead = (TYPE)this;
}
#if DO_VERIFY
VerifyLinks(pHead);
#endif // DO_VERIFY
}
}
template <class TYPE, class BaseClass>
class TDoubleLink : public BaseClass
{
public:
TYPE* m_pLinkStart;
public:
TDoubleLink()
{
m_pLinkStart = NULL;
}
~TDoubleLink()
{
ASSERT(!m_pLinkStart);
}
operator TYPE* () const { return m_pLinkStart; }
TYPE* CutHead()
{
return TYPE::CutHead(m_pLinkStart);
}
void CutListAll()
{
TYPE::CutListAll(m_pLinkStart);
}
void FreeListAll()
{
TYPE::FreeListAll(m_pLinkStart);
}
void DestroyListAll()
{
TYPE::DestroyListAll(m_pLinkStart);
}
int GetCount() const
{
return m_pLinkStart->GetCount();
}
TYPE* GetHead() const
{
return m_pLinkStart;
}
TYPE* GetTail() const
{
return m_pLinkStart->GetTail();
}
BOOL CutCheck(TYPE* pLink)
{
return pLink->CutCheck(m_pLinkStart);
}
TYPE* Cut(TYPE* pLink)
{
return pLink->Cut(m_pLinkStart);
}
void InsHead(TYPE* pLink)
{
pLink->InsHead(m_pLinkStart);
}
void InsBefore(TYPE* pLink, TYPE* pPrev = NULL)
{
pLink->InsBefore(m_pLinkStart, pPrev);
}
void InsAfter(TYPE* pLink, TYPE* pNext = NULL)
{
pLink->InsAfter(m_pLinkStart, pNext);
}
void AddTail(TYPE* pLink)
{
pLink->AddTail(m_pLinkStart);
}
TYPE* CutGroup(TYPE* pLink)
{
return pLink->CutGroup(m_pLinkStart);
}
void InsHeadGroup(TYPE* pLink)
{
pLink->InsHeadGroup(m_pLinkStart);
}
void InsGroup(TYPE* pLink, TYPE* pPrev = NULL)
{
pLink->InsGroup(m_pLinkStart, pPrev);
}
void AddTailGroup(TYPE* pLink)
{
pLink->AddTailGroup(m_pLinkStart);
}
TYPE* FindIndex(int nIndex) const
{
if (nIndex >= 0) {
TYPE* pLink = m_pLinkStart;
while(pLink) {
if (nIndex == 0) {
return pLink;
}
pLink = pLink->m_pNext;
nIndex--;
}
}
return NULL;
}
int Find(TYPE* pLink) const
{
if (pLink) {
int nIndex = 0;
TYPE* pLink2 = m_pLinkStart;
while(pLink2) {
if (pLink2 == pLink) {
return nIndex;
}
pLink2 = pLink2->m_pNext;
nIndex++;
}
}
return -1;
}
};
template <class TYPE, class BaseClass>
class TDoubleLinkCut : public TDoubleLink<TYPE, BaseClass>
{
public:
~TDoubleLinkCut()
{
Reset();
}
void Reset()
{
CutListAll();
}
void Del(TYPE* pLink)
{
CutCheck(pLink);
}
};
template <class TYPE, class BaseClass>
class TDoubleLinkFree : public TDoubleLink<TYPE, BaseClass>
{
public:
~TDoubleLinkFree()
{
Reset();
}
void Reset()
{
FreeListAll();
}
void Del(TYPE* pLink)
{
CutCheck(pLink);
free(pLink);
}
};
template <class TYPE, class BaseClass>
class TDoubleLinkDestroy : public TDoubleLink<TYPE, BaseClass>
{
public:
~TDoubleLinkDestroy()
{
Reset();
}
void Reset()
{
DestroyListAll();
}
void Del(TYPE* pLink)
{
CutCheck(pLink);
delete pLink;
}
};
template <class TYPE, class BaseClass>
class TDoubleLinkTreeRef : public TDoubleLinkRef<TYPE, BaseClass>
{
public:
TYPE m_pParent;
TYPE m_pChild;
public:
TDoubleLinkTreeRef()
{
m_pParent = NULL;
m_pChild = NULL;
}
#ifdef _DEBUG
~TDoubleLinkTreeRef()
{
ASSERT(!(m_pPrev || m_pNext || m_pParent));
}
#endif // _DEBUG
int CountChildren() const
{
return m_pChild->TDoubleLinkRef<TYPE, BaseClass>::GetCount();
}
int CountChildrenAll() const
{
if (this) {
TYPE pChild = m_pChild;
int nCount;
for(nCount = 0; pChild; nCount++) {
nCount += pChild->CountChildrenAll();
pChild = pChild->m_pNext;
}
return nCount;
}
return 0;
}
int CountParent() const
{
ASSERT(this);
TYPE pParent = m_pParent;
int nCount = 0;
while(pParent) {
nCount++;
pParent = pParent->m_pParent;
}
return nCount;
}
TYPE CutChild(TYPE pLink)
{
ASSERT(pLink->m_pParent == (TYPE)this);
TYPE pPrev = pLink->TDoubleLinkRef<TYPE, BaseClass>::Cut(m_pChild);
pLink->m_pParent = NULL;
return pPrev;
}
void InsChild(TYPE pLink)
{
pLink->TDoubleLinkRef<TYPE, BaseClass>::InsHead(m_pChild);
pLink->m_pParent = (TYPE)this;
}
void InsChildBefore(TYPE pLink, TYPE pPrev = NULL)
{
pLink->TDoubleLinkRef<TYPE, BaseClass>::InsBefore(m_pChild, pPrev);
pLink->m_pParent = (TYPE)this;
}
void AddChild(TYPE pLink)
{
pLink->TDoubleLinkRef<TYPE, BaseClass>::AddTail(m_pChild);
pLink->m_pParent = (TYPE)this;
}
TYPE CutChildren()
{
TYPE pChild = m_pChild;
m_pChild = NULL;
TYPE p = pChild;
while(p) {
p->m_pParent = NULL;
p = p->m_pNext;
}
return pChild;
}
void AddChildren(TYPE pChild)
{
if (pChild) {
ASSERT(!pChild->m_pPrev);
TYPE pTail = m_pChild->TDoubleLinkRef<TYPE, BaseClass>::GetTail();
if (pTail) {
pTail->m_pNext = pChild;
pChild->m_pPrev = pTail;
} else {
m_pChild = pChild;
}
while(pChild) {
ASSERT(!pChild->m_pParent);
pChild->m_pParent = (TYPE)this;
pChild = pChild->m_pNext;
}
}
}
static void DestroyAll(TYPE& pStart)
{
pStart->DestroyAll();
pStart = NULL;
}
void DestroyAll()
{
if (this) {
DestroyAllChildren();
if (m_pParent) {
m_pParent->CutChild((TYPE)this);
}
delete this;
}
}
void DestroyAllChildren()
{
ASSERT(this);
while(m_pChild) {
TYPE pChild = m_pChild;
CutChild(pChild);
pChild->DestroyAllChildren();
delete pChild;
}
}
void SetAtArray(TYPE* pArray, int& nIndex) const
{
// this is not included...
ASSERT(&nIndex);
if (this) {
TYPE pChild = m_pChild;
while(pChild) {
pArray[nIndex++] = pChild;
pChild->SetAtArray(pArray, nIndex);
pChild = pChild->m_pNext;
}
}
}
void MakeArray(TARRAY(TYPE)& aTree) const
{
aTree.Reset();
int nSize = CountChildrenAll();
int nIndex = 0;
SetAtArray(&aTree.Add(nSize), nIndex);
}
};
#endif // !defined(__DBLINKS__)
+89
View File
@@ -0,0 +1,89 @@
#if !defined(__DQFIXED__)
#define __DQFIXED__
#ifndef NULL_CLASS_DEFINED
#define NULL_CLASS_DEFINED
class CNullClass {};
#endif
template <class TYPE, int nMAX, class BaseClass>
class TDeQueueFixed : public BaseClass
{
protected:
int m_nStart, m_nEnd;
TYPE m_a[nMAX];
public:
TDeQueueFixed()
{
m_nStart = m_nEnd = 0;
}
~TDeQueueFixed()
{
}
static int GetMax() { return nMAX; }
int GetDataSize() const
{
return m_nEnd - m_nStart;
}
int GetFreeSize() const
{
return nMAX - (m_nEnd - m_nStart);
}
int GetFreeSizeEnd() const
{
return nMAX - m_nEnd;
}
TYPE* Prepare(int nSize)
{
if (GetFreeSize() >= nSize) {
if (nMAX - m_nEnd < nSize) {
memcpy(&m_a[0], &m_a[m_nStart], (m_nEnd - m_nStart) * sizeof(TYPE));
m_nEnd -= m_nStart;
m_nStart = 0;
}
int nEnd = m_nEnd;
m_nEnd += nSize;
return &m_a[nEnd];
} else {
return NULL;
}
}
int GetBegin(TYPE*& pbBegin) const
{
pbBegin = (TYPE*)&m_a[m_nStart];
return m_nEnd - m_nStart;
}
void CheckEmpty()
{
if (m_nStart >= m_nEnd) {
m_nStart = m_nEnd = 0;
}
}
void RemoveBegin(int nSize)
{
m_nStart += nSize;
CheckEmpty();
}
void RemoveEnd(int nSize)
{
m_nEnd -= nSize;
CheckEmpty();
}
BOOL AddData(const TYPE* pData, int nSize)
{
TYPE* pDest = Prepare(nSize);
if (pDest) {
memcpy(pDest, pData, nSize * sizeof(TYPE));
}
return pDest;
}
void FreeAll()
{
m_nStart = m_nEnd = 0;
}
};
#endif // !defined(__DQFIXED__)
File diff suppressed because it is too large Load Diff
+80
View File
@@ -0,0 +1,80 @@
#ifdef WIN32
#define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */
#pragma warning(disable:4201)
#endif // WIN32
#ifdef IRIX
#define _BSD_SIGNALS
#include <fcntl.h>
/* #include <stropts.h> */
#endif
#include <stdio.h>
#include <time.h>
#include <sys/types.h>
#include <errno.h>
#include <string.h>
#include <stdarg.h>
#ifdef WIN32
//#include <winsock.h>
#include <winsock2.h>
#else
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/signal.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#endif
#ifdef CHECK_ASSERT_VALID
#define CHECK_ASSERT_VALID(expr) (expr)
#endif // CHECK_ASSERT_VALID
#ifndef TRACE
#define TRACE(x)
#endif // TRACE
#ifndef ASSERT
#define ASSERT(x)
#endif // ASSERT
#include "stddefs.h"
#include "array.inl"
#include "dblinks.inl"
#include "qsort.inl"
#include "bsearch.inl"
#include "dqfixed.inl"
DECLARE_CLASS(TEXTFmt);
DECLARE_CLASS(DAPacket);
DECLARE_CLASS(TimerEvent);
DECLARE_CLASS(TimerPool);
DECLARE_CLASS(PacketDumper);
DECLARE_CLASS(PacketDump);
DECLARE_CLASS(Packet);
DECLARE_CLASS(PacketAuto);
DECLARE_CLASS(Broadcast);
DECLARE_CLASS(SockAddr);
DECLARE_CLASS(FileTransfer);
DECLARE_CLASS(FTPArray);
DECLARE_CLASS(SOC);
DECLARE_CLASS(SOCListen);
DECLARE_CLASS(SOCConnect);
DECLARE_CLASS(SOCClient);
DECLARE_CLASS(SOCServer);
DECLARE_CLASS(FDSet);
DECLARE_CLASS(Droppings);
DECLARE_CLASS(SOCManager);
DECLARE_CLASS(SOCSystem);
#include "cstr.h"
#include "mugsocs.h"
#ifdef WIN32
#pragma warning(default:4201)
#endif // WIN32
File diff suppressed because it is too large Load Diff
+108
View File
@@ -0,0 +1,108 @@
#ifdef _DEBUG
#define AssertDebugBreak() _asm { int 3 }
inline BOOL AssertDialog(const char* pcszExpr, const char* pcszfile, int nLine)
{
char szBuf[MAX_PATH * 2];
sprintf(szBuf, "\"%s\" 파일의 %d줄에서 ASSERT!!!\n\n디버깅을 하시겠습니까?", pcszfile, nLine);
#ifdef WIN32
return ::MessageBox(NULL, szBuf, pcszExpr, MB_YESNO) == IDYES;
#else // !WIN32
return FALSE;
#endif // WIN32
}
inline BOOL __cdecl AssertReturnFALSE()
{
return FALSE;
}
#ifndef ASSERT
#define ASSERT(x) { if (!(x)) AssertDialog(#x, THIS_FILE, __LINE__); }
#endif
#define ASSERT_FALSE() ASSERT(AssertReturnFALSE())
#ifndef VERIFY
#define VERIFY(x) { if (!(x)) AssertDialog(#x, THIS_FILE, __LINE__); }
#endif
#ifndef TRACE
inline int __DbgTrace(const char* pcszFormat, ...)
{
va_list ap;
va_start(ap, pcszFormat);
char caBuffer[1024];
vsprintf(caBuffer, pcszFormat, ap);
va_end(ap);
::OutputDebugString(caBuffer);
return 0;
}
#define TRACE __DbgTrace
#endif
#ifndef THIS_FILE
#define THIS_FILE __FILE__
#endif // !THIS_FILE
#ifndef BASED_CODE
#define BASED_CODE
#endif // !BASED_CODE
#ifdef malloc
#undef malloc
#undef calloc
#undef realloc
#undef _expand
#undef free
#undef _msize
#endif
#define malloc(s) _malloc_dbg(s, _NORMAL_BLOCK, THIS_FILE, __LINE__)
#define calloc(c, s) _calloc_dbg(c, s, _NORMAL_BLOCK, THIS_FILE, __LINE__)
#define realloc(p, s) _realloc_dbg(p, s, _NORMAL_BLOCK, THIS_FILE, __LINE__)
#define _expand(p, s) _expand_dbg(p, s, _NORMAL_BLOCK, THIS_FILE, __LINE__)
#define free(p) _free_dbg(p, _NORMAL_BLOCK)
#define _msize(p) _msize_dbg(p, _NORMAL_BLOCK)
//----------------------------------------------------------------------------------------------------------
inline void* __cdecl operator new(size_t nSize, LPCSTR lpszFileName, int nLine)
{
void* p = _malloc_dbg(nSize, _NORMAL_BLOCK, lpszFileName, nLine);
return p;
}
inline void __cdecl operator delete(void* p, LPCSTR lpszFileName, int nLine)
{
_free_dbg(p, _NORMAL_BLOCK);
}
//----------------------------------------------------------------------------------------------------------
#ifndef _AFX
#define DEBUG_NEW new //(THIS_FILE, __LINE__)
#define DEBUG_DELETE delete //(THIS_FILE, __LINE__)
#endif
#else // !_DEBUG
#define ASSERTDLG_PUSH(hWnd)
#define ASSERTDLG_POP()
#ifndef ASSERT
#define ASSERT(x)
#endif
#define ASSERT_FALSE()
#ifndef VERIFY
#define VERIFY(x) x
#endif
#ifndef TRACE
inline int __DbgTraceIgnore(const char* pcszFormat, ...) { &pcszFormat; return 0; }
#define TRACE 1 ? 0: __DbgTraceIgnore
#endif
#endif // _DEBUG
+27
View File
@@ -0,0 +1,27 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by LAUNCHER.RC
//
#define IDR_MAINFRAME 128
#define IDD_LAUNCHER_DIALOG 102
#define IDD_ABOUTBOX 103
#define IDS_APP_TITLE 103
#define IDM_ABOUT 104
#define IDM_EXIT 105
#define IDS_HELLO 106
#define IDI_LAUNCHER 107
#define IDI_SMALL 108
#define IDC_LAUNCHER 109
#define IDC_MYICON 2
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 129
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 110
#endif
#endif
+100
View File
@@ -0,0 +1,100 @@
#ifndef NULL_CLASS_DEFINED
#define NULL_CLASS_DEFINED
class CNullClass {};
#endif
#define TTREENODE(TYPE) TTreeNode<TYPE,CNullClass>
enum ETreeNodeState {
ETNS_Unknown = -1,
ETNS_None,
ETNS_Plus,
ETNS_Minus,
};
template <class TYPE, class BaseClass>
class TTreeNode : public TDoubleLinkTreeRef<TYPE, BaseClass>
{
public:
ETreeNodeState m_eTNS;
CStr m_strName;
// runtime...
HTREEITEM m_hTI;
public:
TTreeNode(const char* pcszName = NULL)
: m_strName(pcszName)
{
m_eTNS = ETNS_Unknown;
// runtime...
m_hTI = NULL;
}
void SetAsRoot()
{
ASSERT(this);
m_eTNS = ETNS_Unknown;
// runtime...
m_hTI = TVI_ROOT;
}
TYPE FindNode(HTREEITEM hTI) const
{
if (this) {
if (m_hTI == hTI)
return (TYPE)this;
TYPE pChild = m_pChild;
while(pChild) {
TYPE pFound = pChild->FindNode(hTI);
if (pFound)
return pFound;
pChild = pChild->m_pNext;
}
}
return NULL;
}
void Validate(CTreeCtrl& TC)
{
if (m_eTNS == ETNS_Unknown) {
TYPE pChild = m_pChild;
if (pChild) {
m_eTNS = ETNS_Plus;
} else {
m_eTNS = ETNS_None;
}
while(pChild) {
pChild->Validate(TC);
pChild = pChild->m_pNext;
}
}
}
void InsertNode(CTreeCtrl& TC, TYPE pNode, HTREEITEM hTIAfter = TVI_LAST)
{
ASSERT(this && &TC);
TV_INSERTSTRUCT tvi;
memset(&tvi, 0, sizeof(tvi));
tvi.hParent = this ? m_hTI: TVI_ROOT;
tvi.hInsertAfter = hTIAfter;
tvi.item.mask = TVIF_STATE | TVIF_TEXT;
tvi.item.stateMask = TVIS_EXPANDED;
tvi.item.state = (pNode->m_eTNS == ETNS_Minus) ? TVIS_EXPANDED: 0;
//tvi.item.iImage = 0;
tvi.item.pszText = (char *)(LPCTSTR)pNode->m_strName;
pNode->m_hTI = TC.InsertItem(&tvi);
}
void InsertRecursive(CTreeCtrl& TC)
{
TYPE pNode = m_pChild;
while(pNode) {
InsertNode(TC, pNode);
pNode->InsertRecursive(TC);
pNode = pNode->m_pNext;
}
}
};