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

Method doZoneStatus

MicropolisCore/src/MicropolisEngine/src/tool.cpp:830–882  ·  view source on GitHub ↗

* Report about the status of a tile. * @param mapH X coordinate of the tile. * @param mapV Y coordinate of the tile. * @bug Program breaks for status on 'dirt' */

Source from the content-addressed store, hash-verified

828 * @bug Program breaks for status on 'dirt'
829 */
830void Micropolis::doZoneStatus(short mapH, short mapV)
831{
832 int tileCategory;
833 int status[5];
834
835 short tileNum = map[mapH][mapV] & LOMASK;
836
837 if (tileNum >= COALSMOKE1 && tileNum < FOOTBALLGAME1) {
838 tileNum = COALBASE;
839 }
840
841 // Find the category where the tile belongs to
842 // Note: If 'tileNum < idArray[i]', it belongs to category i-1
843 short i;
844 for (i = 1; i < 29; i++) {
845 if (tileNum < idArray[i]) {
846 break;
847 }
848 }
849
850 i--;
851 // i contains the category that the tile belongs to (in theory 0..27).
852 // However, it is 0..26, since 956 is the first unused tile
853
854 // FIXME: This needs to be fixed to support plug-in churches.
855
856 // TODO: This should also return the bounding box and hot spot of
857 // the zone to the user interface, as well as other interesting
858 // information.
859
860 // Code below looks buggy, 0 is a valid value (namely 'dirt'), and upper
861 // limit is not correctly checked either ('stri.219' has only 27 lines).
862
863 // FIXME: This is strange... Normalize to zero based index.
864 if (i < 1 || i > 28) {
865 i = 28; // This breaks the program (when you click 'dirt')
866 }
867
868 // Obtain the string index of the tile category.
869 // 'stri.219' has only 27 lines, so 0 <= i <= 26 is acceptable.
870 tileCategory = i + 1;
871
872 for (i = 0; i < 5; i++) {
873 int id = clamp(getDensity(i, mapH, mapV) + 1, 1, 20);
874 status[i] = id;
875 }
876
877 doShowZoneStatus(
878 tileCategory,
879 status[0], status[1], status[2],
880 status[3], status[4],
881 mapH, mapV);
882}
883
884
885/** Tell front-end to report on status of a tile.

Callers

nothing calls this directly

Calls 1

clampFunction · 0.85

Tested by

no test coverage detected