From 908ff0b5a1f39b0970b73d2f0f84f176ee3de936 Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Mon, 18 Feb 2013 01:58:21 +0000 Subject: [PATCH] cleanup: drawStadium: use xpos,ypos properties instead of function arguments git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@558 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/MapScanner.java | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/micropolisj/engine/MapScanner.java b/src/micropolisj/engine/MapScanner.java index 137f88b..a958c23 100644 --- a/src/micropolisj/engine/MapScanner.java +++ b/src/micropolisj/engine/MapScanner.java @@ -607,7 +607,7 @@ class MapScanner if (powerOn) { if (((city.cityTime + xpos + ypos) % 32) == 0) { - drawStadium(xpos, ypos, FULLSTADIUM); + drawStadium(FULLSTADIUM); city.setTile(xpos+1,ypos, (char)(FOOTBALLGAME1 | ANIMBIT)); city.setTile(xpos+1,ypos+1,(char)(FOOTBALLGAME2 | ANIMBIT)); } @@ -617,7 +617,7 @@ class MapScanner case FULLSTADIUM: city.stadiumCount++; if (((city.cityTime + xpos + ypos) % 8) == 0) { - drawStadium(xpos, ypos, STADIUM); + drawStadium(STADIUM); } return; @@ -1356,14 +1356,20 @@ class MapScanner city.rateOGMem[ypos/8][xpos/8] += 4*amount; } - void drawStadium(int mapx, int mapy, int z) + /** + * Place tiles for a stadium (full or empty). + * @param zoneCenter either STADIUM or FULLSTADIUM + */ + void drawStadium(int zoneCenter) { - z -= 5; + int zoneBase = zoneCenter - 1 - 4; - for (int y = mapy-1; y < mapy+3; y++) { - for (int x = mapx-1; x < mapx+3; x++) { - city.setTile(x, y, (char) (z | BNCNBIT | (x == mapx && y == mapy ? (ZONEBIT|PWRBIT) : 0))); - z++; + for (int y = 0; y < 4; y++) + { + for (int x = 0; x < 4; x++, zoneBase++) + { + city.setTile(xpos - 1 + x, ypos - 1 + y, + (char) (zoneBase | BNCNBIT | (x == 1 && y == 1 ? (ZONEBIT|PWRBIT) : 0))); } } }