MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / update

Method update

game/ui/tileview/cityview.cpp:1832–3007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1830}
1831
1832void CityView::update()
1833{
1834 unsigned int ticks = 0;
1835 int day = state->gameTime.getDay();
1836 bool turbo = false;
1837 switch (this->updateSpeed)
1838 {
1839 case CityUpdateSpeed::Pause:
1840 ticks = 0;
1841 break;
1842 /* POSSIBLE FIXME: 'vanilla' apoc appears to implement Speed1 as 1/2 speed - that is
1843 * only
1844 * every other call calls the update loop, meaning that the later update tick counts are
1845 * halved as well.
1846 * This effectively means that all openapoc tick counts count for 1/2 the value of
1847 * vanilla
1848 * apoc ticks */
1849 case CityUpdateSpeed::Speed1:
1850 ticks = 1;
1851 break;
1852 case CityUpdateSpeed::Speed2:
1853 ticks = 2;
1854 break;
1855 case CityUpdateSpeed::Speed3:
1856 ticks = 4;
1857 break;
1858 case CityUpdateSpeed::Speed4:
1859 ticks = 6;
1860 break;
1861 case CityUpdateSpeed::Speed5:
1862 if (!this->state->canTurbo())
1863 {
1864 setUpdateSpeed(CityUpdateSpeed::Speed1);
1865 ticks = 1;
1866 }
1867 else
1868 {
1869 turbo = true;
1870 }
1871 break;
1872 }
1873 baseForm->findControl("BUTTON_SPEED5")->Enabled = this->state->canTurbo();
1874
1875 if (turbo)
1876 {
1877 this->state->updateTurbo();
1878 if (!this->state->canTurbo())
1879 {
1880 setUpdateSpeed(CityUpdateSpeed::Speed1);
1881 }
1882 }
1883 else
1884 {
1885 while (ticks > 0)
1886 {
1887 int ticksPerUpdate = UPDATE_EVERY_TICK ? 1 : ticks;
1888 state->update(ticksPerUpdate);
1889 ticks -= ticksPerUpdate;

Callers

nothing calls this directly

Calls 15

formatFunction · 0.85
trFunction · 0.85
getDayMethod · 0.80
canTurboMethod · 0.80
findControlMethod · 0.80
updateTurboMethod · 0.80
getPlayerMethod · 0.80
setCurrentCityMethod · 0.80
stageQueueCommandMethod · 0.80
getLongTimeStringMethod · 0.80
insertMethod · 0.80
addCallbackMethod · 0.80

Tested by

no test coverage detected