forked from metin-server/m2dev-client-src
Full Unicode patch with RTL Support & BiDi logic.
This commit is well documented, so no need to tell you my life story. Full Unicode patch with RTL Support & BiDi logic. Removed the legacy codePage, normalised to UTF8 (65001). It also comes with: CTRL + A : select text (highlighted) CTRL + C : copy CTRL + V : paste CTRL + X : cut CTRL + Y : redo CTRL + Z : undo
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
|
||||
#include "ItemData.h"
|
||||
|
||||
CDynamicPool<CItemData> CItemData::ms_kPool;
|
||||
|
||||
extern DWORD GetDefaultCodePage();
|
||||
CDynamicPool<CItemData> CItemData::ms_kPool;
|
||||
|
||||
CItemData* CItemData::New()
|
||||
{
|
||||
@@ -98,59 +96,7 @@ void CItemData::SetDescription(const std::string& c_rstDesc)
|
||||
{
|
||||
m_strDescription=c_rstDesc;
|
||||
}
|
||||
/*
|
||||
BOOL CItemData::LoadItemData(const char * c_szFileName)
|
||||
{
|
||||
CTextFileLoader TextFileLoader;
|
||||
|
||||
if (!TextFileLoader.Load(c_szFileName))
|
||||
{
|
||||
//Lognf(1, "CItemData::LoadItemData(c_szFileName=%s) - FAILED", c_szFileName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
TextFileLoader.SetTop();
|
||||
|
||||
TextFileLoader.GetTokenString("modelfilename", &m_strModelFileName);
|
||||
TextFileLoader.GetTokenString("submodelfilename", &m_strSubModelFileName);
|
||||
TextFileLoader.GetTokenString("dropmodelfilename", &m_strDropModelFileName);
|
||||
TextFileLoader.GetTokenString("iconimagefilename", &m_strIconFileName);
|
||||
|
||||
char szDescriptionKey[32+1];
|
||||
_snprintf(szDescriptionKey, 32, "%ddescription", GetDefaultCodePage());
|
||||
if (!TextFileLoader.GetTokenString(szDescriptionKey, &m_strDescription))
|
||||
{
|
||||
TextFileLoader.GetTokenString("description", &m_strDescription);
|
||||
}
|
||||
|
||||
// LOD Model File Name List
|
||||
CTokenVector * pLODModelList;
|
||||
if (TextFileLoader.GetTokenVector("lodmodellist", &pLODModelList))
|
||||
{
|
||||
m_strLODModelFileNameVector.clear();
|
||||
m_strLODModelFileNameVector.resize(pLODModelList->size());
|
||||
|
||||
for (DWORD i = 0; i < pLODModelList->size(); ++i)
|
||||
{
|
||||
m_strLODModelFileNameVector[i] = pLODModelList->at(0);
|
||||
}
|
||||
}
|
||||
|
||||
// Attaching Data
|
||||
// Item 에 Attaching Data 일단 없음.
|
||||
// if (TextFileLoader.SetChildNode("attachingdata"))
|
||||
// {
|
||||
// if (!NRaceData::LoadAttachingData(TextFileLoader, &m_AttachingDataVector))
|
||||
// return FALSE;
|
||||
//
|
||||
// TextFileLoader.SetParentNode();
|
||||
// }
|
||||
|
||||
__LoadFiles();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
*/
|
||||
void CItemData::SetDefaultItemData(const char * c_szIconFileName, const char * c_szModelFileName)
|
||||
{
|
||||
if(c_szModelFileName)
|
||||
|
||||
@@ -12,7 +12,7 @@ class CItemData
|
||||
public:
|
||||
enum
|
||||
{
|
||||
ITEM_NAME_MAX_LEN = 24,
|
||||
ITEM_NAME_MAX_LEN = 64,
|
||||
ITEM_LIMIT_MAX_NUM = 2,
|
||||
ITEM_VALUES_MAX_NUM = 6,
|
||||
ITEM_SMALL_DESCR_MAX_LEN = 256,
|
||||
|
||||
@@ -366,29 +366,6 @@ bool CItemManager::LoadItemTable(const char* c_szFileName)
|
||||
}
|
||||
}
|
||||
|
||||
//!@#
|
||||
// CItemData::TItemTable * table = (CItemData::TItemTable *) zObj.GetBuffer();
|
||||
// for (DWORD i = 0; i < dwElements; ++i, ++table)
|
||||
// {
|
||||
// CItemData * pItemData;
|
||||
// DWORD dwVnum = table->dwVnum;
|
||||
//
|
||||
// TItemMap::iterator f = m_ItemMap.find(dwVnum);
|
||||
//
|
||||
// if (m_ItemMap.end() == f)
|
||||
// {
|
||||
// pItemData = CItemData::New();
|
||||
//
|
||||
// pItemData->LoadItemData(_getf("d:/ymir work/item/%05d.msm", dwVnum));
|
||||
// m_ItemMap.insert(TItemMap::value_type(dwVnum, pItemData));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// pItemData = f->second;
|
||||
// }
|
||||
// pItemData->SetItemTableData(table);
|
||||
// }
|
||||
|
||||
delete [] pbData;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -124,94 +124,72 @@ void CProperty::PutVector(const char * c_pszKey, const CTokenVector & c_rTokenVe
|
||||
|
||||
void GetTimeString(char * str, time_t ct)
|
||||
{
|
||||
struct tm tm;
|
||||
tm = *localtime(&ct);
|
||||
struct tm tm;
|
||||
tm = *localtime(&ct);
|
||||
|
||||
_snprintf(str, 15, "%04d%02d%02d%02d%02d%02d",
|
||||
tm.tm_year + 1900,
|
||||
tm.tm_mon + 1,
|
||||
tm.tm_mday,
|
||||
tm.tm_hour,
|
||||
tm.tm_min,
|
||||
tm.tm_sec);
|
||||
_snprintf(str, 15, "%04d%02d%02d%02d%02d%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
|
||||
}
|
||||
|
||||
bool CProperty::ReadFromMemory(const void * c_pvData, int iLen, const char * c_pszFileName)
|
||||
{
|
||||
const char * pcData = (const char *) c_pvData;
|
||||
const char* pStart = (const char*)c_pvData;
|
||||
const char* pcData = pStart;
|
||||
|
||||
if (*(DWORD *) pcData != MAKEFOURCC('Y', 'P', 'R', 'T'))
|
||||
return false;
|
||||
|
||||
pcData += sizeof(DWORD);
|
||||
|
||||
if (*pcData != '\r' || *(pcData + 1) != '\n')
|
||||
|
||||
while (pcData < pStart + iLen && (*pcData == '\r' || *pcData == '\n' || *pcData == ' ' || *pcData == '\t'))
|
||||
++pcData;
|
||||
|
||||
|
||||
int textLen = iLen - int(pcData - pStart);
|
||||
if (textLen <= 0)
|
||||
{
|
||||
TraceError("CProperty::ReadFromMemory: File format error after FourCC: %s\n", c_pszFileName);
|
||||
TraceError("CProperty::ReadFromMemory: textLen <= 0 in %s\n", c_pszFileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
pcData += 2;
|
||||
|
||||
CTokenVector stTokenVector;
|
||||
/*
|
||||
char szTimeStamp[64];
|
||||
memcpy(szTimeStamp, pcData, 14);
|
||||
szTimeStamp[14] = '\0';
|
||||
pcData += 14;
|
||||
|
||||
if (*pcData != '\r' || *(pcData + 1) != '\n')
|
||||
{
|
||||
TraceError("CProperty::ReadFromMemory: File format error after TimeStamp: %s\n", c_pszFileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string m_stTimeStamp;
|
||||
|
||||
m_stTimeStamp = szTimeStamp;
|
||||
|
||||
int iTimeStampLen = 14 + _snprintf(szTimeStamp + 14, 64 - 14, "%s", mc_pFileName);
|
||||
m_dwCRC = GetCRC32(szTimeStamp, iTimeStampLen);
|
||||
|
||||
char tmp[64];
|
||||
sprintf(tmp, "%u", m_dwCRC);
|
||||
m_stCRC.assign(tmp);
|
||||
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
textFileLoader.Bind(iLen - (sizeof(DWORD) + 2 + 14 + 2), pcData);
|
||||
textFileLoader.Bind(textLen, pcData);
|
||||
|
||||
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
m_stCRC.clear();
|
||||
m_dwCRC = 0;
|
||||
|
||||
if (textFileLoader.GetLineCount() > 0)
|
||||
{
|
||||
if (!textFileLoader.SplitLine(i, &stTokenVector))
|
||||
continue;
|
||||
m_stCRC = textFileLoader.GetLineString(0);
|
||||
|
||||
stl_lowers(stTokenVector[0]);
|
||||
std::string stKey = stTokenVector[0];
|
||||
bool bAllDigits = !m_stCRC.empty() && std::all_of(m_stCRC.begin(), m_stCRC.end(), [](char c)
|
||||
{
|
||||
return isdigit((unsigned char)c);
|
||||
});
|
||||
|
||||
stTokenVector.erase(stTokenVector.begin());
|
||||
PutVector(stKey.c_str(), stTokenVector);
|
||||
}
|
||||
return true;
|
||||
*/
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
textFileLoader.Bind(iLen - (sizeof(DWORD) + 2), pcData);
|
||||
DWORD startLine = 0;
|
||||
|
||||
m_stCRC = textFileLoader.GetLineString(0);
|
||||
m_dwCRC = atoi(m_stCRC.c_str());
|
||||
if (bAllDigits)
|
||||
{
|
||||
m_dwCRC = atoi(m_stCRC.c_str());
|
||||
startLine = 1;
|
||||
}
|
||||
|
||||
for (DWORD i = 1; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
if (!textFileLoader.SplitLine(i, &stTokenVector))
|
||||
continue;
|
||||
for (DWORD i = startLine; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
if (!textFileLoader.SplitLine(i, &stTokenVector))
|
||||
continue;
|
||||
|
||||
stl_lowers(stTokenVector[0]);
|
||||
std::string stKey = stTokenVector[0];
|
||||
stl_lowers(stTokenVector[0]);
|
||||
std::string stKey = stTokenVector[0];
|
||||
|
||||
stTokenVector.erase(stTokenVector.begin());
|
||||
PutVector(stKey.c_str(), stTokenVector);
|
||||
stTokenVector.erase(stTokenVector.begin());
|
||||
PutVector(stKey.c_str(), stTokenVector);
|
||||
}
|
||||
}
|
||||
|
||||
//Tracef("Property: %s\n", c_pszFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user