mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 18:59:09 +00:00
Reroute plResPatcher
This commit is contained in:
@ -153,6 +153,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
|
|
||||||
#include "pfSecurePreloader/pfSecurePreloader.h"
|
#include "pfSecurePreloader/pfSecurePreloader.h"
|
||||||
#include "pfLocalizationMgr/pfLocalizationMgr.h"
|
#include "pfLocalizationMgr/pfLocalizationMgr.h"
|
||||||
|
#include "pfPatcher/plManifests.h"
|
||||||
|
|
||||||
#include "plTweak.h"
|
#include "plTweak.h"
|
||||||
|
|
||||||
@ -1613,19 +1614,10 @@ bool plClient::StartInit()
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void plClient::IPatchGlobalAgeFiles( void )
|
void plClient::IPatchGlobalAgeFiles( void )
|
||||||
{
|
{
|
||||||
plResPatcher* patcher = plResPatcher::GetInstance();
|
|
||||||
if (!gDataServerLocal)
|
|
||||||
{
|
|
||||||
patcher->RequestManifest("CustomAvatars");
|
|
||||||
patcher->RequestManifest("GlobalAnimations");
|
|
||||||
patcher->RequestManifest("GlobalAvatars");
|
|
||||||
patcher->RequestManifest("GlobalClothing");
|
|
||||||
patcher->RequestManifest("GlobalMarkers");
|
|
||||||
patcher->RequestManifest("GUI");
|
|
||||||
}
|
|
||||||
|
|
||||||
plgDispatch::Dispatch()->RegisterForExactType(plResPatcherMsg::Index(), GetKey());
|
plgDispatch::Dispatch()->RegisterForExactType(plResPatcherMsg::Index(), GetKey());
|
||||||
patcher->Start();
|
|
||||||
|
plResPatcher* patcher = plResPatcher::GetInstance();
|
||||||
|
patcher->Update(plManifest::EssentialGameManifests());
|
||||||
}
|
}
|
||||||
|
|
||||||
void plClient::InitDLLs()
|
void plClient::InitDLLs()
|
||||||
@ -2550,7 +2542,7 @@ void plClient::IHandlePatcherMsg (plResPatcherMsg * msg) {
|
|||||||
plgDispatch::Dispatch()->UnRegisterForExactType(plResPatcherMsg::Index(), GetKey());
|
plgDispatch::Dispatch()->UnRegisterForExactType(plResPatcherMsg::Index(), GetKey());
|
||||||
|
|
||||||
if (!msg->Success()) {
|
if (!msg->Success()) {
|
||||||
plNetClientApp::GetInstance()->QueueDisableNet(true, msg->GetError());
|
plNetClientApp::GetInstance()->QueueDisableNet(true, msg->GetError().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,5 +18,7 @@ set(plAgeLoader_HEADERS
|
|||||||
|
|
||||||
add_library(plAgeLoader STATIC ${plAgeLoader_SOURCES} ${plAgeLoader_HEADERS})
|
add_library(plAgeLoader STATIC ${plAgeLoader_SOURCES} ${plAgeLoader_HEADERS})
|
||||||
|
|
||||||
|
target_link_libraries(plAgeLoader pfPatcher)
|
||||||
|
|
||||||
source_group("Source Files" FILES ${plAgeLoader_SOURCES})
|
source_group("Source Files" FILES ${plAgeLoader_SOURCES})
|
||||||
source_group("Header Files" FILES ${plAgeLoader_HEADERS})
|
source_group("Header Files" FILES ${plAgeLoader_HEADERS})
|
||||||
|
@ -69,15 +69,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#include "plResMgr/plRegistryNode.h"
|
#include "plResMgr/plRegistryNode.h"
|
||||||
#include "plResMgr/plResManager.h"
|
#include "plResMgr/plResManager.h"
|
||||||
#include "plFile/plEncryptedStream.h"
|
#include "plFile/plEncryptedStream.h"
|
||||||
|
#include "plProgressMgr/plProgressMgr.h"
|
||||||
|
|
||||||
/// TEMP HACK TO LOAD CONSOLE INIT FILES ON AGE LOAD
|
/// TEMP HACK TO LOAD CONSOLE INIT FILES ON AGE LOAD
|
||||||
#include "plMessage/plConsoleMsg.h"
|
#include "plMessage/plConsoleMsg.h"
|
||||||
#include "plMessage/plLoadAvatarMsg.h"
|
#include "plMessage/plLoadAvatarMsg.h"
|
||||||
#include "plMessage/plAgeLoadedMsg.h"
|
#include "plMessage/plAgeLoadedMsg.h"
|
||||||
|
|
||||||
|
|
||||||
extern bool gDataServerLocal;
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
plAgeLoader* plAgeLoader::fInstance=nil;
|
plAgeLoader* plAgeLoader::fInstance=nil;
|
||||||
|
|
||||||
@ -119,6 +117,7 @@ void plAgeLoader::Init()
|
|||||||
RegisterAs( kAgeLoader_KEY );
|
RegisterAs( kAgeLoader_KEY );
|
||||||
plgDispatch::Dispatch()->RegisterForExactType(plInitialAgeStateLoadedMsg::Index(), GetKey());
|
plgDispatch::Dispatch()->RegisterForExactType(plInitialAgeStateLoadedMsg::Index(), GetKey());
|
||||||
plgDispatch::Dispatch()->RegisterForExactType(plClientMsg::Index(), GetKey());
|
plgDispatch::Dispatch()->RegisterForExactType(plClientMsg::Index(), GetKey());
|
||||||
|
plgDispatch::Dispatch()->RegisterForExactType(plResPatcherMsg::Index(), GetKey());
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -156,7 +155,12 @@ bool plAgeLoader::MsgReceive(plMessage* msg)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sadface thread protection
|
||||||
|
if (plResPatcherMsg::ConvertNoRef(msg)) {
|
||||||
|
delete plResPatcher::GetInstance()->fProgress;
|
||||||
|
plResPatcher::GetInstance()->fProgress = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
return plReceiver::MsgReceive(msg);
|
return plReceiver::MsgReceive(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,14 +177,7 @@ bool plAgeLoader::LoadAge(const char ageName[])
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void plAgeLoader::UpdateAge(const char ageName[])
|
void plAgeLoader::UpdateAge(const char ageName[])
|
||||||
{
|
{
|
||||||
if (gDataServerLocal)
|
plResPatcher::GetInstance()->Update(ageName);
|
||||||
// We have to send this msg ourselves since we're not actually updating
|
|
||||||
plgDispatch::Dispatch()->MsgSend(new plResPatcherMsg);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plResPatcher::GetInstance()->RequestManifest(ageName);
|
|
||||||
plResPatcher::GetInstance()->Start();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -42,153 +42,19 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
|
|
||||||
#include "plResPatcher.h"
|
#include "plResPatcher.h"
|
||||||
#include "hsResMgr.h"
|
#include "hsResMgr.h"
|
||||||
|
#include "plgDispatch.h"
|
||||||
|
|
||||||
#include "plAgeLoader/plAgeLoader.h"
|
#include "plAgeLoader/plAgeLoader.h"
|
||||||
#include "plCompression/plZlibStream.h"
|
|
||||||
#include "pnEncryption/plChecksum.h"
|
|
||||||
#include "plMessage/plResPatcherMsg.h"
|
#include "plMessage/plResPatcherMsg.h"
|
||||||
#include "pnNetBase/pnNbError.h"
|
#include "pfPatcher/pfPatcher.h"
|
||||||
#include "plNetGameLib/plNetGameLib.h"
|
|
||||||
#include "plProgressMgr/plProgressMgr.h"
|
#include "plProgressMgr/plProgressMgr.h"
|
||||||
#include "plResMgr/plResManager.h"
|
#include "plResMgr/plResManager.h"
|
||||||
#include "plStatusLog/plStatusLog.h"
|
|
||||||
|
extern bool gDataServerLocal;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class plResDownloadStream : public plZlibStream
|
plResPatcher* plResPatcher::fInstance = nullptr;
|
||||||
{
|
|
||||||
plOperationProgress* fProgress;
|
|
||||||
plFileName fFilename;
|
|
||||||
bool fIsZipped;
|
|
||||||
|
|
||||||
public:
|
|
||||||
plResDownloadStream(plOperationProgress* prog, const plFileName& reqFile)
|
|
||||||
: fProgress(prog)
|
|
||||||
{
|
|
||||||
fIsZipped = reqFile.GetFileExt().CompareI("gz") == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Open(const plFileName& filename, const char* mode)
|
|
||||||
{
|
|
||||||
fFilename = filename;
|
|
||||||
return plZlibStream::Open(filename, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual uint32_t Write(uint32_t count, const void* buf)
|
|
||||||
{
|
|
||||||
fProgress->Increment((float)count);
|
|
||||||
if (fIsZipped)
|
|
||||||
return plZlibStream::Write(count, buf);
|
|
||||||
else
|
|
||||||
return fOutput->Write(count, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
plFileName GetFileName() const { return fFilename; }
|
|
||||||
bool IsZipped() const { return fIsZipped; }
|
|
||||||
void Unlink() const { plFileSystem::Unlink(fFilename); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static void FileDownloaded(
|
|
||||||
ENetError result,
|
|
||||||
void* param,
|
|
||||||
const plFileName & filename,
|
|
||||||
hsStream* writer)
|
|
||||||
{
|
|
||||||
plResPatcher* patcher = (plResPatcher*)param;
|
|
||||||
plFileName file = filename;
|
|
||||||
if (((plResDownloadStream*)writer)->IsZipped())
|
|
||||||
file = file.StripFileExt(); // Kill off .gz
|
|
||||||
writer->Close();
|
|
||||||
|
|
||||||
switch (result)
|
|
||||||
{
|
|
||||||
case kNetSuccess:
|
|
||||||
{
|
|
||||||
PatcherLog(kStatus, " Download Complete: %s", file.AsString().c_str());
|
|
||||||
|
|
||||||
// If this is a PRP, then we need to add it to the ResManager
|
|
||||||
plFileName clientPath = static_cast<plResDownloadStream*>(writer)->GetFileName();
|
|
||||||
if (clientPath.GetFileExt().CompareI("prp") == 0)
|
|
||||||
{
|
|
||||||
plResManager* clientResMgr = static_cast<plResManager*>(hsgResMgr::ResMgr());
|
|
||||||
clientResMgr->AddSinglePage(clientPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue down the warpath
|
|
||||||
patcher->IssueRequest();
|
|
||||||
delete writer;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
case kNetErrFileNotFound:
|
|
||||||
PatcherLog(kError, " Download Failed: %s not found", file.AsString().c_str());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
char* error = hsWStringToString(NetErrorToString(result));
|
|
||||||
PatcherLog(kError, " Download Failed: %s", error);
|
|
||||||
delete[] error;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Failure case
|
|
||||||
static_cast<plResDownloadStream*>(writer)->Unlink();
|
|
||||||
patcher->Finish(false);
|
|
||||||
delete writer;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ManifestDownloaded(
|
|
||||||
ENetError result,
|
|
||||||
void* param,
|
|
||||||
const wchar_t group[],
|
|
||||||
const NetCliFileManifestEntry manifest[],
|
|
||||||
uint32_t entryCount)
|
|
||||||
{
|
|
||||||
plResPatcher* patcher = (plResPatcher*)param;
|
|
||||||
plString name = plString::FromWchar(group);
|
|
||||||
if (IS_NET_SUCCESS(result))
|
|
||||||
PatcherLog(kInfo, " Downloaded manifest %s", name.c_str());
|
|
||||||
else {
|
|
||||||
PatcherLog(kError, " Failed to download manifest %s", name.c_str());
|
|
||||||
patcher->Finish(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < entryCount; ++i)
|
|
||||||
{
|
|
||||||
const NetCliFileManifestEntry mfs = manifest[i];
|
|
||||||
plFileName fileName = plString::FromWchar(mfs.clientName);
|
|
||||||
plFileName downloadName = plString::FromWchar(mfs.downloadName);
|
|
||||||
|
|
||||||
// See if the files are the same
|
|
||||||
// 1. Check file size before we do time consuming md5 operations
|
|
||||||
// 2. Do wasteful md5. We should consider implementing a CRC instead.
|
|
||||||
if (plFileInfo(fileName).FileSize() == mfs.fileSize)
|
|
||||||
{
|
|
||||||
plMD5Checksum cliMD5(fileName);
|
|
||||||
plMD5Checksum srvMD5;
|
|
||||||
srvMD5.SetFromHexString(plString::FromWchar(mfs.md5, 32).c_str());
|
|
||||||
|
|
||||||
if (cliMD5 == srvMD5)
|
|
||||||
continue;
|
|
||||||
else
|
|
||||||
PatcherLog(kInfo, " Enqueueing %s: MD5 Checksums Differ", fileName.AsString().c_str());
|
|
||||||
} else
|
|
||||||
PatcherLog(kInfo, " Enqueueing %s: File Sizes Differ", fileName.AsString().c_str());
|
|
||||||
|
|
||||||
// If we're still here, then we need to update the file.
|
|
||||||
float size = mfs.zipSize ? (float)mfs.zipSize : (float)mfs.fileSize;
|
|
||||||
patcher->GetProgress()->SetLength(size + patcher->GetProgress()->GetMax());
|
|
||||||
patcher->RequestFile(downloadName, fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
patcher->IssueRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
static char* sLastError = nil;
|
|
||||||
plResPatcher* plResPatcher::fInstance = nil;
|
|
||||||
|
|
||||||
plResPatcher* plResPatcher::GetInstance()
|
plResPatcher* plResPatcher::GetInstance()
|
||||||
{
|
{
|
||||||
@ -199,134 +65,102 @@ plResPatcher* plResPatcher::GetInstance()
|
|||||||
|
|
||||||
void plResPatcher::Shutdown()
|
void plResPatcher::Shutdown()
|
||||||
{
|
{
|
||||||
// Better not call this while we're patching
|
|
||||||
delete fInstance;
|
delete fInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
plResPatcher::plResPatcher()
|
void plResPatcher::OnCompletion(ENetError result, const plString& status)
|
||||||
: fPatching(false), fProgress(nil) { }
|
|
||||||
|
|
||||||
plResPatcher::~plResPatcher()
|
|
||||||
{
|
{
|
||||||
if (fProgress)
|
plString error = plString::Null;
|
||||||
delete fProgress;
|
if (IS_NET_ERROR(result))
|
||||||
|
error = plString::Format("Update Failed: %S\n%s", NetErrorAsString(result), status.c_str());
|
||||||
|
plgDispatch::Dispatch()->MsgQueue(new plResPatcherMsg(IS_NET_SUCCESS(result), error));
|
||||||
}
|
}
|
||||||
|
|
||||||
void plResPatcher::IssueRequest()
|
void plResPatcher::OnFileDownloadBegin(const plFileName& file)
|
||||||
{
|
{
|
||||||
if (!fPatching) return;
|
fProgress->SetTitle(plString::Format("Downloading %s...", file.GetFileName().c_str()));
|
||||||
if (fRequests.empty())
|
|
||||||
// Wheee!
|
|
||||||
Finish();
|
|
||||||
else {
|
|
||||||
Request req = fRequests.front();
|
|
||||||
fRequests.pop();
|
|
||||||
|
|
||||||
plString title;
|
if (file.GetFileExt().CompareI("prp") == 0) {
|
||||||
if (req.fType == kManifest)
|
plResManager* mgr = static_cast<plResManager*>(hsgResMgr::ResMgr());
|
||||||
{
|
if (mgr)
|
||||||
PatcherLog(kMajorStatus, " Downloading manifest... %s", req.fFile.AsString().c_str());
|
mgr->RemoveSinglePage(file);
|
||||||
title = plString::Format("Checking %s for updates...", req.fFile.AsString().c_str());
|
|
||||||
NetCliFileManifestRequest(ManifestDownloaded, this, req.fFile.AsString().ToWchar());
|
|
||||||
} else if (req.fType == kFile) {
|
|
||||||
PatcherLog(kMajorStatus, " Downloading file... %s", req.fFriendlyName.AsString().c_str());
|
|
||||||
title = plString::Format("Downloading... %s", req.fFriendlyName.GetFileName().c_str());
|
|
||||||
|
|
||||||
// If this is a PRP, we need to unload it from the ResManager
|
|
||||||
|
|
||||||
if (req.fFriendlyName.GetFileExt().CompareI("prp") == 0)
|
|
||||||
((plResManager*)hsgResMgr::ResMgr())->RemoveSinglePage(req.fFriendlyName);
|
|
||||||
|
|
||||||
plFileSystem::CreateDir(req.fFriendlyName.StripFileName(), true);
|
|
||||||
plResDownloadStream* stream = new plResDownloadStream(fProgress, req.fFile);
|
|
||||||
if (stream->Open(req.fFriendlyName, "wb"))
|
|
||||||
NetCliFileDownloadRequest(req.fFile, stream, FileDownloaded, this);
|
|
||||||
else {
|
|
||||||
PatcherLog(kError, " Unable to create file %s", req.fFriendlyName.AsString().c_str());
|
|
||||||
Finish(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fProgress->SetTitle(title);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void plResPatcher::Finish(bool success)
|
void plResPatcher::OnFileDownloaded(const plFileName& file)
|
||||||
{
|
{
|
||||||
while (fRequests.size())
|
if (file.GetFileExt().CompareI("prp") == 0) {
|
||||||
fRequests.pop();
|
plResManager* mgr = static_cast<plResManager*>(hsgResMgr::ResMgr());
|
||||||
|
if (mgr)
|
||||||
fPatching = false;
|
mgr->AddSinglePage(file);
|
||||||
if (success)
|
|
||||||
PatcherLog(kHeader, "--- Patch Completed Successfully ---");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
PatcherLog(kHeader, "--- Patch Killed by Error ---");
|
|
||||||
if (fProgress)
|
|
||||||
fProgress->SetAborting();
|
|
||||||
}
|
}
|
||||||
delete fProgress; fProgress = nil;
|
|
||||||
|
|
||||||
plResPatcherMsg* pMsg = new plResPatcherMsg(success, sLastError);
|
|
||||||
delete[] sLastError; sLastError = nil;
|
|
||||||
pMsg->Send(); // whoosh... off it goes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void plResPatcher::RequestFile(const plFileName& srvName, const plFileName& cliName)
|
void plResPatcher::OnProgressTick(uint64_t dl, uint64_t total, const plString& msg)
|
||||||
{
|
{
|
||||||
fRequests.push(Request(srvName, kFile, cliName));
|
if (dl && total) {
|
||||||
|
fProgress->SetLength(total);
|
||||||
|
fProgress->SetHowMuch(dl);
|
||||||
|
}
|
||||||
|
|
||||||
|
plString status = plString::Format("%s / %s",
|
||||||
|
plFileSystem::ConvertFileSize(dl).c_str(),
|
||||||
|
plFileSystem::ConvertFileSize(total).c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
fProgress->SetStatusText(status);
|
||||||
|
fProgress->SetInfoText(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void plResPatcher::RequestManifest(const plString& age)
|
pfPatcher* plResPatcher::CreatePatcher()
|
||||||
{
|
{
|
||||||
fRequests.push(Request(age, kManifest));
|
pfPatcher* patcher = new pfPatcher;
|
||||||
|
patcher->OnCompletion(std::bind(&plResPatcher::OnCompletion, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
|
patcher->OnFileDownloadBegin(std::bind(&plResPatcher::OnFileDownloadBegin, this, std::placeholders::_1));
|
||||||
|
patcher->OnFileDownloaded(std::bind(&plResPatcher::OnFileDownloaded, this, std::placeholders::_1));
|
||||||
|
patcher->OnProgressTick(std::bind(&plResPatcher::OnProgressTick, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
|
return patcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
void plResPatcher::Start()
|
void plResPatcher::InitProgress()
|
||||||
{
|
{
|
||||||
hsAssert(!fPatching, "Too many calls to plResPatcher::Start");
|
// this is deleted in plAgeLoader::MsgReceive for thread safety
|
||||||
fPatching = true;
|
fProgress = plProgressMgr::GetInstance()->RegisterOperation(0.f, nullptr, plProgressMgr::kUpdateText);
|
||||||
PatcherLog(kHeader, "--- Patch Started (%i requests) ---", fRequests.size());
|
|
||||||
fProgress = plProgressMgr::GetInstance()->RegisterOperation(0.0, "Checking for updates...",
|
|
||||||
plProgressMgr::kUpdateText, false, true);
|
|
||||||
IssueRequest();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void PatcherLog(PatcherLogType type, const char* format, ...)
|
plResPatcher::plResPatcher()
|
||||||
|
: fProgress(nullptr) { }
|
||||||
|
|
||||||
|
plResPatcher::~plResPatcher()
|
||||||
{
|
{
|
||||||
uint32_t color = 0;
|
delete fProgress;
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case kHeader: color = plStatusLog::kWhite; break;
|
|
||||||
case kInfo: color = plStatusLog::kBlue; break;
|
|
||||||
case kMajorStatus: color = plStatusLog::kYellow; break;
|
|
||||||
case kStatus: color = plStatusLog::kGreen; break;
|
|
||||||
case kError: color = plStatusLog::kRed; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
static plStatusLog* gStatusLog = nil;
|
|
||||||
if (!gStatusLog)
|
|
||||||
{
|
|
||||||
gStatusLog = plStatusLogMgr::GetInstance().CreateStatusLog(
|
|
||||||
20,
|
|
||||||
"patcher.log",
|
|
||||||
plStatusLog::kFilledBackground | plStatusLog::kAlignToTop | plStatusLog::kDeleteForMe);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_list args;
|
|
||||||
va_start(args, format);
|
|
||||||
|
|
||||||
if (type == kError)
|
|
||||||
{
|
|
||||||
sLastError = new char[1024]; // Deleted by Finish(false)
|
|
||||||
vsnprintf(sLastError, 1024, format, args);
|
|
||||||
gStatusLog->AddLine(sLastError, color);
|
|
||||||
} else
|
|
||||||
gStatusLog->AddLineV(color, format, args);
|
|
||||||
|
|
||||||
va_end(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void plResPatcher::Update(const std::vector<plString>& manifests)
|
||||||
|
{
|
||||||
|
if (gDataServerLocal)
|
||||||
|
plgDispatch::Dispatch()->MsgSend(new plResPatcherMsg());
|
||||||
|
else {
|
||||||
|
InitProgress();
|
||||||
|
pfPatcher* patcher = CreatePatcher();
|
||||||
|
patcher->RequestManifest(manifests);
|
||||||
|
patcher->Start(); // whoosh... off it goes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void plResPatcher::Update(const plString& manifest)
|
||||||
|
{
|
||||||
|
if (gDataServerLocal)
|
||||||
|
plgDispatch::Dispatch()->MsgSend(new plResPatcherMsg());
|
||||||
|
else {
|
||||||
|
InitProgress();
|
||||||
|
pfPatcher* patcher = CreatePatcher();
|
||||||
|
patcher->RequestManifest(manifest);
|
||||||
|
patcher->Start(); // whoosh... off it goes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -39,57 +39,47 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
Mead, WA 99021
|
Mead, WA 99021
|
||||||
|
|
||||||
*==LICENSE==*/
|
*==LICENSE==*/
|
||||||
|
|
||||||
#ifndef plResPatcher_h_inc
|
#ifndef plResPatcher_h_inc
|
||||||
#define plResPatcher_h_inc
|
#define plResPatcher_h_inc
|
||||||
|
|
||||||
#include "HeadSpin.h"
|
|
||||||
#include "plFileSystem.h"
|
#include "plFileSystem.h"
|
||||||
#include <queue>
|
#include "pnNetBase/pnNbError.h"
|
||||||
#include <string>
|
#include <vector>
|
||||||
|
|
||||||
class plOperationProgress;
|
class plOperationProgress;
|
||||||
|
class plString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plasma Resource Patcher
|
||||||
|
* This is a thin wrapper around \sa pfPatcher that ensures updates are propagated to the rest of the engine.
|
||||||
|
*/
|
||||||
class plResPatcher
|
class plResPatcher
|
||||||
{
|
{
|
||||||
enum { kManifest, kFile };
|
plOperationProgress* fProgress;
|
||||||
struct Request
|
static plResPatcher* fInstance;
|
||||||
{
|
|
||||||
plFileName fFile;
|
|
||||||
plFileName fFriendlyName;
|
|
||||||
uint8_t fType;
|
|
||||||
|
|
||||||
Request(const plFileName& file, uint8_t type, const plFileName& friendly = "")
|
friend class plAgeLoader;
|
||||||
: fFile(file), fFriendlyName(friendly), fType(type) { }
|
|
||||||
};
|
|
||||||
|
|
||||||
static plResPatcher* fInstance;
|
void OnCompletion(ENetError, const plString& msg);
|
||||||
std::queue<Request> fRequests;
|
void OnFileDownloadBegin(const plFileName& file);
|
||||||
plOperationProgress* fProgress;
|
void OnFileDownloaded(const plFileName& file);
|
||||||
bool fPatching;
|
void OnProgressTick(uint64_t dl, uint64_t total, const plString& msg);
|
||||||
|
|
||||||
plResPatcher();
|
class pfPatcher* CreatePatcher();
|
||||||
~plResPatcher();
|
void InitProgress();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static plResPatcher* GetInstance();
|
static plResPatcher* GetInstance();
|
||||||
static void Shutdown();
|
static void Shutdown();
|
||||||
|
|
||||||
plOperationProgress* GetProgress() { return fProgress; }
|
public:
|
||||||
|
plResPatcher();
|
||||||
|
~plResPatcher();
|
||||||
|
|
||||||
void Finish(bool success = true);
|
void Update(const std::vector<plString>& manifests);
|
||||||
void IssueRequest();
|
void Update(const plString& manifest);
|
||||||
void RequestFile(const plFileName& file, const plFileName& friendlyName);
|
|
||||||
void RequestManifest(const plString& age);
|
|
||||||
void Start();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum PatcherLogType
|
|
||||||
{
|
|
||||||
kHeader,
|
|
||||||
kInfo,
|
|
||||||
kMajorStatus,
|
|
||||||
kStatus,
|
|
||||||
kError,
|
|
||||||
};
|
|
||||||
void PatcherLog(PatcherLogType type, const char* format, ...);
|
|
||||||
#endif // _plResPatcher_h
|
#endif // _plResPatcher_h
|
||||||
|
@ -42,31 +42,28 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
|||||||
#ifndef _PLMESSAGE_PLRESPATCHERMSG_H
|
#ifndef _PLMESSAGE_PLRESPATCHERMSG_H
|
||||||
#define _PLMESSAGE_PLRESPATCHERMSG_H
|
#define _PLMESSAGE_PLRESPATCHERMSG_H
|
||||||
|
|
||||||
#include "HeadSpin.h"
|
#include "plString.h"
|
||||||
#include "pnMessage/plMessage.h"
|
#include "pnMessage/plMessage.h"
|
||||||
|
|
||||||
// This message is sent when plResPatcher has completed its async operation
|
// This message is sent when plResPatcher has completed its async operation
|
||||||
class plResPatcherMsg : public plMessage {
|
class plResPatcherMsg : public plMessage {
|
||||||
bool fSuccess;
|
bool fSuccess;
|
||||||
char* fError;
|
plString fError;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
plResPatcherMsg() : fSuccess(true), fError(nil) { SetBCastFlag(kBCastByExactType); }
|
plResPatcherMsg() : fSuccess(true) { SetBCastFlag(kBCastByExactType); }
|
||||||
plResPatcherMsg(bool success, const char* error) : fSuccess(success)
|
plResPatcherMsg(bool success, const plString& error) : fSuccess(success), fError(error)
|
||||||
{
|
{
|
||||||
SetBCastFlag(kBCastByExactType);
|
SetBCastFlag(kBCastByExactType);
|
||||||
fError = hsStrcpy(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~plResPatcherMsg() { delete[] fError; }
|
|
||||||
|
|
||||||
CLASSNAME_REGISTER(plResPatcherMsg);
|
CLASSNAME_REGISTER(plResPatcherMsg);
|
||||||
GETINTERFACE_ANY(plResPatcherMsg, plMessage);
|
GETINTERFACE_ANY(plResPatcherMsg, plMessage);
|
||||||
|
|
||||||
void Read (hsStream *, hsResMgr *) { FATAL("What the hell are you doing?"); }
|
void Read (hsStream *, hsResMgr *) { FATAL("What the hell are you doing?"); }
|
||||||
void Write (hsStream *, hsResMgr *) { FATAL("What the hell are you doing?"); }
|
void Write (hsStream *, hsResMgr *) { FATAL("What the hell are you doing?"); }
|
||||||
|
|
||||||
const char* GetError() const { return fError; }
|
plString GetError() const { return fError; }
|
||||||
bool Success() const { return fSuccess; }
|
bool Success() const { return fSuccess; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ bool plNCAgeJoiner::MsgReceive (plMessage * msg) {
|
|||||||
);
|
);
|
||||||
LogMsg(kLogPerf, L"AgeJoiner: Next:kNoOp (age updated)");
|
LogMsg(kLogPerf, L"AgeJoiner: Next:kNoOp (age updated)");
|
||||||
} else
|
} else
|
||||||
Complete(false, resMsg->GetError());
|
Complete(false, resMsg->GetError().c_str());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user