Restructure repository to include all source folders

Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-29 20:17:20 +09:00
parent 5d3cd64a25
commit dd97ddec92
11602 changed files with 1446576 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,877 @@
#ifndef _CITEM_CLASS_H_
#define _CITEM_CLASS_H_
#include <limits>
#include <vector>
#include <algorithm>
#include <Network/Packet/PacketStruct/CharItemPacketStruct.h>
#include "item/ItemMgr.h"
#include "item/ItemStructure.h"
// 전방 참조
class CCharacter;
#define DELITEMLOG(x) (void*)0
//#define DELITEMLOG(x) x
namespace Item
{
class CItem
{
public:
CItem();
CItem(const ItemInfo& itemInfo);
// 스크립트로부터 로드한 아이템 데이터를 얻어 온다.
const ItemInfo& GetItemInfo() const { return m_ItemInfo; }
// Desc : 아이템 정보를 char버퍼로 기록한다.
// In : 버퍼, 버퍼 크기
// Out : (Return)성공 여부, nBufferLength_InOut - 기록한 크기
virtual bool SerializeOut(char* lpSerializeItem_Out, size_t& nBufferLength_InOut);
// Desc : char버퍼로부터 아이템 정보를 읽어 온다.
// In : 버퍼, 버퍼 크기
// Out : (Return)성공 여부, nBufferLength_InOut - 사용한 버퍼 크기
virtual bool SerializeIn(const char* lpSerializeItem_In, size_t& nBufferLength_InOut);
inline void MoveItem(ItemPos itemPos);
inline unsigned __int64 GetUID(void) const { return m_ItemData.m_dwUID; }
inline ItemPos GetPos(void) const { return m_ItemData.m_ItemPos; }
inline ItemPos GetRealPos(void) const { return m_itemPos_Real; }
inline void SwapPos(void) { std::swap(m_ItemData.m_ItemPos, m_itemPos_Real); }
inline unsigned short GetPrototypeID(void) const { return m_ItemData.m_usProtoTypeID; }
inline unsigned char GetNumOrDurability(void) const { return m_ItemData.m_cNumOrDurability; }
inline unsigned char GetMaxNumOrDurability(void) const { return m_cMaxNumOrDurability; }
inline void SetNumOrDurability(unsigned char cNumOrDurability) { m_ItemData.m_cNumOrDurability = cNumOrDurability; }
inline void SetMaxNumOrDurability(unsigned char cNumOrDurability) { m_cMaxNumOrDurability = cNumOrDurability; }
inline void SetStallPrice(unsigned long dwStallPrice) { m_dwStallPrice = dwStallPrice; }
inline unsigned long GetStallPrice(void) const { return m_dwStallPrice; }
inline unsigned long GetBuyBlackPrice(void) const { return m_ItemInfo.m_DetailData.m_dwBlackPrice; }
inline unsigned long GetBuyMedalPrice(void) const { return m_ItemInfo.m_DetailData.m_dwMedalPrice; }
virtual unsigned long GetBuyPrice(void) const;
virtual unsigned long GetSellPrice(void) const;
virtual unsigned long GetRepairPrice(void) const;
virtual unsigned long GetUpgradePrice(void) const;
virtual unsigned long GetGraftPrice(void) const;
inline const char* GetItemTypeName(void) const { return m_ItemInfo.m_StringData.m_szTypeName; }
inline bool IsSet(unsigned long dwDetailDataFlag) const { return dwDetailDataFlag == (m_ItemInfo.m_DetailData.m_dwFlags & dwDetailDataFlag); }
inline bool GetEnableRepair(void);
inline bool GetEnableStack(void);
inline bool GetSocketItem(void);
inline bool GetRuneItem(void);
inline bool GetTwohandItem(void);
inline bool GetEnableEquip(void);
inline void SetItemPos(unsigned short wItemPos) { m_ItemData.m_ItemPos.m_cPos = wItemPos; }
inline unsigned short GetItemPos(void) { return m_ItemData.m_ItemPos.m_cPos; }
inline void SetPos(unsigned char cXIndex, unsigned char cYIndex, unsigned char cZIndex) { m_ItemData.m_ItemPos.SetPos(cXIndex, cYIndex, cZIndex); }
inline void SetXIndex(unsigned char cXIndex) { m_ItemData.m_ItemPos.SetXIndex(cXIndex); }
inline void SetYIndex(unsigned char cYIndex) { m_ItemData.m_ItemPos.SetYIndex(cYIndex); }
inline void SetZIndex(unsigned char cZIndex) { m_ItemData.m_ItemPos.SetZIndex(cZIndex); }
inline void SetPos(unsigned short wIndex) { m_ItemData.m_ItemPos.SetPos(wIndex); }
// SetUID는 아무때나 함부로 사용하지 마시오!
inline void SetUID(unsigned __int64 dwItemUID) { m_ItemData.m_dwUID = dwItemUID; }
// S 그레이드 제한값 보정(S 그레이드 이외에는 쓰지 마세요. 공식이 정확하지 않습니다. - by hackermz)
virtual void RevisionLimit() { }
virtual void RevisionLimit(short* lpattrLimit) { }
virtual void RevisionLimit(Item::Attribute::Type eAttributeType, short& attrLImit) { }
protected:
virtual ~CItem();
const ItemInfo& m_ItemInfo; // 스크립트로부터 로드한 아이템 데이터
ItemData m_ItemData; // DB에 저장되는 아이템 데이터
ItemPos m_itemPos_Real; // 임시 공간이 아닌 아이템 위치
unsigned char m_cMaxNumOrDurability; // 최대 내구도
unsigned long m_dwStallPrice; // 노점상에서의 가격
unsigned long m_dwPrice; // 아이템 가격 (옵션에 의해 갱신되지만 내구도를 고려하지는 않은 값)
friend class CItemFactory;
};
class CEquipment : public CItem
{
public:
enum EQUIPMENT_ERROR
{
// 소켓 박기
S_SUCCESS = 0, // 성공
E_SERVER_ERROR = 1, // 서버 에러
E_GET_EQUIP_FAILED = 2, // 장비 얻기 실패
E_GET_GEM_FAILED = 3, // 젬 얻기 실패
E_NOT_EQUIP = 4, // 업그레이드 가능한 아이템 아님
E_NOT_GEM = 5, // 젬 아이템 아님
E_REMOVE_GEM_FAILED = 6, // 젬 제거 실패
E_SOCKET_IS_FULL = 7, // 소켓 슬롯 초과
E_OVER_MAX_SOCKET = 8, // 최대 소켓 초과
E_SOCKET_NOT_MAX = 9, // 소켓 개수가 7개가 아니다.
E_SOCKET_NOT_INST = 10, // 소켓에 인스톨된 보석이 없다.
// 룬 설치/제거
R_SUCCESS = 0, // 룬 설치/제거 성공.
E_GET_RUNE_FAILED = 9, // 룬 개수가 없을때.
E_NOT_RUNE = 10, // 룬이 없을때.
E_NOT_RUNE_SLOT = 11, // 룬에 빈 소켓이 없을때.
E_NOT_RUNE_LEVEL_LIMIT = 12, // 룬에 레벨제한때 문제에 설치할 수 없을때.
E_USED_RUNE_SKILL_POINT = 13, // 룬에 추가 스킬 포인트를 사용하고 있어서 제거 할 수 없을때.
E_NOT_RUNE_SCRIPT_INFO = 14, // 룬에 스크립트 정보를 얻어올수 없을때.
// 강화
E_GET_MINERAL_FAILED = 3, // 광물 얻기 실패
E_NOT_MINERAL = 5, // 광물이 아님
E_NOT_MATCH_MINERAL_TYPE = 6, // 광물 타입 틀림
E_NOT_ENOUGH_MINERAL = 7, // 광물 부족
E_REMOVE_EQUIP_FAILED = 8, // 장비 제거 실패
E_CREATE_SCRAP_FAILED = 9, // 고철 생성 실패
E_SET_SCRAP_FAILED = 10, // 고철 놓기 실패
E_REMOVE_MINERAL_FAILED = 11, // 광물 제거 실패
E_UPGRADE_LEVEL_IS_FULL = 12, // 더 이상 업그레이드를 할 수 없음
E_NOT_ENOUGH_MONEY = 13, // 돈이 부족해서 업그레이드 할 수 없음
S_BROKEN_EQUIP = 14, // 성공했으나 무기 부서짐 (클라이언트로 보내지는 않는다.)
E_NOT_UPGRADE_LEVEL = 15, // 옵션 이식 가능한 제련 업그레이드 레벨이 아님.
E_NOT_UPGRADE_AS_OVER = 16, // 고대의 돌 이용 회수 초과.
E_NOT_UPGRADE_ENDURANCE = 17, // 내구도 회복 아이템 사용 불가.
E_NOT_UPGRADE_MINENDURANCE = 18, // 제련가능한 내구도 10이 되지 않습니다.
// 옵션 이식
E_WRONG_ATTRIBUTE = 2, // 이식 불가능한 옵션
E_NOT_EQUAL_KIND = 3, // 다른 종류의 장비
E_HIGH_GRADE_ORIGINAL = 4, // 원본의 그레이드가 높음
E_GRAFE_FAILD = 5, // 옵션이식 실패
// 보상 판매
E_WRONG_TYPE = 2, // 보상 판매 대상이 아님
E_NEW_SEASON_EQUIP = 3, // 새로 드랍됬거나 이미 보상된 장비
E_LOW_STATUS_EQUIP = 4 // 너무 낮은 수준의 장비
};
enum PASSIVE_TYPE
{
PASSIVE_ALWAYS = 0, // 무기에 상관없이 항상 발생하는 패시브
PASSIVE_THIS_WEAPON = 1, // 해당 무기에 발생하는 패시브
NONE_PASSIVE_THIS_WEAPON = 2 // 해당 무기에 발생하지 않는 패시브
};
enum RuneApplyType
{
RUNE_NONE = 0,
RUNE_INDEX = (1 << 0), // 하나에 속성.
RUNE_ALL = (1 << 1), // 모든 속성.
RUNE_APPLY = (1 << 2), // 속성을 추가.
RUNE_REMOVE = (1 << 3) // 속성을 삭제.
};
// 아이템을 장비로 Downcast한다.
inline static CEquipment* DowncastToEquipment(CItem* lpItem);
// Desc : 아이템 정보를 char버퍼로 기록한다.
// In : 버퍼, 버퍼 크기
// Out : (Return)성공 여부, nBufferLength_InOut - 기록한 크기
virtual bool SerializeOut(char* lpSerializeItem_Out, size_t& nBufferLength_InOut);
// Desc : char버퍼로부터 아이템 정보를 읽어 온다.
// In : 버퍼, 버퍼 크기
// Out : (Return)성공 여부, nBufferLength_InOut - 사용한 버퍼 크기
virtual bool SerializeIn(const char* lpSerializeItem_In, size_t& nBufferLength_InOut);
// 아이템 속성 추가 (속성 변경 후에는 반드시 가격/그레이드 계산을 다시 해줍시다.)
inline void AddAttribute(Item::Attribute::Type eAttributeType, short nAttributeValue);
inline void SetAttribute(Item::Attribute::Type eAttributeType, short nAttributeValue);
// 3차 밸런스 패치(소켓, 업그레이드 값 제거)0
inline void RemoveUpgradeAttribute(Item::Attribute::Type eAttributeType);
inline void RemoveGemAttribute(Item::Attribute::Type eAttributeType);
// 아이템 속성을 얻어 온다.
inline short GetAttribute(Item::Attribute::Type eAttributeType);
inline void GetAttribute(short* lpAttributeArray_Out, unsigned short nArraySize);
// 옵션별 한계값에 도달했는지 체크한다.
bool CheckAttributeLimit(Item::Attribute::Type eAttributeType, unsigned char cType = 0);
inline bool AddSocket(unsigned char cSocket);
inline void GetSocket(unsigned char* cSockets, unsigned char cArraySize);
unsigned char GetSocket(unsigned char cIndex) { return m_cSocket[cIndex]; }
const Grade::GradeInfo& GetItemGrade(void) const { return m_GradeInfo; }
inline void InitializeAttribute(void); // 아이템 정보를 상점값으로 초기화
BOOL AddRandomOption(Item::EquipType::Grade eGrade, unsigned char cBaseNum, int iMagicChance = 0);
// 소켓 설정
BOOL AddRandomSocket();
// 옵션 이식
EQUIPMENT_ERROR OptionGraft(CEquipment* lpSacrifice, bool bUpgradeLevelLimit, unsigned char cAttributeType,
unsigned long dwCurrentGold, unsigned long& dwUsedGold);
bool CanOptionGraft(Item::CItemType::ArrayType eItemType, Item::Attribute::Type eAttributeType);
// 보상 판매
EQUIPMENT_ERROR Compensation(unsigned char cClass, unsigned char cLevel,
CharacterStatus status, CEquipment** lppResultEquip, long& lCompensationGold);
unsigned char GetUpgradeLevel(void) const { return m_cUpgradeLevel; }
unsigned char GetCurrentSocketNum(void) const { return m_cSocketNum; }
unsigned char GetMaxSocketNum(void) const { return m_cMaxSocket; }
// 리밸런싱 이후 생성되는 장비는 이 함수를 호출해준다.
void SetNewEquip(char cStrong = 0)
{
if(cStrong == 2)
m_cSeasonRecord = 3;
else if(cStrong == 1)
m_cSeasonRecord = 2;
else if(m_cSeasonRecord == 0)
m_cSeasonRecord = 1;
}
unsigned char GetSeasonRecord(void) { return m_cSeasonRecord; }
unsigned long GetBuyPrice(void) const;
unsigned long GetSellPrice(void) const;
unsigned long GetRepairPrice(void) const;
unsigned long GetUpgradePrice(void) const;
unsigned long GetGraftPrice(void) const;
unsigned char GetUpgradeCnt(void) { return m_cUpgradeCnt; }
void SetUpgradeCnt(unsigned char cUpgradeCnt) { m_cUpgradeCnt = cUpgradeCnt; }
// 업그레이드 가능 여부 리턴
bool IsUpgradable(void) const;
// 장착아이템에 룬 소켓 개수 체크
inline unsigned char GetMaxRuneSocket();
// 룬을 아이템에 장착 가능한지 체크
inline unsigned char GetRuneEquipable();
// 장착 아이템에 장착제한에 레벨을 얻어온다.
inline unsigned short GetRuneEquipLimitLevel(void) const;
// 룬 아이템을 제거(속성도 같이 제거)
inline bool SubRuneAttribute(void);
// 설치 되어 있는 룬 소켓값을 넘겨준다.
inline unsigned short GetRuneSocket(unsigned char cIndex)
{
if (cIndex >= EquipmentInfo::MAX_RUNE_SOCKET_NUM)
{
return 0;
}
return m_usRuneSocket[cIndex];
}
// 룬 속성을 삭제한 아이템 속성 복사본을 넘겨준다.
inline void GetSubRuneAttribute(short* psAttribute);
inline void GetSubRuneAttribute(Item::Attribute::Type eAttributeType, short& sAttribute);
// 외부에서 사용할 룬 속성 삭제/추가
inline void SetRuneAttribute(RuneApplyType enRuneApplyType, unsigned char ucIndex);
// 장착 아이템에 있는 모든 룬 아이템에 속성중 스킬포인트 리턴해준다.
unsigned short GetAllRuneSkillPointCheck();
// 룬 아이템이 장착 되어 있으면 스킬 포인트 체크
bool GetRuneCheckSkill(CCharacter* lpCharacter, Item::ItemPos itemPos, bool bChk = true);
// ------------------------------------------------------------------------------------------------------------
// ConvertTool에서만 사용되는 함수들 - RebalanceOverItem.cpp 에서 사용
inline void Repair();
inline void InitEquip();
inline void SetEquip();
// ------------------------------------------------------------------------------------------------------------
// 서버에서만 사용되는 함수들 - ItemServerFunc.cpp 에서 별도 구현
EQUIPMENT_ERROR InstallSocket(CItem& Gem);
EQUIPMENT_ERROR UpgradeItem(CItem& Mineral_InOut, unsigned long dwCurrentGold_In, unsigned long& dwUsedGold_Out, unsigned char& cMaxDur_Out);
EQUIPMENT_ERROR InstallRuneSocket(CItem& Rune, bool bEquip, unsigned char cLevel); // 장착 아이템에 룬 소켓 설치.
EQUIPMENT_ERROR UnInstallRuneSocket(CItem& Rune, bool bEquip, unsigned char cLevel, unsigned short usSkillPoint); // 장착 아이템에 룬 소켓 제거.
// ------------------------------------------------------------------------------------------------------------
// 3차 밸런스 패치 관련 함수
// S 그레이드 제한값 구하기
bool GetLimitValue(short* lpattrLimit);
bool GetLimitValue(Item::Attribute::Type eAttributeType, short& attrLimit);
// S 그레이드 제한값 보정(S 그레이드 이외에는 쓰지 마세요. 공식이 정확하지 않습니다. - by hackermz)
void RevisionLimit();
void RevisionLimit(short* lpattrLimit);
void RevisionLimit(Item::Attribute::Type eAttributeType, short& attrLImit);
// 그레이드 책정
void CalculateItemGrade(void);
protected:
enum ApplyType
{
APPLY = 1, // 값 바꾸지 말 것
REMOVE = -1 // 값 바꾸지 말 것
};
CEquipment(const ItemInfo& itemInfo);
virtual ~CEquipment();
inline void InitializeGemAttribute(void); // 소켓 정보로 소켓 속성을 초기화
inline void InitializeUpgradeAttribute(void); // 업그레이드 단계로 업그레이드 속성을 초기화
inline void ApplyGemAttribute(ApplyType eApplyType); // 소켓 속성을 적용
inline void ApplyUpgradeAttribute(ApplyType eApplyType); // 업그레이드 속성을 적용
inline void ApplyRuneAttribute(ApplyType eApplyType); // 룬 아이템 속성을 적용
void CalculateItemPrice(void); // 가격 책정
unsigned char m_cSocket[EquipmentInfo::MAX_SOCKET_NUM]; // 아이템 소켓 정보
ItemAttribute m_SocketAttribute[EquipmentInfo::MAX_SOCKET_ATTRIBUTE_NUM]; // 아이템 소켓으로 박은 속성
ItemAttribute m_UpgradeAttribute[EquipmentInfo::MAX_UPGRADE_ATTRIBUTE]; // 아이템 업그레이드시 붙는 속성
unsigned short m_usRuneSocket[EquipmentInfo::MAX_RUNE_SOCKET_NUM]; // 룬 소켓
short m_wAttribute[Attribute::MAX_ATTRIBUTE_NUM]; // 최종적으로 계산된 아이템 속성 (스크립트 + DB + ...)
unsigned char m_cUpgradeLevel; // 업그레이드 단계
unsigned char m_cSocketNum; // 현재 소켓 개수
unsigned char m_cMaxSocket; // 최대 소켓 개수
unsigned char m_cMaxAttribute; // 최대 속성 개수
unsigned char m_cSeasonRecord; // 아이템 생성 시기
Grade::GradeInfo m_GradeInfo; // 그레이드 정보
unsigned char m_cUpgradeCnt;
friend class CItemFactory;
friend class CItemType;
};
class CUseItem : public CItem
{
public:
inline static CUseItem* DowncastToUseItem(CItem* lpItem);
// ------------------------------------------------------------------------------------------------------------
// 서버에서만 사용되는 함수들 - ItemServerFunc.cpp 에서 별도 구현
bool Use(CCharacter* lpSender, CCharacter* lpRecver, unsigned short& wError);
protected:
CUseItem(const ItemInfo& itemInfo);
virtual ~CUseItem();
bool UsePotion(CCharacter* lpSender, CCharacter* lpRecver);
friend class CItemFactory;
};
};
inline void Item::CItem::MoveItem(ItemPos itemPos)
{
if (TakeType::TS_STALL == itemPos.m_cPos)
{
m_itemPos_Real = itemPos;
}
else
{
m_ItemData.m_ItemPos = itemPos;
if (TakeType::TS_TEMP != itemPos.m_cPos)
{
m_itemPos_Real = itemPos;
}
}
}
inline Item::CEquipment* Item::CEquipment::DowncastToEquipment(Item::CItem* lpItem)
{
if (NULL == lpItem) { return NULL; }
return lpItem->IsSet(DetailData::EQUIP) ?
static_cast<CEquipment*>(lpItem) : NULL;
}
inline void Item::CEquipment::AddAttribute(Item::Attribute::Type eAttributeType, short nAttributeValue)
{
/*
// 룬아이템에 속성 추가
if (eAttributeType == Attribute::RUNE && 0 != nAttributeValue)
{
unsigned short usRuneID = nAttributeValue + EtcItemID::RUNE_START_ID;
const ItemInfo* lpRuneInfo = CItemMgr::GetInstance().GetItemInfo(usRuneID);
if (NULL != lpRuneInfo)
{
for (unsigned char cIndex = 0; cIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cIndex)
{
if (0 != m_usRuneSocket[cIndex])
{
m_usRuneSocket[cIndex] = usRuneID;
for (int nIndex = 0; nIndex < Item::Attribute::MAX_ATTRIBUTE_NUM; ++nIndex)
{
if (Item::EquipType::S_GRADE != GetItemGrade().m_aryAttributeGrade[nIndex])
{
m_wAttribute[nIndex] += lpRuneInfo->m_EquipAttribute.m_usAttributeValue[nIndex];
}
}
return;
}
}
}
}
else
*/
{
if (Item::EquipType::S_GRADE != GetItemGrade().m_aryAttributeGrade[eAttributeType])
{
m_wAttribute[eAttributeType] += nAttributeValue;
}
}
}
inline void Item::CEquipment::SetAttribute(Item::Attribute::Type eAttributeType, short nAttributeValue)
{
/*
// 룬아이템에 속성 추가
if (eAttributeType == Attribute::RUNE && 0 != nAttributeValue)
{
unsigned short usRuneID = nAttributeValue + EtcItemID::RUNE_START_ID;
const ItemInfo* lpRuneInfo = CItemMgr::GetInstance().GetItemInfo(usRuneID);
if (NULL != lpRuneInfo)
{
for (unsigned char cIndex = 0; cIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cIndex)
{
if (0 != m_usRuneSocket[cIndex])
{
m_usRuneSocket[cIndex] = usRuneID;
for (int nIndex = 0; nIndex < Item::Attribute::MAX_ATTRIBUTE_NUM; ++nIndex)
{
m_wAttribute[nIndex] = lpRuneInfo->m_EquipAttribute.m_usAttributeValue[nIndex];
}
return;
}
}
}
}
else
*/
{
m_wAttribute[eAttributeType] = nAttributeValue;
}
}
inline void Item::CEquipment::RemoveUpgradeAttribute(Item::Attribute::Type eAttributeType)
{
ItemAttribute* first = m_UpgradeAttribute;
ItemAttribute* last = m_UpgradeAttribute + EquipmentInfo::MAX_UPGRADE_ATTRIBUTE;
for (;first != last; ++first)
{
if(eAttributeType == static_cast<Item::Attribute::Type>(first->m_cType))
{
first->m_usValue = 0;
}
}
}
inline void Item::CEquipment::RemoveGemAttribute(Item::Attribute::Type eAttributeType)
{
ItemAttribute* first = m_SocketAttribute;
ItemAttribute* last = m_SocketAttribute + EquipmentInfo::MAX_UPGRADE_ATTRIBUTE;
for (;first != last; ++first)
{
if(eAttributeType == static_cast<Item::Attribute::Type>(first->m_cType))
{
first->m_usValue = 0;
}
}
}
inline bool Item::CEquipment::SubRuneAttribute(void)
{
// 룬 아이템 제거
for (unsigned char cRune = 0; cRune <= EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cRune)
{
if (m_usRuneSocket[cRune])
{
unsigned short usItemId = m_usRuneSocket[cRune];
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(usItemId);
if (itemInfo)
{
for (unsigned char cIndex = 0; cIndex < Item::Attribute::MAX_ATTRIBUTE_NUM; ++cIndex)
{
m_wAttribute[cIndex] -= itemInfo->m_EquipAttribute.m_usAttributeValue[cIndex];
}
}
m_usRuneSocket[cRune] = 0;
}
}
return true;
}
inline short Item::CEquipment::GetAttribute(Item::Attribute::Type eAttributeType)
{
return m_wAttribute[eAttributeType];
}
inline void Item::CEquipment::GetAttribute(short* lpAttributeArray_Out, unsigned short nArraySize)
{
unsigned short nCopyNum = nArraySize < Item::Attribute::MAX_ATTRIBUTE_NUM
? nArraySize : Item::Attribute::MAX_ATTRIBUTE_NUM;
for (int nIndex = 0; nIndex < nCopyNum; ++nIndex)
{
*(lpAttributeArray_Out + nIndex) = GetAttribute(static_cast<Item::Attribute::Type>(nIndex));
}
}
inline bool Item::CEquipment::AddSocket(unsigned char cSocket)
{
if (m_cSocketNum < m_cMaxSocket && 0 == m_cSocket[m_cSocketNum])
{
m_cSocket[m_cSocketNum] = cSocket;
++m_cSocketNum;
return true;
}
return false;
}
inline void Item::CEquipment::GetSocket(unsigned char* cSockets, unsigned char cArraySize)
{
unsigned short nCopyNum = cArraySize < Item::EquipmentInfo::MAX_SOCKET_NUM
? cArraySize : Item::EquipmentInfo::MAX_SOCKET_NUM;
unsigned char* lpSocketPastEnd = m_cSocket + nCopyNum;
std::copy(m_cSocket, lpSocketPastEnd , cSockets);
}
inline void Item::CEquipment::InitializeAttribute(void)
{
for (unsigned int nIndex = 0; nIndex < Item::Attribute::MAX_ATTRIBUTE_NUM; ++nIndex)
{
m_wAttribute[nIndex] = m_ItemInfo.m_EquipAttribute.m_usAttributeValue[nIndex];
}
}
inline void Item::CEquipment::InitializeGemAttribute(void)
{
std::fill_n(m_SocketAttribute, int(EquipmentInfo::MAX_SOCKET_ATTRIBUTE_NUM), ItemAttribute());
// 설치된 소켓을 가지고 속성과 값을 설정
CItemType::SetInstallGemAttribute(this);
}
inline void Item::CEquipment::InitializeUpgradeAttribute(void)
{
std::fill_n(m_UpgradeAttribute, int(EquipmentInfo::MAX_UPGRADE_ATTRIBUTE), ItemAttribute());
// 아이템 업그레이드 단계값을 가지고 속성과 값을 설정
CItemType::SetUpgradeItemAttribute(this);
}
inline void Item::CEquipment::ApplyGemAttribute(ApplyType eApplyType)
{
ItemAttribute* first = m_SocketAttribute;
ItemAttribute* last = m_SocketAttribute + EquipmentInfo::MAX_SOCKET_ATTRIBUTE_NUM;
for (;first != last; ++first)
{
AddAttribute(static_cast<Item::Attribute::Type>(first->m_cType), first->m_usValue * eApplyType);
}
}
inline unsigned char Item::CEquipment::GetMaxRuneSocket()
{
// 장착아이템에 룬 소켓 개수 체크
return Item::CItemMgr::GetInstance().GetMaxRuneSocket(static_cast<ItemType::Type>(GetItemInfo().m_DetailData.m_cItemType));
}
inline unsigned char Item::CEquipment::GetRuneEquipable()
{
// 장착아이템에 룬 소켓 빈공간 체크
unsigned char cRuneSocketCnt = Item::CItemMgr::GetInstance().GetMaxRuneSocket(static_cast<ItemType::Type>(GetItemInfo().m_DetailData.m_cItemType));
if (!cRuneSocketCnt)
{
return 0;
}
if (!m_usRuneSocket[0])
{
return 1;
}
if (!m_usRuneSocket[1] && cRuneSocketCnt == EquipmentInfo::MAX_RUNE_SOCKET_NUM)
{
return 2;
}
return 0;
}
inline void Item::CEquipment::ApplyUpgradeAttribute(ApplyType eApplyType)
{
ItemAttribute* first = m_UpgradeAttribute;
ItemAttribute* last = m_UpgradeAttribute + EquipmentInfo::MAX_UPGRADE_ATTRIBUTE;
for (;first != last; ++first)
{
AddAttribute(static_cast<Item::Attribute::Type>(first->m_cType), first->m_usValue * eApplyType);
}
}
inline void Item::CEquipment::ApplyRuneAttribute(ApplyType eApplyType)
{
// 룬아이템에 속성 추가/삭제
for (unsigned char cIndex = 0; cIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cIndex)
{
if (m_usRuneSocket[cIndex])
{
unsigned short usItemId = m_usRuneSocket[cIndex];
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(usItemId);
if (itemInfo)
{
for (unsigned char cAttribute = 0; cAttribute < Item::Attribute::MAX_ATTRIBUTE_NUM; ++cAttribute)
{
m_wAttribute[cAttribute] += itemInfo->m_EquipAttribute.m_usAttributeValue[cAttribute]*eApplyType;
}
}
}
}
}
inline void Item::CEquipment::GetSubRuneAttribute(short* psAttribute)
{
// 룬 속성을 삭제한 아이템 속성 복사본을 넘겨준다.
memcpy(psAttribute, m_wAttribute, sizeof(m_wAttribute));
for (unsigned char cIndex = 0; cIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cIndex)
{
if (m_usRuneSocket[cIndex])
{
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(m_usRuneSocket[cIndex]);
if (itemInfo)
{
for (unsigned char cAttribute = 0; cAttribute < Item::Attribute::MAX_ATTRIBUTE_NUM; ++cAttribute)
{
psAttribute[cAttribute] -= itemInfo->m_EquipAttribute.m_usAttributeValue[cAttribute];
}
}
}
}
}
inline void Item::CEquipment::GetSubRuneAttribute(Item::Attribute::Type eAttributeType, short& sAttribute)
{
sAttribute = m_wAttribute[eAttributeType];
for (unsigned char cIndex = 0; cIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cIndex)
{
if (m_usRuneSocket[cIndex])
{
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(m_usRuneSocket[cIndex]);
if (itemInfo)
{
sAttribute -= itemInfo->m_EquipAttribute.m_usAttributeValue[eAttributeType];
}
}
}
}
inline void Item::CEquipment::SetRuneAttribute(RuneApplyType enRuneApplyType, unsigned char ucIndex)
{
// 외부에서 사용할 룬 속성 삭제/추가.
if (enRuneApplyType&RuneApplyType::RUNE_INDEX && enRuneApplyType&RuneApplyType::RUNE_REMOVE)
{
for (unsigned char ucRuneIndex = 0; ucRuneIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ucRuneIndex++)
{
if (m_usRuneSocket[ucRuneIndex])
{
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(m_usRuneSocket[ucRuneIndex]);
if (itemInfo)
{
m_wAttribute[ucIndex] -= itemInfo->m_EquipAttribute.m_usAttributeValue[ucIndex];
}
}
}
}
else if (enRuneApplyType&RuneApplyType::RUNE_ALL && enRuneApplyType&RuneApplyType::RUNE_REMOVE)
{
ApplyRuneAttribute(REMOVE);
}
else if (enRuneApplyType&RuneApplyType::RUNE_INDEX && enRuneApplyType&RuneApplyType::RUNE_APPLY)
{
for (unsigned char ucRuneIndex = 0; ucRuneIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ucRuneIndex++)
{
if (m_usRuneSocket[ucRuneIndex])
{
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(m_usRuneSocket[ucRuneIndex]);
if (itemInfo)
{
m_wAttribute[ucIndex] += itemInfo->m_EquipAttribute.m_usAttributeValue[ucIndex];
}
}
}
}
else if (enRuneApplyType&RuneApplyType::RUNE_ALL && enRuneApplyType&RuneApplyType::RUNE_APPLY)
{
ApplyRuneAttribute(APPLY);
}
}
inline unsigned short Item::CEquipment::GetRuneEquipLimitLevel(void) const
{
// 장착 아이템에 장착제한에 레벨을 얻어온다.
unsigned short usResult = 0;
for (unsigned char cIndex = 0; cIndex < EquipmentInfo::MAX_RUNE_SOCKET_NUM; ++cIndex)
{
if (m_usRuneSocket[cIndex])
{
unsigned short usItemId = m_usRuneSocket[cIndex];
const ItemInfo* itemInfo = CItemMgr::GetInstance().GetItemInfo(usItemId);
if (itemInfo)
{
if (itemInfo->m_UseLimit.m_cLimitStatus==Item::StatusLimit::LEVEL)
{
if (usResult<itemInfo->m_UseLimit.m_wLimitValue)
{
usResult = itemInfo->m_UseLimit.m_wLimitValue;
}
}
}
}
}
return usResult;
}
inline Item::CUseItem* Item::CUseItem::DowncastToUseItem(CItem* lpItem)
{
if (NULL == lpItem) { return NULL; }
return lpItem->IsSet(DetailData::USE_ITEM) ?
static_cast<CUseItem*>(lpItem) : NULL;
}
inline bool Item::CItem::GetEnableRepair(void)
{
unsigned long dwFlags = GetItemInfo().m_DetailData.m_dwFlags;
return ((dwFlags & Item::DetailData::EQUIP) && !(dwFlags & Item::DetailData::STACKABLE));
}
inline bool Item::CItem::GetEnableStack(void)
{
return (GetItemInfo().m_DetailData.m_dwFlags & Item::DetailData::STACKABLE) ? true : false;
}
inline bool Item::CItem::GetEnableEquip(void)
{
return (GetItemInfo().m_DetailData.m_dwFlags & Item::DetailData::EQUIP);
}
inline bool Item::CItem::GetSocketItem(void)
{
return (GetItemInfo().m_DetailData.m_cItemType == Item::ItemType::GEM);
}
inline bool Item::CItem::GetRuneItem(void)
{
return (GetItemInfo().m_DetailData.m_cItemType == Item::ItemType::RUNE);
}
inline bool Item::CItem::GetTwohandItem(void)
{
unsigned char cItemType = GetItemInfo().m_DetailData.m_cItemType;
return (cItemType == Item::ItemType::BOW ||
cItemType == Item::ItemType::CROSSBOW ||
cItemType == Item::ItemType::STAFF ||
cItemType == Item::ItemType::TWOHANDED_AXE ||
cItemType == Item::ItemType::TWOHANDED_BLUNT ||
cItemType == Item::ItemType::TWOHANDED_SWORD ||
cItemType == Item::ItemType::OPP_SYTHE);
}
// ------------------------------------------------------------------------------------------------------------
// ConvertTool에서만 사용되는 함수들 - RebalanceOverItem.cpp 에서 사용
inline void Item::CEquipment::Repair()
{
SetNumOrDurability(GetMaxNumOrDurability());
CalculateItemPrice();
}
inline void Item::CEquipment::InitEquip()
{
// 옵션 이식을 하기전에 룬 추가 옵션을 삭제한다.
RuneApplyType enRuneApplyType = static_cast<RuneApplyType>(RUNE_ALL | RUNE_REMOVE);
SetRuneAttribute(enRuneApplyType, 0);
// 제련 단계는 초기화된다. (옵션은 남는다.)
m_cUpgradeLevel = 0;
InitializeUpgradeAttribute();
// 소켓도 초기화된다. (보석은 모두 제거되지만 옵션은 남는다.)
m_cSocketNum = 0;
std::fill_n(m_cSocket, unsigned char(Item::EquipmentInfo::MAX_SOCKET_NUM), 0);
InitializeGemAttribute();
m_cMaxSocket = m_ItemInfo.m_DetailData.m_cMaxSocketNum;
}
inline void Item::CEquipment::SetEquip()
{
// 룬 속성을 다시 추가한다.
RuneApplyType enRuneApplyType = static_cast<RuneApplyType>(RUNE_ALL | RUNE_APPLY);
SetRuneAttribute(enRuneApplyType, 0);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,107 @@
#ifndef _CITEM_MGR_H_
#define _CITEM_MGR_H_
#define g_ItemMgr Item::CItemMgr::GetInstance()
#include <vector>
#include <map>
#include "item/ItemStructure.h"
// ----------------------------------------------------------------------------
// class : CItemMgr ( must use in single thread )
// 아이템 스크립트를 로딩하고, 저장하고, 새 아이템을 생성하는 등의 역할을 한다.
namespace Item
{
// 전방 참조
class CItem;
class CItemMgr
{
public:
static CItemMgr& GetInstance();
typedef std::map<ItemType::Type, unsigned char> RuneItemCnt;
// ----------------------------------------------------------------------------
// 아이템 스크립트 (ItemScript.txt)
bool LoadItemProtoType(const char* szFileName = NULL);
bool LoadItemProtoTypeBinary(const char* szFileNameBinary = NULL);
bool SaveItemProtoTypeBinary(const char* szFileNameBinary = NULL, const char* szTrashFile = NULL);
const ItemInfo* GetItemInfo(unsigned short usProtoTypeID);
const ItemInfo* GetItemInfoFromItemName(const char* szItemName);
const ItemInfo* GetItemInfoFromEquipName(const char* szEquipName);
const char* GetEquipName(const unsigned short usItemProtoTypeID);
const unsigned short GetItemIDFromSkillID(const unsigned short usSkill_ID, const unsigned short unSkill_LockCount);
const unsigned short GetDropItem(const Item::ItemType::Type eItemType, const unsigned char cLevel);
const unsigned short GetRingDropItem(const unsigned char cLevel, const unsigned char cGrade); //--//
const unsigned short GetNecklaceDropItem(const unsigned char cLevel, const unsigned char cGrade); //--//
const unsigned short GetRuneDropItem(const unsigned char cLevel, const unsigned char cGrade); //--//
void PrintDropListByLevel(void);
void PrintRingDropListByLevel(void); //--//
void PrintNecklaceDropListByLevel(void); //--//
void PrintRuneDropListByLevel(void); //--//
// ----------------------------------------------------------------------------
// 아이템 합성 스크립트 (ChemicalInfo.txt)
bool LoadItemChemical(const char* szFileName = NULL);
bool LoadItemChemicalBinary(const char* szFileNameBinary = NULL);
bool SaveItemChemicalBinary(const char* szFileNameBinary = NULL, const char* szTrashFile = NULL);
unsigned char GetChemicalResult(ChemicalInfo& chemical);
// ----------------------------------------------------------------------------
// 아이템 보상 스크립트 (SpeacialCompensation.txt)
bool LoadItemSpeacialCompensation(const char* szFileName = NULL);
bool LoadItemSpeacialCompensationBinary(const char* szFileNameBinary = NULL);
bool SaveItemSpeacialCompensationBinary(const char* szFileNameBinary = NULL, const char* szTrashFile = NULL);
unsigned short GetCompensationItem(unsigned char cItemType, short wLimitValue);
// 아이템 타입에 따른 룬 소켓 쵀대값.
unsigned char GetMaxRuneSocket(ItemType::Type type);
private:
CItemMgr();
~CItemMgr();
void DestoryItemInfo(void);
void DestoryChemical(void);
void DestoryCompensation(void);
static const char* ms_szChemicalScriptFileName;
static const char* ms_szSpeacialCompensationFileName;
static CItemMgr ms_this;
size_t m_nItemNum;
ItemInfo* m_ItemInfoArray;
typedef std::vector<unsigned short> ItemIDVector;
ItemIDVector m_vecDropListByLevel[Creature::MONSTER_MAX_LEVEL];
ItemIDVector m_vecRingDropListByLevel[Creature::MONSTER_MAX_LEVEL][EquipType::MAX_GRADE]; //--//
ItemIDVector m_vecNecklaceDropListByLevel[Creature::MONSTER_MAX_LEVEL][EquipType::MAX_GRADE]; //--//
ItemIDVector m_vecRuneDropListByLevel[Creature::MONSTER_MAX_LEVEL][EquipType::MAX_GRADE]; //--//
ItemIDVector m_vecCompensation[Compensation::MAX_CASE];
size_t m_nChemicalNum;
ChemicalInfo* m_ChemicalArray;
RuneItemCnt m_mapRuneItemCnt; // 룬 아이템 최대 개수.
};
}
#endif

View File

@@ -0,0 +1,163 @@
#ifndef _LOGIN_SERVER_INFO_
#define _LOGIN_SERVER_INFO_
#include <winsock2.h>
#include <windows.h>
#include <algorithm>
#pragma pack(1)
// -----------------------------------------------------------------------------
// 서버 정보 관련 구조체들
typedef union SERVER_ID* LPSERVER_ID;
union SERVER_ID
{
// 서버군
enum Group
{
GROUP_TEST = 0, // 테스트
GROUP_OFFICIAL1 = 1, // Ichman
GROUP_OFFICIAL2 = 2, //
GROUP_OFFICIAL3 = 3, //
GROUP_OFFICIAL4 = 4, //
GROUP_OFFICIAL5 = 5, //
GROUP_OFFICIAL6 = 6, //
GROUP_OFFICIAL7 = 7, //
GROUP_OFFICIAL8 = 8, //
GROUP_BATTLE_SERVER = 9, // 배틀서버
// Rodin : MAX_GROUP_NUM을 8로 하면 로긴 서버가 릴리즈에서 죽습니다. 왜?!?!
MAX_GROUP_NUM = 10
};
enum Zone
{
NONE = 0,
ZONE1 = 1, // 그랜드 코스트
ZONE2 = 2, // 레한 스팟
ZONE3 = 3, // X 구 배틀그라운드 (현재 사용안함)
ZONE4 = 4, // 사이너 아일랜드
ZONE5 = 5, // 아일랜드 오브 페인
BATTLE_ZONE = 6, // X 배틀 존
ADMIN_TOOL_ZONE = 7, // X (클라이언트 사정으로 쓰이지 않음) - 운영툴이 사용하겠소.
CAPITAL = 8, // 카나번
ZONE9 = 9, // X 구 NEWZONE5 번인데 글로벌에서 사용해야하기 때문에 ZONE9로 이전후 제거
FRAG_ZONE = 10, // X 배틀 그라운드 전용 서버의 가상 존
BATTLE_SERVER = 11, // X 배틀 그라운드 전용 서버
ZONE12 = 12, // 신의 대지
STATUE_ZONE = 13, // X 배틀 그라운드 전용 서버의 가상 존
PRISON = 14, // 감옥 (감금 시스템)
CHAR_SELECT = 15, // X 캐릭터 선택 화면 존
STONE_WAR1 = 16, // 로우 40랩이하 석상전용
STONE_WAR2 = 17, // 로우 80랩이하 석상전용
STONE_WAR3 = 18, // 로우 80랩이상 석상전용
MAX_ZONE_NUM = 19
};
enum Channel
{
// sphawk : 채널 관련해서 고쳤습니다. 여기저기 복잡하게 흩어져 있으니 함부로 건들지 마세요.
// 고친 패킷은 다음과 같습니다.
// 1. 여기.
// 2. PktSCInfo (중계쪽에서도 사용하는 패킷입니다)
// 3. PktCSAck
// 4. PktSZMvAck
// 5. PktCSDAck (중계쪽에서도 사용하는 패킷입니다)
// 6. PktSZMvDAck (중계쪽에서도 사용하는 패킷입니다)
// SERVER_GROUP쪽은 채널이라고 써 있지만 실제로는 휴먼/아칸 의 인원수입니다.(중계 소스를 보면 압니다.)
// 착오 없으시길 바랍니다.
MAX_CHANNEL_NUM = 5
};
typedef struct SID* LPSID;
struct SID
{
char Type;
char Group;
char Channel;
char ID;
};
SID sID;
unsigned long dwID;
inline char GetType(void) { return sID.Type; }
inline char GetChannel(void) { return sID.Channel; }
inline char GetZone(void) { return sID.ID; }
inline char GetGroup(void) { return sID.Group; }
};
typedef struct SERVER* LPSERVER_GROUP;
struct SERVER_GROUP
{
enum { CHANNEL_NUM = 2, SERVER_NAME = 15 };
char m_Group; // 서버 그룹
char m_Name[SERVER_NAME]; // 서버 이름
long m_ClientNum[CHANNEL_NUM]; // 접속 자 수
IN_ADDR m_Address; // 서버 주소
};
typedef struct SERVER* LPSERVER_LIST;
struct SERVER_LIST
{
enum { SERVER_NUM = 10 };
unsigned short m_ServerNum; // 서버 숫자
SERVER_GROUP m_ServerGroup[SERVER_NUM]; // 서버 그룹
};
#pragma pack()
typedef struct RylServerInfo* LPRylServerInfo;
struct RylServerInfo
{
enum
{
GROUP_NAME_LENGTH = 120,
PATCH_ADDRESS_LENGTH = 100
};
SERVER_ID m_ServerUID;
IN_ADDR m_ServerAddress;
unsigned long m_dwClientVer;
unsigned long m_dwChecksum;
size_t m_nGroupNameLen;
size_t m_nPatchAddressLen;
char m_szGroupName[GROUP_NAME_LENGTH];
char m_szPatchAddress[PATCH_ADDRESS_LENGTH];
unsigned short m_usChannelClientNum[SERVER_GROUP::CHANNEL_NUM];
unsigned short m_usChannelNum;
RylServerInfo::RylServerInfo()
: m_dwClientVer(0), m_dwChecksum(0),
m_nPatchAddressLen(0), m_usChannelNum(0)
{
m_ServerUID.dwID = 0;
m_ServerAddress.S_un.S_addr = 0;
m_szPatchAddress[0] = '\0';
strncpy(m_szGroupName, "UnKnown", GROUP_NAME_LENGTH);
m_nGroupNameLen = strlen(m_szGroupName);
std::fill_n(m_usChannelClientNum, int(SERVER_GROUP::CHANNEL_NUM), 0);
}
};
#endif

View File

@@ -0,0 +1,205 @@
// XORCrypt.cpp: implementation of the CXORCrypt class.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "XORCrypt.h"
#include <ctime>
#include <cstdlib>
#include "GMMemory.h"
CXORCrypt CXORCrypt::ms_this;
CXORCrypt::CXORCrypt()
{
InitCodePage();
for(int iVer = 2; iVer < 4; ++iVer)
{
for(int iPage = 0; iPage < CODE_PAGE; ++iPage)
{
for( int iBit = 0; iBit < BIT_COUNT; ++iBit)
{
BitFields[iVer][iPage][iBit] = BitFields[iVer][iPage][iBit]^BitFields[0][iPage][iBit];
}
}
}
return;
}
CXORCrypt::~CXORCrypt()
{
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// XORF [ public ] - XOR 연산. # 순방향
// Parameter : 1st : 시작 포인터, 2st : 길이, 3st : 코드 페이지
// Return:
void CXORCrypt::XORF(char *Start_In, int Length_In, unsigned short PageVer,
unsigned char PageNum1, unsigned char PageNum2)
{
for (int Counter = 0; Counter < Length_In; ++Counter)
{
*Start_In = *Start_In ^ BitFields[PageVer][PageNum1][Counter % BIT_COUNT];
*Start_In = *Start_In ^ BitFields[PageVer][PageNum2][Counter % BIT_COUNT];
++Start_In;
}
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// XORB [ public ] - XOR 연산. # 역방향
// Parameter : 1st : 시작 포인터, 2st : 길이, 3st : 코드 페이지
// Return:
void CXORCrypt::XORB(char *Start_In, int Length_In, unsigned short PageVer,
unsigned char PageNum1, unsigned char PageNum2)
{
for (int Counter = 0; Counter < Length_In; ++Counter)
{
*Start_In = *Start_In ^ BitFields[PageVer][PageNum2][Counter % BIT_COUNT];
*Start_In = *Start_In ^ BitFields[PageVer][PageNum1][Counter % BIT_COUNT];
++Start_In;
}
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// InitCODE_PAGE [ public ] - 암호 페이지를 초기화 한다
// Parameter :
// Return:
void CXORCrypt::InitCodePage(void)
{
int CODE_PAGENums = CODE_PAGE * 10;
srand((unsigned)time(NULL));
for (int Counter = 0; Counter < CODE_PAGENums; ++Counter)
{
m_CodePage[Counter] = rand() % CODE_PAGE;
if(Counter > 1)
{
if (m_CodePage[Counter] == m_CodePage[Counter - 1])
{
--Counter;
}
}
}
m_CodePageCount = rand() % (CODE_PAGE * 10);
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// GetCODE_PAGE [ public ] - 암호 페이지를 얻는다
// Parameter :
// Return:
unsigned long CXORCrypt::GetCodePage(void)
{
if(0xffffff00 < m_CodePageCount)
{
m_CodePageCount = 0;
}
m_CodePageCount = (m_CodePageCount + 2) % (CODE_PAGE * 10);
return (((unsigned long)PAGE_VERSION << 16) & 0xffff0000) |
(((unsigned long)m_CodePage[m_CodePageCount] << 8) & 0x0000ff00) |
((unsigned long)m_CodePage[m_CodePageCount - 1] & 0x000000ff);
}
unsigned long CXORCrypt::GetCodePage(unsigned short PageVer_In)
{
if(0xffffff00 < m_CodePageCount)
{
m_CodePageCount = 0;
}
m_CodePageCount = (m_CodePageCount + 2) % (CODE_PAGE * 10);
return (((unsigned long)PageVer_In << 16) & 0xffff0000) |
(((unsigned long)m_CodePage[m_CodePageCount] << 8) & 0x0000ff00) |
((unsigned long)m_CodePage[m_CodePageCount - 1] & 0x000000ff);
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// InnerEncodeS [ public ] - 데이터 암호화 : 데이터를 XOR 연산 한다. # 클라이언트 용
// Parameter : 1st : 시작 포인터, 2st : 길이, 3st : 코드 페이지
// Return:
bool CXORCrypt::EncodePacket(char *Start_In, int Length_In, unsigned long CodePage_In)
{
unsigned short PageVer = 0;
unsigned char PageNum1 = 0, PageNum2 = 0;
PageVer = (unsigned short)(((CodePage_In & 0xffff0000) >> 16) & 0x0000ffff);
PageNum1 = (unsigned char)(((CodePage_In & 0xff00) >> 8) & 0x00ff);
PageNum2 = (unsigned char)(CodePage_In & 0x00ff);
if(PageVer < 0 || PageVer > 4)
return false;
if(PageNum1 < 0 || PageNum1 >= CODE_PAGE || PageNum2 < 0 || PageNum2 >= CODE_PAGE)
return false;
XORF(Start_In, Length_In, PageVer, PageNum1, PageNum2);
return true;
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// InnerEncodeS [ public ] - 데이터 암호화 : 데이터를 XOR 연산 한다. # 서버용
// Parameter : 1st : 시작 포인터, 2st : 길이, 3st : 코드 페이지
// Return:
bool CXORCrypt::DecodePacket(char *Start_In, int Length_In, unsigned long CodePage_In)
{
unsigned short PageVer = 0;
unsigned char PageNum1 = 0, PageNum2 = 0;
PageVer = (unsigned short)(((CodePage_In & 0xffff0000) >> 16) & 0x0000ffff);
PageNum1 = (unsigned char)(((CodePage_In & 0xff00) >> 8) & 0x00ff);
PageNum2 = (unsigned char)(CodePage_In & 0x00ff);
if(PageVer < 0 || PageVer > 4)
return false;
if(PageNum1 < 0 || PageNum1 >= CODE_PAGE || PageNum2 < 0 || PageNum2 >= CODE_PAGE)
return false;
XORB(Start_In, Length_In, PageVer, PageNum1, PageNum2);
return true;
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// EncodeHeader [ public ] - 데이터 암호화 : 데이터를 XOR 연산 한다.
// Parameter : 1st : 시작 포인터, 2st : 길이
// Return:
void CXORCrypt::EncodeHeader(char *Start_In, int Length_In, unsigned short PageVer_In, unsigned char PageNum_In)
{
for(int Counter = 0; Counter < Length_In; ++Counter)
{
*Start_In = *Start_In ^ BitFields[PageVer_In][PageNum_In][Counter % BIT_COUNT];
*Start_In = (((*Start_In & 0x80) >> 7) & 0x01) | ((*Start_In << 1) & 0xFE);
++Start_In;
}
}
//Interface////////////////////////////////////////////////////////////////////////////////////
// DecodeHeader [ public ] - 데이터 복호화 : 데이터를 XOR 연산 한다. # 서버용
// Parameter : 1st : 시작 포인터, 2st : 길이
// Return:
void CXORCrypt::DecodeHeader(char *Start_In, int Length_In, unsigned short PageVer_In, unsigned char PageNum_In)
{
for(int Counter = 0; Counter < Length_In; ++Counter)
{
*Start_In = (((*Start_In & 0x01) << 7) & 0x80) | ((*Start_In >> 1) & 0x7F);
*Start_In = *Start_In ^ BitFields[PageVer_In][PageNum_In][Counter % BIT_COUNT];
++Start_In;
}
}

View File

@@ -0,0 +1,59 @@
#ifndef _CXOR_CRYPT_H_
#define _CXOR_CRYPT_H_
#pragma once
#include <Pattern/Singleton.h>
class CXORCrypt : public CSingleton<CXORCrypt>
{
public:
enum
{
PAGE_VERSION = 3,
BIT_COUNT = 40,
CODE_PAGE = 10,
};
private:
static unsigned char BitFields[][CODE_PAGE][BIT_COUNT];
unsigned char m_CodePage[CODE_PAGE * 10];
unsigned long m_CodePageCount;
void InitCodePage(void);
void XORF(char *Start_In, int Length_In, unsigned short PageVer, unsigned char PageNum1, unsigned char PageNum2);
void XORB(char *Start_In, int Length_In, unsigned short PageVer, unsigned char PageNum1, unsigned char PageNum2);
// To make Singleton Class.
CXORCrypt();
static CXORCrypt ms_this;
public:
~CXORCrypt();
// interface of encoder, decoder
unsigned long GetCodePage(void);
unsigned long GetCodePage(unsigned short PageVer_In);
inline unsigned short GetPageVer(unsigned long CodePage_In);
bool EncodePacket(char *Start_In, int Length_In, unsigned long CodePage_In);
bool DecodePacket(char *Start_In, int Length_In, unsigned long CodePage_In);
void EncodeHeader(char *Start_In, int HeaderLen_In, unsigned short PageVer_In, unsigned char PageNum_In);
void DecodeHeader(char *Start_In, int HeaderLen_In, unsigned short PageVer_In, unsigned char PageNum_In);
};
inline unsigned short CXORCrypt::GetPageVer(unsigned long CodePage_In)
{
return (unsigned short)(((CodePage_In & 0xffff0000) >> 16) & 0x0000ffff);
}
#endif

View File

@@ -0,0 +1,422 @@
#include "stdafx.h"
#include "XORCrypt.h"
#include "GMMemory.h"
unsigned char CXORCrypt::BitFields[][CODE_PAGE][BIT_COUNT] =
{
///////////////////////////////////////////////////////////////////////
//Code Version 0
{
// Code Page 1
0x82, 0x53, 0x43, 0x4C, 0x2B,
0x0D, 0x37, 0xD7, 0xD9, 0xD8,
0x1B, 0x6D, 0xA0, 0xC3, 0x2B,
0xEE, 0x45, 0x88, 0x1A, 0xA6,
0x18, 0x1D, 0x9D, 0x38, 0x2A,
0x55, 0x03, 0x1D, 0xCD, 0xA6,
0x73, 0x07, 0xED, 0x8D, 0xC5,
0xDB, 0xA3, 0xBD, 0xB6, 0xD5,
// Code Page 2
0x34, 0xB5, 0xB2, 0x3D, 0x7D,
0x43, 0x8C, 0xC0, 0x21, 0x25,
0xCD, 0xB6, 0x53, 0x76, 0xCE,
0x5D, 0xD4, 0x87, 0xCA, 0x84,
0x81, 0xCB, 0x5E, 0x04, 0xBA,
0x69, 0x3E, 0x65, 0xDE, 0x21,
0x8A, 0x63, 0x62, 0x71, 0x90,
0x87, 0x0A, 0x52, 0x28, 0x44,
// Code Page 3
0xA3, 0x49, 0xDC, 0xEA, 0x09,
0xB7, 0x01, 0xA4, 0xA1, 0x11,
0x11, 0x8E, 0x80, 0x35, 0x5B,
0xDD, 0x38, 0xD5, 0x4E, 0x36,
0x0C, 0xA2, 0xBB, 0x05, 0x36,
0x57, 0x2E, 0x98, 0xBE, 0x88,
0x3C, 0x28, 0x43, 0x63, 0xA0,
0xE9, 0xE1, 0x6D, 0x51, 0xCB,
// Code Page 4
0x4D, 0x62, 0x84, 0x43, 0x89,
0xC7, 0x89, 0x83, 0x65, 0x29,
0x53, 0x95, 0x7C, 0xC0, 0xA1,
0x0C, 0xDB, 0xD7, 0x04, 0xD8,
0x6A, 0xD1, 0x73, 0x1D, 0x21,
0x67, 0x86, 0x8D, 0xA4, 0xA0,
0x34, 0xBD, 0x31, 0x20, 0x61,
0x0E, 0xE9, 0x63, 0xB4, 0xC0,
// Code Page 5
0xC7, 0x36, 0x1B, 0x41, 0x23,
0x9C, 0xD1, 0x8C, 0x25, 0x53,
0x42, 0x2E, 0x45, 0x6D, 0x42,
0x7B, 0x4E, 0x5B, 0xEB, 0x24,
0x33, 0x74, 0x52, 0x28, 0xC6,
0x2A, 0xC3, 0x16, 0x60, 0xA5,
0x45, 0x35, 0xDB, 0x9A, 0x54,
0x97, 0xE2, 0xEE, 0x9B, 0xDE,
// Code Page 6
0xE0, 0xC3, 0x84, 0x41, 0xED,
0x45, 0x4C, 0x69, 0xD9, 0x28,
0x55, 0x27, 0x8E, 0x3A, 0x3C,
0x8E, 0x84, 0x97, 0x14, 0xE6,
0x58, 0x51, 0x26, 0x0D, 0xE2,
0x9E, 0x66, 0x7C, 0x0D, 0x01,
0x7D, 0x17, 0x4C, 0x08, 0xDD,
0x97, 0x1C, 0x7B, 0xCE, 0x5D,
// Code Page 7
0x54, 0x37, 0x7C, 0x0C, 0x8E,
0x27, 0x7A, 0x78, 0x2E, 0xE6,
0x6D, 0x25, 0x62, 0x62, 0x98,
0x20, 0x2E, 0x23, 0x15, 0x61,
0x7D, 0x97, 0x50, 0x07, 0x20,
0x7A, 0x04, 0x29, 0x62, 0x90,
0x6B, 0xE9, 0xE6, 0x22, 0x72,
0x38, 0x56, 0xC9, 0x06, 0x2E,
// Code Page 8
0x3B, 0x47, 0x08, 0x2D, 0x21,
0x42, 0x07, 0x69, 0x4A, 0x57,
0x8B, 0x79, 0xE7, 0x56, 0x27,
0x23, 0x24, 0x85, 0x47, 0x74,
0x75, 0x85, 0xA9, 0xEB, 0x10,
0xCB, 0x17, 0x85, 0x4B, 0x5E,
0x20, 0x78, 0xD0, 0x7D, 0x86,
0x5E, 0x14, 0x7E, 0x64, 0x50,
// Code Page 9
0x69, 0x52, 0x4A, 0xBD, 0x8C,
0x9B, 0xD6, 0x63, 0xBD, 0x26,
0x86, 0x32, 0x95, 0xA4, 0x02,
0x9B, 0x01, 0x14, 0x49, 0x78,
0x88, 0x57, 0x3A, 0x01, 0x4A,
0xBC, 0x50, 0xCD, 0x31, 0x39,
0x71, 0x30, 0x5B, 0x9C, 0x4D,
0x21, 0x67, 0x82, 0xE8, 0x5C,
// Code Page 10
0x66, 0x10, 0xA9, 0x7D, 0xD2,
0x36, 0xE2, 0xB1, 0x28, 0x20,
0xD5, 0xE7, 0xD5, 0x0E, 0xD4,
0x0C, 0x2C, 0x77, 0x80, 0x0E,
0xA6, 0x37, 0xBE, 0x61, 0xAD,
0xD6, 0x17, 0x65, 0x13, 0x70,
0xAE, 0x40, 0x3B, 0x52, 0xEE,
0x53, 0x84, 0xEB, 0x04, 0x0D,
},
///////////////////////////////////////////////////////////////////////
//Code Version 1
{
// Code Page 1
0x49, 0x8C, 0x77, 0xC0, 0xC0,
0x64, 0x54, 0x0B, 0x22, 0xBD,
0x82, 0x93, 0x9A, 0x23, 0x8D,
0xE4, 0xC8, 0x9D, 0xB3, 0x50,
0x44, 0xB1, 0xE2, 0x9E, 0x15,
0x7A, 0xA1, 0x0C, 0x24, 0xE3,
0x1E, 0x0A, 0x0A, 0x73, 0x6A,
0xA5, 0x8B, 0x3A, 0x53, 0x33,
// Code Page 2
0xB0, 0xE6, 0xB7, 0x51, 0x70,
0xDA, 0xD6, 0x29, 0xAA, 0x10,
0xB5, 0x8A, 0x38, 0x37, 0x4E,
0x7A, 0x3B, 0x74, 0x7B, 0x63,
0x41, 0x7C, 0x21, 0x65, 0x5E,
0x26, 0x95, 0x44, 0x75, 0xA3,
0x74, 0xDD, 0xB4, 0x33, 0x9E,
0x54, 0x3C, 0x95, 0x5E, 0x34,
// Code Page 3
0x10, 0x19, 0x43, 0x64, 0x78,
0x2B, 0xA6, 0x60, 0x7D, 0xCD,
0xA9, 0x28, 0xB8, 0x85, 0x0E,
0x66, 0xC7, 0x3C, 0x28, 0xDC,
0xA1, 0x4D, 0x60, 0x9B, 0xC7,
0xD3, 0x74, 0x93, 0xE6, 0xC3,
0x97, 0x76, 0x12, 0xA4, 0xCB,
0xB9, 0x22, 0x51, 0xB9, 0x79,
// Code Page 4
0x5C, 0x68, 0xDB, 0xE6, 0x59,
0x57, 0x95, 0xCD, 0xAE, 0xCA,
0x67, 0xB8, 0x37, 0x90, 0xBA,
0x54, 0x98, 0x95, 0x73, 0x8E,
0x47, 0xC1, 0x40, 0xBA, 0x80,
0x26, 0x10, 0xAA, 0x60, 0x64,
0xD8, 0x69, 0xC7, 0x0D, 0x2B,
0x28, 0xA6, 0xBA, 0x01, 0x4A,
// Code Page 5
0xEE, 0x28, 0x65, 0xC4, 0x9D,
0x41, 0x8D, 0x91, 0x6C, 0x91,
0x7E, 0x80, 0xC3, 0xD1, 0xAE,
0xB6, 0x92, 0x41, 0x66, 0x13,
0x72, 0x20, 0x26, 0xA1, 0x72,
0x05, 0x29, 0x08, 0x88, 0x30,
0x40, 0x6D, 0x5A, 0x41, 0x01,
0x7A, 0xDB, 0x2C, 0xEE, 0xC3,
// Code Page 6
0x5C, 0x03, 0x38, 0xD8, 0x95,
0xE7, 0xB4, 0x67, 0x30, 0x51,
0x21, 0x68, 0x78, 0x89, 0x68,
0x0B, 0xE3, 0xB0, 0x28, 0xB3,
0xA9, 0x38, 0x18, 0xE4, 0x59,
0x43, 0xC9, 0x52, 0x75, 0x04,
0x15, 0x07, 0x97, 0x14, 0x07,
0x27, 0xDA, 0xE5, 0xD9, 0xDB,
// Code Page 7
0xDB, 0x08, 0x27, 0xA3, 0x64,
0xDC, 0x42, 0xE3, 0x3D, 0x0D,
0x26, 0xA2, 0xC3, 0x5E, 0x3E,
0xA7, 0x47, 0xE4, 0x1C, 0x73,
0x13, 0x99, 0x9E, 0xBA, 0xD3,
0x08, 0x73, 0x88, 0x03, 0x01,
0x24, 0x2E, 0x09, 0xBD, 0x3A,
0x6E, 0x3C, 0xB6, 0xA2, 0x22,
// Code Page 8
0xE7, 0x27, 0x60, 0x20, 0x85,
0xDA, 0xEA, 0x84, 0x86, 0x41,
0x67, 0x1C, 0x83, 0xBE, 0x7A,
0x61, 0x67, 0x01, 0x18, 0x30,
0xC6, 0x37, 0xBC, 0x51, 0xBC,
0x78, 0xA1, 0x53, 0x53, 0x58,
0x9B, 0x32, 0x05, 0x67, 0x6B,
0xC7, 0x3A, 0x7C, 0xA8, 0xE5,
// Code Page 9
0x70, 0x10, 0x29, 0x88, 0x94,
0xC0, 0xEE, 0x8D, 0x52, 0x20,
0xD9, 0xC3, 0x3C, 0xB3, 0x43,
0x74, 0x83, 0xC8, 0xC5, 0xAA,
0x90, 0x58, 0x0C, 0xD0, 0xBC,
0x2A, 0xED, 0x04, 0x05, 0x8E,
0x27, 0xDE, 0x9C, 0x37, 0x57,
0x2A, 0x93, 0x63, 0x1B, 0x9E,
// Code Page 10
0xC3, 0x52, 0xDB, 0xE9, 0x63,
0x9A, 0x87, 0x18, 0x6D, 0xBE,
0x1B, 0x37, 0x6A, 0xEA, 0x01,
0x02, 0x01, 0xB5, 0x74, 0x71,
0xA5, 0x9A, 0x9A, 0x3A, 0x11,
0x8B, 0x62, 0xD7, 0xB0, 0x06,
0x0C, 0xA0, 0x10, 0x09, 0x97,
0x5A, 0xEB, 0xEA, 0x18, 0xB8,
},
///////////////////////////////////////////////////////////////////////
//Code Version 2
{
// Code Page 1
0xDD, 0x9E, 0xB4, 0x33, 0x74,
0x32, 0x6B, 0x05, 0x67, 0x9B,
0xD6, 0x10, 0x29, 0xAA, 0xDA,
0x8A, 0x4E, 0x38, 0x37, 0xB5,
0x3B, 0x63, 0x74, 0x7B, 0x7A,
0x7C, 0x5E, 0x21, 0x65, 0x41,
0x3A, 0xE5, 0x7C, 0xA8, 0xC7,
0x10, 0x94, 0x29, 0x88, 0x70,
// Code Page 2
0x68, 0x68, 0x78, 0x89, 0x21,
0xA0, 0x97, 0x10, 0x09, 0x0C,
0xB4, 0x51, 0x67, 0x30, 0xE7,
0x47, 0x73, 0xE4, 0x1C, 0xA7,
0x99, 0xD3, 0x9E, 0xBA, 0x13,
0x74, 0xC3, 0x93, 0xE6, 0xD3,
0x76, 0xCB, 0x12, 0xA4, 0x97,
0xE3, 0xB3, 0xB0, 0x28, 0x0B,
// Code Page 3
0x45, 0xA6, 0x88, 0x1A, 0xEE,
0x1D, 0x2A, 0x9D, 0x38, 0x18,
0xA3, 0xD5, 0xBD, 0xB6, 0xDB,
0x95, 0xCA, 0xCD, 0xAE, 0x57,
0x38, 0x36, 0xD5, 0x4E, 0xDD,
0x2E, 0x88, 0x98, 0xBE, 0x57,
0x89, 0x29, 0x83, 0x65, 0xC7,
0x95, 0xA1, 0x7C, 0xC0, 0x53,
// Code Page 4
0xD1, 0x21, 0x73, 0x1D, 0x6A,
0x86, 0xA0, 0x8D, 0xA4, 0x67,
0xA2, 0x36, 0xBB, 0x05, 0x0C,
0xBD, 0x61, 0x31, 0x20, 0x34,
0x36, 0x23, 0x1B, 0x41, 0xC7,
0xD1, 0x53, 0x8C, 0x25, 0x9C,
0x2E, 0x42, 0x45, 0x6D, 0x42,
0x4E, 0x24, 0x5B, 0xEB, 0x7B,
// Code Page 5
0x74, 0xC6, 0x52, 0x28, 0x33,
0xC3, 0xA5, 0x16, 0x60, 0x2A,
0x35, 0x54, 0xDB, 0x9A, 0x45,
0xE2, 0xDE, 0xEE, 0x9B, 0x97,
0xC3, 0xED, 0x84, 0x41, 0xE0,
0x4C, 0x28, 0x69, 0xD9, 0x45,
0x27, 0x3C, 0x8E, 0x3A, 0x55,
0x84, 0xE6, 0x97, 0x14, 0x8E,
// Code Page 6
0x69, 0x2B, 0xC7, 0x0D, 0xD8,
0xA6, 0x4A, 0xBA, 0x01, 0x28,
0x28, 0x9D, 0x65, 0xC4, 0xEE,
0x98, 0x8E, 0x95, 0x73, 0x54,
0x51, 0xE2, 0x26, 0x0D, 0x58,
0xDB, 0xD8, 0xD7, 0x04, 0x0C,
0x66, 0x01, 0x7C, 0x0D, 0x9E,
0x17, 0xDD, 0x4C, 0x08, 0x7D,
// Code Page 7
0x25, 0x98, 0x62, 0x62, 0x6D,
0x2E, 0x61, 0x23, 0x15, 0x20,
0x97, 0x20, 0x50, 0x07, 0x7D,
0x1C, 0x5D, 0x7B, 0xCE, 0x97,
0x37, 0x8E, 0x7C, 0x0C, 0x54,
0x7A, 0xE6, 0x78, 0x2E, 0x27,
0x04, 0x90, 0x29, 0x62, 0x7A,
0xE9, 0x72, 0xE6, 0x22, 0x6B,
// Code Page 8
0x07, 0x57, 0x69, 0x4A, 0x42,
0x79, 0x27, 0xE7, 0x56, 0x8B,
0xC8, 0x50, 0x9D, 0xB3, 0xE4,
0xB1, 0x15, 0xE2, 0x9E, 0x44,
0x56, 0x2E, 0xC9, 0x06, 0x38,
0x47, 0x21, 0x08, 0x2D, 0x3B,
0xA1, 0xE3, 0x0C, 0x24, 0x7A,
0x24, 0x74, 0x85, 0x47, 0x23,
// Code Page 9
0x14, 0x50, 0x7E, 0x64, 0x5E,
0x52, 0x8C, 0x4A, 0xBD, 0x69,
0xD6, 0x26, 0x63, 0xBD, 0x9B,
0x85, 0x10, 0xA9, 0xEB, 0x75,
0x17, 0x5E, 0x85, 0x4B, 0xCB,
0x78, 0x86, 0xD0, 0x7D, 0x20,
0x32, 0x02, 0x95, 0xA4, 0x86,
0x01, 0x78, 0x14, 0x49, 0x9B,
// Code Page 10
0x57, 0x4A, 0x3A, 0x01, 0x88,
0x07, 0x07, 0x97, 0x14, 0x15,
0xDA, 0xDB, 0xE5, 0xD9, 0x27,
0x50, 0x39, 0xCD, 0x31, 0xBC,
0x30, 0x4D, 0x5B, 0x9C, 0x71,
0x67, 0x5C, 0x82, 0xE8, 0x21,
0x08, 0x64, 0x27, 0xA3, 0xDB,
0x42, 0x0D, 0xE3, 0x3D, 0xDC,
},
///////////////////////////////////////////////////////////////////////
//Code Version 3
{
// Code Page 1
0xA2, 0x3E, 0xC3, 0x5E, 0x26,
0xE7, 0xD4, 0xD5, 0x0E, 0xD5,
0x2C, 0x0E, 0x77, 0x80, 0x0C,
0x37, 0xAD, 0xBE, 0x61, 0xA6,
0x10, 0xD2, 0xA9, 0x7D, 0x66,
0xE2, 0x20, 0xB1, 0x28, 0x36,
0x17, 0x70, 0x65, 0x13, 0xD6,
0x40, 0xEE, 0x3B, 0x52, 0xAE,
// Code Page 2
0x37, 0x01, 0x6A, 0xEA, 0x1B,
0x0A, 0x6A, 0x0A, 0x73, 0x1E,
0xB5, 0x7D, 0xB2, 0x3D, 0x34,
0x8C, 0x25, 0xC0, 0x21, 0x43,
0x01, 0x71, 0xB5, 0x74, 0x02,
0x84, 0x0D, 0xEB, 0x04, 0x53,
0x87, 0xBE, 0x18, 0x6D, 0x9A,
0x93, 0x8D, 0x9A, 0x23, 0x82,
// Code Page 3
0xE6, 0x70, 0xB7, 0x51, 0xB0,
0x8C, 0xC0, 0x77, 0xC0, 0x49,
0xCB, 0xBA, 0x5E, 0x04, 0x81,
0x3E, 0x21, 0x65, 0xDE, 0x69,
0x63, 0x90, 0x62, 0x71, 0x8A,
0x62, 0x89, 0x84, 0x43, 0x4D,
0xE9, 0xC0, 0x63, 0xB4, 0x0E,
0x28, 0x0E, 0xB8, 0x85, 0xA9,
// Code Page 4
0xC7, 0xDC, 0x3C, 0x28, 0x66,
0x68, 0x59, 0xDB, 0xE6, 0x5C,
0x0A, 0x44, 0x52, 0x28, 0x87,
0x95, 0xA3, 0x44, 0x75, 0x26,
0x3C, 0x34, 0x95, 0x5E, 0x54,
0x19, 0x78, 0x43, 0x64, 0x10,
0x4D, 0xC7, 0x60, 0x9B, 0xA1,
0x8B, 0x33, 0x3A, 0x53, 0xA5,
// Code Page 5
0xB8, 0xBA, 0x37, 0x90, 0x67,
0xEE, 0x20, 0x8D, 0x52, 0xC0,
0xED, 0x8E, 0x04, 0x05, 0x2A,
0xB6, 0xCE, 0x53, 0x76, 0xCD,
0xD4, 0x84, 0x87, 0xCA, 0x5D,
0x62, 0x06, 0xD7, 0xB0, 0x8B,
0xC1, 0x80, 0x40, 0xBA, 0x47,
0x10, 0x64, 0xAA, 0x60, 0x26,
// Code Page 6
0x54, 0xBD, 0x0B, 0x22, 0x64,
0x53, 0x2B, 0x43, 0x4C, 0x82,
0x37, 0xD8, 0xD7, 0xD9, 0x0D,
0x6D, 0x2B, 0xA0, 0xC3, 0x1B,
0x49, 0x09, 0xDC, 0xEA, 0xA3,
0x01, 0x11, 0xA4, 0xA1, 0xB7,
0x8E, 0x5B, 0x80, 0x35, 0x11,
0x6D, 0x01, 0x5A, 0x41, 0x40,
// Code Page 7
0xDB, 0xC3, 0x2C, 0xEE, 0x7A,
0x03, 0x95, 0x38, 0xD8, 0x5C,
0x8D, 0x91, 0x91, 0x6C, 0x41,
0x80, 0xAE, 0xC3, 0xD1, 0x7E,
0x38, 0x59, 0x18, 0xE4, 0xA9,
0xC9, 0x04, 0x52, 0x75, 0x43,
0x92, 0x13, 0x41, 0x66, 0xB6,
0x20, 0x72, 0x26, 0xA1, 0x72,
// Code Page 8
0x29, 0x30, 0x08, 0x88, 0x05,
0x3C, 0x22, 0xB6, 0xA2, 0x6E,
0x27, 0x85, 0x60, 0x20, 0xE7,
0x73, 0x01, 0x88, 0x03, 0x08,
0x2E, 0x3A, 0x09, 0xBD, 0x24,
0xEA, 0x41, 0x84, 0x86, 0xDA,
0x1C, 0x7A, 0x83, 0xBE, 0x67,
0x67, 0x30, 0x01, 0x18, 0x61,
// Code Page 9
0x37, 0xBC, 0xBC, 0x51, 0xC6,
0xA1, 0x58, 0x53, 0x53, 0x78,
0xDE, 0x57, 0x9C, 0x37, 0x27,
0xC3, 0x43, 0x3C, 0xB3, 0xD9,
0x83, 0xAA, 0xC8, 0xC5, 0x74,
0x58, 0xBC, 0x0C, 0xD0, 0x90,
0x93, 0x9E, 0x63, 0x1B, 0x2A,
0x52, 0x63, 0xDB, 0xE9, 0xC3,
// Code Page 10
0x9A, 0x11, 0x9A, 0x3A, 0xA5,
0x22, 0x79, 0x51, 0xB9, 0xB9,
0xEB, 0xB8, 0xEA, 0x18, 0x5A,
0x28, 0xA0, 0x43, 0x63, 0x3C,
0xE1, 0xCB, 0x6D, 0x51, 0xE9,
0xA6, 0xCD, 0x60, 0x7D, 0x2B,
0x03, 0xA6, 0x1D, 0xCD, 0x55,
0x07, 0xC5, 0xED, 0x8D, 0x73,
}
};

View File

@@ -0,0 +1,357 @@
#include "stdafx.h"
using namespace Item;
enum SERVER_TYPE
{
SERVER_NORMAL = 1,
SERVER_BATTLE = 2
};
#define MAX_VERSION_HISTORY 2000 // 총 버전 라인수
char g_szCurrentVersion[10] = { 0, };
int g_nVersionLineCnt = 0;
char g_szVersionInfo[MAX_VERSION_HISTORY][MAX_PATH] = { 0, };
void InitVersionInfo(void);
SERVER_TYPE GetCurrentItemScript(void)
{
int nSelect = 0;
while (true)
{
printf("Type of ItemScript (1 -ROW Online , 2 -Battle Lohan) : ");
scanf("%d", &nSelect);
if (1 == nSelect)
{
return SERVER_NORMAL;
}
if (2 == nSelect)
{
return SERVER_BATTLE;
}
}
}
bool ItemScriptCheck(CItemMgr& ItemMgr)
{
while (true)
{
int nType = 0;
printf("\nInput Items ID. (0 - Quit) : ");
scanf("%d", &nType);
if (0 == nType) { break; }
if (0 == ItemMgr.GetItemInfo(nType))
{
printf("Can't find the Item which is ID No.%d ", nType);
continue;
}
printf("Item Name : %s Note : %s\n", ItemMgr.GetItemInfo(nType)->m_SpriteData.m_szName,
ItemMgr.GetItemInfo(nType)->m_StringData.m_szItemDescribe);
}
return true;
}
int _tmain(int argc, _TCHAR* argv[])
{
InitVersionInfo();
printf("\n<< Script Convert Ver %s >>\n", g_szCurrentVersion);
char szItemScriptTrashFile[MAX_PATH] = "ItemScript.jpg";
CItemMgr& ItemMgr = CItemMgr::GetInstance();
int nType = 0;
printf("\nSelect Number. (Quit : 0)");
printf("\n===========================================================");
printf("\n1 : Item Script Converting & Load Test");
printf("\n2 : Skillscript");
printf("\n2 : Monster proto");
printf("\n===========================================================");
printf("\n");
printf("\n");
START:
printf("\n? ");
scanf("%d", &nType);
switch (nType)
{
case 0:
break;
case 1:
{
SERVER_TYPE serverType = GetCurrentItemScript();
if (false == ItemMgr.LoadItemProtoType((SERVER_BATTLE == serverType) ? "BGItemScript.txt" : "ItemScript.txt"))
{
printf("Failed to ItemScipt file loading!\n");
getchar();getchar();
return -1;
}
if (false == ItemMgr.SaveItemProtoTypeBinary((SERVER_BATTLE == serverType) ? "BGItemScript.gsf" : "ItemScript.gsf",
szItemScriptTrashFile))
{
printf("Failed to ItemScipt file saving!\n");
getchar();getchar();
return -1;
}
if (false == ItemMgr.LoadItemProtoTypeBinary((SERVER_BATTLE == serverType) ? "BGItemScript.gsf" : "ItemScript.gsf"))
{
printf("Failed to ItemScipt reloading!\n");
getchar();getchar();
return -1;
}
if (false == ItemScriptCheck(ItemMgr))
{
printf("Irregular ItemScript. Check script Please.\n");
getchar();getchar();
return -1;
}
/*ItemMgr.PrintDropListByLevel();
ItemMgr.PrintRingDropListByLevel();
ItemMgr.PrintNecklaceDropListByLevel();
ItemMgr.PrintRuneDropListByLevel();*/
printf("Success to ItemScript converting.\n");
getchar();getchar();
break;
}
case 2:
{
if (g_SkillMgr.LoadSkillsFromFile("SkillScript.txt") == false)
{
printf("Failed to load SkillScript.txt!\n");
getchar();getchar();
return -1;
}
if (g_SkillMgr.SaveSkillsToBinary("SkillScript.gsf", "SkillScript.jpg") == false)
{
printf("Failed to save SkillScript.gsf!\n");
printf("You sure you got write rights and SkillScript.jpg in this folder?!\n");
getchar();getchar();
return -1;
}
if (g_SkillMgr.LoadSkillsFromBinary("SkillScript.gsf") == false)
{
printf("Failed to load SkillScript.gsf!\n");
getchar();getchar();
return -1;
}
printf("Converting done.\n");
getchar();getchar();
break;
}
case 3:
{
if (g_MonsterMgr.LoadMonstersFromFile("MonsterProtoType.txt") == false)
{
printf("Failed to load MonsterProtoType.txt!\n");
getchar();getchar();
return -1;
}
if (g_MonsterMgr.SaveMonstersToBinary("MonsterProtoType.gsf", "MonsterProtoType.jpg") == false)
{
printf("Failed to save MonsterProtoType.gsf!\n");
printf("You sure you got write rights and MonsterProtoType.jpg in this folder?!\n");
getchar();getchar();
return -1;
}
if (g_MonsterMgr.LoadMonstersFromBinary("MonsterProtoType.gsf") == false)
{
printf("Failed to load MonsterProtoType.gsf!\n");
getchar();getchar();
return -1;
}
printf("Converting done.\n");
getchar();getchar();
break;
}
default:
{
printf("It is wrong number.\n");
getchar();getchar();
goto START;
}
}
return 0;
}
void InitVersionInfo(void)
{
#define ADD_LINE() \
++nLine; \
if (nLine >= MAX_VERSION_HISTORY) { \
MessageBox(NULL, "VERSION ERROR : Input higher number of MAX_VERSION_HISTORY.", "Error", MB_OK); \
exit(0); \
}
// 메뉴에 표시될 최신 버전 정보
strcpy(g_szCurrentVersion, "1.39");
// 최신 버전의 라인수
g_nVersionLineCnt = 2;
// "========================================================================================"
// "Version History"
// "----------------------------------------------------------------------------------------"
//
int nLine = 0;
strcpy(g_szVersionInfo[nLine], " - 1.39 (2006-06-19)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : ItemType에 GEM_SELL 타입 추가(구매/판매가 동일 아이템) " ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.38 (2006-04-26)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 3차 밸런스 패치 / S 그레이드 아이템 추가로 인한 리빌드 " ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.37 (2005-10-31)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : 국가전 석상 리스폰 가능 여부 컬럼 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.36 (2005-07-20)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : SKILL_ITEM 타입(연결된 스킬의 효과를 발휘하는 아이템) 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : LinkQID 컬럼 삭제" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : ForStatueWar, LimitRealmPoint 컬럼 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.35 (2005-07-15)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : 석상 효과 타입, 석상 효과 퍼센트 탭 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.34 (2005-07-08)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : FIXED_PORTAL 타입(귀환 위치 고정형 귀환서) 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.33 (2005-04-12)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 프로토타입 스크립트 : Guard 타입 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.32 (2005-03-18)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 광물 배치 스크립트 : 광맥 이름 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.31 (2005-02-25)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : LinkQID 컬럼 추가 (사용아이템만 적용)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.30 (2005-02-24)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 프로그램 영문화 (히스토리 제외)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.29 (2005-02-23)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : AbleExchangeAndDrop, AbleSell 컬럼 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.28 (2005-02-23)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : 몬스터 이름 최대길이를 32 바이트에서 64 바이트로 늘림" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 버전 정보 확인 기능 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.27 (2005-02-17)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 룬, 악세사리 추가 수정" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : 룬, 악세사리 드랍률 탭 추가 수정, 드랍률 단위 증가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.26 (2005-02-15)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 룬, 악세사리와 관련된 루틴 추가로 재컨버팅 필요" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : 룬, 악세사리 드랍률 탭 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.25 (2005-02-14)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 복권 스크립트 : 로딩시 버그 수정 및 관련 로그 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.24 (2005-01-20)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 스킬 스크립트 : 소셜 액션 관련 내용 추가 (타입 추가)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 보상 스크립트 : 아이템 타입의 증가로 인해 재컨버팅 필요" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.23 (2005-01-20)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 광물 배치 스크립트 : 문자열 처음부분에 있는 Tab 문자 제거 기능 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.22 (2005-01-06)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 월드웨폰 스타터킷 2개, 광물 매립량 확인 킷 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.21 (2004-12-29)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : '아이템 드랍 개선 계획'에 따라 드랍 관련 열 추가/수정" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.20 (2004-12-21)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 광물 배치 스크립트 : Trash 파일을 스크립트에 넣어주도록 변경" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.19 (2004-12-16)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 스킬 스크립트 : Counter 열 추가 (카운터를 당할 수 있는지 여부)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.18 (2004-12-16)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 새로운 스킬 타입으로 SET 추가 (챈트/인챈트의 추가 효과 스킬)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 스킬 스크립트 체크 루틴 입력 방식 변경 (10진수 -> 16진수)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.17 (2004-12-15)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 광물 배치 스크립트 컨버팅 기능 추가 (MineralVein?.gsf)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.16 (2004-11-23)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 욕설 스크립트 원본 읽어오는 경로를 수정" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.15 (2004-11-17)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 챈트/인챈트 플래그가 수정되어서 몬스터 스크립트 컨버팅을 다시 해야합니다." ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.14 (2004-09-21)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 복권 이벤트 스크립트 로딩을 현재 폴더에서 하게끔 수정" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.13 (2004-09-02)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + FightStatus가 수정되서 몬스터 스크립트 컨버팅을 다시 해야합니다." ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.12 (2004-08-13)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 보상 스크립트 추가 (SpeacialCompensation.txt)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.11 (2004-08-10)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 아이템 퀘스트를 위한 퀘스트 ID 열 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.10 (2004-07-21)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : LOD 여부 열 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.09 (2004-07-14)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 플래그값 수정 (Item::DetailData::Flags 참고)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.08 (2004-07-07)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : 몬스터 레벨별로 떨구는 아이템 목록(기획 참고용) 작성 기능 추가 "); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.07 (2004-06-18)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 스킬 스크립트 : mRange, LockAdd 열 추가. DRC 열 삭제" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.06 (2004-06-17)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 몬스터 스크립트 : 장비 드랍 확률이 그레이드별로 세분화됨 " ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.05 (2004-06-16)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 아이템 스크립트 : OptionPrice 열 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.04 (2004-06-09)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 리밸런싱용으로 아이템/몬스터 스크립트 대폭 수정" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.03" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 공성 오브젝트 몬스터 프로토 타입 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 공성 오브젝트에 필요한 열 추가 (마지막 13개)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.02" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 공성 오브젝트를 위해 인챈트/챈트 무시여부 정보를 몬스터 프로토 타입에 추가" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.01" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 공성 아이템 추가 (스타터킷 4개)" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " - 1.00" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 버전 넘버링 시작" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], " + 치프 몬스터 추가에 더불어 배포" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "" ); ADD_LINE();
strcpy(g_szVersionInfo[nLine], "End" ); ADD_LINE();
// " ======================================================================================="
}

View File

@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="ScriptConvert"
ProjectGUID="{189EAF5C-37B9-4AF9-971A-09CB54F9C78D}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="../DBToolExecutable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../;./;../../RylServerProject/;../../RylServerProject/BaseLibrary;../../RylServerProject/RylGameLibrary;../../RylServerProject/RylServerLibrary"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/ScriptConvert.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/ScriptConvert.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="../DBToolExecutable/$(ConfigurationName)"
IntermediateDirectory="../Intermediate/$(ProjectName)/$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
OmitFramePointers="TRUE"
AdditionalIncludeDirectories="../;./;../../RylServerProject/;../../RylServerProject/BaseLibrary;../../RylServerProject/RylGameLibrary;../../RylServerProject/RylServerLibrary"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
OutputFile="$(OutDir)/ScriptConvert.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="소스 파일"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm">
<File
RelativePath="ScriptConvert.cpp">
</File>
<File
RelativePath="stdafx.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="헤더 파일"
Filter="h;hpp;hxx;hm;inl;inc">
<File
RelativePath="stdafx.h">
</File>
</Filter>
<Filter
Name="리소스 파일"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
<File
RelativePath="ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{189EAF5C-37B9-4AF9-971A-09CB54F9C78D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../DBToolExecutable/$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../DBToolExecutable/$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">../Intermediate/$(ProjectName)/$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../;./;../../Server/RylServerProject/;../../Server/RylServerProject/BaseLibrary;../../Server/RylServerProject/RylGameLibrary;../../Server/RylServerProject/RylServerLibrary;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)ScriptConvert.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<ProgramDatabaseFile>$(OutDir)ScriptConvert.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
<AdditionalLibraryDirectories>E:\myProj\GodsOfWar\Server\Library\Debug</AdditionalLibraryDirectories>
<AdditionalDependencies>kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;GMMemory.lib;zlib.lib;RylServerLibrary.lib;BaseLibrary.lib;RylGameLibrary.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ProjectReference>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
</ProjectReference>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>../;./;../../RylServerProject/;../../RylServerProject/BaseLibrary;../../RylServerProject/RylGameLibrary;../../RylServerProject/RylServerLibrary;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)ScriptConvert.exe</OutputFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="ScriptConvert.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="소스 파일">
<UniqueIdentifier>{b94f9f63-b74e-4f89-bd39-31325a12f45a}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
</Filter>
<Filter Include="헤더 파일">
<UniqueIdentifier>{6a51cbc6-61a4-4f36-9331-7c842cd55c21}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
</Filter>
<Filter Include="리소스 파일">
<UniqueIdentifier>{dbb24ffd-2f87-4ad7-803e-1026b3c8e937}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ScriptConvert.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>소스 파일</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>헤더 파일</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="ReadMe.txt" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerWorkingDirectory>$(outdir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,451 @@
/* lzoconf.h -- configuration for the LZO real-time data compression library
This file is part of the LZO real-time data compression library.
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
*/
#ifndef __LZOCONF_H
#define __LZOCONF_H
#define LZO_VERSION 0x1080
#define LZO_VERSION_STRING "1.08"
#define LZO_VERSION_DATE "Jul 12 2002"
/* internal Autoconf configuration file - only used when building LZO */
#if defined(LZO_HAVE_CONFIG_H)
# include <config.h>
#endif
#include <limits.h>
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************************
// LZO requires a conforming <limits.h>
************************************************************************/
#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
# error "invalid CHAR_BIT"
#endif
#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
# error "check your compiler installation"
#endif
#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
# error "your limits.h macros are broken"
#endif
/* workaround a cpp bug under hpux 10.20 */
#define LZO_0xffffffffL 4294967295ul
#if !defined(LZO_UINT32_C)
# if (UINT_MAX < LZO_0xffffffffL)
# define LZO_UINT32_C(c) c ## UL
# else
# define LZO_UINT32_C(c) c ## U
# endif
#endif
/***********************************************************************
// architecture defines
************************************************************************/
#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2)
# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
# define __LZO_WIN
# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
# define __LZO_WIN
# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
# define __LZO_WIN
# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
# define __LZO_DOS
# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
# define __LZO_OS2
# elif defined(__palmos__)
# define __LZO_PALMOS
# elif defined(__TOS__) || defined(__atarist__)
# define __LZO_TOS
# endif
#endif
#if (UINT_MAX < LZO_0xffffffffL)
# if defined(__LZO_WIN)
# define __LZO_WIN16
# elif defined(__LZO_DOS)
# define __LZO_DOS16
# elif defined(__LZO_PALMOS)
# define __LZO_PALMOS16
# elif defined(__LZO_TOS)
# define __LZO_TOS16
# elif defined(__C166__)
# else
/* porting hint: for pure 16-bit architectures try compiling
* everything with -D__LZO_STRICT_16BIT */
# error "16-bit target not supported - contact me for porting hints"
# endif
#endif
#if !defined(__LZO_i386)
# if defined(__LZO_DOS) || defined(__LZO_WIN16)
# define __LZO_i386
# elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
# define __LZO_i386
# endif
#endif
#if defined(__LZO_STRICT_16BIT)
# if (UINT_MAX < LZO_0xffffffffL)
# include <lzo16bit.h>
# endif
#endif
/* memory checkers */
#if !defined(__LZO_CHECKER)
# if defined(__BOUNDS_CHECKING_ON)
# define __LZO_CHECKER
# elif defined(__CHECKER__)
# define __LZO_CHECKER
# elif defined(__INSURE__)
# define __LZO_CHECKER
# elif defined(__PURIFY__)
# define __LZO_CHECKER
# endif
#endif
/***********************************************************************
// integral and pointer types
************************************************************************/
/* Integral types with 32 bits or more */
#if !defined(LZO_UINT32_MAX)
# if (UINT_MAX >= LZO_0xffffffffL)
typedef unsigned int lzo_uint32;
typedef int lzo_int32;
# define LZO_UINT32_MAX UINT_MAX
# define LZO_INT32_MAX INT_MAX
# define LZO_INT32_MIN INT_MIN
# elif (ULONG_MAX >= LZO_0xffffffffL)
typedef unsigned long lzo_uint32;
typedef long lzo_int32;
# define LZO_UINT32_MAX ULONG_MAX
# define LZO_INT32_MAX LONG_MAX
# define LZO_INT32_MIN LONG_MIN
# else
# error "lzo_uint32"
# endif
#endif
/* lzo_uint is used like size_t */
#if !defined(LZO_UINT_MAX)
# if (UINT_MAX >= LZO_0xffffffffL)
typedef unsigned int lzo_uint;
typedef int lzo_int;
# define LZO_UINT_MAX UINT_MAX
# define LZO_INT_MAX INT_MAX
# define LZO_INT_MIN INT_MIN
# elif (ULONG_MAX >= LZO_0xffffffffL)
typedef unsigned long lzo_uint;
typedef long lzo_int;
# define LZO_UINT_MAX ULONG_MAX
# define LZO_INT_MAX LONG_MAX
# define LZO_INT_MIN LONG_MIN
# else
# error "lzo_uint"
# endif
#endif
typedef int lzo_bool;
/***********************************************************************
// memory models
************************************************************************/
/* Memory model for the public code segment. */
#if !defined(__LZO_CMODEL)
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
# define __LZO_CMODEL __far
# elif defined(__LZO_i386) && defined(__WATCOMC__)
# define __LZO_CMODEL __near
# else
# define __LZO_CMODEL
# endif
#endif
/* Memory model for the public data segment. */
#if !defined(__LZO_DMODEL)
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
# define __LZO_DMODEL __far
# elif defined(__LZO_i386) && defined(__WATCOMC__)
# define __LZO_DMODEL __near
# else
# define __LZO_DMODEL
# endif
#endif
/* Memory model that allows to access memory at offsets of lzo_uint. */
#if !defined(__LZO_MMODEL)
# if (LZO_UINT_MAX <= UINT_MAX)
# define __LZO_MMODEL
# elif defined(__LZO_DOS16) || defined(__LZO_WIN16)
# define __LZO_MMODEL __huge
# define LZO_999_UNSUPPORTED
# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16)
# define __LZO_MMODEL
# else
# error "__LZO_MMODEL"
# endif
#endif
/* no typedef here because of const-pointer issues */
#define lzo_byte unsigned char __LZO_MMODEL
#define lzo_bytep unsigned char __LZO_MMODEL *
#define lzo_charp char __LZO_MMODEL *
#define lzo_voidp void __LZO_MMODEL *
#define lzo_shortp short __LZO_MMODEL *
#define lzo_ushortp unsigned short __LZO_MMODEL *
#define lzo_uint32p lzo_uint32 __LZO_MMODEL *
#define lzo_int32p lzo_int32 __LZO_MMODEL *
#define lzo_uintp lzo_uint __LZO_MMODEL *
#define lzo_intp lzo_int __LZO_MMODEL *
#define lzo_voidpp lzo_voidp __LZO_MMODEL *
#define lzo_bytepp lzo_bytep __LZO_MMODEL *
#ifndef lzo_sizeof_dict_t
# define lzo_sizeof_dict_t sizeof(lzo_bytep)
#endif
/***********************************************************************
// calling conventions and function types
************************************************************************/
/* linkage */
#if !defined(__LZO_EXTERN_C)
# ifdef __cplusplus
# define __LZO_EXTERN_C extern "C"
# else
# define __LZO_EXTERN_C extern
# endif
#endif
/* calling convention */
#if !defined(__LZO_CDECL)
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
# define __LZO_CDECL __LZO_CMODEL __cdecl
# elif defined(__LZO_i386) && defined(_MSC_VER)
# define __LZO_CDECL __LZO_CMODEL __cdecl
# elif defined(__LZO_i386) && defined(__WATCOMC__)
# define __LZO_CDECL __LZO_CMODEL __cdecl
# else
# define __LZO_CDECL __LZO_CMODEL
# endif
#endif
#if !defined(__LZO_ENTRY)
# define __LZO_ENTRY __LZO_CDECL
#endif
/* C++ exception specification for extern "C" function types */
#if !defined(__cplusplus)
# undef LZO_NOTHROW
# define LZO_NOTHROW
#elif !defined(LZO_NOTHROW)
# define LZO_NOTHROW
#endif
typedef int
(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
typedef int
(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
typedef int
(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
typedef int
(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem,
const lzo_byte *dict, lzo_uint dict_len );
typedef int
(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem,
const lzo_byte *dict, lzo_uint dict_len );
/* assembler versions always use __cdecl */
typedef int
(__LZO_CDECL *lzo_compress_asm_t)( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
typedef int
(__LZO_CDECL *lzo_decompress_asm_t)( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
/* a progress indicator callback function */
typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint);
/***********************************************************************
// export information
************************************************************************/
/* DLL export information */
#if !defined(__LZO_EXPORT1)
# define __LZO_EXPORT1
#endif
#if !defined(__LZO_EXPORT2)
# define __LZO_EXPORT2
#endif
/* exported calling convention for C functions */
#if !defined(LZO_PUBLIC)
# define LZO_PUBLIC(_rettype) \
__LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY
#endif
#if !defined(LZO_EXTERN)
# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
#endif
#if !defined(LZO_PRIVATE)
# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY
#endif
/* exported __cdecl calling convention for assembler functions */
#if !defined(LZO_PUBLIC_CDECL)
# define LZO_PUBLIC_CDECL(_rettype) \
__LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
#endif
#if !defined(LZO_EXTERN_CDECL)
# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype)
#endif
/* exported global variables (LZO currently uses no static variables and
* is fully thread safe) */
#if !defined(LZO_PUBLIC_VAR)
# define LZO_PUBLIC_VAR(_type) \
__LZO_EXPORT1 _type __LZO_EXPORT2 __LZO_DMODEL
#endif
#if !defined(LZO_EXTERN_VAR)
# define LZO_EXTERN_VAR(_type) extern LZO_PUBLIC_VAR(_type)
#endif
/***********************************************************************
// error codes and prototypes
************************************************************************/
/* Error codes for the compression/decompression functions. Negative
* values are errors, positive values will be used for special but
* normal events.
*/
#define LZO_E_OK 0
#define LZO_E_ERROR (-1)
#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */
#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */
#define LZO_E_INPUT_OVERRUN (-4)
#define LZO_E_OUTPUT_OVERRUN (-5)
#define LZO_E_LOOKBEHIND_OVERRUN (-6)
#define LZO_E_EOF_NOT_FOUND (-7)
#define LZO_E_INPUT_NOT_CONSUMED (-8)
/* lzo_init() should be the first function you call.
* Check the return code !
*
* lzo_init() is a macro to allow checking that the library and the
* compiler's view of various types are consistent.
*/
#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
(int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
(int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
(int)sizeof(lzo_compress_t))
LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int);
/* version functions (useful for shared libraries) */
LZO_EXTERN(unsigned) lzo_version(void);
LZO_EXTERN(const char *) lzo_version_string(void);
LZO_EXTERN(const char *) lzo_version_date(void);
LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
/* string functions */
LZO_EXTERN(int)
lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len);
LZO_EXTERN(lzo_voidp)
lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
LZO_EXTERN(lzo_voidp)
lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
LZO_EXTERN(lzo_voidp)
lzo_memset(lzo_voidp _s, int _c, lzo_uint _len);
/* checksum functions */
LZO_EXTERN(lzo_uint32)
lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len);
LZO_EXTERN(lzo_uint32)
lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len);
/* misc. */
LZO_EXTERN(lzo_bool) lzo_assert(int _expr);
LZO_EXTERN(int) _lzo_config_check(void);
typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t;
/* align a char pointer on a boundary that is a multiple of `size' */
LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
#define LZO_PTR_ALIGN_UP(_ptr,_size) \
((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
/* deprecated - only for backward compatibility */
#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size)
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* already included */

View File

@@ -0,0 +1,30 @@
#include "stdafx.h"
#include "minilzo.h"
#include "miniLZOWrapper.h"
#if _MSC_VER >= 1300
#define THREAD_LOCAL_STORAGE __declspec(thread) static
#else
#define THREAD_LOCAL_STORAGE
#endif
bool CMiniLZO::CheckLZOUsable()
{
return LZO_E_OK == lzo_init();
}
bool CMiniLZO::Compress(const char* in, unsigned long in_len,
char* out, unsigned long* lp_out_len)
{
THREAD_LOCAL_STORAGE lzo_voidp wrkmem[LZO1X_1_MEM_COMPRESS];
return (LZO_E_OK == lzo1x_1_compress(reinterpret_cast<const lzo_byte*>(in), in_len,
reinterpret_cast<lzo_byte*>(out), reinterpret_cast<lzo_uintp>(lp_out_len), wrkmem));
}
bool CMiniLZO::Decompress(const char* in, unsigned long in_len,
char* out, unsigned long* buffersize_in_out_len)
{
return (LZO_E_OK == lzo1x_decompress_safe(reinterpret_cast<const lzo_byte*>(in), in_len,
reinterpret_cast<lzo_byte*>(out), reinterpret_cast<lzo_uintp>(buffersize_in_out_len), 0));
}

View File

@@ -0,0 +1,20 @@
#ifndef _MINI_LZO_WRAPPER_H_
#define _MINI_LZO_WRAPPER_H_
namespace CMiniLZO
{
bool CheckLZOUsable();
bool Compress(const char* in, unsigned long in_len,
char* out, unsigned long* lp_out_len);
bool Decompress(const char* in, unsigned long in_len,
char* out, unsigned long* buffersize_in_out_len);
inline unsigned long GetLeastCompressBuffer(unsigned long dwInputBlockSize)
{
return dwInputBlockSize + (dwInputBlockSize / 64) + 16 + 3;
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,100 @@
/* minilzo.h -- mini subset of the LZO real-time data compression library
This file is part of the LZO real-time data compression library.
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
*/
/*
* NOTE:
* the full LZO package can be found at
* http://www.oberhumer.com/opensource/lzo/
*/
#ifndef __MINILZO_H
#define __MINILZO_H
#define MINILZO_VERSION 0x1080
#ifdef __LZOCONF_H
# error "you cannot use both LZO and miniLZO"
#endif
#undef LZO_HAVE_CONFIG_H
#include "lzoconf.h"
#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION)
# error "version mismatch in header files"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/***********************************************************************
//
************************************************************************/
/* Memory required for the wrkmem parameter.
* When the required size is 0, you can also pass a NULL pointer.
*/
#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t))
#define LZO1X_MEM_DECOMPRESS (0)
/* compression */
LZO_EXTERN(int)
lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem );
/* decompression */
LZO_EXTERN(int)
lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ );
/* safe decompression with overrun testing */
LZO_EXTERN(int)
lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len,
lzo_byte *dst, lzo_uintp dst_len,
lzo_voidp wrkmem /* NOT USED */ );
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* already included */

View File

@@ -0,0 +1,513 @@
#include "stdafx.h"
#include "DelimitedFile.h"
CDelimitedFile::CDelimitedFile(const char* pszDelimiter)
: m_fpFile(0), m_dwColumn(0), m_dwColumnCount(0)
{
m_ColumnNames.reserve(DEFAULT_COLUMN_NUM);
strncpy(m_szDelimiter, pszDelimiter, MAX_DELIMITER_NUM);
}
CDelimitedFile::~CDelimitedFile()
{
Close();
}
CDelimitedFile::SectionInfo::SectionInfo(std::string& szSectionName, unsigned long dwLine)
: m_szSectionName(szSectionName), m_dwLine(dwLine)
{
}
bool CDelimitedFile::Open( LPCSTR szFilename, int nHeadLine, UINT nOpenFlags )
{
m_fpFile = ::fopen( szFilename, (nOpenFlags & modeCreate) ? "wt" : "rt" );
if (NULL == m_fpFile)
{
#ifdef ERRLOG2
unsigned long dwError = ::GetLastError();
ERRLOG2(g_Log, "파일 %s를 열 수 없습니다. Error Code : %d", szFilename, dwError);
#endif
return false;
}
if (nHeadLine > -1)
{
for (int i = 0; i < nHeadLine; )
{
if (true == ReadLine())
{
++i;
}
}
for (m_dwColumnCount = 0; true; ++m_dwColumnCount)
{
char* szColumnName = new char[MAX_COLUMN_LENGHT];
if (0 == szColumnName)
{
return false;
}
if (false == ReadString(szColumnName, MAX_COLUMN_LENGHT - 1))
{
delete szColumnName;
break;
}
size_t nLength = strlen(szColumnName);
while (nLength-- > 0)
{
if (szColumnName[nLength] == '\r' || szColumnName[nLength] == '\n')
{
szColumnName[nLength] = 0;
}
}
szColumnName[MAX_COLUMN_LENGHT - 1] = 0;
m_ColumnNames.push_back(szColumnName);
}
}
return true;
}
void CDelimitedFile::Close( void )
{
if ( m_fpFile )
{
::fclose( m_fpFile );
m_fpFile = 0;
}
ColumnArray::size_type nTotalSize = m_ColumnNames.size();
for (ColumnArray::size_type nCount = 0; nCount < nTotalSize; ++nCount)
{
delete [] m_ColumnNames[nCount];
}
m_ColumnNames.clear();
}
unsigned long CDelimitedFile::GetSection(std::string& szSectionName)
{
for (SectionArray::iterator it = m_SectionInfo.begin(); it != m_SectionInfo.end(); ++it)
{
if (szSectionName == it->m_szSectionName)
{
return it->m_dwLine;
}
}
return 0;
}
bool CDelimitedFile::ReadSection(void)
{
char szBuffer[MAX_LINE_LENGTH];
unsigned long dwLine = 1;
m_SectionInfo.clear();
while (NULL != fgets(szBuffer, MAX_LINE_LENGTH, m_fpFile))
{
std::string strSectionIn = std::string(szBuffer);
if (';' == *(strSectionIn.begin()) || 0 == strcmp("\n", strSectionIn.c_str()))
{
continue;
}
if ('[' == *(strSectionIn.begin()))
{
std::string::iterator end = std::find(strSectionIn.begin(), strSectionIn.end(), ']');
if (end != strSectionIn.end())
{
std::string strSectionOut;
strSectionOut.assign(strSectionIn.begin() + 1, end);
m_SectionInfo.push_back(SectionInfo(strSectionOut, dwLine));
}
}
++dwLine;
}
if (true == m_SectionInfo.empty())
{
return false;
}
rewind(m_fpFile);
return true;
}
bool CDelimitedFile::ReadLine(void)
{
while (NULL != ::fgets(m_szLine, MAX_LINE_LENGTH, m_fpFile))
{
if (0 == strcmp("\n", m_szLine))
{
break;
}
if (';' != m_szLine[0])
{
m_dwColumn = 0;
memcpy(m_szBackupLine, m_szLine, MAX_LINE_LENGTH);
return true;
}
}
return false;
}
// 빈줄 및 C++ 스타일 주석 지원
bool CDelimitedFile::ReadLine2nd(void)
{
while (NULL != ::fgets(m_szLine, MAX_LINE_LENGTH, m_fpFile))
{
// 문자열 처음부분에 있는 Tab 없애주기
int iEnd = 0;
while (true)
{
if ('\t' == m_szLine[iEnd])
{
++iEnd;
}
else
{
if (0 != iEnd)
{
strcpy(m_szLine, m_szLine + iEnd);
}
break;
}
}
if (0 == strcmp("\n", m_szLine))
{
continue;
}
if ('/' != m_szLine[0] && '/' != m_szLine[1])
{
m_dwColumn = 0;
memcpy(m_szBackupLine, m_szLine, MAX_LINE_LENGTH);
return true;
}
}
return false;
}
bool CDelimitedFile::ReadData( bool &bNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
bNumber = false;
if (atoi(pszData) == 1)
bNumber = true;
char szString[2];
strncpy(szString, pszData, 1);
if (NULL == ::strcmp(szString, "O"))
bNumber = true;
return true;
}
bool CDelimitedFile::ReadData( double &dNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
dNumber = atof( pszData );
return true;
}
bool CDelimitedFile::ReadData( float &fNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
fNumber = (float) atof( pszData );
return true;
}
bool CDelimitedFile::ReadData( long &lNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
lNumber = (long) atol( pszData );
return true;
}
bool CDelimitedFile::ReadData( unsigned long &fNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
fNumber = (unsigned long) atol( pszData );
return true;
}
bool CDelimitedFile::ReadData( int &iNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
iNumber = atoi( pszData );
return true;
}
bool CDelimitedFile::ReadData( unsigned short &iNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
iNumber = (unsigned short)atoi( pszData );
return true;
}
bool CDelimitedFile::ReadData( short &iNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
iNumber = (short)atoi( pszData );
return true;
}
bool CDelimitedFile::ReadData( unsigned char &iNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
iNumber = (unsigned char)atoi( pszData );
return true;
}
bool CDelimitedFile::ReadData( char &iNumber )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
iNumber = (char)atoi( pszData );
return true;
}
bool CDelimitedFile::ReadData( __int64 &i64Number )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
i64Number = _atoi64( pszData );
return true;
}
bool CDelimitedFile::ReadData( DWORD64 &i64Number )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
i64Number = (unsigned long)_atoi64( pszData );
return true;
}
bool CDelimitedFile::ReadString( char *szString, unsigned long dwSize )
{
CHAR *pszData = ::strtok( (m_dwColumn++) ? NULL : m_szLine, m_szDelimiter );
if ( !pszData || !(*pszData) )
return false;
strncpy(szString, pszData, dwSize);
return true;
}
bool CDelimitedFile::ReadData(const char *szField, double &dNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( dNumber );
}
bool CDelimitedFile::ReadData(const char *szField, float &fNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( fNumber );
}
bool CDelimitedFile::ReadData(const char *szField, long &lNumber )
{
int nSearch;
if( ((nSearch = FindColumn( szField )) == -1) )
return FALSE;
GotoColumn( nSearch );
return ReadData( lNumber );
}
bool CDelimitedFile::ReadData(const char *szField, unsigned long &fNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( fNumber );
}
bool CDelimitedFile::ReadData(const char *szField, int &iNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( iNumber );
}
bool CDelimitedFile::ReadData(const char *szField, unsigned short &iNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( iNumber );
}
bool CDelimitedFile::ReadData(const char *szField, short &iNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( iNumber );
}
bool CDelimitedFile::ReadData(const char *szField, unsigned char &iNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( iNumber );
}
bool CDelimitedFile::ReadData(const char *szField, char &iNumber )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( iNumber );
}
bool CDelimitedFile::ReadData(const char *szField, __int64 &i64Number )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( i64Number );
}
bool CDelimitedFile::ReadData(const char *szField, DWORD64 &i64Number )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadData( i64Number );
}
bool CDelimitedFile::ReadString(const char *szField, char *szString, unsigned long dwSize )
{
int nSearch;
if ( ((nSearch = FindColumn( szField )) == -1) )
return false;
GotoColumn( nSearch );
return ReadString( szString, dwSize );
}
bool CDelimitedFile::GotoColumn( int nColumn )
{
CHAR* pszPos = 0;
if (nColumn < 0 || (unsigned long)nColumn > m_dwColumnCount) {
return false;
}
if ((m_dwColumn == (unsigned long) nColumn)) {
return true;
}
if ( nColumn == 0 ) {
m_dwColumn = 0;
strtok(m_szLine, m_szDelimiter);
}
else {
for (;m_dwColumn < m_dwColumnCount && nColumn != m_dwColumn; ++m_dwColumn )
pszPos = strtok(0, m_szDelimiter);
if (m_dwColumn == m_dwColumnCount) {
memcpy(m_szLine, m_szBackupLine, MAX_LINE_LENGTH);
pszPos = strtok(m_szLine, m_szDelimiter);
for (m_dwColumn = 1; m_dwColumn < (unsigned long)nColumn && nColumn != m_dwColumn; ++m_dwColumn ) {
pszPos = strtok(NULL, m_szDelimiter );
}
}
}
return true;
}
int CDelimitedFile::FindColumn(const char *szField)
{
for (ColumnArray::size_type nCount = 0; nCount < m_ColumnNames.size(); ++nCount)
{
const char* szColumnName = m_ColumnNames[nCount];
if (0 == strcmp(szField, szColumnName))
{
return static_cast<int>(nCount);
}
}
return -1;
}

View File

@@ -0,0 +1,103 @@
#ifndef _DELIMITED_FILE_H_
#define _DELIMITED_FILE_H_
#pragma once
#include <winsock2.h>
#include <windows.h>
#include <vector>
class CDelimitedFile
{
public:
// MAX Delimiter num is 32;
CDelimitedFile(const char* pszDelimiter = "\t");
~CDelimitedFile();
enum
{
MAX_LINE_LENGTH = 16384,
MAX_DELIMITER_NUM = 32,
MAX_COLUMN_LENGHT = 64,
DEFAULT_COLUMN_NUM = 32
};
enum OpenFlags
{
modeRead = (int) 0x00000,
modeCreate = (int) 0x01000
};
private:
struct SectionInfo
{
unsigned long m_dwLine;
std::string m_szSectionName;
SectionInfo() : m_dwLine(0) { m_szSectionName.clear(); }
SectionInfo(std::string& szSectionName, unsigned long dwLine);
};
FILE* m_fpFile;
unsigned long m_dwColumn;
unsigned long m_dwColumnCount;
char m_szLine[MAX_LINE_LENGTH];
char m_szBackupLine[MAX_LINE_LENGTH];
char m_szDelimiter[MAX_DELIMITER_NUM];
typedef std::vector<char*> ColumnArray;
typedef std::vector<SectionInfo> SectionArray;
ColumnArray m_ColumnNames;
SectionArray m_SectionInfo;
int FindColumn(const char *szField );
bool GotoColumn( int nColumn );
public:
bool Open(LPCSTR szFilename, int nHeadLine = -1, UINT nOpenFlags = modeRead );
void Close();
unsigned long GetSection(std::string& szSectionName);
bool ReadSection(void);
bool ReadLine2nd(void); // 빈줄 및 C++ 스타일 주석 지원
bool ReadLine(); // ; 주석지원, 빈줄 지원하지 않음
bool ReadData(bool &bNumber);
bool ReadData(double &dNumber);
bool ReadData(float &fNumber);
bool ReadData(long &lNumber);
bool ReadData(unsigned long &fNumber);
bool ReadData(int &iNumber);
bool ReadData(unsigned short &iNumber);
bool ReadData(short &iNumber);
bool ReadData(unsigned char &iNumber);
bool ReadData(char &iNumber);
bool ReadData(__int64 &i64Number);
bool ReadData(DWORD64 &i64Number);
bool ReadString(char *szString, unsigned long dwSize);
bool ReadData(const char *szField, double &dNumber);
bool ReadData(const char *szField, float &fNumber);
bool ReadData(const char *szField, long &lNumber );
bool ReadData(const char *szField, unsigned long &fNumber);
bool ReadData(const char *szField, int &iNumber);
bool ReadData(const char *szField, unsigned short &iNumber);
bool ReadData(const char *szField, short &iNumber);
bool ReadData(const char *szField, unsigned char &iNumber);
bool ReadData(const char *szField, char &iNumber);
bool ReadData(const char *szField, __int64 &i64Number);
bool ReadData(const char *szField, DWORD64 &i64Number);
bool ReadString(const char *szField, char *szString, unsigned long dwSize);
};
#endif

View File

@@ -0,0 +1,220 @@
#ifndef _MATH_CONVERT_INLINE_H_
#define _MATH_CONVERT_INLINE_H_
#include <cstdlib>
#include <tchar.h>
inline void Math::Convert::Hex08ToStr( TCHAR *szDest, BYTE hex )
{
*((WORD *) szDest) = m_FastHeToBi[ hex ]; szDest += 2;
*(szDest) = '\0';
}
inline void Math::Convert::Hex16ToStr( TCHAR *szDest, WORD hex )
{
LPBYTE pSrc = (LPBYTE) &hex;
#ifdef BIG_ENDIAN
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
#else
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
#endif
*(szDest + 4) = '\0';
}
inline void Math::Convert::Hex32ToStr( TCHAR *szDest, unsigned long hex )
{
LPBYTE pSrc = (LPBYTE) &hex;
#ifdef BIG_ENDIAN
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
#else
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
#endif
*(szDest + 8) = '\0';
}
inline void Math::Convert::Hex64ToStr( TCHAR *szDest, DWORD64 hex )
{
LPBYTE pSrc = (LPBYTE) &hex;
#ifdef BIG_ENDIAN
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 8)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 10)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 12)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 14)) = m_FastHeToBi[ *(pSrc++) ];
#else
*((WORD *) (szDest + 14)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 12)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 10)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 8)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 6)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 4)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 2)) = m_FastHeToBi[ *(pSrc++) ];
*((WORD *) (szDest + 0)) = m_FastHeToBi[ *(pSrc++) ];
#endif
*(szDest + 16) = '\0';
}
//
// this function returns the equivalent binary value for an individual character specified in the ascii format
inline TCHAR Math::Convert::BiToHe(TCHAR cBin)
{
if((cBin >= '0') && (cBin <= '9'))
{
return (cBin - '0');
}
else if((cBin >= 'A') && (cBin <= 'F'))
{
return (cBin - 'A' + 0xA);
}
if((cBin >= 'a') && (cBin <= 'f'))
{
return (cBin -'a' + 0xA);
}
return cBin;
}
inline void Math::Convert::AcToHe(char *szDst, char *szSrc, int iCount)
{
while(iCount--)
{
*szDst = BiToHe(*szSrc) << 4;
*szSrc++;
*szDst += BiToHe(*szSrc);
*szSrc++;
*szDst++;
}
}
inline BYTE Math::Convert::StrToHex08(const TCHAR *szSrc)
{
const TCHAR* pStart = szSrc + 2;
BYTE cHex = 0;
TCHAR c1, c2;
for (int i=0; i<1; ++i)
{
c1 = BiToHe(*pStart++);
c1 <<= (8*(7-i)+4);
c2 = BiToHe(*pStart++);
c2 <<= (8*(7-i));
cHex += (c1 + c2);
}
return cHex;
}
inline WORD Math::Convert::StrToHex16(const TCHAR *szSrc)
{
const TCHAR* pStart = szSrc + 2;
WORD sHex = 0;
for (int i=0; i<2; i++)
{
WORD s1 = BiToHe(*pStart++);
s1 <<= (8*(1-i)+4);
WORD s2 = BiToHe(*pStart++);
s2 <<= (8*(1-i));
WORD sRet = s1 + s2;
sHex += sRet;
}
return sHex;
}
// convert string to hexadecimal value
inline unsigned long Math::Convert::StrToHex32(const TCHAR *szSrc)
{
const TCHAR* pStart = szSrc + 2;
unsigned long nHex = 0;
for (int i=0; i<4; i++)
{
unsigned long n1 = BiToHe(*pStart++);
n1 <<= (8*(3-i)+4);
unsigned long n2 = BiToHe(*pStart++);
n2 <<= (8*(3-i));
unsigned long nRet = n1 + n2;
nHex += nRet;
}
return nHex;
}
// convert string to hexadecimal value
inline DWORD64 Math::Convert::StrToHex64(const TCHAR *szSrc)
{
const TCHAR* pStart = szSrc + 2;
DWORD64 dlHex = 0;
for (int i=0; i<8; i++)
{
DWORD64 dl1 = BiToHe(*pStart++);
dl1 <<= (8*(7-i)+4);
DWORD64 dl2 = BiToHe(*pStart++);
dl2 <<= (8*(7-i));
DWORD64 dlRet = dl1 + dl2;
dlHex += dlRet;
}
return dlHex;
}
inline BYTE Math::Convert::Atoc(const TCHAR *szSrc)
{
return (0 == _tcsncmp(szSrc, _T("0x"), 2)) ? StrToHex08(szSrc) : (BYTE) _ttol(szSrc);
}
//
// TCHAR *로 고칩시다! (By Standil)
//
inline WORD Math::Convert::Atos(const TCHAR *szSrc)
{
return (0 == _tcsncmp(szSrc, _T("0x"), 2)) ? StrToHex16(szSrc) : _ttoi(szSrc);
}
//
// TCHAR *로 고칩시다! (By Standil)
//
inline unsigned long Math::Convert::Atoi(const TCHAR *szSrc)
{
return (0 == _tcsncmp(szSrc, _T("0x"), 2)) ? StrToHex32(szSrc) : _ttol(szSrc);
}
//
// TCHAR *로 고칩시다! (By Standil)
//
inline DWORD64 Math::Convert::Atol64(const TCHAR *szSrc)
{
return (0 == _tcsncmp(szSrc, _T("0x"), 2)) ? StrToHex64(szSrc) : _ttoi64(szSrc);
}
#endif

View File

@@ -0,0 +1,88 @@
// FastMath.cpp: implementation of the CFastMath class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Math.h"
///////////////////////////////////////////////////////////////////////////////////////////////
// utility functions
// 0 -0x7FFFFFFF.
unsigned long Math::Random::ComplexRandom(int nEndExtent, int nBeginExtent)
{
if (nEndExtent < 1 || nEndExtent <= nBeginExtent)
{
return nBeginExtent;
}
static unsigned long x = 1;
static unsigned long c = 0;
static unsigned long a = 2083801278UL;
#define addto(rh,rl,ah,al) (rl) = ((rl) + (al)) & 0xFFFFFFFFUL; \
(rh) = ((rh) + (ah) + (((rl) < (al)) ? 1 : 0)) & 0xFFFFFFFFUL
unsigned long xl = (x & 0xFFFFUL);
unsigned long xh = (x >> 16) & 0xFFFFUL;
unsigned long al = (a & 0xFFFFUL);
unsigned long ah = (a >> 16) & 0xFFFFUL;
unsigned long tmp;
x = c;
c = 0;
tmp = xl * al;
addto(c, x, 0, tmp);
tmp = xl * ah;
addto(c, x, (tmp >> 16), (tmp & 0xFFFFUL) << 16);
tmp = xh * ah;
addto(c, x, tmp, 1);
tmp = xh * al;
addto(c, x, (tmp >> 16), (tmp & 0xFFFFUL) << 16);
return (x % (nEndExtent - nBeginExtent)) + nBeginExtent; // return x & 0x7FFFFFFFUL;
}
int Math::Random::SimpleRandom(unsigned long dwSeed, int nEndExtent, int nBeginExtent)
{
return( nBeginExtent + ((((dwSeed * 214013L + 2531011L) >> 16) & 0x7FFF) % (nEndExtent - nBeginExtent)) );
}
// This table only works on Little Endian(Byte Order) machine.
const unsigned short Math::Convert::m_FastHeToBi[0x100] =
{
0x3030, 0x3130, 0x3230, 0x3330, 0x3430, 0x3530, 0x3630, 0x3730,
0x3830, 0x3930, 0x4130, 0x4230, 0x4330, 0x4430, 0x4530, 0x4630,
0x3031, 0x3131, 0x3231, 0x3331, 0x3431, 0x3531, 0x3631, 0x3731,
0x3831, 0x3931, 0x4131, 0x4231, 0x4331, 0x4431, 0x4531, 0x4631,
0x3032, 0x3132, 0x3232, 0x3332, 0x3432, 0x3532, 0x3632, 0x3732,
0x3832, 0x3932, 0x4132, 0x4232, 0x4332, 0x4432, 0x4532, 0x4632,
0x3033, 0x3133, 0x3233, 0x3333, 0x3433, 0x3533, 0x3633, 0x3733,
0x3833, 0x3933, 0x4133, 0x4233, 0x4333, 0x4433, 0x4533, 0x4633,
0x3034, 0x3134, 0x3234, 0x3334, 0x3434, 0x3534, 0x3634, 0x3734,
0x3834, 0x3934, 0x4134, 0x4234, 0x4334, 0x4434, 0x4534, 0x4634,
0x3035, 0x3135, 0x3235, 0x3335, 0x3435, 0x3535, 0x3635, 0x3735,
0x3835, 0x3935, 0x4135, 0x4235, 0x4335, 0x4435, 0x4535, 0x4635,
0x3036, 0x3136, 0x3236, 0x3336, 0x3436, 0x3536, 0x3636, 0x3736,
0x3836, 0x3936, 0x4136, 0x4236, 0x4336, 0x4436, 0x4536, 0x4636,
0x3037, 0x3137, 0x3237, 0x3337, 0x3437, 0x3537, 0x3637, 0x3737,
0x3837, 0x3937, 0x4137, 0x4237, 0x4337, 0x4437, 0x4537, 0x4637,
0x3038, 0x3138, 0x3238, 0x3338, 0x3438, 0x3538, 0x3638, 0x3738,
0x3838, 0x3938, 0x4138, 0x4238, 0x4338, 0x4438, 0x4538, 0x4638,
0x3039, 0x3139, 0x3239, 0x3339, 0x3439, 0x3539, 0x3639, 0x3739,
0x3839, 0x3939, 0x4139, 0x4239, 0x4339, 0x4439, 0x4539, 0x4639,
0x3041, 0x3141, 0x3241, 0x3341, 0x3441, 0x3541, 0x3641, 0x3741,
0x3841, 0x3941, 0x4141, 0x4241, 0x4341, 0x4441, 0x4541, 0x4641,
0x3042, 0x3142, 0x3242, 0x3342, 0x3442, 0x3542, 0x3642, 0x3742,
0x3842, 0x3942, 0x4142, 0x4242, 0x4342, 0x4442, 0x4542, 0x4642,
0x3043, 0x3143, 0x3243, 0x3343, 0x3443, 0x3543, 0x3643, 0x3743,
0x3843, 0x3943, 0x4143, 0x4243, 0x4343, 0x4443, 0x4543, 0x4643,
0x3044, 0x3144, 0x3244, 0x3344, 0x3444, 0x3544, 0x3644, 0x3744,
0x3844, 0x3944, 0x4144, 0x4244, 0x4344, 0x4444, 0x4544, 0x4644,
0x3045, 0x3145, 0x3245, 0x3345, 0x3445, 0x3545, 0x3645, 0x3745,
0x3845, 0x3945, 0x4145, 0x4245, 0x4345, 0x4445, 0x4545, 0x4645,
0x3046, 0x3146, 0x3246, 0x3346, 0x3446, 0x3546, 0x3646, 0x3746,
0x3846, 0x3946, 0x4146, 0x4246, 0x4346, 0x4446, 0x4546, 0x4646,
};

View File

@@ -0,0 +1,99 @@
// FastMath.h: interface for the CFastMath class.
//
//////////////////////////////////////////////////////////////////////
#ifndef _CUSTOM_MATH_FUNCTIONS_H_
#define _CUSTOM_MATH_FUNCTIONS_H_
#include <winsock2.h>
#include <windows.h>
#include <cmath>
namespace Math
{
namespace Convert
{
extern const unsigned short m_FastHeToBi[0x100];
// SPX, IPX 주소 계산을 위해 사용하는 함수
inline TCHAR BiToHe(TCHAR cBin);
inline void AcToHe(char *szDst, char *szSrc, int iCount);
// String을 값으로 바꿈(String은 0x가 붙은 Hex string이다.)
inline BYTE StrToHex08(const TCHAR *szSrc);
inline WORD StrToHex16(const TCHAR *szSrc);
inline unsigned long StrToHex32(const TCHAR *szSrc);
inline DWORD64 StrToHex64(const TCHAR *szSrc);
// String을 값으로 바꿈(0x가 붙던지, 붙지 않던지간에 전부 바꿀 수 있다)
inline BYTE Atoc(const TCHAR *szSrc);
inline WORD Atos(const TCHAR *szSrc);
inline unsigned long Atoi(const TCHAR *szSrc);
inline DWORD64 Atol64(const TCHAR *szSrc);
// 값을 Hex String으로 바꿈
inline void Hex08ToStr(TCHAR *szDest, BYTE hex);
inline void Hex16ToStr(TCHAR *szDest, WORD hex);
inline void Hex32ToStr(TCHAR *szDest, unsigned long hex);
inline void Hex64ToStr(TCHAR *szDest, DWORD64 hex);
};
namespace Random
{
// 리턴값은 nBeginExtent ~ nEndExtent - 1의 범위를 갖는다.
unsigned long ComplexRandom(int nEndExtent, int nBeginExtent = 0); // 비교적 분포가 좋다.
int SimpleRandom(unsigned long dwSeed, int nEndExtent, int nBeginExtent = 0);
};
namespace HashFunc
{
// -------------------------------------------------------------------------------------------------
// String-to-Hash 함수들 : http://www.cs.yorku.ca/~oz/hash.html 에서 참고
inline unsigned long djb2Hash(const unsigned char *str); // first reported by dan bernstein
inline unsigned long sdbmHash(const unsigned char *str); // this is one of the algorithms used in berkeley db
inline unsigned long looseHash(const unsigned char *str); // 가장 간단한 해쉬. 그냥 모두 더함.
};
namespace Const
{
static float PI = 3.14159f;
}
};
#include "Convert.inl"
inline unsigned long Math::HashFunc::djb2Hash(const unsigned char *str)
{
unsigned long hash = 5381;
int c;
while (c = *str++) { hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ }
return hash;
}
inline unsigned long Math::HashFunc::sdbmHash(const unsigned char *str)
{
unsigned long hash = 0;
int c;
while (c = *str++) { hash = c + (hash << 6) + (hash << 16) - hash; }
return hash;
}
inline unsigned long Math::HashFunc::looseHash(const unsigned char *str)
{
unsigned int hash = 0;
int c;
while (c = *str++) { hash += c; }
return hash;
}
#endif // !defined(AFX_FASTMATH_H__ED69578B_18C1_42EA_9C5E_888DC38101C2__INCLUDED_)

View File

@@ -0,0 +1,225 @@
/******************************************************************************
Module: EnsureCleanup.h
Notices: Copyright (c) 2000 Jeffrey Richter
Purpose: These classes ensure object cleanup when an object goes out of scope.
See Appendix B.
******************************************************************************/
#ifndef _ENSURE_CLEAN_UP_BY_JEFFERY_RICHTER
#define _ENSURE_CLEAN_UP_BY_JEFFERY_RICHTER
#pragma once // Include this header file once per compilation unit
#include <winsock2.h>
#include <windows.h>
// Data type representing the address of the object's cleanup function.
// I used UINT_PTR so that this class works properly in 64-bit Windows.
typedef VOID (WINAPI* PFNENSURECLEANUP)(UINT_PTR);
// Each template instantiation requires a data type, address of cleanup
// function, and a value that indicates an invalid value.
template<class TYPE, PFNENSURECLEANUP pfn, UINT_PTR tInvalid = NULL>
class CEnsureCleanup
{
public:
// Default constructor assumes an invalid value (nothing to cleanup)
CEnsureCleanup() { m_t = tInvalid; }
// This constructor sets the value to the specified value
CEnsureCleanup(TYPE t) : m_t((UINT_PTR) t) { }
// The destructor performs the cleanup.
~CEnsureCleanup() { Cleanup(); }
// Helper methods to tell if the value represents a valid object or not..
BOOL IsValid() { return(m_t != tInvalid); }
BOOL IsInvalid() { return(!IsValid()); }
// Re-assigning the object forces the current object to be cleaned-up.
TYPE operator=(TYPE t)
{
Cleanup();
m_t = (UINT_PTR) t;
return(*this);
}
// Returns the value (supports both 32-bit and 64-bit Windows).
operator TYPE()
{
// If TYPE is a 32-bit value, cast m_t to 32-bit TYPE
// If TYPE is a 64-bit value, case m_t to 64-bit TYPE
return((sizeof(TYPE) == 4) ? (TYPE) PtrToUint(m_t) : (TYPE) m_t);
}
// Cleanup the object if the value represents a valid object
void Cleanup()
{
if (IsValid())
{
// In 64-bit Windows, all parameters are 64-bits,
// so no casting is required
pfn(m_t); // Close the object.
m_t = tInvalid; // We no longer represent a valid object.
}
}
private:
UINT_PTR m_t; // The member representing the object
};
///////////////////////////////////////////////////////////////////////////////
// Macros to make it easier to declare instances of the template
// class for specific data types.
#define MakeCleanupClass(className, tData, pfnCleanup) \
typedef CEnsureCleanup<tData, (PFNENSURECLEANUP) pfnCleanup> className;
#define MakeCleanupClassX(className, tData, pfnCleanup, tInvalid) \
typedef CEnsureCleanup<tData, (PFNENSURECLEANUP) pfnCleanup, \
(INT_PTR) tInvalid> className;
///////////////////////////////////////////////////////////////////////////////
// Instances of the template C++ class for common data types.
MakeCleanupClass(CEnsureCloseHandle, HANDLE, CloseHandle);
MakeCleanupClassX(CEnsureCloseFile, HANDLE, CloseHandle, INVALID_HANDLE_VALUE);
MakeCleanupClass(CEnsureLocalFree, HLOCAL, LocalFree);
MakeCleanupClass(CEnsureGlobalFree, HGLOBAL, GlobalFree);
MakeCleanupClass(CEnsureRegCloseKey, HKEY, RegCloseKey);
MakeCleanupClass(CEnsureCloseServiceHandle, SC_HANDLE, CloseServiceHandle);
MakeCleanupClass(CEnsureCloseWindowStation, HWINSTA, CloseWindowStation);
MakeCleanupClass(CEnsureCloseDesktop, HDESK, CloseDesktop);
MakeCleanupClass(CEnsureUnmapViewOfFile, PVOID, UnmapViewOfFile);
MakeCleanupClass(CEnsureFreeLibrary, HMODULE, FreeLibrary);
///////////////////////////////////////////////////////////////////////////////
// Special class for releasing a reserved region.
// Special class is required because VirtualFree requires 3 parameters
class CEnsureReleaseRegion
{
public:
CEnsureReleaseRegion(PVOID pv = NULL) : m_pv(pv) { }
~CEnsureReleaseRegion() { Cleanup(); }
PVOID operator=(PVOID pv)
{
Cleanup();
m_pv = pv;
return(m_pv);
}
operator PVOID() { return(m_pv); }
void Cleanup()
{
if (m_pv != NULL)
{
VirtualFree(m_pv, 0, MEM_RELEASE);
m_pv = NULL;
}
}
private:
PVOID m_pv;
};
///////////////////////////////////////////////////////////////////////////////
// Special class for freeing a block from a heap
// Special class is required because HeapFree requires 3 parameters
class CEnsureHeapFree
{
public:
CEnsureHeapFree(PVOID pv = NULL, HANDLE hHeap = GetProcessHeap())
: m_pv(pv), m_hHeap(hHeap) { }
~CEnsureHeapFree() { Cleanup(); }
PVOID operator=(PVOID pv)
{
Cleanup();
m_pv = pv;
return(m_pv);
}
operator PVOID() { return(m_pv); }
void Cleanup()
{
if (m_pv != NULL)
{
HeapFree(m_hHeap, 0, m_pv);
m_pv = NULL;
}
}
private:
HANDLE m_hHeap;
PVOID m_pv;
};
template<typename T>
class CEnsureDelete
{
public:
CEnsureDelete(T* ptr) : m_ptr(ptr) { }
~CEnsureDelete() { if(NULL != m_ptr) { delete m_ptr; } }
private:
// 복사를 할 수 없게 함.
CEnsureDelete& operator =(const CEnsureDelete& ensureDelete);
CEnsureDelete(const CEnsureDelete& ensureDelete);
T* m_ptr;
};
template<typename T>
class CEnsureDeleteArray
{
public:
CEnsureDeleteArray(T* ptrArray) : m_ptrArray(ptrArray) { }
~CEnsureDeleteArray() { if(NULL != m_ptrArray) { delete [] m_ptrArray; } }
private:
// 복사를 할 수 없게 함.
CEnsureDeleteArray& operator =(const CEnsureDeleteArray& ensureDeleteArray);
CEnsureDeleteArray(const CEnsureDeleteArray& ensureDeleteArray);
T* m_ptrArray;
};
template<typename T>
class CEnsureRelease
{
public:
CEnsureRelease(T& t) : m_t(&t) { }
CEnsureRelease(T* t) : m_t(t) { }
~CEnsureRelease() { if(NULL != m_t) { m_t->Release(); } }
private:
// 복사를 할 수 없게 함.
CEnsureRelease& operator =(const CEnsureRelease& ensureRelease);
CEnsureRelease(const CEnsureRelease& ensureRelease);
T* m_t;
};
#endif

View File

@@ -0,0 +1,158 @@
#include "stdafx.h"
#include "TokenlizedFile.h"
#include <algorithm>
#include <Utility/Math/Math.h>
using namespace std;
char* trim_string(char* szString)
{
while(*szString == '\r'|| *szString == '\n' || *szString == ' ')
{
++szString;
}
char* szTail = szString + strlen(szString);
while(szString != szTail
&& (*szTail == '\r'|| *szTail == '\n' || *szTail == ' ' || *szTail == '\0'))
{
*szTail = 0;
--szTail;
}
return szString;
}
CTokenlizedFile::ColumnInfo::ColumnInfo(const char* szColumnName, unsigned int dwIndex)
: m_dwHashKey(Math::HashFunc::sdbmHash(reinterpret_cast<const unsigned char*>(szColumnName))),
m_szColumnName(szColumnName), m_dwIndex(dwIndex)
{
}
CTokenlizedFile::CTokenlizedFile(const char* lpszDelimiter)
: m_lpFile(0), m_nLine(0)
{
strncpy(m_szDelimiter, lpszDelimiter, MAX_DELIMITER_NUM - 1);
m_szDelimiter[MAX_DELIMITER_NUM - 1] = '\0';
m_ColumnInfo.reserve(DEFAULT_COLUMN_NUM);
m_ColumnValues.reserve(DEFAULT_COLUMN_NUM);
}
CTokenlizedFile::~CTokenlizedFile()
{
}
void CTokenlizedFile::Close(void)
{
if (0 != m_lpFile)
{
fclose(m_lpFile);
}
m_ColumnInfo.clear();
m_ColumnValues.clear();
}
bool CTokenlizedFile::Open(const char* szFilename, const char* szOpenMode)
{
Close();
m_nLine = 0;
m_lpFile = fopen(szFilename, szOpenMode);
return (0 != m_lpFile) ? true : false;
}
bool CTokenlizedFile::ReadColumn(void)
{
m_ColumnInfo.clear();
if (0 != fgets(m_szColumn, MAX_LINE_BUFFER, m_lpFile))
{
char* szToken = strtok(m_szColumn, m_szDelimiter);
unsigned int dwIndex = 0;
do
{
m_ColumnInfo.push_back(ColumnInfo(trim_string(szToken), dwIndex));
++dwIndex;
} while (0 != (szToken = strtok(0, m_szDelimiter)));
++m_nLine;
std::sort(m_ColumnInfo.begin(), m_ColumnInfo.end());
return true;
}
return false;
}
bool CTokenlizedFile::ReadLine(void)
{
m_ColumnValues.clear();
if (0 != fgets(m_szLine, MAX_LINE_BUFFER, m_lpFile))
{
if (0 == strcmp("\n", m_szLine))
{
return false;
}
char* szToken = strtok(m_szLine, m_szDelimiter);
do
{
m_ColumnValues.push_back(trim_string(szToken));
} while (0 != (szToken = strtok(0, m_szDelimiter)));
++m_nLine;
return true;
}
return false;
}
const char* CTokenlizedFile::GetStringValue(const char* szColumnName)
{
ColumnInfo Info(szColumnName, 0);
pair<ColumnArray::iterator, ColumnArray::iterator> pair =
std::equal_range(m_ColumnInfo.begin(), m_ColumnInfo.end(), Info);
for(;pair.first != pair.second; ++pair.first)
{
ColumnInfo& Index = *pair.first;
if (0 == strcmp(Info.m_szColumnName, Index.m_szColumnName))
{
return GetStringValue(Index.m_dwIndex);
}
}
return 0;
}
const char* CTokenlizedFile::GetColumnName(size_t nIndex)
{
return (nIndex < m_ColumnInfo.size()) ?
m_ColumnInfo[nIndex].m_szColumnName : 0;
}
const char* CTokenlizedFile::GetStringValue(size_t nIndex)
{
return (nIndex < m_ColumnValues.size()) ?
m_ColumnValues[nIndex] : 0;
}

View File

@@ -0,0 +1,65 @@
#ifndef _CUSTOM_TOKENLIZED_FILE_H_
#define _CUSTOM_TOKENLIZED_FILE_H_
#include <cstdio>
#include <vector>
class CTokenlizedFile
{
public:
CTokenlizedFile(const char* lpszDelimiter = "\t");
~CTokenlizedFile();
enum
{
MAX_LINE_BUFFER = 16384,
MAX_DELIMITER_NUM = 16,
DEFAULT_COLUMN_NUM = 64
};
bool Open(const char* szFilename, const char* szOpenMode = "rt");
void Close(void);
bool ReadColumn(void); // 컬럼 이름을 읽는다.
bool ReadLine(void); // 한 라인을 읽는다.
bool IsEOF(void) { return (NULL != m_lpFile) ? (0 != feof(m_lpFile)) : false; }
size_t GetColumnNum(void) { return m_ColumnInfo.size(); }
size_t GetCurrentLine(void) { return m_nLine; }
size_t GetValueNum(void) { return m_ColumnValues.size(); }
const char* GetColumnName(size_t nIndex);
const char* GetStringValue(size_t nIndex);
const char* GetStringValue(const char* szColumnName);
private:
struct ColumnInfo
{
unsigned long m_dwHashKey;
unsigned int m_dwIndex;
const char* m_szColumnName;
ColumnInfo() : m_dwHashKey(0), m_dwIndex(0), m_szColumnName(0) { }
ColumnInfo(const char* szColumnName, unsigned int dwIndex);
bool operator < (const ColumnInfo& rhsInfo) const { return m_dwHashKey < rhsInfo.m_dwHashKey; }
};
FILE* m_lpFile;
size_t m_nLine;
char m_szDelimiter[MAX_DELIMITER_NUM];
char m_szColumn[MAX_LINE_BUFFER];
char m_szLine[MAX_LINE_BUFFER];
typedef std::vector<ColumnInfo> ColumnArray;
typedef std::vector<char*> ValueArray;
ColumnArray m_ColumnInfo;
ValueArray m_ColumnValues;
};
#endif

View File

@@ -0,0 +1,18 @@
#include "stdafx.h"
#include "TypeArray.h"
bool CTypeName::Test(const CTypeName* lpTypeArray, int nArrayNum, const char* lpTypeArrayName)
{
for(int nCount = 0; nCount < nArrayNum; ++nCount)
{
if(lpTypeArray[nCount].m_nType != nCount)
{
ERRLOG2(g_Log, "검사한 타입들의 배열 인덱스와 타입 값이 맞지 않습니다."
"타입 테이블 이름은 %s이고, 맞지 않는 커맨드 번호는 %d입니다.", lpTypeArrayName, nCount);
return false;
}
}
return true;
}

View File

@@ -0,0 +1,22 @@
#ifndef _TYPE_ARRAY_H_
#define _TYPE_ARRAY_H_
class CTypeName
{
public:
CTypeName() : m_nType(0), m_lpszName(0) { }
CTypeName(unsigned char nType, char* lpszName) : m_nType(nType), m_lpszName(lpszName) { }
unsigned char GetTypeValue() const { return m_nType; }
const char* GetTypeName() const { return m_lpszName; }
static bool Test(const CTypeName* lpTypeArray, int nArrayNum, const char* lpTypeArrayName);
private:
unsigned char m_nType;
char* m_lpszName;
};
#endif

View File

@@ -0,0 +1,8 @@
// stdafx.cpp : 표준 포함 파일만 들어 있는 소스 파일입니다.
// ScriptConvert.pch는 미리 컴파일된 헤더가 됩니다.
// stdafx.obj에는 미리 컴파일된 형식 정보가 포함됩니다.
#include "stdafx.h"
// TODO: 필요한 추가 헤더는
// 이 파일이 아닌 STDAFX.H에서 참조합니다.

View File

@@ -0,0 +1,25 @@
// stdafx.h : 잘 변경되지 않고 자주 사용하는
// 표준 시스템 포함 파일 및 프로젝트 관련 포함 파일이
// 들어 있는 포함 파일입니다.
//
#pragma once
#define WIN32_LEAN_AND_MEAN // 거의 사용되지 않는 내용은 Windows 헤더에서 제외합니다.
#include <stdio.h>
#include <tchar.h>
// TODO: 프로그램에 필요한 추가 헤더는 여기에서 참조합니다.
#include <Item/ItemMgr.h>
#include <Item/Item.h>
#include <Log/ServerLog.h>
#include <Skill/SkillMgr.h>
#include <Creature/Monster/MonsterMgr.h>
#include <Map/FieldMap/MineralVeinMgr.h>
#include <Utility/Filter/Filter.h>
#include <Utility/Math/Math.h>
#include <GameEvent/GameEventMgr.h>
#include <GameEvent/LotteryEvent/LotteryEvent.h>