src/openttd.cpp
branchgamebalance
changeset 9911 0b8b245a2391
parent 9910 0b2aebc8283e
child 9912 1ac8aac92385
equal deleted inserted replaced
9910:0b2aebc8283e 9911:0b8b245a2391
    59 #include "clear_map.h"
    59 #include "clear_map.h"
    60 #include "fontcache.h"
    60 #include "fontcache.h"
    61 #include "newgrf.h"
    61 #include "newgrf.h"
    62 #include "newgrf_config.h"
    62 #include "newgrf_config.h"
    63 #include "newgrf_house.h"
    63 #include "newgrf_house.h"
       
    64 #include "newgrf_commons.h"
    64 #include "player_face.h"
    65 #include "player_face.h"
       
    66 #include "group.h"
    65 
    67 
    66 #include "bridge_map.h"
    68 #include "bridge_map.h"
    67 #include "clear_map.h"
    69 #include "clear_map.h"
    68 #include "rail_map.h"
    70 #include "rail_map.h"
    69 #include "road_map.h"
    71 #include "road_map.h"
   291 	CleanPool(&_Industry_pool);
   293 	CleanPool(&_Industry_pool);
   292 	CleanPool(&_Station_pool);
   294 	CleanPool(&_Station_pool);
   293 	CleanPool(&_Vehicle_pool);
   295 	CleanPool(&_Vehicle_pool);
   294 	CleanPool(&_Sign_pool);
   296 	CleanPool(&_Sign_pool);
   295 	CleanPool(&_Order_pool);
   297 	CleanPool(&_Order_pool);
       
   298 	CleanPool(&_Group_pool);
   296 
   299 
   297 	free((void*)_town_sort);
   300 	free((void*)_town_sort);
   298 	free((void*)_industry_sort);
   301 	free((void*)_industry_sort);
   299 
   302 
   300 	free(_config_file);
   303 	free(_config_file);
   500 	DEBUG(driver, 1, "Loading drivers...");
   503 	DEBUG(driver, 1, "Loading drivers...");
   501 	LoadDriver(SOUND_DRIVER, _ini_sounddriver);
   504 	LoadDriver(SOUND_DRIVER, _ini_sounddriver);
   502 	LoadDriver(MUSIC_DRIVER, _ini_musicdriver);
   505 	LoadDriver(MUSIC_DRIVER, _ini_musicdriver);
   503 	LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads
   506 	LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads
   504 	_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
   507 	_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
       
   508 	/* Initialize the zoom level of the screen to normal */
       
   509 	_screen.zoom = ZOOM_LVL_NORMAL;
   505 
   510 
   506 	/* restore saved music volume */
   511 	/* restore saved music volume */
   507 	_music_driver->set_volume(msf.music_vol);
   512 	_music_driver->set_volume(msf.music_vol);
   508 
   513 
   509 	NetworkStartUp(); // initialize network-core
   514 	NetworkStartUp(); // initialize network-core
   683 static void MakeNewGame(bool from_heightmap)
   688 static void MakeNewGame(bool from_heightmap)
   684 {
   689 {
   685 	_game_mode = GM_NORMAL;
   690 	_game_mode = GM_NORMAL;
   686 
   691 
   687 	ResetGRFConfig(true);
   692 	ResetGRFConfig(true);
   688 	ResetHouseIDMapping();
   693 	_house_mngr.ResetMapping();
   689 
   694 
   690 	GenerateWorldSetCallback(&MakeNewGameDone);
   695 	GenerateWorldSetCallback(&MakeNewGameDone);
   691 	GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
   696 	GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
   692 }
   697 }
   693 
   698 
   984 {
   989 {
   985 	if (_game_mode != GM_MENU) {
   990 	if (_game_mode != GM_MENU) {
   986 		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
   991 		Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
   987 		assert(w);
   992 		assert(w);
   988 
   993 
   989 		WP(w,vp_d).scrollpos_x += x << w->viewport->zoom;
   994 		WP(w,vp_d).scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
   990 		WP(w,vp_d).scrollpos_y += y << w->viewport->zoom;
   995 		WP(w,vp_d).scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
   991 	}
   996 	}
   992 }
   997 }
   993 
   998 
   994 static const int8 scrollamt[16][2] = {
   999 static const int8 scrollamt[16][2] = {
   995 	{ 0,  0},
  1000 	{ 0,  0},
  1074 	}
  1079 	}
  1075 #else
  1080 #else
  1076 	StateGameLoop();
  1081 	StateGameLoop();
  1077 #endif /* ENABLE_NETWORK */
  1082 #endif /* ENABLE_NETWORK */
  1078 
  1083 
  1079 	if (!_pause_game && _display_opt & DO_FULL_ANIMATION) DoPaletteAnimations();
  1084 	if (!_pause_game && HASBIT(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations();
  1080 
  1085 
  1081 	if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects();
  1086 	if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects();
  1082 
  1087 
  1083 	InputLoop();
  1088 	InputLoop();
  1084 
  1089 
  1101 	TileIndex tile;
  1106 	TileIndex tile;
  1102 
  1107 
  1103 	for (tile = 0; tile != MapSize(); tile++) {
  1108 	for (tile = 0; tile != MapSize(); tile++) {
  1104 		switch (GetTileType(tile)) {
  1109 		switch (GetTileType(tile)) {
  1105 			case MP_STREET:
  1110 			case MP_STREET:
  1106 				if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) & 0x80) {
  1111 				if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HASBIT(_m[tile].m4, 7)) {
  1107 					SetCrossingRoadOwner(tile, OWNER_TOWN);
  1112 					_m[tile].m4 = OWNER_TOWN;
  1108 				}
  1113 				}
  1109 				/* FALLTHROUGH */
  1114 				/* FALLTHROUGH */
  1110 
  1115 
  1111 			case MP_TUNNELBRIDGE:
  1116 			case MP_TUNNELBRIDGE:
  1112 				if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
  1117 				if (GetTileOwner(tile) & 0x80) SetTileOwner(tile, OWNER_TOWN);
  1280 	WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
  1285 	WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
  1281 	WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
  1286 	WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
  1282 
  1287 
  1283 	vp = w->viewport;
  1288 	vp = w->viewport;
  1284 	vp->zoom = _saved_scrollpos_zoom;
  1289 	vp->zoom = _saved_scrollpos_zoom;
  1285 	vp->virtual_width = vp->width << vp->zoom;
  1290 	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
  1286 	vp->virtual_height = vp->height << vp->zoom;
  1291 	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
  1287 
  1292 
  1288 	/* in version 4.1 of the savegame, is_active was introduced to determine
  1293 	/* in version 4.1 of the savegame, is_active was introduced to determine
  1289 	 * if a player does exist, rather then checking name_1 */
  1294 	 * if a player does exist, rather then checking name_1 */
  1290 	if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive();
  1295 	if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive();
  1291 
  1296 
  1293 	if (CheckSavegameVersionOldStyle(4, 3)) UpdateVoidTiles();
  1298 	if (CheckSavegameVersionOldStyle(4, 3)) UpdateVoidTiles();
  1294 
  1299 
  1295 	/* If Load Scenario / New (Scenario) Game is used,
  1300 	/* If Load Scenario / New (Scenario) Game is used,
  1296 	 *  a player does not exist yet. So create one here.
  1301 	 *  a player does not exist yet. So create one here.
  1297 	 * 1 exeption: network-games. Those can have 0 players
  1302 	 * 1 exeption: network-games. Those can have 0 players
  1298 	 *   But this exeption is not true for network_servers! */
  1303 	 *   But this exeption is not true for non dedicated network_servers! */
  1299 	if (!_players[0].is_active && (!_networking || (_networking && _network_server)))
  1304 	if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated)))
  1300 		DoStartupNewPlayer(false);
  1305 		DoStartupNewPlayer(false);
  1301 
  1306 
  1302 	DoZoomInOutWindow(ZOOM_NONE, w); // update button status
  1307 	DoZoomInOutWindow(ZOOM_NONE, w); // update button status
  1303 	MarkWholeScreenDirty();
  1308 	MarkWholeScreenDirty();
  1304 
  1309 
  1407 			p->engine_renew_months = _patches.autorenew_months;
  1412 			p->engine_renew_months = _patches.autorenew_months;
  1408 			p->engine_renew_money  = _patches.autorenew_money;
  1413 			p->engine_renew_money  = _patches.autorenew_money;
  1409 		}
  1414 		}
  1410 	}
  1415 	}
  1411 
  1416 
  1412 	if (CheckSavegameVersion(42)) {
       
  1413 		Vehicle* v;
       
  1414 
       
  1415 		for (TileIndex t = 0; t < map_size; t++) {
       
  1416 			if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t);
       
  1417 			if (IsBridgeTile(t)) {
       
  1418 				if (HASBIT(_m[t].m5, 6)) { // middle part
       
  1419 					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
       
  1420 
       
  1421 					if (HASBIT(_m[t].m5, 5)) { // transport route under bridge?
       
  1422 						if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) {
       
  1423 							MakeRailNormal(
       
  1424 								t,
       
  1425 								GetTileOwner(t),
       
  1426 								axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X,
       
  1427 								GetRailType(t)
       
  1428 							);
       
  1429 						} else {
       
  1430 							TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->index : 0;
       
  1431 
       
  1432 							MakeRoadNormal(
       
  1433 								t,
       
  1434 								GetTileOwner(t),
       
  1435 								axis == AXIS_X ? ROAD_Y : ROAD_X,
       
  1436 								town
       
  1437 							);
       
  1438 						}
       
  1439 					} else {
       
  1440 						if (GB(_m[t].m5, 3, 2) == 0) {
       
  1441 							MakeClear(t, CLEAR_GRASS, 3);
       
  1442 						} else {
       
  1443 							MakeCanal(t, GetTileOwner(t));
       
  1444 						}
       
  1445 					}
       
  1446 					SetBridgeMiddle(t, axis);
       
  1447 				} else { // ramp
       
  1448 					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
       
  1449 					uint north_south = GB(_m[t].m5, 5, 1);
       
  1450 					DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south));
       
  1451 					TransportType type = (TransportType)GB(_m[t].m5, 1, 2);
       
  1452 
       
  1453 					_m[t].m5 = 1 << 7 | type << 2 | dir;
       
  1454 				}
       
  1455 			}
       
  1456 		}
       
  1457 
       
  1458 		FOR_ALL_VEHICLES(v) {
       
  1459 			if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
       
  1460 			if (IsBridgeTile(v->tile)) {
       
  1461 				DiagDirection dir = GetBridgeRampDirection(v->tile);
       
  1462 
       
  1463 				if (dir != DirToDiagDir(v->direction)) continue;
       
  1464 				switch (dir) {
       
  1465 					default: NOT_REACHED();
       
  1466 					case DIAGDIR_NE: if ((v->x_pos & 0xF) !=  0)            continue; break;
       
  1467 					case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break;
       
  1468 					case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break;
       
  1469 					case DIAGDIR_NW: if ((v->y_pos & 0xF) !=  0)            continue; break;
       
  1470 				}
       
  1471 			} else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) {
       
  1472 				v->tile = GetNorthernBridgeEnd(v->tile);
       
  1473 			} else {
       
  1474 				continue;
       
  1475 			}
       
  1476 			if (v->type == VEH_TRAIN) {
       
  1477 				v->u.rail.track = TRACK_BIT_WORMHOLE;
       
  1478 			} else {
       
  1479 				v->u.road.state = RVSB_WORMHOLE;
       
  1480 			}
       
  1481 		}
       
  1482 	}
       
  1483 
       
  1484 	if (CheckSavegameVersion(48)) {
  1417 	if (CheckSavegameVersion(48)) {
  1485 		for (TileIndex t = 0; t < map_size; t++) {
  1418 		for (TileIndex t = 0; t < map_size; t++) {
  1486 			switch (GetTileType(t)) {
  1419 			switch (GetTileType(t)) {
  1487 				case MP_RAILWAY:
  1420 				case MP_RAILWAY:
  1488 					if (IsPlainRailTile(t)) {
  1421 					if (IsPlainRailTile(t)) {
  1507 				default: break;
  1440 				default: break;
  1508 			}
  1441 			}
  1509 		}
  1442 		}
  1510 	}
  1443 	}
  1511 
  1444 
       
  1445 	if (CheckSavegameVersion(61)) {
       
  1446 		/* Added the RoadType */
       
  1447 		for (TileIndex t = 0; t < map_size; t++) {
       
  1448 			switch(GetTileType(t)) {
       
  1449 				case MP_STREET:
       
  1450 					SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2));
       
  1451 					switch (GetRoadTileType(t)) {
       
  1452 						default: NOT_REACHED();
       
  1453 						case ROAD_TILE_NORMAL:
       
  1454 							SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4));
       
  1455 							SB(_m[t].m4, 4, 4, 0);
       
  1456 							SB(_m[t].m6, 2, 4, 0);
       
  1457 							break;
       
  1458 						case ROAD_TILE_CROSSING:
       
  1459 							SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2));
       
  1460 							break;
       
  1461 						case ROAD_TILE_DEPOT:    break;
       
  1462 					}
       
  1463 					SetRoadTypes(t, ROADTYPES_ROAD);
       
  1464 					break;
       
  1465 
       
  1466 				case MP_STATION:
       
  1467 					if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
       
  1468 					break;
       
  1469 
       
  1470 				case MP_TUNNELBRIDGE:
       
  1471 					if ((IsTunnel(t) ? GetTunnelTransportType(t) : GetBridgeTransportType(t)) == TRANSPORT_ROAD) {
       
  1472 						SetRoadTypes(t, ROADTYPES_ROAD);
       
  1473 					}
       
  1474 					break;
       
  1475 
       
  1476 				default: break;
       
  1477 			}
       
  1478 		}
       
  1479 	}
       
  1480 
       
  1481 	if (CheckSavegameVersion(42)) {
       
  1482 		Vehicle* v;
       
  1483 
       
  1484 		for (TileIndex t = 0; t < map_size; t++) {
       
  1485 			if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t);
       
  1486 			if (IsBridgeTile(t)) {
       
  1487 				if (HASBIT(_m[t].m5, 6)) { // middle part
       
  1488 					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
       
  1489 
       
  1490 					if (HASBIT(_m[t].m5, 5)) { // transport route under bridge?
       
  1491 						if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) {
       
  1492 							MakeRailNormal(
       
  1493 								t,
       
  1494 								GetTileOwner(t),
       
  1495 								axis == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X,
       
  1496 								GetRailType(t)
       
  1497 							);
       
  1498 						} else {
       
  1499 							TownID town = IsTileOwner(t, OWNER_TOWN) ? ClosestTownFromTile(t, (uint)-1)->index : 0;
       
  1500 
       
  1501 							MakeRoadNormal(
       
  1502 								t,
       
  1503 								axis == AXIS_X ? ROAD_Y : ROAD_X,
       
  1504 								ROADTYPES_ROAD,
       
  1505 								town,
       
  1506 								GetTileOwner(t), OWNER_NONE, OWNER_NONE
       
  1507 							);
       
  1508 						}
       
  1509 					} else {
       
  1510 						if (GB(_m[t].m5, 3, 2) == 0) {
       
  1511 							MakeClear(t, CLEAR_GRASS, 3);
       
  1512 						} else {
       
  1513 							MakeCanal(t, GetTileOwner(t));
       
  1514 						}
       
  1515 					}
       
  1516 					SetBridgeMiddle(t, axis);
       
  1517 				} else { // ramp
       
  1518 					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
       
  1519 					uint north_south = GB(_m[t].m5, 5, 1);
       
  1520 					DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south));
       
  1521 					TransportType type = (TransportType)GB(_m[t].m5, 1, 2);
       
  1522 
       
  1523 					_m[t].m5 = 1 << 7 | type << 2 | dir;
       
  1524 				}
       
  1525 			}
       
  1526 		}
       
  1527 
       
  1528 		FOR_ALL_VEHICLES(v) {
       
  1529 			if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
       
  1530 			if (IsBridgeTile(v->tile)) {
       
  1531 				DiagDirection dir = GetBridgeRampDirection(v->tile);
       
  1532 
       
  1533 				if (dir != DirToDiagDir(v->direction)) continue;
       
  1534 				switch (dir) {
       
  1535 					default: NOT_REACHED();
       
  1536 					case DIAGDIR_NE: if ((v->x_pos & 0xF) !=  0)            continue; break;
       
  1537 					case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break;
       
  1538 					case DIAGDIR_SW: if ((v->x_pos & 0xF) != TILE_SIZE - 1) continue; break;
       
  1539 					case DIAGDIR_NW: if ((v->y_pos & 0xF) !=  0)            continue; break;
       
  1540 				}
       
  1541 			} else if (v->z_pos > GetSlopeZ(v->x_pos, v->y_pos)) {
       
  1542 				v->tile = GetNorthernBridgeEnd(v->tile);
       
  1543 			} else {
       
  1544 				continue;
       
  1545 			}
       
  1546 			if (v->type == VEH_TRAIN) {
       
  1547 				v->u.rail.track = TRACK_BIT_WORMHOLE;
       
  1548 			} else {
       
  1549 				v->u.road.state = RVSB_WORMHOLE;
       
  1550 			}
       
  1551 		}
       
  1552 	}
       
  1553 
  1512 	/* Elrails got added in rev 24 */
  1554 	/* Elrails got added in rev 24 */
  1513 	if (CheckSavegameVersion(24)) {
  1555 	if (CheckSavegameVersion(24)) {
  1514 		Vehicle *v;
  1556 		Vehicle *v;
  1515 		RailType min_rail = RAILTYPE_ELECTRIC;
  1557 		RailType min_rail = RAILTYPE_ELECTRIC;
  1516 
  1558 
  1765 
  1807 
  1766 	/* From version 53, the map array was changed for house tiles to allow
  1808 	/* From version 53, the map array was changed for house tiles to allow
  1767 	 * space for newhouses grf features. A new byte, m7, was also added. */
  1809 	 * space for newhouses grf features. A new byte, m7, was also added. */
  1768 	if (CheckSavegameVersion(53)) {
  1810 	if (CheckSavegameVersion(53)) {
  1769 		for (TileIndex t = 0; t < map_size; t++) {
  1811 		for (TileIndex t = 0; t < map_size; t++) {
  1770 			_me[t].m7 = 0;
       
  1771 
       
  1772 			if (IsTileType(t, MP_HOUSE)) {
  1812 			if (IsTileType(t, MP_HOUSE)) {
  1773 				if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
  1813 				if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
  1774 					/* Move the construction stage from m3[7..6] to m5[5..4].
  1814 					/* Move the construction stage from m3[7..6] to m5[5..4].
  1775 					 * The construction counter does not have to move. */
  1815 					 * The construction counter does not have to move. */
  1776 					SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2));
  1816 					SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2));
  1932 		FOR_ALL_VEHICLES(v) {
  1972 		FOR_ALL_VEHICLES(v) {
  1933 			if ((v->type != VEH_TRAIN || IsFrontEngine(v)) &&  // for all locs
  1973 			if ((v->type != VEH_TRAIN || IsFrontEngine(v)) &&  // for all locs
  1934 					!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
  1974 					!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
  1935 					v->current_order.type == OT_LOADING) {         // loading
  1975 					v->current_order.type == OT_LOADING) {         // loading
  1936 				GetStation(v->last_station_visited)->loading_vehicles.push_back(v);
  1976 				GetStation(v->last_station_visited)->loading_vehicles.push_back(v);
       
  1977 
       
  1978 				/* The loading finished flag is *only* set when actually completely
       
  1979 				 * finished. Because the vehicle is loading, it is not finished. */
       
  1980 				CLRBIT(v->vehicle_flags, VF_LOADING_FINISHED);
  1937 			}
  1981 			}
  1938 		}
  1982 		}
  1939 	}
  1983 	}
  1940 
  1984 
  1941 	if (CheckSavegameVersion(58)) {
  1985 	if (CheckSavegameVersion(58)) {
       
  1986 		/* patch difficulty number_industries other then zero get bumped to +1
       
  1987 		 * since a new option (very low at position1) has been added */
       
  1988 		if (_opt.diff.number_industries > 0) {
       
  1989 			_opt.diff.number_industries++;
       
  1990 		}
       
  1991 
       
  1992 		/* Same goes for number of towns, although no test is needed, just an increment */
       
  1993 		_opt.diff.number_towns++;
       
  1994 	}
       
  1995 
       
  1996 	/* Recalculate */
       
  1997 	Group *g;
       
  1998 	FOR_ALL_GROUPS(g) {
       
  1999 		const Vehicle *v;
       
  2000 		FOR_ALL_VEHICLES(v) {
       
  2001 			if (!IsEngineCountable(v)) continue;
       
  2002 
       
  2003 			if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
       
  2004 
       
  2005 			g->num_engines[v->engine_type]++;
       
  2006 		}
       
  2007 	}
       
  2008 
       
  2009 	if (CheckSavegameVersion(62)) {
  1942 		Town *t;
  2010 		Town *t;
  1943 		FOR_ALL_TOWNS(t) t->SetActivity(1);
  2011 		FOR_ALL_TOWNS(t) t->SetActivity(1);
  1944 	}
  2012 	}
  1945 
  2013 
  1946 	return true;
  2014 	return true;