/// <summary> /// Free / Clear all Map Arrays /// </summary> private void destoryMapArrays() { InitMapArrays(); for (int x = 0; x < Constants.WorldWidth; ++x) { for (int y = 0; y < Constants.WorldHeight; ++y) { Map[x, y] = (ushort)MapTileCharacters.DIRT; } } PopulationDensityMap.Clear(); TrafficDensityMap.Clear(); PollutionDensityMap.Clear(); LandValueMap.Clear(); CrimeRateMap.Clear(); TerrainDensityMap.Clear(); RateOfGrowthMap.Clear(); PowerGridMap.Clear(); FireStationMap.Clear(); FireStationEffectMap.Clear(); PoliceStationMap.Clear(); PoliceStationEffectMap.Clear(); ComRateMap.Clear(); TempMap1.Clear(); TempMap2.Clear(); TempMap3.Clear(); }
/// <summary> /// comefrom: simulate SpecialInit /// </summary> public void PollutionTerrainLandValueScan() { /* Does pollution, terrain, land value */ long ptot, LVtot; int x, y, z, dis; int pollutionLevel, loc, worldX, worldY, Mx, My, pnum, LVnum, pmax; // tempMap3 is a map of development density, smoothed into terrainMap. TempMap3.Clear(); LVtot = 0; LVnum = 0; for (x = 0; x < LandValueMap.width; x++) { for (y = 0; y < LandValueMap.height; y++) { pollutionLevel = 0; bool landValueFlag = false; worldX = x * 2; worldY = y * 2; for (Mx = worldX; Mx <= worldX + 1; Mx++) { for (My = worldY; My <= worldY + 1; My++) { loc = (Map[Mx, My] & (ushort)MapTileBits.LowMask); if (loc.IsTrue()) { if (loc < (ushort)MapTileCharacters.RUBBLE) { // Increment terrain memory. byte value = TempMap3.Get(x >> 1, y >> 1); TempMap3.Set(x >> 1, y >> 1, (byte)(value + 15)); continue; } pollutionLevel += GetPollutionValue(loc); if (loc >= (ushort)MapTileCharacters.ROADBASE) { landValueFlag = true; } } } } /* XXX ??? This might have to do with the radiation tile returning -40. * if (pollutionLevel < 0) { * pollutionLevel = 250; * } */ pollutionLevel = Math.Min(pollutionLevel, 255); TempMap1.Set(x, y, (byte)pollutionLevel); if (landValueFlag) { /* LandValue Equation */ dis = 34 - GetCityCenterDistance(worldX, worldY) / 2; dis = dis << 2; dis += TerrainDensityMap.Get(x >> 1, y >> 1); dis -= PollutionDensityMap.Get(x, y); if (CrimeRateMap.Get(x, y) > 190) { dis -= 20; } dis = Utilities.Restrict(dis, 1, 250); LandValueMap.Set(x, y, (byte)dis); LVtot += dis; LVnum++; } else { LandValueMap.Set(x, y, 0); } } } if (LVnum > 0) { LandValueAverage = (short)(LVtot / LVnum); } else { LandValueAverage = 0; } DoSmooth1(); // tempMap1 -> tempMap2 DoSmooth2(); // tempMap2 -> tempMap1 pmax = 0; pnum = 0; ptot = 0; for (x = 0; x < Constants.WorldWidth; x += PollutionDensityMap.BlockSize) { for (y = 0; y < Constants.WorldHeight; y += PollutionDensityMap.BlockSize) { z = TempMap1.WorldGet(x, y); PollutionDensityMap.WorldSet(x, y, (byte)z); if (z.IsTrue()) { /* get pollute average */ pnum++; ptot += z; /* find max pol for monster */ if (z > pmax || (z == pmax && (GetRandom16() & 3) == 0)) { pmax = z; PollutionMaxX = (short)x; PollutionMaxY = (short)y; } } } } if (pnum.IsTrue()) { PollutionAverage = (short)(ptot / pnum); } else { PollutionAverage = 0; } SmoothTerrain(); NewMapFlags[(int)MapType.Pollution] = 1; NewMapFlags[(int)MapType.LandValue] = 1; NewMapFlags[(int)MapType.Dynamic] = 1; }