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>
134 lines
3.8 KiB
C++
134 lines
3.8 KiB
C++
// FindCharCopyLog.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#pragma warning(disable:4800)
|
|
|
|
#include <fstream>
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <ctime>
|
|
#include <set>
|
|
#include <iomanip>
|
|
#include <boost/pool/pool_alloc.hpp>
|
|
|
|
void PrintUsage()
|
|
{
|
|
printf("Usage : FindCharCopyLog ServerGroupNum(0~9) filename(can use wildcard * or ? ) ");
|
|
}
|
|
|
|
struct CopyCharData
|
|
{
|
|
unsigned long m_dwUID; // UID
|
|
unsigned long m_dwCID; // CID
|
|
time_t m_nCopyTime; // 복사 신청한 시간
|
|
unsigned long m_dwIndex; // 시간이 같은 경우에, 이거 순서대로 비교.
|
|
};
|
|
|
|
struct SortByTime
|
|
{
|
|
bool operator () (const CopyCharData& lhs, const CopyCharData& rhs)
|
|
{
|
|
return lhs.m_nCopyTime < rhs.m_nCopyTime ||
|
|
(!(rhs.m_nCopyTime < lhs.m_nCopyTime) && lhs.m_dwIndex, rhs.m_dwIndex);
|
|
}
|
|
};
|
|
|
|
typedef std::set<CopyCharData, SortByTime, boost::fast_pool_allocator<CopyCharData> > CopyCharUIDDataSet;
|
|
|
|
int _tmain(int argc, _TCHAR* argv[])
|
|
{
|
|
if(3 != argc)
|
|
{
|
|
PrintUsage();
|
|
return -1;
|
|
}
|
|
|
|
int nServerGroup = atoi(argv[1]);
|
|
|
|
WIN32_FIND_DATA findData;
|
|
memset(&findData, 0, sizeof(WIN32_FIND_DATA));
|
|
|
|
HANDLE hSearch = FindFirstFile(argv[2], &findData);
|
|
if (hSearch == INVALID_HANDLE_VALUE)
|
|
{
|
|
printf("File not found\n");
|
|
return -1;
|
|
}
|
|
|
|
CopyCharUIDDataSet copyCharUIDDataSet;
|
|
|
|
tm localTm;
|
|
memset(&localTm, 0, sizeof(tm));
|
|
|
|
unsigned long dwUID = 0;
|
|
unsigned long dwCID = 0;
|
|
|
|
const int MAX_BUFFER = 4096;
|
|
char szReadBuffer[MAX_BUFFER];
|
|
|
|
CopyCharData copyTempCharData;
|
|
|
|
do
|
|
{
|
|
std::fstream inputFile(findData.cFileName, std::ios_base::in);
|
|
|
|
if(!inputFile.is_open())
|
|
{
|
|
printf("File open failed : %s", findData.cFileName);
|
|
}
|
|
else
|
|
{
|
|
unsigned long dwLineCount = 0;
|
|
|
|
while(inputFile.getline(szReadBuffer, MAX_BUFFER - 1))
|
|
{
|
|
szReadBuffer[MAX_BUFFER - 1] = 0;
|
|
|
|
if(0 != strstr(szReadBuffer, "[Copy Log]") &&
|
|
8 == sscanf(szReadBuffer, "[Ty-DET][Tm-%d-%d-%d %d:%d:%d][Ex-UID:%d/CID:%d/",
|
|
&localTm.tm_year, &localTm.tm_mon, &localTm.tm_mday, &localTm.tm_hour, &localTm.tm_min, &localTm.tm_sec,
|
|
&dwUID, &dwCID))
|
|
{
|
|
// 값이 전부 제대로 들어 왔으면 데이터를 맵에 넣는다.
|
|
|
|
localTm.tm_year -= 1900;
|
|
localTm.tm_mon -= 1;
|
|
|
|
copyTempCharData.m_dwUID = dwUID;
|
|
copyTempCharData.m_dwCID = dwCID;
|
|
copyTempCharData.m_nCopyTime = mktime(&localTm);
|
|
copyTempCharData.m_dwIndex = ++dwLineCount;
|
|
|
|
copyCharUIDDataSet.insert(copyTempCharData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
while(FindNextFile(hSearch, &findData));
|
|
FindClose(hSearch);
|
|
|
|
// 시간순으로 소트해서, 일단 전부 뽑아낸 뒤, 나중에 중복체크, 종족체크 등을 한다.
|
|
std::stringstream outFileName;
|
|
outFileName << "./CharCopy" << std::setfill('0') << std::setw(2) << nServerGroup << ".log" << std::ends;
|
|
|
|
std::fstream outstream(outFileName.str().c_str(), std::ios_base::out);
|
|
if(outstream.is_open())
|
|
{
|
|
CopyCharUIDDataSet::iterator pos = copyCharUIDDataSet.begin();
|
|
CopyCharUIDDataSet::iterator end = copyCharUIDDataSet.end();
|
|
|
|
for(; pos != end; ++pos)
|
|
{
|
|
CopyCharData& copyCharData = *pos;
|
|
|
|
outstream << copyCharData.m_dwUID << ":" << copyCharData.m_dwCID
|
|
<< ":" << copyCharData.m_nCopyTime << ":" << copyCharData.m_dwIndex << std::endl;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|