Skip to content

Commit

Permalink
Fix: CmdSetAutoReplace didn't validate group type and engine type mat…
Browse files Browse the repository at this point in the history
…ch (OpenTTD#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.
  • Loading branch information
TrueBrain authored Jul 9, 2022
1 parent 9797042 commit 77a85e9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/autoreplace_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 77a85e9

Please sign in to comment.