File diff r25654:e264fd698eb2 → r25655:1030dcb7eb52
src/openttd.cpp
Show inline comments
 
@@ -185,13 +185,13 @@ static void ShowHelp()
 
		"  -g [savegame]       = Start new/save game immediately\n"
 
		"  -G seed             = Set random seed\n"
 
		"  -n [ip:port#company]= Join network game\n"
 
		"  -p password         = Password to join server\n"
 
		"  -P password         = Password to join company\n"
 
		"  -D [ip][:port]      = Start dedicated server\n"
 
		"  -l ip[:port]        = Redirect DEBUG()\n"
 
		"  -l ip[:port]        = Redirect Debug()\n"
 
#if !defined(_WIN32)
 
		"  -f                  = Fork into the background (dedicated only)\n"
 
#endif
 
		"  -I graphics_set     = Force the graphics set (see below)\n"
 
		"  -S sounds_set       = Force the sounds set (see below)\n"
 
		"  -M music_set        = Force the music set (see below)\n"
 
@@ -663,13 +663,13 @@ int openttd_main(int argc, char *argv[])
 
		return ret;
 
	}
 

	
 
	DeterminePaths(argv[0], only_local_path);
 
	TarScanner::DoScan(TarScanner::BASESET);
 

	
 
	if (dedicated) DEBUG(net, 3, "Starting dedicated server, version %s", _openttd_revision);
 
	if (dedicated) Debug(net, 3, "Starting dedicated server, version {}", _openttd_revision);
 
	if (_dedicated_forks && !dedicated) _dedicated_forks = false;
 

	
 
#if defined(UNIX)
 
	/* We must fork here, or we'll end up without some resources we need (like sockets) */
 
	if (_dedicated_forks) DedicatedFork();
 
#endif
 
@@ -712,13 +712,13 @@ int openttd_main(int argc, char *argv[])
 
		}
 
	}
 

	
 
	/* Initialize game palette */
 
	GfxInitPalettes();
 

	
 
	DEBUG(misc, 1, "Loading blitter...");
 
	Debug(misc, 1, "Loading blitter...");
 
	if (blitter.empty() && !_ini_blitter.empty()) blitter = _ini_blitter;
 
	_blitter_autodetected = blitter.empty();
 
	/* Activate the initial blitter.
 
	 * This is only some initial guess, after NewGRFs have been loaded SwitchNewGRFBlitter may switch to a different one.
 
	 *  - Never guess anything, if the user specified a blitter. (_blitter_autodetected)
 
	 *  - Use 32bpp blitter if baseset or 8bpp-support settings says so.
 
@@ -942,13 +942,13 @@ bool SafeLoad(const std::string &filenam
 
				/*
 
				 * We need to reinit a network map...
 
				 * We can't simply load the intro game here as that game has many
 
				 * special cases which make clients desync immediately. So we fall
 
				 * back to just generating a new game with the current settings.
 
				 */
 
				DEBUG(net, 0, "Loading game failed, so a new (random) game will be started");
 
				Debug(net, 0, "Loading game failed, so a new (random) game will be started");
 
				MakeNewGame(false, true);
 
				return false;
 
			}
 
			if (_network_server) {
 
				/* We can't load the intro game as server, so disconnect first. */
 
				NetworkDisconnect();
 
@@ -1133,13 +1133,13 @@ static void CheckCaches()
 
	RebuildTownCaches();
 
	RebuildSubsidisedSourceAndDestinationCache();
 

	
 
	uint i = 0;
 
	for (Town *t : Town::Iterate()) {
 
		if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
 
			DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
 
			Debug(desync, 2, "town cache mismatch: town {}", t->index);
 
		}
 
		i++;
 
	}
 

	
 
	/* Check company infrastructure cache. */
 
	std::vector<CompanyInfrastructure> old_infrastructure;
 
@@ -1148,13 +1148,13 @@ static void CheckCaches()
 
	extern void AfterLoadCompanyStats();
 
	AfterLoadCompanyStats();
 

	
 
	i = 0;
 
	for (const Company *c : Company::Iterate()) {
 
		if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
 
			DEBUG(desync, 2, "infrastructure cache mismatch: company %i", (int)c->index);
 
			Debug(desync, 2, "infrastructure cache mismatch: company {}", c->index);
 
		}
 
		i++;
 
	}
 

	
 
	/* Strict checking of the road stop cache entries */
 
	for (const RoadStop *rs : RoadStop::Iterate()) {
 
@@ -1205,29 +1205,29 @@ static void CheckCaches()
 
		}
 

	
 
		length = 0;
 
		for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
 
			FillNewGRFVehicleCache(u);
 
			if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) {
 
				DEBUG(desync, 2, "newgrf cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
 
				Debug(desync, 2, "newgrf cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
 
			}
 
			if (memcmp(&veh_cache[length], &u->vcache, sizeof(VehicleCache)) != 0) {
 
				DEBUG(desync, 2, "vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
 
				Debug(desync, 2, "vehicle cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
 
			}
 
			switch (u->type) {
 
				case VEH_TRAIN:
 
					if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
 
						DEBUG(desync, 2, "train ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
 
						Debug(desync, 2, "train ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
 
					}
 
					if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
 
						DEBUG(desync, 2, "train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
 
						Debug(desync, 2, "train cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
 
					}
 
					break;
 
				case VEH_ROAD:
 
					if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
 
						DEBUG(desync, 2, "road vehicle ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
 
						Debug(desync, 2, "road vehicle ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
 
					}
 
					break;
 
				default:
 
					break;
 
			}
 
			length++;
 
@@ -1268,40 +1268,40 @@ static void CheckCaches()
 
		for (TileIndex tile : st->docking_station) {
 
			ta.Add(tile);
 
			docking_tiles[tile] = IsDockingTile(tile);
 
		}
 
		UpdateStationDockingTiles(st);
 
		if (ta.tile != st->docking_station.tile || ta.w != st->docking_station.w || ta.h != st->docking_station.h) {
 
			DEBUG(desync, 2, "station docking mismatch: station %i, company %i", st->index, (int)st->owner);
 
			Debug(desync, 2, "station docking mismatch: station {}, company {}", st->index, st->owner);
 
		}
 
		for (TileIndex tile : ta) {
 
			if (docking_tiles[tile] != IsDockingTile(tile)) {
 
				DEBUG(desync, 2, "docking tile mismatch: tile %i", (int)tile);
 
				Debug(desync, 2, "docking tile mismatch: tile {}", tile);
 
			}
 
		}
 

	
 
		/* Check industries_near */
 
		IndustryList industries_near = st->industries_near;
 
		st->RecomputeCatchment();
 
		if (st->industries_near != industries_near) {
 
			DEBUG(desync, 2, "station industries near mismatch: station %i", st->index);
 
			Debug(desync, 2, "station industries near mismatch: station {}", st->index);
 
		}
 
	}
 

	
 
	/* Check stations_near */
 
	i = 0;
 
	for (Town *t : Town::Iterate()) {
 
		if (t->stations_near != old_town_stations_near[i]) {
 
			DEBUG(desync, 2, "town stations near mismatch: town %i", t->index);
 
			Debug(desync, 2, "town stations near mismatch: town {}", t->index);
 
		}
 
		i++;
 
	}
 
	i = 0;
 
	for (Industry *ind : Industry::Iterate()) {
 
		if (ind->stations_near != old_industry_stations_near[i]) {
 
			DEBUG(desync, 2, "industry stations near mismatch: industry %i", ind->index);
 
			Debug(desync, 2, "industry stations near mismatch: industry {}", ind->index);
 
		}
 
		i++;
 
	}
 
}
 

	
 
/**
 
@@ -1403,13 +1403,13 @@ static void DoAutosave()
 
		/* generate a savegame name and number according to _settings_client.gui.max_num_autosaves */
 
		seprintf(buf, lastof(buf), "autosave%d.sav", _autosave_ctr);
 

	
 
		if (++_autosave_ctr >= _settings_client.gui.max_num_autosaves) _autosave_ctr = 0;
 
	}
 

	
 
	DEBUG(sl, 2, "Autosaving to '%s'", buf);
 
	Debug(sl, 2, "Autosaving to '{}'", buf);
 
	if (SaveOrLoad(buf, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR) != SL_OK) {
 
		ShowErrorMessage(STR_ERROR_AUTOSAVE_FAILED, INVALID_STRING_ID, WL_ERROR);
 
	}
 
}
 

	
 
/**