File diff r7939:523d421f9d0c → r7940:bb8a390f6b5f
src/openttd.cpp
Show inline comments
 
@@ -1328,28 +1328,12 @@ bool AfterLoadGame()
 
	/* make sure there is a town in the game */
 
	if (_game_mode == GM_NORMAL && !ClosestTownFromTile(0, (uint)-1)) {
 
		SetSaveLoadError(STR_NO_TOWN_IN_SCENARIO);
 
		return false;
 
	}
 

	
 
	/* Initialize windows */
 
	ResetWindowSystem();
 
	SetupColorsAndInitialWindow();
 

	
 
	w = FindWindowById(WC_MAIN_WINDOW, 0);
 

	
 
	WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
 
	WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
 
	WP(w,vp_d).dest_scrollpos_x = _saved_scrollpos_x;
 
	WP(w,vp_d).dest_scrollpos_y = _saved_scrollpos_y;
 

	
 
	vp = w->viewport;
 
	vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
 
	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
 
	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
 

	
 
	/* in version 4.1 of the savegame, is_active was introduced to determine
 
	 * if a player does exist, rather then checking name_1 */
 
	if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive();
 

	
 
	/* the void tiles on the southern border used to belong to a wrong class (pre 4.3). */
 
	if (CheckSavegameVersionOldStyle(4, 3)) UpdateVoidTiles();
 
@@ -2167,25 +2151,12 @@ bool AfterLoadGame()
 
					TileHeight(t) != 0) {
 
				SetTileOwner(t, OWNER_NONE);
 
			}
 
		}
 
	}
 

	
 
	/* Recalculate */
 
	Group *g;
 
	FOR_ALL_GROUPS(g) {
 
		const Vehicle *v;
 
		FOR_ALL_VEHICLES(v) {
 
			if (!IsEngineCountable(v)) continue;
 

	
 
			if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
 

	
 
			g->num_engines[v->engine_type]++;
 
		}
 
	}
 

	
 
	if (CheckSavegameVersion(74)) {
 
		Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				st->goods[c].last_speed = 0;
 
				if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP);
 
@@ -2217,12 +2188,41 @@ bool AfterLoadGame()
 
				TreeGround groundType = GetTreeGround(t);
 
				if (groundType != TREE_GROUND_SNOW_DESERT) SetTreeGroundDensity(t, groundType, 3);
 
			}
 
		}
 
	}
 

	
 
	/* Initialize windows */
 
	ResetWindowSystem();
 
	SetupColorsAndInitialWindow();
 

	
 
	w = FindWindowById(WC_MAIN_WINDOW, 0);
 

	
 
	WP(w,vp_d).scrollpos_x = _saved_scrollpos_x;
 
	WP(w,vp_d).scrollpos_y = _saved_scrollpos_y;
 
	WP(w,vp_d).dest_scrollpos_x = _saved_scrollpos_x;
 
	WP(w,vp_d).dest_scrollpos_y = _saved_scrollpos_y;
 

	
 
	vp = w->viewport;
 
	vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
 
	vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
 
	vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
 

	
 
	/* Recalculate */
 
	Group *g;
 
	FOR_ALL_GROUPS(g) {
 
		const Vehicle *v;
 
		FOR_ALL_VEHICLES(v) {
 
			if (!IsEngineCountable(v)) continue;
 

	
 
			if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
 

	
 
			g->num_engines[v->engine_type]++;
 
		}
 
	}
 

	
 
	return true;
 
}
 

	
 
/** Reload all NewGRF files during a running game. This is a cut-down
 
 * version of AfterLoadGame().
 
 * XXX - We need to reset the vehicle position hash because with a non-empty