Browse Source

Deprecate plFileUtils and parts of pnUtPath

Michael Hansen 11 years ago
parent
commit
6e564476b7
  1. 1
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 3
      Sources/Plasma/Apps/plClient/winmain.cpp
  3. 140
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp
  4. 2
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.h
  5. 1
      Sources/Plasma/Apps/plFileSecure/main.cpp
  6. 32
      Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp
  7. 4
      Sources/Plasma/Apps/plPageOptimizer/main.cpp
  8. 19
      Sources/Plasma/Apps/plPageOptimizer/plPageOptimizer.cpp
  9. 7
      Sources/Plasma/Apps/plPageOptimizer/plPageOptimizer.h
  10. 32
      Sources/Plasma/Apps/plUruLauncher/Main.cpp
  11. 1
      Sources/Plasma/Apps/plUruLauncher/Pch.h
  12. 41
      Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
  13. 8
      Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp
  14. 12
      Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp
  15. 116
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  16. 10
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp
  17. 1
      Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp
  18. 6
      Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp
  19. 48
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp
  20. 12
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.h
  21. 2
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationMgr.cpp
  22. 4
      Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationMgr.h
  23. 10
      Sources/Plasma/FeatureLib/pfMessage/pfMovieEventMsg.cpp
  24. 14
      Sources/Plasma/FeatureLib/pfMessage/pfMovieEventMsg.h
  25. 28
      Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp
  26. 11
      Sources/Plasma/FeatureLib/pfPython/cyMisc.h
  27. 44
      Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp
  28. 10
      Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp
  29. 25
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp
  30. 2
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.h
  31. 8
      Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp
  32. 34
      Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp
  33. 18
      Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.h
  34. 6
      Sources/Plasma/NucleusLib/pnMessage/plClientMsg.cpp
  35. 7
      Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h
  36. 4
      Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2File/pnNpCli2File.h
  37. 178
      Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp
  38. 86
      Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h
  39. 143
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp
  40. 45
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.h
  41. 14
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp
  42. 17
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.h
  43. 4
      Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp
  44. 4
      Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp
  45. 31
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  46. 6
      Sources/Plasma/PubUtilLib/plAudio/plSound.cpp
  47. 4
      Sources/Plasma/PubUtilLib/plAudio/plSound.h
  48. 12
      Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp
  49. 54
      Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp
  50. 16
      Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.h
  51. 46
      Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp
  52. 13
      Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.h
  53. 5
      Sources/Plasma/PubUtilLib/plAudioCore/plBufferedFileReader.cpp
  54. 8
      Sources/Plasma/PubUtilLib/plAudioCore/plBufferedFileReader.h
  55. 18
      Sources/Plasma/PubUtilLib/plAudioCore/plCachedFileReader.cpp
  56. 11
      Sources/Plasma/PubUtilLib/plAudioCore/plCachedFileReader.h
  57. 12
      Sources/Plasma/PubUtilLib/plAudioCore/plFastWavReader.cpp
  58. 11
      Sources/Plasma/PubUtilLib/plAudioCore/plFastWavReader.h
  59. 10
      Sources/Plasma/PubUtilLib/plAudioCore/plOGGCodec.cpp
  60. 21
      Sources/Plasma/PubUtilLib/plAudioCore/plOGGCodec.h
  61. 90
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp
  62. 35
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.h
  63. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  64. 2
      Sources/Plasma/PubUtilLib/plFile/CMakeLists.txt
  65. 5
      Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp
  66. 30
      Sources/Plasma/PubUtilLib/plFile/plBrowseFolder.cpp
  67. 3
      Sources/Plasma/PubUtilLib/plFile/plBrowseFolder.h
  68. 1
      Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp
  69. 503
      Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp
  70. 116
      Sources/Plasma/PubUtilLib/plFile/plFileUtils.h
  71. 1
      Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp
  72. 1
      Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp
  73. 6
      Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp
  74. 2
      Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.h
  75. 3
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp
  76. 12
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  77. 10
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h
  78. 34
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  79. 22
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h
  80. 4
      Sources/Plasma/PubUtilLib/plPipeline/plDynamicEnvMap.cpp
  81. 4
      Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp
  82. 36
      Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp
  83. 10
      Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h
  84. 39
      Sources/Plasma/PubUtilLib/plResMgr/plLocalization.cpp
  85. 11
      Sources/Plasma/PubUtilLib/plResMgr/plLocalization.h
  86. 1
      Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp
  87. 53
      Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp
  88. 24
      Sources/Plasma/PubUtilLib/plResMgr/plResManager.h
  89. 8
      Sources/Plasma/PubUtilLib/plSDL/plSDL.h
  90. 1
      Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp
  91. 1
      Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp
  92. 4
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
  93. 1
      Sources/Tools/MaxComponent/Pch.h
  94. 86
      Sources/Tools/MaxComponent/plAudioComponents.cpp
  95. 5
      Sources/Tools/MaxComponent/plAudioComponents.h
  96. 4
      Sources/Tools/MaxComponent/plGUIComponents.cpp
  97. 70
      Sources/Tools/MaxComponent/plMiscComponents.cpp
  98. 15
      Sources/Tools/MaxComponent/plMiscComponents.h
  99. 21
      Sources/Tools/MaxComponent/plResponderLink.cpp
  100. 12
      Sources/Tools/MaxConvert/hsMaterialConverter.cpp
  101. Some files were not shown because too many files have changed in this diff Show More

1
Sources/Plasma/Apps/plClient/plClient.cpp

@ -58,7 +58,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h"
#include "plPipeline/hsG3DDeviceSelector.h"
#include "plFile/plEncryptedStream.h"
#include "plFile/plFileUtils.h"
#include "plInputCore/plInputManager.h"
#include "plInputCore/plInputInterfaceMgr.h"
#include "plInputCore/plInputDevice.h"

3
Sources/Plasma/Apps/plClient/winmain.cpp

@ -75,7 +75,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h"
#include "plProduct.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plFile/plFileUtils.h"
#include "plPhysX/plSimulationMgr.h"
@ -542,7 +541,7 @@ bool InitClient( HWND hWnd )
resMgr->SetDataPath("dat");
hsgResMgr::Init(resMgr);
if(!plFileUtils::FileExists("resource.dat"))
if (!plFileInfo("resource.dat").Exists())
{
hsMessageBox("Required file 'resource.dat' not found.", "Error", hsMessageBoxNormal);
return false;

140
Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp

@ -66,21 +66,21 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct ManifestFile
{
ManifestFile(const wchar_t clientName[], const wchar_t downloadName[], const wchar_t md5val[], int flags, plLauncherInfo *info)
ManifestFile(const plFileName &clientName, const plFileName &downloadName, const plString &md5val, int flags, plLauncherInfo *info)
{
StrCopy(filename, clientName, arrsize(filename));
StrCopy(zipName, downloadName, arrsize(zipName));
StrCopy(md5, md5val, arrsize(md5));
filename = clientName;
zipName = downloadName;
md5 = md5val;
this->flags = flags;
this->info = info;
md5failed = false;
md5failed = false;
}
wchar_t filename[MAX_PATH];
wchar_t zipName[MAX_PATH];
wchar_t md5[MAX_PATH];
plFileName filename;
plFileName zipName;
plString md5;
int flags;
bool md5failed;
bool md5failed;
plLauncherInfo *info;
};
@ -117,10 +117,10 @@ struct ManifestResult {
static void DownloadCallback (
ENetError result,
void * param,
const wchar_t filename[],
hsStream * writer
ENetError result,
void * param,
const plFileName & filename,
hsStream * writer
);
@ -140,7 +140,7 @@ static unsigned s_fileListRequests;
static bool s_patchComplete;
static PROCESS_INFORMATION s_pi;
static long s_numFiles;
static char s_workingDir[MAX_PATH];
static plFileName s_workingDir;
static bool s_patchError;
static long s_asyncCoreInitCount;
static long s_numConnectFailures;
@ -179,9 +179,9 @@ double ProcessManifestEntryParam::startTime = 0;
// leaving clients with older patchers "dead in the water", without
// a way to play Uru.
#ifdef PLASMA_EXTERNAL_RELEASE
const wchar_t kPatcherExeFilename[] = L"UruLauncher.exe";
plFileName kPatcherExeFilename = "UruLauncher.exe";
#else
const wchar_t kPatcherExeFilename[] = L"plUruLauncher.exe";
plFileName kPatcherExeFilename = "plUruLauncher.exe";
#endif
@ -285,14 +285,11 @@ static void WaitUruExitProc (void * param) {
*/
//============================================================================
static bool MD5Check (const char filename[], const wchar_t md5[]) {
// Do md5 check
char md5copy[MAX_PATH];
static bool MD5Check (const plFileName& filename, const char *md5) {
plMD5Checksum existingMD5(filename);
plMD5Checksum latestMD5;
StrToAnsi(md5copy, md5, arrsize(md5copy));
latestMD5.SetFromHexString(md5copy);
latestMD5.SetFromHexString(md5);
return (existingMD5 == latestMD5);
}
@ -304,9 +301,8 @@ static void DecompressOgg (ManifestFile *mf) {
// decompress ogg if necessary
if ( (hsCheckBits(flags, plManifestFile::kSndFlagCacheSplit) || hsCheckBits(flags, plManifestFile::kSndFlagCacheStereo)) )
{
char path[MAX_PATH];
StrPrintf(path, arrsize(path), "%s%S", s_workingDir, mf->filename);
plFileName path = plFileName::Join(s_workingDir, mf->filename);
plAudioFileReader* reader = plAudioFileReader::CreateReader(path, plAudioCore::kAll, plAudioFileReader::kStreamNative);
if (!reader)
{
@ -355,12 +351,8 @@ static void RequestNextManifestFile () {
ManifestFile* nextfile = manifestQueue.front();
manifestQueue.pop();
char path[MAX_PATH];
wchar_t basePath[MAX_PATH];
StrPrintf(path, arrsize(path), "%s%S", s_workingDir, nextfile->filename);
StrToUnicode(basePath, path, arrsize(basePath));
PathRemoveFilename(basePath, basePath, arrsize(basePath));
PathCreateDirectory(basePath, kPathCreateDirFlagEntireTree);
plFileName path = plFileName::Join(s_workingDir, nextfile->filename);
plFileSystem::CreateDir(path.StripFileName(), true);
ProgressStream *writer = new ProgressStream(); // optimization: dont delete and recreate. Doesn't seem to be working currently, ZLibStream is breaking
if(!writer->Open(path, "wb"))
@ -374,7 +366,7 @@ static void RequestNextManifestFile () {
{
#ifndef PLASMA_EXTERNAL_RELEASE
char text[256];
StrPrintf(text, arrsize(text), "Updating URU... %S", nextfile->filename);
StrPrintf(text, arrsize(text), "Updating URU... %s", nextfile->filename.AsString().c_str());
nextfile->info->SetText(text);
#endif
NetCliFileDownloadRequest(nextfile->zipName, writer, DownloadCallback, nextfile, nextfile->info->buildId);
@ -383,19 +375,18 @@ static void RequestNextManifestFile () {
//============================================================================
static void DownloadCallback (
ENetError result,
void * param,
const wchar_t filename[],
hsStream * writer
ENetError result,
void * param,
const plFileName & filename,
hsStream * writer
) {
s_numConnectFailures = 0;
ManifestFile *mf = (ManifestFile *)param;
if (IS_NET_ERROR(result) && s_running && !s_patchError) {
if (result == kNetErrFileNotFound) {
char str[256];
StrPrintf(str, arrsize(str), "File not found on server: %S", filename);
MessageBox(nil, str, "URU Launcher", MB_ICONERROR);
plString str = plString::Format("File not found on server: %s", filename.AsString().c_str());
MessageBox(nil, str.c_str(), "URU Launcher", MB_ICONERROR);
s_patchError = true;
}
else if (result == kNetErrRemoteShutdown) {
@ -414,24 +405,17 @@ static void DownloadCallback (
writer->Close();
delete writer; // delete our stream
char path[MAX_PATH];
StrPrintf(
path,
arrsize(path),
"%s%S",
s_workingDir,
mf->filename
);
if(s_running)
plFileName path = plFileName::Join(s_workingDir, mf->filename);
if (s_running)
{
if(!MD5Check(path, mf->md5)) {
if(mf->md5failed)
if (!MD5Check(path, mf->md5.c_str())) {
if (mf->md5failed)
{
#ifdef PLASMA_EXTERNAL_RELEASE
MessageBox(nil, s_md5CheckError, "URU Launcher", MB_ICONERROR);
#else
char str[256];
StrPrintf(str, arrsize(str), "%s %s ", path, s_md5CheckError);
StrPrintf(str, arrsize(str), "%s %s ", path.AsString().c_str(), s_md5CheckError);
MessageBox(nil, str, "URU Launcher", MB_ICONERROR);
#endif // PLASMA_EXTERNAL_RELEASE
Shutdown(mf->info);
@ -442,7 +426,7 @@ static void DownloadCallback (
MessageBox(nil, s_fileOpenError, "URU Launcher", MB_ICONERROR);
#else
char str[256];
StrPrintf(str, arrsize(str), "%s %s", s_fileOpenError, path);
StrPrintf(str, arrsize(str), "%s %s", s_fileOpenError, path.AsString().c_str());
MessageBox(nil, str, "URU Launcher", MB_ICONERROR);
#endif // PLASMA_EXTERNAL_RELEASE
Shutdown(mf->info);
@ -456,11 +440,9 @@ static void DownloadCallback (
AtomicAdd(&s_numFiles, -1);
if(s_running)
if (s_running)
{
wchar_t ext[MAX_EXT];
PathSplitPath(mf->filename, nil, nil, nil, ext);
if(!StrCmpI(L".ogg", ext))
if (!mf->filename.GetFileExt().CompareI("ogg"))
{
DecompressOgg(mf);
}
@ -490,16 +472,9 @@ static void ProcessManifestEntry (void * param, ENetError error) {
StrPrintf(text, arrsize(text), "Checking for updates... %S", p->mr->manifest[p->index].clientName);
p->mr->info->SetText(text);
#endif
char path[MAX_PATH];
StrPrintf(
path,
arrsize(path),
"%s%S",
s_workingDir,
p->mr->manifest[p->index].clientName
);
plFileName path = plFileName::Join(s_workingDir, p->mr->manifest[p->index].clientName);
uint32_t start = (uint32_t)(TimeGetTime() / kTimeIntervalsPerMs);
if(!MD5Check(path, p->mr->manifest[p->index].md5)) {
if (!MD5Check(path, p->mr->manifest[p->index].md5.c_str())) {
p->mr->critsect.Lock();
p->mr->indices.Add(p->index);
p->mr->critsect.Unlock();
@ -547,10 +522,8 @@ static void ProcessManifest (void * param) {
VLDEnable();
#endif
wchar_t basePath[MAX_PATH];
char path[MAX_PATH];
AtomicAdd(&s_perf[kPerfThreadTaskCount], 1);
ManifestResult * mr = (ManifestResult *)param;
PatchInfo patchInfo;
@ -574,14 +547,13 @@ static void ProcessManifest (void * param) {
p->index = i;
p->mr = mr;
p->exists = false;
StrPrintf(path, arrsize(path), "%s%S", s_workingDir, mr->manifest[i].clientName);
fd = fopen(path, "r");
if(fd)
plFileName path = plFileName::Join(s_workingDir, mr->manifest[i].clientName);
fd = plFileSystem::Open(path, "r");
if (fd)
{
p->exists = true;
p->totalSize += p->mr->manifest[i].zipSize;
fclose(fd);
}
}
@ -617,10 +589,8 @@ static void ProcessManifest (void * param) {
if(s_running)
{
unsigned index = mr->indices[i];
StrPrintf(path, arrsize(path), "%s%S", s_workingDir, manifest[index].clientName);
StrToUnicode(basePath, path, arrsize(basePath));
PathRemoveFilename(basePath, basePath, arrsize(basePath));
PathCreateDirectory(basePath, kPathCreateDirFlagEntireTree);
plFileName path = plFileName::Join(s_workingDir, manifest[index].clientName);
plFileSystem::CreateDir(path.StripFileName(), true);
ManifestFile* mf = new ManifestFile(
manifest[index].clientName,
@ -637,7 +607,7 @@ static void ProcessManifest (void * param) {
MessageBox(nil, s_fileOpenError, "URU Launcher", MB_ICONERROR);
#else
char str[256];
StrPrintf(str, arrsize(str), "%s %s", path, s_fileOpenError);
StrPrintf(str, arrsize(str), "%s %s", path.AsString().c_str(), s_fileOpenError);
MessageBox(nil, str, "URU Launcher", MB_ICONERROR);
#endif
Shutdown(mr->info);
@ -711,10 +681,10 @@ static void ManifestCallback (
noDuplicates.Reserve(mr->manifest.Count());
for(unsigned i = 0; i < entryCount - 1; ++i)
{
if(StrCmp(mr->manifest[i].clientName, mr->manifest[i+1].clientName))
if (mr->manifest[i].clientName != mr->manifest[i+1].clientName)
{
noDuplicates.Add(mr->manifest[i]);
}
}
}
noDuplicates.Add(mr->manifest[entryCount - 1]);
@ -759,11 +729,12 @@ static void ThinManifestCallback (
return;
}
s_patchComplete = true;
char path[MAX_PATH];
for (unsigned i = 0; i < entryCount; ++i) {
if(!s_running) return;
StrPrintf(path, arrsize(path), "%s%S", s_workingDir, manifest[i].clientName);
if(!MD5Check(path, manifest[i].md5)){
if (!s_running)
return;
plFileName path = plFileName::Join(s_workingDir, manifest[i].clientName);
if (!MD5Check(path, manifest[i].md5.c_str())) {
s_patchComplete = false;
NetCliFileManifestRequest(ManifestCallback, info, s_manifest, info->buildId);
break;
@ -775,7 +746,7 @@ static void ThinManifestCallback (
info->progressCallback(kStatusPending, &patchInfo);
#ifndef PLASMA_EXTERNAL_RELEASE
char text[256];
StrPrintf(text, arrsize(text), "Checking for updates... %S", manifest[i].clientName);
StrPrintf(text, arrsize(text), "Checking for updates... %s", manifest[i].clientName.AsString().c_str());
info->SetText(text);
#endif
}
@ -894,9 +865,8 @@ void UruPrepProc (void * param) {
s_running = true;
plLauncherInfo *info = (plLauncherInfo *) param;
s_workingDir = plString::FromWchar(info->path);
StrToAnsi(s_workingDir, info->path, arrsize(s_workingDir));
InitAsyncCore();
NetClientInitialize();
NetClientSetErrorHandler(NetErrorHandler);

2
Sources/Plasma/Apps/plClientPatcher/UruPlayer.h

@ -64,4 +64,4 @@ void UruStartProc (void * param);
void PlayerTerminateProc (void * param);
void PlayerStopProc (void * param);
extern const wchar_t kPatcherExeFilename[];
extern plFileName kPatcherExeFilename;

1
Sources/Plasma/Apps/plFileSecure/main.cpp

@ -40,7 +40,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plFile/plSecureStream.h"
#include "plProduct.h"

32
Sources/Plasma/Apps/plPageInfo/plPageInfo.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h"
@ -61,7 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
plResManager* gResMgr = nil;
bool DumpStats(const char* patchDir);
bool DumpStats(const plFileName& patchDir);
bool DumpSounds();
//// PrintVersion ///////////////////////////////////////////////////////////////
@ -117,7 +116,7 @@ int main(int argc, char* argv[])
}
// Make sure we have 1 arg left after getting the options
char* pageFile = nil;
plFileName pageFile;
if (arg < argc)
pageFile = argv[arg];
else
@ -134,12 +133,7 @@ int main(int argc, char* argv[])
if (sounds)
DumpSounds();
if (stats)
{
char path[256];
strcpy(path, pageFile);
plFileUtils::StripFile(path);
DumpStats(path);
}
DumpStats(pageFile.StripFileName());
hsgResMgr::Shutdown();
@ -180,12 +174,12 @@ bool DumpSounds()
buffer->GetKey()->RefObject();
// Get the filename from it and add that file if necessary
const char* filename = buffer->GetFileName();
if (filename)
plFileName filename = buffer->GetFileName();
if (filename.IsValid())
{
uint32_t flags = 0;
if (stricmp(plFileUtils::GetFileExt(filename), "wav") != 0)
if (filename.GetFileExt().CompareI("wav") != 0)
{
if (buffer->HasFlag(plSoundBuffer::kOnlyLeftChannel) ||
buffer->HasFlag(plSoundBuffer::kOnlyRightChannel))
@ -196,9 +190,9 @@ bool DumpSounds()
hsSetBits(flags, plManifestFile::kSndFlagCacheStereo);
}
printf("%s,%u\n", filename, flags);
printf("%s,%u\n", filename.AsString().c_str(), flags);
}
// Unref the object so it goes away
buffer->GetKey()->UnRefObject();
}
@ -218,11 +212,11 @@ bool DumpSounds()
class plStatDumpIterator : public plRegistryPageIterator, public plRegistryKeyIterator
{
protected:
const char* fOutputDir;
plFileName fOutputDir;
hsUNIXStream fStream;
public:
plStatDumpIterator(const char* outputDir) : fOutputDir(outputDir) {}
plStatDumpIterator(const plFileName& outputDir) : fOutputDir(outputDir) {}
bool EatKey(const plKey& key)
{
@ -246,8 +240,8 @@ public:
{
const plPageInfo& info = page->GetPageInfo();
char fileName[256];
sprintf(fileName, "%s%s_%s.csv", fOutputDir, info.GetAge().c_str(), info.GetPage().c_str());
plFileName fileName = plFileName::Join(fOutputDir,
plString::Format("%s_%s.csv", info.GetAge().c_str(), info.GetPage().c_str()));
fStream.Open(fileName, "wt");
page->LoadKeys();
@ -259,7 +253,7 @@ public:
}
};
bool DumpStats(const char* patchDir)
bool DumpStats(const plFileName& patchDir)
{
plStatDumpIterator statDump(patchDir);
gResMgr->IterateAllPages(&statDump);

4
Sources/Plasma/Apps/plPageOptimizer/main.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plResManager.h"
#include "plPageOptimizer.h"
#include "plFile/plFileUtils.h"
#include "pnNetCommon/plSynchedObject.h"
int main(int argc, char* argv[])
@ -53,7 +52,8 @@ int main(int argc, char* argv[])
return 1;
}
printf("Optimizing %s...", plFileUtils::GetFileName(argv[1]));
plFileName filename = argv[1];
printf("Optimizing %s...", filename.GetFileName().c_str());
#ifndef _DEBUG
try {

19
Sources/Plasma/Apps/plPageOptimizer/plPageOptimizer.cpp

@ -50,21 +50,18 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnFactory/plFactory.h"
#include "pnKeyedObject/plKeyImp.h"
#include "plFile/plFileUtils.h"
#include "hsStream.h"
plPageOptimizer* plPageOptimizer::fInstance = nil;
plPageOptimizer::plPageOptimizer(const char* pagePath) :
plPageOptimizer::plPageOptimizer(const plFileName& pagePath) :
fOptimized(true),
fPageNode(nil),
fPagePath(pagePath)
{
fInstance = this;
strcpy(fTempPagePath, fPagePath);
plFileUtils::StripExt(fTempPagePath);
strcat(fTempPagePath, "_opt.prp");
fTempPagePath = fPagePath.StripFileExt() + "_opt.prp";
fResMgr = (plResManager*)hsgResMgr::ResMgr();
}
@ -135,8 +132,8 @@ void plPageOptimizer::Optimize()
if (loaded)
IRewritePage();
uint32_t oldSize = plFileUtils::GetFileSize(fPagePath);
uint32_t newSize = plFileUtils::GetFileSize(fTempPagePath);
uint64_t oldSize = plFileInfo(fPagePath).FileSize();
uint64_t newSize = plFileInfo(fTempPagePath).FileSize();
if (!loaded)
{
@ -144,19 +141,19 @@ void plPageOptimizer::Optimize()
}
else if (fOptimized)
{
plFileUtils::RemoveFile(fTempPagePath);
plFileSystem::Unlink(fTempPagePath);
puts("already optimized.");
}
else if (oldSize == newSize)
{
plFileUtils::RemoveFile(fPagePath, true);
plFileUtils::FileMove(fTempPagePath, fPagePath);
plFileSystem::Unlink(fPagePath);
plFileSystem::Move(fTempPagePath, fPagePath);
puts("complete");
}
else
{
plFileUtils::RemoveFile(fTempPagePath);
plFileSystem::Unlink(fTempPagePath);
puts("failed. File sizes different");
}
}

7
Sources/Plasma/Apps/plPageOptimizer/plPageOptimizer.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKey.h"
#include "pnKeyedObject/plUoid.h"
#include "plFileSystem.h"
#include <vector>
#include <set>
@ -63,8 +64,8 @@ protected:
bool fOptimized; // True after optimization if the page was already optimized
const char* fPagePath; // Path to our page
char fTempPagePath[512]; // Path to the temp output page
plFileName fPagePath; // Path to our page
plFileName fTempPagePath; // Path to the temp output page
plLocation fLoc; // Location of our page
plRegistryPageNode* fPageNode; // PageNode for our page
@ -78,7 +79,7 @@ protected:
void IRewritePage();
public:
plPageOptimizer(const char* pagePath);
plPageOptimizer(const plFileName& pagePath);
void Optimize();
};

32
Sources/Plasma/Apps/plUruLauncher/Main.cpp

@ -601,7 +601,7 @@ static const CmdArgDef s_cmdLineArgs[] = {
PF_CONSOLE_LINK_FILE(Core)
//============================================================================
int __stdcall WinMain (
int __stdcall WinMain (
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
@ -619,18 +619,15 @@ int __stdcall WinMain (
while (*appCmdLine == L' ')
++appCmdLine;
wchar_t curPatcherFile[MAX_PATH];
wchar_t newPatcherFile[MAX_PATH];
bool isTempPatcher = false;
PathGetProgramName(curPatcherFile, arrsize(curPatcherFile));
PathRemoveFilename(newPatcherFile, curPatcherFile, arrsize(newPatcherFile));
PathAddFilename(newPatcherFile, newPatcherFile, kPatcherExeFilename, arrsize(newPatcherFile));
plFileName curPatcherFile = plFileSystem::GetCurrentAppPath();
plFileName newPatcherFile = plFileName::Join(curPatcherFile.StripFileName(), kPatcherExeFilename);
// If our exe name doesn't match the "real" patcher exe name, then we are a newly
// downloaded patcher that needs to be copied over to the "real" exe.. so do that,
// exec it, and exit.
if (0 != StrCmpI(curPatcherFile, newPatcherFile)) {
if (0 != curPatcherFile.AsString().CompareI(newPatcherFile.AsString())) {
isTempPatcher = true;
}
@ -683,12 +680,12 @@ int __stdcall WinMain (
for (;;) {
// Wait for previous process to exit. This will happen if we just patched.
HANDLE mutex = CreateMutexW(NULL, TRUE, kPatcherExeFilename);
HANDLE mutex = CreateMutexW(NULL, TRUE, kPatcherExeFilename.AsString().ToWchar());
DWORD wait = WaitForSingleObject(mutex, 0);
while(!s_shutdown && wait != WAIT_OBJECT_0)
wait = WaitForSingleObject(mutex, 100);
// User canceled
// User canceled
if (s_shutdown)
break;
@ -701,7 +698,7 @@ int __stdcall WinMain (
// Wait for the other process to exit
Sleep(1000);
if (!plFileUtils::RemoveFile(newPatcherFile)) {
if (!plFileSystem::Unlink(newPatcherFile)) {
wchar_t error[256];
DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode);
@ -711,7 +708,7 @@ int __stdcall WinMain (
LocalFree(msg);
break;
}
if (!plFileUtils::FileMove(curPatcherFile, newPatcherFile)) {
if (!plFileSystem::Move(curPatcherFile, newPatcherFile)) {
wchar_t error[256];
DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode);
@ -719,7 +716,7 @@ int __stdcall WinMain (
StrPrintf(error, arrsize(error), L"Failed to replace old patcher executable. %s", msg);
MessageBoxW(GetTopWindow(nil), error, L"Error", MB_OK);
// attempt to clean up this tmp file
plFileUtils::RemoveFile(curPatcherFile);
plFileSystem::Unlink(curPatcherFile);
LocalFree(msg);
break;
}
@ -732,7 +729,7 @@ int __stdcall WinMain (
si.cb = sizeof(si);
wchar_t cmdline[MAX_PATH];
StrPrintf(cmdline, arrsize(cmdline), L"%s %s", newPatcherFile, s_launcherInfo.cmdLine);
StrPrintf(cmdline, arrsize(cmdline), L"%S %s", newPatcherFile.AsString().c_str(), s_launcherInfo.cmdLine);
// we have only successfully patched if we actually launch the new version of the patcher
(void)CreateProcessW(
@ -758,12 +755,11 @@ int __stdcall WinMain (
// Clean up old temp files
ARRAY(PathFind) paths;
wchar_t fileSpec[MAX_PATH];
PathGetProgramDirectory(fileSpec, arrsize(fileSpec));
PathAddFilename(fileSpec, fileSpec, L"*.tmp", arrsize(fileSpec));
PathFindFiles(&paths, fileSpec, kPathFlagFile);
plFileName fileSpec = plFileSystem::GetCurrentAppPath().StripFileName();
fileSpec = plFileName::Join(fileSpec, "*.tmp");
PathFindFiles(&paths, fileSpec.AsString().ToWchar(), kPathFlagFile);
for (PathFind * path = paths.Ptr(); path != paths.Term(); ++path)
plFileUtils::RemoveFile(path->name);
plFileSystem::Unlink(plString::FromWchar(path->name));
SetConsoleCtrlHandler(CtrlHandler, TRUE);
InitAsyncCore(); // must do this before self patch, since it needs to connect to the file server

1
Sources/Plasma/Apps/plUruLauncher/Pch.h

@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h"

41
Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp

@ -77,7 +77,7 @@ static bool s_downloadComplete;
static long s_numFiles;
static ENetError s_patchResult;
static bool s_updated;
static wchar_t s_newPatcherFile[MAX_PATH];
static plFileName s_newPatcherFile;
/*****************************************************************************
@ -106,10 +106,10 @@ static void NetErrorHandler (ENetProtocol protocol, ENetError error) {
//============================================================================
static void DownloadCallback (
ENetError result,
void * param,
const wchar_t filename[],
hsStream * writer
ENetError result,
void * param,
const plFileName & filename,
hsStream * writer
) {
if(IS_NET_ERROR(result)) {
switch (result) {
@ -140,14 +140,12 @@ static void DownloadCallback (
}
//============================================================================
static bool MD5Check (const char filename[], const wchar_t md5[]) {
static bool MD5Check (const plFileName &filename, const char *md5) {
// Do md5 check
char md5copy[MAX_PATH];
plMD5Checksum existingMD5(filename);
plMD5Checksum latestMD5;
StrToAnsi(md5copy, md5, arrsize(md5copy));
latestMD5.SetFromHexString(md5copy);
latestMD5.SetFromHexString(md5);
return (existingMD5 == latestMD5);
}
@ -155,7 +153,7 @@ static bool MD5Check (const char filename[], const wchar_t md5[]) {
static void ManifestCallback (
ENetError result,
void * param,
const wchar_t group[],
const wchar_t group[],
const NetCliFileManifestEntry manifest[],
unsigned entryCount
) {
@ -183,24 +181,19 @@ static void ManifestCallback (
}
#endif
char ansi[MAX_PATH];
// MD5 check current patcher against value in manifest
ASSERT(entryCount == 1);
wchar_t curPatcherFile[MAX_PATH];
PathGetProgramName(curPatcherFile, arrsize(curPatcherFile));
StrToAnsi(ansi, curPatcherFile, arrsize(ansi));
if (!MD5Check(ansi, manifest[0].md5)) {
plFileName curPatcherFile = plFileSystem::GetCurrentAppPath();
if (!MD5Check(curPatcherFile, manifest[0].md5.c_str())) {
// MessageBox(GetTopWindow(nil), "MD5 failed", "Msg", MB_OK);
SelfPatcherStream::totalBytes += manifest[0].zipSize;
AtomicAdd(&s_numFiles, 1);
SetText("Downloading new patcher...");
StrToAnsi(ansi, s_newPatcherFile, arrsize(ansi));
SelfPatcherStream * stream = new SelfPatcherStream;
if (!stream->Open(ansi, "wb"))
ErrorAssert(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", ansi, errno);
if (!stream->Open(s_newPatcherFile, "wb"))
ErrorAssert(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", s_newPatcherFile.AsString().c_str(), errno);
NetCliFileDownloadRequest(manifest[0].downloadName, stream, DownloadCallback, nil);
}
@ -213,7 +206,7 @@ static void ManifestCallback (
static void FileSrvIpAddressCallback (
ENetError result,
void * param,
const wchar_t addr[]
const wchar_t addr[]
) {
NetCliGateKeeperDisconnect();
@ -230,9 +223,9 @@ static void FileSrvIpAddressCallback (
NetCliFileStartConnect(&caddr, 1, true);
delete[] caddr;
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
plFileUtils::RemoveFile(s_newPatcherFile);
s_newPatcherFile = plFileSystem::GetCurrentAppPath().StripFileName();
s_newPatcherFile = plFileSystem::GetTempFilename(kPatcherExeFilename.AsString().c_str(), s_newPatcherFile);
plFileSystem::Unlink(s_newPatcherFile);
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
}
@ -279,7 +272,7 @@ static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
si.cb = sizeof(si);
wchar_t cmdline[MAX_PATH];
StrPrintf(cmdline, arrsize(cmdline), L"%s %s", s_newPatcherFile, info->cmdLine);
StrPrintf(cmdline, arrsize(cmdline), L"%s %s", s_newPatcherFile.AsString().ToWchar(), info->cmdLine);
// we have only successfully patched if we actually launch the new version of the patcher
patched = CreateProcessW(

8
Sources/Plasma/FeatureLib/pfCamera/plVirtualCamNeu.cpp

@ -187,16 +187,10 @@ plVirtualCam1::plVirtualCam1()
#ifndef PLASMA_EXTERNAL_RELEASE
// only open log file if logging is on
if ( !plStatusLog::fLoggingOff )
{
wchar_t fileAndPath[MAX_PATH];
PathGetLogDirectory(fileAndPath, arrsize(fileAndPath));
PathAddFilename(fileAndPath, fileAndPath, L"camLog.txt", arrsize(fileAndPath));
foutLog = hsWFopen( fileAndPath, L"wt" );
}
foutLog = plFileSystem::Open(plFileName::Join(plFileSystem::GetLogPath(), "camLog.txt"), "wt");
#endif
SetFlags(kFirstPersonEnabled);
}
plVirtualCam1::~plVirtualCam1()

12
Sources/Plasma/FeatureLib/pfConsole/pfAvatarConsoleCommands.cpp

@ -112,9 +112,9 @@ PF_CONSOLE_FILE_DUMMY(Avatar)
//
/////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -361,7 +361,7 @@ PF_CONSOLE_CMD( Avatar_Turn, SetMouseTurnSensitivity, "float sensitivity", "Set
PF_CONSOLE_CMD( Avatar_Multistage, Trigger, "string multiComp", "Triggers the named Multistage Animation component")
{
char str[256];
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plMultistageBehMod", nil, str, true);
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plMultistageBehMod", "", str, true);
PrintString(str);
if (key)
@ -499,7 +499,7 @@ PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpo
if(avatar)
{
char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff);
plKey seekKey = FindSceneObjectByName(spName, "", buff);
plSeekPointMod *mod = plAvatarMgr::GetInstance()->FindSeekPoint(spName);
if(mod)
@ -596,7 +596,7 @@ PF_CONSOLE_CMD( Avatar, FakeLinkToObj, "string objName", "Pseudo-Link the avatar
{
plString spName = plString::FromUtf8(params[0]);
char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff);
plKey seekKey = FindSceneObjectByName(spName, "", buff);
if (!seekKey)
{
PrintString("Can't find object with that name, fake link failed.");

116
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -263,9 +263,9 @@ PF_CONSOLE_FILE_DUMMY(Main)
// utility functions
//
//////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -273,7 +273,7 @@ void PrintStringF(void pfun(const char *),const char * fmt, ...);
// Find an object from name, type (int), and optionally age.
// Name can be an alias specified by saying $foo
//
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString)
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString)
{
if (name.IsNull())
{
@ -293,22 +293,22 @@ plKey FindObjectByName(const plString& name, int type, const char* ageName, char
// Try restricted to our age first, if we're not given an age name. This works
// around most of the problems associated with unused keys in pages causing the pages to be marked
// as not loaded and thus screwing up our searches
if( ageName == nil && plNetClientMgr::GetInstance() != nil )
if (ageName.IsNull() && plNetClientMgr::GetInstance() != nil)
{
const char *thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if (thisAge != nil)
plString thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if (!thisAge.IsNull())
{
key = plKeyFinder::Instance().StupidSearch(thisAge, nil, type, name, subString);
key = plKeyFinder::Instance().StupidSearch(thisAge, "", type, name, subString);
if (key != nil)
{
if (statusStr)
if (statusStr)
sprintf(statusStr, "Found Object");
return key;
}
}
}
// Fallback
key = plKeyFinder::Instance().StupidSearch(ageName,nil,type, name, subString);
key = plKeyFinder::Instance().StupidSearch(ageName, "", type, name, subString);
if (!key)
{
@ -334,7 +334,7 @@ plKey FindObjectByName(const plString& name, int type, const char* ageName, char
// Name can be an alias specified by saying $foo.
// Will load the object if necessary.
//
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString)
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString)
{
plKey key=FindObjectByName(name, plSceneObject::Index(), ageName, statusStr, subString);
@ -352,7 +352,7 @@ plKey FindSceneObjectByName(const plString& name, const char* ageName, char* sta
// Find an object from name, type (string) and optionally age.
// Name can be an alias specified by saying $foo
//
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString)
{
if (!typeName)
@ -1579,8 +1579,8 @@ PF_CONSOLE_CMD( Graphics_Renderer, GrabCubeMap,
"Take cubemap from sceneObject's position and name it prefix_XX.jpg")
{
char str[512];
plString objName = plString::FromUtf8(params[0]);
plKey key = FindSceneObjectByName(objName, nil, str);
plString objName = static_cast<const char *>(params[0]);
plKey key = FindSceneObjectByName(objName, "", str);
PrintString( str );
if( !key )
return;
@ -1841,7 +1841,7 @@ PF_CONSOLE_CMD( Graphics_Show, SingleSound,
{
char str[ 512 ];
const char *ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
plString ageName = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
plKey key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), ageName, str, true );
plSceneObject *obj = ( key != nil ) ? plSceneObject::ConvertNoRef( key->GetObjectPtr() ) : nil;
@ -2175,7 +2175,7 @@ PF_CONSOLE_CMD( App,
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj )
{
@ -2252,7 +2252,7 @@ PF_CONSOLE_CMD( App,
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
plSceneObject* obj = plSceneObject::ConvertNoRef(key->GetObjectPtr());
if( !obj )
{
@ -2307,7 +2307,7 @@ PF_CONSOLE_CMD( App,
{
char str[256];
plString name = plString::FromUtf8(params[0]);
plKey key = FindSceneObjectByName(name, nil, str);
plKey key = FindSceneObjectByName(name, "", str);
if( !key )
{
sprintf(str, "%s - Not Found!", name.c_str());
@ -2773,7 +2773,7 @@ PF_CONSOLE_CMD( Registry, ListRefs, "string keyType, string keyName", "For the g
"the objects who currently have active refs on it." )
{
char result[ 256 ];
plKey obj = FindObjectByNameAndType( plString::FromUtf8( params[ 1 ] ), params[ 0 ], nil, result);
plKey obj = FindObjectByNameAndType( plString::FromUtf8( params[ 1 ] ), params[ 0 ], "", result);
if( obj == nil )
{
PrintString( result );
@ -2950,7 +2950,7 @@ PF_CONSOLE_CMD( Camera, SwitchTo, "string cameraName", "Switch to the named came
{
char str[256];
plString foo = plString::Format("%s_", (char*)params[0]);
plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", nil, str, true);
plKey key = FindObjectByNameAndType(foo, "plCameraModifier1", "", str, true);
PrintString(str);
if (key)
@ -3076,7 +3076,7 @@ PF_CONSOLE_GROUP( Logic )
static plLogicModBase *FindLogicMod(const plString &name)
{
char str[256];
plKey key = FindObjectByNameAndType(name, "plLogicModifier", nil, str, true);
plKey key = FindObjectByNameAndType(name, "plLogicModifier", "", str, true);
pfConsole::AddLine(str);
if (key)
@ -3173,7 +3173,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponderNum, "int responderNum, ...", "Triggers t
}
char str[256];
plKey key = FindObjectByNameAndType(responderNames[responderNum-1], "plResponderModifier", nil, str, true);
plKey key = FindObjectByNameAndType(responderNames[responderNum-1], "plResponderModifier", "", str, true);
PrintString(str);
if (key)
@ -3189,7 +3189,7 @@ PF_CONSOLE_CMD( Logic, TriggerResponder, "string responderComp, ...", "Triggers
}
char str[256];
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true);
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", "", str, true);
PrintString(str);
int responderState = -1;
@ -3211,7 +3211,7 @@ PF_CONSOLE_CMD( Logic, FastForwardResponder, "string responderComp, ...", "Fastf
}
char str[256];
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", nil, str, true);
plKey key = FindObjectByNameAndType(plString::FromUtf8(params[0]), "plResponderModifier", "", str, true);
PrintString(str);
int responderState = -1;
@ -3522,7 +3522,7 @@ PF_CONSOLE_CMD( Audio, SetVolume,
"string obj, float vol", "Sets the volume on a given object. 1 is max volume, 0 is silence" )
{
char str[ 256 ];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[ 0 ]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[ 0 ]), "", str);
if( key == nil )
return;
@ -3551,7 +3551,7 @@ PF_CONSOLE_CMD( Audio, IsolateSound,
plKey key;
plAudioSysMsg *asMsg;
key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), nil, str );
key = FindSceneObjectByName( plString::FromUtf8( params[ 0 ] ), "", str );
if( key == nil )
{
sprintf( str, "Cannot find sound %s", (char *)params[ 0 ] );
@ -3928,7 +3928,7 @@ PF_CONSOLE_CMD( Nav, PageInNode, // Group name, Function name
plSynchEnabler ps(false); // disable dirty tracking while paging in
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoom);
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, params[0]));
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", static_cast<const char *>(params[0])));
plgDispatch::MsgSend(pMsg1);
}
@ -3951,7 +3951,7 @@ PF_CONSOLE_CMD( Nav, PageInNodeList, // Group name, Function name
{
char nodeName[255];
_splitpath(pageInNodesIter.GetFileName(), NULL, NULL, nodeName, NULL);
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, nodeName));
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName));
}
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
plgDispatch::MsgSend(pMsg1);
@ -3968,7 +3968,7 @@ PF_CONSOLE_CMD( Nav, PageOutNode, // Group name, Function name
plSynchEnabler ps(false); // disable dirty tracking while paging out
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kUnloadRoom);
pMsg1->AddReceiver( plClient::GetInstance()->GetKey() );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, params[0]));
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", static_cast<const char *>(params[0])));
plgDispatch::MsgSend(pMsg1);
}
@ -3977,7 +3977,7 @@ PF_CONSOLE_CMD( Nav, UnloadPlayer, // Group name, Function name
"unloads a named player" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
PrintString("UnloadPlayer (console version) is currently broken. Hassle Matt.");
// plNetClientMgr::UnloadPlayer(key);
}
@ -3995,12 +3995,12 @@ PF_CONSOLE_CMD( Nav, MovePlayer, // Group name, Function name
"moves a player from one paging unit to another" ) // Help string
{
char str[256];
plKey playerKey = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey playerKey = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if( !playerKey )
return;
plKey nodeKey = FindObjectByName(plString::FromUtf8(params[1]), plSceneNode::Index(), nil, str);
plKey nodeKey = FindObjectByName(static_cast<const char *>(params[1]), plSceneNode::Index(), "", str);
PrintString(str);
if( !nodeKey )
return;
@ -4307,7 +4307,7 @@ PF_CONSOLE_CMD( Access,
char str[256];
char* preFix = params[0];
plString name = plString::Format("%s_plMorphSequence_0", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str);
PrintString(str);
if (!key)
return;
@ -4332,7 +4332,7 @@ PF_CONSOLE_CMD( Access,
char str[256];
char* preFix = params[0];
plString name = plString::Format("%s_plMorphSequence_2", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str);
PrintString(str);
if (!key)
return;
@ -4353,7 +4353,7 @@ PF_CONSOLE_CMD( Access,
char str[256];
char* preFix = params[0];
plString name = plString::Format("%s_plMorphSequence_2", preFix);
plKey key = FindObjectByName(name, plMorphSequence::Index(), nil, str);
plKey key = FindObjectByName(name, plMorphSequence::Index(), "", str);
PrintString(str);
if (!key)
return;
@ -4572,7 +4572,7 @@ PF_CONSOLE_CMD( Access,
"Test fading on visibility" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), "", str);
PrintString(str);
if( !key )
return;
@ -4604,7 +4604,7 @@ PF_CONSOLE_CMD( Access,
"Set the los test marker" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if( !key )
return;
@ -4618,7 +4618,7 @@ PF_CONSOLE_CMD( Access,
"Set the Los hack marker" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
plSceneObject* so = nil;
@ -4693,7 +4693,7 @@ PF_CONSOLE_CMD( Access,
"Fire shot along gun's z-axis, creating decal of radius <radius>, with optional max-range (def 1000)" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if( !key )
return;
@ -4774,7 +4774,7 @@ PF_CONSOLE_CMD( Access,
"Add particle system <psys> to bulletMgr <bull>")
{
char str[256];
plKey bullKey = FindObjectByName(plString::FromUtf8(params[0]), plDynaBulletMgr::Index(), nil, str, false);
plKey bullKey = FindObjectByName(static_cast<const char *>(params[0]), plDynaBulletMgr::Index(), "", str, false);
PrintString(str);
if( !(bullKey && bullKey->GetObjectPtr()) )
{
@ -4782,7 +4782,7 @@ PF_CONSOLE_CMD( Access,
return;
}
plKey sysKey = FindSceneObjectByName(plString::FromUtf8(params[1]), nil, str);
plKey sysKey = FindSceneObjectByName(static_cast<const char *>(params[1]), "", str);
if( !(sysKey && sysKey->GetObjectPtr()) )
{
PrintString("Psys not found");
@ -4982,7 +4982,7 @@ static void IDisplayWaveVal(PrintFunk PrintString, plWaveSet7* wave, plWaveCmd::
static plWaveSet7* IGetWaveSet(PrintFunk PrintString, const plString& name)
{
char str[256];
plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), nil, str, false);
plKey waveKey = FindObjectByName(name, plWaveSet7::Index(), "", str, false);
PrintString(str);
if (!waveKey)
return nil;
@ -5463,7 +5463,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Drawable, // Group name, Function name
"Enable or disable drawing of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5482,7 +5482,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Physical, // Group name, Function name
"Enable or disable the physical of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5524,7 +5524,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, Audible, // Group name, Function name
"Enable or disable the audible of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5543,7 +5543,7 @@ PF_CONSOLE_CMD( SceneObject_SetEnable, All, // Group name, Function name
"Enable or disable all fxns of a sceneobject" ) // Help string
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;
@ -5563,10 +5563,10 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name
{
char str[256];
plString childName = plString::FromUtf8(params[0]);
plString parentName = plString::FromUtf8(params[1]);
plString childName = static_cast<const char *>(params[0]);
plString parentName = static_cast<const char *>(params[1]);
plKey childKey = FindSceneObjectByName(childName, nil, str);
plKey childKey = FindSceneObjectByName(childName, "", str);
if( !childKey )
{
PrintString(str);
@ -5580,7 +5580,7 @@ PF_CONSOLE_CMD( SceneObject, Attach, // Group name, Function name
return;
}
plKey parentKey = FindSceneObjectByName(parentName, nil, str);
plKey parentKey = FindSceneObjectByName(parentName, "", str);
if( !parentKey )
{
PrintString(str);
@ -5601,9 +5601,9 @@ PF_CONSOLE_CMD( SceneObject, Detach, // Group name, Function name
{
char str[256];
plString childName = plString::FromUtf8(params[0]);
plString childName = static_cast<const char *>(params[0]);
plKey childKey = FindSceneObjectByName(childName, nil, str);
plKey childKey = FindSceneObjectByName(childName, "", str);
if( !childKey )
{
PrintString(str);
@ -6186,7 +6186,7 @@ PF_CONSOLE_GROUP( ParticleSystem ) // Defines a main command group
void UpdateParticleParam(const plString &objName, int32_t paramID, float value, void (*PrintString)(const char *))
{
char str[256];
plKey key = FindSceneObjectByName(objName, nil, str);
plKey key = FindSceneObjectByName(objName, "", str);
PrintString(str);
if (key == nil) return;
@ -6309,7 +6309,7 @@ PF_CONSOLE_CMD( ParticleSystem,
"Creates a system (if necessary) on the avatar, and transfers particles" )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
if (key == nil)
return;
@ -6317,7 +6317,7 @@ PF_CONSOLE_CMD( ParticleSystem,
if (so == nil)
return;
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
plArmatureMod *avMod = plAvatarMgr::GetInstance()->GetLocalAvatar();
if (avMod)
(new plParticleTransferMsg(nil, avMod->GetKey(), 0, so->GetKey(), (int)params[1]))->Send();
}
@ -6328,7 +6328,7 @@ PF_CONSOLE_CMD( ParticleSystem,
"Flag some particles for death." )
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
if (key == nil)
return;
@ -6350,7 +6350,7 @@ PF_CONSOLE_SUBGROUP( ParticleSystem, Flock )
static plParticleFlockEffect *FindFlock(const plString &objName)
{
char str[256];
plKey key = FindSceneObjectByName(objName, nil, str);
plKey key = FindSceneObjectByName(objName, "", str);
if (key == nil)
return nil;
@ -6528,7 +6528,7 @@ PF_CONSOLE_GROUP( Animation ) // Defines a main command group
void SendAnimCmdMsg(const plString &objName, plMessage *msg)
{
char str[256];
plKey key = FindSceneObjectByName(objName, nil, str);
plKey key = FindSceneObjectByName(objName, "", str);
if (key != nil)
{
msg->AddReceiver(key);

10
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommandsNet.cpp

@ -196,9 +196,9 @@ PF_CONSOLE_FILE_DUMMY(Net)
// utility functions
//
//////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const char* ageName,
plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -507,9 +507,9 @@ PF_CONSOLE_CMD( Net, // groupName
SetObjUpdateFreq, // fxnName
"string objName, float freqInSecs", // paramList
"Instructs the server to only send me updates about this object periodically" ) // helpString
{
{
char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str);
plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str);
if (!key)
return;

1
Sources/Plasma/FeatureLib/pfCrashHandler/plCrashSrv.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plCrashSrv.h"
#include "plCrash_Private.h"
#include "plFile/plFileUtils.h"
#include "plProduct.h"
#include "plFileSystem.h"

6
Sources/Plasma/FeatureLib/pfJournalBook/pfJournalBook.cpp

@ -2535,10 +2535,10 @@ plKey pfJournalBook::IGetMipmapKey( const wchar_t *name, const plLocation &loc
// Do a search through our current age with just the name given
if( plNetClientMgr::GetInstance() != nil )
{
const char *thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if( thisAge != nil )
plString thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if (!thisAge.IsNull())
{
key = plKeyFinder::Instance().StupidSearch( thisAge, nil, plMipmap::Index(), cName, true );
key = plKeyFinder::Instance().StupidSearch( thisAge, "", plMipmap::Index(), cName, true );
if( key != nil )
{
return key;

48
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp

@ -94,7 +94,7 @@ public:
protected:
bool fWeExploded; // alternative to massive error stack
plString fFilename;
plFileName fFilename;
XML_Parser fParser;
struct tagInfo
@ -121,7 +121,7 @@ protected:
public:
LocalizationXMLFile() : fWeExploded(false) { }
bool Parse(const plString & fileName); // returns false on failure
bool Parse(const plFileName & fileName); // returns false on failure
void AddError(const plString & errorText);
};
@ -354,7 +354,7 @@ void LocalizationXMLFile::IHandleTranslationTag(const LocalizationXMLFile::tagIn
//// Parse() /////////////////////////////////////////////////////////
bool LocalizationXMLFile::Parse(const plString& fileName)
bool LocalizationXMLFile::Parse(const plFileName& fileName)
{
fFilename = fileName;
@ -382,10 +382,10 @@ bool LocalizationXMLFile::Parse(const plString& fileName)
XML_SetCharacterDataHandler(fParser, HandleData);
XML_SetUserData(fParser, (void*)this);
hsStream *xmlStream = plEncryptedStream::OpenEncryptedFile(fileName.c_str());
hsStream *xmlStream = plEncryptedStream::OpenEncryptedFile(fileName);
if (!xmlStream)
{
pfLocalizationDataMgr::GetLog()->AddLineF("ERROR: Can't open file stream for %s", fileName.c_str());
pfLocalizationDataMgr::GetLog()->AddLineF("ERROR: Can't open file stream for %s", fileName.AsString().c_str());
return false;
}
@ -437,15 +437,15 @@ void LocalizationXMLFile::AddError(const plString& errorText)
class LocalizationDatabase
{
protected:
plString fDirectory; // the directory we're supposed to parse
plFileName fDirectory; // the directory we're supposed to parse
std::vector<LocalizationXMLFile> fFiles; // the various XML files in that directory
LocalizationXMLFile::ageMap fData;
LocalizationXMLFile::element IMergeElementData(LocalizationXMLFile::element firstElement, LocalizationXMLFile::element secondElement, const plString & fileName, const plString & path);
LocalizationXMLFile::set IMergeSetData(LocalizationXMLFile::set firstSet, LocalizationXMLFile::set secondSet, const plString & fileName, const plString & path);
LocalizationXMLFile::age IMergeAgeData(LocalizationXMLFile::age firstAge, LocalizationXMLFile::age secondAge, const plString & fileName, const plString & path);
LocalizationXMLFile::element IMergeElementData(LocalizationXMLFile::element firstElement, LocalizationXMLFile::element secondElement, const plFileName & fileName, const plString & path);
LocalizationXMLFile::set IMergeSetData(LocalizationXMLFile::set firstSet, LocalizationXMLFile::set secondSet, const plFileName & fileName, const plString & path);
LocalizationXMLFile::age IMergeAgeData(LocalizationXMLFile::age firstAge, LocalizationXMLFile::age secondAge, const plFileName & fileName, const plString & path);
void IMergeData(); // merge all localization data in the files
void IVerifyElement(const plString &ageName, const plString &setName, LocalizationXMLFile::set::iterator& curElement);
@ -456,7 +456,7 @@ protected:
public:
LocalizationDatabase() {}
void Parse(const plString & directory);
void Parse(const plFileName & directory);
LocalizationXMLFile::ageMap GetData() {return fData;}
};
@ -466,7 +466,7 @@ public:
//// IMergeElementData ///////////////////////////////////////////////
LocalizationXMLFile::element LocalizationDatabase::IMergeElementData(LocalizationXMLFile::element firstElement, LocalizationXMLFile::element secondElement, const plString & fileName, const plString & path)
LocalizationXMLFile::element LocalizationDatabase::IMergeElementData(LocalizationXMLFile::element firstElement, LocalizationXMLFile::element secondElement, const plFileName & fileName, const plString & path)
{
// copy the data over, alerting the user to any duplicate translations
LocalizationXMLFile::element::iterator curTranslation;
@ -475,7 +475,7 @@ LocalizationXMLFile::element LocalizationDatabase::IMergeElementData(Localizatio
if (firstElement.find(curTranslation->first) != firstElement.end())
{
pfLocalizationDataMgr::GetLog()->AddLineF("Duplicate %s translation for %s found in file %s. Ignoring second translation.",
curTranslation->first.c_str(), path.c_str(), fileName.c_str());
curTranslation->first.c_str(), path.c_str(), fileName.AsString().c_str());
}
else
firstElement[curTranslation->first] = curTranslation->second;
@ -486,7 +486,7 @@ LocalizationXMLFile::element LocalizationDatabase::IMergeElementData(Localizatio
//// IMergeSetData ///////////////////////////////////////////////////
LocalizationXMLFile::set LocalizationDatabase::IMergeSetData(LocalizationXMLFile::set firstSet, LocalizationXMLFile::set secondSet, const plString & fileName, const plString & path)
LocalizationXMLFile::set LocalizationDatabase::IMergeSetData(LocalizationXMLFile::set firstSet, LocalizationXMLFile::set secondSet, const plFileName & fileName, const plString & path)
{
// Merge all the elements
LocalizationXMLFile::set::iterator curElement;
@ -505,7 +505,7 @@ LocalizationXMLFile::set LocalizationDatabase::IMergeSetData(LocalizationXMLFile
//// IMergeAgeData ///////////////////////////////////////////////////
LocalizationXMLFile::age LocalizationDatabase::IMergeAgeData(LocalizationXMLFile::age firstAge, LocalizationXMLFile::age secondAge, const plString & fileName, const plString & path)
LocalizationXMLFile::age LocalizationDatabase::IMergeAgeData(LocalizationXMLFile::age firstAge, LocalizationXMLFile::age secondAge, const plFileName & fileName, const plString & path)
{
// Merge all the sets
LocalizationXMLFile::age::iterator curSet;
@ -640,14 +640,14 @@ void LocalizationDatabase::IVerifyData()
//// Parse() /////////////////////////////////////////////////////////
void LocalizationDatabase::Parse(const plString & directory)
void LocalizationDatabase::Parse(const plFileName & directory)
{
fDirectory = directory;
fFiles.clear();
char filename[255];
hsFolderIterator xmlFolder((directory + PATH_SEPARATOR_STR).c_str());
while(xmlFolder.NextFileSuffix(".loc"))
hsFolderIterator xmlFolder(directory.AsString().c_str());
while (xmlFolder.NextFileSuffix(".loc"))
{
xmlFolder.GetPathAndName(filename);
@ -822,7 +822,7 @@ plStatusLog *pfLocalizationDataMgr::fLog = nil; // output logfile
//// Constructor/Destructor //////////////////////////////////////////
pfLocalizationDataMgr::pfLocalizationDataMgr(const plString & path)
pfLocalizationDataMgr::pfLocalizationDataMgr(const plFileName & path)
{
hsAssert(!fInstance, "Tried to create the localization data manager more than once!");
fInstance = this;
@ -932,7 +932,7 @@ void pfLocalizationDataMgr::IConvertAge(LocAgeInfo *ageInfo, const plString & cu
//// IWriteText //////////////////////////////////////////////////////
void pfLocalizationDataMgr::IWriteText(const plString & filename, const plString & ageName, const plString & languageName)
void pfLocalizationDataMgr::IWriteText(const plFileName & filename, const plString & ageName, const plString & languageName)
{
bool weWroteData = false; // did we actually write any data of consequence?
bool setEmpty = true;
@ -980,7 +980,7 @@ void pfLocalizationDataMgr::IWriteText(const plString & filename, const plString
if (weWroteData)
{
// now spit the results out to the file
hsStream *xmlStream = plEncryptedStream::OpenEncryptedFileWrite(filename.c_str());
hsStream *xmlStream = plEncryptedStream::OpenEncryptedFileWrite(filename);
xmlStream->Write(fileData.GetLength(), fileData.GetString().c_str());
xmlStream->Close();
delete xmlStream;
@ -989,7 +989,7 @@ void pfLocalizationDataMgr::IWriteText(const plString & filename, const plString
//// Initialize //////////////////////////////////////////////////////
void pfLocalizationDataMgr::Initialize(const plString & path)
void pfLocalizationDataMgr::Initialize(const plFileName & path)
{
if (fInstance)
return;
@ -1194,7 +1194,7 @@ bool pfLocalizationDataMgr::DeleteElement(const plString & name)
//// WriteDatabaseToDisk /////////////////////////////////////////////
void pfLocalizationDataMgr::WriteDatabaseToDisk(const plString & path)
void pfLocalizationDataMgr::WriteDatabaseToDisk(const plFileName & path)
{
std::vector<plString> ageNames = GetAgeList();
std::vector<plString> languageNames = IGetAllLanguageNames();
@ -1202,7 +1202,9 @@ void pfLocalizationDataMgr::WriteDatabaseToDisk(const plString & path)
{
for (int curLanguage = 0; curLanguage < languageNames.size(); curLanguage++)
{
IWriteText(plString::Format("%s/%s%s.loc", path, ageNames[curAge].c_str(), languageNames[curLanguage].c_str()), ageNames[curAge], languageNames[curLanguage]);
plFileName locPath = plFileName::Join(path, plString::Format("%s%s.loc",
ageNames[curAge].c_str(), languageNames[curLanguage].c_str()));
IWriteText(locPath, ageNames[curAge], languageNames[curLanguage]);
}
}
}

12
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.h

@ -53,9 +53,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <map>
#include "pfLocalizedString.h"
#include "plFileSystem.h"
class plStatusLog;
class plString;
// Helper classes/structs that are only used in this main class
class LocalizationDatabase;
@ -106,7 +106,7 @@ protected:
// Contains all localized strings, the key is the Age.Set.Name specified by XML, in localizedElement, the key is the language string
pf3PartMap<localizedElement> fLocalizedElements;
plString fDataPath;
plFileName fDataPath;
localizedElement ICreateLocalizedElement(); // ease of use function that creates a basic localized element object
@ -117,13 +117,13 @@ protected:
void IConvertSet(LocSetInfo *setInfo, const plString & curPath);
void IConvertAge(LocAgeInfo *ageInfo, const plString & curPath);
void IWriteText(const plString & filename, const plString & ageName, const plString & languageName); // Write localization text to the specified file
void IWriteText(const plFileName & filename, const plString & ageName, const plString & languageName); // Write localization text to the specified file
pfLocalizationDataMgr(const plString & path);
pfLocalizationDataMgr(const plFileName & path);
public:
virtual ~pfLocalizationDataMgr();
static void Initialize(const plString & path);
static void Initialize(const plFileName & path);
static void Shutdown();
static pfLocalizationDataMgr &Instance(void) {return *fInstance;}
static bool InstanceValid(void) {return fInstance != nil;}
@ -162,7 +162,7 @@ public:
bool DeleteElement(const plString & name);
// Writes the current database to the disk (editor only). It will create all the files and put them into path
void WriteDatabaseToDisk(const plString & path);
void WriteDatabaseToDisk(const plFileName & path);
void OutputTreeToLog(); // prints the localization tree to the log file
};

2
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationMgr.cpp

@ -73,7 +73,7 @@ pfLocalizationMgr::~pfLocalizationMgr()
//// Initialize //////////////////////////////////////////////////////
void pfLocalizationMgr::Initialize(const plString & dataPath)
void pfLocalizationMgr::Initialize(const plFileName & dataPath)
{
if (fInstance)
return;

4
Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationMgr.h

@ -51,6 +51,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
class plFileName;
class pfLocalizationMgr
{
private:
@ -60,7 +62,7 @@ protected:
public:
virtual ~pfLocalizationMgr();
static void Initialize(const plString & dataPath);
static void Initialize(const plFileName & dataPath);
static void Shutdown();
static pfLocalizationMgr &Instance(void) {return *fInstance;}
static bool InstanceValid(void) {return fInstance != nil;}

10
Sources/Plasma/FeatureLib/pfMessage/pfMovieEventMsg.cpp

@ -43,19 +43,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h"
pfMovieEventMsg::~pfMovieEventMsg()
{
delete [] fMovieName;
}
void pfMovieEventMsg::Read(hsStream* stream, hsResMgr* mgr)
{
plMessage::IMsgRead(stream, mgr);
fReason = (Reason)stream->ReadByte();
fMovieName = stream->ReadSafeString();
fMovieName = stream->ReadSafeString_TEMP();
}
void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr)
@ -64,6 +58,6 @@ void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr)
stream->WriteByte(fReason);
stream->WriteSafeString(fMovieName);
stream->WriteSafeString(fMovieName.AsString());
}

14
Sources/Plasma/FeatureLib/pfMessage/pfMovieEventMsg.h

@ -43,6 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define pfMovieEventMsg_h_inc
#include "pnMessage/plMessage.h"
#include "plFileSystem.h"
class pfMovieEventMsg : public plMessage
{
@ -54,23 +55,18 @@ public:
Reason fReason;
char* fMovieName;
plFileName fMovieName;
pfMovieEventMsg(const char* movieName, Reason reason=kMovieDone) : plMessage(nil, nil, nil)
pfMovieEventMsg(const plFileName& movieName, Reason reason=kMovieDone) : plMessage(nil, nil, nil)
{
fReason = reason;
if (movieName)
fMovieName = hsStrcpy(movieName);
else
fMovieName = nil;
fMovieName = movieName;
}
pfMovieEventMsg() : plMessage(nil, nil, nil), fMovieName(nil), fReason(kMovieDone)
pfMovieEventMsg() : plMessage(nil, nil, nil), fReason(kMovieDone)
{
}
virtual ~pfMovieEventMsg();
CLASSNAME_REGISTER(pfMovieEventMsg);
GETINTERFACE_ANY(pfMovieEventMsg, plMessage);

28
Sources/Plasma/FeatureLib/pfPython/cyMisc.cpp

@ -208,7 +208,7 @@ PyObject* cyMisc::FindSceneObject(const plString& name, const char* ageName)
const char* theAge = ageName;
if ( ageName[0] == 0 )
theAge = nil;
key=plKeyFinder::Instance().StupidSearch(theAge,nil,plSceneObject::Index(), name, false);
key=plKeyFinder::Instance().StupidSearch(theAge, "", plSceneObject::Index(), name, false);
}
if ( key == nil )
@ -1457,7 +1457,7 @@ void cyMisc::PageOutNode(const char* nodeName)
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kUnloadRoom);
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY );
pMsg1->AddReceiver( clientKey );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, nodeName));
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName));
plgDispatch::MsgSend(pMsg1);
}
}
@ -2484,7 +2484,7 @@ void cyMisc::RebuildCameraStack(const plString& name, const char* ageName)
if ( !name.IsEmpty() )
{
key=plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false);
key=plKeyFinder::Instance().StupidSearch("", "", plSceneObject::Index(), name, false);
}
if ( key == nil )
{
@ -2685,7 +2685,7 @@ void cyMisc::FakeLinkToObjectNamed(const plString& name)
plKey key = nil;
if ( !name.IsEmpty() )
{
key = plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false);
key = plKeyFinder::Instance().StupidSearch("", "", plSceneObject::Index(), name, false);
}
if (!key)
@ -2790,28 +2790,24 @@ bool cyMisc::DumpLogs(const std::wstring & folder)
return retVal;
}
bool cyMisc::FileExists(const std::wstring & filename)
bool cyMisc::FileExists(const plFileName & filename)
{
return PathDoesFileExist(filename.c_str());
return plFileInfo(filename).Exists();
}
bool cyMisc::CreateDir(const std::wstring & directory)
bool cyMisc::CreateDir(const plFileName & directory)
{
return PathCreateDirectory(directory.c_str(), kPathCreateDirFlagEntireTree) == kPathCreateDirSuccess;
return plFileSystem::CreateDir(directory, true);
}
std::wstring cyMisc::GetUserPath()
plFileName cyMisc::GetUserPath()
{
wchar_t path[MAX_PATH];
PathGetUserDirectory(path, arrsize(path));
return path;
return plFileSystem::GetUserDataPath();
}
std::wstring cyMisc::GetInitPath()
plFileName cyMisc::GetInitPath()
{
wchar_t path[MAX_PATH];
PathGetInitDirectory(path, arrsize(path));
return path;
return plFileSystem::GetInitPath();
}
void cyMisc::SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp)

11
Sources/Plasma/FeatureLib/pfPython/cyMisc.h

@ -42,8 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef cyMisc_h
#define cyMisc_h
#include <string>
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyMisc
@ -67,6 +65,7 @@ class pyGUIDialog;
class plPipeline;
class plDisplayMode;
class plUUID;
class plFileName;
struct PipelineParams;
typedef struct _object PyObject;
@ -934,11 +933,11 @@ public:
static bool DumpLogs(const std::wstring & folder);
static bool FileExists(const std::wstring & filename);
static bool CreateDir(const std::wstring & directory);
static bool FileExists(const plFileName & filename);
static bool CreateDir(const plFileName & directory);
static std::wstring GetUserPath();
static std::wstring GetInitPath();
static plFileName GetUserPath();
static plFileName GetInitPath();
static void SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp);
static void SendFriendInvite(const wchar_t email[], const wchar_t toName[]);

44
Sources/Plasma/FeatureLib/pfPython/cyMiscGlue3.cpp

@ -632,24 +632,9 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtFileExists, args, "Params: filename\nReturns t
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(filenameObj))
if (PyString_CheckEx(filenameObj))
{
int strLen = PyUnicode_GetSize(filenameObj);
wchar_t* text = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)filenameObj, text, strLen);
text[strLen] = L'\0';
bool retVal = cyMisc::FileExists(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(filenameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(filenameObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = cyMisc::FileExists(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
PYTHON_RETURN_BOOL(cyMisc::FileExists(PyString_AsStringEx(filenameObj)));
}
else
{
@ -667,24 +652,9 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtCreateDir, args, "Params: directory\nCreates t
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(directoryObj))
{
int strLen = PyUnicode_GetSize(directoryObj);
wchar_t* text = new wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)directoryObj, text, strLen);
text[strLen] = L'\0';
bool retVal = cyMisc::CreateDir(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(directoryObj))
if (PyString_CheckEx(directoryObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(directoryObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = cyMisc::CreateDir(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
PYTHON_RETURN_BOOL(cyMisc::CreateDir(PyString_AsStringEx(directoryObj)));
}
else
{
@ -695,14 +665,12 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtCreateDir, args, "Params: directory\nCreates t
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetUserPath, "Returns the unicode path to the client's root user directory. Do NOT convert to a standard string.")
{
std::wstring val = cyMisc::GetUserPath();
return PyUnicode_FromWideChar(val.c_str(), val.length());
return PyUnicode_FromStringEx(cyMisc::GetUserPath().AsString());
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetInitPath, "Returns the unicode path to the client's init directory. Do NOT convert to a standard string.")
{
std::wstring val = cyMisc::GetInitPath();
return PyUnicode_FromWideChar(val.c_str(), val.length());
return PyUnicode_FromStringEx(cyMisc::GetInitPath().AsString());
}
///////////////////////////////////////////////////////////////////////////

10
Sources/Plasma/FeatureLib/pfPython/plPythonFileMod.cpp

@ -438,12 +438,8 @@ bool plPythonFileMod::ILoadPythonCode()
#ifndef PLASMA_EXTERNAL_RELEASE
// get code from file and execute in module
// see if the file exists first before trying to import it
char pathandfile[256];
sprintf(pathandfile, ".\\python\\%s.py",fPythonFile);
wchar_t *wPathandfile = hsStringToWString(pathandfile);
bool exists = PathDoesFileExist(wPathandfile);
delete [] wPathandfile;
if (exists)
plFileName pyfile = plFileName::Join(".", "python", plString::Format("%s.py", fPythonFile));
if (plFileInfo(pyfile).Exists())
{
char fromLoad[256];
//sprintf(fromLoad,"from %s import *", fPythonFile);
@ -453,7 +449,7 @@ bool plPythonFileMod::ILoadPythonCode()
if ( PythonInterface::RunString( fromLoad, fModule) )
{
// we've loaded the code into our module
// now attach the glue python code to the end
// now attach the glue python code to the end
if ( !PythonInterface::RunString("execfile('.\\\\python\\\\plasma\\\\glue.py')", fModule) )
{
// display any output (NOTE: this would be disabled in production)

25
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp

@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h"
#include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h"
#include "plMessage/plNetCommMsgs.h"
@ -96,7 +95,7 @@ void GotFileSrvManifest(
void* param,
const wchar_t group[],
const NetCliFileManifestEntry manifest[],
uint32_t entryCount
uint32_t entryCount
) {
pfSecurePreloader* sp = (pfSecurePreloader*)param;
if (result == kNetErrFileNotFound)
@ -116,10 +115,10 @@ void GotFileSrvManifest(
}
void FileDownloaded(
ENetError result,
void* param,
const wchar_t filename[],
hsStream* writer
ENetError result,
void* param,
const plFileName & filename,
hsStream* writer
) {
pfSecurePreloader* sp = (pfSecurePreloader*)param;
if (IS_NET_ERROR(result))
@ -243,9 +242,9 @@ void pfSecurePreloader::PreloadNextFile()
// Thankfully, both callbacks have the same arguments
if (fLegacyMode)
NetCliAuthFileRequest(filename.AsString().ToWchar(), s, FileDownloaded, this);
NetCliAuthFileRequest(filename, s, FileDownloaded, this);
else
NetCliFileDownloadRequest(filename.AsString().ToWchar(), s, FileDownloaded, this);
NetCliFileDownloadRequest(filename, s, FileDownloaded, this);
}
void pfSecurePreloader::Init()
@ -346,8 +345,8 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
const NetCliFileManifestEntry mfs = manifestEntries[i];
bool fetchMe = true;
hsRAMStream* s = nil;
plFileName clientName = plString::FromWchar(mfs.clientName);
plFileName downloadName = plString::FromWchar(mfs.downloadName);
plFileName clientName = mfs.clientName;
plFileName downloadName = mfs.downloadName;
if (plFileInfo(clientName).Exists())
{
@ -355,10 +354,8 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
if (s)
{
// Damn this
const char* md5 = hsWStringToString(mfs.md5);
plMD5Checksum srvHash;
srvHash.SetFromHexString(md5);
delete[] md5;
srvHash.SetFromHexString(mfs.md5.c_str());
// Now actually copare the hashes
plMD5Checksum lclHash;
@ -394,7 +391,7 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
PreloadNextFile();
}
void pfSecurePreloader::FilePreloaded(const wchar_t* file, hsStream* stream)
void pfSecurePreloader::FilePreloaded(const plFileName& file, hsStream* stream)
{
// Clear out queue
fDownloadEntries.pop();

2
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.h

@ -85,7 +85,7 @@ public:
void PreloadManifest(const NetCliFileManifestEntry manifestEntries[], uint32_t entryCount);
void PreloadManifest(const NetCliAuthFileInfo manifestEntries[], uint32_t entryCount);
void PreloadNextFile();
void FilePreloaded(const wchar_t* filename, hsStream* stream);
void FilePreloaded(const plFileName& filename, hsStream* stream);
plOperationProgress* GetProgressBar() { return fProgress; }

8
Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp

@ -85,10 +85,10 @@ plLayerAVI::~plLayerAVI()
bool plLayerAVI::IInit()
{
#if HS_BUILD_FOR_WIN32
int ret = AVIStreamOpenFromFile( &fAVIInfo->fAVIStream,
fMovieName,
streamtypeVIDEO,
0,
int ret = AVIStreamOpenFromFileW( &fAVIInfo->fAVIStream,
fMovieName.AsString().ToWchar(),
streamtypeVIDEO,
0,
OF_READ,
NULL);

34
Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp

@ -51,8 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPipeline/hsGDeviceRef.h"
plLayerMovie::plLayerMovie()
: fMovieName(nil),
fCurrentFrame(-1),
: fCurrentFrame(-1),
fLength(0),
fWidth(32),
fHeight(32)
@ -66,8 +65,6 @@ plLayerMovie::plLayerMovie()
plLayerMovie::~plLayerMovie()
{
delete [] fMovieName;
delete *fTexture;
}
@ -75,10 +72,10 @@ bool plLayerMovie::ISetFault(const char* errStr)
{
#ifdef HS_DEBUGGING
char buff[256];
sprintf(buff, "ERROR %s: %s\n", fMovieName, errStr);
sprintf(buff, "ERROR %s: %s\n", fMovieName.AsString().c_str(), errStr);
hsStatusMessage(buff);
#endif // HS_DEBUGGING
*fMovieName = 0;
fMovieName = "";
return true;
}
@ -115,7 +112,7 @@ bool plLayerMovie::ISetupBitmap()
memset(b->GetImage(), 0x10, b->GetHeight() * b->GetRowBytes() );
b->SetFlags( b->GetFlags() | plMipmap::kDontThrowAwayImage );
plString name = plString::Format( "%s_BMap", fMovieName );
plString name = plString::Format( "%s_BMap", fMovieName.AsString().c_str() );
hsgResMgr::ResMgr()->NewKey( name, b, plLocation::kGlobalFixedLoc );
*fTexture = (plBitmap *)b;
@ -183,18 +180,19 @@ void plLayerMovie::Read(hsStream* s, hsResMgr* mgr)
{
plLayerAnimation::Read(s, mgr);
delete [] fMovieName;
int len = s->ReadLE32();
if( len )
{
fMovieName = new char[len+1];
s->Read(len, fMovieName);
fMovieName[len] = 0;
plStringBuffer<char> movieName;
char *buf = movieName.CreateWritableBuffer(len);
s->Read(len, buf);
buf[len] = 0;
fMovieName = plString(movieName);
}
else
{
hsAssert(false, "Reading empty string for movie name");
fMovieName = nil;
fMovieName = "";
}
}
@ -202,16 +200,8 @@ void plLayerMovie::Write(hsStream* s, hsResMgr* mgr)
{
plLayerAnimation::Write(s, mgr);
int len = (fMovieName) ? strlen(fMovieName) : 0;
s->WriteLE32(len);
if( len )
s->Write(len, fMovieName);
}
void plLayerMovie::SetMovieName(const char* n)
{
delete [] fMovieName;
fMovieName = hsStrcpy(n);
s->WriteLE32(fMovieName.GetSize());
s->Write(fMovieName.GetSize(), fMovieName.AsString().c_str());
}
bool plLayerMovie::MsgReceive(plMessage* msg)

18
Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.h

@ -53,17 +53,17 @@ class hsResMgr;
class plLayerMovie : public plLayerAnimation
{
protected:
char* fMovieName;
plFileName fMovieName;
// plAnimTimeConvert fTimeConvert;
int32_t fCurrentFrame;
float fLength;
uint32_t fWidth, fHeight;
int32_t fCurrentFrame;
float fLength;
uint32_t fWidth, fHeight;
virtual int32_t ISecsToFrame(float secs) = 0;
virtual int32_t ISecsToFrame(float secs) = 0;
bool IGetFault() const { return !(fMovieName && *fMovieName); }
bool IGetFault() const { return !fMovieName.IsValid(); }
bool ISetFault(const char* errStr);
bool ICheckBitmap();
bool IMovieIsIdle(); // will call IRelease();
@ -82,15 +82,15 @@ public:
CLASSNAME_REGISTER( plLayerMovie );
GETINTERFACE_ANY( plLayerMovie, plLayerAnimation );
virtual uint32_t Eval(double secs, uint32_t frame, uint32_t ignore);
virtual uint32_t Eval(double secs, uint32_t frame, uint32_t ignore);
virtual void Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr);
bool IsStopped() { return fTimeConvert.IsStopped(); }
void SetMovieName(const char* n);
const char* GetMovieName() const { return fMovieName; }
void SetMovieName(const plFileName& n) { fMovieName = n; }
const plFileName& GetMovieName() const { return fMovieName; }
virtual bool MsgReceive(plMessage* msg);

6
Sources/Plasma/NucleusLib/pnMessage/plClientMsg.cpp

@ -42,10 +42,10 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plClientMsg.h"
#include "HeadSpin.h"
void plClientMsg::IReset()
void plClientMsg::IReset()
{
fMsgFlag = 0;
fAgeName = nil;
fMsgFlag = 0;
fAgeName = "";
}
void plClientMsg::AddRoomLoc(plLocation loc)

7
Sources/Plasma/NucleusLib/pnMessage/plClientMsg.h

@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plClientMsg : public plMessage
{
int fMsgFlag;
char* fAgeName;
plString fAgeName;
std::vector<plLocation> fRoomLocs;
void IReset();
@ -105,7 +105,6 @@ public:
plClientMsg(const plKey &s) { IReset();}
plClientMsg(int i) { IReset(); fMsgFlag = i; }
plClientMsg(const plKey &s, const plKey &r, const double* t) { IReset(); }
~plClientMsg() { delete [] fAgeName; }
CLASSNAME_REGISTER(plClientMsg);
GETINTERFACE_ANY(plClientMsg, plMessage);
@ -115,8 +114,8 @@ public:
void AddRoomLoc(plLocation loc);
// Used for kLoadAgeKeys, kLetGoOfAgeKeys only
const char* GetAgeName() const { return fAgeName; }
void SetAgeName(const char* age) { delete [] fAgeName; fAgeName = hsStrcpy(age); }
plString GetAgeName() const { return fAgeName; }
void SetAgeName(const plString& age) { fAgeName = age; }
int GetNumRoomLocs() { return fRoomLocs.size(); }
const plLocation& GetRoomLoc(int i) const { return fRoomLocs[i]; }

4
Sources/Plasma/NucleusLib/pnNetProtocol/Private/Protocols/Cli2File/pnNpCli2File.h

@ -151,8 +151,8 @@ struct Cli2File_ManifestEntryAck : Cli2File_MsgHeader {
// FileDownloadRequest
struct Cli2File_FileDownloadRequest : Cli2File_MsgHeader {
uint32_t transId;
wchar_t filename[MAX_PATH];
uint32_t transId;
wchar_t filename[MAX_PATH];
unsigned buildId; // 0 = newest
};
struct Cli2File_FileDownloadChunkAck : Cli2File_MsgHeader {

178
Sources/Plasma/NucleusLib/pnUtils/Win32/pnUtW32Path.cpp

@ -101,16 +101,6 @@ static const wchar_t * SkipUncDrive (const wchar_t path[]) {
}
}
//===========================================================================
static wchar_t * PathSkipOverSeparator (wchar_t * path) {
for (; *path; ++path) {
if (IsSlash(*path))
return path + 1;
}
return path;
}
//===========================================================================
const wchar_t * PathFindFilename (
const wchar_t path[]
@ -144,16 +134,6 @@ static void GetProgramName (
}
}
//============================================================================
bool PathDoesDirectoryExist (const wchar_t directory[]) {
uint32_t attributes = GetFileAttributesW(directory);
if (attributes == (uint32_t) -1)
return false;
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
return true;
return false;
}
/****************************************************************************
*
@ -169,39 +149,6 @@ void PathGetProgramName (
GetProgramName(nil, dst, dstChars);
}
//===========================================================================
bool PathFromString (
wchar_t * dst,
const wchar_t src[],
unsigned dstChars
) {
ASSERT(dst);
ASSERT(src);
ASSERT(dstChars);
for (;;) {
// enable src and dst to be the same buffer
wchar_t temp[MAX_PATH];
if (dst == src) {
StrCopy(temp, src, arrsize(temp));
src = temp;
}
DWORD const result = GetFullPathNameW(src, dstChars, dst, 0);
if (!result)
break;
if (dstChars < result)
break;
if (!dst[0])
break;
return true;
}
*dst = 0;
return false;
}
//===========================================================================
// this function was originally derived from _tsplitpath in the MSVCRT library,
// but has been updated to support UNC paths and to avoid blasting off the end
@ -348,52 +295,6 @@ void PathMakePath (
*path = L'\0';
}
//===========================================================================
void PathGetUserDirectory (
wchar_t * dst,
unsigned dstChars
) {
ASSERT(dst);
ASSERT(dstChars);
wchar_t temp[MAX_PATH]; // GetSpecialFolder path requires a buffer of MAX_PATH size or larger
if (SHGetSpecialFolderPathW(NULL, temp, CSIDL_LOCAL_APPDATA, TRUE) == FALSE)
StrCopy(temp, L"C:\\", arrsize(temp));
// append the product name
PathAddFilename(dst, temp, plProduct::LongName().ToWchar(), dstChars);
// ensure it exists
if (!PathDoesDirectoryExist(dst))
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
}
//============================================================================
void PathGetLogDirectory (
wchar_t * dst,
unsigned dstChars
) {
ASSERT(dst);
ASSERT(dstChars);
PathGetUserDirectory(dst, dstChars);
PathAddFilename(dst, dst, L"Log", dstChars);
if (!PathDoesDirectoryExist(dst))
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
}
//============================================================================
void PathGetInitDirectory (
wchar_t * dst,
unsigned dstChars
) {
ASSERT(dst);
ASSERT(dstChars);
PathGetUserDirectory(dst, dstChars);
PathAddFilename(dst, dst, L"Init", dstChars);
if (!PathDoesDirectoryExist(dst))
PathCreateDirectory(dst, kPathCreateDirFlagEntireTree);
}
//===========================================================================
void PathFindFiles (
ARRAY(PathFind) * paths,
@ -504,82 +405,3 @@ void PathFindFiles (
} while (FindNextFileW(find, &fd));
FindClose(find);
}
//===========================================================================
EPathCreateDirError PathCreateDirectory (const wchar_t path[], unsigned flags) {
ASSERT(path);
// convert from relative path to full path
wchar_t dir[MAX_PATH];
if (!PathFromString(dir, path, arrsize(dir))) {
return kPathCreateDirErrInvalidPath;
}
// are we going to build the entire directory tree?
wchar_t * dirEnd;
if (flags & kPathCreateDirFlagEntireTree) {
dirEnd = dir;
// skip over leading slashes in UNC paths
while (IsSlash(*dirEnd))
++dirEnd;
// skip forward to first directory
dirEnd = PathSkipOverSeparator(dirEnd);
}
// we're only creating the very last entry in the path
else {
dirEnd = dir + StrLen(dir);
}
bool result = true;
for (wchar_t saveChar = L' '; saveChar; *dirEnd++ = saveChar) {
// find the end of the current directory string and terminate it
dirEnd = PathSkipOverSeparator(dirEnd);
saveChar = *dirEnd;
*dirEnd = 0;
// create the directory and track the result from the last call
result = CreateDirectoryW(dir, (LPSECURITY_ATTRIBUTES) nil);
}
// if we successfully created the directory then we're done
if (result) {
// Avoid check for kPathCreateDirFlagOsError
static_assert(kPathCreateDirSuccess == NO_ERROR, "Path creation success and NO_ERROR constants differ");
return kPathCreateDirSuccess;
}
unsigned error = GetLastError();
switch (error) {
case ERROR_ACCESS_DENIED:
return kPathCreateDirErrAccessDenied;
case ERROR_ALREADY_EXISTS: {
DWORD attrib;
if (0xffffffff == (attrib = GetFileAttributesW(dir)))
return kPathCreateDirErrInvalidPath;
if (! (attrib & FILE_ATTRIBUTE_DIRECTORY))
return kPathCreateDirErrFileWithSameName;
if (flags & kPathCreateDirFlagCreateNew)
return kPathCreateDirErrDirExists;
}
return kPathCreateDirSuccess;
default:
return kPathCreateDirErrInvalidPath;
}
}
//===========================================================================
bool PathDoesFileExist (const wchar_t fileName[]) {
uint32_t attributes = GetFileAttributesW(fileName);
if (attributes == (uint32_t) -1)
return false;
if (attributes & FILE_ATTRIBUTE_DIRECTORY)
return false;
return true;
}

86
Sources/Plasma/NucleusLib/pnUtils/pnUtPath.h

@ -76,9 +76,9 @@ const unsigned kPathFlagRecurse = 1<<4; // also set if "**" used in filesp
struct PathFind {
unsigned flags;
uint64_t fileLength;
uint64_t lastWriteTime;
wchar_t name[MAX_PATH];
uint64_t fileLength;
uint64_t lastWriteTime;
wchar_t name[MAX_PATH];
};
@ -90,18 +90,14 @@ struct PathFind {
void PathFindFiles (
ARRAY(PathFind) * paths,
const wchar_t fileSpec[],
const wchar_t fileSpec[],
unsigned pathFlags
);
void PathGetProgramName (
wchar_t * dst,
wchar_t * dst,
unsigned dstChars
);
bool PathDoesFileExist (
const wchar_t fileName[]
);
/*****************************************************************************
*
@ -110,20 +106,20 @@ bool PathDoesFileExist (
***/
void PathSplitPath (
const wchar_t path[],
wchar_t * drive,
wchar_t * dir,
wchar_t * fname,
wchar_t * ext
const wchar_t path[],
wchar_t * drive,
wchar_t * dir,
wchar_t * fname,
wchar_t * ext
);
void PathMakePath (
wchar_t * path,
wchar_t * path,
unsigned chars,
const wchar_t drive[],
const wchar_t dir[],
const wchar_t fname[],
const wchar_t ext[]
const wchar_t drive[],
const wchar_t dir[],
const wchar_t fname[],
const wchar_t ext[]
);
// c:\dir1 + dir2\file.txt => c:\dir1\dir2\file.txt
@ -148,51 +144,9 @@ void PathRemoveFilename (
*
***/
// Create directory
enum EPathCreateDirError {
kPathCreateDirSuccess,
kPathCreateDirErrInvalidPath,
kPathCreateDirErrAccessDenied,
kPathCreateDirErrFileWithSameName,
kPathCreateDirErrDirExists, // Directory exists and kPathCreateDirFlagCreateNew was specified
};
// Setting this flag causes the function to create the entire directory
// tree from top to bottom. Clearing this flag causes the function to
// create only the last entry in the path.
const unsigned kPathCreateDirFlagEntireTree = 1<<0;
// Setting this flag causes the function to create the last entry in the path
// ONLY if it doesn't already exist. If it does exist the function will return
// kPathCreateDirErrDirExistes.
const unsigned kPathCreateDirFlagCreateNew = 1<<1;
EPathCreateDirError PathCreateDirectory (
const wchar_t path[],
unsigned flags
);
// Get directory
void PathGetProgramDirectory (
wchar_t * dst,
unsigned dstChars
);
// Product and user-specific common directory locations
void PathGetUserDirectory (
wchar_t * dst,
unsigned dstChars
);
void PathGetLogDirectory (
wchar_t * dst,
unsigned dstChars
);
void PathGetInitDirectory (
wchar_t * dst,
wchar_t * dst,
unsigned dstChars
);
@ -206,13 +160,13 @@ void PathGetInitDirectory (
// you may send nil for any fields you don't care about
void PathSplitEmail (
const wchar_t emailAddr[],
wchar_t * user,
wchar_t * user,
unsigned userChars,
wchar_t * domain,
wchar_t * domain,
unsigned domainChars,
wchar_t * tld,
wchar_t * tld,
unsigned tldChars,
wchar_t * subDomains, // (wchar_t *)&subs --> wchar_t subs[16][256];
wchar_t * subDomains, // (wchar_t *)&subs --> wchar_t subs[16][256];
unsigned subDomainChars, // arrsize(subs[0]) --> 256
unsigned subDomainCount // arrsize(subs) --> 16
);

143
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

@ -53,44 +53,38 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
const uint32_t plAgePage::kInvalidSeqSuffix = (uint32_t)-1;
plAgePage::plAgePage( const char *name, uint32_t seqSuffix, uint8_t flags )
plAgePage::plAgePage( const plString &name, uint32_t seqSuffix, uint8_t flags )
{
fName = name != nil ? hsStrcpy( name ) : nil;
fName = name;
fSeqSuffix = seqSuffix;
fFlags = flags;
}
plAgePage::plAgePage( char *stringFrom ) : fName(nil)
plAgePage::plAgePage( const plString &stringFrom )
{
SetFromString( stringFrom );
}
plAgePage::plAgePage()
{
fName = nil;
fName = "";
fFlags = 0;
fSeqSuffix = 0;
}
plAgePage::plAgePage( const plAgePage &src ) : fName(nil)
plAgePage::plAgePage( const plAgePage &src )
{
fName = src.fName != nil ? hsStrcpy( src.fName ) : nil;
fName = src.fName;
fSeqSuffix = src.fSeqSuffix;
fFlags = src.fFlags;
}
plAgePage::~plAgePage()
{
delete [] fName;
}
plAgePage &plAgePage::operator=( const plAgePage &src )
{
delete [] fName;
fName = src.fName != nil ? hsStrcpy( src.fName ) : nil;
fName = src.fName;
fSeqSuffix = src.fSeqSuffix;
fFlags = src.fFlags;
return *this;
}
@ -103,54 +97,31 @@ void plAgePage::SetFlags(uint8_t f, bool on)
}
// now preservs original string
bool plAgePage::SetFromString( const char *stringIn )
bool plAgePage::SetFromString( const plString &stringIn )
{
char *c, seps[] = ", \n";
std::string string = stringIn;
// Parse. Format is going to be "pageName[,seqSuffix[,flags]]"
c = strtok( (char*)string.c_str(), seps );
if( c == nil )
std::vector<plString> toks = stringIn.Tokenize(", \n");
if (toks.size() == 0)
return false;
delete [] fName;
fName = hsStrcpy( c );
fName = toks[0];
fSeqSuffix = kInvalidSeqSuffix;
fFlags = 0;
// Look for seqSuffix
c = strtok( nil, seps );
if( c != nil )
{
fSeqSuffix = atoi( c );
// Look for flags
c = strtok( nil, seps );
if( c != nil )
{
fFlags = atoi( c );
}
else
fFlags = 0;
}
else
{
fSeqSuffix = kInvalidSeqSuffix;
fFlags = 0;
}
if (toks.size() > 1)
fSeqSuffix = toks[1].ToUInt();
if (toks.size() > 2)
fFlags = toks[2].ToUInt();
return true;
}
char *plAgePage::GetAsString( void ) const
plString plAgePage::GetAsString( void ) const
{
static char str[ 256 ];
if (fFlags)
return plString::Format("%s,%d,%d", fName.c_str(), fSeqSuffix, fFlags);
// Format is "pageName[,seqSuffix[,flags]]"
if( fFlags != 0 )
sprintf( str, "%s,%d,%d", fName, fSeqSuffix, fFlags );
else
sprintf( str, "%s,%d", fName, fSeqSuffix );
return str;
return plString::Format("%s,%d", fName.c_str(), fSeqSuffix);
}
@ -179,10 +150,9 @@ plAgeDescription::~plAgeDescription()
void plAgeDescription::IDeInit()
{
ClearPageList();
delete [] fName;
}
plAgeDescription::plAgeDescription( const char *fileNameToReadFrom ) : plInitSectionTokenReader()
plAgeDescription::plAgeDescription( const plFileName &fileNameToReadFrom ) : plInitSectionTokenReader()
{
ReadFromFile(fileNameToReadFrom);
}
@ -190,7 +160,7 @@ plAgeDescription::plAgeDescription( const char *fileNameToReadFrom ) : plInitSec
//
// Reads from a file, returns false if failed.
//
bool plAgeDescription::ReadFromFile( const char *fileNameToReadFrom )
bool plAgeDescription::ReadFromFile( const plFileName &fileNameToReadFrom )
{
IInit();
@ -206,38 +176,20 @@ bool plAgeDescription::ReadFromFile( const char *fileNameToReadFrom )
return true;
}
void plAgeDescription::SetAgeNameFromPath( const char *path )
void plAgeDescription::SetAgeNameFromPath( const plFileName &path )
{
delete [] fName;
if( path == nil )
if (!path.IsValid())
{
fName = nil;
fName = "";
return;
}
// Construct our name from the path
const char *pathSep1 = strrchr( path, '\\' );
const char *pathSep2 = strrchr( path, '/' );
if( pathSep2 > pathSep1 )
pathSep1 = pathSep2;
if( pathSep1 == nil )
pathSep1 = (char *)path;
else
pathSep1++; // Get past the actual character we found
char temp[ 512 ];
strcpy( temp, pathSep1 );
char *end = strrchr( temp, '.' );
if( end != nil )
*end = 0;
fName = hsStrcpy( temp );
fName = path.GetFileNameNoExt();
}
void plAgeDescription::IInit( void )
void plAgeDescription::IInit( void )
{
fName = nil;
fName = "";
fDayLength = 24.0f;
fMaxCapacity = -1;
fLingerTime = 180; // seconds
@ -248,14 +200,12 @@ void plAgeDescription::IInit( void )
fPageIterator = -1;
}
struct SzDelete { void operator()(char * str) { delete [] str;} };
void plAgeDescription::ClearPageList()
{
fPages.Reset();
}
void plAgeDescription::AppendPage( const char *name, int seqSuffix, uint8_t flags )
void plAgeDescription::AppendPage( const plString &name, int seqSuffix, uint8_t flags )
{
fPages.Append( plAgePage( name, ( seqSuffix == -1 ) ? fPages.GetCount() : (uint32_t)seqSuffix, flags ) );
}
@ -280,35 +230,30 @@ plAgePage *plAgeDescription::GetNextPage( void )
return ret;
}
void plAgeDescription::RemovePage( const char *page )
void plAgeDescription::RemovePage( const plString &page )
{
int i;
for( i = 0; i < fPages.GetCount(); i++ )
for (int i = 0; i < fPages.GetCount(); i++)
{
if( strcmp( page, fPages[ i ].GetName() ) == 0 )
if (page == fPages[i].GetName())
{
fPages.Remove( i );
fPages.Remove(i);
return;
}
}
}
plAgePage *plAgeDescription::FindPage( const char *name ) const
plAgePage *plAgeDescription::FindPage( const plString &name ) const
{
int i;
for( i = 0; i < fPages.GetCount(); i++ )
for (int i = 0; i < fPages.GetCount(); i++)
{
if( strcmp( name, fPages[ i ].GetName() ) == 0 )
return &fPages[ i ];
if (name == fPages[i].GetName())
return &fPages[i];
}
return nil;
}
plLocation plAgeDescription::CalcPageLocation( const char *page ) const
plLocation plAgeDescription::CalcPageLocation( const plString &page ) const
{
plAgePage *ap = FindPage( page );
if( ap != nil )
@ -334,10 +279,10 @@ plLocation plAgeDescription::CalcPageLocation( const char *page ) const
else
{
plLocation ret = plLocation::MakeNormal( combined );
if (page && !stricmp(page, "builtin"))
if (!page.CompareI("builtin"))
ret.SetFlags(plLocation::kBuiltIn);
return ret;
}
}
}
// Just make a blank (invalid) one
@ -380,7 +325,7 @@ void plAgeDescription::Write(hsStream* stream) const
int i;
for( i = 0; i < fPages.GetCount(); i++ )
{
sprintf(buf, "Page=%s\n", fPages[ i ].GetAsString() );
sprintf(buf, "Page=%s\n", fPages[ i ].GetAsString().c_str() );
stream->WriteString(buf);
}
}
@ -537,7 +482,7 @@ void plAgeDescription::AppendCommonPages( void )
void plAgeDescription::CopyFrom(const plAgeDescription& other)
{
IDeInit();
fName = hsStrcpy(other.GetAgeName());
fName = other.GetAgeName();
int i;
for(i=0;i<other.fPages.GetCount(); i++)
fPages.Append( other.fPages[ i ] );

45
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.h

@ -57,9 +57,9 @@ class hsStream;
class plAgePage
{
protected:
char *fName;
uint32_t fSeqSuffix;
uint8_t fFlags;
plString fName;
uint32_t fSeqSuffix;
uint8_t fFlags;
public:
@ -73,21 +73,20 @@ class plAgePage
kIsVolatile = 0x08,
};
plAgePage( const char *name, uint32_t seqSuffix, uint8_t flags );
plAgePage( char *stringFrom );
plAgePage( const plString &name, uint32_t seqSuffix, uint8_t flags );
plAgePage( const plString &stringFrom );
plAgePage( const plAgePage &src );
plAgePage();
~plAgePage();
const char *GetName( void ) const { return fName; }
uint32_t GetSeqSuffix( void ) const { return fSeqSuffix; }
uint8_t GetFlags( void ) const { return fFlags; }
plString GetName( void ) const { return fName; }
uint32_t GetSeqSuffix( void ) const { return fSeqSuffix; }
uint8_t GetFlags( void ) const { return fFlags; }
void SetSeqSuffix( uint32_t s ) { fSeqSuffix = s; }
void SetFlags(uint8_t f, bool on=true);
bool SetFromString( const char *string );
char *GetAsString( void ) const;
bool SetFromString( const plString &string );
plString GetAsString( void ) const;
plAgePage &operator=( const plAgePage &src );
};
@ -98,16 +97,16 @@ class plAgeDescription : public plInitSectionTokenReader
{
private:
char *fName;
plString fName;
int32_t fPageIterator;
int32_t fPageIterator;
hsTArray<plAgePage> fPages;
plUnifiedTime fStart;
float fDayLength;
short fMaxCapacity;
short fLingerTime; // seconds game instance should linger after last player leaves. -1 means never exit.
short fLingerTime; // seconds game instance should linger after last player leaves. -1 means never exit.
int32_t fSeqPrefix;
uint32_t fReleaseVersion; // 0 for pre-release, 1+ for actual released ages
@ -124,7 +123,7 @@ public:
static char kAgeDescPath[];
plAgeDescription();
plAgeDescription( const char *fileNameToReadFrom );
plAgeDescription( const plFileName &fileNameToReadFrom );
plAgeDescription( const plAgeDescription &src )
{
IInit();
@ -132,28 +131,28 @@ public:
}
~plAgeDescription();
bool ReadFromFile( const char *fileNameToReadFrom ) ;
bool ReadFromFile( const plFileName &fileNameToReadFrom );
void Read(hsStream* stream);
void Write(hsStream* stream) const;
// Overload for plInitSectionTokenReader
virtual const char *GetSectionName( void ) const;
const char *GetAgeName( void ) const { return fName; }
void SetAgeNameFromPath( const char *path );
void SetAgeName(const char* ageName) { delete [] fName; fName=hsStrcpy(ageName); }
plString GetAgeName( void ) const { return fName; }
void SetAgeNameFromPath( const plFileName &path );
void SetAgeName(const plString& ageName) { fName = ageName; }
// Page list
void ClearPageList();
void RemovePage( const char *page );
void AppendPage( const char *name, int seqSuffix = -1, uint8_t flags = 0 );
void RemovePage( const plString &page );
void AppendPage( const plString &name, int seqSuffix = -1, uint8_t flags = 0 );
void SeekFirstPage( void );
plAgePage *GetNextPage( void );
int GetNumPages() const { return fPages.GetCount(); }
plAgePage *FindPage( const char *name ) const;
plAgePage *FindPage( const plString &name ) const;
bool FindLocation(const plLocation& loc) const;
plLocation CalcPageLocation( const char *page ) const;
plLocation CalcPageLocation( const plString &page ) const;
// Getters
short GetStartMonth() const { return fStart.GetMonth(); }

14
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp

@ -52,23 +52,23 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plFile/plInitFileReader.h"
#include "hsStringTokenizer.h"
//// plManifestFile ///////////////////////////////////////////////////////
plManifestFile::plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, uint32_t size, uint32_t zippedSize, uint32_t flags, bool md5Now) :
plManifestFile::plManifestFile(const plFileName& name, const plFileName& serverPath,
const plMD5Checksum& check, uint32_t size, uint32_t zippedSize,
uint32_t flags, bool md5Now) :
fName(name),
fServerPath(serverPath),
fChecksum(check),
fSize(size),
fZippedSize(zippedSize),
fFlags(flags),
fMd5Checked(md5Now)
{
fName = name;
fServerPath = serverPath;
if (md5Now)
{
DoMd5Check();
@ -81,9 +81,9 @@ plManifestFile::~plManifestFile()
void plManifestFile::DoMd5Check()
{
if (plFileUtils::FileExists(fName.c_str()))
if (plFileInfo(fName).Exists())
{
plMD5Checksum localFile(fName.c_str());
plMD5Checksum localFile(fName);
fIsLocalUpToDate = (localFile == fChecksum);
fLocalExists = true;
}

17
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.h

@ -63,12 +63,12 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plManifestFile
{
protected:
std::string fName;
std::string fServerPath;
plFileName fName;
plFileName fServerPath;
plMD5Checksum fChecksum;
uint32_t fSize;
uint32_t fZippedSize;
uint32_t fFlags;
uint32_t fSize;
uint32_t fZippedSize;
uint32_t fFlags;
bool fMd5Checked;
bool fIsLocalUpToDate;
@ -86,11 +86,12 @@ public:
kFlagZipped = 1<<3,
};
plManifestFile(const char* name, const char* serverPath, const plMD5Checksum& check, uint32_t size, uint32_t zippedSize, uint32_t flags, bool md5Now = true);
plManifestFile(const plFileName& name, const plFileName& serverPath, const plMD5Checksum& check,
uint32_t size, uint32_t zippedSize, uint32_t flags, bool md5Now = true);
virtual ~plManifestFile();
const char* GetName() const { return fName.c_str(); }
const char* GetServerPath() const { return fServerPath.c_str(); }
const plFileName &GetName() const { return fName; }
const plFileName &GetServerPath() const { return fServerPath; }
const plMD5Checksum& GetChecksum() const { return fChecksum; }
uint32_t GetDiskSize() const { return fSize; }
uint32_t GetDownloadSize() const { return hsCheckBits(fFlags, kFlagZipped) ? fZippedSize : fSize; }

4
Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoader.cpp

@ -294,14 +294,14 @@ bool plAgeLoader::ILoadAge(const char ageName[])
{
if( IsPageExcluded( page, fAgeName) )
{
nc->DebugMsg( "\tExcluding page %s\n", page->GetName() );
nc->DebugMsg("\tExcluding page %s\n", page->GetName().c_str());
continue;
}
nPages++;
pMsg1->AddRoomLoc(ad.CalcPageLocation(page->GetName()));
nc->DebugMsg("\tPaging in room %s\n", page->GetName());
nc->DebugMsg("\tPaging in room %s\n", page->GetName().c_str());
}
pMsg1->Send(clientKey);

4
Sources/Plasma/PubUtilLib/plAgeLoader/plAgeLoaderPaging.cpp

@ -301,11 +301,11 @@ bool plAgeLoader::IsPageExcluded( const plAgePage *page, const char *ageName
return true;
// check exclude list
const char* pageName = page->GetName();
plString pageName = page->GetName();
int i;
for( i = 0; i < sExcludeList.GetCount(); i++ )
{
if( stricmp( pageName, sExcludeList[ i ].fPageName ) == 0 )
if( pageName.CompareI( sExcludeList[ i ].fPageName ) == 0 )
{
if( ageName == nil || sExcludeList[ i ].fAgeName == nil ||
stricmp( ageName, sExcludeList[ i ].fAgeName ) == 0 )

31
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -46,7 +46,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeLoader/plAgeLoader.h"
#include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plMessage/plResPatcherMsg.h"
#include "pnNetBase/pnNbError.h"
#include "plNetGameLib/plNetGameLib.h"
@ -91,33 +90,32 @@ public:
/////////////////////////////////////////////////////////////////////////////
static void FileDownloaded(
ENetError result,
void* param,
const wchar_t filename[],
hsStream* writer)
ENetError result,
void* param,
const plFileName & filename,
hsStream* writer)
{
plResPatcher* patcher = (plResPatcher*)param;
char* name = hsWStringToString(filename);
plFileName file = filename;
if (((plResDownloadStream*)writer)->IsZipped())
plFileUtils::StripExt(name); // Kill off .gz
file = file.StripFileExt(); // Kill off .gz
writer->Close();
switch (result)
{
case kNetSuccess:
PatcherLog(kStatus, " Download Complete: %s", name);
PatcherLog(kStatus, " Download Complete: %s", file.AsString().c_str());
// If this is a PRP, then we need to add it to the ResManager
if (stricmp(plFileUtils::GetFileExt(name), "prp") == 0)
((plResManager*)hsgResMgr::ResMgr())->AddSinglePage(name);
if (file.AsString().CompareI("prp") == 0)
((plResManager*)hsgResMgr::ResMgr())->AddSinglePage(file);
// Continue down the warpath
patcher->IssueRequest();
delete[] name;
delete writer;
return;
case kNetErrFileNotFound:
PatcherLog(kError, " Download Failed: %s not found", name);
PatcherLog(kError, " Download Failed: %s not found", file.AsString().c_str());
break;
default:
char* error = hsWStringToString(NetErrorToString(result));
@ -129,7 +127,6 @@ static void FileDownloaded(
// Failure case
((plResDownloadStream*)writer)->Unlink();
patcher->Finish(false);
delete[] name;
delete writer;
}
@ -153,8 +150,8 @@ static void ManifestDownloaded(
for (uint32_t i = 0; i < entryCount; ++i)
{
const NetCliFileManifestEntry mfs = manifest[i];
plFileName fileName = plString::FromWchar(mfs.clientName);
plFileName downloadName = plString::FromWchar(mfs.downloadName);
plFileName fileName = mfs.clientName;
plFileName downloadName = mfs.downloadName;
// See if the files are the same
// 1. Check file size before we do time consuming md5 operations
@ -163,7 +160,7 @@ static void ManifestDownloaded(
{
plMD5Checksum cliMD5(fileName);
plMD5Checksum srvMD5;
srvMD5.SetFromHexString(plString::FromWchar(mfs.md5).c_str());
srvMD5.SetFromHexString(mfs.md5.c_str());
if (cliMD5 == srvMD5)
continue;
@ -238,7 +235,7 @@ void plResPatcher::IssueRequest()
plFileSystem::CreateDir(req.fFriendlyName.StripFileName(), true);
plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile);
if (stream->Open(req.fFriendlyName, "wb"))
NetCliFileDownloadRequest(req.fFile.AsString().ToWchar(), stream, FileDownloaded, this);
NetCliFileDownloadRequest(req.fFile, stream, FileDownloaded, this);
else {
PatcherLog(kError, " Unable to create file %s", req.fFriendlyName.AsString().c_str());
Finish(false);

6
Sources/Plasma/PubUtilLib/plAudio/plSound.cpp

@ -868,14 +868,14 @@ plSoundBuffer::ELoadReturnVal plSound::IPreLoadBuffer( bool playWhenLoaded, bool
}
}
const char *plSound::GetFileName( void ) const
plFileName plSound::GetFileName( void ) const
{
if(fDataBufferKey->ObjectIsLoaded())
if (fDataBufferKey->ObjectIsLoaded())
{
return ((plSoundBuffer *)fDataBufferKey->ObjectIsLoaded())->GetFileName();
}
return nil;
return "";
}
/////////////////////////////////////////////////////////////////////////

4
Sources/Plasma/PubUtilLib/plAudio/plSound.h

@ -211,9 +211,9 @@ public:
virtual void Update();
plSoundBuffer * GetDataBuffer( void ) const { return (plSoundBuffer *)fDataBufferKey->ObjectIsLoaded(); }
float QueryCurrVolume( void ) const; // Returns the current volume, attenuated
float QueryCurrVolume( void ) const; // Returns the current volume, attenuated
const char * GetFileName( void ) const;
plFileName GetFileName( void ) const;
virtual double GetLength();
void SetProperty( Property prop, bool on ) { if( on ) fProperties |= prop; else fProperties &= ~prop; }

12
Sources/Plasma/PubUtilLib/plAudio/plWin32GroupedSound.cpp

@ -228,14 +228,14 @@ bool plWin32GroupedSound::LoadSound( bool is3D )
IFillCurrentSound( 0 );
// Logging
plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName() != nil ? "file" : "buffer",
buffer->GetFileName() != nil ? buffer->GetFileName() : buffer->GetKey()->GetUoid().GetObjectName().c_str(),
//fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software",
//fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic",
plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName().IsValid() ? "file" : "buffer",
buffer->GetFileName().IsValid() ? buffer->GetFileName().AsString().c_str() : buffer->GetKey()->GetUoid().GetObjectName().c_str(),
//fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software",
//fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic",
#ifdef PL_PROFILE_ENABLED
gProfileVarStaticSndShoveTime.GetValue() );
gProfileVarStaticSndShoveTime.GetValue() );
#else
0 );
0 );
#endif
IPrintDbgMessage( str.c_str() );
if( GetKey() != nil && GetKeyName().Find( "Footstep" ) >= 0 )

54
Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.cpp

@ -91,9 +91,6 @@ plWin32StreamingSound::~plWin32StreamingSound()
IUnloadDataBuffer();
delete fDataStream;
fDataStream = nil;
fSrcFilename[ 0 ] = 0;
delete fDeswizzler;
}
@ -117,11 +114,11 @@ plSoundBuffer::ELoadReturnVal plWin32StreamingSound::IPreLoadBuffer( bool playWh
{
if(fPlayWhenStopped)
return plSoundBuffer::kPending;
bool sfxPath = fNewFilename.size() ? false : true;
if( fDataStream != nil && fNewFilename.size() == 0)
bool sfxPath = fNewFilename.IsValid() ? false : true;
if (fDataStream != nil && !fNewFilename.IsValid())
return plSoundBuffer::kSuccess; // Already loaded
if(!ILoadDataBuffer())
{
return plSoundBuffer::kError;
@ -131,11 +128,11 @@ plSoundBuffer::ELoadReturnVal plWin32StreamingSound::IPreLoadBuffer( bool playWh
return plSoundBuffer::kError;
// The databuffer also needs to know if the source is compressed or not
if(fNewFilename.length())
if (fNewFilename.IsValid())
{
buffer->SetFileName(fNewFilename.c_str());
buffer->SetFileName(fNewFilename);
buffer->SetFlag(plSoundBuffer::kStreamCompressed, fIsCompressed);
fNewFilename.clear();
fNewFilename = "";
if(fReallyPlaying)
{
fPlayWhenStopped = true;
@ -172,8 +169,7 @@ plSoundBuffer::ELoadReturnVal plWin32StreamingSound::IPreLoadBuffer( bool playWh
}
}
char str[ 256 ];
strncpy( fSrcFilename, buffer->GetFileName(), sizeof( fSrcFilename ) );
fSrcFilename = buffer->GetFileName();
bool streamCompressed = (buffer->HasFlag(plSoundBuffer::kStreamCompressed) != 0);
delete fDataStream;
@ -185,20 +181,14 @@ plSoundBuffer::ELoadReturnVal plWin32StreamingSound::IPreLoadBuffer( bool playWh
bool streamCompressed = (buffer->HasFlag(plSoundBuffer::kStreamCompressed) != 0);
/// Open da file
char strPath[ kFolderIterator_MaxPath ];
getcwd(strPath, kFolderIterator_MaxPath);
if(sfxPath)
strcat( strPath, "\\sfx\\" );
else
{
// if we've changing the filename don't append 'sfx', just append a '\' since a path to the folder is expected
strcat( strPath, "\\");
}
strcat( strPath, fSrcFilename );
plFileName strPath = plFileSystem::GetCWD();
if (sfxPath)
strPath = plFileName::Join(strPath, "sfx");
strPath = plFileName::Join(strPath, fSrcFilename);
fDataStream = plAudioFileReader::CreateReader(strPath, select,type);
}
}
if( fDataStream == nil || !fDataStream->IsValid() )
{
delete fDataStream;
@ -206,8 +196,7 @@ plSoundBuffer::ELoadReturnVal plWin32StreamingSound::IPreLoadBuffer( bool playWh
return plSoundBuffer::kError;
}
sprintf( str, " Readied file %s for streaming", fSrcFilename );
IPrintDbgMessage( str );
IPrintDbgMessage(plString::Format(" Readied file %s for streaming", fSrcFilename.AsString().c_str()).c_str());
// dont free sound data until we have a chance to use it in load sound
@ -227,11 +216,11 @@ void plWin32StreamingSound::IFreeBuffers( void )
if(!plgAudioSys::IsRestarting())
{
// we are deleting the stream, we must release the sound data.
FreeSoundData();
FreeSoundData();
delete fDataStream;
fDataStream = nil;
}
fSrcFilename[ 0 ] = 0;
fSrcFilename = "";
}
}
@ -303,9 +292,10 @@ bool plWin32StreamingSound::LoadSound( bool is3D )
delete fDSoundBuffer;
fDSoundBuffer = nil;
char str[256];
sprintf(str, "Can't create sound buffer for %s.wav. This could happen if the wav file is a stereo file. Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.", GetFileName());
IPrintDbgMessage( str, true );
plString str = plString::Format("Can't create sound buffer for %s.wav. This could happen if the wav file is a stereo file."
" Stereo files are not supported on 3D sounds. If the file is not stereo then please report this error.",
GetFileName().AsString().c_str());
IPrintDbgMessage(str.c_str(), true);
fFailed = true;
return false;
}

16
Sources/Plasma/PubUtilLib/plAudio/plWin32StreamingSound.h

@ -70,15 +70,15 @@ public:
virtual bool MsgReceive( plMessage *pMsg );
protected:
float fTimeAtBufferStart;
plAudioFileReader *fDataStream;
float fBufferLengthInSecs;
uint8_t fBlankBufferFillCounter;
plSoundDeswizzler *fDeswizzler;
char fSrcFilename[ 256 ];
float fTimeAtBufferStart;
plAudioFileReader *fDataStream;
float fBufferLengthInSecs;
uint8_t fBlankBufferFillCounter;
plSoundDeswizzler *fDeswizzler;
plFileName fSrcFilename;
StreamType fStreamType;
bool fIsCompressed; // this applies only to the new sound file specified in fNewFilename, so we can play both ogg's and wav's
std::string fNewFilename; // allow the filename to be changed so we can play from a different source.
plFileName fNewFilename; // allow the filename to be changed so we can play from a different source.
// ultimately this filename will be given to fDataBuffer, but since it's not always around we'll store it here
bool fStopping;
@ -86,7 +86,7 @@ protected:
bool fPlayWhenStopped;
unsigned fStartPos;
float IGetTimeAtBufferStart( void ) { return fTimeAtBufferStart; }
float IGetTimeAtBufferStart( void ) { return fTimeAtBufferStart; }
virtual void SetStartPos(unsigned bytes);
virtual void IDerivedActuallyPlay( void );

46
Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.cpp

@ -56,7 +56,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//#include "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.h"
#include "plCachedFileReader.h"
@ -66,20 +65,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define kCacheDirName "temp"
plAudioFileReader* plAudioFileReader::CreateReader(const char* path, plAudioCore::ChannelSelect whichChan, StreamType type)
plAudioFileReader* plAudioFileReader::CreateReader(const plFileName& path, plAudioCore::ChannelSelect whichChan, StreamType type)
{
const char* ext = plFileUtils::GetFileExt(path);
plString ext = path.GetFileExt();
if (type == kStreamWAV)
{
bool isWav = (stricmp(ext, "wav") == 0);
bool isWav = (ext.CompareI("wav") == 0);
// We want to stream a wav off disk, but this is a compressed file.
// Get the uncompressed path. Ignore the requested channel, since it
// will have already been split into two files if that is necessary.
if (!isWav)
{
char cachedPath[256];
IGetCachedPath(path, cachedPath, whichChan);
plFileName cachedPath = IGetCachedPath(path, whichChan);
plAudioFileReader *r = new plCachedFileReader(cachedPath, plAudioCore::kAll);
if (!r->IsValid()) {
// So we tried to play a cached file and it didn't exist
@ -102,43 +100,37 @@ plAudioFileReader* plAudioFileReader::CreateReader(const char* path, plAudioCore
return nil;
}
plAudioFileReader* plAudioFileReader::CreateWriter(const char* path, plWAVHeader& header)
plAudioFileReader* plAudioFileReader::CreateWriter(const plFileName& path, plWAVHeader& header)
{
const char* ext = plFileUtils::GetFileExt(path);
plAudioFileReader* writer = new plCachedFileReader(path, plAudioCore::kAll);
writer->OpenForWriting(path, header);
return writer;
}
void plAudioFileReader::IGetCachedPath(const char* path, char* cachedPath, plAudioCore::ChannelSelect whichChan)
plFileName plAudioFileReader::IGetCachedPath(const plFileName& path, plAudioCore::ChannelSelect whichChan)
{
// Get the file's path and add our streaming cache folder to it
strcpy(cachedPath, path);
plFileUtils::StripFile(cachedPath);
strcat(cachedPath, kCacheDirName"\\");
plFileName cachedPath = plFileName::Join(path.StripFileName(), kCacheDirName);
// Create the directory first
plFileUtils::CreateDir(cachedPath);
// Get the path to the cached version of the file, without the extension
const char* fileName = plFileUtils::GetFileName(path);
const char* fileExt = plFileUtils::GetFileExt(fileName);
strncat(cachedPath, fileName, fileExt-fileName-1);
plFileSystem::CreateDir(cachedPath);
const char *suffix = "";
if (whichChan == plAudioCore::kLeft)
strcat(cachedPath, "-Left.tmp");
suffix = "-Left.tmp";
else if (whichChan == plAudioCore::kRight)
strcat(cachedPath, "-Right.tmp");
suffix = "-Right.tmp";
else if (whichChan == plAudioCore::kAll)
strcat(cachedPath, ".tmp");
suffix = ".tmp";
// Get the path to the cached version of the file, without the extension
return plFileName::Join(cachedPath, path.GetFileNameNoExt() + suffix);
}
void plAudioFileReader::ICacheFile(const char* path, bool noOverwrite, plAudioCore::ChannelSelect whichChan)
void plAudioFileReader::ICacheFile(const plFileName& path, bool noOverwrite, plAudioCore::ChannelSelect whichChan)
{
char cachedPath[256];
IGetCachedPath(path, cachedPath, whichChan);
if (!noOverwrite || !plFileUtils::FileExists(cachedPath))
plFileName cachedPath = IGetCachedPath(path, whichChan);
if (!noOverwrite || !plFileInfo(cachedPath).Exists())
{
plAudioFileReader* reader = plAudioFileReader::CreateReader(path, whichChan, kStreamNative);
if (!reader || !reader->IsValid())
@ -169,7 +161,7 @@ void plAudioFileReader::ICacheFile(const char* path, bool noOverwrite, plAudioCo
}
}
void plAudioFileReader::CacheFile(const char* path, bool splitChannels, bool noOverwrite)
void plAudioFileReader::CacheFile(const plFileName& path, bool splitChannels, bool noOverwrite)
{
if (splitChannels)
{

13
Sources/Plasma/PubUtilLib/plAudioCore/plAudioFileReader.h

@ -55,6 +55,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//// Class Definition ////////////////////////////////////////////////////////
class plFileName;
class plUnifiedTime;
class plWAVHeader;
class plAudioFileReader
@ -80,20 +81,20 @@ public:
virtual bool Read( uint32_t numBytes, void *buffer ) = 0;
virtual uint32_t NumBytesLeft( void ) = 0;
virtual bool OpenForWriting( const char *path, plWAVHeader &header ) { return false; }
virtual bool OpenForWriting( const plFileName& path, plWAVHeader &header ) { return false; }
virtual uint32_t Write( uint32_t bytes, void *buffer ) { return 0; }
virtual bool IsValid( void ) = 0;
static plAudioFileReader* CreateReader(const char* path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll, StreamType type = kStreamWAV);
static plAudioFileReader* CreateWriter(const char* path, plWAVHeader& header);
static plAudioFileReader* CreateReader(const plFileName& path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll, StreamType type = kStreamWAV);
static plAudioFileReader* CreateWriter(const plFileName& path, plWAVHeader& header);
// Decompresses a compressed file to the cache directory
static void CacheFile(const char* path, bool splitChannels=false, bool noOverwrite=false);
static void CacheFile(const plFileName& path, bool splitChannels=false, bool noOverwrite=false);
protected:
static void IGetCachedPath(const char* path, char* cachedPath, plAudioCore::ChannelSelect whichChan);
static void ICacheFile(const char* path, bool noOverwrite, plAudioCore::ChannelSelect whichChan);
static plFileName IGetCachedPath(const plFileName& path, plAudioCore::ChannelSelect whichChan);
static void ICacheFile(const plFileName& path, bool noOverwrite, plAudioCore::ChannelSelect whichChan);
};
#endif //_plAudioFileReader_h

5
Sources/Plasma/PubUtilLib/plAudioCore/plBufferedFileReader.cpp

@ -57,6 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <string.h>
#include "HeadSpin.h"
#include "plBufferedFileReader.h"
#include "plFileSystem.h"
//#include "plProfile.h"
@ -64,14 +65,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//// Constructor/Destructor //////////////////////////////////////////////////
plBufferedFileReader::plBufferedFileReader( const char *path, plAudioCore::ChannelSelect whichChan )
plBufferedFileReader::plBufferedFileReader( const plFileName &path, plAudioCore::ChannelSelect whichChan )
{
// Init some stuff
fBufferSize = 0;
fBuffer = nil;
fCursor = 0;
hsAssert( path != nil, "Invalid path specified in plBufferedFileReader" );
hsAssert( path.IsValid(), "Invalid path specified in plBufferedFileReader" );
// Ask plAudioFileReader for another reader to get this file
// Note: have this reader do the chanSelect for us

8
Sources/Plasma/PubUtilLib/plAudioCore/plBufferedFileReader.h

@ -59,7 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plBufferedFileReader : public plAudioFileReader
{
public:
plBufferedFileReader( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
plBufferedFileReader( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
virtual ~plBufferedFileReader();
virtual plWAVHeader &GetHeader( void );
@ -72,10 +72,10 @@ public:
virtual bool IsValid( void ) { return ( fBuffer != nil ) ? true : false; }
protected:
uint32_t fBufferSize;
uint8_t *fBuffer;
uint32_t fBufferSize;
uint8_t *fBuffer;
plWAVHeader fHeader;
uint32_t fCursor;
uint32_t fCursor;
void IError( const char *msg );
};

18
Sources/Plasma/PubUtilLib/plAudioCore/plCachedFileReader.cpp

@ -55,16 +55,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//// Constructor/Destructor //////////////////////////////////////////////////
plCachedFileReader::plCachedFileReader(const char *path,
plCachedFileReader::plCachedFileReader(const plFileName &path,
plAudioCore::ChannelSelect whichChan)
: fFileHandle(nil), fCurPosition(0)
: fFilename(path), fFileHandle(nil), fCurPosition(0)
{
hsAssert(path != nil, "Invalid path specified in plCachedFileReader");
strncpy(fFilename, path, sizeof(fFilename));
hsAssert(path.IsValid(), "Invalid path specified in plCachedFileReader");
/// Open the file as a plain binary stream
fFileHandle = fopen(path, "rb");
fFileHandle = plFileSystem::Open(path, "rb");
if (fFileHandle != nil)
{
if (fread(&fHeader, 1, sizeof(plWAVHeader), fFileHandle)
@ -162,17 +160,17 @@ uint32_t plCachedFileReader::NumBytesLeft()
return fDataLength - fCurPosition;
}
bool plCachedFileReader::OpenForWriting(const char *path, plWAVHeader &header)
bool plCachedFileReader::OpenForWriting(const plFileName &path, plWAVHeader &header)
{
hsAssert(path != nil, "Invalid path specified in plCachedFileReader");
hsAssert(path.IsValid(), "Invalid path specified in plCachedFileReader");
fHeader = header;
fCurPosition = 0;
fDataLength = 0;
strncpy(fFilename, path, sizeof(fFilename));
fFilename = path;
/// Open the file as a plain binary stream
fFileHandle = fopen(path, "wb");
fFileHandle = plFileSystem::Open(path, "wb");
if (fFileHandle != nil)
{

11
Sources/Plasma/PubUtilLib/plAudioCore/plCachedFileReader.h

@ -54,13 +54,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _plcachedfilereader_h
#include "plAudioFileReader.h"
#include "plFileSystem.h"
//// Class Definition ////////////////////////////////////////////////////////
class plCachedFileReader : public plAudioFileReader
{
public:
plCachedFileReader(const char *path,
plCachedFileReader(const plFileName &path,
plAudioCore::ChannelSelect whichChan = plAudioCore::kAll);
virtual ~plCachedFileReader();
@ -75,7 +76,7 @@ public:
virtual bool Read(uint32_t numBytes, void *buffer);
virtual uint32_t NumBytesLeft();
virtual bool OpenForWriting(const char *path, plWAVHeader &header);
virtual bool OpenForWriting(const plFileName &path, plWAVHeader &header);
virtual uint32_t Write(uint32_t bytes, void *buffer);
virtual bool IsValid() { return fFileHandle != nil; }
@ -86,11 +87,11 @@ protected:
kPCMFormatTag = 1
};
char fFilename[512];
plFileName fFilename;
FILE * fFileHandle;
plWAVHeader fHeader;
uint32_t fDataLength;
uint32_t fCurPosition;
uint32_t fDataLength;
uint32_t fCurPosition;
void IError(const char *msg);
};

12
Sources/Plasma/PubUtilLib/plAudioCore/plFastWavReader.cpp

@ -112,14 +112,14 @@ class plRIFFHeader
//// Constructor/Destructor //////////////////////////////////////////////////
plFastWAV::plFastWAV( const char *path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil )
plFastWAV::plFastWAV( const plFileName &path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil )
{
hsAssert( path != nil, "Invalid path specified in plFastWAV reader" );
hsAssert(path.IsValid(), "Invalid path specified in plFastWAV reader");
strncpy( fFilename, path, sizeof( fFilename ) );
fFilename = path;
fWhichChannel = whichChan;
fFileHandle = fopen( path, "rb" );
fFileHandle = plFileSystem::Open(path, "rb");
if( fFileHandle != nil )
{
/// Read in our header and calc our start position
@ -226,8 +226,8 @@ void plFastWAV::Open()
{
if(fFileHandle)
return;
fFileHandle = fopen( fFilename, "rb" );
fFileHandle = plFileSystem::Open(fFilename, "rb");
if(!fFileHandle)
return;

11
Sources/Plasma/PubUtilLib/plAudioCore/plFastWavReader.h

@ -51,6 +51,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _plFastWavReader_h
#include "plAudioFileReader.h"
#include "plFileSystem.h"
//// Class Definition ////////////////////////////////////////////////////////
@ -60,7 +61,7 @@ class plRIFFChunk;
class plFastWAV : public plAudioFileReader
{
public:
plFastWAV( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
plFastWAV( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
virtual ~plFastWAV();
virtual plWAVHeader &GetHeader( void );
@ -83,13 +84,13 @@ protected:
kPCMFormatTag = 1
};
char fFilename[ 512 ];
plFileName fFilename;
FILE * fFileHandle;
plWAVHeader fHeader, fFakeHeader;
uint32_t fDataStartPos, fCurrDataPos, fDataSize;
uint32_t fChunkStart;
uint32_t fDataStartPos, fCurrDataPos, fDataSize;
uint32_t fChunkStart;
plAudioCore::ChannelSelect fWhichChannel;
uint32_t fChannelAdjust, fChannelOffset;
uint32_t fChannelAdjust, fChannelOffset;
void IError( const char *msg );
bool ISeekToChunk( const char *type, plRIFFChunk *c );

10
Sources/Plasma/PubUtilLib/plAudioCore/plOGGCodec.cpp

@ -65,7 +65,7 @@ uint8_t plOGGCodec::fDecodeFlags = 0;
//// Constructor/Destructor //////////////////////////////////////////////////
plOGGCodec::plOGGCodec( const char *path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil )
plOGGCodec::plOGGCodec( const plFileName &path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil )
{
fOggFile = nil;
IOpen( path, whichChan );
@ -112,17 +112,17 @@ bool plOGGCodec::ReadFromHeader(int numBytes, void *data)
return false;
}
void plOGGCodec::IOpen( const char *path, plAudioCore::ChannelSelect whichChan )
void plOGGCodec::IOpen( const plFileName &path, plAudioCore::ChannelSelect whichChan )
{
hsAssert( path != nil, "Invalid path specified in plOGGCodec reader" );
hsAssert( path.IsValid(), "Invalid path specified in plOGGCodec reader" );
// plNetClientApp::StaticDebugMsg("Ogg Open %s, t=%f, start", path, hsTimer::GetSeconds());
strncpy( fFilename, path, sizeof( fFilename ) );
fFilename = path;
fWhichChannel = whichChan;
/// Open the file as a plain binary stream
fFileHandle = fopen( path, "rb" );
fFileHandle = plFileSystem::Open(path, "rb");
if( fFileHandle != nil )
{
/// Create the OGG data struct

21
Sources/Plasma/PubUtilLib/plAudioCore/plOGGCodec.h

@ -49,6 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define _plOGGCodec_h
#include "plAudioFileReader.h"
#include "plFileSystem.h"
//// Class Definition ////////////////////////////////////////////////////////
@ -59,7 +60,7 @@ class plOGGCodec : public plAudioFileReader
{
public:
plOGGCodec( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
plOGGCodec( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
virtual ~plOGGCodec();
enum DecodeFormat
@ -88,7 +89,7 @@ public:
static void SetDecodeFormat( DecodeFormat f ) { fDecodeFormat = f; }
static void SetDecodeFlag( uint8_t flag, bool on ) { if( on ) fDecodeFlags |= flag; else fDecodeFlags &= ~flag; }
static uint8_t GetDecodeFlags( void ) { return fDecodeFlags; }
static uint8_t GetDecodeFlags( void ) { return fDecodeFlags; }
void ResetWaveHeaderRef() { fCurHeaderPos = 0; }
void BuildActualWaveHeader();
bool ReadFromHeader(int numBytes, void *data); // read from Actual wave header
@ -100,23 +101,23 @@ protected:
kPCMFormatTag = 1
};
char fFilename[ 512 ];
FILE *fFileHandle;
OggVorbis_File *fOggFile;
plFileName fFilename;
FILE *fFileHandle;
OggVorbis_File *fOggFile;
plWAVHeader fHeader, fFakeHeader;
uint32_t fDataStartPos, fCurrDataPos, fDataSize;
uint32_t fDataStartPos, fCurrDataPos, fDataSize;
plAudioCore::ChannelSelect fWhichChannel;
uint32_t fChannelAdjust, fChannelOffset;
uint32_t fChannelAdjust, fChannelOffset;
static DecodeFormat fDecodeFormat;
static uint8_t fDecodeFlags;
uint8_t * fHeadBuf;
static uint8_t fDecodeFlags;
uint8_t * fHeadBuf;
int fCurHeaderPos;
void IError( const char *msg );
void IOpen( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
void IOpen( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
};
#endif //_plOGGCodec_h

90
Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp

@ -49,35 +49,31 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h"
#include "hsResMgr.h"
#include "pnMessage/plRefMsg.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.h"
#include "hsTimer.h"
static void GetFullPath( const char filename[], char *destStr )
static plFileName GetFullPath(const plFileName &filename)
{
char path[ kFolderIterator_MaxPath ];
if (filename.StripFileName().IsValid())
return filename;
if( strchr( filename, '\\' ) != nil )
strcpy( path, filename );
else
sprintf( path, "sfx\\%s", filename );
strcpy( destStr, path );
return plFileName::Join("sfx", filename);
}
//// IGetReader //////////////////////////////////////////////////////////////
// Makes sure the sound is ready to load without any extra processing (like
// decompression or the like), then opens a reader for it.
// fullpath tells the function whether to append 'sfx' to the path or not (we don't want to do this if were providing the full path)
static plAudioFileReader *CreateReader( bool fullpath, const char filename[], plAudioFileReader::StreamType type, plAudioCore::ChannelSelect channel )
static plAudioFileReader *CreateReader( bool fullpath, const plFileName &filename, plAudioFileReader::StreamType type, plAudioCore::ChannelSelect channel )
{
char path[512];
if(fullpath) GetFullPath(filename, path);
plFileName path;
if (fullpath)
path = GetFullPath(filename);
else
strcpy(path, filename);
path = filename;
plAudioFileReader* reader = plAudioFileReader::CreateReader(path, channel, type);
if( reader == nil || !reader->IsValid() )
@ -115,11 +111,11 @@ hsError plSoundPreloader::Run()
if (buf->GetData())
{
reader = CreateReader(true, buf->GetFileName(), buf->GetAudioReaderType(), buf->GetReaderSelect());
reader = CreateReader(true, buf->GetFileName(), buf->GetAudioReaderType(), buf->GetReaderSelect());
if( reader )
{
unsigned readLen = buf->GetAsyncLoadLength() ? buf->GetAsyncLoadLength() : buf->GetDataLength();
unsigned readLen = buf->GetAsyncLoadLength() ? buf->GetAsyncLoadLength() : buf->GetDataLength();
reader->Read( readLen, buf->GetData() );
buf->SetAudioReader(reader); // give sound buffer reader, since we may need it later
}
@ -166,7 +162,7 @@ plSoundBuffer::plSoundBuffer()
IInitBuffer();
}
plSoundBuffer::plSoundBuffer( const char *fileName, uint32_t flags )
plSoundBuffer::plSoundBuffer( const plFileName &fileName, uint32_t flags )
{
IInitBuffer();
SetFileName( fileName );
@ -186,7 +182,6 @@ plSoundBuffer::~plSoundBuffer()
}
}
delete [] fFileName;
UnLoad();
}
@ -194,7 +189,7 @@ void plSoundBuffer::IInitBuffer()
{
fError = false;
fValid = false;
fFileName = nil;
fFileName = "";
fData = nil;
fDataLength = 0;
fFlags = 0;
@ -225,7 +220,7 @@ void plSoundBuffer::Read( hsStream *s, hsResMgr *mgr )
s->ReadLE( &fFlags );
s->ReadLE( &fDataLength );
fFileName = s->ReadSafeString();
fFileName = s->ReadSafeString_TEMP();
s->ReadLE( &fHeader.fFormatTag );
s->ReadLE( &fHeader.fNumChannels );
@ -266,16 +261,10 @@ void plSoundBuffer::Write( hsStream *s, hsResMgr *mgr )
s->WriteLE( fDataLength );
// Truncate the path to just a file name on write
if( fFileName != nil )
{
char *nameOnly = strrchr( fFileName, '\\' );
if( nameOnly != nil )
s->WriteSafeString( nameOnly + 1 );
else
s->WriteSafeString( fFileName );
}
if (fFileName.IsValid())
s->WriteSafeString(fFileName.GetFileName());
else
s->WriteSafeString( "" );
s->WriteSafeString("");
s->WriteLE( fHeader.fFormatTag );
s->WriteLE( fHeader.fNumChannels );
@ -290,7 +279,7 @@ void plSoundBuffer::Write( hsStream *s, hsResMgr *mgr )
//// SetFileName /////////////////////////////////////////////////////////////
void plSoundBuffer::SetFileName( const char *name )
void plSoundBuffer::SetFileName( const plFileName &name )
{
if(fLoading)
{
@ -298,11 +287,7 @@ void plSoundBuffer::SetFileName( const char *name )
return;
}
delete [] fFileName;
if( name != nil )
fFileName = hsStrcpy( name );
else
fFileName = nil;
fFileName = name;
// Data is no longer valid
UnLoad();
@ -325,22 +310,17 @@ plAudioCore::ChannelSelect plSoundBuffer::GetReaderSelect( void ) const
//// IGetFullPath ////////////////////////////////////////////////////////////
// Construct our current full path to our sound.
void plSoundBuffer::IGetFullPath( char *destStr )
plFileName plSoundBuffer::IGetFullPath()
{
if(!fFileName)
if (!fFileName.IsValid())
{
*destStr = 0;
return;
return plFileName();
}
char path[ kFolderIterator_MaxPath ];
if( strchr( fFileName, '\\' ) != nil )
strcpy( path, fFileName );
else
sprintf( path, "sfx\\%s", fFileName );
if (fFileName.StripFileName().IsValid())
return fFileName;
strcpy( destStr, path );
return plFileName::Join("sfx", fFileName);
}
@ -459,8 +439,9 @@ void plSoundBuffer::SetLoaded(bool loaded)
void plSoundBuffer::SetInternalData( plWAVHeader &header, uint32_t length, uint8_t *data )
{
if(fLoading) return;
fFileName = nil;
if (fLoading)
return;
fFileName = "";
fHeader = header;
fFlags = 0;
@ -509,11 +490,9 @@ plSoundBuffer::ELoadReturnVal plSoundBuffer::EnsureInternal()
//// IGrabHeaderInfo /////////////////////////////////////////////////////////
bool plSoundBuffer::IGrabHeaderInfo( void )
{
static char path[ 512 ];
if( fFileName != nil )
if (fFileName.IsValid())
{
IGetFullPath( path );
plFileName path = IGetFullPath();
// Go grab from the WAV file
if(!fReader)
@ -545,10 +524,11 @@ bool plSoundBuffer::IGrabHeaderInfo( void )
// fullpath tells the function whether to append 'sfx' to the path or not (we don't want to do this if were providing the full path)
plAudioFileReader *plSoundBuffer::IGetReader( bool fullpath )
{
char path[512];
if(fullpath) IGetFullPath(path);
plFileName path;
if (fullpath)
path = IGetFullPath();
else
strcpy(path, fFileName);
path = fFileName;
// Go grab from the WAV file
plAudioFileReader::StreamType type = plAudioFileReader::kStreamWAV;

35
Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.h

@ -56,16 +56,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudioCore.h"
#include "plAudioFileReader.h"
#include "hsThread.h"
#include "plFileSystem.h"
//// Class Definition ////////////////////////////////////////////////////////
class plUnifiedTime;
class plAudioFileReader;
class plSoundBuffer : public hsKeyedObject
{
{
public:
plSoundBuffer();
plSoundBuffer( const char *fileName, uint32_t flags = 0 );
plSoundBuffer( const plFileName &fileName, uint32_t flags = 0 );
~plSoundBuffer();
CLASSNAME_REGISTER( plSoundBuffer );
@ -93,14 +94,14 @@ public:
virtual void Write( hsStream *s, hsResMgr *mgr );
plWAVHeader &GetHeader( void ) { return fHeader; }
uint32_t GetDataLength( void ) const { return fDataLength; }
uint32_t GetDataLength( void ) const { return fDataLength; }
void SetDataLength(unsigned length) { fDataLength = length; }
void *GetData( void ) const { return fData; }
const char *GetFileName( void ) const { return fFileName; }
void *GetData( void ) const { return fData; }
plFileName GetFileName( void ) const { return fFileName; }
bool IsValid( void ) const { return fValid; }
float GetDataLengthInSecs( void ) const;
float GetDataLengthInSecs( void ) const;
void SetFileName( const char *name );
void SetFileName( const plFileName &name );
bool HasFlag( uint32_t flag ) { return ( fFlags & flag ) ? true : false; }
void SetFlag( uint32_t flag, bool yes = true ) { if( yes ) fFlags |= flag; else fFlags &= ~flag; }
@ -135,22 +136,22 @@ protected:
bool IGrabHeaderInfo( void );
void IAddBuffers( void *base, void *toAdd, uint32_t lengthInBytes, uint8_t bitsPerSample );
void IGetFullPath( char *destStr );
uint32_t fFlags;
plFileName IGetFullPath();
uint32_t fFlags;
bool fValid;
uint32_t fDataRead;
char *fFileName;
uint32_t fDataRead;
plFileName fFileName;
bool fLoaded;
bool fLoading;
bool fError;
plAudioFileReader * fReader;
uint8_t * fData;
plAudioFileReader * fReader;
uint8_t * fData;
plWAVHeader fHeader;
uint32_t fDataLength;
uint32_t fAsyncLoadLength;
uint32_t fDataLength;
uint32_t fAsyncLoadLength;
plAudioFileReader::StreamType fStreamType;
// for plugins only

2
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp

@ -277,7 +277,7 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr)
if (fAccessoryName)
{
plString strBuf = plString::Format("CItm_%s", fAccessoryName);
accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", nil, plClothingItem::Index(), strBuf);
accessoryKey = plKeyFinder::Instance().StupidSearch("GlobalClothing", "", plClothingItem::Index(), strBuf);
if (accessoryKey == nil)
{
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName);

2
Sources/Plasma/PubUtilLib/plFile/CMakeLists.txt

@ -8,7 +8,6 @@ set(plFile_SOURCES
hsFiles.cpp
plBrowseFolder.cpp
plEncryptedStream.cpp
plFileUtils.cpp
plInitFileReader.cpp
plSecureStream.cpp
plStreamSource.cpp
@ -26,7 +25,6 @@ set(plFile_HEADERS
hsFiles.h
plBrowseFolder.h
plEncryptedStream.h
plFileUtils.h
plInitFileReader.h
plSecureStream.h
plStreamSource.h

5
Sources/Plasma/PubUtilLib/plFile/hsFiles_Unix.cpp

@ -52,7 +52,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <glob.h>
#include <string>
#include "hsTemplates.h"
#include "plFileUtils.h"
struct hsFolderIterator_Data {
glob_t fGlobBuf;
@ -122,8 +121,8 @@ const char* hsFolderIterator::GetFileName() const
if (!fData->fInited || fData->fCnt > fData->fGlobBuf.gl_pathc)
throw "end of folder";
const char* fn=fData->fGlobBuf.gl_pathv[fData->fCnt-1];
return plFileUtils::GetFileName(fn);
plFileName fn = fData->fGlobBuf.gl_pathv[fData->fCnt-1];
return fn.GetFileName().c_str();
}
bool hsFolderIterator::IsDirectory( void ) const

30
Sources/Plasma/PubUtilLib/plFile/plBrowseFolder.cpp

@ -45,22 +45,26 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <shlobj.h>
bool plBrowseFolder::GetFolder(char *path, const char *startPath, const char *title, HWND hwndOwner)
plFileName plBrowseFolder::GetFolder(const plFileName &startPath, const plString &title, HWND hwndOwner)
{
BROWSEINFO bi;
BROWSEINFOW bi;
memset(&bi, 0, sizeof(bi));
bi.hwndOwner = hwndOwner;
bi.lpszTitle = title;
bi.lpszTitle = title.ToWchar();
bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) startPath;
ITEMIDLIST *iil = SHBrowseForFolder(&bi);
// Browse failed, or cancel was selected
if (!iil)
return false;
// Browse succeded. Get the path.
else
SHGetPathFromIDList(iil, path);
bi.lParam = (LPARAM) startPath.AsString().ToWchar().GetData();
LPITEMIDLIST iil = SHBrowseForFolderW(&bi);
plFileName path;
if (!iil) {
// Browse failed, or cancel was selected
path = "";
} else {
// Browse succeded. Get the path.
wchar_t buffer[MAX_PATH];
SHGetPathFromIDListW(iil, buffer);
path = plString::FromWchar(buffer);
}
// Free the memory allocated by SHBrowseForFolder
LPMALLOC pMalloc;
@ -68,7 +72,7 @@ bool plBrowseFolder::GetFolder(char *path, const char *startPath, const char *ti
pMalloc->Free(iil);
pMalloc->Release();
return true;
return path;
}
int CALLBACK plBrowseFolder::BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)

3
Sources/Plasma/PubUtilLib/plFile/plBrowseFolder.h

@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsWindows.h"
#include "plFileSystem.h"
//
// Gets a directory using the "Browse for Folder" dialog.
@ -63,7 +64,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plBrowseFolder
{
public:
static bool GetFolder(char *path, const char *startPath = NULL, const char *title = NULL, HWND hwndOwner = NULL);
static plFileName GetFolder(const plFileName &startPath = "", const plString &title = "", HWND hwndOwner = NULL);
protected:
static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);

1
Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "plEncryptedStream.h"
#include "plFileUtils.h"
#include "hsSTLStream.h"
#include <time.h>

503
Sources/Plasma/PubUtilLib/plFile/plFileUtils.cpp

@ -1,503 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/////////////////////////////////////////////////////////////////////////////
//
// plFileUtils - Namespace of fun file utilities
//
//// History /////////////////////////////////////////////////////////////////
//
// 5.7.2002 mcn - Created
// 4.8.2003 chip - added FileCopy and FileMove for Unix
//
//////////////////////////////////////////////////////////////////////////////
#include "HeadSpin.h"
#include "hsWindows.h"
#include "plFileUtils.h"
#include "hsFiles.h"
#include "hsStringTokenizer.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#if HS_BUILD_FOR_WIN32
#include <direct.h>
#include <io.h>
#define mkdir _mkdir
#define chdir _chdir
#define chmod _chmod
#define rmdir _rmdir
#define unlink _unlink
#endif
#if HS_BUILD_FOR_UNIX
#include <unistd.h>
#include <utime.h>
#endif
//// CreateDir ///////////////////////////////////////////////////////////////
// Creates the directory specified. Returns false if unsuccessful or
// directory already exists
bool plFileUtils::CreateDir( const char *path )
{
// Create our directory
#if HS_BUILD_FOR_WIN32
return ( mkdir( path ) == 0 ) ? true : ( errno==EEXIST );
#elif HS_BUILD_FOR_UNIX
return ( mkdir( path, 0777 ) == 0 ) ? true : ( errno==EEXIST );
#endif
}
bool plFileUtils::CreateDir( const wchar_t *path )
{
// Create our directory
#if HS_BUILD_FOR_WIN32
return ( _wmkdir( path ) == 0 ) ? true : ( errno==EEXIST );
#elif HS_BUILD_FOR_UNIX
const char* cpath = hsWStringToString(path);
bool ret = CreateDir(cpath);
delete[] cpath; /* Free the string */
return ret;
#endif
}
bool plFileUtils::RemoveDir(const char* path)
{
return (rmdir(path) == 0);
}
bool plFileUtils::RemoveDirTree(const char * path)
{
hsFolderIterator it(path);
while (it.NextFile())
{
const char * fname = it.GetFileName();
if ( fname[0]=='.' )
continue;
char pathAndName[128];
it.GetPathAndName(pathAndName);
if ( it.IsDirectory() )
{
RemoveDirTree( pathAndName );
RemoveDir( pathAndName );
}
else
{
RemoveFile( pathAndName );
}
}
RemoveDir( path );
return 1;
}
//// RemoveFile ////////////////////////////////////////////////////////////
bool plFileUtils::RemoveFile(const char* filename, bool delReadOnly)
{
if (delReadOnly)
chmod(filename, S_IWRITE);
return (unlink(filename) == 0);
}
bool plFileUtils::RemoveFile(const wchar_t* filename, bool delReadOnly)
{
#ifdef HS_BUILD_FOR_WIN32
if (delReadOnly)
_wchmod(filename, S_IWRITE);
return (_wunlink(filename) == 0);
#elif HS_BUILD_FOR_UNIX
const char* cfilename = hsWStringToString(filename);
bool ret = RemoveFile(cfilename, delReadOnly);
delete[] cfilename; /* Free the string */
return ret;
#endif
}
bool plFileUtils::FileCopy(const char* existingFile, const char* newFile)
{
wchar_t* wExisting = hsStringToWString(existingFile);
wchar_t* wNew = hsStringToWString(newFile);
bool ret = FileCopy(wExisting, wNew);
delete [] wExisting;
delete [] wNew;
return ret;
}
bool plFileUtils::FileCopy(const wchar_t* existingFile, const wchar_t* newFile)
{
#if HS_BUILD_FOR_WIN32
return (::CopyFileW(existingFile, newFile, FALSE) != 0);
#elif HS_BUILD_FOR_UNIX
char data[1500];
const char* cexisting = hsWStringToString(existingFile);
const char* cnew = hsWStringToString(newFile);
FILE* fp = fopen(cexisting, "rb");
FILE* fw = fopen(cnew, "w");
delete[] cexisting;
delete[] cnew;
int num = 0;
bool retVal = true;
if (fp && fw){
while(!feof(fp)){
num = fread(data, sizeof( char ), 1500, fp);
if( ferror( fp ) ) {
retVal = false;
break;
}
fwrite(data, sizeof( char ), num, fw);
}
fclose(fp);
fclose(fw);
} else {
retVal = false;
}
return retVal;
#else
hsAssert(0, "Not implemented");
return false;
#endif
}
bool plFileUtils::FileMove(const char* existingFile, const char* newFile)
{
#if HS_BUILD_FOR_WIN32
return (::MoveFile(existingFile, newFile) != 0);
#elif HS_BUILD_FOR_UNIX
FileCopy(existingFile,newFile);
return( RemoveFile( existingFile )==0);
#else
hsAssert(0, "Not implemented");
return false;
#endif
}
bool plFileUtils::FileMove(const wchar_t* existingFile, const wchar_t* newFile)
{
#if HS_BUILD_FOR_WIN32
return (::MoveFileW(existingFile, newFile) != 0);
#elif HS_BUILD_FOR_UNIX
FileCopy(existingFile,newFile);
return( RemoveFile( existingFile )==0);
#else
hsAssert(0, "Not implemented");
return false;
#endif
}
bool plFileUtils::FileExists(const wchar_t* file)
{
FILE* fp = hsWFopen(file, L"rb");
bool retVal = (fp != nil);
if (fp)
fclose(fp);
return retVal;
}
bool plFileUtils::FileExists(const char* file)
{
FILE* fp = fopen(file, "rb");
bool retVal = (fp != nil);
if (fp)
fclose(fp);
return retVal;
}
//// EnsureFilePathExists ////////////////////////////////////////////////////
// Given a filename with path, makes sure the file's path exists
bool plFileUtils::EnsureFilePathExists( const char *filename )
{
wchar_t* wFilename = hsStringToWString(filename);
bool ret = EnsureFilePathExists(wFilename);
delete [] wFilename;
return ret;
}
bool plFileUtils::EnsureFilePathExists( const wchar_t *filename )
{
hsWStringTokenizer izer( filename, L"\\/" );
bool lastWorked = false;
wchar_t token[ kFolderIterator_MaxPath ];
while( izer.Next( token, arrsize( token ) ) && izer.HasMoreTokens() )
{
// Want the full path from the start of the string
lastWorked = CreateDir( izer.fString );
izer.RestoreLastTerminator();
}
return lastWorked;
}
//// GetFileTimes ////////////////////////////////////////////////////////////
// Gets the creation and modification dates of the file specified. Returns
// false if unsuccessful
bool plFileUtils::GetFileTimes( const char *path, plUnifiedTime *createTimeOut, plUnifiedTime *modifyTimeOut )
{
struct stat fileInfo;
int result = stat( path, &fileInfo );
if( result != 0 )
return false;
if( createTimeOut != nil )
*createTimeOut = plUnifiedTime( fileInfo.st_ctime );
if( modifyTimeOut != nil )
*modifyTimeOut = plUnifiedTime( fileInfo.st_mtime );
return true;
}
plFileUtils::Modify plFileUtils::CompareModifyTimes(const char* file1, const char* file2)
{
plUnifiedTime modTime1, modTime2;
if (GetFileTimes(file1, nil, &modTime1) &&
GetFileTimes(file2, nil, &modTime2))
{
double diff = plUnifiedTime::GetTimeDifference(modTime1, modTime2);
if (hsABS(diff) <= 2)
return kFilesEqual;
else if (diff > 0)
return kFile1Newer;
else
return kFile2Newer;
}
return kFileError;
}
bool plFileUtils::SetModifyTime( const char * filename, const plUnifiedTime & timestamp )
{
#ifdef HS_BUILD_FOR_WIN32
HANDLE hFile = CreateFile(filename,
GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,
nil,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,nil);
if (hFile==INVALID_HANDLE_VALUE)
return false;
SYSTEMTIME systime;
systime.wDay = timestamp.GetDay();
systime.wDayOfWeek = timestamp.GetDayOfWeek();
systime.wHour = timestamp.GetHour();
systime.wMilliseconds = 0;
systime.wMinute = timestamp.GetMinute();
systime.wMonth = timestamp.GetMonth();
systime.wSecond = timestamp.GetSecond();
systime.wYear = timestamp.GetYear();
FILETIME localFileTime, filetime;
SystemTimeToFileTime(&systime,&localFileTime);
LocalFileTimeToFileTime(&localFileTime,&filetime);
SetFileTime(hFile,nil,nil,&filetime);
CloseHandle(hFile);
return true;
#elif HS_BUILD_FOR_UNIX
struct stat sbuf;
int result = stat( filename, &sbuf );
if( result )
return false;
struct utimbuf utb;
utb.actime = sbuf.st_atime;
utb.modtime = timestamp.GetSecs();
result = utime( filename, &utb );
if( result )
return false;
return true;
#endif
}
//// StripPath ///////////////////////////////////////////////////////////////
const char* plFileUtils::GetFileName(const char* path)
{
const char* c = strrchr(path, '/');
if (c == nil)
c = strrchr(path, '\\');
if (c == nil)
c = path;
else
c++;
return c;
}
const wchar_t* plFileUtils::GetFileName(const wchar_t* path)
{
const wchar_t* c = wcsrchr(path, L'/');
if (c == nil)
c = wcsrchr(path, L'\\');
if (c == nil)
c = path;
else
c++;
return c;
}
void plFileUtils::StripFile(char* pathAndName)
{
char* fileName = (char*)GetFileName(pathAndName);
if (fileName != pathAndName)
*fileName = '\0';
}
void plFileUtils::StripFile(wchar_t* pathAndName)
{
wchar_t* fileName = (wchar_t*)GetFileName(pathAndName);
if (fileName != pathAndName)
*fileName = L'\0';
}
void plFileUtils::StripExt(char* fileName)
{
char* ext = (char*)GetFileExt(fileName);
if (ext)
*(ext-1) = '\0';
}
void plFileUtils::StripExt(wchar_t* fileName)
{
wchar_t* ext = (wchar_t*)GetFileExt(fileName);
if (ext)
*(ext-1) = L'\0';
}
const char* plFileUtils::GetFileExt(const char* pathAndName)
{
const char* fileName = GetFileName(pathAndName);
if (fileName)
{
const char* ext = strrchr(fileName, '.');
if (ext)
return ext+1;
}
return nil;
}
const wchar_t* plFileUtils::GetFileExt(const wchar_t* pathAndName)
{
const wchar_t* fileName = GetFileName(pathAndName);
if (fileName)
{
const wchar_t* ext = wcsrchr(fileName, L'.');
if (ext)
return ext+1;
}
return nil;
}
void plFileUtils::AddSlash(char* path)
{
char lastChar = path[strlen(path)-1];
if (lastChar != '\\' && lastChar != '/')
#if HS_BUILD_FOR_WIN32
strcat(path, "\\");
#else
strcat(path, "/");
#endif
}
void plFileUtils::AddSlash(wchar_t* path)
{
wchar_t lastChar = path[wcslen(path)-1];
if (lastChar != L'\\' && lastChar != L'/')
#if HS_BUILD_FOR_WIN32
wcscat(path, L"\\");
#else
wcscat(path, L"/");
#endif
}
void plFileUtils::ConcatFileName(char* path, const char* fileName)
{
AddSlash(path);
strcat(path, fileName);
}
void plFileUtils::ConcatFileName(wchar_t* path, const wchar_t* fileName)
{
AddSlash(path);
wcscat(path, fileName);
}
//// GetFileSize /////////////////////////////////////////////////////////////
uint32_t plFileUtils::GetFileSize( const char *path )
{
wchar_t* wPath = hsStringToWString(path);
uint32_t ret = GetFileSize(wPath);
delete [] wPath;
return ret;
}
uint32_t plFileUtils::GetFileSize( const wchar_t *path )
{
uint32_t len = 0;
hsUNIXStream str;
if (str.Open(plString::FromWchar(path), "rb"))
{
len = str.GetEOF();
str.Close();
}
return len;
}

116
Sources/Plasma/PubUtilLib/plFile/plFileUtils.h

@ -1,116 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////////////
//
// plFileUtils - Namespace of fun file utilities
//
//// History /////////////////////////////////////////////////////////////////
//
// 5.7.2002 mcn - Created
//
//////////////////////////////////////////////////////////////////////////////
#ifndef _plFileUtils_h
#define _plFileUtils_h
class plUnifiedTime;
namespace plFileUtils
{
// Creates the directory specified. Returns false if unsuccessful or directory already exists
bool CreateDir( const char *path );
bool CreateDir( const wchar_t *path );
bool RemoveDir(const char* path);
bool RemoveDirTree(const char * path);
// delete file from disk
bool RemoveFile(const char* filename, bool delReadOnly=false);
bool RemoveFile(const wchar_t* filename, bool delReadOnly=false);
bool FileCopy(const char* existingFile, const char* newFile);
bool FileCopy(const wchar_t* existingFile, const wchar_t* newFile);
bool FileMove(const char* existingFile, const char* newFile);
bool FileMove(const wchar_t* existingFile, const wchar_t* newFile);
bool FileExists(const char* file);
bool FileExists(const wchar_t* file);
// Given a filename with path, makes sure the file's path exists
bool EnsureFilePathExists( const char *filename );
bool EnsureFilePathExists( const wchar_t *filename );
// Gets the creation and modification dates of the file specified. Returns false if unsuccessful
bool GetFileTimes( const char *path, plUnifiedTime *createTimeOut, plUnifiedTime *modifyTimeOut );
// Compares file times, taking into account NTFS/FAT32 time issues
enum Modify { kFileError, kFilesEqual, kFile1Newer, kFile2Newer };
Modify CompareModifyTimes(const char* file1, const char* file2);
// Set file modify time
bool SetModifyTime( const char * filename, const plUnifiedTime & time );
// Return a pointer into the given string at the start of the actual filename (i.e. past any path info)
const char* GetFileName(const char* pathAndName);
const wchar_t* GetFileName(const wchar_t* pathAndName);
// Get the file extension (without the .), or nil if it doesn't have one
const char* GetFileExt(const char* pathAndName);
const wchar_t* GetFileExt(const wchar_t* pathAndName);
// Strips the filename off the given full path
void StripFile(char* pathAndName);
void StripFile(wchar_t* pathAndName);
void StripExt(char* fileName);
void StripExt(wchar_t* fileName);
// Get the size of the given file in bytes
uint32_t GetFileSize( const char *path );
uint32_t GetFileSize( const wchar_t *path );
// Adds a slash to the end of a filename (or does nothing if it's already there)
void AddSlash(char* path);
void AddSlash(wchar_t* path);
// Concatenates fileName onto path, making sure to add a slash if necessary
void ConcatFileName(char* path, const char* fileName);
void ConcatFileName(wchar_t* path, const wchar_t* fileName);
};
#endif // _plFileUtils_h

1
Sources/Plasma/PubUtilLib/plFile/plSecureStream.cpp

@ -44,7 +44,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSecureStream.h"
#include "hsWindows.h"
#include "plFileUtils.h"
#include "hsSTLStream.h"
#include <time.h>

1
Sources/Plasma/PubUtilLib/plFile/plStreamSource.cpp

@ -45,7 +45,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStreamSource.h"
#include "plSecureStream.h"
#include "plEncryptedStream.h"
#include "plFileUtils.h"
#if HS_BUILD_FOR_UNIX
# include <wctype.h>

6
Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.cpp

@ -89,8 +89,8 @@ void plCloneSpawnModifier::SetTarget(plSceneObject* so)
{
// Assume the clone template is in the same age we are
const plLocation& loc = GetKey()->GetUoid().GetLocation();
char ageName[256];
((plResManager*)hsgResMgr::ResMgr())->GetLocationStrings(loc, ageName, nil);
plString ageName;
((plResManager*)hsgResMgr::ResMgr())->GetLocationStrings(loc, &ageName, nil);
// Spawn the clone
plKey cloneKey = SpawnClone(fTemplateName, ageName, GetTarget()->GetLocalToWorld(), GetKey());
@ -98,7 +98,7 @@ void plCloneSpawnModifier::SetTarget(plSceneObject* so)
}
plKey plCloneSpawnModifier::SpawnClone(const char* cloneName, const char* cloneAge, const hsMatrix44& pos, plKey requestor)
plKey plCloneSpawnModifier::SpawnClone(const plString& cloneName, const plString& cloneAge, const hsMatrix44& pos, plKey requestor)
{
plResManager* resMgr = (plResManager*)hsgResMgr::ResMgr();

2
Sources/Plasma/PubUtilLib/plModifier/plCloneSpawnModifier.h

@ -71,7 +71,7 @@ public:
void SetExportTime() { fExportTime = true; }
// Console backdoor
static plKey SpawnClone(const char* cloneName, const char* cloneAge, const hsMatrix44& pos, plKey requestor);
static plKey SpawnClone(const plString& cloneName, const plString& cloneAge, const hsMatrix44& pos, plKey requestor);
};
#endif // plCloneSpawnModifier_inc

3
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.cpp

@ -1474,8 +1474,7 @@ plUoid plNetClientMgr::GetAgeSDLObjectUoid(const char* ageName) const
if (!loc.IsValid())
{
// check current age des
if (plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName() &&
!strcmp(plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName(), ageName))
if (plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName() == ageName)
loc=plAgeLoader::GetInstance()->GetCurrAgeDesc().CalcPageLocation("BuiltIn");
if (!loc.IsValid())

12
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -555,13 +555,13 @@ struct FileDownloadRequestTrans : NetAuthTrans {
FNetCliAuthFileRequestCallback m_callback;
void * m_param;
wchar_t m_filename[MAX_PATH];
plFileName m_filename;
hsStream * m_writer;
FileDownloadRequestTrans (
FNetCliAuthFileRequestCallback callback,
void * param,
const wchar_t filename[],
const plFileName & filename,
hsStream * writer
);
@ -3572,14 +3572,14 @@ bool FileListRequestTrans::Recv (
FileDownloadRequestTrans::FileDownloadRequestTrans (
FNetCliAuthFileRequestCallback callback,
void * param,
const wchar_t filename[],
const plFileName & filename,
hsStream * writer
) : NetAuthTrans(kFileDownloadRequestTrans)
, m_callback(callback)
, m_param(param)
, m_filename(filename)
, m_writer(writer)
{
StrCopy(m_filename, filename, arrsize(m_filename));
// This transaction issues "sub transactions" which must complete
// before this one even though they were issued after us.
m_hasSubTrans = true;
@ -3593,7 +3593,7 @@ bool FileDownloadRequestTrans::Send () {
const uintptr_t msg[] = {
kCli2Auth_FileDownloadRequest,
m_transId,
(uintptr_t) m_filename,
reinterpret_cast<uintptr_t>(m_filename.AsString().ToWchar().GetData()),
};
m_conn->Send(msg, arrsize(msg));
@ -5530,7 +5530,7 @@ void NetCliAuthFileListRequest (
//============================================================================
void NetCliAuthFileRequest (
const wchar_t filename[],
const plFileName & filename,
hsStream * writer,
FNetCliAuthFileRequestCallback callback,
void * param

10
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.h

@ -368,13 +368,13 @@ void NetCliAuthFileListRequest (
// File Download
//============================================================================
typedef void (*FNetCliAuthFileRequestCallback)(
ENetError result,
void * param,
const wchar_t filename[],
hsStream * writer
ENetError result,
void * param,
const plFileName & filename,
hsStream * writer
);
void NetCliAuthFileRequest (
const wchar_t filename[],
const plFileName & filename,
hsStream * writer,
FNetCliAuthFileRequestCallback callback,
void * param

34
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp

@ -145,7 +145,7 @@ struct BuildIdRequestTrans : NetFileTrans {
struct ManifestRequestTrans : NetFileTrans {
FNetCliFileManifestRequestCallback m_callback;
void * m_param;
wchar_t m_group[MAX_PATH];
wchar_t m_group[MAX_PATH];
unsigned m_buildId;
ARRAY(NetCliFileManifestEntry) m_manifest;
@ -154,7 +154,7 @@ struct ManifestRequestTrans : NetFileTrans {
ManifestRequestTrans (
FNetCliFileManifestRequestCallback callback,
void * param,
const wchar_t group[],
const wchar_t group[],
unsigned buildId
);
@ -173,7 +173,7 @@ struct DownloadRequestTrans : NetFileTrans {
FNetCliFileDownloadRequestCallback m_callback;
void * m_param;
wchar_t m_filename[MAX_PATH];
plFileName m_filename;
hsStream * m_writer;
unsigned m_buildId;
@ -182,7 +182,7 @@ struct DownloadRequestTrans : NetFileTrans {
DownloadRequestTrans (
FNetCliFileDownloadRequestCallback callback,
void * param,
const wchar_t filename[],
const plFileName & filename,
hsStream * writer,
unsigned buildId
);
@ -943,11 +943,9 @@ void ManifestRequestTrans::Post () {
}
//============================================================================
void ReadStringFromMsg(const wchar_t* curMsgPtr, wchar_t str[], unsigned maxStrLen, unsigned* length) {
StrCopy(str, curMsgPtr, maxStrLen);
str[maxStrLen - 1] = L'\0'; // make sure it's terminated
(*length) = StrLen(str);
plString ReadStringFromMsg(const wchar_t* curMsgPtr, unsigned* length) {
(*length) = wcslen(curMsgPtr);
return plString::FromWchar(curMsgPtr, *length);
}
//============================================================================
@ -1004,7 +1002,7 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the clientFilename
unsigned filenameLen;
ReadStringFromMsg(curChar, entry.clientName, arrsize(entry.clientName), &filenameLen);
entry.clientName = ReadStringFromMsg(curChar, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1016,7 +1014,7 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the downloadFilename
ReadStringFromMsg(curChar, entry.downloadName, arrsize(entry.downloadName), &filenameLen);
entry.downloadName = ReadStringFromMsg(curChar, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1028,7 +1026,7 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the md5
ReadStringFromMsg(curChar, entry.md5, arrsize(entry.md5), &filenameLen);
entry.md5 = ReadStringFromMsg(curChar, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1040,7 +1038,7 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the md5 for compressed files
ReadStringFromMsg(curChar, entry.md5compressed, arrsize(entry.md5compressed), &filenameLen);
entry.md5compressed = ReadStringFromMsg(curChar, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1129,17 +1127,17 @@ bool ManifestRequestTrans::Recv (
DownloadRequestTrans::DownloadRequestTrans (
FNetCliFileDownloadRequestCallback callback,
void * param,
const wchar_t filename[],
const plFileName & filename,
hsStream * writer,
unsigned buildId
) : NetFileTrans(kDownloadRequestTrans)
, m_callback(callback)
, m_param(param)
, m_filename(filename)
, m_writer(writer)
, m_totalBytesReceived(0)
, m_buildId(buildId)
{
StrCopy(m_filename, filename, arrsize(m_filename));
// This transaction issues "sub transactions" which must complete
// before this one even though they were issued after us.
m_hasSubTrans = true;
@ -1151,7 +1149,7 @@ bool DownloadRequestTrans::Send () {
return false;
Cli2File_FileDownloadRequest filedownloadReq;
StrCopy(filedownloadReq.filename, m_filename, arrsize(m_filename));
StrCopy(filedownloadReq.filename, m_filename.AsString().ToWchar(), arrsize(filedownloadReq.filename));
filedownloadReq.messageId = kCli2File_FileDownloadRequest;
filedownloadReq.transId = m_transId;
filedownloadReq.messageBytes = sizeof(filedownloadReq);
@ -1443,7 +1441,7 @@ void NetCliFileRegisterBuildIdUpdate (FNetCliFileBuildIdUpdateCallback callback)
void NetCliFileManifestRequest (
FNetCliFileManifestRequestCallback callback,
void * param,
const wchar_t group[],
const wchar_t group[],
unsigned buildId /* = 0 */
) {
ManifestRequestTrans * trans = new ManifestRequestTrans(
@ -1457,7 +1455,7 @@ void NetCliFileManifestRequest (
//============================================================================
void NetCliFileDownloadRequest (
const wchar_t filename[],
const plFileName & filename,
hsStream * writer,
FNetCliFileDownloadRequestCallback callback,
void * param,

22
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h

@ -97,10 +97,10 @@ void NetCliFileRegisterBuildIdUpdate (FNetCliFileBuildIdUpdateCallback callback)
// Manifest
//============================================================================
struct NetCliFileManifestEntry {
wchar_t clientName[MAX_PATH]; // path and file on client side (for comparison)
wchar_t downloadName[MAX_PATH]; // path and file on server side (for download)
wchar_t md5[MAX_PATH];
wchar_t md5compressed[MAX_PATH]; // md5 for the compressed file
plFileName clientName; // path and file on client side (for comparison)
plFileName downloadName; // path and file on server side (for download)
plString md5;
plString md5compressed; // md5 for the compressed file
unsigned fileSize;
unsigned zipSize;
unsigned flags;
@ -108,14 +108,14 @@ struct NetCliFileManifestEntry {
typedef void (*FNetCliFileManifestRequestCallback)(
ENetError result,
void * param,
const wchar_t group[],
const wchar_t group[],
const NetCliFileManifestEntry manifest[],
unsigned entryCount
);
void NetCliFileManifestRequest (
FNetCliFileManifestRequestCallback callback,
void * param,
const wchar_t group[], // the group of files you want (empty or nil = all)
const wchar_t group[], // the group of files you want (empty or nil = all)
unsigned buildId = 0 // 0 = get latest, other = get particular build (servers only)
);
@ -123,13 +123,13 @@ void NetCliFileManifestRequest (
// File Download
//============================================================================
typedef void (*FNetCliFileDownloadRequestCallback)(
ENetError result,
void * param,
const wchar_t filename[],
hsStream * writer
ENetError result,
void * param,
const plFileName & filename,
hsStream * writer
);
void NetCliFileDownloadRequest (
const wchar_t filename[],
const plFileName & filename,
hsStream * writer,
FNetCliFileDownloadRequestCallback callback,
void * param,

4
Sources/Plasma/PubUtilLib/plPipeline/plDynamicEnvMap.cpp

@ -439,7 +439,7 @@ void plDynamicEnvMap::Read(hsStream* s, hsResMgr* mgr)
nVis = s->ReadLE32();
for( i = 0; i < nVis; i++)
{
plKey key = plKeyFinder::Instance().StupidSearch(nil, nil, plVisRegion::Index(), s->ReadSafeString_TEMP());
plKey key = plKeyFinder::Instance().StupidSearch("", "", plVisRegion::Index(), s->ReadSafeString_TEMP());
if (key)
hsgResMgr::ResMgr()->AddViaNotify(key, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef);
}
@ -912,7 +912,7 @@ void plDynamicCamMap::Read(hsStream* s, hsResMgr* mgr)
nVis = s->ReadLE32();
for( i = 0; i < nVis; i++)
{
plKey key = plKeyFinder::Instance().StupidSearch(nil, nil, plVisRegion::Index(), s->ReadSafeString_TEMP());
plKey key = plKeyFinder::Instance().StupidSearch("", "", plVisRegion::Index(), s->ReadSafeString_TEMP());
if (key)
hsgResMgr::ResMgr()->AddViaNotify(key, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef);
}

4
Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp

@ -111,8 +111,8 @@ void plStatusLogDrawer::Draw(plStatusLog* curLog, plStatusLog* firstLog)
drawText.DrawRect( x, y, x + width, y + height, 0, 0, 0, 127 );
drawText.DrawString( x + 2, y + ( lineHt >> 1 ), IGetFilename( curLog ).AsString(), 127, 127, 255, 255, plDebugText::kStyleBold );
drawText.DrawRect( x + 2, y + ( lineHt << 1 ) + 1,
x + width - 8, y + ( lineHt << 1 ) + 2, 127, 127, 255, 255 );
drawText.DrawRect( x + 2, y + ( lineHt << 1 ) + 1,
x + width - 8, y + ( lineHt << 1 ) + 2, 127, 127, 255, 255 );
y += lineHt * 2;
for( i = 0; i < IGetMaxNumLines( curLog ); i++ )

36
Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp

@ -115,7 +115,7 @@ bool NameMatches(const char* obName, const char* pKName, bool subString)
return false;
}
plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
plKey plKeyFinder::StupidSearch(const plString & age, const plString & rm,
const char *className, const plString &obName, bool subString)
{
uint16_t ty = plFactory::FindClassIndex(className);
@ -129,7 +129,7 @@ protected:
plString fObjName;
bool fSubstr;
plKey fFoundKey;
const char *fAgeName;
plString fAgeName;
public:
plKey GetFoundKey( void ) const { return fFoundKey; }
@ -137,7 +137,7 @@ public:
plKeyFinderIter( uint16_t classType, const plString &obName, bool substr )
: fFoundKey( nil ), fClassType( classType ), fObjName( obName ), fSubstr( substr ) { }
plKeyFinderIter( uint16_t classType, const plString &obName, bool substr, const char *ageName )
plKeyFinderIter( uint16_t classType, const plString &obName, bool substr, const plString &ageName )
: fFoundKey( nil ), fClassType( classType ), fObjName( obName ), fSubstr( substr ),
fAgeName( ageName ) {}
@ -180,7 +180,7 @@ public:
}
};
plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
plKey plKeyFinder::StupidSearch(const plString & age, const plString & rm,
uint16_t classType, const plString &obName, bool subString)
{
if (obName.IsNull())
@ -196,9 +196,9 @@ plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
if (ty == maxClasses) // error
{ fLastError = kInvalidClass;
return nil;
}
}
if( age != nil && rm != nil )
if (!age.IsNull() && !rm.IsNull())
{
const plLocation &loc = IGetResMgr()->FindLocation( age, rm );
if( !loc.IsValid() )
@ -213,7 +213,7 @@ plKey plKeyFinder::StupidSearch(const char * age, const char * rm,
// Return value of false means it stopped somewhere, i.e. found something
return keyFinder.GetFoundKey();
}
else if( age != nil )
else if (!age.IsNull())
{
plKeyFinderIter keyFinder(classType, obName, subString, age);
@ -335,23 +335,22 @@ class plPageFinder : public plRegistryPageIterator
protected:
plRegistryPageNode **fPagePtr;
const char *fFindString, *fAgeString;
plString fFindString, fAgeString;
public:
plPageFinder( plRegistryPageNode **page, const char *find ) : fPagePtr( page ), fFindString( find ), fAgeString( nil )
plPageFinder( plRegistryPageNode **page, const plString &find ) : fPagePtr( page ), fFindString( find )
{ *fPagePtr = nil; }
plPageFinder( plRegistryPageNode **page, const char *ageS, const char *pageS ) : fPagePtr( page ), fFindString( pageS ), fAgeString( ageS )
plPageFinder( plRegistryPageNode **page, const plString &ageS, const plString &pageS ) : fPagePtr( page ), fFindString( pageS ), fAgeString( ageS )
{ *fPagePtr = nil; }
virtual bool EatPage( plRegistryPageNode *node )
{
static char str[ 512 ];
const plPageInfo &info = node->GetPageInfo();
// Are we searching by age/page?
if( fAgeString != nil )
if (!fAgeString.IsNull())
{
if (info.GetAge().CompareI(fAgeString) == 0 && info.GetPage().CompareI(fFindString) == 0)
{
@ -369,8 +368,7 @@ class plPageFinder : public plRegistryPageIterator
}
// Try for full location
sprintf( str, "%s_%s", info.GetAge().c_str(), info.GetPage().c_str() );
if( stricmp( str, fFindString ) == 0 )
if (plString::Format("%s_%s", info.GetAge().c_str(), info.GetPage().c_str()).CompareI(fFindString) == 0)
{
*fPagePtr = node;
return false;
@ -387,7 +385,7 @@ class plPageFinder : public plRegistryPageIterator
// since the only time we call this function will be to actually load
// the darned thing.
plKey plKeyFinder::FindSceneNodeKey( const char *pageOrFullLocName ) const
plKey plKeyFinder::FindSceneNodeKey( const plString &pageOrFullLocName ) const
{
plRegistryPageNode *pageNode;
plPageFinder pageFinder( &pageNode, pageOrFullLocName );
@ -404,7 +402,7 @@ plKey plKeyFinder::FindSceneNodeKey( const char *pageOrFullLocName ) const
//// FindSceneNodeKey ////////////////////////////////////////////////////////
// Age/page pair version
plKey plKeyFinder::FindSceneNodeKey( const char *ageName, const char *pageName ) const
plKey plKeyFinder::FindSceneNodeKey( const plString &ageName, const plString &pageName ) const
{
plRegistryPageNode *pageNode;
plPageFinder pageFinder( &pageNode, ageName, pageName );
@ -471,12 +469,12 @@ plKey plKeyFinder::IFindSceneNodeKey(plRegistryPageNode* page) const
//// FindLocation ////////////////////////////////////////////////////////////
const plLocation &plKeyFinder::FindLocation( const char *age, const char *page ) const
const plLocation &plKeyFinder::FindLocation(const plString &age, const plString &page) const
{
if (age == nil)
if (age == "")
{
static plLocation invalidLoc;
plRegistryPageNode *pageNode;
plRegistryPageNode *pageNode;
plPageFinder pageFinder( &pageNode, page );
if( IGetResMgr()->IterateAllPages( &pageFinder ) || pageNode == nil )

10
Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h

@ -88,8 +88,8 @@ public:
static plKeyFinder& Instance();
// These are Stupid search because they just do string searchs on the objects.
plKey StupidSearch(const char * age, const char * rm, const char *className, const plString &obName, bool subString=false);
plKey StupidSearch(const char * age, const char * rm, uint16_t objType, const plString &obName, bool subString=false);
plKey StupidSearch(const plString & age, const plString & rm, const char *className, const plString &obName, bool subString=false);
plKey StupidSearch(const plString & age, const plString & rm, uint16_t objType, const plString &obName, bool subString=false);
eErrCodes GetLastErrorCode() { return fLastError; }
const char* GetLastErrorString(); // For Console display
@ -102,11 +102,11 @@ public:
void GetActivatorNames(std::vector<plString>& names);
void GetResponderNames(std::vector<plString>& names);
plKey FindSceneNodeKey(const char* pageOrFullLocName) const;
plKey FindSceneNodeKey(const char* ageName, const char* pageName) const;
plKey FindSceneNodeKey(const plString& pageOrFullLocName) const;
plKey FindSceneNodeKey(const plString& ageName, const plString& pageName) const;
plKey FindSceneNodeKey(const plLocation& location) const;
const plLocation& FindLocation(const char* age, const char* page) const;
const plLocation& FindLocation(const plString& age, const plString& page) const;
const plPageInfo* GetLocationInfo(const plLocation& loc) const;
protected:

39
Sources/Plasma/PubUtilLib/plResMgr/plLocalization.cpp

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "plLocalization.h"
#include "plFile/plFileUtils.h"
plLocalization::Language plLocalization::fLanguage = plLocalization::kEnglish;
@ -87,36 +86,28 @@ plLocalization::encodingTypes plLocalization::fUnicodeEncoding[] =
Enc_UTF8, // kJapanese
};
bool plLocalization::IGetLocalized(const char* name, Language lang, char* localizedName)
plFileName plLocalization::IGetLocalized(const plFileName& name, Language lang)
{
const char* underscore = strrchr(name, '_');
if (underscore)
int underscore = name.AsString().FindLast('_');
if (underscore >= 0)
{
char langTag[kLangTagLen+1];
strncpy(langTag,underscore,kLangTagLen);
langTag[kLangTagLen] = '\0';
if (strncmp(langTag, fLangTags[kEnglish], kLangTagLen) == 0)
{
if (localizedName)
{
strcpy(localizedName, name);
int underscorePos = underscore - name;
memcpy(localizedName + underscorePos, fLangTags[lang], kLangTagLen);
}
return true;
}
plString langTag = name.AsString().Substr(underscore, kLangTagLen);
if (langTag == fLangTags[kEnglish])
return name.AsString().Left(underscore) + fLangTags[lang];
}
return false;
return "";
}
bool plLocalization::ExportGetLocalized(const char* name, int lang, char* localizedName)
plFileName plLocalization::ExportGetLocalized(const plFileName& name, int lang)
{
return IGetLocalized(name, Language(lang+1), localizedName) &&
plFileUtils::FileExists(localizedName);
plFileName localizedName = IGetLocalized(name, Language(lang+1));
if (plFileInfo(localizedName).Exists())
return localizedName;
return "";
}
std::string plLocalization::LocalToString(const std::vector<std::string> & localizedText)

11
Sources/Plasma/PubUtilLib/plResMgr/plLocalization.h

@ -44,6 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <vector>
#include <string>
#include "plFileSystem.h"
class plLocalization
{
@ -81,7 +82,7 @@ protected:
static bool fUsesUnicode[kNumLanguages];
static encodingTypes fUnicodeEncoding[kNumLanguages];
static bool IGetLocalized(const char* name, Language lang, char* localizedName);
static plFileName IGetLocalized(const plFileName& name, Language lang);
public:
static void SetLanguage(Language lang) { fLanguage = lang; }
@ -97,8 +98,8 @@ public:
static bool IsLocalized() { return fLanguage != kEnglish; }
// Pass in a key name and this will give you the localized name
// Returns false if the original keyname is not for a localized asset
static bool GetLocalized(const char* name, char* localizedName) { return IGetLocalized(name, fLanguage, localizedName); }
// Returns an invalid filename if the original keyname is not for a localized asset
static plFileName GetLocalized(const plFileName& name) { return IGetLocalized(name, fLanguage); }
//
// Export only
@ -116,9 +117,9 @@ public:
// }
//
static int GetNumLocales() { return kNumLanguages - 1; }
static bool ExportGetLocalized(const char* name, int lang, char* localizedName);
static plFileName ExportGetLocalized(const plFileName& name, int lang);
// Just tells us if this is localized, doesn't actually convert it for us
static bool IsLocalizedName(const char* name) { return IGetLocalized(name, kEnglish, nil); }
static bool IsLocalizedName(const plFileName& name) { return IGetLocalized(name, kEnglish).IsValid(); }
// Converts a vector of translated strings to a encoded string that can be decoded by StringToLocal()
// The index in the vector of a string is it's language

1
Sources/Plasma/PubUtilLib/plResMgr/plRegistryNode.cpp

@ -48,7 +48,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plStatusLog/plStatusLog.h"
#include "pnFactory/plFactory.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plVersion.h"

53
Sources/Plasma/PubUtilLib/plResMgr/plResManager.cpp

@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plAgeLoadedMsg.h"
#include "pnMessage/plClientMsg.h"
#include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "pnFactory/plCreator.h"
#include "pnNetCommon/plSynchedObject.h"
#include "pnNetCommon/plNetApp.h"
@ -131,7 +130,7 @@ bool plResManager::IInit()
{
// We want to go through all the data files in our data path and add new
// plRegistryPageNodes to the regTree for each
hsFolderIterator pathIterator(fDataPath.c_str());
hsFolderIterator pathIterator(fDataPath.AsString().c_str());
while (pathIterator.NextFileSuffix(".prp"))
{
char fileName[kFolderIterator_MaxPath];
@ -517,10 +516,10 @@ inline plKeyImp* IFindKeyLocalized(const plUoid& uoid, plRegistryPageNode* page)
// If we're running localized, try to find a localized version first
if ((!objectName.IsNull()) && plLocalization::IsLocalized())
{
char localName[256];
if (plLocalization::GetLocalized(objectName.c_str(), localName))
plFileName localName = plLocalization::GetLocalized(objectName.c_str());
if (localName.IsValid())
{
plKeyImp* localKey = page->FindKey(uoid.GetClassType(), localName);
plKeyImp* localKey = page->FindKey(uoid.GetClassType(), localName.AsString());
if (localKey != nil)
return localKey;
}
@ -585,7 +584,7 @@ plKey plResManager::FindKey(const plUoid& uoid)
return key;
}
const plLocation& plResManager::FindLocation(const char* age, const char* page) const
const plLocation& plResManager::FindLocation(const plString& age, const plString& page) const
{
static plLocation invalidLoc;
@ -596,16 +595,16 @@ const plLocation& plResManager::FindLocation(const char* age, const char* page)
return invalidLoc;
}
void plResManager::GetLocationStrings(const plLocation& loc, char* ageBuffer, char* pageBuffer) const
void plResManager::GetLocationStrings(const plLocation& loc, plString* ageBuffer, plString* pageBuffer) const
{
plRegistryPageNode* page = FindPage(loc);
const plPageInfo& info = page->GetPageInfo();
// Those buffers better be big enough...
if (ageBuffer)
hsStrcpy(ageBuffer, info.GetAge().c_str());
*ageBuffer = info.GetAge();
if (pageBuffer)
hsStrcpy(pageBuffer, info.GetPage().c_str());
*pageBuffer = info.GetPage();
}
bool plResManager::AddViaNotify(plRefMsg* msg, plRefFlags::Type flags)
@ -996,10 +995,10 @@ class plResAgeHolder : public hsRefCnt
{
public:
hsTArray<plKey> fKeys;
std::string fAge;
plString fAge;
plResAgeHolder() {}
plResAgeHolder( const char* age ) : fAge( age ) {}
plResAgeHolder( const plString& age ) : fAge( age ) {}
~plResAgeHolder() { fKeys.Reset(); }
};
@ -1009,11 +1008,11 @@ class plResHolderIterator : public plRegistryPageIterator
{
protected:
hsTArray<plKey>& fKeys;
const char* fAgeName;
plString fAgeName;
plResManager* fResMgr;
public:
plResHolderIterator(const char* age, hsTArray<plKey>& keys, plResManager* resMgr)
plResHolderIterator(const plString& age, hsTArray<plKey>& keys, plResManager* resMgr)
: fAgeName(age), fKeys(keys), fResMgr(resMgr) {}
virtual bool EatPage(plRegistryPageNode* page)
@ -1031,21 +1030,21 @@ public:
//// LoadAndHoldAgeKeys //////////////////////////////////////////////////////
void plResManager::LoadAgeKeys(const char* age)
void plResManager::LoadAgeKeys(const plString& age)
{
hsAssert(age && age[0] != '\0', "age is nil");
hsAssert(!age.IsEmpty(), "age is nil");
HeldAgeKeyMap::const_iterator it = fHeldAgeKeys.find(age);
if (it != fHeldAgeKeys.end())
{
kResMgrLog(1, ILog(1, "Reffing age keys for age %s", age));
hsStatusMessageF("*** Reffing age keys for age %s ***\n", age);
kResMgrLog(1, ILog(1, "Reffing age keys for age %s", age.c_str()));
hsStatusMessageF("*** Reffing age keys for age %s ***\n", age.c_str());
plResAgeHolder* holder = it->second;
holder->Ref();
}
else
{
kResMgrLog(1, ILog(1, "Loading age keys for age %s", age));
hsStatusMessageF("*** Loading age keys for age %s ***\n", age);
kResMgrLog(1, ILog(1, "Loading age keys for age %s", age.c_str()));
hsStatusMessageF("*** Loading age keys for age %s ***\n", age.c_str());
plResAgeHolder* holder = new plResAgeHolder(age);
fHeldAgeKeys[age] = holder;
@ -1057,7 +1056,7 @@ void plResManager::LoadAgeKeys(const char* age)
//// DropAgeKeys /////////////////////////////////////////////////////////////
void plResManager::DropAgeKeys(const char* age)
void plResManager::DropAgeKeys(const plString& age)
{
HeldAgeKeyMap::iterator it = fHeldAgeKeys.find(age);
if (it != fHeldAgeKeys.end())
@ -1066,12 +1065,12 @@ void plResManager::DropAgeKeys(const char* age)
if (holder->RefCnt() == 1)
{
// Found it!
kResMgrLog(1, ILog(1, "Dropping held age keys for age %s", age));
kResMgrLog(1, ILog(1, "Dropping held age keys for age %s", age.c_str()));
fHeldAgeKeys.erase(it);
}
else
{
kResMgrLog(1, ILog(1, "Unreffing age keys for age %s", age));
kResMgrLog(1, ILog(1, "Unreffing age keys for age %s", age.c_str()));
}
holder->UnRef();
@ -1236,11 +1235,11 @@ class plPageInAgeIter : public plRegistryPageIterator
{
private:
plKey fDestKey;
const char* fAgeName;
plString fAgeName;
std::vector<plLocation> fLocations;
public:
plPageInAgeIter(plKey destKey, const char *ageName) : fDestKey(destKey), fAgeName(ageName) {}
plPageInAgeIter(plKey destKey, const plString &ageName) : fDestKey(destKey), fAgeName(ageName) {}
~plPageInAgeIter()
{
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoomHold);
@ -1263,7 +1262,7 @@ public:
// PageInAge is intended for bulk global ages, like GlobalAnimations or GlobalClothing
// that store a lot of data we always want available. (Used to be known as PageInHold)
void plResManager::PageInAge(const char *age)
void plResManager::PageInAge(const plString &age)
{
plSynchEnabler ps(false); // disable dirty tracking while paging in
plUoid lu(kClient_KEY);
@ -1492,9 +1491,9 @@ void plResManager::DumpUnusedKeys(plRegistryPageNode* page) const
page->IterateKeys(&reffer);
}
plRegistryPageNode* plResManager::CreatePage(const plLocation& location, const char* age, const char* page)
plRegistryPageNode* plResManager::CreatePage(const plLocation& location, const plString& age, const plString& page)
{
plRegistryPageNode* pageNode = new plRegistryPageNode(location, age, page, fDataPath.c_str());
plRegistryPageNode* pageNode = new plRegistryPageNode(location, age, page, fDataPath);
fAllPages[location] = pageNode;
return pageNode;

24
Sources/Plasma/PubUtilLib/plResMgr/plResManager.h

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <map>
#include <vector>
#include <string>
#include "plFileSystem.h"
class plRegistryPageNode;
class plRegistryKeyIterator;
@ -55,7 +56,6 @@ class plRegistryDataStream;
class plResAgeHolder;
class plResManagerHelper;
class plDispatch;
class plFileName;
// plProgressProc is a proc called every time an object loads, to keep a progress bar for
// loading ages up-to-date.
@ -68,7 +68,7 @@ public:
virtual ~plResManager();
// If the ResManager has already been initialized, you should call Reset after setting this
void SetDataPath(const char* path) { fDataPath = path; }
void SetDataPath(const plFileName& path) { fDataPath = path; }
// Mainly for external tools.
void AddSinglePage(const plFileName& path);
@ -87,9 +87,9 @@ public:
//---------------------------
plKey FindOriginalKey(const plUoid&);
virtual plKey FindKey(const plUoid&); // Same as above, but will check the uoid for clones
const plLocation& FindLocation(const char* age, const char* page) const;
const plLocation& FindLocation(const plString& age, const plString& page) const;
// Use nil for any strings you don't need
void GetLocationStrings(const plLocation& loc, char* ageBuffer, char* pageBuffer) const;
void GetLocationStrings(const plLocation& loc, plString* ageBuffer, plString* pageBuffer) const;
//---------------------------
// Establish reference linkage
@ -134,10 +134,10 @@ public:
//---------------------------
// Load optimizations
//---------------------------
void LoadAgeKeys(const char* age);
void DropAgeKeys(const char* age);
void LoadAgeKeys(const plString& age);
void DropAgeKeys(const plString& age);
void PageInRoom(const plLocation& page, uint16_t objClassToRef, plRefMsg* refMsg);
void PageInAge(const char* age);
void PageInAge(const plString& age);
// Usually, a page file is kept open during load because the first keyed object
// read causes all the other objects to be read before it returns. In some
@ -152,7 +152,7 @@ public:
void LogReadTimes(bool logReadTimes);
// All keys version
bool IterateKeys(plRegistryKeyIterator* iterator);
bool IterateKeys(plRegistryKeyIterator* iterator);
// Single page version
bool IterateKeys(plRegistryKeyIterator* iterator, const plLocation& pageToRestrictTo);
// Iterate through loaded pages
@ -185,7 +185,7 @@ protected:
virtual void IKeyReffed(plKeyImp* key);
virtual void IKeyUnreffed(plKeyImp* key);
virtual bool IReset();
virtual bool IReset();
virtual bool IInit();
virtual void IShutdown();
@ -207,7 +207,7 @@ protected:
// Adds a key to the registry. Assumes uoid already set
void AddKey(plKeyImp* key);
plRegistryPageNode* CreatePage(const plLocation& location, const char* age, const char* page);
plRegistryPageNode* CreatePage(const plLocation& location, const plString& age, const plString& page);
bool fInited;
@ -215,7 +215,7 @@ protected:
bool fReadingObject;
std::vector<plKey> fQueuedReads;
std::string fDataPath;
plFileName fDataPath;
plDispatch* fDispatch;
@ -223,7 +223,7 @@ protected:
uint32_t fCurClonePlayerID;
uint32_t fCloningCounter; // Next clone ID to use.
typedef std::map<std::string,plResAgeHolder*> HeldAgeKeyMap;
typedef std::map<plString, plResAgeHolder*> HeldAgeKeyMap;
HeldAgeKeyMap fHeldAgeKeys;
plProgressProc fProgressProc;

8
Sources/Plasma/PubUtilLib/plSDL/plSDL.h

@ -533,10 +533,10 @@ class plSDLMgr
{
friend class plSDLParser;
private:
std::string fSDLDir;
plFileName fSDLDir;
plSDL::DescriptorList fDescriptors;
plNetApp* fNetApp;
uint32_t fBehaviorFlags;
uint32_t fBehaviorFlags;
void IDeleteDescriptors(plSDL::DescriptorList* dl);
public:
@ -548,8 +548,8 @@ public:
const plSDL::DescriptorList * GetDescriptors( void ) const { return &fDescriptors;}
void SetSDLDir(const char* s) { fSDLDir=s; }
const char* GetSDLDir() const { return fSDLDir.c_str(); }
void SetSDLDir(const plFileName& s) { fSDLDir=s; }
plFileName GetSDLDir() const { return fSDLDir; }
void SetNetApp(plNetApp* a) { fNetApp=a; }
plNetApp* GetNetApp() const { return fNetApp; }

1
Sources/Plasma/PubUtilLib/plStatGather/plAutoProfile.cpp

@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plClientMsg.h"
#include "plAgeLoader/plAgeLoader.h"
#include "plProfileManagerFull.h"
#include "plFile/plFileUtils.h"
#include "plPipeline/plDebugText.h"
#include "pnMessage/plTimeMsg.h"

1
Sources/Plasma/PubUtilLib/plStatGather/plProfileManagerFull.cpp

@ -50,7 +50,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h"
#include "pnUtils/pnUtils.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plFile/plFileUtils.h"
plProfileManagerFull::plProfileManagerFull() :
fVars(plProfileManager::Instance().fVars),

4
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsThread.h"
#include "hsTemplates.h"
#include "hsTimer.h"
#include "plFile/plFileUtils.h"
#include "plStatusLog.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h"
@ -220,7 +219,7 @@ plStatusLog *plStatusLogMgr::FindLog( const plFileName &filename, bool createIfN
return nil;
// Didn't find one, so create one! (make it a nice default one :)
log = CreateStatusLog( kDefaultNumLines, filename, plStatusLog::kFilledBackground |
log = CreateStatusLog( kDefaultNumLines, filename, plStatusLog::kFilledBackground |
plStatusLog::kDeleteForMe );
return log;
@ -753,4 +752,3 @@ bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count )
return ret;
}

1
Sources/Tools/MaxComponent/Pch.h

@ -60,7 +60,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudible.h"
#include "plCreatableIndex.h"
#include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h"
#include "hsGeometry3.h"
#include "plLoadMask.h"

86
Sources/Tools/MaxComponent/plAudioComponents.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plAnimComponent.h"
#include "plAudioComponents.h"
@ -588,21 +587,20 @@ uint32_t plBaseSoundEmitterComponent::ICalcSourceBufferFlags( void ) const
return bufferFlags;
}
plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags )
plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const plFileName &fileName, plMaxNode *srcNode, uint32_t srcBufferFlags )
{
plSoundBuffer* sb = IGetSourceBuffer(fileName, srcNode, srcBufferFlags);
const char* plasmaDir = plMaxConfig::GetClientPath();
if (plasmaDir)
plFileName plasmaDir = plMaxConfig::GetClientPath();
if (plasmaDir.IsValid())
{
char sfxPath[MAX_PATH];
sprintf(sfxPath, "%ssfx\\%s", plasmaDir, plFileUtils::GetFileName(fileName));
plFileName sfxPath = plFileName::Join(plasmaDir, "sfx", fileName.GetFileName());
// Export any localized versions as well
for (int i = 0; i < plLocalization::GetNumLocales(); i++)
{
char localName[MAX_PATH];
if (plLocalization::ExportGetLocalized(sfxPath, i, localName))
plFileName localName = plLocalization::ExportGetLocalized(sfxPath, i);
if (localName.IsValid())
{
IGetSourceBuffer(localName, srcNode, srcBufferFlags);
}
@ -612,58 +610,45 @@ plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const char *fileN
return sb;
}
plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags )
plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer(const plFileName &fileName, plMaxNode *srcNode, uint32_t srcBufferFlags)
{
plKey key;
plString keyName;
char fullPath[ MAX_PATH ];
// ***TEMP plString REVISIT***
char tempPath[ MAX_PATH ];
strncpy(tempPath, fileName, MAX_PATH);
::PathStripPath( tempPath );
keyName = tempPath;
plString keyName = fileName.GetFileName();
// TEMP HACK until we get packed sounds:
// Given the source filename, we check to see if it's in our plasma game directory. If not, or if
// it's out of date, we copy it over. We'll truncate the filename inside plSoundBuffer when we're ready.
const char *plasmaDir = plMaxConfig::GetClientPath();
if( plasmaDir != nil )
plFileName plasmaDir = plMaxConfig::GetClientPath();
plFileName rfilename = fileName;
if (plasmaDir.IsValid())
{
strcpy( fullPath, plasmaDir );
strcat( fullPath, "sfx\\" );
plFileName fullPath = plFileName::Join(plasmaDir, "sfx");
// Before we finish our path, make sure that directory EXISTS
plFileUtils::CreateDir( fullPath );
plFileSystem::CreateDir(fullPath);
// Now finish the path...
strcat( fullPath, keyName.c_str() );
fullPath = plFileName::Join(fullPath, keyName);
// Check filestamp
WIN32_FILE_ATTRIBUTE_DATA oldFileAttrib, newFileAttrib;
BOOL oldOK, newOK;
oldOK = GetFileAttributesEx( fileName, GetFileExInfoStandard, &oldFileAttrib );
newOK = GetFileAttributesEx( fullPath, GetFileExInfoStandard, &newFileAttrib );
plFileInfo oldInfo(fileName);
plFileInfo newInfo(fullPath);
if( oldOK && newOK )
if (oldInfo.Exists() && newInfo.Exists())
{
// Only copy if the file is newer
if( ::CompareFileTime( &oldFileAttrib.ftLastWriteTime, &newFileAttrib.ftLastWriteTime ) > 0 )
{
::CopyFile( fileName, fullPath, FALSE );
}
if (oldInfo.ModifyTime() > newInfo.ModifyTime())
plFileSystem::Copy(fileName, fullPath);
}
else
{
// Can't compare, so either there was an error or the target file doesn't exist. Copy no matter what.
::CopyFile( fileName, fullPath, FALSE );
plFileSystem::Copy(fileName, fullPath);
}
// Point to our new sound file
fileName = fullPath;
rfilename = fullPath;
}
// Additional info for the keyName--need some flag mangling, specifically for the left/right channel mangling
@ -672,12 +657,12 @@ plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *file
else if( srcBufferFlags & plSoundBuffer::kOnlyRightChannel )
keyName += ":R";
key = srcNode->FindPageKey( plSoundBuffer::Index(), keyName );
key = srcNode->FindPageKey( plSoundBuffer::Index(), keyName );
if( key != nil )
return plSoundBuffer::ConvertNoRef( key->GetObjectPtr() );
// Not yet created, so make a new one
plSoundBuffer *buffer = new plSoundBuffer( fileName, srcBufferFlags );
plSoundBuffer *buffer = new plSoundBuffer( rfilename, srcBufferFlags );
if( !buffer->IsValid() )
{
// Invalid, so delete and return nil
@ -2258,29 +2243,18 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
}
// Grab the buffer for this sound directly from the original source
const char *fileName = groupArray[ i ]->GetSoundFileName( kBaseSound );
plFileName fileName = groupArray[ i ]->GetSoundFileName( kBaseSound );
plSoundBuffer *buffer = new plSoundBuffer( fileName );
if( !buffer->IsValid() || !buffer->EnsureInternal() )
{
// OK, because some *cough* machines are completely stupid and don't load AssetMan scenes with
// AssetMan plugins, we need to do a really stupid fallback search to the current exporting directory.
const char *plasmaDir = plMaxConfig::GetClientPath();
plFileName plasmaDir = plMaxConfig::GetClientPath();
bool worked = false;
if( plasmaDir != nil )
if (plasmaDir.IsValid())
{
char newPath[ MAX_PATH ];
strcpy( newPath, plasmaDir );
strcat( newPath, "sfx\\" );
const char* c = strrchr( fileName, '\\' );
if( c == nil )
c = strrchr( fileName, '/' );
if( c == nil )
c = fileName;
else
c++;
strcat( newPath, c );
plFileName newPath = plFileName::Join(plasmaDir, "sfx", fileName.GetFileName());
// Got a path to try, so try it!
delete buffer;
@ -2292,7 +2266,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
if( !worked )
{
char msg[ 512 ];
sprintf( msg, "The sound file %s cannot be loaded for component %s.", fileName, groupArray[ i ]->GetINode()->GetName() );
sprintf( msg, "The sound file %s cannot be loaded for component %s.", fileName.AsString().c_str(), groupArray[ i ]->GetINode()->GetName() );
IShowError( kSrcBufferInvalid, msg, baseNode->GetName(), pErrMsg );
delete buffer;
@ -2312,7 +2286,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
{
char msg[ 512 ];
sprintf( msg, "The format for sound file %s does not match the format for the other grouped sounds on node %s. "
"Make sure the sounds are all the same format.", fileName, baseNode->GetName() );
"Make sure the sounds are all the same format.", fileName.AsString().c_str(), baseNode->GetName() );
IShowError( kMergeSourceFormatMismatch, msg, baseNode->GetName(), pErrMsg );
delete buffer;

5
Sources/Tools/MaxComponent/plAudioComponents.h

@ -65,6 +65,7 @@ class plMaxNode;
class plSoundBuffer;
class plSound;
class plAudioBaseComponentProc;
class plFileName;
namespace plAudioComp
{
@ -117,7 +118,7 @@ class plBaseSoundEmitterComponent : public plComponent
return -1;
}
static plSoundBuffer *GetSourceBuffer( const char *fileName, plMaxNode *node, uint32_t srcBufferFlags );
static plSoundBuffer *GetSourceBuffer( const plFileName &fileName, plMaxNode *node, uint32_t srcBufferFlags );
static bool LookupLatestAsset( const char *waveName, char *retPath, plErrorMsg *errMsg );
virtual void UpdateSoundFileSelection( void );
@ -177,7 +178,7 @@ class plBaseSoundEmitterComponent : public plComponent
virtual uint32_t ICalcSourceBufferFlags() const;
static plSoundBuffer *IGetSourceBuffer( const char *fileName, plMaxNode *srcNode, uint32_t srcBufferFlags );
static plSoundBuffer *IGetSourceBuffer( const plFileName &fileName, plMaxNode *srcNode, uint32_t srcBufferFlags );
plSoundBuffer *IProcessSourceBuffer( plMaxNode *maxNode, plErrorMsg *errMsg );

4
Sources/Tools/MaxComponent/plGUIComponents.cpp

@ -1449,8 +1449,8 @@ void plGUIDialogProc::ILoadPages( HWND hWnd, IParamBlock2 *pb )
while( ( page = aged->GetNextPage() ) != nil )
{
int idx = ComboBox_AddString( hWnd, page->GetName() );
if( selPageName && stricmp( page->GetName(), selPageName ) == 0 )
int idx = ComboBox_AddString( hWnd, page->GetName().c_str() );
if( selPageName && page->GetName().CompareI( selPageName ) == 0 )
ComboBox_SetCurSel( hWnd, idx );
}

70
Sources/Tools/MaxComponent/plMiscComponents.cpp

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plCreatableIndex.h"
#include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h"
#include "plComponentReg.h"
@ -237,8 +236,8 @@ protected:
aged.SeekFirstPage();
while( ( page = aged.GetNextPage() ) != nil )
{
int idx = ComboBox_AddString(hPageCombo, page->GetName() );
if (curPage && !strcmp(page->GetName(), curPage))
int idx = ComboBox_AddString(hPageCombo, page->GetName().c_str() );
if (curPage && (page->GetName() == curPage))
ComboBox_SetCurSel(hPageCombo, idx);
ComboBox_SetItemData( hPageCombo, idx, (int)page->GetSeqSuffix() );
}
@ -576,33 +575,32 @@ const char *plPageInfoComponent::GetAgeName()
// Checks in assetMan to make sure we have the latest .age file to export
// with.
void plPageInfoComponent::IVerifyLatestAgeAsset( const char *ageName, const char *localPath, plErrorMsg *errMsg )
void plPageInfoComponent::IVerifyLatestAgeAsset( const plString &ageName, const plFileName &localPath, plErrorMsg *errMsg )
{
#ifdef MAXASS_AVAILABLE
char ageFileName[ MAX_PATH ], assetPath[ MAX_PATH ];
plFileName ageFileName, assetPath;
MaxAssInterface *assetMan = GetMaxAssInterface();
if( assetMan == nil )
return; // No AssetMan available
// Try to find it in assetMan
sprintf( ageFileName, "%s.age", ageName );
ageFileName = ageName + ".age";
jvUniqueId assetId;
if (assetMan->FindAssetByFilename(ageFileName, assetId))
if (assetMan->FindAssetByFilename(ageFileName.AsString().c_str(), assetId))
{
// Get the latest version
if (!assetMan->GetLatestVersionFile(assetId, assetPath, sizeof(assetPath)))
{
errMsg->Set( true, "PageInfo Convert Error",
"Unable to update age file for '%s' because AssetMan was unable to get the latest version. Using local copy instead.", ageName ).Show();
"Unable to update age file for '%s' because AssetMan was unable to get the latest version. Using local copy instead.", ageName.c_str() ).Show();
errMsg->Set( false );
return;
}
// Got the latest version, just copy over and roll!
plFileUtils::RemoveFile( localPath );
plFileUtils::FileCopy( assetPath, localPath );
plFileSystem::Unlink(localPath);
plFileSystem::Copy(assetPath, localPath);
}
else
{
@ -625,10 +623,8 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
// Mark us as updated
fCompPB->SetValue( kRefVolatile_PageInfoUpdated, 0, (int)true );
char path[MAX_PATH];
const char *ageFolder = plPageInfoUtils::GetAgeFolder();
if( ageFolder == nil )
plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid())
{
errMsg->Set( true,
"PageInfo Convert Error",
@ -653,7 +649,7 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
fCompPB->SetValue( kInfoSeqSuffix, 0, 0 );
return;
}
sprintf(path, "%s%s.age", ageFolder, curAge);
plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge));
IVerifyLatestAgeAsset( curAge, path, errMsg );
@ -699,12 +695,12 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
while( ( page = aged.GetNextPage() ) != nil )
{
if( stricmp( page->GetName(), compPBPageName ) == 0 )
if( page->GetName().CompareI( compPBPageName ) == 0 )
{
fCompPB->SetValue( kInfoSeqSuffix, 0, (int)page->GetSeqSuffix() );
// Also re-copy the page name, just to make sure the case is correct
fCompPB->SetValue( kInfoPage, 0, (char *)page->GetName() );
fCompPB->SetValue( kInfoPage, 0, (const char *)page->GetName().c_str() );
return;
}
}
@ -720,28 +716,20 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
fCompPB->SetValue( kInfoSeqSuffix, 0, 0 );
}
const char *plPageInfoUtils::GetAgeFolder()
plFileName plPageInfoUtils::GetAgeFolder()
{
static char ageFolder[MAX_PATH];
static bool initialized = false;
static plFileName ageFolder;
if (!initialized)
if (!ageFolder.IsValid())
{
initialized = true;
ageFolder[0] = '\0';
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return "";
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
return nil;
strcpy(ageFolder, plasmaPath);
strcat(ageFolder, plAgeDescription::kAgeDescPath);
ageFolder = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
}
if (ageFolder[0] != '\0')
return ageFolder;
else
return nil;
return ageFolder;
}
int32_t plPageInfoUtils::CombineSeqNum( int prefix, int suffix )
@ -789,7 +777,7 @@ int32_t plPageInfoUtils::GetSeqNumFromAgeDesc( const char *ageName, const char
aged->SeekFirstPage();
while( ( page = aged->GetNextPage() ) != nil )
{
if( stricmp( pageName, page->GetName() ) == 0 )
if (page->GetName().CompareI(pageName) == 0)
{
seqSuffix = page->GetSeqSuffix();
break;
@ -801,18 +789,14 @@ int32_t plPageInfoUtils::GetSeqNumFromAgeDesc( const char *ageName, const char
return CombineSeqNum( seqPrefix, seqSuffix );
}
plAgeDescription *plPageInfoUtils::GetAgeDesc( const char *ageName )
plAgeDescription *plPageInfoUtils::GetAgeDesc( const plString &ageName )
{
char path[ MAX_PATH ];
const char *ageFolder = plPageInfoUtils::GetAgeFolder();
if( ageFolder == nil || ageName == nil )
plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid() || ageName.IsNull())
return nil;
sprintf( path, "%s%s.age", ageFolder, ageName );
hsUNIXStream s;
if( !s.Open( path ) )
if (!s.Open(plFileName::Join(ageFolder, ageName + ".age")))
return nil;
// Create and read the age desc

15
Sources/Tools/MaxComponent/plMiscComponents.h

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define CIRCLE_CAM_CID Class_ID(0x66f85282, 0x4daa1b8e)
#define IMAGE_LIB_CID Class_ID(0x736c18d3, 0x6a6d5dde)
class plFileName;
class plAgeDescription;
class plComponentBase;
struct NotifyInfo;
@ -60,12 +61,12 @@ const char* LocCompGetPage(plComponentBase* comp);
namespace plPageInfoUtils
{
const char *GetAgeFolder();
int32_t GetSeqNumFromAgeDesc( const char *ageName, const char *pageName );
int32_t CombineSeqNum( int prefix, int suffix );
int32_t GetCommonSeqNumFromNormal( int32_t normalSeqNumber, int whichCommonPage );
plFileName GetAgeFolder();
int32_t GetSeqNumFromAgeDesc( const char *ageName, const char *pageName );
int32_t CombineSeqNum( int prefix, int suffix );
int32_t GetCommonSeqNumFromNormal( int32_t normalSeqNumber, int whichCommonPage );
plAgeDescription *GetAgeDesc( const char *ageName );
plAgeDescription *GetAgeDesc( const plString &ageName );
};
// PageInfo component definition, here so other components can get to the static function(s)
@ -76,8 +77,8 @@ protected:
bool fItinerant;
static char fCurrExportedAge[ 256 ];
void IVerifyLatestAgeAsset( const char *ageName, const char *localPath, plErrorMsg *errMsg );
void IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg );
void IVerifyLatestAgeAsset( const plString &ageName, const plFileName &localPath, plErrorMsg *errMsg );
void IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg );
public:
plPageInfoComponent();

21
Sources/Tools/MaxComponent/plResponderLink.cpp

@ -318,19 +318,18 @@ void plResponderLinkProc::ILoadAgeFilenamesCombo(HWND hWnd, IParamBlock2 *pb)
SendMessage(hAge, CB_RESETCONTENT, 0, 0);
// Get the path to the description folder
char agePath[MAX_PATH];
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return;
strcpy(agePath, plasmaPath);
strcat(agePath, plAgeDescription::kAgeDescPath);
plFileName agePath = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
const char *savedName = pb->GetStr(kLinkAgeFilename);
if (!savedName)
savedName = "";
// Iterate through the age descriptions
hsFolderIterator ageFolder(agePath);
hsFolderIterator ageFolder(agePath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age"))
{
char ageFile[MAX_PATH];
@ -355,19 +354,17 @@ void plResponderLinkProc::ILoadParentAgeFilenamesCombo(HWND hWnd, IParamBlock2 *
SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)"<None>");
// Get the path to the description folder
char agePath[MAX_PATH];
const char *plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath)
plFileName plasmaPath = plMaxConfig::GetClientPath();
if (!plasmaPath.IsValid())
return;
strcpy(agePath, plasmaPath);
strcat(agePath, plAgeDescription::kAgeDescPath);
plFileName agePath = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
const char *savedName = pb->GetStr(kLinkParentAgeFilename);
if (!savedName)
savedName = "<None>";
// Iterate through the age descriptions
hsFolderIterator ageFolder(agePath);
hsFolderIterator ageFolder(agePath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age"))
{
char ageFile[MAX_PATH];

12
Sources/Tools/MaxConvert/hsMaterialConverter.cpp

@ -71,7 +71,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plSurface/hsGMaterial.h"
#include "pnSceneObject/plSceneObject.h"
#include "UserPropMgr.h"
#include "plFile/plFileUtils.h"
#include "hsConverterUtils.h"
#include "hsControlConverter.h"
@ -1981,18 +1980,17 @@ static plLayerInterface* IProcessLayerMovie(plPassMtlBase* mtl, plLayerTex* layT
if( !bi || !bi->Name() || !*bi->Name() )
return layerIFace;
const char* fileName = bi->Name();
plFileName fileName = bi->Name();
plAnimStealthNode* stealth = IGetEntireAnimation(mtl);
const char* ext = plFileUtils::GetFileExt(fileName);
bool isBink = ext && (stricmp(ext, "bik") == 0);
bool isAvi = ext &&(stricmp(ext, "avi") == 0);
plString ext = fileName.GetFileExt();
bool isBink = (ext.CompareI("bik") == 0);
bool isAvi = (ext.CompareI("avi") == 0);
if (isBink || isAvi)
{
char movieName[256];
sprintf(movieName, "avi/%s", plFileUtils::GetFileName(fileName));
plFileName movieName = plFileName::Join("avi", fileName.GetFileName());
plLayerMovie* movieLayer = nil;
plString moviePostfix;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save