1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-26 07:59:09 +00:00

Fix: CmdSetAutoReplace didn't validate group type and engine type match (#9950)

Basically, you could setup an auto-replace in a group for trains
to replace a ship with another ship.

Most of the code is surprisingly okay with this, it is only the
group statistics that doesn't like this.
This commit is contained in:
Patric Stout
2022-07-09 20:06:22 +02:00
committed by GitHub
parent 979704271b
commit 77a85e9b4c

View File

@@ -815,6 +815,7 @@ CommandCost CmdSetAutoReplace(DoCommandFlag flags, GroupID id_g, EngineID old_en
if (Group::IsValidID(id_g) ? Group::Get(id_g)->owner != _current_company : !IsAllGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR;
if (!Engine::IsValidID(old_engine_type)) return CMD_ERROR;
if (Group::IsValidID(id_g) && Group::Get(id_g)->vehicle_type != Engine::Get(old_engine_type)->type) return CMD_ERROR;
if (new_engine_type != INVALID_ENGINE) {
if (!Engine::IsValidID(new_engine_type)) return CMD_ERROR;