(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.

This commit is contained in:
rubidium
2008-09-30 20:39:50 +00:00
parent dba193d4a5
commit f56e630e5c
158 changed files with 4661 additions and 4675 deletions

View File

@@ -16,16 +16,16 @@
#include "../signal_func.h"
AIStruct _ai;
AIPlayer _ai_player[MAX_PLAYERS];
AICompany _ai_company[MAX_COMPANIES];
/**
* Dequeues commands put in the queue via AI_PutCommandInQueue.
*/
static void AI_DequeueCommands(PlayerID player)
static void AI_DequeueCommands(CompanyID company)
{
AICommand *com, *entry_com;
entry_com = _ai_player[player].queue;
entry_com = _ai_company[company].queue;
/* It happens that DoCommandP issues a new DoCommandAI which adds a new command
* to this very same queue (don't argue about this, if it currently doesn't
@@ -33,12 +33,12 @@ static void AI_DequeueCommands(PlayerID player)
* do not make the queue NULL, that commands will be dequeued immediatly.
* Therefor we safe the entry-point to entry_com, and make the queue NULL, so
* the new queue can be safely built up. */
_ai_player[player].queue = NULL;
_ai_player[player].queue_tail = NULL;
_ai_company[company].queue = NULL;
_ai_company[company].queue_tail = NULL;
/* Dequeue all commands */
while ((com = entry_com) != NULL) {
_current_player = player;
_current_company = company;
_cmd_text = com->text;
DoCommandP(com->tile, com->p1, com->p2, com->callback, com->procc);
@@ -54,22 +54,22 @@ static void AI_DequeueCommands(PlayerID player)
* Needed for SP; we need to delay DoCommand with 1 tick, because else events
* will make infinite loops (AIScript).
*/
static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
static void AI_PutCommandInQueue(CompanyID company, TileIndex tile, uint32 p1, uint32 p2, uint32 procc, CommandCallback* callback)
{
AICommand *com;
if (_ai_player[player].queue_tail == NULL) {
if (_ai_company[company].queue_tail == NULL) {
/* There is no item in the queue yet, create the queue */
_ai_player[player].queue = MallocT<AICommand>(1);
_ai_player[player].queue_tail = _ai_player[player].queue;
_ai_company[company].queue = MallocT<AICommand>(1);
_ai_company[company].queue_tail = _ai_company[company].queue;
} else {
/* Add an item at the end */
_ai_player[player].queue_tail->next = MallocT<AICommand>(1);
_ai_player[player].queue_tail = _ai_player[player].queue_tail->next;
_ai_company[company].queue_tail->next = MallocT<AICommand>(1);
_ai_company[company].queue_tail = _ai_company[company].queue_tail->next;
}
/* This is our new item */
com = _ai_player[player].queue_tail;
com = _ai_company[company].queue_tail;
/* Assign the info */
com->tile = tile;
@@ -92,7 +92,7 @@ static void AI_PutCommandInQueue(PlayerID player, TileIndex tile, uint32 p1, uin
*/
CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint32 procc, CommandCallback* callback)
{
PlayerID old_lp;
CompanyID old_local_company;
CommandCost res;
const char* tmp_cmdtext;
@@ -113,10 +113,10 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
/* Restore _cmd_text */
_cmd_text = tmp_cmdtext;
/* NetworkSend_Command needs _local_player to be set correctly, so
/* NetworkSend_Command needs _local_company to be set correctly, so
* adjust it, and put it back right after the function */
old_lp = _local_player;
_local_player = _current_player;
old_local_company = _local_company;
_local_company = _current_company;
#ifdef ENABLE_NETWORK
/* Send the command */
@@ -129,11 +129,11 @@ CommandCost AI_DoCommandCc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, u
#endif
/* If we execute BuildCommands directly in SP, we have a big problem with events
* so we need to delay is for 1 tick */
AI_PutCommandInQueue(_current_player, tile, p1, p2, procc, callback);
AI_PutCommandInQueue(_current_company, tile, p1, p2, procc, callback);
}
/* Set _local_player back */
_local_player = old_lp;
/* Set _local_company back */
_local_company = old_local_company;
return res;
}
@@ -148,20 +148,20 @@ CommandCost AI_DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uin
/**
* Run 1 tick of the AI. Don't overdo it, keep it realistic.
*/
static void AI_RunTick(PlayerID player)
static void AI_RunTick(CompanyID company)
{
extern void AiNewDoGameLoop(Player *p);
extern void AiNewDoGameLoop(Company *c);
Player *p = GetPlayer(player);
_current_player = player;
Company *c = GetCompany(company);
_current_company = company;
if (_settings_game.ai.ainew_active) {
AiNewDoGameLoop(p);
AiNewDoGameLoop(c);
} else {
/* Enable all kind of cheats the old AI needs in order to operate correctly... */
_is_old_ai_player = true;
AiDoGameLoop(p);
_is_old_ai_player = false;
_is_old_ai_company = true;
AiDoGameLoop(c);
_is_old_ai_company = false;
}
/* AI could change some track, so update signals */
@@ -191,47 +191,47 @@ void AI_RunGameLoop()
/* Check for AI-client (so joining a network with an AI) */
if (!_networking || _network_server) {
/* Check if we want to run AIs (server or SP only) */
const Player* p;
const Company *c;
FOR_ALL_PLAYERS(p) {
if (p->is_ai) {
FOR_ALL_COMPANIES(c) {
if (c->is_ai) {
/* This should always be true, else something went wrong... */
assert(_ai_player[p->index].active);
assert(_ai_company[c->index].active);
/* Run the script */
AI_DequeueCommands(p->index);
AI_RunTick(p->index);
AI_DequeueCommands(c->index);
AI_RunTick(c->index);
}
}
}
_current_player = OWNER_NONE;
_current_company = OWNER_NONE;
}
/**
* A new AI sees the day of light. You can do here what ever you think is needed.
*/
void AI_StartNewAI(PlayerID player)
void AI_StartNewAI(CompanyID company)
{
assert(IsValidPlayerID(player));
assert(IsValidCompanyID(company));
/* Called if a new AI is booted */
_ai_player[player].active = true;
_ai_company[company].active = true;
}
/**
* This AI player died. Give it some chance to make a final puf.
* This AI company died. Give it some chance to make a final puf.
*/
void AI_PlayerDied(PlayerID player)
void AI_CompanyDied(CompanyID company)
{
/* Called if this AI died */
_ai_player[player].active = false;
_ai_company[company].active = false;
if (_players_ainew[player].pathfinder == NULL) return;
if (_companies_ainew[company].pathfinder == NULL) return;
AyStarMain_Free(_players_ainew[player].pathfinder);
delete _players_ainew[player].pathfinder;
_players_ainew[player].pathfinder = NULL;
AyStarMain_Free(_companies_ainew[company].pathfinder);
delete _companies_ainew[company].pathfinder;
_companies_ainew[company].pathfinder = NULL;
}
@@ -244,7 +244,7 @@ void AI_Initialize()
AI_Uninitialize();
memset(&_ai, 0, sizeof(_ai));
memset(&_ai_player, 0, sizeof(_ai_player));
memset(&_ai_company, 0, sizeof(_ai_company));
_ai.enabled = true;
}
@@ -254,5 +254,5 @@ void AI_Initialize()
*/
void AI_Uninitialize()
{
for (PlayerID p = PLAYER_FIRST; p < MAX_PLAYERS; p++) AI_PlayerDied(p);
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) AI_CompanyDied(c);
}

View File

@@ -24,8 +24,8 @@ struct AICommand {
AICommand *next;
};
/* The struct for an AIScript Player */
struct AIPlayer {
/* The struct for an AIScript Company */
struct AICompany {
bool active; ///< Is this AI active?
AICommand *queue; ///< The commands that he has in his queue
AICommand *queue_tail; ///< The tail of this queue
@@ -39,11 +39,11 @@ struct AIStruct {
};
extern AIStruct _ai;
extern AIPlayer _ai_player[MAX_PLAYERS];
extern AICompany _ai_company[MAX_COMPANIES];
// ai.c
void AI_StartNewAI(PlayerID player);
void AI_PlayerDied(PlayerID player);
void AI_StartNewAI(CompanyID company);
void AI_CompanyDied(CompanyID company);
void AI_RunGameLoop();
void AI_Initialize();
void AI_Uninitialize();

File diff suppressed because it is too large Load Diff

View File

@@ -9,8 +9,8 @@
#include "../../vehicle_type.h"
#include "../../rail_type.h"
void AiDoGameLoop(Player*);
void SaveLoad_AI(PlayerID id);
void AiDoGameLoop(Company *c);
void SaveLoad_AI(CompanyID company);
struct AiBuildRec {
TileIndex spec_tile;
@@ -25,7 +25,7 @@ struct AiBuildRec {
CargoID cargo;
};
struct PlayerAI {
struct CompanyAI {
byte state;
byte tick; ///< Used to determine how often to move
uint32 state_counter; ///< Can hold tile index!
@@ -65,6 +65,6 @@ struct PlayerAI {
byte banned_val[16];
};
extern PlayerAI _players_ai[MAX_PLAYERS];
extern CompanyAI _companies_ai[MAX_COMPANIES];
#endif

View File

@@ -23,7 +23,7 @@
// Build HQ
// Params:
// tile : tile where HQ is going to be build
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
bool AiNew_Build_CompanyHQ(Company *c, TileIndex tile)
{
if (CmdFailed(AI_DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_BUILD_COMPANY_HQ)))
return false;
@@ -40,7 +40,7 @@ bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile)
// 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)
CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
CommandCost AiNew_Build_Station(Company *c, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag)
{
if (type == AI_TRAIN)
return AI_DoCommand(tile, direction + (numtracks << 8) + (length << 16), 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_RAILROAD_STATION);
@@ -52,12 +52,12 @@ CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte lengt
}
// Builds a brdige. The second best out of the ones available for this player
// Builds a brdige. The second best out of the ones available for this company
// Params:
// tile_a : starting point
// tile_b : end point
// flag : flag passed to DoCommand
CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag)
CommandCost AiNew_Build_Bridge(Company *c, TileIndex tile_a, TileIndex tile_b, byte flag)
{
int bridge_type, bridge_len, type, type2;
@@ -76,7 +76,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
if (type2 == 0 && type != 0) type2 = type;
// Now, simply, build the bridge!
if (_players_ainew[p->index].tbt == AI_TRAIN) {
if (_companies_ainew[c->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile_a, tile_b, type2 | RAILTYPE_RAIL << 8 | TRANSPORT_RAIL << 15, flag | DC_AUTO, CMD_BUILD_BRIDGE);
} else {
return AI_DoCommand(tile_a, tile_b, type2 | ROADTYPES_ROAD << 8 | TRANSPORT_ROAD << 15, flag | DC_AUTO, CMD_BUILD_BRIDGE);
@@ -94,7 +94,7 @@ CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, by
// part : Which part we need to build
//
// TODO: skip already builded road-pieces (e.g.: cityroad)
CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag)
CommandCost AiNew_Build_RoutePart(Company *c, Ai_PathFinderInfo *PathFinderInfo, byte flag)
{
int part = PathFinderInfo->position;
byte *route_extra = PathFinderInfo->route_extra;
@@ -127,7 +127,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
}
// Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
cost.AddCost(AiNew_Build_Bridge(p, route[part], route[part - 1], flag));
cost.AddCost(AiNew_Build_Bridge(c, route[part], route[part - 1], flag));
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
@@ -150,7 +150,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
res = AI_DoCommand(route[part], 0, dir, flag, CMD_BUILD_SINGLE_RAIL);
if (CmdFailed(res)) {
// Problem.. let's just abort it all!
_players_ainew[p->index].state = AI_STATE_NOTHING;
_companies_ainew[c->index].state = AI_STATE_NOTHING;
return CommandCost();
}
cost.AddCost(res);
@@ -177,7 +177,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
}
// Bridge code
if ((AI_PATHFINDER_FLAG_BRIDGE & route_extra[part]) != 0) {
cost.AddCost(AiNew_Build_Bridge(p, route[part], route[part + 1], flag));
cost.AddCost(AiNew_Build_Bridge(c, route[part], route[part + 1], flag));
PathFinderInfo->position++;
// TODO: problems!
if (CmdFailed(cost)) {
@@ -206,7 +206,7 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
if (CmdFailed(res) && flag == DC_EXEC && !IsTileType(route[part], MP_ROAD) && !EnsureNoVehicleOnGround(route[part])) {
// Problem.. let's just abort it all!
DEBUG(ai, 0, "[BuidPath] route building failed at tile 0x%X, aborting", route[part]);
_players_ainew[p->index].state = AI_STATE_NOTHING;
_companies_ainew[c->index].state = AI_STATE_NOTHING;
return CommandCost();
}
@@ -230,9 +230,9 @@ CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo,
// This functions tries to find the best vehicle for this type of cargo
// It returns INVALID_ENGINE if not suitable engine is found
EngineID AiNew_PickVehicle(Player *p)
EngineID AiNew_PickVehicle(Company *c)
{
if (_players_ainew[p->index].tbt == AI_TRAIN) {
if (_companies_ainew[c->index].tbt == AI_TRAIN) {
// Not supported yet
return INVALID_ENGINE;
} else {
@@ -246,14 +246,14 @@ EngineID AiNew_PickVehicle(Player *p)
const RoadVehicleInfo *rvi = &e->u.road;
/* Skip vehicles which can't take our cargo type */
if (rvi->cargo_type != _players_ainew[p->index].cargo && !CanRefitTo(i, _players_ainew[p->index].cargo)) continue;
if (rvi->cargo_type != _companies_ainew[c->index].cargo && !CanRefitTo(i, _companies_ainew[c->index].cargo)) continue;
/* Skip trams */
if (HasBit(EngInfo(i)->misc_flags, EF_ROAD_TRAM)) continue;
// Is it availiable?
// Also, check if the reliability of the vehicle is above the AI_VEHICLE_MIN_RELIABILTY
if (!HasBit(e->player_avail, _current_player) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
if (!HasBit(e->company_avail, _current_company) || e->reliability * 100 < AI_VEHICLE_MIN_RELIABILTY << 16) continue;
/* Rate and compare the engine by speed & capacity */
int rating = rvi->max_speed * rvi->capacity;
@@ -274,34 +274,34 @@ EngineID AiNew_PickVehicle(Player *p)
void CcAI(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
Player* p = GetPlayer(_current_player);
Company *c = GetCompany(_current_company);
if (success) {
_players_ainew[p->index].state = AI_STATE_GIVE_ORDERS;
_players_ainew[p->index].veh_id = _new_vehicle_id;
_companies_ainew[c->index].state = AI_STATE_GIVE_ORDERS;
_companies_ainew[c->index].veh_id = _new_vehicle_id;
if (GetVehicle(_players_ainew[p->index].veh_id)->cargo_type != _players_ainew[p->index].cargo) {
if (GetVehicle(_companies_ainew[c->index].veh_id)->cargo_type != _companies_ainew[c->index].cargo) {
/* Cargo type doesn't match, so refit it */
if (CmdFailed(DoCommand(tile, _players_ainew[p->index].veh_id, _players_ainew[p->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
if (CmdFailed(DoCommand(tile, _companies_ainew[c->index].veh_id, _companies_ainew[c->index].cargo, DC_EXEC, CMD_REFIT_ROAD_VEH))) {
/* Refit failed, so sell the vehicle */
DoCommand(tile, _players_ainew[p->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
_players_ainew[p->index].state = AI_STATE_NOTHING;
DoCommand(tile, _companies_ainew[c->index].veh_id, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
_companies_ainew[c->index].state = AI_STATE_NOTHING;
}
}
} else {
/* XXX this should be handled more gracefully */
_players_ainew[p->index].state = AI_STATE_NOTHING;
_companies_ainew[c->index].state = AI_STATE_NOTHING;
}
}
// Builds the best vehicle possible
CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
CommandCost AiNew_Build_Vehicle(Company *c, TileIndex tile, byte flag)
{
EngineID i = AiNew_PickVehicle(p);
EngineID i = AiNew_PickVehicle(c);
if (i == INVALID_ENGINE) return CMD_ERROR;
if (_players_ainew[p->index].tbt == AI_TRAIN) return CMD_ERROR;
if (_companies_ainew[c->index].tbt == AI_TRAIN) return CMD_ERROR;
if (flag & DC_EXEC) {
return AI_DoCommandCc(tile, i, 0, flag, CMD_BUILD_ROAD_VEH, CcAI);
@@ -310,10 +310,10 @@ CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag)
}
}
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag)
CommandCost AiNew_Build_Depot(Company *c, TileIndex tile, DiagDirection direction, byte flag)
{
CommandCost ret, ret2;
if (_players_ainew[p->index].tbt == AI_TRAIN) {
if (_companies_ainew[c->index].tbt == AI_TRAIN) {
return AI_DoCommand(tile, 0, direction, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_TRAIN_DEPOT);
} else {
ret = AI_DoCommand(tile, direction, 0, flag | DC_AUTO | DC_NO_WATER, CMD_BUILD_ROAD_DEPOT);

View File

@@ -24,21 +24,21 @@
// TODO: make it train compatible
static bool TestCanBuildStationHere(TileIndex tile, byte dir)
{
Player *p = GetPlayer(_current_player);
Company *c = GetCompany(_current_company);
if (dir == TEST_STATION_NO_DIR) {
CommandCost ret;
// TODO: currently we only allow spots that can be access from al 4 directions...
// should be fixed!!!
for (dir = 0; dir < 4; dir++) {
ret = AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST);
ret = AiNew_Build_Station(c, _companies_ainew[c->index].tbt, tile, 1, 1, dir, DC_QUERY_COST);
if (CmdSucceeded(ret)) return true;
}
return false;
}
// return true if command succeeded, so the inverse of CmdFailed()
return CmdSucceeded(AiNew_Build_Station(p, _players_ainew[p->index].tbt, tile, 1, 1, dir, DC_QUERY_COST));
return CmdSucceeded(AiNew_Build_Station(c, _companies_ainew[c->index].tbt, tile, 1, 1, dir, DC_QUERY_COST));
}

View File

@@ -78,13 +78,13 @@ DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b)
// This functions looks up if this vehicle is special for this AI
// and returns his flag
uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
uint AiNew_GetSpecialVehicleFlag(Company *c, Vehicle *v)
{
uint i;
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
return _players_ainew[p->index].special_vehicles[i].flag;
if (_companies_ainew[c->index].special_vehicles[i].veh_id == v->index) {
return _companies_ainew[c->index].special_vehicles[i].flag;
}
}
@@ -93,19 +93,19 @@ uint AiNew_GetSpecialVehicleFlag(Player* p, Vehicle* v)
}
bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
bool AiNew_SetSpecialVehicleFlag(Company *c, Vehicle *v, uint flag)
{
int new_id = -1;
uint i;
for (i = 0; i < AI_MAX_SPECIAL_VEHICLES; i++) {
if (_players_ainew[p->index].special_vehicles[i].veh_id == v->index) {
_players_ainew[p->index].special_vehicles[i].flag |= flag;
if (_companies_ainew[c->index].special_vehicles[i].veh_id == v->index) {
_companies_ainew[c->index].special_vehicles[i].flag |= flag;
return true;
}
if (new_id == -1 &&
_players_ainew[p->index].special_vehicles[i].veh_id == 0 &&
_players_ainew[p->index].special_vehicles[i].flag == 0) {
_companies_ainew[c->index].special_vehicles[i].veh_id == 0 &&
_companies_ainew[c->index].special_vehicles[i].flag == 0) {
new_id = i;
}
}
@@ -115,7 +115,7 @@ bool AiNew_SetSpecialVehicleFlag(Player* p, Vehicle* v, uint flag)
DEBUG(ai, 1, "special_vehicles list is too small");
return false;
}
_players_ainew[p->index].special_vehicles[new_id].veh_id = v->index;
_players_ainew[p->index].special_vehicles[new_id].flag = flag;
_companies_ainew[c->index].special_vehicles[new_id].veh_id = v->index;
_companies_ainew[c->index].special_vehicles[new_id].flag = flag;
return true;
}

File diff suppressed because it is too large Load Diff

View File

@@ -120,7 +120,7 @@
// Minimum % of reliabilty a vehicle has to have before the AI buys it
#define AI_VEHICLE_MIN_RELIABILTY 60
// The minimum amount of money a player should always have
// The minimum amount of money a company should always have
#define AI_MINIMUM_MONEY 15000
// If the most cheap route is build, how much is it going to cost..
@@ -148,7 +148,7 @@
// How many days must there between vehicle checks
// The more often, the less non-money-making lines there will be
// but the unfair it may seem to a human player
// but the unfair it may seem to a human company
#define AI_DAYS_BETWEEN_VEHICLE_CHECKS 30
// How money profit does a vehicle needs to make to stay in order
@@ -239,10 +239,10 @@ enum {
#define AI_PATHFINDER_FLAG_BRIDGE 1
#define AI_PATHFINDER_FLAG_TUNNEL 2
typedef void AiNew_StateFunction(Player *p);
typedef void AiNew_StateFunction(Company *c);
// ai_new.c
void AiNewDoGameLoop(Player *p);
void AiNewDoGameLoop(Company *c);
struct Ai_PathFinderInfo {
TileIndex start_tile_tl; ///< tl = top-left
@@ -268,17 +268,17 @@ void clean_AyStar_AiPathFinder(AyStar *aystar, Ai_PathFinderInfo *PathFinderInfo
int AiNew_GetRailDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
int AiNew_GetRoadDirection(TileIndex tile_a, TileIndex tile_b, TileIndex tile_c);
DiagDirection AiNew_GetDirection(TileIndex tile_a, TileIndex tile_b);
bool AiNew_SetSpecialVehicleFlag(Player *p, Vehicle *v, uint flag);
uint AiNew_GetSpecialVehicleFlag(Player *p, Vehicle *v);
bool AiNew_SetSpecialVehicleFlag(Company *c, Vehicle *v, uint flag);
uint AiNew_GetSpecialVehicleFlag(Company *c, Vehicle *v);
// ai_build.c
bool AiNew_Build_CompanyHQ(Player *p, TileIndex tile);
CommandCost AiNew_Build_Station(Player *p, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
CommandCost AiNew_Build_Bridge(Player *p, TileIndex tile_a, TileIndex tile_b, byte flag);
CommandCost AiNew_Build_RoutePart(Player *p, Ai_PathFinderInfo *PathFinderInfo, byte flag);
EngineID AiNew_PickVehicle(Player *p);
CommandCost AiNew_Build_Vehicle(Player *p, TileIndex tile, byte flag);
CommandCost AiNew_Build_Depot(Player* p, TileIndex tile, DiagDirection direction, byte flag);
bool AiNew_Build_CompanyHQ(Company *c, TileIndex tile);
CommandCost AiNew_Build_Station(Company *c, byte type, TileIndex tile, byte length, byte numtracks, byte direction, byte flag);
CommandCost AiNew_Build_Bridge(Company *c, TileIndex tile_a, TileIndex tile_b, byte flag);
CommandCost AiNew_Build_RoutePart(Company *c, Ai_PathFinderInfo *PathFinderInfo, byte flag);
EngineID AiNew_PickVehicle(Company *c);
CommandCost AiNew_Build_Vehicle(Company *c, TileIndex tile, byte flag);
CommandCost AiNew_Build_Depot(Company *c, TileIndex tile, DiagDirection direction, byte flag);
/* The amount of memory reserved for the AI-special-vehicles */
#define AI_MAX_SPECIAL_VEHICLES 100
@@ -288,7 +288,7 @@ struct Ai_SpecialVehicle {
uint32 flag;
};
struct PlayerAiNew {
struct CompanyAiNew {
uint8 state;
uint tick;
uint idle;
@@ -338,6 +338,6 @@ struct PlayerAiNew {
int to_ic;
byte to_type;
};
extern PlayerAiNew _players_ainew[MAX_PLAYERS];
extern CompanyAiNew _companies_ainew[MAX_COMPANIES];
#endif /* AI_TROLLY_H */