summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-16 23:34:14 +0000
committersmatz <smatz@openttd.org>2009-05-16 23:34:14 +0000
commit6221d74644922ea4bbba3ed9cd8bbec42398f77b (patch)
tree0069bbd6bb7525754c5d9353132f5dc64a0996cc /src
parent814f153b5a98e0030cbd221e6a89e083ce62bb1d (diff)
downloadopenttd-6221d74644922ea4bbba3ed9cd8bbec42398f77b.tar.xz
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_core.cpp18
-rw-r--r--src/ai/ai_gui.cpp8
-rw-r--r--src/ai/ai_instance.cpp4
-rw-r--r--src/ai/api/ai_airport.cpp2
-rw-r--r--src/ai/api/ai_cargolist.cpp4
-rw-r--r--src/ai/api/ai_company.cpp14
-rw-r--r--src/ai/api/ai_controller.cpp2
-rw-r--r--src/ai/api/ai_engine.cpp28
-rw-r--r--src/ai/api/ai_event_types.cpp12
-rw-r--r--src/ai/api/ai_group.cpp10
-rw-r--r--src/ai/api/ai_industry.cpp24
-rw-r--r--src/ai/api/ai_order.cpp42
-rw-r--r--src/ai/api/ai_sign.cpp4
-rw-r--r--src/ai/api/ai_station.cpp18
-rw-r--r--src/ai/api/ai_stationlist.cpp2
-rw-r--r--src/ai/api/ai_subsidy.cpp2
-rw-r--r--src/ai/api/ai_tilelist.cpp6
-rw-r--r--src/ai/api/ai_town.cpp32
-rw-r--r--src/ai/api/ai_vehicle.cpp82
-rw-r--r--src/ai/api/ai_vehiclelist.cpp2
-rw-r--r--src/ai/api/ai_waypoint.cpp4
-rw-r--r--src/ai/api/ai_waypointlist.cpp2
-rw-r--r--src/aircraft_cmd.cpp54
-rw-r--r--src/aircraft_gui.cpp2
-rw-r--r--src/articulated_vehicles.cpp8
-rw-r--r--src/autoreplace.cpp2
-rw-r--r--src/autoreplace_base.h2
-rw-r--r--src/autoreplace_cmd.cpp10
-rw-r--r--src/autoreplace_gui.cpp12
-rw-r--r--src/build_vehicle_gui.cpp50
-rw-r--r--src/cargopacket.cpp2
-rw-r--r--src/cargopacket.h2
-rw-r--r--src/command.cpp4
-rw-r--r--src/company_base.h4
-rw-r--r--src/company_cmd.cpp20
-rw-r--r--src/company_gui.cpp18
-rw-r--r--src/console_cmds.cpp6
-rw-r--r--src/core/random_func.cpp2
-rw-r--r--src/date.cpp2
-rw-r--r--src/depot_base.h4
-rw-r--r--src/depot_gui.cpp8
-rw-r--r--src/disaster_cmd.cpp12
-rw-r--r--src/economy.cpp56
-rw-r--r--src/engine.cpp20
-rw-r--r--src/engine_base.h12
-rw-r--r--src/engine_gui.cpp14
-rw-r--r--src/graph_gui.cpp2
-rw-r--r--src/group.h8
-rw-r--r--src/group_cmd.cpp22
-rw-r--r--src/group_gui.cpp6
-rw-r--r--src/highscore_gui.cpp6
-rw-r--r--src/industry.h6
-rw-r--r--src/industry_cmd.cpp4
-rw-r--r--src/industry_gui.cpp10
-rw-r--r--src/industry_map.h2
-rw-r--r--src/main_gui.cpp2
-rw-r--r--src/misc_cmd.cpp14
-rw-r--r--src/misc_gui.cpp4
-rw-r--r--src/network/core/tcp_game.h4
-rw-r--r--src/network/network.cpp4
-rw-r--r--src/network/network_base.h4
-rw-r--r--src/network/network_client.cpp2
-rw-r--r--src/network/network_server.cpp2
-rw-r--r--src/newgrf.cpp4
-rw-r--r--src/newgrf_engine.cpp36
-rw-r--r--src/newgrf_industries.cpp2
-rw-r--r--src/news_gui.cpp2
-rw-r--r--src/oldpool.h12
-rw-r--r--src/openttd.cpp4
-rw-r--r--src/order_base.h6
-rw-r--r--src/order_cmd.cpp46
-rw-r--r--src/order_gui.cpp14
-rw-r--r--src/pathfind.h2
-rw-r--r--src/rail.cpp2
-rw-r--r--src/road.cpp2
-rw-r--r--src/roadveh_cmd.cpp24
-rw-r--r--src/roadveh_gui.cpp2
-rw-r--r--src/saveload/afterload.cpp10
-rw-r--r--src/saveload/oldloader_sl.cpp20
-rw-r--r--src/saveload/order_sl.cpp4
-rw-r--r--src/saveload/saveload.cpp18
-rw-r--r--src/saveload/vehicle_sl.cpp2
-rw-r--r--src/ship_cmd.cpp20
-rw-r--r--src/ship_gui.cpp2
-rw-r--r--src/signs_base.h4
-rw-r--r--src/signs_cmd.cpp6
-rw-r--r--src/station_base.h6
-rw-r--r--src/station_cmd.cpp16
-rw-r--r--src/station_gui.cpp22
-rw-r--r--src/station_map.h2
-rw-r--r--src/statusbar_gui.cpp2
-rw-r--r--src/strings.cpp20
-rw-r--r--src/subsidy_gui.cpp14
-rw-r--r--src/timetable_cmd.cpp6
-rw-r--r--src/timetable_gui.cpp4
-rw-r--r--src/toolbar_gui.cpp4
-rw-r--r--src/town.h6
-rw-r--r--src/town_cmd.cpp10
-rw-r--r--src/town_gui.cpp4
-rw-r--r--src/town_map.h2
-rw-r--r--src/train_cmd.cpp44
-rw-r--r--src/train_gui.cpp6
-rw-r--r--src/tunnelbridge_cmd.cpp2
-rw-r--r--src/unmovable_cmd.cpp8
-rw-r--r--src/vehicle.cpp40
-rw-r--r--src/vehicle_base.h4
-rw-r--r--src/vehicle_cmd.cpp12
-rw-r--r--src/vehicle_gui.cpp30
-rw-r--r--src/vehiclelist.cpp2
-rw-r--r--src/viewport.cpp4
-rw-r--r--src/waypoint.cpp2
-rw-r--r--src/waypoint.h6
-rw-r--r--src/waypoint_cmd.cpp4
-rw-r--r--src/waypoint_gui.cpp2
-rw-r--r--src/window.cpp2
-rw-r--r--src/yapf/yapf_destrail.hpp2
116 files changed, 645 insertions, 637 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index ea2531b1b..625c707a9 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -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, uint32 p1, uint32 p2)
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, uint32 p1, uint32 p2)
{
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, uint32 p1, uint32 p2)
/* 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()
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index d7fd0e306..ac8401dff 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -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());
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index 0ad34836b..89f8ab98b 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -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;
}
/*
diff --git a/src/ai/api/ai_airport.cpp b/src/ai/api/ai_airport.cpp
index 819880f97..1a5ea04ee 100644
--- a/src/ai/api/ai_airport.cpp
+++ b/src/ai/api/ai_airport.cpp
@@ -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;
}
diff --git a/src/ai/api/ai_cargolist.cpp b/src/ai/api/ai_cargolist.cpp
index fe92a3886..d35e54e30 100644
--- a/src/ai/api/ai_cargolist.cpp
+++ b/src/ai/api/ai_cargolist.cpp
@@ -22,7 +22,7 @@ AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(IndustryID industry
{
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::AICargoList_IndustryProducing(IndustryID industry
{
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) {
diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp
index 89ad2d728..075ef6b51 100644
--- a/src/ai/api/ai_company.cpp
+++ b/src/ai/api/ai_company.cpp
@@ -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;
}
diff --git a/src/ai/api/ai_controller.cpp b/src/ai/api/ai_controller.cpp
index f9ef2ab16..24510b7e7 100644
--- a/src/ai/api/ai_controller.cpp
+++ b/src/ai/api/ai_controller.cpp
@@ -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)
diff --git a/src/ai/api/ai_engine.cpp b/src/ai/api/ai_engine.cpp
index 669c44ec5..5e0ac5b4a 100644
--- a/src/ai/api/ai_engine.cpp
+++ b/src/ai/api/ai_engine.cpp
@@ -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;
diff --git a/src/ai/api/ai_event_types.cpp b/src/ai/api/ai_event_types.cpp
index bf6bfeb88..80607220d 100644
--- a/src/ai/api/ai_event_types.cpp
+++ b/src/ai/api/ai_event_types.cpp
@@ -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;
diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp
index 71df52a43..165b1028e 100644
--- a/src/ai/api/ai_group.cpp
+++ b/src/ai/api/ai_group.cpp
@@ -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)
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index 7c0753502..3a1acb213 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -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;
}
diff --git a/src/ai/api/ai_order.cpp b/src/ai/api/ai_order.cpp
index cdff05c06..22b86f683 100644
--- a/src/ai/api/ai_order.cpp
+++ b/src/ai/api/ai_order.cpp
@@ -43,7 +43,7 @@ static OrderType GetOrderTypeByTile(TileIndex t)
/* 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(TileIndex t)
*/
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
{
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(VehicleID vehicle_id, AIOrder::OrderPosition or
/* 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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
}
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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(VehicleID vehicle_id, AIOrder::OrderPosition or
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 _DoCommandReturnSetOrderFlags(class AIInstance *instance)
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);
diff --git a/src/ai/api/ai_sign.cpp b/src/ai/api/ai_sign.cpp
index 3f397a4f0..72e34d333 100644
--- a/src/ai/api/ai_sign.cpp
+++ b/src/ai/api/ai_sign.cpp
@@ -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);
}
diff --git a/src/ai/api/ai_station.cpp b/src/ai/api/ai_station.cpp
index 364b09538..7a9f5cb8d 100644
--- a/src/ai/api/ai_station.cpp
+++ b/src/ai/api/ai_station.cpp
@@ -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;
}
diff --git a/src/ai/api/ai_stationlist.cpp b/src/ai/api/ai_stationlist.cpp
index f392513e7..5e7e82f52 100644
--- a/src/ai/api/ai_stationlist.cpp
+++ b/src/ai/api/ai_stationlist.cpp
@@ -20,7 +20,7 @@ AIStationList_Vehicle::AIStationList_Vehicle(VehicleID vehicle_id)
{
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());
diff --git a/src/ai/api/ai_subsidy.cpp b/src/ai/api/ai_subsidy.cpp
index d4a8b7e0f..4ffdbac2a 100644
--- a/src/ai/api/ai_subsidy.cpp
+++ b/src/ai/api/ai_subsidy.cpp
@@ -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)
diff --git a/src/ai/api/ai_tilelist.cpp b/src/ai/api/ai_tilelist.cpp
index d2fa8c468..31ea81861 100644
--- a/src/ai/api/ai_tilelist.cpp
+++ b/src/ai/api/ai_tilelist.cpp
@@ -72,7 +72,7 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
{
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_IndustryProducing(IndustryID industry_i
{
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_StationType(StationID station_id, AIStation::
{
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
diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp
index f7584c979..a37d065e5 100644
--- a/src/ai/api/ai_town.cpp
+++ b/src/ai/api/ai_town.cpp
@@ -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);
}
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index 130ebe05e..b61519915 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -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;
}
diff --git a/src/ai/api/ai_vehiclelist.cpp b/src/ai/api/ai_vehiclelist.cpp
index c7daff5c5..52ca83dae 100644
--- a/src/ai/api/ai_vehiclelist.cpp
+++ b/src/ai/api/ai_vehiclelist.cpp
@@ -40,7 +40,7 @@ AIVehicleList_SharedOrders::AIVehicleList_SharedOrders(VehicleID vehicle_id)
{
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);
}
}
diff --git a/src/ai/api/ai_waypoint.cpp b/src/ai/api/ai_waypoint.cpp
index 3836978df..ec6af36eb 100644
--- a/src/ai/api/ai_waypoint.cpp
+++ b/src/ai/api/ai_waypoint.cpp
@@ -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;
}
diff --git a/src/ai/api/ai_waypointlist.cpp b/src/ai/api/ai_waypointlist.cpp
index 2b25157a4..c2d87e6b7 100644
--- a/src/ai/api/ai_waypointlist.cpp
+++ b/src/ai/api/ai_waypointlist.cpp
@@ -21,7 +21,7 @@ AIWaypointList_Vehicle::AIWaypointList_Vehicle(VehicleID vehicle_id)
{
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());
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index e195eea11..2c2fac150 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -136,7 +136,7 @@ static bool HaveHangarInOrderList(Vehicle *v)
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 direction) const
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 engine)
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 tile, DoCommandFlag flags, uint32 p1, uin
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 tile, DoCommandFlag flags, uint32 p1, uin
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 tile, DoCommandFlag flags, uint32 p1, uint
{
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(TileIndex *location, DestinationID *destination,
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(TileIndex tile, DoCommandFlag flags, uint32
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 tile, DoCommandFlag flags, uint32 p1, uin
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(Vehicle *v)
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 Vehicle *v, const AirportFTAClass *apc)
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 *v)
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(Vehicle *v)
{
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 CheckSendAircraftToHangarForReplacement(const Vehicle *v)
}
}
- 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_AtTerminal(Vehicle *v, const AirportFTAClass *a
/* 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_AtTerminal(Vehicle *v, const AirportFTAClass *a
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_HeliTakeOff(Vehicle *v, const AirportFTAClass *
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 Vehicle *v, const AirportFTAClass *apc)
{
/* 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(Vehicle *v)
/* 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, const AirportFTA *current_pos, const Air
/* 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, const AirportFTA *current_pos, const Ai
* 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, const AirportFTA *current_pos, const Ai
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(Vehicle *v, const AirportFTAClass *apc)
* 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(Vehicle *v, const AirportFTAClass *apc)
/* 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 Vehicle *v)
if (!IsValidStationID(sid)) return NULL;
- Station *st = GetStation(sid);
+ Station *st = Station::Get(sid);
return st->airport_tile == INVALID_TILE ? NULL : st;
}
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 5cbe97773..e588ecf9c 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -86,7 +86,7 @@ void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection)
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;
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index 44c8656f1..a271ee7ce 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -48,7 +48,7 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
*/
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(EngineID engine)
{
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 IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *carg
*/
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, VehicleType type)
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();
diff --git a/src/autoreplace.cpp b/src/autoreplace.cpp
index fe9359c01..fb206cfaa 100644
--- a/src/autoreplace.cpp
+++ b/src/autoreplace.cpp
@@ -40,7 +40,7 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
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);
}
diff --git a/src/autoreplace_base.h b/src/autoreplace_base.h
index ca5533e47..2c704b70a 100644
--- a/src/autoreplace_base.h
+++ b/src/autoreplace_base.h
@@ -34,7 +34,7 @@ struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
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 */
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 1453a2a9a..acfd985ec 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -47,7 +47,7 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
/* 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 BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
*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 BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
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(TileIndex tile, DoCommandFlag flags, uint32 p1
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(TileIndex tile, DoCommandFlag flags, uint32 p1
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 */
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 92f48960d..2e8438ecf 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -69,14 +69,14 @@ static int CDECL EngineNumberSorter(const void *a, const void *b)
*/
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 Window {
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
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index 962751635..955f5f3ad 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -114,8 +114,8 @@ static int CDECL EngineNumberSorter(const void *a, const void *b)
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 void *a, const void *b)
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(const void *a, const void *b)
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 void *a, const void *b)
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 void *a, const void *b)
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 void *a, const void *b)
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(const void *a, const void *b)
/* 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 RoadVehEngineCapacitySorter(const void *a, const void *b)
/* 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 ShipEngineCapacitySorter(const void *a, const void *b)
/* 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 left, int right, int y, EngineID engine, Ve
/* 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 left, int right, int y, EngineID engine
/* 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(int left, int right, int y, EngineID engin
/* 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 left, int right, int y, EngineID engine_n
/* 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, int right, int y, EngineID engine_numb
/* 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 left, int right, int y, EngineID engine_
*/
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);
diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp
index f94363fd9..cd5524c57 100644
--- a/src/cargopacket.cpp
+++ b/src/cargopacket.cpp
@@ -21,7 +21,7 @@ CargoPacket::CargoPacket(StationID source, uint16 count)
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;
diff --git a/src/cargopacket.h b/src/cargopacket.h
index 12014d3fd..68efb8557 100644
--- a/src/cargopacket.h
+++ b/src/cargopacket.h
@@ -63,7 +63,7 @@ struct CargoPacket : PoolItem<CargoPacket, CargoPacketID, &_CargoPacket_pool> {
* @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
diff --git a/src/command.cpp b/src/command.cpp
index b59023fa6..49804f4b4 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -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 p1, uint32 p2, uint32 cmd, CommandCallbac
/* 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
diff --git a/src/company_base.h b/src/company_base.h
index 02efa3ddb..e1ab9c9ca 100644
--- a/src/company_base.h
+++ b/src/company_base.h
@@ -87,10 +87,10 @@ struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
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()
diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp
index 0fab4b840..6e75e5428 100644
--- a/src/company_cmd.cpp
+++ b/src/company_cmd.cpp
@@ -77,7 +77,7 @@ void SetLocalCompany(CompanyID new_company)
/* 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_company)
bool IsHumanCompany(CompanyID company)
{
- return !GetCompany(company)->is_ai;
+ return !Company::Get(company)->is_ai;
}
@@ -151,7 +151,7 @@ bool CheckCompanyHasMoney(CommandCost cost)
{
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(CommandCost cost)
{
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 tile, DoCommandFlag flags, uint32 p1, ui
{
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
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;
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 3f977333c..630223432 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -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();
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index 771ee62f1..48f5d4a2c 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -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.");
diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp
index b64d5b9d6..6e9cb0a94 100644
--- a/src/core/random_func.cpp
+++ b/src/core/random_func.cpp
@@ -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);
}
diff --git a/src/date.cpp b/src/date.cpp
index 7b442b04b..129460795 100644
--- a/src/date.cpp
+++ b/src/date.cpp
@@ -188,7 +188,7 @@ static void RunVehicleDayProc(uint daytick)
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 */
diff --git a/src/depot_base.h b/src/depot_base.h
index 53877485d..9bd5908e1 100644
--- a/src/depot_base.h
+++ b/src/depot_base.h
@@ -24,12 +24,12 @@ struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
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 */
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index d47265987..002c4b063 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -139,14 +139,14 @@ void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
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();
diff --git a/src/disaster_cmd.cpp b/src/disaster_cmd.cpp
index 6c0f61128..bf3ad6b3b 100644
--- a/src/disaster_cmd.cpp
+++ b/src/disaster_cmd.cpp
@@ -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(Vehicle *v, uint16 image_override, bool leave_
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(Vehicle *v, uint16 image_override, bool leave_
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(Vehicle *v, uint16 image_override, bool leave_
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_Destroyer(Vehicle *v)
}
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)
diff --git a/src/economy.cpp b/src/economy.cpp
index 997e4ca8e..cc69b8569 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -294,7 +294,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_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 old_owner, Owner new_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 old_owner, Owner new_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 old_owner, Owner new_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 old_owner, Owner new_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 Subsidy *s, bool mode)
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 *from, Station *to, CargoID cargo_type)
/* 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 *from, Station *to, CargoID cargo_type)
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, CargoID cargo_type, StationID source,
/* 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, int *cargo_left)
}
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
* 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(TileIndex tile, DoCommandFlag flags, uint32 p1
* 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, DoCommandFlag flags, uint32 p1, uint32
/* 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;
diff --git a/src/engine.cpp b/src/engine.cpp
index f194a949b..aa7e29c32 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -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 engine);
/* 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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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 tile, DoCommandFlag flags, uint32 p1, uint
}
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, VehicleType type, CompanyID company)
/* 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, VehicleType type, CompanyID company)
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;
diff --git a/src/engine_base.h b/src/engine_base.h
index 3e81ce9aa..8974f09f8 100644
--- a/src/engine_base.h
+++ b/src/engine_base.h
@@ -87,34 +87,34 @@ static inline bool IsEngineIndex(uint index)
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 */
diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp
index e87643dc5..411c6e34f 100644
--- a/src/engine_gui.cpp
+++ b/src/engine_gui.cpp
@@ -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(EngineID engine, VehicleType type)
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 engine, int left, int right, int top, i
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(EngineID engine, int left, int right, int top
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(EngineID engine, int left, int right, int top,
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 engine, int left, int right, int top, in
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);
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 8ce2b4ade..df4c5f85c 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -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);
diff --git a/src/group.h b/src/group.h
index 9c4d7ffec..618d1407f 100644
--- a/src/group.h
+++ b/src/group.h
@@ -32,7 +32,7 @@ struct Group : PoolItem<Group, GroupID, &_Group_pool> {
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 id_g)
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 company, GroupID id_g, EngineID id_e);
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--;
}
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index 6b3242cfa..6834596fb 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -32,10 +32,10 @@ static inline void UpdateNumEngineGroup(EngineID i, GroupID old_g, GroupID new_g
{
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 tile, DoCommandFlag flags, uint32 p1, uint3
{
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
{
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 tile, DoCommandFlag flags, uint32 p1, u
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(TileIndex tile, DoCommandFlag flags, uint3
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(TileIndex tile, DoCommandFlag flags, ui
{
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;
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index ac9dfefdd..cf6ece60c 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -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);
}
diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp
index cfe81ce15..2b0917b6f 100644
--- a/src/highscore_gui.cpp
+++ b/src/highscore_gui.cpp
@@ -59,7 +59,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
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 : EndGameHighScoreBaseWindow {
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 : EndGameHighScoreBaseWindow {
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/
diff --git a/src/industry.h b/src/industry.h
index 2f21197d3..d06764429 100644
--- a/src/industry.h
+++ b/src/industry.h
@@ -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 *GetRandomIndustry()
}
}
- 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;
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 61486e193..6d8435005 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1624,7 +1624,7 @@ static Industry *CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCo
/* 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 */
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 194770d76..3c51b996a 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -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);
diff --git a/src/industry_map.h b/src/industry_map.h
index abfbfdf4a..4d46e9c97 100644
--- a/src/industry_map.h
+++ b/src/industry_map.h
@@ -70,7 +70,7 @@ static inline IndustryID GetIndustryIndex(TileIndex t)
*/
static inline Industry *GetIndustryByTile(TileIndex t)
{
- return GetIndustry(GetIndustryIndex(t));
+ return Industry::Get(GetIndustryIndex(t));
}
/**
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 0b1c1cc73..c6cfb1262 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -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
diff --git a/src/misc_cmd.cpp b/src/misc_cmd.cpp
index 4df2ec41f..907d6724c 100644
--- a/src/misc_cmd.cpp
+++ b/src/misc_cmd.cpp
@@ -35,7 +35,7 @@ CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
*/
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 tile, DoCommandFlag flags, uint32 p1, uint
*/
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 tile, DoCommandFlag flags, uint32 p1, uin
}
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 tile, DoCommandFlag flags, uint32 p1, u
}
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, DoCommandFlag flags, uint32 p1, uint32
{
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 */
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 7ba8c1c77..2d0ef8931 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -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);
}
diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h
index 3acd61310..e1224c5e2 100644
--- a/src/network/core/tcp_game.h
+++ b/src/network/core/tcp_game.h
@@ -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 */
diff --git a/src/network/network.cpp b/src/network/network.cpp
index a98ff2f12..95ff34dcc 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -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;
}
diff --git a/src/network/network_base.h b/src/network/network_base.h
index 191b6be40..3892db7d3 100644
--- a/src/network/network_base.h
+++ b/src/network/network_base.h
@@ -29,10 +29,10 @@ struct NetworkClientInfo : PoolItem<NetworkClientInfo, ClientIndex, &_NetworkCli
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 */
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index c5ac55961..4a6897bf3 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -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;
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp
index 2b8f44ffc..9b29070a9 100644
--- a/src/network/network_server.cpp
+++ b/src/network/network_server.cpp
@@ -1237,7 +1237,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MOVE)
/* 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)) {
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 08978f011..9ee16ba94 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -354,13 +354,13 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
/* 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;
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 43855a435..383ccc1ef 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -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 engine, CargoID cargo, const SpriteGroup *
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 engine, byte cargo, const SpriteGroup *grou
*/
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 GRFFile *file)
*/
const GRFFile *GetEngineGRF(EngineID engine)
{
- return GetEngine(engine)->grffile;
+ return Engine::Get(engine)->grffile;
}
@@ -479,7 +479,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
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 ResolverObject *object, byte variable, by
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 ResolverObject *object, byte variable, by
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 ResolverObject *object, byte variable, by
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 ResolverObject *object, byte variable, by
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(ResolverObject *res, EngineID engine_type,
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 *GetVehicleSpriteGroup(EngineID engine, const Vehicle *
}
}
- 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 engine, const Vehicle *v, Direction dire
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, VehicleTrigger trigger)
*/
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 */
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 34a6f8975..2cf283574 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -215,7 +215,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
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;
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index 3863af991..d086223cb 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -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) {
diff --git a/src/oldpool.h b/src/oldpool.h
index 9e49e22b3..14e31a1bd 100644
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -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 */
diff --git a/src/openttd.cpp b/src/openttd.cpp
index ad3babbe4..6807a75dd 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -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();
diff --git a/src/order_base.h b/src/order_base.h
index 029413ee0..b743a26fa 100644
--- a/src/order_base.h
+++ b/src/order_base.h
@@ -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 */
diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp
index 8abb51901..e71d3b43b 100644
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -379,8 +379,8 @@ static TileIndex GetOrderLocation(const Order& o)
{
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
} 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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
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, DoCommandFlag flags, uint32 p1, uint32
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 tile, DoCommandFlag flags, uint32 p1, uint3
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 tile, DoCommandFlag flags, uint32 p1, uint3
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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 Order *order, int conditional_depth)
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;
}
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index fd925f838..1f6958471 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -224,7 +224,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
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 Vehicle *v, TileIndex tile)
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;
diff --git a/src/pathfind.h b/src/pathfind.h
index 0a006190f..7785192b2 100644
--- a/src/pathfind.h
+++ b/src/pathfind.h
@@ -88,7 +88,7 @@ void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypes railtypes, DiagD
*/
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;
diff --git a/src/rail.cpp b/src/rail.cpp
index f45bc1424..2d7894e24 100644
--- a/src/rail.cpp
+++ b/src/rail.cpp
@@ -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)
diff --git a/src/road.cpp b/src/road.cpp
index 597098a2e..4634d1a6f 100644
--- a/src/road.cpp
+++ b/src/road.cpp
@@ -85,7 +85,7 @@ bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts)
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;
}
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index f5a03541e..bdaab2281 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -90,7 +90,7 @@ static SpriteID GetRoadVehIcon(EngineID engine)
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 direction) const
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 tile, DoCommandFlag flags, uint32 p1, uint
{
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 tile, DoCommandFlag flags, uint32 p1, uint
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 tile, DoCommandFlag flags, uint32 p1, uint3
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(TileIndex tile, DoCommandFlag flags, uint32 p1
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 tile, DoCommandFlag flags, uint32 p1, uint3
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::GetOrderStationLocation(StationID station)
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 tile, DoCommandFlag flags, uint32 p1, uint
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 tile, DoCommandFlag flags, uint32 p1, uint
* [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 tile, DoCommandFlag flags, uint32 p1, uint
}
}
- if (flags & DC_EXEC) RoadVehUpdateCache(GetVehicle(p1)->First());
+ if (flags & DC_EXEC) RoadVehUpdateCache(Vehicle::Get(p1)->First());
_returned_refit_capacity = total_capacity;
diff --git a/src/roadveh_gui.cpp b/src/roadveh_gui.cpp
index 16dbd22e2..96130851d 100644
--- a/src/roadveh_gui.cpp
+++ b/src/roadveh_gui.cpp
@@ -158,7 +158,7 @@ void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
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);
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index cc982485e..b33b7e14a 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -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);
}
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 812427b2c..b668828c0 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -587,8 +587,8 @@ static bool LoadOldOrder(LoadgameState *ls, int num)
/* 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 *ls, int num)
/* 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 *ls, int num)
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(LoadgameState *ls, int num)
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_chunk[] = {
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_chunk[] = {
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_chunk[] = {
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, int num)
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);
diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp
index dc583a371..c7c66e130 100644
--- a/src/saveload/order_sl.cpp
+++ b/src/saveload/order_sl.cpp
@@ -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;
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index b74c2af40..89731bf9c 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1431,35 +1431,35 @@ static void *IntToReference(uint index, SLRefType rt)
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, SLRefType rt)
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();
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index a05987a27..695b2c831 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -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;
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 3a49d66c7..2948117a7 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -56,7 +56,7 @@ static SpriteID GetShipIcon(EngineID engine)
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 direction) const
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(StationID station)
{
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32 p
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 tile, DoCommandFlag flags, uint32 p1, u
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, DoCommandFlag flags, uint32 p1, uint32
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);
diff --git a/src/ship_gui.cpp b/src/ship_gui.cpp
index cd3703fac..f6ddfa437 100644
--- a/src/ship_gui.cpp
+++ b/src/ship_gui.cpp
@@ -26,7 +26,7 @@ void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
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);
diff --git a/src/signs_base.h b/src/signs_base.h
index 52737a833..cf1f99005 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -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 */
diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp
index 464419e4e..93ef28c1a 100644
--- a/src/signs_cmd.cpp
+++ b/src/signs_cmd.cpp
@@ -73,7 +73,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
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, DoCommandFlag flags, uint32 p1, uint32
}
} 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, DoCommandFlag flags, uint32 p1, uint32
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
if (success) {
- ShowRenameSignWindow(GetSign(_new_sign_id));
+ ShowRenameSignWindow(Sign::Get(_new_sign_id));
ResetObjectToPlace();
}
}
diff --git a/src/station_base.h b/src/station_base.h
index 97477324d..756d4721d 100644
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -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 */
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 1d4d2948f..c26cfacfc 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -100,7 +100,7 @@ static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest
}
}
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(TileIndex tile_org, DoCommandFlag flags, uin
} 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(TileIndex tile_org, DoCommandFlag flags, uin
}
/* 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 tile, DoCommandFlag flags, uint32 p1, uin
}
/* 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 tile, DoCommandFlag flags, uint32 p1, uint
}
/* 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, DoCommandFlag flags, uint32 p1, uint32
}
/* 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 tile, DoCommandFlag flags, uint32 p1, uin
{
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);
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 62d8c54a4..f0abf4626 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -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 tile, void *user_data)
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);
diff --git a/src/station_map.h b/src/station_map.h
index e706dd2a6..06da1588f 100644
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -26,7 +26,7 @@ static inline StationID GetStationIndex(TileIndex t)
static inline Station *GetStationByTile(TileIndex t)
{
- return GetStation(GetStationIndex(t));
+ return Station::Get(GetStationIndex(t));
}
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index b376befff..20dcefb6d 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -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);
diff --git a/src/strings.cpp b/src/strings.cpp
index 85b3b3789..0af358b41 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -665,7 +665,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
}
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, const char *str, const int64 *argv, uint c
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, const char *str, const int64 *argv, uint c
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, const char *str, const int64 *argv, uint c
}
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, const char *str, const int64 *argv, uint c
}
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, const char *str, const int64 *argv, uint c
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, const char *str, const int64 *argv, uint c
}
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, const char *str, const int64 *argv, uint c
}
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, const char *str, const int64 *argv, uint c
}
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, const char *str, const int64 *argv, uint c
}
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);
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 298592522..8d666fca1 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -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 */
diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp
index 4ecfc4947..5f12bb365 100644
--- a/src/timetable_cmd.cpp
+++ b/src/timetable_cmd.cpp
@@ -59,7 +59,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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) {
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 857aa82ad..72d66c1c4 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -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:
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index 07907e0e1..3be67b7d3 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -624,7 +624,7 @@ static void ToolbarZoomOutClick(Window *w)
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 */
diff --git a/src/town.h b/src/town.h
index fe50fd17a..71f65f552 100644
--- a/src/town.h
+++ b/src/town.h
@@ -302,7 +302,7 @@ TileIndexDiff GetHouseNorthPart(HouseID &house);
*/
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;
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index 3e8d1bdfa..e36fd2905 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -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, DoCommandFlag flags, uint32 p1, uint32
}
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, CompanyID cid, const Town *t)
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 tile, DoCommandFlag flags, uint32 p1, uint
{
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, uint threshold)
return NULL;
}
- Town *town = GetTown(tid);
+ Town *town = Town::Get(tid);
assert(town->IsValid());
if (DistanceManhattan(tile, town->xy) >= threshold) town = NULL;
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index dab990824..92147a31b 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -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;
diff --git a/src/town_map.h b/src/town_map.h
index b0653a1cd..e1007a030 100644
--- a/src/town_map.h
+++ b/src/town_map.h
@@ -40,7 +40,7 @@ static inline void SetTownIndex(TileIndex t, TownID index)
*/
static inline Town *GetTownByTile(TileIndex t)
{
- return GetTown(GetTownIndex(t));
+ return Town::Get(GetTownIndex(t));
}
/**
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 4b0a01b9f..0fc2a6ff1 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -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, bool same_length)
}
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 direction) const
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 engine, bool rear_head, int &y)
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, EngineID engine, SpriteID pal)
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(EngineID engine, TileIndex tile, DoCommandF
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
/* 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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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 tile, DoCommandFlag flags, uint32 p1, u
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 tile, DoCommandFlag flags, uint32 p1, u
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 tile, DoCommandFlag flags, uint32 p1, u
/* 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 tile, DoCommandFlag flags, uint32 p1, uin
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(TileIndex tile, DoCommandFlag flags, uint32
{
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
{
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
* 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(TileIndex tile, DoCommandFlag flags, uint32 p1,
_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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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(StationID station)
{
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, StationID station)
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;
}
diff --git a/src/train_gui.cpp b/src/train_gui.cpp
index 898182a8e..7ffeac6aa 100644
--- a/src/train_gui.cpp
+++ b/src/train_gui.cpp
@@ -47,7 +47,7 @@ void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
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 veh_id, byte det_tab)
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 veh_id, byte det_tab)
}
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++;
}
}
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index 6e8b88cbd..ce36289e6 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -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))
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index d700ceb89..c4932d815 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -51,7 +51,7 @@ static inline const UnmovableSpec *GetUnmovableSpec(UnmovableType type)
*/
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(TileIndex tile, uint w, uint h, DoCommandF
*/
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(TileIndex tile, DoCommandFlag flags)
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(TileIndex tile, Owner old_owner, Owner new
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 */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 454a7bb84..8982c23e3 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -62,7 +62,7 @@ bool Vehicle::NeedsAutorenewing(const Company *c) const
* 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() const
*/
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_type)
{
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 Vehicle *v, StringID *colour)
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(VehicleType type)
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 engine_type, CompanyID company, EngineID
* 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 engine_type, CompanyID company, EngineID
/* 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 engine_type, CompanyID company, EngineID
/* 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:
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index 5edb31c9e..a1d451d32 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -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();
}
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp
index 5a4c35c1f..e127b6107 100644
--- a/src/vehicle_cmd.cpp
+++ b/src/vehicle_cmd.cpp
@@ -63,7 +63,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
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 tile, DoCommandFlag flags, uint32 p1, uint
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 tile, DoCommandFlag flags, uint32 p1, uint
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 tile, DoCommandFlag flags, uint32 p1, uint
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 tile, DoCommandFlag flags, uint32 p1, uin
{
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(TileIndex tile, DoCommandFlag flags, uint32 p1,
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;
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index e177de4ef..34737643d 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -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 right, int y, EngineID engine)
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 Vehicle *v, int left, int right, int y)
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 BaseVehicleListWindow {
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 Vehicle *v)
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
diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp
index 6ecdc5964..b72882b73 100644
--- a/src/vehiclelist.cpp
+++ b/src/vehiclelist.cpp
@@ -92,7 +92,7 @@ void GenerateVehicleSortList(VehicleList *list, VehicleType type, Owner owner, u
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;
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 32bea397e..3fac8bda6 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -186,7 +186,7 @@ void InitializeWindowViewport(Window *w, int x, int y,
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;
diff --git a/src/waypoint.cpp b/src/waypoint.cpp
index c39a83273..f35628492 100644
--- a/src/waypoint.cpp
+++ b/src/waypoint.cpp
@@ -56,7 +56,7 @@ Station *ComposeWaypointStation(TileIndex tile)
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;
diff --git a/src/waypoint.h b/src/waypoint.h
index c57e793ed..c33910564 100644
--- a/src/waypoint.h
+++ b/src/waypoint.h
@@ -42,10 +42,10 @@ struct Waypoint : PoolItem<Waypoint, WaypointID, &_Waypoint_pool> {
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(WaypointID index)
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);
diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp
index 8a606b727..a8f50e13e 100644
--- a/src/waypoint_cmd.cpp
+++ b/src/waypoint_cmd.cpp
@@ -71,7 +71,7 @@ static void MakeDefaultWaypointName(Waypoint *wp)
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 tile, DoCommandFlag flags, uint32 p1, ui
{
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);
diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp
index 984b82b64..10f067677 100644
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -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;
diff --git a/src/window.cpp b/src/window.cpp
index daaa18d9b..191fc5b31 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -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;
}
diff --git a/src/yapf/yapf_destrail.hpp b/src/yapf/yapf_destrail.hpp
index 9e19ded1d..7fb41d653 100644
--- a/src/yapf/yapf_destrail.hpp
+++ b/src/yapf/yapf_destrail.hpp
@@ -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);