my launcher crashed it might be becuse of a file i may have deleted not sure. help?

Comment below rating threshold, click here to show it.

durfys

Junior Member

04-26-2011

{
this.statusCallback = null;
this.downloaderStatusCallback = null;
this.patcherErrorCallback = null;
this.launcherErrorCallback = null;
this.getSettingsCallback = null;
this.isErrorMessageOpen = false;
this.startTime = new Date().getTime();

this.version = 4;
this.LAUNCHERMODELSTATE_INVALID = 0;
this.LAUNCHERMODELSTATE_INITIALIZE = 1;
this.LAUNCHERMODELSTATE_UPDATE_WAIT = 2;
this.LAUNCHERMODELSTATE_UPDATE = 3;
this.LAUNCHERMODELSTATE_UPDATE_COMPLETE = 4;
this.LAUNCHERMODELSTATE_MAESTRO = 6;
this.LAUNCHERMODELSTATE_FAILURE = 5;

this.PATCHER_STATE_INVALID = 0;
this.PATCHER_STATE_IDLE = 1;
this.PATCHER_STATE_PREPARE = 2;
this.PATCHER_STATE_DOWNLOAD = 3;
this.PATCHER_STATE_WAITFORLIVE = 4;
this.PATCHER_STATE_PREPROCESS = 5;
this.PATCHER_STATE_ALLOWRESTART = 6;
this.PATCHER_STATE_PERFORMRESTART = 7;
this.PATCHER_STATE_PROCESS = 8;
this.PATCHER_STATE_POSTPROCESS = 9;
this.PATCHER_STATE_SAVE = 10;
this.PATCHER_STATE_TASKCOMPLETE = 11;
this.PATCHER_STATE_ALLTASKSCOMPLETE = 12;
this.PATCHER_STATE_FAILED = 13;

this.PATCHER_ERROR_COPY = 0;
this.PATCHER_ERROR_RETRIEVEPACKAGE = 1;
this.PATCHER_ERROR_DATAFORMAT = 2;
this.PATCHER_ERROR_DOWNLOAD = 3;
this.PATCHER_ERROR_DRM_CONTACT = 4;
this.PATCHER_ERROR_DRM_AUTH = 5;
this.PATCHER_ERROR_DRM_PERMISSION = 6;
this.PATCHER_ERROR_PROCESSLAUNCH = 7;
this.PATCHER_ERROR_COPY_DIFFSOURCEVERIFY = 8;
this.PATCHER_ERROR_INVALID = 9;

this.LAUNCHERERRORTYPE_SUCCESS = 0;
this.LAUNCHERERRORTYPE_PROCCESSLAUNCH = 1;
this.LAUNCHERERRORTYPE_PROCCESSLAUNCHEXITFAIL = 2;
this.LAUNCHERERRORTYPE_PROCCESSLAUNCHTIMEOUT = 3;
this.LAUNCHERERRORTYPE_ELEVATIONFAIL = 4;
this.LAUNCHERERRORTYPE_ELEVATECOMFAIL = 5;
this.LAUNCHERERRORTYPE_WARN_ELEVATIONREQUEST = 6;
this.LAUNCHERERRORTYPE_WARN_CUSTOM = 7;
this.LAUNCHERERRORTYPE_VERSIONFAIL = 8
this.LAUNCHERERRORTYPE_INVALID = 9;

this.isNaB = function(value) { return typeof(value) != 'boolean' };
}

_Launcher.prototype = {

setStatusCallback: function(callback)
{
this.statusCallback = callback;
},

setDownloaderStatusCallback: function(callback)
{
this.downloaderStatusCallback = callback;
},

setPatcherErrorCallback: function(callback)
{
this.patcherErrorCallback = callback;
},

defaultPatcherErrorHandler: function(error, time, message)
{
if (!this.isErrorMessageOpen)
{
isErrorMessageOpen = true;

if (error == this.PATCHER_ERROR_DRM_CONTACT || error == this.PATCHER_ERROR_RETRIEVEPACKAGE || error == this.PATCHER_ERROR_DOWNLOAD)
{
// warn but don't raise error ui
isErrorMessageOpen = false;
}
else if (error == this.PATCHER_ERROR_COPY || error == this.PATCHER_ERROR_DATAFORMAT || error == this.PATCHER_ERROR_COPY_DIFFSOURCEVERIFY)
{
alert(LauncherLanguage.ErrorRestart);
}
else if (error == this.PATCHER_ERROR_DRM_AUTH || error == this.PATCHER_ERROR_DRM_PERMISSION)
{
alert(LauncherLanguage.ErrorAuthorization);
}
else
{
alert(LauncherLanguage.ErrorReinstall);
}
}
},

setLauncherErrorCallback: function(callback)
{
this.launcherErrorCallback = callback;
},

defaultLauncherErrorHandler: function(error, message)
{
if (!this.isErrorMessageOpen)
{
isErrorMessageOpen = true;

if (error == this.LAUNCHERERRORTYPE_WARN_ELEVATIONREQUEST)
{
// the os already warns, so this is redundant
isErrorMessageOpen = true;
}
else
{
alert(LauncherLanguage.ErrorRestart);
}
}
},

setGetSettingsCallback: function(callback)
{
this.getSettingsCallback = callback;
},

doEvent: function(eventName)
{
location.href = 'event:|' + eventName;
},

play: function()
{
this.playWithParameters('');
},

playWithParameters: function(arguments)
{
this.doEvent('play||' + arguments);
},

launchProcess: function(processName, showWindow)
{
this.doEvent('launchProcess||' + 'string:' + processName + '|' + 'bool:' + showWindow);
},

pauseDownload: function()
{
this.doEvent('pause||');
},

beginMoveWindow: function()
{
this.doEvent('beginmovewindow||');
},

minimize: function()
{
this.doEvent('minimize||');
},

close: function()
{
this.doEvent('close||');
},

navigate: function(url, useExternalBrowser)
{
this.doEvent('navigate||' + 'string:' + url + '|' + 'bool:' + useExternalBrowser);
},

setSettings: function(enableP2P, rateLimit, maxUploadRate, maxDownloadRate)
{
if (this.isNaB(enableP2P))
{
throw 'enableP2P must be a boolean value.';
}

if (this.isNaB(rateLimit))
{
throw 'rateLimit must be a boolean value.';
}

if (isNaN(maxUploadRate))
{
throw 'maxUploadRate must be numeric.';
}

if (isNaN(maxDownloadRate))
{
throw 'maxDownloadRate must be numeric.';
}

this.doEvent('setSettings||' + 'bool:' + enableP2P + '|' + 'bool:' + rateLimit + '|' + 'numeric:' + maxUploadRate + '|' + 'numeric:' + maxDownloadRate);

},

getSettings: function()
{
this.doEvent('getSettings||');
},

requestStatus: function()
{
this.doEvent('getStatus||');
},

eulaAccepted: function()
{
this.doEvent('eulaAccepted||');
},

openLogPage: function()
{
this.doEvent('openLogPage||');
},

getCompletePercentage: function(packageListState, patcherState, totalBytes, copyBytesLeft, copyBytesTotal, downloadBytesLeft, scanBytesLeft)
{
if (packageListState == this.LAUNCHERMODELSTATE_UPDATE_COMPLETE)
{
return 1;
}

if (packageListState == this.LAUNCHERMODELSTATE_UPDATE)
{
if (patcherState == this.PATCHER_STATE_PROCESS)
{
if (copyBytesLeft == 0)
{
return 0;
}

return ((copyBytesTotal - copyBytesLeft) / copyBytesTotal).toFixed(2);
}
else if (patcherState == this.PATCHER_STATE_POSTPROCESS)
{
return 1;
}
else
{
if ((totalBytes == 0) && (downloadBytesLeft == 0) && (scanBytesLeft == 0))
{
return 0;
}

if (totalBytes <= 0)
{
return 1;
}

if (patcherState == this.PATCHER_STATE_PREPARE)
{
return ((totalBytes - scanBytesLeft) / totalBytes).toFixed(2);
}
else
{
return ((totalBytes - downloadBytesLeft) / totalBytes).toFixed(2);
}
}
}

return 0;
},

getStatusMessage: function(packageListState, active, packageName, currentName, targetName)
{

if (active == false)
{
return '';
}

if (packageListState == this.LAUNCHERMODELSTATE_UPDATE)
{
var message = LauncherLanguage.Updating + ' [' + packageName + ']';

if (currentName != '' && targetName != '')
{
message += ' ' + currentName + '/' + targetName;
}

return message;
}
return '';
},

getDetailStatusMessage: function(packageListState, active, patcherState, totalBytes, copyBytesLeft, copyBytesTotal, downloadBytesLeft, scanBytesLeft, bytesRead, averageIncoming)
{
if (active == false)
{
return LauncherLanguage.Paused;
}

if (packageListState == this.LAUNCHERMODELSTATE_INITIALIZE)
{
return LauncherLanguage.Retrieving;
}

if (packageListState == this.LAUNCHERMODELSTATE_UPDATE_COMPLETE)
{
RecordError("3/12/2010", "Launcher Succeeded", averageIncoming, totalBytes);
return LauncherLanguage.AllComplete;
}

if (packageListState == this.LAUNCHERMODELSTATE_INVALID || packageListState == this.LAUNCHERMODELSTATE_FAILURE)
{
return LauncherLanguage.ErrorConnect;
}

if (packageListState == this.LAUNCHERMODELSTATE_UPDATE)
{
var percent = this.getCompletePercentage(packageListState, patcherState, totalBytes, copyBytesLeft, copyBytesTotal, downloadBytesLeft, scanBytesLeft);
percent = (percent * 100).toFixed(0);

if (patcherState == this.PATCHER_STATE_PREPARE)
{
return LauncherLanguage.Prepare + ' (' + percent + '% ' + LauncherLanguage.Complete + ')';
}
else if (patcherState == this.PATCHER_STATE_DOWNLOAD)
{
return LauncherLanguage.Download + ' (' + percent + '% ' + LauncherLanguage.Complete + ')';
}
else if (patcherState == this.PATCHER_STATE_PROCESS)
{
return LauncherLanguage.Copying + ' (' + percent + '% ' + LauncherLanguage.Complete + ')';
}
else if (patcherState == this.PATCHER_STATE_POSTPROCESS)
{
return LauncherLanguage.Installing;
}
else if (patcherState == this.PATCHER_STATE_ALLTASKSCOMPLETE)
{
return LauncherLanguage.Finished;
}
}

return '';
},

getBytesLeftMessage: function(packageListState, active, patcherState, downloadBytesLeft)
{
if (active == false || packageListState != this.LAUNCHERMODELSTATE_UPDATE || patcherState != this.PATCHER_STATE_DOWNLOAD)
{
return '';
}

return (downloadBytesLeft / (1024 * 1024)).toFixed(2) + ' ' + LauncherLanguage.BytesLeft;
},

getTimeEstimateMessage: function(packageListState, active, patcherState, downloadBytesLeft, bytesRead, averageIncoming)
{
if (active == false || packageListState != this.LAUNCHERMODELSTATE_UPDATE || patcherState != this.PATCHER_STATE_DOWNLOAD)
{
return '';
}

var oneSecond = 1;
var oneMinute = oneSecond * 60;
var oneHour = oneMinute * 60;
var oneDay = oneHour * 24;

var elapsedSeconds = new Date().getTime() - this.startTime;
elapsedSeconds /= 1000;

if (elapsedSeconds == 0)
{
return '';
}

if ((elapsedSeconds <= 30) || (downloadBytesLeft < (1 << 20)))
{
return LauncherLanguage.EstimatingTime;
}

var startingThroughput = bytesRead / elapsedSeconds;
var estimatedSeconds = (downloadBytesLeft / ((startingThroughput * 0.90) + (averageIncoming * 0.10)));

if (estimatedSeconds == Infinity)
{
estimatedSeconds = 0;
}

if (estimatedSeconds < oneMinute)
{
return LauncherLanguage.ShortTimeLeft;
}

if (estimatedSeconds > 7 * oneDay)
{
return LauncherLanguage.LongTimeLeft;
}

var timeEstimateString = '';

var days = (estimatedSeconds / oneDay).toString().split('.')[0];
estimatedSeconds -= days * oneDay;
if (days > 0)
{
timeEstimateString += ' ' + days + LauncherLanguage.DayAbbreviation;
}

var hours = (estimatedSeconds / oneHour).toString().split('.')[0];
estimatedSeconds -= hours * oneHour;
if (hours > 0)
{
timeEstimateString += ' ' + hours + LauncherLanguage.HourAbbreviation;
}

var minutes = (estimatedSeconds / oneMinute).toString().split('.')[0];
estimatedSeconds -= minutes * oneMinute;
if (minutes > 0)
{
timeEstimateString += ' ' + minutes + LauncherLanguage.MinuteAbbreviation;
}

return timeEstimateString + ' ' + LauncherLanguage.Left;
},

getTransferSpeedMessage: function(packageListState, active, patcherState, averageIncoming)
{
if (active == false || packageListState != this.LAUNCHERMODELSTATE_UPDATE || patcherState != this.PATCHER_STATE_DOWNLOAD)
{
return '';
}

if (averageIncoming / 1024 <= 0.1)
{
return '';
}

return (averageIncoming / 1024).toFixed(0) + ' ' + LauncherLanguage.Speed;
}
}

var Launcher = new _Launcher();
Launcher.setPatcherErrorCallback(Launcher.defaultP atcherErrorHandler);
Launcher.setLauncherErrorCallback(Launcher.default LauncherErrorHandler);

function __launcher_getVersion()
{
return Launcher.version;
}

function __launcher_reportStatus(packageName, packageListState, active, averageIncoming, bytesRead, bytesSent, copyBytesLeft, copyBytesTotal, currentIncoming, currentName, currentVersion, downloadBytesLeft, maxIncoming, packageType, patcherState, scanBytesLeft, targetName, targetVersion, totalBytes)
{
if (Launcher.statusCallback != null)
{
Launcher.statusCallback(packageName, packageListState, active, averageIncoming, bytesRead, bytesSent, copyBytesLeft, copyBytesTotal, currentIncoming, currentName, currentVersion, downloadBytesLeft, maxIncoming, packageType, patcherState, scanBytesLeft, targetName, targetVersion, totalBytes);
}
}

function __launcher_reportDownloadStatus(packageName, packageListState, active, averageIncoming, bytesRead, bytesSent, copyBytesLeft, copyBytesTotal, currentIncoming, currentName, currentVersion, downloadBytesLeft, maxIncoming, packageType, patcherState, scanBytesLeft, targetName, targetVersion, totalBytes)
{
if (Launcher.downloaderStatusCallback != null)
{
Launcher.downloaderStatusCallback(packageName, packageListState, active, averageIncoming, bytesRead, bytesSent, copyBytesLeft, copyBytesTotal, currentIncoming, currentName, currentVersion, downloadBytesLeft, maxIncoming, packageType, patcherState, scanBytesLeft, targetName, targetVersion, totalBytes);
}
}

function RecordError(myTime, myMessage, averageIncoming, totalBytes)
{
var endTime = new Date().getTime();
var strMessage = "http://m.leagueoflegends.com/patcher/log/vote.php?strError=" + myMessage + "&averageIncoming=" + averageIncoming + "&totalBytes=" + totalBytes + "&startTime=" + Launcher.startTime + "&endTime=" + endTime;
parent.postdata.location.href = strMessage;
}

function __launcher_reportPatcherError(error, time, message)
{
if (Launcher.patcherErrorCallback != null)
{
RecordError(time, message, 0, 0);
Launcher.patcherErrorCallback(error, time, message);
}
}

function __launcher_reportLauncherError(error, message)
{
if (Launcher.launcherErrorCallback != null)
{
RecordError(time, message, 0, 0);
Launcher.launcherErrorCallback(error, message);
}
}

function __launcher_getSettings(enableP2P, rateLimit, maxUploadRate, maxDownloadRate)
{
if (Launcher.getSettingsCallback != null)
{
Launcher.getSettingsCallback(enableP2P, rateLimit, maxUploadRate, maxDownloadRate);
}


Comment below rating threshold, click here to show it.

NotMontag

Junior Member

04-26-2011

That code is beautiful, but we really need more of a description of the problem with some more context to be able to help out. Got anything for us?