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

Method getHistory

MicropolisCore/src/MicropolisEngine/src/graph.cpp:277–327  ·  view source on GitHub ↗

* Get a value from the history tables. * @param historyType Type of history information. @see HistoryType * @param historyScale Scale of history data. @see HistoryScale * @param historyIndex Index in the data to obtain * @return Historic data value of the requested graph */

Source from the content-addressed store, hash-verified

275 * @return Historic data value of the requested graph
276 */
277short Micropolis::getHistory(int historyType, int historyScale,
278 int historyIndex)
279{
280 if (historyType < 0 || historyType >= HISTORY_TYPE_COUNT
281 || historyScale < 0 || historyScale >= HISTORY_SCALE_COUNT
282 || historyIndex < 0 || historyIndex >= HISTORY_COUNT) {
283 return 0;
284 }
285
286 short *history = NULL;
287 switch (historyType) {
288 case HISTORY_TYPE_RES:
289 history = resHist;
290 break;
291 case HISTORY_TYPE_COM:
292 history = comHist;
293 break;
294 case HISTORY_TYPE_IND:
295 history = indHist;
296 break;
297 case HISTORY_TYPE_MONEY:
298 history = moneyHist;
299 break;
300 case HISTORY_TYPE_CRIME:
301 history = crimeHist;
302 break;
303 case HISTORY_TYPE_POLLUTION:
304 history = pollutionHist;
305 break;
306 default:
307 NOT_REACHED();
308 break;
309 }
310
311 int offset = 0;
312 switch (historyScale) {
313 case HISTORY_SCALE_SHORT:
314 offset = 0;
315 break;
316 case HISTORY_SCALE_LONG:
317 offset = 120;
318 break;
319 default:
320 NOT_REACHED();
321 break;
322 }
323
324 short result = history[historyIndex + offset];
325
326 return result;
327}
328
329
330/**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected