summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-05-17 01:00:56 +0000
committersmatz <smatz@openttd.org>2009-05-17 01:00:56 +0000
commit871107f52952ee59c353feab933126ed206e60bf (patch)
tree482884dfedc1700bddb8812f1de755212ed8bb22 /src/ai
parented1e54bd84074412ea9f273b7cd86aed42d844ce (diff)
downloadopenttd-871107f52952ee59c353feab933126ed206e60bf.tar.xz
(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_core.cpp12
-rw-r--r--src/ai/ai_gui.cpp8
-rw-r--r--src/ai/ai_instance.cpp2
-rw-r--r--src/ai/api/ai_company.cpp2
-rw-r--r--src/ai/api/ai_group.cpp2
-rw-r--r--src/ai/api/ai_industry.cpp2
-rw-r--r--src/ai/api/ai_sign.cpp2
-rw-r--r--src/ai/api/ai_station.cpp2
-rw-r--r--src/ai/api/ai_town.cpp2
-rw-r--r--src/ai/api/ai_vehicle.cpp2
-rw-r--r--src/ai/api/ai_waypoint.cpp2
11 files changed, 19 insertions, 19 deletions
diff --git a/src/ai/ai_core.cpp b/src/ai/ai_core.cpp
index 16ad01452..df470d035 100644
--- a/src/ai/ai_core.cpp
+++ b/src/ai/ai_core.cpp
@@ -28,7 +28,7 @@
/* static */ void AI::StartNew(CompanyID company)
{
- assert(IsValidCompanyID(company));
+ assert(Company::IsValidID(company));
/* Clients shouldn't start AIs */
if (_networking && !_network_server) return;
@@ -74,7 +74,7 @@
* Effectively collecting garbage once every two months per AI. */
if ((AI::frame_counter & 255) == 0) {
CompanyID cid = (CompanyID)GB(AI::frame_counter, 8, 4);
- if (IsValidCompanyID(cid) && !IsHumanCompany(cid)) Company::Get(cid)->ai_instance->CollectGarbage();
+ if (Company::IsValidID(cid) && !IsHumanCompany(cid)) Company::Get(cid)->ai_instance->CollectGarbage();
}
_current_company = OWNER_NONE;
@@ -178,7 +178,7 @@
}
/* Only AIs can have an event-queue */
- if (!IsValidCompanyID(company) || IsHumanCompany(company)) {
+ if (!Company::IsValidID(company) || IsHumanCompany(company)) {
event->Release();
return;
}
@@ -227,7 +227,7 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
/* static */ void AI::Save(CompanyID company)
{
if (!_networking || _network_server) {
- assert(IsValidCompanyID(company));
+ assert(Company::IsValidID(company));
assert(Company::Get(company)->ai_instance != NULL);
CompanyID old_company = _current_company;
@@ -242,7 +242,7 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
/* static */ void AI::Load(CompanyID company, int version)
{
if (!_networking || _network_server) {
- assert(IsValidCompanyID(company));
+ assert(Company::IsValidID(company));
assert(Company::Get(company)->ai_instance != NULL);
CompanyID old_company = _current_company;
@@ -259,7 +259,7 @@ void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
/* Find the first company which doesn't exist yet */
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
- if (!IsValidCompanyID(c)) return AIConfig::GetConfig(c)->GetSetting("start_date");
+ if (!Company::IsValidID(c)) return AIConfig::GetConfig(c)->GetSetting("start_date");
}
/* Currently no AI can be started, check again in a year. */
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index ac8401dff..f0ffee121 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -641,7 +641,7 @@ struct AIDebugWindow : public Window {
{
/* Disable the companies who are not active or not an AI */
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
- this->SetWidgetDisabledState(i + AID_WIDGET_COMPANY_BUTTON_START, !IsValidCompanyID(i) || !Company::Get(i)->is_ai);
+ this->SetWidgetDisabledState(i + AID_WIDGET_COMPANY_BUTTON_START, !Company::IsValidID(i) || !Company::Get(i)->is_ai);
}
this->DisableWidget(AID_WIDGET_RELOAD_TOGGLE);
@@ -659,7 +659,7 @@ struct AIDebugWindow : public Window {
virtual void OnPaint()
{
/* Check if the currently selected company is still active. */
- if (ai_debug_company == INVALID_COMPANY || !IsValidCompanyID(ai_debug_company)) {
+ if (ai_debug_company == INVALID_COMPANY || !Company::IsValidID(ai_debug_company)) {
if (ai_debug_company != INVALID_COMPANY) {
/* Raise and disable the widget for the previous selection. */
this->RaiseWidget(ai_debug_company + AID_WIDGET_COMPANY_BUTTON_START);
@@ -669,7 +669,7 @@ struct AIDebugWindow : public Window {
}
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
- if (IsValidCompanyID(i) && Company::Get(i)->is_ai) {
+ if (Company::IsValidID(i) && Company::Get(i)->is_ai) {
/* Lower the widget corresponding to this company. */
this->LowerWidget(i + AID_WIDGET_COMPANY_BUTTON_START);
@@ -690,7 +690,7 @@ struct AIDebugWindow : public Window {
/* Paint the company icons */
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
- if (!IsValidCompanyID(i) || !Company::Get(i)->is_ai) {
+ if (!Company::IsValidID(i) || !Company::Get(i)->is_ai) {
/* Check if we have the company as an active company */
if (!this->IsWidgetDisabled(i + AID_WIDGET_COMPANY_BUTTON_START)) {
/* Bah, company gone :( */
diff --git a/src/ai/ai_instance.cpp b/src/ai/ai_instance.cpp
index 89f8ab98b..0b140c172 100644
--- a/src/ai/ai_instance.cpp
+++ b/src/ai/ai_instance.cpp
@@ -353,7 +353,7 @@ void AIInstance::CollectGarbage()
/* static */ AIStorage *AIInstance::GetStorage()
{
- assert(IsValidCompanyID(_current_company) && !IsHumanCompany(_current_company));
+ assert(Company::IsValidID(_current_company) && !IsHumanCompany(_current_company));
return Company::Get(_current_company)->ai_instance->storage;
}
diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp
index 075ef6b51..ba70d859a 100644
--- a/src/ai/api/ai_company.cpp
+++ b/src/ai/api/ai_company.cpp
@@ -19,7 +19,7 @@
{
if (company == COMPANY_SELF) return (CompanyID)((byte)_current_company);
- return ::IsValidCompanyID((::CompanyID)company) ? company : COMPANY_INVALID;
+ return ::Company::IsValidID((::CompanyID)company) ? company : COMPANY_INVALID;
}
/* static */ bool AICompany::IsMine(AICompany::CompanyID company)
diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp
index 165b1028e..6f4d25de9 100644
--- a/src/ai/api/ai_group.cpp
+++ b/src/ai/api/ai_group.cpp
@@ -16,7 +16,7 @@
/* static */ bool AIGroup::IsValidGroup(GroupID group_id)
{
- return ::IsValidGroupID(group_id) && ::Group::Get(group_id)->owner == _current_company;
+ return ::Group::IsValidID(group_id) && ::Group::Get(group_id)->owner == _current_company;
}
/* static */ AIGroup::GroupID AIGroup::CreateGroup(AIVehicle::VehicleType vehicle_type)
diff --git a/src/ai/api/ai_industry.cpp b/src/ai/api/ai_industry.cpp
index 3a1acb213..5b7766fa2 100644
--- a/src/ai/api/ai_industry.cpp
+++ b/src/ai/api/ai_industry.cpp
@@ -18,7 +18,7 @@
/* static */ bool AIIndustry::IsValidIndustry(IndustryID industry_id)
{
- return ::IsValidIndustryID(industry_id);
+ return ::Industry::IsValidID(industry_id);
}
/* static */ char *AIIndustry::GetName(IndustryID industry_id)
diff --git a/src/ai/api/ai_sign.cpp b/src/ai/api/ai_sign.cpp
index 72e34d333..8876bbeec 100644
--- a/src/ai/api/ai_sign.cpp
+++ b/src/ai/api/ai_sign.cpp
@@ -20,7 +20,7 @@
/* static */ bool AISign::IsValidSign(SignID sign_id)
{
- return ::IsValidSignID(sign_id) && ::Sign::Get(sign_id)->owner == _current_company;
+ return ::Sign::IsValidID(sign_id) && ::Sign::Get(sign_id)->owner == _current_company;
}
/* static */ bool AISign::SetName(SignID sign_id, const char *name)
diff --git a/src/ai/api/ai_station.cpp b/src/ai/api/ai_station.cpp
index 7a9f5cb8d..cc1167ddc 100644
--- a/src/ai/api/ai_station.cpp
+++ b/src/ai/api/ai_station.cpp
@@ -17,7 +17,7 @@
/* static */ bool AIStation::IsValidStation(StationID station_id)
{
- return ::IsValidStationID(station_id) && ::Station::Get(station_id)->owner == _current_company;
+ return ::Station::IsValidID(station_id) && ::Station::Get(station_id)->owner == _current_company;
}
/* static */ StationID AIStation::GetStationID(TileIndex tile)
diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp
index a37d065e5..e49c1a36a 100644
--- a/src/ai/api/ai_town.cpp
+++ b/src/ai/api/ai_town.cpp
@@ -21,7 +21,7 @@
/* static */ bool AITown::IsValidTown(TownID town_id)
{
- return ::IsValidTownID(town_id);
+ return ::Town::IsValidID(town_id);
}
/* static */ char *AITown::GetName(TownID town_id)
diff --git a/src/ai/api/ai_vehicle.cpp b/src/ai/api/ai_vehicle.cpp
index b61519915..5d1579364 100644
--- a/src/ai/api/ai_vehicle.cpp
+++ b/src/ai/api/ai_vehicle.cpp
@@ -19,7 +19,7 @@
/* static */ bool AIVehicle::IsValidVehicle(VehicleID vehicle_id)
{
- if (!::IsValidVehicleID(vehicle_id)) return false;
+ if (!::Vehicle::IsValidID(vehicle_id)) return false;
const Vehicle *v = ::Vehicle::Get(vehicle_id);
return v->owner == _current_company && (v->IsPrimaryVehicle() || (v->type == VEH_TRAIN && ::IsFreeWagon(v)));
}
diff --git a/src/ai/api/ai_waypoint.cpp b/src/ai/api/ai_waypoint.cpp
index ec6af36eb..0c1e3194b 100644
--- a/src/ai/api/ai_waypoint.cpp
+++ b/src/ai/api/ai_waypoint.cpp
@@ -14,7 +14,7 @@
/* static */ bool AIWaypoint::IsValidWaypoint(WaypointID waypoint_id)
{
- return ::IsValidWaypointID(waypoint_id) && ::Waypoint::Get(waypoint_id)->owner == _current_company;
+ return ::Waypoint::IsValidID(waypoint_id) && ::Waypoint::Get(waypoint_id)->owner == _current_company;
}
/* static */ WaypointID AIWaypoint::GetWaypointID(TileIndex tile)