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

Method take10Census

MicropolisCore/src/MicropolisEngine/src/simulate.cpp:712–785  ·  view source on GitHub ↗

* Take monthly snaphsot of all relevant data for the historic graphs. * Also update variables that control building new churches and hospitals. * @todo Rename to takeMonthlyCensus (or takeMonthlySnaphshot?). * @todo A lot of this max stuff is also done in graph.cpp */

Source from the content-addressed store, hash-verified

710 * @todo A lot of this max stuff is also done in graph.cpp
711 */
712void Micropolis::take10Census()
713{
714 // TODO: Make configurable parameters.
715 int resPopDenom = 8;
716
717 short x;
718
719 /* put census#s in Historical Graphs and scroll data */
720 resHist10Max = 0;
721 comHist10Max = 0;
722 indHist10Max = 0;
723
724 for (x = 118; x >= 0; x--) {
725
726 resHist10Max = max(resHist10Max, resHist[x]);
727 comHist10Max = max(comHist10Max, comHist[x]);
728 indHist10Max = max(indHist10Max, indHist[x]);
729
730 resHist[x + 1] = resHist[x];
731 comHist[x + 1] = comHist[x];
732 indHist[x + 1] = indHist[x];
733 crimeHist[x + 1] = crimeHist[x];
734 pollutionHist[x + 1] = pollutionHist[x];
735 moneyHist[x + 1] = moneyHist[x];
736
737 }
738
739 graph10Max = resHist10Max;
740 graph10Max = max(graph10Max, comHist10Max);
741 graph10Max = max(graph10Max, indHist10Max);
742
743 resHist[0] = resPop / resPopDenom;
744 comHist[0] = comPop;
745 indHist[0] = indPop;
746
747 crimeRamp += (crimeAverage - crimeRamp) / 4;
748 crimeHist[0] = min(crimeRamp, (short)255);
749
750 pollutionRamp += (pollutionAverage - pollutionRamp) / 4;
751 pollutionHist[0] = min(pollutionRamp, (short)255);
752
753 x = (cashFlow / 20) + 128; /* scale to 0..255 */
754 moneyHist[0] = clamp(x, (short)0, (short)255);
755
756 changeCensus();
757
758 short resPopScaled = resPop >> 8;
759
760 if (hospitalPop < resPopScaled) {
761 needHospital = 1;
762 }
763
764 if (hospitalPop > resPopScaled) {
765 needHospital = -1;
766 }
767
768 if (hospitalPop == resPopScaled) {
769 needHospital = 0;

Callers

nothing calls this directly

Calls 3

maxFunction · 0.85
minFunction · 0.85
clampFunction · 0.85

Tested by

no test coverage detected