285 if (t == NULL) { |
285 if (t == NULL) { |
286 ShowInfoF("Invalid resolution '%s'", s); |
286 ShowInfoF("Invalid resolution '%s'", s); |
287 return; |
287 return; |
288 } |
288 } |
289 |
289 |
290 res[0] = clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); |
290 res[0] = Clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); |
291 res[1] = clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT); |
291 res[1] = Clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT); |
292 } |
292 } |
293 |
293 |
294 static void InitializeDynamicVariables() |
294 static void InitializeDynamicVariables() |
295 { |
295 { |
296 /* Dynamic stuff needs to be initialized somewhere... */ |
296 /* Dynamic stuff needs to be initialized somewhere... */ |
325 } |
325 } |
326 |
326 |
327 static void LoadIntroGame() |
327 static void LoadIntroGame() |
328 { |
328 { |
329 _game_mode = GM_MENU; |
329 _game_mode = GM_MENU; |
330 |
|
331 /* Clear transparency options */ |
|
332 _transparent_opt = 0; |
|
333 |
330 |
334 _opt_ptr = &_opt_newgame; |
331 _opt_ptr = &_opt_newgame; |
335 ResetGRFConfig(false); |
332 ResetGRFConfig(false); |
336 |
333 |
337 /* Setup main window */ |
334 /* Setup main window */ |
1170 TileIndex tile; |
1167 TileIndex tile; |
1171 |
1168 |
1172 for (tile = 0; tile != MapSize(); tile++) { |
1169 for (tile = 0; tile != MapSize(); tile++) { |
1173 switch (GetTileType(tile)) { |
1170 switch (GetTileType(tile)) { |
1174 case MP_ROAD: |
1171 case MP_ROAD: |
1175 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HASBIT(_m[tile].m4, 7)) { |
1172 if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) { |
1176 _m[tile].m4 = OWNER_TOWN; |
1173 _m[tile].m4 = OWNER_TOWN; |
1177 } |
1174 } |
1178 /* FALLTHROUGH */ |
1175 /* FALLTHROUGH */ |
1179 |
1176 |
1180 case MP_TUNNELBRIDGE: |
1177 case MP_TUNNELBRIDGE: |
1341 if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) { |
1336 if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) { |
1342 SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); |
1337 SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO); |
1343 return false; |
1338 return false; |
1344 } |
1339 } |
1345 |
1340 |
1346 /* Initialize windows */ |
|
1347 ResetWindowSystem(); |
|
1348 SetupColorsAndInitialWindow(); |
|
1349 |
|
1350 w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
1351 |
|
1352 WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; |
|
1353 WP(w,vp_d).scrollpos_y = _saved_scrollpos_y; |
|
1354 WP(w,vp_d).dest_scrollpos_x = _saved_scrollpos_x; |
|
1355 WP(w,vp_d).dest_scrollpos_y = _saved_scrollpos_y; |
|
1356 |
|
1357 vp = w->viewport; |
|
1358 vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX); |
|
1359 vp->virtual_width = ScaleByZoom(vp->width, vp->zoom); |
|
1360 vp->virtual_height = ScaleByZoom(vp->height, vp->zoom); |
|
1361 |
|
1362 /* in version 4.1 of the savegame, is_active was introduced to determine |
1341 /* in version 4.1 of the savegame, is_active was introduced to determine |
1363 * if a player does exist, rather then checking name_1 */ |
1342 * if a player does exist, rather then checking name_1 */ |
1364 if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
1343 if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); |
1365 |
1344 |
1366 /* the void tiles on the southern border used to belong to a wrong class (pre 4.3). */ |
1345 /* the void tiles on the southern border used to belong to a wrong class (pre 4.3). */ |
1371 * 1 exeption: network-games. Those can have 0 players |
1350 * 1 exeption: network-games. Those can have 0 players |
1372 * But this exeption is not true for non dedicated network_servers! */ |
1351 * But this exeption is not true for non dedicated network_servers! */ |
1373 if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) |
1352 if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) |
1374 DoStartupNewPlayer(false); |
1353 DoStartupNewPlayer(false); |
1375 |
1354 |
1376 DoZoomInOutWindow(ZOOM_NONE, w); // update button status |
|
1377 MarkWholeScreenDirty(); |
|
1378 |
|
1379 if (CheckSavegameVersion(72)) { |
1355 if (CheckSavegameVersion(72)) { |
1380 /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */ |
1356 /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */ |
1381 for (TileIndex t = 0; t < MapSize(); t++) { |
1357 for (TileIndex t = 0; t < MapSize(); t++) { |
1382 switch (GetTileType(t)) { |
1358 switch (GetTileType(t)) { |
1383 default: break; |
1359 default: break; |
1385 case MP_WATER: |
1361 case MP_WATER: |
1386 if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE); |
1362 if (GetWaterTileType(t) == WATER_TILE_LOCK && GetTileOwner(t) == OWNER_WATER) SetTileOwner(t, OWNER_NONE); |
1387 break; |
1363 break; |
1388 |
1364 |
1389 case MP_STATION: { |
1365 case MP_STATION: { |
1390 if (HASBIT(_m[t].m6, 3)) SETBIT(_m[t].m6, 2); |
1366 if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2); |
1391 StationGfx gfx = GetStationGfx(t); |
1367 StationGfx gfx = GetStationGfx(t); |
1392 StationType st; |
1368 StationType st; |
1393 if ( IS_INT_INSIDE(gfx, 0, 8)) { // Railway station |
1369 if ( IS_INT_INSIDE(gfx, 0, 8)) { // Railway station |
1394 st = STATION_RAIL; |
1370 st = STATION_RAIL; |
1395 SetStationGfx(t, gfx - 0); |
1371 SetStationGfx(t, gfx - 0); |
1544 /* Swap ground type and signal type for plain rail tiles, so the |
1520 /* Swap ground type and signal type for plain rail tiles, so the |
1545 * ground type uses the same bits as for depots and waypoints. */ |
1521 * ground type uses the same bits as for depots and waypoints. */ |
1546 uint tmp = GB(_m[t].m4, 0, 4); |
1522 uint tmp = GB(_m[t].m4, 0, 4); |
1547 SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4)); |
1523 SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4)); |
1548 SB(_m[t].m2, 0, 4, tmp); |
1524 SB(_m[t].m2, 0, 4, tmp); |
1549 } else if (HASBIT(_m[t].m5, 2)) { |
1525 } else if (HasBit(_m[t].m5, 2)) { |
1550 /* Split waypoint and depot rail type and remove the subtype. */ |
1526 /* Split waypoint and depot rail type and remove the subtype. */ |
1551 CLRBIT(_m[t].m5, 2); |
1527 ClrBit(_m[t].m5, 2); |
1552 CLRBIT(_m[t].m5, 6); |
1528 ClrBit(_m[t].m5, 6); |
1553 } |
1529 } |
1554 break; |
1530 break; |
1555 |
1531 |
1556 case MP_ROAD: |
1532 case MP_ROAD: |
1557 /* Swap m3 and m4, so the track type for rail crossings is the |
1533 /* Swap m3 and m4, so the track type for rail crossings is the |
1590 if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD); |
1566 if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD); |
1591 break; |
1567 break; |
1592 |
1568 |
1593 case MP_TUNNELBRIDGE: |
1569 case MP_TUNNELBRIDGE: |
1594 /* Middle part of "old" bridges */ |
1570 /* Middle part of "old" bridges */ |
1595 if (old_bridge && IsBridgeTile(t) && HASBIT(_m[t].m5, 6)) break; |
1571 if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break; |
1596 if ((IsTunnel(t) ? GetTunnelTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetBridgeTransportType(t))) == TRANSPORT_ROAD) { |
1572 if ((IsTunnel(t) ? GetTunnelTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetBridgeTransportType(t))) == TRANSPORT_ROAD) { |
1597 SetRoadTypes(t, ROADTYPES_ROAD); |
1573 SetRoadTypes(t, ROADTYPES_ROAD); |
1598 } |
1574 } |
1599 break; |
1575 break; |
1600 |
1576 |
1607 Vehicle* v; |
1583 Vehicle* v; |
1608 |
1584 |
1609 for (TileIndex t = 0; t < map_size; t++) { |
1585 for (TileIndex t = 0; t < map_size; t++) { |
1610 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); |
1586 if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); |
1611 if (IsBridgeTile(t)) { |
1587 if (IsBridgeTile(t)) { |
1612 if (HASBIT(_m[t].m5, 6)) { // middle part |
1588 if (HasBit(_m[t].m5, 6)) { // middle part |
1613 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
1589 Axis axis = (Axis)GB(_m[t].m5, 0, 1); |
1614 |
1590 |
1615 if (HASBIT(_m[t].m5, 5)) { // transport route under bridge? |
1591 if (HasBit(_m[t].m5, 5)) { // transport route under bridge? |
1616 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { |
1592 if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { |
1617 MakeRailNormal( |
1593 MakeRailNormal( |
1618 t, |
1594 t, |
1619 GetTileOwner(t), |
1595 GetTileOwner(t), |
1620 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X, |
1596 axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X, |
1748 |
1724 |
1749 FOR_ALL_WAYPOINTS(wp) { |
1725 FOR_ALL_WAYPOINTS(wp) { |
1750 if (wp->deleted == 0) { |
1726 if (wp->deleted == 0) { |
1751 const StationSpec *statspec = NULL; |
1727 const StationSpec *statspec = NULL; |
1752 |
1728 |
1753 if (HASBIT(_m[wp->xy].m3, 4)) |
1729 if (HasBit(_m[wp->xy].m3, 4)) |
1754 statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); |
1730 statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); |
1755 |
1731 |
1756 if (statspec != NULL) { |
1732 if (statspec != NULL) { |
1757 wp->stat_id = _m[wp->xy].m4 + 1; |
1733 wp->stat_id = _m[wp->xy].m4 + 1; |
1758 wp->grfid = statspec->grffile->grfid; |
1734 wp->grfid = statspec->grffile->grfid; |
1782 for (TileIndex t = 0; t < map_size; t++) { |
1758 for (TileIndex t = 0; t < map_size; t++) { |
1783 switch (GetTileType(t)) { |
1759 switch (GetTileType(t)) { |
1784 case MP_RAILWAY: |
1760 case MP_RAILWAY: |
1785 if (HasSignals(t)) { |
1761 if (HasSignals(t)) { |
1786 /* convert PBS signals to combo-signals */ |
1762 /* convert PBS signals to combo-signals */ |
1787 if (HASBIT(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO); |
1763 if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO); |
1788 |
1764 |
1789 /* move the signal variant back */ |
1765 /* move the signal variant back */ |
1790 SetSignalVariant(t, TRACK_X, HASBIT(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
1766 SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); |
1791 CLRBIT(_m[t].m2, 3); |
1767 ClrBit(_m[t].m2, 3); |
1792 } |
1768 } |
1793 |
1769 |
1794 /* Clear PBS reservation on track */ |
1770 /* Clear PBS reservation on track */ |
1795 if (!IsTileDepotType(t, TRANSPORT_RAIL)) { |
1771 if (!IsTileDepotType(t, TRANSPORT_RAIL)) { |
1796 SB(_m[t].m4, 4, 4, 0); |
1772 SB(_m[t].m4, 4, 4, 0); |
1797 } else { |
1773 } else { |
1798 CLRBIT(_m[t].m3, 6); |
1774 ClrBit(_m[t].m3, 6); |
1799 } |
1775 } |
1800 break; |
1776 break; |
1801 |
1777 |
1802 case MP_ROAD: /* Clear PBS reservation on crossing */ |
1778 case MP_ROAD: /* Clear PBS reservation on crossing */ |
1803 if (IsLevelCrossing(t)) CLRBIT(_m[t].m5, 0); |
1779 if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0); |
1804 break; |
1780 break; |
1805 |
1781 |
1806 case MP_STATION: /* Clear PBS reservation on station */ |
1782 case MP_STATION: /* Clear PBS reservation on station */ |
1807 CLRBIT(_m[t].m3, 6); |
1783 ClrBit(_m[t].m3, 6); |
1808 break; |
1784 break; |
1809 |
1785 |
1810 default: break; |
1786 default: break; |
1811 } |
1787 } |
1812 } |
1788 } |
1948 /* The "house is completed" bit is now in m6[2]. */ |
1924 /* The "house is completed" bit is now in m6[2]. */ |
1949 SetHouseCompleted(t, false); |
1925 SetHouseCompleted(t, false); |
1950 } else { |
1926 } else { |
1951 /* The "lift has destination" bit has been moved from |
1927 /* The "lift has destination" bit has been moved from |
1952 * m5[7] to m7[0]. */ |
1928 * m5[7] to m7[0]. */ |
1953 SB(_me[t].m7, 0, 1, HASBIT(_m[t].m5, 7)); |
1929 SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7)); |
1954 CLRBIT(_m[t].m5, 7); |
1930 ClrBit(_m[t].m5, 7); |
1955 |
1931 |
1956 /* The "lift is moving" bit has been removed, as it does |
1932 /* The "lift is moving" bit has been removed, as it does |
1957 * the same job as the "lift has destination" bit. */ |
1933 * the same job as the "lift has destination" bit. */ |
1958 CLRBIT(_m[t].m1, 7); |
1934 ClrBit(_m[t].m1, 7); |
1959 |
1935 |
1960 /* The position of the lift goes from m1[7..0] to m6[7..2], |
1936 /* The position of the lift goes from m1[7..0] to m6[7..2], |
1961 * making m1 totally free, now. The lift position does not |
1937 * making m1 totally free, now. The lift position does not |
1962 * have to be a full byte since the maximum value is 36. */ |
1938 * have to be a full byte since the maximum value is 36. */ |
1963 SetLiftPosition(t, GB(_m[t].m1, 0, 6 )); |
1939 SetLiftPosition(t, GB(_m[t].m1, 0, 6 )); |
2047 * amount of cargo that has been paid for is stored. */ |
2023 * amount of cargo that has been paid for is stored. */ |
2048 FOR_ALL_VEHICLES(v) { |
2024 FOR_ALL_VEHICLES(v) { |
2049 const CargoList::List *packets = v->cargo.Packets(); |
2025 const CargoList::List *packets = v->cargo.Packets(); |
2050 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
2026 for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { |
2051 CargoPacket *cp = *it; |
2027 CargoPacket *cp = *it; |
2052 cp->paid_for = HASBIT(v->vehicle_flags, 2); |
2028 cp->paid_for = HasBit(v->vehicle_flags, 2); |
2053 } |
2029 } |
2054 CLRBIT(v->vehicle_flags, 2); |
2030 ClrBit(v->vehicle_flags, 2); |
2055 v->cargo.InvalidateCache(); |
2031 v->cargo.InvalidateCache(); |
2056 } |
2032 } |
2057 } |
2033 } |
2058 |
2034 |
2059 /* Buoys do now store the owner of the previous water tile, which can never |
2035 /* Buoys do now store the owner of the previous water tile, which can never |
2060 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */ |
2036 * be OWNER_NONE. So replace OWNER_NONE with OWNER_WATER. */ |
2061 if (CheckSavegameVersion(46)) { |
2037 if (CheckSavegameVersion(46)) { |
2062 Station *st; |
2038 Station *st; |
2063 FOR_ALL_STATIONS(st) { |
2039 FOR_ALL_STATIONS(st) { |
2064 if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE)) SetTileOwner(st->xy, OWNER_WATER); |
2040 if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE) && TileHeight(st->xy) == 0) SetTileOwner(st->xy, OWNER_WATER); |
2065 } |
2041 } |
2066 } |
2042 } |
2067 |
2043 |
2068 if (CheckSavegameVersion(50)) { |
2044 if (CheckSavegameVersion(50)) { |
2069 Vehicle *v; |
2045 Vehicle *v; |
2111 v->current_order.type == OT_LOADING) { // loading |
2087 v->current_order.type == OT_LOADING) { // loading |
2112 GetStation(v->last_station_visited)->loading_vehicles.push_back(v); |
2088 GetStation(v->last_station_visited)->loading_vehicles.push_back(v); |
2113 |
2089 |
2114 /* The loading finished flag is *only* set when actually completely |
2090 /* The loading finished flag is *only* set when actually completely |
2115 * finished. Because the vehicle is loading, it is not finished. */ |
2091 * finished. Because the vehicle is loading, it is not finished. */ |
2116 CLRBIT(v->vehicle_flags, VF_LOADING_FINISHED); |
2092 ClrBit(v->vehicle_flags, VF_LOADING_FINISHED); |
2117 } |
2093 } |
2118 } |
2094 } |
2119 } else if (CheckSavegameVersion(59)) { |
2095 } else if (CheckSavegameVersion(59)) { |
2120 /* For some reason non-loading vehicles could be in the station's loading vehicle list */ |
2096 /* For some reason non-loading vehicles could be in the station's loading vehicle list */ |
2121 |
2097 |
2146 for (TileIndex t = 0; t < map_size; t++) { |
2122 for (TileIndex t = 0; t < map_size; t++) { |
2147 if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) { |
2123 if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) { |
2148 SetSignalStates(t, GB(_m[t].m2, 4, 4)); |
2124 SetSignalStates(t, GB(_m[t].m2, 4, 4)); |
2149 SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X)); |
2125 SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X)); |
2150 SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X)); |
2126 SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X)); |
2151 CLRBIT(_m[t].m2, 7); |
2127 ClrBit(_m[t].m2, 7); |
2152 } |
2128 } |
2153 } |
2129 } |
2154 } |
2130 } |
2155 |
2131 |
2156 if (CheckSavegameVersion(69)) { |
2132 if (CheckSavegameVersion(69)) { |
2157 /* In some old savegames a bit was cleared when it should not be cleared */ |
2133 /* In some old savegames a bit was cleared when it should not be cleared */ |
2158 Vehicle *v; |
2134 Vehicle *v; |
2159 FOR_ALL_VEHICLES(v) { |
2135 FOR_ALL_VEHICLES(v) { |
2160 if (v->type == VEH_ROAD && (v->u.road.state == 250 || v->u.road.state == 251)) { |
2136 if (v->type == VEH_ROAD && (v->u.road.state == 250 || v->u.road.state == 251)) { |
2161 SETBIT(v->u.road.state, RVS_IS_STOPPING); |
2137 SetBit(v->u.road.state, RVS_IS_STOPPING); |
2162 } |
2138 } |
2163 } |
2139 } |
2164 } |
2140 } |
2165 |
2141 |
2166 if (CheckSavegameVersion(70)) { |
2142 if (CheckSavegameVersion(70)) { |
2180 SetTileOwner(t, OWNER_NONE); |
2156 SetTileOwner(t, OWNER_NONE); |
2181 } |
2157 } |
2182 } |
2158 } |
2183 } |
2159 } |
2184 |
2160 |
2185 /* Recalculate */ |
|
2186 Group *g; |
|
2187 FOR_ALL_GROUPS(g) { |
|
2188 const Vehicle *v; |
|
2189 FOR_ALL_VEHICLES(v) { |
|
2190 if (!IsEngineCountable(v)) continue; |
|
2191 |
|
2192 if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue; |
|
2193 |
|
2194 g->num_engines[v->engine_type]++; |
|
2195 } |
|
2196 } |
|
2197 |
|
2198 if (CheckSavegameVersion(74)) { |
2161 if (CheckSavegameVersion(74)) { |
2199 Station *st; |
2162 Station *st; |
2200 FOR_ALL_STATIONS(st) { |
2163 FOR_ALL_STATIONS(st) { |
2201 for (CargoID c = 0; c < NUM_CARGO; c++) { |
2164 for (CargoID c = 0; c < NUM_CARGO; c++) { |
2202 st->goods[c].last_speed = 0; |
2165 st->goods[c].last_speed = 0; |
2203 if (st->goods[c].cargo.Count() != 0) SETBIT(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); |
2166 if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); |
2204 } |
2167 } |
2205 } |
2168 } |
2206 } |
2169 } |
2207 |
2170 |
2208 if (CheckSavegameVersion(78)) { |
2171 if (CheckSavegameVersion(78)) { |
2227 for (TileIndex t = 0; t < map_size; t++) { |
2190 for (TileIndex t = 0; t < map_size; t++) { |
2228 if (GetTileType(t) == MP_TREES) { |
2191 if (GetTileType(t) == MP_TREES) { |
2229 TreeGround groundType = GetTreeGround(t); |
2192 TreeGround groundType = GetTreeGround(t); |
2230 if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3); |
2193 if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3); |
2231 } |
2194 } |
|
2195 } |
|
2196 } |
|
2197 |
|
2198 /* Initialize windows */ |
|
2199 ResetWindowSystem(); |
|
2200 SetupColorsAndInitialWindow(); |
|
2201 |
|
2202 Window *w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
2203 |
|
2204 WP(w, vp_d).scrollpos_x = _saved_scrollpos_x; |
|
2205 WP(w, vp_d).scrollpos_y = _saved_scrollpos_y; |
|
2206 WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x; |
|
2207 WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y; |
|
2208 |
|
2209 ViewPort *vp = w->viewport; |
|
2210 vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX); |
|
2211 vp->virtual_width = ScaleByZoom(vp->width, vp->zoom); |
|
2212 vp->virtual_height = ScaleByZoom(vp->height, vp->zoom); |
|
2213 |
|
2214 DoZoomInOutWindow(ZOOM_NONE, w); // update button status |
|
2215 MarkWholeScreenDirty(); |
|
2216 |
|
2217 /* Recalculate */ |
|
2218 Group *g; |
|
2219 FOR_ALL_GROUPS(g) { |
|
2220 const Vehicle *v; |
|
2221 FOR_ALL_VEHICLES(v) { |
|
2222 if (!IsEngineCountable(v)) continue; |
|
2223 |
|
2224 if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue; |
|
2225 |
|
2226 g->num_engines[v->engine_type]++; |
2232 } |
2227 } |
2233 } |
2228 } |
2234 |
2229 |
2235 return true; |
2230 return true; |
2236 } |
2231 } |