Changeset - r4845:2200ed004c20
[Not reviewed]
master
0 12 0
Darkvater - 18 years ago 2006-10-14 15:15:56
darkvater@openttd.org
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
IS_INTERACTIVE_PLAYER
12 files changed with 39 insertions and 32 deletions:
0 comments (0 inline, 0 general)
ai/default/default.c
Show inline comments
 
@@ -3773,7 +3773,7 @@ static void AiHandleTakeover(Player *p)
 
			AskExitToGameMenu();
 
			return;
 
		}
 
		if (IS_HUMAN_PLAYER(_current_player)) return;
 
		if (IsHumanPlayer(_current_player)) return;
 
	}
 

	
 
	if (p->bankrupt_asked == 255) return;
 
@@ -3809,7 +3809,7 @@ static void AiHandleTakeover(Player *p)
 
			ShowBuyCompanyDialog(_current_player);
 
			return;
 
		}
 
		if (IS_HUMAN_PLAYER(best_pl->index)) return;
 
		if (IsHumanPlayer(best_pl->index)) return;
 

	
 
		// Too little money for computer to buy it?
 
		if (best_pl->player_money >> 1 >= p->bankrupt_value) {
 
@@ -3866,7 +3866,7 @@ void AiDoGameLoop(Player *p)
 
	//  or in %
 
	_ai_service_interval = _patches.servint_ispercent?80:180;
 

	
 
	if (IS_HUMAN_PLAYER(_current_player)) return;
 
	if (IsHumanPlayer(_current_player)) return;
 

	
 
	AiAdjustLoan(p);
 
	AiBuildCompanyHQ(p);
aircraft_cmd.c
Show inline comments
 
@@ -627,7 +627,7 @@ int32 CmdRefitAircraft(TileIndex tile, u
 
	_returned_refit_capacity = pass;
 

	
 
	cost = 0;
 
	if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
 
	if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
 
		cost = GetRefitCost(v->engine_type);
 
	}
 

	
disaster_cmd.c
Show inline comments
 
@@ -28,7 +28,7 @@ static void DisasterClearSquare(TileInde
 

	
 
	switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
 
			if (IS_HUMAN_PLAYER(GetTileOwner(tile)) && !IsRailWaypoint(tile)) {
 
			if (IsHumanPlayer(GetTileOwner(tile)) && !IsRailWaypoint(tile)) {
 
				PlayerID p = _current_player;
 
				_current_player = OWNER_WATER;
 
				DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
@@ -188,7 +188,7 @@ static void DisasterTick_Zeppeliner(Vehi
 
			if (IsValidTile(tile) &&
 
					IsTileType(tile, MP_STATION) &&
 
					IsAirport(tile) &&
 
					IS_HUMAN_PLAYER(GetTileOwner(tile))) {
 
					IsHumanPlayer(GetTileOwner(tile))) {
 
				v->current_order.dest = 1;
 
				v->age = 0;
 

	
 
@@ -213,7 +213,7 @@ static void DisasterTick_Zeppeliner(Vehi
 
		if (IsValidTile(tile) &&
 
				IsTileType(tile, MP_STATION) &&
 
				IsAirport(tile) &&
 
				IS_HUMAN_PLAYER(GetTileOwner(tile))) {
 
				IsHumanPlayer(GetTileOwner(tile))) {
 
			st = GetStationByTile(tile);
 
			CLRBITS(st->airport_flags, RUNWAY_IN_block);
 
		}
 
@@ -255,7 +255,7 @@ static void DisasterTick_Zeppeliner(Vehi
 
	if (IsValidTile(tile) &&
 
			IsTileType(tile, MP_STATION) &&
 
			IsAirport(tile) &&
 
			IS_HUMAN_PLAYER(GetTileOwner(tile))) {
 
			IsHumanPlayer(GetTileOwner(tile))) {
 
		st = GetStationByTile(tile);
 
		SETBITS(st->airport_flags, RUNWAY_IN_block);
 
	}
 
@@ -289,7 +289,7 @@ static void DisasterTick_UFO(Vehicle *v)
 
		v->current_order.dest = 1;
 

	
 
		FOR_ALL_VEHICLES(u) {
 
			if (u->type == VEH_Road && IS_HUMAN_PLAYER(u->owner)) {
 
			if (u->type == VEH_Road && IsHumanPlayer(u->owner)) {
 
				v->dest_tile = u->index;
 
				v->age = 0;
 
				return;
 
@@ -595,7 +595,7 @@ static void DisasterTick_4(Vehicle *v)
 
		do {
 
			if (IsTileType(tile, MP_RAILWAY) &&
 
					IsPlainRailTile(tile) &&
 
					IS_HUMAN_PLAYER(GetTileOwner(tile))) {
 
					IsHumanPlayer(GetTileOwner(tile))) {
 
				break;
 
			}
 
			tile = TILE_MASK(tile+1);
 
@@ -726,7 +726,7 @@ static void Disaster0_Init(void)
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport_tile != 0 &&
 
				st->airport_type <= 1 &&
 
				IS_HUMAN_PLAYER(st->owner)) {
 
				IsHumanPlayer(st->owner)) {
 
			x = (TileX(st->xy) + 2) * TILE_SIZE;
 
			break;
 
		}
economy.c
Show inline comments
 
@@ -388,7 +388,7 @@ static void PlayersCheckBankrupt(Player 
 
		case 3: {
 
			/* XXX - In multiplayer, should we ask other players if it wants to take
 
		          over when it is a human company? -- TrueLight */
 
			if (IS_HUMAN_PLAYER(owner)) {
 
			if (IsHumanPlayer(owner)) {
 
				AddNewsItem( (StringID)(owner + 16),
 
					NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
 
				break;
 
@@ -415,12 +415,12 @@ static void PlayersCheckBankrupt(Player 
 
			AddNewsItem( (StringID)(owner + 16*3), NEWS_FLAGS(NM_CALLBACK, 0, NT_COMPANY_INFO, DNC_BANKRUPCY),0,0);
 

	
 
			// If the player is human, and it is no network play, leave the player playing
 
			if (IS_HUMAN_PLAYER(owner) && !_networking) {
 
			if (IsHumanPlayer(owner) && !_networking) {
 
				p->bankrupt_asked = 255;
 
				p->bankrupt_timeout = 0x456;
 
			} else {
 
#ifdef ENABLE_NETWORK
 
				if (IS_HUMAN_PLAYER(owner) && _network_server) {
 
				if (IsHumanPlayer(owner) && _network_server) {
 
					// If we are the server, make sure it is clear that his player is no
 
					//  longer with us!
 
					NetworkClientInfo *ci;
 
@@ -436,7 +436,7 @@ static void PlayersCheckBankrupt(Player 
 
					}
 
				}
 
				// Make sure the player no longer controls the company
 
				if (IS_HUMAN_PLAYER(owner) && owner == _local_player) {
 
				if (IsHumanPlayer(owner) && owner == _local_player) {
 
					// Switch the player to spectator..
 
					_local_player = OWNER_SPECTATOR;
 
				}
 
@@ -447,9 +447,9 @@ static void PlayersCheckBankrupt(Player 
 
				// Register the player as not-active
 
				p->is_active = false;
 

	
 
				if (!IS_HUMAN_PLAYER(owner) && (!_networking || _network_server) && _ai.enabled)
 
				if (!IsHumanPlayer(owner) && (!_networking || _network_server) && _ai.enabled)
 
					AI_PlayerDied(owner);
 
				if (IS_HUMAN_PLAYER(owner) && owner == _local_player && _ai.network_client)
 
				if (IsHumanPlayer(owner) && owner == _local_player && _ai.network_client)
 
					AI_PlayerDied(owner);
 
			}
 
		}
engine.c
Show inline comments
 
@@ -268,13 +268,13 @@ void EnginesDailyLoop(void)
 
					continue;
 
				}
 

	
 
				if (!IS_HUMAN_PLAYER(best_player)) {
 
				if (!IsHumanPlayer(best_player)) {
 
					/* XXX - TTDBUG: TTD has a bug here ???? */
 
					AcceptEnginePreview(e, best_player);
 
				} else {
 
					e->flags |= ENGINE_PREVIEWING;
 
					e->preview_wait = 20;
 
					if (IS_INTERACTIVE_PLAYER(best_player)) ShowEnginePreviewWindow(i);
 
					if (IsInteractivePlayer(best_player)) ShowEnginePreviewWindow(i);
 
				}
 
			}
 
		}
misc_cmd.c
Show inline comments
 
@@ -126,7 +126,7 @@ int32 CmdIncreaseLoan(TileIndex tile, ui
 

	
 
	if (flags & DC_EXEC) {
 
		/* Loan the maximum amount or not? */
 
		int32 loan = (p2) ? _economy.max_loan - p->current_loan : (IS_HUMAN_PLAYER(_current_player) || _patches.ainew_active) ? 10000 : 50000;
 
		int32 loan = (p2) ? _economy.max_loan - p->current_loan : (IsHumanPlayer(_current_player) || _patches.ainew_active) ? 10000 : 50000;
 

	
 
		p->money64 += loan;
 
		p->current_loan += loan;
 
@@ -160,7 +160,7 @@ int32 CmdDecreaseLoan(TileIndex tile, ui
 
		loan = max(loan, 10000);
 
		loan -= loan % 10000;
 
	} else {
 
		loan = min(loan, (IS_HUMAN_PLAYER(_current_player) || _patches.ainew_active) ? 10000 : 50000);
 
		loan = min(loan, (IsHumanPlayer(_current_player) || _patches.ainew_active) ? 10000 : 50000);
 
	}
 

	
 
	if (p->player_money < loan) {
oldloader.c
Show inline comments
 
@@ -997,7 +997,7 @@ static bool LoadOldPlayer(LoadgameState 
 
	 * really figured out as of now, p->ai.cur_veh; needed for 'sell vehicle'
 
	 * is NULL and the function will crash. To fix this, just change the state
 
	 * to some harmless state, like 'loop vehicle'; 1 */
 
	if (!IS_HUMAN_PLAYER(num) && p->ai.state == 20) p->ai.state = 1;
 
	if (!IsHumanPlayer(num) && p->ai.state == 20) p->ai.state = 1;
 

	
 
	if (p->is_ai && (!_networking || _network_server) && _ai.enabled)
 
		AI_StartNewAI(p->index);
order_cmd.c
Show inline comments
 
@@ -352,7 +352,7 @@ int32 CmdInsertOrder(TileIndex tile, uin
 

	
 
	/* For ships, make sure that the station is not too far away from the
 
	 * previous destination, for human players with new pathfinding disabled */
 
	if (v->type == VEH_Ship && IS_HUMAN_PLAYER(v->owner) &&
 
	if (v->type == VEH_Ship && IsHumanPlayer(v->owner) &&
 
		sel_ord != 0 && GetVehicleOrder(v, sel_ord - 1)->type == OT_GOTO_STATION
 
		&& !_patches.new_pathfinding_all) {
 

	
player.h
Show inline comments
 
@@ -248,6 +248,16 @@ static inline bool HasRailtypeAvail(cons
 
	return HASBIT(p->avail_railtypes, Railtype);
 
}
 

	
 
static inline bool IsHumanPlayer(PlayerID pi)
 
{
 
	return !GetPlayer(pi)->is_ai;
 
}
 

	
 
static inline bool IsInteractivePlayer(PlayerID pi)
 
{
 
	return pi == _local_player;
 
}
 

	
 
/* Validate functions for rail building */
 
static inline bool ValParamRailtype(uint32 rail) { return HASBIT(GetPlayer(_current_player)->avail_railtypes, rail);}
 

	
 
@@ -265,9 +275,6 @@ static inline RailType GetBestRailtype(c
 
	return RAILTYPE_RAIL;
 
}
 

	
 
#define IS_HUMAN_PLAYER(p) (!GetPlayer(p)->is_ai)
 
#define IS_INTERACTIVE_PLAYER(p) ((p) == _local_player)
 

	
 
typedef struct HighScore {
 
	char company[100];
 
	StringID title; // NO_SAVE, has troubles with changing string-numbers.
players.c
Show inline comments
 
@@ -341,7 +341,7 @@ set_name:;
 

	
 
		MarkWholeScreenDirty();
 

	
 
		if (!IS_HUMAN_PLAYER(p->index)) {
 
		if (!IsHumanPlayer(p->index)) {
 
			SetDParam(0, t->index);
 
			AddNewsItem(p->index + (4 << 4), NEWS_FLAGS(NM_CALLBACK, NF_TILE, NT_COMPANY_INFO, DNC_BANKRUPCY), p->last_build_coordinate, 0);
 
		}
 
@@ -584,7 +584,7 @@ void OnTick_Players(void)
 
// index is the next parameter in _decode_parameters to set up
 
StringID GetPlayerNameString(PlayerID player, uint index)
 
{
 
	if (IS_HUMAN_PLAYER(player) && player < MAX_PLAYERS) {
 
	if (IsHumanPlayer(player) && player < MAX_PLAYERS) {
 
		SetDParam(index, player+1);
 
		return STR_7002_PLAYER;
 
	}
 
@@ -917,7 +917,7 @@ int32 CmdPlayerCtrl(TileIndex tile, uint
 
		p = GetPlayer(p2);
 

	
 
		/* Only allow removal of HUMAN companies */
 
		if (IS_HUMAN_PLAYER(p->index)) {
 
		if (IsHumanPlayer(p->index)) {
 
			/* Delete any open window of the company */
 
			DeletePlayerWindows(p->index);
 

	
 
@@ -1268,7 +1268,7 @@ static void SaveLoad_PLYR(Player* p)
 
	SlObject(p, _player_desc);
 

	
 
	// Write AI?
 
	if (!IS_HUMAN_PLAYER(p->index)) {
 
	if (!IsHumanPlayer(p->index)) {
 
		SlObject(&p->ai, _player_ai_desc);
 
		for (i = 0; i != p->ai.num_build_rec; i++) {
 
			SlObject(&p->ai.src + i, _player_ai_build_rec_desc);
roadveh_cmd.c
Show inline comments
 
@@ -1804,7 +1804,7 @@ int32 CmdRefitRoadVeh(TileIndex tile, ui
 
	_returned_refit_capacity = capacity;
 

	
 
	cost = 0;
 
	if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
 
	if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
 
		cost = GetRefitCost(v->engine_type);
 
	}
 

	
ship_cmd.c
Show inline comments
 
@@ -1089,7 +1089,7 @@ int32 CmdRefitShip(TileIndex tile, uint3
 
	_returned_refit_capacity = capacity;
 

	
 
	cost = 0;
 
	if (IS_HUMAN_PLAYER(v->owner) && new_cid != v->cargo_type) {
 
	if (IsHumanPlayer(v->owner) && new_cid != v->cargo_type) {
 
		cost = GetRefitCost(v->engine_type);
 
	}
 

	
0 comments (0 inline, 0 general)