ai_build.c
changeset 1217 59c024cfaf54
parent 1209 2e00193652b2
child 1299 39c06aba09aa
equal deleted inserted replaced
1216:47aa486849d9 1217:59c024cfaf54
     3 #include "map.h"
     3 #include "map.h"
     4 #include "tile.h"
     4 #include "tile.h"
     5 #include "command.h"
     5 #include "command.h"
     6 #include "ai.h"
     6 #include "ai.h"
     7 #include "engine.h"
     7 #include "engine.h"
       
     8 #include "station.h"
     8 
     9 
     9 // Build HQ
    10 // Build HQ
    10 //  Params:
    11 //  Params:
    11 //    tile : tile where HQ is going to be build
    12 //    tile : tile where HQ is going to be build
    12 bool AiNew_Build_CompanyHQ(Player *p, uint tile) {
    13 bool AiNew_Build_CompanyHQ(Player *p, uint tile) {
    26 //    flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
    27 //    flag : flag passed to DoCommand (normally 0 to get the cost or DC_EXEC to build it)
    27 int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag) {
    28 int AiNew_Build_Station(Player *p, byte type, uint tile, byte length, byte numtracks, byte direction, byte flag) {
    28 	if (type == AI_TRAIN)
    29 	if (type == AI_TRAIN)
    29 		return DoCommandByTile(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
    30 		return DoCommandByTile(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
    30 	else if (type == AI_BUS)
    31 	else if (type == AI_BUS)
    31 		return DoCommandByTile(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_BUS_STATION);
    32 		return DoCommandByTile(tile, direction, RS_BUS, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
    32 	else
    33 	else
    33 		return DoCommandByTile(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRUCK_STATION);
    34 		return DoCommandByTile(tile, direction, RS_TRUCK, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_STOP);
    34 }
    35 }
    35 
    36 
    36 // Builds a brdige. The second best out of the ones available for this player
    37 // Builds a brdige. The second best out of the ones available for this player
    37 //  Params:
    38 //  Params:
    38 //   tile_a : starting point
    39 //   tile_a : starting point