1
0
forked from metin2/client

Used shared pointers and string streams to read data from the CEterPackManager

This commit is contained in:
2024-12-24 06:54:43 +02:00
parent 603f2207ef
commit c21c99393d
50 changed files with 363 additions and 3668 deletions

View File

@ -196,21 +196,19 @@ bool CPythonLauncher::RunCompiledFile(const char* c_szFileName)
}
bool CPythonLauncher::RunMemoryTextFile(const char* c_szFileName, UINT uFileSize, const VOID* c_pvFileData)
bool CPythonLauncher::RunMemoryTextFile(const char* c_szFileName, std::shared_ptr<std::vector<char>> fileData)
{
NANOBEGIN
const CHAR* c_pcFileData=(const CHAR*)c_pvFileData;
std::string stConvFileData;
stConvFileData.reserve(uFileSize);
stConvFileData.reserve(fileData->size());
stConvFileData+="exec(compile('''";
// ConvertPythonTextFormat
{
for (UINT i=0; i<uFileSize; ++i)
for (UINT i=0; i<fileData->size(); ++i)
{
if (c_pcFileData[i]!=13)
stConvFileData+=c_pcFileData[i];
if ((*fileData)[i] != 13)
stConvFileData+= (*fileData)[i];
}
}
@ -227,29 +225,14 @@ bool CPythonLauncher::RunMemoryTextFile(const char* c_szFileName, UINT uFileSize
bool CPythonLauncher::RunFile(const char* c_szFileName)
{
char* acBufData=NULL;
DWORD dwBufSize=0;
{
CMappedFile file;
const VOID* pvData;
CEterPackManager::Instance().Get(file, c_szFileName, &pvData);
CEterPackManager::TPackDataPtr data;
if (!CEterPackManager::Instance().Get(c_szFileName, data))
return false;
dwBufSize=file.Size();
if (dwBufSize==0)
return false;
if (data->size() == 0)
return false;
acBufData=new char[dwBufSize];
memcpy(acBufData, pvData, dwBufSize);
}
bool ret=false;
ret=RunMemoryTextFile(c_szFileName, dwBufSize, acBufData);
delete [] acBufData;
return ret;
return RunMemoryTextFile(c_szFileName, data);
}
bool CPythonLauncher::RunLine(const char* c_szSrc)

View File

@ -15,7 +15,7 @@ class CPythonLauncher : public CSingleton<CPythonLauncher>
void SetTraceFunc(int (*pFunc)(PyObject * obj, PyFrameObject * f, int what, PyObject *arg));
bool RunLine(const char* c_szLine);
bool RunFile(const char* c_szFileName);
bool RunMemoryTextFile(const char* c_szFileName, UINT uFileSize, const VOID* c_pvFileData);
bool RunMemoryTextFile(const char* c_szFileName, std::shared_ptr<std::vector<char>> fileData);
bool RunCompiledFile(const char* c_szFileName);
const char* GetError();