Index: src/ai/api/ai_road.hpp =================================================================== --- src/ai/api/ai_road.hpp (revision 12187) +++ src/ai/api/ai_road.hpp (working copy) @@ -35,7 +35,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has road. */ - bool IsRoadTile(TileIndex tile); + static bool IsRoadTile(TileIndex tile); /** * Checks whether the given tile is actually a tile with a road depot. @@ -43,7 +43,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has a road depot. */ - bool IsRoadDepotTile(TileIndex tile); + static bool IsRoadDepotTile(TileIndex tile); /** * Checks whether the given tile is actually a tile with a road station. @@ -51,7 +51,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has a road station. */ - bool IsRoadStationTile(TileIndex tile); + static bool IsRoadStationTile(TileIndex tile); /** * Checks whether the given tile is actually a tile with a drive through @@ -60,7 +60,7 @@ * @pre tile is always positive and smaller than AIMap::GetMapSize(). * @return true if and only if the tile has a drive through road station. */ - bool IsDriveThroughRoadStationTile(TileIndex tile); + static bool IsDriveThroughRoadStationTile(TileIndex tile); /** * Checks whether the given tiles are directly connected, i.e. whether @@ -73,7 +73,7 @@ * @pre t1 and t2 are directly neighbouring tiles. * @return true if and only if a road vehicle can go from t1 to t2. */ - bool AreRoadTilesConnected(TileIndex t1, TileIndex t2); + static bool AreRoadTilesConnected(TileIndex t1, TileIndex t2); /** * Count how many neighbours are road. @@ -89,7 +89,7 @@ * @pre IsRoadDepotTile(depot). * @return the tile in front of the depot. */ - TileIndex GetRoadDepotFrontTile(TileIndex depot); + static TileIndex GetRoadDepotFrontTile(TileIndex depot); /** * Gets the tile in front of a road station. @@ -97,7 +97,7 @@ * @pre IsRoadStationTile(station). * @return the tile in front of the road station. */ - TileIndex GetRoadStationFrontTile(TileIndex station); + static TileIndex GetRoadStationFrontTile(TileIndex station); /** * Gets the tile at the back of a drive through road station. @@ -107,7 +107,7 @@ * @pre IsDriveThroughRoadStationTile(station). * @return the tile at the back of the drive through road station. */ - TileIndex GetDriveThroughBackTile(TileIndex station); + static TileIndex GetDriveThroughBackTile(TileIndex station); /** * Builds a road from the center of tile start to the @@ -122,7 +122,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be build or not. */ - bool BuildRoad(TileIndex start, TileIndex end); + static bool BuildRoad(TileIndex start, TileIndex end); /** * Builds a road from the edge of tile start to the @@ -137,7 +137,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be build or not. */ - bool BuildRoadFull(TileIndex start, TileIndex end); + static bool BuildRoadFull(TileIndex start, TileIndex end); /** * Builds a road depot. @@ -148,7 +148,7 @@ * @pre tile is not equal to front * @return whether the road depot has been/can be build or not. */ - bool BuildRoadDepot(TileIndex tile, TileIndex front); + static bool BuildRoadDepot(TileIndex tile, TileIndex front); /** * Builds a road bus or truck station. @@ -162,7 +162,7 @@ * @pre tile is not equal to front * @return whether the station has been/can be build or not. */ - bool BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through); + static bool BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through); /** * Removes a road from the center of tile start to the @@ -176,7 +176,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be removed or not. */ - bool RemoveRoad(TileIndex start, TileIndex end); + static bool RemoveRoad(TileIndex start, TileIndex end); /** * Removes a road from the edge of tile start to the @@ -190,7 +190,7 @@ * AIMap::GetTileY(start) == AIMap::GetTileY(end). * @return whether the road has been/can be removed or not. */ - bool RemoveRoadFull(TileIndex start, TileIndex end); + static bool RemoveRoadFull(TileIndex start, TileIndex end); /** * Removes a road depot. @@ -199,7 +199,7 @@ * @pre tile is a road depot. * @return whether the road depot has been/can be removed or not. */ - bool RemoveRoadDepot(TileIndex tile); + static bool RemoveRoadDepot(TileIndex tile); /** * Removes a road bus or truck station. @@ -208,7 +208,7 @@ * @pre tile is a road station. * @return whether the station has been/can be removed or not. */ - bool RemoveRoadStation(TileIndex tile); + static bool RemoveRoadStation(TileIndex tile); }; #endif /* AI_ROAD_HPP */ Index: src/ai/api/ai_road.cpp =================================================================== --- src/ai/api/ai_road.cpp (revision 12187) +++ src/ai/api/ai_road.cpp (working copy) @@ -6,16 +6,16 @@ #include "../../road_map.h" #include "../../station_map.h" -bool AIRoad::IsRoadTile(TileIndex tile) +/* static */ bool AIRoad::IsRoadTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; return (::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) != ROAD_TILE_DEPOT) || - this->IsDriveThroughRoadStationTile(tile); + IsDriveThroughRoadStationTile(tile); } -bool AIRoad::IsRoadDepotTile(TileIndex tile) +/* static */ bool AIRoad::IsRoadDepotTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -23,7 +23,7 @@ return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT; } -bool AIRoad::IsRoadStationTile(TileIndex tile) +/* static */ bool AIRoad::IsRoadStationTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -31,7 +31,7 @@ return ::IsRoadStopTile(tile); } -bool AIRoad::IsDriveThroughRoadStationTile(TileIndex tile) +/* static */ bool AIRoad::IsDriveThroughRoadStationTile(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -39,7 +39,7 @@ return ::IsDriveThroughStopTile(tile); } -bool AIRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2) +/* static */ bool AIRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2) { /* Outside of the map */ if (t1 >= ::MapSize() || t2 >= ::MapSize()) return false; @@ -56,7 +56,7 @@ return HasBit(r1, dir_1) && HasBit(r2, dir_2); } -int32 AIRoad::GetNeighbourRoadCount(TileIndex tile) +/* static */ int32 AIRoad::GetNeighbourRoadCount(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -71,28 +71,28 @@ return neighbour; } -TileIndex AIRoad::GetRoadDepotFrontTile(TileIndex depot) +/* static */ TileIndex AIRoad::GetRoadDepotFrontTile(TileIndex depot) { - if (!this->IsRoadDepotTile(depot)) return INVALID_TILE; + if (!IsRoadDepotTile(depot)) return INVALID_TILE; return depot + ::TileOffsByDiagDir(::GetRoadDepotDirection(depot)); } -TileIndex AIRoad::GetRoadStationFrontTile(TileIndex station) +/* static */ TileIndex AIRoad::GetRoadStationFrontTile(TileIndex station) { - if (!this->IsRoadStationTile(station)) return INVALID_TILE; + if (!IsRoadStationTile(station)) return INVALID_TILE; return station + ::TileOffsByDiagDir(::GetRoadStopDir(station)); } -TileIndex AIRoad::GetDriveThroughBackTile(TileIndex station) +/* static */ TileIndex AIRoad::GetDriveThroughBackTile(TileIndex station) { - if (!this->IsDriveThroughRoadStationTile(station)) return INVALID_TILE; + if (!IsDriveThroughRoadStationTile(station)) return INVALID_TILE; return station + ::TileOffsByDiagDir(::ReverseDiagDir(::GetRoadStopDir(station))); } -bool AIRoad::BuildRoad(TileIndex start, TileIndex end) +/* static */ bool AIRoad::BuildRoad(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize() || start == end) return false; @@ -100,10 +100,10 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_BUILD_LONG_ROAD); + return DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_BUILD_LONG_ROAD); } -bool AIRoad::BuildRoadFull(TileIndex start, TileIndex end) +/* static */ bool AIRoad::BuildRoadFull(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize() || start == end) return false; @@ -111,20 +111,20 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_BUILD_LONG_ROAD); + return DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_BUILD_LONG_ROAD); } -bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front) +/* static */ bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front) { /* Outside of the map */ if (tile >= ::MapSize() || tile == front) return false; uint entrance_dir = (TileX(tile) == TileX(front)) ? (TileY(tile) < TileY(front) ? 1 : 3) : (TileX(tile) < TileX(front) ? 2 : 0); - return this->DoCommand(tile, entrance_dir, ROADTYPE_ROAD << 2, CMD_BUILD_ROAD_DEPOT); + return DoCommand(tile, entrance_dir, ROADTYPE_ROAD << 2, CMD_BUILD_ROAD_DEPOT); } -bool AIRoad::BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through) +/* static */ bool AIRoad::BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through) { /* Outside of the map */ if (tile >= ::MapSize() || tile == front) return false; @@ -136,10 +136,10 @@ entrance_dir = (TileX(tile) == TileX(front)) ? (TileY(tile) < TileY(front) ? 1 : 3) : (TileX(tile) < TileX(front) ? 2 : 0); } - return this->DoCommand(tile, entrance_dir, (drive_through ? 2 : 0) | (truck ? 1 : 0) | (ROADTYPES_ROAD << 2), CMD_BUILD_ROAD_STOP); + return DoCommand(tile, entrance_dir, (drive_through ? 2 : 0) | (truck ? 1 : 0) | (ROADTYPES_ROAD << 2), CMD_BUILD_ROAD_STOP); } -bool AIRoad::RemoveRoad(TileIndex start, TileIndex end) +/* static */ bool AIRoad::RemoveRoad(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize()) return false; @@ -147,10 +147,10 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_REMOVE_LONG_ROAD); + return DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (ROADTYPE_ROAD << 3), CMD_REMOVE_LONG_ROAD); } -bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end) +/* static */ bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end) { /* Outside of the map */ if (start >= ::MapSize() || end >= ::MapSize()) return false; @@ -158,10 +158,10 @@ if (TileX(start) != TileX(end) && TileY(start) != TileY(end)) return false; - return this->DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_REMOVE_LONG_ROAD); + return DoCommand(end, start, (TileY(start) != TileY(end) ? 4 : 0) | (start < end ? 2 : 1), CMD_REMOVE_LONG_ROAD); } -bool AIRoad::RemoveRoadDepot(TileIndex tile) +/* static */ bool AIRoad::RemoveRoadDepot(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -169,10 +169,10 @@ /* Not a road depot tile */ if (!IsTileType(tile, MP_ROAD) || GetRoadTileType(tile) != ROAD_TILE_DEPOT) return false; - return this->DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); + return DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); } -bool AIRoad::RemoveRoadStation(TileIndex tile) +/* static */ bool AIRoad::RemoveRoadStation(TileIndex tile) { /* Outside of the map */ if (tile >= ::MapSize()) return false; @@ -180,5 +180,5 @@ /* Not a road station tile */ if (!IsTileType(tile, MP_STATION) || !IsRoadStop(tile)) return false; - return this->DoCommand(tile, 0, GetRoadStopType(tile), CMD_REMOVE_ROAD_STOP); + return DoCommand(tile, 0, GetRoadStopType(tile), CMD_REMOVE_ROAD_STOP); } Index: src/ai/api/ai_road.hpp.sq =================================================================== --- src/ai/api/ai_road.hpp.sq (revision 12187) +++ src/ai/api/ai_road.hpp.sq (working copy) @@ -14,25 +14,24 @@ SQAIRoad.PreRegister(engine); SQAIRoad.AddConstructor(engine, "x"); - SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetClassName, "GetClassName", 1, "x"); - SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetNeighbourRoadCount, "GetNeighbourRoadCount", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetClassName, "GetClassName", 1, "x"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsRoadTile, "IsRoadTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsRoadStationTile, "IsRoadStationTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::IsDriveThroughRoadStationTile, "IsDriveThroughRoadStationTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetNeighbourRoadCount, "GetNeighbourRoadCount", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetRoadDepotFrontTile, "GetRoadDepotFrontTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoad, "BuildRoad", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoadFull, "BuildRoadFull", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation", 5, "xiibb"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoadFull, "RemoveRoadFull", 3, "xii"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, "xi"); + SQAIRoad.DefSQStaticMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadTile, "IsRoadTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadDepotTile, "IsRoadDepotTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsRoadStationTile, "IsRoadStationTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::IsDriveThroughRoadStationTile, "IsDriveThroughRoadStationTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::AreRoadTilesConnected, "AreRoadTilesConnected", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadDepotFrontTile, "GetRoadDepotFrontTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::GetRoadStationFrontTile, "GetRoadStationFrontTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::GetDriveThroughBackTile, "GetDriveThroughBackTile", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoad, "BuildRoad", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadFull, "BuildRoadFull", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadDepot, "BuildRoadDepot", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::BuildRoadStation, "BuildRoadStation", 5, "xiibb"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoad, "RemoveRoad", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadFull, "RemoveRoadFull", 3, "xii"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadDepot, "RemoveRoadDepot", 2, "xi"); - SQAIRoad.DefSQMethod(engine, &AIRoad::RemoveRoadStation, "RemoveRoadStation", 2, "xi"); - SQAIRoad.PostRegister(engine); }