OpenTTD/OpenTTD

[Bug]: No descriptive error when hostile takeover fails due to vehicle limit

Closed this issue · 2 comments

Version of OpenTTD

14.0

Expected result

You can execute a hostile takeover of the company

Actual result

A message saying "Can't buy company..." appears, with no additional information.

Steps to reproduce

  1. Load attached savegame.
  2. Try and execute a hostile takeover of the "AAAHogEx" AI
  3. You will see a message saying the cost will be around £12m but on attempting to execute the takeover you just see a message labelled "Can't buy company..."
    Wutborough Market Transport, 1963-05-28.sav.zip

Can reproduce on b852a3f on Windows 10, 64-bit.

This appears to be related to vehicle limits; increasing the maximum number of vehicles per company for each of the four vehicle types allows the hostile takeover to succeed.

As far as I know, the full error message was/should be "Can't buy company... Too many vehicles in game"

Caused by:

OpenTTD/src/economy.cpp

Lines 2065 to 2066 in cc6e476

/* Disable taking over when not allowed. */
if (!MayCompanyTakeOver(_current_company, target_company)) return CMD_ERROR;
where MayCompanyTakeOver is just a check that the combined vehicle counts don't exceed the currently set limits.

Thank you for looking, @James103 ! You're correct - if I increase the maximum vehicle count in the Settings dialog then the takeover works.

Gotta love that comment, too: /* Disable taking over when not allowed. */ !