diff options
-rw-r--r-- | ai/default/default.c | 6 | ||||
-rw-r--r-- | aircraft_cmd.c | 2 | ||||
-rw-r--r-- | disaster_cmd.c | 14 | ||||
-rw-r--r-- | economy.c | 12 | ||||
-rw-r--r-- | engine.c | 4 | ||||
-rw-r--r-- | misc_cmd.c | 4 | ||||
-rw-r--r-- | oldloader.c | 2 | ||||
-rw-r--r-- | order_cmd.c | 2 | ||||
-rw-r--r-- | player.h | 13 | ||||
-rw-r--r-- | players.c | 8 | ||||
-rw-r--r-- | roadveh_cmd.c | 2 | ||||
-rw-r--r-- | ship_cmd.c | 2 |
12 files changed, 39 insertions, 32 deletions
diff --git a/ai/default/default.c b/ai/default/default.c index acc7b8166..dc4cce2fa 100644 --- a/ai/default/default.c +++ b/ai/default/default.c @@ -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); diff --git a/aircraft_cmd.c b/aircraft_cmd.c index 80bec98f5..1bec78aff 100644 --- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -627,7 +627,7 @@ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) _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 --git a/disaster_cmd.c b/disaster_cmd.c index 440175727..2d4579b52 100644 --- a/disaster_cmd.c +++ b/disaster_cmd.c @@ -28,7 +28,7 @@ static void DisasterClearSquare(TileIndex tile) 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(Vehicle *v) 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(Vehicle *v) 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(Vehicle *v) 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; } @@ -388,7 +388,7 @@ static void PlayersCheckBankrupt(Player *p) 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 *p) 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 *p) } } // 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 *p) // 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); } } @@ -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); } } } diff --git a/misc_cmd.c b/misc_cmd.c index d96572bb6..342cbbbe3 100644 --- a/misc_cmd.c +++ b/misc_cmd.c @@ -126,7 +126,7 @@ int32 CmdIncreaseLoan(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) 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, uint32 flags, uint32 p1, uint32 p2) 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 --git a/oldloader.c b/oldloader.c index 71a9f764c..0d1caf41b 100644 --- a/oldloader.c +++ b/oldloader.c @@ -997,7 +997,7 @@ static bool LoadOldPlayer(LoadgameState *ls, int num) * 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 --git a/order_cmd.c b/order_cmd.c index 17ba95ce2..b872e9ea2 100644 --- a/order_cmd.c +++ b/order_cmd.c @@ -352,7 +352,7 @@ int32 CmdInsertOrder(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) /* 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) { @@ -248,6 +248,16 @@ static inline bool HasRailtypeAvail(const Player *p, RailType Railtype) 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(const Player* p) 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. @@ -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, uint32 flags, uint32 p1, uint32 p2) 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); diff --git a/roadveh_cmd.c b/roadveh_cmd.c index a5064b8ff..04959beee 100644 --- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -1804,7 +1804,7 @@ int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) _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 --git a/ship_cmd.c b/ship_cmd.c index 2580ef2cf..691008073 100644 --- a/ship_cmd.c +++ b/ship_cmd.c @@ -1089,7 +1089,7 @@ int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) _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); } |