Codechange: make explicit when a TileIndex is cast to its basetype (#11190)
This prevents people accidentially assigning a TileIndex to a Date or any other type they shouldn't.
This commit is contained in:
@@ -83,8 +83,8 @@ static void _DoCommandReturnBuildBridge1(class ScriptInstance *instance)
|
||||
|
||||
switch (vehicle_type) {
|
||||
case ScriptVehicle::VT_ROAD:
|
||||
ScriptObject::SetCallbackVariable(0, start);
|
||||
ScriptObject::SetCallbackVariable(1, end);
|
||||
ScriptObject::SetCallbackVariable(0, static_cast<uint32_t>(start));
|
||||
ScriptObject::SetCallbackVariable(1, static_cast<uint32_t>(end));
|
||||
return ScriptObject::Command<CMD_BUILD_BRIDGE>::Do(&::_DoCommandReturnBuildBridge1, end, start, TRANSPORT_ROAD, bridge_id, ScriptRoad::GetCurrentRoadType());
|
||||
case ScriptVehicle::VT_RAIL:
|
||||
return ScriptObject::Command<CMD_BUILD_BRIDGE>::Do(end, start, TRANSPORT_RAIL, bridge_id, ScriptRail::GetCurrentRailType());
|
||||
|
@@ -30,7 +30,7 @@ ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
|
||||
for (const Station *st : Station::Iterate()) {
|
||||
if (st->owner == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) {
|
||||
for (uint i = 0; i < st->airport.GetNumHangars(); i++) {
|
||||
this->AddItem(st->airport.GetHangarTile(i));
|
||||
this->AddItem(static_cast<uint32_t>(st->airport.GetHangarTile(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,6 @@ ScriptDepotList::ScriptDepotList(ScriptTile::TransportType transport_type)
|
||||
|
||||
/* Handle 'standard' depots. */
|
||||
for (const Depot *depot : Depot::Iterate()) {
|
||||
if ((::GetTileOwner(depot->xy) == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && ::IsTileType(depot->xy, tile_type)) this->AddItem(depot->xy);
|
||||
if ((::GetTileOwner(depot->xy) == ScriptObject::GetCompany() || ScriptCompanyMode::IsDeity()) && ::IsTileType(depot->xy, tile_type)) this->AddItem(static_cast<uint32_t>(depot->xy));
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
class ScriptMap : public ScriptObject {
|
||||
public:
|
||||
static const int TILE_INVALID = (int)INVALID_TILE; ///< Invalid TileIndex.
|
||||
static const int TILE_INVALID = static_cast<uint32_t>(INVALID_TILE); ///< Invalid TileIndex.
|
||||
|
||||
/**
|
||||
* Checks whether the given tile is valid.
|
||||
|
@@ -382,8 +382,8 @@ static bool NormaliseTileOffset(int32_t *tile)
|
||||
/* static */ SQInteger ScriptRoad::CanBuildConnectedRoadParts(ScriptTile::Slope slope_, Array<> &&existing, TileIndex start_, TileIndex end_)
|
||||
{
|
||||
::Slope slope = (::Slope)slope_;
|
||||
int32_t start = start_;
|
||||
int32_t end = end_;
|
||||
int32_t start = static_cast<uint32_t>(start_);
|
||||
int32_t end = static_cast<uint32_t>(end_);
|
||||
|
||||
/* The start tile and end tile cannot be the same tile either. */
|
||||
if (start == end) return -1;
|
||||
|
@@ -21,14 +21,14 @@ void ScriptTileList::AddRectangle(TileIndex t1, TileIndex t2)
|
||||
if (!::IsValidTile(t2)) return;
|
||||
|
||||
TileArea ta(t1, t2);
|
||||
for (TileIndex t : ta) this->AddItem(t);
|
||||
for (TileIndex t : ta) this->AddItem(static_cast<uint32_t>(t));
|
||||
}
|
||||
|
||||
void ScriptTileList::AddTile(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return;
|
||||
|
||||
this->AddItem(tile);
|
||||
this->AddItem(static_cast<uint32_t>(tile));
|
||||
}
|
||||
|
||||
void ScriptTileList::RemoveRectangle(TileIndex t1, TileIndex t2)
|
||||
@@ -37,14 +37,14 @@ void ScriptTileList::RemoveRectangle(TileIndex t1, TileIndex t2)
|
||||
if (!::IsValidTile(t2)) return;
|
||||
|
||||
TileArea ta(t1, t2);
|
||||
for (TileIndex t : ta) this->RemoveItem(t);
|
||||
for (TileIndex t : ta) this->RemoveItem(static_cast<uint32_t>(t));
|
||||
}
|
||||
|
||||
void ScriptTileList::RemoveTile(TileIndex tile)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return;
|
||||
|
||||
this->RemoveItem(tile);
|
||||
this->RemoveItem(static_cast<uint32_t>(tile));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -93,7 +93,7 @@ static void _DoCommandReturnBuildTunnel1(class ScriptInstance *instance)
|
||||
/* For rail we do nothing special */
|
||||
return ScriptObject::Command<CMD_BUILD_TUNNEL>::Do(start, TRANSPORT_RAIL, ScriptRail::GetCurrentRailType());
|
||||
} else {
|
||||
ScriptObject::SetCallbackVariable(0, start);
|
||||
ScriptObject::SetCallbackVariable(0, static_cast<uint32_t>(start));
|
||||
return ScriptObject::Command<CMD_BUILD_TUNNEL>::Do(&::_DoCommandReturnBuildTunnel1, start, TRANSPORT_ROAD, ScriptRoad::GetCurrentRoadType());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user