1
0
Fork 0

(svn r14895) -Change: move CMD_NO_WATER from all DoCommandPs to the command table

release/0.7
rubidium 2009-01-07 14:45:07 +00:00
parent d66d36126c
commit 5fcf07f388
7 changed files with 133 additions and 133 deletions

View File

@ -40,7 +40,7 @@ void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceAirport(TileIndex tile) static void PlaceAirport(TileIndex tile)
{ {
DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CMD_BUILD_AIRPORT | CMD_NO_WATER | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport); DoCommandP(tile, _selected_airport_type, _ctrl_pressed, CMD_BUILD_AIRPORT | CMD_MSG(STR_A001_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport);
} }

View File

@ -204,18 +204,18 @@ DEF_COMMAND(CmdAutofillTimetable);
* as the value from the CMD_* enums. * as the value from the CMD_* enums.
*/ */
static const Command _command_proc_table[] = { static const Command _command_proc_table[] = {
{CmdBuildRailroadTrack, CMD_AUTO}, /* CMD_BUILD_RAILROAD_TRACK */ {CmdBuildRailroadTrack, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_RAILROAD_TRACK */
{CmdRemoveRailroadTrack, CMD_AUTO}, /* CMD_REMOVE_RAILROAD_TRACK */ {CmdRemoveRailroadTrack, CMD_AUTO}, /* CMD_REMOVE_RAILROAD_TRACK */
{CmdBuildSingleRail, CMD_AUTO}, /* CMD_BUILD_SINGLE_RAIL */ {CmdBuildSingleRail, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_SINGLE_RAIL */
{CmdRemoveSingleRail, CMD_AUTO}, /* CMD_REMOVE_SINGLE_RAIL */ {CmdRemoveSingleRail, CMD_AUTO}, /* CMD_REMOVE_SINGLE_RAIL */
{CmdLandscapeClear, 0}, /* CMD_LANDSCAPE_CLEAR */ {CmdLandscapeClear, 0}, /* CMD_LANDSCAPE_CLEAR */
{CmdBuildBridge, CMD_AUTO}, /* CMD_BUILD_BRIDGE */ {CmdBuildBridge, CMD_AUTO}, /* CMD_BUILD_BRIDGE */
{CmdBuildRailroadStation, CMD_AUTO}, /* CMD_BUILD_RAILROAD_STATION */ {CmdBuildRailroadStation, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_RAILROAD_STATION */
{CmdBuildTrainDepot, CMD_AUTO}, /* CMD_BUILD_TRAIN_DEPOT */ {CmdBuildTrainDepot, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_TRAIN_DEPOT */
{CmdBuildSingleSignal, CMD_AUTO}, /* CMD_BUILD_SIGNALS */ {CmdBuildSingleSignal, CMD_AUTO}, /* CMD_BUILD_SIGNALS */
{CmdRemoveSingleSignal, CMD_AUTO}, /* CMD_REMOVE_SIGNALS */ {CmdRemoveSingleSignal, CMD_AUTO}, /* CMD_REMOVE_SIGNALS */
{CmdTerraformLand, CMD_AUTO}, /* CMD_TERRAFORM_LAND */ {CmdTerraformLand, CMD_AUTO}, /* CMD_TERRAFORM_LAND */
{CmdPurchaseLandArea, CMD_AUTO}, /* CMD_PURCHASE_LAND_AREA */ {CmdPurchaseLandArea, CMD_NO_WATER | CMD_AUTO}, /* CMD_PURCHASE_LAND_AREA */
{CmdSellLandArea, 0}, /* CMD_SELL_LAND_AREA */ {CmdSellLandArea, 0}, /* CMD_SELL_LAND_AREA */
{CmdBuildTunnel, CMD_AUTO}, /* CMD_BUILD_TUNNEL */ {CmdBuildTunnel, CMD_AUTO}, /* CMD_BUILD_TUNNEL */
{CmdRemoveFromRailroadStation, 0}, /* CMD_REMOVE_FROM_RAILROAD_STATION */ {CmdRemoveFromRailroadStation, 0}, /* CMD_REMOVE_FROM_RAILROAD_STATION */
@ -224,15 +224,15 @@ static const Command _command_proc_table[] = {
{CmdRenameWaypoint, 0}, /* CMD_RENAME_WAYPOINT */ {CmdRenameWaypoint, 0}, /* CMD_RENAME_WAYPOINT */
{CmdRemoveTrainWaypoint, 0}, /* CMD_REMOVE_TRAIN_WAYPOINT */ {CmdRemoveTrainWaypoint, 0}, /* CMD_REMOVE_TRAIN_WAYPOINT */
{CmdBuildRoadStop, CMD_AUTO}, /* CMD_BUILD_ROAD_STOP */ {CmdBuildRoadStop, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_ROAD_STOP */
{CmdRemoveRoadStop, 0}, /* CMD_REMOVE_ROAD_STOP */ {CmdRemoveRoadStop, 0}, /* CMD_REMOVE_ROAD_STOP */
{CmdBuildLongRoad, CMD_AUTO}, /* CMD_BUILD_LONG_ROAD */ {CmdBuildLongRoad, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_LONG_ROAD */
{CmdRemoveLongRoad, CMD_NO_TEST | CMD_AUTO}, /* CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed. */ {CmdRemoveLongRoad, CMD_NO_TEST | CMD_AUTO}, /* CMD_REMOVE_LONG_ROAD; towns may disallow removing road bits (as they are connected) in test, but in exec they're removed and thus removing is allowed. */
{CmdBuildRoad, 0}, /* CMD_BUILD_ROAD */ {CmdBuildRoad, 0}, /* CMD_BUILD_ROAD */
{CmdRemoveRoad, 0}, /* CMD_REMOVE_ROAD */ {CmdRemoveRoad, 0}, /* CMD_REMOVE_ROAD */
{CmdBuildRoadDepot, CMD_AUTO}, /* CMD_BUILD_ROAD_DEPOT */ {CmdBuildRoadDepot, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_ROAD_DEPOT */
{CmdBuildAirport, CMD_AUTO}, /* CMD_BUILD_AIRPORT */ {CmdBuildAirport, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_AIRPORT */
{CmdBuildDock, CMD_AUTO}, /* CMD_BUILD_DOCK */ {CmdBuildDock, CMD_AUTO}, /* CMD_BUILD_DOCK */
{CmdBuildShipDepot, CMD_AUTO}, /* CMD_BUILD_SHIP_DEPOT */ {CmdBuildShipDepot, CMD_AUTO}, /* CMD_BUILD_SHIP_DEPOT */
{CmdBuildBuoy, CMD_AUTO}, /* CMD_BUILD_BUOY */ {CmdBuildBuoy, CMD_AUTO}, /* CMD_BUILD_BUOY */
@ -253,7 +253,7 @@ static const Command _command_proc_table[] = {
{CmdChangeServiceInt, 0}, /* CMD_CHANGE_SERVICE_INT */ {CmdChangeServiceInt, 0}, /* CMD_CHANGE_SERVICE_INT */
{CmdBuildIndustry, 0}, /* CMD_BUILD_INDUSTRY */ {CmdBuildIndustry, 0}, /* CMD_BUILD_INDUSTRY */
{CmdBuildCompanyHQ, CMD_AUTO}, /* CMD_BUILD_COMPANY_HQ */ {CmdBuildCompanyHQ, CMD_NO_WATER | CMD_AUTO}, /* CMD_BUILD_COMPANY_HQ */
{CmdSetCompanyManagerFace, 0}, /* CMD_SET_COMPANY_MANAGER_FACE */ {CmdSetCompanyManagerFace, 0}, /* CMD_SET_COMPANY_MANAGER_FACE */
{CmdSetCompanyColor, 0}, /* CMD_SET_COMPANY_COLOR */ {CmdSetCompanyColor, 0}, /* CMD_SET_COMPANY_COLOR */
@ -506,7 +506,7 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallbac
uint32 flags = 0; uint32 flags = 0;
/* Command flags are used internally */ /* Command flags are used internally */
uint cmd_flags = GetCommandFlags(cmd); uint cmd_flags = GetCommandFlags(cmd);
if (cmd & CMD_NO_WATER) flags |= DC_NO_WATER; if (cmd_flags & CMD_NO_WATER) flags |= DC_NO_WATER;
if (cmd_flags & CMD_AUTO) flags |= DC_AUTO; if (cmd_flags & CMD_AUTO) flags |= DC_AUTO;
bool notest = (cmd_flags & CMD_NO_TEST) != 0; bool notest = (cmd_flags & CMD_NO_TEST) != 0;

View File

@ -324,7 +324,6 @@ enum {
* This enumeration defines some flags which are binary-or'ed on a command. * This enumeration defines some flags which are binary-or'ed on a command.
*/ */
enum { enum {
CMD_NO_WATER = 0x0400, ///< dont build on water
CMD_NETWORK_COMMAND = 0x0800, ///< execute the command without sending it on the network CMD_NETWORK_COMMAND = 0x0800, ///< execute the command without sending it on the network
CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network CMD_NO_TEST_IF_IN_NETWORK = 0x1000, ///< When enabled, the command will bypass the no-DC_EXEC round if in network
CMD_SHOW_NO_ERROR = 0x2000, ///< do not show the error message CMD_SHOW_NO_ERROR = 0x2000, ///< do not show the error message
@ -338,10 +337,11 @@ enum {
* This enumeration defines flags for the _command_proc_table. * This enumeration defines flags for the _command_proc_table.
*/ */
enum { enum {
CMD_SERVER = 0x1, ///< the command can only be initiated by the server CMD_SERVER = 0x01, ///< the command can only be initiated by the server
CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only CMD_OFFLINE = 0x02, ///< the command cannot be executed in a multiplayer game; single-player only
CMD_AUTO = 0x4, ///< set the DC_AUTO flag on this command CMD_AUTO = 0x04, ///< set the DC_AUTO flag on this command
CMD_NO_TEST = 0x8, ///< the command's output may differ between test and execute due to town rating changes etc. CMD_NO_TEST = 0x08, ///< the command's output may differ between test and execute due to town rating changes etc.
CMD_NO_WATER = 0x10, ///< set the DC_NO_WATER flag on this command
}; };
/** /**

View File

@ -1310,7 +1310,7 @@ struct CompanyWindow : Window
virtual void OnPlaceObject(Point pt, TileIndex tile) virtual void OnPlaceObject(Point pt, TileIndex tile)
{ {
if (DoCommandP(tile, 0, 0, CMD_BUILD_COMPANY_HQ | CMD_NO_WATER | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS))) if (DoCommandP(tile, 0, 0, CMD_BUILD_COMPANY_HQ | CMD_MSG(STR_7071_CAN_T_BUILD_COMPANY_HEADQUARTERS)))
ResetObjectToPlace(); ResetObjectToPlace();
this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button this->widget[CW_WIDGET_BUILD_VIEW_HQ].type = WWT_PUSHTXTBTN; // this button can now behave as a normal push button
this->RaiseButtons(); this->RaiseButtons();

View File

@ -81,8 +81,8 @@ static void GenericPlaceRail(TileIndex tile, int cmd)
{ {
DoCommandP(tile, _cur_railtype, cmd, DoCommandP(tile, _cur_railtype, cmd,
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) | CMD_NO_WATER : CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) | CMD_NO_WATER, CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK),
CcPlaySound1E CcPlaySound1E
); );
} }
@ -125,7 +125,7 @@ static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return; if (GetRailTileType(tile) != RAIL_TILE_NORMAL) return;
if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return; if ((GetTrackBits(tile) & GB(extra, 8, 8)) == 0) return;
DoCommandP(tile, _cur_railtype, extra & 0xFF, CMD_BUILD_SINGLE_RAIL | CMD_NO_WATER); DoCommandP(tile, _cur_railtype, extra & 0xFF, CMD_BUILD_SINGLE_RAIL);
} }
/** Additional pieces of track to add at the entrance of a depot. */ /** Additional pieces of track to add at the entrance of a depot. */
@ -157,7 +157,7 @@ void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRail_Depot(TileIndex tile) static void PlaceRail_Depot(TileIndex tile)
{ {
DoCommandP(tile, _cur_railtype, _build_depot_direction, DoCommandP(tile, _cur_railtype, _build_depot_direction,
CMD_BUILD_TRAIN_DEPOT | CMD_NO_WATER | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT), CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_100E_CAN_T_BUILD_TRAIN_DEPOT),
CcRailDepot); CcRailDepot);
} }
@ -191,7 +191,7 @@ static void PlaceRail_Station(TileIndex tile)
DoCommandP(tile, DoCommandP(tile,
_railstation.orientation | (_settings_client.gui.station_numtracks << 8) | (_settings_client.gui.station_platlength << 16) | (_ctrl_pressed << 24), _railstation.orientation | (_settings_client.gui.station_numtracks << 8) | (_settings_client.gui.station_platlength << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16),
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation); CMD_BUILD_RAILROAD_STATION | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation);
} }
} }
@ -514,8 +514,8 @@ static void DoRailroadTrack(int mode)
{ {
DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4), DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), _cur_railtype | (mode << 4),
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_1012_CAN_T_REMOVE_RAILROAD_TRACK) :
CMD_BUILD_RAILROAD_TRACK | CMD_NO_WATER | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK) CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_1011_CAN_T_BUILD_RAILROAD_TRACK)
); );
} }
@ -572,8 +572,8 @@ static void HandleAutoSignalPlacement()
TileVirtXY(thd->selend.x, thd->selend.y), TileVirtXY(thd->selend.x, thd->selend.y),
p2, p2,
_remove_button_clicked ? _remove_button_clicked ?
CMD_REMOVE_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) : CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_1013_CAN_T_REMOVE_SIGNALS_FROM) :
CMD_BUILD_SIGNAL_TRACK | CMD_NO_WATER | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE), CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_1010_CAN_T_BUILD_SIGNALS_HERE),
CcPlaySound1E); CcPlaySound1E);
} }
@ -878,7 +878,7 @@ static void HandleStationPlacement(TileIndex start, TileIndex end)
DoCommandP(TileXY(sx, sy), DoCommandP(TileXY(sx, sy),
_railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24), _railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), _cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16),
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation); CMD_BUILD_RAILROAD_STATION | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION), CcStation);
} }
struct BuildRailStationWindow : public PickerWindowBase { struct BuildRailStationWindow : public PickerWindowBase {

View File

@ -200,7 +200,7 @@ void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
static void PlaceRoad_Depot(TileIndex tile) static void PlaceRoad_Depot(TileIndex tile)
{ {
DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CMD_BUILD_ROAD_DEPOT | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot), CcRoadDepot); DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CMD_BUILD_ROAD_DEPOT | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot), CcRoadDepot);
} }
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd) static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
@ -219,7 +219,7 @@ static void PlaceRoad_BusStation(TileIndex tile)
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(tile, 0, ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound1D); DoCommandP(tile, 0, ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound1D);
} else { } else {
PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS])); PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
} }
} }
@ -228,7 +228,7 @@ static void PlaceRoad_TruckStation(TileIndex tile)
if (_remove_button_clicked) { if (_remove_button_clicked) {
DoCommandP(tile, 0, ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound1D); DoCommandP(tile, 0, ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound1D);
} else { } else {
PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK])); PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
} }
} }
@ -598,8 +598,8 @@ struct BuildRoadToolbarWindow : Window {
DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
(_ctrl_pressed || _remove_button_clicked) ? (_ctrl_pressed || _remove_button_clicked) ?
CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) : CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D); CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound1D);
break; break;
} }
} }

View File

@ -155,7 +155,7 @@ void CcPlaySound1E(bool success, TileIndex tile, uint32 p1, uint32 p2);
static void PlaceProc_BuyLand(TileIndex tile) static void PlaceProc_BuyLand(TileIndex tile)
{ {
DoCommandP(tile, 0, 0, CMD_PURCHASE_LAND_AREA | CMD_NO_WATER | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E); DoCommandP(tile, 0, 0, CMD_PURCHASE_LAND_AREA | CMD_MSG(STR_5806_CAN_T_PURCHASE_THIS_LAND), CcPlaySound1E);
} }
void PlaceProc_DemolishArea(TileIndex tile) void PlaceProc_DemolishArea(TileIndex tile)