# HG changeset patch # User Darkvater # Date 1160838956 0 # Node ID 49105d3b5a9ae72801e9171732e11d700d533b7a # Parent 15faacbff62215124794ca5c9765244076603ead (svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and IS_INTERACTIVE_PLAYER diff -r 15faacbff622 -r 49105d3b5a9a ai/default/default.c --- a/ai/default/default.c Sat Oct 14 10:26:13 2006 +0000 +++ b/ai/default/default.c Sat Oct 14 15:15:56 2006 +0000 @@ -3773,7 +3773,7 @@ AskExitToGameMenu(); return; } - if (IS_HUMAN_PLAYER(_current_player)) return; + if (IsHumanPlayer(_current_player)) return; } if (p->bankrupt_asked == 255) return; @@ -3809,7 +3809,7 @@ 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 @@ // 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); diff -r 15faacbff622 -r 49105d3b5a9a aircraft_cmd.c --- a/aircraft_cmd.c Sat Oct 14 10:26:13 2006 +0000 +++ b/aircraft_cmd.c Sat Oct 14 15:15:56 2006 +0000 @@ -627,7 +627,7 @@ _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); } diff -r 15faacbff622 -r 49105d3b5a9a disaster_cmd.c --- a/disaster_cmd.c Sat Oct 14 10:26:13 2006 +0000 +++ b/disaster_cmd.c Sat Oct 14 15:15:56 2006 +0000 @@ -28,7 +28,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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; } diff -r 15faacbff622 -r 49105d3b5a9a economy.c --- a/economy.c Sat Oct 14 10:26:13 2006 +0000 +++ b/economy.c Sat Oct 14 15:15:56 2006 +0000 @@ -388,7 +388,7 @@ 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 @@ 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 @@ } } // 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 @@ // 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); } } diff -r 15faacbff622 -r 49105d3b5a9a engine.c --- a/engine.c Sat Oct 14 10:26:13 2006 +0000 +++ b/engine.c Sat Oct 14 15:15:56 2006 +0000 @@ -268,13 +268,13 @@ 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); } } } diff -r 15faacbff622 -r 49105d3b5a9a misc_cmd.c --- a/misc_cmd.c Sat Oct 14 10:26:13 2006 +0000 +++ b/misc_cmd.c Sat Oct 14 15:15:56 2006 +0000 @@ -126,7 +126,7 @@ 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 @@ 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) { diff -r 15faacbff622 -r 49105d3b5a9a oldloader.c --- a/oldloader.c Sat Oct 14 10:26:13 2006 +0000 +++ b/oldloader.c Sat Oct 14 15:15:56 2006 +0000 @@ -997,7 +997,7 @@ * 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); diff -r 15faacbff622 -r 49105d3b5a9a order_cmd.c --- a/order_cmd.c Sat Oct 14 10:26:13 2006 +0000 +++ b/order_cmd.c Sat Oct 14 15:15:56 2006 +0000 @@ -352,7 +352,7 @@ /* 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) { diff -r 15faacbff622 -r 49105d3b5a9a player.h --- a/player.h Sat Oct 14 10:26:13 2006 +0000 +++ b/player.h Sat Oct 14 15:15:56 2006 +0000 @@ -248,6 +248,16 @@ 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 @@ 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. diff -r 15faacbff622 -r 49105d3b5a9a players.c --- a/players.c Sat Oct 14 10:26:13 2006 +0000 +++ b/players.c Sat Oct 14 15:15:56 2006 +0000 @@ -341,7 +341,7 @@ 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 @@ // 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 @@ 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 @@ 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); diff -r 15faacbff622 -r 49105d3b5a9a roadveh_cmd.c --- a/roadveh_cmd.c Sat Oct 14 10:26:13 2006 +0000 +++ b/roadveh_cmd.c Sat Oct 14 15:15:56 2006 +0000 @@ -1804,7 +1804,7 @@ _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); } diff -r 15faacbff622 -r 49105d3b5a9a ship_cmd.c --- a/ship_cmd.c Sat Oct 14 10:26:13 2006 +0000 +++ b/ship_cmd.c Sat Oct 14 15:15:56 2006 +0000 @@ -1089,7 +1089,7 @@ _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); }