Browse Source

Deprecate plFileUtils and parts of pnUtPath

Michael Hansen 12 years ago
parent
commit
6e564476b7
  1. 1
      Sources/Plasma/Apps/plClient/plClient.cpp
  2. 3
      Sources/Plasma/Apps/plClient/winmain.cpp
  3. 130
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp
  4. 2
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.h
  5. 1
      Sources/Plasma/Apps/plFileSecure/main.cpp
  6. 30
      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. 28
      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. 112
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  16. 8
      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. 4
      Sources/Plasma/FeatureLib/pfSurface/plLayerAVI.cpp
  32. 34
      Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.cpp
  33. 18
      Sources/Plasma/FeatureLib/pfSurface/plLayerMovie.h
  34. 2
      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. 139
      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. 42
      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. 10
      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. 84
      Sources/Plasma/PubUtilLib/plAudioCore/plSoundBuffer.cpp
  62. 27
      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. 2
      Sources/Plasma/PubUtilLib/plPipeline/plStatusLogDrawer.cpp
  82. 34
      Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.cpp
  83. 10
      Sources/Plasma/PubUtilLib/plResMgr/plKeyFinder.h
  84. 35
      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. 20
      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. 2
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp
  93. 1
      Sources/Tools/MaxComponent/Pch.h
  94. 82
      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. 13
      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 "hsTimer.h"
#include "plPipeline/hsG3DDeviceSelector.h" #include "plPipeline/hsG3DDeviceSelector.h"
#include "plFile/plEncryptedStream.h" #include "plFile/plEncryptedStream.h"
#include "plFile/plFileUtils.h"
#include "plInputCore/plInputManager.h" #include "plInputCore/plInputManager.h"
#include "plInputCore/plInputInterfaceMgr.h" #include "plInputCore/plInputInterfaceMgr.h"
#include "plInputCore/plInputDevice.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 "plStatusLog/plStatusLog.h"
#include "plProduct.h" #include "plProduct.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
#include "plFile/plFileUtils.h"
#include "plPhysX/plSimulationMgr.h" #include "plPhysX/plSimulationMgr.h"
@ -542,7 +541,7 @@ bool InitClient( HWND hWnd )
resMgr->SetDataPath("dat"); resMgr->SetDataPath("dat");
hsgResMgr::Init(resMgr); hsgResMgr::Init(resMgr);
if(!plFileUtils::FileExists("resource.dat")) if (!plFileInfo("resource.dat").Exists())
{ {
hsMessageBox("Required file 'resource.dat' not found.", "Error", hsMessageBoxNormal); hsMessageBox("Required file 'resource.dat' not found.", "Error", hsMessageBoxNormal);
return false; return false;

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

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

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

@ -64,4 +64,4 @@ void UruStartProc (void * param);
void PlayerTerminateProc (void * param); void PlayerTerminateProc (void * param);
void PlayerStopProc (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==*/ *==LICENSE==*/
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plProduct.h" #include "plProduct.h"

30
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 "hsTimer.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plResMgr/plResManager.h" #include "plResMgr/plResManager.h"
#include "plResMgr/plResMgrSettings.h" #include "plResMgr/plResMgrSettings.h"
@ -61,7 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
plResManager* gResMgr = nil; plResManager* gResMgr = nil;
bool DumpStats(const char* patchDir); bool DumpStats(const plFileName& patchDir);
bool DumpSounds(); bool DumpSounds();
//// PrintVersion /////////////////////////////////////////////////////////////// //// PrintVersion ///////////////////////////////////////////////////////////////
@ -117,7 +116,7 @@ int main(int argc, char* argv[])
} }
// Make sure we have 1 arg left after getting the options // Make sure we have 1 arg left after getting the options
char* pageFile = nil; plFileName pageFile;
if (arg < argc) if (arg < argc)
pageFile = argv[arg]; pageFile = argv[arg];
else else
@ -134,12 +133,7 @@ int main(int argc, char* argv[])
if (sounds) if (sounds)
DumpSounds(); DumpSounds();
if (stats) if (stats)
{ DumpStats(pageFile.StripFileName());
char path[256];
strcpy(path, pageFile);
plFileUtils::StripFile(path);
DumpStats(path);
}
hsgResMgr::Shutdown(); hsgResMgr::Shutdown();
@ -180,12 +174,12 @@ bool DumpSounds()
buffer->GetKey()->RefObject(); buffer->GetKey()->RefObject();
// Get the filename from it and add that file if necessary // Get the filename from it and add that file if necessary
const char* filename = buffer->GetFileName(); plFileName filename = buffer->GetFileName();
if (filename) if (filename.IsValid())
{ {
uint32_t flags = 0; uint32_t flags = 0;
if (stricmp(plFileUtils::GetFileExt(filename), "wav") != 0) if (filename.GetFileExt().CompareI("wav") != 0)
{ {
if (buffer->HasFlag(plSoundBuffer::kOnlyLeftChannel) || if (buffer->HasFlag(plSoundBuffer::kOnlyLeftChannel) ||
buffer->HasFlag(plSoundBuffer::kOnlyRightChannel)) buffer->HasFlag(plSoundBuffer::kOnlyRightChannel))
@ -196,7 +190,7 @@ bool DumpSounds()
hsSetBits(flags, plManifestFile::kSndFlagCacheStereo); 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 // Unref the object so it goes away
@ -218,11 +212,11 @@ bool DumpSounds()
class plStatDumpIterator : public plRegistryPageIterator, public plRegistryKeyIterator class plStatDumpIterator : public plRegistryPageIterator, public plRegistryKeyIterator
{ {
protected: protected:
const char* fOutputDir; plFileName fOutputDir;
hsUNIXStream fStream; hsUNIXStream fStream;
public: public:
plStatDumpIterator(const char* outputDir) : fOutputDir(outputDir) {} plStatDumpIterator(const plFileName& outputDir) : fOutputDir(outputDir) {}
bool EatKey(const plKey& key) bool EatKey(const plKey& key)
{ {
@ -246,8 +240,8 @@ public:
{ {
const plPageInfo& info = page->GetPageInfo(); const plPageInfo& info = page->GetPageInfo();
char fileName[256]; plFileName fileName = plFileName::Join(fOutputDir,
sprintf(fileName, "%s%s_%s.csv", fOutputDir, info.GetAge().c_str(), info.GetPage().c_str()); plString::Format("%s_%s.csv", info.GetAge().c_str(), info.GetPage().c_str()));
fStream.Open(fileName, "wt"); fStream.Open(fileName, "wt");
page->LoadKeys(); page->LoadKeys();
@ -259,7 +253,7 @@ public:
} }
}; };
bool DumpStats(const char* patchDir) bool DumpStats(const plFileName& patchDir)
{ {
plStatDumpIterator statDump(patchDir); plStatDumpIterator statDump(patchDir);
gResMgr->IterateAllPages(&statDump); 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 "plResMgr/plResManager.h"
#include "plPageOptimizer.h" #include "plPageOptimizer.h"
#include "plFile/plFileUtils.h"
#include "pnNetCommon/plSynchedObject.h" #include "pnNetCommon/plSynchedObject.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
@ -53,7 +52,8 @@ int main(int argc, char* argv[])
return 1; return 1;
} }
printf("Optimizing %s...", plFileUtils::GetFileName(argv[1])); plFileName filename = argv[1];
printf("Optimizing %s...", filename.GetFileName().c_str());
#ifndef _DEBUG #ifndef _DEBUG
try { 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 "pnFactory/plFactory.h"
#include "pnKeyedObject/plKeyImp.h" #include "pnKeyedObject/plKeyImp.h"
#include "plFile/plFileUtils.h"
#include "hsStream.h" #include "hsStream.h"
plPageOptimizer* plPageOptimizer::fInstance = nil; plPageOptimizer* plPageOptimizer::fInstance = nil;
plPageOptimizer::plPageOptimizer(const char* pagePath) : plPageOptimizer::plPageOptimizer(const plFileName& pagePath) :
fOptimized(true), fOptimized(true),
fPageNode(nil), fPageNode(nil),
fPagePath(pagePath) fPagePath(pagePath)
{ {
fInstance = this; fInstance = this;
strcpy(fTempPagePath, fPagePath); fTempPagePath = fPagePath.StripFileExt() + "_opt.prp";
plFileUtils::StripExt(fTempPagePath);
strcat(fTempPagePath, "_opt.prp");
fResMgr = (plResManager*)hsgResMgr::ResMgr(); fResMgr = (plResManager*)hsgResMgr::ResMgr();
} }
@ -135,8 +132,8 @@ void plPageOptimizer::Optimize()
if (loaded) if (loaded)
IRewritePage(); IRewritePage();
uint32_t oldSize = plFileUtils::GetFileSize(fPagePath); uint64_t oldSize = plFileInfo(fPagePath).FileSize();
uint32_t newSize = plFileUtils::GetFileSize(fTempPagePath); uint64_t newSize = plFileInfo(fTempPagePath).FileSize();
if (!loaded) if (!loaded)
{ {
@ -144,19 +141,19 @@ void plPageOptimizer::Optimize()
} }
else if (fOptimized) else if (fOptimized)
{ {
plFileUtils::RemoveFile(fTempPagePath); plFileSystem::Unlink(fTempPagePath);
puts("already optimized."); puts("already optimized.");
} }
else if (oldSize == newSize) else if (oldSize == newSize)
{ {
plFileUtils::RemoveFile(fPagePath, true); plFileSystem::Unlink(fPagePath);
plFileUtils::FileMove(fTempPagePath, fPagePath); plFileSystem::Move(fTempPagePath, fPagePath);
puts("complete"); puts("complete");
} }
else else
{ {
plFileUtils::RemoveFile(fTempPagePath); plFileSystem::Unlink(fTempPagePath);
puts("failed. File sizes different"); 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/plKey.h"
#include "pnKeyedObject/plUoid.h" #include "pnKeyedObject/plUoid.h"
#include "plFileSystem.h"
#include <vector> #include <vector>
#include <set> #include <set>
@ -63,8 +64,8 @@ protected:
bool fOptimized; // True after optimization if the page was already optimized bool fOptimized; // True after optimization if the page was already optimized
const char* fPagePath; // Path to our page plFileName fPagePath; // Path to our page
char fTempPagePath[512]; // Path to the temp output page plFileName fTempPagePath; // Path to the temp output page
plLocation fLoc; // Location of our page plLocation fLoc; // Location of our page
plRegistryPageNode* fPageNode; // PageNode for our page plRegistryPageNode* fPageNode; // PageNode for our page
@ -78,7 +79,7 @@ protected:
void IRewritePage(); void IRewritePage();
public: public:
plPageOptimizer(const char* pagePath); plPageOptimizer(const plFileName& pagePath);
void Optimize(); void Optimize();
}; };

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

@ -619,18 +619,15 @@ int __stdcall WinMain (
while (*appCmdLine == L' ') while (*appCmdLine == L' ')
++appCmdLine; ++appCmdLine;
wchar_t curPatcherFile[MAX_PATH];
wchar_t newPatcherFile[MAX_PATH];
bool isTempPatcher = false; bool isTempPatcher = false;
PathGetProgramName(curPatcherFile, arrsize(curPatcherFile)); plFileName curPatcherFile = plFileSystem::GetCurrentAppPath();
PathRemoveFilename(newPatcherFile, curPatcherFile, arrsize(newPatcherFile)); plFileName newPatcherFile = plFileName::Join(curPatcherFile.StripFileName(), kPatcherExeFilename);
PathAddFilename(newPatcherFile, newPatcherFile, kPatcherExeFilename, arrsize(newPatcherFile));
// If our exe name doesn't match the "real" patcher exe name, then we are a newly // 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, // downloaded patcher that needs to be copied over to the "real" exe.. so do that,
// exec it, and exit. // exec it, and exit.
if (0 != StrCmpI(curPatcherFile, newPatcherFile)) { if (0 != curPatcherFile.AsString().CompareI(newPatcherFile.AsString())) {
isTempPatcher = true; isTempPatcher = true;
} }
@ -683,7 +680,7 @@ int __stdcall WinMain (
for (;;) { for (;;) {
// Wait for previous process to exit. This will happen if we just patched. // 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); DWORD wait = WaitForSingleObject(mutex, 0);
while(!s_shutdown && wait != WAIT_OBJECT_0) while(!s_shutdown && wait != WAIT_OBJECT_0)
wait = WaitForSingleObject(mutex, 100); wait = WaitForSingleObject(mutex, 100);
@ -701,7 +698,7 @@ int __stdcall WinMain (
// Wait for the other process to exit // Wait for the other process to exit
Sleep(1000); Sleep(1000);
if (!plFileUtils::RemoveFile(newPatcherFile)) { if (!plFileSystem::Unlink(newPatcherFile)) {
wchar_t error[256]; wchar_t error[256];
DWORD errorCode = GetLastError(); DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode); wchar_t *msg = TranslateErrorCode(errorCode);
@ -711,7 +708,7 @@ int __stdcall WinMain (
LocalFree(msg); LocalFree(msg);
break; break;
} }
if (!plFileUtils::FileMove(curPatcherFile, newPatcherFile)) { if (!plFileSystem::Move(curPatcherFile, newPatcherFile)) {
wchar_t error[256]; wchar_t error[256];
DWORD errorCode = GetLastError(); DWORD errorCode = GetLastError();
wchar_t *msg = TranslateErrorCode(errorCode); 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); StrPrintf(error, arrsize(error), L"Failed to replace old patcher executable. %s", msg);
MessageBoxW(GetTopWindow(nil), error, L"Error", MB_OK); MessageBoxW(GetTopWindow(nil), error, L"Error", MB_OK);
// attempt to clean up this tmp file // attempt to clean up this tmp file
plFileUtils::RemoveFile(curPatcherFile); plFileSystem::Unlink(curPatcherFile);
LocalFree(msg); LocalFree(msg);
break; break;
} }
@ -732,7 +729,7 @@ int __stdcall WinMain (
si.cb = sizeof(si); si.cb = sizeof(si);
wchar_t cmdline[MAX_PATH]; 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 // we have only successfully patched if we actually launch the new version of the patcher
(void)CreateProcessW( (void)CreateProcessW(
@ -758,12 +755,11 @@ int __stdcall WinMain (
// Clean up old temp files // Clean up old temp files
ARRAY(PathFind) paths; ARRAY(PathFind) paths;
wchar_t fileSpec[MAX_PATH]; plFileName fileSpec = plFileSystem::GetCurrentAppPath().StripFileName();
PathGetProgramDirectory(fileSpec, arrsize(fileSpec)); fileSpec = plFileName::Join(fileSpec, "*.tmp");
PathAddFilename(fileSpec, fileSpec, L"*.tmp", arrsize(fileSpec)); PathFindFiles(&paths, fileSpec.AsString().ToWchar(), kPathFlagFile);
PathFindFiles(&paths, fileSpec, kPathFlagFile);
for (PathFind * path = paths.Ptr(); path != paths.Term(); ++path) for (PathFind * path = paths.Ptr(); path != paths.Term(); ++path)
plFileUtils::RemoveFile(path->name); plFileSystem::Unlink(plString::FromWchar(path->name));
SetConsoleCtrlHandler(CtrlHandler, TRUE); SetConsoleCtrlHandler(CtrlHandler, TRUE);
InitAsyncCore(); // must do this before self patch, since it needs to connect to the file server 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 "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.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 long s_numFiles;
static ENetError s_patchResult; static ENetError s_patchResult;
static bool s_updated; 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 ( static void DownloadCallback (
ENetError result, ENetError result,
void * param, void * param,
const wchar_t filename[], const plFileName & filename,
hsStream * writer hsStream * writer
) { ) {
if(IS_NET_ERROR(result)) { if(IS_NET_ERROR(result)) {
switch (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 // Do md5 check
char md5copy[MAX_PATH];
plMD5Checksum existingMD5(filename); plMD5Checksum existingMD5(filename);
plMD5Checksum latestMD5; plMD5Checksum latestMD5;
StrToAnsi(md5copy, md5, arrsize(md5copy)); latestMD5.SetFromHexString(md5);
latestMD5.SetFromHexString(md5copy);
return (existingMD5 == latestMD5); return (existingMD5 == latestMD5);
} }
@ -155,7 +153,7 @@ static bool MD5Check (const char filename[], const wchar_t md5[]) {
static void ManifestCallback ( static void ManifestCallback (
ENetError result, ENetError result,
void * param, void * param,
const wchar_t group[], const wchar_t group[],
const NetCliFileManifestEntry manifest[], const NetCliFileManifestEntry manifest[],
unsigned entryCount unsigned entryCount
) { ) {
@ -183,24 +181,19 @@ static void ManifestCallback (
} }
#endif #endif
char ansi[MAX_PATH];
// MD5 check current patcher against value in manifest // MD5 check current patcher against value in manifest
ASSERT(entryCount == 1); ASSERT(entryCount == 1);
wchar_t curPatcherFile[MAX_PATH]; plFileName curPatcherFile = plFileSystem::GetCurrentAppPath();
PathGetProgramName(curPatcherFile, arrsize(curPatcherFile)); if (!MD5Check(curPatcherFile, manifest[0].md5.c_str())) {
StrToAnsi(ansi, curPatcherFile, arrsize(ansi));
if (!MD5Check(ansi, manifest[0].md5)) {
// MessageBox(GetTopWindow(nil), "MD5 failed", "Msg", MB_OK); // MessageBox(GetTopWindow(nil), "MD5 failed", "Msg", MB_OK);
SelfPatcherStream::totalBytes += manifest[0].zipSize; SelfPatcherStream::totalBytes += manifest[0].zipSize;
AtomicAdd(&s_numFiles, 1); AtomicAdd(&s_numFiles, 1);
SetText("Downloading new patcher..."); SetText("Downloading new patcher...");
StrToAnsi(ansi, s_newPatcherFile, arrsize(ansi));
SelfPatcherStream * stream = new SelfPatcherStream; SelfPatcherStream * stream = new SelfPatcherStream;
if (!stream->Open(ansi, "wb")) if (!stream->Open(s_newPatcherFile, "wb"))
ErrorAssert(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", ansi, errno); ErrorAssert(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", s_newPatcherFile.AsString().c_str(), errno);
NetCliFileDownloadRequest(manifest[0].downloadName, stream, DownloadCallback, nil); NetCliFileDownloadRequest(manifest[0].downloadName, stream, DownloadCallback, nil);
} }
@ -213,7 +206,7 @@ static void ManifestCallback (
static void FileSrvIpAddressCallback ( static void FileSrvIpAddressCallback (
ENetError result, ENetError result,
void * param, void * param,
const wchar_t addr[] const wchar_t addr[]
) { ) {
NetCliGateKeeperDisconnect(); NetCliGateKeeperDisconnect();
@ -230,9 +223,9 @@ static void FileSrvIpAddressCallback (
NetCliFileStartConnect(&caddr, 1, true); NetCliFileStartConnect(&caddr, 1, true);
delete[] caddr; delete[] caddr;
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile)); s_newPatcherFile = plFileSystem::GetCurrentAppPath().StripFileName();
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile); s_newPatcherFile = plFileSystem::GetTempFilename(kPatcherExeFilename.AsString().c_str(), s_newPatcherFile);
plFileUtils::RemoveFile(s_newPatcherFile); plFileSystem::Unlink(s_newPatcherFile);
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest); NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
} }
@ -279,7 +272,7 @@ static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
si.cb = sizeof(si); si.cb = sizeof(si);
wchar_t cmdline[MAX_PATH]; 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 // we have only successfully patched if we actually launch the new version of the patcher
patched = CreateProcessW( patched = CreateProcessW(

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

@ -187,16 +187,10 @@ plVirtualCam1::plVirtualCam1()
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
// only open log file if logging is on // only open log file if logging is on
if ( !plStatusLog::fLoggingOff ) if ( !plStatusLog::fLoggingOff )
{ foutLog = plFileSystem::Open(plFileName::Join(plFileSystem::GetLogPath(), "camLog.txt"), "wt");
wchar_t fileAndPath[MAX_PATH];
PathGetLogDirectory(fileAndPath, arrsize(fileAndPath));
PathAddFilename(fileAndPath, fileAndPath, L"camLog.txt", arrsize(fileAndPath));
foutLog = hsWFopen( fileAndPath, L"wt" );
}
#endif #endif
SetFlags(kFirstPersonEnabled); SetFlags(kFirstPersonEnabled);
} }
plVirtualCam1::~plVirtualCam1() 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 FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* 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 char* ageName, plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false); char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...); 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") PF_CONSOLE_CMD( Avatar_Multistage, Trigger, "string multiComp", "Triggers the named Multistage Animation component")
{ {
char str[256]; 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); PrintString(str);
if (key) if (key)
@ -499,7 +499,7 @@ PF_CONSOLE_CMD( Avatar, SeekPoint, "string seekpoint", "Move to the given seekpo
if(avatar) if(avatar)
{ {
char buff[256]; char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff); plKey seekKey = FindSceneObjectByName(spName, "", buff);
plSeekPointMod *mod = plAvatarMgr::GetInstance()->FindSeekPoint(spName); plSeekPointMod *mod = plAvatarMgr::GetInstance()->FindSeekPoint(spName);
if(mod) if(mod)
@ -596,7 +596,7 @@ PF_CONSOLE_CMD( Avatar, FakeLinkToObj, "string objName", "Pseudo-Link the avatar
{ {
plString spName = plString::FromUtf8(params[0]); plString spName = plString::FromUtf8(params[0]);
char buff[256]; char buff[256];
plKey seekKey = FindSceneObjectByName(spName, nil, buff); plKey seekKey = FindSceneObjectByName(spName, "", buff);
if (!seekKey) if (!seekKey)
{ {
PrintString("Can't find object with that name, fake link failed."); PrintString("Can't find object with that name, fake link failed.");

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

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

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

@ -196,9 +196,9 @@ PF_CONSOLE_FILE_DUMMY(Net)
// utility functions // utility functions
// //
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
plKey FindSceneObjectByName(const plString& name, const char* ageName, char* statusStr, bool subString=false); plKey FindSceneObjectByName(const plString& name, const plString& ageName, char* statusStr, bool subString=false);
plKey FindObjectByName(const plString& name, int type, const char* 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 char* ageName, plKey FindObjectByNameAndType(const plString& name, const char* typeName, const plString& ageName,
char* statusStr, bool subString=false); char* statusStr, bool subString=false);
void PrintStringF(void pfun(const char *),const char * fmt, ...); void PrintStringF(void pfun(const char *),const char * fmt, ...);
@ -509,7 +509,7 @@ PF_CONSOLE_CMD( Net, // groupName
"Instructs the server to only send me updates about this object periodically" ) // helpString "Instructs the server to only send me updates about this object periodically" ) // helpString
{ {
char str[256]; char str[256];
plKey key = FindSceneObjectByName(plString::FromUtf8(params[0]), nil, str); plKey key = FindSceneObjectByName(static_cast<const char *>(params[0]), "", str);
PrintString(str); PrintString(str);
if (!key) if (!key)
return; 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 "plCrashSrv.h"
#include "plCrash_Private.h" #include "plCrash_Private.h"
#include "plFile/plFileUtils.h"
#include "plProduct.h" #include "plProduct.h"
#include "plFileSystem.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 // Do a search through our current age with just the name given
if( plNetClientMgr::GetInstance() != nil ) if( plNetClientMgr::GetInstance() != nil )
{ {
const char *thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName(); plString thisAge = plAgeLoader::GetInstance()->GetCurrAgeDesc().GetAgeName();
if( thisAge != nil ) 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 ) if( key != nil )
{ {
return key; return key;

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

@ -94,7 +94,7 @@ public:
protected: protected:
bool fWeExploded; // alternative to massive error stack bool fWeExploded; // alternative to massive error stack
plString fFilename; plFileName fFilename;
XML_Parser fParser; XML_Parser fParser;
struct tagInfo struct tagInfo
@ -121,7 +121,7 @@ protected:
public: public:
LocalizationXMLFile() : fWeExploded(false) { } 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); void AddError(const plString & errorText);
}; };
@ -354,7 +354,7 @@ void LocalizationXMLFile::IHandleTranslationTag(const LocalizationXMLFile::tagIn
//// Parse() ///////////////////////////////////////////////////////// //// Parse() /////////////////////////////////////////////////////////
bool LocalizationXMLFile::Parse(const plString& fileName) bool LocalizationXMLFile::Parse(const plFileName& fileName)
{ {
fFilename = fileName; fFilename = fileName;
@ -382,10 +382,10 @@ bool LocalizationXMLFile::Parse(const plString& fileName)
XML_SetCharacterDataHandler(fParser, HandleData); XML_SetCharacterDataHandler(fParser, HandleData);
XML_SetUserData(fParser, (void*)this); XML_SetUserData(fParser, (void*)this);
hsStream *xmlStream = plEncryptedStream::OpenEncryptedFile(fileName.c_str()); hsStream *xmlStream = plEncryptedStream::OpenEncryptedFile(fileName);
if (!xmlStream) 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; return false;
} }
@ -437,15 +437,15 @@ void LocalizationXMLFile::AddError(const plString& errorText)
class LocalizationDatabase class LocalizationDatabase
{ {
protected: 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 std::vector<LocalizationXMLFile> fFiles; // the various XML files in that directory
LocalizationXMLFile::ageMap fData; LocalizationXMLFile::ageMap fData;
LocalizationXMLFile::element IMergeElementData(LocalizationXMLFile::element firstElement, LocalizationXMLFile::element secondElement, 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 plString & 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 plString & 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 IMergeData(); // merge all localization data in the files
void IVerifyElement(const plString &ageName, const plString &setName, LocalizationXMLFile::set::iterator& curElement); void IVerifyElement(const plString &ageName, const plString &setName, LocalizationXMLFile::set::iterator& curElement);
@ -456,7 +456,7 @@ protected:
public: public:
LocalizationDatabase() {} LocalizationDatabase() {}
void Parse(const plString & directory); void Parse(const plFileName & directory);
LocalizationXMLFile::ageMap GetData() {return fData;} LocalizationXMLFile::ageMap GetData() {return fData;}
}; };
@ -466,7 +466,7 @@ public:
//// IMergeElementData /////////////////////////////////////////////// //// 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 // copy the data over, alerting the user to any duplicate translations
LocalizationXMLFile::element::iterator curTranslation; LocalizationXMLFile::element::iterator curTranslation;
@ -475,7 +475,7 @@ LocalizationXMLFile::element LocalizationDatabase::IMergeElementData(Localizatio
if (firstElement.find(curTranslation->first) != firstElement.end()) if (firstElement.find(curTranslation->first) != firstElement.end())
{ {
pfLocalizationDataMgr::GetLog()->AddLineF("Duplicate %s translation for %s found in file %s. Ignoring second translation.", 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 else
firstElement[curTranslation->first] = curTranslation->second; firstElement[curTranslation->first] = curTranslation->second;
@ -486,7 +486,7 @@ LocalizationXMLFile::element LocalizationDatabase::IMergeElementData(Localizatio
//// IMergeSetData /////////////////////////////////////////////////// //// 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 // Merge all the elements
LocalizationXMLFile::set::iterator curElement; LocalizationXMLFile::set::iterator curElement;
@ -505,7 +505,7 @@ LocalizationXMLFile::set LocalizationDatabase::IMergeSetData(LocalizationXMLFile
//// IMergeAgeData /////////////////////////////////////////////////// //// 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 // Merge all the sets
LocalizationXMLFile::age::iterator curSet; LocalizationXMLFile::age::iterator curSet;
@ -640,14 +640,14 @@ void LocalizationDatabase::IVerifyData()
//// Parse() ///////////////////////////////////////////////////////// //// Parse() /////////////////////////////////////////////////////////
void LocalizationDatabase::Parse(const plString & directory) void LocalizationDatabase::Parse(const plFileName & directory)
{ {
fDirectory = directory; fDirectory = directory;
fFiles.clear(); fFiles.clear();
char filename[255]; char filename[255];
hsFolderIterator xmlFolder((directory + PATH_SEPARATOR_STR).c_str()); hsFolderIterator xmlFolder(directory.AsString().c_str());
while(xmlFolder.NextFileSuffix(".loc")) while (xmlFolder.NextFileSuffix(".loc"))
{ {
xmlFolder.GetPathAndName(filename); xmlFolder.GetPathAndName(filename);
@ -822,7 +822,7 @@ plStatusLog *pfLocalizationDataMgr::fLog = nil; // output logfile
//// Constructor/Destructor ////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////
pfLocalizationDataMgr::pfLocalizationDataMgr(const plString & path) pfLocalizationDataMgr::pfLocalizationDataMgr(const plFileName & path)
{ {
hsAssert(!fInstance, "Tried to create the localization data manager more than once!"); hsAssert(!fInstance, "Tried to create the localization data manager more than once!");
fInstance = this; fInstance = this;
@ -932,7 +932,7 @@ void pfLocalizationDataMgr::IConvertAge(LocAgeInfo *ageInfo, const plString & cu
//// IWriteText ////////////////////////////////////////////////////// //// 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 weWroteData = false; // did we actually write any data of consequence?
bool setEmpty = true; bool setEmpty = true;
@ -980,7 +980,7 @@ void pfLocalizationDataMgr::IWriteText(const plString & filename, const plString
if (weWroteData) if (weWroteData)
{ {
// now spit the results out to the file // 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->Write(fileData.GetLength(), fileData.GetString().c_str());
xmlStream->Close(); xmlStream->Close();
delete xmlStream; delete xmlStream;
@ -989,7 +989,7 @@ void pfLocalizationDataMgr::IWriteText(const plString & filename, const plString
//// Initialize ////////////////////////////////////////////////////// //// Initialize //////////////////////////////////////////////////////
void pfLocalizationDataMgr::Initialize(const plString & path) void pfLocalizationDataMgr::Initialize(const plFileName & path)
{ {
if (fInstance) if (fInstance)
return; return;
@ -1194,7 +1194,7 @@ bool pfLocalizationDataMgr::DeleteElement(const plString & name)
//// WriteDatabaseToDisk ///////////////////////////////////////////// //// WriteDatabaseToDisk /////////////////////////////////////////////
void pfLocalizationDataMgr::WriteDatabaseToDisk(const plString & path) void pfLocalizationDataMgr::WriteDatabaseToDisk(const plFileName & path)
{ {
std::vector<plString> ageNames = GetAgeList(); std::vector<plString> ageNames = GetAgeList();
std::vector<plString> languageNames = IGetAllLanguageNames(); std::vector<plString> languageNames = IGetAllLanguageNames();
@ -1202,7 +1202,9 @@ void pfLocalizationDataMgr::WriteDatabaseToDisk(const plString & path)
{ {
for (int curLanguage = 0; curLanguage < languageNames.size(); curLanguage++) 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 <map>
#include "pfLocalizedString.h" #include "pfLocalizedString.h"
#include "plFileSystem.h"
class plStatusLog; class plStatusLog;
class plString;
// Helper classes/structs that are only used in this main class // Helper classes/structs that are only used in this main class
class LocalizationDatabase; 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 // 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; pf3PartMap<localizedElement> fLocalizedElements;
plString fDataPath; plFileName fDataPath;
localizedElement ICreateLocalizedElement(); // ease of use function that creates a basic localized element object 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 IConvertSet(LocSetInfo *setInfo, const plString & curPath);
void IConvertAge(LocAgeInfo *ageInfo, 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: public:
virtual ~pfLocalizationDataMgr(); virtual ~pfLocalizationDataMgr();
static void Initialize(const plString & path); static void Initialize(const plFileName & path);
static void Shutdown(); static void Shutdown();
static pfLocalizationDataMgr &Instance(void) {return *fInstance;} static pfLocalizationDataMgr &Instance(void) {return *fInstance;}
static bool InstanceValid(void) {return fInstance != nil;} static bool InstanceValid(void) {return fInstance != nil;}
@ -162,7 +162,7 @@ public:
bool DeleteElement(const plString & name); 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 // 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 void OutputTreeToLog(); // prints the localization tree to the log file
}; };

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

@ -73,7 +73,7 @@ pfLocalizationMgr::~pfLocalizationMgr()
//// Initialize ////////////////////////////////////////////////////// //// Initialize //////////////////////////////////////////////////////
void pfLocalizationMgr::Initialize(const plString & dataPath) void pfLocalizationMgr::Initialize(const plFileName & dataPath)
{ {
if (fInstance) if (fInstance)
return; 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" #include "HeadSpin.h"
class plFileName;
class pfLocalizationMgr class pfLocalizationMgr
{ {
private: private:
@ -60,7 +62,7 @@ protected:
public: public:
virtual ~pfLocalizationMgr(); virtual ~pfLocalizationMgr();
static void Initialize(const plString & dataPath); static void Initialize(const plFileName & dataPath);
static void Shutdown(); static void Shutdown();
static pfLocalizationMgr &Instance(void) {return *fInstance;} static pfLocalizationMgr &Instance(void) {return *fInstance;}
static bool InstanceValid(void) {return fInstance != nil;} 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" #include "hsStream.h"
pfMovieEventMsg::~pfMovieEventMsg()
{
delete [] fMovieName;
}
void pfMovieEventMsg::Read(hsStream* stream, hsResMgr* mgr) void pfMovieEventMsg::Read(hsStream* stream, hsResMgr* mgr)
{ {
plMessage::IMsgRead(stream, mgr); plMessage::IMsgRead(stream, mgr);
fReason = (Reason)stream->ReadByte(); fReason = (Reason)stream->ReadByte();
fMovieName = stream->ReadSafeString(); fMovieName = stream->ReadSafeString_TEMP();
} }
void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr) void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr)
@ -64,6 +58,6 @@ void pfMovieEventMsg::Write(hsStream* stream, hsResMgr* mgr)
stream->WriteByte(fReason); 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 #define pfMovieEventMsg_h_inc
#include "pnMessage/plMessage.h" #include "pnMessage/plMessage.h"
#include "plFileSystem.h"
class pfMovieEventMsg : public plMessage class pfMovieEventMsg : public plMessage
{ {
@ -54,23 +55,18 @@ public:
Reason fReason; 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; fReason = reason;
if (movieName) fMovieName = movieName;
fMovieName = hsStrcpy(movieName);
else
fMovieName = nil;
} }
pfMovieEventMsg() : plMessage(nil, nil, nil), fMovieName(nil), fReason(kMovieDone) pfMovieEventMsg() : plMessage(nil, nil, nil), fReason(kMovieDone)
{ {
} }
virtual ~pfMovieEventMsg();
CLASSNAME_REGISTER(pfMovieEventMsg); CLASSNAME_REGISTER(pfMovieEventMsg);
GETINTERFACE_ANY(pfMovieEventMsg, plMessage); 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; const char* theAge = ageName;
if ( ageName[0] == 0 ) if ( ageName[0] == 0 )
theAge = nil; theAge = nil;
key=plKeyFinder::Instance().StupidSearch(theAge,nil,plSceneObject::Index(), name, false); key=plKeyFinder::Instance().StupidSearch(theAge, "", plSceneObject::Index(), name, false);
} }
if ( key == nil ) if ( key == nil )
@ -1457,7 +1457,7 @@ void cyMisc::PageOutNode(const char* nodeName)
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kUnloadRoom); plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kUnloadRoom);
plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY ); plKey clientKey = hsgResMgr::ResMgr()->FindKey( kClient_KEY );
pMsg1->AddReceiver( clientKey ); pMsg1->AddReceiver( clientKey );
pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation(nil, nodeName)); pMsg1->AddRoomLoc(plKeyFinder::Instance().FindLocation("", nodeName));
plgDispatch::MsgSend(pMsg1); plgDispatch::MsgSend(pMsg1);
} }
} }
@ -2484,7 +2484,7 @@ void cyMisc::RebuildCameraStack(const plString& name, const char* ageName)
if ( !name.IsEmpty() ) if ( !name.IsEmpty() )
{ {
key=plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false); key=plKeyFinder::Instance().StupidSearch("", "", plSceneObject::Index(), name, false);
} }
if ( key == nil ) if ( key == nil )
{ {
@ -2685,7 +2685,7 @@ void cyMisc::FakeLinkToObjectNamed(const plString& name)
plKey key = nil; plKey key = nil;
if ( !name.IsEmpty() ) if ( !name.IsEmpty() )
{ {
key = plKeyFinder::Instance().StupidSearch(nil,nil,plSceneObject::Index(), name, false); key = plKeyFinder::Instance().StupidSearch("", "", plSceneObject::Index(), name, false);
} }
if (!key) if (!key)
@ -2790,28 +2790,24 @@ bool cyMisc::DumpLogs(const std::wstring & folder)
return retVal; 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]; return plFileSystem::GetUserDataPath();
PathGetUserDirectory(path, arrsize(path));
return path;
} }
std::wstring cyMisc::GetInitPath() plFileName cyMisc::GetInitPath()
{ {
wchar_t path[MAX_PATH]; return plFileSystem::GetInitPath();
PathGetInitDirectory(path, arrsize(path));
return path;
} }
void cyMisc::SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp) 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 #ifndef cyMisc_h
#define cyMisc_h #define cyMisc_h
#include <string>
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// NAME: cyMisc // NAME: cyMisc
@ -67,6 +65,7 @@ class pyGUIDialog;
class plPipeline; class plPipeline;
class plDisplayMode; class plDisplayMode;
class plUUID; class plUUID;
class plFileName;
struct PipelineParams; struct PipelineParams;
typedef struct _object PyObject; typedef struct _object PyObject;
@ -934,11 +933,11 @@ public:
static bool DumpLogs(const std::wstring & folder); static bool DumpLogs(const std::wstring & folder);
static bool FileExists(const std::wstring & filename); static bool FileExists(const plFileName & filename);
static bool CreateDir(const std::wstring & directory); static bool CreateDir(const plFileName & directory);
static std::wstring GetUserPath(); static plFileName GetUserPath();
static std::wstring GetInitPath(); static plFileName GetInitPath();
static void SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp); static void SetBehaviorNetFlags(pyKey & behKey, bool netForce, bool netProp);
static void SendFriendInvite(const wchar_t email[], const wchar_t toName[]); 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; PYTHON_RETURN_ERROR;
} }
if (PyUnicode_Check(filenameObj)) if (PyString_CheckEx(filenameObj))
{ {
int strLen = PyUnicode_GetSize(filenameObj); PYTHON_RETURN_BOOL(cyMisc::FileExists(PyString_AsStringEx(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);
} }
else else
{ {
@ -667,24 +652,9 @@ PYTHON_GLOBAL_METHOD_DEFINITION(PtCreateDir, args, "Params: directory\nCreates t
PYTHON_RETURN_ERROR; PYTHON_RETURN_ERROR;
} }
if (PyUnicode_Check(directoryObj)) if (PyString_CheckEx(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))
{ {
// we'll allow this, just in case something goes weird PYTHON_RETURN_BOOL(cyMisc::CreateDir(PyString_AsStringEx(directoryObj)));
char* text = PyString_AsString(directoryObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = cyMisc::CreateDir(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
} }
else 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.") 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_FromStringEx(cyMisc::GetUserPath().AsString());
return PyUnicode_FromWideChar(val.c_str(), val.length());
} }
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetInitPath, "Returns the unicode path to the client's init directory. Do NOT convert to a standard string.") 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_FromStringEx(cyMisc::GetInitPath().AsString());
return PyUnicode_FromWideChar(val.c_str(), val.length());
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////

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

@ -438,12 +438,8 @@ bool plPythonFileMod::ILoadPythonCode()
#ifndef PLASMA_EXTERNAL_RELEASE #ifndef PLASMA_EXTERNAL_RELEASE
// get code from file and execute in module // get code from file and execute in module
// see if the file exists first before trying to import it // see if the file exists first before trying to import it
char pathandfile[256]; plFileName pyfile = plFileName::Join(".", "python", plString::Format("%s.py", fPythonFile));
sprintf(pathandfile, ".\\python\\%s.py",fPythonFile); if (plFileInfo(pyfile).Exists())
wchar_t *wPathandfile = hsStringToWString(pathandfile);
bool exists = PathDoesFileExist(wPathandfile);
delete [] wPathandfile;
if (exists)
{ {
char fromLoad[256]; char fromLoad[256];
//sprintf(fromLoad,"from %s import *", fPythonFile); //sprintf(fromLoad,"from %s import *", fPythonFile);
@ -453,7 +449,7 @@ bool plPythonFileMod::ILoadPythonCode()
if ( PythonInterface::RunString( fromLoad, fModule) ) if ( PythonInterface::RunString( fromLoad, fModule) )
{ {
// we've loaded the code into our module // 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) ) if ( !PythonInterface::RunString("execfile('.\\\\python\\\\plasma\\\\glue.py')", fModule) )
{ {
// display any output (NOTE: this would be disabled in production) // 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 "plgDispatch.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plFile/plSecureStream.h" #include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h" #include "plFile/plStreamSource.h"
#include "plMessage/plNetCommMsgs.h" #include "plMessage/plNetCommMsgs.h"
@ -96,7 +95,7 @@ void GotFileSrvManifest(
void* param, void* param,
const wchar_t group[], const wchar_t group[],
const NetCliFileManifestEntry manifest[], const NetCliFileManifestEntry manifest[],
uint32_t entryCount uint32_t entryCount
) { ) {
pfSecurePreloader* sp = (pfSecurePreloader*)param; pfSecurePreloader* sp = (pfSecurePreloader*)param;
if (result == kNetErrFileNotFound) if (result == kNetErrFileNotFound)
@ -116,10 +115,10 @@ void GotFileSrvManifest(
} }
void FileDownloaded( void FileDownloaded(
ENetError result, ENetError result,
void* param, void* param,
const wchar_t filename[], const plFileName & filename,
hsStream* writer hsStream* writer
) { ) {
pfSecurePreloader* sp = (pfSecurePreloader*)param; pfSecurePreloader* sp = (pfSecurePreloader*)param;
if (IS_NET_ERROR(result)) if (IS_NET_ERROR(result))
@ -243,9 +242,9 @@ void pfSecurePreloader::PreloadNextFile()
// Thankfully, both callbacks have the same arguments // Thankfully, both callbacks have the same arguments
if (fLegacyMode) if (fLegacyMode)
NetCliAuthFileRequest(filename.AsString().ToWchar(), s, FileDownloaded, this); NetCliAuthFileRequest(filename, s, FileDownloaded, this);
else else
NetCliFileDownloadRequest(filename.AsString().ToWchar(), s, FileDownloaded, this); NetCliFileDownloadRequest(filename, s, FileDownloaded, this);
} }
void pfSecurePreloader::Init() void pfSecurePreloader::Init()
@ -346,8 +345,8 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
const NetCliFileManifestEntry mfs = manifestEntries[i]; const NetCliFileManifestEntry mfs = manifestEntries[i];
bool fetchMe = true; bool fetchMe = true;
hsRAMStream* s = nil; hsRAMStream* s = nil;
plFileName clientName = plString::FromWchar(mfs.clientName); plFileName clientName = mfs.clientName;
plFileName downloadName = plString::FromWchar(mfs.downloadName); plFileName downloadName = mfs.downloadName;
if (plFileInfo(clientName).Exists()) if (plFileInfo(clientName).Exists())
{ {
@ -355,10 +354,8 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
if (s) if (s)
{ {
// Damn this // Damn this
const char* md5 = hsWStringToString(mfs.md5);
plMD5Checksum srvHash; plMD5Checksum srvHash;
srvHash.SetFromHexString(md5); srvHash.SetFromHexString(mfs.md5.c_str());
delete[] md5;
// Now actually copare the hashes // Now actually copare the hashes
plMD5Checksum lclHash; plMD5Checksum lclHash;
@ -394,7 +391,7 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
PreloadNextFile(); PreloadNextFile();
} }
void pfSecurePreloader::FilePreloaded(const wchar_t* file, hsStream* stream) void pfSecurePreloader::FilePreloaded(const plFileName& file, hsStream* stream)
{ {
// Clear out queue // Clear out queue
fDownloadEntries.pop(); 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 NetCliFileManifestEntry manifestEntries[], uint32_t entryCount);
void PreloadManifest(const NetCliAuthFileInfo manifestEntries[], uint32_t entryCount); void PreloadManifest(const NetCliAuthFileInfo manifestEntries[], uint32_t entryCount);
void PreloadNextFile(); void PreloadNextFile();
void FilePreloaded(const wchar_t* filename, hsStream* stream); void FilePreloaded(const plFileName& filename, hsStream* stream);
plOperationProgress* GetProgressBar() { return fProgress; } plOperationProgress* GetProgressBar() { return fProgress; }

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

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

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

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

@ -53,17 +53,17 @@ class hsResMgr;
class plLayerMovie : public plLayerAnimation class plLayerMovie : public plLayerAnimation
{ {
protected: protected:
char* fMovieName; plFileName fMovieName;
// plAnimTimeConvert fTimeConvert; // plAnimTimeConvert fTimeConvert;
int32_t fCurrentFrame; int32_t fCurrentFrame;
float fLength; float fLength;
uint32_t fWidth, fHeight; 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 ISetFault(const char* errStr);
bool ICheckBitmap(); bool ICheckBitmap();
bool IMovieIsIdle(); // will call IRelease(); bool IMovieIsIdle(); // will call IRelease();
@ -82,15 +82,15 @@ public:
CLASSNAME_REGISTER( plLayerMovie ); CLASSNAME_REGISTER( plLayerMovie );
GETINTERFACE_ANY( plLayerMovie, plLayerAnimation ); 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 Read(hsStream* s, hsResMgr* mgr);
virtual void Write(hsStream* s, hsResMgr* mgr); virtual void Write(hsStream* s, hsResMgr* mgr);
bool IsStopped() { return fTimeConvert.IsStopped(); } bool IsStopped() { return fTimeConvert.IsStopped(); }
void SetMovieName(const char* n); void SetMovieName(const plFileName& n) { fMovieName = n; }
const char* GetMovieName() const { return fMovieName; } const plFileName& GetMovieName() const { return fMovieName; }
virtual bool MsgReceive(plMessage* msg); virtual bool MsgReceive(plMessage* msg);

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

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
void plClientMsg::IReset() void plClientMsg::IReset()
{ {
fMsgFlag = 0; fMsgFlag = 0;
fAgeName = nil; fAgeName = "";
} }
void plClientMsg::AddRoomLoc(plLocation loc) 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 class plClientMsg : public plMessage
{ {
int fMsgFlag; int fMsgFlag;
char* fAgeName; plString fAgeName;
std::vector<plLocation> fRoomLocs; std::vector<plLocation> fRoomLocs;
void IReset(); void IReset();
@ -105,7 +105,6 @@ public:
plClientMsg(const plKey &s) { IReset();} plClientMsg(const plKey &s) { IReset();}
plClientMsg(int i) { IReset(); fMsgFlag = i; } plClientMsg(int i) { IReset(); fMsgFlag = i; }
plClientMsg(const plKey &s, const plKey &r, const double* t) { IReset(); } plClientMsg(const plKey &s, const plKey &r, const double* t) { IReset(); }
~plClientMsg() { delete [] fAgeName; }
CLASSNAME_REGISTER(plClientMsg); CLASSNAME_REGISTER(plClientMsg);
GETINTERFACE_ANY(plClientMsg, plMessage); GETINTERFACE_ANY(plClientMsg, plMessage);
@ -115,8 +114,8 @@ public:
void AddRoomLoc(plLocation loc); void AddRoomLoc(plLocation loc);
// Used for kLoadAgeKeys, kLetGoOfAgeKeys only // Used for kLoadAgeKeys, kLetGoOfAgeKeys only
const char* GetAgeName() const { return fAgeName; } plString GetAgeName() const { return fAgeName; }
void SetAgeName(const char* age) { delete [] fAgeName; fAgeName = hsStrcpy(age); } void SetAgeName(const plString& age) { fAgeName = age; }
int GetNumRoomLocs() { return fRoomLocs.size(); } int GetNumRoomLocs() { return fRoomLocs.size(); }
const plLocation& GetRoomLoc(int i) const { return fRoomLocs[i]; } 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 // FileDownloadRequest
struct Cli2File_FileDownloadRequest : Cli2File_MsgHeader { struct Cli2File_FileDownloadRequest : Cli2File_MsgHeader {
uint32_t transId; uint32_t transId;
wchar_t filename[MAX_PATH]; wchar_t filename[MAX_PATH];
unsigned buildId; // 0 = newest unsigned buildId; // 0 = newest
}; };
struct Cli2File_FileDownloadChunkAck : Cli2File_MsgHeader { 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 * PathFindFilename (
const wchar_t path[] 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); 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, // 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 // but has been updated to support UNC paths and to avoid blasting off the end
@ -348,52 +295,6 @@ void PathMakePath (
*path = L'\0'; *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 ( void PathFindFiles (
ARRAY(PathFind) * paths, ARRAY(PathFind) * paths,
@ -504,82 +405,3 @@ void PathFindFiles (
} while (FindNextFileW(find, &fd)); } while (FindNextFileW(find, &fd));
FindClose(find); 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 { struct PathFind {
unsigned flags; unsigned flags;
uint64_t fileLength; uint64_t fileLength;
uint64_t lastWriteTime; uint64_t lastWriteTime;
wchar_t name[MAX_PATH]; wchar_t name[MAX_PATH];
}; };
@ -90,18 +90,14 @@ struct PathFind {
void PathFindFiles ( void PathFindFiles (
ARRAY(PathFind) * paths, ARRAY(PathFind) * paths,
const wchar_t fileSpec[], const wchar_t fileSpec[],
unsigned pathFlags unsigned pathFlags
); );
void PathGetProgramName ( void PathGetProgramName (
wchar_t * dst, wchar_t * dst,
unsigned dstChars unsigned dstChars
); );
bool PathDoesFileExist (
const wchar_t fileName[]
);
/***************************************************************************** /*****************************************************************************
* *
@ -110,20 +106,20 @@ bool PathDoesFileExist (
***/ ***/
void PathSplitPath ( void PathSplitPath (
const wchar_t path[], const wchar_t path[],
wchar_t * drive, wchar_t * drive,
wchar_t * dir, wchar_t * dir,
wchar_t * fname, wchar_t * fname,
wchar_t * ext wchar_t * ext
); );
void PathMakePath ( void PathMakePath (
wchar_t * path, wchar_t * path,
unsigned chars, unsigned chars,
const wchar_t drive[], const wchar_t drive[],
const wchar_t dir[], const wchar_t dir[],
const wchar_t fname[], const wchar_t fname[],
const wchar_t ext[] const wchar_t ext[]
); );
// c:\dir1 + dir2\file.txt => c:\dir1\dir2\file.txt // 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 // Get directory
void PathGetProgramDirectory ( void PathGetProgramDirectory (
wchar_t * dst, 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,
unsigned dstChars unsigned dstChars
); );
@ -206,13 +160,13 @@ void PathGetInitDirectory (
// you may send nil for any fields you don't care about // you may send nil for any fields you don't care about
void PathSplitEmail ( void PathSplitEmail (
const wchar_t emailAddr[], const wchar_t emailAddr[],
wchar_t * user, wchar_t * user,
unsigned userChars, unsigned userChars,
wchar_t * domain, wchar_t * domain,
unsigned domainChars, unsigned domainChars,
wchar_t * tld, wchar_t * tld,
unsigned tldChars, 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 subDomainChars, // arrsize(subs[0]) --> 256
unsigned subDomainCount // arrsize(subs) --> 16 unsigned subDomainCount // arrsize(subs) --> 16
); );

139
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeDescription.cpp

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

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

@ -57,9 +57,9 @@ class hsStream;
class plAgePage class plAgePage
{ {
protected: protected:
char *fName; plString fName;
uint32_t fSeqSuffix; uint32_t fSeqSuffix;
uint8_t fFlags; uint8_t fFlags;
public: public:
@ -73,21 +73,20 @@ class plAgePage
kIsVolatile = 0x08, kIsVolatile = 0x08,
}; };
plAgePage( const char *name, uint32_t seqSuffix, uint8_t flags ); plAgePage( const plString &name, uint32_t seqSuffix, uint8_t flags );
plAgePage( char *stringFrom ); plAgePage( const plString &stringFrom );
plAgePage( const plAgePage &src ); plAgePage( const plAgePage &src );
plAgePage(); plAgePage();
~plAgePage();
const char *GetName( void ) const { return fName; } plString GetName( void ) const { return fName; }
uint32_t GetSeqSuffix( void ) const { return fSeqSuffix; } uint32_t GetSeqSuffix( void ) const { return fSeqSuffix; }
uint8_t GetFlags( void ) const { return fFlags; } uint8_t GetFlags( void ) const { return fFlags; }
void SetSeqSuffix( uint32_t s ) { fSeqSuffix = s; } void SetSeqSuffix( uint32_t s ) { fSeqSuffix = s; }
void SetFlags(uint8_t f, bool on=true); void SetFlags(uint8_t f, bool on=true);
bool SetFromString( const char *string ); bool SetFromString( const plString &string );
char *GetAsString( void ) const; plString GetAsString( void ) const;
plAgePage &operator=( const plAgePage &src ); plAgePage &operator=( const plAgePage &src );
}; };
@ -98,16 +97,16 @@ class plAgeDescription : public plInitSectionTokenReader
{ {
private: private:
char *fName; plString fName;
int32_t fPageIterator; int32_t fPageIterator;
hsTArray<plAgePage> fPages; hsTArray<plAgePage> fPages;
plUnifiedTime fStart; plUnifiedTime fStart;
float fDayLength; float fDayLength;
short fMaxCapacity; 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; int32_t fSeqPrefix;
uint32_t fReleaseVersion; // 0 for pre-release, 1+ for actual released ages uint32_t fReleaseVersion; // 0 for pre-release, 1+ for actual released ages
@ -124,7 +123,7 @@ public:
static char kAgeDescPath[]; static char kAgeDescPath[];
plAgeDescription(); plAgeDescription();
plAgeDescription( const char *fileNameToReadFrom ); plAgeDescription( const plFileName &fileNameToReadFrom );
plAgeDescription( const plAgeDescription &src ) plAgeDescription( const plAgeDescription &src )
{ {
IInit(); IInit();
@ -132,28 +131,28 @@ public:
} }
~plAgeDescription(); ~plAgeDescription();
bool ReadFromFile( const char *fileNameToReadFrom ) ; bool ReadFromFile( const plFileName &fileNameToReadFrom );
void Read(hsStream* stream); void Read(hsStream* stream);
void Write(hsStream* stream) const; void Write(hsStream* stream) const;
// Overload for plInitSectionTokenReader // Overload for plInitSectionTokenReader
virtual const char *GetSectionName( void ) const; virtual const char *GetSectionName( void ) const;
const char *GetAgeName( void ) const { return fName; } plString GetAgeName( void ) const { return fName; }
void SetAgeNameFromPath( const char *path ); void SetAgeNameFromPath( const plFileName &path );
void SetAgeName(const char* ageName) { delete [] fName; fName=hsStrcpy(ageName); } void SetAgeName(const plString& ageName) { fName = ageName; }
// Page list // Page list
void ClearPageList(); void ClearPageList();
void RemovePage( const char *page ); void RemovePage( const plString &page );
void AppendPage( const char *name, int seqSuffix = -1, uint8_t flags = 0 ); void AppendPage( const plString &name, int seqSuffix = -1, uint8_t flags = 0 );
void SeekFirstPage( void ); void SeekFirstPage( void );
plAgePage *GetNextPage( void ); plAgePage *GetNextPage( void );
int GetNumPages() const { return fPages.GetCount(); } int GetNumPages() const { return fPages.GetCount(); }
plAgePage *FindPage( const char *name ) const; plAgePage *FindPage( const plString &name ) const;
bool FindLocation(const plLocation& loc) const; bool FindLocation(const plLocation& loc) const;
plLocation CalcPageLocation( const char *page ) const; plLocation CalcPageLocation( const plString &page ) const;
// Getters // Getters
short GetStartMonth() const { return fStart.GetMonth(); } 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/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plFile/plInitFileReader.h" #include "plFile/plInitFileReader.h"
#include "hsStringTokenizer.h" #include "hsStringTokenizer.h"
//// plManifestFile /////////////////////////////////////////////////////// //// 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), fChecksum(check),
fSize(size), fSize(size),
fZippedSize(zippedSize), fZippedSize(zippedSize),
fFlags(flags), fFlags(flags),
fMd5Checked(md5Now) fMd5Checked(md5Now)
{ {
fName = name;
fServerPath = serverPath;
if (md5Now) if (md5Now)
{ {
DoMd5Check(); DoMd5Check();
@ -81,9 +81,9 @@ plManifestFile::~plManifestFile()
void plManifestFile::DoMd5Check() void plManifestFile::DoMd5Check()
{ {
if (plFileUtils::FileExists(fName.c_str())) if (plFileInfo(fName).Exists())
{ {
plMD5Checksum localFile(fName.c_str()); plMD5Checksum localFile(fName);
fIsLocalUpToDate = (localFile == fChecksum); fIsLocalUpToDate = (localFile == fChecksum);
fLocalExists = true; 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 class plManifestFile
{ {
protected: protected:
std::string fName; plFileName fName;
std::string fServerPath; plFileName fServerPath;
plMD5Checksum fChecksum; plMD5Checksum fChecksum;
uint32_t fSize; uint32_t fSize;
uint32_t fZippedSize; uint32_t fZippedSize;
uint32_t fFlags; uint32_t fFlags;
bool fMd5Checked; bool fMd5Checked;
bool fIsLocalUpToDate; bool fIsLocalUpToDate;
@ -86,11 +86,12 @@ public:
kFlagZipped = 1<<3, 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(); virtual ~plManifestFile();
const char* GetName() const { return fName.c_str(); } const plFileName &GetName() const { return fName; }
const char* GetServerPath() const { return fServerPath.c_str(); } const plFileName &GetServerPath() const { return fServerPath; }
const plMD5Checksum& GetChecksum() const { return fChecksum; } const plMD5Checksum& GetChecksum() const { return fChecksum; }
uint32_t GetDiskSize() const { return fSize; } uint32_t GetDiskSize() const { return fSize; }
uint32_t GetDownloadSize() const { return hsCheckBits(fFlags, kFlagZipped) ? fZippedSize : 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) ) if( IsPageExcluded( page, fAgeName) )
{ {
nc->DebugMsg( "\tExcluding page %s\n", page->GetName() ); nc->DebugMsg("\tExcluding page %s\n", page->GetName().c_str());
continue; continue;
} }
nPages++; nPages++;
pMsg1->AddRoomLoc(ad.CalcPageLocation(page->GetName())); 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); 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; return true;
// check exclude list // check exclude list
const char* pageName = page->GetName(); plString pageName = page->GetName();
int i; int i;
for( i = 0; i < sExcludeList.GetCount(); 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 || if( ageName == nil || sExcludeList[ i ].fAgeName == nil ||
stricmp( ageName, sExcludeList[ i ].fAgeName ) == 0 ) 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 "plAgeLoader/plAgeLoader.h"
#include "plCompression/plZlibStream.h" #include "plCompression/plZlibStream.h"
#include "pnEncryption/plChecksum.h" #include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plMessage/plResPatcherMsg.h" #include "plMessage/plResPatcherMsg.h"
#include "pnNetBase/pnNbError.h" #include "pnNetBase/pnNbError.h"
#include "plNetGameLib/plNetGameLib.h" #include "plNetGameLib/plNetGameLib.h"
@ -91,33 +90,32 @@ public:
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
static void FileDownloaded( static void FileDownloaded(
ENetError result, ENetError result,
void* param, void* param,
const wchar_t filename[], const plFileName & filename,
hsStream* writer) hsStream* writer)
{ {
plResPatcher* patcher = (plResPatcher*)param; plResPatcher* patcher = (plResPatcher*)param;
char* name = hsWStringToString(filename); plFileName file = filename;
if (((plResDownloadStream*)writer)->IsZipped()) if (((plResDownloadStream*)writer)->IsZipped())
plFileUtils::StripExt(name); // Kill off .gz file = file.StripFileExt(); // Kill off .gz
writer->Close(); writer->Close();
switch (result) switch (result)
{ {
case kNetSuccess: 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 this is a PRP, then we need to add it to the ResManager
if (stricmp(plFileUtils::GetFileExt(name), "prp") == 0) if (file.AsString().CompareI("prp") == 0)
((plResManager*)hsgResMgr::ResMgr())->AddSinglePage(name); ((plResManager*)hsgResMgr::ResMgr())->AddSinglePage(file);
// Continue down the warpath // Continue down the warpath
patcher->IssueRequest(); patcher->IssueRequest();
delete[] name;
delete writer; delete writer;
return; return;
case kNetErrFileNotFound: case kNetErrFileNotFound:
PatcherLog(kError, " Download Failed: %s not found", name); PatcherLog(kError, " Download Failed: %s not found", file.AsString().c_str());
break; break;
default: default:
char* error = hsWStringToString(NetErrorToString(result)); char* error = hsWStringToString(NetErrorToString(result));
@ -129,7 +127,6 @@ static void FileDownloaded(
// Failure case // Failure case
((plResDownloadStream*)writer)->Unlink(); ((plResDownloadStream*)writer)->Unlink();
patcher->Finish(false); patcher->Finish(false);
delete[] name;
delete writer; delete writer;
} }
@ -153,8 +150,8 @@ static void ManifestDownloaded(
for (uint32_t i = 0; i < entryCount; ++i) for (uint32_t i = 0; i < entryCount; ++i)
{ {
const NetCliFileManifestEntry mfs = manifest[i]; const NetCliFileManifestEntry mfs = manifest[i];
plFileName fileName = plString::FromWchar(mfs.clientName); plFileName fileName = mfs.clientName;
plFileName downloadName = plString::FromWchar(mfs.downloadName); plFileName downloadName = mfs.downloadName;
// See if the files are the same // See if the files are the same
// 1. Check file size before we do time consuming md5 operations // 1. Check file size before we do time consuming md5 operations
@ -163,7 +160,7 @@ static void ManifestDownloaded(
{ {
plMD5Checksum cliMD5(fileName); plMD5Checksum cliMD5(fileName);
plMD5Checksum srvMD5; plMD5Checksum srvMD5;
srvMD5.SetFromHexString(plString::FromWchar(mfs.md5).c_str()); srvMD5.SetFromHexString(mfs.md5.c_str());
if (cliMD5 == srvMD5) if (cliMD5 == srvMD5)
continue; continue;
@ -238,7 +235,7 @@ void plResPatcher::IssueRequest()
plFileSystem::CreateDir(req.fFriendlyName.StripFileName(), true); plFileSystem::CreateDir(req.fFriendlyName.StripFileName(), true);
plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile); plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile);
if (stream->Open(req.fFriendlyName, "wb")) if (stream->Open(req.fFriendlyName, "wb"))
NetCliFileDownloadRequest(req.fFile.AsString().ToWchar(), stream, FileDownloaded, this); NetCliFileDownloadRequest(req.fFile, stream, FileDownloaded, this);
else { else {
PatcherLog(kError, " Unable to create file %s", req.fFriendlyName.AsString().c_str()); PatcherLog(kError, " Unable to create file %s", req.fFriendlyName.AsString().c_str());
Finish(false); 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 ((plSoundBuffer *)fDataBufferKey->ObjectIsLoaded())->GetFileName();
} }
return nil; return "";
} }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////

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

@ -211,9 +211,9 @@ public:
virtual void Update(); virtual void Update();
plSoundBuffer * GetDataBuffer( void ) const { return (plSoundBuffer *)fDataBufferKey->ObjectIsLoaded(); } 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(); virtual double GetLength();
void SetProperty( Property prop, bool on ) { if( on ) fProperties |= prop; else fProperties &= ~prop; } 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 ); IFillCurrentSound( 0 );
// Logging // Logging
plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName() != nil ? "file" : "buffer", plString str = plString::Format(" Grouped %s %s allocated (%d msec).", buffer->GetFileName().IsValid() ? "file" : "buffer",
buffer->GetFileName() != nil ? buffer->GetFileName() : buffer->GetKey()->GetUoid().GetObjectName().c_str(), buffer->GetFileName().IsValid() ? buffer->GetFileName().AsString().c_str() : buffer->GetKey()->GetUoid().GetObjectName().c_str(),
//fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software", //fDSoundBuffer->IsHardwareAccelerated() ? "hardware" : "software",
//fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic", //fDSoundBuffer->IsStaticVoice() ? "static" : "dynamic",
#ifdef PL_PROFILE_ENABLED #ifdef PL_PROFILE_ENABLED
gProfileVarStaticSndShoveTime.GetValue() ); gProfileVarStaticSndShoveTime.GetValue() );
#else #else
0 ); 0 );
#endif #endif
IPrintDbgMessage( str.c_str() ); IPrintDbgMessage( str.c_str() );
if( GetKey() != nil && GetKeyName().Find( "Footstep" ) >= 0 ) if( GetKey() != nil && GetKeyName().Find( "Footstep" ) >= 0 )

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

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

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

@ -70,15 +70,15 @@ public:
virtual bool MsgReceive( plMessage *pMsg ); virtual bool MsgReceive( plMessage *pMsg );
protected: protected:
float fTimeAtBufferStart; float fTimeAtBufferStart;
plAudioFileReader *fDataStream; plAudioFileReader *fDataStream;
float fBufferLengthInSecs; float fBufferLengthInSecs;
uint8_t fBlankBufferFillCounter; uint8_t fBlankBufferFillCounter;
plSoundDeswizzler *fDeswizzler; plSoundDeswizzler *fDeswizzler;
char fSrcFilename[ 256 ]; plFileName fSrcFilename;
StreamType fStreamType; 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 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 // ultimately this filename will be given to fDataBuffer, but since it's not always around we'll store it here
bool fStopping; bool fStopping;
@ -86,7 +86,7 @@ protected:
bool fPlayWhenStopped; bool fPlayWhenStopped;
unsigned fStartPos; unsigned fStartPos;
float IGetTimeAtBufferStart( void ) { return fTimeAtBufferStart; } float IGetTimeAtBufferStart( void ) { return fTimeAtBufferStart; }
virtual void SetStartPos(unsigned bytes); virtual void SetStartPos(unsigned bytes);
virtual void IDerivedActuallyPlay( void ); 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 "hsTimer.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.h" #include "plBufferedFileReader.h"
#include "plCachedFileReader.h" #include "plCachedFileReader.h"
@ -66,20 +65,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#define kCacheDirName "temp" #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) 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. // We want to stream a wav off disk, but this is a compressed file.
// Get the uncompressed path. Ignore the requested channel, since it // Get the uncompressed path. Ignore the requested channel, since it
// will have already been split into two files if that is necessary. // will have already been split into two files if that is necessary.
if (!isWav) if (!isWav)
{ {
char cachedPath[256]; plFileName cachedPath = IGetCachedPath(path, whichChan);
IGetCachedPath(path, cachedPath, whichChan);
plAudioFileReader *r = new plCachedFileReader(cachedPath, plAudioCore::kAll); plAudioFileReader *r = new plCachedFileReader(cachedPath, plAudioCore::kAll);
if (!r->IsValid()) { if (!r->IsValid()) {
// So we tried to play a cached file and it didn't exist // 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; 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); plAudioFileReader* writer = new plCachedFileReader(path, plAudioCore::kAll);
writer->OpenForWriting(path, header); writer->OpenForWriting(path, header);
return writer; 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 // Get the file's path and add our streaming cache folder to it
strcpy(cachedPath, path); plFileName cachedPath = plFileName::Join(path.StripFileName(), kCacheDirName);
plFileUtils::StripFile(cachedPath);
strcat(cachedPath, kCacheDirName"\\");
// Create the directory first // Create the directory first
plFileUtils::CreateDir(cachedPath); plFileSystem::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);
const char *suffix = "";
if (whichChan == plAudioCore::kLeft) if (whichChan == plAudioCore::kLeft)
strcat(cachedPath, "-Left.tmp"); suffix = "-Left.tmp";
else if (whichChan == plAudioCore::kRight) else if (whichChan == plAudioCore::kRight)
strcat(cachedPath, "-Right.tmp"); suffix = "-Right.tmp";
else if (whichChan == plAudioCore::kAll) 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]; plFileName cachedPath = IGetCachedPath(path, whichChan);
IGetCachedPath(path, cachedPath, whichChan); if (!noOverwrite || !plFileInfo(cachedPath).Exists())
if (!noOverwrite || !plFileUtils::FileExists(cachedPath))
{ {
plAudioFileReader* reader = plAudioFileReader::CreateReader(path, whichChan, kStreamNative); plAudioFileReader* reader = plAudioFileReader::CreateReader(path, whichChan, kStreamNative);
if (!reader || !reader->IsValid()) 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) 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 Definition ////////////////////////////////////////////////////////
class plFileName;
class plUnifiedTime; class plUnifiedTime;
class plWAVHeader; class plWAVHeader;
class plAudioFileReader class plAudioFileReader
@ -80,20 +81,20 @@ public:
virtual bool Read( uint32_t numBytes, void *buffer ) = 0; virtual bool Read( uint32_t numBytes, void *buffer ) = 0;
virtual uint32_t NumBytesLeft( void ) = 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 uint32_t Write( uint32_t bytes, void *buffer ) { return 0; }
virtual bool IsValid( void ) = 0; virtual bool IsValid( void ) = 0;
static plAudioFileReader* CreateReader(const char* path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll, StreamType type = kStreamWAV); static plAudioFileReader* CreateReader(const plFileName& path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll, StreamType type = kStreamWAV);
static plAudioFileReader* CreateWriter(const char* path, plWAVHeader& header); static plAudioFileReader* CreateWriter(const plFileName& path, plWAVHeader& header);
// Decompresses a compressed file to the cache directory // 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: protected:
static void IGetCachedPath(const char* path, char* cachedPath, plAudioCore::ChannelSelect whichChan); static plFileName IGetCachedPath(const plFileName& path, plAudioCore::ChannelSelect whichChan);
static void ICacheFile(const char* path, bool noOverwrite, plAudioCore::ChannelSelect whichChan); static void ICacheFile(const plFileName& path, bool noOverwrite, plAudioCore::ChannelSelect whichChan);
}; };
#endif //_plAudioFileReader_h #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 <string.h>
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plBufferedFileReader.h" #include "plBufferedFileReader.h"
#include "plFileSystem.h"
//#include "plProfile.h" //#include "plProfile.h"
@ -64,14 +65,14 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
//// Constructor/Destructor ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
plBufferedFileReader::plBufferedFileReader( const char *path, plAudioCore::ChannelSelect whichChan ) plBufferedFileReader::plBufferedFileReader( const plFileName &path, plAudioCore::ChannelSelect whichChan )
{ {
// Init some stuff // Init some stuff
fBufferSize = 0; fBufferSize = 0;
fBuffer = nil; fBuffer = nil;
fCursor = 0; 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 // Ask plAudioFileReader for another reader to get this file
// Note: have this reader do the chanSelect for us // 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 class plBufferedFileReader : public plAudioFileReader
{ {
public: public:
plBufferedFileReader( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll ); plBufferedFileReader( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
virtual ~plBufferedFileReader(); virtual ~plBufferedFileReader();
virtual plWAVHeader &GetHeader( void ); virtual plWAVHeader &GetHeader( void );
@ -72,10 +72,10 @@ public:
virtual bool IsValid( void ) { return ( fBuffer != nil ) ? true : false; } virtual bool IsValid( void ) { return ( fBuffer != nil ) ? true : false; }
protected: protected:
uint32_t fBufferSize; uint32_t fBufferSize;
uint8_t *fBuffer; uint8_t *fBuffer;
plWAVHeader fHeader; plWAVHeader fHeader;
uint32_t fCursor; uint32_t fCursor;
void IError( const char *msg ); 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 ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
plCachedFileReader::plCachedFileReader(const char *path, plCachedFileReader::plCachedFileReader(const plFileName &path,
plAudioCore::ChannelSelect whichChan) plAudioCore::ChannelSelect whichChan)
: fFileHandle(nil), fCurPosition(0) : fFilename(path), fFileHandle(nil), fCurPosition(0)
{ {
hsAssert(path != nil, "Invalid path specified in plCachedFileReader"); hsAssert(path.IsValid(), "Invalid path specified in plCachedFileReader");
strncpy(fFilename, path, sizeof(fFilename));
/// Open the file as a plain binary stream /// Open the file as a plain binary stream
fFileHandle = fopen(path, "rb"); fFileHandle = plFileSystem::Open(path, "rb");
if (fFileHandle != nil) if (fFileHandle != nil)
{ {
if (fread(&fHeader, 1, sizeof(plWAVHeader), fFileHandle) if (fread(&fHeader, 1, sizeof(plWAVHeader), fFileHandle)
@ -162,17 +160,17 @@ uint32_t plCachedFileReader::NumBytesLeft()
return fDataLength - fCurPosition; 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; fHeader = header;
fCurPosition = 0; fCurPosition = 0;
fDataLength = 0; fDataLength = 0;
strncpy(fFilename, path, sizeof(fFilename)); fFilename = path;
/// Open the file as a plain binary stream /// Open the file as a plain binary stream
fFileHandle = fopen(path, "wb"); fFileHandle = plFileSystem::Open(path, "wb");
if (fFileHandle != nil) 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 #define _plcachedfilereader_h
#include "plAudioFileReader.h" #include "plAudioFileReader.h"
#include "plFileSystem.h"
//// Class Definition //////////////////////////////////////////////////////// //// Class Definition ////////////////////////////////////////////////////////
class plCachedFileReader : public plAudioFileReader class plCachedFileReader : public plAudioFileReader
{ {
public: public:
plCachedFileReader(const char *path, plCachedFileReader(const plFileName &path,
plAudioCore::ChannelSelect whichChan = plAudioCore::kAll); plAudioCore::ChannelSelect whichChan = plAudioCore::kAll);
virtual ~plCachedFileReader(); virtual ~plCachedFileReader();
@ -75,7 +76,7 @@ public:
virtual bool Read(uint32_t numBytes, void *buffer); virtual bool Read(uint32_t numBytes, void *buffer);
virtual uint32_t NumBytesLeft(); 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 uint32_t Write(uint32_t bytes, void *buffer);
virtual bool IsValid() { return fFileHandle != nil; } virtual bool IsValid() { return fFileHandle != nil; }
@ -86,11 +87,11 @@ protected:
kPCMFormatTag = 1 kPCMFormatTag = 1
}; };
char fFilename[512]; plFileName fFilename;
FILE * fFileHandle; FILE * fFileHandle;
plWAVHeader fHeader; plWAVHeader fHeader;
uint32_t fDataLength; uint32_t fDataLength;
uint32_t fCurPosition; uint32_t fCurPosition;
void IError(const char *msg); void IError(const char *msg);
}; };

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

@ -112,14 +112,14 @@ class plRIFFHeader
//// Constructor/Destructor ////////////////////////////////////////////////// //// 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; fWhichChannel = whichChan;
fFileHandle = fopen( path, "rb" ); fFileHandle = plFileSystem::Open(path, "rb");
if( fFileHandle != nil ) if( fFileHandle != nil )
{ {
/// Read in our header and calc our start position /// Read in our header and calc our start position
@ -227,7 +227,7 @@ void plFastWAV::Open()
if(fFileHandle) if(fFileHandle)
return; return;
fFileHandle = fopen( fFilename, "rb" ); fFileHandle = plFileSystem::Open(fFilename, "rb");
if(!fFileHandle) if(!fFileHandle)
return; 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 #define _plFastWavReader_h
#include "plAudioFileReader.h" #include "plAudioFileReader.h"
#include "plFileSystem.h"
//// Class Definition //////////////////////////////////////////////////////// //// Class Definition ////////////////////////////////////////////////////////
@ -60,7 +61,7 @@ class plRIFFChunk;
class plFastWAV : public plAudioFileReader class plFastWAV : public plAudioFileReader
{ {
public: public:
plFastWAV( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll ); plFastWAV( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
virtual ~plFastWAV(); virtual ~plFastWAV();
virtual plWAVHeader &GetHeader( void ); virtual plWAVHeader &GetHeader( void );
@ -83,13 +84,13 @@ protected:
kPCMFormatTag = 1 kPCMFormatTag = 1
}; };
char fFilename[ 512 ]; plFileName fFilename;
FILE * fFileHandle; FILE * fFileHandle;
plWAVHeader fHeader, fFakeHeader; plWAVHeader fHeader, fFakeHeader;
uint32_t fDataStartPos, fCurrDataPos, fDataSize; uint32_t fDataStartPos, fCurrDataPos, fDataSize;
uint32_t fChunkStart; uint32_t fChunkStart;
plAudioCore::ChannelSelect fWhichChannel; plAudioCore::ChannelSelect fWhichChannel;
uint32_t fChannelAdjust, fChannelOffset; uint32_t fChannelAdjust, fChannelOffset;
void IError( const char *msg ); void IError( const char *msg );
bool ISeekToChunk( const char *type, plRIFFChunk *c ); 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 ////////////////////////////////////////////////// //// Constructor/Destructor //////////////////////////////////////////////////
plOGGCodec::plOGGCodec( const char *path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil ) plOGGCodec::plOGGCodec( const plFileName &path, plAudioCore::ChannelSelect whichChan ) : fFileHandle( nil )
{ {
fOggFile = nil; fOggFile = nil;
IOpen( path, whichChan ); IOpen( path, whichChan );
@ -112,17 +112,17 @@ bool plOGGCodec::ReadFromHeader(int numBytes, void *data)
return false; 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()); // plNetClientApp::StaticDebugMsg("Ogg Open %s, t=%f, start", path, hsTimer::GetSeconds());
strncpy( fFilename, path, sizeof( fFilename ) ); fFilename = path;
fWhichChannel = whichChan; fWhichChannel = whichChan;
/// Open the file as a plain binary stream /// Open the file as a plain binary stream
fFileHandle = fopen( path, "rb" ); fFileHandle = plFileSystem::Open(path, "rb");
if( fFileHandle != nil ) if( fFileHandle != nil )
{ {
/// Create the OGG data struct /// 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 #define _plOGGCodec_h
#include "plAudioFileReader.h" #include "plAudioFileReader.h"
#include "plFileSystem.h"
//// Class Definition //////////////////////////////////////////////////////// //// Class Definition ////////////////////////////////////////////////////////
@ -59,7 +60,7 @@ class plOGGCodec : public plAudioFileReader
{ {
public: public:
plOGGCodec( const char *path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll ); plOGGCodec( const plFileName &path, plAudioCore::ChannelSelect whichChan = plAudioCore::kAll );
virtual ~plOGGCodec(); virtual ~plOGGCodec();
enum DecodeFormat enum DecodeFormat
@ -88,7 +89,7 @@ public:
static void SetDecodeFormat( DecodeFormat f ) { fDecodeFormat = f; } static void SetDecodeFormat( DecodeFormat f ) { fDecodeFormat = f; }
static void SetDecodeFlag( uint8_t flag, bool on ) { if( on ) fDecodeFlags |= flag; else fDecodeFlags &= ~flag; } 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 ResetWaveHeaderRef() { fCurHeaderPos = 0; }
void BuildActualWaveHeader(); void BuildActualWaveHeader();
bool ReadFromHeader(int numBytes, void *data); // read from Actual wave header bool ReadFromHeader(int numBytes, void *data); // read from Actual wave header
@ -100,23 +101,23 @@ protected:
kPCMFormatTag = 1 kPCMFormatTag = 1
}; };
char fFilename[ 512 ]; plFileName fFilename;
FILE *fFileHandle; FILE *fFileHandle;
OggVorbis_File *fOggFile; OggVorbis_File *fOggFile;
plWAVHeader fHeader, fFakeHeader; plWAVHeader fHeader, fFakeHeader;
uint32_t fDataStartPos, fCurrDataPos, fDataSize; uint32_t fDataStartPos, fCurrDataPos, fDataSize;
plAudioCore::ChannelSelect fWhichChannel; plAudioCore::ChannelSelect fWhichChannel;
uint32_t fChannelAdjust, fChannelOffset; uint32_t fChannelAdjust, fChannelOffset;
static DecodeFormat fDecodeFormat; static DecodeFormat fDecodeFormat;
static uint8_t fDecodeFlags; static uint8_t fDecodeFlags;
uint8_t * fHeadBuf; uint8_t * fHeadBuf;
int fCurHeaderPos; int fCurHeaderPos;
void IError( const char *msg ); 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 #endif //_plOGGCodec_h

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

@ -49,34 +49,30 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h" #include "plgDispatch.h"
#include "hsResMgr.h" #include "hsResMgr.h"
#include "pnMessage/plRefMsg.h" #include "pnMessage/plRefMsg.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.h" #include "plStatusLog/plStatusLog.h"
#include "hsTimer.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 ) return plFileName::Join("sfx", filename);
strcpy( path, filename );
else
sprintf( path, "sfx\\%s", filename );
strcpy( destStr, path );
} }
//// IGetReader ////////////////////////////////////////////////////////////// //// IGetReader //////////////////////////////////////////////////////////////
// Makes sure the sound is ready to load without any extra processing (like // Makes sure the sound is ready to load without any extra processing (like
// decompression or the like), then opens a reader for it. // 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) // 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]; plFileName path;
if(fullpath) GetFullPath(filename, path); if (fullpath)
path = GetFullPath(filename);
else else
strcpy(path, filename); path = filename;
plAudioFileReader* reader = plAudioFileReader::CreateReader(path, channel, type); plAudioFileReader* reader = plAudioFileReader::CreateReader(path, channel, type);
@ -166,7 +162,7 @@ plSoundBuffer::plSoundBuffer()
IInitBuffer(); IInitBuffer();
} }
plSoundBuffer::plSoundBuffer( const char *fileName, uint32_t flags ) plSoundBuffer::plSoundBuffer( const plFileName &fileName, uint32_t flags )
{ {
IInitBuffer(); IInitBuffer();
SetFileName( fileName ); SetFileName( fileName );
@ -186,7 +182,6 @@ plSoundBuffer::~plSoundBuffer()
} }
} }
delete [] fFileName;
UnLoad(); UnLoad();
} }
@ -194,7 +189,7 @@ void plSoundBuffer::IInitBuffer()
{ {
fError = false; fError = false;
fValid = false; fValid = false;
fFileName = nil; fFileName = "";
fData = nil; fData = nil;
fDataLength = 0; fDataLength = 0;
fFlags = 0; fFlags = 0;
@ -225,7 +220,7 @@ void plSoundBuffer::Read( hsStream *s, hsResMgr *mgr )
s->ReadLE( &fFlags ); s->ReadLE( &fFlags );
s->ReadLE( &fDataLength ); s->ReadLE( &fDataLength );
fFileName = s->ReadSafeString(); fFileName = s->ReadSafeString_TEMP();
s->ReadLE( &fHeader.fFormatTag ); s->ReadLE( &fHeader.fFormatTag );
s->ReadLE( &fHeader.fNumChannels ); s->ReadLE( &fHeader.fNumChannels );
@ -266,16 +261,10 @@ void plSoundBuffer::Write( hsStream *s, hsResMgr *mgr )
s->WriteLE( fDataLength ); s->WriteLE( fDataLength );
// Truncate the path to just a file name on write // Truncate the path to just a file name on write
if( fFileName != nil ) if (fFileName.IsValid())
{ s->WriteSafeString(fFileName.GetFileName());
char *nameOnly = strrchr( fFileName, '\\' );
if( nameOnly != nil )
s->WriteSafeString( nameOnly + 1 );
else
s->WriteSafeString( fFileName );
}
else else
s->WriteSafeString( "" ); s->WriteSafeString("");
s->WriteLE( fHeader.fFormatTag ); s->WriteLE( fHeader.fFormatTag );
s->WriteLE( fHeader.fNumChannels ); s->WriteLE( fHeader.fNumChannels );
@ -290,7 +279,7 @@ void plSoundBuffer::Write( hsStream *s, hsResMgr *mgr )
//// SetFileName ///////////////////////////////////////////////////////////// //// SetFileName /////////////////////////////////////////////////////////////
void plSoundBuffer::SetFileName( const char *name ) void plSoundBuffer::SetFileName( const plFileName &name )
{ {
if(fLoading) if(fLoading)
{ {
@ -298,11 +287,7 @@ void plSoundBuffer::SetFileName( const char *name )
return; return;
} }
delete [] fFileName; fFileName = name;
if( name != nil )
fFileName = hsStrcpy( name );
else
fFileName = nil;
// Data is no longer valid // Data is no longer valid
UnLoad(); UnLoad();
@ -325,22 +310,17 @@ plAudioCore::ChannelSelect plSoundBuffer::GetReaderSelect( void ) const
//// IGetFullPath //////////////////////////////////////////////////////////// //// IGetFullPath ////////////////////////////////////////////////////////////
// Construct our current full path to our sound. // Construct our current full path to our sound.
void plSoundBuffer::IGetFullPath( char *destStr ) plFileName plSoundBuffer::IGetFullPath()
{ {
if(!fFileName) if (!fFileName.IsValid())
{ {
*destStr = 0; return plFileName();
return;
} }
char path[ kFolderIterator_MaxPath ];
if( strchr( fFileName, '\\' ) != nil ) if (fFileName.StripFileName().IsValid())
strcpy( path, fFileName ); return fFileName;
else
sprintf( path, "sfx\\%s", 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 ) void plSoundBuffer::SetInternalData( plWAVHeader &header, uint32_t length, uint8_t *data )
{ {
if(fLoading) return; if (fLoading)
fFileName = nil; return;
fFileName = "";
fHeader = header; fHeader = header;
fFlags = 0; fFlags = 0;
@ -509,11 +490,9 @@ plSoundBuffer::ELoadReturnVal plSoundBuffer::EnsureInternal()
//// IGrabHeaderInfo ///////////////////////////////////////////////////////// //// IGrabHeaderInfo /////////////////////////////////////////////////////////
bool plSoundBuffer::IGrabHeaderInfo( void ) bool plSoundBuffer::IGrabHeaderInfo( void )
{ {
static char path[ 512 ]; if (fFileName.IsValid())
if( fFileName != nil )
{ {
IGetFullPath( path ); plFileName path = IGetFullPath();
// Go grab from the WAV file // Go grab from the WAV file
if(!fReader) 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) // 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 ) plAudioFileReader *plSoundBuffer::IGetReader( bool fullpath )
{ {
char path[512]; plFileName path;
if(fullpath) IGetFullPath(path); if (fullpath)
path = IGetFullPath();
else else
strcpy(path, fFileName); path = fFileName;
// Go grab from the WAV file // Go grab from the WAV file
plAudioFileReader::StreamType type = plAudioFileReader::kStreamWAV; plAudioFileReader::StreamType type = plAudioFileReader::kStreamWAV;

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

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

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

@ -277,7 +277,7 @@ void plClothingItem::Write(hsStream *s, hsResMgr *mgr)
if (fAccessoryName) if (fAccessoryName)
{ {
plString strBuf = plString::Format("CItm_%s", 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) if (accessoryKey == nil)
{ {
strBuf = plString::Format("Couldn't find accessory \"%s\". It won't show at runtime.", fAccessoryName); 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 hsFiles.cpp
plBrowseFolder.cpp plBrowseFolder.cpp
plEncryptedStream.cpp plEncryptedStream.cpp
plFileUtils.cpp
plInitFileReader.cpp plInitFileReader.cpp
plSecureStream.cpp plSecureStream.cpp
plStreamSource.cpp plStreamSource.cpp
@ -26,7 +25,6 @@ set(plFile_HEADERS
hsFiles.h hsFiles.h
plBrowseFolder.h plBrowseFolder.h
plEncryptedStream.h plEncryptedStream.h
plFileUtils.h
plInitFileReader.h plInitFileReader.h
plSecureStream.h plSecureStream.h
plStreamSource.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 <glob.h>
#include <string> #include <string>
#include "hsTemplates.h" #include "hsTemplates.h"
#include "plFileUtils.h"
struct hsFolderIterator_Data { struct hsFolderIterator_Data {
glob_t fGlobBuf; glob_t fGlobBuf;
@ -122,8 +121,8 @@ const char* hsFolderIterator::GetFileName() const
if (!fData->fInited || fData->fCnt > fData->fGlobBuf.gl_pathc) if (!fData->fInited || fData->fCnt > fData->fGlobBuf.gl_pathc)
throw "end of folder"; throw "end of folder";
const char* fn=fData->fGlobBuf.gl_pathv[fData->fCnt-1]; plFileName fn = fData->fGlobBuf.gl_pathv[fData->fCnt-1];
return plFileUtils::GetFileName(fn); return fn.GetFileName().c_str();
} }
bool hsFolderIterator::IsDirectory( void ) const 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> #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)); memset(&bi, 0, sizeof(bi));
bi.hwndOwner = hwndOwner; bi.hwndOwner = hwndOwner;
bi.lpszTitle = title; bi.lpszTitle = title.ToWchar();
bi.lpfn = BrowseCallbackProc; bi.lpfn = BrowseCallbackProc;
bi.lParam = (LPARAM) startPath; bi.lParam = (LPARAM) startPath.AsString().ToWchar().GetData();
ITEMIDLIST *iil = SHBrowseForFolder(&bi); LPITEMIDLIST iil = SHBrowseForFolderW(&bi);
// Browse failed, or cancel was selected plFileName path;
if (!iil) if (!iil) {
return false; // Browse failed, or cancel was selected
// Browse succeded. Get the path. path = "";
else } else {
SHGetPathFromIDList(iil, path); // Browse succeded. Get the path.
wchar_t buffer[MAX_PATH];
SHGetPathFromIDListW(iil, buffer);
path = plString::FromWchar(buffer);
}
// Free the memory allocated by SHBrowseForFolder // Free the memory allocated by SHBrowseForFolder
LPMALLOC pMalloc; LPMALLOC pMalloc;
@ -68,7 +72,7 @@ bool plBrowseFolder::GetFolder(char *path, const char *startPath, const char *ti
pMalloc->Free(iil); pMalloc->Free(iil);
pMalloc->Release(); pMalloc->Release();
return true; return path;
} }
int CALLBACK plBrowseFolder::BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) 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 "HeadSpin.h"
#include "hsWindows.h" #include "hsWindows.h"
#include "plFileSystem.h"
// //
// Gets a directory using the "Browse for Folder" dialog. // 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 class plBrowseFolder
{ {
public: 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: protected:
static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); 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==*/ *==LICENSE==*/
#include "plEncryptedStream.h" #include "plEncryptedStream.h"
#include "plFileUtils.h"
#include "hsSTLStream.h" #include "hsSTLStream.h"
#include <time.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 "plSecureStream.h"
#include "hsWindows.h" #include "hsWindows.h"
#include "plFileUtils.h"
#include "hsSTLStream.h" #include "hsSTLStream.h"
#include <time.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 "plStreamSource.h"
#include "plSecureStream.h" #include "plSecureStream.h"
#include "plEncryptedStream.h" #include "plEncryptedStream.h"
#include "plFileUtils.h"
#if HS_BUILD_FOR_UNIX #if HS_BUILD_FOR_UNIX
# include <wctype.h> # 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 // Assume the clone template is in the same age we are
const plLocation& loc = GetKey()->GetUoid().GetLocation(); const plLocation& loc = GetKey()->GetUoid().GetLocation();
char ageName[256]; plString ageName;
((plResManager*)hsgResMgr::ResMgr())->GetLocationStrings(loc, ageName, nil); ((plResManager*)hsgResMgr::ResMgr())->GetLocationStrings(loc, &ageName, nil);
// Spawn the clone // Spawn the clone
plKey cloneKey = SpawnClone(fTemplateName, ageName, GetTarget()->GetLocalToWorld(), GetKey()); 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(); plResManager* resMgr = (plResManager*)hsgResMgr::ResMgr();

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

@ -71,7 +71,7 @@ public:
void SetExportTime() { fExportTime = true; } void SetExportTime() { fExportTime = true; }
// Console backdoor // 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 #endif // plCloneSpawnModifier_inc

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

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

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

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

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

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

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

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

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

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

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

@ -439,7 +439,7 @@ void plDynamicEnvMap::Read(hsStream* s, hsResMgr* mgr)
nVis = s->ReadLE32(); nVis = s->ReadLE32();
for( i = 0; i < nVis; i++) 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) if (key)
hsgResMgr::ResMgr()->AddViaNotify(key, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef); 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(); nVis = s->ReadLE32();
for( i = 0; i < nVis; i++) 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) if (key)
hsgResMgr::ResMgr()->AddViaNotify(key, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef); hsgResMgr::ResMgr()->AddViaNotify(key, new plGenRefMsg(GetKey(), plRefMsg::kOnCreate, -1, kRefVisSet), plRefFlags::kActiveRef);
} }

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

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

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

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

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

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

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

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/ *==LICENSE==*/
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plLocalization.h" #include "plLocalization.h"
#include "plFile/plFileUtils.h"
plLocalization::Language plLocalization::fLanguage = plLocalization::kEnglish; plLocalization::Language plLocalization::fLanguage = plLocalization::kEnglish;
@ -87,36 +86,28 @@ plLocalization::encodingTypes plLocalization::fUnicodeEncoding[] =
Enc_UTF8, // kJapanese 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, '_'); int underscore = name.AsString().FindLast('_');
if (underscore) if (underscore >= 0)
{ {
char langTag[kLangTagLen+1]; plString langTag = name.AsString().Substr(underscore, kLangTagLen);
strncpy(langTag,underscore,kLangTagLen);
langTag[kLangTagLen] = '\0';
if (strncmp(langTag, fLangTags[kEnglish], kLangTagLen) == 0) if (langTag == fLangTags[kEnglish])
{ return name.AsString().Left(underscore) + fLangTags[lang];
if (localizedName)
{
strcpy(localizedName, name);
int underscorePos = underscore - name;
memcpy(localizedName + underscorePos, fLangTags[lang], kLangTagLen);
}
return true;
}
} }
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) && plFileName localizedName = IGetLocalized(name, Language(lang+1));
plFileUtils::FileExists(localizedName); if (plFileInfo(localizedName).Exists())
return localizedName;
return "";
} }
std::string plLocalization::LocalToString(const std::vector<std::string> & localizedText) 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 <vector>
#include <string> #include <string>
#include "plFileSystem.h"
class plLocalization class plLocalization
{ {
@ -81,7 +82,7 @@ protected:
static bool fUsesUnicode[kNumLanguages]; static bool fUsesUnicode[kNumLanguages];
static encodingTypes fUnicodeEncoding[kNumLanguages]; static encodingTypes fUnicodeEncoding[kNumLanguages];
static bool IGetLocalized(const char* name, Language lang, char* localizedName); static plFileName IGetLocalized(const plFileName& name, Language lang);
public: public:
static void SetLanguage(Language lang) { fLanguage = lang; } static void SetLanguage(Language lang) { fLanguage = lang; }
@ -97,8 +98,8 @@ public:
static bool IsLocalized() { return fLanguage != kEnglish; } static bool IsLocalized() { return fLanguage != kEnglish; }
// Pass in a key name and this will give you the localized name // 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 // Returns an invalid filename if the original keyname is not for a localized asset
static bool GetLocalized(const char* name, char* localizedName) { return IGetLocalized(name, fLanguage, localizedName); } static plFileName GetLocalized(const plFileName& name) { return IGetLocalized(name, fLanguage); }
// //
// Export only // Export only
@ -116,9 +117,9 @@ public:
// } // }
// //
static int GetNumLocales() { return kNumLanguages - 1; } 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 // 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() // 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 // 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 "plStatusLog/plStatusLog.h"
#include "pnFactory/plFactory.h" #include "pnFactory/plFactory.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "plVersion.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 "plMessage/plAgeLoadedMsg.h"
#include "pnMessage/plClientMsg.h" #include "pnMessage/plClientMsg.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plFile/plFileUtils.h"
#include "pnFactory/plCreator.h" #include "pnFactory/plCreator.h"
#include "pnNetCommon/plSynchedObject.h" #include "pnNetCommon/plSynchedObject.h"
#include "pnNetCommon/plNetApp.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 // We want to go through all the data files in our data path and add new
// plRegistryPageNodes to the regTree for each // plRegistryPageNodes to the regTree for each
hsFolderIterator pathIterator(fDataPath.c_str()); hsFolderIterator pathIterator(fDataPath.AsString().c_str());
while (pathIterator.NextFileSuffix(".prp")) while (pathIterator.NextFileSuffix(".prp"))
{ {
char fileName[kFolderIterator_MaxPath]; 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 we're running localized, try to find a localized version first
if ((!objectName.IsNull()) && plLocalization::IsLocalized()) if ((!objectName.IsNull()) && plLocalization::IsLocalized())
{ {
char localName[256]; plFileName localName = plLocalization::GetLocalized(objectName.c_str());
if (plLocalization::GetLocalized(objectName.c_str(), localName)) if (localName.IsValid())
{ {
plKeyImp* localKey = page->FindKey(uoid.GetClassType(), localName); plKeyImp* localKey = page->FindKey(uoid.GetClassType(), localName.AsString());
if (localKey != nil) if (localKey != nil)
return localKey; return localKey;
} }
@ -585,7 +584,7 @@ plKey plResManager::FindKey(const plUoid& uoid)
return key; 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; static plLocation invalidLoc;
@ -596,16 +595,16 @@ const plLocation& plResManager::FindLocation(const char* age, const char* page)
return invalidLoc; 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); plRegistryPageNode* page = FindPage(loc);
const plPageInfo& info = page->GetPageInfo(); const plPageInfo& info = page->GetPageInfo();
// Those buffers better be big enough... // Those buffers better be big enough...
if (ageBuffer) if (ageBuffer)
hsStrcpy(ageBuffer, info.GetAge().c_str()); *ageBuffer = info.GetAge();
if (pageBuffer) if (pageBuffer)
hsStrcpy(pageBuffer, info.GetPage().c_str()); *pageBuffer = info.GetPage();
} }
bool plResManager::AddViaNotify(plRefMsg* msg, plRefFlags::Type flags) bool plResManager::AddViaNotify(plRefMsg* msg, plRefFlags::Type flags)
@ -996,10 +995,10 @@ class plResAgeHolder : public hsRefCnt
{ {
public: public:
hsTArray<plKey> fKeys; hsTArray<plKey> fKeys;
std::string fAge; plString fAge;
plResAgeHolder() {} plResAgeHolder() {}
plResAgeHolder( const char* age ) : fAge( age ) {} plResAgeHolder( const plString& age ) : fAge( age ) {}
~plResAgeHolder() { fKeys.Reset(); } ~plResAgeHolder() { fKeys.Reset(); }
}; };
@ -1009,11 +1008,11 @@ class plResHolderIterator : public plRegistryPageIterator
{ {
protected: protected:
hsTArray<plKey>& fKeys; hsTArray<plKey>& fKeys;
const char* fAgeName; plString fAgeName;
plResManager* fResMgr; plResManager* fResMgr;
public: 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) {} : fAgeName(age), fKeys(keys), fResMgr(resMgr) {}
virtual bool EatPage(plRegistryPageNode* page) virtual bool EatPage(plRegistryPageNode* page)
@ -1031,21 +1030,21 @@ public:
//// LoadAndHoldAgeKeys ////////////////////////////////////////////////////// //// 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); HeldAgeKeyMap::const_iterator it = fHeldAgeKeys.find(age);
if (it != fHeldAgeKeys.end()) if (it != fHeldAgeKeys.end())
{ {
kResMgrLog(1, ILog(1, "Reffing age keys for age %s", age)); kResMgrLog(1, ILog(1, "Reffing age keys for age %s", age.c_str()));
hsStatusMessageF("*** Reffing age keys for age %s ***\n", age); hsStatusMessageF("*** Reffing age keys for age %s ***\n", age.c_str());
plResAgeHolder* holder = it->second; plResAgeHolder* holder = it->second;
holder->Ref(); holder->Ref();
} }
else else
{ {
kResMgrLog(1, ILog(1, "Loading age keys for age %s", age)); kResMgrLog(1, ILog(1, "Loading age keys for age %s", age.c_str()));
hsStatusMessageF("*** Loading age keys for age %s ***\n", age); hsStatusMessageF("*** Loading age keys for age %s ***\n", age.c_str());
plResAgeHolder* holder = new plResAgeHolder(age); plResAgeHolder* holder = new plResAgeHolder(age);
fHeldAgeKeys[age] = holder; fHeldAgeKeys[age] = holder;
@ -1057,7 +1056,7 @@ void plResManager::LoadAgeKeys(const char* age)
//// DropAgeKeys ///////////////////////////////////////////////////////////// //// DropAgeKeys /////////////////////////////////////////////////////////////
void plResManager::DropAgeKeys(const char* age) void plResManager::DropAgeKeys(const plString& age)
{ {
HeldAgeKeyMap::iterator it = fHeldAgeKeys.find(age); HeldAgeKeyMap::iterator it = fHeldAgeKeys.find(age);
if (it != fHeldAgeKeys.end()) if (it != fHeldAgeKeys.end())
@ -1066,12 +1065,12 @@ void plResManager::DropAgeKeys(const char* age)
if (holder->RefCnt() == 1) if (holder->RefCnt() == 1)
{ {
// Found it! // 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); fHeldAgeKeys.erase(it);
} }
else 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(); holder->UnRef();
@ -1236,11 +1235,11 @@ class plPageInAgeIter : public plRegistryPageIterator
{ {
private: private:
plKey fDestKey; plKey fDestKey;
const char* fAgeName; plString fAgeName;
std::vector<plLocation> fLocations; std::vector<plLocation> fLocations;
public: public:
plPageInAgeIter(plKey destKey, const char *ageName) : fDestKey(destKey), fAgeName(ageName) {} plPageInAgeIter(plKey destKey, const plString &ageName) : fDestKey(destKey), fAgeName(ageName) {}
~plPageInAgeIter() ~plPageInAgeIter()
{ {
plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoomHold); plClientMsg* pMsg1 = new plClientMsg(plClientMsg::kLoadRoomHold);
@ -1263,7 +1262,7 @@ public:
// PageInAge is intended for bulk global ages, like GlobalAnimations or GlobalClothing // 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) // 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 plSynchEnabler ps(false); // disable dirty tracking while paging in
plUoid lu(kClient_KEY); plUoid lu(kClient_KEY);
@ -1492,9 +1491,9 @@ void plResManager::DumpUnusedKeys(plRegistryPageNode* page) const
page->IterateKeys(&reffer); 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; fAllPages[location] = pageNode;
return pageNode; return pageNode;

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

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <map> #include <map>
#include <vector> #include <vector>
#include <string> #include <string>
#include "plFileSystem.h"
class plRegistryPageNode; class plRegistryPageNode;
class plRegistryKeyIterator; class plRegistryKeyIterator;
@ -55,7 +56,6 @@ class plRegistryDataStream;
class plResAgeHolder; class plResAgeHolder;
class plResManagerHelper; class plResManagerHelper;
class plDispatch; class plDispatch;
class plFileName;
// plProgressProc is a proc called every time an object loads, to keep a progress bar for // plProgressProc is a proc called every time an object loads, to keep a progress bar for
// loading ages up-to-date. // loading ages up-to-date.
@ -68,7 +68,7 @@ public:
virtual ~plResManager(); virtual ~plResManager();
// If the ResManager has already been initialized, you should call Reset after setting this // 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. // Mainly for external tools.
void AddSinglePage(const plFileName& path); void AddSinglePage(const plFileName& path);
@ -87,9 +87,9 @@ public:
//--------------------------- //---------------------------
plKey FindOriginalKey(const plUoid&); plKey FindOriginalKey(const plUoid&);
virtual plKey FindKey(const plUoid&); // Same as above, but will check the uoid for clones 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 // 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 // Establish reference linkage
@ -134,10 +134,10 @@ public:
//--------------------------- //---------------------------
// Load optimizations // Load optimizations
//--------------------------- //---------------------------
void LoadAgeKeys(const char* age); void LoadAgeKeys(const plString& age);
void DropAgeKeys(const char* age); void DropAgeKeys(const plString& age);
void PageInRoom(const plLocation& page, uint16_t objClassToRef, plRefMsg* refMsg); 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 // 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 // read causes all the other objects to be read before it returns. In some
@ -207,7 +207,7 @@ protected:
// Adds a key to the registry. Assumes uoid already set // Adds a key to the registry. Assumes uoid already set
void AddKey(plKeyImp* key); 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; bool fInited;
@ -215,7 +215,7 @@ protected:
bool fReadingObject; bool fReadingObject;
std::vector<plKey> fQueuedReads; std::vector<plKey> fQueuedReads;
std::string fDataPath; plFileName fDataPath;
plDispatch* fDispatch; plDispatch* fDispatch;
@ -223,7 +223,7 @@ protected:
uint32_t fCurClonePlayerID; uint32_t fCurClonePlayerID;
uint32_t fCloningCounter; // Next clone ID to use. uint32_t fCloningCounter; // Next clone ID to use.
typedef std::map<std::string,plResAgeHolder*> HeldAgeKeyMap; typedef std::map<plString, plResAgeHolder*> HeldAgeKeyMap;
HeldAgeKeyMap fHeldAgeKeys; HeldAgeKeyMap fHeldAgeKeys;
plProgressProc fProgressProc; plProgressProc fProgressProc;

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

@ -533,10 +533,10 @@ class plSDLMgr
{ {
friend class plSDLParser; friend class plSDLParser;
private: private:
std::string fSDLDir; plFileName fSDLDir;
plSDL::DescriptorList fDescriptors; plSDL::DescriptorList fDescriptors;
plNetApp* fNetApp; plNetApp* fNetApp;
uint32_t fBehaviorFlags; uint32_t fBehaviorFlags;
void IDeleteDescriptors(plSDL::DescriptorList* dl); void IDeleteDescriptors(plSDL::DescriptorList* dl);
public: public:
@ -548,8 +548,8 @@ public:
const plSDL::DescriptorList * GetDescriptors( void ) const { return &fDescriptors;} const plSDL::DescriptorList * GetDescriptors( void ) const { return &fDescriptors;}
void SetSDLDir(const char* s) { fSDLDir=s; } void SetSDLDir(const plFileName& s) { fSDLDir=s; }
const char* GetSDLDir() const { return fSDLDir.c_str(); } plFileName GetSDLDir() const { return fSDLDir; }
void SetNetApp(plNetApp* a) { fNetApp=a; } void SetNetApp(plNetApp* a) { fNetApp=a; }
plNetApp* GetNetApp() const { return fNetApp; } 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 "pnMessage/plClientMsg.h"
#include "plAgeLoader/plAgeLoader.h" #include "plAgeLoader/plAgeLoader.h"
#include "plProfileManagerFull.h" #include "plProfileManagerFull.h"
#include "plFile/plFileUtils.h"
#include "plPipeline/plDebugText.h" #include "plPipeline/plDebugText.h"
#include "pnMessage/plTimeMsg.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 "hsStream.h"
#include "pnUtils/pnUtils.h" #include "pnUtils/pnUtils.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
#include "plFile/plFileUtils.h"
plProfileManagerFull::plProfileManagerFull() : plProfileManagerFull::plProfileManagerFull() :
fVars(plProfileManager::Instance().fVars), fVars(plProfileManager::Instance().fVars),

2
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 "hsThread.h"
#include "hsTemplates.h" #include "hsTemplates.h"
#include "hsTimer.h" #include "hsTimer.h"
#include "plFile/plFileUtils.h"
#include "plStatusLog.h" #include "plStatusLog.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h" #include "plUnifiedTime/plUnifiedTime.h"
@ -753,4 +752,3 @@ bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count )
return ret; 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 "plAudible.h"
#include "plCreatableIndex.h" #include "plCreatableIndex.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "hsGeometry3.h" #include "hsGeometry3.h"
#include "plLoadMask.h" #include "plLoadMask.h"

82
Sources/Tools/MaxComponent/plAudioComponents.cpp

@ -42,7 +42,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h" #include "HeadSpin.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plAnimComponent.h" #include "plAnimComponent.h"
#include "plAudioComponents.h" #include "plAudioComponents.h"
@ -588,21 +587,20 @@ uint32_t plBaseSoundEmitterComponent::ICalcSourceBufferFlags( void ) const
return bufferFlags; 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); plSoundBuffer* sb = IGetSourceBuffer(fileName, srcNode, srcBufferFlags);
const char* plasmaDir = plMaxConfig::GetClientPath(); plFileName plasmaDir = plMaxConfig::GetClientPath();
if (plasmaDir) if (plasmaDir.IsValid())
{ {
char sfxPath[MAX_PATH]; plFileName sfxPath = plFileName::Join(plasmaDir, "sfx", fileName.GetFileName());
sprintf(sfxPath, "%ssfx\\%s", plasmaDir, plFileUtils::GetFileName(fileName));
// Export any localized versions as well // Export any localized versions as well
for (int i = 0; i < plLocalization::GetNumLocales(); i++) for (int i = 0; i < plLocalization::GetNumLocales(); i++)
{ {
char localName[MAX_PATH]; plFileName localName = plLocalization::ExportGetLocalized(sfxPath, i);
if (plLocalization::ExportGetLocalized(sfxPath, i, localName)) if (localName.IsValid())
{ {
IGetSourceBuffer(localName, srcNode, srcBufferFlags); IGetSourceBuffer(localName, srcNode, srcBufferFlags);
} }
@ -612,58 +610,45 @@ plSoundBuffer *plBaseSoundEmitterComponent::GetSourceBuffer( const char *fileN
return sb; 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; plKey key;
plString keyName; plString keyName = fileName.GetFileName();
char fullPath[ MAX_PATH ];
// ***TEMP plString REVISIT***
char tempPath[ MAX_PATH ];
strncpy(tempPath, fileName, MAX_PATH);
::PathStripPath( tempPath );
keyName = tempPath;
// TEMP HACK until we get packed sounds: // 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 // 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. // 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(); plFileName plasmaDir = plMaxConfig::GetClientPath();
if( plasmaDir != nil ) plFileName rfilename = fileName;
if (plasmaDir.IsValid())
{ {
strcpy( fullPath, plasmaDir ); plFileName fullPath = plFileName::Join(plasmaDir, "sfx");
strcat( fullPath, "sfx\\" );
// Before we finish our path, make sure that directory EXISTS // Before we finish our path, make sure that directory EXISTS
plFileUtils::CreateDir( fullPath ); plFileSystem::CreateDir(fullPath);
// Now finish the path... // Now finish the path...
strcat( fullPath, keyName.c_str() ); fullPath = plFileName::Join(fullPath, keyName);
// Check filestamp // Check filestamp
WIN32_FILE_ATTRIBUTE_DATA oldFileAttrib, newFileAttrib; plFileInfo oldInfo(fileName);
BOOL oldOK, newOK; plFileInfo newInfo(fullPath);
oldOK = GetFileAttributesEx( fileName, GetFileExInfoStandard, &oldFileAttrib );
newOK = GetFileAttributesEx( fullPath, GetFileExInfoStandard, &newFileAttrib );
if( oldOK && newOK ) if (oldInfo.Exists() && newInfo.Exists())
{ {
// Only copy if the file is newer // Only copy if the file is newer
if( ::CompareFileTime( &oldFileAttrib.ftLastWriteTime, &newFileAttrib.ftLastWriteTime ) > 0 ) if (oldInfo.ModifyTime() > newInfo.ModifyTime())
{ plFileSystem::Copy(fileName, fullPath);
::CopyFile( fileName, fullPath, FALSE );
}
} }
else else
{ {
// Can't compare, so either there was an error or the target file doesn't exist. Copy no matter what. // 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 // 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 // Additional info for the keyName--need some flag mangling, specifically for the left/right channel mangling
@ -677,7 +662,7 @@ plSoundBuffer *plBaseSoundEmitterComponent::IGetSourceBuffer( const char *file
return plSoundBuffer::ConvertNoRef( key->GetObjectPtr() ); return plSoundBuffer::ConvertNoRef( key->GetObjectPtr() );
// Not yet created, so make a new one // Not yet created, so make a new one
plSoundBuffer *buffer = new plSoundBuffer( fileName, srcBufferFlags ); plSoundBuffer *buffer = new plSoundBuffer( rfilename, srcBufferFlags );
if( !buffer->IsValid() ) if( !buffer->IsValid() )
{ {
// Invalid, so delete and return nil // 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 // 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 ); plSoundBuffer *buffer = new plSoundBuffer( fileName );
if( !buffer->IsValid() || !buffer->EnsureInternal() ) if( !buffer->IsValid() || !buffer->EnsureInternal() )
{ {
// OK, because some *cough* machines are completely stupid and don't load AssetMan scenes with // 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. // 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; bool worked = false;
if( plasmaDir != nil ) if (plasmaDir.IsValid())
{ {
char newPath[ MAX_PATH ]; plFileName newPath = plFileName::Join(plasmaDir, "sfx", fileName.GetFileName());
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 );
// Got a path to try, so try it! // Got a path to try, so try it!
delete buffer; delete buffer;
@ -2292,7 +2266,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
if( !worked ) if( !worked )
{ {
char msg[ 512 ]; 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 ); IShowError( kSrcBufferInvalid, msg, baseNode->GetName(), pErrMsg );
delete buffer; delete buffer;
@ -2312,7 +2286,7 @@ bool plSound3DEmitterComponent::ConvertGrouped( plMaxNode *baseNode, hsTArray
{ {
char msg[ 512 ]; char msg[ 512 ];
sprintf( msg, "The format for sound file %s does not match the format for the other grouped sounds on node %s. " 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 ); IShowError( kMergeSourceFormatMismatch, msg, baseNode->GetName(), pErrMsg );
delete buffer; delete buffer;

5
Sources/Tools/MaxComponent/plAudioComponents.h

@ -65,6 +65,7 @@ class plMaxNode;
class plSoundBuffer; class plSoundBuffer;
class plSound; class plSound;
class plAudioBaseComponentProc; class plAudioBaseComponentProc;
class plFileName;
namespace plAudioComp namespace plAudioComp
{ {
@ -117,7 +118,7 @@ class plBaseSoundEmitterComponent : public plComponent
return -1; 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 ); static bool LookupLatestAsset( const char *waveName, char *retPath, plErrorMsg *errMsg );
virtual void UpdateSoundFileSelection( void ); virtual void UpdateSoundFileSelection( void );
@ -177,7 +178,7 @@ class plBaseSoundEmitterComponent : public plComponent
virtual uint32_t ICalcSourceBufferFlags() const; 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 ); 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 ) while( ( page = aged->GetNextPage() ) != nil )
{ {
int idx = ComboBox_AddString( hWnd, page->GetName() ); int idx = ComboBox_AddString( hWnd, page->GetName().c_str() );
if( selPageName && stricmp( page->GetName(), selPageName ) == 0 ) if( selPageName && page->GetName().CompareI( selPageName ) == 0 )
ComboBox_SetCurSel( hWnd, idx ); 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 "HeadSpin.h"
#include "plCreatableIndex.h" #include "plCreatableIndex.h"
#include "plgDispatch.h" #include "plgDispatch.h"
#include "plFile/plFileUtils.h"
#include "plFile/hsFiles.h" #include "plFile/hsFiles.h"
#include "plComponentReg.h" #include "plComponentReg.h"
@ -237,8 +236,8 @@ protected:
aged.SeekFirstPage(); aged.SeekFirstPage();
while( ( page = aged.GetNextPage() ) != nil ) while( ( page = aged.GetNextPage() ) != nil )
{ {
int idx = ComboBox_AddString(hPageCombo, page->GetName() ); int idx = ComboBox_AddString(hPageCombo, page->GetName().c_str() );
if (curPage && !strcmp(page->GetName(), curPage)) if (curPage && (page->GetName() == curPage))
ComboBox_SetCurSel(hPageCombo, idx); ComboBox_SetCurSel(hPageCombo, idx);
ComboBox_SetItemData( hPageCombo, idx, (int)page->GetSeqSuffix() ); 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 // Checks in assetMan to make sure we have the latest .age file to export
// with. // 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 #ifdef MAXASS_AVAILABLE
char ageFileName[ MAX_PATH ], assetPath[ MAX_PATH ]; plFileName ageFileName, assetPath;
MaxAssInterface *assetMan = GetMaxAssInterface(); MaxAssInterface *assetMan = GetMaxAssInterface();
if( assetMan == nil ) if( assetMan == nil )
return; // No AssetMan available return; // No AssetMan available
// Try to find it in assetMan // Try to find it in assetMan
sprintf( ageFileName, "%s.age", ageName ); ageFileName = ageName + ".age";
jvUniqueId assetId; jvUniqueId assetId;
if (assetMan->FindAssetByFilename(ageFileName, assetId)) if (assetMan->FindAssetByFilename(ageFileName.AsString().c_str(), assetId))
{ {
// Get the latest version // Get the latest version
if (!assetMan->GetLatestVersionFile(assetId, assetPath, sizeof(assetPath))) if (!assetMan->GetLatestVersionFile(assetId, assetPath, sizeof(assetPath)))
{ {
errMsg->Set( true, "PageInfo Convert Error", 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 ); errMsg->Set( false );
return; return;
} }
// Got the latest version, just copy over and roll! // Got the latest version, just copy over and roll!
plFileUtils::RemoveFile( localPath ); plFileSystem::Unlink(localPath);
plFileUtils::FileCopy( assetPath, localPath ); plFileSystem::Copy(assetPath, localPath);
} }
else else
{ {
@ -625,10 +623,8 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
// Mark us as updated // Mark us as updated
fCompPB->SetValue( kRefVolatile_PageInfoUpdated, 0, (int)true ); fCompPB->SetValue( kRefVolatile_PageInfoUpdated, 0, (int)true );
char path[MAX_PATH]; plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid())
const char *ageFolder = plPageInfoUtils::GetAgeFolder();
if( ageFolder == nil )
{ {
errMsg->Set( true, errMsg->Set( true,
"PageInfo Convert Error", "PageInfo Convert Error",
@ -653,7 +649,7 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
fCompPB->SetValue( kInfoSeqSuffix, 0, 0 ); fCompPB->SetValue( kInfoSeqSuffix, 0, 0 );
return; return;
} }
sprintf(path, "%s%s.age", ageFolder, curAge); plFileName path = plFileName::Join(ageFolder, plString::Format("%s.age", curAge));
IVerifyLatestAgeAsset( curAge, path, errMsg ); IVerifyLatestAgeAsset( curAge, path, errMsg );
@ -699,12 +695,12 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
while( ( page = aged.GetNextPage() ) != nil ) while( ( page = aged.GetNextPage() ) != nil )
{ {
if( stricmp( page->GetName(), compPBPageName ) == 0 ) if( page->GetName().CompareI( compPBPageName ) == 0 )
{ {
fCompPB->SetValue( kInfoSeqSuffix, 0, (int)page->GetSeqSuffix() ); fCompPB->SetValue( kInfoSeqSuffix, 0, (int)page->GetSeqSuffix() );
// Also re-copy the page name, just to make sure the case is correct // 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; return;
} }
} }
@ -720,28 +716,20 @@ void plPageInfoComponent::IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg )
fCompPB->SetValue( kInfoSeqSuffix, 0, 0 ); fCompPB->SetValue( kInfoSeqSuffix, 0, 0 );
} }
const char *plPageInfoUtils::GetAgeFolder() plFileName plPageInfoUtils::GetAgeFolder()
{ {
static char ageFolder[MAX_PATH]; static plFileName ageFolder;
static bool initialized = false;
if (!initialized) if (!ageFolder.IsValid())
{ {
initialized = true; plFileName plasmaPath = plMaxConfig::GetClientPath();
ageFolder[0] = '\0'; if (!plasmaPath.IsValid())
return "";
const char *plasmaPath = plMaxConfig::GetClientPath(); ageFolder = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
if (!plasmaPath)
return nil;
strcpy(ageFolder, plasmaPath);
strcat(ageFolder, plAgeDescription::kAgeDescPath);
} }
if (ageFolder[0] != '\0') return ageFolder;
return ageFolder;
else
return nil;
} }
int32_t plPageInfoUtils::CombineSeqNum( int prefix, int suffix ) int32_t plPageInfoUtils::CombineSeqNum( int prefix, int suffix )
@ -789,7 +777,7 @@ int32_t plPageInfoUtils::GetSeqNumFromAgeDesc( const char *ageName, const char
aged->SeekFirstPage(); aged->SeekFirstPage();
while( ( page = aged->GetNextPage() ) != nil ) while( ( page = aged->GetNextPage() ) != nil )
{ {
if( stricmp( pageName, page->GetName() ) == 0 ) if (page->GetName().CompareI(pageName) == 0)
{ {
seqSuffix = page->GetSeqSuffix(); seqSuffix = page->GetSeqSuffix();
break; break;
@ -801,18 +789,14 @@ int32_t plPageInfoUtils::GetSeqNumFromAgeDesc( const char *ageName, const char
return CombineSeqNum( seqPrefix, seqSuffix ); return CombineSeqNum( seqPrefix, seqSuffix );
} }
plAgeDescription *plPageInfoUtils::GetAgeDesc( const char *ageName ) plAgeDescription *plPageInfoUtils::GetAgeDesc( const plString &ageName )
{ {
char path[ MAX_PATH ]; plFileName ageFolder = plPageInfoUtils::GetAgeFolder();
if (!ageFolder.IsValid() || ageName.IsNull())
const char *ageFolder = plPageInfoUtils::GetAgeFolder();
if( ageFolder == nil || ageName == nil )
return nil; return nil;
sprintf( path, "%s%s.age", ageFolder, ageName );
hsUNIXStream s; hsUNIXStream s;
if( !s.Open( path ) ) if (!s.Open(plFileName::Join(ageFolder, ageName + ".age")))
return nil; return nil;
// Create and read the age desc // Create and read the age desc

13
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 CIRCLE_CAM_CID Class_ID(0x66f85282, 0x4daa1b8e)
#define IMAGE_LIB_CID Class_ID(0x736c18d3, 0x6a6d5dde) #define IMAGE_LIB_CID Class_ID(0x736c18d3, 0x6a6d5dde)
class plFileName;
class plAgeDescription; class plAgeDescription;
class plComponentBase; class plComponentBase;
struct NotifyInfo; struct NotifyInfo;
@ -60,12 +61,12 @@ const char* LocCompGetPage(plComponentBase* comp);
namespace plPageInfoUtils namespace plPageInfoUtils
{ {
const char *GetAgeFolder(); plFileName GetAgeFolder();
int32_t GetSeqNumFromAgeDesc( const char *ageName, const char *pageName ); int32_t GetSeqNumFromAgeDesc( const char *ageName, const char *pageName );
int32_t CombineSeqNum( int prefix, int suffix ); int32_t CombineSeqNum( int prefix, int suffix );
int32_t GetCommonSeqNumFromNormal( int32_t normalSeqNumber, int whichCommonPage ); 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) // PageInfo component definition, here so other components can get to the static function(s)
@ -76,7 +77,7 @@ protected:
bool fItinerant; bool fItinerant;
static char fCurrExportedAge[ 256 ]; static char fCurrExportedAge[ 256 ];
void IVerifyLatestAgeAsset( const char *ageName, const char *localPath, plErrorMsg *errMsg ); void IVerifyLatestAgeAsset( const plString &ageName, const plFileName &localPath, plErrorMsg *errMsg );
void IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg ); void IUpdateSeqNumbersFromAgeFile( plErrorMsg *errMsg );
public: public:

21
Sources/Tools/MaxComponent/plResponderLink.cpp

@ -318,19 +318,18 @@ void plResponderLinkProc::ILoadAgeFilenamesCombo(HWND hWnd, IParamBlock2 *pb)
SendMessage(hAge, CB_RESETCONTENT, 0, 0); SendMessage(hAge, CB_RESETCONTENT, 0, 0);
// Get the path to the description folder // Get the path to the description folder
char agePath[MAX_PATH]; plFileName plasmaPath = plMaxConfig::GetClientPath();
const char *plasmaPath = plMaxConfig::GetClientPath(); if (!plasmaPath.IsValid())
if (!plasmaPath)
return; return;
strcpy(agePath, plasmaPath);
strcat(agePath, plAgeDescription::kAgeDescPath); plFileName agePath = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
const char *savedName = pb->GetStr(kLinkAgeFilename); const char *savedName = pb->GetStr(kLinkAgeFilename);
if (!savedName) if (!savedName)
savedName = ""; savedName = "";
// Iterate through the age descriptions // Iterate through the age descriptions
hsFolderIterator ageFolder(agePath); hsFolderIterator ageFolder(agePath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age")) while (ageFolder.NextFileSuffix(".age"))
{ {
char ageFile[MAX_PATH]; char ageFile[MAX_PATH];
@ -355,19 +354,17 @@ void plResponderLinkProc::ILoadParentAgeFilenamesCombo(HWND hWnd, IParamBlock2 *
SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)"<None>"); SendMessage(hAge, CB_ADDSTRING, 0, (LPARAM)"<None>");
// Get the path to the description folder // Get the path to the description folder
char agePath[MAX_PATH]; plFileName plasmaPath = plMaxConfig::GetClientPath();
const char *plasmaPath = plMaxConfig::GetClientPath(); if (!plasmaPath.IsValid())
if (!plasmaPath)
return; return;
strcpy(agePath, plasmaPath); plFileName agePath = plFileName::Join(plasmaPath, plAgeDescription::kAgeDescPath);
strcat(agePath, plAgeDescription::kAgeDescPath);
const char *savedName = pb->GetStr(kLinkParentAgeFilename); const char *savedName = pb->GetStr(kLinkParentAgeFilename);
if (!savedName) if (!savedName)
savedName = "<None>"; savedName = "<None>";
// Iterate through the age descriptions // Iterate through the age descriptions
hsFolderIterator ageFolder(agePath); hsFolderIterator ageFolder(agePath.AsString().c_str());
while (ageFolder.NextFileSuffix(".age")) while (ageFolder.NextFileSuffix(".age"))
{ {
char ageFile[MAX_PATH]; 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 "plSurface/hsGMaterial.h"
#include "pnSceneObject/plSceneObject.h" #include "pnSceneObject/plSceneObject.h"
#include "UserPropMgr.h" #include "UserPropMgr.h"
#include "plFile/plFileUtils.h"
#include "hsConverterUtils.h" #include "hsConverterUtils.h"
#include "hsControlConverter.h" #include "hsControlConverter.h"
@ -1981,18 +1980,17 @@ static plLayerInterface* IProcessLayerMovie(plPassMtlBase* mtl, plLayerTex* layT
if( !bi || !bi->Name() || !*bi->Name() ) if( !bi || !bi->Name() || !*bi->Name() )
return layerIFace; return layerIFace;
const char* fileName = bi->Name(); plFileName fileName = bi->Name();
plAnimStealthNode* stealth = IGetEntireAnimation(mtl); plAnimStealthNode* stealth = IGetEntireAnimation(mtl);
const char* ext = plFileUtils::GetFileExt(fileName); plString ext = fileName.GetFileExt();
bool isBink = ext && (stricmp(ext, "bik") == 0); bool isBink = (ext.CompareI("bik") == 0);
bool isAvi = ext &&(stricmp(ext, "avi") == 0); bool isAvi = (ext.CompareI("avi") == 0);
if (isBink || isAvi) if (isBink || isAvi)
{ {
char movieName[256]; plFileName movieName = plFileName::Join("avi", fileName.GetFileName());
sprintf(movieName, "avi/%s", plFileUtils::GetFileName(fileName));
plLayerMovie* movieLayer = nil; plLayerMovie* movieLayer = nil;
plString moviePostfix; plString moviePostfix;

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

Loading…
Cancel
Save