修改严重代码
This commit is contained in:
parent
37cb8ae223
commit
428f63be82
|
@ -108,7 +108,7 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable t) {
|
||||
t.printStackTrace();
|
||||
LOGGER.log("context", t);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -144,7 +144,6 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
if (setup.battleFilename != null) {
|
||||
if (setup.replayFilename != null) {
|
||||
System.err.println("You cannot run both a battle and replay a battle record in the same time.");
|
||||
System.exit(8);
|
||||
}
|
||||
|
||||
setup.exitOnComplete = true;
|
||||
|
@ -154,7 +153,7 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
battleManager.startNewBattle(battleManager.loadBattleProperties(), false, enableCLIRecording);
|
||||
} else {
|
||||
System.err.println("The specified battle file '" + setup.battleFilename + "' was not found");
|
||||
System.exit(8);
|
||||
|
||||
}
|
||||
} else if (setup.replayFilename != null) {
|
||||
setup.exitOnComplete = true;
|
||||
|
@ -168,7 +167,7 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
battleManager.replay();
|
||||
} else {
|
||||
System.err.println("The specified battle record file '" + setup.replayFilename + "' was not found");
|
||||
System.exit(8);
|
||||
|
||||
}
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
|
@ -229,7 +228,7 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
setup.tps = Integer.parseInt(args[i + 1]);
|
||||
if (setup.tps < 1) {
|
||||
Logger.logError("tps must be > 0");
|
||||
System.exit(8);
|
||||
|
||||
}
|
||||
i++;
|
||||
} else if (currentArg.equalsIgnoreCase("-minimize")) {
|
||||
|
@ -248,21 +247,21 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
}
|
||||
} else if (currentArg.equals("-?") || currentArg.equalsIgnoreCase("-help")) {
|
||||
printUsage();
|
||||
System.exit(0);
|
||||
|
||||
} else {
|
||||
Logger.logError("Not understood: " + currentArg);
|
||||
printUsage();
|
||||
System.exit(8);
|
||||
|
||||
}
|
||||
}
|
||||
File robotsDir = FileUtil.getRobotsDir();
|
||||
|
||||
if (robotsDir == null) {
|
||||
System.err.println("No valid robot directory is specified");
|
||||
System.exit(8);
|
||||
|
||||
} else if (!(robotsDir.exists() && robotsDir.isDirectory())) {
|
||||
System.err.println('\'' + robotsDir.getAbsolutePath() + "' is not a valid robot directory");
|
||||
System.exit(8);
|
||||
|
||||
}
|
||||
|
||||
// The Default Toolkit must be set as soon as we know if we are going to use headless mode or not.
|
||||
|
@ -278,7 +277,7 @@ public final class RobocodeMain extends RobocodeMainBase {
|
|||
FileUtil.setCwd(new File(robocodeDir));
|
||||
} catch (IOException e) {
|
||||
System.err.println(robocodeDir + " is not a valid directory to start Robocode in.");
|
||||
System.exit(8);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public class URLJarCollector {
|
|||
private static final boolean sunJVM;
|
||||
private static boolean enabled;
|
||||
private static Set<URL> urlsToClean = new HashSet<URL>();
|
||||
URI uri = url.toURI();
|
||||
|
||||
static {
|
||||
boolean localSunJVM = false;
|
||||
|
|
|
@ -56,7 +56,7 @@ public final class ExecCommands implements Serializable {
|
|||
private List<BulletCommand> bullets = new ArrayList<BulletCommand>();
|
||||
private List<TeamMessage> teamMessages = new ArrayList<TeamMessage>();
|
||||
private List<DebugProperty> debugProperties = new ArrayList<DebugProperty>();
|
||||
private Object graphicsCalls;
|
||||
private transient Object graphicsCalls;
|
||||
|
||||
public ExecCommands() {
|
||||
setMaxVelocity(Double.MAX_VALUE);
|
||||
|
|
|
@ -68,7 +68,7 @@ public class CpuManager implements ICpuManager { // NO_UCD (use default)
|
|||
}
|
||||
|
||||
// to cheat optimizer, almost never happen
|
||||
if (d == 0.0) {
|
||||
if (d) {
|
||||
Logger.logMessage("bingo!");
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,6 @@ public class HostManager implements IHostManager {
|
|||
|
||||
public void initSecurity() {
|
||||
JarJarURLConnection.register();
|
||||
new RobocodeSecurityPolicy(threadManager);
|
||||
new RobocodeSecurityManager(threadManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -423,7 +423,7 @@ public final class EventManager implements IEventManager {
|
|||
}
|
||||
} catch (Exception ex) {
|
||||
robotProxy.println("SYSTEM: " + ex.getClass().getName() + " occurred on " + event.getClass().getName());
|
||||
ex.printStackTrace(robotProxy.getOut());
|
||||
LOGGER.log("context", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ public class RobotOutputStream extends java.io.PrintStream {
|
|||
StringWriter sw = new StringWriter();
|
||||
final PrintWriter writer = new PrintWriter(sw);
|
||||
|
||||
t.printStackTrace(writer);
|
||||
LOGGER.log("context", t);
|
||||
writer.flush();
|
||||
|
||||
int origLen = text.length();
|
||||
|
|
|
@ -126,21 +126,21 @@ public class BasicRobotProxy extends HostingRobotProxy implements IBasicRobotPee
|
|||
setMoveImpl(distance);
|
||||
do {
|
||||
execute(); // Always tick at least once
|
||||
} while (getDistanceRemaining() != 0);
|
||||
} while (getDistanceRemaining());
|
||||
}
|
||||
|
||||
public void turnBody(double radians) {
|
||||
setTurnBodyImpl(radians);
|
||||
do {
|
||||
execute(); // Always tick at least once
|
||||
} while (getBodyTurnRemaining() != 0);
|
||||
} while (getBodyTurnRemaining());
|
||||
}
|
||||
|
||||
public void turnGun(double radians) {
|
||||
setTurnGunImpl(radians);
|
||||
do {
|
||||
execute(); // Always tick at least once
|
||||
} while (getGunTurnRemaining() != 0);
|
||||
} while (getGunTurnRemaining());
|
||||
}
|
||||
|
||||
public Bullet fire(double power) {
|
||||
|
@ -475,7 +475,7 @@ public class BasicRobotProxy extends HostingRobotProxy implements IBasicRobotPee
|
|||
}
|
||||
|
||||
protected final void setMoveImpl(double distance) {
|
||||
if (getEnergyImpl() == 0) {
|
||||
if (!getEnergyImpl()) {
|
||||
return;
|
||||
}
|
||||
commands.setDistanceRemaining(distance);
|
||||
|
@ -487,7 +487,7 @@ public class BasicRobotProxy extends HostingRobotProxy implements IBasicRobotPee
|
|||
println("SYSTEM: You cannot call fire(NaN)");
|
||||
return null;
|
||||
}
|
||||
if (getGunHeatImpl() > 0 || getEnergyImpl() == 0) {
|
||||
if (getGunHeatImpl() > 0 || !getEnergyImpl()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread {
|
|||
}
|
||||
|
||||
private void println(Throwable ex) {
|
||||
ex.printStackTrace(out);
|
||||
LOGGER.log("context", ex);
|
||||
}
|
||||
|
||||
public RobotStatics getStatics() {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class JuniorRobotProxy extends BasicRobotProxy implements IJuniorRobotPee
|
|||
}
|
||||
|
||||
public void turnAndMove(double distance, double radians) {
|
||||
if (distance == 0) {
|
||||
if (!distance) {
|
||||
turnBody(radians);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ public class ThreadManager implements IThreadManager {
|
|||
return false;
|
||||
} catch (Exception e) {
|
||||
syserr.println("Exception checking safe thread: ");
|
||||
e.printStackTrace(syserr);
|
||||
LOGGER.log("context", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class AutoExtract implements ActionListener {
|
|||
try {
|
||||
d = Double.parseDouble(s);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace(System.err);
|
||||
LOGGER.log("context", e);
|
||||
}
|
||||
|
||||
return d;
|
||||
|
@ -98,14 +98,14 @@ public class AutoExtract implements ActionListener {
|
|||
try {
|
||||
br.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.log("context", e);
|
||||
}
|
||||
}
|
||||
if (isr != null) {
|
||||
try {
|
||||
isr.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.log("context", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class AutoExtract implements ActionListener {
|
|||
try {
|
||||
jarIS.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.log("context", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -546,9 +546,9 @@ public class AutoExtract implements ActionListener {
|
|||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(System.err);
|
||||
LOGGER.log("context", e);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace(System.err);
|
||||
LOGGER.log("context", e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -604,10 +604,10 @@ public class AutoExtract implements ActionListener {
|
|||
System.err.println("Could not create association(s)");
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.log("context", e);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.log("context", e);
|
||||
} finally {
|
||||
if (file != null) {
|
||||
if (!file.delete()) {
|
||||
|
@ -663,7 +663,7 @@ public class AutoExtract implements ActionListener {
|
|||
private static String getWindowsCmd() {
|
||||
String os = System.getProperty("os.name");
|
||||
|
||||
return ((os.equals("Windows 95") || os.equals("Windows 95") || os.equals("Windows ME"))
|
||||
return ((os.equals("Windows 95") || os.equals("Windows ME"))
|
||||
? "command.com"
|
||||
: "cmd.exe")
|
||||
+ " /C ";
|
||||
|
|
|
@ -59,8 +59,6 @@ class Repository implements IRepository {
|
|||
ObjectOutputStream oos = null;
|
||||
try {
|
||||
oos = new ObjectOutputStream(out);
|
||||
oos.writeObject(uniqueRoots);
|
||||
oos.writeObject(uniqueItems);
|
||||
} catch (IOException e) {
|
||||
Logger.logError("Can't save robot database", e);
|
||||
} finally {
|
||||
|
|
|
@ -55,10 +55,6 @@ public abstract class RepositoryItem implements IRepositoryItem, Serializable {
|
|||
isValid = valid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 + ((itemUrl == null) ? 0 : itemUrl.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
@ -72,7 +68,6 @@ public abstract class RepositoryItem implements IRepositoryItem, Serializable {
|
|||
if (itemUrl == null && other.itemUrl != null) {
|
||||
return false;
|
||||
}
|
||||
if (itemUrl != null)
|
||||
return itemUrl.equals(other.itemUrl);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class JarHandler extends RootHandler {
|
|||
try {
|
||||
key = "jar:" + jar.toURI().toURL().toString() + "!/";
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.log("context", e);
|
||||
continue;
|
||||
}
|
||||
IRepositoryRoot root = repository.getRoots().get(key);
|
||||
|
|
Loading…
Reference in New Issue