Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////
- Gamelib/Property.h
- //////////////////////////////////////////////////////////////////////////
- search:
- DWORD GetCRC();
- add below:
- bool ReadFromXML(const char* c_pszCRC);
- //////////////////////////////////////////////////////////////////////////
- Gamelib/Property.cpp
- //////////////////////////////////////////////////////////////////////////
- search:
- bool CProperty::Save(const char * c_pszFileName)
- {
- add below:
- return false;
- it should look like:
- bool CProperty::Save(const char * c_pszFileName)
- {
- return false;
- CTempFile file;
- ...
- ...
- }
- //////////////////////////////////////////////////////////////////////////
- search:
- void CProperty::Clear()
- add above:
- bool CProperty::ReadFromXML(const char* c_pszCRC)
- {
- m_dwCRC = atoi(c_pszCRC);
- return true;
- }
- //////////////////////////////////////////////////////////////////////////
- Gamelib/PropertyManager.cpp
- //////////////////////////////////////////////////////////////////////////
- search:
- #include "Property.h"
- add below:
- #include <boost/property_tree/ptree.hpp>
- #include <boost/property_tree/xml_parser.hpp>
- #include <boost/foreach.hpp>
- //////////////////////////////////////////////////////////////////////////
- search:
- bool CPropertyManager::Initialize(const char * c_pszPackFileName)
- {
- if (c_pszPackFileName)
- {
- if (!m_pack.Create(m_fileDict, c_pszPackFileName, "", true))
- {
- LogBoxf("Cannot open property pack file (filename %s)", c_pszPackFileName);
- return false;
- }
- m_isFileMode = false;
- TDataPositionMap & indexMap = m_pack.GetIndexMap();
- TDataPositionMap::iterator itor = indexMap.begin();
- typedef std::map<DWORD, TEterPackIndex *> TDataPositionMap;
- int i = 0;
- while (indexMap.end() != itor)
- {
- TEterPackIndex * pIndex = itor->second;
- ++itor;
- if (!stricmp("property/reserve", pIndex->filename))
- {
- LoadReservedCRC(pIndex->filename);
- continue;
- }
- if (!Register(pIndex->filename))
- continue;
- ++i;
- }
- }
- else
- {
- m_isFileMode = true;
- // NOTE : 여기서 Property를 등록시키면 WorldEditor에서 이상이 생김 ;
- // 또한, Property Tree List에도 등록을 시켜야 되기 때문에 바깥쪽에서.. - [levites]
- }
- return true;
- }
- bool CPropertyManager::BuildPack()
- {
- if (!m_pack.Create(m_fileDict, "property", ""))
- return false;
- WIN32_FIND_DATA fdata;
- HANDLE hFind = FindFirstFile("property\\*", &fdata);
- if (hFind == INVALID_HANDLE_VALUE)
- return false;
- do
- {
- if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
- continue;
- char szSourceFileName[256 + 1];
- _snprintf(szSourceFileName, sizeof(szSourceFileName), "property\\%s", fdata.cFileName);
- m_pack.Put(fdata.cFileName, szSourceFileName,COMPRESSED_TYPE_NONE,"");
- }
- while (FindNextFile(hFind, &fdata));
- FindClose(hFind);
- return true;
- }
- replace with:
- bool CPropertyManager::Initialize(const char * c_pszPackFileName)
- {
- if (c_pszPackFileName)
- {
- if (CEterPackManager::Instance().isExist("property/reserve"))
- {
- LoadReservedCRC("property/reserve");
- }
- CMappedFile kListFile;
- PBYTE pbListData;
- if (CEterPackManager::Instance().Get(kListFile, "property/list", (LPCVOID*)&pbListData))
- {
- std::stringstream kSS;
- kSS << (char*)pbListData;
- std::string strLine;
- while (std::getline(kSS, strLine))
- {
- std::size_t posRight = strLine.find_last_not_of(" \t\r\n");
- strLine = (posRight == std::string::npos ? "" : strLine.substr(0, posRight + 1));
- std::size_t posLeft = strLine.find_first_not_of(" \t\r\n");
- strLine = (posLeft == std::string::npos ? "" : strLine.substr(posLeft, std::string::npos));
- if (!Register(strLine.c_str(), NULL))
- {
- TraceError("CPropertyManager::Initialize: Cannot register property '%s'!", strLine.c_str());
- }
- }
- }
- CMappedFile kPropertyXML;
- PBYTE pbPropertyXML;
- if (CEterPackManager::Instance().Get(kPropertyXML, "property.xml", (LPCVOID*)&pbPropertyXML))
- {
- char* pszXML = new char[kPropertyXML.Size() + 1];
- memcpy(pszXML, pbPropertyXML, kPropertyXML.Size());
- pszXML[kPropertyXML.Size()] = 0;
- std::stringstream kXML;
- kXML << pszXML;
- delete[] pszXML;
- try
- {
- boost::property_tree::ptree kPT;
- read_xml(kXML, kPT);
- BOOST_FOREACH(boost::property_tree::ptree::value_type& v, kPT.get_child("PropertyList"))
- {
- if (v.first == "Property")
- {
- CProperty* pProperty = new CProperty(v.second.get<std::string>("<xmlattr>.filename").c_str());
- if (!pProperty->ReadFromXML(v.second.get<std::string>("<xmlattr>.crc").c_str()))
- {
- TraceError("CPropertyManager::Initialize: Cannot register '%s'!", v.second.get<std::string>("<xmlattr>.filename").c_str());
- delete pProperty;
- continue;
- }
- DWORD dwCRC = pProperty->GetCRC();
- TPropertyCRCMap::iterator itor = m_PropertyByCRCMap.find(dwCRC);
- if (m_PropertyByCRCMap.end() != itor)
- {
- Tracef("Property already registered, replace %s to %s\n",
- itor->second->GetFileName(), v.second.get<std::string>("<xmlattr>.filename").c_str());
- delete itor->second;
- itor->second = pProperty;
- }
- else
- m_PropertyByCRCMap.insert(TPropertyCRCMap::value_type(dwCRC, pProperty));
- BOOST_FOREACH(boost::property_tree::ptree::value_type& s, v.second)
- {
- if (s.first == "<xmlattr>")
- {
- BOOST_FOREACH(boost::property_tree::ptree::value_type& d, s.second)
- {
- CTokenVector kVec;
- kVec.push_back(d.second.data());
- pProperty->PutVector(d.first.c_str(), kVec);
- }
- }
- }
- }
- }
- }
- catch (std::exception& e)
- {
- TraceError("CPropertyManager::Initialize: %s", e.what());
- return false;
- }
- }
- }
- else
- {
- m_isFileMode = true;
- }
- return true;
- }
- bool CPropertyManager::BuildPack()
- {
- return false;
- }
- //////////////////////////////////////////////////////////////////////////
- search:
- bool CPropertyManager::Get(DWORD dwCRC, CProperty ** ppProperty)
- {
- TPropertyCRCMap::iterator itor = m_PropertyByCRCMap.find(dwCRC);
- if (m_PropertyByCRCMap.end() == itor)
- return false;
- *ppProperty = itor->second;
- return true;
- }
- add below:
- bool CPropertyManager::Put(const char * c_pszFileName, const char * c_pszSourceFileName)
- {
- if (!CopyFile(c_pszSourceFileName, c_pszFileName, FALSE))
- return false;
- if (!m_isFileMode) // 팩 파일에도 넣음
- {
- if (!m_pack.Put(c_pszFileName, NULL, COMPRESSED_TYPE_NONE,""))
- {
- assert(!"CPropertyManager::Put cannot write to pack file");
- return false;
- }
- }
- Register(c_pszFileName);
- return true;
- }
- bool CPropertyManager::Erase(DWORD dwCRC)
- {
- TPropertyCRCMap::iterator itor = m_PropertyByCRCMap.find(dwCRC);
- if (m_PropertyByCRCMap.end() == itor)
- return false;
- CProperty * pProperty = itor->second;
- m_PropertyByCRCMap.erase(itor);
- DeleteFile(pProperty->GetFileName());
- ReserveCRC(pProperty->GetCRC());
- if (!m_isFileMode) // 파일 모드가 아니면 팩에서도 지움
- m_pack.Delete(pProperty->GetFileName());
- FILE * fp = fopen("property/reserve", "a+");
- if (!fp)
- LogBox("예약 CRC 파일을 열 수 없습니다.");
- else
- {
- char szCRC[64 + 1];
- _snprintf(szCRC, sizeof(szCRC), "%u\r\n", pProperty->GetCRC());
- fputs(szCRC, fp);
- fclose(fp);
- }
- delete pProperty;
- return true;
- }
- bool CPropertyManager::Erase(const char * c_pszFileName)
- {
- CProperty * pProperty = NULL;
- if (Get(c_pszFileName, &pProperty))
- return Erase(pProperty->GetCRC());
- return false;
- //////////////////////////////////////////////////////////////////////////
- EterPack/EterPackManager.h
- //////////////////////////////////////////////////////////////////////////
- search:
- #include "EterPack.h"
- add below:
- #include "FoxFS.h"
- //////////////////////////////////////////////////////////////////////////
- search:
- enum ESearchModes
- {
- SEARCH_FILE_FIRST,
- SEARCH_PACK_FIRST
- };
- replace with:
- enum ESearchModes
- {
- SEARCH_FILE,
- SEARCH_PACK
- };
- enum ESearchModes2
- {
- SEARCH_FILE_FIRST,
- SEARCH_PACK_FIRST
- };
- //////////////////////////////////////////////////////////////////////////
- search:
- CRITICAL_SECTION m_csFinder;
- add below:
- PFoxFS m_pFoxFS;
- //////////////////////////////////////////////////////////////////////////
- EterPack/EterPackManager.cpp
- //////////////////////////////////////////////////////////////////////////
- search:
- #ifdef __THEMIDA__
- #include <ThemidaSDK.h>
- #endif
- add below:
- namespace FoxFS
- {
- enum
- {
- ERROR_OK = 0,
- ERROR_BASE_CODE = 0,
- ERROR_FILE_WAS_NOT_FOUND = ERROR_BASE_CODE + 1,
- ERROR_CORRUPTED_FILE = ERROR_BASE_CODE + 2,
- ERROR_MISSING_KEY = ERROR_BASE_CODE + 3,
- ERROR_MISSING_IV = ERROR_BASE_CODE + 4,
- ERROR_DECRYPTION_HAS_FAILED = ERROR_BASE_CODE + 5,
- ERROR_DECOMPRESSION_FAILED = ERROR_BASE_CODE + 6,
- ERROR_ARCHIVE_NOT_FOUND = ERROR_BASE_CODE + 7,
- ERROR_ARCHIVE_NOT_READABLE = ERROR_BASE_CODE + 8,
- ERROR_ARCHIVE_INVALID = ERROR_BASE_CODE + 9,
- ERROR_ARCHIVE_ACCESS_DENIED = ERROR_BASE_CODE + 10,
- ERROR_KEYSERVER_SOCKET = ERROR_BASE_CODE + 11,
- ERROR_KEYSERVER_CONNECTION = ERROR_BASE_CODE + 12,
- ERROR_KEYSERVER_RESPONSE = ERROR_BASE_CODE + 13,
- ERROR_KEYSERVER_TIMEOUT = ERROR_BASE_CODE + 14,
- ERROR_UNKNOWN = ERROR_BASE_CODE + 15
- };
- }
- const char* white_file_list[] = { "mark\10_0.tga" "mark\250_0.tga" };
- bool isWhiteFile(const char* c_szFileName)
- {
- for (int i = 0; i < ARRAYSIZE(white_file_list); i++)
- {
- if (stricmp(c_szFileName, white_file_list[i]) == 0)
- {
- return true;
- }
- }
- return false;
- }
- const char* white_file_list_ext[] = { "xml", "tga", "png", "bmp", "mp3", "jpg" };
- bool isWhiteFileExt(const char* c_szFileName)
- {
- for (int i = 0; i < ARRAYSIZE(white_file_list_ext); i++)
- {
- std::string ext = CFileNameHelper::GetExtension(std::string(c_szFileName));
- std::transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
- std::string whiteExt = std::string(white_file_list_ext[i]);
- if (ext == whiteExt)
- return true;
- }
- return false;
- }
- //////////////////////////////////////////////////////////////////////////
- in:
- bool CEterPackManager::Get(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)
- replace:
- if (m_iSearchMode == SEARCH_FILE_FIRST)
- {
- if (GetFromFile(rMappedFile, c_szFileName, pData))
- {
- return true;
- }
- return GetFromPack(rMappedFile, c_szFileName, pData);
- }
- if (GetFromPack(rMappedFile, c_szFileName, pData))
- {
- return true;
- }
- return GetFromFile(rMappedFile, c_szFileName, pData);
- with:
- if (m_iSearchMode == SEARCH_FILE)
- {
- if (GetFromFile(rMappedFile, c_szFileName, pData))
- {
- return true;
- }
- return GetFromPack(rMappedFile, c_szFileName, pData);
- }
- else
- {
- if (isExistInPack(c_szFileName))
- {
- return GetFromPack(rMappedFile, c_szFileName, pData);
- }
- else if (isExist(c_szFileName))
- {
- return GetFromFile(rMappedFile, c_szFileName, pData);
- }
- }
- return false;
- //////////////////////////////////////////////////////////////////////////
- replace all bool:
- bool CEterPackManager::GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)
- {
- ...
- ...
- }
- with:
- bool CEterPackManager::GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)
- {
- assert(c_szFileName);
- FinderLock lock(m_csFinder);
- if (m_pFoxFS)
- {
- int errorCodeSize = 0;
- if ((errorCodeSize = FoxFS_ExistsA(m_pFoxFS, c_szFileName)) == FoxFS::ERROR_OK)
- {
- unsigned int dwSize = FoxFS_SizeA(m_pFoxFS, c_szFileName), dwReadSize = 0;
- BYTE* pbData = new BYTE[dwSize + 1];
- int errorCode = 0;
- if ((errorCode = FoxFS_GetA(m_pFoxFS, c_szFileName, pbData, dwSize, &dwReadSize)) == FoxFS::ERROR_OK)
- {
- pbData[dwReadSize] = 0;
- *pData = pbData;
- rMappedFile.Link(dwReadSize, pbData);
- return true;
- }
- else {
- TraceError("FoxFS - Could not get file %s Error Code %d", c_szFileName, errorCode);
- }
- delete[] pbData;
- }
- else {
- TraceError("FoxFS: File not existing %s Error Code %d", c_szFileName, errorCodeSize);
- }
- }
- else
- {
- TraceError("FoxFS: Not initialized!");
- }
- return false;
- }
- //////////////////////////////////////////////////////////////////////////
- replace all bool:
- bool CEterPackManager::isExistInPack(const char * c_szFileName)
- {
- ...
- ...
- }
- with:
- bool CEterPackManager::isExistInPack(const char * c_szFileName)
- {
- assert(c_szFileName);
- if (m_pFoxFS)
- {
- int errorCodeSize = 0;
- if ((errorCodeSize = FoxFS_ExistsA(m_pFoxFS, c_szFileName)) == FoxFS::ERROR_OK)
- {
- return true;
- }
- else
- {
- Tracenf("FoxFS : File not exists %s with error code %d", c_szFileName, errorCodeSize);
- }
- }
- else
- {
- TraceError("FoxFS: Not initialized!");
- }
- return false;
- }
- //////////////////////////////////////////////////////////////////////////
- replace all bool:
- bool CEterPackManager::isExist(const char * c_szFileName)
- {
- ...
- ...
- }
- with:
- bool CEterPackManager::isExist(const char * c_szFileName)
- {
- if (m_iSearchMode == SEARCH_PACK)
- {
- if (isWhiteFile(c_szFileName) || isWhiteFileExt(c_szFileName))
- {
- return isExistInPack(c_szFileName) || (_access(c_szFileName, 0) == 0);
- }
- return isExistInPack(c_szFileName);
- }
- if (_access(c_szFileName, 0) == 0)
- return true;
- return isExistInPack(c_szFileName);
- }
- //////////////////////////////////////////////////////////////////////////
- replace all function:
- void CEterPackManager::RegisterRootPack(const char * c_szName)
- {
- ...
- ...
- }
- with:
- void CEterPackManager::RegisterRootPack(const char * c_szName)
- {
- assert(c_szName);
- if (m_pFoxFS)
- {
- int errorCode = 0;
- if ((errorCode = FoxFS_LoadA(m_pFoxFS, c_szName)) != FoxFS::ERROR_OK)
- {
- TraceError("%s: Error Code %d", c_szName, errorCode);
- }
- }
- else
- {
- TraceError("FoxFS: Not initialized!");
- }
- }
- //////////////////////////////////////////////////////////////////////////
- replace all bool:
- bool CEterPackManager::RegisterPack(const char * c_szName, const char * c_szDirectory, const BYTE* c_pbIV)
- {
- ...
- ...
- }
- with:
- bool CEterPackManager::RegisterPack(const char * c_szName, const char * c_szDirectory, const BYTE* c_pbIV)
- {
- assert(c_szName);
- if (m_pFoxFS)
- {
- int errorCode = 0;
- if ((errorCode = FoxFS_LoadA(m_pFoxFS, c_szName)) != FoxFS::ERROR_OK)
- {
- TraceError("%s: Error Code %d", c_szName, errorCode);
- }
- }
- else
- {
- TraceError("FoxFS: Not initialized!");
- }
- return false;
- }
- //////////////////////////////////////////////////////////////////////////
- replace:
- CEterPackManager::CEterPackManager() : m_bTryRelativePath(false), m_iSearchMode(SEARCH_FILE_FIRST), m_isCacheMode(false)
- {
- InitializeCriticalSection(&m_csFinder);
- }
- with:
- CEterPackManager::CEterPackManager() : m_bTryRelativePath(false), m_iSearchMode(SEARCH_FILE_FIRST), m_isCacheMode(false)
- {
- InitializeCriticalSection(&m_csFinder);
- m_pFoxFS = FoxFS_Create();
- }
- //////////////////////////////////////////////////////////////////////////
- search:
- DeleteCriticalSection(&m_csFinder);
- add below:
- if (m_pFoxFS)
- {
- FoxFS_Destroy(m_pFoxFS);
- }
- //////////////////////////////////////////////////////////////////////////
- UserInterface/UserInterface.cpp
- //////////////////////////////////////////////////////////////////////////
- search:
- #pragma comment( lib, "dmoguids.lib" )
- add below:
- #pragma comment( lib, "lz4.lib" )
- #pragma comment( lib, "xxhash.lib" )
- #pragma comment( lib, "FoxFS.lib" )
- replace all bool:
- bool PackInitialize(const char * c_pszFolder)
- {
- ...
- ...
- }
- with:
- bool PackInitialize(const char * c_pszFolder)
- {
- NANOBEGIN
- if (_access(c_pszFolder, 0) != 0)
- return true;
- std::string stFolder(c_pszFolder);
- stFolder += "/";
- CTextFileLoader::SetCacheMode();
- CEterPackManager::Instance().SetCacheMode();
- CEterPackManager::Instance().SetSearchMode(CEterPackManager::SEARCH_PACK);
- CSoundData::SetPackMode();
- CEterPackManager::Instance().RegisterPack("pack/bgm", "bgm/");
- CEterPackManager::Instance().RegisterPack("pack/effect", "d:/ymir work/effect/");
- CEterPackManager::Instance().RegisterPack("pack/etc", "*");
- CEterPackManager::Instance().RegisterPack("pack/guild", "d:/ymir work/guild/");
- CEterPackManager::Instance().RegisterPack("pack/icon", "icon/");
- CEterPackManager::Instance().RegisterPack("pack/item", "d:/ymir work/item/");
- CEterPackManager::Instance().RegisterPack("pack/locale", "locale/");
- CEterPackManager::Instance().RegisterPack("pack/monster", "d:/ymir work/monster/");
- CEterPackManager::Instance().RegisterPack("pack/monster2", "d:/ymir work/monster2/");
- CEterPackManager::Instance().RegisterPack("pack/season1", "season1/");
- CEterPackManager::Instance().RegisterPack("pack/season2", "season2/");
- CEterPackManager::Instance().RegisterPack("pack/npc", "d:/ymir work/npc/");
- CEterPackManager::Instance().RegisterPack("pack/npc2", "d:/ymir work/npc2/");
- CEterPackManager::Instance().RegisterPack("pack/pc", "d:/ymir work/pc/");
- CEterPackManager::Instance().RegisterPack("pack/pc2", "d:/ymir work/pc2/");
- CEterPackManager::Instance().RegisterPack("pack/property", "property");
- CEterPackManager::Instance().RegisterPack("pack/sound", "sound/");
- CEterPackManager::Instance().RegisterPack("pack/terrain", "d:/ymir work/terrainmaps/");
- CEterPackManager::Instance().RegisterPack("pack/textureset", "textureset/");
- CEterPackManager::Instance().RegisterPack("pack/tree", "d:/ymir work/tree/");
- CEterPackManager::Instance().RegisterPack("pack/zone", "d:/ymir work/zone/");
- CEterPackManager::Instance().RegisterPack("pack/map", "map/");
- CEterPackManager::Instance().RegisterRootPack((stFolder + std::string("root")).c_str());
- NANOEND
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement