MCPcopy Create free account
hub / github.com/SimHacker/micropolis / getDensity

Method getDensity

MicropolisCore/src/MicropolisEngine/src/tool.cpp:780–821  ·  view source on GitHub ↗

* Get string index for a status report on tile \a mapH, \a mapV on a * given status category. * @param catNo Category number: * 0: population density * 1: land value. * 2: crime rate. * 3: pollution. * 4: growth rate. * @param mapH X coordinate of the tile. * @param mapV Y coordinate of the tile. * @return Index into stri.202 file. */

Source from the content-addressed store, hash-verified

778 * @return Index into stri.202 file.
779 */
780int Micropolis::getDensity(short catNo, short mapH, short mapV)
781{
782 int z;
783
784 switch (catNo) {
785
786 case 0:
787 default:
788 z = populationDensityMap.worldGet(mapH, mapV);
789 z = z >> 6;
790 z = z & 3;
791 return z + STR202_POPULATIONDENSITY_LOW;
792
793 case 1:
794 z = landValueMap.worldGet(mapH, mapV);
795 if (z < 30) return STR202_LANDVALUE_SLUM;
796 if (z < 80) return STR202_LANDVALUE_LOWER_CLASS;
797 if (z < 150) return STR202_LANDVALUE_MIDDLE_CLASS;
798 return STR202_LANDVALUE_HIGH_CLASS;
799
800 case 2:
801 z = crimeRateMap.worldGet(mapH, mapV);
802 z = z >> 6;
803 z = z & 3;
804 return z + STR202_CRIME_NONE;
805
806 case 3:
807 z = pollutionDensityMap.worldGet(mapH, mapV);
808 if (z < 64 && z > 0) return 13;
809 z = z >> 6;
810 z = z & 3;
811 return z + STR202_POLLUTION_NONE;
812
813 case 4:
814 z = rateOfGrowthMap.worldGet(mapH, mapV);
815 if (z < 0) return STR202_GROWRATE_DECLINING;
816 if (z == 0) return STR202_GROWRATE_STABLE;
817 if (z > 100) return STR202_GROWRATE_FASTGROWTH;
818 return STR202_GROWRATE_SLOWGROWTH;
819
820 }
821}
822
823
824/**

Callers

nothing calls this directly

Calls 1

worldGetMethod · 0.80

Tested by

no test coverage detected