Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
189
Engine/Zalla3D Base Class/ResourceLoader.cpp
Normal file
189
Engine/Zalla3D Base Class/ResourceLoader.cpp
Normal file
@@ -0,0 +1,189 @@
|
||||
#include ".\resourceloader.h"
|
||||
#include "GMMemory.h"
|
||||
namespace CROSSM {
|
||||
|
||||
unsigned int __stdcall LoaderThreadProc(void *lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->LoaderFunc();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
unsigned int __stdcall ProcessThreadProc(void *lpParam)
|
||||
{
|
||||
CResourceLoader *pLoader = (CResourceLoader *)(lpParam);
|
||||
pLoader->ProcessFunc();
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
void CResourceLoader::StartLoader()
|
||||
{
|
||||
if(!m_LoaderHandle)
|
||||
{
|
||||
|
||||
if((m_LoaderHandle =(HANDLE)_beginthreadex(NULL,0,LoaderThreadProc,(LPVOID)this,0,&m_LoaderThreadID)) == NULL ) {
|
||||
//CLogMgr::_LogError("CResourceLoader::Loading() : Create Loader Thread Failed");
|
||||
}
|
||||
}
|
||||
if(!m_ProcessHandle)
|
||||
{
|
||||
if((m_ProcessHandle =(HANDLE)_beginthreadex(NULL,0,ProcessThreadProc,(LPVOID)this,0,&m_ProcessThreadID)) == NULL ) {
|
||||
//CLogMgr::_LogError("CResourceLoader::Loading() : Create Process Thread Failed");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
void CResourceLoader::LoaderFunc()
|
||||
{
|
||||
CResourceObj *pObj = NULL;
|
||||
|
||||
while( m_ReadyQueue.RemoveFront(pObj))
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
pObj->Init();
|
||||
|
||||
if(!(pObj->LoadByte()))
|
||||
{
|
||||
pObj->SetLoaded(false);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Queue.PushBack(pObj);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::ProcessFunc()
|
||||
{
|
||||
|
||||
CResourceObj *pObj = NULL;
|
||||
while( m_Queue.RemoveFront(pObj))
|
||||
{
|
||||
if(pObj)
|
||||
{
|
||||
if(!pObj->Load())
|
||||
{ // <20>ε<EFBFBD> <20><><EFBFBD>нÿ<D0BD> <20>ٽ<EFBFBD> queue<75><65> <20>־ ReLoading <20>õ<EFBFBD> <20>Ѵ<EFBFBD>.
|
||||
if(pObj->Reloading() < MAX_RELOADING) {
|
||||
m_Queue.PushBack(pObj);
|
||||
//CLogMgr::_LogError("CResourceLoader::ProcessFunc: Load fail, Reloading.");
|
||||
}
|
||||
else
|
||||
{
|
||||
pObj->ReleaseByte();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ResultQueue.PushBack(pObj);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//CLogMgr::_LogError("CResourceLoader::ProcessFunc: Obj Ptr is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void CResourceLoader::ProcessAllData()
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
|
||||
if(!m_ReadyQueue.GetQueueSize() &&
|
||||
!m_Queue.GetQueueSize())
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
Sleep(2000);
|
||||
}
|
||||
if(m_ResultQueue.GetQueueSize())
|
||||
{
|
||||
int iProcess = m_ResultQueue.GetQueueSize();
|
||||
CResourceObj *pObj = NULL;
|
||||
|
||||
while(iProcess)
|
||||
{
|
||||
if(m_ResultQueue.RemoveFront(pObj))
|
||||
{
|
||||
pObj->PostLoad();
|
||||
pObj->SetLoaded(true);
|
||||
pObj->ReleaseByte();
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
iProcess--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CResourceLoader::Process()
|
||||
{
|
||||
if(m_ResultQueue.GetQueueSize())
|
||||
{
|
||||
int iProcess = (m_ResultQueue.GetQueueSize() > g_iMaxProcessNums) ? g_iMaxProcessNums : m_ResultQueue.GetQueueSize();
|
||||
CResourceObj *pObj = NULL;
|
||||
|
||||
while(iProcess)
|
||||
{
|
||||
if(m_ResultQueue.RemoveFront(pObj))
|
||||
{
|
||||
pObj->PostLoad();
|
||||
pObj->SetLoaded(true);
|
||||
pObj->ReleaseByte();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
iProcess--;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
void CResourceLoader::Clear()
|
||||
{
|
||||
ProcessAllData();
|
||||
m_ReadyQueue.ClearQueue();
|
||||
m_Queue.ClearQueue();
|
||||
|
||||
m_ResultQueue.ClearQueue();
|
||||
|
||||
}
|
||||
|
||||
// 2005.01.10 yundi ImmediateLoad <20>߰<EFBFBD>
|
||||
void CResourceLoader::ImmediateLoad(CResourceObj *pObj)
|
||||
{
|
||||
pObj->Init();
|
||||
|
||||
if(!(pObj->LoadByte()))
|
||||
{
|
||||
pObj->SetLoaded(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!pObj->Load())
|
||||
{
|
||||
// <20>ε<EFBFBD> <20><><EFBFBD>н<EFBFBD> <20><><EFBFBD><EFBFBD>
|
||||
pObj->ReleaseByte();
|
||||
return;
|
||||
}
|
||||
|
||||
pObj->PostLoad();
|
||||
pObj->SetLoaded(true);
|
||||
pObj->ReleaseByte();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user