1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Closes #182 -- dpogue/kill_utils

Conflicts:
	Sources/Plasma/Apps/plClient/winmain.cpp
This commit is contained in:
2012-04-14 19:34:07 -04:00
96 changed files with 890 additions and 5687 deletions

View File

@ -121,7 +121,7 @@ bool gPendingActivate = false;
bool gPendingActivateFlag = false;
static bool s_loginDlgRunning = false;
static CEvent s_statusEvent(kEventManualReset);
static hsSemaphore s_statusEvent(0); // Start non-signalled
static UINT s_WmTaskbarList = RegisterWindowMessage("TaskbarButtonCreated");
FILE *errFP = nil;
@ -1129,7 +1129,7 @@ void StatusCallback(void *param)
{
HWND hwnd = (HWND)param;
char *statusUrl = hsWStringToString(GetServerStatusUrl());
const char *statusUrl = GetServerStatusUrl();
CURL *hCurl = curl_easy_init();
// For reporting errors
@ -1153,9 +1153,8 @@ void StatusCallback(void *param)
}
curl_easy_cleanup(hCurl);
delete [] statusUrl;
s_statusEvent.Signal();
s_statusEvent.Signal(); // Signal the semaphore
}
BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
@ -1211,7 +1210,7 @@ BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
case WM_DESTROY:
{
s_loginDlgRunning = false;
s_statusEvent.Wait(kEventWaitForever);
s_statusEvent.Wait();
KillTimer(hwndDlg, AUTH_LOGIN_TIMER);
return TRUE;
}
@ -1283,8 +1282,8 @@ BOOL CALLBACK UruLoginDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM
}
else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_URULOGIN_GAMETAPLINK)
{
const wchar_t *signupurl = GetServerSignupUrl();
ShellExecuteW(NULL, L"open", signupurl, NULL, NULL, SW_SHOWNORMAL);
const char* signupurl = GetServerSignupUrl();
ShellExecuteA(NULL, "open", signupurl, NULL, NULL, SW_SHOWNORMAL);
return TRUE;
}
@ -1490,25 +1489,27 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));
si.cb = sizeof(si);
wchar_t cmdLine[MAX_PATH];
const wchar_t ** addrs;
plStringStream cmdLine;
const char** addrs;
if (!eventExists) // if it is missing, assume patcher wasn't launched
{
StrCopy(cmdLine, s_patcherExeName, arrsize(cmdLine));
cmdLine << _TEMP_CONVERT_FROM_WCHAR_T(s_patcherExeName);
GetAuthSrvHostnames(&addrs);
if(wcslen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /AuthSrv=%ws", cmdLine, addrs[0]);
if(strlen(addrs[0]))
cmdLine << plString::Format(" /AuthSrv=%s", addrs[0]);
GetFileSrvHostnames(&addrs);
if(wcslen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /FileSrv=%ws", cmdLine, addrs[0]);
if(strlen(addrs[0]))
cmdLine << plString::Format(" /FileSrv=%s", addrs[0]);
GetGateKeeperSrvHostnames(&addrs);
if(wcslen(addrs[0]))
StrPrintf(cmdLine, arrsize(cmdLine), L"%ws /GateKeeperSrv=%ws", cmdLine, addrs[0]);
if(strlen(addrs[0]))
cmdLine << plString::Format(" /GateKeeperSrv=%s", addrs[0]);
if(!CreateProcessW(NULL, cmdLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
if(!CreateProcessW(NULL, (LPWSTR)cmdLine.GetString().ToUtf16().GetData(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
hsMessageBox("Failed to launch patcher", "Error", hsMessageBoxNormal);
}

View File

@ -47,6 +47,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h"
#include "plStatusLog/plStatusLog.h"
#include <queue>
#pragma hdrstop
@ -67,7 +68,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct ManifestFile
{
LINK(ManifestFile) link;
ManifestFile(const wchar_t clientName[], const wchar_t downloadName[], const wchar_t md5val[], int flags, plLauncherInfo *info)
{
StrCopy(filename, clientName, arrsize(filename));
@ -113,7 +113,7 @@ struct ManifestResult {
long * indicator;
plLauncherInfo * info;
CCritSect critsect;
hsMutex critsect;
ARRAY(unsigned) indices;
};
@ -142,13 +142,12 @@ static unsigned s_fileListRequests;
static bool s_patchComplete;
static PROCESS_INFORMATION s_pi;
static long s_numFiles;
static CCritSect s_critsect;
static char s_workingDir[MAX_PATH];
static bool s_patchError;
static long s_asyncCoreInitCount;
static long s_numConnectFailures;
static bool s_running;
static LISTDECL(ManifestFile, link) s_manifestQueue;
static std::queue<ManifestFile*> manifestQueue;
//static AsyncThreadTaskList * s_taskList;
// error strings
@ -347,10 +346,13 @@ void Shutdown(plLauncherInfo *info) {
//============================================================================
static void RequestNextManifestFile () {
bool success = true;
ManifestFile *nextfile = s_manifestQueue.Head();
if(!nextfile)
if (!manifestQueue.size())
return;
s_manifestQueue.Unlink(nextfile);
ManifestFile* nextfile = manifestQueue.front();
manifestQueue.pop();
char path[MAX_PATH];
wchar_t basePath[MAX_PATH];
StrPrintf(path, arrsize(path), "%s%S", s_workingDir, nextfile->filename);
@ -496,9 +498,9 @@ static void ProcessManifestEntry (void * param, ENetError error) {
);
uint32_t start = (uint32_t)(TimeGetTime() / kTimeIntervalsPerMs);
if(!MD5Check(path, p->mr->manifest[p->index].md5)) {
p->mr->critsect.Enter();
p->mr->critsect.Lock();
p->mr->indices.Add(p->index);
p->mr->critsect.Leave();
p->mr->critsect.Unlock();
AtomicAdd(&ProgressStream::totalBytes, p->mr->manifest[p->index].zipSize);
}
@ -614,14 +616,14 @@ static void ProcessManifest (void * param) {
PathRemoveFilename(basePath, basePath, arrsize(basePath));
PathCreateDirectory(basePath, kPathCreateDirFlagEntireTree);
ManifestFile * mf = new ManifestFile(
ManifestFile* mf = new ManifestFile(
manifest[index].clientName,
manifest[index].downloadName,
manifest[index].md5,
manifest[index].flags,
mr->info
);
if (i < kMaxManifestFileRequests) {
ProgressStream * stream;
stream = NEWZERO(ProgressStream);
@ -645,7 +647,7 @@ static void ProcessManifest (void * param) {
}
else {
// queue up this file download
s_manifestQueue.Link(mf);
manifestQueue.push(mf);
}
}
}
@ -838,7 +840,9 @@ static void FileSrvIpAddressCallback (
plLauncherInfo *info = (plLauncherInfo *) param;
// Start connecting to the server
NetCliFileStartConnect(&addr, 1, true);
const char* caddr = hsWStringToString(addr);
NetCliFileStartConnect(&caddr, 1, true);
delete[] caddr;
NetCliFileManifestRequest(ThinManifestCallback, info, s_thinmanifest, info->buildId);
@ -900,7 +904,7 @@ void UruPrepProc (void * param) {
s_patchComplete = false;
s_patchError = false;
const wchar_t ** addrs;
const char** addrs;
unsigned count;
count = GetGateKeeperSrvHostnames(&addrs);
@ -916,8 +920,10 @@ void UruPrepProc (void * param) {
AsyncSleep(10);
} while ((!s_patchComplete && !s_patchError && s_running) || s_perf[kPerfThreadTaskCount]);
while(ManifestFile *mf = s_manifestQueue.Head())
while (manifestQueue.size())
{
ManifestFile* mf = manifestQueue.front();
manifestQueue.pop();
delete mf;
}
// If s_patchError, we don't wait around for s_numFiles

View File

@ -46,6 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
***/
#include "Pch.h"
#include "hsThread.h"
#pragma hdrstop
@ -147,12 +148,12 @@ static HANDLE s_thread;
static HANDLE s_event;
static HINSTANCE s_hInstance;
static HWND s_dialog;
static CEvent s_dialogCreateEvent(kEventManualReset);
static CCritSect s_critsect;
static hsSemaphore s_dialogCreateEvent(0);
static hsMutex s_critsect;
static LISTDECL(WndEvent, link) s_eventQ;
static CEvent s_shutdownEvent(kEventManualReset);
static hsSemaphore s_shutdownEvent(0);
static wchar_t s_workingDir[MAX_PATH];
static CEvent s_statusEvent(kEventManualReset);
static hsSemaphore s_statusEvent(0);
static char s_curlError[CURL_ERROR_SIZE];
@ -196,9 +197,9 @@ static void Abort () {
//============================================================================
static void PostEvent (WndEvent *event) {
s_critsect.Enter();
s_critsect.Lock();
s_eventQ.Link(event);
s_critsect.Leave();
s_critsect.Unlock();
}
//============================================================================
@ -393,11 +394,11 @@ static void Recv_SetBytesRemaining (HWND hwnd, const SetBytesRemainingEvent &eve
static void DispatchEvents (HWND hwnd) {
LISTDECL(WndEvent, link) eventQ;
s_critsect.Enter();
s_critsect.Lock();
{
eventQ.Link(&s_eventQ);
}
s_critsect.Leave();
s_critsect.Unlock();
#define DISPATCH(a) case kEvent##a: Recv_##a(hwnd, *(const a##Event *) event); break
while (WndEvent *event = eventQ.Head()) {
@ -608,7 +609,7 @@ static size_t CurlCallback(void *buffer, size_t size, size_t nmemb, void *)
//============================================================================
static void StatusCallback(void *)
{
char *serverUrl = hsWStringToString(GetServerStatusUrl());
const char *serverUrl = GetServerStatusUrl();
CURL * hCurl = curl_easy_init();
curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, s_curlError);
@ -630,7 +631,6 @@ static void StatusCallback(void *)
}
curl_easy_cleanup(hCurl);
delete [] serverUrl;
s_statusEvent.Signal();
}
@ -810,7 +810,7 @@ int __stdcall WinMain (
s_launcherInfo.buildId = cmdParser.GetInt(kArgBuildId);
// Wait for the dialog to be created
s_dialogCreateEvent.Wait(kEventWaitForever);
s_dialogCreateEvent.Wait();
_beginthread(StatusCallback, 0, nil); // get status
}
@ -950,10 +950,10 @@ int __stdcall WinMain (
}
ShutdownAsyncCore();
s_statusEvent.Wait(kEventWaitForever);
s_statusEvent.Wait();
PostMessage(s_dialog, WM_QUIT, 0, 0); // tell our window to shutdown
s_shutdownEvent.Wait(kEventWaitForever); // wait for our window to shutdown
s_shutdownEvent.Wait(); // wait for our window to shutdown
SetConsoleCtrlHandler(CtrlHandler, FALSE);

View File

@ -226,7 +226,9 @@ static void FileSrvIpAddressCallback (
}
// Start connecting to the server
NetCliFileStartConnect(&addr, 1, true);
const char* caddr = hsWStringToString(addr);
NetCliFileStartConnect(&caddr, 1, true);
delete[] caddr;
PathGetProgramDirectory(s_newPatcherFile, arrsize(s_newPatcherFile));
GetTempFileNameW(s_newPatcherFile, kPatcherExeFilename, 0, s_newPatcherFile);
@ -245,7 +247,7 @@ static bool SelfPatcherProc (bool * abort, plLauncherInfo *info) {
NetClientInitialize();
NetClientSetErrorHandler(NetErrorHandler);
const wchar_t ** addrs;
const char** addrs;
unsigned count;
count = GetGateKeeperSrvHostnames(&addrs);