From c4d5a71da1b6921a9d9401d6d2f43a1be18f7b5d Mon Sep 17 00:00:00 2001 From: dP Date: Mon, 2 Aug 2021 18:13:15 +0300 Subject: [PATCH] Allow CmdCompanyCtrl while replaying the command log --- src/citymania/cm_console_cmds.cpp | 5 +++++ src/citymania/cm_console_cmds.hpp | 1 + src/company_cmd.cpp | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/citymania/cm_console_cmds.cpp b/src/citymania/cm_console_cmds.cpp index 7f1facaada..de80c345f1 100644 --- a/src/citymania/cm_console_cmds.cpp +++ b/src/citymania/cm_console_cmds.cpp @@ -283,6 +283,11 @@ void LoadCommands(const std::string &filename) { _replay_started = false; } +bool IsReplayingCommands() { + return !_fake_commands.empty(); +} + + bool ConLoadCommands(byte argc, char *argv[]) { if (argc == 0) { IConsoleHelp("Loads a file with command queue to execute"); diff --git a/src/citymania/cm_console_cmds.hpp b/src/citymania/cm_console_cmds.hpp index 5d80ab12a2..ab957c8e8a 100644 --- a/src/citymania/cm_console_cmds.hpp +++ b/src/citymania/cm_console_cmds.hpp @@ -9,6 +9,7 @@ void SkipFakeCommands(Date date, DateFract date_fract); void SetReplaySaveInterval(uint32 interval); void LoadCommands(const std::string &filename); void CheckIntervalSave(); +bool IsReplayingCommands(); bool ConGameSpeed(byte argc, char *argv[]); bool ConStep(byte argc, char *argv[]); diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 08ff5f66f2..543a41c449 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -41,6 +41,7 @@ #include "cargo_type.h" #include "citymania/cm_hotkeys.hpp" +#include "citymania/cm_console_cmds.hpp" #include "safeguards.h" @@ -824,7 +825,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 switch ((CompanyCtrlAction)GB(p1, 0, 16)) { case CCA_NEW: { // Create a new company /* This command is only executed in a multiplayer game */ - if (!_networking) return CMD_ERROR; + if (!_networking && !citymania::IsReplayingCommands()) return CMD_ERROR; /* Has the network client a correct ClientIndex? */ if (!(flags & DC_EXEC)) return CommandCost();