Browse Source

Merge pull request #138 from branan/patcher-cleanup

Patcher cleanup
Branan Purvine-Riley 13 years ago
parent
commit
383ef67790
  1. 20
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  2. 16
      Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

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

@ -59,15 +59,28 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
class plResDownloadStream : public plZlibStream
{
plOperationProgress* fProgress;
char* fFilename;
bool fIsZipped;
public:
plResDownloadStream(plOperationProgress* prog, const wchar_t* reqFile)
: fProgress(prog)
: fProgress(prog), fFilename(nil)
{
fIsZipped = wcscmp(plFileUtils::GetFileExt(reqFile), L"gz") == 0;
}
~plResDownloadStream()
{
if (fFilename)
delete[] fFilename;
}
hsBool Open(const char* filename, const char* mode)
{
fFilename = hsStrcpy(filename);
return plZlibStream::Open(filename, mode);
}
uint32_t Write(uint32_t count, const void* buf)
{
fProgress->Increment((float)count);
@ -78,6 +91,7 @@ public:
}
bool IsZipped() const { return fIsZipped; }
void Unlink() const { plFileUtils::RemoveFile(fFilename); }
};
/////////////////////////////////////////////////////////////////////////////
@ -93,7 +107,6 @@ static void FileDownloaded(
if (((plResDownloadStream*)writer)->IsZipped())
plFileUtils::StripExt(name); // Kill off .gz
writer->Close();
delete writer;
switch (result)
{
@ -107,6 +120,7 @@ static void FileDownloaded(
// Continue down the warpath
patcher->IssueRequest();
delete[] name;
delete writer;
return;
case kNetErrFileNotFound:
PatcherLog(kError, " Download Failed: %s not found", name);
@ -119,8 +133,10 @@ static void FileDownloaded(
}
// Failure case
((plResDownloadStream*)writer)->Unlink();
patcher->Finish(false);
delete[] name;
delete writer;
}
static void ManifestDownloaded(

16
Sources/Plasma/PubUtilLib/plNetClient/plNetLinkingMgr.cpp

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetTransport/plNetTransportMember.h" // OfferLinkToPlayer()
#include "plgDispatch.h"
#include "pnMessage/plClientMsg.h"
#include "pnMessage/plTimeMsg.h"
#include "plMessage/plLinkToAgeMsg.h"
#include "pnKeyedObject/plKey.h"
@ -159,8 +160,21 @@ void plNetLinkingMgr::NCAgeJoinerCallback (
void * notify,
void * userState
) {
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();
NCAgeJoinerCompleteNotify* params = (NCAgeJoinerCompleteNotify*)notify;
// Tell the user we failed to link.
// In the future, we might want to try graceful recovery (link back to Relto?)
if (!params->success) {
plNetClientMgr::StaticErrorMsg(params->msg);
hsMessageBox(params->msg, "Linking Error", hsMessageBoxNormal, hsMessageBoxIconError);
#ifdef PLASMA_EXTERNAL_RELEASE
plClientMsg* clientMsg = new plClientMsg(plClientMsg::kQuit);
clientMsg->Send(hsgResMgr::ResMgr()->FindKey(kClient_KEY));
#endif
return;
}
plNetLinkingMgr * lm = plNetLinkingMgr::GetInstance();
switch (type) {
case kAgeJoinerComplete: {
ASSERT(joiner == s_ageJoiner);

Loading…
Cancel
Save