src/player.h
branchnoai
changeset 9359 e915dd81a279
parent 6574 e1d1a12faaf7
child 9374 61379e9b2393
equal deleted inserted replaced
9358:42713dbe6ebe 9359:e915dd81a279
    15 	int32 delivered_cargo;
    15 	int32 delivered_cargo;
    16 	int32 performance_history; // player score (scale 0-1000)
    16 	int32 performance_history; // player score (scale 0-1000)
    17 	int64 company_value;
    17 	int64 company_value;
    18 };
    18 };
    19 
    19 
    20 struct AiBuildRec {
       
    21 	TileIndex spec_tile;
       
    22 	TileIndex use_tile;
       
    23 	byte rand_rng;
       
    24 	byte cur_building_rule;
       
    25 	byte unk6;
       
    26 	byte unk7;
       
    27 	byte buildcmd_a;
       
    28 	byte buildcmd_b;
       
    29 	byte direction;
       
    30 	CargoID cargo;
       
    31 };
       
    32 
       
    33 struct PlayerAI {
       
    34 	byte state;
       
    35 	byte tick;            // Used to determine how often to move
       
    36 	uint32 state_counter; // Can hold tile index!
       
    37 	uint16 timeout_counter;
       
    38 
       
    39 	byte state_mode;
       
    40 	byte banned_tile_count;
       
    41 	RailTypeByte railtype_to_use;
       
    42 
       
    43 	CargoID cargo_type;
       
    44 	byte num_wagons;
       
    45 	byte build_kind;
       
    46 	byte num_build_rec;
       
    47 	byte num_loco_to_build;
       
    48 	byte num_want_fullload;
       
    49 
       
    50 	byte route_type_mask;
       
    51 
       
    52 	TileIndex start_tile_a;
       
    53 	TileIndex cur_tile_a;
       
    54 	byte cur_dir_a;
       
    55 	byte start_dir_a;
       
    56 
       
    57 	TileIndex start_tile_b;
       
    58 	TileIndex cur_tile_b;
       
    59 	byte cur_dir_b;
       
    60 	byte start_dir_b;
       
    61 
       
    62 	Vehicle *cur_veh; /* only used by some states */
       
    63 
       
    64 	AiBuildRec src, dst, mid1, mid2;
       
    65 
       
    66 	VehicleID wagon_list[9];
       
    67 	byte order_list_blocks[20];
       
    68 
       
    69 	TileIndex banned_tiles[16];
       
    70 	byte banned_val[16];
       
    71 };
       
    72 
       
    73 struct Ai_PathFinderInfo {
       
    74 	TileIndex start_tile_tl; // tl = top-left
       
    75 	TileIndex start_tile_br; // br = bottom-right
       
    76 	TileIndex end_tile_tl;   // tl = top-left
       
    77 	TileIndex end_tile_br;   // br = bottom-right
       
    78 	byte start_direction;    // 0 to 3 or AI_PATHFINDER_NO_DIRECTION
       
    79 	byte end_direction;      // 0 to 3 or AI_PATHFINDER_NO_DIRECTION
       
    80 
       
    81 	TileIndex route[500];
       
    82 	byte route_extra[500];   // Some extra information about the route like bridge/tunnel
       
    83 	int route_length;
       
    84 	int position;            // Current position in the build-path, needed to build the path
       
    85 
       
    86 	bool rail_or_road;       // true = rail, false = road
       
    87 };
       
    88 
       
    89 // The amount of memory reserved for the AI-special-vehicles
       
    90 #define AI_MAX_SPECIAL_VEHICLES 100
       
    91 
       
    92 struct Ai_SpecialVehicle {
       
    93 	VehicleID veh_id;
       
    94 	uint32 flag;
       
    95 };
       
    96 
       
    97 struct PlayerAiNew {
       
    98 	uint8 state;
       
    99 	uint tick;
       
   100 	uint idle;
       
   101 
       
   102 	int temp;    // A value used in more than one function, but it just temporary
       
   103 	             // The use is pretty simple: with this we can 'think' about stuff
       
   104 	             //   in more than one tick, and more than one AI. A static will not
       
   105 	             //   do, because they are not saved. This way, the AI is almost human ;)
       
   106 	int counter; // For the same reason as temp, we have counter. It can count how
       
   107 	             //  long we are trying something, and just abort if it takes too long
       
   108 
       
   109 	// Pathfinder stuff
       
   110 	Ai_PathFinderInfo path_info;
       
   111 	AyStar *pathfinder;
       
   112 
       
   113 	// Route stuff
       
   114 
       
   115 	CargoID cargo;
       
   116 	byte tbt; // train/bus/truck 0/1/2 AI_TRAIN/AI_BUS/AI_TRUCK
       
   117 	int new_cost;
       
   118 
       
   119 	byte action;
       
   120 
       
   121 	int last_id; // here is stored the last id of the searched city/industry
       
   122 	Date last_vehiclecheck_date; // Used in CheckVehicle
       
   123 	Ai_SpecialVehicle special_vehicles[AI_MAX_SPECIAL_VEHICLES]; // Some vehicles have some special flags
       
   124 
       
   125 	TileIndex from_tile;
       
   126 	TileIndex to_tile;
       
   127 
       
   128 	byte from_direction;
       
   129 	byte to_direction;
       
   130 
       
   131 	bool from_deliver; // True if this is the station that GIVES cargo
       
   132 	bool to_deliver;
       
   133 
       
   134 	TileIndex depot_tile;
       
   135 	DiagDirectionByte depot_direction;
       
   136 
       
   137 	byte amount_veh;       // How many vehicles we are going to build in this route
       
   138 	byte cur_veh;          // How many vehicles did we bought?
       
   139 	VehicleID veh_id;      // Used when bought a vehicle
       
   140 	VehicleID veh_main_id; // The ID of the first vehicle, for shared copy
       
   141 
       
   142 	int from_ic;           // ic = industry/city. This is the ID of them
       
   143 	byte from_type;        // AI_NO_TYPE/AI_CITY/AI_INDUSTRY
       
   144 	int to_ic;
       
   145 	byte to_type;
       
   146 
       
   147 };
       
   148 
       
   149 
       
   150 typedef uint32 PlayerFace;
    20 typedef uint32 PlayerFace;
   151 
    21 
   152 struct Player {
    22 struct Player {
   153 	uint32 name_2;
    23 	uint32 name_2;
   154 	uint16 name_1;
    24 	uint16 name_1;
   184 	int16 bankrupt_timeout;
    54 	int16 bankrupt_timeout;
   185 	int32 bankrupt_value;
    55 	int32 bankrupt_value;
   186 
    56 
   187 	bool is_active;
    57 	bool is_active;
   188 	bool is_ai;
    58 	bool is_ai;
   189 	PlayerAI ai;
       
   190 	PlayerAiNew ainew;
       
   191 
    59 
   192 	int64 yearly_expenses[3][13];
    60 	int64 yearly_expenses[3][13];
   193 	PlayerEconomyEntry cur_economy;
    61 	PlayerEconomyEntry cur_economy;
   194 	PlayerEconomyEntry old_economy[24];
    62 	PlayerEconomyEntry old_economy[24];
   195 	EngineRenewList engine_renew_list; // Defined later
    63 	EngineRenewList engine_renew_list; // Defined later