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:
125
Engine/Caldron/Src/Base/CaldronByteDataObj.cpp
Normal file
125
Engine/Caldron/Src/Base/CaldronByteDataObj.cpp
Normal file
@@ -0,0 +1,125 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* CByteDataObj
|
||||
|
||||
* <20><><EFBFBD><EFBFBD> : ByteDataObj.h
|
||||
* <20><><EFBFBD><EFBFBD> : Caldron Engine<6E><65> CResourceMgr <20><><EFBFBD><EFBFBD> <20>о<EFBFBD><D0BE><EFBFBD><EFBFBD>̴<EFBFBD> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>Ǵ<EFBFBD> <20>⺻ <20><><EFBFBD><EFBFBD>.
|
||||
CLoadedObj<62><6A> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD> <20><><EFBFBD><EFBFBD> obj <20><><EFBFBD><EFBFBD> Load <20><>ƾ<EFBFBD><C6BE><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ҽ<EFBFBD><D2BD><EFBFBD> <20>˸<EFBFBD><CBB8><EFBFBD> <20><><EFBFBD>·<EFBFBD> <20><>ȯ <20>ε<EFBFBD> <20>ȴ<EFBFBD>.
|
||||
|
||||
* <20>ۼ<EFBFBD><DBBC><EFBFBD> : 2004.01.06
|
||||
* history :
|
||||
wizardbug ( 2004.01.06)
|
||||
|
||||
********************************************************************** */
|
||||
|
||||
|
||||
#include "CaldronByteDataObj.h"
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "GMMemory.h"
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CCaldronByteDataObj::CCaldronByteDataObj()
|
||||
{
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
CCaldronByteDataObj::~CCaldronByteDataObj()
|
||||
{
|
||||
if(m_pBytes)
|
||||
{
|
||||
delete[] m_pBytes;
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
}
|
||||
unsigned char *CCaldronByteDataObj::GetReadPtr()
|
||||
{
|
||||
if((m_lReadPos >= m_lSize) || (m_pBytes == NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_pBytes[m_lReadPos]);
|
||||
|
||||
}
|
||||
bool CCaldronByteDataObj::LoadByte(char *strFileName,long lOffset)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
long lFileSize = 0;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,0,SEEK_END);
|
||||
m_lSize = ftell(fp);
|
||||
if(m_lSize <= 0)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
// Offset <20><><EFBFBD><EFBFBD>
|
||||
if(m_lSize > lOffset)
|
||||
m_lSize -= lOffset;
|
||||
else
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
m_pBytes = new unsigned char[m_lSize];
|
||||
if(m_pBytes == NULL)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
if(fread((unsigned char *)m_pBytes,sizeof(unsigned char),m_lSize,fp) != m_lSize)
|
||||
{
|
||||
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
long CCaldronByteDataObj::Read(void *ptr,size_t UnitSize,int iNum)
|
||||
{
|
||||
if(ptr == NULL)
|
||||
return -1;
|
||||
long lCurrentReaded = ((long)(UnitSize) * iNum) / UINT_SIZE;
|
||||
if(m_lSize >= lCurrentReaded + m_lReadPos)
|
||||
{
|
||||
memcpy(ptr,&(m_pBytes[m_lReadPos]), (size_t)(UINT_SIZE * lCurrentReaded));
|
||||
m_lReadPos += lCurrentReaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
|
||||
}
|
||||
return m_lReadPos;
|
||||
|
||||
}
|
||||
}}
|
||||
Reference in New Issue
Block a user