(svn r16327) -Codechange: replace IsValidPoolItemID(index) by PoolItem::IsValidID(index)
This commit is contained in:
@@ -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. */
|
||||
|
@@ -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 :( */
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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)));
|
||||
}
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user