From 47fdf7c3c2ea1ca1e3246be276c5434b4b769753 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Thu, 16 May 2013 23:46:09 +0000 Subject: [PATCH] toolstroke: do not pick random numbers when generating a tool preview git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@647 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/Bulldozer.java | 4 ++-- src/micropolisj/engine/ToolStroke.java | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/micropolisj/engine/Bulldozer.java b/src/micropolisj/engine/Bulldozer.java index 26e773a..2455119 100644 --- a/src/micropolisj/engine/Bulldozer.java +++ b/src/micropolisj/engine/Bulldozer.java @@ -100,8 +100,8 @@ class Bulldozer extends ToolStroke continue; tile = tile & LOMASK; if (tile != RADTILE && tile != DIRT) { - int nTile = (TINYEXP + city.PRNG.nextInt(3)) - | ANIMBIT | BULLBIT; + int z = inPreview ? 0 : city.PRNG.nextInt(3); + int nTile = (TINYEXP + z) | ANIMBIT | BULLBIT; eff.setTile(xx, yy, nTile); } } diff --git a/src/micropolisj/engine/ToolStroke.java b/src/micropolisj/engine/ToolStroke.java index 522ce0a..6db34da 100644 --- a/src/micropolisj/engine/ToolStroke.java +++ b/src/micropolisj/engine/ToolStroke.java @@ -19,6 +19,7 @@ public class ToolStroke int ypos; int xdest; int ydest; + boolean inPreview; ToolStroke(Micropolis city, MicropolisTool tool, int xpos, int ypos) { @@ -33,7 +34,13 @@ public class ToolStroke public final ToolPreview getPreview() { ToolEffect eff = new ToolEffect(city); - applyArea(eff); + inPreview = true; + try { + applyArea(eff); + } + finally { + inPreview = false; + } return eff.preview; } @@ -232,7 +239,7 @@ public class ToolStroke } } - int z = city.PRNG.nextInt(5); + int z = inPreview ? 0 : city.PRNG.nextInt(5); int tile; if (z < 4) { tile = (WOODS2 + z) | BURNBIT | BULLBIT;