diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-22 11:38:58 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-22 11:38:58 +0000 |
| commit | 4de5343c60cc165cdf30121e0ed9eca96ac91a22 (patch) | |
| tree | e3dfa59c91fc6954a07377c8f445dac175beea26 | |
| parent | 70cacb6ee93b9f74b8a8ca5b003c88e35276d0b7 (diff) | |
Random crash tasks bugfix.
| -rw-r--r-- | ROADMAP | 1 | ||||
| -rw-r--r-- | sources/core/VSProcess.java | 13 | ||||
| -rw-r--r-- | sources/simulator/VSSimulation.java | 2 | ||||
| -rw-r--r-- | sources/simulator/VSSimulationCanvas.java | 7 |
4 files changed, 15 insertions, 8 deletions
@@ -1,5 +1,6 @@ TODO: +Slow-Motion Bug: Ausfallwkeit geht nicht?!?!?! (Nur beim 1. mal tut das) Prozesse hinzufuegen/loeschen koennen Neuen Protokolleditor bauen diff --git a/sources/core/VSProcess.java b/sources/core/VSProcess.java index e4f3332..ad3af56 100644 --- a/sources/core/VSProcess.java +++ b/sources/core/VSProcess.java @@ -211,21 +211,24 @@ public final class VSProcess extends VSPrefs { protocol.reset(); setCurrentColor(getColor("col.process.default")); - createRandomCrashTask(); resetTimeFormats(); } - private void createRandomCrashTask() { + public void createRandomCrashTask() { if (!isCrashed) { VSTaskManager taskManager = simulationCanvas.getTaskManager(); long crashTime = getARandomCrashTime(); + if (crashTime < 0) + return; + if (randomCrashTask != null) taskManager.removeTask(randomCrashTask); - if (crashTime >= 0 && crashTime >= getGlobalTime()) { + + if (crashTime >= getGlobalTime()) { VSEvent event = new ProcessCrashEvent(); - event.init(this); + //event.init(this); randomCrashTask = new VSTask(crashTime, this, event, VSTask.GLOBAL); taskManager.addTask(randomCrashTask); @@ -356,7 +359,7 @@ public final class VSProcess extends VSPrefs { public synchronized long getARandomMessageOutageTime(final long durationTime) { /* Check if the message will have an outage or not */ - if (random.nextInt(100) <= getInteger("message.prob.outage")) { + if (random.nextInt(100) < getInteger("message.prob.outage")) { /* Calculate the random outage time! */ final long outageTime = globalTime + random.nextLong(durationTime+1) % simulationCanvas.getUntilTime(); return outageTime; diff --git a/sources/simulator/VSSimulation.java b/sources/simulator/VSSimulation.java index d2cc070..06ca0d9 100644 --- a/sources/simulator/VSSimulation.java +++ b/sources/simulator/VSSimulation.java @@ -69,7 +69,7 @@ public class VSSimulation extends JPanel { this.replay = replay; } - public void setReset(boolean pause) { + public void setReset(boolean reset) { this.reset = reset; } diff --git a/sources/simulator/VSSimulationCanvas.java b/sources/simulator/VSSimulationCanvas.java index 91d5232..dea55ae 100644 --- a/sources/simulator/VSSimulationCanvas.java +++ b/sources/simulator/VSSimulationCanvas.java @@ -590,12 +590,15 @@ public class VSSimulationCanvas extends Canvas implements Runnable, MouseMotionL time = 0; lastTime = 0; - for (VSProcess p : processes) - p.reset(); + for (VSProcess process : processes) + process.reset(); /* Reset the task manager AFTER the processes, for the programmed tasks */ taskManager.reset(); + for (VSProcess process : processes) + process.createRandomCrashTask(); + synchronized (messageLines) { messageLines.clear(); } |
