Changeset - r27045:822ceeea88a2
[Not reviewed]
master
0 5 0
Peter Nelson - 14 months ago 2023-04-05 06:49:41
peter1138@openttd.org
Codechange: Be consistent with how company masks are set to all.
5 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -672,13 +672,13 @@ void StartupOneEngine(Engine *e, Date ag
 
	/* Don't randomise the start-date in the first two years after gamestart to ensure availability
 
	 * of engines in early starting games.
 
	 * Note: TTDP uses fixed 1922 */
 
	e->intro_date = ei->base_intro <= ConvertYMDToDate(_settings_game.game_creation.starting_year + 2, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro;
 
	if (e->intro_date <= _date) {
 
		e->age = (aging_date - e->intro_date) >> 5;
 
		e->company_avail = (CompanyMask)-1;
 
		e->company_avail = MAX_UVALUE(CompanyMask);
 
		e->flags |= ENGINE_AVAILABLE;
 
	}
 

	
 
	/* Get parent variant index for syncing reliability via random seed. */
 
	const Engine *re = e;
 
	while (re->info.variant_id != INVALID_ENGINE && re->info.variant_id != re->index && (re->info.extra_flags & ExtraEngineFlags::SyncReliability) != ExtraEngineFlags::None) {
 
@@ -801,13 +801,13 @@ static void DisableEngineForCompany(Engi
 
 */
 
static void AcceptEnginePreview(EngineID eid, CompanyID company, int recursion_depth = 0)
 
{
 
	Engine *e = Engine::Get(eid);
 

	
 
	e->preview_company = INVALID_COMPANY;
 
	e->preview_asked = (CompanyMask)-1;
 
	e->preview_asked = MAX_UVALUE(CompanyMask);
 

	
 
	EnableEngineForCompany(eid, company);
 

	
 
	/* Notify preview window, that it might want to close.
 
	 * Note: We cannot directly close the window.
 
	 *       In singleplayer this function is called from the preview window, so
 
@@ -896,13 +896,13 @@ void EnginesDailyLoop()
 
					e->preview_company = INVALID_COMPANY;
 
				}
 
			} else if (CountBits(e->preview_asked) < MAX_COMPANIES) {
 
				e->preview_company = GetPreviewCompany(e);
 

	
 
				if (e->preview_company == INVALID_COMPANY) {
 
					e->preview_asked = (CompanyMask)-1;
 
					e->preview_asked = MAX_UVALUE(CompanyMask);
 
					continue;
 
				}
 

	
 
				SetBit(e->preview_asked, e->preview_company);
 
				e->preview_wait = 20;
 
				/* AIs are intentionally not skipped for preview even if they cannot build a certain
 
@@ -1025,13 +1025,13 @@ static void NewVehicleAvailable(Engine *
 
	}
 

	
 
	e->flags = (e->flags & ~ENGINE_EXCLUSIVE_PREVIEW) | ENGINE_AVAILABLE;
 
	AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);
 

	
 
	/* Now available for all companies */
 
	e->company_avail = (CompanyMask)-1;
 
	e->company_avail = MAX_UVALUE(CompanyMask);
 

	
 
	/* Do not introduce new rail wagons */
 
	if (IsWagon(index)) return;
 

	
 
	if (e->type == VEH_TRAIN) {
 
		/* maybe make another rail type available */
src/road.cpp
Show inline comments
 
@@ -283,13 +283,13 @@ RoadTypes ExistingRoadTypes(CompanyID c)
 
	/* Find used roadtypes */
 
	for (Engine *e : Engine::IterateType(VEH_ROAD)) {
 
		/* Check if the roadtype can be used in the current climate */
 
		if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
 

	
 
		/* Check whether available for all potential companies */
 
		if (e->company_avail != (CompanyMask)-1) continue;
 
		if (e->company_avail != MAX_UVALUE(CompanyMask)) continue;
 

	
 
		known_roadtypes |= GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes;
 
	}
 

	
 
	/* Get the date introduced roadtypes as well. */
 
	known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, MAX_DAY);
src/saveload/afterload.cpp
Show inline comments
 
@@ -2008,21 +2008,21 @@ bool AfterLoadGame()
 
				a->engine_type = a->First()->engine_type;
 
			}
 
		}
 

	
 
		/* More companies ... */
 
		for (Company *c : Company::Iterate()) {
 
			if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = 0xFFFF;
 
			if (c->bankrupt_asked == 0xFF) c->bankrupt_asked = MAX_UVALUE(CompanyMask);
 
		}
 

	
 
		for (Engine *e : Engine::Iterate()) {
 
			if (e->company_avail == 0xFF) e->company_avail = 0xFFFF;
 
			if (e->company_avail == 0xFF) e->company_avail = MAX_UVALUE(CompanyMask);
 
		}
 

	
 
		for (Town *t : Town::Iterate()) {
 
			if (t->have_ratings == 0xFF) t->have_ratings = 0xFFFF;
 
			if (t->have_ratings == 0xFF) t->have_ratings = MAX_UVALUE(CompanyMask);
 
			for (uint i = 8; i != MAX_COMPANIES; i++) t->ratings[i] = RATING_INITIAL;
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_112)) {
 
		for (auto t : Map::Iterate()) {
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -107,13 +107,13 @@ struct ENGNChunkHandler : ChunkHandler {
 

	
 
			if (IsSavegameVersionBefore(SLV_179)) {
 
				/* preview_company_rank was replaced with preview_company and preview_asked.
 
				 * Just cancel any previews. */
 
				e->flags &= ~4; // ENGINE_OFFER_WINDOW_OPEN
 
				e->preview_company = INVALID_COMPANY;
 
				e->preview_asked = (CompanyMask)-1;
 
				e->preview_asked = MAX_UVALUE(CompanyMask);
 
			}
 
		}
 
	}
 
};
 

	
 
/**
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -410,13 +410,13 @@ static bool FixTTOEngines()
 
			e->intro_date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 
			_date -= DAYS_TILL_ORIGINAL_BASE_YEAR;
 

	
 
			/* Make sure for example monorail and maglev are available when they should be */
 
			if (_date >= e->intro_date && HasBit(e->info.climates, 0)) {
 
				e->flags |= ENGINE_AVAILABLE;
 
				e->company_avail = (CompanyMask)0xFF;
 
				e->company_avail = MAX_UVALUE(CompanyMask);
 
				e->age = _date > e->intro_date ? (_date - e->intro_date) / 30 : 0;
 
			}
 
		} else {
 
			/* Using data from TTO savegame */
 
			Engine *oe = &_old_engines[oi];
 

	
 
@@ -435,23 +435,23 @@ static bool FixTTOEngines()
 
			e->company_avail = 0;
 

	
 
			/* One or more engines were remapped to this one. Make this engine available
 
			 * if at least one of them was available. */
 
			for (uint j = 0; j < lengthof(tto_to_ttd); j++) {
 
				if (tto_to_ttd[j] == i && _old_engines[j].company_avail != 0) {
 
					e->company_avail = (CompanyMask)0xFF;
 
					e->company_avail = MAX_UVALUE(CompanyMask);
 
					e->flags |= ENGINE_AVAILABLE;
 
					break;
 
				}
 
			}
 

	
 
			e->info.climates = 1;
 
		}
 

	
 
		e->preview_company = INVALID_COMPANY;
 
		e->preview_asked = (CompanyMask)-1;
 
		e->preview_asked = MAX_UVALUE(CompanyMask);
 
		e->preview_wait = 0;
 
		e->name = std::string{};
 
	}
 

	
 
	return true;
 
}
0 comments (0 inline, 0 general)