Code:
#pragma pack(push, 1)
struct SERVER_LIST_INFO //39
{
WORD Index;
char Name[32];
BYTE Unknown34;
BYTE Unknown35;
BYTE Unknown36;
WORD DescriptLen;
};
#pragma pack(pop)
bool Dec(char* path)
{
if (path[strlen(path) - 1] != 'd' && path[strlen(path) - 1] != 'D')
{
return 0;
}
FILE* hFile;
fopen_s(&hFile, path, "rb");
if (!hFile)
{
return 0;
}
int BlockSize = sizeof(SERVER_LIST_INFO);
SERVER_LIST_INFO info;
char Descript[1024];
while (fread(&info, BlockSize, 1, hFile))
{
memset(Descript, 0, sizeof(Descript));
BuxConvert((BYTE*)&info, BlockSize);
fread(Descript, info.DescriptLen, 1, hFile);
BuxConvert((BYTE*)&Descript, info.DescriptLen);
ServerListInfo.insert(std::pair<int, SERVER_LIST_INFO>(info.Index, info));
ServerListDesInfo.insert(std::pair<int, std::string>(info.Index, Descript));
}
fclose(hFile);
char SavePath[MAX_PATH] = { 0 }, FileName[MAX_PATH] = { 0 };
_splitpath(path, 0, 0, FileName, 0);
sprintf_s(SavePath, "%s.txt", FileName);
fopen_s(&hFile, SavePath, "wb");
if (!hFile)
{
return 1;
}
fprintf(hFile, "//Index Name C3 C4 C5 Description\n");
for (std::map<int, SERVER_LIST_INFO>::iterator it = ServerListInfo.begin(); it != ServerListInfo.end(); it++)
{
if (ServerListDesInfo.find(it->first) != ServerListDesInfo.end())
{
fprintf(hFile, "%d \"%s\" %d %d %d \"%s\"\n",
it->second.Index,
it->second.Name,
it->second.Unknown34,
it->second.Unknown35,
it->second.Unknown36,
ServerListDesInfo.at(it->first).c_str()
);
}
else
{
fprintf(hFile, "%d \"%s\" %d %d %d \"\"\n",
it->second.Index,
it->second.Name,
it->second.Unknown34,
it->second.Unknown35,
it->second.Unknown36
);
}
}
fprintf(hFile, "end");
fclose(hFile);
return 1;
}