1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +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

View File

@ -1,66 +1,66 @@
include_directories("../../Apps")
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plUruLauncher_HEADERS
Intern.h
Pch.h
plLauncherInfo.h
)
set(plUruLauncher_SOURCES
Main.cpp
SelfPatcher.cpp
)
set(plUruLauncher_RESOURCES
plUruLauncher.rc
resource.h
banner.bmp
Dirt.ICO
)
add_executable(plUruLauncher WIN32 ${plUruLauncher_SOURCES} ${plUruLauncher_HEADERS}
${plUruLauncher_RESOURCES})
target_link_libraries(plUruLauncher CoreLib)
target_link_libraries(plUruLauncher CoreLibExe)
target_link_libraries(plUruLauncher plAudioCore)
target_link_libraries(plUruLauncher plClientPatcher)
target_link_libraries(plUruLauncher plCompression)
target_link_libraries(plUruLauncher plEncryption)
target_link_libraries(plUruLauncher plFile)
target_link_libraries(plUruLauncher plNetClient)
target_link_libraries(plUruLauncher plNetClientComm)
target_link_libraries(plUruLauncher plNetGameLib)
target_link_libraries(plUruLauncher plNetMessage)
target_link_libraries(plUruLauncher plNetTransport)
target_link_libraries(plUruLauncher plUnifiedTime)
target_link_libraries(plUruLauncher pnAsyncCore)
target_link_libraries(plUruLauncher pnAsyncCoreExe)
target_link_libraries(plUruLauncher pnNetBase)
target_link_libraries(plUruLauncher pnNetCli)
target_link_libraries(plUruLauncher pnNetCommon)
target_link_libraries(plUruLauncher pnNetProtocol)
target_link_libraries(plUruLauncher pnProduct)
target_link_libraries(plUruLauncher pnSimpleNet)
target_link_libraries(plUruLauncher pnTimer)
target_link_libraries(plUruLauncher pnUtils)
target_link_libraries(plUruLauncher pnUtilsExe)
target_link_libraries(plUruLauncher ${DirectX_LIBRARIES})
target_link_libraries(plUruLauncher ${OPENSSL_LIBRARIES})
target_link_libraries(plUruLauncher ${Ogg_LIBRARIES})
target_link_libraries(plUruLauncher ${Vorbis_LIBRARIES})
target_link_libraries(plUruLauncher ws2_32)
target_link_libraries(plUruLauncher winhttp)
target_link_libraries(plUruLauncher rpcrt4)
target_link_libraries(plUruLauncher comctl32)
source_group("Source Files" FILES ${plUruLauncher_SOURCES})
source_group("Header Files" FILES ${plUruLauncher_HEADERS})
source_group("Resource Files" FILES ${plUruLauncher_RESOURCES})
include_directories("../../Apps")
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plUruLauncher_HEADERS
Intern.h
Pch.h
plLauncherInfo.h
)
set(plUruLauncher_SOURCES
Main.cpp
SelfPatcher.cpp
)
set(plUruLauncher_RESOURCES
plUruLauncher.rc
resource.h
banner.bmp
Dirt.ICO
)
add_executable(plUruLauncher WIN32 ${plUruLauncher_SOURCES} ${plUruLauncher_HEADERS}
${plUruLauncher_RESOURCES})
target_link_libraries(plUruLauncher CoreLib)
target_link_libraries(plUruLauncher CoreLibExe)
target_link_libraries(plUruLauncher plAudioCore)
target_link_libraries(plUruLauncher plClientPatcher)
target_link_libraries(plUruLauncher plCompression)
target_link_libraries(plUruLauncher plEncryption)
target_link_libraries(plUruLauncher plFile)
target_link_libraries(plUruLauncher plNetClient)
target_link_libraries(plUruLauncher plNetClientComm)
target_link_libraries(plUruLauncher plNetGameLib)
target_link_libraries(plUruLauncher plNetMessage)
target_link_libraries(plUruLauncher plNetTransport)
target_link_libraries(plUruLauncher plUnifiedTime)
target_link_libraries(plUruLauncher pnAsyncCore)
target_link_libraries(plUruLauncher pnAsyncCoreExe)
target_link_libraries(plUruLauncher pnNetBase)
target_link_libraries(plUruLauncher pnNetCli)
target_link_libraries(plUruLauncher pnNetCommon)
target_link_libraries(plUruLauncher pnNetProtocol)
target_link_libraries(plUruLauncher pnProduct)
target_link_libraries(plUruLauncher pnSimpleNet)
target_link_libraries(plUruLauncher pnTimer)
target_link_libraries(plUruLauncher pnUtils)
target_link_libraries(plUruLauncher pnUtilsExe)
target_link_libraries(plUruLauncher ${DirectX_LIBRARIES})
target_link_libraries(plUruLauncher ${OPENSSL_LIBRARIES})
target_link_libraries(plUruLauncher ${Ogg_LIBRARIES})
target_link_libraries(plUruLauncher ${Vorbis_LIBRARIES})
target_link_libraries(plUruLauncher ws2_32)
target_link_libraries(plUruLauncher winhttp)
target_link_libraries(plUruLauncher rpcrt4)
target_link_libraries(plUruLauncher comctl32)
source_group("Source Files" FILES ${plUruLauncher_SOURCES})
source_group("Header Files" FILES ${plUruLauncher_HEADERS})
source_group("Resource Files" FILES ${plUruLauncher_RESOURCES})

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1,45 +1,45 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
/*****************************************************************************
*
* SelfPatcher.cpp
*
***/
bool SelfPatch (bool noSelfPatch, bool * abort, ENetError * result, plLauncherInfo *info);
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_INTERN_H
/*****************************************************************************
*
* SelfPatcher.cpp
*
***/
bool SelfPatch (bool noSelfPatch, bool * abort, ENetError * result, plLauncherInfo *info);
void SetReturnCode (DWORD retCode);

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,57 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PCH_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PCH_H
#include <process.h>
#include <time.h>
#include <winsock2.h>
#include <windows.h>
#include <WinHttp.h>
#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnProduct/pnProduct.h"
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plEncryption/plChecksum.h"
#include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h"
#include "plLauncherInfo.h"
#include "Intern.h"
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PCH_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PCH_H
#include <process.h>
#include <time.h>
#include <winsock2.h>
#include <windows.h>
#include <WinHttp.h>
#include "pnUtils/pnUtils.h"
#include "pnNetBase/pnNetBase.h"
#include "pnAsyncCore/pnAsyncCore.h"
#include "pnProduct/pnProduct.h"
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plEncryption/plChecksum.h"
#include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h"
#include "plLauncherInfo.h"
#include "Intern.h"

View File

@ -1,305 +1,305 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private Data
*
***/
#ifndef PLASMA_EXTERNAL_RELEASE
static const wchar s_manifest[] = L"InternalPatcher";
#else
static const wchar s_manifest[] = L"ExternalPatcher";
#endif
class SelfPatcherStream : public plZlibStream {
public:
virtual UInt32 Write(UInt32 byteCount, const void* buffer);
static plLauncherInfo *info;
static unsigned totalBytes;
static unsigned progress;
};
unsigned SelfPatcherStream::totalBytes = 0;
unsigned SelfPatcherStream::progress = 0;
static bool s_downloadComplete;
static long s_numFiles;
static ENetError s_patchResult;
static bool s_updated;
static wchar s_newPatcherFile[MAX_PATH];
/*****************************************************************************
*
* Private Functions
*
***/
//============================================================================
static void NetErrorHandler (ENetProtocol protocol, ENetError error) {
LogMsg(kLogError, L"NetErr: %s", NetErrorToString(error));
if (IS_NET_SUCCESS(s_patchResult))
s_patchResult = error;
s_downloadComplete = true;
switch(error) {
case kNetErrServerBusy:
MessageBox(0, "Due to the high demand, the server is currently busy. Please try again later, or for alternative download options visit: http://www.mystonline.com/play/", "UruLauncher", MB_OK);
s_patchResult = kNetErrServerBusy;
s_downloadComplete = true;
break;
}
}
//============================================================================
static void DownloadCallback (
ENetError result,
void * param,
const wchar filename[],
hsStream * writer
) {
if(IS_NET_ERROR(result)) {
switch (result) {
case kNetErrTimeout:
writer->Rewind();
NetCliFileDownloadRequest(filename, writer, DownloadCallback, param);
break;
default:
LogMsg(kLogError, L"Error getting patcher file: %s", NetErrorToString(result));
if (IS_NET_SUCCESS(s_patchResult))
s_patchResult = result;
break;
}
return;
}
writer->Close();
delete writer;
AtomicAdd(&s_numFiles, -1);
if(!s_numFiles) {
s_downloadComplete = true;
s_updated = true;
}
}
//============================================================================
static bool MD5Check (const char filename[], const wchar md5[]) {
// Do md5 check
char md5copy[MAX_PATH];
plMD5Checksum existingMD5(filename);
plMD5Checksum latestMD5;
StrToAnsi(md5copy, md5, arrsize(md5copy));
latestMD5.SetFromHexString(md5copy);
return (existingMD5 == latestMD5);
}
//============================================================================
static void ManifestCallback (
ENetError result,
void * param,
const wchar group[],
const NetCliFileManifestEntry manifest[],
unsigned entryCount
) {
if(IS_NET_ERROR(result)) {
switch (result) {
case kNetErrTimeout:
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
break;
default:
LogMsg(kLogError, L"Error getting patcher manifest: %s", NetErrorToString(result));
if (IS_NET_SUCCESS(s_patchResult))
s_patchResult = result;
break;
}
return;
}
char ansi[MAX_PATH];
// MD5 check current patcher against value in manifest
ASSERT(entryCount == 1);
wchar curPatcherFile[MAX_PATH];
PathGetProgramName(curPatcherFile, arrsize(curPatcherFile));
StrToAnsi(ansi, curPatcherFile, arrsize(ansi));
if (!MD5Check(ansi, manifest[0].md5)) {
// MessageBox(GetTopWindow(nil), "MD5 failed", "Msg", MB_OK);
SelfPatcherStream::totalBytes += manifest[0].zipSize;
AtomicAdd(&s_numFiles, 1);
SetText("Downloading new patcher...");
StrToAnsi(ansi, s_newPatcherFile, arrsize(ansi));
SelfPatcherStream * stream = NEWZERO(SelfPatcherStream);
if (!stream->Open(ansi, "wb"))
ErrorFatal(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", ansi, errno);
NetCliFileDownloadRequest(manifest[0].downloadName, stream, DownloadCallback, nil);
}
else {
s_downloadComplete = true;
}
}
//============================================================================
static void FileSrvIpAddressCallback (
ENetError result,
void * param,
const wchar addr[]
) {
NetCliGateKeeperDisconnect();
if (IS_NET_ERROR(result)) {
LogMsg(kLogDebug, L"FileSrvIpAddressRequest failed: %s", NetErrorToString(result));
s_patchResult = result;
s_downloadComplete = true;
}
// Start connecting to the server
NetCliFileStartConnect(&addr, 1, true);
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
PathDeleteFile(s_newPatcherFile);
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
}
//============================================================================
static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
bool patched = false;
s_downloadComplete = false;
s_patchResult = kNetSuccess;
NetClientInitialize();
NetClientSetErrorHandler(NetErrorHandler);
const wchar ** addrs;
unsigned count;
count = GetGateKeeperSrvHostnames(&addrs);
// Start connecting to the server
NetCliGateKeeperStartConnect(addrs, count);
// request a file server ip address
NetCliGateKeeperFileSrvIpAddressRequest(FileSrvIpAddressCallback, nil, true);
while(!s_downloadComplete && !*abort) {
NetClientUpdate();
AsyncSleep(10);
}
NetCliFileDisconnect();
NetClientUpdate();
// Shutdown the client/server networking subsystem
NetClientDestroy();
if (s_downloadComplete && !*abort && s_updated && IS_NET_SUCCESS(s_patchResult)) {
// launch new patcher
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZERO(si);
ZERO(pi);
si.cb = sizeof(si);
wchar cmdline[MAX_PATH];
StrPrintf(cmdline, arrsize(cmdline), L"%s %s", s_newPatcherFile, info->cmdLine);
// we have only successfully patched if we actually launch the new version of the patcher
patched = CreateProcessW(
NULL,
cmdline,
NULL,
NULL,
FALSE,
DETACHED_PROCESS,
NULL,
NULL,
&si,
&pi
);
SetReturnCode(pi.dwProcessId);
CloseHandle( pi.hThread );
CloseHandle( pi.hProcess );
ASSERT(patched);
}
return patched;
}
/*****************************************************************************
*
* ProgressStream Functions
*
***/
//============================================================================
UInt32 SelfPatcherStream::Write(UInt32 byteCount, const void* buffer) {
progress += byteCount;
float p = (float)progress / (float)totalBytes * 100; // progress
SetProgress( (int)p );
return plZlibStream::Write(byteCount, buffer);
}
/*****************************************************************************
*
* Protected Functions
*
***/
//============================================================================
// if return value is true, there was an update and the patcher should be shutdown, so the new patcher can take over
bool SelfPatch (bool noSelfPatch, bool * abort, ENetError * result, plLauncherInfo *info) {
bool patched = false;
if (!noSelfPatch) {
SetText("Checking for patcher update...");
patched = SelfPatcherProc(abort, info);
}
*result = s_patchResult;
return patched;
}
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/SelfPatcher.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
/*****************************************************************************
*
* Private Data
*
***/
#ifndef PLASMA_EXTERNAL_RELEASE
static const wchar s_manifest[] = L"InternalPatcher";
#else
static const wchar s_manifest[] = L"ExternalPatcher";
#endif
class SelfPatcherStream : public plZlibStream {
public:
virtual UInt32 Write(UInt32 byteCount, const void* buffer);
static plLauncherInfo *info;
static unsigned totalBytes;
static unsigned progress;
};
unsigned SelfPatcherStream::totalBytes = 0;
unsigned SelfPatcherStream::progress = 0;
static bool s_downloadComplete;
static long s_numFiles;
static ENetError s_patchResult;
static bool s_updated;
static wchar s_newPatcherFile[MAX_PATH];
/*****************************************************************************
*
* Private Functions
*
***/
//============================================================================
static void NetErrorHandler (ENetProtocol protocol, ENetError error) {
LogMsg(kLogError, L"NetErr: %s", NetErrorToString(error));
if (IS_NET_SUCCESS(s_patchResult))
s_patchResult = error;
s_downloadComplete = true;
switch(error) {
case kNetErrServerBusy:
MessageBox(0, "Due to the high demand, the server is currently busy. Please try again later, or for alternative download options visit: http://www.mystonline.com/play/", "UruLauncher", MB_OK);
s_patchResult = kNetErrServerBusy;
s_downloadComplete = true;
break;
}
}
//============================================================================
static void DownloadCallback (
ENetError result,
void * param,
const wchar filename[],
hsStream * writer
) {
if(IS_NET_ERROR(result)) {
switch (result) {
case kNetErrTimeout:
writer->Rewind();
NetCliFileDownloadRequest(filename, writer, DownloadCallback, param);
break;
default:
LogMsg(kLogError, L"Error getting patcher file: %s", NetErrorToString(result));
if (IS_NET_SUCCESS(s_patchResult))
s_patchResult = result;
break;
}
return;
}
writer->Close();
delete writer;
AtomicAdd(&s_numFiles, -1);
if(!s_numFiles) {
s_downloadComplete = true;
s_updated = true;
}
}
//============================================================================
static bool MD5Check (const char filename[], const wchar md5[]) {
// Do md5 check
char md5copy[MAX_PATH];
plMD5Checksum existingMD5(filename);
plMD5Checksum latestMD5;
StrToAnsi(md5copy, md5, arrsize(md5copy));
latestMD5.SetFromHexString(md5copy);
return (existingMD5 == latestMD5);
}
//============================================================================
static void ManifestCallback (
ENetError result,
void * param,
const wchar group[],
const NetCliFileManifestEntry manifest[],
unsigned entryCount
) {
if(IS_NET_ERROR(result)) {
switch (result) {
case kNetErrTimeout:
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
break;
default:
LogMsg(kLogError, L"Error getting patcher manifest: %s", NetErrorToString(result));
if (IS_NET_SUCCESS(s_patchResult))
s_patchResult = result;
break;
}
return;
}
char ansi[MAX_PATH];
// MD5 check current patcher against value in manifest
ASSERT(entryCount == 1);
wchar curPatcherFile[MAX_PATH];
PathGetProgramName(curPatcherFile, arrsize(curPatcherFile));
StrToAnsi(ansi, curPatcherFile, arrsize(ansi));
if (!MD5Check(ansi, manifest[0].md5)) {
// MessageBox(GetTopWindow(nil), "MD5 failed", "Msg", MB_OK);
SelfPatcherStream::totalBytes += manifest[0].zipSize;
AtomicAdd(&s_numFiles, 1);
SetText("Downloading new patcher...");
StrToAnsi(ansi, s_newPatcherFile, arrsize(ansi));
SelfPatcherStream * stream = NEWZERO(SelfPatcherStream);
if (!stream->Open(ansi, "wb"))
ErrorFatal(__LINE__, __FILE__, "Failed to create file: %s, errno: %u", ansi, errno);
NetCliFileDownloadRequest(manifest[0].downloadName, stream, DownloadCallback, nil);
}
else {
s_downloadComplete = true;
}
}
//============================================================================
static void FileSrvIpAddressCallback (
ENetError result,
void * param,
const wchar addr[]
) {
NetCliGateKeeperDisconnect();
if (IS_NET_ERROR(result)) {
LogMsg(kLogDebug, L"FileSrvIpAddressRequest failed: %s", NetErrorToString(result));
s_patchResult = result;
s_downloadComplete = true;
}
// Start connecting to the server
NetCliFileStartConnect(&addr, 1, true);
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
PathDeleteFile(s_newPatcherFile);
NetCliFileManifestRequest(ManifestCallback, nil, s_manifest);
}
//============================================================================
static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
bool patched = false;
s_downloadComplete = false;
s_patchResult = kNetSuccess;
NetClientInitialize();
NetClientSetErrorHandler(NetErrorHandler);
const wchar ** addrs;
unsigned count;
count = GetGateKeeperSrvHostnames(&addrs);
// Start connecting to the server
NetCliGateKeeperStartConnect(addrs, count);
// request a file server ip address
NetCliGateKeeperFileSrvIpAddressRequest(FileSrvIpAddressCallback, nil, true);
while(!s_downloadComplete && !*abort) {
NetClientUpdate();
AsyncSleep(10);
}
NetCliFileDisconnect();
NetClientUpdate();
// Shutdown the client/server networking subsystem
NetClientDestroy();
if (s_downloadComplete && !*abort && s_updated && IS_NET_SUCCESS(s_patchResult)) {
// launch new patcher
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZERO(si);
ZERO(pi);
si.cb = sizeof(si);
wchar cmdline[MAX_PATH];
StrPrintf(cmdline, arrsize(cmdline), L"%s %s", s_newPatcherFile, info->cmdLine);
// we have only successfully patched if we actually launch the new version of the patcher
patched = CreateProcessW(
NULL,
cmdline,
NULL,
NULL,
FALSE,
DETACHED_PROCESS,
NULL,
NULL,
&si,
&pi
);
SetReturnCode(pi.dwProcessId);
CloseHandle( pi.hThread );
CloseHandle( pi.hProcess );
ASSERT(patched);
}
return patched;
}
/*****************************************************************************
*
* ProgressStream Functions
*
***/
//============================================================================
UInt32 SelfPatcherStream::Write(UInt32 byteCount, const void* buffer) {
progress += byteCount;
float p = (float)progress / (float)totalBytes * 100; // progress
SetProgress( (int)p );
return plZlibStream::Write(byteCount, buffer);
}
/*****************************************************************************
*
* Protected Functions
*
***/
//============================================================================
// if return value is true, there was an update and the patcher should be shutdown, so the new patcher can take over
bool SelfPatch (bool noSelfPatch, bool * abort, ENetError * result, plLauncherInfo *info) {
bool patched = false;
if (!noSelfPatch) {
SetText("Checking for patcher update...");
patched = SelfPatcherProc(abort, info);
}
*result = s_patchResult;
return patched;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

@ -1,87 +1,87 @@
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/plLauncherCallback.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/plLauncherCallback.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
enum EStatus {
kStatusOk,
kStatusError,
kStatusPending,
};
struct PatchInfo {
unsigned progress;
unsigned stage;
unsigned progressStage;
};
typedef void (*launcherCallback)(int status, void *param);
typedef void (*setTextCallback)(const char text[]);
typedef void (*setStatusTextCallback)(const char text[]);
typedef void (*setTimeRemainingCallback)(unsigned seconds);
typedef void (*setBytesRemainingCallback)(unsigned bytes);
struct plLauncherInfo {
wchar path[MAX_PATH];
wchar cmdLine[512];
unsigned buildId; // buildId override
launcherCallback prepCallback;
launcherCallback initCallback;
launcherCallback startCallback;
launcherCallback stopCallback;
launcherCallback terminateCallback;
launcherCallback progressCallback;
launcherCallback exitCallback;
setTextCallback SetText;
setStatusTextCallback SetStatusText;
setTimeRemainingCallback SetTimeRemaining;
setBytesRemainingCallback SetBytesRemaining;
PatchInfo patchInfo;
bool IsTGCider;
DWORD returnCode; // used so we can pass a new process id back to gametap. That way gametap wont think uru has exited when the patcher quits.
};
/*****************************************************************************
*
* Main.cpp
*
***/
void SetProgress (unsigned progress) ;
void SetText (const char text[]);
void SetStatusText (const char text[]);
void SetTimeRemaining(unsigned seconds);
/*==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==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plUruLauncher/plLauncherCallback.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plUruLauncher/plLauncherCallback.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLURULAUNCHER_PLLAUNCHERCALLBACK_H
enum EStatus {
kStatusOk,
kStatusError,
kStatusPending,
};
struct PatchInfo {
unsigned progress;
unsigned stage;
unsigned progressStage;
};
typedef void (*launcherCallback)(int status, void *param);
typedef void (*setTextCallback)(const char text[]);
typedef void (*setStatusTextCallback)(const char text[]);
typedef void (*setTimeRemainingCallback)(unsigned seconds);
typedef void (*setBytesRemainingCallback)(unsigned bytes);
struct plLauncherInfo {
wchar path[MAX_PATH];
wchar cmdLine[512];
unsigned buildId; // buildId override
launcherCallback prepCallback;
launcherCallback initCallback;
launcherCallback startCallback;
launcherCallback stopCallback;
launcherCallback terminateCallback;
launcherCallback progressCallback;
launcherCallback exitCallback;
setTextCallback SetText;
setStatusTextCallback SetStatusText;
setTimeRemainingCallback SetTimeRemaining;
setBytesRemainingCallback SetBytesRemaining;
PatchInfo patchInfo;
bool IsTGCider;
DWORD returnCode; // used so we can pass a new process id back to gametap. That way gametap wont think uru has exited when the patcher quits.
};
/*****************************************************************************
*
* Main.cpp
*
***/
void SetProgress (unsigned progress) ;
void SetText (const char text[]);
void SetStatusText (const char text[]);
void SetTimeRemaining(unsigned seconds);
void SetBytesRemaining(unsigned bytes);

View File

@ -1,125 +1,125 @@
// 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
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG DIALOGEX 0, 0, 301, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS |
DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL 109,IDB_BITMAP,"Static",SS_BITMAP | SS_SUNKEN,7,7,288,36
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER | 0x1,7,
162,234,11
LTEXT "Static",IDC_TEXT,10,152,266,8
PUSHBUTTON "Cancel",IDCANCEL,243,162,51,11
LTEXT "Welcome to URU",IDC_STATUS_TEXT,19,57,266,17
GROUPBOX "",IDC_STATIC,7,46,287,49
GROUPBOX "Status",IDC_STATIC,7,103,287,44
LTEXT "Approx. Time Remaining:",IDC_STATIC,19,117,88,11
LTEXT "Update Remaining:",IDC_STATIC,20,130,73,9
LTEXT "...",IDC_TIMEREMAINING,111,117,165,12
LTEXT "...",IDC_BYTESREMAINING,111,130,42,12
RTEXT "Product String",IDC_PRODUCTSTRING,19,85,272,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 294
TOPMARGIN, 7
BOTTOMMARGIN, 173
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP BITMAP "banner.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 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
#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
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//
IDD_DIALOG DIALOGEX 0, 0, 301, 180
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS |
DS_CENTER | WS_POPUP | WS_VISIBLE | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
CONTROL 109,IDB_BITMAP,"Static",SS_BITMAP | SS_SUNKEN,7,7,288,36
CONTROL "",IDC_PROGRESS,"msctls_progress32",WS_BORDER | 0x1,7,
162,234,11
LTEXT "Static",IDC_TEXT,10,152,266,8
PUSHBUTTON "Cancel",IDCANCEL,243,162,51,11
LTEXT "Welcome to URU",IDC_STATUS_TEXT,19,57,266,17
GROUPBOX "",IDC_STATIC,7,46,287,49
GROUPBOX "Status",IDC_STATIC,7,103,287,44
LTEXT "Approx. Time Remaining:",IDC_STATIC,19,117,88,11
LTEXT "Update Remaining:",IDC_STATIC,20,130,73,9
LTEXT "...",IDC_TIMEREMAINING,111,117,165,12
LTEXT "...",IDC_BYTESREMAINING,111,130,42,12
RTEXT "Product String",IDC_PRODUCTSTRING,19,85,272,8
END
/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO
BEGIN
IDD_DIALOG, DIALOG
BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 294
TOPMARGIN, 7
BOTTOMMARGIN, 173
END
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//
IDB_BITMAP BITMAP "banner.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "Dirt.ICO"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -1,25 +1,25 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plUruLauncher.rc
//
#define IDD_DIALOG 106
#define IDB_BITMAP 109
#define IDI_ICON1 111
#define IDC_PROGRESS 1003
#define IDC_TEXT 1006
#define IDC_STATUS_TEXT 1009
#define IDC_TIMEREMAINING 1010
#define IDC_BYTESREMAINING 1011
#define IDC_PRODUCTSTRING 1012
#define IDC_FILESREMAINING 1013
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 112
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by plUruLauncher.rc
//
#define IDD_DIALOG 106
#define IDB_BITMAP 109
#define IDI_ICON1 111
#define IDC_PROGRESS 1003
#define IDC_TEXT 1006
#define IDC_STATUS_TEXT 1009
#define IDC_TIMEREMAINING 1010
#define IDC_BYTESREMAINING 1011
#define IDC_PRODUCTSTRING 1012
#define IDC_FILESREMAINING 1013
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 112
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1014
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif