Changeset - r11917:612c11f7ab47
[Not reviewed]
master
! ! !
smatz - 15 years ago 2009-05-16 23:34:14
smatz@openttd.org
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
116 files changed with 645 insertions and 637 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_core.cpp
Show inline comments
 
@@ -42,7 +42,7 @@
 
	}
 

	
 
	_current_company = company;
 
	Company *c = GetCompany(company);
 
	Company *c = Company::Get(company);
 

	
 
	c->ai_info = info;
 
	assert(c->ai_instance == NULL);
 
@@ -74,7 +74,7 @@
 
	 * Effectively collecting garbage once every two months per AI. */
 
	if ((AI::frame_counter & 255) == 0) {
 
		CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
 
		if (IsValidCompanyID(cid) && !IsHumanCompany(cid)) GetCompany(cid)->ai_instance->CollectGarbage();
 
		if (IsValidCompanyID(cid) && !IsHumanCompany(cid)) Company::Get(cid)->ai_instance->CollectGarbage();
 
	}
 

	
 
	_current_company = OWNER_NONE;
 
@@ -91,7 +91,7 @@
 

	
 
	CompanyID old_company = _current_company;
 
	_current_company = company;
 
	Company *c = GetCompany(company);
 
	Company *c = Company::Get(company);
 

	
 
	delete c->ai_instance;
 
	c->ai_instance = NULL;
 
@@ -221,18 +221,18 @@ void CcAI(bool success, TileIndex tile, 
 
		AIObject::IncreaseDoCommandCosts(AIObject::GetLastCost());
 
	}
 

	
 
	GetCompany(_current_company)->ai_instance->Continue();
 
	Company::Get(_current_company)->ai_instance->Continue();
 
}
 

	
 
/* static */ void AI::Save(CompanyID company)
 
{
 
	if (!_networking || _network_server) {
 
		assert(IsValidCompanyID(company));
 
		assert(GetCompany(company)->ai_instance != NULL);
 
		assert(Company::Get(company)->ai_instance != NULL);
 

	
 
		CompanyID old_company = _current_company;
 
		_current_company = company;
 
		GetCompany(company)->ai_instance->Save();
 
		Company::Get(company)->ai_instance->Save();
 
		_current_company = old_company;
 
	} else {
 
		AIInstance::SaveEmpty();
 
@@ -243,11 +243,11 @@ void CcAI(bool success, TileIndex tile, 
 
{
 
	if (!_networking || _network_server) {
 
		assert(IsValidCompanyID(company));
 
		assert(GetCompany(company)->ai_instance != NULL);
 
		assert(Company::Get(company)->ai_instance != NULL);
 

	
 
		CompanyID old_company = _current_company;
 
		_current_company = company;
 
		GetCompany(company)->ai_instance->Load(version);
 
		Company::Get(company)->ai_instance->Load(version);
 
		_current_company = old_company;
 
	} else {
 
		/* Read, but ignore, the load data */
 
@@ -288,7 +288,7 @@ void CcAI(bool success, TileIndex tile, 
 

	
 
/* static */ bool AI::ImportLibrary(const char *library, const char *class_name, int version, HSQUIRRELVM vm)
 
{
 
	return AI::ai_scanner->ImportLibrary(library, class_name, version, vm, GetCompany(_current_company)->ai_instance->GetController());
 
	return AI::ai_scanner->ImportLibrary(library, class_name, version, vm, Company::Get(_current_company)->ai_instance->GetController());
 
}
 

	
 
/* static */ void AI::Rescan()
src/ai/ai_gui.cpp
Show inline comments
 
@@ -641,7 +641,7 @@ struct AIDebugWindow : public Window {
 
	{
 
		/* Disable the companies who are not active or not an AI */
 
		for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
			this->SetWidgetDisabledState(i + AID_WIDGET_COMPANY_BUTTON_START, !IsValidCompanyID(i) || !GetCompany(i)->is_ai);
 
			this->SetWidgetDisabledState(i + AID_WIDGET_COMPANY_BUTTON_START, !IsValidCompanyID(i) || !Company::Get(i)->is_ai);
 
		}
 
		this->DisableWidget(AID_WIDGET_RELOAD_TOGGLE);
 

	
 
@@ -669,7 +669,7 @@ struct AIDebugWindow : public Window {
 
			}
 

	
 
			for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
				if (IsValidCompanyID(i) && GetCompany(i)->is_ai) {
 
				if (IsValidCompanyID(i) && Company::Get(i)->is_ai) {
 
					/* Lower the widget corresponding to this company. */
 
					this->LowerWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
 

	
 
@@ -690,7 +690,7 @@ struct AIDebugWindow : public Window {
 

	
 
		/* Paint the company icons */
 
		for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
 
			if (!IsValidCompanyID(i) || !GetCompany(i)->is_ai) {
 
			if (!IsValidCompanyID(i) || !Company::Get(i)->is_ai) {
 
				/* Check if we have the company as an active company */
 
				if (!this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
 
					/* Bah, company gone :( */
 
@@ -716,7 +716,7 @@ struct AIDebugWindow : public Window {
 
		}
 

	
 
		/* Draw the AI name */
 
		AIInfo *info = GetCompany(ai_debug_company)->ai_info;
 
		AIInfo *info = Company::Get(ai_debug_company)->ai_info;
 
		assert(info != NULL);
 
		char name[1024];
 
		snprintf(name, sizeof(name), "%s (v%d)", info->GetName(), info->GetVersion());
src/ai/ai_instance.cpp
Show inline comments
 
@@ -103,7 +103,7 @@ AIInstance::AIInstance(AIInfo *info) :
 
	callback(NULL)
 
{
 
	/* Set the instance already, so we can use AIObject::Set commands */
 
	GetCompany(_current_company)->ai_instance = this;
 
	Company::Get(_current_company)->ai_instance = this;
 
	AIInstance::current_instance = this;
 

	
 
	this->controller = new AIController();
 
@@ -354,7 +354,7 @@ void AIInstance::CollectGarbage()
 
/* static */ AIStorage *AIInstance::GetStorage()
 
{
 
	assert(IsValidCompanyID(_current_company) && !IsHumanCompany(_current_company));
 
	return GetCompany(_current_company)->ai_instance->storage;
 
	return Company::Get(_current_company)->ai_instance->storage;
 
}
 

	
 
/*
src/ai/api/ai_airport.cpp
Show inline comments
 
@@ -110,7 +110,7 @@
 

	
 
	if (!AIStation::HasStationType(station_id, AIStation::STATION_AIRPORT)) return AT_INVALID;
 

	
 
	return (AirportType)::GetStation(station_id)->airport_type;
 
	return (AirportType)::Station::Get(station_id)->airport_type;
 
}
 

	
 

	
src/ai/api/ai_cargolist.cpp
Show inline comments
 
@@ -22,7 +22,7 @@ AICargoList_IndustryAccepting::AICargoLi
 
{
 
	if (!AIIndustry::IsValidIndustry(industry_id)) return;
 

	
 
	Industry *ind = ::GetIndustry(industry_id);
 
	Industry *ind = ::Industry::Get(industry_id);
 
	for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
 
		CargoID cargo_id = ind->accepts_cargo[i];
 
		if (cargo_id != CT_INVALID) {
 
@@ -35,7 +35,7 @@ AICargoList_IndustryProducing::AICargoLi
 
{
 
	if (!AIIndustry::IsValidIndustry(industry_id)) return;
 

	
 
	Industry *ind = ::GetIndustry(industry_id);
 
	Industry *ind = ::Industry::Get(industry_id);
 
	for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
 
		CargoID cargo_id = ind->produced_cargo[i];
 
		if (cargo_id != CT_INVALID) {
src/ai/api/ai_company.cpp
Show inline comments
 
@@ -76,7 +76,7 @@
 
	company = ResolveCompanyID(company);
 
	if (company == COMPANY_INVALID) return -1;
 

	
 
	return ::CalculateCompanyValue(::GetCompany((CompanyID)company));
 
	return ::CalculateCompanyValue(::Company::Get((CompanyID)company));
 
}
 

	
 
/* static */ Money AICompany::GetBankBalance(AICompany::CompanyID company)
 
@@ -84,12 +84,12 @@
 
	company = ResolveCompanyID(company);
 
	if (company == COMPANY_INVALID) return -1;
 

	
 
	return ::GetCompany((CompanyID)company)->money;
 
	return ::Company::Get((CompanyID)company)->money;
 
}
 

	
 
/* static */ Money AICompany::GetLoanAmount()
 
{
 
	return ::GetCompany(_current_company)->current_loan;
 
	return ::Company::Get(_current_company)->current_loan;
 
}
 

	
 
/* static */ Money AICompany::GetMaxLoanAmount()
 
@@ -142,7 +142,7 @@
 
	company = ResolveCompanyID(company);
 
	if (company == COMPANY_INVALID) return INVALID_TILE;
 

	
 
	TileIndex loc = ::GetCompany((CompanyID)company)->location_of_HQ;
 
	TileIndex loc = ::Company::Get((CompanyID)company)->location_of_HQ;
 
	return (loc == 0) ? INVALID_TILE : loc;
 
}
 

	
 
@@ -156,7 +156,7 @@
 
	company = ResolveCompanyID(company);
 
	if (company == COMPANY_INVALID) return false;
 

	
 
	return ::GetCompany((CompanyID)company)->settings.engine_renew;
 
	return ::Company::Get((CompanyID)company)->settings.engine_renew;
 
}
 

	
 
/* static */ bool AICompany::SetAutoRenewMonths(int16 months)
 
@@ -169,7 +169,7 @@
 
	company = ResolveCompanyID(company);
 
	if (company == COMPANY_INVALID) return 0;
 

	
 
	return ::GetCompany((CompanyID)company)->settings.engine_renew_months;
 
	return ::Company::Get((CompanyID)company)->settings.engine_renew_months;
 
}
 

	
 
/* static */ bool AICompany::SetAutoRenewMoney(uint32 money)
 
@@ -182,5 +182,5 @@
 
	company = ResolveCompanyID(company);
 
	if (company == COMPANY_INVALID) return 0;
 

	
 
	return ::GetCompany((CompanyID)company)->settings.engine_renew_money;
 
	return ::Company::Get((CompanyID)company)->settings.engine_renew_money;
 
}
src/ai/api/ai_controller.cpp
Show inline comments
 
@@ -59,7 +59,7 @@ AIController::~AIController()
 

	
 
/* static */ uint AIController::GetTick()
 
{
 
	return ::GetCompany(_current_company)->ai_instance->GetController()->ticks;
 
	return ::Company::Get(_current_company)->ai_instance->GetController()->ticks;
 
}
 

	
 
/* static */ int AIController::GetSetting(const char *name)
src/ai/api/ai_engine.cpp
Show inline comments
 
@@ -15,7 +15,7 @@
 

	
 
/* static */ bool AIEngine::IsValidEngine(EngineID engine_id)
 
{
 
	return ::IsEngineIndex(engine_id) && HasBit(::GetEngine(engine_id)->company_avail, _current_company);
 
	return ::IsEngineIndex(engine_id) && HasBit(::Engine::Get(engine_id)->company_avail, _current_company);
 
}
 

	
 
/* static */ char *AIEngine::GetName(EngineID engine_id)
 
@@ -34,7 +34,7 @@
 
{
 
	if (!IsValidEngine(engine_id)) return CT_INVALID;
 

	
 
	const Engine *e = ::GetEngine(engine_id);
 
	const Engine *e = ::Engine::Get(engine_id);
 
	if (!e->CanCarryCargo()) return CT_INVALID;
 

	
 
	return e->GetDefaultCargoType();
 
@@ -46,8 +46,8 @@
 
	if (!AICargo::IsValidCargo(cargo_id)) return false;
 

	
 
	if (GetCargoType(engine_id) == cargo_id) return true;
 
	if (cargo_id == CT_MAIL && ::GetEngine(engine_id)->type == VEH_AIRCRAFT) return true;
 
	if (::GetEngine(engine_id)->type == VEH_SHIP && !ShipVehInfo(engine_id)->refittable) return false;
 
	if (cargo_id == CT_MAIL && ::Engine::Get(engine_id)->type == VEH_AIRCRAFT) return true;
 
	if (::Engine::Get(engine_id)->type == VEH_SHIP && !ShipVehInfo(engine_id)->refittable) return false;
 
	return ::CanRefitTo(engine_id, cargo_id);
 
}
 

	
 
@@ -65,7 +65,7 @@
 
{
 
	if (!IsValidEngine(engine_id)) return -1;
 

	
 
	const Engine *e = ::GetEngine(engine_id);
 
	const Engine *e = ::Engine::Get(engine_id);
 
	switch (e->type) {
 
		case VEH_ROAD:
 
		case VEH_TRAIN: {
 
@@ -91,14 +91,14 @@
 
	if (!IsValidEngine(engine_id)) return -1;
 
	if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
 

	
 
	return (::GetEngine(engine_id)->reliability * 100 >> 16);
 
	return (::Engine::Get(engine_id)->reliability * 100 >> 16);
 
}
 

	
 
/* static */ int32 AIEngine::GetMaxSpeed(EngineID engine_id)
 
{
 
	if (!IsValidEngine(engine_id)) return -1;
 

	
 
	const Engine *e = ::GetEngine(engine_id);
 
	const Engine *e = ::Engine::Get(engine_id);
 
	int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
 
	if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
 
	return max_speed;
 
@@ -108,7 +108,7 @@
 
{
 
	if (!IsValidEngine(engine_id)) return -1;
 

	
 
	return ::GetEngine(engine_id)->GetCost();
 
	return ::Engine::Get(engine_id)->GetCost();
 
}
 

	
 
/* static */ int32 AIEngine::GetMaxAge(EngineID engine_id)
 
@@ -116,14 +116,14 @@
 
	if (!IsValidEngine(engine_id)) return -1;
 
	if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(engine_id)) return -1;
 

	
 
	return ::GetEngine(engine_id)->lifelength * DAYS_IN_LEAP_YEAR;
 
	return ::Engine::Get(engine_id)->lifelength * DAYS_IN_LEAP_YEAR;
 
}
 

	
 
/* static */ Money AIEngine::GetRunningCost(EngineID engine_id)
 
{
 
	if (!IsValidEngine(engine_id)) return -1;
 

	
 
	return ::GetEngine(engine_id)->GetRunningCost();
 
	return ::Engine::Get(engine_id)->GetRunningCost();
 
}
 

	
 
/* static */ int32 AIEngine::GetPower(EngineID engine_id)
 
@@ -132,7 +132,7 @@
 
	if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
 
	if (IsWagon(engine_id)) return -1;
 

	
 
	return ::GetEngine(engine_id)->GetPower();
 
	return ::Engine::Get(engine_id)->GetPower();
 
}
 

	
 
/* static */ int32 AIEngine::GetWeight(EngineID engine_id)
 
@@ -140,7 +140,7 @@
 
	if (!IsValidEngine(engine_id)) return -1;
 
	if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
 

	
 
	return ::GetEngine(engine_id)->GetDisplayWeight();
 
	return ::Engine::Get(engine_id)->GetDisplayWeight();
 
}
 

	
 
/* static */ int32 AIEngine::GetMaxTractiveEffort(EngineID engine_id)
 
@@ -149,14 +149,14 @@
 
	if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
 
	if (IsWagon(engine_id)) return -1;
 

	
 
	return ::GetEngine(engine_id)->GetDisplayMaxTractiveEffort();
 
	return ::Engine::Get(engine_id)->GetDisplayMaxTractiveEffort();
 
}
 

	
 
/* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id)
 
{
 
	if (!IsValidEngine(engine_id)) return AIVehicle::VT_INVALID;
 

	
 
	switch (::GetEngine(engine_id)->type) {
 
	switch (::Engine::Get(engine_id)->type) {
 
		case VEH_ROAD:     return AIVehicle::VT_ROAD;
 
		case VEH_TRAIN:    return AIVehicle::VT_RAIL;
 
		case VEH_SHIP:     return AIVehicle::VT_WATER;
src/ai/api/ai_event_types.cpp
Show inline comments
 
@@ -24,14 +24,14 @@ char *AIEventEnginePreview::GetName()
 

	
 
CargoID AIEventEnginePreview::GetCargoType()
 
{
 
	const Engine *e = ::GetEngine(engine);
 
	const Engine *e = ::Engine::Get(engine);
 
	if (!e->CanCarryCargo()) return CT_INVALID;
 
	return e->GetDefaultCargoType();
 
}
 

	
 
int32 AIEventEnginePreview::GetCapacity()
 
{
 
	const Engine *e = ::GetEngine(engine);
 
	const Engine *e = ::Engine::Get(engine);
 
	switch (e->type) {
 
		case VEH_ROAD:
 
		case VEH_TRAIN: {
 
@@ -54,7 +54,7 @@ int32 AIEventEnginePreview::GetCapacity(
 

	
 
int32 AIEventEnginePreview::GetMaxSpeed()
 
{
 
	const Engine *e = ::GetEngine(engine);
 
	const Engine *e = ::Engine::Get(engine);
 
	int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
 
	if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
 
	return max_speed;
 
@@ -62,17 +62,17 @@ int32 AIEventEnginePreview::GetMaxSpeed(
 

	
 
Money AIEventEnginePreview::GetPrice()
 
{
 
	return ::GetEngine(engine)->GetCost();
 
	return ::Engine::Get(engine)->GetCost();
 
}
 

	
 
Money AIEventEnginePreview::GetRunningCost()
 
{
 
	return ::GetEngine(engine)->GetRunningCost();
 
	return ::Engine::Get(engine)->GetRunningCost();
 
}
 

	
 
int32 AIEventEnginePreview::GetVehicleType()
 
{
 
	switch (::GetEngine(engine)->type) {
 
	switch (::Engine::Get(engine)->type) {
 
		case VEH_ROAD:     return AIVehicle::VT_ROAD;
 
		case VEH_TRAIN:    return AIVehicle::VT_RAIL;
 
		case VEH_SHIP:     return AIVehicle::VT_WATER;
src/ai/api/ai_group.cpp
Show inline comments
 
@@ -16,7 +16,7 @@
 

	
 
/* static */ bool AIGroup::IsValidGroup(GroupID group_id)
 
{
 
	return ::IsValidGroupID(group_id) && ::GetGroup(group_id)->owner == _current_company;
 
	return ::IsValidGroupID(group_id) && ::Group::Get(group_id)->owner == _current_company;
 
}
 

	
 
/* static */ AIGroup::GroupID AIGroup::CreateGroup(AIVehicle::VehicleType vehicle_type)
 
@@ -38,7 +38,7 @@
 
{
 
	if (!IsValidGroup(group_id)) return AIVehicle::VT_INVALID;
 

	
 
	return (AIVehicle::VehicleType)((::VehicleType)::GetGroup(group_id)->vehicle_type);
 
	return (AIVehicle::VehicleType)((::VehicleType)::Group::Get(group_id)->vehicle_type);
 
}
 

	
 
/* static */ bool AIGroup::SetName(GroupID group_id, const char *name)
 
@@ -73,7 +73,7 @@
 
{
 
	if (!IsValidGroup(group_id)) return false;
 

	
 
	return ::GetGroup(group_id)->replace_protection;
 
	return ::Group::Get(group_id)->replace_protection;
 
}
 

	
 
/* static */ int32 AIGroup::GetNumEngines(GroupID group_id, EngineID engine_id)
 
@@ -100,7 +100,7 @@
 

	
 
/* static */ bool AIGroup::HasWagonRemoval()
 
{
 
	return ::GetCompany(_current_company)->settings.renew_keep_length;
 
	return ::Company::Get(_current_company)->settings.renew_keep_length;
 
}
 

	
 
/* static */ bool AIGroup::SetAutoReplace(GroupID group_id, EngineID engine_id_old, EngineID engine_id_new)
 
@@ -115,7 +115,7 @@
 
{
 
	if (!IsValidGroup(group_id) && group_id != GROUP_ALL) return ::INVALID_ENGINE;
 

	
 
	return ::EngineReplacementForCompany(GetCompany(_current_company), engine_id, group_id);
 
	return ::EngineReplacementForCompany(Company::Get(_current_company), engine_id, group_id);
 
}
 

	
 
/* static */ bool AIGroup::StopAutoReplace(GroupID group_id, EngineID engine_id)
src/ai/api/ai_industry.cpp
Show inline comments
 
@@ -38,7 +38,7 @@
 
	if (!IsValidIndustry(industry_id)) return false;
 
	if (!AICargo::IsValidCargo(cargo_id)) return false;
 

	
 
	const Industry *i = ::GetIndustry(industry_id);
 
	const Industry *i = ::Industry::Get(industry_id);
 

	
 
	for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
 
		if (i->accepts_cargo[j] == cargo_id) return true;
 
@@ -52,7 +52,7 @@
 
	if (!IsValidIndustry(industry_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	Industry *ind = ::GetIndustry(industry_id);
 
	Industry *ind = ::Industry::Get(industry_id);
 
	for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
 
		CargoID cid = ind->accepts_cargo[i];
 
		if (cid == cargo_id) {
 
@@ -68,7 +68,7 @@
 
	if (!IsValidIndustry(industry_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	const Industry *i = ::GetIndustry(industry_id);
 
	const Industry *i = ::Industry::Get(industry_id);
 

	
 
	for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
		if (i->produced_cargo[j] == cargo_id) return i->last_month_production[j];
 
@@ -82,7 +82,7 @@
 
	if (!IsValidIndustry(industry_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	const Industry *i = ::GetIndustry(industry_id);
 
	const Industry *i = ::Industry::Get(industry_id);
 

	
 
	for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
 
		if (i->produced_cargo[j] == cargo_id) return i->last_month_transported[j];
 
@@ -95,14 +95,14 @@
 
{
 
	if (!IsValidIndustry(industry_id)) return INVALID_TILE;
 

	
 
	return ::GetIndustry(industry_id)->xy;
 
	return ::Industry::Get(industry_id)->xy;
 
}
 

	
 
/* static */ int32 AIIndustry::GetAmountOfStationsAround(IndustryID industry_id)
 
{
 
	if (!IsValidIndustry(industry_id)) return -1;
 

	
 
	Industry *ind = ::GetIndustry(industry_id);
 
	Industry *ind = ::Industry::Get(industry_id);
 
	StationList stations;
 
	::FindStationsAroundTiles(ind->xy, ind->width, ind->height, &stations);
 
	return (int32)stations.Length();
 
@@ -126,14 +126,14 @@
 
{
 
	if (!IsValidIndustry(industry_id)) return false;
 

	
 
	return (::GetIndustrySpec(::GetIndustry(industry_id)->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
 
	return (::GetIndustrySpec(::Industry::Get(industry_id)->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) != 0;
 
}
 

	
 
/* static */ bool AIIndustry::HasHeliport(IndustryID industry_id)
 
{
 
	if (!IsValidIndustry(industry_id)) return false;
 

	
 
	return (::GetIndustrySpec(::GetIndustry(industry_id)->type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
 
	return (::GetIndustrySpec(::Industry::Get(industry_id)->type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
 
}
 

	
 
/* static */ TileIndex AIIndustry::GetHeliportLocation(IndustryID industry_id)
 
@@ -141,7 +141,7 @@
 
	if (!IsValidIndustry(industry_id)) return INVALID_TILE;
 
	if (!HasHeliport(industry_id)) return INVALID_TILE;
 

	
 
	const Industry *ind = ::GetIndustry(industry_id);
 
	const Industry *ind = ::Industry::Get(industry_id);
 
	BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
 
		if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
 
			return tile_cur;
 
@@ -155,7 +155,7 @@
 
{
 
	if (!IsValidIndustry(industry_id)) return false;
 

	
 
	return (::GetIndustrySpec(::GetIndustry(industry_id)->type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
 
	return (::GetIndustrySpec(::Industry::Get(industry_id)->type)->behaviour & INDUSTRYBEH_AI_AIRSHIP_ROUTES) != 0;
 
}
 

	
 
/* static */ TileIndex AIIndustry::GetDockLocation(IndustryID industry_id)
 
@@ -163,7 +163,7 @@
 
	if (!IsValidIndustry(industry_id)) return INVALID_TILE;
 
	if (!HasDock(industry_id)) return INVALID_TILE;
 

	
 
	const Industry *ind = ::GetIndustry(industry_id);
 
	const Industry *ind = ::Industry::Get(industry_id);
 
	BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
 
		if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
 
			return tile_cur;
 
@@ -177,5 +177,5 @@
 
{
 
	if (!IsValidIndustry(industry_id)) return INVALID_INDUSTRYTYPE;
 

	
 
	return ::GetIndustry(industry_id)->type;
 
	return ::Industry::Get(industry_id)->type;
 
}
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -43,7 +43,7 @@ static OrderType GetOrderTypeByTile(Tile
 

	
 
/* static */ bool AIOrder::IsValidVehicleOrder(VehicleID vehicle_id, OrderPosition order_position)
 
{
 
	return AIVehicle::IsValidVehicle(vehicle_id) && order_position >= 0 && (order_position < ::GetVehicle(vehicle_id)->GetNumOrders() || order_position == ORDER_CURRENT);
 
	return AIVehicle::IsValidVehicle(vehicle_id) && order_position >= 0 && (order_position < ::Vehicle::Get(vehicle_id)->GetNumOrders() || order_position == ORDER_CURRENT);
 
}
 

	
 
/**
 
@@ -53,7 +53,7 @@ static OrderType GetOrderTypeByTile(Tile
 
 */
 
static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition order_position)
 
{
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	if (order_position == AIOrder::ORDER_CURRENT) {
 
		const Order *order = &v->current_order;
 
		if (order->GetType() == OT_GOTO_DEPOT && !(order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return order;
 
@@ -92,7 +92,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (order_position == ORDER_CURRENT) return false;
 
	if (!IsValidVehicleOrder(vehicle_id, order_position)) return false;
 

	
 
	const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
 
	const Order *order = ::GetVehicleOrder(Vehicle::Get(vehicle_id), order_position);
 
	return order->GetType() == OT_CONDITIONAL;
 
}
 

	
 
@@ -101,7 +101,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (AIVehicle::IsValidVehicle(vehicle_id)) return false;
 
	if (GetOrderCount(vehicle_id) == 0) return false;
 

	
 
	const Order *order = &::GetVehicle(vehicle_id)->current_order;
 
	const Order *order = &::Vehicle::Get(vehicle_id)->current_order;
 
	if (order->GetType() != OT_GOTO_DEPOT) return true;
 
	return (order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0;
 
}
 
@@ -110,8 +110,8 @@ static const Order *ResolveOrder(Vehicle
 
{
 
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return ORDER_INVALID;
 

	
 
	if (order_position == ORDER_CURRENT) return (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->cur_order_index;
 
	return (order_position >= 0 && order_position < ::GetVehicle(vehicle_id)->GetNumOrders()) ? order_position : ORDER_INVALID;
 
	if (order_position == ORDER_CURRENT) return (AIOrder::OrderPosition)::Vehicle::Get(vehicle_id)->cur_order_index;
 
	return (order_position >= 0 && order_position < ::Vehicle::Get(vehicle_id)->GetNumOrders()) ? order_position : ORDER_INVALID;
 
}
 

	
 

	
 
@@ -158,7 +158,7 @@ static const Order *ResolveOrder(Vehicle
 

	
 
/* static */ int32 AIOrder::GetOrderCount(VehicleID vehicle_id)
 
{
 
	return AIVehicle::IsValidVehicle(vehicle_id) ? ::GetVehicle(vehicle_id)->GetNumOrders() : -1;
 
	return AIVehicle::IsValidVehicle(vehicle_id) ? ::Vehicle::Get(vehicle_id)->GetNumOrders() : -1;
 
}
 

	
 
/* static */ TileIndex AIOrder::GetOrderDestination(VehicleID vehicle_id, OrderPosition order_position)
 
@@ -167,20 +167,20 @@ static const Order *ResolveOrder(Vehicle
 

	
 
	const Order *order = ::ResolveOrder(vehicle_id, order_position);
 
	if (order == NULL || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 

	
 
	switch (order->GetType()) {
 
		case OT_GOTO_DEPOT: {
 
			if (v->type != VEH_AIRCRAFT) return ::GetDepot(order->GetDestination())->xy;
 
			if (v->type != VEH_AIRCRAFT) return ::Depot::Get(order->GetDestination())->xy;
 
			/* Aircraft's hangars are referenced by StationID, not DepotID */
 
			const Station *st = ::GetStation(order->GetDestination());
 
			const Station *st = ::Station::Get(order->GetDestination());
 
			const AirportFTAClass *airport = st->Airport();
 
			if (airport == NULL || airport->nof_depots == 0) return INVALID_TILE;
 
			return st->airport_tile + ::ToTileIndexDiff(st->Airport()->airport_depots[0]);
 
		}
 

	
 
		case OT_GOTO_STATION: {
 
			const Station *st = ::GetStation(order->GetDestination());
 
			const Station *st = ::Station::Get(order->GetDestination());
 
			if (st->train_tile != INVALID_TILE) {
 
				for (uint i = 0; i < st->trainst_w; i++) {
 
					TileIndex t = st->train_tile + TileDiffXY(i, 0);
 
@@ -200,7 +200,7 @@ static const Order *ResolveOrder(Vehicle
 
			}
 
			return INVALID_TILE;
 
		}
 
		case OT_GOTO_WAYPOINT: return ::GetWaypoint(order->GetDestination())->xy;
 
		case OT_GOTO_WAYPOINT: return ::Waypoint::Get(order->GetDestination())->xy;
 
		default:               return INVALID_TILE;
 
	}
 
}
 
@@ -236,7 +236,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (!IsValidVehicleOrder(vehicle_id, order_position)) return ORDER_INVALID;
 
	if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return ORDER_INVALID;
 

	
 
	const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
 
	const Order *order = ::GetVehicleOrder(Vehicle::Get(vehicle_id), order_position);
 
	return (OrderPosition)order->GetConditionSkipToOrder();
 
}
 

	
 
@@ -245,7 +245,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (!IsValidVehicleOrder(vehicle_id, order_position)) return OC_INVALID;
 
	if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return OC_INVALID;
 

	
 
	const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
 
	const Order *order = ::GetVehicleOrder(Vehicle::Get(vehicle_id), order_position);
 
	return (OrderCondition)order->GetConditionVariable();
 
}
 

	
 
@@ -254,7 +254,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (!IsValidVehicleOrder(vehicle_id, order_position)) return CF_INVALID;
 
	if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return CF_INVALID;
 

	
 
	const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
 
	const Order *order = ::GetVehicleOrder(Vehicle::Get(vehicle_id), order_position);
 
	return (CompareFunction)order->GetConditionComparator();
 
}
 

	
 
@@ -263,7 +263,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (!IsValidVehicleOrder(vehicle_id, order_position)) return -1;
 
	if (order_position == ORDER_CURRENT || !IsConditionalOrder(vehicle_id, order_position)) return -1;
 

	
 
	const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
 
	const Order *order = ::GetVehicleOrder(Vehicle::Get(vehicle_id), order_position);
 
	int32 value = order->GetConditionValue();
 
	if (order->GetConditionVariable() == OCV_MAX_SPEED) value = value * 16 / 10;
 
	return value;
 
@@ -311,7 +311,7 @@ static const Order *ResolveOrder(Vehicle
 
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
 
	EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
 

	
 
	return InsertOrder(vehicle_id, (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->GetNumOrders(), destination, order_flags);
 
	return InsertOrder(vehicle_id, (AIOrder::OrderPosition)::Vehicle::Get(vehicle_id)->GetNumOrders(), destination, order_flags);
 
}
 

	
 
/* static */ bool AIOrder::AppendConditionalOrder(VehicleID vehicle_id, OrderPosition jump_to)
 
@@ -319,7 +319,7 @@ static const Order *ResolveOrder(Vehicle
 
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
 
	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to));
 

	
 
	return InsertConditionalOrder(vehicle_id, (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->GetNumOrders(), jump_to);
 
	return InsertConditionalOrder(vehicle_id, (AIOrder::OrderPosition)::Vehicle::Get(vehicle_id)->GetNumOrders(), jump_to);
 
}
 

	
 
/* static */ bool AIOrder::InsertOrder(VehicleID vehicle_id, OrderPosition order_position, TileIndex destination, AIOrder::AIOrderFlags order_flags)
 
@@ -328,7 +328,7 @@ static const Order *ResolveOrder(Vehicle
 
	if (order_position == ORDER_CURRENT) order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position);
 

	
 
	EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
 
	EnforcePrecondition(false, order_position >= 0 && order_position <= ::GetVehicle(vehicle_id)->GetNumOrders());
 
	EnforcePrecondition(false, order_position >= 0 && order_position <= ::Vehicle::Get(vehicle_id)->GetNumOrders());
 
	EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
 

	
 
	Order order;
 
@@ -339,7 +339,7 @@ static const Order *ResolveOrder(Vehicle
 
			OrderNonStopFlags onsf = (OrderNonStopFlags)((order_flags & AIOF_NON_STOP_INTERMEDIATE) ? ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS : ONSF_STOP_EVERYWHERE);
 
			/* Check explicitly if the order is to a station (for aircraft) or
 
			 * to a depot (other vehicle types). */
 
			if (::GetVehicle(vehicle_id)->type == VEH_AIRCRAFT) {
 
			if (::Vehicle::Get(vehicle_id)->type == VEH_AIRCRAFT) {
 
				if (!::IsTileType(destination, MP_STATION)) return false;
 
				order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf);
 
			} else {
 
@@ -432,7 +432,7 @@ static void _DoCommandReturnSetOrderFlag
 
	EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position));
 
	EnforcePrecondition(false, AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_position), order_flags));
 

	
 
	const Order *order = ::GetVehicleOrder(GetVehicle(vehicle_id), order_position);
 
	const Order *order = ::GetVehicleOrder(Vehicle::Get(vehicle_id), order_position);
 

	
 
	AIOrderFlags current = GetOrderFlags(vehicle_id, order_position);
 

	
src/ai/api/ai_sign.cpp
Show inline comments
 
@@ -20,7 +20,7 @@
 

	
 
/* static */ bool AISign::IsValidSign(SignID sign_id)
 
{
 
	return ::IsValidSignID(sign_id) && ::GetSign(sign_id)->owner == _current_company;
 
	return ::IsValidSignID(sign_id) && ::Sign::Get(sign_id)->owner == _current_company;
 
}
 

	
 
/* static */ bool AISign::SetName(SignID sign_id, const char *name)
 
@@ -49,7 +49,7 @@
 
{
 
	if (!IsValidSign(sign_id)) return INVALID_TILE;
 

	
 
	const Sign *sign = ::GetSign(sign_id);
 
	const Sign *sign = ::Sign::Get(sign_id);
 
	return ::TileVirtXY(sign->x, sign->y);
 
}
 

	
src/ai/api/ai_station.cpp
Show inline comments
 
@@ -17,7 +17,7 @@
 

	
 
/* static */ bool AIStation::IsValidStation(StationID station_id)
 
{
 
	return ::IsValidStationID(station_id) && ::GetStation(station_id)->owner == _current_company;
 
	return ::IsValidStationID(station_id) && ::Station::Get(station_id)->owner == _current_company;
 
}
 

	
 
/* static */ StationID AIStation::GetStationID(TileIndex tile)
 
@@ -33,7 +33,7 @@
 
	static const int len = 64;
 
	char *station_name = MallocT<char>(len);
 

	
 
	::SetDParam(0, GetStation(station_id)->index);
 
	::SetDParam(0, Station::Get(station_id)->index);
 
	::GetString(station_name, STR_STATION, &station_name[len - 1]);
 
	return station_name;
 
}
 
@@ -51,7 +51,7 @@
 
{
 
	if (!IsValidStation(station_id)) return INVALID_TILE;
 

	
 
	return ::GetStation(station_id)->xy;
 
	return ::Station::Get(station_id)->xy;
 
}
 

	
 
/* static */ int32 AIStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
 
@@ -59,7 +59,7 @@
 
	if (!IsValidStation(station_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	return ::GetStation(station_id)->goods[cargo_id].cargo.Count();
 
	return ::Station::Get(station_id)->goods[cargo_id].cargo.Count();
 
}
 

	
 
/* static */ int32 AIStation::GetCargoRating(StationID station_id, CargoID cargo_id)
 
@@ -67,7 +67,7 @@
 
	if (!IsValidStation(station_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	return ::GetStation(station_id)->goods[cargo_id].rating * 101 >> 8;
 
	return ::Station::Get(station_id)->goods[cargo_id].rating * 101 >> 8;
 
}
 

	
 
/* static */ int32 AIStation::GetCoverageRadius(AIStation::StationType station_type)
 
@@ -114,7 +114,7 @@
 
	if (!IsValidStation(station_id)) return false;
 
	if (CountBits(station_type) != 1) return false;
 

	
 
	return (::GetStation(station_id)->facilities & station_type) != 0;
 
	return (::Station::Get(station_id)->facilities & station_type) != 0;
 
}
 

	
 
/* static */ bool AIStation::HasRoadType(StationID station_id, AIRoad::RoadType road_type)
 
@@ -124,10 +124,10 @@
 

	
 
	::RoadTypes r = RoadTypeToRoadTypes((::RoadType)road_type);
 

	
 
	for (const RoadStop *rs = ::GetStation(station_id)->GetPrimaryRoadStop(ROADSTOP_BUS); rs != NULL; rs = rs->next) {
 
	for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_BUS); rs != NULL; rs = rs->next) {
 
		if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
 
	}
 
	for (const RoadStop *rs = ::GetStation(station_id)->GetPrimaryRoadStop(ROADSTOP_TRUCK); rs != NULL; rs = rs->next) {
 
	for (const RoadStop *rs = ::Station::Get(station_id)->GetPrimaryRoadStop(ROADSTOP_TRUCK); rs != NULL; rs = rs->next) {
 
		if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
 
	}
 

	
 
@@ -138,5 +138,5 @@
 
{
 
	if (!IsValidStation(station_id)) return INVALID_TOWN;
 

	
 
	return ::GetStation(station_id)->town->index;
 
	return ::Station::Get(station_id)->town->index;
 
}
src/ai/api/ai_stationlist.cpp
Show inline comments
 
@@ -20,7 +20,7 @@ AIStationList_Vehicle::AIStationList_Veh
 
{
 
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
 

	
 
	Vehicle *v = ::GetVehicle(vehicle_id);
 
	Vehicle *v = ::Vehicle::Get(vehicle_id);
 

	
 
	for (Order *o = v->GetFirstOrder(); o != NULL; o = o->next) {
 
		if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination());
src/ai/api/ai_subsidy.cpp
Show inline comments
 
@@ -24,7 +24,7 @@
 
{
 
	if (!IsAwarded(subsidy_id)) return AICompany::COMPANY_INVALID;
 

	
 
	return (AICompany::CompanyID)((byte)GetStation(_subsidies[subsidy_id].from)->owner);
 
	return (AICompany::CompanyID)((byte)Station::Get(_subsidies[subsidy_id].from)->owner);
 
}
 

	
 
/* static */ int32 AISubsidy::GetExpireDate(SubsidyID subsidy_id)
src/ai/api/ai_tilelist.cpp
Show inline comments
 
@@ -72,7 +72,7 @@ AITileList_IndustryAccepting::AITileList
 
{
 
	if (!AIIndustry::IsValidIndustry(industry_id)) return;
 

	
 
	const Industry *i = ::GetIndustry(industry_id);
 
	const Industry *i = ::Industry::Get(industry_id);
 

	
 
	/* Check if this industry accepts anything */
 
	{
 
@@ -110,7 +110,7 @@ AITileList_IndustryProducing::AITileList
 
{
 
	if (!AIIndustry::IsValidIndustry(industry_id)) return;
 

	
 
	const Industry *i = ::GetIndustry(industry_id);
 
	const Industry *i = ::Industry::Get(industry_id);
 

	
 
	/* Check if this industry produces anything */
 
	{
 
@@ -148,7 +148,7 @@ AITileList_StationType::AITileList_Stati
 
{
 
	if (!AIStation::IsValidStation(station_id)) return;
 

	
 
	const StationRect *rect = &::GetStation(station_id)->rect;
 
	const StationRect *rect = &::Station::Get(station_id)->rect;
 

	
 
	uint station_type_value = 0;
 
	/* Convert AIStation::StationType to ::StationType, but do it in a
src/ai/api/ai_town.cpp
Show inline comments
 
@@ -39,21 +39,21 @@
 
/* static */ int32 AITown::GetPopulation(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return -1;
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 
	return t->population;
 
}
 

	
 
/* static */ int32 AITown::GetHouseCount(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return -1;
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 
	return t->num_houses;
 
}
 

	
 
/* static */ TileIndex AITown::GetLocation(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return INVALID_TILE;
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 
	return t->xy;
 
}
 

	
 
@@ -62,7 +62,7 @@
 
	if (!IsValidTown(town_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	switch(AICargo::GetTownEffect(cargo_id)) {
 
		case AICargo::TE_PASSENGERS: return t->act_pass;
 
@@ -76,7 +76,7 @@
 
	if (!IsValidTown(town_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	switch(AICargo::GetTownEffect(cargo_id)) {
 
		case AICargo::TE_PASSENGERS: return t->pct_pass_transported;
 
@@ -90,7 +90,7 @@
 
	if (!IsValidTown(town_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo_id)) return -1;
 

	
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 

	
 
	switch(AICargo::GetTownEffect(cargo_id)) {
 
		case AICargo::TE_PASSENGERS: return t->max_pass;
 
@@ -113,7 +113,7 @@
 
{
 
	if (!IsValidTown(town_id)) return false;
 

	
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 
	return ((uint32)GetDistanceSquareToTile(town_id, tile) <= t->squared_town_zone_radius[0]);
 
}
 

	
 
@@ -121,35 +121,35 @@
 
{
 
	if (!IsValidTown(town_id)) return false;
 

	
 
	return ::HasBit(::GetTown(town_id)->statues, _current_company);
 
	return ::HasBit(::Town::Get(town_id)->statues, _current_company);
 
}
 

	
 
/* static */ int AITown::GetRoadReworkDuration(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return -1;
 

	
 
	return ::GetTown(town_id)->road_build_months;
 
	return ::Town::Get(town_id)->road_build_months;
 
}
 

	
 
/* static */ AICompany::CompanyID AITown::GetExclusiveRightsCompany(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return AICompany::COMPANY_INVALID;
 

	
 
	return (AICompany::CompanyID)(int8)::GetTown(town_id)->exclusivity;
 
	return (AICompany::CompanyID)(int8)::Town::Get(town_id)->exclusivity;
 
}
 

	
 
/* static */ int32 AITown::GetExclusiveRightsDuration(TownID town_id)
 
{
 
	if (!IsValidTown(town_id)) return -1;
 

	
 
	return ::GetTown(town_id)->exclusive_counter;
 
	return ::Town::Get(town_id)->exclusive_counter;
 
}
 

	
 
/* static */ bool AITown::IsActionAvailable(TownID town_id, TownAction town_action)
 
{
 
	if (!IsValidTown(town_id)) return false;
 

	
 
	return HasBit(::GetMaskOfTownActions(NULL, _current_company, ::GetTown(town_id)), town_action);
 
	return HasBit(::GetMaskOfTownActions(NULL, _current_company, ::Town::Get(town_id)), town_action);
 
}
 

	
 
/* static */ bool AITown::PerformTownAction(TownID town_id, TownAction town_action)
 
@@ -157,7 +157,7 @@
 
	EnforcePrecondition(false, IsValidTown(town_id));
 
	EnforcePrecondition(false, IsActionAvailable(town_id, town_action));
 

	
 
	return AIObject::DoCommand(::GetTown(town_id)->xy, town_id, town_action, CMD_DO_TOWN_ACTION);
 
	return AIObject::DoCommand(::Town::Get(town_id)->xy, town_id, town_action, CMD_DO_TOWN_ACTION);
 
}
 

	
 
/* static */ AITown::TownRating AITown::GetRating(TownID town_id, AICompany::CompanyID company_id)
 
@@ -166,7 +166,7 @@
 
	AICompany::CompanyID company = AICompany::ResolveCompanyID(company_id);
 
	if (company == AICompany::COMPANY_INVALID) return TOWN_RATING_INVALID;
 

	
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 
	if (!HasBit(t->have_ratings, company)) return TOWN_RATING_NONE;
 
	return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 3));
 
}
 
@@ -175,7 +175,7 @@
 
{
 
	if (!IsValidTown(town_id)) return -1;
 

	
 
	const Town *t = ::GetTown(town_id);
 
	const Town *t = ::Town::Get(town_id);
 
	if (_settings_game.economy.station_noise_level) {
 
		return t->MaxTownNoise() - t->noise_reached;
 
	}
 
@@ -192,5 +192,5 @@
 
{
 
	if (!IsValidTown(town_id)) return ROAD_LAYOUT_INVALID;
 

	
 
	return (AITown::RoadLayout)((TownLayout)::GetTown(town_id)->layout);
 
	return (AITown::RoadLayout)((TownLayout)::Town::Get(town_id)->layout);
 
}
src/ai/api/ai_vehicle.cpp
Show inline comments
 
@@ -20,7 +20,7 @@
 
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
 
{
 
	if (!::IsValidVehicleID(vehicle_id)) return false;
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	return v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v)));
 
}
 

	
 
@@ -29,8 +29,8 @@
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	int num = 1;
 
	if (::GetVehicle(vehicle_id)->type == VEH_TRAIN) {
 
		const Vehicle *v = ::GetVehicle(vehicle_id);
 
	if (::Vehicle::Get(vehicle_id)->type == VEH_TRAIN) {
 
		const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
		while ((v = GetNextUnit(v)) != NULL) num++;
 
	}
 

	
 
@@ -41,7 +41,7 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	switch (v->type) {
 
		case VEH_ROAD: {
 
			uint total_length = 0;
 
@@ -59,7 +59,7 @@
 
{
 
	EnforcePrecondition(INVALID_VEHICLE, AIEngine::IsValidEngine(engine_id));
 

	
 
	::VehicleType type = ::GetEngine(engine_id)->type;
 
	::VehicleType type = ::Engine::Get(engine_id)->type;
 

	
 
	EnforcePreconditionCustomError(INVALID_VEHICLE, !AIGameSettings::IsDisabledVehicleType((AIVehicle::VehicleType)type), AIVehicle::ERR_VEHICLE_BUILD_DISABLED);
 

	
 
@@ -83,14 +83,14 @@
 
{
 
	EnforcePrecondition(false, IsValidVehicle(source_vehicle_id) && source_wagon < GetNumWagons(source_vehicle_id));
 
	EnforcePrecondition(false, dest_vehicle_id == -1 || (IsValidVehicle(dest_vehicle_id) && dest_wagon < GetNumWagons(dest_vehicle_id)));
 
	EnforcePrecondition(false, ::GetVehicle(source_vehicle_id)->type == VEH_TRAIN);
 
	EnforcePrecondition(false, dest_vehicle_id == -1 || ::GetVehicle(dest_vehicle_id)->type == VEH_TRAIN);
 
	EnforcePrecondition(false, ::Vehicle::Get(source_vehicle_id)->type == VEH_TRAIN);
 
	EnforcePrecondition(false, dest_vehicle_id == -1 || ::Vehicle::Get(dest_vehicle_id)->type == VEH_TRAIN);
 

	
 
	const Vehicle *v = ::GetVehicle(source_vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(source_vehicle_id);
 
	while (source_wagon-- > 0) v = GetNextUnit(v);
 
	const Vehicle *w = NULL;
 
	if (dest_vehicle_id != -1) {
 
		w = ::GetVehicle(dest_vehicle_id);
 
		w = ::Vehicle::Get(dest_vehicle_id);
 
		while (dest_wagon-- > 0) w = GetNextUnit(w);
 
	}
 

	
 
@@ -112,7 +112,7 @@
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 
	if (!AICargo::IsValidCargo(cargo)) return -1;
 

	
 
	CommandCost res = ::DoCommand(0, vehicle_id, cargo, DC_QUERY_COST, GetCmdRefitVeh(::GetVehicle(vehicle_id)));
 
	CommandCost res = ::DoCommand(0, vehicle_id, cargo, DC_QUERY_COST, GetCmdRefitVeh(::Vehicle::Get(vehicle_id)));
 
	return CmdSucceeded(res) ? _returned_refit_capacity : -1;
 
}
 

	
 
@@ -120,7 +120,7 @@
 
{
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id) && AICargo::IsValidCargo(cargo));
 

	
 
	return AIObject::DoCommand(0, vehicle_id, cargo, GetCmdRefitVeh(::GetVehicle(vehicle_id)));
 
	return AIObject::DoCommand(0, vehicle_id, cargo, GetCmdRefitVeh(::Vehicle::Get(vehicle_id)));
 
}
 

	
 

	
 
@@ -128,16 +128,16 @@
 
{
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	return AIObject::DoCommand(0, vehicle_id, v->type == VEH_TRAIN ? 1 : 0, GetCmdSellVeh(v));
 
}
 

	
 
/* static */ bool AIVehicle::_SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons)
 
{
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id) && wagon < GetNumWagons(vehicle_id));
 
	EnforcePrecondition(false, ::GetVehicle(vehicle_id)->type == VEH_TRAIN);
 
	EnforcePrecondition(false, ::Vehicle::Get(vehicle_id)->type == VEH_TRAIN);
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	while (wagon-- > 0) v = GetNextUnit(v);
 

	
 
	return AIObject::DoCommand(0, v->index, sell_attached_wagons ? 1 : 0, CMD_SELL_RAIL_WAGON);
 
@@ -157,26 +157,26 @@
 
{
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 

	
 
	return AIObject::DoCommand(0, vehicle_id, 0, GetCmdSendToDepot(::GetVehicle(vehicle_id)));
 
	return AIObject::DoCommand(0, vehicle_id, 0, GetCmdSendToDepot(::Vehicle::Get(vehicle_id)));
 
}
 

	
 
/* static */ bool AIVehicle::SendVehicleToDepotForServicing(VehicleID vehicle_id)
 
{
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 

	
 
	return AIObject::DoCommand(0, vehicle_id, DEPOT_SERVICE, GetCmdSendToDepot(::GetVehicle(vehicle_id)));
 
	return AIObject::DoCommand(0, vehicle_id, DEPOT_SERVICE, GetCmdSendToDepot(::Vehicle::Get(vehicle_id)));
 
}
 

	
 
/* static */ bool AIVehicle::IsInDepot(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return false;
 
	return ::GetVehicle(vehicle_id)->IsInDepot();
 
	return ::Vehicle::Get(vehicle_id)->IsInDepot();
 
}
 

	
 
/* static */ bool AIVehicle::IsStoppedInDepot(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return false;
 
	return ::GetVehicle(vehicle_id)->IsStoppedInDepot();
 
	return ::Vehicle::Get(vehicle_id)->IsStoppedInDepot();
 
}
 

	
 
/* static */ bool AIVehicle::StartStopVehicle(VehicleID vehicle_id)
 
@@ -198,9 +198,9 @@
 
/* static */ bool AIVehicle::ReverseVehicle(VehicleID vehicle_id)
 
{
 
	EnforcePrecondition(false, IsValidVehicle(vehicle_id));
 
	EnforcePrecondition(false, ::GetVehicle(vehicle_id)->type == VEH_ROAD || ::GetVehicle(vehicle_id)->type == VEH_TRAIN);
 
	EnforcePrecondition(false, ::Vehicle::Get(vehicle_id)->type == VEH_ROAD || ::Vehicle::Get(vehicle_id)->type == VEH_TRAIN);
 

	
 
	switch (::GetVehicle(vehicle_id)->type) {
 
	switch (::Vehicle::Get(vehicle_id)->type) {
 
		case VEH_ROAD: return AIObject::DoCommand(0, vehicle_id, 0, CMD_TURN_ROADVEH);
 
		case VEH_TRAIN: return AIObject::DoCommand(0, vehicle_id, 0, CMD_REVERSE_TRAIN_DIRECTION);
 
		default: NOT_REACHED();
 
@@ -220,7 +220,7 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return INVALID_TILE;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	if (v->type == VEH_AIRCRAFT) {
 
		uint x = Clamp(v->x_pos / TILE_SIZE, 0, ::MapSizeX() - 2);
 
		uint y = Clamp(v->y_pos / TILE_SIZE, 0, ::MapSizeY() - 2);
 
@@ -234,7 +234,7 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
 

	
 
	return ::GetVehicle(vehicle_id)->engine_type;
 
	return ::Vehicle::Get(vehicle_id)->engine_type;
 
}
 

	
 
/* static */ EngineID AIVehicle::GetWagonEngineType(VehicleID vehicle_id, int wagon)
 
@@ -242,7 +242,7 @@
 
	if (!IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
 
	if (wagon >= GetNumWagons(vehicle_id)) return INVALID_ENGINE;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	if (v->type == VEH_TRAIN) {
 
		while (wagon-- > 0) v = GetNextUnit(v);
 
	}
 
@@ -253,7 +253,7 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->unitnumber;
 
	return ::Vehicle::Get(vehicle_id)->unitnumber;
 
}
 

	
 
/* static */ char *AIVehicle::GetName(VehicleID vehicle_id)
 
@@ -272,7 +272,7 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->age;
 
	return ::Vehicle::Get(vehicle_id)->age;
 
}
 

	
 
/* static */ int32 AIVehicle::GetWagonAge(VehicleID vehicle_id, int wagon)
 
@@ -280,7 +280,7 @@
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 
	if (wagon >= GetNumWagons(vehicle_id)) return -1;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	if (v->type == VEH_TRAIN) {
 
		while (wagon-- > 0) v = GetNextUnit(v);
 
	}
 
@@ -291,28 +291,28 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->max_age;
 
	return ::Vehicle::Get(vehicle_id)->max_age;
 
}
 

	
 
/* static */ int32 AIVehicle::GetAgeLeft(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->max_age - ::GetVehicle(vehicle_id)->age;
 
	return ::Vehicle::Get(vehicle_id)->max_age - ::Vehicle::Get(vehicle_id)->age;
 
}
 

	
 
/* static */ int32 AIVehicle::GetCurrentSpeed(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->GetDisplaySpeed(); // km-ish/h
 
	return ::Vehicle::Get(vehicle_id)->GetDisplaySpeed(); // km-ish/h
 
}
 

	
 
/* static */ AIVehicle::VehicleState AIVehicle::GetState(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return AIVehicle::VS_INVALID;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	byte vehstatus = v->vehstatus;
 

	
 
	if (vehstatus & ::VS_CRASHED) return AIVehicle::VS_CRASHED;
 
@@ -327,35 +327,35 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->GetRunningCost() >> 8;
 
	return ::Vehicle::Get(vehicle_id)->GetRunningCost() >> 8;
 
}
 

	
 
/* static */ Money AIVehicle::GetProfitThisYear(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->GetDisplayProfitThisYear();
 
	return ::Vehicle::Get(vehicle_id)->GetDisplayProfitThisYear();
 
}
 

	
 
/* static */ Money AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->GetDisplayProfitLastYear();
 
	return ::Vehicle::Get(vehicle_id)->GetDisplayProfitLastYear();
 
}
 

	
 
/* static */ Money AIVehicle::GetCurrentValue(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return -1;
 

	
 
	return ::GetVehicle(vehicle_id)->value;
 
	return ::Vehicle::Get(vehicle_id)->value;
 
}
 

	
 
/* static */ AIVehicle::VehicleType AIVehicle::GetVehicleType(VehicleID vehicle_id)
 
{
 
	if (!IsValidVehicle(vehicle_id)) return VT_INVALID;
 

	
 
	switch (::GetVehicle(vehicle_id)->type) {
 
	switch (::Vehicle::Get(vehicle_id)->type) {
 
		case VEH_ROAD:     return VT_ROAD;
 
		case VEH_TRAIN:    return VT_RAIL;
 
		case VEH_SHIP:     return VT_WATER;
 
@@ -369,7 +369,7 @@
 
	if (!IsValidVehicle(vehicle_id)) return AIRoad::ROADTYPE_INVALID;
 
	if (GetVehicleType(vehicle_id) != VT_ROAD) return AIRoad::ROADTYPE_INVALID;
 

	
 
	return (AIRoad::RoadType)::GetVehicle(vehicle_id)->u.road.roadtype;
 
	return (AIRoad::RoadType)::Vehicle::Get(vehicle_id)->u.road.roadtype;
 
}
 

	
 
/* static */ int32 AIVehicle::GetCapacity(VehicleID vehicle_id, CargoID cargo)
 
@@ -378,7 +378,7 @@
 
	if (!AICargo::IsValidCargo(cargo)) return -1;
 

	
 
	uint32 amount = 0;
 
	for (const Vehicle *v = ::GetVehicle(vehicle_id); v != NULL; v = v->Next()) {
 
	for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != NULL; v = v->Next()) {
 
		if (v->cargo_type == cargo) amount += v->cargo_cap;
 
	}
 

	
 
@@ -391,7 +391,7 @@
 
	if (!AICargo::IsValidCargo(cargo)) return -1;
 

	
 
	uint32 amount = 0;
 
	for (const Vehicle *v = ::GetVehicle(vehicle_id); v != NULL; v = v->Next()) {
 
	for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != NULL; v = v->Next()) {
 
		if (v->cargo_type == cargo) amount += v->cargo.Count();
 
	}
 

	
 
@@ -402,7 +402,7 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return AIGroup::GROUP_INVALID;
 

	
 
	return ::GetVehicle(vehicle_id)->group_id;
 
	return ::Vehicle::Get(vehicle_id)->group_id;
 
}
 

	
 
/* static */ bool AIVehicle::IsArticulated(VehicleID vehicle_id)
 
@@ -410,7 +410,7 @@
 
	if (!IsValidVehicle(vehicle_id)) return false;
 
	if (GetVehicleType(vehicle_id) != VT_ROAD && GetVehicleType(vehicle_id) != VT_RAIL) return false;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	switch (v->type) {
 
		case VEH_ROAD: return RoadVehHasArticPart(v);
 
		case VEH_TRAIN: return EngineHasArticPart(v);
 
@@ -422,6 +422,6 @@
 
{
 
	if (!IsValidVehicle(vehicle_id)) return false;
 

	
 
	Vehicle *v = ::GetVehicle(vehicle_id);
 
	Vehicle *v = ::Vehicle::Get(vehicle_id);
 
	return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
 
}
src/ai/api/ai_vehiclelist.cpp
Show inline comments
 
@@ -40,7 +40,7 @@ AIVehicleList_SharedOrders::AIVehicleLis
 
{
 
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
 

	
 
	for (const Vehicle *v = GetVehicle(vehicle_id)->FirstShared(); v != NULL; v = v->NextShared()) {
 
	for (const Vehicle *v = Vehicle::Get(vehicle_id)->FirstShared(); v != NULL; v = v->NextShared()) {
 
		this->AddItem(v->index);
 
	}
 
}
src/ai/api/ai_waypoint.cpp
Show inline comments
 
@@ -14,7 +14,7 @@
 

	
 
/* static */ bool AIWaypoint::IsValidWaypoint(WaypointID waypoint_id)
 
{
 
	return ::IsValidWaypointID(waypoint_id) && ::GetWaypoint(waypoint_id)->owner == _current_company;
 
	return ::IsValidWaypointID(waypoint_id) && ::Waypoint::Get(waypoint_id)->owner == _current_company;
 
}
 

	
 
/* static */ WaypointID AIWaypoint::GetWaypointID(TileIndex tile)
 
@@ -49,5 +49,5 @@
 
{
 
	if (!IsValidWaypoint(waypoint_id)) return INVALID_TILE;
 

	
 
	return ::GetWaypoint(waypoint_id)->xy;
 
	return ::Waypoint::Get(waypoint_id)->xy;
 
}
src/ai/api/ai_waypointlist.cpp
Show inline comments
 
@@ -21,7 +21,7 @@ AIWaypointList_Vehicle::AIWaypointList_V
 
{
 
	if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
 

	
 
	const Vehicle *v = ::GetVehicle(vehicle_id);
 
	const Vehicle *v = ::Vehicle::Get(vehicle_id);
 

	
 
	for (const Order *o = v->GetFirstOrder(); o != NULL; o = o->next) {
 
		if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination());
src/aircraft_cmd.cpp
Show inline comments
 
@@ -136,7 +136,7 @@ static bool HaveHangarInOrderList(Vehicl
 
	const Order *order;
 

	
 
	FOR_VEHICLE_ORDERS(v, order) {
 
		const Station *st = GetStation(order->station);
 
		const Station *st = Station::Get(order->station);
 
		if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
 
			/* If an airport doesn't have a hangar, skip it */
 
			if (st->Airport()->nof_depots != 0)
 
@@ -156,7 +156,7 @@ SpriteID Aircraft::GetImage(Direction di
 
		SpriteID sprite = GetCustomVehicleSprite(this, direction);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(this->engine_type)->image_index;
 
		spritenum = Engine::Get(this->engine_type)->image_index;
 
	}
 

	
 
	return direction + _aircraft_sprite[spritenum];
 
@@ -184,7 +184,7 @@ static SpriteID GetAircraftIcon(EngineID
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(engine)->image_index;
 
		spritenum = Engine::Get(engine)->image_index;
 
	}
 

	
 
	return 6 + _aircraft_sprite[spritenum];
 
@@ -251,7 +251,7 @@ CommandCost CmdBuildAircraft(TileIndex t
 
	if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_company)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
 

	
 
	const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
 
	const Engine *e = GetEngine(p1);
 
	const Engine *e = Engine::Get(p1);
 
	CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
 

	
 
	/* Engines without valid cargo should not be available */
 
@@ -424,7 +424,7 @@ CommandCost CmdBuildAircraft(TileIndex t
 
		if (IsLocalCompany())
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Aircraft window
 

	
 
		GetCompany(_current_company)->num_engines[p1]++;
 
		Company::Get(_current_company)->num_engines[p1]++;
 
	}
 

	
 
	return value;
 
@@ -442,7 +442,7 @@ CommandCost CmdSellAircraft(TileIndex ti
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
 
@@ -468,7 +468,7 @@ bool Aircraft::FindClosestDepot(TileInde
 

	
 
		if (station == INVALID_STATION) return false;
 

	
 
		st = GetStation(station);
 
		st = Station::Get(station);
 
	}
 

	
 
	if (location    != NULL) *location    = st->xy;
 
@@ -496,7 +496,7 @@ CommandCost CmdSendAircraftToHangar(Tile
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_AIRCRAFT) return CMD_ERROR;
 

	
 
@@ -520,7 +520,7 @@ CommandCost CmdRefitAircraft(TileIndex t
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
 
@@ -591,7 +591,7 @@ static void CheckIfAircraftNeedsService(
 
		return;
 
	}
 

	
 
	const Station *st = GetStation(v->current_order.GetDestination());
 
	const Station *st = Station::Get(v->current_order.GetDestination());
 
	/* only goto depot if the target airport has terminals (eg. it is airport) */
 
	if (st->IsValid() && st->airport_tile != INVALID_TILE && st->Airport()->terminals != NULL) {
 
//		printf("targetairport = %d, st->index = %d\n", v->u.air.targetairport, st->index);
 
@@ -890,7 +890,7 @@ static byte AircraftGetEntryPoint(const 
 
	TileIndex tile = 0;
 

	
 
	if (IsValidStationID(v->u.air.targetairport)) {
 
		const Station *st = GetStation(v->u.air.targetairport);
 
		const Station *st = Station::Get(v->u.air.targetairport);
 
		/* Make sure we don't go to INVALID_TILE if the airport has been removed. */
 
		tile = (st->airport_tile != INVALID_TILE) ? st->airport_tile : st->xy;
 
	}
 
@@ -921,7 +921,7 @@ static bool AircraftController(Vehicle *
 
	int count;
 

	
 
	/* NULL if station is invalid */
 
	const Station *st = IsValidStationID(v->u.air.targetairport) ? GetStation(v->u.air.targetairport) : NULL;
 
	const Station *st = IsValidStationID(v->u.air.targetairport) ? Station::Get(v->u.air.targetairport) : NULL;
 
	/* INVALID_TILE if there is no station */
 
	TileIndex tile = INVALID_TILE;
 
	if (st != NULL) {
 
@@ -1326,7 +1326,7 @@ static void CrashAirplane(Vehicle *v)
 

	
 
static void MaybeCrashAirplane(Vehicle *v)
 
{
 
	Station *st = GetStation(v->u.air.targetairport);
 
	Station *st = Station::Get(v->u.air.targetairport);
 

	
 
	/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
 
	uint16 prob = 0x10000 / 1500;
 
@@ -1352,7 +1352,7 @@ static void AircraftEntersTerminal(Vehic
 
{
 
	if (v->current_order.IsType(OT_GOTO_DEPOT)) return;
 

	
 
	Station *st = GetStation(v->u.air.targetairport);
 
	Station *st = Station::Get(v->u.air.targetairport);
 
	v->last_station_visited = v->u.air.targetairport;
 

	
 
	/* Check if station was ever visited before */
 
@@ -1427,7 +1427,7 @@ void AircraftLeaveHangar(Vehicle *v)
 
static inline bool CheckSendAircraftToHangarForReplacement(const Vehicle *v)
 
{
 
	EngineID new_engine;
 
	Company *c = GetCompany(v->owner);
 
	Company *c = Company::Get(v->owner);
 

	
 
	if (VehicleHasDepotOrders(v)) return false; // The aircraft will end up in the hangar eventually on it's own
 

	
 
@@ -1443,7 +1443,7 @@ static inline bool CheckSendAircraftToHa
 
		}
 
	}
 

	
 
	if (!HasBit(GetEngine(new_engine)->company_avail, v->owner)) {
 
	if (!HasBit(Engine::Get(new_engine)->company_avail, v->owner)) {
 
		/* Engine is not buildable anymore */
 
		return false;
 
	}
 
@@ -1527,7 +1527,7 @@ static void AircraftEventHandler_AtTermi
 
				/* an exerpt of ServiceAircraft, without the invisibility stuff */
 
				v->date_of_last_service = _date;
 
				v->breakdowns_since_last_service = 0;
 
				v->reliability = GetEngine(v->engine_type)->reliability;
 
				v->reliability = Engine::Get(v->engine_type)->reliability;
 
				InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
			}
 
		}
 
@@ -1556,7 +1556,7 @@ static void AircraftEventHandler_AtTermi
 
			return;
 
		default:  // orders have been deleted (no orders), goto depot and don't bother us
 
			v->current_order.Free();
 
			go_to_hangar = GetStation(v->u.air.targetairport)->Airport()->nof_depots != 0;
 
			go_to_hangar = Station::Get(v->u.air.targetairport)->Airport()->nof_depots != 0;
 
	}
 

	
 
	if (go_to_hangar) {
 
@@ -1610,7 +1610,7 @@ static void AircraftEventHandler_HeliTak
 

	
 
static void AircraftEventHandler_Flying(Vehicle *v, const AirportFTAClass *apc)
 
{
 
	Station *st = GetStation(v->u.air.targetairport);
 
	Station *st = Station::Get(v->u.air.targetairport);
 

	
 
	/* runway busy or not allowed to use this airstation, circle */
 
	if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
 
@@ -1731,7 +1731,7 @@ static void AirportClearBlock(const Vehi
 
{
 
	/* we have left the previous block, and entered the new one. Free the previous block */
 
	if (apc->layout[v->u.air.previous_pos].block != apc->layout[v->u.air.pos].block) {
 
		Station *st = GetStation(v->u.air.targetairport);
 
		Station *st = Station::Get(v->u.air.targetairport);
 

	
 
		CLRBITS(st->airport_flags, apc->layout[v->u.air.previous_pos].block);
 
	}
 
@@ -1742,7 +1742,7 @@ static void AirportGoToNextPosition(Vehi
 
	/* if aircraft is not in position, wait until it is */
 
	if (!AircraftController(v)) return;
 

	
 
	const AirportFTAClass *apc = GetStation(v->u.air.targetairport)->Airport();
 
	const AirportFTAClass *apc = Station::Get(v->u.air.targetairport)->Airport();
 

	
 
	AirportClearBlock(v, apc);
 
	AirportMove(v, apc); // move aircraft to next position
 
@@ -1805,7 +1805,7 @@ static bool AirportHasBlock(Vehicle *v, 
 

	
 
	/* same block, then of course we can move */
 
	if (apc->layout[current_pos->position].block != next->block) {
 
		const Station *st = GetStation(v->u.air.targetairport);
 
		const Station *st = Station::Get(v->u.air.targetairport);
 
		uint64 airport_flags = next->block;
 

	
 
		/* check additional possible extra blocks */
 
@@ -1853,7 +1853,7 @@ static bool AirportSetBlocks(Vehicle *v,
 
		 * checking, because it has been set by the airplane before */
 
		if (current_pos->block == next->block) airport_flags ^= next->block;
 

	
 
		Station *st = GetStation(v->u.air.targetairport);
 
		Station *st = Station::Get(v->u.air.targetairport);
 
		if (HASBITS(st->airport_flags, airport_flags)) {
 
			v->cur_speed = 0;
 
			v->subspeed = 0;
 
@@ -1869,7 +1869,7 @@ static bool AirportSetBlocks(Vehicle *v,
 

	
 
static bool FreeTerminal(Vehicle *v, byte i, byte last_terminal)
 
{
 
	Station *st = GetStation(v->u.air.targetairport);
 
	Station *st = Station::Get(v->u.air.targetairport);
 
	for (; i < last_terminal; i++) {
 
		if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
 
			/* TERMINAL# HELIPAD# */
 
@@ -1903,7 +1903,7 @@ static bool AirportFindFreeTerminal(Vehi
 
	 * fails, then attempt fails and plane waits
 
	 */
 
	if (apc->terminals[0] > 1) {
 
		const Station *st = GetStation(v->u.air.targetairport);
 
		const Station *st = Station::Get(v->u.air.targetairport);
 
		const AirportFTA *temp = apc->layout[v->u.air.pos].next;
 

	
 
		while (temp != NULL) {
 
@@ -1954,7 +1954,7 @@ static bool AirportFindFreeHelipad(Vehic
 

	
 
	/* if there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal() */
 
	if (apc->helipads[0] > 1) {
 
		const Station *st = GetStation(v->u.air.targetairport);
 
		const Station *st = Station::Get(v->u.air.targetairport);
 
		const AirportFTA *temp = apc->layout[v->u.air.pos].next;
 

	
 
		while (temp != NULL) {
 
@@ -2053,7 +2053,7 @@ Station *GetTargetAirportIfValid(const V
 

	
 
	if (!IsValidStationID(sid)) return NULL;
 

	
 
	Station *st = GetStation(sid);
 
	Station *st = Station::Get(sid);
 

	
 
	return st->airport_tile == INVALID_TILE ? NULL : st;
 
}
src/aircraft_gui.cpp
Show inline comments
 
@@ -86,7 +86,7 @@ void DrawAircraftImage(const Vehicle *v,
 
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		const Vehicle *v = GetVehicle(_new_vehicle_id);
 
		const Vehicle *v = Vehicle::Get(_new_vehicle_id);
 

	
 
		if (v->tile == _backup_orders_tile) {
 
			_backup_orders_tile = 0;
src/articulated_vehicles.cpp
Show inline comments
 
@@ -48,7 +48,7 @@ uint CountArticulatedParts(EngineID engi
 
 */
 
static inline uint16 GetVehicleDefaultCapacity(EngineID engine, VehicleType type, CargoID *cargo_type)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 
	CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
 
	if (cargo_type != NULL) *cargo_type = cargo;
 
	if (cargo == CT_INVALID) return 0;
 
@@ -113,7 +113,7 @@ bool IsArticulatedVehicleRefittable(Engi
 
{
 
	if (IsEngineRefittable(engine)) return true;
 

	
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 
	if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return false;
 

	
 
	if (!HasBit(e->info.callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) return false;
 
@@ -235,7 +235,7 @@ bool IsArticulatedVehicleCarryingDiffere
 
 */
 
void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
 
{
 
	const Engine *engine = GetEngine(v->engine_type);
 
	const Engine *engine = Engine::Get(v->engine_type);
 

	
 
	uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true);
 
	uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, v->type, true);
 
@@ -303,7 +303,7 @@ void AddArticulatedParts(Vehicle *first,
 
		bool flip_image = HasBit(callback, 7);
 

	
 
		Vehicle *previous = u;
 
		const Engine *e_artic = GetEngine(engine_type);
 
		const Engine *e_artic = Engine::Get(engine_type);
 
		switch (type) {
 
			default: NOT_REACHED();
 

	
src/autoreplace.cpp
Show inline comments
 
@@ -40,7 +40,7 @@ void RemoveAllEngineReplacement(EngineRe
 
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
 
{
 
	const EngineRenew *er = GetEngineReplacement(erl, engine, group);
 
	if (er == NULL && (group == DEFAULT_GROUP || (IsValidGroupID(group) && !GetGroup(group)->replace_protection))) {
 
	if (er == NULL && (group == DEFAULT_GROUP || (IsValidGroupID(group) && !Group::Get(group)->replace_protection))) {
 
		/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
 
		er = GetEngineReplacement(erl, engine, ALL_GROUP);
 
	}
src/autoreplace_base.h
Show inline comments
 
@@ -34,7 +34,7 @@ struct EngineRenew : PoolItem<EngineRene
 
	inline bool IsValid() const { return this->from != INVALID_ENGINE; }
 
};
 

	
 
#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = GetEngineRenew(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) if (er->IsValid())
 
#define FOR_ALL_ENGINE_RENEWS_FROM(er, start) for (er = EngineRenew::Get(start); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? EngineRenew::Get(er->index + 1U) : NULL) if (er->IsValid())
 
#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
 

	
 
#endif /* AUTOREPLACE_BASE_H */
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -47,7 +47,7 @@ bool CheckAutoreplaceValidity(EngineID f
 
	/* we can't replace an engine into itself (that would be autorenew) */
 
	if (from == to) return false;
 

	
 
	VehicleType type = GetEngine(from)->type;
 
	VehicleType type = Engine::Get(from)->type;
 

	
 
	/* check that the new vehicle type is available to the company and its type is the same as the original one */
 
	if (!IsEngineBuildable(to, type, company)) return false;
 
@@ -247,7 +247,7 @@ static CommandCost BuildReplacementVehic
 
	*new_vehicle = NULL;
 

	
 
	/* Shall the vehicle be replaced? */
 
	const Company *c = GetCompany(_current_company);
 
	const Company *c = Company::Get(_current_company);
 
	EngineID e = GetNewEngineType(old_veh, c);
 
	if (e == INVALID_ENGINE) return CommandCost(); // neither autoreplace is set, nor autorenew is triggered
 

	
 
@@ -259,7 +259,7 @@ static CommandCost BuildReplacementVehic
 
	CommandCost cost = DoCommand(old_veh->tile, e, 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh));
 
	if (cost.Failed()) return cost;
 

	
 
	Vehicle *new_veh = GetVehicle(_new_vehicle_id);
 
	Vehicle *new_veh = Vehicle::Get(_new_vehicle_id);
 
	*new_vehicle = new_veh;
 

	
 
	/* Refit the vehicle if needed */
 
@@ -609,7 +609,7 @@ CommandCost CmdAutoreplaceVehicle(TileIn
 
	bool nothing_to_do = true;
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!v->IsInDepot()) return CMD_ERROR;
 
	if (HASBITS(v->vehstatus, VS_CRASHED)) return CMD_ERROR;
 
@@ -623,7 +623,7 @@ CommandCost CmdAutoreplaceVehicle(TileIn
 
		if (!v->IsPrimaryVehicle()) return CMD_ERROR;
 
	}
 

	
 
	const Company *c = GetCompany(_current_company);
 
	const Company *c = Company::Get(_current_company);
 
	bool wagon_removal = c->settings.renew_keep_length;
 

	
 
	/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
src/autoreplace_gui.cpp
Show inline comments
 
@@ -69,14 +69,14 @@ static int CDECL EngineNumberSorter(cons
 
 */
 
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
 
{
 
	Company *c = GetCompany(_local_company);
 
	Company *c = Company::Get(_local_company);
 
	uint num_engines = GetGroupNumEngines(_local_company, id_g, e);
 

	
 
	if (num_engines == 0 || c->num_engines[e] == 0) {
 
		/* We don't have any of this engine type.
 
		 * Either we just sold the last one, we build a new one or we stopped replacing it.
 
		 * In all cases, we need to update the left list */
 
		InvalidateWindowData(WC_REPLACE_VEHICLE, GetEngine(e)->type, true);
 
		InvalidateWindowData(WC_REPLACE_VEHICLE, Engine::Get(e)->type, true);
 
	}
 
}
 

	
 
@@ -148,7 +148,7 @@ class ReplaceVehicleWindow : public Wind
 
				const uint num_engines = GetGroupNumEngines(_local_company, selected_group, eid);
 

	
 
				/* Skip drawing the engines we don't have any of and haven't set for replacement */
 
				if (num_engines == 0 && EngineReplacementForCompany(GetCompany(_local_company), eid, selected_group) == INVALID_ENGINE) continue;
 
				if (num_engines == 0 && EngineReplacementForCompany(Company::Get(_local_company), eid, selected_group) == INVALID_ENGINE) continue;
 
			} else {
 
				if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
 
			}
 
@@ -238,7 +238,7 @@ public:
 
	{
 
		if (this->update_left || this->update_right) this->GenerateLists();
 

	
 
		Company *c = GetCompany(_local_company);
 
		Company *c = Company::Get(_local_company);
 
		EngineID selected_id[2];
 
		const GroupID selected_group = this->sel_group;
 

	
 
@@ -334,7 +334,7 @@ public:
 
				break;
 

	
 
			case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { // Railtype selection dropdown menu
 
				const Company *c = GetCompany(_local_company);
 
				const Company *c = Company::Get(_local_company);
 
				DropDownList *list = new DropDownList();
 
				for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
					const RailtypeInfo *rti = GetRailTypeInfo(rt);
 
@@ -347,7 +347,7 @@ public:
 
			}
 

	
 
			case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
 
				DoCommandP(0, 5, GetCompany(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_SET_AUTOREPLACE);
 
				DoCommandP(0, 5, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_SET_AUTOREPLACE);
 
				break;
 

	
 
			case RVW_WIDGET_START_REPLACE: { // Start replacing
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -114,8 +114,8 @@ static int CDECL EngineNumberSorter(cons
 

	
 
static int CDECL EngineIntroDateSorter(const void *a, const void *b)
 
{
 
	const int va = GetEngine(*(const EngineID*)a)->intro_date;
 
	const int vb = GetEngine(*(const EngineID*)b)->intro_date;
 
	const int va = Engine::Get(*(const EngineID*)a)->intro_date;
 
	const int vb = Engine::Get(*(const EngineID*)b)->intro_date;
 
	const int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -152,8 +152,8 @@ static int CDECL EngineNameSorter(const 
 

	
 
static int CDECL EngineReliabilitySorter(const void *a, const void *b)
 
{
 
	const int va = GetEngine(*(const EngineID*)a)->reliability;
 
	const int vb = GetEngine(*(const EngineID*)b)->reliability;
 
	const int va = Engine::Get(*(const EngineID*)a)->reliability;
 
	const int vb = Engine::Get(*(const EngineID*)b)->reliability;
 
	const int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -163,8 +163,8 @@ static int CDECL EngineReliabilitySorter
 

	
 
static int CDECL EngineCostSorter(const void *a, const void *b)
 
{
 
	Money va = GetEngine(*(const EngineID*)a)->GetCost();
 
	Money vb = GetEngine(*(const EngineID*)b)->GetCost();
 
	Money va = Engine::Get(*(const EngineID*)a)->GetCost();
 
	Money vb = Engine::Get(*(const EngineID*)b)->GetCost();
 
	int r = ClampToI32(va - vb);
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -174,8 +174,8 @@ static int CDECL EngineCostSorter(const 
 

	
 
static int CDECL EngineSpeedSorter(const void *a, const void *b)
 
{
 
	int va = GetEngine(*(const EngineID*)a)->GetDisplayMaxSpeed();
 
	int vb = GetEngine(*(const EngineID*)b)->GetDisplayMaxSpeed();
 
	int va = Engine::Get(*(const EngineID*)a)->GetDisplayMaxSpeed();
 
	int vb = Engine::Get(*(const EngineID*)b)->GetDisplayMaxSpeed();
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -185,8 +185,8 @@ static int CDECL EngineSpeedSorter(const
 

	
 
static int CDECL EnginePowerSorter(const void *a, const void *b)
 
{
 
	int va = GetEngine(*(const EngineID*)a)->GetPower();
 
	int vb = GetEngine(*(const EngineID*)b)->GetPower();
 
	int va = Engine::Get(*(const EngineID*)a)->GetPower();
 
	int vb = Engine::Get(*(const EngineID*)b)->GetPower();
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -196,8 +196,8 @@ static int CDECL EnginePowerSorter(const
 

	
 
static int CDECL EngineRunningCostSorter(const void *a, const void *b)
 
{
 
	Money va = GetEngine(*(const EngineID*)a)->GetRunningCost();
 
	Money vb = GetEngine(*(const EngineID*)b)->GetRunningCost();
 
	Money va = Engine::Get(*(const EngineID*)a)->GetRunningCost();
 
	Money vb = Engine::Get(*(const EngineID*)b)->GetRunningCost();
 
	int r = ClampToI32(va - vb);
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -208,8 +208,8 @@ static int CDECL EngineRunningCostSorter
 
/* Train sorting functions */
 
static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *b)
 
{
 
	const Engine *e_a = GetEngine(*(const EngineID*)a);
 
	const Engine *e_b = GetEngine(*(const EngineID*)b);
 
	const Engine *e_a = Engine::Get(*(const EngineID*)a);
 
	const Engine *e_b = Engine::Get(*(const EngineID*)b);
 

	
 
	/* Here we are using a few tricks to get the right sort.
 
	 * We want power/running cost, but since we usually got higher running cost than power and we store the result in an int,
 
@@ -268,8 +268,8 @@ static int CDECL RoadVehEngineCapacitySo
 
/* Ship vehicle sorting functions */
 
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
 
{
 
	const Engine *e_a = GetEngine(*(const EngineID*)a);
 
	const Engine *e_b = GetEngine(*(const EngineID*)b);
 
	const Engine *e_a = Engine::Get(*(const EngineID*)a);
 
	const Engine *e_b = Engine::Get(*(const EngineID*)b);
 

	
 
	int va = e_a->GetDisplayDefaultCapacity();
 
	int vb = e_b->GetDisplayDefaultCapacity();
 
@@ -283,8 +283,8 @@ static int CDECL ShipEngineCapacitySorte
 
/* Aircraft sorting functions */
 
static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
 
{
 
	const Engine *e_a = GetEngine(*(const EngineID*)a);
 
	const Engine *e_b = GetEngine(*(const EngineID*)b);
 
	const Engine *e_a = Engine::Get(*(const EngineID*)a);
 
	const Engine *e_b = Engine::Get(*(const EngineID*)b);
 

	
 
	int va = e_a->GetDisplayDefaultCapacity();
 
	int vb = e_b->GetDisplayDefaultCapacity();
 
@@ -400,7 +400,7 @@ static const StringID _sort_listing[][11
 
static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid)
 
{
 
	if (cid == CF_ANY) return true;
 
	uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, GetEngine(*eid)->type, true);
 
	uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, Engine::Get(*eid)->type, true);
 
	return (cid == CF_NONE ? refit_mask == 0 : HasBit(refit_mask, cid));
 
}
 

	
 
@@ -431,7 +431,7 @@ static int DrawCargoCapacityInfo(int lef
 
/* Draw rail wagon specific details */
 
static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	const Engine *e = Engine::Get(engine_number);
 

	
 
	/* Purchase cost */
 
	SetDParam(0, e->GetCost());
 
@@ -469,7 +469,7 @@ static int DrawRailWagonPurchaseInfo(int
 
/* Draw locomotive specific details */
 
static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	const Engine *e = Engine::Get(engine_number);
 

	
 
	/* Purchase Cost - Engine weight */
 
	SetDParam(0, e->GetCost());
 
@@ -511,7 +511,7 @@ static int DrawRailEnginePurchaseInfo(in
 
/* Draw road vehicle specific details */
 
static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_number)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	const Engine *e = Engine::Get(engine_number);
 

	
 
	/* Purchase cost - Max speed */
 
	SetDParam(0, e->GetCost());
 
@@ -530,7 +530,7 @@ static int DrawRoadVehPurchaseInfo(int l
 
/* Draw ship specific details */
 
static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_number, const ShipVehicleInfo *svi, bool refittable)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	const Engine *e = Engine::Get(engine_number);
 

	
 
	/* Purchase cost - Max speed */
 
	SetDParam(0, e->GetCost());
 
@@ -556,7 +556,7 @@ static int DrawShipPurchaseInfo(int left
 
/* Draw aircraft specific details */
 
static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_number, const AircraftVehicleInfo *avi, bool refittable)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	const Engine *e = Engine::Get(engine_number);
 
	CargoID cargo = e->GetDefaultCargoType();
 

	
 
	/* Purchase cost - Max speed */
 
@@ -598,7 +598,7 @@ static int DrawAircraftPurchaseInfo(int 
 
 */
 
int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	const Engine *e = Engine::Get(engine_number);
 
	YearMonthDay ymd;
 
	ConvertDateToYMD(e->intro_date, &ymd);
 
	bool refittable = IsArticulatedVehicleRefittable(engine_number);
src/cargopacket.cpp
Show inline comments
 
@@ -21,7 +21,7 @@ CargoPacket::CargoPacket(StationID sourc
 
	if (source != INVALID_STATION) assert(count != 0);
 

	
 
	this->source          = source;
 
	this->source_xy       = (source != INVALID_STATION) ? GetStation(source)->xy : 0;
 
	this->source_xy       = (source != INVALID_STATION) ? Station::Get(source)->xy : 0;
 
	this->loaded_at_xy    = this->source_xy;
 

	
 
	this->count           = count;
src/cargopacket.h
Show inline comments
 
@@ -63,7 +63,7 @@ struct CargoPacket : PoolItem<CargoPacke
 
 * @param cp    the variable used as "iterator"
 
 * @param start the cargo packet ID of the first packet to iterate over
 
 */
 
#define FOR_ALL_CARGOPACKETS_FROM(cp, start) for (cp = GetCargoPacket(start); cp != NULL; cp = (cp->index + 1U < GetCargoPacketPoolSize()) ? GetCargoPacket(cp->index + 1U) : NULL) if (cp->IsValid())
 
#define FOR_ALL_CARGOPACKETS_FROM(cp, start) for (cp = CargoPacket::Get(start); cp != NULL; cp = (cp->index + 1U < GetCargoPacketPoolSize()) ? CargoPacket::Get(cp->index + 1U) : NULL) if (cp->IsValid())
 

	
 
/**
 
 * Iterate over all _valid_ cargo packets from the begin of the pool
src/command.cpp
Show inline comments
 
@@ -459,7 +459,7 @@ Money GetAvailableMoneyForCommand()
 
{
 
	CompanyID company = _current_company;
 
	if (!IsValidCompanyID(company)) return INT64_MAX;
 
	return GetCompany(company)->money;
 
	return Company::Get(company)->money;
 
}
 

	
 
/**
 
@@ -591,7 +591,7 @@ bool DoCommandP(TileIndex tile, uint32 p
 

	
 
	/* update last build coordinate of company. */
 
	if (tile != 0 && IsValidCompanyID(_current_company)) {
 
		GetCompany(_current_company)->last_build_coordinate = tile;
 
		Company::Get(_current_company)->last_build_coordinate = tile;
 
	}
 

	
 
	/* Actually try and execute the command. If no cost-type is given
src/company_base.h
Show inline comments
 
@@ -87,10 +87,10 @@ struct Company : PoolItem<Company, Compa
 

	
 
static inline bool IsValidCompanyID(CompanyID company)
 
{
 
	return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && GetCompany(company)->IsValid();
 
	return company < MAX_COMPANIES && (uint)company < GetCompanyPoolSize() && Company::Get(company)->IsValid();
 
}
 

	
 
#define FOR_ALL_COMPANIES_FROM(d, start) for (d = GetCompany(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? GetCompany(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_COMPANIES_FROM(d, start) for (d = Company::Get(start); d != NULL; d = (d->index + 1U < GetCompanyPoolSize()) ? Company::Get(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
 

	
 
static inline byte ActiveCompanyCount()
src/company_cmd.cpp
Show inline comments
 
@@ -77,7 +77,7 @@ void SetLocalCompany(CompanyID new_compa
 

	
 
	/* Do not update the settings if we are in the intro GUI */
 
	if (IsValidCompanyID(new_company) && _game_mode != GM_MENU) {
 
		const Company *c = GetCompany(new_company);
 
		const Company *c = Company::Get(new_company);
 
		_settings_client.company = c->settings;
 
		InvalidateWindow(WC_GAME_OPTIONS, 0);
 
	}
 
@@ -91,7 +91,7 @@ void SetLocalCompany(CompanyID new_compa
 

	
 
bool IsHumanCompany(CompanyID company)
 
{
 
	return !GetCompany(company)->is_ai;
 
	return !Company::Get(company)->is_ai;
 
}
 

	
 

	
 
@@ -151,7 +151,7 @@ bool CheckCompanyHasMoney(CommandCost co
 
{
 
	if (cost.GetCost() > 0) {
 
		CompanyID company = _current_company;
 
		if (IsValidCompanyID(company) && cost.GetCost() > GetCompany(company)->money) {
 
		if (IsValidCompanyID(company) && cost.GetCost() > Company::Get(company)->money) {
 
			SetDParam(0, cost.GetCost());
 
			_error_message = STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY;
 
			return false;
 
@@ -189,12 +189,12 @@ void SubtractMoneyFromCompany(CommandCos
 
{
 
	CompanyID cid = _current_company;
 

	
 
	if (IsValidCompanyID(cid)) SubtractMoneyFromAnyCompany(GetCompany(cid), cost);
 
	if (IsValidCompanyID(cid)) SubtractMoneyFromAnyCompany(Company::Get(cid), cost);
 
}
 

	
 
void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cst)
 
{
 
	Company *c = GetCompany(company);
 
	Company *c = Company::Get(company);
 
	byte m = c->money_fraction;
 
	Money cost = cst.GetCost();
 

	
 
@@ -500,7 +500,7 @@ void OnTick_Companies()
 
	if (_game_mode == GM_EDITOR) return;
 

	
 
	if (IsValidCompanyID((CompanyID)_cur_company_tick_index)) {
 
		Company *c = GetCompany((CompanyID)_cur_company_tick_index);
 
		Company *c = Company::Get((CompanyID)_cur_company_tick_index);
 
		if (c->name_1 != 0) GenerateCompanyName(c);
 
	}
 

	
 
@@ -528,7 +528,7 @@ void CompaniesYearlyLoop()
 

	
 
	if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) {
 
		ShowCompanyFinances(_local_company);
 
		c = GetCompany(_local_company);
 
		c = Company::Get(_local_company);
 
		if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) {
 
			SndPlayFx(SND_01_BAD_YEAR);
 
		} else {
 
@@ -569,7 +569,7 @@ CommandCost CmdSetAutoReplace(TileIndex 
 
{
 
	if (!IsValidCompanyID(_current_company)) return CMD_ERROR;
 

	
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 
	switch (GB(p1, 0, 3)) {
 
		case 0:
 
			if (c->settings.engine_renew == HasBit(p2, 0)) return CMD_ERROR;
 
@@ -823,7 +823,7 @@ CommandCost CmdCompanyCtrl(TileIndex til
 

	
 
			if (!(flags & DC_EXEC)) return CommandCost();
 

	
 
			c = GetCompany((CompanyID)p2);
 
			c = Company::Get((CompanyID)p2);
 

	
 
			/* Delete any open window of the company */
 
			DeleteCompanyWindows(c->index);
 
@@ -854,7 +854,7 @@ CommandCost CmdCompanyCtrl(TileIndex til
 
			if (!(flags & DC_EXEC)) return CMD_ERROR;
 

	
 
			ChangeOwnershipOfCompanyItems(cid_old, cid_new);
 
			delete GetCompany(cid_old);
 
			delete Company::Get(cid_old);
 
		} break;
 

	
 
		default: return CMD_ERROR;
src/company_gui.cpp
Show inline comments
 
@@ -337,7 +337,7 @@ struct CompanyFinancesWindow : Window {
 
	virtual void OnPaint()
 
	{
 
		CompanyID company = (CompanyID)this->window_number;
 
		const Company *c = GetCompany(company);
 
		const Company *c = Company::Get(company);
 

	
 
		if (!small) {
 
			int type = _settings_client.gui.expenses_layout;
 
@@ -542,7 +542,7 @@ private:
 
			if (HasBit(this->sel, scheme)) break;
 
		}
 
		if (scheme == LS_END) scheme = LS_DEFAULT;
 
		livery = &GetCompany((CompanyID)this->window_number)->livery[scheme];
 
		livery = &Company::Get((CompanyID)this->window_number)->livery[scheme];
 

	
 
		DropDownList *list = new DropDownList();
 
		for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
 
@@ -565,7 +565,7 @@ public:
 

	
 
	virtual void OnPaint()
 
	{
 
		const Company *c = GetCompany((CompanyID)this->window_number);
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 
		LiveryScheme scheme = LS_DEFAULT;
 
		int y = 51;
 

	
 
@@ -667,7 +667,7 @@ public:
 

	
 
				/* If clicking on the left edge, toggle using the livery */
 
				if (pt.x < 10) {
 
					DoCommandP(0, j | (2 << 8), !GetCompany((CompanyID)this->window_number)->livery[j].in_use, CMD_SET_COMPANY_COLOUR);
 
					DoCommandP(0, j | (2 << 8), !Company::Get((CompanyID)this->window_number)->livery[j].in_use, CMD_SET_COMPANY_COLOUR);
 
				}
 

	
 
				if (_ctrl_pressed) {
 
@@ -1112,7 +1112,7 @@ public:
 
	{
 
		this->parent = parent;
 
		this->owner = (Owner)this->window_number;
 
		this->face = GetCompany((CompanyID)this->window_number)->face;
 
		this->face = Company::Get((CompanyID)this->window_number)->face;
 
		this->advanced = advanced;
 

	
 
		this->UpdateData();
 
@@ -1218,7 +1218,7 @@ public:
 
		}
 

	
 
		/* Draw the company manager face picture */
 
		DrawCompanyManagerFace(this->face, GetCompany((CompanyID)this->window_number)->colour, this->widget[SCMFM_WIDGET_FACE].left, this->widget[SCMFM_WIDGET_FACE].top);
 
		DrawCompanyManagerFace(this->face, Company::Get((CompanyID)this->window_number)->colour, this->widget[SCMFM_WIDGET_FACE].left, this->widget[SCMFM_WIDGET_FACE].top);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget)
 
@@ -1577,7 +1577,7 @@ struct CompanyWindow : Window
 

	
 
	virtual void OnPaint()
 
	{
 
		const Company *c = GetCompany((CompanyID)this->window_number);
 
		const Company *c = Company::Get((CompanyID)this->window_number);
 
		bool local = this->window_number == _local_company;
 

	
 
		this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE,       !local);
 
@@ -1674,7 +1674,7 @@ struct CompanyWindow : Window
 
				break;
 

	
 
			case CW_WIDGET_BUILD_VIEW_HQ: {
 
				TileIndex tile = GetCompany((CompanyID)this->window_number)->location_of_HQ;
 
				TileIndex tile = Company::Get((CompanyID)this->window_number)->location_of_HQ;
 
				if (tile == INVALID_TILE) {
 
					if ((byte)this->window_number != _local_company) return;
 
					SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, HT_RECT, this);
 
@@ -1804,7 +1804,7 @@ struct BuyCompanyWindow : Window {
 

	
 
	virtual void OnPaint()
 
	{
 
		Company *c = GetCompany((CompanyID)this->window_number);
 
		Company *c = Company::Get((CompanyID)this->window_number);
 
		SetDParam(0, STR_COMPANY_NAME);
 
		SetDParam(1, c->index);
 
		this->DrawWidgets();
src/console_cmds.cpp
Show inline comments
 
@@ -650,7 +650,7 @@ DEF_CONSOLE_CMD(ConJoinCompany)
 
		return true;
 
	}
 

	
 
	if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) {
 
	if (company_id != COMPANY_SPECTATOR && Company::Get(company_id)->is_ai) {
 
		IConsoleError("Cannot join AI company.");
 
		return true;
 
	}
 
@@ -693,7 +693,7 @@ DEF_CONSOLE_CMD(ConMoveClient)
 
		return true;
 
	}
 

	
 
	if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) {
 
	if (company_id != COMPANY_SPECTATOR && Company::Get(company_id)->is_ai) {
 
		IConsoleError("You cannot move clients to AI companies.");
 
		return true;
 
	}
 
@@ -734,7 +734,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
 
		return true;
 
	}
 

	
 
	const Company *c = GetCompany(index);
 
	const Company *c = Company::Get(index);
 

	
 
	if (c->is_ai) {
 
		IConsoleError("Company is owned by an AI.");
src/core/random_func.cpp
Show inline comments
 
@@ -40,7 +40,7 @@ void SetRandomSeed(uint32 seed)
 

	
 
uint32 DoRandom(int line, const char *file)
 
{
 
	if (_networking && (GetNetworkClientSocket(0)->status != STATUS_INACTIVE || !_network_server)) {
 
	if (_networking && (NetworkClientSocket::Get(0)->status != STATUS_INACTIVE || !_network_server)) {
 
		printf("Random [%d/%d] %s:%d\n", _frame_counter, (byte)_current_company, file, line);
 
	}
 

	
src/date.cpp
Show inline comments
 
@@ -188,7 +188,7 @@ static void RunVehicleDayProc(uint dayti
 
	uint i;
 

	
 
	for (i = daytick; i < total; i += DAY_TICKS) {
 
		Vehicle *v = GetVehicle(i);
 
		Vehicle *v = Vehicle::Get(i);
 

	
 
		if (v->IsValid()) {
 
			/* Call the 32-day callback if needed */
src/depot_base.h
Show inline comments
 
@@ -24,12 +24,12 @@ struct Depot : PoolItem<Depot, DepotID, 
 

	
 
static inline bool IsValidDepotID(DepotID index)
 
{
 
	return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
 
	return index < GetDepotPoolSize() && Depot::Get(index)->IsValid();
 
}
 

	
 
Depot *GetDepotByTile(TileIndex tile);
 

	
 
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_DEPOTS_FROM(d, start) for (d = Depot::Get(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? Depot::Get(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
 

	
 
#endif /* DEPOT_BASE_H */
src/depot_gui.cpp
Show inline comments
 
@@ -139,14 +139,14 @@ void CcCloneVehicle(bool success, TileIn
 
{
 
	if (!success) return;
 

	
 
	const Vehicle *v = GetVehicle(_new_vehicle_id);
 
	const Vehicle *v = Vehicle::Get(_new_vehicle_id);
 

	
 
	ShowVehicleViewWindow(v);
 
}
 

	
 
static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
 
{
 
	const Vehicle *v = GetVehicle(sel);
 
	const Vehicle *v = Vehicle::Get(sel);
 

	
 
	if (v == wagon) return;
 

	
 
@@ -948,7 +948,7 @@ struct DepotWindow : Window {
 
					if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
 
						sel != INVALID_VEHICLE) {
 
						if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
 
							DoCommandP(GetVehicle(sel)->tile, GetVehicle(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_MAKE_VEHICLE_TURN));
 
							DoCommandP(Vehicle::Get(sel)->tile, Vehicle::Get(sel)->index, true, CMD_REVERSE_TRAIN_DIRECTION | CMD_MSG(STR_ERROR_CAN_T_MAKE_VEHICLE_TURN));
 
						} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
 
							TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
 
						} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
 
@@ -972,7 +972,7 @@ struct DepotWindow : Window {
 

	
 
					this->HandleButtonClick(widget);
 

	
 
					const Vehicle *v = GetVehicle(this->sel);
 
					const Vehicle *v = Vehicle::Get(this->sel);
 
					this->sel = INVALID_VEHICLE;
 
					this->SetDirty();
 

	
src/disaster_cmd.cpp
Show inline comments
 
@@ -307,7 +307,7 @@ static void DisasterTick_Ufo(Vehicle *v)
 
		delete v;
 
	} else {
 
		/* Target a vehicle */
 
		Vehicle *u = GetVehicle(v->dest_tile);
 
		Vehicle *u = Vehicle::Get(v->dest_tile);
 
		if (u->type != VEH_ROAD || !IsRoadVehFront(u)) {
 
			delete v;
 
			return;
 
@@ -393,7 +393,7 @@ static void DisasterTick_Aircraft(Vehicl
 

	
 
	if (v->current_order.GetDestination() == 2) {
 
		if (GB(v->tick_counter, 0, 2) == 0) {
 
			Industry *i = GetIndustry(v->dest_tile);
 
			Industry *i = Industry::Get(v->dest_tile);
 
			int x = TileX(i->xy) * TILE_SIZE;
 
			int y = TileY(i->xy) * TILE_SIZE;
 
			uint32 r = Random();
 
@@ -411,7 +411,7 @@ static void DisasterTick_Aircraft(Vehicl
 
			v->current_order.SetDestination(2);
 
			v->age = 0;
 

	
 
			Industry *i = GetIndustry(v->dest_tile);
 
			Industry *i = Industry::Get(v->dest_tile);
 
			DestructIndustry(i);
 

	
 
			SetDParam(0, i->town->index);
 
@@ -430,7 +430,7 @@ static void DisasterTick_Aircraft(Vehicl
 
		IndustryID ind = GetIndustryIndex(tile);
 
		v->dest_tile = ind;
 

	
 
		if (GetIndustrySpec(GetIndustry(ind)->type)->behaviour & industry_flag) {
 
		if (GetIndustrySpec(Industry::Get(ind)->type)->behaviour & industry_flag) {
 
			v->current_order.SetDestination(1);
 
			v->age = 0;
 
		}
 
@@ -574,7 +574,7 @@ static void DisasterTick_Big_Ufo_Destroy
 
	}
 

	
 
	if (v->current_order.GetDestination() == 0) {
 
		Vehicle *u = GetVehicle(v->u.disaster.big_ufo_destroyer_target);
 
		Vehicle *u = Vehicle::Get(v->u.disaster.big_ufo_destroyer_target);
 
		if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
 
		v->current_order.SetDestination(1);
 

	
 
@@ -911,7 +911,7 @@ void StartupDisasters()
 
}
 

	
 
/** Marks all disasters targeting this industry in such a way
 
 * they won't call GetIndustry(v->dest_tile) on invalid industry anymore.
 
 * they won't call Industry::Get(v->dest_tile) on invalid industry anymore.
 
 * @param i deleted industry
 
 */
 
void ReleaseDisastersTargetingIndustry(IndustryID i)
src/economy.cpp
Show inline comments
 
@@ -294,7 +294,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 
		}
 

	
 
		/* Sell all the shares that people have on this company */
 
		c = GetCompany(old_owner);
 
		c = Company::Get(old_owner);
 
		for (i = 0; i < 4; i++) {
 
			_current_company = c->share_owners[i];
 
			if (_current_company != INVALID_OWNER) {
 
@@ -313,7 +313,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 
	 * removing his/her property doesn't fail because of lack of money.
 
	 * Not too drastically though, because it could overflow */
 
	if (new_owner == INVALID_OWNER) {
 
		GetCompany(old_owner)->money = UINT64_MAX >> 2; // jackpot ;p
 
		Company::Get(old_owner)->money = UINT64_MAX >> 2; // jackpot ;p
 
	}
 

	
 
	if (new_owner == INVALID_OWNER) {
 
@@ -321,7 +321,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 

	
 
		for (s = _subsidies; s != endof(_subsidies); s++) {
 
			if (s->cargo_type != CT_INVALID && s->age >= 12) {
 
				if (GetStation(s->to)->owner == old_owner) s->cargo_type = CT_INVALID;
 
				if (Station::Get(s->to)->owner == old_owner) s->cargo_type = CT_INVALID;
 
			}
 
		}
 
	}
 
@@ -360,7 +360,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 
				} else {
 
					v->owner = new_owner;
 
					v->colourmap = PAL_NONE;
 
					if (IsEngineCountable(v)) GetCompany(new_owner)->num_engines[v->engine_type]++;
 
					if (IsEngineCountable(v)) Company::Get(new_owner)->num_engines[v->engine_type]++;
 
					if (v->IsPrimaryVehicle()) v->unitnumber = unitidgen[v->type].NextID();
 
				}
 
			}
 
@@ -418,7 +418,7 @@ void ChangeOwnershipOfCompanyItems(Owner
 

	
 
	/* In all cases clear replace engine rules.
 
	 * Even if it was copied, it could interfere with new owner's rules */
 
	RemoveAllEngineReplacementForCompany(GetCompany(old_owner));
 
	RemoveAllEngineReplacementForCompany(Company::Get(old_owner));
 

	
 
	if (new_owner == INVALID_OWNER) {
 
		RemoveAllGroupsForCompany(old_owner);
 
@@ -872,32 +872,32 @@ Pair SetupSubsidyDecodeParam(const Subsi
 
		if (cs->town_effect != TE_PASSENGERS && cs->town_effect != TE_MAIL) {
 
			SetDParam(1, STR_INDUSTRY);
 
			SetDParam(2, s->from);
 
			tile = GetIndustry(s->from)->xy;
 
			tile = Industry::Get(s->from)->xy;
 

	
 
			if (cs->town_effect != TE_GOODS && cs->town_effect != TE_FOOD) {
 
				SetDParam(4, STR_INDUSTRY);
 
				SetDParam(5, s->to);
 
				tile2 = GetIndustry(s->to)->xy;
 
				tile2 = Industry::Get(s->to)->xy;
 
			} else {
 
				SetDParam(4, STR_TOWN);
 
				SetDParam(5, s->to);
 
				tile2 = GetTown(s->to)->xy;
 
				tile2 = Town::Get(s->to)->xy;
 
			}
 
		} else {
 
			SetDParam(1, STR_TOWN);
 
			SetDParam(2, s->from);
 
			tile = GetTown(s->from)->xy;
 
			tile = Town::Get(s->from)->xy;
 

	
 
			SetDParam(4, STR_TOWN);
 
			SetDParam(5, s->to);
 
			tile2 = GetTown(s->to)->xy;
 
			tile2 = Town::Get(s->to)->xy;
 
		}
 
	} else {
 
		SetDParam(1, s->from);
 
		tile = GetStation(s->from)->xy;
 
		tile = Station::Get(s->from)->xy;
 

	
 
		SetDParam(2, s->to);
 
		tile2 = GetStation(s->to)->xy;
 
		tile2 = Station::Get(s->to)->xy;
 
	}
 

	
 
	tp.a = tile;
 
@@ -1069,7 +1069,7 @@ static void SubsidyMonthlyHandler()
 
			modified = true;
 
			AI::BroadcastNewEvent(new AIEventSubsidyOfferExpired(s - _subsidies));
 
		} else if (s->age == 2 * 12 - 1) {
 
			st = GetStation(s->to);
 
			st = Station::Get(s->to);
 
			if (st->owner == _local_company) {
 
				pair = SetupSubsidyDecodeParam(s, 1);
 
				AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, pair.a, pair.b);
 
@@ -1295,9 +1295,9 @@ static bool CheckSubsidised(Station *fro
 
			/* Check distance from source */
 
			const CargoSpec *cs = GetCargo(cargo_type);
 
			if (cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) {
 
				xy = GetTown(s->from)->xy;
 
				xy = Town::Get(s->from)->xy;
 
			} else {
 
				xy = GetIndustry(s->from)->xy;
 
				xy = Industry::Get(s->from)->xy;
 
			}
 
			if (DistanceMax(xy, from->xy) > 9) continue;
 

	
 
@@ -1307,11 +1307,11 @@ static bool CheckSubsidised(Station *fro
 
				case TE_MAIL:
 
				case TE_GOODS:
 
				case TE_FOOD:
 
					xy = GetTown(s->to)->xy;
 
					xy = Town::Get(s->to)->xy;
 
					break;
 

	
 
				default:
 
					xy = GetIndustry(s->to)->xy;
 
					xy = Industry::Get(s->to)->xy;
 
					break;
 
			}
 
			if (DistanceMax(xy, to->xy) > 9) continue;
 
@@ -1360,14 +1360,14 @@ static Money DeliverGoods(int num_pieces
 

	
 
	/* Update company statistics */
 
	{
 
		Company *c = GetCompany(_current_company);
 
		Company *c = Company::Get(_current_company);
 
		c->cur_economy.delivered_cargo += num_pieces;
 
		SetBit(c->cargo_types, cargo_type);
 
	}
 

	
 
	/* Get station pointers. */
 
	s_from = GetStation(source);
 
	s_to = GetStation(dest);
 
	s_from = Station::Get(source);
 
	s_to = Station::Get(dest);
 

	
 
	/* Check if a subsidy applies. */
 
	subsidised = CheckSubsidised(s_from, s_to, cargo_type);
 
@@ -1444,7 +1444,7 @@ void VehiclePayment(Vehicle *front_v)
 
	Money virtual_profit = 0; // The virtual profit for entire vehicle chain
 

	
 
	StationID last_visited = front_v->last_station_visited;
 
	Station *st = GetStation(last_visited);
 
	Station *st = Station::Get(last_visited);
 

	
 
	/* The owner of the train wants to be paid */
 
	CompanyID old_company = _current_company;
 
@@ -1496,7 +1496,7 @@ void VehiclePayment(Vehicle *front_v)
 
					Money profit = GetTransportedGoodsIncome(
 
						cp->count,
 
						/* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */
 
						DistanceManhattan(cp->loaded_at_xy, GetStation(last_visited)->xy),
 
						DistanceManhattan(cp->loaded_at_xy, Station::Get(last_visited)->xy),
 
						cp->days_in_transit,
 
						v->cargo_type);
 

	
 
@@ -1562,7 +1562,7 @@ static void LoadUnloadVehicle(Vehicle *v
 
	}
 

	
 
	StationID last_visited = v->last_station_visited;
 
	Station *st = GetStation(last_visited);
 
	Station *st = Station::Get(last_visited);
 

	
 
	if (v->type == VEH_TRAIN && (!IsTileType(v->tile, MP_STATION) || GetStationIndex(v->tile) != st->index)) {
 
		/* The train reversed in the station. Take the "easy" way
 
@@ -1837,7 +1837,7 @@ static void DoAcquireCompany(Company *c)
 
	CompanyID ci = c->index;
 

	
 
	CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
 
	cni->FillData(c, GetCompany(_current_company));
 
	cni->FillData(c, Company::Get(_current_company));
 

	
 
	SetDParam(0, STR_NEWS_COMPANY_MERGER_TITLE);
 
	SetDParam(1, c->bankrupt_value == 0 ? STR_NEWS_MERGER_TAKEOVER_TITLE : STR_NEWS_COMPANY_MERGER_DESCRIPTION);
 
@@ -1852,7 +1852,7 @@ static void DoAcquireCompany(Company *c)
 
	ChangeOwnershipOfCompanyItems(ci, _current_company);
 

	
 
	if (c->bankrupt_value == 0) {
 
		owner = GetCompany(_current_company);
 
		owner = Company::Get(_current_company);
 
		owner->current_loan += c->current_loan;
 
	}
 

	
 
@@ -1893,7 +1893,7 @@ CommandCost CmdBuyShareInCompany(TileInd
 
	 * Cannot buy own shares */
 
	if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
 

	
 
	Company *c = GetCompany((CompanyID)p1);
 
	Company *c = Company::Get((CompanyID)p1);
 

	
 
	/* Protect new companies from hostile takeovers */
 
	if (_cur_year - c->inaugurated_year < 6) return_cmd_error(STR_PROTECTED);
 
@@ -1936,7 +1936,7 @@ CommandCost CmdSellShareInCompany(TileIn
 
	 * Cannot sell own shares */
 
	if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
 

	
 
	Company *c = GetCompany((CompanyID)p1);
 
	Company *c = Company::Get((CompanyID)p1);
 

	
 
	/* Those lines are here for network-protection (clients can be slow) */
 
	if (GetAmountOwnedBy(c, _current_company) == 0) return CommandCost();
 
@@ -1973,7 +1973,7 @@ CommandCost CmdBuyCompany(TileIndex tile
 
	/* Do not allow companies to take over themselves */
 
	if (cid == _current_company) return CMD_ERROR;
 

	
 
	Company *c = GetCompany(cid);
 
	Company *c = Company::Get(cid);
 

	
 
	if (!c->is_ai) return CMD_ERROR;
 

	
src/engine.cpp
Show inline comments
 
@@ -378,11 +378,11 @@ void SetCachedEngineCounts()
 

	
 
		assert(v->engine_type < engines);
 

	
 
		GetCompany(v->owner)->num_engines[v->engine_type]++;
 
		Company::Get(v->owner)->num_engines[v->engine_type]++;
 

	
 
		if (v->group_id == DEFAULT_GROUP) continue;
 

	
 
		g = GetGroup(v->group_id);
 
		g = Group::Get(v->group_id);
 
		assert(v->type == g->vehicle_type);
 
		assert(v->owner == g->owner);
 

	
 
@@ -410,7 +410,7 @@ void ShowEnginePreviewWindow(EngineID en
 
/* Determine if an engine type is a wagon (and not a loco) */
 
static bool IsWagon(EngineID index)
 
{
 
	const Engine *e = GetEngine(index);
 
	const Engine *e = Engine::Get(index);
 
	return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON;
 
}
 

	
 
@@ -535,8 +535,8 @@ void StartupEngines()
 

	
 
static void AcceptEnginePreview(EngineID eid, CompanyID company)
 
{
 
	Engine *e = GetEngine(eid);
 
	Company *c = GetCompany(company);
 
	Engine *e = Engine::Get(eid);
 
	Company *c = Company::Get(company);
 

	
 
	SetBit(e->company_avail, company);
 
	if (e->type == VEH_TRAIN) {
 
@@ -623,7 +623,7 @@ CommandCost CmdWantEnginePreview(TileInd
 
	Engine *e;
 

	
 
	if (!IsEngineIndex(p1)) return CMD_ERROR;
 
	e = GetEngine(p1);
 
	e = Engine::Get(p1);
 
	if (GetBestCompany(e->preview_company_rank) != _current_company) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
 
@@ -744,7 +744,7 @@ CommandCost CmdRenameEngine(TileIndex ti
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Engine *e = GetEngine(p1);
 
		Engine *e = Engine::Get(p1);
 
		free(e->name);
 

	
 
		if (reset) {
 
@@ -772,7 +772,7 @@ bool IsEngineBuildable(EngineID engine, 
 
	/* check if it's an engine that is in the engine array */
 
	if (!IsEngineIndex(engine)) return false;
 

	
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	/* check if it's an engine of specified type */
 
	if (e->type != type) return false;
 
@@ -782,7 +782,7 @@ bool IsEngineBuildable(EngineID engine, 
 

	
 
	if (type == VEH_TRAIN) {
 
		/* Check if the rail type is available to this company */
 
		const Company *c = GetCompany(company);
 
		const Company *c = Company::Get(company);
 
		if (!HasBit(c->avail_railtypes, RailVehInfo(engine)->railtype)) return false;
 
	}
 

	
 
@@ -800,7 +800,7 @@ bool IsEngineRefittable(EngineID engine)
 
	/* check if it's an engine that is in the engine array */
 
	if (!IsEngineIndex(engine)) return false;
 

	
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
 

	
src/engine_base.h
Show inline comments
 
@@ -87,34 +87,34 @@ static inline bool IsEngineIndex(uint in
 
	return index < GetEnginePoolSize();
 
}
 

	
 
#define FOR_ALL_ENGINES_FROM(e, start) for (e = GetEngine(start); e != NULL; e = (e->index + 1U < GetEnginePoolSize()) ? GetEngine(e->index + 1U) : NULL) if (e->IsValid())
 
#define FOR_ALL_ENGINES_FROM(e, start) for (e = Engine::Get(start); e != NULL; e = (e->index + 1U < GetEnginePoolSize()) ? Engine::Get(e->index + 1U) : NULL) if (e->IsValid())
 
#define FOR_ALL_ENGINES(e) FOR_ALL_ENGINES_FROM(e, 0)
 

	
 
#define FOR_ALL_ENGINES_OF_TYPE(e, engine_type) FOR_ALL_ENGINES(e) if (e->type == engine_type)
 

	
 
static inline const EngineInfo *EngInfo(EngineID e)
 
{
 
	return &GetEngine(e)->info;
 
	return &Engine::Get(e)->info;
 
}
 

	
 
static inline const RailVehicleInfo *RailVehInfo(EngineID e)
 
{
 
	return &GetEngine(e)->u.rail;
 
	return &Engine::Get(e)->u.rail;
 
}
 

	
 
static inline const RoadVehicleInfo *RoadVehInfo(EngineID e)
 
{
 
	return &GetEngine(e)->u.road;
 
	return &Engine::Get(e)->u.road;
 
}
 

	
 
static inline const ShipVehicleInfo *ShipVehInfo(EngineID e)
 
{
 
	return &GetEngine(e)->u.ship;
 
	return &Engine::Get(e)->u.ship;
 
}
 

	
 
static inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
 
{
 
	return &GetEngine(e)->u.air;
 
	return &Engine::Get(e)->u.air;
 
}
 

	
 
#endif /* ENGINE_TYPE_H */
src/engine_gui.cpp
Show inline comments
 
@@ -20,7 +20,7 @@
 

	
 
StringID GetEngineCategoryName(EngineID engine)
 
{
 
	switch (GetEngine(engine)->type) {
 
	switch (Engine::Get(engine)->type) {
 
		default: NOT_REACHED();
 
		case VEH_ROAD:              return STR_ENGINE_PREVIEW_ROAD_VEHICLE;
 
		case VEH_AIRCRAFT:          return STR_ENGINE_PREVIEW_AIRCRAFT;
 
@@ -100,7 +100,7 @@ struct EnginePreviewWindow : Window {
 
		SetDParam(0, engine);
 
		DrawString(this->widget[EPW_BACKGROUND].left + 2, this->widget[EPW_BACKGROUND].right - 2, 80, STR_ENGINE_NAME, TC_BLACK, SA_CENTER);
 

	
 
		const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
 
		const DrawEngineInfo *dei = &_draw_engine_list[Engine::Get(engine)->type];
 

	
 
		int width = this->width;
 
		dei->engine_proc(width >> 1, 100, engine, 0);
 
@@ -147,7 +147,7 @@ uint GetTotalCapacityOfArticulatedParts(
 

	
 
static void DrawTrainEngineInfo(EngineID engine, int left, int right, int top, int bottom)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	SetDParam(0, e->GetCost());
 
	SetDParam(2, e->GetDisplayMaxSpeed());
 
@@ -168,7 +168,7 @@ static void DrawTrainEngineInfo(EngineID
 

	
 
static void DrawAircraftEngineInfo(EngineID engine, int left, int right, int top, int bottom)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 
	CargoID cargo = e->GetDefaultCargoType();
 

	
 
	if (cargo == CT_INVALID || cargo == CT_PASSENGERS) {
 
@@ -194,7 +194,7 @@ static void DrawAircraftEngineInfo(Engin
 

	
 
static void DrawRoadVehEngineInfo(EngineID engine, int left, int right, int top, int bottom)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	SetDParam(0, e->GetCost());
 
	SetDParam(1, e->GetDisplayMaxSpeed());
 
@@ -212,7 +212,7 @@ static void DrawRoadVehEngineInfo(Engine
 

	
 
static void DrawShipEngineInfo(EngineID engine, int left, int right, int top, int bottom)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	SetDParam(0, e->GetCost());
 
	SetDParam(1, e->GetDisplayMaxSpeed());
 
@@ -225,7 +225,7 @@ static void DrawShipEngineInfo(EngineID 
 
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni)
 
{
 
	EngineID engine = ni->data_a;
 
	const DrawEngineInfo *dei = &_draw_engine_list[GetEngine(engine)->type];
 
	const DrawEngineInfo *dei = &_draw_engine_list[Engine::Get(engine)->type];
 

	
 
	SetDParam(0, GetEngineCategoryName(engine));
 
	DrawStringMultiLine(1, w->width - 2, 0, 56, STR_NEW_VEHICLE_NOW_AVAILABLE, TC_FROMSTRING, SA_CENTER);
src/graph_gui.cpp
Show inline comments
 
@@ -426,7 +426,7 @@ public:
 
		int numd = 0;
 
		for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
 
			if (IsValidCompanyID(k)) {
 
				c = GetCompany(k);
 
				c = Company::Get(k);
 
				this->colours[numd] = _colour_gradient[c->colour][6];
 
				for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
 
					this->cost[numd][i] = (j >= c->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j);
src/group.h
Show inline comments
 
@@ -32,7 +32,7 @@ struct Group : PoolItem<Group, GroupID, 
 

	
 
static inline bool IsValidGroupID(GroupID index)
 
{
 
	return index < GetGroupPoolSize() && GetGroup(index)->IsValid();
 
	return index < GetGroupPoolSize() && Group::Get(index)->IsValid();
 
}
 

	
 
static inline bool IsDefaultGroupID(GroupID index)
 
@@ -50,7 +50,7 @@ static inline bool IsAllGroupID(GroupID 
 
	return id_g == ALL_GROUP;
 
}
 

	
 
#define FOR_ALL_GROUPS_FROM(g, start) for (g = GetGroup(start); g != NULL; g = (g->index + 1U < GetGroupPoolSize()) ? GetGroup(g->index + 1) : NULL) if (g->IsValid())
 
#define FOR_ALL_GROUPS_FROM(g, start) for (g = Group::Get(start); g != NULL; g = (g->index + 1U < GetGroupPoolSize()) ? Group::Get(g->index + 1) : NULL) if (g->IsValid())
 
#define FOR_ALL_GROUPS(g) FOR_ALL_GROUPS_FROM(g, 0)
 

	
 
/**
 
@@ -77,12 +77,12 @@ uint GetGroupNumEngines(CompanyID compan
 

	
 
static inline void IncreaseGroupNumVehicle(GroupID id_g)
 
{
 
	if (IsValidGroupID(id_g)) GetGroup(id_g)->num_vehicle++;
 
	if (IsValidGroupID(id_g)) Group::Get(id_g)->num_vehicle++;
 
}
 

	
 
static inline void DecreaseGroupNumVehicle(GroupID id_g)
 
{
 
	if (IsValidGroupID(id_g)) GetGroup(id_g)->num_vehicle--;
 
	if (IsValidGroupID(id_g)) Group::Get(id_g)->num_vehicle--;
 
}
 

	
 

	
src/group_cmd.cpp
Show inline comments
 
@@ -32,10 +32,10 @@ static inline void UpdateNumEngineGroup(
 
{
 
	if (old_g != new_g) {
 
		/* Decrease the num engines of EngineID i of the old group if it's not the default one */
 
		if (!IsDefaultGroupID(old_g) && IsValidGroupID(old_g)) GetGroup(old_g)->num_engines[i]--;
 
		if (!IsDefaultGroupID(old_g) && IsValidGroupID(old_g)) Group::Get(old_g)->num_engines[i]--;
 

	
 
		/* Increase the num engines of EngineID i of the new group if it's not the default one */
 
		if (!IsDefaultGroupID(new_g) && IsValidGroupID(new_g)) GetGroup(new_g)->num_engines[i]++;
 
		if (!IsDefaultGroupID(new_g) && IsValidGroupID(new_g)) Group::Get(new_g)->num_engines[i]++;
 
	}
 
}
 

	
 
@@ -107,7 +107,7 @@ CommandCost CmdDeleteGroup(TileIndex til
 
{
 
	if (!IsValidGroupID(p1)) return CMD_ERROR;
 

	
 
	Group *g = GetGroup(p1);
 
	Group *g = Group::Get(p1);
 
	if (g->owner != _current_company) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -126,7 +126,7 @@ CommandCost CmdDeleteGroup(TileIndex til
 
			Company *c;
 
			EngineRenew *er;
 

	
 
			c = GetCompany(_current_company);
 
			c = Company::Get(_current_company);
 
			FOR_ALL_ENGINE_RENEWS(er) {
 
				if (er->group_id == g->index) RemoveEngineReplacementForCompany(c, er->from, g->index, flags);
 
			}
 
@@ -166,7 +166,7 @@ CommandCost CmdRenameGroup(TileIndex til
 
{
 
	if (!IsValidGroupID(p1)) return CMD_ERROR;
 

	
 
	Group *g = GetGroup(p1);
 
	Group *g = Group::Get(p1);
 
	if (g->owner != _current_company) return CMD_ERROR;
 

	
 
	bool reset = StrEmpty(text);
 
@@ -203,10 +203,10 @@ CommandCost CmdAddVehicleGroup(TileIndex
 

	
 
	if (!IsValidVehicleID(p2) || (!IsValidGroupID(new_g) && !IsDefaultGroupID(new_g))) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p2);
 
	Vehicle *v = Vehicle::Get(p2);
 

	
 
	if (IsValidGroupID(new_g)) {
 
		Group *g = GetGroup(new_g);
 
		Group *g = Group::Get(new_g);
 
		if (g->owner != _current_company || g->vehicle_type != v->type) return CMD_ERROR;
 
	}
 

	
 
@@ -286,7 +286,7 @@ CommandCost CmdRemoveAllVehiclesGroup(Ti
 
	VehicleType type = (VehicleType)p2;
 
	if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
 

	
 
	Group *g = GetGroup(p1);
 
	Group *g = Group::Get(p1);
 
	if (g->owner != _current_company) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -322,7 +322,7 @@ CommandCost CmdSetGroupReplaceProtection
 
{
 
	if (!IsValidGroupID(p1)) return CMD_ERROR;
 

	
 
	Group *g = GetGroup(p1);
 
	Group *g = Group::Get(p1);
 
	if (g->owner != _current_company) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -395,9 +395,9 @@ void UpdateTrainGroupID(Vehicle *v)
 

	
 
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
 
{
 
	if (IsValidGroupID(id_g)) return GetGroup(id_g)->num_engines[id_e];
 
	if (IsValidGroupID(id_g)) return Group::Get(id_g)->num_engines[id_e];
 

	
 
	uint num = GetCompany(company)->num_engines[id_e];
 
	uint num = Company::Get(company)->num_engines[id_e];
 
	if (!IsDefaultGroupID(id_g)) return num;
 

	
 
	const Group *g;
src/group_gui.cpp
Show inline comments
 
@@ -405,7 +405,7 @@ public:
 
				default: NOT_REACHED();
 
			}
 
		} else {
 
			const Group *g = GetGroup(this->group_sel);
 
			const Group *g = Group::Get(this->group_sel);
 

	
 
			SetDParam(0, g->index);
 
			SetDParam(1, g->num_vehicle);
 
@@ -569,7 +569,7 @@ public:
 
			case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
 
				assert(IsValidGroupID(this->group_sel));
 

	
 
				const Group *g = GetGroup(this->group_sel);
 
				const Group *g = Group::Get(this->group_sel);
 

	
 
				SetDParam(0, g->index);
 
				ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, MAX_LENGTH_GROUP_NAME_BYTES, MAX_LENGTH_GROUP_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
@@ -596,7 +596,7 @@ public:
 

	
 
			case GRP_WIDGET_REPLACE_PROTECTION:
 
				if (IsValidGroupID(this->group_sel)) {
 
					const Group *g = GetGroup(this->group_sel);
 
					const Group *g = Group::Get(this->group_sel);
 

	
 
					DoCommandP(0, this->group_sel, !g->replace_protection, CMD_SET_GROUP_REPLACE_PROTECTION);
 
				}
src/highscore_gui.cpp
Show inline comments
 
@@ -59,7 +59,7 @@ struct EndGameWindow : EndGameHighScoreB
 
		this->background_img = SPR_TYCOON_IMG1_BEGIN;
 

	
 
		if (_local_company != COMPANY_SPECTATOR) {
 
			const Company *c = GetCompany(_local_company);
 
			const Company *c = Company::Get(_local_company);
 
			if (c->old_economy[0].performance_history == SCORE_MAX) {
 
				this->background_img = SPR_TYCOON_IMG2_BEGIN;
 
			}
 
@@ -72,7 +72,7 @@ struct EndGameWindow : EndGameHighScoreB
 
			this->rank = SaveHighScoreValueNetwork();
 
		} else {
 
			/* in single player _local company is always valid */
 
			const Company *c = GetCompany(_local_company);
 
			const Company *c = Company::Get(_local_company);
 
			this->window_number = _settings_game.difficulty.diff_level;
 
			this->rank = SaveHighScoreValue(c);
 
		}
 
@@ -95,7 +95,7 @@ struct EndGameWindow : EndGameHighScoreB
 

	
 
		if (!IsValidCompanyID(_local_company)) return;
 

	
 
		c = GetCompany(_local_company);
 
		c = Company::Get(_local_company);
 
		/* We need to get performance from last year because the image is shown
 
		 * at the start of the new year when these things have already been copied */
 
		if (this->background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
src/industry.h
Show inline comments
 
@@ -272,7 +272,7 @@ void SetIndustryDailyChanges();
 
 */
 
static inline bool IsValidIndustryID(IndustryID index)
 
{
 
	return index < GetIndustryPoolSize() && GetIndustry(index)->IsValid();
 
	return index < GetIndustryPoolSize() && Industry::Get(index)->IsValid();
 
}
 

	
 

	
 
@@ -352,10 +352,10 @@ static inline Industry *GetRandomIndustr
 
		}
 
	}
 

	
 
	return GetIndustry(index);
 
	return Industry::Get(index);
 
}
 

	
 
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = GetIndustry(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? GetIndustry(i->index + 1U) : NULL) if (i->IsValid())
 
#define FOR_ALL_INDUSTRIES_FROM(i, start) for (i = Industry::Get(start); i != NULL; i = (i->index + 1U < GetIndustryPoolSize()) ? Industry::Get(i->index + 1U) : NULL) if (i->IsValid())
 
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
 

	
 
static const uint8 IT_INVALID = 255;
src/industry_cmd.cpp
Show inline comments
 
@@ -1624,7 +1624,7 @@ static Industry *CreateNewIndustryHelper
 

	
 
	/* We need to return a non-NULL pointer to tell we have created an industry.
 
	 * However, we haven't created a real one (no DC_EXEC), so return a fake one. */
 
	return GetIndustry(0);
 
	return Industry::Get(0);
 
}
 

	
 
/** Build/Fund an industry
 
@@ -2010,7 +2010,7 @@ int WhoCanServiceIndustry(Industry *ind)
 
		FOR_VEHICLE_ORDERS(v, o) {
 
			if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
 
				/* Vehicle visits a station to load or unload */
 
				Station *st = GetStation(o->GetDestination());
 
				Station *st = Station::Get(o->GetDestination());
 
				if (!st->IsValid()) continue;
 

	
 
				/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
src/industry_gui.cpp
Show inline comments
 
@@ -485,13 +485,13 @@ public:
 
		this->editbox_line = 0;
 
		this->clicked_line = 0;
 
		this->clicked_button = 0;
 
		InitializeWindowViewport(this, 3, 17, 254, 86, GetIndustry(window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
 
		InitializeWindowViewport(this, 3, 17, 254, 86, Industry::Get(window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
 
		this->FindWindowPlacementAndResize(desc);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		Industry *i = GetIndustry(this->window_number);
 
		Industry *i = Industry::Get(this->window_number);
 
		const IndustrySpec *ind = GetIndustrySpec(i->type);
 
		int y = this->widget[IVW_INFO].top + 1;
 
		bool first = true;
 
@@ -594,7 +594,7 @@ public:
 
			case IVW_INFO: {
 
				int line, x;
 

	
 
				i = GetIndustry(this->window_number);
 
				i = Industry::Get(this->window_number);
 

	
 
				/* We should work if needed.. */
 
				if (!IsProductionAlterable(i)) return;
 
@@ -628,7 +628,7 @@ public:
 
			} break;
 

	
 
			case IVW_GOTO:
 
				i = GetIndustry(this->window_number);
 
				i = Industry::Get(this->window_number);
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1));
 
				} else {
 
@@ -660,7 +660,7 @@ public:
 
	{
 
		if (StrEmpty(str)) return;
 

	
 
		Industry *i = GetIndustry(this->window_number);
 
		Industry *i = Industry::Get(this->window_number);
 
		int line = this->editbox_line;
 

	
 
		i->production_rate[line] = ClampU(atoi(str), 0, 255);
src/industry_map.h
Show inline comments
 
@@ -70,7 +70,7 @@ static inline IndustryID GetIndustryInde
 
 */
 
static inline Industry *GetIndustryByTile(TileIndex t)
 
{
 
	return GetIndustry(GetIndustryIndex(t));
 
	return Industry::Get(GetIndustryIndex(t));
 
}
 

	
 
/**
src/main_gui.cpp
Show inline comments
 
@@ -61,7 +61,7 @@ void HandleOnEditText(const char *str)
 
	switch (_rename_what) {
 
#ifdef ENABLE_NETWORK
 
	case 3: { // Give money, you can only give money in excess of loan
 
		const Company *c = GetCompany(_local_company);
 
		const Company *c = Company::Get(_local_company);
 
		Money money = min(c->money - c->current_loan, (Money)(atoi(str) / _currency->rate));
 

	
 
		uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
src/misc_cmd.cpp
Show inline comments
 
@@ -35,7 +35,7 @@ CommandCost CmdSetCompanyManagerFace(Til
 
	if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		GetCompany(_current_company)->face = cmf;
 
		Company::Get(_current_company)->face = cmf;
 
		MarkWholeScreenDirty();
 
	}
 
	return CommandCost();
 
@@ -60,7 +60,7 @@ CommandCost CmdSetCompanyColour(TileInde
 

	
 
	if (scheme >= LS_END || state >= 3) return CMD_ERROR;
 

	
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 

	
 
	/* Ensure no two companies have the same primary colour */
 
	if (scheme == LS_DEFAULT && state == 0) {
 
@@ -138,7 +138,7 @@ CommandCost CmdSetCompanyColour(TileInde
 
 */
 
CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 

	
 
	if (c->current_loan >= _economy.max_loan) {
 
		SetDParam(0, _economy.max_loan);
 
@@ -182,7 +182,7 @@ CommandCost CmdIncreaseLoan(TileIndex ti
 
 */
 
CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 

	
 
	if (c->current_loan == 0) return_cmd_error(STR_ERROR_LOAN_ALREADY_REPAYED);
 

	
 
@@ -242,7 +242,7 @@ CommandCost CmdRenameCompany(TileIndex t
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Company *c = GetCompany(_current_company);
 
		Company *c = Company::Get(_current_company);
 
		free(c->name);
 
		c->name = reset ? NULL : strdup(text);
 
		MarkWholeScreenDirty();
 
@@ -278,7 +278,7 @@ CommandCost CmdRenamePresident(TileIndex
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Company *c = GetCompany(_current_company);
 
		Company *c = Company::Get(_current_company);
 
		free(c->president_name);
 

	
 
		if (reset) {
 
@@ -382,7 +382,7 @@ CommandCost CmdGiveMoney(TileIndex tile,
 
{
 
	if (!_settings_game.economy.give_money) return CMD_ERROR;
 

	
 
	const Company *c = GetCompany(_current_company);
 
	const Company *c = Company::Get(_current_company);
 
	CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
 

	
 
	/* You can only transfer funds that is in excess of your loan */
src/misc_gui.cpp
Show inline comments
 
@@ -104,7 +104,7 @@ public:
 
	}
 

	
 
	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
 
		Company *c = GetCompany(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
 
		Company *c = Company::Get(IsValidCompanyID(_local_company) ? _local_company : COMPANY_FIRST);
 
		Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
 

	
 
		Money old_money = c->money;
 
@@ -556,7 +556,7 @@ public:
 
		RewindTextRefStack();
 

	
 
		if (this->show_company_manager_face) {
 
			const Company *c = GetCompany((CompanyID)GetDParamX(this->decode_params, 2));
 
			const Company *c = Company::Get((CompanyID)GetDParamX(this->decode_params, 2));
 
			DrawCompanyManagerFace(c->face, c->colour, this->widget[EMW_FACE].left, this->widget[EMW_FACE].top);
 
		}
 

	
src/network/core/tcp_game.h
Show inline comments
 
@@ -110,10 +110,10 @@ public:
 

	
 
static inline bool IsValidNetworkClientSocketIndex(ClientIndex index)
 
{
 
	return (uint)index < GetNetworkClientSocketPoolSize() && GetNetworkClientSocket(index)->IsValid();
 
	return (uint)index < GetNetworkClientSocketPoolSize() && NetworkClientSocket::Get(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = GetNetworkClientSocket(start); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? GetNetworkClientSocket(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_CLIENT_SOCKETS_FROM(d, start) for (d = NetworkClientSocket::Get(start); d != NULL; d = (d->index + 1U < GetNetworkClientSocketPoolSize()) ? NetworkClientSocket::Get(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0)
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network.cpp
Show inline comments
 
@@ -97,7 +97,7 @@ extern void StateGameLoop();
 
 */
 
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index)
 
{
 
	return IsValidNetworkClientInfoIndex(index) ? GetNetworkClientInfo(index) : NULL;
 
	return IsValidNetworkClientInfoIndex(index) ? NetworkClientInfo::Get(index) : NULL;
 
}
 

	
 
/**
 
@@ -926,7 +926,7 @@ static bool NetworkDoClientLoop()
 
				NetworkError(STR_NETWORK_ERR_DESYNC);
 
				DEBUG(desync, 1, "sync_err: %d; %d\n", _date, _date_fract);
 
				DEBUG(net, 0, "Sync error detected!");
 
				NetworkClientError(NETWORK_RECV_STATUS_DESYNC, GetNetworkClientSocket(0));
 
				NetworkClientError(NETWORK_RECV_STATUS_DESYNC, NetworkClientSocket::Get(0));
 
				return false;
 
			}
 

	
src/network/network_base.h
Show inline comments
 
@@ -29,10 +29,10 @@ struct NetworkClientInfo : PoolItem<Netw
 

	
 
static inline bool IsValidNetworkClientInfoIndex(ClientIndex index)
 
{
 
	return (uint)index < GetNetworkClientInfoPoolSize() && GetNetworkClientInfo(index)->IsValid();
 
	return (uint)index < GetNetworkClientInfoPoolSize() && NetworkClientInfo::Get(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (d = GetNetworkClientInfo(start); d != NULL; d = (d->index + 1U < GetNetworkClientInfoPoolSize()) ? GetNetworkClientInfo(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_CLIENT_INFOS_FROM(d, start) for (d = NetworkClientInfo::Get(start); d != NULL; d = (d->index + 1U < GetNetworkClientInfoPoolSize()) ? NetworkClientInfo::Get(d->index + 1U) : NULL) if (d->IsValid())
 
#define FOR_ALL_CLIENT_INFOS(d) FOR_ALL_CLIENT_INFOS_FROM(d, 0)
 

	
 
#endif /* ENABLE_NETWORK */
src/network/network_client.cpp
Show inline comments
 
@@ -30,7 +30,7 @@
 

	
 

	
 
/* So we don't make too much typos ;) */
 
#define MY_CLIENT GetNetworkClientSocket(0)
 
#define MY_CLIENT NetworkClientSocket::Get(0)
 

	
 
static uint32 last_ack_frame;
 

	
src/network/network_server.cpp
Show inline comments
 
@@ -1237,7 +1237,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
	/* Check if the company is valid */
 
	if (!IsValidCompanyID(company_id) && company_id != COMPANY_SPECTATOR) return;
 
	/* We don't allow moving to AI companies */
 
	if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) return;
 
	if (company_id != COMPANY_SPECTATOR && Company::Get(company_id)->is_ai) return;
 

	
 
	/* Check if we require a password for this company */
 
	if (company_id != COMPANY_SPECTATOR && !StrEmpty(_network_company_states[company_id].password)) {
src/newgrf.cpp
Show inline comments
 
@@ -354,13 +354,13 @@ static Engine *GetNewEngine(const GRFFil
 

	
 
		/* Check if the engine is registered in the override manager */
 
		EngineID engine = _engine_mngr.GetID(type, internal_id, scope_grfid);
 
		if (engine != INVALID_ENGINE) return GetEngine(engine);
 
		if (engine != INVALID_ENGINE) return Engine::Get(engine);
 
	}
 

	
 
	/* Check if there is an unreserved slot */
 
	EngineID engine = _engine_mngr.GetID(type, internal_id, INVALID_GRFID);
 
	if (engine != INVALID_ENGINE) {
 
		Engine *e = GetEngine(engine);
 
		Engine *e = Engine::Get(engine);
 

	
 
		if (e->grffile == NULL) {
 
			e->grffile = file;
src/newgrf_engine.cpp
Show inline comments
 
@@ -27,7 +27,7 @@ struct WagonOverride {
 

	
 
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const SpriteGroup *group, EngineID *train_id, uint trains)
 
{
 
	Engine *e = GetEngine(engine);
 
	Engine *e = Engine::Get(engine);
 
	WagonOverride *wo;
 

	
 
	assert(cargo < NUM_CARGO + 2); // Include CT_DEFAULT and CT_PURCHASE pseudo cargos.
 
@@ -45,7 +45,7 @@ void SetWagonOverrideSprites(EngineID en
 

	
 
const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, EngineID overriding_engine)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	/* XXX: This could turn out to be a timesink on profiles. We could
 
	 * always just dedicate 65535 bytes for an [engine][train] trampoline
 
@@ -81,7 +81,7 @@ void UnloadWagonOverrides(Engine *e)
 

	
 
void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group)
 
{
 
	Engine *e = GetEngine(engine);
 
	Engine *e = Engine::Get(engine);
 
	assert(cargo < lengthof(e->group));
 

	
 
	if (e->group[cargo] != NULL) {
 
@@ -99,7 +99,7 @@ void SetCustomEngineSprites(EngineID eng
 
 */
 
void SetEngineGRF(EngineID engine, const GRFFile *file)
 
{
 
	Engine *e = GetEngine(engine);
 
	Engine *e = Engine::Get(engine);
 
	e->grffile = file;
 
}
 

	
 
@@ -111,7 +111,7 @@ void SetEngineGRF(EngineID engine, const
 
 */
 
const GRFFile *GetEngineGRF(EngineID engine)
 
{
 
	return GetEngine(engine)->grffile;
 
	return Engine::Get(engine)->grffile;
 
}
 

	
 

	
 
@@ -479,7 +479,7 @@ static uint32 VehicleGetVariable(const R
 
			case 0x43: return _current_company | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information
 
			case 0x46: return 0;               // Motion counter
 
			case 0x47: { // Vehicle cargo info
 
				const Engine *e = GetEngine(object->u.vehicle.self_type);
 
				const Engine *e = Engine::Get(object->u.vehicle.self_type);
 
				CargoID cargo_type = e->GetDefaultCargoType();
 
				if (cargo_type != CT_INVALID) {
 
					const CargoSpec *cs = GetCargo(cargo_type);
 
@@ -488,7 +488,7 @@ static uint32 VehicleGetVariable(const R
 
					return 0x000000FF;
 
				}
 
			}
 
			case 0x48: return GetEngine(object->u.vehicle.self_type)->flags; // Vehicle Type Info
 
			case 0x48: return Engine::Get(object->u.vehicle.self_type)->flags; // Vehicle Type Info
 
			case 0x49: return _cur_year; // 'Long' format build year
 
			case 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
 
			case 0xDA: return INVALID_VEHICLE; // Next vehicle
 
@@ -576,7 +576,7 @@ static uint32 VehicleGetVariable(const R
 

	
 
		case 0x43: // Company information
 
			if (!HasBit(v->cache_valid, 3)) {
 
				v->cached_var43 = v->owner | (GetCompany(v->owner)->is_ai ? 0x10000 : 0) | (LiveryHelper(v->engine_type, v) << 24);
 
				v->cached_var43 = v->owner | (Company::Get(v->owner)->is_ai ? 0x10000 : 0) | (LiveryHelper(v->engine_type, v) << 24);
 
				SetBit(v->cache_valid, 3);
 
			}
 
			return v->cached_var43;
 
@@ -646,18 +646,18 @@ static uint32 VehicleGetVariable(const R
 
			return (cs->classes << 16) | (cs->weight << 8) | GetEngineGRF(v->engine_type)->cargo_map[v->cargo_type];
 
		}
 

	
 
		case 0x48: return GetEngine(v->engine_type)->flags; // Vehicle Type Info
 
		case 0x48: return Engine::Get(v->engine_type)->flags; // Vehicle Type Info
 
		case 0x49: return v->build_year;
 

	
 
		/* Variables which use the parameter */
 
		case 0x60: // Count consist's engine ID occurance
 
			//EngineID engine = GetNewEngineID(GetEngineGRF(v->engine_type), v->type, parameter);
 
			if (v->type != VEH_TRAIN) return GetEngine(v->engine_type)->internal_id == parameter;
 
			if (v->type != VEH_TRAIN) return Engine::Get(v->engine_type)->internal_id == parameter;
 

	
 
			{
 
				uint count = 0;
 
				for (; v != NULL; v = v->Next()) {
 
					if (GetEngine(v->engine_type)->internal_id == parameter) count++;
 
					if (Engine::Get(v->engine_type)->internal_id == parameter) count++;
 
				}
 
				return count;
 
			}
 
@@ -730,8 +730,8 @@ static uint32 VehicleGetVariable(const R
 
		case 0x43: return GB(v->max_age, 8, 8);
 
		case 0x44: return Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
 
		case 0x45: return v->unitnumber;
 
		case 0x46: return GetEngine(v->engine_type)->internal_id;
 
		case 0x47: return GB(GetEngine(v->engine_type)->internal_id, 8, 8);
 
		case 0x46: return Engine::Get(v->engine_type)->internal_id;
 
		case 0x47: return GB(Engine::Get(v->engine_type)->internal_id, 8, 8);
 
		case 0x48:
 
			if (v->type != VEH_TRAIN || v->spritenum != 0xFD) return v->spritenum;
 
			return HasBit(v->u.rail.flags, VRF_REVERSE_DIRECTION) ? 0xFE : 0xFD;
 
@@ -854,7 +854,7 @@ static inline void NewVehicleResolver(Re
 
	res->reseed          = 0;
 
	res->count           = 0;
 

	
 
	const Engine *e = GetEngine(engine_type);
 
	const Engine *e = Engine::Get(engine_type);
 
	res->grffile         = (e != NULL ? e->grffile : NULL);
 
}
 

	
 
@@ -889,7 +889,7 @@ static const SpriteGroup *GetVehicleSpri
 
		}
 
	}
 

	
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	assert(cargo < lengthof(e->group));
 
	group = e->group[cargo];
 
@@ -916,7 +916,7 @@ SpriteID GetCustomEngineSprite(EngineID 
 

	
 
SpriteID GetRotorOverrideSprite(EngineID engine, const Vehicle *v, bool info_view)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 

	
 
	/* Only valid for helicopters */
 
	assert(e->type == VEH_AIRCRAFT);
 
@@ -1107,7 +1107,7 @@ void TriggerVehicle(Vehicle *v, VehicleT
 
 */
 
uint ListPositionOfEngine(EngineID engine)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 
	if (e->grffile == NULL) return e->list_position;
 

	
 
	/* Crude sorting to group by GRF ID */
 
@@ -1142,7 +1142,7 @@ void CommitVehicleListOrderChanges()
 

	
 
		if (engine == target) continue;
 

	
 
		Engine *source_e = GetEngine(engine);
 
		Engine *source_e = Engine::Get(engine);
 
		Engine *target_e = NULL;
 

	
 
		/* Populate map with current list positions */
src/newgrf_industries.cpp
Show inline comments
 
@@ -215,7 +215,7 @@ uint32 IndustryGetVariable(const Resolve
 
			bool is_ai = false;
 

	
 
			if (IsValidCompanyID(industry->founder)) {
 
				const Company *c = GetCompany(industry->founder);
 
				const Company *c = Company::Get(industry->founder);
 
				const Livery *l = &c->livery[LS_DEFAULT];
 

	
 
				is_ai = c->is_ai;
src/news_gui.cpp
Show inline comments
 
@@ -254,7 +254,7 @@ struct NewsWindow : Window {
 

	
 
			case 0:
 
				if (this->ni->flags & NF_VEHICLE) {
 
					const Vehicle *v = GetVehicle(this->ni->data_a);
 
					const Vehicle *v = Vehicle::Get(this->ni->data_a);
 
					ScrollMainWindowTo(v->x_pos, v->y_pos, v->z_pos);
 
				} else if (this->ni->flags & NF_TILE) {
 
					if (_ctrl_pressed) {
src/oldpool.h
Show inline comments
 
@@ -277,6 +277,14 @@ struct PoolItem {
 
		Tpool->UpdateFirstFreeIndex(pn->index);
 
	}
 

	
 
	/**
 
	 * Get item with given index
 
	 */
 
	static FORCEINLINE T *Get(uint index)
 
	{
 
		return Tpool->Get(index);
 
	}
 

	
 
private:
 
	static T *AllocateSafeRaw(uint &first);
 

	
 
@@ -326,7 +334,6 @@ public:
 

	
 

	
 
#define OLD_POOL_ACCESSORS(name, type) \
 
	static inline type *Get##name(uint index) { return _##name##_pool.Get(index);  } \
 
	static inline uint Get##name##PoolSize()  { return _##name##_pool.GetSize(); }
 

	
 

	
 
@@ -352,6 +359,7 @@ public:
 
#define STATIC_OLD_POOL(name, type, block_size_bits, max_blocks, new_block_proc, clean_block_proc) \
 
	OLD_POOL_ENUM(name, type, block_size_bits, max_blocks) \
 
	static DEFINE_OLD_POOL(name, type, new_block_proc, clean_block_proc) \
 
	OLD_POOL_ACCESSORS(name, type)
 
	OLD_POOL_ACCESSORS(name, type) \
 
	static inline type *Get##name(uint index) { return _##name##_pool.Get(index); }
 

	
 
#endif /* OLDPOOL_H */
src/openttd.cpp
Show inline comments
 
@@ -754,7 +754,7 @@ static void MakeNewGameDone()
 
	/* Create a single company */
 
	DoStartupNewCompany(false);
 

	
 
	Company *c = GetCompany(COMPANY_FIRST);
 
	Company *c = Company::Get(COMPANY_FIRST);
 
	c->settings = _settings_client.company;
 

	
 
	IConsoleCmdExec("exec scripts/game_start.scr 0");
 
@@ -851,7 +851,7 @@ static void StartScenario()
 

	
 
	SetLocalCompany(COMPANY_FIRST);
 
	_current_company = _local_company;
 
	Company *c = GetCompany(COMPANY_FIRST);
 
	Company *c = Company::Get(COMPANY_FIRST);
 
	c->settings = _settings_client.company;
 

	
 
	MarkWholeScreenDirty();
src/order_base.h
Show inline comments
 
@@ -423,17 +423,17 @@ public:
 

	
 
static inline bool IsValidOrderListID(uint index)
 
{
 
	return index < GetOrderListPoolSize() && GetOrderList(index)->IsValid();
 
	return index < GetOrderListPoolSize() && OrderList::Get(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_ORDERS_FROM(order, start) for (order = GetOrder(start); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? GetOrder(order->index + 1U) : NULL) if (order->IsValid())
 
#define FOR_ALL_ORDERS_FROM(order, start) for (order = Order::Get(start); order != NULL; order = (order->index + 1U < GetOrderPoolSize()) ? Order::Get(order->index + 1U) : NULL) if (order->IsValid())
 
#define FOR_ALL_ORDERS(order) FOR_ALL_ORDERS_FROM(order, 0)
 

	
 

	
 
#define FOR_VEHICLE_ORDERS(v, order) for (order = (v->orders.list == NULL) ? NULL : v->orders.list->GetFirstOrder(); order != NULL; order = order->next)
 

	
 

	
 
#define FOR_ALL_ORDER_LISTS_FROM(ol, start) for (ol = GetOrderList(start); ol != NULL; ol = (ol->index + 1U < GetOrderListPoolSize()) ? GetOrderList(ol->index + 1U) : NULL) if (ol->IsValid())
 
#define FOR_ALL_ORDER_LISTS_FROM(ol, start) for (ol = OrderList::Get(start); ol != NULL; ol = (ol->index + 1U < GetOrderListPoolSize()) ? OrderList::Get(ol->index + 1U) : NULL) if (ol->IsValid())
 
#define FOR_ALL_ORDER_LISTS(ol) FOR_ALL_ORDER_LISTS_FROM(ol, 0)
 

	
 
#endif /* ORDER_H */
src/order_cmd.cpp
Show inline comments
 
@@ -379,8 +379,8 @@ static TileIndex GetOrderLocation(const 
 
{
 
	switch (o.GetType()) {
 
		default: NOT_REACHED();
 
		case OT_GOTO_STATION: return GetStation(o.GetDestination())->xy;
 
		case OT_GOTO_DEPOT:   return GetDepot(o.GetDestination())->xy;
 
		case OT_GOTO_STATION: return Station::Get(o.GetDestination())->xy;
 
		case OT_GOTO_DEPOT:   return Depot::Get(o.GetDestination())->xy;
 
	}
 
}
 

	
 
@@ -418,7 +418,7 @@ CommandCost CmdInsertOrder(TileIndex til
 

	
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	v = GetVehicle(veh);
 
	v = Vehicle::Get(veh);
 

	
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -428,7 +428,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
		case OT_GOTO_STATION: {
 
			if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR;
 

	
 
			const Station *st = GetStation(new_order.GetDestination());
 
			const Station *st = Station::Get(new_order.GetDestination());
 

	
 
			if (st->owner != OWNER_NONE && !CheckOwnership(st->owner)) return CMD_ERROR;
 

	
 
@@ -474,7 +474,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
				if (v->type == VEH_AIRCRAFT) {
 
					if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR;
 

	
 
					const Station *st = GetStation(new_order.GetDestination());
 
					const Station *st = Station::Get(new_order.GetDestination());
 

	
 
					if (!CheckOwnership(st->owner) ||
 
							!CanVehicleUseStation(v, st) ||
 
@@ -484,7 +484,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
				} else {
 
					if (!IsValidDepotID(new_order.GetDestination())) return CMD_ERROR;
 

	
 
					const Depot *dp = GetDepot(new_order.GetDestination());
 
					const Depot *dp = Depot::Get(new_order.GetDestination());
 

	
 
					if (!CheckOwnership(GetTileOwner(dp->xy))) return CMD_ERROR;
 

	
 
@@ -519,7 +519,7 @@ CommandCost CmdInsertOrder(TileIndex til
 
			if (v->type != VEH_TRAIN) return CMD_ERROR;
 

	
 
			if (!IsValidWaypointID(new_order.GetDestination())) return CMD_ERROR;
 
			const Waypoint *wp = GetWaypoint(new_order.GetDestination());
 
			const Waypoint *wp = Waypoint::Get(new_order.GetDestination());
 

	
 
			if (!CheckOwnership(wp->owner)) return CMD_ERROR;
 

	
 
@@ -667,7 +667,7 @@ CommandCost CmdDeleteOrder(TileIndex til
 

	
 
	if (!IsValidVehicleID(veh_id)) return CMD_ERROR;
 

	
 
	v = GetVehicle(veh_id);
 
	v = Vehicle::Get(veh_id);
 

	
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -734,7 +734,7 @@ CommandCost CmdSkipToOrder(TileIndex til
 

	
 
	if (!IsValidVehicleID(veh_id)) return CMD_ERROR;
 

	
 
	v = GetVehicle(veh_id);
 
	v = Vehicle::Get(veh_id);
 

	
 
	if (!CheckOwnership(v->owner) || sel_ord == v->cur_order_index ||
 
			sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR;
 
@@ -774,7 +774,7 @@ CommandCost CmdMoveOrder(TileIndex tile,
 

	
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(veh);
 
	Vehicle *v = Vehicle::Get(veh);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	/* Don't make senseless movements */
 
@@ -854,7 +854,7 @@ CommandCost CmdModifyOrder(TileIndex til
 
	if (mof >= MOF_END) return CMD_ERROR;
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(veh);
 
	Vehicle *v = Vehicle::Get(veh);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	/* Is it a valid order? */
 
@@ -863,7 +863,7 @@ CommandCost CmdModifyOrder(TileIndex til
 
	Order *order = GetVehicleOrder(v, sel_ord);
 
	switch (order->GetType()) {
 
		case OT_GOTO_STATION:
 
			if (mof == MOF_COND_VARIABLE || mof == MOF_COND_COMPARATOR || mof == MOF_DEPOT_ACTION || mof == MOF_COND_VALUE || GetStation(order->GetDestination())->IsBuoy()) return CMD_ERROR;
 
			if (mof == MOF_COND_VARIABLE || mof == MOF_COND_COMPARATOR || mof == MOF_DEPOT_ACTION || mof == MOF_COND_VALUE || Station::Get(order->GetDestination())->IsBuoy()) return CMD_ERROR;
 
			break;
 

	
 
		case OT_GOTO_DEPOT:
 
@@ -1078,7 +1078,7 @@ CommandCost CmdCloneOrder(TileIndex tile
 

	
 
	if (!IsValidVehicleID(veh_dst)) return CMD_ERROR;
 

	
 
	dst = GetVehicle(veh_dst);
 
	dst = Vehicle::Get(veh_dst);
 

	
 
	if (!CheckOwnership(dst->owner)) return CMD_ERROR;
 

	
 
@@ -1088,7 +1088,7 @@ CommandCost CmdCloneOrder(TileIndex tile
 

	
 
			if (!IsValidVehicleID(veh_src)) return CMD_ERROR;
 

	
 
			src = GetVehicle(veh_src);
 
			src = Vehicle::Get(veh_src);
 

	
 
			/* Sanity checks */
 
			if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src)
 
@@ -1107,7 +1107,7 @@ CommandCost CmdCloneOrder(TileIndex tile
 

	
 
			FOR_VEHICLE_ORDERS(src, order) {
 
				if (OrderGoesToStation(dst, order) &&
 
						!CanVehicleUseStation(dst, GetStation(order->GetDestination()))) {
 
						!CanVehicleUseStation(dst, Station::Get(order->GetDestination()))) {
 
					return_cmd_error(STR_ERROR_CAN_T_COPY_SHARE_ORDER);
 
				}
 
			}
 
@@ -1134,7 +1134,7 @@ CommandCost CmdCloneOrder(TileIndex tile
 

	
 
			if (!IsValidVehicleID(veh_src)) return CMD_ERROR;
 

	
 
			src = GetVehicle(veh_src);
 
			src = Vehicle::Get(veh_src);
 

	
 
			/* Sanity checks */
 
			if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src)
 
@@ -1145,7 +1145,7 @@ CommandCost CmdCloneOrder(TileIndex tile
 
			const Order *order;
 
			FOR_VEHICLE_ORDERS(src, order) {
 
				if (OrderGoesToStation(dst, order) &&
 
						!CanVehicleUseStation(dst, GetStation(order->GetDestination()))) {
 
						!CanVehicleUseStation(dst, Station::Get(order->GetDestination()))) {
 
					return_cmd_error(STR_ERROR_CAN_T_COPY_SHARE_ORDER);
 
				}
 
			}
 
@@ -1210,7 +1210,7 @@ CommandCost CmdOrderRefit(TileIndex tile
 

	
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	v = GetVehicle(veh);
 
	v = Vehicle::Get(veh);
 

	
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -1363,7 +1363,7 @@ CommandCost CmdRestoreOrderIndex(TileInd
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
	v = Vehicle::Get(p1);
 

	
 
	/* Check the vehicle type and ownership, and if the service interval and order are in range */
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 
@@ -1429,7 +1429,7 @@ void CheckOrders(const Vehicle *v)
 
			}
 
			/* Does station have a load-bay for this vehicle? */
 
			if (order->IsType(OT_GOTO_STATION)) {
 
				const Station *st = GetStation(order->GetDestination());
 
				const Station *st = Station::Get(order->GetDestination());
 
				TileIndex required_tile = GetStationTileForVehicle(v, st);
 

	
 
				n_st++;
 
@@ -1657,12 +1657,12 @@ bool UpdateOrderDest(Vehicle *v, const O
 
					v->IncrementOrderIndex();
 
				}
 
			} else if (v->type != VEH_AIRCRAFT) {
 
				v->dest_tile = GetDepot(order->GetDestination())->xy;
 
				v->dest_tile = Depot::Get(order->GetDestination())->xy;
 
			}
 
			break;
 

	
 
		case OT_GOTO_WAYPOINT:
 
			v->dest_tile = GetWaypoint(order->GetDestination())->xy;
 
			v->dest_tile = Waypoint::Get(order->GetDestination())->xy;
 
			break;
 

	
 
		case OT_CONDITIONAL: {
 
@@ -1769,7 +1769,7 @@ bool ProcessOrders(Vehicle *v)
 

	
 
	/* If it is unchanged, keep it. */
 
	if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0) &&
 
			(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || GetStation(order->GetDestination())->dock_tile != INVALID_TILE)) {
 
			(v->type != VEH_SHIP || !order->IsType(OT_GOTO_STATION) || Station::Get(order->GetDestination())->dock_tile != INVALID_TILE)) {
 
		return false;
 
	}
 

	
src/order_gui.cpp
Show inline comments
 
@@ -224,7 +224,7 @@ void DrawOrderString(const Vehicle *v, c
 
					SetDParam(3, STR_ORDER_NEAREST_DEPOT);
 
				} else {
 
					SetDParam(1, STR_GO_TO_DEPOT);
 
					SetDParam(3, GetDepot(order->GetDestination())->town_index);
 
					SetDParam(3, Depot::Get(order->GetDestination())->town_index);
 
				}
 

	
 
				switch (v->type) {
 
@@ -351,7 +351,7 @@ static Order GetOrderCmdFromTile(const V
 

	
 
	if (IsTileType(tile, MP_STATION)) {
 
		StationID st_index = GetStationIndex(tile);
 
		const Station *st = GetStation(st_index);
 
		const Station *st = Station::Get(st_index);
 

	
 
		if (st->owner == _local_company || st->owner == OWNER_NONE) {
 
			byte facil;
 
@@ -659,7 +659,7 @@ public:
 
		switch (data) {
 
			case 0:
 
				/* Autoreplace replaced the vehicle */
 
				this->vehicle = GetVehicle(this->window_number);
 
				this->vehicle = Vehicle::Get(this->window_number);
 
				break;
 

	
 
			case -1:
 
@@ -762,7 +762,7 @@ public:
 
			this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
 
			switch (order->GetType()) {
 
				case OT_GOTO_STATION:
 
					if (!GetStation(order->GetDestination())->IsBuoy()) {
 
					if (!Station::Get(order->GetDestination())->IsBuoy()) {
 
						this->SetWidgetLoweredState(ORDER_WIDGET_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
 
						this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
 
						break;
 
@@ -856,11 +856,11 @@ public:
 
					TileIndex xy = INVALID_TILE;
 

	
 
					switch (ord->GetType()) {
 
						case OT_GOTO_STATION:  xy = GetStation(ord->GetDestination())->xy ; break;
 
						case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break;
 
						case OT_GOTO_STATION:  xy = Station::Get(ord->GetDestination())->xy ; break;
 
						case OT_GOTO_WAYPOINT: xy = Waypoint::Get(ord->GetDestination())->xy; break;
 
						case OT_GOTO_DEPOT:
 
							if ((ord->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) break;
 
							xy = (this->vehicle->type == VEH_AIRCRAFT) ?  GetStation(ord->GetDestination())->xy : GetDepot(ord->GetDestination())->xy;
 
							xy = (this->vehicle->type == VEH_AIRCRAFT) ?  Station::Get(ord->GetDestination())->xy : Depot::Get(ord->GetDestination())->xy;
 
							break;
 
						default:
 
							break;
src/pathfind.h
Show inline comments
 
@@ -88,7 +88,7 @@ void NewTrainPathfind(TileIndex tile, Ti
 
 */
 
static inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile)
 
{
 
	const Station *st = GetStation(station);
 
	const Station *st = Station::Get(station);
 

	
 
	/* If the rail station is (temporarily) not present, use the station sign to drive near the station */
 
	if (st->train_tile == INVALID_TILE) return st->xy;
src/rail.cpp
Show inline comments
 
@@ -170,7 +170,7 @@ RailType GetTileRailType(TileIndex tile)
 

	
 
bool HasRailtypeAvail(const CompanyID company, const RailType railtype)
 
{
 
	return HasBit(GetCompany(company)->avail_railtypes, railtype);
 
	return HasBit(Company::Get(company)->avail_railtypes, railtype);
 
}
 

	
 
bool ValParamRailtype(const RailType rail)
src/road.cpp
Show inline comments
 
@@ -85,7 +85,7 @@ bool HasRoadTypesAvail(const CompanyID c
 
		avail_roadtypes = ROADTYPES_ROAD;
 
	} else {
 
		if (!IsValidCompanyID(company)) return false;
 
		avail_roadtypes = (RoadTypes)GetCompany(company)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
 
		avail_roadtypes = (RoadTypes)Company::Get(company)->avail_roadtypes | ROADTYPES_ROAD; // road is available for always for everybody
 
	}
 
	return (rts & ~avail_roadtypes) == 0;
 
}
src/roadveh_cmd.cpp
Show inline comments
 
@@ -90,7 +90,7 @@ static SpriteID GetRoadVehIcon(EngineID 
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(engine)->image_index;
 
		spritenum = Engine::Get(engine)->image_index;
 
	}
 

	
 
	return 6 + _roadveh_images[spritenum];
 
@@ -105,7 +105,7 @@ SpriteID RoadVehicle::GetImage(Direction
 
		sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)));
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(this->engine_type)->image_index;
 
		spritenum = Engine::Get(this->engine_type)->image_index;
 
	}
 

	
 
	sprite = direction + _roadveh_images[spritenum];
 
@@ -162,7 +162,7 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
{
 
	if (!IsEngineBuildable(p1, VEH_ROAD, _current_company)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
 

	
 
	const Engine *e = GetEngine(p1);
 
	const Engine *e = Engine::Get(p1);
 
	/* Engines without valid cargo should not be available */
 
	if (e->GetDefaultCargoType() == CT_INVALID) return CMD_ERROR;
 

	
 
@@ -269,7 +269,7 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Road window
 
		}
 

	
 
		GetCompany(_current_company)->num_engines[p1]++;
 
		Company::Get(_current_company)->num_engines[p1]++;
 

	
 
		CheckConsistencyOfArticulatedVehicle(v);
 
	}
 
@@ -316,7 +316,7 @@ CommandCost CmdSellRoadVeh(TileIndex til
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
	v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -425,7 +425,7 @@ CommandCost CmdSendRoadVehToDepot(TileIn
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_ROAD) return CMD_ERROR;
 

	
 
@@ -444,7 +444,7 @@ CommandCost CmdTurnRoadVeh(TileIndex til
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
	v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -664,7 +664,7 @@ TileIndex RoadVehicle::GetOrderStationLo
 
	if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
 

	
 
	TileIndex dest = INVALID_TILE;
 
	const RoadStop *rs = GetStation(station)->GetPrimaryRoadStop(this);
 
	const RoadStop *rs = Station::Get(station)->GetPrimaryRoadStop(this);
 
	if (rs != NULL) {
 
		uint mindist = UINT_MAX;
 

	
 
@@ -1882,7 +1882,7 @@ void RoadVehicle::OnNewDay()
 

	
 
	/* update destination */
 
	if (!(this->vehstatus & VS_STOPPED) && this->current_order.IsType(OT_GOTO_STATION) && !(this->current_order.GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) && this->u.road.slot == NULL && !(this->vehstatus & VS_CRASHED)) {
 
		Station *st = GetStation(this->current_order.GetDestination());
 
		Station *st = Station::Get(this->current_order.GetDestination());
 
		RoadStop *rs = st->GetPrimaryRoadStop(this);
 
		RoadStop *best = NULL;
 

	
 
@@ -1978,7 +1978,7 @@ CommandCost CmdRefitRoadVeh(TileIndex ti
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
	v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_ROAD_MUST_BE_STOPPED_INSIDE_DEPOT);
 
@@ -1992,7 +1992,7 @@ CommandCost CmdRefitRoadVeh(TileIndex ti
 
		 * [Refit] button near each wagon. */
 
		if (!CanRefitTo(v->engine_type, new_cid)) continue;
 

	
 
		const Engine *e = GetEngine(v->engine_type);
 
		const Engine *e = Engine::Get(v->engine_type);
 
		if (!e->CanCarryCargo()) continue;
 

	
 
		if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
 
@@ -2050,7 +2050,7 @@ CommandCost CmdRefitRoadVeh(TileIndex ti
 
		}
 
	}
 

	
 
	if (flags & DC_EXEC) RoadVehUpdateCache(GetVehicle(p1)->First());
 
	if (flags & DC_EXEC) RoadVehUpdateCache(Vehicle::Get(p1)->First());
 

	
 
	_returned_refit_capacity = total_capacity;
 

	
src/roadveh_gui.cpp
Show inline comments
 
@@ -158,7 +158,7 @@ void CcBuildRoadVeh(bool success, TileIn
 

	
 
	if (!success) return;
 

	
 
	v = GetVehicle(_new_vehicle_id);
 
	v = Vehicle::Get(_new_vehicle_id);
 
	if (v->tile == _backup_orders_tile) {
 
		_backup_orders_tile = 0;
 
		RestoreVehicleOrders(v);
src/saveload/afterload.cpp
Show inline comments
 
@@ -674,7 +674,7 @@ bool AfterLoadGame()
 
		 * companies are 'invalid'.
 
		 */
 
		if (!_network_dedicated && IsValidCompanyID(COMPANY_FIRST)) {
 
			c = GetCompany(COMPANY_FIRST);
 
			c = Company::Get(COMPANY_FIRST);
 
			c->settings = _settings_client.company;
 
		}
 
	}
 
@@ -1203,7 +1203,7 @@ bool AfterLoadGame()
 
			const CargoList::List *packets = v->cargo.Packets();
 
			for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
 
				CargoPacket *cp = *it;
 
				cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : v->tile;
 
				cp->source_xy = IsValidStationID(cp->source) ? Station::Get(cp->source)->xy : v->tile;
 
				cp->loaded_at_xy = cp->source_xy;
 
			}
 
			v->cargo.InvalidateCache();
 
@@ -1222,7 +1222,7 @@ bool AfterLoadGame()
 
				const CargoList::List *packets = ge->cargo.Packets();
 
				for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
 
					CargoPacket *cp = *it;
 
					cp->source_xy = IsValidStationID(cp->source) ? GetStation(cp->source)->xy : st->xy;
 
					cp->source_xy = IsValidStationID(cp->source) ? Station::Get(cp->source)->xy : st->xy;
 
					cp->loaded_at_xy = cp->source_xy;
 
				}
 
			}
 
@@ -1300,7 +1300,7 @@ bool AfterLoadGame()
 
			if ((v->type != VEH_TRAIN || IsFrontEngine(v)) &&  // for all locs
 
					!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
 
					v->current_order.IsType(OT_LOADING)) {         // loading
 
				GetStation(v->last_station_visited)->loading_vehicles.push_back(v);
 
				Station::Get(v->last_station_visited)->loading_vehicles.push_back(v);
 

	
 
				/* The loading finished flag is *only* set when actually completely
 
				 * finished. Because the vehicle is loading, it is not finished. */
 
@@ -1465,7 +1465,7 @@ bool AfterLoadGame()
 
		/* Update go to buoy orders because they are just waypoints */
 
		Order *order;
 
		FOR_ALL_ORDERS(order) {
 
			if (order->IsType(OT_GOTO_STATION) && GetStation(order->GetDestination())->IsBuoy()) {
 
			if (order->IsType(OT_GOTO_STATION) && Station::Get(order->GetDestination())->IsBuoy()) {
 
				order->SetLoadType(OLF_LOAD_IF_POSSIBLE);
 
				order->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
 
			}
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -587,8 +587,8 @@ static bool LoadOldOrder(LoadgameState *
 

	
 
	/* Relink the orders to eachother (in the orders for one vehicle are behind eachother,
 
	 * with an invalid order (OT_NOTHING) as indication that it is the last order */
 
	if (num > 0 && GetOrder(num)->IsValid()) {
 
		GetOrder(num - 1)->next = GetOrder(num);
 
	if (num > 0 && Order::Get(num)->IsValid()) {
 
		Order::Get(num - 1)->next = Order::Get(num);
 
	}
 

	
 
	return true;
 
@@ -729,7 +729,7 @@ static bool LoadOldGood(LoadgameState *l
 
	/* for TTO games, 12th (num == 11) goods entry is created in the Station constructor */
 
	if (_savegame_type == SGT_TTO && num == 11) return true;
 

	
 
	Station *st = GetStation(_current_station_id);
 
	Station *st = Station::Get(_current_station_id);
 
	GoodsEntry *ge = &st->goods[num];
 

	
 
	if (!LoadChunk(ls, ge, goods_chunk)) return false;
 
@@ -792,7 +792,7 @@ static bool LoadOldStation(LoadgameState
 
	if (!LoadChunk(ls, st, station_chunk)) return false;
 

	
 
	if (st->xy != 0) {
 
		st->town = GetTown(RemapTownIndex(_old_town_index));
 
		st->town = Town::Get(RemapTownIndex(_old_town_index));
 

	
 
		if (_savegame_type == SGT_TTO) {
 
			if (IsInsideBS(_old_string_id, 0x180F, 32)) {
 
@@ -869,7 +869,7 @@ static bool LoadOldIndustry(LoadgameStat
 
	if (!LoadChunk(ls, i, industry_chunk)) return false;
 

	
 
	if (i->xy != 0) {
 
		i->town = GetTown(RemapTownIndex(_old_town_index));
 
		i->town = Town::Get(RemapTownIndex(_old_town_index));
 

	
 
		if (_savegame_type == SGT_TTO) {
 
			if (i->type > 0x06) i->type++; // Printing Works were added
 
@@ -900,7 +900,7 @@ static const OldChunks _company_yearly_c
 

	
 
static bool LoadOldCompanyYearly(LoadgameState *ls, int num)
 
{
 
	Company *c = GetCompany(_current_company_id);
 
	Company *c = Company::Get(_current_company_id);
 

	
 
	for (uint i = 0; i < 13; i++) {
 
		if (_savegame_type == SGT_TTO && i == 6) {
 
@@ -927,7 +927,7 @@ static const OldChunks _company_economy_
 

	
 
static bool LoadOldCompanyEconomy(LoadgameState *ls, int num)
 
{
 
	Company *c = GetCompany(_current_company_id);
 
	Company *c = Company::Get(_current_company_id);
 

	
 
	if (!LoadChunk(ls, &c->cur_economy, _company_economy_chunk)) return false;
 

	
 
@@ -1131,7 +1131,7 @@ static const OldChunks vehicle_empty_chu
 

	
 
static bool LoadOldVehicleUnion(LoadgameState *ls, int num)
 
{
 
	Vehicle *v = GetVehicle(_current_vehicle_id);
 
	Vehicle *v = Vehicle::Get(_current_vehicle_id);
 
	uint temp = ls->total_read;
 
	bool res;
 

	
 
@@ -1358,11 +1358,11 @@ bool LoadOldVehicle(LoadgameState *ls, i
 
		if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
 
			uint max = _savegame_type == SGT_TTO ? 3000 : 5000;
 
			uint old_id = RemapOrderIndex(_old_order_ptr);
 
			if (old_id < max) v->orders.old = GetOrder(old_id); // don't accept orders > max number of orders
 
			if (old_id < max) v->orders.old = Order::Get(old_id); // don't accept orders > max number of orders
 
		}
 
		v->current_order.AssignOrder(UnpackOldOrder(_old_order));
 

	
 
		if (_old_next_ptr != 0xFFFF) v->next = GetVehiclePoolSize() <= _old_next_ptr ? new (_old_next_ptr) InvalidVehicle() : GetVehicle(_old_next_ptr);
 
		if (_old_next_ptr != 0xFFFF) v->next = GetVehiclePoolSize() <= _old_next_ptr ? new (_old_next_ptr) InvalidVehicle() : Vehicle::Get(_old_next_ptr);
 

	
 
		if (_cargo_count != 0) {
 
			CargoPacket *cp = new CargoPacket((_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, _cargo_count);
src/saveload/order_sl.cpp
Show inline comments
 
@@ -157,8 +157,8 @@ static void Load_ORDR()
 
			/* The orders were built like this:
 
			 *   While the order is valid, set the previous will get it's next pointer set
 
			 *   We start with index 1 because no order will have the first in it's next pointer */
 
			if (GetOrder(i)->IsValid())
 
				GetOrder(i - 1)->next = GetOrder(i);
 
			if (Order::Get(i)->IsValid())
 
				Order::Get(i - 1)->next = Order::Get(i);
 
		}
 
	} else {
 
		int index;
src/saveload/saveload.cpp
Show inline comments
 
@@ -1431,35 +1431,35 @@ static void *IntToReference(uint index, 
 

	
 
	switch (rt) {
 
		case REF_ORDERLIST:
 
			if (_OrderList_pool.AddBlockIfNeeded(index)) return GetOrderList(index);
 
			if (_OrderList_pool.AddBlockIfNeeded(index)) return OrderList::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "OrderList index out of range");
 

	
 
		case REF_ORDER:
 
			if (_Order_pool.AddBlockIfNeeded(index)) return GetOrder(index);
 
			if (_Order_pool.AddBlockIfNeeded(index)) return Order::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Order index out of range");
 

	
 
		case REF_VEHICLE:
 
			if (_Vehicle_pool.AddBlockIfNeeded(index)) return GetVehicle(index);
 
			if (_Vehicle_pool.AddBlockIfNeeded(index)) return Vehicle::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Vehicle index out of range");
 

	
 
		case REF_STATION:
 
			if (_Station_pool.AddBlockIfNeeded(index)) return GetStation(index);
 
			if (_Station_pool.AddBlockIfNeeded(index)) return Station::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Station index out of range");
 

	
 
		case REF_TOWN:
 
			if (_Town_pool.AddBlockIfNeeded(index)) return GetTown(index);
 
			if (_Town_pool.AddBlockIfNeeded(index)) return Town::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Town index out of range");
 

	
 
		case REF_ROADSTOPS:
 
			if (_RoadStop_pool.AddBlockIfNeeded(index)) return GetRoadStop(index);
 
			if (_RoadStop_pool.AddBlockIfNeeded(index)) return RoadStop::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "RoadStop index out of range");
 

	
 
		case REF_ENGINE_RENEWS:
 
			if (_EngineRenew_pool.AddBlockIfNeeded(index)) return GetEngineRenew(index);
 
			if (_EngineRenew_pool.AddBlockIfNeeded(index)) return EngineRenew::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "EngineRenew index out of range");
 

	
 
		case REF_CARGO_PACKET:
 
			if (_CargoPacket_pool.AddBlockIfNeeded(index)) return GetCargoPacket(index);
 
			if (_CargoPacket_pool.AddBlockIfNeeded(index)) return CargoPacket::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "CargoPacket index out of range");
 

	
 
		case REF_VEHICLE_OLD:
 
@@ -1469,7 +1469,7 @@ static void *IntToReference(uint index, 
 
			index++;
 
			if (index == INVALID_VEHICLE) return NULL;
 

	
 
			if (_Vehicle_pool.AddBlockIfNeeded(index)) return GetVehicle(index);
 
			if (_Vehicle_pool.AddBlockIfNeeded(index)) return Vehicle::Get(index);
 
			SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Vehicle index out of range");
 

	
 
		default: NOT_REACHED();
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -225,7 +225,7 @@ static void CheckValidVehicles()
 
			case VEH_ROAD:
 
			case VEH_SHIP:
 
			case VEH_AIRCRAFT:
 
				if (v->engine_type >= total_engines || v->type != GetEngine(v->engine_type)->type) {
 
				if (v->engine_type >= total_engines || v->type != Engine::Get(v->engine_type)->type) {
 
					v->engine_type = first_engine[v->type];
 
				}
 
				break;
src/ship_cmd.cpp
Show inline comments
 
@@ -56,7 +56,7 @@ static SpriteID GetShipIcon(EngineID eng
 
		SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(engine)->image_index;
 
		spritenum = Engine::Get(engine)->image_index;
 
	}
 

	
 
	return 6 + _ship_sprites[spritenum];
 
@@ -88,7 +88,7 @@ SpriteID Ship::GetImage(Direction direct
 
		SpriteID sprite = GetCustomVehicleSprite(this, direction);
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(this->engine_type)->image_index;
 
		spritenum = Engine::Get(this->engine_type)->image_index;
 
	}
 

	
 
	return _ship_sprites[spritenum] + direction;
 
@@ -231,7 +231,7 @@ TileIndex Ship::GetOrderStationLocation(
 
{
 
	if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
 

	
 
	const Station *st = GetStation(station);
 
	const Station *st = Station::Get(station);
 
	if (st->dock_tile != INVALID_TILE) {
 
		return TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
 
	} else {
 
@@ -609,7 +609,7 @@ static void ShipController(Vehicle *v)
 
				} else if (v->dest_tile != 0) {
 
					/* We have a target, let's see if we reached it... */
 
					if (v->current_order.IsType(OT_GOTO_STATION) &&
 
							GetStation(v->current_order.GetDestination())->IsBuoy() &&
 
							Station::Get(v->current_order.GetDestination())->IsBuoy() &&
 
							DistanceManhattan(v->dest_tile, gp.new_tile) <= 3) {
 
						/* We got within 3 tiles of our target buoy, so let's skip to our
 
						 * next order */
 
@@ -628,7 +628,7 @@ static void ShipController(Vehicle *v)
 
								v->last_station_visited = v->current_order.GetDestination();
 

	
 
								/* Process station in the orderlist. */
 
								Station *st = GetStation(v->current_order.GetDestination());
 
								Station *st = Station::Get(v->current_order.GetDestination());
 
								if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
 
									ShipArrivesAt(v, st);
 
									v->BeginLoading();
 
@@ -728,7 +728,7 @@ CommandCost CmdBuildShip(TileIndex tile,
 

	
 
	if (!IsEngineBuildable(p1, VEH_SHIP, _current_company)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
 

	
 
	const Engine *e = GetEngine(p1);
 
	const Engine *e = Engine::Get(p1);
 
	CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
 

	
 
	/* Engines without valid cargo should not be available */
 
@@ -805,7 +805,7 @@ CommandCost CmdBuildShip(TileIndex tile,
 
		if (IsLocalCompany())
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
 

	
 
		GetCompany(_current_company)->num_engines[p1]++;
 
		Company::Get(_current_company)->num_engines[p1]++;
 
	}
 

	
 
	return value;
 
@@ -823,7 +823,7 @@ CommandCost CmdSellShip(TileIndex tile, 
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
	v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -872,7 +872,7 @@ CommandCost CmdSendShipToDepot(TileIndex
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_SHIP) return CMD_ERROR;
 

	
 
@@ -900,7 +900,7 @@ CommandCost CmdRefitShip(TileIndex tile,
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 
	v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
src/ship_gui.cpp
Show inline comments
 
@@ -26,7 +26,7 @@ void CcBuildShip(bool success, TileIndex
 
	const Vehicle *v;
 
	if (!success) return;
 

	
 
	v = GetVehicle(_new_vehicle_id);
 
	v = Vehicle::Get(_new_vehicle_id);
 
	if (v->tile == _backup_orders_tile) {
 
		_backup_orders_tile = 0;
 
		RestoreVehicleOrders(v);
src/signs_base.h
Show inline comments
 
@@ -43,10 +43,10 @@ static inline SignID GetMaxSignIndex()
 

	
 
static inline bool IsValidSignID(uint index)
 
{
 
	return index < GetSignPoolSize() && GetSign(index)->IsValid();
 
	return index < GetSignPoolSize() && Sign::Get(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = GetSign(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? GetSign(ss->index + 1U) : NULL) if (ss->IsValid())
 
#define FOR_ALL_SIGNS_FROM(ss, start) for (ss = Sign::Get(start); ss != NULL; ss = (ss->index + 1U < GetSignPoolSize()) ? Sign::Get(ss->index + 1U) : NULL) if (ss->IsValid())
 
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
 

	
 
#endif /* SIGNS_BASE_H */
src/signs_cmd.cpp
Show inline comments
 
@@ -73,7 +73,7 @@ CommandCost CmdRenameSign(TileIndex tile
 
		if (strlen(text) >= MAX_LENGTH_SIGN_NAME_BYTES) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			Sign *si = GetSign(p1);
 
			Sign *si = Sign::Get(p1);
 

	
 
			/* Delete the old name */
 
			free(si->name);
 
@@ -89,7 +89,7 @@ CommandCost CmdRenameSign(TileIndex tile
 
		}
 
	} else { // Delete sign
 
		if (flags & DC_EXEC) {
 
			Sign *si = GetSign(p1);
 
			Sign *si = Sign::Get(p1);
 

	
 
			MarkSignDirty(si);
 
			delete si;
 
@@ -111,7 +111,7 @@ CommandCost CmdRenameSign(TileIndex tile
 
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) {
 
		ShowRenameSignWindow(GetSign(_new_sign_id));
 
		ShowRenameSignWindow(Sign::Get(_new_sign_id));
 
		ResetObjectToPlace();
 
	}
 
}
src/station_base.h
Show inline comments
 
@@ -221,16 +221,16 @@ static inline uint GetNumStations()
 

	
 
static inline bool IsValidStationID(StationID index)
 
{
 
	return index < GetStationPoolSize() && GetStation(index)->IsValid();
 
	return index < GetStationPoolSize() && Station::Get(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (st->IsValid())
 
#define FOR_ALL_STATIONS_FROM(st, start) for (st = Station::Get(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? Station::Get(st->index + 1U) : NULL) if (st->IsValid())
 
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
 

	
 

	
 
/* Stuff for ROADSTOPS */
 

	
 
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (rs->IsValid())
 
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = RoadStop::Get(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? RoadStop::Get(rs->index + 1U) : NULL) if (rs->IsValid())
 
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
 

	
 
/* End of stuff for ROADSTOPS */
src/station_cmd.cpp
Show inline comments
 
@@ -100,7 +100,7 @@ static Station *GetStationAround(TileInd
 
			}
 
		}
 
	END_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
 
	return (closest_station == INVALID_STATION) ? NULL : GetStation(closest_station);
 
	return (closest_station == INVALID_STATION) ? NULL : Station::Get(closest_station);
 
}
 

	
 
/**
 
@@ -911,7 +911,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
			} else {
 
				/* Extend the current station, and don't check whether it will
 
				 * be near any other stations. */
 
				st = GetStation(est);
 
				st = Station::Get(est);
 
				check_surrounding = false;
 
			}
 
		} else {
 
@@ -928,7 +928,7 @@ CommandCost CmdBuildRailroadStation(Tile
 
	}
 

	
 
	/* Distant join */
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 
	if (st == NULL && distant_join) st = Station::Get(station_to_join);
 

	
 
	/* See if there is a deleted station close to us. */
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile_org);
 
@@ -1425,7 +1425,7 @@ CommandCost CmdBuildRoadStop(TileIndex t
 
	}
 

	
 
	/* Distant join */
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 
	if (st == NULL && distant_join) st = Station::Get(station_to_join);
 

	
 
	/* Find a deleted station close to us */
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
 
@@ -1876,7 +1876,7 @@ CommandCost CmdBuildAirport(TileIndex ti
 
	}
 

	
 
	/* Distant join */
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 
	if (st == NULL && distant_join) st = Station::Get(station_to_join);
 

	
 
	/* Find a deleted station close to us */
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
 
@@ -2183,7 +2183,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 
	}
 

	
 
	/* Distant join */
 
	if (st == NULL && distant_join) st = GetStation(station_to_join);
 
	if (st == NULL && distant_join) st = Station::Get(station_to_join);
 

	
 
	/* Find a deleted station close to us */
 
	if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
 
@@ -2842,7 +2842,7 @@ void OnTick_Station()
 
	uint i = _station_tick_ctr;
 
	if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
 

	
 
	if (IsValidStationID(i)) StationHandleBigTick(GetStation(i));
 
	if (IsValidStationID(i)) StationHandleBigTick(Station::Get(i));
 

	
 
	Station *st;
 
	FOR_ALL_STATIONS(st) {
 
@@ -2913,7 +2913,7 @@ CommandCost CmdRenameStation(TileIndex t
 
{
 
	if (!IsValidStationID(p1)) return CMD_ERROR;
 

	
 
	Station *st = GetStation(p1);
 
	Station *st = Station::Get(p1);
 
	if (!CheckOwnership(st->owner)) return CMD_ERROR;
 

	
 
	bool reset = StrEmpty(text);
src/station_gui.cpp
Show inline comments
 
@@ -783,7 +783,7 @@ struct StationViewWindow : public Window
 

	
 
	StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		Owner owner = GetStation(window_number)->owner;
 
		Owner owner = Station::Get(window_number)->owner;
 
		if (owner != OWNER_NONE) this->owner = owner;
 
		this->vscroll.cap = 5;
 
		this->resize.step_height = 10;
 
@@ -794,7 +794,7 @@ struct StationViewWindow : public Window
 
	~StationViewWindow()
 
	{
 
		WindowNumber wno =
 
			(this->window_number << 16) | VLW_STATION_LIST | GetStation(this->window_number)->owner;
 
			(this->window_number << 16) | VLW_STATION_LIST | Station::Get(this->window_number)->owner;
 

	
 
		DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11), false);
 
		DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
 
@@ -805,7 +805,7 @@ struct StationViewWindow : public Window
 
	virtual void OnPaint()
 
	{
 
		StationID station_id = this->window_number;
 
		const Station *st = GetStation(station_id);
 
		const Station *st = Station::Get(station_id);
 
		CargoDataList cargolist;
 
		uint32 transfers = 0;
 

	
 
@@ -982,9 +982,9 @@ struct StationViewWindow : public Window
 

	
 
			case SVW_LOCATION:
 
				if (_ctrl_pressed) {
 
					ShowExtraViewPortWindow(GetStation(this->window_number)->xy);
 
					ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
 
				} else {
 
					ScrollMainWindowToTile(GetStation(this->window_number)->xy);
 
					ScrollMainWindowToTile(Station::Get(this->window_number)->xy);
 
				}
 
				break;
 

	
 
@@ -1012,19 +1012,19 @@ struct StationViewWindow : public Window
 
				break;
 

	
 
			case SVW_TRAINS: { // Show a list of scheduled trains to this station
 
				const Station *st = GetStation(this->window_number);
 
				const Station *st = Station::Get(this->window_number);
 
				ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)this->window_number);
 
				break;
 
			}
 

	
 
			case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
 
				const Station *st = GetStation(this->window_number);
 
				const Station *st = Station::Get(this->window_number);
 
				ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)this->window_number);
 
				break;
 
			}
 

	
 
			case SVW_PLANES: { // Show a list of scheduled aircraft to this station
 
				const Station *st = GetStation(this->window_number);
 
				const Station *st = Station::Get(this->window_number);
 
				/* Since oilrigs have no owners, show the scheduled aircraft of local company */
 
				Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
 
				ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
 
@@ -1032,7 +1032,7 @@ struct StationViewWindow : public Window
 
			}
 

	
 
			case SVW_SHIPS: { // Show a list of scheduled ships to this station
 
				const Station *st = GetStation(this->window_number);
 
				const Station *st = Station::Get(this->window_number);
 
				/* Since oilrigs/bouys have no owners, show the scheduled ships of local company */
 
				Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
 
				ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
 
@@ -1104,7 +1104,7 @@ static bool AddNearbyStation(TileIndex t
 
	if (!IsTileType(tile, MP_STATION)) return false;
 

	
 
	StationID sid = GetStationIndex(tile);
 
	Station *st = GetStation(sid);
 
	Station *st = Station::Get(sid);
 
	if (st->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
 

	
 
	if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST)) {
 
@@ -1236,7 +1236,7 @@ struct SelectStationWindow : Window {
 
			/* Don't draw anything if it extends past the end of the window. */
 
			if (i - this->vscroll.pos >= this->vscroll.cap) break;
 

	
 
			const Station *st = GetStation(_stations_nearby_list[i - 1]);
 
			const Station *st = Station::Get(_stations_nearby_list[i - 1]);
 
			SetDParam(0, st->index);
 
			SetDParam(1, st->facilities);
 
			DrawString(3, this->widget[JSW_PANEL].right - 2, y, STR_STATION_LIST_STATION);
src/station_map.h
Show inline comments
 
@@ -26,7 +26,7 @@ static inline StationID GetStationIndex(
 

	
 
static inline Station *GetStationByTile(TileIndex t)
 
{
 
	return GetStation(GetStationIndex(t));
 
	return Station::Get(GetStationIndex(t));
 
}
 

	
 

	
src/statusbar_gui.cpp
Show inline comments
 
@@ -94,7 +94,7 @@ struct StatusBarWindow : Window {
 

	
 
	virtual void OnPaint()
 
	{
 
		const Company *c = (_local_company == COMPANY_SPECTATOR) ? NULL : GetCompany(_local_company);
 
		const Company *c = (_local_company == COMPANY_SPECTATOR) ? NULL : Company::Get(_local_company);
 

	
 
		this->DrawWidgets();
 
		SetDParam(0, _date);
src/strings.cpp
Show inline comments
 
@@ -665,7 +665,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_INDUSTRY_NAME: { // {INDUSTRY}
 
				const Industry *i = GetIndustry(GetInt32(&argv));
 
				const Industry *i = Industry::Get(GetInt32(&argv));
 
				int64 args[2];
 

	
 
				/* industry not valid anymore? */
 
@@ -827,7 +827,7 @@ static char *FormatString(char *buff, co
 
				break;
 

	
 
			case SCC_WAYPOINT_NAME: { // {WAYPOINT}
 
				Waypoint *wp = GetWaypoint(GetInt32(&argv));
 
				Waypoint *wp = Waypoint::Get(GetInt32(&argv));
 

	
 
				assert(wp->IsValid());
 

	
 
@@ -855,7 +855,7 @@ static char *FormatString(char *buff, co
 
					break;
 
				}
 

	
 
				const Station *st = GetStation(sid);
 
				const Station *st = Station::Get(sid);
 
				if (st->name != NULL) {
 
					buff = strecpy(buff, st->name, last);
 
				} else {
 
@@ -882,7 +882,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_TOWN_NAME: { // {TOWN}
 
				const Town *t = GetTown(GetInt32(&argv));
 
				const Town *t = Town::Get(GetInt32(&argv));
 
				int64 temp[1];
 

	
 
				assert(t->IsValid());
 
@@ -909,7 +909,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_GROUP_NAME: { // {GROUP}
 
				const Group *g = GetGroup(GetInt32(&argv));
 
				const Group *g = Group::Get(GetInt32(&argv));
 

	
 
				assert(g->IsValid());
 

	
 
@@ -926,7 +926,7 @@ static char *FormatString(char *buff, co
 

	
 
			case SCC_ENGINE_NAME: { // {ENGINE}
 
				EngineID engine = (EngineID)GetInt32(&argv);
 
				const Engine *e = GetEngine(engine);
 
				const Engine *e = Engine::Get(engine);
 

	
 
				if (e->name != NULL) {
 
					buff = strecpy(buff, e->name, last);
 
@@ -937,7 +937,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_VEHICLE_NAME: { // {VEHICLE}
 
				const Vehicle *v = GetVehicle(GetInt32(&argv));
 
				const Vehicle *v = Vehicle::Get(GetInt32(&argv));
 

	
 
				if (v->name != NULL) {
 
					buff = strecpy(buff, v->name, last);
 
@@ -960,7 +960,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_SIGN_NAME: { // {SIGN}
 
				const Sign *si = GetSign(GetInt32(&argv));
 
				const Sign *si = Sign::Get(GetInt32(&argv));
 
				if (si->name != NULL) {
 
					buff = strecpy(buff, si->name, last);
 
				} else {
 
@@ -970,7 +970,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_COMPANY_NAME: { // {COMPANY}
 
				const Company *c = GetCompany((CompanyID)GetInt32(&argv));
 
				const Company *c = Company::Get((CompanyID)GetInt32(&argv));
 

	
 
				if (c->name != NULL) {
 
					buff = strecpy(buff, c->name, last);
 
@@ -995,7 +995,7 @@ static char *FormatString(char *buff, co
 
			}
 

	
 
			case SCC_PRESIDENT_NAME: { // {PRESIDENTNAME}
 
				const Company *c = GetCompany((CompanyID)GetInt32(&argv));
 
				const Company *c = Company::Get((CompanyID)GetInt32(&argv));
 

	
 
				if (c->president_name != NULL) {
 
					buff = strecpy(buff, c->president_name, last);
src/subsidy_gui.cpp
Show inline comments
 
@@ -80,11 +80,11 @@ struct SubsidyListWindow : Window {
 
		/* determine from coordinate for subsidy and try to scroll to it */
 
		uint offs = s->from;
 
		if (s->age >= 12) {
 
			xy = GetStation(offs)->xy;
 
			xy = Station::Get(offs)->xy;
 
		} else if (te == TE_PASSENGERS || te == TE_MAIL) {
 
			xy = GetTown(offs)->xy;
 
			xy = Town::Get(offs)->xy;
 
		} else {
 
			xy = GetIndustry(offs)->xy;
 
			xy = Industry::Get(offs)->xy;
 
		}
 

	
 
		if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) {
 
@@ -93,11 +93,11 @@ struct SubsidyListWindow : Window {
 
			/* otherwise determine to coordinate for subsidy and scroll to it */
 
			offs = s->to;
 
			if (s->age >= 12) {
 
				xy = GetStation(offs)->xy;
 
				xy = Station::Get(offs)->xy;
 
			} else if (te == TE_PASSENGERS || te == TE_MAIL || te == TE_GOODS || te == TE_FOOD) {
 
				xy = GetTown(offs)->xy;
 
				xy = Town::Get(offs)->xy;
 
			} else {
 
				xy = GetIndustry(offs)->xy;
 
				xy = Industry::Get(offs)->xy;
 
			}
 

	
 
			if (_ctrl_pressed) {
 
@@ -151,7 +151,7 @@ struct SubsidyListWindow : Window {
 
		for (s = _subsidies; s != endof(_subsidies); s++) {
 
			if (s->cargo_type != CT_INVALID && s->age >= 12) {
 
				SetupSubsidyDecodeParam(s, 1);
 
				SetDParam(3, GetStation(s->to)->owner);
 
				SetDParam(3, Station::Get(s->to)->owner);
 
				SetDParam(4, _date - ymd.day + 768 - s->age * 32);
 

	
 
				/* Displays the two connected stations */
src/timetable_cmd.cpp
Show inline comments
 
@@ -59,7 +59,7 @@ CommandCost CmdChangeTimetable(TileIndex
 
	VehicleID veh = GB(p1, 0, 16);
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(veh);
 
	Vehicle *v = Vehicle::Get(veh);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	VehicleOrderID order_number = GB(p1, 16, 8);
 
@@ -117,7 +117,7 @@ CommandCost CmdSetVehicleOnTime(TileInde
 
	VehicleID veh = GB(p1, 0, 16);
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(veh);
 
	Vehicle *v = Vehicle::Get(veh);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
@@ -145,7 +145,7 @@ CommandCost CmdAutofillTimetable(TileInd
 
	VehicleID veh = GB(p1, 0, 16);
 
	if (!IsValidVehicleID(veh)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(veh);
 
	Vehicle *v = Vehicle::Get(veh);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
src/timetable_gui.cpp
Show inline comments
 
@@ -50,7 +50,7 @@ struct TimetableWindow : Window {
 

	
 
	TimetableWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->vehicle = GetVehicle(window_number);
 
		this->vehicle = Vehicle::Get(window_number);
 
		this->owner = this->vehicle->owner;
 
		this->vscroll.cap = 8;
 
		this->resize.step_height = 10;
 
@@ -80,7 +80,7 @@ struct TimetableWindow : Window {
 
		switch (data) {
 
			case 0:
 
				/* Autoreplace replaced the vehicle */
 
				this->vehicle = GetVehicle(this->window_number);
 
				this->vehicle = Vehicle::Get(this->window_number);
 
				break;
 

	
 
			case -1:
src/toolbar_gui.cpp
Show inline comments
 
@@ -624,7 +624,7 @@ static void ToolbarZoomOutClick(Window *
 

	
 
static void ToolbarBuildRailClick(Window *w)
 
{
 
	const Company *c = GetCompany(_local_company);
 
	const Company *c = Company::Get(_local_company);
 
	DropDownList *list = new DropDownList();
 
	for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
		const RailtypeInfo *rti = GetRailTypeInfo(rt);
 
@@ -646,7 +646,7 @@ static void MenuClickBuildRail(int index
 

	
 
static void ToolbarBuildRoadClick(Window *w)
 
{
 
	const Company *c = GetCompany(_local_company);
 
	const Company *c = Company::Get(_local_company);
 
	DropDownList *list = new DropDownList();
 
	for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
 
		/* The standard road button is *always* available */
src/town.h
Show inline comments
 
@@ -302,7 +302,7 @@ TileIndexDiff GetHouseNorthPart(HouseID 
 
 */
 
static inline bool IsValidTownID(TownID index)
 
{
 
	return index < GetTownPoolSize() && GetTown(index)->IsValid();
 
	return index < GetTownPoolSize() && Town::Get(index)->IsValid();
 
}
 

	
 
static inline TownID GetMaxTownIndex()
 
@@ -341,12 +341,12 @@ static inline Town *GetRandomTown()
 
		}
 
	}
 

	
 
	return GetTown(index);
 
	return Town::Get(index);
 
}
 

	
 
Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
 

	
 
#define FOR_ALL_TOWNS_FROM(t, start) for (t = GetTown(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? GetTown(t->index + 1U) : NULL) if (t->IsValid())
 
#define FOR_ALL_TOWNS_FROM(t, start) for (t = Town::Get(start); t != NULL; t = (t->index + 1U < GetTownPoolSize()) ? Town::Get(t->index + 1U) : NULL) if (t->IsValid())
 
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
 

	
 
extern Town *_cleared_town;
src/town_cmd.cpp
Show inline comments
 
@@ -693,7 +693,7 @@ void OnTick_Town()
 
		if (++_cur_town_ctr > GetMaxTownIndex())
 
			_cur_town_ctr = 0;
 

	
 
		if (IsValidTownID(i)) TownTickHandler(GetTown(i));
 
		if (IsValidTownID(i)) TownTickHandler(Town::Get(i));
 
	}
 
}
 

	
 
@@ -2288,7 +2288,7 @@ CommandCost CmdRenameTown(TileIndex tile
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		Town *t = GetTown(p1);
 
		Town *t = Town::Get(p1);
 

	
 
		free(t->name);
 
		t->name = reset ? NULL : strdup(text);
 
@@ -2512,7 +2512,7 @@ uint GetMaskOfTownActions(int *nump, Com
 
	if (cid != COMPANY_SPECTATOR && !(_settings_game.economy.bribe && t->unwanted[cid])) {
 

	
 
		/* Things worth more than this are not shown */
 
		Money avail = GetCompany(cid)->money + _price.station_value * 200;
 
		Money avail = Company::Get(cid)->money + _price.station_value * 200;
 
		Money ref = _price.build_industry >> 8;
 

	
 
		/* Check the action bits for validity and
 
@@ -2555,7 +2555,7 @@ CommandCost CmdDoTownAction(TileIndex ti
 
{
 
	if (!IsValidTownID(p1) || p2 >= lengthof(_town_action_proc)) return CMD_ERROR;
 

	
 
	Town *t = GetTown(p1);
 
	Town *t = Town::Get(p1);
 

	
 
	if (!HasBit(GetMaskOfTownActions(NULL, _current_company, t), p2)) return CMD_ERROR;
 

	
 
@@ -2727,7 +2727,7 @@ Town *ClosestTownFromTile(TileIndex tile
 
					return NULL;
 
				}
 

	
 
				Town *town = GetTown(tid);
 
				Town *town = Town::Get(tid);
 
				assert(town->IsValid());
 

	
 
				if (DistanceManhattan(tile, town->xy) >= threshold) town = NULL;
src/town_gui.cpp
Show inline comments
 
@@ -100,7 +100,7 @@ public:
 
	TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) :
 
			Window(desc, window_number), sel_index(-1)
 
	{
 
		this->town = GetTown(this->window_number);
 
		this->town = Town::Get(this->window_number);
 
		this->vscroll.cap = 5;
 

	
 
		this->FindWindowPlacementAndResize(desc);
 
@@ -258,7 +258,7 @@ public:
 

	
 
	TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->town = GetTown(this->window_number);
 
		this->town = Town::Get(this->window_number);
 
		bool ingame = _game_mode != GM_EDITOR;
 

	
 
		this->flags4 |= WF_DISABLE_VP_SCROLL;
src/town_map.h
Show inline comments
 
@@ -40,7 +40,7 @@ static inline void SetTownIndex(TileInde
 
 */
 
static inline Town *GetTownByTile(TileIndex t)
 
{
 
	return GetTown(GetTownIndex(t));
 
	return Town::Get(GetTownIndex(t));
 
}
 

	
 
/**
src/train_cmd.cpp
Show inline comments
 
@@ -174,7 +174,7 @@ static void TrainCargoChanged(Vehicle *v
 
static void RailVehicleLengthChanged(const Vehicle *u)
 
{
 
	/* show a warning once for each engine in whole game and once for each GRF after each game load */
 
	const Engine *engine = GetEngine(u->engine_type);
 
	const Engine *engine = Engine::Get(u->engine_type);
 
	uint32 grfid = engine->grffile->grfid;
 
	GRFConfig *grfconfig = GetGRFConfig(grfid);
 
	if (GamelogGRFBugReverse(grfid, engine->internal_id) || !HasBit(grfconfig->grf_bugs, GBUG_VEH_LENGTH)) {
 
@@ -251,7 +251,7 @@ void TrainConsistChanged(Vehicle *v, boo
 
	}
 

	
 
	for (Vehicle *u = v; u != NULL; u = u->Next()) {
 
		const Engine *e_u = GetEngine(u->engine_type);
 
		const Engine *e_u = Engine::Get(u->engine_type);
 
		const RailVehicleInfo *rvi_u = &e_u->u.rail;
 

	
 
		if (!HasBit(EngInfo(u->engine_type)->misc_flags, EF_RAIL_TILTS)) train_can_tilt = false;
 
@@ -366,7 +366,7 @@ enum AccelType {
 
 */
 
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Vehicle *v, int *station_ahead, int *station_length)
 
{
 
	const Station *st = GetStation(station_id);
 
	const Station *st = Station::Get(station_id);
 
	*station_ahead  = st->GetPlatformLength(tile, DirToDiagDir(v->direction)) * TILE_SIZE;
 
	*station_length = st->GetPlatformLength(tile) * TILE_SIZE;
 

	
 
@@ -579,7 +579,7 @@ SpriteID Train::GetImage(Direction direc
 
		sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)));
 
		if (sprite != 0) return sprite;
 

	
 
		spritenum = GetEngine(this->engine_type)->image_index;
 
		spritenum = Engine::Get(this->engine_type)->image_index;
 
	}
 

	
 
	sprite = _engine_sprite_base[spritenum] + ((direction + _engine_sprite_add[spritenum]) & _engine_sprite_and[spritenum]);
 
@@ -601,7 +601,7 @@ static SpriteID GetRailIcon(EngineID eng
 
			return sprite;
 
		}
 

	
 
		spritenum = GetEngine(engine)->image_index;
 
		spritenum = Engine::Get(engine)->image_index;
 
	}
 

	
 
	if (rear_head) spritenum++;
 
@@ -627,7 +627,7 @@ void DrawTrainEngine(int x, int y, Engin
 

	
 
static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandFlag flags)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 
	const RailVehicleInfo *rvi = &e->u.rail;
 
	CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
 

	
 
@@ -716,7 +716,7 @@ static CommandCost CmdBuildRailWagon(Eng
 
		if (IsLocalCompany()) {
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
 
		}
 
		GetCompany(_current_company)->num_engines[engine]++;
 
		Company::Get(_current_company)->num_engines[engine]++;
 

	
 
		CheckConsistencyOfArticulatedVehicle(v);
 
	}
 
@@ -784,7 +784,7 @@ CommandCost CmdBuildRailVehicle(TileInde
 
	/* Check if the engine-type is valid (for the company) */
 
	if (!IsEngineBuildable(p1, VEH_TRAIN, _current_company)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
 

	
 
	const Engine *e = GetEngine(p1);
 
	const Engine *e = Engine::Get(p1);
 
	CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
 

	
 
	/* Engines with CT_INVALID should not be available */
 
@@ -890,7 +890,7 @@ CommandCost CmdBuildRailVehicle(TileInde
 
			InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Train window
 
		}
 

	
 
		GetCompany(_current_company)->num_engines[p1]++;
 
		Company::Get(_current_company)->num_engines[p1]++;
 

	
 
		CheckConsistencyOfArticulatedVehicle(v);
 
	}
 
@@ -1042,7 +1042,7 @@ CommandCost CmdMoveRailVehicle(TileIndex
 

	
 
	if (!IsValidVehicleID(s)) return CMD_ERROR;
 

	
 
	Vehicle *src = GetVehicle(s);
 
	Vehicle *src = Vehicle::Get(s);
 

	
 
	if (src->type != VEH_TRAIN || !CheckOwnership(src->owner)) return CMD_ERROR;
 

	
 
@@ -1055,7 +1055,7 @@ CommandCost CmdMoveRailVehicle(TileIndex
 
		dst = IsTrainEngine(src) ? NULL : FindGoodVehiclePos(src);
 
	} else {
 
		if (!IsValidVehicleID(d)) return CMD_ERROR;
 
		dst = GetVehicle(d);
 
		dst = Vehicle::Get(d);
 
		if (dst->type != VEH_TRAIN || !CheckOwnership(dst->owner)) return CMD_ERROR;
 

	
 
		/* Do not allow appending to crashed vehicles, too */
 
@@ -1291,7 +1291,7 @@ CommandCost CmdMoveRailVehicle(TileIndex
 

	
 
					/* Decrease the engines number of the src engine_type */
 
					if (!IsDefaultGroupID(src->group_id) && IsValidGroupID(src->group_id)) {
 
						GetGroup(src->group_id)->num_engines[src->engine_type]--;
 
						Group::Get(src->group_id)->num_engines[src->engine_type]--;
 
					}
 

	
 
					/* If we move an engine to a new line affect it to the DEFAULT_GROUP */
 
@@ -1397,7 +1397,7 @@ CommandCost CmdSellRailWagon(TileIndex t
 

	
 
	if (!IsValidVehicleID(p1) || p2 > 1) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -1954,7 +1954,7 @@ CommandCost CmdReverseTrainDirection(Til
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -2015,7 +2015,7 @@ CommandCost CmdForceTrainProceed(TileInd
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
@@ -2042,7 +2042,7 @@ CommandCost CmdRefitRailVehicle(TileInde
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (CheckTrainStoppedInDepot(v) < 0) return_cmd_error(STR_TRAIN_MUST_BE_STOPPED);
 
@@ -2060,7 +2060,7 @@ CommandCost CmdRefitRailVehicle(TileInde
 
		 * some nice [Refit] button near each wagon. --pasky */
 
		if (!CanRefitTo(v->engine_type, new_cid)) continue;
 

	
 
		const Engine *e = GetEngine(v->engine_type);
 
		const Engine *e = Engine::Get(v->engine_type);
 
		if (e->CanCarryCargo()) {
 
			uint16 amount = CALLBACK_FAILED;
 

	
 
@@ -2118,7 +2118,7 @@ CommandCost CmdRefitRailVehicle(TileInde
 
	_returned_refit_capacity = num;
 

	
 
	/* Update the train's cached variables */
 
	if (flags & DC_EXEC) TrainConsistChanged(GetVehicle(p1)->First(), false);
 
	if (flags & DC_EXEC) TrainConsistChanged(Vehicle::Get(p1)->First(), false);
 

	
 
	return cost;
 
}
 
@@ -2248,7 +2248,7 @@ CommandCost CmdSendTrainToDepot(TileInde
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (v->type != VEH_TRAIN) return CMD_ERROR;
 

	
 
@@ -3280,7 +3280,7 @@ TileIndex Train::GetOrderStationLocation
 
{
 
	if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
 

	
 
	const Station *st = GetStation(station);
 
	const Station *st = Station::Get(station);
 
	if (!(st->facilities & FACIL_TRAIN)) {
 
		/* The destination station has no trainstation tiles. */
 
		this->IncrementOrderIndex();
 
@@ -3363,7 +3363,7 @@ static void TrainEnterStation(Vehicle *v
 
	v->last_station_visited = station;
 

	
 
	/* check if a train ever visited this station before */
 
	Station *st = GetStation(station);
 
	Station *st = Station::Get(station);
 
	if (!(st->had_vehicle_of_type & HVOT_TRAIN)) {
 
		st->had_vehicle_of_type |= HVOT_TRAIN;
 
		SetDParam(0, st->index);
 
@@ -4501,7 +4501,7 @@ void Train::OnNewDay()
 

	
 
		/* update destination */
 
		if (this->current_order.IsType(OT_GOTO_STATION)) {
 
			TileIndex tile = GetStation(this->current_order.GetDestination())->train_tile;
 
			TileIndex tile = Station::Get(this->current_order.GetDestination())->train_tile;
 
			if (tile != INVALID_TILE) this->dest_tile = tile;
 
		}
 

	
src/train_gui.cpp
Show inline comments
 
@@ -47,7 +47,7 @@ void CcBuildLoco(bool success, TileIndex
 
{
 
	if (!success) return;
 

	
 
	const Vehicle *v = GetVehicle(_new_vehicle_id);
 
	const Vehicle *v = Vehicle::Get(_new_vehicle_id);
 
	if (tile == _backup_orders_tile) {
 
		_backup_orders_tile = 0;
 
		RestoreVehicleOrders(v);
 
@@ -185,7 +185,7 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
		memset(max_cargo, 0, sizeof(max_cargo));
 
		memset(act_cargo, 0, sizeof(act_cargo));
 

	
 
		for (const Vehicle *v = GetVehicle(veh_id) ; v != NULL ; v = v->Next()) {
 
		for (const Vehicle *v = Vehicle::Get(veh_id) ; v != NULL ; v = v->Next()) {
 
			act_cargo[v->cargo_type] += v->cargo.Count();
 
			max_cargo[v->cargo_type] += v->cargo_cap;
 
		}
 
@@ -198,7 +198,7 @@ int GetTrainDetailsWndVScroll(VehicleID 
 
		}
 
		num++; // needs one more because first line is description string
 
	} else {
 
		for (const Vehicle *v = GetVehicle(veh_id) ; v != NULL ; v = v->Next()) {
 
		for (const Vehicle *v = Vehicle::Get(veh_id) ; v != NULL ; v = v->Next()) {
 
			if (!IsArticulatedPart(v) || v->cargo_cap != 0) num++;
 
		}
 
	}
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -440,7 +440,7 @@ not_valid_below:;
 
	 * It's unnecessary to execute this command every time for every bridge. So it is done only
 
	 * and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
 
	 */
 
	if (!(flags & DC_QUERY_COST) || (IsValidCompanyID(_current_company) && GetCompany(_current_company)->is_ai)) {
 
	if (!(flags & DC_QUERY_COST) || (IsValidCompanyID(_current_company) && Company::Get(_current_company)->is_ai)) {
 
		bridge_len += 2; // begin and end tiles/ramps
 

	
 
		if (IsValidCompanyID(_current_company))
src/unmovable_cmd.cpp
Show inline comments
 
@@ -51,7 +51,7 @@ static inline const UnmovableSpec *GetUn
 
 */
 
static CommandCost DestroyCompanyHQ(CompanyID cid, DoCommandFlag flags)
 
{
 
	Company *c = GetCompany(cid);
 
	Company *c = Company::Get(cid);
 

	
 
	if (flags & DC_EXEC) {
 
		TileIndex t = c->location_of_HQ;
 
@@ -99,7 +99,7 @@ extern CommandCost CheckFlatLandBelow(Ti
 
 */
 
CommandCost CmdBuildCompanyHQ(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	Company *c = GetCompany(_current_company);
 
	Company *c = Company::Get(_current_company);
 
	CommandCost cost(EXPENSES_PROPERTY);
 

	
 
	cost = CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL);
 
@@ -280,7 +280,7 @@ static CommandCost ClearTile_Unmovable(T
 
		if (flags & DC_AUTO) return_cmd_error(STR_ERROR_OBJECT_IN_THE_WAY);
 

	
 
		TownID town = GetStatueTownID(tile);
 
		ClrBit(GetTown(town)->statues, GetTileOwner(tile));
 
		ClrBit(Town::Get(town)->statues, GetTileOwner(tile));
 
		InvalidateWindow(WC_TOWN_AUTHORITY, town);
 
	}
 

	
 
@@ -469,7 +469,7 @@ static void ChangeTileOwner_Unmovable(Ti
 
		SetTileOwner(tile, new_owner);
 
	} else if (IsStatueTile(tile)) {
 
		TownID town = GetStatueTownID(tile);
 
		Town *t = GetTown(town);
 
		Town *t = Town::Get(town);
 
		ClrBit(t->statues, old_owner);
 
		if (new_owner != INVALID_OWNER && !HasBit(t->statues, new_owner)) {
 
			/* Transfer ownership to the new company */
src/vehicle.cpp
Show inline comments
 
@@ -62,7 +62,7 @@ bool Vehicle::NeedsAutorenewing(const Co
 
	 * However this takes time and since the Company pointer is often present
 
	 * when this function is called then it's faster to pass the pointer as an
 
	 * argument rather than finding it again. */
 
	assert(c == GetCompany(this->owner));
 
	assert(c == Company::Get(this->owner));
 

	
 
	if (!c->settings.engine_renew) return false;
 
	if (this->age - this->max_age < (c->settings.engine_renew_months * 30)) return false;
 
@@ -75,7 +75,7 @@ void VehicleServiceInDepot(Vehicle *v)
 
{
 
	v->date_of_last_service = _date;
 
	v->breakdowns_since_last_service = 0;
 
	v->reliability = GetEngine(v->engine_type)->reliability;
 
	v->reliability = Engine::Get(v->engine_type)->reliability;
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index); // ensure that last service date and reliability are updated
 
}
 

	
 
@@ -86,11 +86,11 @@ bool Vehicle::NeedsServicing() const
 
	if (_settings_game.order.no_servicing_if_no_breakdowns && _settings_game.difficulty.vehicle_breakdowns == 0) {
 
		/* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off.
 
		 * Note: If servicing is enabled, we postpone replacement till next service. */
 
		return EngineHasReplacementForCompany(GetCompany(this->owner), this->engine_type, this->group_id);
 
		return EngineHasReplacementForCompany(Company::Get(this->owner), this->engine_type, this->group_id);
 
	}
 

	
 
	return _settings_game.vehicle.servint_ispercent ?
 
		(this->reliability < GetEngine(this->engine_type)->reliability * (100 - this->service_interval) / 100) :
 
		(this->reliability < Engine::Get(this->engine_type)->reliability * (100 - this->service_interval) / 100) :
 
		(this->date_of_last_service + this->service_interval < _date);
 
}
 

	
 
@@ -112,7 +112,7 @@ bool Vehicle::NeedsAutomaticServicing() 
 
 */
 
void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBugs bug_type, bool critical)
 
{
 
	const Engine *e = GetEngine(engine);
 
	const Engine *e = Engine::Get(engine);
 
	uint32 grfid = e->grffile->grfid;
 
	GRFConfig *grfconfig = GetGRFConfig(grfid);
 

	
 
@@ -510,17 +510,17 @@ void Vehicle::PreDestructor()
 
	if (CleaningPool()) return;
 

	
 
	if (IsValidStationID(this->last_station_visited)) {
 
		GetStation(this->last_station_visited)->loading_vehicles.remove(this);
 
		Station::Get(this->last_station_visited)->loading_vehicles.remove(this);
 

	
 
		HideFillingPercent(&this->fill_percent_te_id);
 
	}
 

	
 
	if (IsEngineCountable(this)) {
 
		GetCompany(this->owner)->num_engines[this->engine_type]--;
 
		Company::Get(this->owner)->num_engines[this->engine_type]--;
 
		if (this->owner == _local_company) InvalidateAutoreplaceWindow(this->engine_type, this->group_id);
 

	
 
		DeleteGroupHighlightOfVehicle(this);
 
		if (IsValidGroupID(this->group_id)) GetGroup(this->group_id)->num_engines[this->engine_type]--;
 
		if (IsValidGroupID(this->group_id)) Group::Get(this->group_id)->num_engines[this->engine_type]--;
 
		if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id);
 
	}
 

	
 
@@ -641,7 +641,7 @@ void CallVehicleTicks()
 
		int y = v->y_pos;
 
		int z = v->z_pos;
 

	
 
		const Company *c = GetCompany(_current_company);
 
		const Company *c = Company::Get(_current_company);
 
		SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, (Money)c->settings.engine_renew_money));
 
		CommandCost res = DoCommand(0, v->index, 0, DC_EXEC, CMD_AUTOREPLACE_VEHICLE);
 
		SubtractMoneyFromCompany(CommandCost(EXPENSES_NEW_VEHICLES, -(Money)c->settings.engine_renew_money));
 
@@ -708,7 +708,7 @@ CommandCost GetRefitCost(EngineID engine
 
{
 
	Money base_cost;
 
	ExpensesType expense_type;
 
	switch (GetEngine(engine_type)->type) {
 
	switch (Engine::Get(engine_type)->type) {
 
		case VEH_SHIP:
 
			base_cost = _price.ship_base;
 
			expense_type = EXPENSES_SHIP_RUN;
 
@@ -906,7 +906,7 @@ void AgeVehicle(Vehicle *v)
 
	if (v->Previous() != NULL || v->owner != _local_company || (v->vehstatus & VS_CRASHED) != 0) return;
 

	
 
	/* Don't warn if a renew is active */
 
	if (GetCompany(v->owner)->settings.engine_renew && GetEngine(v->engine_type)->company_avail != 0) return;
 
	if (Company::Get(v->owner)->settings.engine_renew && Engine::Get(v->engine_type)->company_avail != 0) return;
 

	
 
	StringID str;
 
	if (age == -DAYS_IN_LEAP_YEAR) {
 
@@ -938,7 +938,7 @@ uint8 CalcPercentVehicleFilled(const Veh
 
	bool loading = false;
 

	
 
	const Vehicle *u = v;
 
	const Station *st = v->last_station_visited != INVALID_STATION ? GetStation(v->last_station_visited) : NULL;
 
	const Station *st = v->last_station_visited != INVALID_STATION ? Station::Get(v->last_station_visited) : NULL;
 

	
 
	/* Count up max and used */
 
	for (; v != NULL; v = v->Next()) {
 
@@ -1317,7 +1317,7 @@ bool CanBuildVehicleInfrastructure(Vehic
 

	
 
const Livery *GetEngineLivery(EngineID engine_type, CompanyID company, EngineID parent_engine_type, const Vehicle *v)
 
{
 
	const Company *c = GetCompany(company);
 
	const Company *c = Company::Get(company);
 
	LiveryScheme scheme = LS_DEFAULT;
 
	CargoID cargo_type = v == NULL ? (CargoID)CT_INVALID : v->cargo_type;
 

	
 
@@ -1325,7 +1325,7 @@ const Livery *GetEngineLivery(EngineID e
 
	 * whether any _other_ liveries are in use. */
 
	if (c->livery[LS_DEFAULT].in_use && (_settings_client.gui.liveries == 2 || (_settings_client.gui.liveries == 1 && company == _local_company))) {
 
		/* Determine the livery scheme to use */
 
		const Engine *e = GetEngine(engine_type);
 
		const Engine *e = Engine::Get(engine_type);
 
		switch (e->type) {
 
			default: NOT_REACHED();
 
			case VEH_TRAIN: {
 
@@ -1334,7 +1334,7 @@ const Livery *GetEngineLivery(EngineID e
 
					/* Wagonoverrides use the coloir scheme of the front engine.
 
					 * Articulated parts use the colour scheme of the first part. (Not supported for articulated wagons) */
 
					engine_type = parent_engine_type;
 
					e = GetEngine(engine_type);
 
					e = Engine::Get(engine_type);
 
					rvi = RailVehInfo(engine_type);
 
					/* Note: Luckily cargo_type is not needed for engines */
 
				}
 
@@ -1377,7 +1377,7 @@ const Livery *GetEngineLivery(EngineID e
 
				/* Always use the livery of the front */
 
				if (v != NULL && parent_engine_type != INVALID_ENGINE) {
 
					engine_type = parent_engine_type;
 
					e = GetEngine(engine_type);
 
					e = Engine::Get(engine_type);
 
					cargo_type = v->First()->cargo_type;
 
				}
 
				if (cargo_type == CT_INVALID) cargo_type = e->GetDefaultCargoType();
 
@@ -1494,7 +1494,7 @@ void Vehicle::BeginLoading()
 
		current_order.MakeLoading(false);
 
	}
 

	
 
	GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
 
	Station::Get(this->last_station_visited)->loading_vehicles.push_back(this);
 

	
 
	VehiclePayment(this);
 

	
 
@@ -1503,7 +1503,7 @@ void Vehicle::BeginLoading()
 
	InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
 
	InvalidateWindow(WC_STATION_VIEW, this->last_station_visited);
 

	
 
	GetStation(this->last_station_visited)->MarkTilesDirty(true);
 
	Station::Get(this->last_station_visited)->MarkTilesDirty(true);
 
	this->cur_speed = 0;
 
	this->MarkDirty();
 
}
 
@@ -1516,7 +1516,7 @@ void Vehicle::LeaveStation()
 
	if (current_order.GetNonStopType() != ONSF_STOP_EVERYWHERE) UpdateVehicleTimetable(this, false);
 

	
 
	current_order.MakeLeaveStation();
 
	Station *st = GetStation(this->last_station_visited);
 
	Station *st = Station::Get(this->last_station_visited);
 
	st->loading_vehicles.remove(this);
 

	
 
	HideFillingPercent(&this->fill_percent_te_id);
 
@@ -1748,7 +1748,7 @@ void VehiclesYearlyLoop()
 
bool CanVehicleUseStation(EngineID engine_type, const Station *st)
 
{
 
	assert(IsEngineIndex(engine_type));
 
	const Engine *e = GetEngine(engine_type);
 
	const Engine *e = Engine::Get(engine_type);
 

	
 
	switch (e->type) {
 
		case VEH_TRAIN:
src/vehicle_base.h
Show inline comments
 
@@ -657,7 +657,7 @@ static inline uint GetNumVehicles()
 
	return GetVehiclePoolSize();
 
}
 

	
 
#define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (v->IsValid())
 
#define FOR_ALL_VEHICLES_FROM(v, start) for (v = Vehicle::Get(start); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? Vehicle::Get(v->index + 1) : NULL) if (v->IsValid())
 
#define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
 

	
 
/**
 
@@ -667,7 +667,7 @@ static inline uint GetNumVehicles()
 
 */
 
static inline bool IsValidVehicleID(uint index)
 
{
 
	return index < GetVehiclePoolSize() && GetVehicle(index)->IsValid();
 
	return index < GetVehiclePoolSize() && Vehicle::Get(index)->IsValid();
 
}
 

	
 

	
src/vehicle_cmd.cpp
Show inline comments
 
@@ -63,7 +63,7 @@ CommandCost CmdStartStopVehicle(TileInde
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 
	if (!v->IsPrimaryVehicle()) return CMD_ERROR;
 
@@ -336,7 +336,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 

	
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 
	Vehicle *v_front = v;
 
	Vehicle *w = NULL;
 
	Vehicle *w_front = NULL;
 
@@ -382,7 +382,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
		total_cost.AddCost(cost);
 

	
 
		if (flags & DC_EXEC) {
 
			w = GetVehicle(_new_vehicle_id);
 
			w = Vehicle::Get(_new_vehicle_id);
 

	
 
			if (v->type == VEH_TRAIN && HasBit(v->u.rail.flags, VRF_REVERSE_DIRECTION)) {
 
				SetBit(w->u.rail.flags, VRF_REVERSE_DIRECTION);
 
@@ -447,7 +447,7 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
					break;
 
				}
 
			} else {
 
				const Engine *e = GetEngine(v->engine_type);
 
				const Engine *e = Engine::Get(v->engine_type);
 
				CargoID initial_cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
 

	
 
				if (v->cargo_type != initial_cargo && initial_cargo != CT_INVALID) {
 
@@ -534,7 +534,7 @@ CommandCost CmdRenameVehicle(TileIndex t
 
{
 
	if (!IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	bool reset = StrEmpty(text);
 
@@ -567,7 +567,7 @@ CommandCost CmdChangeServiceInt(TileInde
 

	
 
	if (serv_int != p2 || !IsValidVehicleID(p1)) return CMD_ERROR;
 

	
 
	Vehicle *v = GetVehicle(p1);
 
	Vehicle *v = Vehicle::Get(p1);
 

	
 
	if (!CheckOwnership(v->owner)) return CMD_ERROR;
 

	
src/vehicle_gui.cpp
Show inline comments
 
@@ -333,7 +333,7 @@ struct RefitWindow : public Window {
 

	
 
	virtual void OnPaint()
 
	{
 
		Vehicle *v = GetVehicle(this->window_number);
 
		Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
		if (v->type == VEH_TRAIN) {
 
			uint length = CountVehiclesInChain(v);
 
@@ -383,7 +383,7 @@ struct RefitWindow : public Window {
 

	
 
			case VRW_REFITBUTTON: // refit button
 
				if (this->cargo != NULL) {
 
					const Vehicle *v = GetVehicle(this->window_number);
 
					const Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
					if (this->order == INVALID_VEH_ORDER_ID) {
 
						int command = 0;
 
@@ -477,7 +477,7 @@ uint ShowAdditionalText(int left, int ri
 
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
 
{
 
	/* List of cargo types of this engine */
 
	uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, GetEngine(engine)->type, false);
 
	uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, Engine::Get(engine)->type, false);
 
	/* List of cargo types available in this climate */
 
	uint32 lmask = _cargo_mask;
 
	char string[512];
 
@@ -796,7 +796,7 @@ static void DrawSmallOrderList(const Veh
 
		sel--;
 

	
 
		if (order->IsType(OT_GOTO_STATION)) {
 
			if (v->type == VEH_SHIP && GetStation(order->GetDestination())->IsBuoy()) continue;
 
			if (v->type == VEH_SHIP && Station::Get(order->GetDestination())->IsBuoy()) continue;
 

	
 
			SetDParam(0, order->GetDestination());
 
			DrawString(left, right, y, STR_ORDER_STATION_SMALL);
 
@@ -1042,7 +1042,7 @@ struct VehicleListWindow : public BaseVe
 
				if (this->vehicle_type == VEH_AIRCRAFT) {
 
					SetDParam(1, index); // Airport name
 
				} else {
 
					SetDParam(1, GetDepot(index)->town_index);
 
					SetDParam(1, Depot::Get(index)->town_index);
 
				}
 
				SetDParam(2, this->vscroll.count);
 
				break;
 
@@ -1346,7 +1346,7 @@ struct VehicleDetailsWindow : Window {
 
	/** Initialize a newly created vehicle details window */
 
	VehicleDetailsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		const Vehicle *v = GetVehicle(this->window_number);
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
		switch (v->type) {
 
			case VEH_TRAIN:
 
@@ -1439,7 +1439,7 @@ struct VehicleDetailsWindow : Window {
 
	/** Repaint vehicle details window. */
 
	virtual void OnPaint()
 
	{
 
		const Vehicle *v = GetVehicle(this->window_number);
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 
		byte det_tab = this->tab;
 

	
 
		this->SetWidgetDisabledState(VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_company);
 
@@ -1540,7 +1540,7 @@ struct VehicleDetailsWindow : Window {
 

	
 
		switch (widget) {
 
			case VLD_WIDGET_RENAME_VEHICLE: {// rename
 
				const Vehicle *v = GetVehicle(this->window_number);
 
				const Vehicle *v = Vehicle::Get(this->window_number);
 
				SetDParam(0, v->index);
 
				ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], MAX_LENGTH_VEHICLE_NAME_BYTES, MAX_LENGTH_VEHICLE_NAME_PIXELS, this, CS_ALPHANUMERAL, QSF_ENABLE_DEFAULT);
 
			} break;
 
@@ -1548,7 +1548,7 @@ struct VehicleDetailsWindow : Window {
 
			case VLD_WIDGET_INCREASE_SERVICING_INTERVAL:   // increase int
 
			case VLD_WIDGET_DECREASE_SERVICING_INTERVAL: { // decrease int
 
				int mod = _ctrl_pressed ? 5 : 10;
 
				const Vehicle *v = GetVehicle(this->window_number);
 
				const Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
				mod = (widget == VLD_WIDGET_DECREASE_SERVICING_INTERVAL) ? -mod : mod;
 
				mod = GetServiceIntervalClamped(mod + v->service_interval);
 
@@ -1587,7 +1587,7 @@ struct VehicleDetailsWindow : Window {
 

	
 
		if (str == NULL) return;
 

	
 
		DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(_name_vehicle_error[GetVehicle(this->window_number)->type]), NULL, str);
 
		DoCommandP(0, this->window_number, 0, CMD_RENAME_VEHICLE | CMD_MSG(_name_vehicle_error[Vehicle::Get(this->window_number)->type]), NULL, str);
 
	}
 

	
 
	virtual void OnResize(Point delta)
 
@@ -1768,7 +1768,7 @@ static bool IsVehicleRefitable(const Veh
 
struct VehicleViewWindow : Window {
 
	VehicleViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		const Vehicle *v = GetVehicle(this->window_number);
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
		this->owner = v->owner;
 
		InitializeWindowViewport(this, VV_VIEWPORT_X, VV_VIEWPORT_Y, VV_INITIAL_VIEWPORT_WIDTH,
 
@@ -1924,7 +1924,7 @@ struct VehicleViewWindow : Window {
 
			STR_HEADING_FOR_HANGAR_SERVICE,
 
		};
 

	
 
		const Vehicle *v = GetVehicle(this->window_number);
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 
		StringID str;
 
		bool is_localcompany = v->owner == _local_company;
 
		bool refitable_and_stopped_in_depot = IsVehicleRefitable(v);
 
@@ -1978,7 +1978,7 @@ struct VehicleViewWindow : Window {
 
						SetDParam(0, v->current_order.GetDestination());
 
						SetDParam(1, v->GetDisplaySpeed());
 
					} else {
 
						Depot *depot = GetDepot(v->current_order.GetDestination());
 
						Depot *depot = Depot::Get(v->current_order.GetDestination());
 
						SetDParam(0, depot->town_index);
 
						SetDParam(1, v->GetDisplaySpeed());
 
					}
 
@@ -2027,7 +2027,7 @@ struct VehicleViewWindow : Window {
 

	
 
	virtual void OnClick(Point pt, int widget)
 
	{
 
		const Vehicle *v = GetVehicle(this->window_number);
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 

	
 
		switch (widget) {
 
			case VVW_WIDGET_START_STOP_VEH: // start stop
 
@@ -2088,7 +2088,7 @@ struct VehicleViewWindow : Window {
 

	
 
	virtual void OnTick()
 
	{
 
		const Vehicle *v = GetVehicle(this->window_number);
 
		const Vehicle *v = Vehicle::Get(this->window_number);
 
		bool veh_stopped = v->IsStoppedInDepot();
 

	
 
		/* Widget VVW_WIDGET_GOTO_DEPOT must be hidden if the vehicle is already
src/vehiclelist.cpp
Show inline comments
 
@@ -92,7 +92,7 @@ void GenerateVehicleSortList(VehicleList
 

	
 
		case VLW_SHARED_ORDERS:
 
			/* Add all vehicles from this vehicle's shared order list */
 
			for (v = GetVehicle(index); v != NULL; v = v->NextShared()) {
 
			for (v = Vehicle::Get(index); v != NULL; v = v->NextShared()) {
 
				*list->Append() = v;
 
			}
 
			break;
src/viewport.cpp
Show inline comments
 
@@ -186,7 +186,7 @@ void InitializeWindowViewport(Window *w,
 
		const Vehicle *veh;
 

	
 
		vp->follow_vehicle = (VehicleID)(follow_flags & 0xFFFF);
 
		veh = GetVehicle(vp->follow_vehicle);
 
		veh = Vehicle::Get(vp->follow_vehicle);
 
		pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
 
	} else {
 
		uint x = TileX(follow_flags) * TILE_SIZE;
 
@@ -1614,7 +1614,7 @@ void UpdateViewportPosition(Window *w)
 
	const ViewPort *vp = w->viewport;
 

	
 
	if (w->viewport->follow_vehicle != INVALID_VEHICLE) {
 
		const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle);
 
		const Vehicle *veh = Vehicle::Get(w->viewport->follow_vehicle);
 
		Point pt = MapXYZToViewport(vp, veh->x_pos, veh->y_pos, veh->z_pos);
 

	
 
		w->viewport->scrollpos_x = pt.x;
src/waypoint.cpp
Show inline comments
 
@@ -56,7 +56,7 @@ Station *ComposeWaypointStation(TileInde
 
	static Station &stat = *(Station*)stat_raw;
 

	
 
	stat.train_tile = stat.xy = wp->xy;
 
	stat.town = GetTown(wp->town_index);
 
	stat.town = Town::Get(wp->town_index);
 
	stat.build_date = wp->build_date;
 

	
 
	return &stat;
src/waypoint.h
Show inline comments
 
@@ -42,10 +42,10 @@ struct Waypoint : PoolItem<Waypoint, Way
 

	
 
static inline bool IsValidWaypointID(WaypointID index)
 
{
 
	return index < GetWaypointPoolSize() && GetWaypoint(index)->IsValid();
 
	return index < GetWaypointPoolSize() && Waypoint::Get(index)->IsValid();
 
}
 

	
 
#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (wp->IsValid())
 
#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = Waypoint::Get(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? Waypoint::Get(wp->index + 1U) : NULL) if (wp->IsValid())
 
#define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)
 

	
 

	
 
@@ -57,7 +57,7 @@ static inline bool IsValidWaypointID(Way
 
static inline Waypoint *GetWaypointByTile(TileIndex tile)
 
{
 
	assert(IsRailWaypointTile(tile));
 
	return GetWaypoint(GetWaypointIndex(tile));
 
	return Waypoint::Get(GetWaypointIndex(tile));
 
}
 

	
 
CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justremove);
src/waypoint_cmd.cpp
Show inline comments
 
@@ -71,7 +71,7 @@ static void MakeDefaultWaypointName(Wayp
 

	
 
	WaypointID cid = 0; // current index, goes to GetWaypointPoolSize()-1, then wraps to 0
 
	do {
 
		Waypoint *lwp = GetWaypoint(cid);
 
		Waypoint *lwp = Waypoint::Get(cid);
 

	
 
		/* check only valid waypoints... */
 
		if (lwp->IsValid() && wp != lwp) {
 
@@ -316,7 +316,7 @@ CommandCost CmdRenameWaypoint(TileIndex 
 
{
 
	if (!IsValidWaypointID(p1)) return CMD_ERROR;
 

	
 
	Waypoint *wp = GetWaypoint(p1);
 
	Waypoint *wp = Waypoint::Get(p1);
 
	if (!CheckOwnership(wp->owner)) return CMD_ERROR;
 

	
 
	bool reset = StrEmpty(text);
src/waypoint_gui.cpp
Show inline comments
 
@@ -35,7 +35,7 @@ private:
 
public:
 
	WaypointWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
 
	{
 
		this->wp = GetWaypoint(this->window_number);
 
		this->wp = Waypoint::Get(this->window_number);
 
		if (this->wp->owner != OWNER_NONE) this->owner = this->wp->owner;
 

	
 
		this->flags4 |= WF_DISABLE_VP_SCROLL;
src/window.cpp
Show inline comments
 
@@ -1684,7 +1684,7 @@ static bool HandleViewportScroll()
 

	
 
	if (w == FindWindowById(WC_MAIN_WINDOW, 0) && w->viewport->follow_vehicle != INVALID_VEHICLE) {
 
		/* If the main window is following a vehicle, then first let go of it! */
 
		const Vehicle *veh = GetVehicle(w->viewport->follow_vehicle);
 
		const Vehicle *veh = Vehicle::Get(w->viewport->follow_vehicle);
 
		ScrollMainWindowTo(veh->x_pos, veh->y_pos, veh->z_pos, true); // This also resets follow_vehicle
 
		return true;
 
	}
src/yapf/yapf_destrail.hpp
Show inline comments
 
@@ -135,7 +135,7 @@ public:
 
				break;
 

	
 
			case OT_GOTO_WAYPOINT: {
 
				Waypoint *wp = GetWaypoint(v->current_order.GetDestination());
 
				Waypoint *wp = Waypoint::Get(v->current_order.GetDestination());
 
				if (wp == NULL) {
 
					/* Invalid waypoint in orders! */
 
					DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, company %d)", v->current_order.GetDestination(), v->unitnumber, (CompanyID)v->owner);
0 comments (0 inline, 0 general)