Game Development Reference
In-Depth Information
of the Zip file and the name of the resource in the Zip file to decompress. It is
declared exactly the same as other events you ' ve seen.
Here
'
s VThreadProc() :
void DecompressionProcess::VThreadProc(void)
{
while (1)
{
// check the queue for events we should consume
IEventDataPtr e;
if (m_RealtimeEventQueue.try_pop(e))
{
// there
.
if (EvtData_Decompress_Request::sk_EventType == e->VGetEventType())
{
'
s an event! Something to do
shared_ptr<EvtData_Decompress_Request> decomp =
static_pointer_cast<EvtData_Decompress_Request>(e);
ZipFile zipFile;
bool success = FALSE;
if (zipFile.Init(decomp->m_zipFileName.c_str()))
{
int size = 0;
int resourceNum = zipFile.Find(decomp->m_fileName.c_str());
if (resourceNum >= 0)
{
char *buffer = GCC_NEW char[size];
zipFile.ReadFile(resourceNum, buffer);
// send decompression result event
IEventDataPtr e(
GCC_NEW EvtData_Decompression_Progress (
100, decomp->m_zipFileName,
decomp->m_fileName, buffer) );
IEventManager::Get()->VThreadSafeQueueEvent(e);
}
}
}
}
else
{
Sleep(10);
Search WWH ::




Custom Search