* Change one of the per-company settings. * @param flags operation to perform * @param name the name of the company setting to change * @param value the new value for the setting * The new value is properly clamped to its minimum/maximum when setting * @return the cost of this operation or an error */
| 1794 | * @return the cost of this operation or an error |
| 1795 | */ |
| 1796 | CommandCost CmdChangeCompanySetting(DoCommandFlags flags, const std::string &name, int32_t value) |
| 1797 | { |
| 1798 | if (name.empty()) return CMD_ERROR; |
| 1799 | const SettingDesc *sd = GetCompanySettingFromName(name); |
| 1800 | |
| 1801 | if (sd == nullptr) return CMD_ERROR; |
| 1802 | if (!sd->IsIntSetting()) return CMD_ERROR; |
| 1803 | |
| 1804 | if (flags.Test(DoCommandFlag::Execute)) { |
| 1805 | sd->AsIntSetting()->ChangeValue(&Company::Get(_current_company)->settings, value); |
| 1806 | } |
| 1807 | |
| 1808 | return CommandCost(); |
| 1809 | } |
| 1810 | |
| 1811 | /** |
| 1812 | * Top function to save the new value of an element of the Settings struct |
nothing calls this directly
no test coverage detected