1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-17 20:58:07 +02:00

[programming challenge] Unique names for recording files

This commit is contained in:
Michał W. Urbańczyk 2011-12-28 02:55:02 +00:00
parent 2691fd62f4
commit b41dd8d88c

View File

@ -550,6 +550,22 @@ void memoryMonitor(int lAIpid, int rAIpid, int refPid)
}
////
std::string clearBaseName(const std::string &fname)
{
std::string ret = fname;
int hlp = ret.find_last_of('/');
if(hlp != std::string::npos)
{
ret = ret.substr(hlp+1);
}
hlp = ret.find_last_of('.');
if(hlp != std::string::npos)
{
ret = ret.substr(0,hlp);
}
return ret;
};
void CVCMIServer::startDuel(const std::string &battle, const std::string &leftAI, const std::string &rightAI, int howManyClients)
{
std::map<CConnection *, si32> pidsFromConns;
@ -642,8 +658,7 @@ void CVCMIServer::startDuel(const std::string &battle, const std::string &leftAI
//TODO monitor memory of PIDs
testMem.set(true);
boost::thread* memMon = new boost::thread(boost::bind(memoryMonitor, PIDs[0], PIDs[1], PIDs[2]));
std::string logFName = LOGS_DIR + "/" + leftAI + "_vs_"+rightAI+"_on_" + battle + ".vdat";
std::string logFName = LOGS_DIR + "/" + clearBaseName(leftAI) + "_vs_"+clearBaseName(rightAI)+"_on_" + clearBaseName(battle) + ".vdat";
tlog0 << "Logging battle activities (for replay possibility) in " << logFName << std::endl;
gh->gameLog = new CSaveFile(logFName);
gh->gameLog->smartPointerSerialization = false;