mirror of https://github.com/OpenTTD/OpenTTD
(svn r16325) -Codechange: replace GetPoolItem(index) by PoolItem::Get(index)
parent
814f153b5a
commit
6221d74644
|
@ -42,7 +42,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
_current_company = company;
|
_current_company = company;
|
||||||
Company *c = GetCompany(company);
|
Company *c = Company::Get(company);
|
||||||
|
|
||||||
c->ai_info = info;
|
c->ai_info = info;
|
||||||
assert(c->ai_instance == NULL);
|
assert(c->ai_instance == NULL);
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
* Effectively collecting garbage once every two months per AI. */
|
* Effectively collecting garbage once every two months per AI. */
|
||||||
if ((AI::frame_counter & 255) == 0) {
|
if ((AI::frame_counter & 255) == 0) {
|
||||||
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
|
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;
|
_current_company = OWNER_NONE;
|
||||||
|
@ -91,7 +91,7 @@
|
||||||
|
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
_current_company = company;
|
_current_company = company;
|
||||||
Company *c = GetCompany(company);
|
Company *c = Company::Get(company);
|
||||||
|
|
||||||
delete c->ai_instance;
|
delete c->ai_instance;
|
||||||
c->ai_instance = NULL;
|
c->ai_instance = NULL;
|
||||||
|
@ -221,18 +221,18 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
AIObject::IncreaseDoCommandCosts(AIObject::GetLastCost());
|
AIObject::IncreaseDoCommandCosts(AIObject::GetLastCost());
|
||||||
}
|
}
|
||||||
|
|
||||||
GetCompany(_current_company)->ai_instance->Continue();
|
Company::Get(_current_company)->ai_instance->Continue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ void AI::Save(CompanyID company)
|
/* static */ void AI::Save(CompanyID company)
|
||||||
{
|
{
|
||||||
if (!_networking || _network_server) {
|
if (!_networking || _network_server) {
|
||||||
assert(IsValidCompanyID(company));
|
assert(IsValidCompanyID(company));
|
||||||
assert(GetCompany(company)->ai_instance != NULL);
|
assert(Company::Get(company)->ai_instance != NULL);
|
||||||
|
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
_current_company = company;
|
_current_company = company;
|
||||||
GetCompany(company)->ai_instance->Save();
|
Company::Get(company)->ai_instance->Save();
|
||||||
_current_company = old_company;
|
_current_company = old_company;
|
||||||
} else {
|
} else {
|
||||||
AIInstance::SaveEmpty();
|
AIInstance::SaveEmpty();
|
||||||
|
@ -243,11 +243,11 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (!_networking || _network_server) {
|
if (!_networking || _network_server) {
|
||||||
assert(IsValidCompanyID(company));
|
assert(IsValidCompanyID(company));
|
||||||
assert(GetCompany(company)->ai_instance != NULL);
|
assert(Company::Get(company)->ai_instance != NULL);
|
||||||
|
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
_current_company = company;
|
_current_company = company;
|
||||||
GetCompany(company)->ai_instance->Load(version);
|
Company::Get(company)->ai_instance->Load(version);
|
||||||
_current_company = old_company;
|
_current_company = old_company;
|
||||||
} else {
|
} else {
|
||||||
/* Read, but ignore, the load data */
|
/* 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)
|
/* 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()
|
/* static */ void AI::Rescan()
|
||||||
|
|
|
@ -641,7 +641,7 @@ struct AIDebugWindow : public Window {
|
||||||
{
|
{
|
||||||
/* Disable the companies who are not active or not an AI */
|
/* Disable the companies who are not active or not an AI */
|
||||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
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);
|
this->DisableWidget(AID_WIDGET_RELOAD_TOGGLE);
|
||||||
|
|
||||||
|
@ -669,7 +669,7 @@ struct AIDebugWindow : public Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
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. */
|
/* Lower the widget corresponding to this company. */
|
||||||
this->LowerWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
|
this->LowerWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
|
||||||
|
|
||||||
|
@ -690,7 +690,7 @@ struct AIDebugWindow : public Window {
|
||||||
|
|
||||||
/* Paint the company icons */
|
/* Paint the company icons */
|
||||||
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
|
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 */
|
/* Check if we have the company as an active company */
|
||||||
if (!this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
|
if (!this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
|
||||||
/* Bah, company gone :( */
|
/* Bah, company gone :( */
|
||||||
|
@ -716,7 +716,7 @@ struct AIDebugWindow : public Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the AI name */
|
/* Draw the AI name */
|
||||||
AIInfo *info = GetCompany(ai_debug_company)->ai_info;
|
AIInfo *info = Company::Get(ai_debug_company)->ai_info;
|
||||||
assert(info != NULL);
|
assert(info != NULL);
|
||||||
char name[1024];
|
char name[1024];
|
||||||
snprintf(name, sizeof(name), "%s (v%d)", info->GetName(), info->GetVersion());
|
snprintf(name, sizeof(name), "%s (v%d)", info->GetName(), info->GetVersion());
|
||||||
|
|
|
@ -103,7 +103,7 @@ AIInstance::AIInstance(AIInfo *info) :
|
||||||
callback(NULL)
|
callback(NULL)
|
||||||
{
|
{
|
||||||
/* Set the instance already, so we can use AIObject::Set commands */
|
/* 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;
|
AIInstance::current_instance = this;
|
||||||
|
|
||||||
this->controller = new AIController();
|
this->controller = new AIController();
|
||||||
|
@ -354,7 +354,7 @@ void AIInstance::CollectGarbage()
|
||||||
/* static */ AIStorage *AIInstance::GetStorage()
|
/* static */ AIStorage *AIInstance::GetStorage()
|
||||||
{
|
{
|
||||||
assert(IsValidCompanyID(_current_company) && !IsHumanCompany(_current_company));
|
assert(IsValidCompanyID(_current_company) && !IsHumanCompany(_current_company));
|
||||||
return GetCompany(_current_company)->ai_instance->storage;
|
return Company::Get(_current_company)->ai_instance->storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
|
|
||||||
if (!AIStation::HasStationType(station_id, AIStation::STATION_AIRPORT)) return AT_INVALID;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ AICargoList_IndustryAccepting::AICargoList_IndustryAccepting(IndustryID industry
|
||||||
{
|
{
|
||||||
if (!AIIndustry::IsValidIndustry(industry_id)) return;
|
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++) {
|
for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
|
||||||
CargoID cargo_id = ind->accepts_cargo[i];
|
CargoID cargo_id = ind->accepts_cargo[i];
|
||||||
if (cargo_id != CT_INVALID) {
|
if (cargo_id != CT_INVALID) {
|
||||||
|
@ -35,7 +35,7 @@ AICargoList_IndustryProducing::AICargoList_IndustryProducing(IndustryID industry
|
||||||
{
|
{
|
||||||
if (!AIIndustry::IsValidIndustry(industry_id)) return;
|
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++) {
|
for (uint i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||||
CargoID cargo_id = ind->produced_cargo[i];
|
CargoID cargo_id = ind->produced_cargo[i];
|
||||||
if (cargo_id != CT_INVALID) {
|
if (cargo_id != CT_INVALID) {
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return -1;
|
if (company == COMPANY_INVALID) return -1;
|
||||||
|
|
||||||
return ::CalculateCompanyValue(::GetCompany((CompanyID)company));
|
return ::CalculateCompanyValue(::Company::Get((CompanyID)company));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money AICompany::GetBankBalance(AICompany::CompanyID company)
|
/* static */ Money AICompany::GetBankBalance(AICompany::CompanyID company)
|
||||||
|
@ -84,12 +84,12 @@
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return -1;
|
if (company == COMPANY_INVALID) return -1;
|
||||||
|
|
||||||
return ::GetCompany((CompanyID)company)->money;
|
return ::Company::Get((CompanyID)company)->money;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money AICompany::GetLoanAmount()
|
/* static */ Money AICompany::GetLoanAmount()
|
||||||
{
|
{
|
||||||
return ::GetCompany(_current_company)->current_loan;
|
return ::Company::Get(_current_company)->current_loan;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money AICompany::GetMaxLoanAmount()
|
/* static */ Money AICompany::GetMaxLoanAmount()
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return INVALID_TILE;
|
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;
|
return (loc == 0) ? INVALID_TILE : loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return false;
|
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)
|
/* static */ bool AICompany::SetAutoRenewMonths(int16 months)
|
||||||
|
@ -169,7 +169,7 @@
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return 0;
|
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)
|
/* static */ bool AICompany::SetAutoRenewMoney(uint32 money)
|
||||||
|
@ -182,5 +182,5 @@
|
||||||
company = ResolveCompanyID(company);
|
company = ResolveCompanyID(company);
|
||||||
if (company == COMPANY_INVALID) return 0;
|
if (company == COMPANY_INVALID) return 0;
|
||||||
|
|
||||||
return ::GetCompany((CompanyID)company)->settings.engine_renew_money;
|
return ::Company::Get((CompanyID)company)->settings.engine_renew_money;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ AIController::~AIController()
|
||||||
|
|
||||||
/* static */ uint AIController::GetTick()
|
/* 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)
|
/* static */ int AIController::GetSetting(const char *name)
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
/* static */ bool AIEngine::IsValidEngine(EngineID engine_id)
|
/* 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)
|
/* static */ char *AIEngine::GetName(EngineID engine_id)
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidEngine(engine_id)) return CT_INVALID;
|
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;
|
if (!e->CanCarryCargo()) return CT_INVALID;
|
||||||
|
|
||||||
return e->GetDefaultCargoType();
|
return e->GetDefaultCargoType();
|
||||||
|
@ -46,8 +46,8 @@
|
||||||
if (!AICargo::IsValidCargo(cargo_id)) return false;
|
if (!AICargo::IsValidCargo(cargo_id)) return false;
|
||||||
|
|
||||||
if (GetCargoType(engine_id) == cargo_id) return true;
|
if (GetCargoType(engine_id) == cargo_id) return true;
|
||||||
if (cargo_id == CT_MAIL && ::GetEngine(engine_id)->type == VEH_AIRCRAFT) return true;
|
if (cargo_id == CT_MAIL && ::Engine::Get(engine_id)->type == VEH_AIRCRAFT) return true;
|
||||||
if (::GetEngine(engine_id)->type == VEH_SHIP && !ShipVehInfo(engine_id)->refittable) return false;
|
if (::Engine::Get(engine_id)->type == VEH_SHIP && !ShipVehInfo(engine_id)->refittable) return false;
|
||||||
return ::CanRefitTo(engine_id, cargo_id);
|
return ::CanRefitTo(engine_id, cargo_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
if (!IsValidEngine(engine_id)) return -1;
|
||||||
|
|
||||||
const Engine *e = ::GetEngine(engine_id);
|
const Engine *e = ::Engine::Get(engine_id);
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN: {
|
||||||
|
@ -91,14 +91,14 @@
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
if (!IsValidEngine(engine_id)) return -1;
|
||||||
if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(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)
|
/* static */ int32 AIEngine::GetMaxSpeed(EngineID engine_id)
|
||||||
{
|
{
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
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
|
int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
|
||||||
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
|
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
|
||||||
return max_speed;
|
return max_speed;
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
if (!IsValidEngine(engine_id)) return -1;
|
||||||
|
|
||||||
return ::GetEngine(engine_id)->GetCost();
|
return ::Engine::Get(engine_id)->GetCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int32 AIEngine::GetMaxAge(EngineID engine_id)
|
/* static */ int32 AIEngine::GetMaxAge(EngineID engine_id)
|
||||||
|
@ -116,14 +116,14 @@
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
if (!IsValidEngine(engine_id)) return -1;
|
||||||
if (GetVehicleType(engine_id) == AIVehicle::VT_RAIL && IsWagon(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)
|
/* static */ Money AIEngine::GetRunningCost(EngineID engine_id)
|
||||||
{
|
{
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
if (!IsValidEngine(engine_id)) return -1;
|
||||||
|
|
||||||
return ::GetEngine(engine_id)->GetRunningCost();
|
return ::Engine::Get(engine_id)->GetRunningCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int32 AIEngine::GetPower(EngineID engine_id)
|
/* static */ int32 AIEngine::GetPower(EngineID engine_id)
|
||||||
|
@ -132,7 +132,7 @@
|
||||||
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
||||||
if (IsWagon(engine_id)) 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)
|
/* static */ int32 AIEngine::GetWeight(EngineID engine_id)
|
||||||
|
@ -140,7 +140,7 @@
|
||||||
if (!IsValidEngine(engine_id)) return -1;
|
if (!IsValidEngine(engine_id)) return -1;
|
||||||
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) 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)
|
/* static */ int32 AIEngine::GetMaxTractiveEffort(EngineID engine_id)
|
||||||
|
@ -149,14 +149,14 @@
|
||||||
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
if (GetVehicleType(engine_id) != AIVehicle::VT_RAIL) return -1;
|
||||||
if (IsWagon(engine_id)) 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)
|
/* static */ AIVehicle::VehicleType AIEngine::GetVehicleType(EngineID engine_id)
|
||||||
{
|
{
|
||||||
if (!IsValidEngine(engine_id)) return AIVehicle::VT_INVALID;
|
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_ROAD: return AIVehicle::VT_ROAD;
|
||||||
case VEH_TRAIN: return AIVehicle::VT_RAIL;
|
case VEH_TRAIN: return AIVehicle::VT_RAIL;
|
||||||
case VEH_SHIP: return AIVehicle::VT_WATER;
|
case VEH_SHIP: return AIVehicle::VT_WATER;
|
||||||
|
|
|
@ -24,14 +24,14 @@ char *AIEventEnginePreview::GetName()
|
||||||
|
|
||||||
CargoID AIEventEnginePreview::GetCargoType()
|
CargoID AIEventEnginePreview::GetCargoType()
|
||||||
{
|
{
|
||||||
const Engine *e = ::GetEngine(engine);
|
const Engine *e = ::Engine::Get(engine);
|
||||||
if (!e->CanCarryCargo()) return CT_INVALID;
|
if (!e->CanCarryCargo()) return CT_INVALID;
|
||||||
return e->GetDefaultCargoType();
|
return e->GetDefaultCargoType();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 AIEventEnginePreview::GetCapacity()
|
int32 AIEventEnginePreview::GetCapacity()
|
||||||
{
|
{
|
||||||
const Engine *e = ::GetEngine(engine);
|
const Engine *e = ::Engine::Get(engine);
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN: {
|
||||||
|
@ -54,7 +54,7 @@ int32 AIEventEnginePreview::GetCapacity()
|
||||||
|
|
||||||
int32 AIEventEnginePreview::GetMaxSpeed()
|
int32 AIEventEnginePreview::GetMaxSpeed()
|
||||||
{
|
{
|
||||||
const Engine *e = ::GetEngine(engine);
|
const Engine *e = ::Engine::Get(engine);
|
||||||
int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
|
int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h
|
||||||
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
|
if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed;
|
||||||
return max_speed;
|
return max_speed;
|
||||||
|
@ -62,17 +62,17 @@ int32 AIEventEnginePreview::GetMaxSpeed()
|
||||||
|
|
||||||
Money AIEventEnginePreview::GetPrice()
|
Money AIEventEnginePreview::GetPrice()
|
||||||
{
|
{
|
||||||
return ::GetEngine(engine)->GetCost();
|
return ::Engine::Get(engine)->GetCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
Money AIEventEnginePreview::GetRunningCost()
|
Money AIEventEnginePreview::GetRunningCost()
|
||||||
{
|
{
|
||||||
return ::GetEngine(engine)->GetRunningCost();
|
return ::Engine::Get(engine)->GetRunningCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 AIEventEnginePreview::GetVehicleType()
|
int32 AIEventEnginePreview::GetVehicleType()
|
||||||
{
|
{
|
||||||
switch (::GetEngine(engine)->type) {
|
switch (::Engine::Get(engine)->type) {
|
||||||
case VEH_ROAD: return AIVehicle::VT_ROAD;
|
case VEH_ROAD: return AIVehicle::VT_ROAD;
|
||||||
case VEH_TRAIN: return AIVehicle::VT_RAIL;
|
case VEH_TRAIN: return AIVehicle::VT_RAIL;
|
||||||
case VEH_SHIP: return AIVehicle::VT_WATER;
|
case VEH_SHIP: return AIVehicle::VT_WATER;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
/* static */ bool AIGroup::IsValidGroup(GroupID group_id)
|
/* 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)
|
/* static */ AIGroup::GroupID AIGroup::CreateGroup(AIVehicle::VehicleType vehicle_type)
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidGroup(group_id)) return AIVehicle::VT_INVALID;
|
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)
|
/* static */ bool AIGroup::SetName(GroupID group_id, const char *name)
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidGroup(group_id)) return false;
|
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)
|
/* static */ int32 AIGroup::GetNumEngines(GroupID group_id, EngineID engine_id)
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
|
|
||||||
/* static */ bool AIGroup::HasWagonRemoval()
|
/* 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)
|
/* 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;
|
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)
|
/* static */ bool AIGroup::StopAutoReplace(GroupID group_id, EngineID engine_id)
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
if (!IsValidIndustry(industry_id)) return false;
|
if (!IsValidIndustry(industry_id)) return false;
|
||||||
if (!AICargo::IsValidCargo(cargo_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++) {
|
for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
|
||||||
if (i->accepts_cargo[j] == cargo_id) return true;
|
if (i->accepts_cargo[j] == cargo_id) return true;
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
if (!IsValidIndustry(industry_id)) return -1;
|
if (!IsValidIndustry(industry_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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++) {
|
for (uint i = 0; i < lengthof(ind->accepts_cargo); i++) {
|
||||||
CargoID cid = ind->accepts_cargo[i];
|
CargoID cid = ind->accepts_cargo[i];
|
||||||
if (cid == cargo_id) {
|
if (cid == cargo_id) {
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
if (!IsValidIndustry(industry_id)) return -1;
|
if (!IsValidIndustry(industry_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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++) {
|
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||||
if (i->produced_cargo[j] == cargo_id) return i->last_month_production[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 (!IsValidIndustry(industry_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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++) {
|
for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
|
||||||
if (i->produced_cargo[j] == cargo_id) return i->last_month_transported[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;
|
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)
|
/* static */ int32 AIIndustry::GetAmountOfStationsAround(IndustryID industry_id)
|
||||||
{
|
{
|
||||||
if (!IsValidIndustry(industry_id)) return -1;
|
if (!IsValidIndustry(industry_id)) return -1;
|
||||||
|
|
||||||
Industry *ind = ::GetIndustry(industry_id);
|
Industry *ind = ::Industry::Get(industry_id);
|
||||||
StationList stations;
|
StationList stations;
|
||||||
::FindStationsAroundTiles(ind->xy, ind->width, ind->height, &stations);
|
::FindStationsAroundTiles(ind->xy, ind->width, ind->height, &stations);
|
||||||
return (int32)stations.Length();
|
return (int32)stations.Length();
|
||||||
|
@ -126,14 +126,14 @@
|
||||||
{
|
{
|
||||||
if (!IsValidIndustry(industry_id)) return false;
|
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)
|
/* static */ bool AIIndustry::HasHeliport(IndustryID industry_id)
|
||||||
{
|
{
|
||||||
if (!IsValidIndustry(industry_id)) return false;
|
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)
|
/* static */ TileIndex AIIndustry::GetHeliportLocation(IndustryID industry_id)
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
if (!IsValidIndustry(industry_id)) return INVALID_TILE;
|
if (!IsValidIndustry(industry_id)) return INVALID_TILE;
|
||||||
if (!HasHeliport(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);
|
BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
|
||||||
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
|
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
|
||||||
return tile_cur;
|
return tile_cur;
|
||||||
|
@ -155,7 +155,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidIndustry(industry_id)) return false;
|
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)
|
/* static */ TileIndex AIIndustry::GetDockLocation(IndustryID industry_id)
|
||||||
|
@ -163,7 +163,7 @@
|
||||||
if (!IsValidIndustry(industry_id)) return INVALID_TILE;
|
if (!IsValidIndustry(industry_id)) return INVALID_TILE;
|
||||||
if (!HasDock(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);
|
BEGIN_TILE_LOOP(tile_cur, ind->width, ind->height, ind->xy);
|
||||||
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
|
if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
|
||||||
return tile_cur;
|
return tile_cur;
|
||||||
|
@ -177,5 +177,5 @@
|
||||||
{
|
{
|
||||||
if (!IsValidIndustry(industry_id)) return INVALID_INDUSTRYTYPE;
|
if (!IsValidIndustry(industry_id)) return INVALID_INDUSTRYTYPE;
|
||||||
|
|
||||||
return ::GetIndustry(industry_id)->type;
|
return ::Industry::Get(industry_id)->type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ static OrderType GetOrderTypeByTile(TileIndex t)
|
||||||
|
|
||||||
/* static */ bool AIOrder::IsValidVehicleOrder(VehicleID vehicle_id, OrderPosition order_position)
|
/* 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)
|
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) {
|
if (order_position == AIOrder::ORDER_CURRENT) {
|
||||||
const Order *order = &v->current_order;
|
const Order *order = &v->current_order;
|
||||||
if (order->GetType() == OT_GOTO_DEPOT && !(order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) return 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 (order_position == ORDER_CURRENT) return false;
|
||||||
if (!IsValidVehicleOrder(vehicle_id, order_position)) 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;
|
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 (AIVehicle::IsValidVehicle(vehicle_id)) return false;
|
||||||
if (GetOrderCount(vehicle_id) == 0) 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;
|
if (order->GetType() != OT_GOTO_DEPOT) return true;
|
||||||
return (order->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0;
|
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 (!AIVehicle::IsValidVehicle(vehicle_id)) return ORDER_INVALID;
|
||||||
|
|
||||||
if (order_position == ORDER_CURRENT) return (AIOrder::OrderPosition)::GetVehicle(vehicle_id)->cur_order_index;
|
if (order_position == ORDER_CURRENT) return (AIOrder::OrderPosition)::Vehicle::Get(vehicle_id)->cur_order_index;
|
||||||
return (order_position >= 0 && order_position < ::GetVehicle(vehicle_id)->GetNumOrders()) ? order_position : ORDER_INVALID;
|
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)
|
/* 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)
|
/* 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);
|
const Order *order = ::ResolveOrder(vehicle_id, order_position);
|
||||||
if (order == NULL || order->GetType() == OT_CONDITIONAL) return INVALID_TILE;
|
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()) {
|
switch (order->GetType()) {
|
||||||
case OT_GOTO_DEPOT: {
|
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 */
|
/* 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();
|
const AirportFTAClass *airport = st->Airport();
|
||||||
if (airport == NULL || airport->nof_depots == 0) return INVALID_TILE;
|
if (airport == NULL || airport->nof_depots == 0) return INVALID_TILE;
|
||||||
return st->airport_tile + ::ToTileIndexDiff(st->Airport()->airport_depots[0]);
|
return st->airport_tile + ::ToTileIndexDiff(st->Airport()->airport_depots[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
case OT_GOTO_STATION: {
|
case OT_GOTO_STATION: {
|
||||||
const Station *st = ::GetStation(order->GetDestination());
|
const Station *st = ::Station::Get(order->GetDestination());
|
||||||
if (st->train_tile != INVALID_TILE) {
|
if (st->train_tile != INVALID_TILE) {
|
||||||
for (uint i = 0; i < st->trainst_w; i++) {
|
for (uint i = 0; i < st->trainst_w; i++) {
|
||||||
TileIndex t = st->train_tile + TileDiffXY(i, 0);
|
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;
|
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;
|
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 (!IsValidVehicleOrder(vehicle_id, order_position)) return ORDER_INVALID;
|
||||||
if (order_position == ORDER_CURRENT || !IsConditionalOrder(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();
|
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 (!IsValidVehicleOrder(vehicle_id, order_position)) return OC_INVALID;
|
||||||
if (order_position == ORDER_CURRENT || !IsConditionalOrder(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();
|
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 (!IsValidVehicleOrder(vehicle_id, order_position)) return CF_INVALID;
|
||||||
if (order_position == ORDER_CURRENT || !IsConditionalOrder(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();
|
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 (!IsValidVehicleOrder(vehicle_id, order_position)) return -1;
|
||||||
if (order_position == ORDER_CURRENT || !IsConditionalOrder(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();
|
int32 value = order->GetConditionValue();
|
||||||
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = value * 16 / 10;
|
if (order->GetConditionVariable() == OCV_MAX_SPEED) value = value * 16 / 10;
|
||||||
return value;
|
return value;
|
||||||
|
@ -311,7 +311,7 @@ static const Order *ResolveOrder(VehicleID vehicle_id, AIOrder::OrderPosition or
|
||||||
EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
|
EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
|
||||||
EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
|
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)
|
/* 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, AIVehicle::IsValidVehicle(vehicle_id));
|
||||||
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, jump_to));
|
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)
|
/* 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);
|
if (order_position == ORDER_CURRENT) order_position = AIOrder::ResolveOrderPosition(vehicle_id, order_position);
|
||||||
|
|
||||||
EnforcePrecondition(false, AIVehicle::IsValidVehicle(vehicle_id));
|
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));
|
EnforcePrecondition(false, AreOrderFlagsValid(destination, order_flags));
|
||||||
|
|
||||||
Order order;
|
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);
|
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
|
/* Check explicitly if the order is to a station (for aircraft) or
|
||||||
* to a depot (other vehicle types). */
|
* 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;
|
if (!::IsTileType(destination, MP_STATION)) return false;
|
||||||
order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf);
|
order.MakeGoToDepot(::GetStationIndex(destination), odtf, onsf, odaf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -432,7 +432,7 @@ static void _DoCommandReturnSetOrderFlags(class AIInstance *instance)
|
||||||
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position));
|
EnforcePrecondition(false, IsValidVehicleOrder(vehicle_id, order_position));
|
||||||
EnforcePrecondition(false, AreOrderFlagsValid(GetOrderDestination(vehicle_id, order_position), order_flags));
|
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);
|
AIOrderFlags current = GetOrderFlags(vehicle_id, order_position);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
/* static */ bool AISign::IsValidSign(SignID sign_id)
|
/* 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)
|
/* static */ bool AISign::SetName(SignID sign_id, const char *name)
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidSign(sign_id)) return INVALID_TILE;
|
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);
|
return ::TileVirtXY(sign->x, sign->y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/* static */ bool AIStation::IsValidStation(StationID station_id)
|
/* 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)
|
/* static */ StationID AIStation::GetStationID(TileIndex tile)
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
static const int len = 64;
|
static const int len = 64;
|
||||||
char *station_name = MallocT<char>(len);
|
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]);
|
::GetString(station_name, STR_STATION, &station_name[len - 1]);
|
||||||
return station_name;
|
return station_name;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidStation(station_id)) return INVALID_TILE;
|
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)
|
/* static */ int32 AIStation::GetCargoWaiting(StationID station_id, CargoID cargo_id)
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
if (!IsValidStation(station_id)) return -1;
|
if (!IsValidStation(station_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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)
|
/* static */ int32 AIStation::GetCargoRating(StationID station_id, CargoID cargo_id)
|
||||||
|
@ -67,7 +67,7 @@
|
||||||
if (!IsValidStation(station_id)) return -1;
|
if (!IsValidStation(station_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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)
|
/* static */ int32 AIStation::GetCoverageRadius(AIStation::StationType station_type)
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
if (!IsValidStation(station_id)) return false;
|
if (!IsValidStation(station_id)) return false;
|
||||||
if (CountBits(station_type) != 1) 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)
|
/* static */ bool AIStation::HasRoadType(StationID station_id, AIRoad::RoadType road_type)
|
||||||
|
@ -124,10 +124,10 @@
|
||||||
|
|
||||||
::RoadTypes r = RoadTypeToRoadTypes((::RoadType)road_type);
|
::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;
|
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;
|
if ((::GetRoadTypes(rs->xy) & r) != 0) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,5 +138,5 @@
|
||||||
{
|
{
|
||||||
if (!IsValidStation(station_id)) return INVALID_TOWN;
|
if (!IsValidStation(station_id)) return INVALID_TOWN;
|
||||||
|
|
||||||
return ::GetStation(station_id)->town->index;
|
return ::Station::Get(station_id)->town->index;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ AIStationList_Vehicle::AIStationList_Vehicle(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
|
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) {
|
for (Order *o = v->GetFirstOrder(); o != NULL; o = o->next) {
|
||||||
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination());
|
if (o->IsType(OT_GOTO_STATION)) this->AddItem(o->GetDestination());
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
{
|
{
|
||||||
if (!IsAwarded(subsidy_id)) return AICompany::COMPANY_INVALID;
|
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)
|
/* static */ int32 AISubsidy::GetExpireDate(SubsidyID subsidy_id)
|
||||||
|
|
|
@ -72,7 +72,7 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
|
||||||
{
|
{
|
||||||
if (!AIIndustry::IsValidIndustry(industry_id)) return;
|
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 */
|
/* Check if this industry accepts anything */
|
||||||
{
|
{
|
||||||
|
@ -110,7 +110,7 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
|
||||||
{
|
{
|
||||||
if (!AIIndustry::IsValidIndustry(industry_id)) return;
|
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 */
|
/* Check if this industry produces anything */
|
||||||
{
|
{
|
||||||
|
@ -148,7 +148,7 @@ AITileList_StationType::AITileList_StationType(StationID station_id, AIStation::
|
||||||
{
|
{
|
||||||
if (!AIStation::IsValidStation(station_id)) return;
|
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;
|
uint station_type_value = 0;
|
||||||
/* Convert AIStation::StationType to ::StationType, but do it in a
|
/* Convert AIStation::StationType to ::StationType, but do it in a
|
||||||
|
|
|
@ -39,21 +39,21 @@
|
||||||
/* static */ int32 AITown::GetPopulation(TownID town_id)
|
/* static */ int32 AITown::GetPopulation(TownID town_id)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return -1;
|
if (!IsValidTown(town_id)) return -1;
|
||||||
const Town *t = ::GetTown(town_id);
|
const Town *t = ::Town::Get(town_id);
|
||||||
return t->population;
|
return t->population;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ int32 AITown::GetHouseCount(TownID town_id)
|
/* static */ int32 AITown::GetHouseCount(TownID town_id)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return -1;
|
if (!IsValidTown(town_id)) return -1;
|
||||||
const Town *t = ::GetTown(town_id);
|
const Town *t = ::Town::Get(town_id);
|
||||||
return t->num_houses;
|
return t->num_houses;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ TileIndex AITown::GetLocation(TownID town_id)
|
/* static */ TileIndex AITown::GetLocation(TownID town_id)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return INVALID_TILE;
|
if (!IsValidTown(town_id)) return INVALID_TILE;
|
||||||
const Town *t = ::GetTown(town_id);
|
const Town *t = ::Town::Get(town_id);
|
||||||
return t->xy;
|
return t->xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
if (!IsValidTown(town_id)) return -1;
|
if (!IsValidTown(town_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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)) {
|
switch(AICargo::GetTownEffect(cargo_id)) {
|
||||||
case AICargo::TE_PASSENGERS: return t->act_pass;
|
case AICargo::TE_PASSENGERS: return t->act_pass;
|
||||||
|
@ -76,7 +76,7 @@
|
||||||
if (!IsValidTown(town_id)) return -1;
|
if (!IsValidTown(town_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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)) {
|
switch(AICargo::GetTownEffect(cargo_id)) {
|
||||||
case AICargo::TE_PASSENGERS: return t->pct_pass_transported;
|
case AICargo::TE_PASSENGERS: return t->pct_pass_transported;
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
if (!IsValidTown(town_id)) return -1;
|
if (!IsValidTown(town_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo_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)) {
|
switch(AICargo::GetTownEffect(cargo_id)) {
|
||||||
case AICargo::TE_PASSENGERS: return t->max_pass;
|
case AICargo::TE_PASSENGERS: return t->max_pass;
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return false;
|
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]);
|
return ((uint32)GetDistanceSquareToTile(town_id, tile) <= t->squared_town_zone_radius[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,35 +121,35 @@
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return false;
|
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)
|
/* static */ int AITown::GetRoadReworkDuration(TownID town_id)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return -1;
|
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)
|
/* static */ AICompany::CompanyID AITown::GetExclusiveRightsCompany(TownID town_id)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return AICompany::COMPANY_INVALID;
|
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)
|
/* static */ int32 AITown::GetExclusiveRightsDuration(TownID town_id)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return -1;
|
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)
|
/* static */ bool AITown::IsActionAvailable(TownID town_id, TownAction town_action)
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return false;
|
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)
|
/* static */ bool AITown::PerformTownAction(TownID town_id, TownAction town_action)
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
EnforcePrecondition(false, IsValidTown(town_id));
|
EnforcePrecondition(false, IsValidTown(town_id));
|
||||||
EnforcePrecondition(false, IsActionAvailable(town_id, town_action));
|
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)
|
/* static */ AITown::TownRating AITown::GetRating(TownID town_id, AICompany::CompanyID company_id)
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
AICompany::CompanyID company = AICompany::ResolveCompanyID(company_id);
|
AICompany::CompanyID company = AICompany::ResolveCompanyID(company_id);
|
||||||
if (company == AICompany::COMPANY_INVALID) return TOWN_RATING_INVALID;
|
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;
|
if (!HasBit(t->have_ratings, company)) return TOWN_RATING_NONE;
|
||||||
return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 3));
|
return max(TOWN_RATING_APPALLING, (TownRating)((t->ratings[company] / 200) + 3));
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return -1;
|
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) {
|
if (_settings_game.economy.station_noise_level) {
|
||||||
return t->MaxTownNoise() - t->noise_reached;
|
return t->MaxTownNoise() - t->noise_reached;
|
||||||
}
|
}
|
||||||
|
@ -192,5 +192,5 @@
|
||||||
{
|
{
|
||||||
if (!IsValidTown(town_id)) return ROAD_LAYOUT_INVALID;
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
|
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!::IsValidVehicleID(vehicle_id)) return false;
|
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)));
|
return v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
|
|
||||||
int num = 1;
|
int num = 1;
|
||||||
if (::GetVehicle(vehicle_id)->type == VEH_TRAIN) {
|
if (::Vehicle::Get(vehicle_id)->type == VEH_TRAIN) {
|
||||||
const Vehicle *v = ::GetVehicle(vehicle_id);
|
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
while ((v = GetNextUnit(v)) != NULL) num++;
|
while ((v = GetNextUnit(v)) != NULL) num++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
|
|
||||||
const Vehicle *v = ::GetVehicle(vehicle_id);
|
const Vehicle *v = ::Vehicle::Get(vehicle_id);
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
case VEH_ROAD: {
|
case VEH_ROAD: {
|
||||||
uint total_length = 0;
|
uint total_length = 0;
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
{
|
{
|
||||||
EnforcePrecondition(INVALID_VEHICLE, AIEngine::IsValidEngine(engine_id));
|
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);
|
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, 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, 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, ::Vehicle::Get(source_vehicle_id)->type == VEH_TRAIN);
|
||||||
EnforcePrecondition(false, dest_vehicle_id == -1 || ::GetVehicle(dest_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);
|
while (source_wagon-- > 0) v = GetNextUnit(v);
|
||||||
const Vehicle *w = NULL;
|
const Vehicle *w = NULL;
|
||||||
if (dest_vehicle_id != -1) {
|
if (dest_vehicle_id != -1) {
|
||||||
w = ::GetVehicle(dest_vehicle_id);
|
w = ::Vehicle::Get(dest_vehicle_id);
|
||||||
while (dest_wagon-- > 0) w = GetNextUnit(w);
|
while (dest_wagon-- > 0) w = GetNextUnit(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
if (!AICargo::IsValidCargo(cargo)) 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;
|
return CmdSucceeded(res) ? _returned_refit_capacity : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id) && AICargo::IsValidCargo(cargo));
|
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));
|
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));
|
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)
|
/* static */ bool AIVehicle::_SellWagonInternal(VehicleID vehicle_id, int wagon, bool sell_attached_wagons)
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id) && wagon < GetNumWagons(vehicle_id));
|
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);
|
while (wagon-- > 0) v = GetNextUnit(v);
|
||||||
|
|
||||||
return AIObject::DoCommand(0, v->index, sell_attached_wagons ? 1 : 0, CMD_SELL_RAIL_WAGON);
|
return AIObject::DoCommand(0, v->index, sell_attached_wagons ? 1 : 0, CMD_SELL_RAIL_WAGON);
|
||||||
|
@ -157,26 +157,26 @@
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidVehicle(vehicle_id));
|
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)
|
/* static */ bool AIVehicle::SendVehicleToDepotForServicing(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidVehicle(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)
|
/* static */ bool AIVehicle::IsInDepot(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return false;
|
if (!IsValidVehicle(vehicle_id)) return false;
|
||||||
return ::GetVehicle(vehicle_id)->IsInDepot();
|
return ::Vehicle::Get(vehicle_id)->IsInDepot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool AIVehicle::IsStoppedInDepot(VehicleID vehicle_id)
|
/* static */ bool AIVehicle::IsStoppedInDepot(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return false;
|
if (!IsValidVehicle(vehicle_id)) return false;
|
||||||
return ::GetVehicle(vehicle_id)->IsStoppedInDepot();
|
return ::Vehicle::Get(vehicle_id)->IsStoppedInDepot();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ bool AIVehicle::StartStopVehicle(VehicleID vehicle_id)
|
/* static */ bool AIVehicle::StartStopVehicle(VehicleID vehicle_id)
|
||||||
|
@ -198,9 +198,9 @@
|
||||||
/* static */ bool AIVehicle::ReverseVehicle(VehicleID vehicle_id)
|
/* static */ bool AIVehicle::ReverseVehicle(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidVehicle(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_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);
|
case VEH_TRAIN: return AIObject::DoCommand(0, vehicle_id, 0, CMD_REVERSE_TRAIN_DIRECTION);
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return INVALID_TILE;
|
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) {
|
if (v->type == VEH_AIRCRAFT) {
|
||||||
uint x = Clamp(v->x_pos / TILE_SIZE, 0, ::MapSizeX() - 2);
|
uint x = Clamp(v->x_pos / TILE_SIZE, 0, ::MapSizeX() - 2);
|
||||||
uint y = Clamp(v->y_pos / TILE_SIZE, 0, ::MapSizeY() - 2);
|
uint y = Clamp(v->y_pos / TILE_SIZE, 0, ::MapSizeY() - 2);
|
||||||
|
@ -234,7 +234,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
|
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)
|
/* static */ EngineID AIVehicle::GetWagonEngineType(VehicleID vehicle_id, int wagon)
|
||||||
|
@ -242,7 +242,7 @@
|
||||||
if (!IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
|
if (!IsValidVehicle(vehicle_id)) return INVALID_ENGINE;
|
||||||
if (wagon >= GetNumWagons(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) {
|
if (v->type == VEH_TRAIN) {
|
||||||
while (wagon-- > 0) v = GetNextUnit(v);
|
while (wagon-- > 0) v = GetNextUnit(v);
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
|
|
||||||
return ::GetVehicle(vehicle_id)->unitnumber;
|
return ::Vehicle::Get(vehicle_id)->unitnumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ char *AIVehicle::GetName(VehicleID vehicle_id)
|
/* static */ char *AIVehicle::GetName(VehicleID vehicle_id)
|
||||||
|
@ -272,7 +272,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
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)
|
/* static */ int32 AIVehicle::GetWagonAge(VehicleID vehicle_id, int wagon)
|
||||||
|
@ -280,7 +280,7 @@
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
if (wagon >= GetNumWagons(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) {
|
if (v->type == VEH_TRAIN) {
|
||||||
while (wagon-- > 0) v = GetNextUnit(v);
|
while (wagon-- > 0) v = GetNextUnit(v);
|
||||||
}
|
}
|
||||||
|
@ -291,28 +291,28 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
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)
|
/* static */ int32 AIVehicle::GetAgeLeft(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
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)
|
/* static */ int32 AIVehicle::GetCurrentSpeed(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
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)
|
/* static */ AIVehicle::VehicleState AIVehicle::GetState(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return AIVehicle::VS_INVALID;
|
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;
|
byte vehstatus = v->vehstatus;
|
||||||
|
|
||||||
if (vehstatus & ::VS_CRASHED) return AIVehicle::VS_CRASHED;
|
if (vehstatus & ::VS_CRASHED) return AIVehicle::VS_CRASHED;
|
||||||
|
@ -327,35 +327,35 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
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)
|
/* static */ Money AIVehicle::GetProfitThisYear(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
|
|
||||||
return ::GetVehicle(vehicle_id)->GetDisplayProfitThisYear();
|
return ::Vehicle::Get(vehicle_id)->GetDisplayProfitThisYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
|
/* static */ Money AIVehicle::GetProfitLastYear(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
if (!IsValidVehicle(vehicle_id)) return -1;
|
||||||
|
|
||||||
return ::GetVehicle(vehicle_id)->GetDisplayProfitLastYear();
|
return ::Vehicle::Get(vehicle_id)->GetDisplayProfitLastYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */ Money AIVehicle::GetCurrentValue(VehicleID vehicle_id)
|
/* static */ Money AIVehicle::GetCurrentValue(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return -1;
|
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)
|
/* static */ AIVehicle::VehicleType AIVehicle::GetVehicleType(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return VT_INVALID;
|
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_ROAD: return VT_ROAD;
|
||||||
case VEH_TRAIN: return VT_RAIL;
|
case VEH_TRAIN: return VT_RAIL;
|
||||||
case VEH_SHIP: return VT_WATER;
|
case VEH_SHIP: return VT_WATER;
|
||||||
|
@ -369,7 +369,7 @@
|
||||||
if (!IsValidVehicle(vehicle_id)) return AIRoad::ROADTYPE_INVALID;
|
if (!IsValidVehicle(vehicle_id)) return AIRoad::ROADTYPE_INVALID;
|
||||||
if (GetVehicleType(vehicle_id) != VT_ROAD) 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)
|
/* static */ int32 AIVehicle::GetCapacity(VehicleID vehicle_id, CargoID cargo)
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
if (!AICargo::IsValidCargo(cargo)) return -1;
|
if (!AICargo::IsValidCargo(cargo)) return -1;
|
||||||
|
|
||||||
uint32 amount = 0;
|
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;
|
if (v->cargo_type == cargo) amount += v->cargo_cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@
|
||||||
if (!AICargo::IsValidCargo(cargo)) return -1;
|
if (!AICargo::IsValidCargo(cargo)) return -1;
|
||||||
|
|
||||||
uint32 amount = 0;
|
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();
|
if (v->cargo_type == cargo) amount += v->cargo.Count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return AIGroup::GROUP_INVALID;
|
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)
|
/* static */ bool AIVehicle::IsArticulated(VehicleID vehicle_id)
|
||||||
|
@ -410,7 +410,7 @@
|
||||||
if (!IsValidVehicle(vehicle_id)) return false;
|
if (!IsValidVehicle(vehicle_id)) return false;
|
||||||
if (GetVehicleType(vehicle_id) != VT_ROAD && GetVehicleType(vehicle_id) != VT_RAIL) 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) {
|
switch (v->type) {
|
||||||
case VEH_ROAD: return RoadVehHasArticPart(v);
|
case VEH_ROAD: return RoadVehHasArticPart(v);
|
||||||
case VEH_TRAIN: return EngineHasArticPart(v);
|
case VEH_TRAIN: return EngineHasArticPart(v);
|
||||||
|
@ -422,6 +422,6 @@
|
||||||
{
|
{
|
||||||
if (!IsValidVehicle(vehicle_id)) return false;
|
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;
|
return v->orders.list != NULL && v->orders.list->GetNumVehicles() > 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ AIVehicleList_SharedOrders::AIVehicleList_SharedOrders(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
|
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);
|
this->AddItem(v->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
/* static */ bool AIWaypoint::IsValidWaypoint(WaypointID waypoint_id)
|
/* 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)
|
/* static */ WaypointID AIWaypoint::GetWaypointID(TileIndex tile)
|
||||||
|
@ -49,5 +49,5 @@
|
||||||
{
|
{
|
||||||
if (!IsValidWaypoint(waypoint_id)) return INVALID_TILE;
|
if (!IsValidWaypoint(waypoint_id)) return INVALID_TILE;
|
||||||
|
|
||||||
return ::GetWaypoint(waypoint_id)->xy;
|
return ::Waypoint::Get(waypoint_id)->xy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ AIWaypointList_Vehicle::AIWaypointList_Vehicle(VehicleID vehicle_id)
|
||||||
{
|
{
|
||||||
if (!AIVehicle::IsValidVehicle(vehicle_id)) return;
|
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) {
|
for (const Order *o = v->GetFirstOrder(); o != NULL; o = o->next) {
|
||||||
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination());
|
if (o->IsType(OT_GOTO_WAYPOINT)) this->AddItem(o->GetDestination());
|
||||||
|
|
|
@ -136,7 +136,7 @@ static bool HaveHangarInOrderList(Vehicle *v)
|
||||||
const Order *order;
|
const Order *order;
|
||||||
|
|
||||||
FOR_VEHICLE_ORDERS(v, 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 (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
|
||||||
/* If an airport doesn't have a hangar, skip it */
|
/* If an airport doesn't have a hangar, skip it */
|
||||||
if (st->Airport()->nof_depots != 0)
|
if (st->Airport()->nof_depots != 0)
|
||||||
|
@ -156,7 +156,7 @@ SpriteID Aircraft::GetImage(Direction direction) const
|
||||||
SpriteID sprite = GetCustomVehicleSprite(this, direction);
|
SpriteID sprite = GetCustomVehicleSprite(this, direction);
|
||||||
if (sprite != 0) return sprite;
|
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];
|
return direction + _aircraft_sprite[spritenum];
|
||||||
|
@ -184,7 +184,7 @@ static SpriteID GetAircraftIcon(EngineID engine)
|
||||||
SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
|
SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
|
||||||
if (sprite != 0) return sprite;
|
if (sprite != 0) return sprite;
|
||||||
|
|
||||||
spritenum = GetEngine(engine)->image_index;
|
spritenum = Engine::Get(engine)->image_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 6 + _aircraft_sprite[spritenum];
|
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);
|
if (!IsEngineBuildable(p1, VEH_AIRCRAFT, _current_company)) return_cmd_error(STR_AIRCRAFT_NOT_AVAILABLE);
|
||||||
|
|
||||||
const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
|
const AircraftVehicleInfo *avi = AircraftVehInfo(p1);
|
||||||
const Engine *e = GetEngine(p1);
|
const Engine *e = Engine::Get(p1);
|
||||||
CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
|
CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
|
||||||
|
|
||||||
/* Engines without valid cargo should not be available */
|
/* Engines without valid cargo should not be available */
|
||||||
|
@ -424,7 +424,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||||
if (IsLocalCompany())
|
if (IsLocalCompany())
|
||||||
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Aircraft window
|
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;
|
return value;
|
||||||
|
@ -442,7 +442,7 @@ CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
{
|
{
|
||||||
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
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->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
|
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;
|
if (station == INVALID_STATION) return false;
|
||||||
|
|
||||||
st = GetStation(station);
|
st = Station::Get(station);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (location != NULL) *location = st->xy;
|
if (location != NULL) *location = st->xy;
|
||||||
|
@ -496,7 +496,7 @@ CommandCost CmdSendAircraftToHangar(TileIndex tile, DoCommandFlag flags, uint32
|
||||||
|
|
||||||
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Vehicle *v = GetVehicle(p1);
|
Vehicle *v = Vehicle::Get(p1);
|
||||||
|
|
||||||
if (v->type != VEH_AIRCRAFT) return CMD_ERROR;
|
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;
|
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->type != VEH_AIRCRAFT || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
|
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
|
||||||
|
@ -591,7 +591,7 @@ static void CheckIfAircraftNeedsService(Vehicle *v)
|
||||||
return;
|
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) */
|
/* 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) {
|
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);
|
// 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;
|
TileIndex tile = 0;
|
||||||
|
|
||||||
if (IsValidStationID(v->u.air.targetairport)) {
|
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. */
|
/* 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;
|
tile = (st->airport_tile != INVALID_TILE) ? st->airport_tile : st->xy;
|
||||||
}
|
}
|
||||||
|
@ -921,7 +921,7 @@ static bool AircraftController(Vehicle *v)
|
||||||
int count;
|
int count;
|
||||||
|
|
||||||
/* NULL if station is invalid */
|
/* 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 */
|
/* INVALID_TILE if there is no station */
|
||||||
TileIndex tile = INVALID_TILE;
|
TileIndex tile = INVALID_TILE;
|
||||||
if (st != NULL) {
|
if (st != NULL) {
|
||||||
|
@ -1326,7 +1326,7 @@ static void CrashAirplane(Vehicle *v)
|
||||||
|
|
||||||
static void MaybeCrashAirplane(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 */
|
/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
|
||||||
uint16 prob = 0x10000 / 1500;
|
uint16 prob = 0x10000 / 1500;
|
||||||
|
@ -1352,7 +1352,7 @@ static void AircraftEntersTerminal(Vehicle *v)
|
||||||
{
|
{
|
||||||
if (v->current_order.IsType(OT_GOTO_DEPOT)) return;
|
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;
|
v->last_station_visited = v->u.air.targetairport;
|
||||||
|
|
||||||
/* Check if station was ever visited before */
|
/* Check if station was ever visited before */
|
||||||
|
@ -1427,7 +1427,7 @@ void AircraftLeaveHangar(Vehicle *v)
|
||||||
static inline bool CheckSendAircraftToHangarForReplacement(const Vehicle *v)
|
static inline bool CheckSendAircraftToHangarForReplacement(const Vehicle *v)
|
||||||
{
|
{
|
||||||
EngineID new_engine;
|
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
|
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 */
|
/* Engine is not buildable anymore */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1527,7 +1527,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *a
|
||||||
/* an exerpt of ServiceAircraft, without the invisibility stuff */
|
/* an exerpt of ServiceAircraft, without the invisibility stuff */
|
||||||
v->date_of_last_service = _date;
|
v->date_of_last_service = _date;
|
||||||
v->breakdowns_since_last_service = 0;
|
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);
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1556,7 +1556,7 @@ static void AircraftEventHandler_AtTerminal(Vehicle *v, const AirportFTAClass *a
|
||||||
return;
|
return;
|
||||||
default: // orders have been deleted (no orders), goto depot and don't bother us
|
default: // orders have been deleted (no orders), goto depot and don't bother us
|
||||||
v->current_order.Free();
|
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) {
|
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)
|
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 */
|
/* runway busy or not allowed to use this airstation, circle */
|
||||||
if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
|
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 */
|
/* 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) {
|
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);
|
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 aircraft is not in position, wait until it is */
|
||||||
if (!AircraftController(v)) return;
|
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);
|
AirportClearBlock(v, apc);
|
||||||
AirportMove(v, apc); // move aircraft to next position
|
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 */
|
/* same block, then of course we can move */
|
||||||
if (apc->layout[current_pos->position].block != next->block) {
|
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;
|
uint64 airport_flags = next->block;
|
||||||
|
|
||||||
/* check additional possible extra blocks */
|
/* 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 */
|
* checking, because it has been set by the airplane before */
|
||||||
if (current_pos->block == next->block) airport_flags ^= next->block;
|
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)) {
|
if (HASBITS(st->airport_flags, airport_flags)) {
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
v->subspeed = 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)
|
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++) {
|
for (; i < last_terminal; i++) {
|
||||||
if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
|
if (!HasBit(st->airport_flags, _airport_terminal_flag[i])) {
|
||||||
/* TERMINAL# HELIPAD# */
|
/* TERMINAL# HELIPAD# */
|
||||||
|
@ -1903,7 +1903,7 @@ static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *apc)
|
||||||
* fails, then attempt fails and plane waits
|
* fails, then attempt fails and plane waits
|
||||||
*/
|
*/
|
||||||
if (apc->terminals[0] > 1) {
|
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;
|
const AirportFTA *temp = apc->layout[v->u.air.pos].next;
|
||||||
|
|
||||||
while (temp != NULL) {
|
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 there are more helicoptergroups, pick one, just as in AirportFindFreeTerminal() */
|
||||||
if (apc->helipads[0] > 1) {
|
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;
|
const AirportFTA *temp = apc->layout[v->u.air.pos].next;
|
||||||
|
|
||||||
while (temp != NULL) {
|
while (temp != NULL) {
|
||||||
|
@ -2053,7 +2053,7 @@ Station *GetTargetAirportIfValid(const Vehicle *v)
|
||||||
|
|
||||||
if (!IsValidStationID(sid)) return NULL;
|
if (!IsValidStationID(sid)) return NULL;
|
||||||
|
|
||||||
Station *st = GetStation(sid);
|
Station *st = Station::Get(sid);
|
||||||
|
|
||||||
return st->airport_tile == INVALID_TILE ? NULL : st;
|
return st->airport_tile == INVALID_TILE ? NULL : st;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
const Vehicle *v = GetVehicle(_new_vehicle_id);
|
const Vehicle *v = Vehicle::Get(_new_vehicle_id);
|
||||||
|
|
||||||
if (v->tile == _backup_orders_tile) {
|
if (v->tile == _backup_orders_tile) {
|
||||||
_backup_orders_tile = 0;
|
_backup_orders_tile = 0;
|
||||||
|
|
|
@ -48,7 +48,7 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
|
||||||
*/
|
*/
|
||||||
static inline uint16 GetVehicleDefaultCapacity(EngineID engine, VehicleType type, CargoID *cargo_type)
|
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);
|
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
|
||||||
if (cargo_type != NULL) *cargo_type = cargo;
|
if (cargo_type != NULL) *cargo_type = cargo;
|
||||||
if (cargo == CT_INVALID) return 0;
|
if (cargo == CT_INVALID) return 0;
|
||||||
|
@ -113,7 +113,7 @@ bool IsArticulatedVehicleRefittable(EngineID engine)
|
||||||
{
|
{
|
||||||
if (IsEngineRefittable(engine)) return true;
|
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 (e->type != VEH_TRAIN && e->type != VEH_ROAD) return false;
|
||||||
|
|
||||||
if (!HasBit(e->info.callbackmask, CBM_VEHICLE_ARTIC_ENGINE)) 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)
|
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_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true);
|
||||||
uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(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);
|
bool flip_image = HasBit(callback, 7);
|
||||||
|
|
||||||
Vehicle *previous = u;
|
Vehicle *previous = u;
|
||||||
const Engine *e_artic = GetEngine(engine_type);
|
const Engine *e_artic = Engine::Get(engine_type);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ void RemoveAllEngineReplacement(EngineRenewList *erl)
|
||||||
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
|
EngineID EngineReplacement(EngineRenewList erl, EngineID engine, GroupID group)
|
||||||
{
|
{
|
||||||
const EngineRenew *er = GetEngineReplacement(erl, engine, 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 */
|
/* We didn't find anything useful in the vehicle's own group so we will try ALL_GROUP */
|
||||||
er = GetEngineReplacement(erl, engine, ALL_GROUP);
|
er = GetEngineReplacement(erl, engine, ALL_GROUP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct EngineRenew : PoolItem<EngineRenew, EngineRenewID, &_EngineRenew_pool> {
|
||||||
inline bool IsValid() const { return this->from != INVALID_ENGINE; }
|
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)
|
#define FOR_ALL_ENGINE_RENEWS(er) FOR_ALL_ENGINE_RENEWS_FROM(er, 0)
|
||||||
|
|
||||||
#endif /* AUTOREPLACE_BASE_H */
|
#endif /* AUTOREPLACE_BASE_H */
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
|
||||||
/* we can't replace an engine into itself (that would be autorenew) */
|
/* we can't replace an engine into itself (that would be autorenew) */
|
||||||
if (from == to) return false;
|
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 */
|
/* 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;
|
if (!IsEngineBuildable(to, type, company)) return false;
|
||||||
|
@ -247,7 +247,7 @@ static CommandCost BuildReplacementVehicle(Vehicle *old_veh, Vehicle **new_vehic
|
||||||
*new_vehicle = NULL;
|
*new_vehicle = NULL;
|
||||||
|
|
||||||
/* Shall the vehicle be replaced? */
|
/* Shall the vehicle be replaced? */
|
||||||
const Company *c = GetCompany(_current_company);
|
const Company *c = Company::Get(_current_company);
|
||||||
EngineID e = GetNewEngineType(old_veh, c);
|
EngineID e = GetNewEngineType(old_veh, c);
|
||||||
if (e == INVALID_ENGINE) return CommandCost(); // neither autoreplace is set, nor autorenew is triggered
|
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));
|
CommandCost cost = DoCommand(old_veh->tile, e, 0, DC_EXEC | DC_AUTOREPLACE, GetCmdBuildVeh(old_veh));
|
||||||
if (cost.Failed()) return cost;
|
if (cost.Failed()) return cost;
|
||||||
|
|
||||||
Vehicle *new_veh = GetVehicle(_new_vehicle_id);
|
Vehicle *new_veh = Vehicle::Get(_new_vehicle_id);
|
||||||
*new_vehicle = new_veh;
|
*new_vehicle = new_veh;
|
||||||
|
|
||||||
/* Refit the vehicle if needed */
|
/* Refit the vehicle if needed */
|
||||||
|
@ -609,7 +609,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||||
bool nothing_to_do = true;
|
bool nothing_to_do = true;
|
||||||
|
|
||||||
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
||||||
Vehicle *v = GetVehicle(p1);
|
Vehicle *v = Vehicle::Get(p1);
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsInDepot()) return CMD_ERROR;
|
if (!v->IsInDepot()) return CMD_ERROR;
|
||||||
if (HASBITS(v->vehstatus, VS_CRASHED)) 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;
|
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;
|
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 */
|
/* Test whether any replacement is set, before issuing a whole lot of commands that would end in nothing changed */
|
||||||
|
|
|
@ -69,14 +69,14 @@ static int CDECL EngineNumberSorter(const void *a, const void *b)
|
||||||
*/
|
*/
|
||||||
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
|
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);
|
uint num_engines = GetGroupNumEngines(_local_company, id_g, e);
|
||||||
|
|
||||||
if (num_engines == 0 || c->num_engines[e] == 0) {
|
if (num_engines == 0 || c->num_engines[e] == 0) {
|
||||||
/* We don't have any of this engine type.
|
/* 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.
|
* 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 */
|
* 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);
|
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 */
|
/* 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 {
|
} else {
|
||||||
if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
|
if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ public:
|
||||||
{
|
{
|
||||||
if (this->update_left || this->update_right) this->GenerateLists();
|
if (this->update_left || this->update_right) this->GenerateLists();
|
||||||
|
|
||||||
Company *c = GetCompany(_local_company);
|
Company *c = Company::Get(_local_company);
|
||||||
EngineID selected_id[2];
|
EngineID selected_id[2];
|
||||||
const GroupID selected_group = this->sel_group;
|
const GroupID selected_group = this->sel_group;
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ public:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { // Railtype selection dropdown menu
|
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();
|
DropDownList *list = new DropDownList();
|
||||||
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
||||||
|
@ -347,7 +347,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
|
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;
|
break;
|
||||||
|
|
||||||
case RVW_WIDGET_START_REPLACE: { // Start replacing
|
case RVW_WIDGET_START_REPLACE: { // Start replacing
|
||||||
|
|
|
@ -114,8 +114,8 @@ static int CDECL EngineNumberSorter(const void *a, const void *b)
|
||||||
|
|
||||||
static int CDECL EngineIntroDateSorter(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 va = Engine::Get(*(const EngineID*)a)->intro_date;
|
||||||
const int vb = GetEngine(*(const EngineID*)b)->intro_date;
|
const int vb = Engine::Get(*(const EngineID*)b)->intro_date;
|
||||||
const int r = va - vb;
|
const int r = va - vb;
|
||||||
|
|
||||||
/* Use EngineID to sort instead since we want consistent sorting */
|
/* 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)
|
static int CDECL EngineReliabilitySorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const int va = GetEngine(*(const EngineID*)a)->reliability;
|
const int va = Engine::Get(*(const EngineID*)a)->reliability;
|
||||||
const int vb = GetEngine(*(const EngineID*)b)->reliability;
|
const int vb = Engine::Get(*(const EngineID*)b)->reliability;
|
||||||
const int r = va - vb;
|
const int r = va - vb;
|
||||||
|
|
||||||
/* Use EngineID to sort instead since we want consistent sorting */
|
/* 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)
|
static int CDECL EngineCostSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
Money va = GetEngine(*(const EngineID*)a)->GetCost();
|
Money va = Engine::Get(*(const EngineID*)a)->GetCost();
|
||||||
Money vb = GetEngine(*(const EngineID*)b)->GetCost();
|
Money vb = Engine::Get(*(const EngineID*)b)->GetCost();
|
||||||
int r = ClampToI32(va - vb);
|
int r = ClampToI32(va - vb);
|
||||||
|
|
||||||
/* Use EngineID to sort instead since we want consistent sorting */
|
/* 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)
|
static int CDECL EngineSpeedSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
int va = GetEngine(*(const EngineID*)a)->GetDisplayMaxSpeed();
|
int va = Engine::Get(*(const EngineID*)a)->GetDisplayMaxSpeed();
|
||||||
int vb = GetEngine(*(const EngineID*)b)->GetDisplayMaxSpeed();
|
int vb = Engine::Get(*(const EngineID*)b)->GetDisplayMaxSpeed();
|
||||||
int r = va - vb;
|
int r = va - vb;
|
||||||
|
|
||||||
/* Use EngineID to sort instead since we want consistent sorting */
|
/* 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)
|
static int CDECL EnginePowerSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
int va = GetEngine(*(const EngineID*)a)->GetPower();
|
int va = Engine::Get(*(const EngineID*)a)->GetPower();
|
||||||
int vb = GetEngine(*(const EngineID*)b)->GetPower();
|
int vb = Engine::Get(*(const EngineID*)b)->GetPower();
|
||||||
int r = va - vb;
|
int r = va - vb;
|
||||||
|
|
||||||
/* Use EngineID to sort instead since we want consistent sorting */
|
/* 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)
|
static int CDECL EngineRunningCostSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
Money va = GetEngine(*(const EngineID*)a)->GetRunningCost();
|
Money va = Engine::Get(*(const EngineID*)a)->GetRunningCost();
|
||||||
Money vb = GetEngine(*(const EngineID*)b)->GetRunningCost();
|
Money vb = Engine::Get(*(const EngineID*)b)->GetRunningCost();
|
||||||
int r = ClampToI32(va - vb);
|
int r = ClampToI32(va - vb);
|
||||||
|
|
||||||
/* Use EngineID to sort instead since we want consistent sorting */
|
/* 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 */
|
/* Train sorting functions */
|
||||||
static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *b)
|
static int CDECL TrainEnginePowerVsRunningCostSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const Engine *e_a = GetEngine(*(const EngineID*)a);
|
const Engine *e_a = Engine::Get(*(const EngineID*)a);
|
||||||
const Engine *e_b = GetEngine(*(const EngineID*)b);
|
const Engine *e_b = Engine::Get(*(const EngineID*)b);
|
||||||
|
|
||||||
/* Here we are using a few tricks to get the right sort.
|
/* 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,
|
* 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 */
|
/* Ship vehicle sorting functions */
|
||||||
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
|
static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const Engine *e_a = GetEngine(*(const EngineID*)a);
|
const Engine *e_a = Engine::Get(*(const EngineID*)a);
|
||||||
const Engine *e_b = GetEngine(*(const EngineID*)b);
|
const Engine *e_b = Engine::Get(*(const EngineID*)b);
|
||||||
|
|
||||||
int va = e_a->GetDisplayDefaultCapacity();
|
int va = e_a->GetDisplayDefaultCapacity();
|
||||||
int vb = e_b->GetDisplayDefaultCapacity();
|
int vb = e_b->GetDisplayDefaultCapacity();
|
||||||
|
@ -283,8 +283,8 @@ static int CDECL ShipEngineCapacitySorter(const void *a, const void *b)
|
||||||
/* Aircraft sorting functions */
|
/* Aircraft sorting functions */
|
||||||
static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
|
static int CDECL AircraftEngineCargoSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const Engine *e_a = GetEngine(*(const EngineID*)a);
|
const Engine *e_a = Engine::Get(*(const EngineID*)a);
|
||||||
const Engine *e_b = GetEngine(*(const EngineID*)b);
|
const Engine *e_b = Engine::Get(*(const EngineID*)b);
|
||||||
|
|
||||||
int va = e_a->GetDisplayDefaultCapacity();
|
int va = e_a->GetDisplayDefaultCapacity();
|
||||||
int vb = e_b->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)
|
static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid)
|
||||||
{
|
{
|
||||||
if (cid == CF_ANY) return true;
|
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));
|
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 */
|
/* Draw rail wagon specific details */
|
||||||
static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
|
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 */
|
/* Purchase cost */
|
||||||
SetDParam(0, e->GetCost());
|
SetDParam(0, e->GetCost());
|
||||||
|
@ -469,7 +469,7 @@ static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine
|
||||||
/* Draw locomotive specific details */
|
/* Draw locomotive specific details */
|
||||||
static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
|
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 */
|
/* Purchase Cost - Engine weight */
|
||||||
SetDParam(0, e->GetCost());
|
SetDParam(0, e->GetCost());
|
||||||
|
@ -511,7 +511,7 @@ static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engin
|
||||||
/* Draw road vehicle specific details */
|
/* Draw road vehicle specific details */
|
||||||
static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_number)
|
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 */
|
/* Purchase cost - Max speed */
|
||||||
SetDParam(0, e->GetCost());
|
SetDParam(0, e->GetCost());
|
||||||
|
@ -530,7 +530,7 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n
|
||||||
/* Draw ship specific details */
|
/* Draw ship specific details */
|
||||||
static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_number, const ShipVehicleInfo *svi, bool refittable)
|
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 */
|
/* Purchase cost - Max speed */
|
||||||
SetDParam(0, e->GetCost());
|
SetDParam(0, e->GetCost());
|
||||||
|
@ -556,7 +556,7 @@ static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_numb
|
||||||
/* Draw aircraft specific details */
|
/* Draw aircraft specific details */
|
||||||
static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_number, const AircraftVehicleInfo *avi, bool refittable)
|
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();
|
CargoID cargo = e->GetDefaultCargoType();
|
||||||
|
|
||||||
/* Purchase cost - Max speed */
|
/* 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)
|
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;
|
YearMonthDay ymd;
|
||||||
ConvertDateToYMD(e->intro_date, &ymd);
|
ConvertDateToYMD(e->intro_date, &ymd);
|
||||||
bool refittable = IsArticulatedVehicleRefittable(engine_number);
|
bool refittable = IsArticulatedVehicleRefittable(engine_number);
|
||||||
|
|
|
@ -21,7 +21,7 @@ CargoPacket::CargoPacket(StationID source, uint16 count)
|
||||||
if (source != INVALID_STATION) assert(count != 0);
|
if (source != INVALID_STATION) assert(count != 0);
|
||||||
|
|
||||||
this->source = source;
|
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->loaded_at_xy = this->source_xy;
|
||||||
|
|
||||||
this->count = count;
|
this->count = count;
|
||||||
|
|
|
@ -63,7 +63,7 @@ struct CargoPacket : PoolItem<CargoPacket, CargoPacketID, &_CargoPacket_pool> {
|
||||||
* @param cp the variable used as "iterator"
|
* @param cp the variable used as "iterator"
|
||||||
* @param start the cargo packet ID of the first packet to iterate over
|
* @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
|
* Iterate over all _valid_ cargo packets from the begin of the pool
|
||||||
|
|
|
@ -459,7 +459,7 @@ Money GetAvailableMoneyForCommand()
|
||||||
{
|
{
|
||||||
CompanyID company = _current_company;
|
CompanyID company = _current_company;
|
||||||
if (!IsValidCompanyID(company)) return INT64_MAX;
|
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. */
|
/* update last build coordinate of company. */
|
||||||
if (tile != 0 && IsValidCompanyID(_current_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
|
/* Actually try and execute the command. If no cost-type is given
|
||||||
|
|
|
@ -87,10 +87,10 @@ struct Company : PoolItem<Company, CompanyByte, &_Company_pool> {
|
||||||
|
|
||||||
static inline bool IsValidCompanyID(CompanyID company)
|
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)
|
#define FOR_ALL_COMPANIES(d) FOR_ALL_COMPANIES_FROM(d, 0)
|
||||||
|
|
||||||
static inline byte ActiveCompanyCount()
|
static inline byte ActiveCompanyCount()
|
||||||
|
|
|
@ -77,7 +77,7 @@ void SetLocalCompany(CompanyID new_company)
|
||||||
|
|
||||||
/* Do not update the settings if we are in the intro GUI */
|
/* Do not update the settings if we are in the intro GUI */
|
||||||
if (IsValidCompanyID(new_company) && _game_mode != GM_MENU) {
|
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;
|
_settings_client.company = c->settings;
|
||||||
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ void SetLocalCompany(CompanyID new_company)
|
||||||
|
|
||||||
bool IsHumanCompany(CompanyID 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) {
|
if (cost.GetCost() > 0) {
|
||||||
CompanyID company = _current_company;
|
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());
|
SetDParam(0, cost.GetCost());
|
||||||
_error_message = STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY;
|
_error_message = STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY;
|
||||||
return false;
|
return false;
|
||||||
|
@ -189,12 +189,12 @@ void SubtractMoneyFromCompany(CommandCost cost)
|
||||||
{
|
{
|
||||||
CompanyID cid = _current_company;
|
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)
|
void SubtractMoneyFromCompanyFract(CompanyID company, CommandCost cst)
|
||||||
{
|
{
|
||||||
Company *c = GetCompany(company);
|
Company *c = Company::Get(company);
|
||||||
byte m = c->money_fraction;
|
byte m = c->money_fraction;
|
||||||
Money cost = cst.GetCost();
|
Money cost = cst.GetCost();
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ void OnTick_Companies()
|
||||||
if (_game_mode == GM_EDITOR) return;
|
if (_game_mode == GM_EDITOR) return;
|
||||||
|
|
||||||
if (IsValidCompanyID((CompanyID)_cur_company_tick_index)) {
|
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);
|
if (c->name_1 != 0) GenerateCompanyName(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,7 +528,7 @@ void CompaniesYearlyLoop()
|
||||||
|
|
||||||
if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) {
|
if (_settings_client.gui.show_finances && _local_company != COMPANY_SPECTATOR) {
|
||||||
ShowCompanyFinances(_local_company);
|
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) {
|
if (c->num_valid_stat_ent > 5 && c->old_economy[0].performance_history < c->old_economy[4].performance_history) {
|
||||||
SndPlayFx(SND_01_BAD_YEAR);
|
SndPlayFx(SND_01_BAD_YEAR);
|
||||||
} else {
|
} else {
|
||||||
|
@ -569,7 +569,7 @@ CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||||
{
|
{
|
||||||
if (!IsValidCompanyID(_current_company)) return CMD_ERROR;
|
if (!IsValidCompanyID(_current_company)) return CMD_ERROR;
|
||||||
|
|
||||||
Company *c = GetCompany(_current_company);
|
Company *c = Company::Get(_current_company);
|
||||||
switch (GB(p1, 0, 3)) {
|
switch (GB(p1, 0, 3)) {
|
||||||
case 0:
|
case 0:
|
||||||
if (c->settings.engine_renew == HasBit(p2, 0)) return CMD_ERROR;
|
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();
|
if (!(flags & DC_EXEC)) return CommandCost();
|
||||||
|
|
||||||
c = GetCompany((CompanyID)p2);
|
c = Company::Get((CompanyID)p2);
|
||||||
|
|
||||||
/* Delete any open window of the company */
|
/* Delete any open window of the company */
|
||||||
DeleteCompanyWindows(c->index);
|
DeleteCompanyWindows(c->index);
|
||||||
|
@ -854,7 +854,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
if (!(flags & DC_EXEC)) return CMD_ERROR;
|
if (!(flags & DC_EXEC)) return CMD_ERROR;
|
||||||
|
|
||||||
ChangeOwnershipOfCompanyItems(cid_old, cid_new);
|
ChangeOwnershipOfCompanyItems(cid_old, cid_new);
|
||||||
delete GetCompany(cid_old);
|
delete Company::Get(cid_old);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default: return CMD_ERROR;
|
default: return CMD_ERROR;
|
||||||
|
|
|
@ -337,7 +337,7 @@ struct CompanyFinancesWindow : Window {
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
CompanyID company = (CompanyID)this->window_number;
|
CompanyID company = (CompanyID)this->window_number;
|
||||||
const Company *c = GetCompany(company);
|
const Company *c = Company::Get(company);
|
||||||
|
|
||||||
if (!small) {
|
if (!small) {
|
||||||
int type = _settings_client.gui.expenses_layout;
|
int type = _settings_client.gui.expenses_layout;
|
||||||
|
@ -542,7 +542,7 @@ private:
|
||||||
if (HasBit(this->sel, scheme)) break;
|
if (HasBit(this->sel, scheme)) break;
|
||||||
}
|
}
|
||||||
if (scheme == LS_END) scheme = LS_DEFAULT;
|
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();
|
DropDownList *list = new DropDownList();
|
||||||
for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
|
for (uint i = 0; i < lengthof(_colour_dropdown); i++) {
|
||||||
|
@ -565,7 +565,7 @@ public:
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
const Company *c = GetCompany((CompanyID)this->window_number);
|
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||||
LiveryScheme scheme = LS_DEFAULT;
|
LiveryScheme scheme = LS_DEFAULT;
|
||||||
int y = 51;
|
int y = 51;
|
||||||
|
|
||||||
|
@ -667,7 +667,7 @@ public:
|
||||||
|
|
||||||
/* If clicking on the left edge, toggle using the livery */
|
/* If clicking on the left edge, toggle using the livery */
|
||||||
if (pt.x < 10) {
|
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) {
|
if (_ctrl_pressed) {
|
||||||
|
@ -1112,7 +1112,7 @@ public:
|
||||||
{
|
{
|
||||||
this->parent = parent;
|
this->parent = parent;
|
||||||
this->owner = (Owner)this->window_number;
|
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->advanced = advanced;
|
||||||
|
|
||||||
this->UpdateData();
|
this->UpdateData();
|
||||||
|
@ -1218,7 +1218,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the company manager face picture */
|
/* 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)
|
virtual void OnClick(Point pt, int widget)
|
||||||
|
@ -1577,7 +1577,7 @@ struct CompanyWindow : Window
|
||||||
|
|
||||||
virtual void OnPaint()
|
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;
|
bool local = this->window_number == _local_company;
|
||||||
|
|
||||||
this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE, !local);
|
this->SetWidgetHiddenState(CW_WIDGET_NEW_FACE, !local);
|
||||||
|
@ -1674,7 +1674,7 @@ struct CompanyWindow : Window
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CW_WIDGET_BUILD_VIEW_HQ: {
|
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 (tile == INVALID_TILE) {
|
||||||
if ((byte)this->window_number != _local_company) return;
|
if ((byte)this->window_number != _local_company) return;
|
||||||
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, HT_RECT, this);
|
SetObjectToPlaceWnd(SPR_CURSOR_HQ, PAL_NONE, HT_RECT, this);
|
||||||
|
@ -1804,7 +1804,7 @@ struct BuyCompanyWindow : Window {
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
Company *c = GetCompany((CompanyID)this->window_number);
|
Company *c = Company::Get((CompanyID)this->window_number);
|
||||||
SetDParam(0, STR_COMPANY_NAME);
|
SetDParam(0, STR_COMPANY_NAME);
|
||||||
SetDParam(1, c->index);
|
SetDParam(1, c->index);
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
|
|
|
@ -650,7 +650,7 @@ DEF_CONSOLE_CMD(ConJoinCompany)
|
||||||
return true;
|
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.");
|
IConsoleError("Cannot join AI company.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -693,7 +693,7 @@ DEF_CONSOLE_CMD(ConMoveClient)
|
||||||
return true;
|
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.");
|
IConsoleError("You cannot move clients to AI companies.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -734,7 +734,7 @@ DEF_CONSOLE_CMD(ConResetCompany)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Company *c = GetCompany(index);
|
const Company *c = Company::Get(index);
|
||||||
|
|
||||||
if (c->is_ai) {
|
if (c->is_ai) {
|
||||||
IConsoleError("Company is owned by an AI.");
|
IConsoleError("Company is owned by an AI.");
|
||||||
|
|
|
@ -40,7 +40,7 @@ void SetRandomSeed(uint32 seed)
|
||||||
|
|
||||||
uint32 DoRandom(int line, const char *file)
|
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);
|
printf("Random [%d/%d] %s:%d\n", _frame_counter, (byte)_current_company, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ static void RunVehicleDayProc(uint daytick)
|
||||||
uint i;
|
uint i;
|
||||||
|
|
||||||
for (i = daytick; i < total; i += DAY_TICKS) {
|
for (i = daytick; i < total; i += DAY_TICKS) {
|
||||||
Vehicle *v = GetVehicle(i);
|
Vehicle *v = Vehicle::Get(i);
|
||||||
|
|
||||||
if (v->IsValid()) {
|
if (v->IsValid()) {
|
||||||
/* Call the 32-day callback if needed */
|
/* Call the 32-day callback if needed */
|
||||||
|
|
|
@ -24,12 +24,12 @@ struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
|
||||||
|
|
||||||
static inline bool IsValidDepotID(DepotID index)
|
static inline bool IsValidDepotID(DepotID index)
|
||||||
{
|
{
|
||||||
return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
|
return index < GetDepotPoolSize() && Depot::Get(index)->IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
Depot *GetDepotByTile(TileIndex tile);
|
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)
|
#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
|
||||||
|
|
||||||
#endif /* DEPOT_BASE_H */
|
#endif /* DEPOT_BASE_H */
|
||||||
|
|
|
@ -139,14 +139,14 @@ void CcCloneVehicle(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
const Vehicle *v = GetVehicle(_new_vehicle_id);
|
const Vehicle *v = Vehicle::Get(_new_vehicle_id);
|
||||||
|
|
||||||
ShowVehicleViewWindow(v);
|
ShowVehicleViewWindow(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TrainDepotMoveVehicle(const Vehicle *wagon, VehicleID sel, const Vehicle *head)
|
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;
|
if (v == wagon) return;
|
||||||
|
|
||||||
|
@ -948,7 +948,7 @@ struct DepotWindow : Window {
|
||||||
if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
|
if (this->GetVehicleFromDepotWndPt(pt.x, pt.y, &v, &gdvp) == MODE_DRAG_VEHICLE &&
|
||||||
sel != INVALID_VEHICLE) {
|
sel != INVALID_VEHICLE) {
|
||||||
if (gdvp.wagon != NULL && gdvp.wagon->index == sel && _ctrl_pressed) {
|
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) {
|
} else if (gdvp.wagon == NULL || gdvp.wagon->index != sel) {
|
||||||
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
|
TrainDepotMoveVehicle(gdvp.wagon, sel, gdvp.head);
|
||||||
} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
|
} else if (gdvp.head != NULL && IsFrontEngine(gdvp.head)) {
|
||||||
|
@ -972,7 +972,7 @@ struct DepotWindow : Window {
|
||||||
|
|
||||||
this->HandleButtonClick(widget);
|
this->HandleButtonClick(widget);
|
||||||
|
|
||||||
const Vehicle *v = GetVehicle(this->sel);
|
const Vehicle *v = Vehicle::Get(this->sel);
|
||||||
this->sel = INVALID_VEHICLE;
|
this->sel = INVALID_VEHICLE;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
|
|
|
@ -307,7 +307,7 @@ static void DisasterTick_Ufo(Vehicle *v)
|
||||||
delete v;
|
delete v;
|
||||||
} else {
|
} else {
|
||||||
/* Target a vehicle */
|
/* Target a vehicle */
|
||||||
Vehicle *u = GetVehicle(v->dest_tile);
|
Vehicle *u = Vehicle::Get(v->dest_tile);
|
||||||
if (u->type != VEH_ROAD || !IsRoadVehFront(u)) {
|
if (u->type != VEH_ROAD || !IsRoadVehFront(u)) {
|
||||||
delete v;
|
delete v;
|
||||||
return;
|
return;
|
||||||
|
@ -393,7 +393,7 @@ static void DisasterTick_Aircraft(Vehicle *v, uint16 image_override, bool leave_
|
||||||
|
|
||||||
if (v->current_order.GetDestination() == 2) {
|
if (v->current_order.GetDestination() == 2) {
|
||||||
if (GB(v->tick_counter, 0, 2) == 0) {
|
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 x = TileX(i->xy) * TILE_SIZE;
|
||||||
int y = TileY(i->xy) * TILE_SIZE;
|
int y = TileY(i->xy) * TILE_SIZE;
|
||||||
uint32 r = Random();
|
uint32 r = Random();
|
||||||
|
@ -411,7 +411,7 @@ static void DisasterTick_Aircraft(Vehicle *v, uint16 image_override, bool leave_
|
||||||
v->current_order.SetDestination(2);
|
v->current_order.SetDestination(2);
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
|
|
||||||
Industry *i = GetIndustry(v->dest_tile);
|
Industry *i = Industry::Get(v->dest_tile);
|
||||||
DestructIndustry(i);
|
DestructIndustry(i);
|
||||||
|
|
||||||
SetDParam(0, i->town->index);
|
SetDParam(0, i->town->index);
|
||||||
|
@ -430,7 +430,7 @@ static void DisasterTick_Aircraft(Vehicle *v, uint16 image_override, bool leave_
|
||||||
IndustryID ind = GetIndustryIndex(tile);
|
IndustryID ind = GetIndustryIndex(tile);
|
||||||
v->dest_tile = ind;
|
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->current_order.SetDestination(1);
|
||||||
v->age = 0;
|
v->age = 0;
|
||||||
}
|
}
|
||||||
|
@ -574,7 +574,7 @@ static void DisasterTick_Big_Ufo_Destroyer(Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v->current_order.GetDestination() == 0) {
|
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;
|
if (Delta(v->x_pos, u->x_pos) > TILE_SIZE) return;
|
||||||
v->current_order.SetDestination(1);
|
v->current_order.SetDestination(1);
|
||||||
|
|
||||||
|
@ -911,7 +911,7 @@ void StartupDisasters()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Marks all disasters targeting this industry in such a way
|
/** 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
|
* @param i deleted industry
|
||||||
*/
|
*/
|
||||||
void ReleaseDisastersTargetingIndustry(IndustryID i)
|
void ReleaseDisastersTargetingIndustry(IndustryID i)
|
||||||
|
|
|
@ -294,7 +294,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sell all the shares that people have on this company */
|
/* 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++) {
|
for (i = 0; i < 4; i++) {
|
||||||
_current_company = c->share_owners[i];
|
_current_company = c->share_owners[i];
|
||||||
if (_current_company != INVALID_OWNER) {
|
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.
|
* removing his/her property doesn't fail because of lack of money.
|
||||||
* Not too drastically though, because it could overflow */
|
* Not too drastically though, because it could overflow */
|
||||||
if (new_owner == INVALID_OWNER) {
|
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) {
|
if (new_owner == INVALID_OWNER) {
|
||||||
|
@ -321,7 +321,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||||
|
|
||||||
for (s = _subsidies; s != endof(_subsidies); s++) {
|
for (s = _subsidies; s != endof(_subsidies); s++) {
|
||||||
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
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 {
|
} else {
|
||||||
v->owner = new_owner;
|
v->owner = new_owner;
|
||||||
v->colourmap = PAL_NONE;
|
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();
|
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.
|
/* In all cases clear replace engine rules.
|
||||||
* Even if it was copied, it could interfere with new owner's 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) {
|
if (new_owner == INVALID_OWNER) {
|
||||||
RemoveAllGroupsForCompany(old_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) {
|
if (cs->town_effect != TE_PASSENGERS && cs->town_effect != TE_MAIL) {
|
||||||
SetDParam(1, STR_INDUSTRY);
|
SetDParam(1, STR_INDUSTRY);
|
||||||
SetDParam(2, s->from);
|
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) {
|
if (cs->town_effect != TE_GOODS && cs->town_effect != TE_FOOD) {
|
||||||
SetDParam(4, STR_INDUSTRY);
|
SetDParam(4, STR_INDUSTRY);
|
||||||
SetDParam(5, s->to);
|
SetDParam(5, s->to);
|
||||||
tile2 = GetIndustry(s->to)->xy;
|
tile2 = Industry::Get(s->to)->xy;
|
||||||
} else {
|
} else {
|
||||||
SetDParam(4, STR_TOWN);
|
SetDParam(4, STR_TOWN);
|
||||||
SetDParam(5, s->to);
|
SetDParam(5, s->to);
|
||||||
tile2 = GetTown(s->to)->xy;
|
tile2 = Town::Get(s->to)->xy;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetDParam(1, STR_TOWN);
|
SetDParam(1, STR_TOWN);
|
||||||
SetDParam(2, s->from);
|
SetDParam(2, s->from);
|
||||||
tile = GetTown(s->from)->xy;
|
tile = Town::Get(s->from)->xy;
|
||||||
|
|
||||||
SetDParam(4, STR_TOWN);
|
SetDParam(4, STR_TOWN);
|
||||||
SetDParam(5, s->to);
|
SetDParam(5, s->to);
|
||||||
tile2 = GetTown(s->to)->xy;
|
tile2 = Town::Get(s->to)->xy;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetDParam(1, s->from);
|
SetDParam(1, s->from);
|
||||||
tile = GetStation(s->from)->xy;
|
tile = Station::Get(s->from)->xy;
|
||||||
|
|
||||||
SetDParam(2, s->to);
|
SetDParam(2, s->to);
|
||||||
tile2 = GetStation(s->to)->xy;
|
tile2 = Station::Get(s->to)->xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
tp.a = tile;
|
tp.a = tile;
|
||||||
|
@ -1069,7 +1069,7 @@ static void SubsidyMonthlyHandler()
|
||||||
modified = true;
|
modified = true;
|
||||||
AI::BroadcastNewEvent(new AIEventSubsidyOfferExpired(s - _subsidies));
|
AI::BroadcastNewEvent(new AIEventSubsidyOfferExpired(s - _subsidies));
|
||||||
} else if (s->age == 2 * 12 - 1) {
|
} else if (s->age == 2 * 12 - 1) {
|
||||||
st = GetStation(s->to);
|
st = Station::Get(s->to);
|
||||||
if (st->owner == _local_company) {
|
if (st->owner == _local_company) {
|
||||||
pair = SetupSubsidyDecodeParam(s, 1);
|
pair = SetupSubsidyDecodeParam(s, 1);
|
||||||
AddNewsItem(STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE, NS_SUBSIDIES, pair.a, pair.b);
|
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 */
|
/* Check distance from source */
|
||||||
const CargoSpec *cs = GetCargo(cargo_type);
|
const CargoSpec *cs = GetCargo(cargo_type);
|
||||||
if (cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) {
|
if (cs->town_effect == TE_PASSENGERS || cs->town_effect == TE_MAIL) {
|
||||||
xy = GetTown(s->from)->xy;
|
xy = Town::Get(s->from)->xy;
|
||||||
} else {
|
} else {
|
||||||
xy = GetIndustry(s->from)->xy;
|
xy = Industry::Get(s->from)->xy;
|
||||||
}
|
}
|
||||||
if (DistanceMax(xy, from->xy) > 9) continue;
|
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_MAIL:
|
||||||
case TE_GOODS:
|
case TE_GOODS:
|
||||||
case TE_FOOD:
|
case TE_FOOD:
|
||||||
xy = GetTown(s->to)->xy;
|
xy = Town::Get(s->to)->xy;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
xy = GetIndustry(s->to)->xy;
|
xy = Industry::Get(s->to)->xy;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (DistanceMax(xy, to->xy) > 9) continue;
|
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 */
|
/* Update company statistics */
|
||||||
{
|
{
|
||||||
Company *c = GetCompany(_current_company);
|
Company *c = Company::Get(_current_company);
|
||||||
c->cur_economy.delivered_cargo += num_pieces;
|
c->cur_economy.delivered_cargo += num_pieces;
|
||||||
SetBit(c->cargo_types, cargo_type);
|
SetBit(c->cargo_types, cargo_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get station pointers. */
|
/* Get station pointers. */
|
||||||
s_from = GetStation(source);
|
s_from = Station::Get(source);
|
||||||
s_to = GetStation(dest);
|
s_to = Station::Get(dest);
|
||||||
|
|
||||||
/* Check if a subsidy applies. */
|
/* Check if a subsidy applies. */
|
||||||
subsidised = CheckSubsidised(s_from, s_to, cargo_type);
|
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
|
Money virtual_profit = 0; // The virtual profit for entire vehicle chain
|
||||||
|
|
||||||
StationID last_visited = front_v->last_station_visited;
|
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 */
|
/* The owner of the train wants to be paid */
|
||||||
CompanyID old_company = _current_company;
|
CompanyID old_company = _current_company;
|
||||||
|
@ -1496,7 +1496,7 @@ void VehiclePayment(Vehicle *front_v)
|
||||||
Money profit = GetTransportedGoodsIncome(
|
Money profit = GetTransportedGoodsIncome(
|
||||||
cp->count,
|
cp->count,
|
||||||
/* pay transfer vehicle for only the part of transfer it has done: ie. cargo_loaded_at_xy to here */
|
/* 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,
|
cp->days_in_transit,
|
||||||
v->cargo_type);
|
v->cargo_type);
|
||||||
|
|
||||||
|
@ -1562,7 +1562,7 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
|
||||||
}
|
}
|
||||||
|
|
||||||
StationID last_visited = v->last_station_visited;
|
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)) {
|
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
|
/* The train reversed in the station. Take the "easy" way
|
||||||
|
@ -1837,7 +1837,7 @@ static void DoAcquireCompany(Company *c)
|
||||||
CompanyID ci = c->index;
|
CompanyID ci = c->index;
|
||||||
|
|
||||||
CompanyNewsInformation *cni = MallocT<CompanyNewsInformation>(1);
|
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(0, STR_NEWS_COMPANY_MERGER_TITLE);
|
||||||
SetDParam(1, c->bankrupt_value == 0 ? STR_NEWS_MERGER_TAKEOVER_TITLE : STR_NEWS_COMPANY_MERGER_DESCRIPTION);
|
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);
|
ChangeOwnershipOfCompanyItems(ci, _current_company);
|
||||||
|
|
||||||
if (c->bankrupt_value == 0) {
|
if (c->bankrupt_value == 0) {
|
||||||
owner = GetCompany(_current_company);
|
owner = Company::Get(_current_company);
|
||||||
owner->current_loan += c->current_loan;
|
owner->current_loan += c->current_loan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1893,7 +1893,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
* Cannot buy own shares */
|
* Cannot buy own shares */
|
||||||
if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
|
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 */
|
/* Protect new companies from hostile takeovers */
|
||||||
if (_cur_year - c->inaugurated_year < 6) return_cmd_error(STR_PROTECTED);
|
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 */
|
* Cannot sell own shares */
|
||||||
if (!IsValidCompanyID((CompanyID)p1) || !_settings_game.economy.allow_shares || _current_company == (CompanyID)p1) return CMD_ERROR;
|
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) */
|
/* Those lines are here for network-protection (clients can be slow) */
|
||||||
if (GetAmountOwnedBy(c, _current_company) == 0) return CommandCost();
|
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 */
|
/* Do not allow companies to take over themselves */
|
||||||
if (cid == _current_company) return CMD_ERROR;
|
if (cid == _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
Company *c = GetCompany(cid);
|
Company *c = Company::Get(cid);
|
||||||
|
|
||||||
if (!c->is_ai) return CMD_ERROR;
|
if (!c->is_ai) return CMD_ERROR;
|
||||||
|
|
||||||
|
|
|
@ -378,11 +378,11 @@ void SetCachedEngineCounts()
|
||||||
|
|
||||||
assert(v->engine_type < engines);
|
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;
|
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->type == g->vehicle_type);
|
||||||
assert(v->owner == g->owner);
|
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) */
|
/* Determine if an engine type is a wagon (and not a loco) */
|
||||||
static bool IsWagon(EngineID index)
|
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;
|
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)
|
static void AcceptEnginePreview(EngineID eid, CompanyID company)
|
||||||
{
|
{
|
||||||
Engine *e = GetEngine(eid);
|
Engine *e = Engine::Get(eid);
|
||||||
Company *c = GetCompany(company);
|
Company *c = Company::Get(company);
|
||||||
|
|
||||||
SetBit(e->company_avail, company);
|
SetBit(e->company_avail, company);
|
||||||
if (e->type == VEH_TRAIN) {
|
if (e->type == VEH_TRAIN) {
|
||||||
|
@ -623,7 +623,7 @@ CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
Engine *e;
|
Engine *e;
|
||||||
|
|
||||||
if (!IsEngineIndex(p1)) return CMD_ERROR;
|
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 (GetBestCompany(e->preview_company_rank) != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_company);
|
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) {
|
if (flags & DC_EXEC) {
|
||||||
Engine *e = GetEngine(p1);
|
Engine *e = Engine::Get(p1);
|
||||||
free(e->name);
|
free(e->name);
|
||||||
|
|
||||||
if (reset) {
|
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 */
|
/* check if it's an engine that is in the engine array */
|
||||||
if (!IsEngineIndex(engine)) return false;
|
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 */
|
/* check if it's an engine of specified type */
|
||||||
if (e->type != type) return false;
|
if (e->type != type) return false;
|
||||||
|
@ -782,7 +782,7 @@ bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
|
||||||
|
|
||||||
if (type == VEH_TRAIN) {
|
if (type == VEH_TRAIN) {
|
||||||
/* Check if the rail type is available to this company */
|
/* 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;
|
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 */
|
/* check if it's an engine that is in the engine array */
|
||||||
if (!IsEngineIndex(engine)) return false;
|
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;
|
if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
|
||||||
|
|
||||||
|
|
|
@ -87,34 +87,34 @@ static inline bool IsEngineIndex(uint index)
|
||||||
return index < GetEnginePoolSize();
|
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(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)
|
#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)
|
static inline const EngineInfo *EngInfo(EngineID e)
|
||||||
{
|
{
|
||||||
return &GetEngine(e)->info;
|
return &Engine::Get(e)->info;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline const RailVehicleInfo *RailVehInfo(EngineID e)
|
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)
|
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)
|
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)
|
static inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
|
||||||
{
|
{
|
||||||
return &GetEngine(e)->u.air;
|
return &Engine::Get(e)->u.air;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ENGINE_TYPE_H */
|
#endif /* ENGINE_TYPE_H */
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
StringID GetEngineCategoryName(EngineID engine)
|
StringID GetEngineCategoryName(EngineID engine)
|
||||||
{
|
{
|
||||||
switch (GetEngine(engine)->type) {
|
switch (Engine::Get(engine)->type) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case VEH_ROAD: return STR_ENGINE_PREVIEW_ROAD_VEHICLE;
|
case VEH_ROAD: return STR_ENGINE_PREVIEW_ROAD_VEHICLE;
|
||||||
case VEH_AIRCRAFT: return STR_ENGINE_PREVIEW_AIRCRAFT;
|
case VEH_AIRCRAFT: return STR_ENGINE_PREVIEW_AIRCRAFT;
|
||||||
|
@ -100,7 +100,7 @@ struct EnginePreviewWindow : Window {
|
||||||
SetDParam(0, engine);
|
SetDParam(0, engine);
|
||||||
DrawString(this->widget[EPW_BACKGROUND].left + 2, this->widget[EPW_BACKGROUND].right - 2, 80, STR_ENGINE_NAME, TC_BLACK, SA_CENTER);
|
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;
|
int width = this->width;
|
||||||
dei->engine_proc(width >> 1, 100, engine, 0);
|
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)
|
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(0, e->GetCost());
|
||||||
SetDParam(2, e->GetDisplayMaxSpeed());
|
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)
|
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();
|
CargoID cargo = e->GetDefaultCargoType();
|
||||||
|
|
||||||
if (cargo == CT_INVALID || cargo == CT_PASSENGERS) {
|
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)
|
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(0, e->GetCost());
|
||||||
SetDParam(1, e->GetDisplayMaxSpeed());
|
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)
|
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(0, e->GetCost());
|
||||||
SetDParam(1, e->GetDisplayMaxSpeed());
|
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)
|
void DrawNewsNewVehicleAvail(Window *w, const NewsItem *ni)
|
||||||
{
|
{
|
||||||
EngineID engine = ni->data_a;
|
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));
|
SetDParam(0, GetEngineCategoryName(engine));
|
||||||
DrawStringMultiLine(1, w->width - 2, 0, 56, STR_NEW_VEHICLE_NOW_AVAILABLE, TC_FROMSTRING, SA_CENTER);
|
DrawStringMultiLine(1, w->width - 2, 0, 56, STR_NEW_VEHICLE_NOW_AVAILABLE, TC_FROMSTRING, SA_CENTER);
|
||||||
|
|
|
@ -426,7 +426,7 @@ public:
|
||||||
int numd = 0;
|
int numd = 0;
|
||||||
for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
|
for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
|
||||||
if (IsValidCompanyID(k)) {
|
if (IsValidCompanyID(k)) {
|
||||||
c = GetCompany(k);
|
c = Company::Get(k);
|
||||||
this->colours[numd] = _colour_gradient[c->colour][6];
|
this->colours[numd] = _colour_gradient[c->colour][6];
|
||||||
for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
|
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);
|
this->cost[numd][i] = (j >= c->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j);
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct Group : PoolItem<Group, GroupID, &_Group_pool> {
|
||||||
|
|
||||||
static inline bool IsValidGroupID(GroupID index)
|
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)
|
static inline bool IsDefaultGroupID(GroupID index)
|
||||||
|
@ -50,7 +50,7 @@ static inline bool IsAllGroupID(GroupID id_g)
|
||||||
return id_g == ALL_GROUP;
|
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)
|
#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)
|
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)
|
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--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,10 @@ static inline void UpdateNumEngineGroup(EngineID i, GroupID old_g, GroupID new_g
|
||||||
{
|
{
|
||||||
if (old_g != 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 */
|
/* 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 */
|
/* 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;
|
if (!IsValidGroupID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Group *g = GetGroup(p1);
|
Group *g = Group::Get(p1);
|
||||||
if (g->owner != _current_company) return CMD_ERROR;
|
if (g->owner != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
@ -126,7 +126,7 @@ CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
Company *c;
|
Company *c;
|
||||||
EngineRenew *er;
|
EngineRenew *er;
|
||||||
|
|
||||||
c = GetCompany(_current_company);
|
c = Company::Get(_current_company);
|
||||||
FOR_ALL_ENGINE_RENEWS(er) {
|
FOR_ALL_ENGINE_RENEWS(er) {
|
||||||
if (er->group_id == g->index) RemoveEngineReplacementForCompany(c, er->from, g->index, flags);
|
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;
|
if (!IsValidGroupID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Group *g = GetGroup(p1);
|
Group *g = Group::Get(p1);
|
||||||
if (g->owner != _current_company) return CMD_ERROR;
|
if (g->owner != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
bool reset = StrEmpty(text);
|
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;
|
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)) {
|
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;
|
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;
|
VehicleType type = (VehicleType)p2;
|
||||||
if (!IsValidGroupID(p1) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
|
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 (g->owner != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
@ -322,7 +322,7 @@ CommandCost CmdSetGroupReplaceProtection(TileIndex tile, DoCommandFlag flags, ui
|
||||||
{
|
{
|
||||||
if (!IsValidGroupID(p1)) return CMD_ERROR;
|
if (!IsValidGroupID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Group *g = GetGroup(p1);
|
Group *g = Group::Get(p1);
|
||||||
if (g->owner != _current_company) return CMD_ERROR;
|
if (g->owner != _current_company) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
@ -395,9 +395,9 @@ void UpdateTrainGroupID(Vehicle *v)
|
||||||
|
|
||||||
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e)
|
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;
|
if (!IsDefaultGroupID(id_g)) return num;
|
||||||
|
|
||||||
const Group *g;
|
const Group *g;
|
||||||
|
|
|
@ -405,7 +405,7 @@ public:
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Group *g = GetGroup(this->group_sel);
|
const Group *g = Group::Get(this->group_sel);
|
||||||
|
|
||||||
SetDParam(0, g->index);
|
SetDParam(0, g->index);
|
||||||
SetDParam(1, g->num_vehicle);
|
SetDParam(1, g->num_vehicle);
|
||||||
|
@ -569,7 +569,7 @@ public:
|
||||||
case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
|
case GRP_WIDGET_RENAME_GROUP: { // Rename the selected roup
|
||||||
assert(IsValidGroupID(this->group_sel));
|
assert(IsValidGroupID(this->group_sel));
|
||||||
|
|
||||||
const Group *g = GetGroup(this->group_sel);
|
const Group *g = Group::Get(this->group_sel);
|
||||||
|
|
||||||
SetDParam(0, g->index);
|
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);
|
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:
|
case GRP_WIDGET_REPLACE_PROTECTION:
|
||||||
if (IsValidGroupID(this->group_sel)) {
|
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);
|
DoCommandP(0, this->group_sel, !g->replace_protection, CMD_SET_GROUP_REPLACE_PROTECTION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
|
||||||
this->background_img = SPR_TYCOON_IMG1_BEGIN;
|
this->background_img = SPR_TYCOON_IMG1_BEGIN;
|
||||||
|
|
||||||
if (_local_company != COMPANY_SPECTATOR) {
|
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) {
|
if (c->old_economy[0].performance_history == SCORE_MAX) {
|
||||||
this->background_img = SPR_TYCOON_IMG2_BEGIN;
|
this->background_img = SPR_TYCOON_IMG2_BEGIN;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
|
||||||
this->rank = SaveHighScoreValueNetwork();
|
this->rank = SaveHighScoreValueNetwork();
|
||||||
} else {
|
} else {
|
||||||
/* in single player _local company is always valid */
|
/* 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->window_number = _settings_game.difficulty.diff_level;
|
||||||
this->rank = SaveHighScoreValue(c);
|
this->rank = SaveHighScoreValue(c);
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow {
|
||||||
|
|
||||||
if (!IsValidCompanyID(_local_company)) return;
|
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
|
/* 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 */
|
* 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/
|
if (this->background_img == SPR_TYCOON_IMG2_BEGIN) { // Tycoon of the century \o/
|
||||||
|
|
|
@ -272,7 +272,7 @@ void SetIndustryDailyChanges();
|
||||||
*/
|
*/
|
||||||
static inline bool IsValidIndustryID(IndustryID index)
|
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)
|
#define FOR_ALL_INDUSTRIES(i) FOR_ALL_INDUSTRIES_FROM(i, 0)
|
||||||
|
|
||||||
static const uint8 IT_INVALID = 255;
|
static const uint8 IT_INVALID = 255;
|
||||||
|
|
|
@ -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.
|
/* 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. */
|
* 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
|
/** Build/Fund an industry
|
||||||
|
@ -2010,7 +2010,7 @@ int WhoCanServiceIndustry(Industry *ind)
|
||||||
FOR_VEHICLE_ORDERS(v, o) {
|
FOR_VEHICLE_ORDERS(v, o) {
|
||||||
if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
|
if (o->IsType(OT_GOTO_STATION) && !(o->GetUnloadType() & OUFB_TRANSFER)) {
|
||||||
/* Vehicle visits a station to load or unload */
|
/* Vehicle visits a station to load or unload */
|
||||||
Station *st = GetStation(o->GetDestination());
|
Station *st = Station::Get(o->GetDestination());
|
||||||
if (!st->IsValid()) continue;
|
if (!st->IsValid()) continue;
|
||||||
|
|
||||||
/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
|
/* Same cargo produced by industry is dropped here => not serviced by vehicle v */
|
||||||
|
|
|
@ -485,13 +485,13 @@ public:
|
||||||
this->editbox_line = 0;
|
this->editbox_line = 0;
|
||||||
this->clicked_line = 0;
|
this->clicked_line = 0;
|
||||||
this->clicked_button = 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);
|
this->FindWindowPlacementAndResize(desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
Industry *i = GetIndustry(this->window_number);
|
Industry *i = Industry::Get(this->window_number);
|
||||||
const IndustrySpec *ind = GetIndustrySpec(i->type);
|
const IndustrySpec *ind = GetIndustrySpec(i->type);
|
||||||
int y = this->widget[IVW_INFO].top + 1;
|
int y = this->widget[IVW_INFO].top + 1;
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -594,7 +594,7 @@ public:
|
||||||
case IVW_INFO: {
|
case IVW_INFO: {
|
||||||
int line, x;
|
int line, x;
|
||||||
|
|
||||||
i = GetIndustry(this->window_number);
|
i = Industry::Get(this->window_number);
|
||||||
|
|
||||||
/* We should work if needed.. */
|
/* We should work if needed.. */
|
||||||
if (!IsProductionAlterable(i)) return;
|
if (!IsProductionAlterable(i)) return;
|
||||||
|
@ -628,7 +628,7 @@ public:
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case IVW_GOTO:
|
case IVW_GOTO:
|
||||||
i = GetIndustry(this->window_number);
|
i = Industry::Get(this->window_number);
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1));
|
ShowExtraViewPortWindow(i->xy + TileDiffXY(1, 1));
|
||||||
} else {
|
} else {
|
||||||
|
@ -660,7 +660,7 @@ public:
|
||||||
{
|
{
|
||||||
if (StrEmpty(str)) return;
|
if (StrEmpty(str)) return;
|
||||||
|
|
||||||
Industry *i = GetIndustry(this->window_number);
|
Industry *i = Industry::Get(this->window_number);
|
||||||
int line = this->editbox_line;
|
int line = this->editbox_line;
|
||||||
|
|
||||||
i->production_rate[line] = ClampU(atoi(str), 0, 255);
|
i->production_rate[line] = ClampU(atoi(str), 0, 255);
|
||||||
|
|
|
@ -70,7 +70,7 @@ static inline IndustryID GetIndustryIndex(TileIndex t)
|
||||||
*/
|
*/
|
||||||
static inline Industry *GetIndustryByTile(TileIndex t)
|
static inline Industry *GetIndustryByTile(TileIndex t)
|
||||||
{
|
{
|
||||||
return GetIndustry(GetIndustryIndex(t));
|
return Industry::Get(GetIndustryIndex(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -61,7 +61,7 @@ void HandleOnEditText(const char *str)
|
||||||
switch (_rename_what) {
|
switch (_rename_what) {
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
case 3: { // Give money, you can only give money in excess of loan
|
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));
|
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
|
uint32 money_c = Clamp(ClampToI32(money), 0, 20000000); // Clamp between 20 million and 0
|
||||||
|
|
|
@ -35,7 +35,7 @@ CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32
|
||||||
if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
|
if (!IsValidCompanyManagerFace(cmf)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
GetCompany(_current_company)->face = cmf;
|
Company::Get(_current_company)->face = cmf;
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
return CommandCost();
|
return CommandCost();
|
||||||
|
@ -60,7 +60,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
|
|
||||||
if (scheme >= LS_END || state >= 3) return CMD_ERROR;
|
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 */
|
/* Ensure no two companies have the same primary colour */
|
||||||
if (scheme == LS_DEFAULT && state == 0) {
|
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)
|
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) {
|
if (c->current_loan >= _economy.max_loan) {
|
||||||
SetDParam(0, _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)
|
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);
|
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) {
|
if (flags & DC_EXEC) {
|
||||||
Company *c = GetCompany(_current_company);
|
Company *c = Company::Get(_current_company);
|
||||||
free(c->name);
|
free(c->name);
|
||||||
c->name = reset ? NULL : strdup(text);
|
c->name = reset ? NULL : strdup(text);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
@ -278,7 +278,7 @@ CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Company *c = GetCompany(_current_company);
|
Company *c = Company::Get(_current_company);
|
||||||
free(c->president_name);
|
free(c->president_name);
|
||||||
|
|
||||||
if (reset) {
|
if (reset) {
|
||||||
|
@ -382,7 +382,7 @@ CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
{
|
{
|
||||||
if (!_settings_game.economy.give_money) return CMD_ERROR;
|
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));
|
CommandCost amount(EXPENSES_OTHER, min((Money)p1, (Money)20000000LL));
|
||||||
|
|
||||||
/* You can only transfer funds that is in excess of your loan */
|
/* You can only transfer funds that is in excess of your loan */
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
LandInfoWindow(TileIndex tile) : Window(&_land_info_desc) {
|
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);
|
Town *t = ClosestTownFromTile(tile, _settings_game.economy.dist_local_authority);
|
||||||
|
|
||||||
Money old_money = c->money;
|
Money old_money = c->money;
|
||||||
|
@ -556,7 +556,7 @@ public:
|
||||||
RewindTextRefStack();
|
RewindTextRefStack();
|
||||||
|
|
||||||
if (this->show_company_manager_face) {
|
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);
|
DrawCompanyManagerFace(c->face, c->colour, this->widget[EMW_FACE].left, this->widget[EMW_FACE].top);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,10 +110,10 @@ public:
|
||||||
|
|
||||||
static inline bool IsValidNetworkClientSocketIndex(ClientIndex index)
|
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)
|
#define FOR_ALL_CLIENT_SOCKETS(d) FOR_ALL_CLIENT_SOCKETS_FROM(d, 0)
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -97,7 +97,7 @@ extern void StateGameLoop();
|
||||||
*/
|
*/
|
||||||
NetworkClientInfo *NetworkFindClientInfoFromIndex(ClientIndex index)
|
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);
|
NetworkError(STR_NETWORK_ERR_DESYNC);
|
||||||
DEBUG(desync, 1, "sync_err: %d; %d\n", _date, _date_fract);
|
DEBUG(desync, 1, "sync_err: %d; %d\n", _date, _date_fract);
|
||||||
DEBUG(net, 0, "Sync error detected!");
|
DEBUG(net, 0, "Sync error detected!");
|
||||||
NetworkClientError(NETWORK_RECV_STATUS_DESYNC, GetNetworkClientSocket(0));
|
NetworkClientError(NETWORK_RECV_STATUS_DESYNC, NetworkClientSocket::Get(0));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,10 @@ struct NetworkClientInfo : PoolItem<NetworkClientInfo, ClientIndex, &_NetworkCli
|
||||||
|
|
||||||
static inline bool IsValidNetworkClientInfoIndex(ClientIndex index)
|
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)
|
#define FOR_ALL_CLIENT_INFOS(d) FOR_ALL_CLIENT_INFOS_FROM(d, 0)
|
||||||
|
|
||||||
#endif /* ENABLE_NETWORK */
|
#endif /* ENABLE_NETWORK */
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
|
|
||||||
/* So we don't make too much typos ;) */
|
/* So we don't make too much typos ;) */
|
||||||
#define MY_CLIENT GetNetworkClientSocket(0)
|
#define MY_CLIENT NetworkClientSocket::Get(0)
|
||||||
|
|
||||||
static uint32 last_ack_frame;
|
static uint32 last_ack_frame;
|
||||||
|
|
||||||
|
|
|
@ -1237,7 +1237,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MOVE)
|
||||||
/* Check if the company is valid */
|
/* Check if the company is valid */
|
||||||
if (!IsValidCompanyID(company_id) && company_id != COMPANY_SPECTATOR) return;
|
if (!IsValidCompanyID(company_id) && company_id != COMPANY_SPECTATOR) return;
|
||||||
/* We don't allow moving to AI companies */
|
/* 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 */
|
/* Check if we require a password for this company */
|
||||||
if (company_id != COMPANY_SPECTATOR && !StrEmpty(_network_company_states[company_id].password)) {
|
if (company_id != COMPANY_SPECTATOR && !StrEmpty(_network_company_states[company_id].password)) {
|
||||||
|
|
|
@ -354,13 +354,13 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
|
||||||
|
|
||||||
/* Check if the engine is registered in the override manager */
|
/* Check if the engine is registered in the override manager */
|
||||||
EngineID engine = _engine_mngr.GetID(type, internal_id, scope_grfid);
|
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 */
|
/* Check if there is an unreserved slot */
|
||||||
EngineID engine = _engine_mngr.GetID(type, internal_id, INVALID_GRFID);
|
EngineID engine = _engine_mngr.GetID(type, internal_id, INVALID_GRFID);
|
||||||
if (engine != INVALID_ENGINE) {
|
if (engine != INVALID_ENGINE) {
|
||||||
Engine *e = GetEngine(engine);
|
Engine *e = Engine::Get(engine);
|
||||||
|
|
||||||
if (e->grffile == NULL) {
|
if (e->grffile == NULL) {
|
||||||
e->grffile = file;
|
e->grffile = file;
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct WagonOverride {
|
||||||
|
|
||||||
void SetWagonOverrideSprites(EngineID engine, CargoID cargo, const SpriteGroup *group, EngineID *train_id, uint trains)
|
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;
|
WagonOverride *wo;
|
||||||
|
|
||||||
assert(cargo < NUM_CARGO + 2); // Include CT_DEFAULT and CT_PURCHASE pseudo cargos.
|
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 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
|
/* XXX: This could turn out to be a timesink on profiles. We could
|
||||||
* always just dedicate 65535 bytes for an [engine][train] trampoline
|
* 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)
|
void SetCustomEngineSprites(EngineID engine, byte cargo, const SpriteGroup *group)
|
||||||
{
|
{
|
||||||
Engine *e = GetEngine(engine);
|
Engine *e = Engine::Get(engine);
|
||||||
assert(cargo < lengthof(e->group));
|
assert(cargo < lengthof(e->group));
|
||||||
|
|
||||||
if (e->group[cargo] != NULL) {
|
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)
|
void SetEngineGRF(EngineID engine, const GRFFile *file)
|
||||||
{
|
{
|
||||||
Engine *e = GetEngine(engine);
|
Engine *e = Engine::Get(engine);
|
||||||
e->grffile = file;
|
e->grffile = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void SetEngineGRF(EngineID engine, const GRFFile *file)
|
||||||
*/
|
*/
|
||||||
const GRFFile *GetEngineGRF(EngineID engine)
|
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 0x43: return _current_company | (LiveryHelper(object->u.vehicle.self_type, NULL) << 24); // Owner information
|
||||||
case 0x46: return 0; // Motion counter
|
case 0x46: return 0; // Motion counter
|
||||||
case 0x47: { // Vehicle cargo info
|
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();
|
CargoID cargo_type = e->GetDefaultCargoType();
|
||||||
if (cargo_type != CT_INVALID) {
|
if (cargo_type != CT_INVALID) {
|
||||||
const CargoSpec *cs = GetCargo(cargo_type);
|
const CargoSpec *cs = GetCargo(cargo_type);
|
||||||
|
@ -488,7 +488,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||||
return 0x000000FF;
|
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 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 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year
|
||||||
case 0xDA: return INVALID_VEHICLE; // Next vehicle
|
case 0xDA: return INVALID_VEHICLE; // Next vehicle
|
||||||
|
@ -576,7 +576,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||||
|
|
||||||
case 0x43: // Company information
|
case 0x43: // Company information
|
||||||
if (!HasBit(v->cache_valid, 3)) {
|
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);
|
SetBit(v->cache_valid, 3);
|
||||||
}
|
}
|
||||||
return v->cached_var43;
|
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];
|
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;
|
case 0x49: return v->build_year;
|
||||||
|
|
||||||
/* Variables which use the parameter */
|
/* Variables which use the parameter */
|
||||||
case 0x60: // Count consist's engine ID occurance
|
case 0x60: // Count consist's engine ID occurance
|
||||||
//EngineID engine = GetNewEngineID(GetEngineGRF(v->engine_type), v->type, parameter);
|
//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;
|
uint count = 0;
|
||||||
for (; v != NULL; v = v->Next()) {
|
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;
|
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 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 0x44: return Clamp(v->build_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR;
|
||||||
case 0x45: return v->unitnumber;
|
case 0x45: return v->unitnumber;
|
||||||
case 0x46: return GetEngine(v->engine_type)->internal_id;
|
case 0x46: return Engine::Get(v->engine_type)->internal_id;
|
||||||
case 0x47: return GB(GetEngine(v->engine_type)->internal_id, 8, 8);
|
case 0x47: return GB(Engine::Get(v->engine_type)->internal_id, 8, 8);
|
||||||
case 0x48:
|
case 0x48:
|
||||||
if (v->type != VEH_TRAIN || v->spritenum != 0xFD) return v->spritenum;
|
if (v->type != VEH_TRAIN || v->spritenum != 0xFD) return v->spritenum;
|
||||||
return HasBit(v->u.rail.flags, VRF_REVERSE_DIRECTION) ? 0xFE : 0xFD;
|
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->reseed = 0;
|
||||||
res->count = 0;
|
res->count = 0;
|
||||||
|
|
||||||
const Engine *e = GetEngine(engine_type);
|
const Engine *e = Engine::Get(engine_type);
|
||||||
res->grffile = (e != NULL ? e->grffile : NULL);
|
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));
|
assert(cargo < lengthof(e->group));
|
||||||
group = e->group[cargo];
|
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)
|
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 */
|
/* Only valid for helicopters */
|
||||||
assert(e->type == VEH_AIRCRAFT);
|
assert(e->type == VEH_AIRCRAFT);
|
||||||
|
@ -1107,7 +1107,7 @@ void TriggerVehicle(Vehicle *v, VehicleTrigger trigger)
|
||||||
*/
|
*/
|
||||||
uint ListPositionOfEngine(EngineID engine)
|
uint ListPositionOfEngine(EngineID engine)
|
||||||
{
|
{
|
||||||
const Engine *e = GetEngine(engine);
|
const Engine *e = Engine::Get(engine);
|
||||||
if (e->grffile == NULL) return e->list_position;
|
if (e->grffile == NULL) return e->list_position;
|
||||||
|
|
||||||
/* Crude sorting to group by GRF ID */
|
/* Crude sorting to group by GRF ID */
|
||||||
|
@ -1142,7 +1142,7 @@ void CommitVehicleListOrderChanges()
|
||||||
|
|
||||||
if (engine == target) continue;
|
if (engine == target) continue;
|
||||||
|
|
||||||
Engine *source_e = GetEngine(engine);
|
Engine *source_e = Engine::Get(engine);
|
||||||
Engine *target_e = NULL;
|
Engine *target_e = NULL;
|
||||||
|
|
||||||
/* Populate map with current list positions */
|
/* Populate map with current list positions */
|
||||||
|
|
|
@ -215,7 +215,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
|
||||||
bool is_ai = false;
|
bool is_ai = false;
|
||||||
|
|
||||||
if (IsValidCompanyID(industry->founder)) {
|
if (IsValidCompanyID(industry->founder)) {
|
||||||
const Company *c = GetCompany(industry->founder);
|
const Company *c = Company::Get(industry->founder);
|
||||||
const Livery *l = &c->livery[LS_DEFAULT];
|
const Livery *l = &c->livery[LS_DEFAULT];
|
||||||
|
|
||||||
is_ai = c->is_ai;
|
is_ai = c->is_ai;
|
||||||
|
|
|
@ -254,7 +254,7 @@ struct NewsWindow : Window {
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
if (this->ni->flags & NF_VEHICLE) {
|
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);
|
ScrollMainWindowTo(v->x_pos, v->y_pos, v->z_pos);
|
||||||
} else if (this->ni->flags & NF_TILE) {
|
} else if (this->ni->flags & NF_TILE) {
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
|
|
|
@ -277,6 +277,14 @@ struct PoolItem {
|
||||||
Tpool->UpdateFirstFreeIndex(pn->index);
|
Tpool->UpdateFirstFreeIndex(pn->index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get item with given index
|
||||||
|
*/
|
||||||
|
static FORCEINLINE T *Get(uint index)
|
||||||
|
{
|
||||||
|
return Tpool->Get(index);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static T *AllocateSafeRaw(uint &first);
|
static T *AllocateSafeRaw(uint &first);
|
||||||
|
|
||||||
|
@ -326,7 +334,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
#define OLD_POOL_ACCESSORS(name, type) \
|
#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(); }
|
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) \
|
#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) \
|
OLD_POOL_ENUM(name, type, block_size_bits, max_blocks) \
|
||||||
static DEFINE_OLD_POOL(name, type, new_block_proc, clean_block_proc) \
|
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 */
|
#endif /* OLDPOOL_H */
|
||||||
|
|
|
@ -754,7 +754,7 @@ static void MakeNewGameDone()
|
||||||
/* Create a single company */
|
/* Create a single company */
|
||||||
DoStartupNewCompany(false);
|
DoStartupNewCompany(false);
|
||||||
|
|
||||||
Company *c = GetCompany(COMPANY_FIRST);
|
Company *c = Company::Get(COMPANY_FIRST);
|
||||||
c->settings = _settings_client.company;
|
c->settings = _settings_client.company;
|
||||||
|
|
||||||
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
IConsoleCmdExec("exec scripts/game_start.scr 0");
|
||||||
|
@ -851,7 +851,7 @@ static void StartScenario()
|
||||||
|
|
||||||
SetLocalCompany(COMPANY_FIRST);
|
SetLocalCompany(COMPANY_FIRST);
|
||||||
_current_company = _local_company;
|
_current_company = _local_company;
|
||||||
Company *c = GetCompany(COMPANY_FIRST);
|
Company *c = Company::Get(COMPANY_FIRST);
|
||||||
c->settings = _settings_client.company;
|
c->settings = _settings_client.company;
|
||||||
|
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
|
@ -423,17 +423,17 @@ public:
|
||||||
|
|
||||||
static inline bool IsValidOrderListID(uint index)
|
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_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_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)
|
#define FOR_ALL_ORDER_LISTS(ol) FOR_ALL_ORDER_LISTS_FROM(ol, 0)
|
||||||
|
|
||||||
#endif /* ORDER_H */
|
#endif /* ORDER_H */
|
||||||
|
|
|
@ -379,8 +379,8 @@ static TileIndex GetOrderLocation(const Order& o)
|
||||||
{
|
{
|
||||||
switch (o.GetType()) {
|
switch (o.GetType()) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case OT_GOTO_STATION: return GetStation(o.GetDestination())->xy;
|
case OT_GOTO_STATION: return Station::Get(o.GetDestination())->xy;
|
||||||
case OT_GOTO_DEPOT: return GetDepot(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;
|
if (!IsValidVehicleID(veh)) return CMD_ERROR;
|
||||||
|
|
||||||
v = GetVehicle(veh);
|
v = Vehicle::Get(veh);
|
||||||
|
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -428,7 +428,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
case OT_GOTO_STATION: {
|
case OT_GOTO_STATION: {
|
||||||
if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR;
|
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;
|
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 (v->type == VEH_AIRCRAFT) {
|
||||||
if (!IsValidStationID(new_order.GetDestination())) return CMD_ERROR;
|
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) ||
|
if (!CheckOwnership(st->owner) ||
|
||||||
!CanVehicleUseStation(v, st) ||
|
!CanVehicleUseStation(v, st) ||
|
||||||
|
@ -484,7 +484,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
} else {
|
} else {
|
||||||
if (!IsValidDepotID(new_order.GetDestination())) return CMD_ERROR;
|
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;
|
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 (v->type != VEH_TRAIN) return CMD_ERROR;
|
||||||
|
|
||||||
if (!IsValidWaypointID(new_order.GetDestination())) 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;
|
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;
|
if (!IsValidVehicleID(veh_id)) return CMD_ERROR;
|
||||||
|
|
||||||
v = GetVehicle(veh_id);
|
v = Vehicle::Get(veh_id);
|
||||||
|
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
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;
|
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 ||
|
if (!CheckOwnership(v->owner) || sel_ord == v->cur_order_index ||
|
||||||
sel_ord >= v->GetNumOrders() || v->GetNumOrders() < 2) return CMD_ERROR;
|
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;
|
if (!IsValidVehicleID(veh)) return CMD_ERROR;
|
||||||
|
|
||||||
Vehicle *v = GetVehicle(veh);
|
Vehicle *v = Vehicle::Get(veh);
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
/* Don't make senseless movements */
|
/* 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 (mof >= MOF_END) return CMD_ERROR;
|
||||||
if (!IsValidVehicleID(veh)) 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;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
/* Is it a valid order? */
|
/* Is it a valid order? */
|
||||||
|
@ -863,7 +863,7 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
Order *order = GetVehicleOrder(v, sel_ord);
|
Order *order = GetVehicleOrder(v, sel_ord);
|
||||||
switch (order->GetType()) {
|
switch (order->GetType()) {
|
||||||
case OT_GOTO_STATION:
|
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;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
|
@ -1078,7 +1078,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
|
|
||||||
if (!IsValidVehicleID(veh_dst)) return CMD_ERROR;
|
if (!IsValidVehicleID(veh_dst)) return CMD_ERROR;
|
||||||
|
|
||||||
dst = GetVehicle(veh_dst);
|
dst = Vehicle::Get(veh_dst);
|
||||||
|
|
||||||
if (!CheckOwnership(dst->owner)) return CMD_ERROR;
|
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;
|
if (!IsValidVehicleID(veh_src)) return CMD_ERROR;
|
||||||
|
|
||||||
src = GetVehicle(veh_src);
|
src = Vehicle::Get(veh_src);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src)
|
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) {
|
FOR_VEHICLE_ORDERS(src, order) {
|
||||||
if (OrderGoesToStation(dst, 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);
|
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;
|
if (!IsValidVehicleID(veh_src)) return CMD_ERROR;
|
||||||
|
|
||||||
src = GetVehicle(veh_src);
|
src = Vehicle::Get(veh_src);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
if (!CheckOwnership(src->owner) || dst->type != src->type || dst == src)
|
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;
|
const Order *order;
|
||||||
FOR_VEHICLE_ORDERS(src, order) {
|
FOR_VEHICLE_ORDERS(src, order) {
|
||||||
if (OrderGoesToStation(dst, 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);
|
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;
|
if (!IsValidVehicleID(veh)) return CMD_ERROR;
|
||||||
|
|
||||||
v = GetVehicle(veh);
|
v = Vehicle::Get(veh);
|
||||||
|
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
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;
|
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 */
|
/* Check the vehicle type and ownership, and if the service interval and order are in range */
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
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? */
|
/* Does station have a load-bay for this vehicle? */
|
||||||
if (order->IsType(OT_GOTO_STATION)) {
|
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);
|
TileIndex required_tile = GetStationTileForVehicle(v, st);
|
||||||
|
|
||||||
n_st++;
|
n_st++;
|
||||||
|
@ -1657,12 +1657,12 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth)
|
||||||
v->IncrementOrderIndex();
|
v->IncrementOrderIndex();
|
||||||
}
|
}
|
||||||
} else if (v->type != VEH_AIRCRAFT) {
|
} else if (v->type != VEH_AIRCRAFT) {
|
||||||
v->dest_tile = GetDepot(order->GetDestination())->xy;
|
v->dest_tile = Depot::Get(order->GetDestination())->xy;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_GOTO_WAYPOINT:
|
case OT_GOTO_WAYPOINT:
|
||||||
v->dest_tile = GetWaypoint(order->GetDestination())->xy;
|
v->dest_tile = Waypoint::Get(order->GetDestination())->xy;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OT_CONDITIONAL: {
|
case OT_CONDITIONAL: {
|
||||||
|
@ -1769,7 +1769,7 @@ bool ProcessOrders(Vehicle *v)
|
||||||
|
|
||||||
/* If it is unchanged, keep it. */
|
/* If it is unchanged, keep it. */
|
||||||
if (order->Equals(v->current_order) && (v->type == VEH_AIRCRAFT || v->dest_tile != 0) &&
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
|
||||||
SetDParam(3, STR_ORDER_NEAREST_DEPOT);
|
SetDParam(3, STR_ORDER_NEAREST_DEPOT);
|
||||||
} else {
|
} else {
|
||||||
SetDParam(1, STR_GO_TO_DEPOT);
|
SetDParam(1, STR_GO_TO_DEPOT);
|
||||||
SetDParam(3, GetDepot(order->GetDestination())->town_index);
|
SetDParam(3, Depot::Get(order->GetDestination())->town_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
|
@ -351,7 +351,7 @@ static Order GetOrderCmdFromTile(const Vehicle *v, TileIndex tile)
|
||||||
|
|
||||||
if (IsTileType(tile, MP_STATION)) {
|
if (IsTileType(tile, MP_STATION)) {
|
||||||
StationID st_index = GetStationIndex(tile);
|
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) {
|
if (st->owner == _local_company || st->owner == OWNER_NONE) {
|
||||||
byte facil;
|
byte facil;
|
||||||
|
@ -659,7 +659,7 @@ public:
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 0:
|
case 0:
|
||||||
/* Autoreplace replaced the vehicle */
|
/* Autoreplace replaced the vehicle */
|
||||||
this->vehicle = GetVehicle(this->window_number);
|
this->vehicle = Vehicle::Get(this->window_number);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
|
@ -762,7 +762,7 @@ public:
|
||||||
this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
this->SetWidgetLoweredState(ORDER_WIDGET_NON_STOP, order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS);
|
||||||
switch (order->GetType()) {
|
switch (order->GetType()) {
|
||||||
case OT_GOTO_STATION:
|
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_FULL_LOAD, order->GetLoadType() == OLF_FULL_LOAD_ANY);
|
||||||
this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
|
this->SetWidgetLoweredState(ORDER_WIDGET_UNLOAD, order->GetUnloadType() == OUFB_UNLOAD);
|
||||||
break;
|
break;
|
||||||
|
@ -856,11 +856,11 @@ public:
|
||||||
TileIndex xy = INVALID_TILE;
|
TileIndex xy = INVALID_TILE;
|
||||||
|
|
||||||
switch (ord->GetType()) {
|
switch (ord->GetType()) {
|
||||||
case OT_GOTO_STATION: xy = GetStation(ord->GetDestination())->xy ; break;
|
case OT_GOTO_STATION: xy = Station::Get(ord->GetDestination())->xy ; break;
|
||||||
case OT_GOTO_WAYPOINT: xy = GetWaypoint(ord->GetDestination())->xy; break;
|
case OT_GOTO_WAYPOINT: xy = Waypoint::Get(ord->GetDestination())->xy; break;
|
||||||
case OT_GOTO_DEPOT:
|
case OT_GOTO_DEPOT:
|
||||||
if ((ord->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0) break;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -88,7 +88,7 @@ void NewTrainPathfind(TileIndex tile, TileIndex dest, RailTypes railtypes, DiagD
|
||||||
*/
|
*/
|
||||||
static inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile)
|
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 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;
|
if (st->train_tile == INVALID_TILE) return st->xy;
|
||||||
|
|
|
@ -170,7 +170,7 @@ RailType GetTileRailType(TileIndex tile)
|
||||||
|
|
||||||
bool HasRailtypeAvail(const CompanyID company, const RailType railtype)
|
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)
|
bool ValParamRailtype(const RailType rail)
|
||||||
|
|
|
@ -85,7 +85,7 @@ bool HasRoadTypesAvail(const CompanyID company, const RoadTypes rts)
|
||||||
avail_roadtypes = ROADTYPES_ROAD;
|
avail_roadtypes = ROADTYPES_ROAD;
|
||||||
} else {
|
} else {
|
||||||
if (!IsValidCompanyID(company)) return false;
|
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;
|
return (rts & ~avail_roadtypes) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ static SpriteID GetRoadVehIcon(EngineID engine)
|
||||||
SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
|
SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
|
||||||
if (sprite != 0) return sprite;
|
if (sprite != 0) return sprite;
|
||||||
|
|
||||||
spritenum = GetEngine(engine)->image_index;
|
spritenum = Engine::Get(engine)->image_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 6 + _roadveh_images[spritenum];
|
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)));
|
sprite = GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)));
|
||||||
if (sprite != 0) return sprite;
|
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];
|
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);
|
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 */
|
/* Engines without valid cargo should not be available */
|
||||||
if (e->GetDefaultCargoType() == CT_INVALID) return CMD_ERROR;
|
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
|
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);
|
CheckConsistencyOfArticulatedVehicle(v);
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ CommandCost CmdSellRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
|
|
||||||
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
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->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;
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Vehicle *v = GetVehicle(p1);
|
Vehicle *v = Vehicle::Get(p1);
|
||||||
|
|
||||||
if (v->type != VEH_ROAD) return CMD_ERROR;
|
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;
|
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->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;
|
if (station == this->last_station_visited) this->last_station_visited = INVALID_STATION;
|
||||||
|
|
||||||
TileIndex dest = INVALID_TILE;
|
TileIndex dest = INVALID_TILE;
|
||||||
const RoadStop *rs = GetStation(station)->GetPrimaryRoadStop(this);
|
const RoadStop *rs = Station::Get(station)->GetPrimaryRoadStop(this);
|
||||||
if (rs != NULL) {
|
if (rs != NULL) {
|
||||||
uint mindist = UINT_MAX;
|
uint mindist = UINT_MAX;
|
||||||
|
|
||||||
|
@ -1882,7 +1882,7 @@ void RoadVehicle::OnNewDay()
|
||||||
|
|
||||||
/* update destination */
|
/* 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)) {
|
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 *rs = st->GetPrimaryRoadStop(this);
|
||||||
RoadStop *best = NULL;
|
RoadStop *best = NULL;
|
||||||
|
|
||||||
|
@ -1978,7 +1978,7 @@ CommandCost CmdRefitRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
|
|
||||||
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
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->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_ROAD_MUST_BE_STOPPED_INSIDE_DEPOT);
|
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. */
|
* [Refit] button near each wagon. */
|
||||||
if (!CanRefitTo(v->engine_type, new_cid)) continue;
|
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 (!e->CanCarryCargo()) continue;
|
||||||
|
|
||||||
if (HasBit(EngInfo(v->engine_type)->callbackmask, CBM_VEHICLE_REFIT_CAPACITY)) {
|
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;
|
_returned_refit_capacity = total_capacity;
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
|
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
v = GetVehicle(_new_vehicle_id);
|
v = Vehicle::Get(_new_vehicle_id);
|
||||||
if (v->tile == _backup_orders_tile) {
|
if (v->tile == _backup_orders_tile) {
|
||||||
_backup_orders_tile = 0;
|
_backup_orders_tile = 0;
|
||||||
RestoreVehicleOrders(v);
|
RestoreVehicleOrders(v);
|
||||||
|
|
|
@ -674,7 +674,7 @@ bool AfterLoadGame()
|
||||||
* companies are 'invalid'.
|
* companies are 'invalid'.
|
||||||
*/
|
*/
|
||||||
if (!_network_dedicated && IsValidCompanyID(COMPANY_FIRST)) {
|
if (!_network_dedicated && IsValidCompanyID(COMPANY_FIRST)) {
|
||||||
c = GetCompany(COMPANY_FIRST);
|
c = Company::Get(COMPANY_FIRST);
|
||||||
c->settings = _settings_client.company;
|
c->settings = _settings_client.company;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1203,7 +1203,7 @@ bool AfterLoadGame()
|
||||||
const CargoList::List *packets = v->cargo.Packets();
|
const CargoList::List *packets = v->cargo.Packets();
|
||||||
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
|
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
|
||||||
CargoPacket *cp = *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;
|
cp->loaded_at_xy = cp->source_xy;
|
||||||
}
|
}
|
||||||
v->cargo.InvalidateCache();
|
v->cargo.InvalidateCache();
|
||||||
|
@ -1222,7 +1222,7 @@ bool AfterLoadGame()
|
||||||
const CargoList::List *packets = ge->cargo.Packets();
|
const CargoList::List *packets = ge->cargo.Packets();
|
||||||
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
|
for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) {
|
||||||
CargoPacket *cp = *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;
|
cp->loaded_at_xy = cp->source_xy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1300,7 +1300,7 @@ bool AfterLoadGame()
|
||||||
if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs
|
if ((v->type != VEH_TRAIN || IsFrontEngine(v)) && // for all locs
|
||||||
!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
|
!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
|
||||||
v->current_order.IsType(OT_LOADING)) { // loading
|
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
|
/* The loading finished flag is *only* set when actually completely
|
||||||
* finished. Because the vehicle is loading, it is not finished. */
|
* 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 */
|
/* Update go to buoy orders because they are just waypoints */
|
||||||
Order *order;
|
Order *order;
|
||||||
FOR_ALL_ORDERS(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->SetLoadType(OLF_LOAD_IF_POSSIBLE);
|
||||||
order->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
|
order->SetUnloadType(OUF_UNLOAD_IF_POSSIBLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
/* 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 */
|
* with an invalid order (OT_NOTHING) as indication that it is the last order */
|
||||||
if (num > 0 && GetOrder(num)->IsValid()) {
|
if (num > 0 && Order::Get(num)->IsValid()) {
|
||||||
GetOrder(num - 1)->next = GetOrder(num);
|
Order::Get(num - 1)->next = Order::Get(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
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 */
|
/* for TTO games, 12th (num == 11) goods entry is created in the Station constructor */
|
||||||
if (_savegame_type == SGT_TTO && num == 11) return true;
|
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];
|
GoodsEntry *ge = &st->goods[num];
|
||||||
|
|
||||||
if (!LoadChunk(ls, ge, goods_chunk)) return false;
|
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 (!LoadChunk(ls, st, station_chunk)) return false;
|
||||||
|
|
||||||
if (st->xy != 0) {
|
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 (_savegame_type == SGT_TTO) {
|
||||||
if (IsInsideBS(_old_string_id, 0x180F, 32)) {
|
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 (!LoadChunk(ls, i, industry_chunk)) return false;
|
||||||
|
|
||||||
if (i->xy != 0) {
|
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 (_savegame_type == SGT_TTO) {
|
||||||
if (i->type > 0x06) i->type++; // Printing Works were added
|
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)
|
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++) {
|
for (uint i = 0; i < 13; i++) {
|
||||||
if (_savegame_type == SGT_TTO && i == 6) {
|
if (_savegame_type == SGT_TTO && i == 6) {
|
||||||
|
@ -927,7 +927,7 @@ static const OldChunks _company_economy_chunk[] = {
|
||||||
|
|
||||||
static bool LoadOldCompanyEconomy(LoadgameState *ls, int num)
|
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;
|
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)
|
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;
|
uint temp = ls->total_read;
|
||||||
bool res;
|
bool res;
|
||||||
|
|
||||||
|
@ -1358,11 +1358,11 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
|
||||||
if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
|
if (_old_order_ptr != 0 && _old_order_ptr != 0xFFFFFFFF) {
|
||||||
uint max = _savegame_type == SGT_TTO ? 3000 : 5000;
|
uint max = _savegame_type == SGT_TTO ? 3000 : 5000;
|
||||||
uint old_id = RemapOrderIndex(_old_order_ptr);
|
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));
|
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) {
|
if (_cargo_count != 0) {
|
||||||
CargoPacket *cp = new CargoPacket((_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, _cargo_count);
|
CargoPacket *cp = new CargoPacket((_cargo_source == 0xFF) ? INVALID_STATION : _cargo_source, _cargo_count);
|
||||||
|
|
|
@ -157,8 +157,8 @@ static void Load_ORDR()
|
||||||
/* The orders were built like this:
|
/* The orders were built like this:
|
||||||
* While the order is valid, set the previous will get it's next pointer set
|
* 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 */
|
* We start with index 1 because no order will have the first in it's next pointer */
|
||||||
if (GetOrder(i)->IsValid())
|
if (Order::Get(i)->IsValid())
|
||||||
GetOrder(i - 1)->next = GetOrder(i);
|
Order::Get(i - 1)->next = Order::Get(i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int index;
|
int index;
|
||||||
|
|
|
@ -1431,35 +1431,35 @@ static void *IntToReference(uint index, SLRefType rt)
|
||||||
|
|
||||||
switch (rt) {
|
switch (rt) {
|
||||||
case REF_ORDERLIST:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "OrderList index out of range");
|
||||||
|
|
||||||
case REF_ORDER:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Order index out of range");
|
||||||
|
|
||||||
case REF_VEHICLE:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Vehicle index out of range");
|
||||||
|
|
||||||
case REF_STATION:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Station index out of range");
|
||||||
|
|
||||||
case REF_TOWN:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Town index out of range");
|
||||||
|
|
||||||
case REF_ROADSTOPS:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "RoadStop index out of range");
|
||||||
|
|
||||||
case REF_ENGINE_RENEWS:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "EngineRenew index out of range");
|
||||||
|
|
||||||
case REF_CARGO_PACKET:
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "CargoPacket index out of range");
|
||||||
|
|
||||||
case REF_VEHICLE_OLD:
|
case REF_VEHICLE_OLD:
|
||||||
|
@ -1469,7 +1469,7 @@ static void *IntToReference(uint index, SLRefType rt)
|
||||||
index++;
|
index++;
|
||||||
if (index == INVALID_VEHICLE) return NULL;
|
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");
|
SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_SAVEGAME, "Vehicle index out of range");
|
||||||
|
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
|
|
|
@ -225,7 +225,7 @@ static void CheckValidVehicles()
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
case VEH_SHIP:
|
case VEH_SHIP:
|
||||||
case VEH_AIRCRAFT:
|
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];
|
v->engine_type = first_engine[v->type];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -56,7 +56,7 @@ static SpriteID GetShipIcon(EngineID engine)
|
||||||
SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
|
SpriteID sprite = GetCustomVehicleIcon(engine, DIR_W);
|
||||||
if (sprite != 0) return sprite;
|
if (sprite != 0) return sprite;
|
||||||
|
|
||||||
spritenum = GetEngine(engine)->image_index;
|
spritenum = Engine::Get(engine)->image_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 6 + _ship_sprites[spritenum];
|
return 6 + _ship_sprites[spritenum];
|
||||||
|
@ -88,7 +88,7 @@ SpriteID Ship::GetImage(Direction direction) const
|
||||||
SpriteID sprite = GetCustomVehicleSprite(this, direction);
|
SpriteID sprite = GetCustomVehicleSprite(this, direction);
|
||||||
if (sprite != 0) return sprite;
|
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;
|
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;
|
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) {
|
if (st->dock_tile != INVALID_TILE) {
|
||||||
return TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
|
return TILE_ADD(st->dock_tile, ToTileIndexDiff(GetDockOffset(st->dock_tile)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -609,7 +609,7 @@ static void ShipController(Vehicle *v)
|
||||||
} else if (v->dest_tile != 0) {
|
} else if (v->dest_tile != 0) {
|
||||||
/* We have a target, let's see if we reached it... */
|
/* We have a target, let's see if we reached it... */
|
||||||
if (v->current_order.IsType(OT_GOTO_STATION) &&
|
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) {
|
DistanceManhattan(v->dest_tile, gp.new_tile) <= 3) {
|
||||||
/* We got within 3 tiles of our target buoy, so let's skip to our
|
/* We got within 3 tiles of our target buoy, so let's skip to our
|
||||||
* next order */
|
* next order */
|
||||||
|
@ -628,7 +628,7 @@ static void ShipController(Vehicle *v)
|
||||||
v->last_station_visited = v->current_order.GetDestination();
|
v->last_station_visited = v->current_order.GetDestination();
|
||||||
|
|
||||||
/* Process station in the orderlist. */
|
/* 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
|
if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
|
||||||
ShipArrivesAt(v, st);
|
ShipArrivesAt(v, st);
|
||||||
v->BeginLoading();
|
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);
|
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());
|
CommandCost value(EXPENSES_NEW_VEHICLES, e->GetCost());
|
||||||
|
|
||||||
/* Engines without valid cargo should not be available */
|
/* Engines without valid cargo should not be available */
|
||||||
|
@ -805,7 +805,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
if (IsLocalCompany())
|
if (IsLocalCompany())
|
||||||
InvalidateAutoreplaceWindow(v->engine_type, v->group_id); // updates the replace Ship window
|
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;
|
return value;
|
||||||
|
@ -823,7 +823,7 @@ CommandCost CmdSellShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p
|
||||||
|
|
||||||
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
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->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;
|
if (!IsValidVehicleID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Vehicle *v = GetVehicle(p1);
|
Vehicle *v = Vehicle::Get(p1);
|
||||||
|
|
||||||
if (v->type != VEH_SHIP) return CMD_ERROR;
|
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;
|
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->type != VEH_SHIP || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
|
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
|
||||||
|
|
|
@ -26,7 +26,7 @@ void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
const Vehicle *v;
|
const Vehicle *v;
|
||||||
if (!success) return;
|
if (!success) return;
|
||||||
|
|
||||||
v = GetVehicle(_new_vehicle_id);
|
v = Vehicle::Get(_new_vehicle_id);
|
||||||
if (v->tile == _backup_orders_tile) {
|
if (v->tile == _backup_orders_tile) {
|
||||||
_backup_orders_tile = 0;
|
_backup_orders_tile = 0;
|
||||||
RestoreVehicleOrders(v);
|
RestoreVehicleOrders(v);
|
||||||
|
|
|
@ -43,10 +43,10 @@ static inline SignID GetMaxSignIndex()
|
||||||
|
|
||||||
static inline bool IsValidSignID(uint index)
|
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)
|
#define FOR_ALL_SIGNS(ss) FOR_ALL_SIGNS_FROM(ss, 0)
|
||||||
|
|
||||||
#endif /* SIGNS_BASE_H */
|
#endif /* SIGNS_BASE_H */
|
||||||
|
|
|
@ -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 (strlen(text) >= MAX_LENGTH_SIGN_NAME_BYTES) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Sign *si = GetSign(p1);
|
Sign *si = Sign::Get(p1);
|
||||||
|
|
||||||
/* Delete the old name */
|
/* Delete the old name */
|
||||||
free(si->name);
|
free(si->name);
|
||||||
|
@ -89,7 +89,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
}
|
}
|
||||||
} else { // Delete sign
|
} else { // Delete sign
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Sign *si = GetSign(p1);
|
Sign *si = Sign::Get(p1);
|
||||||
|
|
||||||
MarkSignDirty(si);
|
MarkSignDirty(si);
|
||||||
delete 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)
|
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
if (success) {
|
if (success) {
|
||||||
ShowRenameSignWindow(GetSign(_new_sign_id));
|
ShowRenameSignWindow(Sign::Get(_new_sign_id));
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,16 +221,16 @@ static inline uint GetNumStations()
|
||||||
|
|
||||||
static inline bool IsValidStationID(StationID index)
|
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)
|
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
|
||||||
|
|
||||||
|
|
||||||
/* Stuff for ROADSTOPS */
|
/* 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)
|
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
|
||||||
|
|
||||||
/* End of stuff for ROADSTOPS */
|
/* End of stuff for ROADSTOPS */
|
||||||
|
|
|
@ -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))
|
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 {
|
} else {
|
||||||
/* Extend the current station, and don't check whether it will
|
/* Extend the current station, and don't check whether it will
|
||||||
* be near any other stations. */
|
* be near any other stations. */
|
||||||
st = GetStation(est);
|
st = Station::Get(est);
|
||||||
check_surrounding = false;
|
check_surrounding = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -928,7 +928,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Distant join */
|
/* 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. */
|
/* See if there is a deleted station close to us. */
|
||||||
if (st == NULL && reuse) st = GetClosestDeletedStation(tile_org);
|
if (st == NULL && reuse) st = GetClosestDeletedStation(tile_org);
|
||||||
|
@ -1425,7 +1425,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Distant join */
|
/* 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 */
|
/* Find a deleted station close to us */
|
||||||
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
|
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
|
||||||
|
@ -1876,7 +1876,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Distant join */
|
/* 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 */
|
/* Find a deleted station close to us */
|
||||||
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
|
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
|
||||||
|
@ -2183,7 +2183,7 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Distant join */
|
/* 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 */
|
/* Find a deleted station close to us */
|
||||||
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
|
if (st == NULL && reuse) st = GetClosestDeletedStation(tile);
|
||||||
|
@ -2842,7 +2842,7 @@ void OnTick_Station()
|
||||||
uint i = _station_tick_ctr;
|
uint i = _station_tick_ctr;
|
||||||
if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
|
if (++_station_tick_ctr > GetMaxStationIndex()) _station_tick_ctr = 0;
|
||||||
|
|
||||||
if (IsValidStationID(i)) StationHandleBigTick(GetStation(i));
|
if (IsValidStationID(i)) StationHandleBigTick(Station::Get(i));
|
||||||
|
|
||||||
Station *st;
|
Station *st;
|
||||||
FOR_ALL_STATIONS(st) {
|
FOR_ALL_STATIONS(st) {
|
||||||
|
@ -2913,7 +2913,7 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
|
||||||
{
|
{
|
||||||
if (!IsValidStationID(p1)) return CMD_ERROR;
|
if (!IsValidStationID(p1)) return CMD_ERROR;
|
||||||
|
|
||||||
Station *st = GetStation(p1);
|
Station *st = Station::Get(p1);
|
||||||
if (!CheckOwnership(st->owner)) return CMD_ERROR;
|
if (!CheckOwnership(st->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
bool reset = StrEmpty(text);
|
bool reset = StrEmpty(text);
|
||||||
|
|
|
@ -783,7 +783,7 @@ struct StationViewWindow : public Window {
|
||||||
|
|
||||||
StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
|
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;
|
if (owner != OWNER_NONE) this->owner = owner;
|
||||||
this->vscroll.cap = 5;
|
this->vscroll.cap = 5;
|
||||||
this->resize.step_height = 10;
|
this->resize.step_height = 10;
|
||||||
|
@ -794,7 +794,7 @@ struct StationViewWindow : public Window {
|
||||||
~StationViewWindow()
|
~StationViewWindow()
|
||||||
{
|
{
|
||||||
WindowNumber wno =
|
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_TRAINS_LIST, wno | (VEH_TRAIN << 11), false);
|
||||||
DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
|
DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11), false);
|
||||||
|
@ -805,7 +805,7 @@ struct StationViewWindow : public Window {
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
StationID station_id = this->window_number;
|
StationID station_id = this->window_number;
|
||||||
const Station *st = GetStation(station_id);
|
const Station *st = Station::Get(station_id);
|
||||||
CargoDataList cargolist;
|
CargoDataList cargolist;
|
||||||
uint32 transfers = 0;
|
uint32 transfers = 0;
|
||||||
|
|
||||||
|
@ -982,9 +982,9 @@ struct StationViewWindow : public Window {
|
||||||
|
|
||||||
case SVW_LOCATION:
|
case SVW_LOCATION:
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
ShowExtraViewPortWindow(GetStation(this->window_number)->xy);
|
ShowExtraViewPortWindow(Station::Get(this->window_number)->xy);
|
||||||
} else {
|
} else {
|
||||||
ScrollMainWindowToTile(GetStation(this->window_number)->xy);
|
ScrollMainWindowToTile(Station::Get(this->window_number)->xy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1012,19 +1012,19 @@ struct StationViewWindow : public Window {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SVW_TRAINS: { // Show a list of scheduled trains to this station
|
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);
|
ShowVehicleListWindow(st->owner, VEH_TRAIN, (StationID)this->window_number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SVW_ROADVEHS: { // Show a list of scheduled road-vehicles to this station
|
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);
|
ShowVehicleListWindow(st->owner, VEH_ROAD, (StationID)this->window_number);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case SVW_PLANES: { // Show a list of scheduled aircraft to this station
|
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 */
|
/* Since oilrigs have no owners, show the scheduled aircraft of local company */
|
||||||
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
||||||
ShowVehicleListWindow(owner, VEH_AIRCRAFT, (StationID)this->window_number);
|
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
|
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 */
|
/* Since oilrigs/bouys have no owners, show the scheduled ships of local company */
|
||||||
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
Owner owner = (st->owner == OWNER_NONE) ? _local_company : st->owner;
|
||||||
ShowVehicleListWindow(owner, VEH_SHIP, (StationID)this->window_number);
|
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;
|
if (!IsTileType(tile, MP_STATION)) return false;
|
||||||
|
|
||||||
StationID sid = GetStationIndex(tile);
|
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->owner != _local_company || _stations_nearby_list.Contains(sid)) return false;
|
||||||
|
|
||||||
if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST)) {
|
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. */
|
/* Don't draw anything if it extends past the end of the window. */
|
||||||
if (i - this->vscroll.pos >= this->vscroll.cap) break;
|
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(0, st->index);
|
||||||
SetDParam(1, st->facilities);
|
SetDParam(1, st->facilities);
|
||||||
DrawString(3, this->widget[JSW_PANEL].right - 2, y, STR_STATION_LIST_STATION);
|
DrawString(3, this->widget[JSW_PANEL].right - 2, y, STR_STATION_LIST_STATION);
|
||||||
|
|
|
@ -26,7 +26,7 @@ static inline StationID GetStationIndex(TileIndex t)
|
||||||
|
|
||||||
static inline Station *GetStationByTile(TileIndex t)
|
static inline Station *GetStationByTile(TileIndex t)
|
||||||
{
|
{
|
||||||
return GetStation(GetStationIndex(t));
|
return Station::Get(GetStationIndex(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ struct StatusBarWindow : Window {
|
||||||
|
|
||||||
virtual void OnPaint()
|
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();
|
this->DrawWidgets();
|
||||||
SetDParam(0, _date);
|
SetDParam(0, _date);
|
||||||
|
|
|
@ -665,7 +665,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCC_INDUSTRY_NAME: { // {INDUSTRY}
|
case SCC_INDUSTRY_NAME: { // {INDUSTRY}
|
||||||
const Industry *i = GetIndustry(GetInt32(&argv));
|
const Industry *i = Industry::Get(GetInt32(&argv));
|
||||||
int64 args[2];
|
int64 args[2];
|
||||||
|
|
||||||
/* industry not valid anymore? */
|
/* industry not valid anymore? */
|
||||||
|
@ -827,7 +827,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCC_WAYPOINT_NAME: { // {WAYPOINT}
|
case SCC_WAYPOINT_NAME: { // {WAYPOINT}
|
||||||
Waypoint *wp = GetWaypoint(GetInt32(&argv));
|
Waypoint *wp = Waypoint::Get(GetInt32(&argv));
|
||||||
|
|
||||||
assert(wp->IsValid());
|
assert(wp->IsValid());
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Station *st = GetStation(sid);
|
const Station *st = Station::Get(sid);
|
||||||
if (st->name != NULL) {
|
if (st->name != NULL) {
|
||||||
buff = strecpy(buff, st->name, last);
|
buff = strecpy(buff, st->name, last);
|
||||||
} else {
|
} else {
|
||||||
|
@ -882,7 +882,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCC_TOWN_NAME: { // {TOWN}
|
case SCC_TOWN_NAME: { // {TOWN}
|
||||||
const Town *t = GetTown(GetInt32(&argv));
|
const Town *t = Town::Get(GetInt32(&argv));
|
||||||
int64 temp[1];
|
int64 temp[1];
|
||||||
|
|
||||||
assert(t->IsValid());
|
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}
|
case SCC_GROUP_NAME: { // {GROUP}
|
||||||
const Group *g = GetGroup(GetInt32(&argv));
|
const Group *g = Group::Get(GetInt32(&argv));
|
||||||
|
|
||||||
assert(g->IsValid());
|
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}
|
case SCC_ENGINE_NAME: { // {ENGINE}
|
||||||
EngineID engine = (EngineID)GetInt32(&argv);
|
EngineID engine = (EngineID)GetInt32(&argv);
|
||||||
const Engine *e = GetEngine(engine);
|
const Engine *e = Engine::Get(engine);
|
||||||
|
|
||||||
if (e->name != NULL) {
|
if (e->name != NULL) {
|
||||||
buff = strecpy(buff, e->name, last);
|
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}
|
case SCC_VEHICLE_NAME: { // {VEHICLE}
|
||||||
const Vehicle *v = GetVehicle(GetInt32(&argv));
|
const Vehicle *v = Vehicle::Get(GetInt32(&argv));
|
||||||
|
|
||||||
if (v->name != NULL) {
|
if (v->name != NULL) {
|
||||||
buff = strecpy(buff, v->name, last);
|
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}
|
case SCC_SIGN_NAME: { // {SIGN}
|
||||||
const Sign *si = GetSign(GetInt32(&argv));
|
const Sign *si = Sign::Get(GetInt32(&argv));
|
||||||
if (si->name != NULL) {
|
if (si->name != NULL) {
|
||||||
buff = strecpy(buff, si->name, last);
|
buff = strecpy(buff, si->name, last);
|
||||||
} else {
|
} else {
|
||||||
|
@ -970,7 +970,7 @@ static char *FormatString(char *buff, const char *str, const int64 *argv, uint c
|
||||||
}
|
}
|
||||||
|
|
||||||
case SCC_COMPANY_NAME: { // {COMPANY}
|
case SCC_COMPANY_NAME: { // {COMPANY}
|
||||||
const Company *c = GetCompany((CompanyID)GetInt32(&argv));
|
const Company *c = Company::Get((CompanyID)GetInt32(&argv));
|
||||||
|
|
||||||
if (c->name != NULL) {
|
if (c->name != NULL) {
|
||||||
buff = strecpy(buff, c->name, last);
|
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}
|
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) {
|
if (c->president_name != NULL) {
|
||||||
buff = strecpy(buff, c->president_name, last);
|
buff = strecpy(buff, c->president_name, last);
|
||||||
|
|
|
@ -80,11 +80,11 @@ struct SubsidyListWindow : Window {
|
||||||
/* determine from coordinate for subsidy and try to scroll to it */
|
/* determine from coordinate for subsidy and try to scroll to it */
|
||||||
uint offs = s->from;
|
uint offs = s->from;
|
||||||
if (s->age >= 12) {
|
if (s->age >= 12) {
|
||||||
xy = GetStation(offs)->xy;
|
xy = Station::Get(offs)->xy;
|
||||||
} else if (te == TE_PASSENGERS || te == TE_MAIL) {
|
} else if (te == TE_PASSENGERS || te == TE_MAIL) {
|
||||||
xy = GetTown(offs)->xy;
|
xy = Town::Get(offs)->xy;
|
||||||
} else {
|
} else {
|
||||||
xy = GetIndustry(offs)->xy;
|
xy = Industry::Get(offs)->xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) {
|
if (_ctrl_pressed || !ScrollMainWindowToTile(xy)) {
|
||||||
|
@ -93,11 +93,11 @@ struct SubsidyListWindow : Window {
|
||||||
/* otherwise determine to coordinate for subsidy and scroll to it */
|
/* otherwise determine to coordinate for subsidy and scroll to it */
|
||||||
offs = s->to;
|
offs = s->to;
|
||||||
if (s->age >= 12) {
|
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) {
|
} else if (te == TE_PASSENGERS || te == TE_MAIL || te == TE_GOODS || te == TE_FOOD) {
|
||||||
xy = GetTown(offs)->xy;
|
xy = Town::Get(offs)->xy;
|
||||||
} else {
|
} else {
|
||||||
xy = GetIndustry(offs)->xy;
|
xy = Industry::Get(offs)->xy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_ctrl_pressed) {
|
if (_ctrl_pressed) {
|
||||||
|
@ -151,7 +151,7 @@ struct SubsidyListWindow : Window {
|
||||||
for (s = _subsidies; s != endof(_subsidies); s++) {
|
for (s = _subsidies; s != endof(_subsidies); s++) {
|
||||||
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
if (s->cargo_type != CT_INVALID && s->age >= 12) {
|
||||||
SetupSubsidyDecodeParam(s, 1);
|
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);
|
SetDParam(4, _date - ymd.day + 768 - s->age * 32);
|
||||||
|
|
||||||
/* Displays the two connected stations */
|
/* Displays the two connected stations */
|
||||||
|
|
|
@ -59,7 +59,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||||
VehicleID veh = GB(p1, 0, 16);
|
VehicleID veh = GB(p1, 0, 16);
|
||||||
if (!IsValidVehicleID(veh)) 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;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
VehicleOrderID order_number = GB(p1, 16, 8);
|
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);
|
VehicleID veh = GB(p1, 0, 16);
|
||||||
if (!IsValidVehicleID(veh)) 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;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
@ -145,7 +145,7 @@ CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
VehicleID veh = GB(p1, 0, 16);
|
VehicleID veh = GB(p1, 0, 16);
|
||||||
if (!IsValidVehicleID(veh)) 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;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct TimetableWindow : Window {
|
||||||
|
|
||||||
TimetableWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
|
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->owner = this->vehicle->owner;
|
||||||
this->vscroll.cap = 8;
|
this->vscroll.cap = 8;
|
||||||
this->resize.step_height = 10;
|
this->resize.step_height = 10;
|
||||||
|
@ -80,7 +80,7 @@ struct TimetableWindow : Window {
|
||||||
switch (data) {
|
switch (data) {
|
||||||
case 0:
|
case 0:
|
||||||
/* Autoreplace replaced the vehicle */
|
/* Autoreplace replaced the vehicle */
|
||||||
this->vehicle = GetVehicle(this->window_number);
|
this->vehicle = Vehicle::Get(this->window_number);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case -1:
|
case -1:
|
||||||
|
|
|
@ -624,7 +624,7 @@ static void ToolbarZoomOutClick(Window *w)
|
||||||
|
|
||||||
static void ToolbarBuildRailClick(Window *w)
|
static void ToolbarBuildRailClick(Window *w)
|
||||||
{
|
{
|
||||||
const Company *c = GetCompany(_local_company);
|
const Company *c = Company::Get(_local_company);
|
||||||
DropDownList *list = new DropDownList();
|
DropDownList *list = new DropDownList();
|
||||||
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
|
||||||
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
const RailtypeInfo *rti = GetRailTypeInfo(rt);
|
||||||
|
@ -646,7 +646,7 @@ static void MenuClickBuildRail(int index)
|
||||||
|
|
||||||
static void ToolbarBuildRoadClick(Window *w)
|
static void ToolbarBuildRoadClick(Window *w)
|
||||||
{
|
{
|
||||||
const Company *c = GetCompany(_local_company);
|
const Company *c = Company::Get(_local_company);
|
||||||
DropDownList *list = new DropDownList();
|
DropDownList *list = new DropDownList();
|
||||||
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) {
|
||||||
/* The standard road button is *always* available */
|
/* The standard road button is *always* available */
|
||||||
|
|
|
@ -302,7 +302,7 @@ TileIndexDiff GetHouseNorthPart(HouseID &house);
|
||||||
*/
|
*/
|
||||||
static inline bool IsValidTownID(TownID index)
|
static inline bool IsValidTownID(TownID index)
|
||||||
{
|
{
|
||||||
return index < GetTownPoolSize() && GetTown(index)->IsValid();
|
return index < GetTownPoolSize() && Town::Get(index)->IsValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline TownID GetMaxTownIndex()
|
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);
|
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)
|
#define FOR_ALL_TOWNS(t) FOR_ALL_TOWNS_FROM(t, 0)
|
||||||
|
|
||||||
extern Town *_cleared_town;
|
extern Town *_cleared_town;
|
||||||
|
|
|
@ -693,7 +693,7 @@ void OnTick_Town()
|
||||||
if (++_cur_town_ctr > GetMaxTownIndex())
|
if (++_cur_town_ctr > GetMaxTownIndex())
|
||||||
_cur_town_ctr = 0;
|
_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) {
|
if (flags & DC_EXEC) {
|
||||||
Town *t = GetTown(p1);
|
Town *t = Town::Get(p1);
|
||||||
|
|
||||||
free(t->name);
|
free(t->name);
|
||||||
t->name = reset ? NULL : strdup(text);
|
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])) {
|
if (cid != COMPANY_SPECTATOR && !(_settings_game.economy.bribe && t->unwanted[cid])) {
|
||||||
|
|
||||||
/* Things worth more than this are not shown */
|
/* 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;
|
Money ref = _price.build_industry >> 8;
|
||||||
|
|
||||||
/* Check the action bits for validity and
|
/* 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;
|
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;
|
if (!HasBit(GetMaskOfTownActions(NULL, _current_company, t), p2)) return CMD_ERROR;
|
||||||
|
|
||||||
|
@ -2727,7 +2727,7 @@ Town *ClosestTownFromTile(TileIndex tile, uint threshold)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Town *town = GetTown(tid);
|
Town *town = Town::Get(tid);
|
||||||
assert(town->IsValid());
|
assert(town->IsValid());
|
||||||
|
|
||||||
if (DistanceManhattan(tile, town->xy) >= threshold) town = NULL;
|
if (DistanceManhattan(tile, town->xy) >= threshold) town = NULL;
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) :
|
TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) :
|
||||||
Window(desc, window_number), sel_index(-1)
|
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->vscroll.cap = 5;
|
||||||
|
|
||||||
this->FindWindowPlacementAndResize(desc);
|
this->FindWindowPlacementAndResize(desc);
|
||||||
|
@ -258,7 +258,7 @@ public:
|
||||||
|
|
||||||
TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
|
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;
|
bool ingame = _game_mode != GM_EDITOR;
|
||||||
|
|
||||||
this->flags4 |= WF_DISABLE_VP_SCROLL;
|
this->flags4 |= WF_DISABLE_VP_SCROLL;
|
||||||
|
|
|
@ -40,7 +40,7 @@ static inline void SetTownIndex(TileIndex t, TownID index)
|
||||||
*/
|
*/
|
||||||
static inline Town *GetTownByTile(TileIndex t)
|
static inline Town *GetTownByTile(TileIndex t)
|
||||||
{
|
{
|
||||||
return GetTown(GetTownIndex(t));
|
return Town::Get(GetTownIndex(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue