MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / UpdateMap

Method UpdateMap

engine/Poseidon/AI/AICenterImplPreview.cpp:379–467  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377}
378
379void AICenter::UpdateMap()
380{
381 // due to bus limitation it is not possible to check all fields
382 // for dirty flag in every simulation cycle
383 // (it took 10-15% for 20fps when there were no dirty fields)
384 // limit dirty flag checking is important when there are little dirty fields
385 int i;
386 int n = TargetsPerCycle;
387 for (i = 0; i < n; i++)
388 {
389 _map->ProcessChange();
390 }
391
392 n = FieldsPerCycle;
393 int nRows = 16;
394 int nAll = LandRange * LandRange;
395
396 // finish row
397 if (_column != 0)
398 {
399 bool dirty = false;
400 for (i = 0; i < _column; i++)
401 {
402 if (_map->_dirty(i, _row) != 0)
403 {
404 dirty = true;
405 }
406 }
407
408 while (_column != 0)
409 {
410 if (n <= 0 || nAll <= 0)
411 {
412 goto EndOfUpdateMap;
413 }
414 if (_map->_dirty(_column, _row) != 0)
415 {
416 UpdateField(_column, _row);
417 n--;
418 }
419 _column = (_column + 1) & (LandRangeMask);
420 nAll--;
421 }
422 if (!dirty)
423 {
424 _map->_dirtyRow[_row] = 0;
425 }
426 _row = (_row + 1) & (LandRangeMask);
427 nRows--;
428 }
429
430 while (true)
431 {
432 AI_ERROR(_column == 0);
433 if (n <= 0 || nRows <= 0 || nAll <= 0)
434 {
435 goto EndOfUpdateMap;
436 }

Callers

nothing calls this directly

Calls 1

ProcessChangeMethod · 0.80

Tested by

no test coverage detected