File diff r1976:fcef181ed14a → r1977:1f8b99c96041
ai_build.c
Show inline comments
 
@@ -8,13 +8,14 @@
 
#include "engine.h"
 
#include "station.h"
 

	
 
// Build HQ
 
//  Params:
 
//    tile : tile where HQ is going to be build
 
bool AiNew_Build_CompanyHQ(Player *p, uint tile) {
 
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
 
{
 
	if (CmdFailed(DoCommandByTile(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ)))
 
		return false;
 
	DoCommandByTile(tile, 0, 0, DC_EXEC | DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ);
 
	return true;
 
}
 

	
 
@@ -23,13 +24,14 @@ bool AiNew_Build_CompanyHQ(Player *p, ui
 
//    type : AI_TRAIN/AI_BUS/AI_TRUCK : indicates the type of station
 
//    tile : tile where station is going to be build
 
//    length : in case of AI_TRAIN: length of station
 
//    numtracks : in case of AI_TRAIN: tracks of station
 
//    direction : the direction of the station
 
//    flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
 
int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag) {
 
int AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
 
{
 
	if (type == AI_TRAIN)
 
		return DoCommandByTile(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
 

	
 
	if (type == AI_BUS)
 
		return DoCommandByTile(tile, direction, RS_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
 

	
 
@@ -38,13 +40,14 @@ int AiNew_Build_Station(Player *p, byte 
 

	
 
// Builds a brdige. The second best out of the ones available for this player
 
//  Params:
 
//   tile_a : starting point
 
//   tile_b : end point
 
//   flag : flag passed to DoCommand
 
int AiNew_Build_Bridge(Player *p, uint tile_a, uint tile_b, byte flag) {
 
int AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
 
{
 
	int bridge_type, bridge_len, type, type2;
 

	
 
	// Find a good bridgetype (the best money can buy)
 
	bridge_len = GetBridgeLength(tile_a, tile_b);
 
	type = type2 = 0;
 
	for (bridge_type = MAX_BRIDGES-1; bridge_type >= 0; bridge_type--) {
 
@@ -230,23 +233,24 @@ int AiNew_PickVehicle(Player *p) {
 
       	if (CmdFailed(ret)) { return -1; }
 
       	return i;
 
    }
 
}
 

	
 
// Builds the best vehicle possible
 
int AiNew_Build_Vehicle(Player *p, uint tile, byte flag) {
 
int AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
 
{
 
	int i = AiNew_PickVehicle(p);
 
	if (i == -1) return CMD_ERROR;
 

	
 
	if (p->ainew.tbt == AI_TRAIN)
 
		return CMD_ERROR;
 

	
 
	return DoCommandByTile(tile, i, 0, flag, CMD_BUILD_ROAD_VEH);
 
}
 

	
 
int AiNew_Build_Depot(Player *p, uint tile, byte direction, byte flag)
 
int AiNew_Build_Depot(Player *p, TileIndex tile, byte direction, byte flag)
 
{
 
	static const byte _roadbits_by_dir[4] = {2,1,8,4};
 
	int ret, ret2;
 
    if (p->ainew.tbt == AI_TRAIN)
 
    	return DoCommandByTile(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);