new pack system
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
add_library(EterLib STATIC ${FILE_SOURCES})
|
||||
|
||||
target_link_libraries(EterLib
|
||||
lzo2
|
||||
cryptopp-static
|
||||
mio
|
||||
)
|
||||
|
||||
GroupSourcesByFolder(EterLib)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EterPack/EterPackManager.h"
|
||||
#include "EterBase/Stl.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
#include "FileLoaderThread.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
@@ -115,8 +116,7 @@ void CFileLoaderThread::Request(std::string & c_rstFileName) // called in main t
|
||||
{
|
||||
TData * pData = new TData;
|
||||
|
||||
pData->dwSize = 0;
|
||||
pData->pvBuf = NULL;
|
||||
pData->File.clear();
|
||||
pData->stFileName = c_rstFileName;
|
||||
|
||||
m_RequestMutex.Lock();
|
||||
@@ -163,14 +163,7 @@ void CFileLoaderThread::Process() // called in loader thread
|
||||
|
||||
m_RequestMutex.Unlock();
|
||||
|
||||
LPCVOID pvBuf;
|
||||
|
||||
if (CEterPackManager::Instance().Get(pData->File, pData->stFileName.c_str(), &pvBuf))
|
||||
{
|
||||
pData->dwSize = pData->File.Size();
|
||||
pData->pvBuf = new char [pData->dwSize];
|
||||
memcpy(pData->pvBuf, pvBuf, pData->dwSize);
|
||||
}
|
||||
CPackManager::instance().GetFile(pData->stFileName, pData->File);
|
||||
|
||||
m_CompleteMutex.Lock();
|
||||
m_pCompleteDeque.push_back(pData);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <deque>
|
||||
#include "Thread.h"
|
||||
#include "Mutex.h"
|
||||
#include "EterBase/MappedFile.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
|
||||
class CFileLoaderThread
|
||||
{
|
||||
@@ -12,10 +12,7 @@ class CFileLoaderThread
|
||||
typedef struct SData
|
||||
{
|
||||
std::string stFileName;
|
||||
|
||||
CMappedFile File;
|
||||
LPVOID pvBuf;
|
||||
DWORD dwSize;
|
||||
TPackFile File;
|
||||
} TData;
|
||||
|
||||
public:
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EterBase/MappedFile.h"
|
||||
#include "EterPack/EterPackManager.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
#include "GrpImageTexture.h"
|
||||
#include "EterImageLib/DDSTextureLoader9.h"
|
||||
|
||||
@@ -53,13 +52,11 @@ bool CGraphicImageTexture::CreateDeviceObjects()
|
||||
}
|
||||
else
|
||||
{
|
||||
CMappedFile mappedFile;
|
||||
LPCVOID c_pvMap;
|
||||
|
||||
if (!CEterPackManager::Instance().Get(mappedFile, m_stFileName.c_str(), &c_pvMap))
|
||||
TPackFile mappedFile;
|
||||
if (!CPackManager::Instance().GetFile(m_stFileName, mappedFile))
|
||||
return false;
|
||||
|
||||
return CreateFromMemoryFile(mappedFile.Size(), c_pvMap, m_d3dFmt, m_dwFilter);
|
||||
return CreateFromMemoryFile(mappedFile.size(), mappedFile.data(), m_d3dFmt, m_dwFilter);
|
||||
}
|
||||
|
||||
m_bEmpty = false;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EterPack/EterPackManager.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
#include "EterBase/Stl.h"
|
||||
#include "EterBase/CRC32.h"
|
||||
#include "EterBase/Timer.h"
|
||||
|
||||
@@ -43,17 +44,16 @@ void CResource::Load()
|
||||
const char * c_szFileName = GetFileName();
|
||||
|
||||
DWORD dwStart = ELTimer_GetMSec();
|
||||
CMappedFile file;
|
||||
LPCVOID fileData;
|
||||
TPackFile file;
|
||||
|
||||
//Tracenf("Load %s", c_szFileName);
|
||||
|
||||
if (CEterPackManager::Instance().Get(file, c_szFileName, &fileData))
|
||||
if (CPackManager::Instance().GetFile(c_szFileName, file))
|
||||
{
|
||||
m_dwLoadCostMiliiSecond = ELTimer_GetMSec() - dwStart;
|
||||
//Tracef("CResource::Load %s (%d bytes) in %d ms\n", c_szFileName, file.Size(), m_dwLoadCostMiliiSecond);
|
||||
|
||||
if (OnLoad(file.Size(), fileData))
|
||||
if (OnLoad(file.size(), file.data()))
|
||||
{
|
||||
me_state = STATE_EXIST;
|
||||
}
|
||||
@@ -81,12 +81,10 @@ void CResource::Reload()
|
||||
Clear();
|
||||
Tracef("CResource::Reload %s\n", GetFileName());
|
||||
|
||||
CMappedFile file;
|
||||
LPCVOID fileData;
|
||||
|
||||
if (CEterPackManager::Instance().Get(file, GetFileName(), &fileData))
|
||||
TPackFile file;
|
||||
if (CPackManager::Instance().GetFile(GetFileName(), file))
|
||||
{
|
||||
if (OnLoad(file.Size(), fileData))
|
||||
if (OnLoad(file.size(), file.data()))
|
||||
{
|
||||
me_state = STATE_EXIST;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "EterBase/CRC32.h"
|
||||
#include "EterBase/Timer.h"
|
||||
#include "EterBase/Stl.h"
|
||||
#include "EterPack/EterPackManager.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
|
||||
#include "ResourceManager.h"
|
||||
#include "GrpImage.h"
|
||||
@@ -71,7 +71,7 @@ void CResourceManager::ProcessBackgroundLoading()
|
||||
{
|
||||
if (pResource->IsEmpty())
|
||||
{
|
||||
pResource->OnLoad(pData->dwSize, pData->pvBuf);
|
||||
pResource->OnLoad(pData->File.size(), pData->File.data());
|
||||
pResource->AddReferenceOnly();
|
||||
|
||||
// 여기서 올라간 레퍼런스 카운트를 일정 시간이 지난 뒤에 풀어주기 위하여
|
||||
@@ -81,7 +81,6 @@ void CResourceManager::ProcessBackgroundLoading()
|
||||
|
||||
m_WaitingMap.erase(GetCRC32(pData->stFileName.c_str(), pData->stFileName.size()));
|
||||
|
||||
delete [] ((char *) pData->pvBuf);
|
||||
delete pData;
|
||||
}
|
||||
|
||||
@@ -472,7 +471,7 @@ void CResourceManager::DumpFileListToTextFile(const char* c_szFileName)
|
||||
|
||||
bool CResourceManager::IsFileExist(const char * c_szFileName)
|
||||
{
|
||||
return CEterPackManager::Instance().isExist(c_szFileName);
|
||||
return CPackManager::Instance().IsExist(c_szFileName);
|
||||
}
|
||||
|
||||
void CResourceManager::Update()
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
#include "StdAfx.h"
|
||||
#include "TargaResource.h"
|
||||
|
||||
CTargaResource::CTargaResource(const char * c_pszFileName) : CResource(c_pszFileName)
|
||||
{
|
||||
}
|
||||
|
||||
CTargaResource::~CTargaResource()
|
||||
{
|
||||
}
|
||||
|
||||
CTargaResource::TType CTargaResource::Type()
|
||||
{
|
||||
static TType s_type = StringToType("CTargaResource");
|
||||
return s_type;
|
||||
}
|
||||
|
||||
bool CTargaResource::OnIsType(TType type)
|
||||
{
|
||||
if (CTargaResource::Type() == type)
|
||||
return true;
|
||||
|
||||
return CResource::OnIsType(type);
|
||||
}
|
||||
|
||||
bool CTargaResource::OnLoad(int iSize, const void * c_pvBuf)
|
||||
{
|
||||
return image.LoadFromMemory(iSize, static_cast<const BYTE *>(c_pvBuf));
|
||||
}
|
||||
|
||||
void CTargaResource::OnClear()
|
||||
{
|
||||
image.Clear();
|
||||
}
|
||||
|
||||
bool CTargaResource::OnIsEmpty() const
|
||||
{
|
||||
return image.IsEmpty();
|
||||
}
|
||||
|
||||
void CTargaResource::GetRect(DWORD & w, DWORD & h)
|
||||
{
|
||||
w = image.GetWidth();
|
||||
h = image.GetHeight();
|
||||
}
|
||||
|
||||
DWORD * CTargaResource::GetMemPtr()
|
||||
{
|
||||
return image.GetBasePointer();
|
||||
}
|
||||
|
||||
TGA_HEADER & CTargaResource::GetTgaHeader()
|
||||
{
|
||||
return image.GetHeader();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "Ref.h"
|
||||
#include "Resource.h"
|
||||
#include "EterImageLib/TGAImage.h"
|
||||
|
||||
class CTargaResource : public CResource
|
||||
{
|
||||
public:
|
||||
typedef CRef<CTargaResource> TRef;
|
||||
|
||||
public:
|
||||
static TType Type();
|
||||
|
||||
public:
|
||||
CTargaResource(const char * c_pszFileName);
|
||||
virtual ~CTargaResource();
|
||||
|
||||
DWORD * GetMemPtr();
|
||||
void GetRect(DWORD & w, DWORD & h);
|
||||
|
||||
TGA_HEADER & GetTgaHeader();
|
||||
|
||||
protected:
|
||||
virtual bool OnLoad(int iSize, const void * c_pvBuf);
|
||||
virtual void OnClear();
|
||||
virtual bool OnIsEmpty() const;
|
||||
virtual bool OnIsType(TType type);
|
||||
|
||||
protected:
|
||||
CTGAImage image;
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EterBase/CRC32.h"
|
||||
#include <string>
|
||||
#include "EterPack/EterPackManager.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
|
||||
#include "Pool.h"
|
||||
#include "TextFileLoader.h"
|
||||
@@ -179,14 +179,13 @@ bool CTextFileLoader::Load(const char * c_szFileName)
|
||||
{
|
||||
m_strFileName = "";
|
||||
|
||||
const VOID* pvData;
|
||||
CMappedFile kFile;
|
||||
if (!CEterPackManager::Instance().Get(kFile, c_szFileName, &pvData))
|
||||
TPackFile kFile;
|
||||
if (!CPackManager::Instance().GetFile( c_szFileName, kFile))
|
||||
return false;
|
||||
|
||||
if (m_dwBufCapacity<kFile.Size())
|
||||
if (m_dwBufCapacity<kFile.size())
|
||||
{
|
||||
m_dwBufCapacity=kFile.Size();
|
||||
m_dwBufCapacity=kFile.size();
|
||||
|
||||
if (m_acBufData)
|
||||
delete [] m_acBufData;
|
||||
@@ -194,8 +193,8 @@ bool CTextFileLoader::Load(const char * c_szFileName)
|
||||
m_acBufData=new char[m_dwBufCapacity];
|
||||
}
|
||||
|
||||
m_dwBufSize=kFile.Size();
|
||||
memcpy(m_acBufData, pvData, m_dwBufSize);
|
||||
m_dwBufSize=kFile.size();
|
||||
memcpy(m_acBufData, kFile.data(), m_dwBufSize);
|
||||
|
||||
m_strFileName = c_szFileName;
|
||||
m_dwcurLineIndex = 0;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define __INC_METIN_II_TEXTFILELOADER_H__
|
||||
|
||||
#include "EterBase/FileLoader.h"
|
||||
#include "EterBase/MappedFile.h"
|
||||
#include "EterLib/Util.h"
|
||||
#include "EterLib/Pool.h"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "StdAfx.h"
|
||||
#include "EterPack/EterPackManager.h"
|
||||
|
||||
#include "TextFileLoader.h"
|
||||
#include "PackLib/PackManager.h"
|
||||
|
||||
void PrintfTabs(FILE * File, int iTabCount, const char * c_szString, ...)
|
||||
{
|
||||
@@ -20,16 +19,15 @@ void PrintfTabs(FILE * File, int iTabCount, const char * c_szString, ...)
|
||||
|
||||
bool LoadTextData(const char * c_szFileName, CTokenMap & rstTokenMap)
|
||||
{
|
||||
LPCVOID pMotionData;
|
||||
CMappedFile File;
|
||||
TPackFile File;
|
||||
|
||||
if (!CEterPackManager::Instance().Get(File, c_szFileName, &pMotionData))
|
||||
if (!CPackManager::Instance().GetFile(c_szFileName, File))
|
||||
return false;
|
||||
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
CTokenVector stTokenVector;
|
||||
|
||||
textFileLoader.Bind(File.Size(), pMotionData);
|
||||
textFileLoader.Bind(File.size(), File.data());
|
||||
|
||||
for (DWORD i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
@@ -50,10 +48,9 @@ bool LoadTextData(const char * c_szFileName, CTokenMap & rstTokenMap)
|
||||
|
||||
bool LoadMultipleTextData(const char * c_szFileName, CTokenVectorMap & rstTokenVectorMap)
|
||||
{
|
||||
LPCVOID pModelData;
|
||||
CMappedFile File;
|
||||
TPackFile File;
|
||||
|
||||
if (!CEterPackManager::Instance().Get(File, c_szFileName, &pModelData))
|
||||
if (!CPackManager::Instance().GetFile(c_szFileName, File))
|
||||
return false;
|
||||
|
||||
DWORD i;
|
||||
@@ -61,7 +58,7 @@ bool LoadMultipleTextData(const char * c_szFileName, CTokenVectorMap & rstTokenV
|
||||
CMemoryTextFileLoader textFileLoader;
|
||||
CTokenVector stTokenVector;
|
||||
|
||||
textFileLoader.Bind(File.Size(), pModelData);
|
||||
textFileLoader.Bind(File.size(), File.data());
|
||||
|
||||
for (i = 0; i < textFileLoader.GetLineCount(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user