Skip to content

Commit 30ca034

Browse files
committed
ensure target rate is unsigned everywhere
1 parent ae7bbe4 commit 30ca034

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

FlashpointSecurePlayer/OldCPUSimulator.cs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void Activate(string templateName, ref ProcessStartInfo softwareProcessSt
7979

8080
// sigh... okay
8181
// first, we check the target rate
82-
if (!int.TryParse(Environment.ExpandEnvironmentVariables(oldCPUSimulatorElement.TargetRate), out int targetRate)) {
82+
if (!ulong.TryParse(Environment.ExpandEnvironmentVariables(oldCPUSimulatorElement.TargetRate), out ulong targetRate)) {
8383
throw new InvalidOldCPUSimulatorException("The Target Rate is required.");
8484
}
8585

@@ -90,8 +90,6 @@ public void Activate(string templateName, ref ProcessStartInfo softwareProcessSt
9090

9191
// next... we need to check if the CPU speed is actually faster than
9292
// what we want to underclock to
93-
long maxRate = 0;
94-
9593
ProcessStartInfo oldCPUSimulatorProcessStartInfo = new ProcessStartInfo(OLD_CPU_SIMULATOR_PATH, "--dev-get-max-mhz") {
9694
UseShellExecute = false,
9795
RedirectStandardError = false,
@@ -117,20 +115,20 @@ public void Activate(string templateName, ref ProcessStartInfo softwareProcessSt
117115
oldCPUSimulatorProcessStandardOutput = oldCPUSimulatorProcess.StandardOutput.ReadToEnd();
118116
}
119117

120-
if (oldCPUSimulatorProcess.ExitCode != 0 || !long.TryParse(oldCPUSimulatorProcessStandardOutput.Split('\n').Last(), out maxRate)) {
118+
if (oldCPUSimulatorProcess.ExitCode != 0 || !ulong.TryParse(oldCPUSimulatorProcessStandardOutput.Split('\n').Last(), out ulong maxRate)) {
121119
throw new InvalidOldCPUSimulatorException("Failed to get Max Rate.");
122120
}
121+
122+
// if our CPU is too slow, just ignore the modification
123+
if (targetRate >= maxRate) {
124+
return;
125+
}
123126
}
124127
} catch (Exception ex) {
125128
LogExceptionToLauncher(ex);
126129
throw new InvalidOldCPUSimulatorException("Failed to get Max Rate.");
127130
}
128131

129-
// if our CPU is too slow, just ignore the modification
130-
if (targetRate >= maxRate) {
131-
return;
132-
}
133-
134132
switch (modeElement.Name) {
135133
case ModeElement.NAME.WEB_BROWSER:
136134
// server mode, need to restart the whole app

0 commit comments

Comments
 (0)