mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-07-14 08:05:24 +01:00
(svn r18930) -Fix: [NoAI] Autoreplace is also valid for the default group.
This commit is contained in:
parent
ec9ac775bf
commit
7b237ee607
@ -112,7 +112,7 @@
|
|||||||
|
|
||||||
/* 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)
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_ALL);
|
EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL);
|
||||||
EnforcePrecondition(false, AIEngine::IsBuildable(engine_id_new));
|
EnforcePrecondition(false, AIEngine::IsBuildable(engine_id_new));
|
||||||
|
|
||||||
return AIObject::DoCommand(0, 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);
|
||||||
@ -120,14 +120,14 @@
|
|||||||
|
|
||||||
/* static */ EngineID AIGroup::GetEngineReplacement(GroupID group_id, EngineID engine_id)
|
/* static */ EngineID AIGroup::GetEngineReplacement(GroupID group_id, EngineID engine_id)
|
||||||
{
|
{
|
||||||
if (!IsValidGroup(group_id) && group_id != GROUP_ALL) return ::INVALID_ENGINE;
|
if (!IsValidGroup(group_id) && group_id != GROUP_DEFAULT && group_id != GROUP_ALL) return ::INVALID_ENGINE;
|
||||||
|
|
||||||
return ::EngineReplacementForCompany(Company::Get(_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)
|
||||||
{
|
{
|
||||||
EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_ALL);
|
EnforcePrecondition(false, IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL);
|
||||||
|
|
||||||
return AIObject::DoCommand(0, 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);
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ public:
|
|||||||
* vehicles from all groups that haven't set autoreplace protection.
|
* vehicles from all groups that haven't set autoreplace protection.
|
||||||
* @param engine_id_old The engine id to start replacing.
|
* @param engine_id_old The engine id to start replacing.
|
||||||
* @param engine_id_new The engine id to replace with.
|
* @param engine_id_new The engine id to replace with.
|
||||||
* @pre IsValidGroup(group_id) || group_id == GROUP_ALL.
|
* @pre IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL.
|
||||||
* @pre AIEngine.IsBuildable(engine_id_new).
|
* @pre AIEngine.IsBuildable(engine_id_new).
|
||||||
* @note To stop autoreplacing engine_id_old, call StopAutoReplace(group_id, engine_id_old).
|
* @note To stop autoreplacing engine_id_old, call StopAutoReplace(group_id, engine_id_old).
|
||||||
*/
|
*/
|
||||||
@ -158,7 +158,7 @@ public:
|
|||||||
* Get the EngineID the given EngineID is replaced with.
|
* Get the EngineID the given EngineID is replaced with.
|
||||||
* @param group_id The group to get the replacement from.
|
* @param group_id The group to get the replacement from.
|
||||||
* @param engine_id The engine that is being replaced.
|
* @param engine_id The engine that is being replaced.
|
||||||
* @pre IsValidGroup(group_id) || group_id == GROUP_ALL.
|
* @pre IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL.
|
||||||
* @return The EngineID that is replacing engine_id or an invalid EngineID
|
* @return The EngineID that is replacing engine_id or an invalid EngineID
|
||||||
* in case engine_id is not begin replaced.
|
* in case engine_id is not begin replaced.
|
||||||
*/
|
*/
|
||||||
@ -168,7 +168,7 @@ public:
|
|||||||
* Stop replacing a certain engine in the specified group.
|
* Stop replacing a certain engine in the specified group.
|
||||||
* @param group_id The group to stop replacing the engine in.
|
* @param group_id The group to stop replacing the engine in.
|
||||||
* @param engine_id The engine id to stop replacing with another engine.
|
* @param engine_id The engine id to stop replacing with another engine.
|
||||||
* @pre IsValidGroup(group_id) || group_id == GROUP_ALL.
|
* @pre IsValidGroup(group_id) || group_id == GROUP_DEFAULT || group_id == GROUP_ALL.
|
||||||
* @return True if and if the replacing was succesfully stopped.
|
* @return True if and if the replacing was succesfully stopped.
|
||||||
*/
|
*/
|
||||||
static bool StopAutoReplace(GroupID group_id, EngineID engine_id);
|
static bool StopAutoReplace(GroupID group_id, EngineID engine_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user