comefrom: simFrame */
| 120 | |
| 121 | /* comefrom: simFrame */ |
| 122 | void Micropolis::simulate() |
| 123 | { |
| 124 | static const short speedPowerScan[3] = |
| 125 | { 2, 4, 5 }; |
| 126 | static const short SpeedPollutionTerrainLandValueScan[3] = |
| 127 | { 2, 7, 17 }; |
| 128 | static const short speedCrimeScan[3] = |
| 129 | { 1, 8, 18 }; |
| 130 | static const short speedPopulationDensityScan[3] = |
| 131 | { 1, 9, 19 }; |
| 132 | static const short speedFireAnalysis[3] = |
| 133 | { 1, 10, 20 }; |
| 134 | |
| 135 | short speedIndex = clamp((short)(simSpeed - 1), (short)0, (short)2); |
| 136 | |
| 137 | // The simulator has 16 different phases, which we cycle through |
| 138 | // according to phaseCycle, which is incremented and wrapped at |
| 139 | // the end of this switch. |
| 140 | |
| 141 | if (initSimLoad) { |
| 142 | phaseCycle = 0; |
| 143 | } else { |
| 144 | phaseCycle &= 15; |
| 145 | } |
| 146 | |
| 147 | switch (phaseCycle) { |
| 148 | |
| 149 | case 0: |
| 150 | |
| 151 | if (++simCycle > 1023) { |
| 152 | simCycle = 0; // This is cosmic! |
| 153 | } |
| 154 | |
| 155 | if (doInitialEval) { |
| 156 | doInitialEval = false; |
| 157 | cityEvaluation(); |
| 158 | } |
| 159 | |
| 160 | cityTime++; |
| 161 | cityTaxAverage += cityTax; |
| 162 | |
| 163 | if (!(simCycle & 1)) { |
| 164 | setValves(); |
| 165 | } |
| 166 | |
| 167 | clearCensus(); |
| 168 | |
| 169 | break; |
| 170 | |
| 171 | case 1: |
| 172 | case 2: |
| 173 | case 3: |
| 174 | case 4: |
| 175 | case 5: |
| 176 | case 6: |
| 177 | case 7: |
| 178 | case 8: |
| 179 |