* Network-safe changing of settings (server-only). * @param flags operation to perform * @param name the name of the 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 * @see _settings */
| 1768 | * @see _settings |
| 1769 | */ |
| 1770 | CommandCost CmdChangeSetting(DoCommandFlags flags, const std::string &name, int32_t value) |
| 1771 | { |
| 1772 | if (name.empty()) return CMD_ERROR; |
| 1773 | const SettingDesc *sd = GetSettingFromName(name); |
| 1774 | |
| 1775 | if (sd == nullptr) return CMD_ERROR; |
| 1776 | if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR; |
| 1777 | if (!sd->IsIntSetting()) return CMD_ERROR; |
| 1778 | |
| 1779 | if (!sd->IsEditable(true)) return CMD_ERROR; |
| 1780 | |
| 1781 | if (flags.Test(DoCommandFlag::Execute)) { |
| 1782 | sd->AsIntSetting()->ChangeValue(&GetGameSettings(), value); |
| 1783 | } |
| 1784 | |
| 1785 | return CommandCost(); |
| 1786 | } |
| 1787 | |
| 1788 | /** |
| 1789 | * Change one of the per-company settings. |
nothing calls this directly
no test coverage detected