mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-18 19:29:09 +00:00
Replace hsStream::Open duplicated methods everywhere with a single plFileName interface
This commit is contained in:
@ -174,20 +174,13 @@ void plAutoProfileImp::IInit()
|
||||
void plAutoProfileImp::IShutdown()
|
||||
{
|
||||
// KLUDGE - Copy the load timing log, in case we used it
|
||||
#define kTimingLog L"readtimings.0.log"
|
||||
#define kAgeTimingLog L"agetimings.0.log"
|
||||
wchar_t destPath[MAX_PATH];
|
||||
wchar_t sourcePath[MAX_PATH];
|
||||
#define kTimingLog "readtimings.0.log"
|
||||
#define kAgeTimingLog "agetimings.0.log"
|
||||
|
||||
PathAddFilename(destPath, plProfileManagerFull::Instance().GetProfilePath(), kTimingLog, arrsize(destPath));
|
||||
PathGetLogDirectory(sourcePath, arrsize(sourcePath));
|
||||
PathAddFilename(sourcePath, sourcePath, kTimingLog, arrsize(sourcePath));
|
||||
plFileUtils::FileCopy(sourcePath, destPath);
|
||||
|
||||
PathAddFilename(destPath, plProfileManagerFull::Instance().GetProfilePath(), kAgeTimingLog, arrsize(destPath));
|
||||
PathGetLogDirectory(sourcePath, arrsize(sourcePath));
|
||||
PathAddFilename(sourcePath, sourcePath, kAgeTimingLog, arrsize(sourcePath));
|
||||
plFileUtils::FileCopy(sourcePath, destPath);
|
||||
plFileSystem::Copy(plFileName::Join(plFileSystem::GetLogPath(), kTimingLog),
|
||||
plFileName::Join(plProfileManagerFull::Instance().GetProfilePath(), kTimingLog));
|
||||
plFileSystem::Copy(plFileName::Join(plFileSystem::GetLogPath(), kAgeTimingLog),
|
||||
plFileName::Join(plProfileManagerFull::Instance().GetProfilePath(), kAgeTimingLog));
|
||||
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
ShellExecute(nil, nil, "PostRun.bat", nil, nil, SW_SHOWNORMAL);
|
||||
@ -219,7 +212,7 @@ void plAutoProfileImp::INextProfile()
|
||||
if (!fLastSpawnPointName.IsNull())
|
||||
{
|
||||
const char * ageName = NetCommGetAge()->ageDatasetName;
|
||||
plProfileManagerFull::Instance().LogStats(ageName, fLastSpawnPointName.c_str());
|
||||
plProfileManagerFull::Instance().LogStats(ageName, fLastSpawnPointName);
|
||||
|
||||
plMipmap mipmap;
|
||||
if (plClient::GetInstance()->GetPipeline()->CaptureScreen(&mipmap))
|
||||
|
@ -418,40 +418,28 @@ void plProfileManagerFull::IPrintGroup(hsStream* s, const char* groupName, bool
|
||||
}
|
||||
}
|
||||
|
||||
void plProfileManagerFull::LogStats(const char* ageName, const char* spawnName)
|
||||
void plProfileManagerFull::LogStats(const plString& ageName, const plString& spawnName)
|
||||
{
|
||||
fLogStats = true;
|
||||
wchar_t* temp = hsStringToWString(ageName);
|
||||
fLogAgeName = temp;
|
||||
delete [] temp;
|
||||
fLogAgeName = ageName;
|
||||
fLogSpawnName = spawnName;
|
||||
}
|
||||
|
||||
const wchar_t* plProfileManagerFull::GetProfilePath()
|
||||
plFileName plProfileManagerFull::GetProfilePath()
|
||||
{
|
||||
static wchar_t profilePath[MAX_PATH];
|
||||
static bool initialized = false;
|
||||
static plFileName profilePath;
|
||||
|
||||
if (!initialized)
|
||||
if (!profilePath.IsValid())
|
||||
{
|
||||
initialized = true;
|
||||
|
||||
plUnifiedTime curTime = plUnifiedTime::GetCurrent(plUnifiedTime::kLocal);
|
||||
|
||||
PathGetUserDirectory(profilePath, arrsize(profilePath));
|
||||
PathAddFilename(profilePath, profilePath, L"Profile", arrsize(profilePath));
|
||||
plFileUtils::CreateDir(profilePath);
|
||||
|
||||
wchar_t buff[256];
|
||||
hsSnwprintf(buff, 256, L"%02d-%02d-%04d_%02d-%02d//",
|
||||
curTime.GetMonth(),
|
||||
curTime.GetDay(),
|
||||
curTime.GetYear(),
|
||||
curTime.GetHour(),
|
||||
curTime.GetMinute());
|
||||
profilePath = plFileName::Join(plFileSystem::GetUserDataPath(), "Profile",
|
||||
plString::Format("%02d-%02d-%04d_%02d-%02d",
|
||||
curTime.GetMonth(), curTime.GetDay(),
|
||||
curTime.GetYear(), curTime.GetHour(),
|
||||
curTime.GetMinute()));
|
||||
|
||||
PathAddFilename(profilePath, profilePath, buff, arrsize(profilePath));
|
||||
plFileUtils::CreateDir(profilePath);
|
||||
plFileSystem::CreateDir(profilePath, true);
|
||||
}
|
||||
|
||||
return profilePath;
|
||||
@ -459,13 +447,12 @@ const wchar_t* plProfileManagerFull::GetProfilePath()
|
||||
|
||||
void plProfileManagerFull::ILogStats()
|
||||
{
|
||||
wchar_t statFilename[256];
|
||||
hsSnwprintf(statFilename, 256, L"%s%s.csv", GetProfilePath(), fLogAgeName.c_str());
|
||||
plFileName statFilename = plFileName::Join(GetProfilePath(), fLogAgeName + ".csv");
|
||||
|
||||
bool exists = plFileUtils::FileExists(statFilename);
|
||||
bool exists = plFileInfo(statFilename).Exists();
|
||||
|
||||
hsUNIXStream s;
|
||||
if (s.Open(statFilename, L"ab"))
|
||||
if (s.Open(statFilename, "ab"))
|
||||
{
|
||||
GroupSet groups;
|
||||
GetGroups(groups);
|
||||
@ -474,7 +461,7 @@ void plProfileManagerFull::ILogStats()
|
||||
|
||||
if (!exists)
|
||||
{
|
||||
const char* kSpawn = "Spawn";
|
||||
static const char kSpawn[] = "Spawn";
|
||||
s.Write(strlen(kSpawn), kSpawn);
|
||||
s.WriteByte(',');
|
||||
|
||||
@ -487,7 +474,7 @@ void plProfileManagerFull::ILogStats()
|
||||
s.WriteByte('\n');
|
||||
}
|
||||
|
||||
s.Write(fLogSpawnName.length(), fLogSpawnName.c_str());
|
||||
s.Write(fLogSpawnName.GetSize(), fLogSpawnName.c_str());
|
||||
s.WriteByte(',');
|
||||
|
||||
for (it = groups.begin(); it != groups.end(); it++)
|
||||
@ -502,7 +489,7 @@ void plProfileManagerFull::ILogStats()
|
||||
}
|
||||
|
||||
fLogStats = false;
|
||||
fLogAgeName = L"";
|
||||
fLogAgeName = "";
|
||||
fLogSpawnName = "";
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "plString.h"
|
||||
#include "plFileSystem.h"
|
||||
|
||||
#include "plProfileManager.h"
|
||||
|
||||
@ -63,8 +63,8 @@ protected:
|
||||
plProfileManager::VarVec& fVars;
|
||||
|
||||
bool fLogStats; // If true, log the stats at the end of the frame
|
||||
std::wstring fLogAgeName;
|
||||
std::string fLogSpawnName;
|
||||
plString fLogAgeName;
|
||||
plString fLogSpawnName;
|
||||
|
||||
std::vector<plGraphPlate*> fGraphs;
|
||||
plGraphPlate* fDetailGraph;
|
||||
@ -119,9 +119,9 @@ public:
|
||||
void UpdateDetailLabels();
|
||||
|
||||
void ResetMax();
|
||||
|
||||
void LogStats(const char* ageName, const char* spawnName);
|
||||
const wchar_t* GetProfilePath();
|
||||
|
||||
void LogStats(const plString& ageName, const plString& spawnName);
|
||||
plFileName GetProfilePath();
|
||||
|
||||
// If you're going to call LogStats, make sure to call this first so all stats will be evaluated before logging
|
||||
void ActivateAllStats();
|
||||
|
Reference in New Issue
Block a user