Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
124
GameTools/CaldronBase/ByteDataObj.cpp
Normal file
124
GameTools/CaldronBase/ByteDataObj.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
|
||||
/* *********************************************************************
|
||||
|
||||
* 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 "./LogMgr.h"
|
||||
#include "ByteDataObj.h"
|
||||
|
||||
|
||||
namespace Caldron {
|
||||
namespace Base {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CByteDataObj::CByteDataObj()
|
||||
{
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
|
||||
CByteDataObj::~CByteDataObj()
|
||||
{
|
||||
if(m_pBytes)
|
||||
{
|
||||
delete[] m_pBytes;
|
||||
m_pBytes = NULL;
|
||||
m_lSize = 0;
|
||||
m_lReadPos = 0;
|
||||
|
||||
}
|
||||
}
|
||||
unsigned char *CByteDataObj::GetReadPtr()
|
||||
{
|
||||
if((m_lReadPos >= m_lSize) || (m_pBytes == NULL))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &(m_pBytes[m_lReadPos]);
|
||||
|
||||
}
|
||||
bool CByteDataObj::LoadByte(char *strFileName,long lOffset)
|
||||
{
|
||||
FILE *fp = fopen(strFileName,"rb");
|
||||
long lFileSize = 0;
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : %s file not exist\n",strFileName);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,0,SEEK_END);
|
||||
m_lSize = ftell(fp);
|
||||
if(m_lSize <= 0)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : %s file size Wrong\n",strFileName);
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
// Offset <20><><EFBFBD><EFBFBD>
|
||||
if(m_lSize > lOffset)
|
||||
m_lSize -= lOffset;
|
||||
else
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : %s File Offset<65><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ѱ踦 <20>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD>ϴ<EFBFBD>.\n",strFileName);
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
m_pBytes = new unsigned char[m_lSize];
|
||||
if(m_pBytes == NULL)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : File Load Buffer's New Fail.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
|
||||
}
|
||||
fseek(fp,lOffset,SEEK_SET);
|
||||
if(fread((unsigned char *)m_pBytes,sizeof(unsigned char),m_lSize,fp) != m_lSize)
|
||||
{
|
||||
CLogMgr::_LogError("CByteDataObj::LoadByte() : Load File Fail.\n");
|
||||
fclose(fp);
|
||||
return false;
|
||||
}
|
||||
fclose(fp);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
long CByteDataObj::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