summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-05-26 13:29:01 +0000
committeryexo <yexo@openttd.org>2009-05-26 13:29:01 +0000
commit2a5a8f395c0c71146259433a1a4abe7807d2f8ac (patch)
treee21a14ab69dcbb702f56c284719ecdbf8a0cf4fd /src/ai/api
parent55225433c4517e0daa514d0e4cd20660396d5008 (diff)
downloadopenttd-2a5a8f395c0c71146259433a1a4abe7807d2f8ac.tar.xz
(svn r16433) -Codechange: Remove most of CmdSetAutoreplace and replace it with calls to CmdChangeCompanySetting
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_company.cpp7
-rw-r--r--src/ai/api/ai_group.cpp7
2 files changed, 8 insertions, 6 deletions
diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp
index ba70d859a..ca11b7f73 100644
--- a/src/ai/api/ai_company.cpp
+++ b/src/ai/api/ai_company.cpp
@@ -13,6 +13,7 @@
#include "../../tile_map.h"
#include "../../core/alloc_func.hpp"
#include "../../string_func.h"
+#include "../../settings_func.h"
#include "table/strings.h"
/* static */ AICompany::CompanyID AICompany::ResolveCompanyID(AICompany::CompanyID company)
@@ -148,7 +149,7 @@
/* static */ bool AICompany::SetAutoRenewStatus(bool autorenew)
{
- return AIObject::DoCommand(0, 0, autorenew ? 1 : 0, CMD_SET_AUTOREPLACE);
+ return AIObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew"), autorenew ? 1 : 0, CMD_CHANGE_COMPANY_SETTING);
}
/* static */ bool AICompany::GetAutoRenewStatus(CompanyID company)
@@ -161,7 +162,7 @@
/* static */ bool AICompany::SetAutoRenewMonths(int16 months)
{
- return AIObject::DoCommand(0, 1, months, CMD_SET_AUTOREPLACE);
+ return AIObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_months"), months, CMD_CHANGE_COMPANY_SETTING);
}
/* static */ int16 AICompany::GetAutoRenewMonths(CompanyID company)
@@ -174,7 +175,7 @@
/* static */ bool AICompany::SetAutoRenewMoney(uint32 money)
{
- return AIObject::DoCommand(0, 2, money, CMD_SET_AUTOREPLACE);
+ return AIObject::DoCommand(0, ::GetCompanySettingIndex("company.engine_renew_money"), money, CMD_CHANGE_COMPANY_SETTING);
}
/* static */ uint32 AICompany::GetAutoRenewMoney(CompanyID company)
diff --git a/src/ai/api/ai_group.cpp b/src/ai/api/ai_group.cpp
index cbcc8162b..f072f7390 100644
--- a/src/ai/api/ai_group.cpp
+++ b/src/ai/api/ai_group.cpp
@@ -12,6 +12,7 @@
#include "../../core/alloc_func.hpp"
#include "../../command_func.h"
#include "../../autoreplace_func.h"
+#include "../../settings_func.h"
#include "table/strings.h"
/* static */ bool AIGroup::IsValidGroup(GroupID group_id)
@@ -96,7 +97,7 @@
{
if (HasWagonRemoval() == enable_removal) return true;
- return AIObject::DoCommand(0, 5, enable_removal ? 1 : 0, CMD_SET_AUTOREPLACE);
+ return AIObject::DoCommand(0, ::GetCompanySettingIndex("company.renew_keep_length"), enable_removal ? 1 : 0, CMD_CHANGE_COMPANY_SETTING);
}
/* static */ bool AIGroup::HasWagonRemoval()
@@ -109,7 +110,7 @@
EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_ALL);
EnforcePrecondition(false, AIEngine::IsValidEngine(engine_id_new));
- return AIObject::DoCommand(0, 3 | (group_id << 16), (engine_id_new << 16) | engine_id_old, CMD_SET_AUTOREPLACE);
+ return AIObject::DoCommand(0, group_id << 16, (engine_id_new << 16) | engine_id_old, CMD_SET_AUTOREPLACE);
}
/* static */ EngineID AIGroup::GetEngineReplacement(GroupID group_id, EngineID engine_id)
@@ -123,5 +124,5 @@
{
EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_ALL);
- return AIObject::DoCommand(0, 3 | (group_id << 16), (::INVALID_ENGINE << 16) | engine_id, CMD_SET_AUTOREPLACE);
+ return AIObject::DoCommand(0, group_id << 16, (::INVALID_ENGINE << 16) | engine_id, CMD_SET_AUTOREPLACE);
}