From 000036c3030c463a84deee739876c94dd26b7a85 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Wed, 17 Jul 2013 20:59:06 +0000 Subject: [PATCH] tile animation: cleanup, remove obsolete ANIMBIT constant git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@737 d9718cc8-9f43-0410-858b-315f434eb58c --- graphics/tiles.rc | 19 ++++++++++--------- src/micropolisj/engine/Animate.java | 2 +- src/micropolisj/engine/Bulldozer.java | 2 +- src/micropolisj/engine/ExplosionSprite.java | 2 +- src/micropolisj/engine/MapScanner.java | 17 +++++++---------- src/micropolisj/engine/Micropolis.java | 8 ++++---- src/micropolisj/engine/Sprite.java | 2 +- src/micropolisj/engine/TileConstants.java | 8 +++++++- src/micropolisj/engine/ToolStroke.java | 5 ++--- 9 files changed, 34 insertions(+), 31 deletions(-) diff --git a/graphics/tiles.rc b/graphics/tiles.rc index 3a31b35..922014a 100644 --- a/graphics/tiles.rc +++ b/graphics/tiles.rc @@ -647,16 +647,16 @@ 638 ind_zones@32,128 639 ind_zones@0,144 640 ind_zones@16,144 -641 ind_zones@32,144 (becomes=884) +641 ind_zones@32,144 642 ind_zones@0,160 643 ind_zones@16,160 -644 ind_zones@32,160 (becomes=888) +644 ind_zones@32,160 645 ind_zones@0,176 646 ind_zones@16,176 647 ind_zones@32,176 648 ind_zones@0,192 -649 ind_zones@16,192 (becomes=892) -650 ind_zones@32,192 (becomes=896) +649 ind_zones@16,192 +650 ind_zones@32,192 651 ind_zones@0,208 652 ind_zones@16,208 653 ind_zones@32,208 @@ -682,8 +682,8 @@ 673 ind_zones@16,320 674 ind_zones@32,320 675 ind_zones@0,336 -676 ind_zones@16,336 (becomes=900) -677 ind_zones@32,336 (becomes=904) +676 ind_zones@16,336 +677 ind_zones@32,336 678 ind_zones@0,352 679 ind_zones@16,352 680 ind_zones@32,352 @@ -692,10 +692,10 @@ 683 ind_zones@32,368 684 ind_zones@0,384 685 ind_zones@16,384 -686 ind_zones@32,384 (becomes=908) +686 ind_zones@32,384 687 ind_zones@0,400 688 ind_zones@16,400 -689 ind_zones@32,400 (becomes=912) +689 ind_zones@32,400 690 ind_zones@0,416 691 ind_zones@16,416 692 ind_zones@32,416 @@ -719,7 +719,7 @@ # BEGIN AIRPORT # 709 airport@0,0 710 airport@16,0 -711 airport@32,0 (becomes=832) +711 airport@32,0 712 airport@48,0 713 airport@64,0 714 airport@80,0 @@ -978,6 +978,7 @@ 953 misc_animation@0,2016 (becomes=954) 954 misc_animation@0,2032 (becomes=955) 955 misc_animation@0,2048 (becomes=952) +# unused # 956 misc_animation@0,2064 957 misc_animation@0,2080 958 misc_animation@0,2096 diff --git a/src/micropolisj/engine/Animate.java b/src/micropolisj/engine/Animate.java index 0802058..df8ce91 100644 --- a/src/micropolisj/engine/Animate.java +++ b/src/micropolisj/engine/Animate.java @@ -38,7 +38,7 @@ class Animate static int [] AniTabC = { IND1, 0, IND2, IND4, 0, 0, IND6, IND8 }; static int [] AniTabD = { IND1, 0, IND3, IND5, 0, 0, IND7, IND9 }; - static final int ASCBIT = (ANIMBIT | CONDBIT | BURNBIT); + static final int ASCBIT = (CONDBIT | BURNBIT); static final int REGBIT = (CONDBIT | BURNBIT); } diff --git a/src/micropolisj/engine/Bulldozer.java b/src/micropolisj/engine/Bulldozer.java index 0de76ac..15cae06 100644 --- a/src/micropolisj/engine/Bulldozer.java +++ b/src/micropolisj/engine/Bulldozer.java @@ -100,7 +100,7 @@ class Bulldozer extends ToolStroke tile = tile & LOMASK; if (tile != RADTILE && tile != DIRT) { int z = inPreview ? 0 : city.PRNG.nextInt(3); - int nTile = (TINYEXP + z) | ANIMBIT | BULLBIT; + int nTile = (TINYEXP + z) | BULLBIT; eff.setTile(xx, yy, nTile); } } diff --git a/src/micropolisj/engine/ExplosionSprite.java b/src/micropolisj/engine/ExplosionSprite.java index a757b32..9a21691 100644 --- a/src/micropolisj/engine/ExplosionSprite.java +++ b/src/micropolisj/engine/ExplosionSprite.java @@ -58,6 +58,6 @@ public class ExplosionSprite extends Sprite return; if (isZoneCenter(z)) return; - city.setTile(xpos, ypos, (char)(FIRE + city.PRNG.nextInt(4) + ANIMBIT)); + city.setTile(xpos, ypos, (char)(FIRE + city.PRNG.nextInt(4))); } } diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index d67ec51..b5bba0b 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -158,10 +158,7 @@ class MapScanner if (tden != newLevel) { int z = (((cchr & LOMASK) - ROADBASE) & 15) + TRAFFIC_DENSITY_TAB[newLevel]; - z += cchr & (ALLBITS - ANIMBIT); - - if (newLevel != 0) - z |= ANIMBIT; + z += cchr & ALLBITS; city.setTile(xpos, ypos, (char) z); } @@ -192,7 +189,7 @@ class MapScanner city.makeExplosion(xtem, ytem); } } - city.setTile(xtem, ytem, (char)(FIRE + PRNG.nextInt(4) + ANIMBIT)); + city.setTile(xtem, ytem, (char)(FIRE + PRNG.nextInt(4))); } } } @@ -611,8 +608,8 @@ class MapScanner { if (((city.cityTime + xpos + ypos) % 32) == 0) { drawStadium(FULLSTADIUM); - city.setTile(xpos+1,ypos, (char)(FOOTBALLGAME1 | ANIMBIT)); - city.setTile(xpos+1,ypos+1,(char)(FOOTBALLGAME2 | ANIMBIT)); + city.setTile(xpos+1,ypos, (char)(FOOTBALLGAME1)); + city.setTile(xpos+1,ypos+1,(char)(FOOTBALLGAME2)); } } return; @@ -634,7 +631,7 @@ class MapScanner { if ((city.map[ypos-1][xpos+1] & LOMASK) == RADAR) { city.setTile(xpos+1,ypos-1, (char) - (RADAR + ANIMBIT + CONDBIT + BURNBIT) + (RADAR_ANIM + CONDBIT + BURNBIT) ); } } @@ -754,7 +751,7 @@ class MapScanner continue; } - if ((thCh & ANIMBIT) != 0) + if (isAnimated(thCh)) continue; thCh &= LOMASK; @@ -1345,7 +1342,7 @@ class MapScanner int tile = city.getTile(xpos+dx[z], ypos+dy[z]) & LOMASK; if (tile >= COALBASE && tile < COALBASE + 4*4) { city.setTile(xpos + dx[z], ypos + dy[z], - (char) (SmTb[z] | ANIMBIT | CONDBIT | PWRBIT | BURNBIT) + (char) (SmTb[z] | CONDBIT | PWRBIT | BURNBIT) ); } } diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 95af41c..be427d8 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -1801,7 +1801,7 @@ public class Micropolis for (int x = xpos - 1; x < xpos + 3; x++) { for (int y = ypos - 1; y < ypos + 3; y++) { - setTile(x, y, (char)(FIRE + PRNG.nextInt(4) + ANIMBIT)); + setTile(x, y, (char)(FIRE + PRNG.nextInt(4))); } } @@ -2160,7 +2160,7 @@ public class Micropolis if (PRNG.nextInt(4) != 0) { setTile(x, y, (char)(RUBBLE + BULLBIT + PRNG.nextInt(4))); } else { - setTile(x, y, (char)(FIRE + ANIMBIT + PRNG.nextInt(8))); + setTile(x, y, (char)(FIRE + PRNG.nextInt(8))); } } } @@ -2173,7 +2173,7 @@ public class Micropolis int t = getTile(x, y); if (TileConstants.isArsonable(t)) { - setTile(x, y, (char)(FIRE + ANIMBIT + PRNG.nextInt(8))); + setTile(x, y, (char)(FIRE + PRNG.nextInt(8))); crashLocation = new CityLocation(x, y); sendMessageAtPic(MicropolisMessage.FIRE_REPORT, x, y); } @@ -2191,7 +2191,7 @@ public class Micropolis { tile &= LOMASK; if (tile > 21 && tile < LASTZONE) { - setTile(x, y, (char)(FIRE + ANIMBIT + PRNG.nextInt(8))); + setTile(x, y, (char)(FIRE + PRNG.nextInt(8))); sendMessageAt(MicropolisMessage.FIRE_REPORT, x, y); return; } diff --git a/src/micropolisj/engine/Sprite.java b/src/micropolisj/engine/Sprite.java index a8fb50b..e285bd6 100644 --- a/src/micropolisj/engine/Sprite.java +++ b/src/micropolisj/engine/Sprite.java @@ -193,7 +193,7 @@ public abstract class Sprite } else { city.setTile(xpos, ypos, - (char) (TINYEXP | BULLBIT | ANIMBIT)); + (char) (TINYEXP | BULLBIT)); } } } diff --git a/src/micropolisj/engine/TileConstants.java b/src/micropolisj/engine/TileConstants.java index defa475..e09a194 100644 --- a/src/micropolisj/engine/TileConstants.java +++ b/src/micropolisj/engine/TileConstants.java @@ -212,7 +212,7 @@ public class TileConstants public static final char CONDBIT = 16384; // bit 14 ... can conduct power public static final char BURNBIT = 8192; // bit 13 ... is combustible public static final char BULLBIT = 4096; // bit 12 ... is bulldozable - public static final char ANIMBIT = 2048; // bit 11 ... animates + // bit 11 ... unused public static final char ZONEBIT = 1024; // bit 10 ... is the special tile for a zone public static final char ALLBITS = 64512; // mask for upper 6 bits @@ -280,6 +280,12 @@ public class TileConstants } } + public static boolean isAnimated(int tile) + { + TileSpec spec = Tiles.get(tile & LOMASK); + return spec.animNext != null; + } + //used by setFire() public static boolean isArsonable(int tile) { diff --git a/src/micropolisj/engine/ToolStroke.java b/src/micropolisj/engine/ToolStroke.java index 79e9b61..84cb51f 100644 --- a/src/micropolisj/engine/ToolStroke.java +++ b/src/micropolisj/engine/ToolStroke.java @@ -183,8 +183,7 @@ public class ToolStroke { eff.setTile(columnNum, rowNum, (char) ( tileBase + BNCNBIT + - (columnNum == centerColNum && rowNum == centerRowNum ? ZONEBIT : 0) + - (width==4 && columnNum==1 && rowNum==2 ? ANIMBIT : 0) + (columnNum == centerColNum && rowNum == centerRowNum ? ZONEBIT : 0) )); tileBase++; } @@ -244,7 +243,7 @@ public class ToolStroke if (z < 4) { tile = (WOODS2 + z) | BURNBIT | BULLBIT; } else { - tile = FOUNTAIN | BURNBIT | BULLBIT | ANIMBIT; + tile = FOUNTAIN | BURNBIT | BULLBIT; } eff.spend(cost);