1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Replace hsStream::Open duplicated methods everywhere with a single plFileName interface

This commit is contained in:
2013-01-17 21:08:21 -08:00
parent 219061c095
commit 6f6ade2636
60 changed files with 509 additions and 982 deletions

View File

@ -231,13 +231,12 @@ plClient::plClient()
plAgeLoader::SetInstance(new plAgeLoader);
// Use it to parse the init directory
wchar_t initFolder[MAX_PATH];
PathGetInitDirectory(initFolder, arrsize(initFolder));
pfConsoleDirSrc dirSrc( fConsoleEngine, initFolder, L"*.ini" );
plFileName initFolder = plFileSystem::GetInitPath();
pfConsoleDirSrc dirSrc(fConsoleEngine, initFolder, "*.ini");
#ifndef PLASMA_EXTERNAL_RELEASE
// internal builds also parse the local init folder
dirSrc.ParseDirectory( L"init", L"*.ini" );
dirSrc.ParseDirectory("init", "*.ini");
#endif
/// End of console stuff
@ -467,9 +466,7 @@ void plClient::InitInputs()
void plClient::ISetGraphicsDefaults()
{
// couldn't find display mode set defaults write to ini file
wchar_t graphicsIniFile[MAX_PATH];
PathGetInitDirectory(graphicsIniFile, arrsize(graphicsIniFile));
PathAddFilename(graphicsIniFile, graphicsIniFile, L"graphics.ini", arrsize(graphicsIniFile));
plFileName graphicsIniFile = plFileName::Join(plFileSystem::GetInitPath(), "graphics.ini");
IWriteDefaultGraphicsSettings(graphicsIniFile);
plPipeline::fInitialPipeParams.Windowed = plPipeline::fDefaultPipeParams.Windowed;
plPipeline::fInitialPipeParams.AntiAliasingAmount = plPipeline::fDefaultPipeParams.AntiAliasingAmount;
@ -1624,12 +1621,12 @@ void plClient::IPatchGlobalAgeFiles( void )
plResPatcher* patcher = plResPatcher::GetInstance();
if (!gDataServerLocal)
{
patcher->RequestManifest(L"CustomAvatars");
patcher->RequestManifest(L"GlobalAnimations");
patcher->RequestManifest(L"GlobalAvatars");
patcher->RequestManifest(L"GlobalClothing");
patcher->RequestManifest(L"GlobalMarkers");
patcher->RequestManifest(L"GUI");
patcher->RequestManifest("CustomAvatars");
patcher->RequestManifest("GlobalAnimations");
patcher->RequestManifest("GlobalAvatars");
patcher->RequestManifest("GlobalClothing");
patcher->RequestManifest("GlobalMarkers");
patcher->RequestManifest("GUI");
}
plgDispatch::Dispatch()->RegisterForExactType(plResPatcherMsg::Index(), GetKey());
@ -2344,18 +2341,15 @@ void plClient::IDetectAudioVideoSettings()
int val = 0;
hsStream *stream = nil;
hsUNIXStream s;
wchar_t audioIniFile[MAX_PATH], graphicsIniFile[MAX_PATH];
PathGetInitDirectory(audioIniFile, arrsize(audioIniFile));
StrCopy(graphicsIniFile, audioIniFile, arrsize(audioIniFile));
PathAddFilename(audioIniFile, audioIniFile, L"audio.ini", arrsize(audioIniFile));
PathAddFilename(graphicsIniFile, graphicsIniFile, L"graphics.ini", arrsize(graphicsIniFile));
plFileName audioIniFile = plFileName::Join(plFileSystem::GetInitPath(), "audio.ini");
plFileName graphicsIniFile = plFileName::Join(plFileSystem::GetInitPath(), "graphics.ini");
#ifndef PLASMA_EXTERNAL_RELEASE
// internal builds can use the local dir
if (PathDoesFileExist(L"init//audio.ini"))
StrCopy(audioIniFile, L"init//audio.ini", arrsize(audioIniFile));
if (PathDoesFileExist(L"init//graphics.ini"))
StrCopy(graphicsIniFile, L"init//graphics.ini", arrsize(audioIniFile));
if (plFileInfo("init//audio.ini").Exists())
audioIniFile = "init//audio.ini";
if (plFileInfo("init//graphics.ini").Exists())
graphicsIniFile = "init//graphics.ini";
#endif
//check to see if audio.ini exists
@ -2398,7 +2392,7 @@ void plClient::IDetectAudioVideoSettings()
}
}
void plClient::IWriteDefaultGraphicsSettings(const wchar_t* destFile)
void plClient::IWriteDefaultGraphicsSettings(const plFileName& destFile)
{
hsStream *stream = plEncryptedStream::OpenEncryptedFileWrite(destFile);
@ -2408,7 +2402,7 @@ void plClient::IWriteDefaultGraphicsSettings(const wchar_t* destFile)
WriteBool(stream, "Graphics.Windowed", plPipeline::fDefaultPipeParams.Windowed);
WriteInt(stream, "Graphics.AntiAliasAmount", plPipeline::fDefaultPipeParams.AntiAliasingAmount);
WriteInt(stream, "Graphics.AnisotropicLevel", plPipeline::fDefaultPipeParams.AnisotropicLevel );
WriteInt(stream, "Graphics.TextureQuality",plPipeline::fDefaultPipeParams.TextureQuality);
WriteInt(stream, "Graphics.TextureQuality", plPipeline::fDefaultPipeParams.TextureQuality);
WriteInt(stream, "Quality.Level", plPipeline::fDefaultPipeParams.VideoQuality);
WriteInt(stream, "Graphics.Shadow.Enable", plPipeline::fDefaultPipeParams.Shadows);
WriteInt(stream, "Graphics.EnablePlanarReflections", plPipeline::fDefaultPipeParams.PlanarReflections);
@ -2487,25 +2481,24 @@ void plClient::IOnAsyncInitComplete () {
/// Now parse final init files (*.fni). These are files just like ini files, only to be run
/// after all hell has broken loose in the client.
wchar_t initFolder[MAX_PATH];
PathGetInitDirectory(initFolder, arrsize(initFolder));
pfConsoleDirSrc dirSrc( fConsoleEngine, initFolder, L"net*.fni" ); // connect to net first
plFileName initFolder = plFileSystem::GetInitPath();
pfConsoleDirSrc dirSrc(fConsoleEngine, initFolder, "net*.fni"); // connect to net first
#ifndef PLASMA_EXTERNAL_RELEASE
// internal builds also parse the local init folder
dirSrc.ParseDirectory( L"init", L"net*.fni" );
dirSrc.ParseDirectory("init", "net*.fni");
#endif
dirSrc.ParseDirectory( initFolder, L"*.fni" );
dirSrc.ParseDirectory(initFolder, "*.fni");
#ifndef PLASMA_EXTERNAL_RELEASE
// internal builds also parse the local init folder
dirSrc.ParseDirectory( L"init", L"*.fni" );
dirSrc.ParseDirectory("init", "*.fni");
#endif
// run fni in the Aux Init dir
if (fpAuxInitDir)
{
dirSrc.ParseDirectory(fpAuxInitDir, "net*.fni" ); // connect to net first
dirSrc.ParseDirectory(fpAuxInitDir, "*.fni" );
dirSrc.ParseDirectory(fpAuxInitDir, "net*.fni"); // connect to net first
dirSrc.ParseDirectory(fpAuxInitDir, "*.fni");
}
fNumLoadingRooms--;

View File

@ -296,7 +296,7 @@ public:
void ResetDisplayDevice(int Width, int Height, int ColorDepth, bool Windowed, int NumAASamples, int MaxAnisotropicSamples, bool VSync = false);
void ResizeDisplayDevice(int Width, int Height, bool Windowed);
void IDetectAudioVideoSettings();
void IWriteDefaultGraphicsSettings(const wchar_t* destFile);
void IWriteDefaultGraphicsSettings(const plFileName& destFile);
plAnimDebugList *fAnimDebugList;

View File

@ -843,17 +843,14 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
// FIXME: Real OS detection
NetCommSetAuthTokenAndOS(nil, L"win");
wchar_t fileAndPath[MAX_PATH];
PathGetInitDirectory(fileAndPath, arrsize(fileAndPath));
PathAddFilename(fileAndPath, fileAndPath, L"login.dat", arrsize(fileAndPath));
plFileName loginDat = plFileName::Join(plFileSystem::GetInitPath(), "login.dat");
#ifndef PLASMA_EXTERNAL_RELEASE
// internal builds can use the local init directory
wchar_t localFileAndPath[MAX_PATH];
StrCopy(localFileAndPath, L"init\\login.dat", arrsize(localFileAndPath));
if (PathDoesFileExist(localFileAndPath))
StrCopy(fileAndPath, localFileAndPath, arrsize(localFileAndPath));
plFileName local("init\\login.dat");
if (plFileInfo(local).Exists())
loginDat = local;
#endif
hsStream* stream = plEncryptedStream::OpenEncryptedFileWrite(fileAndPath, cryptKey);
hsStream* stream = plEncryptedStream::OpenEncryptedFileWrite(loginDat, cryptKey);
if (stream)
{
stream->Write(sizeof(cryptKey), cryptKey);
@ -877,17 +874,14 @@ static void LoadUserPass (LoginDialogParam *pLoginParam)
pLoginParam->remember = false;
pLoginParam->username[0] = '\0';
wchar_t fileAndPath[MAX_PATH];
PathGetInitDirectory(fileAndPath, arrsize(fileAndPath));
PathAddFilename(fileAndPath, fileAndPath, L"login.dat", arrsize(fileAndPath));
plFileName loginDat = plFileName::Join(plFileSystem::GetInitPath(), "login.dat");
#ifndef PLASMA_EXTERNAL_RELEASE
// internal builds can use the local init directory
wchar_t localFileAndPath[MAX_PATH];
StrCopy(localFileAndPath, L"init\\login.dat", arrsize(localFileAndPath));
if (PathDoesFileExist(localFileAndPath))
StrCopy(fileAndPath, localFileAndPath, arrsize(localFileAndPath));
plFileName local("init\\login.dat");
if (plFileInfo(local).Exists())
loginDat = local;
#endif
hsStream* stream = plEncryptedStream::OpenEncryptedFile(fileAndPath, cryptKey);
hsStream* stream = plEncryptedStream::OpenEncryptedFile(loginDat, cryptKey);
if (stream && !stream->AtEnd())
{
uint32_t savedKey[4];
@ -1062,9 +1056,7 @@ BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
// The code to write general.ini really doesn't belong here, but it works... for now.
// When general.ini gets expanded, this will need to find a proper home somewhere.
{
wchar_t gipath[MAX_PATH];
PathGetInitDirectory(gipath, arrsize(gipath));
PathAddFilename(gipath, gipath, L"general.ini", arrsize(gipath));
plFileName gipath = plFileName::Join(plFileSystem::GetInitPath(), "general.ini");
plString ini_str = plString::Format("App.SetLanguage %s\n", plLocalization::GetLanguageName(new_language));
hsStream* gini = plEncryptedStream::OpenEncryptedFileWrite(gipath);
gini->WriteString(ini_str);
@ -1215,9 +1207,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
gDataServerLocal = true;
#endif
const wchar_t *serverIni = L"server.ini";
plFileName serverIni = "server.ini";
if (cmdParser.IsSpecified(kArgServerIni))
serverIni = cmdParser.GetString(kArgServerIni);
serverIni = plString::FromWchar(cmdParser.GetString(kArgServerIni));
// check to see if we were launched from the patcher
bool eventExists = false;
@ -1272,10 +1264,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
#endif
// Load an optional general.ini
wchar_t gipath[MAX_PATH];
PathGetInitDirectory(gipath, arrsize(gipath));
PathAddFilename(gipath, gipath, L"general.ini", arrsize(gipath));
FILE *generalini = _wfopen(gipath, L"rb");
plFileName gipath = plFileName::Join(plFileSystem::GetInitPath(), "general.ini");
FILE *generalini = plFileSystem::Open(gipath, "rb");
if (generalini)
{
fclose(generalini);
@ -1312,7 +1302,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
}
#endif
FILE *serverIniFile = _wfopen(serverIni, L"rb");
FILE *serverIniFile = plFileSystem::Open(serverIni, "rb");
if (serverIniFile)
{
fclose(serverIniFile);