Changeset - r2551:d50c1f074472
[Not reviewed]
master
0 3 0
tron - 19 years ago 2005-10-24 05:51:23
tron@openttd.org
(svn r3080) byte -> PlayerID, int -> EngineID, -1 -> INVALID_ENGINE
3 files changed with 9 insertions and 8 deletions:
0 comments (0 inline, 0 general)
ai/ai.c
Show inline comments
 
@@ -74,13 +74,13 @@ void AI_PutCommandInQueue(byte player, u
 

	
 
/**
 
 * Executes a raw DoCommand for the AI.
 
 */
 
int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc)
 
{
 
	byte old_lp;
 
	PlayerID old_lp;
 
	int32 res = 0;
 

	
 
	/* If you enable DC_EXEC with DC_QUERY_COST you are a really strange
 
	 *   person.. should we check for those funny jokes?
 
	 */
 

	
 
@@ -115,13 +115,13 @@ int32 AI_DoCommand(uint tile, uint32 p1,
 
	return res;
 
}
 

	
 
/**
 
 * Run 1 tick of the AI. Don't overdo it, keep it realistic.
 
 */
 
static void AI_RunTick(byte player)
 
static void AI_RunTick(PlayerID player)
 
{
 
	extern void AiNewDoGameLoop(Player *p);
 

	
 
	Player *p = GetPlayer(player);
 
	_current_player = player;
 

	
 
@@ -178,22 +178,22 @@ void AI_RunGameLoop(void)
 
	_current_player = OWNER_NONE;
 
}
 

	
 
/**
 
 * A new AI sees the day of light. You can do here what ever you think is needed.
 
 */
 
void AI_StartNewAI(byte player)
 
void AI_StartNewAI(PlayerID player)
 
{
 
	/* Called if a new AI is booted */
 
	_ai_player[player].active = true;
 
}
 

	
 
/**
 
 * This AI player died. Give it some chance to make a final puf.
 
 */
 
void AI_PlayerDied(byte player)
 
void AI_PlayerDied(PlayerID player)
 
{
 
	/* Called if this AI died */
 
	_ai_player[player].active = false;
 
}
 

	
 
/**
ai/ai.h
Show inline comments
 
@@ -34,14 +34,14 @@ typedef struct AIStruct {
 
} AIStruct;
 

	
 
VARDEF AIStruct _ai;
 
VARDEF AIPlayer _ai_player[MAX_PLAYERS];
 

	
 
// ai.c
 
void AI_StartNewAI(byte player);
 
void AI_PlayerDied(byte player);
 
void AI_StartNewAI(PlayerID player);
 
void AI_PlayerDied(PlayerID player);
 
void AI_RunGameLoop(void);
 
void AI_Initialize(void);
 
void AI_Uninitialize(void);
 
int32 AI_DoCommand(uint tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
 

	
 
#define AI_CHANCE16(a,b)    ((uint16)     AI_Random()  <= (uint16)((65536 * a) / b))
ai/default/default.c
Show inline comments
 
@@ -3180,20 +3180,21 @@ static int AiGetStationIdFromRoadBlock(T
 

	
 
static void AiStateBuildRoadVehicles(Player *p)
 
{
 
	const AiDefaultBlockData *ptr;
 
	TileIndex tile;
 
	uint loco_id;
 
	int veh, i;
 
	EngineID veh;
 
	int i;
 

	
 
	ptr = _road_default_block_data[p->ai.src.cur_building_rule]->data;
 
	for(;ptr->mode != 0;ptr++) {}
 
	tile = TILE_ADD(p->ai.src.use_tile, ToTileIndexDiff(ptr->tileoffs));
 

	
 
	veh = AiChooseRoadVehToBuild(p->ai.cargo_type, p->player_money, tile);
 
	if (veh == -1) {
 
	if (veh == INVALID_ENGINE) {
 
		p->ai.state = AIS_0;
 
		return;
 
	}
 

	
 
	if (CmdFailed(DoCommandByTile(tile, veh, 0, DC_EXEC, CMD_BUILD_ROAD_VEH))) return;
 

	
0 comments (0 inline, 0 general)