mirror of https://github.com/OpenTTD/OpenTTD
(svn r15335) -Change: use the patch change mechanism to change the road side too instead of a separate command.
parent
496b541cb1
commit
09fca459a7
|
@ -144,8 +144,6 @@ DEF_COMMAND(CmdBuildTown);
|
||||||
DEF_COMMAND(CmdRenameTown);
|
DEF_COMMAND(CmdRenameTown);
|
||||||
DEF_COMMAND(CmdDoTownAction);
|
DEF_COMMAND(CmdDoTownAction);
|
||||||
|
|
||||||
DEF_COMMAND(CmdSetRoadDriveSide);
|
|
||||||
|
|
||||||
DEF_COMMAND(CmdChangePatchSetting);
|
DEF_COMMAND(CmdChangePatchSetting);
|
||||||
|
|
||||||
DEF_COMMAND(CmdSellShip);
|
DEF_COMMAND(CmdSellShip);
|
||||||
|
@ -294,8 +292,6 @@ static const Command _command_proc_table[] = {
|
||||||
{CmdRenameTown, CMD_SERVER}, /* CMD_RENAME_TOWN */
|
{CmdRenameTown, CMD_SERVER}, /* CMD_RENAME_TOWN */
|
||||||
{CmdDoTownAction, 0}, /* CMD_DO_TOWN_ACTION */
|
{CmdDoTownAction, 0}, /* CMD_DO_TOWN_ACTION */
|
||||||
|
|
||||||
{CmdSetRoadDriveSide, CMD_SERVER}, /* CMD_SET_ROAD_DRIVE_SIDE */
|
|
||||||
|
|
||||||
{CmdSellShip, 0}, /* CMD_SELL_SHIP */
|
{CmdSellShip, 0}, /* CMD_SELL_SHIP */
|
||||||
{CmdBuildShip, 0}, /* CMD_BUILD_SHIP */
|
{CmdBuildShip, 0}, /* CMD_BUILD_SHIP */
|
||||||
{CmdSendShipToDepot, 0}, /* CMD_SEND_SHIP_TO_DEPOT */
|
{CmdSendShipToDepot, 0}, /* CMD_SEND_SHIP_TO_DEPOT */
|
||||||
|
|
|
@ -240,8 +240,6 @@ enum {
|
||||||
CMD_RENAME_TOWN, ///< rename a town
|
CMD_RENAME_TOWN, ///< rename a town
|
||||||
CMD_DO_TOWN_ACTION, ///< do a action from the town detail window (like advertises or bribe)
|
CMD_DO_TOWN_ACTION, ///< do a action from the town detail window (like advertises or bribe)
|
||||||
|
|
||||||
CMD_SET_ROAD_DRIVE_SIDE, ///< set the side where the road vehicles drive
|
|
||||||
|
|
||||||
CMD_SELL_SHIP, ///< sell a ship
|
CMD_SELL_SHIP, ///< sell a ship
|
||||||
CMD_BUILD_SHIP, ///< build a new ship
|
CMD_BUILD_SHIP, ///< build a new ship
|
||||||
CMD_SEND_SHIP_TO_DEPOT, ///< send a ship to a depot
|
CMD_SEND_SHIP_TO_DEPOT, ///< send a ship to a depot
|
||||||
|
|
|
@ -45,30 +45,6 @@ bool RoadVehiclesAreBuilt()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the side of the road vehicles drive on (server only).
|
|
||||||
* @param tile unused
|
|
||||||
* @param flags operation to perform
|
|
||||||
* @param p1 the side of the road; 0 = left side and 1 = right side
|
|
||||||
* @param p2 unused
|
|
||||||
*/
|
|
||||||
CommandCost CmdSetRoadDriveSide(TileIndex tile, uint32 flags, uint32 p1, uint32 p2, const char *text)
|
|
||||||
{
|
|
||||||
/* Check boundaries and you can only change this if NO vehicles have been built yet,
|
|
||||||
* except in the intro-menu where of course it's always possible to do so. */
|
|
||||||
if (p1 > 1 || (_game_mode != GM_MENU && RoadVehiclesAreBuilt())) return CMD_ERROR;
|
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
|
||||||
if (_game_mode == GM_MENU) {
|
|
||||||
_settings_newgame.vehicle.road_side = p1;
|
|
||||||
} else {
|
|
||||||
_settings_game.vehicle.road_side = p1;
|
|
||||||
}
|
|
||||||
InvalidateWindow(WC_GAME_OPTIONS, 0);
|
|
||||||
}
|
|
||||||
return CommandCost();
|
|
||||||
}
|
|
||||||
|
|
||||||
#define M(x) (1 << (x))
|
#define M(x) (1 << (x))
|
||||||
/* Level crossings may only be built on these slopes */
|
/* Level crossings may only be built on these slopes */
|
||||||
static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
|
static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
|
||||||
|
|
|
@ -1047,6 +1047,17 @@ static bool CheckTownLayout(int32 p1)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the road side may be changed.
|
||||||
|
* @param p1 unused
|
||||||
|
* @return true if the road side may be changed.
|
||||||
|
*/
|
||||||
|
static bool CheckRoadSide(int p1)
|
||||||
|
{
|
||||||
|
extern bool RoadVehiclesAreBuilt();
|
||||||
|
return _game_mode == GM_MENU || !RoadVehiclesAreBuilt();
|
||||||
|
}
|
||||||
|
|
||||||
/** Conversion callback for _gameopt_settings_game.landscape
|
/** Conversion callback for _gameopt_settings_game.landscape
|
||||||
* It converts (or try) between old values and the new ones,
|
* It converts (or try) between old values and the new ones,
|
||||||
* without losing initial setting of the user
|
* without losing initial setting of the user
|
||||||
|
@ -1303,7 +1314,7 @@ const SettingDesc _patch_settings[] = {
|
||||||
SDT_CONDOMANY(GameSettings, game_creation.town_name, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
|
SDT_CONDOMANY(GameSettings, game_creation.town_name, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 255, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
|
||||||
SDT_CONDOMANY(GameSettings, game_creation.landscape, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
|
SDT_CONDOMANY(GameSettings, game_creation.landscape, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 0, 3, "temperate|arctic|tropic|toyland", STR_NULL, NULL, ConvertLandscape),
|
||||||
SDT_CONDVAR(GameSettings, game_creation.snow_line, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
|
SDT_CONDVAR(GameSettings, game_creation.snow_line, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 7 * TILE_HEIGHT, 2 * TILE_HEIGHT, 13 * TILE_HEIGHT, 0, STR_NULL, NULL),
|
||||||
SDT_CONDOMANY(GameSettings, vehicle.road_side, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 1, 1, "left|right", STR_NULL, NULL, NULL),
|
SDT_CONDOMANY(GameSettings, vehicle.road_side, SLE_UINT8, 97, SL_MAX_VERSION, 0,NN, 1, 1, "left|right", STR_NULL, CheckRoadSide, NULL),
|
||||||
|
|
||||||
SDT_BOOL(GameSettings, construction.build_on_slopes, 0,NN, true, STR_CONFIG_PATCHES_BUILDONSLOPES, NULL),
|
SDT_BOOL(GameSettings, construction.build_on_slopes, 0,NN, true, STR_CONFIG_PATCHES_BUILDONSLOPES, NULL),
|
||||||
SDT_CONDBOOL(GameSettings, construction.autoslope, 75, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_AUTOSLOPE, NULL),
|
SDT_CONDBOOL(GameSettings, construction.autoslope, 75, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_AUTOSLOPE, NULL),
|
||||||
|
|
|
@ -275,7 +275,9 @@ struct GameOptionsWindow : Window {
|
||||||
|
|
||||||
case GAMEOPT_ROADSIDE_BTN: // Road side
|
case GAMEOPT_ROADSIDE_BTN: // Road side
|
||||||
if (this->opt->vehicle.road_side != index) { // only change if setting changed
|
if (this->opt->vehicle.road_side != index) { // only change if setting changed
|
||||||
DoCommandP(0, index, 0, CMD_SET_ROAD_DRIVE_SIDE | CMD_MSG(STR_00B4_CAN_T_DO_THIS));
|
uint i;
|
||||||
|
if (GetPatchFromName("vehicle.road_side", &i) == NULL) NOT_REACHED();
|
||||||
|
SetPatchValue(i, index);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue