* Load all the NewGRFs. * @param load_index The offset for the first sprite to add. * @param num_baseset Number of NewGRFs at the front of the list to look up in the baseset dir instead of the newgrf dir. */
| 1756 | * @param num_baseset Number of NewGRFs at the front of the list to look up in the baseset dir instead of the newgrf dir. |
| 1757 | */ |
| 1758 | void LoadNewGRF(SpriteID load_index, uint num_baseset) |
| 1759 | { |
| 1760 | /* In case of networking we need to "sync" the start values |
| 1761 | * so all NewGRFs are loaded equally. For this we use the |
| 1762 | * start date of the game and we set the counters, etc. to |
| 1763 | * 0 so they're the same too. */ |
| 1764 | TimerGameCalendar::Date date = TimerGameCalendar::date; |
| 1765 | TimerGameCalendar::Year year = TimerGameCalendar::year; |
| 1766 | TimerGameCalendar::DateFract date_fract = TimerGameCalendar::date_fract; |
| 1767 | |
| 1768 | TimerGameEconomy::Date economy_date = TimerGameEconomy::date; |
| 1769 | TimerGameEconomy::Year economy_year = TimerGameEconomy::year; |
| 1770 | TimerGameEconomy::DateFract economy_date_fract = TimerGameEconomy::date_fract; |
| 1771 | |
| 1772 | uint64_t tick_counter = TimerGameTick::counter; |
| 1773 | uint8_t display_opt = _display_opt; |
| 1774 | |
| 1775 | if (_networking) { |
| 1776 | TimerGameCalendar::year = _settings_game.game_creation.starting_year; |
| 1777 | TimerGameCalendar::date = TimerGameCalendar::ConvertYMDToDate(TimerGameCalendar::year, 0, 1); |
| 1778 | TimerGameCalendar::date_fract = 0; |
| 1779 | |
| 1780 | TimerGameEconomy::year = TimerGameEconomy::Year{_settings_game.game_creation.starting_year.base()}; |
| 1781 | TimerGameEconomy::date = TimerGameEconomy::ConvertYMDToDate(TimerGameEconomy::year, 0, 1); |
| 1782 | TimerGameEconomy::date_fract = 0; |
| 1783 | |
| 1784 | TimerGameTick::counter = 0; |
| 1785 | _display_opt = 0; |
| 1786 | } |
| 1787 | |
| 1788 | InitializePatchFlags(); |
| 1789 | |
| 1790 | ResetNewGRFData(); |
| 1791 | |
| 1792 | /* |
| 1793 | * Reset the status of all files, so we can 'retry' to load them. |
| 1794 | * This is needed when one for example rearranges the NewGRFs in-game |
| 1795 | * and a previously disabled NewGRF becomes usable. If it would not |
| 1796 | * be reset, the NewGRF would remain disabled even though it should |
| 1797 | * have been enabled. |
| 1798 | */ |
| 1799 | for (const auto &c : _grfconfig) { |
| 1800 | if (c->status != GCS_NOT_FOUND) c->status = GCS_UNKNOWN; |
| 1801 | } |
| 1802 | |
| 1803 | _cur_gps.spriteid = load_index; |
| 1804 | |
| 1805 | /* Load newgrf sprites |
| 1806 | * in each loading stage, (try to) open each file specified in the config |
| 1807 | * and load information from it. */ |
| 1808 | for (GrfLoadingStage stage = GLS_LABELSCAN; stage <= GLS_ACTIVATION; stage++) { |
| 1809 | /* Set activated grfs back to will-be-activated between reservation- and activation-stage. |
| 1810 | * This ensures that action7/9 conditions 0x06 - 0x0A work correctly. */ |
| 1811 | for (const auto &c : _grfconfig) { |
| 1812 | if (c->status == GCS_ACTIVATED) c->status = GCS_INITIALISED; |
| 1813 | } |
| 1814 | |
| 1815 | if (stage == GLS_RESERVE) { |
no test coverage detected