* ???? * @todo Why is Micropolis::cellSrc not allocated together with all the other * variables? * @todo What is the purpose of this function? * @todo KILL the define. */
| 196 | * @todo KILL the define. |
| 197 | */ |
| 198 | void Micropolis::simHeat() |
| 199 | { |
| 200 | int x, y; |
| 201 | static int a = 0; |
| 202 | short *src, *dst; |
| 203 | int fl = heatFlow; |
| 204 | |
| 205 | const int SRCCOL = WORLD_H + 2; |
| 206 | const int DSTCOL = WORLD_H; |
| 207 | |
| 208 | |
| 209 | if (cellSrc == NULL) { |
| 210 | cellSrc = (short *)newPtr((WORLD_W + 2) * (WORLD_H + 2) * sizeof (short)); |
| 211 | cellDst = (short *)&map[0][0]; |
| 212 | } |
| 213 | |
| 214 | src = cellSrc + SRCCOL + 1; |
| 215 | dst = cellDst; |
| 216 | |
| 217 | /* |
| 218 | * Copy wrapping edges: |
| 219 | * |
| 220 | * 0 ff f0 f1 ... fe ff f0 |
| 221 | * |
| 222 | * 1 0f 00 01 ... 0e 0f 00 |
| 223 | * 2 1f 10 11 ... 1e 1f 10 |
| 224 | * .. .. .. .. .. .. |
| 225 | * ef e0 e1 ... ee ef e0 |
| 226 | * h ff f0 f1 ... fe ff f0 |
| 227 | * |
| 228 | * h+1 0f 00 01 ... 0e 0f 00 |
| 229 | * |
| 230 | * wrap value: effect: |
| 231 | * 0 no effect |
| 232 | * 1 copy future=>past, no wrap |
| 233 | * 2 no copy, wrap edges |
| 234 | * 3 copy future=>past, wrap edges |
| 235 | * 4 copy future=>past, same edges |
| 236 | */ |
| 237 | |
| 238 | switch (heatWrap) { |
| 239 | case 0: |
| 240 | break; |
| 241 | case 1: |
| 242 | for (x = 0; x < WORLD_W; x++) { |
| 243 | memcpy(src, dst, WORLD_H * sizeof (short)); |
| 244 | src += SRCCOL; |
| 245 | dst += DSTCOL; |
| 246 | } |
| 247 | break; |
| 248 | case 2: |
| 249 | for (x = 0; x < WORLD_W; x++) { |
| 250 | src[-1] = src[WORLD_H - 1]; |
| 251 | src[WORLD_H] = src[0]; |
| 252 | src += SRCCOL; |
| 253 | dst += DSTCOL; |
| 254 | } |
| 255 | memcpy( |
nothing calls this directly
no outgoing calls
no test coverage detected