Codechange: Un-bitstuff all remaining commands.

This commit is contained in:
Michael Lutz
2021-11-23 01:05:58 +01:00
parent 58cff7b081
commit 13528bfcd0
40 changed files with 192 additions and 260 deletions

View File

@@ -1487,18 +1487,16 @@ const SettingDesc *GetSettingFromName(const std::string_view name)
/**
* Network-safe changing of settings (server-only).
* @param flags operation to perform
* @param tile unused
* @param p1 unused
* @param p2 the new value for the setting
* @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
* @param text the name of the setting to change
* @return the cost of this operation or an error
* @see _settings
*/
CommandCost CmdChangeSetting(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32 value)
{
if (text.empty()) return CMD_ERROR;
const SettingDesc *sd = GetSettingFromName(text);
if (name.empty()) return CMD_ERROR;
const SettingDesc *sd = GetSettingFromName(name);
if (sd == nullptr) return CMD_ERROR;
if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to)) return CMD_ERROR;
@@ -1507,7 +1505,7 @@ CommandCost CmdChangeSetting(DoCommandFlag flags, TileIndex tile, uint32 p1, uin
if (!sd->IsEditable(true)) return CMD_ERROR;
if (flags & DC_EXEC) {
sd->AsIntSetting()->ChangeValue(&GetGameSettings(), p2);
sd->AsIntSetting()->ChangeValue(&GetGameSettings(), value);
}
return CommandCost();
@@ -1516,23 +1514,21 @@ CommandCost CmdChangeSetting(DoCommandFlag flags, TileIndex tile, uint32 p1, uin
/**
* Change one of the per-company settings.
* @param flags operation to perform
* @param tile unused
* @param p1 unused
* @param p2 the new value for the setting
* @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
* @param text the name of the company setting to change
* @return the cost of this operation or an error
*/
CommandCost CmdChangeCompanySetting(DoCommandFlag flags, TileIndex tile, uint32 p1, uint32 p2, const std::string &text)
CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32 value)
{
if (text.empty()) return CMD_ERROR;
const SettingDesc *sd = GetCompanySettingFromName(text.c_str());
if (name.empty()) return CMD_ERROR;
const SettingDesc *sd = GetCompanySettingFromName(name);
if (sd == nullptr) return CMD_ERROR;
if (!sd->IsIntSetting()) return CMD_ERROR;
if (flags & DC_EXEC) {
sd->AsIntSetting()->ChangeValue(&Company::Get(_current_company)->settings, p2);
sd->AsIntSetting()->ChangeValue(&Company::Get(_current_company)->settings, value);
}
return CommandCost();
@@ -1550,7 +1546,7 @@ bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame)
const IntSettingDesc *setting = sd->AsIntSetting();
if ((setting->flags & SF_PER_COMPANY) != 0) {
if (Company::IsValidID(_local_company) && _game_mode != GM_MENU) {
return Command<CMD_CHANGE_COMPANY_SETTING>::Post(0, 0, value, setting->GetName());
return Command<CMD_CHANGE_COMPANY_SETTING>::Post(setting->GetName(), value);
}
setting->ChangeValue(&_settings_client.company, value);
@@ -1576,7 +1572,7 @@ bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame)
/* send non-company-based settings over the network */
if (!_networking || (_networking && _network_server)) {
return Command<CMD_CHANGE_SETTING>::Post(0, 0, value, setting->GetName());
return Command<CMD_CHANGE_SETTING>::Post(setting->GetName(), value);
}
return false;
}
@@ -1604,7 +1600,7 @@ void SyncCompanySettings()
const SettingDesc *sd = GetSettingDesc(desc);
uint32 old_value = (uint32)sd->AsIntSetting()->Read(new_object);
uint32 new_value = (uint32)sd->AsIntSetting()->Read(old_object);
if (old_value != new_value) Command<CMD_CHANGE_COMPANY_SETTING>::SendNet(STR_NULL, nullptr, _local_company, 0, 0, new_value, sd->GetName());
if (old_value != new_value) Command<CMD_CHANGE_COMPANY_SETTING>::SendNet(STR_NULL, nullptr, _local_company, sd->GetName(), new_value);
}
}