Browse Source

Merge pull request #278 from zrax/hacky-sack

Fix patcher brokenness from filesystem PR
Adam Johnson 12 years ago
parent
commit
d3a9a51277
  1. 20
      Sources/Plasma/Apps/plClientPatcher/UruPlayer.cpp
  2. 7
      Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
  3. 6
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp
  4. 6
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  5. 23
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  6. 8
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.h

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

@ -472,9 +472,9 @@ static void ProcessManifestEntry (void * param, ENetError error) {
StrPrintf(text, arrsize(text), "Checking for updates... %S", p->mr->manifest[p->index].clientName);
p->mr->info->SetText(text);
#endif
plFileName path = plFileName::Join(s_workingDir, p->mr->manifest[p->index].clientName);
plFileName path = plFileName::Join(s_workingDir, plString::FromWchar(p->mr->manifest[p->index].clientName));
uint32_t start = (uint32_t)(TimeGetTime() / kTimeIntervalsPerMs);
if (!MD5Check(path, p->mr->manifest[p->index].md5.c_str())) {
if (!MD5Check(path, plString::FromWchar(p->mr->manifest[p->index].md5, 32).c_str())) {
p->mr->critsect.Lock();
p->mr->indices.Add(p->index);
p->mr->critsect.Unlock();
@ -547,7 +547,7 @@ static void ProcessManifest (void * param) {
p->index = i;
p->mr = mr;
p->exists = false;
plFileName path = plFileName::Join(s_workingDir, mr->manifest[i].clientName);
plFileName path = plFileName::Join(s_workingDir, plString::FromWchar(mr->manifest[i].clientName));
fd = plFileSystem::Open(path, "r");
if (fd)
{
@ -589,13 +589,13 @@ static void ProcessManifest (void * param) {
if(s_running)
{
unsigned index = mr->indices[i];
plFileName path = plFileName::Join(s_workingDir, manifest[index].clientName);
plFileName path = plFileName::Join(s_workingDir, plString::FromWchar(manifest[index].clientName));
plFileSystem::CreateDir(path.StripFileName(), true);
ManifestFile* mf = new ManifestFile(
manifest[index].clientName,
manifest[index].downloadName,
manifest[index].md5,
plString::FromWchar(manifest[index].clientName),
plString::FromWchar(manifest[index].downloadName),
plString::FromWchar(manifest[index].md5),
manifest[index].flags,
mr->info
);
@ -733,8 +733,8 @@ static void ThinManifestCallback (
if (!s_running)
return;
plFileName path = plFileName::Join(s_workingDir, manifest[i].clientName);
if (!MD5Check(path, manifest[i].md5.c_str())) {
plFileName path = plFileName::Join(s_workingDir, plString::FromWchar(manifest[i].clientName));
if (!MD5Check(path, plString::FromWchar(manifest[i].md5, 32).c_str())) {
s_patchComplete = false;
NetCliFileManifestRequest(ManifestCallback, info, s_manifest, info->buildId);
break;
@ -746,7 +746,7 @@ static void ThinManifestCallback (
info->progressCallback(kStatusPending, &patchInfo);
#ifndef PLASMA_EXTERNAL_RELEASE
char text[256];
StrPrintf(text, arrsize(text), "Checking for updates... %s", manifest[i].clientName.AsString().c_str());
StrPrintf(text, arrsize(text), "Checking for updates... %S", manifest[i].clientName);
info->SetText(text);
#endif
}

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

@ -184,7 +184,7 @@ static void ManifestCallback (
// MD5 check current patcher against value in manifest
ASSERT(entryCount == 1);
plFileName curPatcherFile = plFileSystem::GetCurrentAppPath();
if (!MD5Check(curPatcherFile, manifest[0].md5.c_str())) {
if (!MD5Check(curPatcherFile, plString::FromWchar(manifest[0].md5, 32).c_str())) {
// MessageBox(GetTopWindow(nil), "MD5 failed", "Msg", MB_OK);
SelfPatcherStream::totalBytes += manifest[0].zipSize;
@ -195,7 +195,7 @@ static void ManifestCallback (
if (!stream->Open(s_newPatcherFile, "wb"))
ErrorAssert(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", s_newPatcherFile.AsString().c_str(), errno);
NetCliFileDownloadRequest(manifest[0].downloadName, stream, DownloadCallback, nil);
NetCliFileDownloadRequest(plString::FromWchar(manifest[0].downloadName), stream, DownloadCallback, nil);
}
else {
s_downloadComplete = true;
@ -272,7 +272,8 @@ static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
si.cb = sizeof(si);
wchar_t cmdline[MAX_PATH];
StrPrintf(cmdline, arrsize(cmdline), L"%s %s", s_newPatcherFile.AsString().ToWchar(), info->cmdLine);
StrPrintf(cmdline, arrsize(cmdline), L"%s %s",
s_newPatcherFile.AsString().ToWchar().GetData(), info->cmdLine);
// we have only successfully patched if we actually launch the new version of the patcher
patched = CreateProcessW(

6
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp

@ -345,8 +345,8 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
const NetCliFileManifestEntry mfs = manifestEntries[i];
bool fetchMe = true;
hsRAMStream* s = nil;
plFileName clientName = mfs.clientName;
plFileName downloadName = mfs.downloadName;
plFileName clientName = plString::FromWchar(mfs.clientName);
plFileName downloadName = plString::FromWchar(mfs.downloadName);
if (plFileInfo(clientName).Exists())
{
@ -355,7 +355,7 @@ void pfSecurePreloader::PreloadManifest(const NetCliFileManifestEntry manifestEn
{
// Damn this
plMD5Checksum srvHash;
srvHash.SetFromHexString(mfs.md5.c_str());
srvHash.SetFromHexString(plString::FromWchar(mfs.md5, 32).c_str());
// Now actually copare the hashes
plMD5Checksum lclHash;

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

@ -150,8 +150,8 @@ static void ManifestDownloaded(
for (uint32_t i = 0; i < entryCount; ++i)
{
const NetCliFileManifestEntry mfs = manifest[i];
plFileName fileName = mfs.clientName;
plFileName downloadName = mfs.downloadName;
plFileName fileName = plString::FromWchar(mfs.clientName);
plFileName downloadName = plString::FromWchar(mfs.downloadName);
// See if the files are the same
// 1. Check file size before we do time consuming md5 operations
@ -160,7 +160,7 @@ static void ManifestDownloaded(
{
plMD5Checksum cliMD5(fileName);
plMD5Checksum srvMD5;
srvMD5.SetFromHexString(mfs.md5.c_str());
srvMD5.SetFromHexString(plString::FromWchar(mfs.md5, 32).c_str());
if (cliMD5 == srvMD5)
continue;

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

@ -943,9 +943,13 @@ void ManifestRequestTrans::Post () {
}
//============================================================================
plString ReadStringFromMsg(const wchar_t* curMsgPtr, unsigned* length) {
(*length) = wcslen(curMsgPtr);
return plString::FromWchar(curMsgPtr, *length);
void ReadStringFromMsg(const wchar_t* curMsgPtr, wchar_t* destPtr, unsigned* length) {
if (!(*length)) {
size_t maxlen = wcsnlen(curMsgPtr, MAX_PATH - 1); // Hacky sack
(*length) = maxlen;
destPtr[maxlen] = 0; // Don't do this on fixed length, because there's no room for it
}
memcpy(destPtr, curMsgPtr, *length * sizeof(wchar_t));
}
//============================================================================
@ -1001,8 +1005,8 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the clientFilename
unsigned filenameLen;
entry.clientName = ReadStringFromMsg(curChar, &filenameLen);
unsigned filenameLen = 0;
ReadStringFromMsg(curChar, entry.clientName, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1014,7 +1018,8 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the downloadFilename
entry.downloadName = ReadStringFromMsg(curChar, &filenameLen);
filenameLen = 0;
ReadStringFromMsg(curChar, entry.downloadName, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1026,7 +1031,8 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the md5
entry.md5 = ReadStringFromMsg(curChar, &filenameLen);
filenameLen = 32;
ReadStringFromMsg(curChar, entry.md5, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))
@ -1038,7 +1044,8 @@ bool ManifestRequestTrans::Recv (
// --------------------------------------------------------------------
// read in the md5 for compressed files
entry.md5compressed = ReadStringFromMsg(curChar, &filenameLen);
filenameLen = 32;
ReadStringFromMsg(curChar, entry.md5compressed, &filenameLen);
curChar += filenameLen; // advance the pointer
wchar_tCount -= filenameLen; // keep track of the amount remaining
if ((*curChar != L'\0') || (wchar_tCount <= 0))

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

@ -97,10 +97,10 @@ void NetCliFileRegisterBuildIdUpdate (FNetCliFileBuildIdUpdateCallback callback)
// Manifest
//============================================================================
struct NetCliFileManifestEntry {
plFileName clientName; // path and file on client side (for comparison)
plFileName downloadName; // path and file on server side (for download)
plString md5;
plString md5compressed; // md5 for the compressed file
wchar_t clientName[MAX_PATH]; // path and file on client side (for comparison)
wchar_t downloadName[MAX_PATH]; // path and file on server side (for download)
wchar_t md5[32];
wchar_t md5compressed[32]; // md5 for the compressed file
unsigned fileSize;
unsigned zipSize;
unsigned flags;

Loading…
Cancel
Save