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 /sources/core/VSProcess.java | |
| parent | 70cacb6ee93b9f74b8a8ca5b003c88e35276d0b7 (diff) | |
Random crash tasks bugfix.
Diffstat (limited to 'sources/core/VSProcess.java')
| -rw-r--r-- | sources/core/VSProcess.java | 13 |
1 files changed, 8 insertions, 5 deletions
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; |
