should always be from simulation thread!
| 1617 | |
| 1618 | // should always be from simulation thread! |
| 1619 | int Core::Update() |
| 1620 | { |
| 1621 | if (shutdown) |
| 1622 | { |
| 1623 | // release the suspender |
| 1624 | MainThread::suspend().unlock(); |
| 1625 | return -1; |
| 1626 | } |
| 1627 | |
| 1628 | if(errorstate) |
| 1629 | return -1; |
| 1630 | |
| 1631 | color_ostream_proxy out(con); |
| 1632 | |
| 1633 | // Pretend this thread has suspended the core in the usual way, |
| 1634 | // and run various processing hooks. |
| 1635 | { |
| 1636 | if(!started) |
| 1637 | { |
| 1638 | // Initialize the core |
| 1639 | InitSimulationThread(); |
| 1640 | if(errorstate) |
| 1641 | return -1; |
| 1642 | } |
| 1643 | |
| 1644 | uint32_t start_ms = p->getTickCount(); |
| 1645 | unpaused_ms += perf_counters.registerTick(start_ms); |
| 1646 | doUpdate(out); |
| 1647 | perf_counters.incCounter(perf_counters.total_update_ms, start_ms); |
| 1648 | } |
| 1649 | |
| 1650 | // Let all commands run that require CoreSuspender |
| 1651 | CoreWakeup.wait(MainThread::suspend(), |
| 1652 | [this]() -> bool {return this->toolCount.load() == 0;}); |
| 1653 | |
| 1654 | return 0; |
| 1655 | }; |
| 1656 | |
| 1657 | extern bool buildings_do_onupdate; |
| 1658 | void buildings_onStateChange(color_ostream &out, state_change_event event); |
no test coverage detected