src/ai/trolly/build.cpp
branchNewGRF_ports
changeset 6719 4cc327ad39d5
parent 6087 b56c54f79335
child 6720 35756db7e577
equal deleted inserted replaced
6718:5a8b295aa345 6719:4cc327ad39d5
    40 {
    40 {
    41 	if (type == AI_TRAIN)
    41 	if (type == AI_TRAIN)
    42 		return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
    42 		return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
    43 
    43 
    44 	if (type == AI_BUS)
    44 	if (type == AI_BUS)
    45 		return AI_DoCommand(tile, direction, RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
    45 		return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | RoadStop::BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
    46 
    46 
    47 	return AI_DoCommand(tile, direction, RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
    47 	return AI_DoCommand(tile, direction, ROADTYPES_ROAD << 2 | RoadStop::TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
    48 }
    48 }
    49 
    49 
    50 
    50 
    51 // Builds a brdige. The second best out of the ones available for this player
    51 // Builds a brdige. The second best out of the ones available for this player
    52 //  Params:
    52 //  Params:
    73 
    73 
    74 	// Now, simply, build the bridge!
    74 	// Now, simply, build the bridge!
    75 	if (p->ainew.tbt == AI_TRAIN) {
    75 	if (p->ainew.tbt == AI_TRAIN) {
    76 		return AI_DoCommand(tile_a, tile_b, (0x00 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
    76 		return AI_DoCommand(tile_a, tile_b, (0x00 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
    77 	} else {
    77 	} else {
    78 		return AI_DoCommand(tile_a, tile_b, (0x80 << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
    78 		return AI_DoCommand(tile_a, tile_b, ((0x80 | ROADTYPES_ROAD) << 8) + type2, flag | DC_AUTO, CMD_BUILD_BRIDGE);
    79 	}
    79 	}
    80 }
    80 }
    81 
    81 
    82 
    82 
    83 // Build the route part by part
    83 // Build the route part by part
   121 			}
   121 			}
   122 			return cost;
   122 			return cost;
   123 		}
   123 		}
   124 		// Bridge code
   124 		// Bridge code
   125 		if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
   125 		if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
   126 			cost += AiNew_Build_Bridge(p, route[part], route[part-1], flag);
   126 			cost += AiNew_Build_Bridge(p, route[part], route[part - 1], flag);
   127 			PathFinderInfo->position++;
   127 			PathFinderInfo->position++;
   128 			// TODO: problems!
   128 			// TODO: problems!
   129 			if (CmdFailed(cost)) {
   129 			if (CmdFailed(cost)) {
   130 				DEBUG(ai, 0, "[BuildPath] bridge could not be built (0x%X, 0x%X)", route[part], route[part - 1]);
   130 				DEBUG(ai, 0, "[BuildPath] bridge could not be built (0x%X, 0x%X)", route[part], route[part - 1]);
   131 				return 0;
   131 				return 0;
   160 		// We want to return the last position, so we go back one
   160 		// We want to return the last position, so we go back one
   161 		PathFinderInfo->position = part;
   161 		PathFinderInfo->position = part;
   162 	} else {
   162 	} else {
   163 		// Tunnel code
   163 		// Tunnel code
   164 		if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
   164 		if ((AI_PATHFINDER_FLAG_TUNNEL & route_extra[part]) != 0) {
   165 			cost += AI_DoCommand(route[part], 0x200, 0, flag, CMD_BUILD_TUNNEL);
   165 			cost += AI_DoCommand(route[part], 0x200 | ROADTYPES_ROAD, 0, flag, CMD_BUILD_TUNNEL);
   166 			PathFinderInfo->position++;
   166 			PathFinderInfo->position++;
   167 			// TODO: problems!
   167 			// TODO: problems!
   168 			if (CmdFailed(cost)) {
   168 			if (CmdFailed(cost)) {
   169 				DEBUG(ai, 0, "[BuildPath] tunnel could not be built (0x%X)", route[part]);
   169 				DEBUG(ai, 0, "[BuildPath] tunnel could not be built (0x%X)", route[part]);
   170 				return 0;
   170 				return 0;
   171 			}
   171 			}
   172 			return cost;
   172 			return cost;
   173 		}
   173 		}
   174 		// Bridge code
   174 		// Bridge code
   175 		if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
   175 		if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
   176 			cost += AiNew_Build_Bridge(p, route[part], route[part+1], flag);
   176 			cost += AiNew_Build_Bridge(p, route[part], route[part + 1], flag);
   177 			PathFinderInfo->position++;
   177 			PathFinderInfo->position++;
   178 			// TODO: problems!
   178 			// TODO: problems!
   179 			if (CmdFailed(cost)) {
   179 			if (CmdFailed(cost)) {
   180 				DEBUG(ai, 0, "[BuildPath] bridge could not be built (0x%X, 0x%X)", route[part], route[part + 1]);
   180 				DEBUG(ai, 0, "[BuildPath] bridge could not be built (0x%X, 0x%X)", route[part], route[part + 1]);
   181 				return 0;
   181 				return 0;