Codechange: Template script command calls.
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include "../../newgrf_generic.h"
|
||||
#include "../../newgrf_station.h"
|
||||
#include "../../strings_func.h"
|
||||
#include "../../rail_cmd.h"
|
||||
#include "../../station_cmd.h"
|
||||
#include "../../waypoint_cmd.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
@@ -113,7 +116,7 @@
|
||||
EnforcePrecondition(false, ::IsValidTile(end_tile));
|
||||
EnforcePrecondition(false, IsRailTypeAvailable(convert_to));
|
||||
|
||||
return ScriptObject::DoCommand(start_tile, end_tile, convert_to, CMD_CONVERT_RAIL);
|
||||
return ScriptObject::Command<CMD_CONVERT_RAIL>::Do(start_tile, end_tile, convert_to, {});
|
||||
}
|
||||
|
||||
/* static */ TileIndex ScriptRail::GetRailDepotFrontTile(TileIndex depot)
|
||||
@@ -141,7 +144,7 @@
|
||||
|
||||
uint entrance_dir = (::TileX(tile) == ::TileX(front)) ? (::TileY(tile) < ::TileY(front) ? 1 : 3) : (::TileX(tile) < ::TileX(front) ? 2 : 0);
|
||||
|
||||
return ScriptObject::DoCommand(tile, ScriptObject::GetRailType(), entrance_dir, CMD_BUILD_TRAIN_DEPOT);
|
||||
return ScriptObject::Command<CMD_BUILD_TRAIN_DEPOT>::Do(tile, ScriptObject::GetRailType(), entrance_dir, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::BuildRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id)
|
||||
@@ -157,7 +160,7 @@
|
||||
uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8);
|
||||
if (direction == RAILTRACK_NW_SE) p1 |= (1 << 6);
|
||||
if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24);
|
||||
return ScriptObject::DoCommand(tile, p1, (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, CMD_BUILD_RAIL_STATION);
|
||||
return ScriptObject::Command<CMD_BUILD_RAIL_STATION>::Do(tile, p1, (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::BuildNewGRFRailStation(TileIndex tile, RailTrack direction, uint num_platforms, uint platform_length, StationID station_id, CargoID cargo_id, IndustryType source_industry, IndustryType goal_industry, int distance, bool source_station)
|
||||
@@ -198,11 +201,11 @@
|
||||
Debug(grf, 1, "{} returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
|
||||
} else {
|
||||
/* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */
|
||||
if (ScriptObject::DoCommand(tile, p1, p2 | spec->cls_id | index << 8, CMD_BUILD_RAIL_STATION)) return true;
|
||||
if (ScriptObject::Command<CMD_BUILD_RAIL_STATION>::Do(tile, p1, p2 | spec->cls_id | index << 8, {})) return true;
|
||||
}
|
||||
}
|
||||
|
||||
return ScriptObject::DoCommand(tile, p1, p2, CMD_BUILD_RAIL_STATION);
|
||||
return ScriptObject::Command<CMD_BUILD_RAIL_STATION>::Do(tile, p1, p2, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::BuildRailWaypoint(TileIndex tile)
|
||||
@@ -213,7 +216,7 @@
|
||||
EnforcePrecondition(false, GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE);
|
||||
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
|
||||
|
||||
return ScriptObject::DoCommand(tile, GetCurrentRailType() | (GetRailTracks(tile) == RAILTRACK_NE_SW ? AXIS_X : AXIS_Y) << 6 | 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT);
|
||||
return ScriptObject::Command<CMD_BUILD_RAIL_WAYPOINT>::Do(tile, GetCurrentRailType() | (GetRailTracks(tile) == RAILTRACK_NE_SW ? AXIS_X : AXIS_Y) << 6 | 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::RemoveRailWaypointTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail)
|
||||
@@ -222,7 +225,7 @@
|
||||
EnforcePrecondition(false, ::IsValidTile(tile));
|
||||
EnforcePrecondition(false, ::IsValidTile(tile2));
|
||||
|
||||
return ScriptObject::DoCommand(tile, tile2, keep_rail ? 1 : 0, CMD_REMOVE_FROM_RAIL_WAYPOINT);
|
||||
return ScriptObject::Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Do(tile, tile2, keep_rail ? 1 : 0, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::RemoveRailStationTileRectangle(TileIndex tile, TileIndex tile2, bool keep_rail)
|
||||
@@ -231,7 +234,7 @@
|
||||
EnforcePrecondition(false, ::IsValidTile(tile));
|
||||
EnforcePrecondition(false, ::IsValidTile(tile2));
|
||||
|
||||
return ScriptObject::DoCommand(tile, tile2, keep_rail ? 1 : 0, CMD_REMOVE_FROM_RAIL_STATION);
|
||||
return ScriptObject::Command<CMD_REMOVE_FROM_RAIL_STATION>::Do(tile, tile2, keep_rail ? 1 : 0, {});
|
||||
}
|
||||
|
||||
/* static */ uint ScriptRail::GetRailTracks(TileIndex tile)
|
||||
@@ -253,7 +256,7 @@
|
||||
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
|
||||
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
|
||||
|
||||
return ScriptObject::DoCommand(tile, tile, GetCurrentRailType() | (FindFirstTrack((::TrackBits)rail_track) << 6), CMD_BUILD_RAILROAD_TRACK);
|
||||
return ScriptObject::Command<CMD_BUILD_RAILROAD_TRACK>::Do(tile, tile, GetCurrentRailType() | (FindFirstTrack((::TrackBits)rail_track) << 6), {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::RemoveRailTrack(TileIndex tile, RailTrack rail_track)
|
||||
@@ -264,7 +267,7 @@
|
||||
EnforcePrecondition(false, GetRailTracks(tile) & rail_track);
|
||||
EnforcePrecondition(false, KillFirstBit((uint)rail_track) == 0);
|
||||
|
||||
return ScriptObject::DoCommand(tile, tile, FindFirstTrack((::TrackBits)rail_track) << 6, CMD_REMOVE_RAILROAD_TRACK);
|
||||
return ScriptObject::Command<CMD_REMOVE_RAILROAD_TRACK>::Do(tile, tile, FindFirstTrack((::TrackBits)rail_track) << 6, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::AreTilesConnected(TileIndex from, TileIndex tile, TileIndex to)
|
||||
@@ -365,7 +368,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
|
||||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
|
||||
|
||||
uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 10 | ScriptRail::GetCurrentRailType();;
|
||||
return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK);
|
||||
return ScriptObject::Command<CMD_BUILD_RAILROAD_TRACK>::Do(tile, to, p2, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::RemoveRail(TileIndex from, TileIndex tile, TileIndex to)
|
||||
@@ -382,7 +385,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to)
|
||||
(::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to)));
|
||||
|
||||
uint32 p2 = SimulateDrag(from, tile, &to);
|
||||
return ScriptObject::DoCommand(tile, to, p2, CMD_REMOVE_RAILROAD_TRACK);
|
||||
return ScriptObject::Command<CMD_REMOVE_RAILROAD_TRACK>::Do(tile, to, p2, {});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -468,7 +471,7 @@ static bool IsValidSignalType(int signal_type)
|
||||
}
|
||||
p1 |= ((signal >= SIGNALTYPE_TWOWAY ? signal ^ SIGNALTYPE_TWOWAY : signal) << 5);
|
||||
|
||||
return ScriptObject::DoCommand(tile, p1, 0, CMD_BUILD_SIGNALS);
|
||||
return ScriptObject::Command<CMD_BUILD_SIGNALS>::Do(tile, p1, 0, {});
|
||||
}
|
||||
|
||||
/* static */ bool ScriptRail::RemoveSignal(TileIndex tile, TileIndex front)
|
||||
@@ -487,7 +490,7 @@ static bool IsValidSignalType(int signal_type)
|
||||
}
|
||||
EnforcePrecondition(false, track != INVALID_TRACK);
|
||||
|
||||
return ScriptObject::DoCommand(tile, track, 0, CMD_REMOVE_SIGNALS);
|
||||
return ScriptObject::Command<CMD_REMOVE_SIGNALS>::Do(tile, track, 0, {});
|
||||
}
|
||||
|
||||
/* static */ Money ScriptRail::GetBuildCost(RailType railtype, BuildType build_type)
|
||||
|
Reference in New Issue
Block a user