I tried to improve support for rattroads (multiple road types), but I'm a bit lost how I could detect the roadtype on a specific tile. There is no AIRoad.GetRoadType(tile), probabaly because a tile could contain both a tram road and a normal road. There is however a function AIRoad.HasRoadType(tile, roadType), but it works different from what I would expect. Could someone check if this is working as intended, a bug in rattroads newGRF or a bug in the NoAI API?
I have built 4 roads, as below, then I check what AIRoad.HasRoadType returns for different parameters: I try every available roadtype, as well as the "default" roadTypes and check 4 tiles with each a different roadtype on it. Seemingly all roadtiles have all road-roadtypes on it according to the API.
NoAI RoadTypes and RattRoads
Moderator: OpenTTD Developers
Re: NoAI RoadTypes and RattRoads
I have also encountered this behaviour. You can find the function code here. I dont understand it well enough to make assumptions if that is correctly implemented.
You can however use a workaround by using function AIRoad.ConvertRoadType in TestMode, which will return false with error ERR_ALREADY_BUILT when you try to upgrade with the same road type.
You can however use a workaround by using function AIRoad.ConvertRoadType in TestMode, which will return false with error ERR_ALREADY_BUILT when you try to upgrade with the same road type.
Re: NoAI RoadTypes and RattRoads
The ::GetRoadTramType in the code hints that the function actually checks if for the given RoadType, it is checked whether the corresponding RoadTramType is present on the tile.
I think the best solution would be to have a new function GetRoadtype(tile, RoadTramType) introduced.
Edit: This might need some more rework, because the functions AIEngine.GetRoadType and AIVehicle.GetRoadType do not use any of the 'new' RoadTypes, but they return RoadType.ROADTYPE_ROAD / RoadType.ROADTYPE_TRAM. That behaviour matches more to the definition of RoadTramType.
I think the best solution would be to have a new function GetRoadtype(tile, RoadTramType) introduced.
Edit: This might need some more rework, because the functions AIEngine.GetRoadType and AIVehicle.GetRoadType do not use any of the 'new' RoadTypes, but they return RoadType.ROADTYPE_ROAD / RoadType.ROADTYPE_TRAM. That behaviour matches more to the definition of RoadTramType.
Who is online
Users browsing this forum: No registered users and 16 guests