(svn r146) -Fix [AI]: Tunnel/bridge bug

-Fix [AI]: Minor problems
-Add [AI]: Profit check (if not making enough money, vehicles are sold)
This commit is contained in:
truelight
2004-08-31 16:12:52 +00:00
parent a7dd461672
commit 5eba928cb8
6 changed files with 250 additions and 103 deletions

View File

@@ -47,19 +47,19 @@ typedef struct PlayerAI {
TileIndex cur_tile_a;
byte cur_dir_a;
byte start_dir_a;
TileIndex start_tile_b;
TileIndex cur_tile_b;
byte cur_dir_b;
byte start_dir_b;
Vehicle *cur_veh; /* only used by some states */
AiBuildRec src, dst, mid1, mid2;
VehicleID wagon_list[9];
byte order_list_blocks[20];
TileIndex banned_tiles[16];
byte banned_val[16];
} PlayerAI;
@@ -76,58 +76,68 @@ typedef struct Ai_PathFinderInfo {
byte route_extra[500]; // Some extra information about the route like bridge/tunnel
int route_length;
int position; // Current position in the build-path, needed to build the path
bool rail_or_road; // true = rail, false = road
} Ai_PathFinderInfo;
// The amount of memory reserved for the AI-special-vehicles
#define AI_MAX_SPECIAL_VEHICLES 100
typedef struct Ai_SpecialVehicle {
VehicleID veh_id;
uint32 flag;
} Ai_SpecialVehicle;
typedef struct PlayerAiNew {
uint8 state;
uint tick;
uint idle;
int temp; // A value used in more then one function, but it just temporary
// The use is pretty simple: with this we can 'think' about stuff
// in more then one tick, and more then one AI. A static will not
// do, because they are not saved. This way, the AI is almost human ;)
int counter; // For the same reason as temp, we have counter. It can count how
// long we are trying something, and just abort if it takes too long
// Pathfinder stuff
Ai_PathFinderInfo path_info;
AyStar *pathfinder;
// Route stuff
byte cargo;
byte tbt; // train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
int new_cost;
byte action;
uint last_id; // here is stored the last id of the searched city/industry
uint last_vehiclecheck_date; // Used in CheckVehicle
Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; // Some vehicles have some special flags
TileIndex from_tile;
TileIndex to_tile;
byte from_direction;
byte to_direction;
bool from_deliver; // True if this is the station that GIVES cargo
bool to_deliver;
TileIndex depot_tile;
byte depot_direction;
byte amount_veh; // How many vehicles we are going to build in this route
byte cur_veh; // How many vehicles did we bought?
VehicleID veh_id; // Used when bought a vehicle
VehicleID veh_main_id; // The ID of the first vehicle, for shared copy
int from_ic; // ic = industry/city. This is the ID of them
byte from_type; // AI_NO_TYPE/AI_CITY/AI_INDUSTRY
int to_ic;
byte to_type;
} PlayerAiNew;
@@ -155,12 +165,12 @@ typedef struct Player {
TileIndex location_of_house;
TileIndex last_build_coordinate;
byte share_owners[4];
byte inaugurated_year;
byte num_valid_stat_ent;
byte quarters_of_bankrupcy;
byte bankrupt_asked; // which players were asked about buying it?
int16 bankrupt_timeout;
@@ -170,7 +180,7 @@ typedef struct Player {
byte is_ai;
PlayerAI ai;
PlayerAiNew ainew;
int64 yearly_expenses[3][13];
PlayerEconomyEntry cur_economy;
PlayerEconomyEntry old_economy[24];