Skip to content

Commit c24829f

Browse files
committed
Update comments & add comments
1 parent 7f9ddb4 commit c24829f

File tree

4 files changed

+46
-49
lines changed

4 files changed

+46
-49
lines changed

MainForm.cs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public partial class MainForm : Form
6363
private bool manualIP;
6464
public MainForm()
6565
{
66-
// check for offline mode
66+
// Check for Offline Mode or No RCLONE Updating
6767
string[] args = Environment.GetCommandLineArgs();
6868
foreach (string arg in args)
6969
{
@@ -111,7 +111,7 @@ public MainForm()
111111
Properties.Settings.Default.SubmittedUpdates = String.Empty;
112112
Properties.Settings.Default.Save();
113113
}
114-
//Time for debuglog
114+
// Launch time used within debuglog.
115115
string launchtime = DateTime.Now.ToString("hh:mmtt(UTC)");
116116
_ = Logger.Log($"\n------\n------\nProgram Launched at: {launchtime}\n------\n------");
117117
if (string.IsNullOrEmpty(Properties.Settings.Default.CurrentLogPath))
@@ -1003,7 +1003,7 @@ private async void getApkButton_Click(object sender, EventArgs e)
10031003
string gameName = $"{GameName} v{VersionInt} {packageName} {HWID.Substring(0, 1)}";
10041004
string gameZipName = $"{gameName}.zip";
10051005

1006-
// delete the zip and txt if they exist from a previously failed upload
1006+
// Delete both zip & txt if the files exist, most likely due to a failed upload.
10071007
if (File.Exists($"{Properties.Settings.Default.MainDir}\\{gameZipName}"))
10081008
{
10091009
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
@@ -1078,15 +1078,15 @@ private async void getApkButton_Click(object sender, EventArgs e)
10781078
string currentlyUploading = GameName;
10791079
changeTitle("Uploading to server, you can continue to use Rookie while it uploads in the background.");
10801080

1081-
// get size of pending zip upload and write to text file
1081+
// Get size of pending zip upload and write to text file
10821082
long zipSize = new FileInfo($"{Properties.Settings.Default.MainDir}\\{gameZipName}").Length;
10831083
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\{gameName}.txt", zipSize.ToString());
1084-
// upload size file
1084+
// Upload size file.
10851085
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameName}.txt\" RSL-gameuploads:");
1086-
// upload zip
1086+
// Upload zip.
10871087
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameZipName}\" RSL-gameuploads:");
10881088

1089-
// deleting uploaded files
1089+
// Delete files once uploaded.
10901090
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameName}.txt");
10911091
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
10921092

@@ -1272,7 +1272,7 @@ private async void Form1_DragDrop(object sender, DragEventArgs e)
12721272
CurrAPK = file2;
12731273
System.Windows.Forms.Timer t3 = new System.Windows.Forms.Timer
12741274
{
1275-
Interval = 150000 // 180 seconds to fail
1275+
Interval = 150000 // 150 seconds to fail
12761276
};
12771277
t3.Tick += timer_Tick4;
12781278
t3.Start();
@@ -1621,8 +1621,8 @@ private async void initListView()
16211621
List<string> blacklistItems = blacklist.ToList();
16221622
List<string> whitelistItems = whitelist.ToList();
16231623
errorOnList = false;
1624-
//This is for black list, but temporarly will be whitelist
1625-
//this list has games that we are actually going to upload
1624+
//This is for the black list, but temporarily will be the whitelist
1625+
//This list contains games that we are actually going to upload
16261626
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
16271627
progressBar.Style = ProgressBarStyle.Marquee;
16281628
if (SideloaderRCLONE.games.Count > 5)
@@ -1915,7 +1915,7 @@ public static async void doUpload()
19151915
string gameName = $"{game.Uploadgamename} v{game.Uploadversion} {game.Pckgcommand} {SideloaderUtilities.UUID().Substring(0, 1)}";
19161916
string gameZipName = $"{gameName}.zip";
19171917

1918-
// delete the zip and txt if they exist from a previously failed upload
1918+
// Delete both zip & txt if the files exist, most likely due to a failed upload.
19191919
if (File.Exists($"{Properties.Settings.Default.MainDir}\\{gameZipName}"))
19201920
{
19211921
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
@@ -1933,12 +1933,12 @@ public static async void doUpload()
19331933
Directory.Delete($"{Properties.Settings.Default.MainDir}\\{game.Pckgcommand}", true);
19341934
Program.form.changeTitle("Uploading to server, you may continue to use Rookie while it uploads.");
19351935

1936-
// get size of pending zip upload and write to text file
1936+
// Get size of pending zip upload and write to text file
19371937
long zipSize = new FileInfo($"{Properties.Settings.Default.MainDir}\\{gameZipName}").Length;
19381938
File.WriteAllText($"{Properties.Settings.Default.MainDir}\\{gameName}.txt", zipSize.ToString());
1939-
// upload size file
1939+
// Upload size file.
19401940
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameName}.txt\" RSL-gameuploads:");
1941-
// upload zip
1941+
// Upload zip.
19421942
_ = RCLONE.runRcloneCommand_UploadConfig($"copy \"{Properties.Settings.Default.MainDir}\\{gameZipName}\" RSL-gameuploads:");
19431943

19441944
if (game.isUpdate)
@@ -1947,7 +1947,7 @@ public static async void doUpload()
19471947
Properties.Settings.Default.Save();
19481948
}
19491949

1950-
// deleting uploaded files
1950+
// Delete files once uploaded.
19511951
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameName}.txt");
19521952
File.Delete($"{Properties.Settings.Default.MainDir}\\{gameZipName}");
19531953

@@ -2085,7 +2085,7 @@ private void initMirrors(bool random)
20852085

20862086
remotesList.Invoke(() =>
20872087
{
2088-
remotesList.SelectedIndex = 0; //set mirror to first
2088+
remotesList.SelectedIndex = 0; // Set mirror to first item in array.
20892089
currentRemote = "VRP-mirror" + remotesList.SelectedItem.ToString();
20902090
});
20912091

@@ -2490,7 +2490,7 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
24902490
changeTitle("Downloading game " + gameName, false);
24912491

24922492
int i = 0;
2493-
//Download
2493+
// Begin download.
24942494
while (t1.IsAlive)
24952495
{
24962496
try
@@ -2569,7 +2569,7 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
25692569
break;
25702570
}
25712571
{
2572-
//Quota Errors
2572+
// Handle quota errors.
25732573
bool isinstalltxt = false;
25742574
bool quotaError = false;
25752575
bool otherError = false;
@@ -2589,7 +2589,7 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
25892589
{
25902590
otherError = true;
25912591

2592-
//Remove current game
2592+
// Remove current game off queue.
25932593
cleanupActiveDownloadStatus();
25942594

25952595
_ = FlexibleMessageBox.Show($"Rclone error: {gameDownloadOutput.Error}");
@@ -2720,6 +2720,7 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
27202720
{
27212721
if (!Properties.Settings.Default.nodevicemode | !nodeviceonstart & DeviceConnected)
27222722
{
2723+
// Attempt to delete OBB Folder before pushing.
27232724
deleteOBB(packagename);
27242725
Thread obbThread = new Thread(() =>
27252726
{
@@ -2742,6 +2743,7 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
27422743
{
27432744
try
27442745
{
2746+
// Check if OBB was properly pushed with a size comparison.
27452747
obbsMismatch = await compareOBBSizes(packagename, gameName, output);
27462748
}
27472749
catch (Exception ex) { _ = FlexibleMessageBox.Show($"Error comparing OBB sizes: {ex.Message}"); }
@@ -2764,7 +2766,7 @@ public async void downloadInstallGameButton_Click(object sender, EventArgs e)
27642766
try { Directory.Delete(Properties.Settings.Default.downloadDir + "\\" + gameName, true); } catch (Exception ex) { _ = FlexibleMessageBox.Show($"Error deleting game files: {ex.Message}"); }
27652767
}
27662768

2767-
//Remove current game
2769+
// Remove current game off queue.
27682770
cleanupActiveDownloadStatus();
27692771
}
27702772
}
@@ -2809,6 +2811,7 @@ private void deleteOBB(string packagename)
28092811

28102812
private const string OBBFolderPath = "/sdcard/Android/obb/";
28112813

2814+
// Logic to compare OBB folders.
28122815
private async Task<bool> compareOBBSizes(string packageName, string gameName, ProcessOutput output)
28132816
{
28142817
string localFolderPath = Path.Combine(Properties.Settings.Default.downloadDir, gameName, packageName);
@@ -2864,6 +2867,7 @@ private string cleanRemoteFolderSize(string rawSize)
28642867
return Regex.Replace(replaced, "[^0-9]", "");
28652868
}
28662869

2870+
// Logic to handle mismatches after comparison.
28672871
private async Task<bool> handleObbSizeMismatchAsync(string packageName, string gameName, ProcessOutput output)
28682872
{
28692873
var dialogResult = MessageBox.Show("Warning! It seems like the OBB wasn't pushed correctly, this means that the game may not launch correctly.\n Do you want to retry the push?", "OBB Size Mismatch!", MessageBoxButtons.YesNo);
@@ -3181,7 +3185,7 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
31813185
{
31823186
if (keyData == (Keys.Control | Keys.F))
31833187
{
3184-
//show search
3188+
// Show search box.
31853189
searchTextBox.Clear();
31863190
searchTextBox.Visible = true;
31873191
label2.Visible = true;
@@ -3235,11 +3239,8 @@ protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
32353239
{
32363240
try
32373241
{
3238-
//run the program again and close this one
3242+
// Relaunch the program using Sideloader Launcher
32393243
_ = Process.Start(Application.StartupPath + "\\Sideloader Launcher.exe");
3240-
//or you can use Application.ExecutablePath
3241-
3242-
//close this one
32433244
Process.GetCurrentProcess().Kill();
32443245
}
32453246
catch
@@ -3704,8 +3705,6 @@ private async void updateAvailable_Click(object sender, EventArgs e)
37043705
List<string> blacklistItems = blacklist.ToList();
37053706
List<string> whitelistItems = whitelist.ToList();
37063707
errorOnList = false;
3707-
//This is for black list, but temporarly will be whitelist
3708-
//this list has games that we are actually going to upload
37093708
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
37103709
progressBar.Style = ProgressBarStyle.Marquee;
37113710
if (SideloaderRCLONE.games.Count > 5)
@@ -4041,8 +4040,6 @@ private async void lblUpToDate_Click(object sender, EventArgs e)
40414040
List<string> blacklistItems = blacklist.ToList();
40424041
List<string> whitelistItems = whitelist.ToList();
40434042
errorOnList = false;
4044-
//This is for black list, but temporarly will be whitelist
4045-
//this list has games that we are actually going to upload
40464043
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
40474044
progressBar.Style = ProgressBarStyle.Marquee;
40484045
if (SideloaderRCLONE.games.Count > 5)
@@ -4176,8 +4173,6 @@ private async void lblNeedsDonate_Click(object sender, EventArgs e)
41764173
List<string> blacklistItems = blacklist.ToList();
41774174
List<string> whitelistItems = whitelist.ToList();
41784175
errorOnList = false;
4179-
//This is for black list, but temporarly will be whitelist
4180-
//this list has games that we are actually going to upload
41814176
newGamesToUploadList = whitelistItems.Intersect(installedGames).ToList();
41824177
progressBar.Style = ProgressBarStyle.Marquee;
41834178
if (SideloaderRCLONE.games.Count > 5)

Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ private static void Main()
2828

2929
private static void CrashHandler(object sender, UnhandledExceptionEventArgs args)
3030
{
31+
// Capture unhandled exceptions and write to file.
3132
Exception e = (Exception)args.ExceptionObject;
3233
string date_time = DateTime.Now.ToString("dddd, MMMM dd @ hh:mmtt (UTC)");
3334
File.WriteAllText(Sideloader.CrashLogPath, $"Date/Time of crash: {date_time}\nMessage: {e.Message}\nData: {e.Data}\nSource: {e.Source}\nTargetSite: {e.TargetSite}\nStack Trace: \n{e.StackTrace}\n\n\nDebuglog: \n\n\n");
35+
// If a debuglog exists we append it to the crashlog.
3436
if (File.Exists(Properties.Settings.Default.CurrentLogPath))
3537
{
3638
File.AppendAllText(Sideloader.CrashLogPath, File.ReadAllText($"{Properties.Settings.Default.CurrentLogPath}"));

0 commit comments

Comments
 (0)