Fix #449: Town setting override not being allowed for MP admins

When the setting to enable for clients was not enabled
pull/451/head
Jonathan G Rennison 2 years ago
parent 0f697c5501
commit 95a646d09b

@ -156,6 +156,7 @@ CommandProc CmdRenameTown;
CommandProc CmdRenameTownNonAdmin;
CommandProc CmdDoTownAction;
CommandProc CmdOverrideTownSetting;
CommandProc CmdOverrideTownSettingNonAdmin;
CommandProc CmdTownGrowthRate;
CommandProc CmdTownRating;
CommandProc CmdTownCargoGoal;
@ -402,7 +403,8 @@ static const Command _command_proc_table[] = {
DEF_CMD(CmdRenameTown, CMD_DEITY | CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_TOWN
DEF_CMD(CmdRenameTownNonAdmin, 0, CMDT_OTHER_MANAGEMENT ), // CMD_RENAME_TOWN_NON_ADMIN
DEF_CMD(CmdDoTownAction, 0, CMDT_LANDSCAPE_CONSTRUCTION), // CMD_DO_TOWN_ACTION
DEF_CMD(CmdOverrideTownSetting, 0, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_SETTING_OVERRIDE
DEF_CMD(CmdOverrideTownSetting, CMD_DEITY | CMD_SERVER, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_SETTING_OVERRIDE
DEF_CMD(CmdOverrideTownSettingNonAdmin, 0, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_SETTING_OVERRIDE_NON_ADMIN
DEF_CMD(CmdTownCargoGoal, CMD_LOG_AUX | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_CARGO_GOAL
DEF_CMD(CmdTownGrowthRate, CMD_LOG_AUX | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_GROWTH_RATE
DEF_CMD(CmdTownRating, CMD_LOG_AUX | CMD_DEITY, CMDT_OTHER_MANAGEMENT ), // CMD_TOWN_RATING

@ -348,6 +348,7 @@ enum Commands {
CMD_RENAME_TOWN_NON_ADMIN, ///< rename a town, non-admin command
CMD_DO_TOWN_ACTION, ///< do a action from the town detail window (like advertises or bribe)
CMD_TOWN_SETTING_OVERRIDE, ///< override a town setting
CMD_TOWN_SETTING_OVERRIDE_NON_ADMIN, ///< override a town setting, non-admin command
CMD_TOWN_CARGO_GOAL, ///< set the goal of a cargo for a town
CMD_TOWN_GROWTH_RATE, ///< set the town growth rate
CMD_TOWN_RATING, ///< set rating of a company in a town

@ -3809,8 +3809,6 @@ CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
*/
CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
if (_networking && !_settings_game.difficulty.override_town_settings_in_multiplayer) return CMD_ERROR;
Town *t = Town::GetIfValid(p1);
if (t == nullptr) return CMD_ERROR;
@ -3856,6 +3854,25 @@ CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32 p
return CommandCost();
}
/**
* Override a town setting (non-admin use)
* @param tile unused
* @param flags type of operation
* @param p1 town to do the action at
* @param p2 various bitstuffed elements
* - p2 = (bit 0 - 7) - what setting to change
* - p2 = (bit 8 - 15) - the data to modify
* - p2 = (bit 16) - whether to override the value, or use the default
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdOverrideTownSettingNonAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
{
if (_networking && !_settings_game.difficulty.override_town_settings_in_multiplayer) return CMD_ERROR;
return CmdOverrideTownSetting(tile, flags, p1, p2, text);
}
template <typename Func>
static void ForAllStationsNearTown(Town *t, Func func)
{

@ -452,7 +452,8 @@ public:
SetBit(p2, 16);
p2 |= (index - 1) << 8;
}
DoCommandP(this->town->xy, this->window_number, p2, CMD_TOWN_SETTING_OVERRIDE | CMD_MSG(STR_ERROR_CAN_T_DO_THIS));
Commands cmd = (_networking && !(_network_server || _network_settings_access)) ? CMD_TOWN_SETTING_OVERRIDE_NON_ADMIN : CMD_TOWN_SETTING_OVERRIDE;
DoCommandP(this->town->xy, this->window_number, p2, cmd | CMD_MSG(STR_ERROR_CAN_T_DO_THIS));
break;
}

Loading…
Cancel
Save