mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
Rebase resync
This commit is contained in:
parent
a0797532e8
commit
1997c1e903
3106 changed files with 11118 additions and 627576 deletions
|
|
@ -26,157 +26,163 @@
|
|||
//---------------------------------------------------------------------------
|
||||
|
||||
__fastcall thOpenFile::thOpenFile(bool CreateSuspended)
|
||||
: TThread(CreateSuspended)
|
||||
: TThread(CreateSuspended)
|
||||
{
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall thOpenFile::Execute()
|
||||
{
|
||||
//---- Place thread code here ----
|
||||
//if(!Terminated){
|
||||
// FrmMain->LoadAndModify(FrmMain->OpenDialog1->FileName.c_str());
|
||||
// FrmMain->OpenOk=true;
|
||||
//}
|
||||
thEnd=false;
|
||||
RunOpen();
|
||||
FrmMain->OpenOk=true;
|
||||
thEnd=true;
|
||||
//---- Place thread code here ----
|
||||
//if(!Terminated){
|
||||
// FrmMain->LoadAndModify(FrmMain->OpenDialog1->FileName.c_str());
|
||||
// FrmMain->OpenOk=true;
|
||||
//}
|
||||
thEnd = false;
|
||||
RunOpen();
|
||||
FrmMain->OpenOk = true;
|
||||
thEnd = true;
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall thOpenFile::RunOpen()
|
||||
{
|
||||
LoadAndModify(FrmMain->OpenDialog1->FileName.c_str());
|
||||
//OpenOk=true;
|
||||
LoadAndModify(FrmMain->OpenDialog1->FileName.c_str());
|
||||
//OpenOk=true;
|
||||
}
|
||||
|
||||
void thOpenFile::ReadAndModifyFromBuff(char *pBuff, DWORD dwSize, const char* pszFileName)
|
||||
void thOpenFile::ReadAndModifyFromBuff(char* pBuff, DWORD dwSize, const char* pszFileName)
|
||||
{
|
||||
char szErrorMsg[MAX_PATH];
|
||||
char szNewFileName[MAX_PATH];
|
||||
DWORD w;
|
||||
TIniFile *ini;
|
||||
char szErrorMsg[MAX_PATH];
|
||||
char szNewFileName[MAX_PATH];
|
||||
DWORD w;
|
||||
TIniFile* ini;
|
||||
|
||||
|
||||
TypePtr p(pBuff);
|
||||
if('WDBC' != TAG(*p.dw))
|
||||
{
|
||||
_snprintf(szErrorMsg, 512, "[%s]Not Wow's dbc file!", pszFileName);
|
||||
ShowMessage(szErrorMsg);
|
||||
return;
|
||||
}
|
||||
p.dw++;
|
||||
TypePtr p(pBuff);
|
||||
if ('WDBC' != TAG(*p.dw))
|
||||
{
|
||||
_snprintf(szErrorMsg, 512, "[%s]Not Wow's dbc file!", pszFileName);
|
||||
ShowMessage(szErrorMsg);
|
||||
return;
|
||||
}
|
||||
p.dw++;
|
||||
|
||||
DWORD dwRows, dwCols, dwRowLen, dwTextLen;
|
||||
dwRows = *p.dw++;
|
||||
dwCols = *p.dw++;
|
||||
dwRowLen = *p.dw++;
|
||||
dwTextLen = *p.dw++;
|
||||
DWORD dwRows, dwCols, dwRowLen, dwTextLen;
|
||||
dwRows = *p.dw++;
|
||||
dwCols = *p.dw++;
|
||||
dwRowLen = *p.dw++;
|
||||
dwTextLen = *p.dw++;
|
||||
|
||||
FrmMain->sgEdit->RowCount = dwRows+1;
|
||||
FrmMain->sgEdit->ColCount = dwCols+1;
|
||||
FrmMain->sgEdit->RowCount = dwRows + 1;
|
||||
FrmMain->sgEdit->ColCount = dwCols + 1;
|
||||
|
||||
for(int i=0; i<FrmMain->sgEdit->RowCount; i++){
|
||||
FrmMain->sgEdit->Cells[0][i]=IntToStr(i);
|
||||
if(Terminated) return;
|
||||
}
|
||||
//设定列标题
|
||||
AnsiString iniSetFile=ExtractFilePath(Application->ExeName)+"BcdEditer.ini";
|
||||
AnsiString SectionName=ExtractFileName(FrmMain->CurrentOpenFile);
|
||||
for (int i = 0; i < FrmMain->sgEdit->RowCount; i++)
|
||||
{
|
||||
FrmMain->sgEdit->Cells[0][i] = IntToStr(i);
|
||||
if (Terminated) return;
|
||||
}
|
||||
//设定列标题
|
||||
AnsiString iniSetFile = ExtractFilePath(Application->ExeName) + "BcdEditer.ini";
|
||||
AnsiString SectionName = ExtractFileName(FrmMain->CurrentOpenFile);
|
||||
|
||||
ini = new TIniFile( iniSetFile );
|
||||
for(int j=0; j<FrmMain->sgEdit->ColCount; j++){
|
||||
FrmMain->sgEdit->Cells[j][0]= ini->ReadString(SectionName,"ColTitle"+IntToStr(j),IntToStr(j));
|
||||
//sgEdit->Cells[j][0]=IntToStr(j);
|
||||
ColType[j]=ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0);
|
||||
if(Terminated) return;
|
||||
}
|
||||
delete ini;
|
||||
ini = new TIniFile(iniSetFile);
|
||||
for (int j = 0; j < FrmMain->sgEdit->ColCount; j++)
|
||||
{
|
||||
FrmMain->sgEdit->Cells[j][0] = ini->ReadString(SectionName, "ColTitle" + IntToStr(j), IntToStr(j));
|
||||
//sgEdit->Cells[j][0]=IntToStr(j);
|
||||
ColType[j] = ini->ReadInteger(SectionName, "ColType" + IntToStr(j), 0);
|
||||
if (Terminated) return;
|
||||
}
|
||||
delete ini;
|
||||
|
||||
//int *ColType = new int[dwCols];
|
||||
//int *ColType = new int[dwCols];
|
||||
|
||||
DWORD dwTextStartPos = dwRows*dwRowLen+20;
|
||||
char* pTextPtr = pBuff + dwTextStartPos;
|
||||
char pszTemp[MAX_PATH];
|
||||
float fTemp;
|
||||
long lTemp;
|
||||
DWORD i, j;
|
||||
BOOL* pbString = new BOOL[dwRows*dwCols];
|
||||
float newTmp;
|
||||
//int ColType;
|
||||
DWORD dwTextStartPos = dwRows * dwRowLen + 20;
|
||||
char* pTextPtr = pBuff + dwTextStartPos;
|
||||
char pszTemp[MAX_PATH];
|
||||
float fTemp;
|
||||
long lTemp;
|
||||
DWORD i, j;
|
||||
BOOL* pbString = new BOOL[dwRows * dwCols];
|
||||
float newTmp;
|
||||
//int ColType;
|
||||
|
||||
ini = new TIniFile( iniSetFile );
|
||||
ini = new TIniFile(iniSetFile);
|
||||
|
||||
for(i=0; i<dwRows; i++)
|
||||
{
|
||||
for(j=0; j<dwCols; j++)
|
||||
{
|
||||
//SleepEx(0,0);
|
||||
if(Terminated) return;
|
||||
lTemp = *p.l;
|
||||
newTmp = *p.f;
|
||||
memcpy(&fTemp, &newTmp, 4);
|
||||
for (i = 0; i < dwRows; i++)
|
||||
{
|
||||
for (j = 0; j < dwCols; j++)
|
||||
{
|
||||
//SleepEx(0,0);
|
||||
if (Terminated) return;
|
||||
lTemp = *p.l;
|
||||
newTmp = *p.f;
|
||||
memcpy(&fTemp, &newTmp, 4);
|
||||
|
||||
if(j==0) //ID
|
||||
FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp);
|
||||
else{
|
||||
if (j == 0) //ID
|
||||
FrmMain->sgEdit->Cells[j + 1][i + 1] = IntToStr(lTemp);
|
||||
else
|
||||
{
|
||||
|
||||
//ColType= ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0);
|
||||
//ColType= ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0);
|
||||
|
||||
switch (ColType[j+1])
|
||||
switch (ColType[j + 1])
|
||||
{
|
||||
case 0: //整型
|
||||
FrmMain->sgEdit->Cells[j + 1][i + 1] = IntToStr(lTemp);
|
||||
break;
|
||||
case 1: //浮点
|
||||
FrmMain->sgEdit->Cells[j + 1][i + 1] = FloatToStr(fTemp);
|
||||
break;
|
||||
case 2: //文本 文本类型只能看,不能编辑
|
||||
if (dwTextStartPos + lTemp < dwSize)
|
||||
{
|
||||
case 0: //整型
|
||||
FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp);
|
||||
break;
|
||||
case 1: //浮点
|
||||
FrmMain->sgEdit->Cells[j+1][i+1]=FloatToStr(fTemp);
|
||||
break;
|
||||
case 2: //文本 文本类型只能看,不能编辑
|
||||
if(dwTextStartPos + lTemp < dwSize){
|
||||
pTextPtr = pBuff + dwTextStartPos + lTemp;
|
||||
FrmMain->sgEdit->Cells[j+1][i+1]=pTextPtr;
|
||||
}else{
|
||||
FrmMain->sgEdit->Cells[j+1][i+1]="该列不是文本";
|
||||
}
|
||||
break;
|
||||
default: //整型
|
||||
FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp);
|
||||
pTextPtr = pBuff + dwTextStartPos + lTemp;
|
||||
FrmMain->sgEdit->Cells[j + 1][i + 1] = pTextPtr;
|
||||
}
|
||||
}
|
||||
p.c += 4;
|
||||
else
|
||||
{
|
||||
FrmMain->sgEdit->Cells[j + 1][i + 1] = "该列不是文本";
|
||||
}
|
||||
break;
|
||||
default: //整型
|
||||
FrmMain->sgEdit->Cells[j + 1][i + 1] = IntToStr(lTemp);
|
||||
}
|
||||
}
|
||||
p.c += 4;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] pbString;
|
||||
//delete [] ColType;
|
||||
delete ini;
|
||||
delete [] pbString;
|
||||
//delete [] ColType;
|
||||
delete ini;
|
||||
|
||||
}
|
||||
|
||||
void thOpenFile::LoadAndModify(const char * pszFileName)
|
||||
void thOpenFile::LoadAndModify(const char* pszFileName)
|
||||
{
|
||||
HANDLE hFile = NULL;
|
||||
hFile = CreateFile(pszFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE)return;
|
||||
HANDLE hFile = NULL;
|
||||
hFile = CreateFile(pszFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFile == INVALID_HANDLE_VALUE)return;
|
||||
|
||||
DWORD r = 0, nFileSize = 0;
|
||||
nFileSize = GetFileSize(hFile, NULL);
|
||||
char* pTmpBuf = new char[nFileSize];
|
||||
if(pTmpBuf==NULL)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return;
|
||||
}
|
||||
ReadFile(hFile, pTmpBuf, nFileSize, &r, NULL);
|
||||
|
||||
FrmMain->CurrentOpenFile=pszFileName;
|
||||
FrmMain->btSave->Enabled=true;
|
||||
|
||||
ReadAndModifyFromBuff(pTmpBuf, nFileSize, pszFileName);
|
||||
|
||||
//SAFE_DELETE_ARRAY(pTmpBuf);
|
||||
delete [] pTmpBuf;
|
||||
DWORD r = 0, nFileSize = 0;
|
||||
nFileSize = GetFileSize(hFile, NULL);
|
||||
char* pTmpBuf = new char[nFileSize];
|
||||
if (pTmpBuf == NULL)
|
||||
{
|
||||
CloseHandle(hFile);
|
||||
return;
|
||||
}
|
||||
ReadFile(hFile, pTmpBuf, nFileSize, &r, NULL);
|
||||
|
||||
FrmMain->CurrentOpenFile = pszFileName;
|
||||
FrmMain->btSave->Enabled = true;
|
||||
|
||||
ReadAndModifyFromBuff(pTmpBuf, nFileSize, pszFileName);
|
||||
|
||||
//SAFE_DELETE_ARRAY(pTmpBuf);
|
||||
delete [] pTmpBuf;
|
||||
CloseHandle(hFile);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue