Codechange: use TileIndex constructor explicitly
This commit is contained in:
@@ -136,16 +136,17 @@ static const NIVariable _niv_stations[] = {
|
||||
};
|
||||
|
||||
class NIHStation : public NIHelper {
|
||||
bool IsInspectable(uint index) const override { return GetStationSpec(index) != nullptr; }
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(index)->town->index); }
|
||||
bool IsInspectable(uint index) const override { return GetStationSpec(TileIndex{index}) != nullptr; }
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Station::GetByTile(TileIndex{index})->town->index); }
|
||||
const void *GetInstance(uint ) const override { return nullptr; }
|
||||
const void *GetSpec(uint index) const override { return GetStationSpec(index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grfid : 0; }
|
||||
const void *GetSpec(uint index) const override { return GetStationSpec(TileIndex{index}); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(TileIndex{index})->grf_prop.grfid : 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
StationResolverObject ro(GetStationSpec(index), Station::GetByTile(index), index);
|
||||
TileIndex tile{index};
|
||||
StationResolverObject ro(GetStationSpec(tile), Station::GetByTile(tile), tile);
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -205,12 +206,13 @@ class NIHHouse : public NIHelper {
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, GetTownIndex(index)); }
|
||||
const void *GetInstance(uint)const override { return nullptr; }
|
||||
const void *GetSpec(uint index) const override { return HouseSpec::Get(GetHouseType(index)); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grfid : 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
HouseResolverObject ro(GetHouseType(index), index, Town::GetByTile(index));
|
||||
TileIndex tile{index};
|
||||
HouseResolverObject ro(GetHouseType(tile), tile, Town::GetByTile(tile));
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -255,12 +257,13 @@ class NIHIndustryTile : public NIHelper {
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_INDUSTRIES, GetIndustryIndex(index)); }
|
||||
const void *GetInstance(uint)const override { return nullptr; }
|
||||
const void *GetSpec(uint index) const override { return GetIndustryTileSpec(GetIndustryGfx(index)); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grfid : 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
IndustryTileResolverObject ro(GetIndustryGfx(index), index, Industry::GetByTile(index));
|
||||
TileIndex tile{index};
|
||||
IndustryTileResolverObject ro(GetIndustryGfx(tile), tile, Industry::GetByTile(tile));
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -427,16 +430,17 @@ static const NIVariable _niv_objects[] = {
|
||||
};
|
||||
|
||||
class NIHObject : public NIHelper {
|
||||
bool IsInspectable(uint index) const override { return ObjectSpec::GetByTile(index)->grf_prop.HasGrfFile(); }
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(index)->town->index); }
|
||||
const void *GetInstance(uint index)const override { return Object::GetByTile(index); }
|
||||
const void *GetSpec(uint index) const override { return ObjectSpec::GetByTile(index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grfid : 0; }
|
||||
bool IsInspectable(uint index) const override { return ObjectSpec::GetByTile(TileIndex{index})->grf_prop.HasGrfFile(); }
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, Object::GetByTile(TileIndex{index})->town->index); }
|
||||
const void *GetInstance(uint index)const override { return Object::GetByTile(TileIndex{index}); }
|
||||
const void *GetSpec(uint index) const override { return ObjectSpec::GetByTile(TileIndex{index}); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(TileIndex{index})->grf_prop.grfid : 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
ObjectResolverObject ro(ObjectSpec::GetByTile(index), Object::GetByTile(index), index);
|
||||
TileIndex tile{index};
|
||||
ObjectResolverObject ro(ObjectSpec::GetByTile(tile), Object::GetByTile(tile), tile);
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -465,14 +469,14 @@ class NIHRailType : public NIHelper {
|
||||
uint GetParent(uint) const override { return UINT32_MAX; }
|
||||
const void *GetInstance(uint) const override { return nullptr; }
|
||||
const void *GetSpec(uint) const override { return nullptr; }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint) const override { return 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
/* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype.
|
||||
* However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */
|
||||
RailTypeResolverObject ro(nullptr, index, TCX_NORMAL, RTSG_END);
|
||||
RailTypeResolverObject ro(nullptr, TileIndex{index}, TCX_NORMAL, RTSG_END);
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -501,12 +505,13 @@ class NIHAirportTile : public NIHelper {
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_AIRPORTS, GetStationIndex(index)); }
|
||||
const void *GetInstance(uint)const override { return nullptr; }
|
||||
const void *GetSpec(uint index) const override { return AirportTileSpec::Get(GetAirportGfx(index)); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grfid : 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
AirportTileResolverObject ro(AirportTileSpec::GetByTile(index), index, Station::GetByTile(index));
|
||||
TileIndex tile{index};
|
||||
AirportTileResolverObject ro(AirportTileSpec::GetByTile(tile), tile, Station::GetByTile(tile));
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -633,14 +638,14 @@ class NIHRoadType : public NIHelper {
|
||||
uint GetParent(uint) const override { return UINT32_MAX; }
|
||||
const void *GetInstance(uint) const override { return nullptr; }
|
||||
const void *GetSpec(uint) const override { return nullptr; }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE, INVALID_STRING_ID, index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_ROAD_TYPE, INVALID_STRING_ID, TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint) const override { return 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint param, bool &avail) const override
|
||||
{
|
||||
/* There is no unique GRFFile for the tile. Multiple GRFs can define different parts of the railtype.
|
||||
* However, currently the NewGRF Debug GUI does not display variables depending on the GRF (like 0x7F) anyway. */
|
||||
RoadTypeResolverObject ro(nullptr, index, TCX_NORMAL, ROTSG_END);
|
||||
RoadTypeResolverObject ro(nullptr, TileIndex{index}, TCX_NORMAL, ROTSG_END);
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
@@ -695,17 +700,18 @@ static const NIVariable _nif_roadstops[] = {
|
||||
};
|
||||
|
||||
class NIHRoadStop : public NIHelper {
|
||||
bool IsInspectable(uint index) const override { return GetRoadStopSpec(index) != nullptr; }
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, BaseStation::GetByTile(index)->town->index); }
|
||||
bool IsInspectable(uint index) const override { return GetRoadStopSpec(TileIndex{index}) != nullptr; }
|
||||
uint GetParent(uint index) const override { return GetInspectWindowNumber(GSF_FAKE_TOWNS, BaseStation::GetByTile(TileIndex{index})->town->index); }
|
||||
const void *GetInstance(uint)const override { return nullptr; }
|
||||
const void *GetSpec(uint index) const override { return GetRoadStopSpec(index); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(index)->grf_prop.grfid : 0; }
|
||||
const void *GetSpec(uint index) const override { return GetRoadStopSpec(TileIndex{index}); }
|
||||
void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), TileIndex{index}); }
|
||||
uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(TileIndex{index})->grf_prop.grfid : 0; }
|
||||
|
||||
uint Resolve(uint index, uint var, uint32_t param, bool &avail) const override
|
||||
{
|
||||
StationGfx view = GetStationGfx(index);
|
||||
RoadStopResolverObject ro(GetRoadStopSpec(index), BaseStation::GetByTile(index), index, INVALID_ROADTYPE, GetStationType(index), view);
|
||||
TileIndex tile{index};
|
||||
StationGfx view = GetStationGfx(tile);
|
||||
RoadStopResolverObject ro(GetRoadStopSpec(tile), BaseStation::GetByTile(tile), tile, INVALID_ROADTYPE, GetStationType(tile), view);
|
||||
return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user