2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 14:37:41 +00:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -1,52 +1,52 @@
/*==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/>.
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==*/
#include "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "jvCoreUtil.h"
#include "hsUtils.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaUpdate installer;
if (!installer.Create())
return 0;
if (!stricmp(lpCmdLine, "AutoDownload"))
installer.SetAutoDownload();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!jvBaseDlg::IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 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/>.
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==*/
#include "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "jvCoreUtil.h"
#include "hsUtils.h"
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
jvCoreUtil::SetHInstance(hInstance);
plPlasmaUpdate installer;
if (!installer.Create())
return 0;
if (!stricmp(lpCmdLine, "AutoDownload"))
installer.SetAutoDownload();
MSG msg;
while (GetMessage(&msg, NULL, 0, 0))
{
if (!jvBaseDlg::IsDialogMessage(&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return 0;
}

View File

@ -1,170 +1,170 @@
/*==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/>.
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==*/
#include "plFileGrabber.h"
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
plHttpFileGrabber::plHttpFileGrabber()
{
fRequestMgr.SetHostname("");
}
bool plHttpFileGrabber::FileToStream(const char* path, hsStream* stream)
{
std::string pathStr(path);
bool retVal = fRequestMgr.GetFileToStream(path, stream);
stream->SetPosition(0);
return retVal;
}
void plHttpFileGrabber::SetServer(const char* server)
{
std::string serverPath(server);
fRequestMgr.SetHostname(serverPath);
}
void plHttpFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '\\');
if (slash)
*slash = '/';
} while(slash != NULL);
}
void plHttpFileGrabber::SetUsernamePassword(const std::string& username, const std::string& password)
{
fRequestMgr.SetUsername(username);
fRequestMgr.SetPassword(password);
}
bool plHttpFileGrabber::IsServerAvailable(const char* serverName)
{
bool retVal = false;
HINTERNET hInternet = InternetOpen("Parable Patcher",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInternet)
{
HINTERNET hHttp = InternetConnect(hInternet,serverName,8080,fUserName.c_str(),fPassword.c_str(),INTERNET_SERVICE_HTTP,0,0);
if (hHttp)
{
HINTERNET hRequest = HttpOpenRequest(hHttp, "GET", "/Current/Current.txt", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hRequest)
{
DWORD dwCode;
DWORD dwSize = sizeof(dwCode);
HttpSendRequest(hRequest, NULL, 0, NULL, 0);
HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL);
if (dwCode >= 200 && dwCode < 300)
{
retVal = true;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hHttp);
}
InternetCloseHandle(hInternet);
}
return retVal;
}
*/
plNetShareFileGrabber::plNetShareFileGrabber()
{
}
#define BUFFER_SIZE 1024*1024
bool plNetShareFileGrabber::FileToStream(const char* path, hsStream* stream)
{
hsUNIXStream fileStream;
std::string filePath = fServerName + path;
if (fileStream.Open(filePath.c_str()))
{
char* buffer = new char[BUFFER_SIZE];
UInt32 streamSize = fileStream.GetSizeLeft();
while (streamSize > (BUFFER_SIZE))
{
fileStream.Read(BUFFER_SIZE, buffer);
stream->Write(BUFFER_SIZE, buffer);
streamSize = fileStream.GetSizeLeft();
}
if (streamSize > 0)
{
fileStream.Read(streamSize, buffer);
stream->Write(streamSize, buffer);
}
stream->Rewind();
fileStream.Close();
delete [] buffer;
return true;
}
return false;
}
void plNetShareFileGrabber::SetServer(const char* server)
{
fServerName = "\\\\";
fServerName += server;
}
void plNetShareFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '/');
if (slash)
*slash = '\\';
} while(slash != NULL);
}
bool plNetShareFileGrabber::IsServerAvailable(const char* serverName, const char* currentDir)
{
bool retVal = false;
char serverPath[MAX_PATH];
sprintf(serverPath, "\\\\%s\\%s\\Current.txt", serverName, currentDir);
hsUNIXStream si;
if (si.Open(serverPath, "rb"))
{
retVal = true;
si.Close();
}
return retVal;
}
/*==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/>.
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==*/
#include "plFileGrabber.h"
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
plHttpFileGrabber::plHttpFileGrabber()
{
fRequestMgr.SetHostname("");
}
bool plHttpFileGrabber::FileToStream(const char* path, hsStream* stream)
{
std::string pathStr(path);
bool retVal = fRequestMgr.GetFileToStream(path, stream);
stream->SetPosition(0);
return retVal;
}
void plHttpFileGrabber::SetServer(const char* server)
{
std::string serverPath(server);
fRequestMgr.SetHostname(serverPath);
}
void plHttpFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '\\');
if (slash)
*slash = '/';
} while(slash != NULL);
}
void plHttpFileGrabber::SetUsernamePassword(const std::string& username, const std::string& password)
{
fRequestMgr.SetUsername(username);
fRequestMgr.SetPassword(password);
}
bool plHttpFileGrabber::IsServerAvailable(const char* serverName)
{
bool retVal = false;
HINTERNET hInternet = InternetOpen("Parable Patcher",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);
if (hInternet)
{
HINTERNET hHttp = InternetConnect(hInternet,serverName,8080,fUserName.c_str(),fPassword.c_str(),INTERNET_SERVICE_HTTP,0,0);
if (hHttp)
{
HINTERNET hRequest = HttpOpenRequest(hHttp, "GET", "/Current/Current.txt", NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_KEEP_CONNECTION, 0);
if (hRequest)
{
DWORD dwCode;
DWORD dwSize = sizeof(dwCode);
HttpSendRequest(hRequest, NULL, 0, NULL, 0);
HttpQueryInfo(hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &dwCode, &dwSize, NULL);
if (dwCode >= 200 && dwCode < 300)
{
retVal = true;
}
InternetCloseHandle(hRequest);
}
InternetCloseHandle(hHttp);
}
InternetCloseHandle(hInternet);
}
return retVal;
}
*/
plNetShareFileGrabber::plNetShareFileGrabber()
{
}
#define BUFFER_SIZE 1024*1024
bool plNetShareFileGrabber::FileToStream(const char* path, hsStream* stream)
{
hsUNIXStream fileStream;
std::string filePath = fServerName + path;
if (fileStream.Open(filePath.c_str()))
{
char* buffer = new char[BUFFER_SIZE];
UInt32 streamSize = fileStream.GetSizeLeft();
while (streamSize > (BUFFER_SIZE))
{
fileStream.Read(BUFFER_SIZE, buffer);
stream->Write(BUFFER_SIZE, buffer);
streamSize = fileStream.GetSizeLeft();
}
if (streamSize > 0)
{
fileStream.Read(streamSize, buffer);
stream->Write(streamSize, buffer);
}
stream->Rewind();
fileStream.Close();
delete [] buffer;
return true;
}
return false;
}
void plNetShareFileGrabber::SetServer(const char* server)
{
fServerName = "\\\\";
fServerName += server;
}
void plNetShareFileGrabber::MakeProperPath(char* path)
{
char* slash = NULL;
do {
slash = strchr(path, '/');
if (slash)
*slash = '\\';
} while(slash != NULL);
}
bool plNetShareFileGrabber::IsServerAvailable(const char* serverName, const char* currentDir)
{
bool retVal = false;
char serverPath[MAX_PATH];
sprintf(serverPath, "\\\\%s\\%s\\Current.txt", serverName, currentDir);
hsUNIXStream si;
if (si.Open(serverPath, "rb"))
{
retVal = true;
si.Close();
}
return retVal;
}

View File

@ -1,73 +1,73 @@
/*==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/>.
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==*/
#ifndef plFileGrabber_h_inc
#define plFileGrabber_h_inc
#include <string>
#include "hsStream.h"
class plFileGrabber
{
public:
virtual bool IsServerAvailable(const char* serverName, const char* currentDir) = 0;
virtual bool FileToStream(const char* path, hsStream* stream) = 0;
virtual void SetServer(const char* server) = 0;
virtual void MakeProperPath(char* path) = 0;
virtual bool NeedsAuth() { return false; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password) {}
};
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
class plHttpFileGrabber : public plFileGrabber
{
private:
plHttpDiverseRequestMgr fRequestMgr;
public:
plHttpFileGrabber();
virtual bool IsServerAvailable(const char* serverName);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
virtual bool NeedsAuth() { return true; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password);
};
*/
class plNetShareFileGrabber : public plFileGrabber
{
private:
std::string fServerName;
public:
plNetShareFileGrabber();
virtual bool IsServerAvailable(const char* serverName, const char* currentDir);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
};
/*==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/>.
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==*/
#ifndef plFileGrabber_h_inc
#define plFileGrabber_h_inc
#include <string>
#include "hsStream.h"
class plFileGrabber
{
public:
virtual bool IsServerAvailable(const char* serverName, const char* currentDir) = 0;
virtual bool FileToStream(const char* path, hsStream* stream) = 0;
virtual void SetServer(const char* server) = 0;
virtual void MakeProperPath(char* path) = 0;
virtual bool NeedsAuth() { return false; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password) {}
};
/* Not needed currently - if we want it again we'll have to reimplement HTTP comm
class plHttpFileGrabber : public plFileGrabber
{
private:
plHttpDiverseRequestMgr fRequestMgr;
public:
plHttpFileGrabber();
virtual bool IsServerAvailable(const char* serverName);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
virtual bool NeedsAuth() { return true; }
virtual void SetUsernamePassword(const std::string& username, const std::string& password);
};
*/
class plNetShareFileGrabber : public plFileGrabber
{
private:
std::string fServerName;
public:
plNetShareFileGrabber();
virtual bool IsServerAvailable(const char* serverName, const char* currentDir);
virtual bool FileToStream(const char* path, hsStream* stream);
virtual void SetServer(const char* server);
virtual void MakeProperPath(char* path);
};
#endif

View File

@ -1,346 +1,346 @@
/*==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/>.
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==*/
#include "HeadSpin.h"
#include "hsUtils.h"
#include "plManifest.h"
#include "../plEncryption/plChecksum.h"
#include "../plCompression/plZlibStream.h"
#include "../plFile/plEncryptedStream.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
class plManifestFile
{
public:
char* fFilename;
plMD5Checksum fSum;
plMD5Checksum fLocalSum;
UInt32 fSize;
UInt32 fCompressedSize;
UInt32 fFlags;
};
plManifest::plManifest(LogFunc log) :
fDownloadFiles(0),
fDownloadBytes(0),
fDirtySums(false),
fLog(log)
{
}
plManifest::~plManifest()
{
if (fDirtySums)
IWriteCache();
delete [] fManifestName;
for (int i = 0; i < fFiles.size(); i++)
{
delete [] fFiles[i]->fFilename;
delete fFiles[i];
}
}
bool plManifest::Read(hsStream* mfsStream, const char* basePath, const char* mfsName)
{
fBasePath = basePath;
fManifestName = hsStrcpy(mfsName);
fLog("--- Reading manifest for %s", fManifestName);
char buf[256];
while (mfsStream->ReadLn(buf, sizeof(buf)))
{
plManifestFile* file = new plManifestFile;
char* tok = strtok(buf, "\t");
file->fFilename = hsStrcpy(tok);
tok = strtok(nil, "\t");
file->fSum.SetFromHexString(tok);
tok = strtok(nil, "\t");
file->fSize = atoi(tok);
tok = strtok(nil, "\t");
file->fCompressedSize = atoi(tok);
tok = strtok(nil, "\t");
file->fFlags = atoi(tok);
fFiles.push_back(file);
}
return true;
}
void plManifest::ValidateFiles(ProgressFunc progress)
{
if (fFiles.empty())
return;
fLog("--- Validating files for %s", fManifestName);
IReadCache(progress);
fDownloadFiles = 0;
fDownloadBytes = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
// If the local checksum is invalid, this file wasn't in our cache.
// Get the sum, and update the progress bar.
if (!file->fLocalSum.IsValid())
{
fLog(" No sum for %s, calculating", file->fFilename);
file->fLocalSum.CalcFromFile(file->fFilename);
fDirtySums = true;
progress(file->fFilename, 1);
}
if (file->fLocalSum != file->fSum)
{
fLog(" Incorrect sum for %s", file->fFilename);
fDownloadFiles++;
fDownloadBytes += file->fCompressedSize;
}
}
fLog("--- Need to download %d files, %.1f MB", fDownloadFiles, float(fDownloadBytes) / (1024.f*1024.f));
}
void plManifest::DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber)
{
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
if (file->fLocalSum != file->fSum)
{
char serverPath[MAX_PATH];
sprintf(serverPath, "%s%s.gz", fBasePath.c_str(), file->fFilename);
grabber->MakeProperPath(serverPath);
hsRAMStream serverStream;
if (grabber->FileToStream(serverPath, &serverStream))
{
plFileUtils::EnsureFilePathExists(file->fFilename);
plFileUtils::RemoveFile(file->fFilename, true);
plZlibStream localStream;
if (localStream.Open(file->fFilename, "wb"))
{
char dataBuf[1024];
UInt32 sizeLeft = serverStream.GetSizeLeft();
while (UInt32 amtRead = serverStream.Read( (sizeof(dataBuf) > sizeLeft) ? sizeLeft : sizeof(dataBuf), dataBuf))
{
progress(file->fFilename, amtRead);
localStream.Write(amtRead, dataBuf);
sizeLeft = serverStream.GetSizeLeft();
}
localStream.Close();
// FIXME - Should we recalc this?
file->fLocalSum = file->fSum;
fDirtySums = true;
if (file->fFlags != 0)
IDecompressSound(file);
}
}
}
}
}
plManifestFile* plManifest::IFindFile(const char* name)
{
// FIXME
for (int i = 0; i < fFiles.size(); i++)
{
if (hsStrEQ(fFiles[i]->fFilename, name))
return fFiles[i];
}
return nil;
}
// KLUDGE - Put age checksums in the dat dir, for backwards compatability
const char* plManifest::IGetCacheDir()
{
const char* prefix = "";
if (strncmp(fFiles[0]->fFilename, "dat\\", strlen("dat\\")) == 0)
return "dat\\";
else
return "";
}
#define kCacheFileVersion 1
void plManifest::IWriteCache()
{
plEncryptedStream s;
bool openedFile = false;
UInt32 numFiles = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
plUnifiedTime modifiedTime;
if (file->fLocalSum.IsValid() &&
plFileUtils::GetFileTimes(file->fFilename, nil, &modifiedTime))
{
if (!openedFile)
{
openedFile = true;
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
s.Open(buf, "wb");
s.WriteSwap32(0);
s.WriteSwap32(kCacheFileVersion);
}
s.WriteSafeString(file->fFilename);
plMD5Checksum& checksum = file->fLocalSum;
s.Write(checksum.GetSize(), checksum.GetValue());
modifiedTime.Write(&s);
numFiles++;
}
}
if (openedFile)
{
s.Rewind();
s.WriteSwap32(numFiles);
s.Close();
}
}
void plManifest::IReadCache(ProgressFunc progress)
{
//
// Load valid cached checksums
//
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
hsStream* s = plEncryptedStream::OpenEncryptedFile(buf);
if (s)
{
UInt32 numCached = s->ReadSwap32();
UInt32 cacheFileVersion = s->ReadSwap32();
if (cacheFileVersion != kCacheFileVersion)
{
s->Close();
delete s;
return;
}
fLog(" Reading cache...found %d cached sums", numCached);
for (int i = 0; i < numCached; i++)
{
char* name = s->ReadSafeString();
UInt8 checksumBuf[MD5_DIGEST_LENGTH];
s->Read(sizeof(checksumBuf), checksumBuf);
plMD5Checksum checksum;
checksum.SetValue(checksumBuf);
plUnifiedTime modifiedTime;
modifiedTime.Read(s);
plManifestFile* file = IFindFile(name);
if (file)
{
plUnifiedTime curModifiedTime;
if (plFileUtils::GetFileTimes(file->fFilename, nil, &curModifiedTime))
{
if (curModifiedTime == modifiedTime)
file->fLocalSum = checksum;
else
fLog(" Invalid modified time for %s", name);
}
else
fLog(" Couldn't get modified time for %s", name);
progress(file->fFilename, 1);
}
else
fLog(" Couldn't find cached file '%s' in manifest, discarding", name);
delete [] name;
}
s->Close();
delete s;
}
}
#include "../plAudioCore/plAudioFileReader.h"
#include "../plAudio/plOGGCodec.h"
#include "../plAudio/plWavFile.h"
bool plManifest::IDecompressSound(plManifestFile* file)
{
enum
{
kSndFlagCacheSplit = 1<<0,
kSndFlagCacheStereo = 1<<2,
};
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit) ||
hsCheckBits(file->fFlags, kSndFlagCacheStereo))
{
plAudioFileReader* reader = plAudioFileReader::CreateReader(file->fFilename, plAudioCore::kAll, plAudioFileReader::kStreamNative);
if (!reader)
return false;
UInt32 size = reader->GetDataSize();
delete reader;
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit))
plAudioFileReader::CacheFile(file->fFilename, true);
if (hsCheckBits(file->fFlags, kSndFlagCacheStereo))
plAudioFileReader::CacheFile(file->fFilename, false);
}
return true;
}
/*==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/>.
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==*/
#include "HeadSpin.h"
#include "hsUtils.h"
#include "plManifest.h"
#include "../plEncryption/plChecksum.h"
#include "../plCompression/plZlibStream.h"
#include "../plFile/plEncryptedStream.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
class plManifestFile
{
public:
char* fFilename;
plMD5Checksum fSum;
plMD5Checksum fLocalSum;
UInt32 fSize;
UInt32 fCompressedSize;
UInt32 fFlags;
};
plManifest::plManifest(LogFunc log) :
fDownloadFiles(0),
fDownloadBytes(0),
fDirtySums(false),
fLog(log)
{
}
plManifest::~plManifest()
{
if (fDirtySums)
IWriteCache();
delete [] fManifestName;
for (int i = 0; i < fFiles.size(); i++)
{
delete [] fFiles[i]->fFilename;
delete fFiles[i];
}
}
bool plManifest::Read(hsStream* mfsStream, const char* basePath, const char* mfsName)
{
fBasePath = basePath;
fManifestName = hsStrcpy(mfsName);
fLog("--- Reading manifest for %s", fManifestName);
char buf[256];
while (mfsStream->ReadLn(buf, sizeof(buf)))
{
plManifestFile* file = new plManifestFile;
char* tok = strtok(buf, "\t");
file->fFilename = hsStrcpy(tok);
tok = strtok(nil, "\t");
file->fSum.SetFromHexString(tok);
tok = strtok(nil, "\t");
file->fSize = atoi(tok);
tok = strtok(nil, "\t");
file->fCompressedSize = atoi(tok);
tok = strtok(nil, "\t");
file->fFlags = atoi(tok);
fFiles.push_back(file);
}
return true;
}
void plManifest::ValidateFiles(ProgressFunc progress)
{
if (fFiles.empty())
return;
fLog("--- Validating files for %s", fManifestName);
IReadCache(progress);
fDownloadFiles = 0;
fDownloadBytes = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
// If the local checksum is invalid, this file wasn't in our cache.
// Get the sum, and update the progress bar.
if (!file->fLocalSum.IsValid())
{
fLog(" No sum for %s, calculating", file->fFilename);
file->fLocalSum.CalcFromFile(file->fFilename);
fDirtySums = true;
progress(file->fFilename, 1);
}
if (file->fLocalSum != file->fSum)
{
fLog(" Incorrect sum for %s", file->fFilename);
fDownloadFiles++;
fDownloadBytes += file->fCompressedSize;
}
}
fLog("--- Need to download %d files, %.1f MB", fDownloadFiles, float(fDownloadBytes) / (1024.f*1024.f));
}
void plManifest::DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber)
{
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
if (file->fLocalSum != file->fSum)
{
char serverPath[MAX_PATH];
sprintf(serverPath, "%s%s.gz", fBasePath.c_str(), file->fFilename);
grabber->MakeProperPath(serverPath);
hsRAMStream serverStream;
if (grabber->FileToStream(serverPath, &serverStream))
{
plFileUtils::EnsureFilePathExists(file->fFilename);
plFileUtils::RemoveFile(file->fFilename, true);
plZlibStream localStream;
if (localStream.Open(file->fFilename, "wb"))
{
char dataBuf[1024];
UInt32 sizeLeft = serverStream.GetSizeLeft();
while (UInt32 amtRead = serverStream.Read( (sizeof(dataBuf) > sizeLeft) ? sizeLeft : sizeof(dataBuf), dataBuf))
{
progress(file->fFilename, amtRead);
localStream.Write(amtRead, dataBuf);
sizeLeft = serverStream.GetSizeLeft();
}
localStream.Close();
// FIXME - Should we recalc this?
file->fLocalSum = file->fSum;
fDirtySums = true;
if (file->fFlags != 0)
IDecompressSound(file);
}
}
}
}
}
plManifestFile* plManifest::IFindFile(const char* name)
{
// FIXME
for (int i = 0; i < fFiles.size(); i++)
{
if (hsStrEQ(fFiles[i]->fFilename, name))
return fFiles[i];
}
return nil;
}
// KLUDGE - Put age checksums in the dat dir, for backwards compatability
const char* plManifest::IGetCacheDir()
{
const char* prefix = "";
if (strncmp(fFiles[0]->fFilename, "dat\\", strlen("dat\\")) == 0)
return "dat\\";
else
return "";
}
#define kCacheFileVersion 1
void plManifest::IWriteCache()
{
plEncryptedStream s;
bool openedFile = false;
UInt32 numFiles = 0;
for (int i = 0; i < fFiles.size(); i++)
{
plManifestFile* file = fFiles[i];
plUnifiedTime modifiedTime;
if (file->fLocalSum.IsValid() &&
plFileUtils::GetFileTimes(file->fFilename, nil, &modifiedTime))
{
if (!openedFile)
{
openedFile = true;
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
s.Open(buf, "wb");
s.WriteSwap32(0);
s.WriteSwap32(kCacheFileVersion);
}
s.WriteSafeString(file->fFilename);
plMD5Checksum& checksum = file->fLocalSum;
s.Write(checksum.GetSize(), checksum.GetValue());
modifiedTime.Write(&s);
numFiles++;
}
}
if (openedFile)
{
s.Rewind();
s.WriteSwap32(numFiles);
s.Close();
}
}
void plManifest::IReadCache(ProgressFunc progress)
{
//
// Load valid cached checksums
//
char buf[256];
sprintf(buf, "%s%s.sum", IGetCacheDir(), fManifestName);
hsStream* s = plEncryptedStream::OpenEncryptedFile(buf);
if (s)
{
UInt32 numCached = s->ReadSwap32();
UInt32 cacheFileVersion = s->ReadSwap32();
if (cacheFileVersion != kCacheFileVersion)
{
s->Close();
delete s;
return;
}
fLog(" Reading cache...found %d cached sums", numCached);
for (int i = 0; i < numCached; i++)
{
char* name = s->ReadSafeString();
UInt8 checksumBuf[MD5_DIGEST_LENGTH];
s->Read(sizeof(checksumBuf), checksumBuf);
plMD5Checksum checksum;
checksum.SetValue(checksumBuf);
plUnifiedTime modifiedTime;
modifiedTime.Read(s);
plManifestFile* file = IFindFile(name);
if (file)
{
plUnifiedTime curModifiedTime;
if (plFileUtils::GetFileTimes(file->fFilename, nil, &curModifiedTime))
{
if (curModifiedTime == modifiedTime)
file->fLocalSum = checksum;
else
fLog(" Invalid modified time for %s", name);
}
else
fLog(" Couldn't get modified time for %s", name);
progress(file->fFilename, 1);
}
else
fLog(" Couldn't find cached file '%s' in manifest, discarding", name);
delete [] name;
}
s->Close();
delete s;
}
}
#include "../plAudioCore/plAudioFileReader.h"
#include "../plAudio/plOGGCodec.h"
#include "../plAudio/plWavFile.h"
bool plManifest::IDecompressSound(plManifestFile* file)
{
enum
{
kSndFlagCacheSplit = 1<<0,
kSndFlagCacheStereo = 1<<2,
};
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit) ||
hsCheckBits(file->fFlags, kSndFlagCacheStereo))
{
plAudioFileReader* reader = plAudioFileReader::CreateReader(file->fFilename, plAudioCore::kAll, plAudioFileReader::kStreamNative);
if (!reader)
return false;
UInt32 size = reader->GetDataSize();
delete reader;
if (hsCheckBits(file->fFlags, kSndFlagCacheSplit))
plAudioFileReader::CacheFile(file->fFilename, true);
if (hsCheckBits(file->fFlags, kSndFlagCacheStereo))
plAudioFileReader::CacheFile(file->fFilename, false);
}
return true;
}

View File

@ -1,77 +1,77 @@
/*==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/>.
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==*/
#ifndef plManifest_h_inc
#define plManifest_h_inc
#include "hsTypes.h"
#include "plFileGrabber.h"
#include <vector>
#include <string>
class plManifestFile;
typedef void (*ProgressFunc)(const char* name, int progDelta);
typedef void (*LogFunc)(const char* format, ...);
class plManifest
{
protected:
std::string fBasePath;
char* fManifestName;
typedef std::vector<plManifestFile*> FileVec;
FileVec fFiles;
UInt32 fDownloadFiles;
UInt32 fDownloadBytes;
bool fDirtySums;
LogFunc fLog;
bool IDecompressSound(plManifestFile* file);
plManifestFile* IFindFile(const char* name);
const char* IGetCacheDir();
void IReadCache(ProgressFunc progress);
void IWriteCache();
public:
plManifest(LogFunc log);
~plManifest();
bool Read(hsStream* mfsStream, const char* basePath, const char* mfsName);
void ValidateFiles(ProgressFunc progress);
void DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber);
int NumFiles() { return fFiles.size(); }
UInt32 NumDownloadFiles() { return fDownloadFiles; }
UInt32 DownloadSize() { return fDownloadBytes; }
};
/*==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/>.
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==*/
#ifndef plManifest_h_inc
#define plManifest_h_inc
#include "hsTypes.h"
#include "plFileGrabber.h"
#include <vector>
#include <string>
class plManifestFile;
typedef void (*ProgressFunc)(const char* name, int progDelta);
typedef void (*LogFunc)(const char* format, ...);
class plManifest
{
protected:
std::string fBasePath;
char* fManifestName;
typedef std::vector<plManifestFile*> FileVec;
FileVec fFiles;
UInt32 fDownloadFiles;
UInt32 fDownloadBytes;
bool fDirtySums;
LogFunc fLog;
bool IDecompressSound(plManifestFile* file);
plManifestFile* IFindFile(const char* name);
const char* IGetCacheDir();
void IReadCache(ProgressFunc progress);
void IWriteCache();
public:
plManifest(LogFunc log);
~plManifest();
bool Read(hsStream* mfsStream, const char* basePath, const char* mfsName);
void ValidateFiles(ProgressFunc progress);
void DownloadUpdates(ProgressFunc progress, plFileGrabber* grabber);
int NumFiles() { return fFiles.size(); }
UInt32 NumDownloadFiles() { return fDownloadFiles; }
UInt32 DownloadSize() { return fDownloadBytes; }
};
#endif // plManifest_h_inc

View File

@ -1,79 +1,79 @@
/*==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/>.
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==*/
#include "plPlasmaServers.h"
#include "hsStream.h"
#include "hsUtils.h"
bool plPlasmaServers::GetServerInfo()
{
bool ret = true;
hsUNIXStream si;
if (si.Open("\\\\dirtcake\\ServerInfo\\ServerInfo.txt", "rb"))
{
char line[256];
// Make sure we've got the latest version
if (si.ReadLn(line, sizeof(line)))
{
int version = atoi(line);
si.ReadLn(line, sizeof(line));
if (version != 4)
{
char errorMsg[512];
sprintf(errorMsg, "This installer is out of date.\nPlease get the latest version from:\n\n%s", line);
hsMessageBox(errorMsg, "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
}
else
ret = false;
// Read in the servers, one per line
while (ret && si.ReadLn(line, sizeof(line)))
{
ServerInfo info;
info.fServerAddress = strtok(line, ",");
info.fServerName = strtok(nil, ",");
info.fURLBase = strtok(nil, ",");
info.fOutputDir = strtok(nil, ",");
info.fCurrentDir = strtok(nil, ",");
info.fCodeDir = strtok(nil, ",");
fServers.push_back(info);
}
si.Close();
}
else
{
hsMessageBox("Couldn't find server info", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
return ret;
}
/*==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/>.
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==*/
#include "plPlasmaServers.h"
#include "hsStream.h"
#include "hsUtils.h"
bool plPlasmaServers::GetServerInfo()
{
bool ret = true;
hsUNIXStream si;
if (si.Open("\\\\dirtcake\\ServerInfo\\ServerInfo.txt", "rb"))
{
char line[256];
// Make sure we've got the latest version
if (si.ReadLn(line, sizeof(line)))
{
int version = atoi(line);
si.ReadLn(line, sizeof(line));
if (version != 4)
{
char errorMsg[512];
sprintf(errorMsg, "This installer is out of date.\nPlease get the latest version from:\n\n%s", line);
hsMessageBox(errorMsg, "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
}
else
ret = false;
// Read in the servers, one per line
while (ret && si.ReadLn(line, sizeof(line)))
{
ServerInfo info;
info.fServerAddress = strtok(line, ",");
info.fServerName = strtok(nil, ",");
info.fURLBase = strtok(nil, ",");
info.fOutputDir = strtok(nil, ",");
info.fCurrentDir = strtok(nil, ",");
info.fCodeDir = strtok(nil, ",");
fServers.push_back(info);
}
si.Close();
}
else
{
hsMessageBox("Couldn't find server info", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
ret = false;
}
return ret;
}

View File

@ -1,59 +1,59 @@
/*==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/>.
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==*/
#ifndef plPlasmaServers_h_inc
#define plPlasmaServers_h_inc
#include "hsTypes.h"
#include <vector>
class plPlasmaServers
{
protected:
class ServerInfo
{
public:
std::string fServerAddress;
std::string fServerName;
std::string fURLBase;
std::string fOutputDir;
std::string fCurrentDir;
std::string fCodeDir;
};
std::vector<ServerInfo> fServers;
public:
bool GetServerInfo();
int GetNumServers() { return fServers.size(); }
std::string& GetServerAddress(int i) { return fServers[i].fServerAddress; }
std::string& GetServerName(int i) { return fServers[i].fServerName; }
std::string& GetServerURLBase(int i) { return fServers[i].fURLBase; }
std::string& GetServerOutputDir(int i) { return fServers[i].fOutputDir; }
std::string& GetServerCurrentDir(int i) { return fServers[i].fCurrentDir; }
std::string& GetServerCodeDir(int i) { return fServers[i].fCodeDir; }
};
#endif // plPlasmaServers_h_inc
/*==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/>.
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==*/
#ifndef plPlasmaServers_h_inc
#define plPlasmaServers_h_inc
#include "hsTypes.h"
#include <vector>
class plPlasmaServers
{
protected:
class ServerInfo
{
public:
std::string fServerAddress;
std::string fServerName;
std::string fURLBase;
std::string fOutputDir;
std::string fCurrentDir;
std::string fCodeDir;
};
std::vector<ServerInfo> fServers;
public:
bool GetServerInfo();
int GetNumServers() { return fServers.size(); }
std::string& GetServerAddress(int i) { return fServers[i].fServerAddress; }
std::string& GetServerName(int i) { return fServers[i].fServerName; }
std::string& GetServerURLBase(int i) { return fServers[i].fURLBase; }
std::string& GetServerOutputDir(int i) { return fServers[i].fOutputDir; }
std::string& GetServerCurrentDir(int i) { return fServers[i].fCurrentDir; }
std::string& GetServerCodeDir(int i) { return fServers[i].fCodeDir; }
};
#endif // plPlasmaServers_h_inc

View File

@ -1,499 +1,499 @@
/*==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/>.
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==*/
#include "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "resource.h"
#include <windowsx.h>
#include <commctrl.h>
#include <direct.h>
#include "jvCoreUtil.h"
#include "jvDialogResizer.h"
#include "hsTypes.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
#include "hsStream.h"
#include "plManifest.h"
#include "hsUtils.h"
#include "../plStatusLog/plStatusLog.h"
static plPlasmaUpdate* gInst = nil;
#define WM_UPDATE_SERVER WM_APP+1
std::string plPlasmaUpdate::fUserName = "dataserver";
std::string plPlasmaUpdate::fPassword = "parabledata";
plPlasmaUpdate::plPlasmaUpdate() : fCanExit(true), fProgressType(kValidating), fResizer(nil), fAutoDownload(false)
{
INITCOMMONCONTROLSEX icc = {0};
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&icc);
gInst = this;
_getcwd(fIniPath, sizeof(fIniPath));
char lastChar = fIniPath[strlen(fIniPath)];
if (lastChar != '\\' && lastChar != '/')
strcat(fIniPath, "\\");
strcat(fIniPath, "ParableUpdate.ini");
fFileGrabber = new plNetShareFileGrabber;
}
plPlasmaUpdate::~plPlasmaUpdate()
{
delete fResizer;
if (fFileGrabber)
delete fFileGrabber;
}
bool plPlasmaUpdate::Create()
{
if (!fServers.GetServerInfo())
return false;
ICreateDialog(IDD_UPDATE, NULL);
return true;
}
BOOL CALLBACK plPlasmaUpdate::ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
case WM_INITDIALOG:
SetFocus(GetDlgItem(hDlg, IDC_USERNAME));
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL))
{
bool ok = (LOWORD(wParam) == IDOK);
if (ok)
{
char username[25];
char password[25];
GetDlgItemText(hDlg, IDC_USERNAME, username, 25);
GetDlgItemText(hDlg, IDC_PASSWORD, password, 25);
fUserName = username;
hsAssert(false, "who uses this program?");
// plChallengeResponse::HashPassword(password, fPassword);
}
EndDialog(hDlg, ok);
return TRUE;
}
break;
}
return FALSE;
}
void plPlasmaUpdate::IInit()
{
char curServerAddress[256];
GetPrivateProfileString("PlasmaUpdate", "ServerAddress", "", curServerAddress, sizeof(curServerAddress), fIniPath);
bool external = (GetPrivateProfileInt("PlasmaUpdate", "External", 0, fIniPath) != 0);
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
for (int i = 0; i < fServers.GetNumServers(); i++)
{
std::string& serverAddress = fServers.GetServerAddress(i);
std::string& serverName = fServers.GetServerName(i);
std::string& currentDir = fServers.GetServerCurrentDir(i);
if (!fFileGrabber->IsServerAvailable(serverAddress.c_str(), currentDir.c_str()))
continue;
bool thisServer = (serverAddress == curServerAddress);
int idx = ComboBox_AddString(hCombo, serverName.c_str());
ComboBox_SetItemData(hCombo, idx, MAKELPARAM(i, 0));
if (thisServer && !external)
ComboBox_SetCurSel(hCombo, idx);
std::string extName = serverName + " (External)";
idx = ComboBox_AddString(hCombo, extName.c_str());
ComboBox_SetItemData(hCombo, idx, MAKELPARAM(i, 1));
if (thisServer && external)
ComboBox_SetCurSel(hCombo, idx);
}
if (ComboBox_GetCurSel(hCombo) == -1)
ComboBox_SetCurSel(hCombo, 0);
SendMessage(fDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(jvCoreUtil::GetHInstance(), MAKEINTRESOURCE(IDI_ICON)));
SendMessage(fDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(jvCoreUtil::GetHInstance(), MAKEINTRESOURCE(IDI_ICON)));
fResizer = new jvDialogResizer(fDlg);
fResizer->AddControl(IDC_BUILD_COMBO, jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_STATUS_LIST, jvDialogResizer::kResizeX | jvDialogResizer::kResizeY);
fResizer->AddControl(IDC_PROGRESS, jvDialogResizer::kLockBottom | jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_DL_TEXT, jvDialogResizer::kLockBottom | jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_DL_BUTTON, jvDialogResizer::kLockBottom | jvDialogResizer::kCenterX);
fResizer->SetSize(360, 320);
fResizer->LoadPosAndSize("PlasmaUpdate");
bool goTime = true;
if (fFileGrabber->NeedsAuth())
{
/*
if (!DialogBox(NULL, MAKEINTRESOURCE(IDD_PLASMAUPDATE_LOGIN), fDlg, ILoginWinProc))
goTime = false;
else
*/
fFileGrabber->SetUsernamePassword(fUserName, fPassword);
}
if (goTime)
{
ShowWindow(fDlg, SW_SHOW);
PostMessage(fDlg, WM_UPDATE_SERVER, 0, 0);
}
else
PostQuitMessage(0);
}
void plPlasmaUpdate::IShutdown()
{
fResizer->SavePosAndSize("PlasmaUpdate");
delete fResizer;
fResizer = NULL;
IDeleteManifests();
}
void plPlasmaUpdate::IEnableCtrls(bool enable)
{
fCanExit = enable;
EnableWindow(GetDlgItem(fDlg, IDC_BUILD_COMBO), enable);
HWND hDlButton = GetDlgItem(fDlg, IDC_DL_BUTTON);
if (fManifests.empty())
SetWindowText(hDlButton, "Close");
else
SetWindowText(hDlButton, "Download");
EnableWindow(hDlButton, enable);
if (enable)
SetFocus(hDlButton);
}
void plPlasmaUpdate::IDeleteManifests()
{
for (int i = 0; i < fManifests.size(); i++)
delete fManifests[i];
fManifests.clear();
}
bool plPlasmaUpdate::IGetManifests(const char* serverRoot, bool external)
{
IDeleteManifests();
char filePath[MAX_PATH];
sprintf(filePath, "%sCurrent.txt", serverRoot);
enum Sections
{
kVersion,
kInternal,
kExternal,
kAll
};
int curSection = kVersion;
hsRAMStream s;
hsRAMStream manifestStream;
if (fFileGrabber->FileToStream(filePath, &s))
{
char buf[256];
while (s.ReadLn(buf, sizeof(buf)))
{
if (buf[0] == '[')
{
if (hsStrEQ(buf, "[Version]"))
curSection = kVersion;
else if (hsStrEQ(buf, "[Internal]"))
curSection = kInternal;
else if (hsStrEQ(buf, "[External]"))
curSection = kExternal;
else if (hsStrEQ(buf, "[All]"))
curSection = kAll;
}
else
{
if (curSection == kVersion)
{
int version = atoi(buf);
if (version != 1)
{
hsMessageBox("Your copy of PlasmaUpdate is out of date.\nPlease get the latest version.", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
return false;
}
}
else if ((!external && curSection == kInternal)
|| (external && curSection == kExternal)
|| curSection == kAll)
{
//if (curSection == kAll && !(!strcmp(buf, "Data\\Movies.mfs") || !strcmp(buf, "Data\\Sounds.mfs")))
// continue;
sprintf(filePath, "%s%s", serverRoot, buf);
fFileGrabber->MakeProperPath(filePath);
manifestStream.Reset();
fFileGrabber->FileToStream(filePath, &manifestStream);
plFileUtils::StripFile(filePath);
plManifest* manifest = new plManifest(ILog);
manifest->Read(&manifestStream, filePath, buf);
fManifests.push_back(manifest);
}
}
}
return true;
}
return false;
}
void plPlasmaUpdate::IUpdateServer()
{
char buf[256];
IEnableCtrls(false);
SetDlgItemText(fDlg, IDC_DL_TEXT, "Checking for updates...");
//
// Figure out what server we're checking
//
bool external = false;
char serverRoot[MAX_PATH];
{
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_GetCurSel(hCombo);
LPARAM data = ComboBox_GetItemData(hCombo, idx);
int server = LOWORD(data);
external = (HIWORD(data) != 0);
sprintf(serverRoot, "/%s/", fServers.GetServerCurrentDir(server).c_str());
const char* serverName = fServers.GetServerAddress(server).c_str();
ILog("===== Server set to %s %s =====", serverName, external ? "external" : "internal");
WritePrivateProfileString("PlasmaUpdate", "ServerAddress", serverName, fIniPath);
WritePrivateProfileString("PlasmaUpdate", "External", external ? "1" : "0", fIniPath);
fFileGrabber->SetServer(serverName);
}
//
// Get the latest publish notes
//
{
HWND hList = GetDlgItem(fDlg, IDC_STATUS_LIST);
ListBox_ResetContent(hList);
char updateFile[MAX_PATH];
if (external)
sprintf(updateFile, "%sUpdates-External.txt", serverRoot);
else
sprintf(updateFile, "%sUpdates-Internal.txt", serverRoot);
hsRAMStream updates;
fFileGrabber->MakeProperPath(updateFile);
if (fFileGrabber->FileToStream(updateFile, &updates))
{
while (updates.ReadLn(buf, sizeof(buf)))
ListBox_InsertString(hList, 0, buf);
}
}
//
// Get the manifests
//
bool gotManifests = IGetManifests(serverRoot, external);
UInt32 dlSize = 0;
fProgressType = kValidating;
if (gotManifests)
{
int i;
UInt32 numFiles = 0;
for (i = 0; i < fManifests.size(); i++)
numFiles += fManifests[i]->NumFiles();
HWND hProgress = GetDlgItem(fDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, numFiles);
for (i = 0; i < fManifests.size(); i++)
{
fManifests[i]->ValidateFiles(ProgressFunc);
dlSize += fManifests[i]->DownloadSize();
}
SendMessage(hProgress, PBM_SETPOS, 0, 0);
}
// Print how many megs there are to download
if (dlSize == 0)
{
strcpy(buf, "No updates to download");
IDeleteManifests();
}
else
{
float dlMegs = float(dlSize) / (1024.f*1024.f);
if (dlMegs < .1)
dlMegs = .1;
sprintf(buf, "%.1f MB of updates to download", dlMegs);
}
SetDlgItemText(fDlg, IDC_DL_TEXT, buf);
IEnableCtrls(true);
if (fAutoDownload)
PostMessage(fDlg, WM_COMMAND, MAKEWPARAM(IDC_DL_BUTTON, BN_CLICKED), LPARAM(GetDlgItem(fDlg, IDC_DL_BUTTON)));
}
void plPlasmaUpdate::IDownloadUpdates()
{
fProgressType = kDownloading;
IEnableCtrls(false);
int i;
UInt32 dlSize = 0;
for (i = 0; i < fManifests.size(); i++)
dlSize += fManifests[i]->DownloadSize();
HWND hProgress = GetDlgItem(fDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, dlSize);
for (i = 0; i < fManifests.size(); i++)
fManifests[i]->DownloadUpdates(ProgressFunc, fFileGrabber);
SendMessage(hProgress, PBM_SETPOS, 0, 0);
EnableWindow(GetDlgItem(fDlg, IDC_DL_BUTTON), false);
SetDlgItemText(fDlg, IDC_DL_TEXT, "No updates to download");
IDeleteManifests();
IEnableCtrls(true);
if (fAutoDownload)
PostMessage(fDlg, WM_COMMAND, MAKEWPARAM(IDC_DL_BUTTON, BN_CLICKED), LPARAM(GetDlgItem(fDlg, IDC_DL_BUTTON)));
}
void plPlasmaUpdate::ProgressFunc(const char* name, int delta)
{
static const char* lastName = nil;
if (lastName != name)
{
lastName = name;
char buf[256];
if (gInst->fProgressType == kValidating)
strcpy(buf, "Checking ");
else
strcpy(buf, "Downloading ");
strcat(buf, name);
SetDlgItemText(gInst->fDlg, IDC_DL_TEXT, buf);
}
SendDlgItemMessage(gInst->fDlg, IDC_PROGRESS, PBM_DELTAPOS, delta, 0);
jvBaseDlg::PumpQueue();
}
void plPlasmaUpdate::ILog(const char* format, ...)
{
static plStatusLog* log = nil;
if (!log)
log = plStatusLogMgr::GetInstance().CreateStatusLog(0, "PlasmaUpdate.log");
va_list args;
va_start(args, format);
log->AddLineV(format, args);
va_end(args);
}
BOOL plPlasmaUpdate::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
IInit();
SetFocus(GetDlgItem(fDlg, IDC_DL_BUTTON));
return FALSE;
case WM_CLOSE:
if (fCanExit)
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
IShutdown();
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_DL_BUTTON)
{
if (fManifests.empty())
SendMessage(fDlg, WM_CLOSE, 0, 0);
else
IDownloadUpdates();
return TRUE;
}
else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_BUILD_COMBO)
{
IUpdateServer();
return TRUE;
}
break;
case WM_UPDATE_SERVER:
IUpdateServer();
return TRUE;
}
return FALSE;
}
/*==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/>.
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==*/
#include "HeadSpin.h"
#include "plPlasmaUpdate.h"
#include "resource.h"
#include <windowsx.h>
#include <commctrl.h>
#include <direct.h>
#include "jvCoreUtil.h"
#include "jvDialogResizer.h"
#include "hsTypes.h"
#include "../plFile/plFileUtils.h"
#include "../plUnifiedTime/plUnifiedTime.h"
#include "hsStream.h"
#include "plManifest.h"
#include "hsUtils.h"
#include "../plStatusLog/plStatusLog.h"
static plPlasmaUpdate* gInst = nil;
#define WM_UPDATE_SERVER WM_APP+1
std::string plPlasmaUpdate::fUserName = "dataserver";
std::string plPlasmaUpdate::fPassword = "parabledata";
plPlasmaUpdate::plPlasmaUpdate() : fCanExit(true), fProgressType(kValidating), fResizer(nil), fAutoDownload(false)
{
INITCOMMONCONTROLSEX icc = {0};
icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
icc.dwICC = ICC_PROGRESS_CLASS;
InitCommonControlsEx(&icc);
gInst = this;
_getcwd(fIniPath, sizeof(fIniPath));
char lastChar = fIniPath[strlen(fIniPath)];
if (lastChar != '\\' && lastChar != '/')
strcat(fIniPath, "\\");
strcat(fIniPath, "ParableUpdate.ini");
fFileGrabber = new plNetShareFileGrabber;
}
plPlasmaUpdate::~plPlasmaUpdate()
{
delete fResizer;
if (fFileGrabber)
delete fFileGrabber;
}
bool plPlasmaUpdate::Create()
{
if (!fServers.GetServerInfo())
return false;
ICreateDialog(IDD_UPDATE, NULL);
return true;
}
BOOL CALLBACK plPlasmaUpdate::ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch( msg )
{
case WM_INITDIALOG:
SetFocus(GetDlgItem(hDlg, IDC_USERNAME));
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL))
{
bool ok = (LOWORD(wParam) == IDOK);
if (ok)
{
char username[25];
char password[25];
GetDlgItemText(hDlg, IDC_USERNAME, username, 25);
GetDlgItemText(hDlg, IDC_PASSWORD, password, 25);
fUserName = username;
hsAssert(false, "who uses this program?");
// plChallengeResponse::HashPassword(password, fPassword);
}
EndDialog(hDlg, ok);
return TRUE;
}
break;
}
return FALSE;
}
void plPlasmaUpdate::IInit()
{
char curServerAddress[256];
GetPrivateProfileString("PlasmaUpdate", "ServerAddress", "", curServerAddress, sizeof(curServerAddress), fIniPath);
bool external = (GetPrivateProfileInt("PlasmaUpdate", "External", 0, fIniPath) != 0);
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
for (int i = 0; i < fServers.GetNumServers(); i++)
{
std::string& serverAddress = fServers.GetServerAddress(i);
std::string& serverName = fServers.GetServerName(i);
std::string& currentDir = fServers.GetServerCurrentDir(i);
if (!fFileGrabber->IsServerAvailable(serverAddress.c_str(), currentDir.c_str()))
continue;
bool thisServer = (serverAddress == curServerAddress);
int idx = ComboBox_AddString(hCombo, serverName.c_str());
ComboBox_SetItemData(hCombo, idx, MAKELPARAM(i, 0));
if (thisServer && !external)
ComboBox_SetCurSel(hCombo, idx);
std::string extName = serverName + " (External)";
idx = ComboBox_AddString(hCombo, extName.c_str());
ComboBox_SetItemData(hCombo, idx, MAKELPARAM(i, 1));
if (thisServer && external)
ComboBox_SetCurSel(hCombo, idx);
}
if (ComboBox_GetCurSel(hCombo) == -1)
ComboBox_SetCurSel(hCombo, 0);
SendMessage(fDlg, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(jvCoreUtil::GetHInstance(), MAKEINTRESOURCE(IDI_ICON)));
SendMessage(fDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(jvCoreUtil::GetHInstance(), MAKEINTRESOURCE(IDI_ICON)));
fResizer = new jvDialogResizer(fDlg);
fResizer->AddControl(IDC_BUILD_COMBO, jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_STATUS_LIST, jvDialogResizer::kResizeX | jvDialogResizer::kResizeY);
fResizer->AddControl(IDC_PROGRESS, jvDialogResizer::kLockBottom | jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_DL_TEXT, jvDialogResizer::kLockBottom | jvDialogResizer::kResizeX);
fResizer->AddControl(IDC_DL_BUTTON, jvDialogResizer::kLockBottom | jvDialogResizer::kCenterX);
fResizer->SetSize(360, 320);
fResizer->LoadPosAndSize("PlasmaUpdate");
bool goTime = true;
if (fFileGrabber->NeedsAuth())
{
/*
if (!DialogBox(NULL, MAKEINTRESOURCE(IDD_PLASMAUPDATE_LOGIN), fDlg, ILoginWinProc))
goTime = false;
else
*/
fFileGrabber->SetUsernamePassword(fUserName, fPassword);
}
if (goTime)
{
ShowWindow(fDlg, SW_SHOW);
PostMessage(fDlg, WM_UPDATE_SERVER, 0, 0);
}
else
PostQuitMessage(0);
}
void plPlasmaUpdate::IShutdown()
{
fResizer->SavePosAndSize("PlasmaUpdate");
delete fResizer;
fResizer = NULL;
IDeleteManifests();
}
void plPlasmaUpdate::IEnableCtrls(bool enable)
{
fCanExit = enable;
EnableWindow(GetDlgItem(fDlg, IDC_BUILD_COMBO), enable);
HWND hDlButton = GetDlgItem(fDlg, IDC_DL_BUTTON);
if (fManifests.empty())
SetWindowText(hDlButton, "Close");
else
SetWindowText(hDlButton, "Download");
EnableWindow(hDlButton, enable);
if (enable)
SetFocus(hDlButton);
}
void plPlasmaUpdate::IDeleteManifests()
{
for (int i = 0; i < fManifests.size(); i++)
delete fManifests[i];
fManifests.clear();
}
bool plPlasmaUpdate::IGetManifests(const char* serverRoot, bool external)
{
IDeleteManifests();
char filePath[MAX_PATH];
sprintf(filePath, "%sCurrent.txt", serverRoot);
enum Sections
{
kVersion,
kInternal,
kExternal,
kAll
};
int curSection = kVersion;
hsRAMStream s;
hsRAMStream manifestStream;
if (fFileGrabber->FileToStream(filePath, &s))
{
char buf[256];
while (s.ReadLn(buf, sizeof(buf)))
{
if (buf[0] == '[')
{
if (hsStrEQ(buf, "[Version]"))
curSection = kVersion;
else if (hsStrEQ(buf, "[Internal]"))
curSection = kInternal;
else if (hsStrEQ(buf, "[External]"))
curSection = kExternal;
else if (hsStrEQ(buf, "[All]"))
curSection = kAll;
}
else
{
if (curSection == kVersion)
{
int version = atoi(buf);
if (version != 1)
{
hsMessageBox("Your copy of PlasmaUpdate is out of date.\nPlease get the latest version.", "Error", hsMessageBoxNormal, hsMessageBoxIconError);
return false;
}
}
else if ((!external && curSection == kInternal)
|| (external && curSection == kExternal)
|| curSection == kAll)
{
//if (curSection == kAll && !(!strcmp(buf, "Data\\Movies.mfs") || !strcmp(buf, "Data\\Sounds.mfs")))
// continue;
sprintf(filePath, "%s%s", serverRoot, buf);
fFileGrabber->MakeProperPath(filePath);
manifestStream.Reset();
fFileGrabber->FileToStream(filePath, &manifestStream);
plFileUtils::StripFile(filePath);
plManifest* manifest = new plManifest(ILog);
manifest->Read(&manifestStream, filePath, buf);
fManifests.push_back(manifest);
}
}
}
return true;
}
return false;
}
void plPlasmaUpdate::IUpdateServer()
{
char buf[256];
IEnableCtrls(false);
SetDlgItemText(fDlg, IDC_DL_TEXT, "Checking for updates...");
//
// Figure out what server we're checking
//
bool external = false;
char serverRoot[MAX_PATH];
{
HWND hCombo = GetDlgItem(fDlg, IDC_BUILD_COMBO);
int idx = ComboBox_GetCurSel(hCombo);
LPARAM data = ComboBox_GetItemData(hCombo, idx);
int server = LOWORD(data);
external = (HIWORD(data) != 0);
sprintf(serverRoot, "/%s/", fServers.GetServerCurrentDir(server).c_str());
const char* serverName = fServers.GetServerAddress(server).c_str();
ILog("===== Server set to %s %s =====", serverName, external ? "external" : "internal");
WritePrivateProfileString("PlasmaUpdate", "ServerAddress", serverName, fIniPath);
WritePrivateProfileString("PlasmaUpdate", "External", external ? "1" : "0", fIniPath);
fFileGrabber->SetServer(serverName);
}
//
// Get the latest publish notes
//
{
HWND hList = GetDlgItem(fDlg, IDC_STATUS_LIST);
ListBox_ResetContent(hList);
char updateFile[MAX_PATH];
if (external)
sprintf(updateFile, "%sUpdates-External.txt", serverRoot);
else
sprintf(updateFile, "%sUpdates-Internal.txt", serverRoot);
hsRAMStream updates;
fFileGrabber->MakeProperPath(updateFile);
if (fFileGrabber->FileToStream(updateFile, &updates))
{
while (updates.ReadLn(buf, sizeof(buf)))
ListBox_InsertString(hList, 0, buf);
}
}
//
// Get the manifests
//
bool gotManifests = IGetManifests(serverRoot, external);
UInt32 dlSize = 0;
fProgressType = kValidating;
if (gotManifests)
{
int i;
UInt32 numFiles = 0;
for (i = 0; i < fManifests.size(); i++)
numFiles += fManifests[i]->NumFiles();
HWND hProgress = GetDlgItem(fDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, numFiles);
for (i = 0; i < fManifests.size(); i++)
{
fManifests[i]->ValidateFiles(ProgressFunc);
dlSize += fManifests[i]->DownloadSize();
}
SendMessage(hProgress, PBM_SETPOS, 0, 0);
}
// Print how many megs there are to download
if (dlSize == 0)
{
strcpy(buf, "No updates to download");
IDeleteManifests();
}
else
{
float dlMegs = float(dlSize) / (1024.f*1024.f);
if (dlMegs < .1)
dlMegs = .1;
sprintf(buf, "%.1f MB of updates to download", dlMegs);
}
SetDlgItemText(fDlg, IDC_DL_TEXT, buf);
IEnableCtrls(true);
if (fAutoDownload)
PostMessage(fDlg, WM_COMMAND, MAKEWPARAM(IDC_DL_BUTTON, BN_CLICKED), LPARAM(GetDlgItem(fDlg, IDC_DL_BUTTON)));
}
void plPlasmaUpdate::IDownloadUpdates()
{
fProgressType = kDownloading;
IEnableCtrls(false);
int i;
UInt32 dlSize = 0;
for (i = 0; i < fManifests.size(); i++)
dlSize += fManifests[i]->DownloadSize();
HWND hProgress = GetDlgItem(fDlg, IDC_PROGRESS);
SendMessage(hProgress, PBM_SETRANGE32, 0, dlSize);
for (i = 0; i < fManifests.size(); i++)
fManifests[i]->DownloadUpdates(ProgressFunc, fFileGrabber);
SendMessage(hProgress, PBM_SETPOS, 0, 0);
EnableWindow(GetDlgItem(fDlg, IDC_DL_BUTTON), false);
SetDlgItemText(fDlg, IDC_DL_TEXT, "No updates to download");
IDeleteManifests();
IEnableCtrls(true);
if (fAutoDownload)
PostMessage(fDlg, WM_COMMAND, MAKEWPARAM(IDC_DL_BUTTON, BN_CLICKED), LPARAM(GetDlgItem(fDlg, IDC_DL_BUTTON)));
}
void plPlasmaUpdate::ProgressFunc(const char* name, int delta)
{
static const char* lastName = nil;
if (lastName != name)
{
lastName = name;
char buf[256];
if (gInst->fProgressType == kValidating)
strcpy(buf, "Checking ");
else
strcpy(buf, "Downloading ");
strcat(buf, name);
SetDlgItemText(gInst->fDlg, IDC_DL_TEXT, buf);
}
SendDlgItemMessage(gInst->fDlg, IDC_PROGRESS, PBM_DELTAPOS, delta, 0);
jvBaseDlg::PumpQueue();
}
void plPlasmaUpdate::ILog(const char* format, ...)
{
static plStatusLog* log = nil;
if (!log)
log = plStatusLogMgr::GetInstance().CreateStatusLog(0, "PlasmaUpdate.log");
va_list args;
va_start(args, format);
log->AddLineV(format, args);
va_end(args);
}
BOOL plPlasmaUpdate::IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
IInit();
SetFocus(GetDlgItem(fDlg, IDC_DL_BUTTON));
return FALSE;
case WM_CLOSE:
if (fCanExit)
DestroyWindow(hDlg);
return TRUE;
case WM_DESTROY:
IShutdown();
PostQuitMessage(0);
return TRUE;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_DL_BUTTON)
{
if (fManifests.empty())
SendMessage(fDlg, WM_CLOSE, 0, 0);
else
IDownloadUpdates();
return TRUE;
}
else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_BUILD_COMBO)
{
IUpdateServer();
return TRUE;
}
break;
case WM_UPDATE_SERVER:
IUpdateServer();
return TRUE;
}
return FALSE;
}

View File

@ -1,78 +1,78 @@
/*==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/>.
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==*/
#include "hsTypes.h"
#include "jvBaseDlg.h"
#include <vector>
#include <string>
#include "plPlasmaServers.h"
#include "plFileGrabber.h"
class plManifest;
class jvDialogResizer;
class plPlasmaUpdate : public jvBaseDlg
{
protected:
static BOOL CALLBACK ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static std::string fUserName;
static std::string fPassword;
std::vector<plManifest*> fManifests;
char fIniPath[MAX_PATH];
bool fCanExit;
enum ProgressType { kValidating, kDownloading };
ProgressType fProgressType;
jvDialogResizer* fResizer;
plPlasmaServers fServers;
bool fAutoDownload;
plFileGrabber* fFileGrabber;
void IInit();
void IShutdown();
bool IReadServerInfo();
void IEnableCtrls(bool enable);
BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void ProgressFunc(const char* name, int delta);
static void ILog(const char* format, ...);
void IUpdateServer();
void IDeleteManifests();
bool IGetManifests(const char* serverRoot, bool external);
void IDownloadUpdates();
public:
plPlasmaUpdate();
virtual ~plPlasmaUpdate();
bool Create();
void SetAutoDownload() { fAutoDownload = true; }
};
/*==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/>.
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==*/
#include "hsTypes.h"
#include "jvBaseDlg.h"
#include <vector>
#include <string>
#include "plPlasmaServers.h"
#include "plFileGrabber.h"
class plManifest;
class jvDialogResizer;
class plPlasmaUpdate : public jvBaseDlg
{
protected:
static BOOL CALLBACK ILoginWinProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static std::string fUserName;
static std::string fPassword;
std::vector<plManifest*> fManifests;
char fIniPath[MAX_PATH];
bool fCanExit;
enum ProgressType { kValidating, kDownloading };
ProgressType fProgressType;
jvDialogResizer* fResizer;
plPlasmaServers fServers;
bool fAutoDownload;
plFileGrabber* fFileGrabber;
void IInit();
void IShutdown();
bool IReadServerInfo();
void IEnableCtrls(bool enable);
BOOL IDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static void ProgressFunc(const char* name, int delta);
static void ILog(const char* format, ...);
void IUpdateServer();
void IDeleteManifests();
bool IGetManifests(const char* serverRoot, bool external);
void IDownloadUpdates();
public:
plPlasmaUpdate();
virtual ~plPlasmaUpdate();
bool Create();
void SetAutoDownload() { fAutoDownload = true; }
};

View File

@ -1,138 +1,138 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_UPDATE DIALOGEX 0, 0, 128, 105
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "Parable Update"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_BUILD_COMBO,27,6,90,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Download",IDC_DL_BUTTON,34,86,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,36,110,11,LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER |
0x1,7,54,110,16
LTEXT "Latest Updates:",IDC_STATIC,7,26,51,8
CONTROL "xx.x MB of updates to download",IDC_DL_TEXT,"Static",
SS_LEFTNOWORDWRAP | WS_GROUP,7,74,110,8
END
IDD_PLASMAUPDATE_LOGIN DIALOGEX 0, 0, 150, 102
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Login"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,48,80,50,14
EDITTEXT IDC_USERNAME,7,17,135,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,7,45,135,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username",IDC_STATIC,7,7,134,8
LTEXT "Password",IDC_STATIC,7,35,136,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_UPDATE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 121
TOPMARGIN, 7
BOTTOMMARGIN, 98
END
IDD_PLASMAUPDATE_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 143
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_UPDATE DIALOGEX 0, 0, 128, 105
STYLE DS_SETFONT | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU |
WS_THICKFRAME
CAPTION "Parable Update"
FONT 8, "MS Sans Serif", 0, 0, 0x0
BEGIN
LTEXT "Build:",IDC_STATIC,7,8,18,8
COMBOBOX IDC_BUILD_COMBO,27,6,90,167,CBS_DROPDOWNLIST |
WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "Download",IDC_DL_BUTTON,34,86,56,16,WS_DISABLED
LISTBOX IDC_STATUS_LIST,7,36,110,11,LBS_NOINTEGRALHEIGHT |
LBS_NOSEL | WS_VSCROLL | WS_TABSTOP
CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",WS_BORDER |
0x1,7,54,110,16
LTEXT "Latest Updates:",IDC_STATIC,7,26,51,8
CONTROL "xx.x MB of updates to download",IDC_DL_TEXT,"Static",
SS_LEFTNOWORDWRAP | WS_GROUP,7,74,110,8
END
IDD_PLASMAUPDATE_LOGIN DIALOGEX 0, 0, 150, 102
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION |
WS_SYSMENU
CAPTION "Login"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,48,62,50,14
PUSHBUTTON "Cancel",IDCANCEL,48,80,50,14
EDITTEXT IDC_USERNAME,7,17,135,12,ES_AUTOHSCROLL
EDITTEXT IDC_PASSWORD,7,45,135,12,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Username",IDC_STATIC,7,7,134,8
LTEXT "Password",IDC_STATIC,7,35,136,10
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_UPDATE, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 121
TOPMARGIN, 7
BOTTOMMARGIN, 98
END
IDD_PLASMAUPDATE_LOGIN, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 143
TOPMARGIN, 7
BOTTOMMARGIN, 95
END
END
#endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,27 +1,27 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plPlasmaUpdate.rc
//
#define IDD_UPDATE 101
#define IDI_ICON1 102
#define IDI_ICON 102
#define IDD_PLASMAUPDATE_LOGIN 103
#define IDC_DL_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BUILD_COMBO 1008
#define IDC_PROGRESS 1014
#define IDC_DL_TEXT 1015
#define IDC_EDIT1 1016
#define IDC_USERNAME 1016
#define IDC_PASSWORD 1017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plPlasmaUpdate.rc
//
#define IDD_UPDATE 101
#define IDI_ICON1 102
#define IDI_ICON 102
#define IDD_PLASMAUPDATE_LOGIN 103
#define IDC_DL_BUTTON 1005
#define IDC_STATUS_LIST 1006
#define IDC_BUILD_COMBO 1008
#define IDC_PROGRESS 1014
#define IDC_DL_TEXT 1015
#define IDC_EDIT1 1016
#define IDC_USERNAME 1016
#define IDC_PASSWORD 1017
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 104
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1018
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif